aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/GameTick.cpp80
-rw-r--r--src/Person.cpp4
-rw-r--r--src/Skeleton.cpp187
3 files changed, 133 insertions, 138 deletions
diff --git a/src/GameTick.cpp b/src/GameTick.cpp
index 5cd11b8..dd23dc9 100644
--- a/src/GameTick.cpp
+++ b/src/GameTick.cpp
@@ -2184,53 +2184,43 @@ void Game::Tick(){
}
//Tackle
-
- if(person[0].currentanimation==diveanim&&visions==0){
-
- for(int i=1;i<numpeople;i++){
-
- if(person[i].skeleton.free<1&&findDistancefast(person[i].playercoords,person[0].playercoords+flatfacing)<22){
-
- float gLoc[3];
-
- gLoc[0]=(camera.position.x+((person[0].playercoords.x+flatfacing.x)-camera.position.x)/2)/soundscalefactor;
-
- gLoc[1]=(camera.position.y+((person[0].playercoords.y+flatfacing.y)-camera.position.y)/2)/soundscalefactor;
-
- gLoc[2]=(camera.position.z+((person[0].playercoords.z+flatfacing.z)-camera.position.z)/2)/soundscalefactor;
-
- alSourcefv(gSourceID[headwhacksound], AL_POSITION, gLoc);
-
- alSourcePlay(gSourceID[headwhacksound]);
-
- person[i].skeleton.free=1;
-
- person[i].longdead=1;
-
- for(int j=0;j<person[i].skeleton.num_joints;j++){
-
- person[i].skeleton.joints[j].position=DoRotation(person[i].skeleton.joints[j].position,0,person[i].playerrotation,0);
-
- person[i].skeleton.joints[j].position+=person[i].playercoords;
-
- person[i].skeleton.joints[j].realoldposition=person[i].skeleton.joints[j].position;
-
- person[i].skeleton.joints[j].velocity=person[0].velocity;
-
- person[i].skeleton.joints[j].velocity.y=-10;
-
- person[i].skeleton.joints[j].velocity.x+=abs(Random()%10)-5;
-
- person[i].skeleton.joints[j].velocity.y+=abs(Random()%10)-5;
-
- person[i].skeleton.joints[j].velocity.z+=abs(Random()%10)-5;
-
- }
-
+ if (person[0].currentanimation == diveanim && visions == 0) {
+ for (int i = 1; i < numpeople; i++) {
+ if (person[i].skeleton.free > 0
+ || findDistancefast(person[i].playercoords,
+ person[0].playercoords
+ + flatfacing) > 22)
+ continue;
+
+ float gLoc[3] {
+ (camera.position.x
+ + person[0].playercoords.x
+ + flatfacing.x) / soundscalefactor / 2,
+ (camera.position.y
+ + person[0].playercoords.y
+ + flatfacing.y) / soundscalefactor / 2,
+ (camera.position.z
+ + person[0].playercoords.z
+ + flatfacing.z) / soundscalefactor / 2,
+ };
+
+ alSourcefv(gSourceID[headwhacksound],
+ AL_POSITION, gLoc);
+ alSourcePlay(gSourceID[headwhacksound]);
+ person[i].skeleton.free = 1;
+ person[i].longdead = 1;
+
+ for (auto& joint : person[i].skeleton.joints) {
+ joint.position = DoRotation(joint.position, 0, person[i].playerrotation, 0);
+ joint.position += person[i].playercoords;
+ joint.realoldposition = joint.position;
+ joint.velocity = person[0].velocity;
+ joint.velocity.y = -10;
+ joint.velocity.x += abs(Random() % 10) - 5;
+ joint.velocity.y += abs(Random() % 10) - 5;
+ joint.velocity.z += abs(Random() % 10) - 5;
}
-
}
-
}
//Fire/wing
diff --git a/src/Person.cpp b/src/Person.cpp
index e0ec5f7..70399a1 100644
--- a/src/Person.cpp
+++ b/src/Person.cpp
@@ -539,11 +539,7 @@ void Person::DoAnimations(int who){
gLoc[0]=playercoords.x/soundscalefactor;
gLoc[1]=playercoords.y/soundscalefactor;
gLoc[2]=playercoords.z/soundscalefactor;
-#ifdef DEBIAN_NEEDS_TO_UPDATE_THEIR_OPENAL
- alGetSourceiv(gSourceID[reloadsound], AL_SOURCE_STATE, &tempint);
-#else
alGetSourcei(gSourceID[reloadsound], AL_SOURCE_STATE, &tempint);
-#endif
if (tempint != AL_PLAYING){
alSourcefv(gSourceID[reloadsound], AL_POSITION, gLoc);
diff --git a/src/Skeleton.cpp b/src/Skeleton.cpp
index a5516c6..8ac7c4f 100644
--- a/src/Skeleton.cpp
+++ b/src/Skeleton.cpp
@@ -96,106 +96,115 @@ void Skeleton::DoConstraints()
void Skeleton::DoConstraints(Model *collide, XYZ *move, float rotation)
{
- friction=20;
- numrepeats=2;
- groundlevel=0;
-
- move->y+=.35;
-
- for(int j=0; j<numrepeats; j++){
- for(int i=0; i<num_joints; i++){
- if(joints[i].existing||i==jointlabels[lefthand]||i==jointlabels[righthand]){
- //Length constraints
+ friction = 20;
+ move->y += 0.35;
+ groundlevel = 0;
+ numrepeats = 2;
+ for (int j = 0; j < numrepeats; j++) {
+ for (int i = 0; i < num_joints; i++) {
+ if (!joints[i].existing
+ && i != jointlabels[lefthand]
+ && i != jointlabels[righthand])
+ continue;
+
+ // Length constraints
joints[i].DoConstraint();
- //Ground constraint
- offset=0;
- overpoint=joints[i].position;
- overpoint.y+=10;
- underpoint=joints[i].position;
- underpoint.y-=offset;
- whichtri=collide->LineCheck2(overpoint,underpoint,&impact,*move,rotation);
- if(collide->normals[whichtri].y<=.8)whichtri=collide->LineCheck2(joints[i].realoldposition,joints[i].position,&impact,*move,rotation);
- if(joints[i].position.y<=groundlevel+offset||whichtri!=-1){
- if(whichtri==-1||(whichtri!=-1&&collide->normals[whichtri].y>.8)){
- if(whichtri==-1)joints[i].position.y=groundlevel+offset;
- if(whichtri!=-1){
- joints[i].position=impact;
- joints[i].position.y+=offset;
+ // Ground constraint
+ auto& pos = joints[i].position;
+ overpoint = pos;
+ overpoint.y += 10;
+ underpoint = pos;
+ underpoint.y -= offset = 0;
+ whichtri = collide->LineCheck2(overpoint, underpoint,
+ &impact, *move, rotation);
+ if (whichtri == -1
+ || collide->normals[whichtri].y <= 0.8)
+ whichtri = collide->LineCheck2(
+ joints[i].realoldposition, pos,
+ &impact, *move, rotation);
+
+ if (pos.y <= groundlevel + offset || whichtri != -1) {
+ if (whichtri == -1
+ || collide->normals[whichtri].y > 0.8) {
+ if (whichtri == -1) {
+ pos.y = groundlevel + offset;
+ } else {
+ pos = impact;
+ pos.y += offset;
}
- joints[i].velocity.y*=-.3;
- joints[i].velocity.x*=.3;
- joints[i].velocity.z*=.3;
+ joints[i].velocity.y *= -0.3;
+ joints[i].velocity.x *= 0.3;
+ joints[i].velocity.z *= 0.3;
}
- offset=.2;
- if(whichtri!=-1&&collide->normals[whichtri].y<=.8){
- normalrotated=DoRotation(collide->normals[whichtri],0,rotation,0);
- joints[i].position=impact+normalrotated*offset;
- ReflectVector(&joints[i].velocity,&normalrotated);
- joints[i].velocity*=.3;
- }
- if(broken<=1){
- XYZ avgvelocity;
- avgvelocity=0;
- float gLoc[3];
- ALint tempint;
- for(int k=0; k<num_joints; k++){
- avgvelocity+=joints[k].velocity;
- }
- avgvelocity/=num_joints;
- if(joints[i].label==head&&(findLengthfast(joints[i].velocity)>2||findLengthfast(avgvelocity)>2)){
- avgvelocity+=joints[i].velocity;
- gLoc[0]=joints[i].position.x/soundscalefactor;
- gLoc[1]=joints[i].position.y/soundscalefactor;
- gLoc[2]=joints[i].position.z/soundscalefactor;
-#ifdef DEBIAN_NEEDS_TO_UPDATE_THEIR_OPENAL
- alGetSourceiv(gSourceID[headlandsound], AL_SOURCE_STATE, &tempint);
-#else
- alGetSourcei(gSourceID[headlandsound], AL_SOURCE_STATE, &tempint);
-#endif
- if (tempint != AL_PLAYING){
- alSourcef(gSourceID[headlandsound], AL_MIN_GAIN, ALfloat(findLengthfast(avgvelocity)*2/findDistancefast(joints[i].position,camera.position)*soundscalefactor*2));
- alSourcef(gSourceID[headlandsound], AL_MAX_GAIN, ALfloat(findLengthfast(avgvelocity)*2/findDistancefast(joints[i].position,camera.position)*soundscalefactor*2));
- alSourcefv(gSourceID[headlandsound], AL_POSITION, gLoc);
- alSourcePlay(gSourceID[headlandsound]);}
- }
- avgvelocity=0;
- for(int k=0; k<num_joints; k++){
- avgvelocity+=joints[k].velocity;
+
+ offset = 0.2;
+ if (whichtri != -1
+ && collide->normals[whichtri].y <= 0.8) {
+ normalrotated = DoRotation(collide->normals[whichtri], 0, rotation, 0);
+ pos = impact + normalrotated * offset;
+ ReflectVector(&joints[i].velocity, &normalrotated);
+ joints[i].velocity *= 0.3;
}
- avgvelocity/=num_joints;
- if((joints[i].label==abdomen)&&(findLengthfast(joints[i].velocity)>2||findLengthfast(avgvelocity)>2)){
- avgvelocity+=joints[i].velocity;
- gLoc[0]=joints[i].position.x/soundscalefactor;
- gLoc[1]=joints[i].position.y/soundscalefactor;
- gLoc[2]=joints[i].position.z/soundscalefactor;
-#ifdef DEBIAN_NEEDS_TO_UPDATE_THEIR_OPENAL
- alGetSourceiv(gSourceID[bodylandsound], AL_SOURCE_STATE, &tempint);
-#else
- alGetSourcei(gSourceID[bodylandsound], AL_SOURCE_STATE, &tempint);
-#endif
- if (tempint != AL_PLAYING){
- alSourcef(gSourceID[bodylandsound], AL_MIN_GAIN, ALfloat(findLengthfast(joints[i].velocity)*1/findDistancefast(joints[i].position,camera.position)*soundscalefactor*2));
- alSourcef(gSourceID[bodylandsound], AL_MAX_GAIN, ALfloat(findLengthfast(joints[i].velocity)*1/findDistancefast(joints[i].position,camera.position)*soundscalefactor*2));
- alSourcefv(gSourceID[bodylandsound], AL_POSITION, gLoc);
- alSourcePlay(gSourceID[bodylandsound]);}
+
+ if (broken > 1)
+ continue;
+ XYZ avgvelocity {0};
+ for (int k = 0; k < num_joints; k++)
+ avgvelocity += joints[k].velocity;
+ avgvelocity /= num_joints;
+
+ int landsound = -1;
+ switch (joints[i].label) {
+ case head:
+ landsound = headlandsound;
+ break;
+ case abdomen:
+ landsound = bodylandsound;
+ break;
}
+ ALint playing = AL_PLAYING;
+ if (landsound >= 0)
+ alGetSourcei(gSourceID[landsound],
+ AL_SOURCE_STATE, &playing);
+
+ if (playing != AL_PLAYING
+ && (findLengthfast(joints[i].velocity) > 2
+ || findLengthfast(avgvelocity) > 2)) {
+ ALfloat gain =
+ findLengthfast(avgvelocity
+ + joints[i].velocity)
+ / findDistancefast(pos,
+ camera.position)
+ * soundscalefactor * 4;
+ alSourcef(gSourceID[landsound],
+ AL_MIN_GAIN, gain);
+ alSourcef(gSourceID[landsound],
+ AL_MAX_GAIN, gain);
+
+ float gLoc[3] {
+ pos.x / soundscalefactor,
+ pos.y / soundscalefactor,
+ pos.z / soundscalefactor,
+ };
+ alSourcefv(gSourceID[landsound],
+ AL_POSITION, gLoc);
+ alSourcePlay(gSourceID[landsound]);
}
- }}
+ }
}
- if(num_muscles)
- for(int i=0; i<num_muscles; i++){
+
+ for (int i = 0; i < num_muscles; i++)
//Length constraints
muscles[i].DoConstraint(broken);
- }
}
- for(int i=0; i<num_joints; i++){
- joints[i].realoldposition=joints[i].position;
- }
-
- //Add velocity
- for(int i=0; i<num_joints; i++){
- if(joints[i].existing||i==jointlabels[lefthand]||i==jointlabels[righthand])joints[i].position=joints[i].position+joints[i].velocity*multiplier;
+ for (int i = 0; i < num_joints; i++) {
+ joints[i].realoldposition = joints[i].position;
+ //Add velocity
+ if (joints[i].existing
+ || i == jointlabels[lefthand]
+ || i == jointlabels[righthand])
+ joints[i].position += joints[i].velocity * multiplier;
}
}