diff options
author | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-06-21 18:11:55 +0700 |
---|---|---|
committer | Nguyễn Gia Phong <mcsinyx@disroot.org> | 2021-06-21 21:31:11 +0700 |
commit | 325dca9f212f9fd44cd10a8180529970c7a08c72 (patch) | |
tree | e1cfaec078dfa49f4d51d05eef8a5b0967843a41 /src/Person.cpp | |
parent | 10f5376de856ecead4e8bbf66f19157f36f7a382 (diff) | |
download | blackshades-1.2.0.tar.gz |
Remove trailing whitespaces and duplicated blank lines 1.2.0
Diffstat (limited to 'src/Person.cpp')
-rw-r--r-- | src/Person.cpp | 109 |
1 files changed, 53 insertions, 56 deletions
diff --git a/src/Person.cpp b/src/Person.cpp index bc77ad9..597aba3 100644 --- a/src/Person.cpp +++ b/src/Person.cpp @@ -144,7 +144,7 @@ HitStruct Person::BulletCollideWithPlayer(int who, XYZ start, XYZ end){ glRotatef(skeleton.muscles[j].rotate3,0,1,0); glRotatef(skeleton.muscles[j].rotate2-90,0,0,1); glRotatef(skeleton.muscles[j].rotate1-90,0,1,0); - + glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2), (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2), (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2)); @@ -189,8 +189,7 @@ HitStruct Person::BulletCollideWithPlayer(int who, XYZ start, XYZ end){ extern float camerashake; extern int cycle; -void Person::DoAnimations(int who){ - +void Person::DoAnimations(int who){ if(target>1&&!skeleton.free){ //Footstep sounds if(who==0&&slomo==0&&(targetanimation==joganim||targetanimation==walkanim)&&(targetframe==0||targetframe==8)&&visions==0&&(onground||abs(velocity.y)<1)){ @@ -251,7 +250,7 @@ void Person::DoAnimations(int who){ } } } - + if(!skeleton.free){ if(currentanimation!=lyinganim){ if(animation[targetanimation].speed[currentframe]>animation[currentanimation].speed[currentframe]) @@ -261,12 +260,12 @@ void Person::DoAnimations(int who){ } if(currentanimation==lyinganim){ target+=multiplier*animation[targetanimation].speed[targetframe]*speed; - } + } if(((currentanimation==crouchanim)&&(targetanimation!=crouchanim))||((currentanimation!=crouchanim)&&(targetanimation==crouchanim)))target+=multiplier*animation[crouchanim].speed[0]*2; if(currentanimation==idleanim&&targetanimation==idleanim)target-=multiplier*animation[idleanim].speed[0]/2; - + if(target>1)currentframe=targetframe; - + for(int i=0;i<skeleton.num_joints;i++){ if(currentanimation!=lyinganim){ skeleton.joints[i].velocity=((animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target))-(skeleton.joints[i].position))/multiplier; @@ -290,9 +289,9 @@ void Person::DoAnimations(int who){ } } } - + //Look up+down - if(!skeleton.free&&(whichgun!=nogun||who==0)&&health==100&¤tanimation!=lyinganim&¤tanimation!=getupfrontanim&¤tanimation!=getupbackanim&¤tanimation!=diveanim&&targetanimation!=diveanim&&targetanimation!=throwanim&&targetanimation!=thrownanim){ + if(!skeleton.free&&(whichgun!=nogun||who==0)&&health==100&¤tanimation!=lyinganim&¤tanimation!=getupfrontanim&¤tanimation!=getupbackanim&¤tanimation!=diveanim&&targetanimation!=diveanim&&targetanimation!=throwanim&&targetanimation!=thrownanim){ XYZ facing; XYZ facingdown; XYZ facinghalf; @@ -302,7 +301,7 @@ void Person::DoAnimations(int who){ //Facing facing=0; facing.z=1; - + facinghalf=DoRotation(facing,playerrotation2/2,0,0); facinghalf=DoRotation(facinghalf,0,-7,0); facing=DoRotation(facing,playerrotation2,0,0); @@ -313,7 +312,7 @@ void Person::DoAnimations(int who){ //Facing facing=0; facing.z=1; - + facinghalf=DoRotation(facing,playerrotation2/2,0,0); facinghalf=DoRotation(facinghalf,0,-7,0); facing=DoRotation(facing,playerrotation2,0,0); @@ -321,7 +320,7 @@ void Person::DoAnimations(int who){ facingdown=DoRotation(facing,90,0,0); } XYZ rotatearound; - XYZ oldpos; + XYZ oldpos; if(whichgun==sniperrifle){ for(int i=0;i<skeleton.num_joints;i++){ if(skeleton.joints[i].label!=righthand&&skeleton.joints[i].label!=rightelbow&&skeleton.joints[i].label!=rightwrist&&skeleton.joints[i].label!=lefthand&&skeleton.joints[i].label!=leftelbow&&skeleton.joints[i].label!=leftwrist){ @@ -339,7 +338,7 @@ void Person::DoAnimations(int who){ if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[skeleton.jointlabels[neck]][0]-skeleton.joints[skeleton.jointlabels[neck]].position); } } - } + } if(whichgun==assaultrifle){ for(int i=0;i<skeleton.num_joints;i++){ if(skeleton.joints[i].label!=righthand&&skeleton.joints[i].label!=rightelbow&&skeleton.joints[i].label!=rightwrist&&skeleton.joints[i].label!=lefthand&&skeleton.joints[i].label!=leftelbow&&skeleton.joints[i].label!=leftwrist){ @@ -348,7 +347,7 @@ void Person::DoAnimations(int who){ if(currentanimation==crouchanim||targetanimation==crouchanim)skeleton.joints[i].position-=(animation[idleanim].position[skeleton.jointlabels[neck]][0]-skeleton.joints[skeleton.jointlabels[neck]].position); } } - } + } if((aiming||aimamount>0||whichgun==grenade)&&whichgun!=nogun){ if(aiming&&targetanimation!=joganim){ if(aimamount<1)aimamount+=multiplier*4; @@ -486,7 +485,7 @@ void Person::DoAnimations(int who){ } } } - + rotatearound=skeleton.joints[skeleton.jointlabels[abdomen]].position; if(who==0) for(int i=0;i<skeleton.num_joints;i++){ @@ -503,9 +502,9 @@ void Person::DoAnimations(int who){ rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position; skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,playerrotation2/2,0,0); } - + skeleton.DoConstraints(); - + //Reload if(whichgun!=nogun&&whichgun!=knife){ if(reloading>0){ @@ -519,9 +518,9 @@ 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 +#ifdef DEBIAN_NEEDS_TO_UPDATE_THEIR_OPENAL alGetSourceiv(gSourceID[reloadsound], AL_SOURCE_STATE, &tempint); -#else +#else alGetSourcei(gSourceID[reloadsound], AL_SOURCE_STATE, &tempint); #endif @@ -541,7 +540,7 @@ void Person::DoAnimations(int who){ reloads[whichgun]--; } if(reloads[whichgun]==0&&whichgun==grenade&&ammo<=0){ - whichgun=nogun; + whichgun=nogun; } if(reloading<0){ reloading=0; @@ -587,7 +586,7 @@ void Person::DoAnimationslite(int who){ targetanimation=idleanim; } } - + if(!skeleton.free){ if(currentanimation!=lyinganim){ if(animation[targetanimation].speed[currentframe]>animation[currentanimation].speed[currentframe]) @@ -597,10 +596,10 @@ void Person::DoAnimationslite(int who){ } if(currentanimation==lyinganim){ target+=multiplier*animation[targetanimation].speed[targetframe]*speed; - } + } if(((currentanimation==crouchanim)&&(targetanimation!=crouchanim))||((currentanimation!=crouchanim)&&(targetanimation==crouchanim)))target+=multiplier*animation[crouchanim].speed[0]*2; if(currentanimation==idleanim&&targetanimation==idleanim)target-=multiplier*animation[idleanim].speed[0]/2; - + if(target>1)currentframe=targetframe; } } @@ -618,13 +617,13 @@ void Person::DoStuff(int who){ if(playerrotation<playerlowrotation-70){playerrotation=playerlowrotation-70;} } if(who==0)camera.rotation=180-playerrotation; - + if(who!=0&&visions==0){ if(targetanimation!=walkanim&&targetanimation!=zombiewalkanim)speed=1.0*speedmult; if(targetanimation==walkanim||targetanimation==zombiewalkanim)speed=1.8*speedmult; playerlowrotation=playerrotation; } - + //Do controls if(who==0&&targetanimation!=diveanim&&targetanimation!=throwanim&&targetanimation!=thrownanim&¤tanimation!=diveanim&¤tanimation!=getupfrontanim){ backwardsanim=0; @@ -634,7 +633,7 @@ void Person::DoStuff(int who){ if(visions==0&&targetanimation==walkanim)speed=2.5; unsigned char theKeyMap[16]; GetKeys( ( unsigned long * )theKeyMap ); - + if(IsKeyDown( theKeyMap, MAC_SHIFT_KEY )||visions==1){ moveanim=joganim; }else{ @@ -651,7 +650,7 @@ void Person::DoStuff(int who){ if((onground||(who==0&&visions==1))&¤tanimation!=crouchanim){ if ( IsKeyDown( theKeyMap, forwardskey )&&!( IsKeyDown( theKeyMap, backwardskey ))){ if(targetanimation!=moveanim)targetframe=0; - targetanimation=moveanim; + targetanimation=moveanim; } if ( IsKeyDown( theKeyMap, rightkey )&&!( IsKeyDown( theKeyMap, leftkey ))){ if(targetanimation!=moveanim)targetframe=0; @@ -678,7 +677,7 @@ void Person::DoStuff(int who){ float oldplayerrotation=playerrotation; if ( IsKeyDown( theKeyMap, forwardskey )&&!( IsKeyDown( theKeyMap, backwardskey ))){ facing=0; - facing.z=1; + facing.z=1; facing=DoRotation(facing,0,playerrotation,0); velocity=velocity+facing*multiplier*4; } @@ -687,7 +686,7 @@ void Person::DoStuff(int who){ if(IsKeyDown( theKeyMap, forwardskey ))playerrotation+=45; if(IsKeyDown( theKeyMap, backwardskey ))playerrotation-=45; facing=0; - facing.z=1; + facing.z=1; facing=DoRotation(facing,0,playerrotation,0); velocity=velocity+facing*multiplier*4; } @@ -696,14 +695,14 @@ void Person::DoStuff(int who){ if(IsKeyDown( theKeyMap, forwardskey ))playerrotation-=45; if(IsKeyDown( theKeyMap, backwardskey ))playerrotation+=45; facing=0; - facing.z=1; + facing.z=1; facing=DoRotation(facing,0,playerrotation,0); velocity=velocity+facing*multiplier*4; } if ( IsKeyDown( theKeyMap, backwardskey )&&!IsKeyDown( theKeyMap, forwardskey )&&!IsKeyDown( theKeyMap, leftkey )&&!IsKeyDown( theKeyMap, rightkey )){ playerrotation+=180; facing=0; - facing.z=1; + facing.z=1; facing=DoRotation(facing,0,playerrotation,0); velocity=velocity+facing*multiplier*4; } @@ -717,14 +716,13 @@ void Person::DoStuff(int who){ } } } - - + facing=0; facing.z=1; - + facing=DoRotation(facing,0,playerlowrotation,0); if(backwardsanim)facing*=-1; - + if(onground){ velocity=0; } @@ -744,7 +742,7 @@ void Person::FindRotationGun(XYZ start, XYZ target) { XYZ temppoint1,temppoint2,tempforward; float distance; - + temppoint1=start; temppoint2=target; distance=findDistance(temppoint1,temppoint2); @@ -779,7 +777,7 @@ int Person::DrawSkeleton(int who){ gunmodels[sniperriflemodel].draw(); glPopMatrix(); } - + if(whichgun==shotgun){ FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,skeleton.joints[skeleton.jointlabels[lefthand]].position); glPushMatrix(); @@ -794,7 +792,7 @@ int Person::DrawSkeleton(int who){ gunmodels[shotgunmodel].draw(); glPopMatrix(); } - + if(whichgun==assaultrifle){ FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,skeleton.joints[skeleton.jointlabels[lefthand]].position); glPushMatrix(); @@ -807,7 +805,7 @@ int Person::DrawSkeleton(int who){ gunmodels[assaultriflemodel].draw(); glPopMatrix(); } - + if(whichgun==handgun1){ if(!thirdperson&&who==0)FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,(skeleton.joints[skeleton.jointlabels[head]].position*.65+skeleton.joints[skeleton.jointlabels[neck]].position*.35)); if(thirdperson||who!=0)FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,(skeleton.joints[skeleton.jointlabels[head]].position*.35+skeleton.joints[skeleton.jointlabels[neck]].position*.65)); @@ -824,7 +822,7 @@ int Person::DrawSkeleton(int who){ gunmodels[handgunslidemodel].draw(); glPopMatrix(); } - + if(whichgun==handgun2){ if(!thirdperson&&who==0)FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,(skeleton.joints[skeleton.jointlabels[head]].position*.65+skeleton.joints[skeleton.jointlabels[neck]].position*.35)); if(thirdperson||who!=0)FindRotationGun(skeleton.joints[skeleton.jointlabels[righthand]].position,(skeleton.joints[skeleton.jointlabels[head]].position*.35+skeleton.joints[skeleton.jointlabels[neck]].position*.65)); @@ -841,7 +839,7 @@ int Person::DrawSkeleton(int who){ gunmodels[handgun2slidemodel].draw(); glPopMatrix(); } - + if(whichgun==grenade){ glPushMatrix(); glTranslatef( skeleton.joints[skeleton.jointlabels[righthand]].position.x, @@ -857,7 +855,7 @@ int Person::DrawSkeleton(int who){ } glPopMatrix(); } - + if(whichgun==grenade){ glPushMatrix(); glTranslatef( skeleton.joints[skeleton.jointlabels[lefthand]].position.x, @@ -880,13 +878,13 @@ int Person::DrawSkeleton(int who){ lightpoint=skeleton.joints[skeleton.jointlabels[lefthand]].position; GLfloat LightPosition[]= {lightpoint.x,lightpoint.y,lightpoint.z,0}; glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); - glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); - glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); + glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient); + glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); glEnable(GL_LIGHT1); - + litup=0; } - + //Find forward vectors if(who==0||skeleton.free!=0||skeleton.offset!=0||whichgun!=nogun||currentanimation==lyinganim||((currentanimation==getupfrontanim||currentanimation==getupbackanim)&&targetanimation==idleanim)){ if(!(skeleton.free==1&&longdead<=0)){ @@ -908,13 +906,13 @@ int Person::DrawSkeleton(int who){ } CrossProduct(skeleton.joints[skeleton.forwardjoints[1]].position-skeleton.joints[skeleton.forwardjoints[0]].position,skeleton.joints[skeleton.forwardjoints[2]].position-skeleton.joints[skeleton.forwardjoints[0]].position,&skeleton.forward); Normalise(&skeleton.forward); - + CrossProduct(skeleton.joints[skeleton.lowforwardjoints[1]].position-skeleton.joints[skeleton.lowforwardjoints[0]].position,skeleton.joints[skeleton.lowforwardjoints[2]].position-skeleton.joints[skeleton.lowforwardjoints[0]].position,&skeleton.lowforward); Normalise(&skeleton.lowforward); - + //Special forwards skeleton.specialforward[0]=skeleton.forward; - + skeleton.specialforward[1]=skeleton.joints[skeleton.jointlabels[rightshoulder]].position+skeleton.joints[skeleton.jointlabels[rightwrist]].position; skeleton.specialforward[1]=skeleton.joints[skeleton.jointlabels[rightelbow]].position-skeleton.specialforward[1]/2; skeleton.specialforward[1]+=skeleton.forward*.2; @@ -931,13 +929,13 @@ int Person::DrawSkeleton(int who){ //Facing facing=0; facing.z=1; - + facing=DoRotation(facing,camera.rotation2,0,0); facingdown=DoRotation(facing,90,0,0); skeleton.specialforward[1]=skeleton.specialforward[1]*(1-aimamount)+facingdown*aimamount; skeleton.specialforward[2]=skeleton.specialforward[2]*(1-aimamount)+facingdown*aimamount; } - + skeleton.specialforward[3]=skeleton.joints[skeleton.jointlabels[righthip]].position+skeleton.joints[skeleton.jointlabels[rightankle]].position; skeleton.specialforward[3]=skeleton.specialforward[3]/2-skeleton.joints[skeleton.jointlabels[rightknee]].position; skeleton.specialforward[3]+=skeleton.lowforward*.2; @@ -983,7 +981,7 @@ int Person::DrawSkeleton(int who){ glPopMatrix(); } } - + for(int i=0;i<skeleton.num_muscles;i++){ if(skeleton.muscles[i].visible) { @@ -1004,7 +1002,7 @@ int Person::DrawSkeleton(int who){ if(skeleton.muscles[i].parent1->modelnum==6)skeletonmodels[skeleton.muscles[i].parent1->modelnum].draw(costume[whichcostume].upperlegcolor[0],costume[whichcostume].upperlegcolor[1],costume[whichcostume].upperlegcolor[2]); if(skeleton.muscles[i].parent1->modelnum==7)skeletonmodels[skeleton.muscles[i].parent1->modelnum].draw(costume[whichcostume].lowerlegcolor[0],costume[whichcostume].lowerlegcolor[1],costume[whichcostume].lowerlegcolor[2]); if(skeleton.muscles[i].parent1->modelnum==8)skeletonmodels[skeleton.muscles[i].parent1->modelnum].draw(costume[whichcostume].footcolor[0],costume[whichcostume].footcolor[1],costume[whichcostume].footcolor[2]); - + glPopMatrix(); } } @@ -1025,9 +1023,8 @@ int Person::DrawSkeleton(int who){ skeleton.joints[i].position=skeleton.joints[i].oldposition; } } - + glDisable(GL_LIGHT1); - + return 0; } - |