]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Person.cpp
add include guard to Texture.h
[lugaru.git] / Source / Person.cpp
index a74b2df22a3ab39f3797f614666503721d402804..b2bb052e035868fe2ef559d6834e0272c7c2a150 100644 (file)
@@ -296,7 +296,6 @@ void Person::DoBlood(float howmuch,int which){
                        bleeding=howmuch+(float)abs(Random()%100)/200-.25;
                        bleedxint=0;
                        bleedyint=0;
-                       int texdetailint=realtexdetail;
                        if(creature==rabbittype)
                                while(bloodText[bleedxint*512*3+bleedyint*3+0]>which+4||bloodText[bleedxint*512*3+bleedyint*3+0]<which-4||bleedxint<10||bleedyint<10||bleedxint>500||bleedyint>500){
                                        bleedxint=abs(Random()%512);
@@ -401,9 +400,7 @@ void Person::DoBloodBig(float howmuch,int which){
                                offsetx=Random()%20;
                        }
                        if(which==220||which==215){
-                               //offsety=Random()%20;
                                offsetx=20;
-                               //offsetx=abs(Random()%80);
                        }
 
 
@@ -519,7 +516,7 @@ void Person::DoBloodBig(float howmuch,int which){
 }
 
 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
-       static int bleedxint,bleedyint,i,j;
+       static int i,j;
        static XYZ bloodvel;
        static XYZ startpoint,endpoint,colpoint,movepoint;
        static float rotationpoint;
@@ -1444,6 +1441,15 @@ void Person::Puff(int whichlabel){
        Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
 }
 
+Joint& Person::getJointFor(int bodypart) {
+    return skeleton.joints[skeleton.jointlabels[bodypart]]; 
+}
+
+void Person::setAnimation(int animation) {
+    targetanimation=animation;
+    targetframe=0;
+    target=0;
+}
 
 void   Person::DoAnimations(){
        if(!skeleton.free){
@@ -1670,10 +1676,9 @@ void     Person::DoAnimations(){
                                                                }
                                                        }
 
-                                                       static bool willwork;
                                                        if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
                                                                for(i=0;i<weapons.size();i++){
-                                                                       bool willwork=1;
+                                                                       bool willwork=true;
                                                                        if(weapons[i].owner!=-1)
                                                                                if(player[weapons[i].owner].weaponstuck!=-1)
                                                                                        if(player[weapons[i].owner].weaponids[player[weapons[i].owner].weaponstuck]==i)
@@ -1681,21 +1686,20 @@ void    Person::DoAnimations(){
                                                                        if((weapons[i].owner==-1)||(hasvictim&&weapons[i].owner==victim->id&&victim->skeleton.free))
                                                                                if(willwork&&findDistancefastflat(&coords,&weapons[i].position)<3&&weaponactive==-1){
                                                                                        if(findDistancefast(&coords,&weapons[i].position)<1||hasvictim){
-                                                                                               bool fleshstuck=0;
+                                                                                               bool fleshstuck=false;
                                                                                                if(weapons[i].owner!=-1)
                                                                                                        if(victim->weaponstuck!=-1){
                                                                                                                if(victim->weaponids[victim->weaponstuck]==i){
-                                                                                                                       fleshstuck=1;
+                                                                                                                       fleshstuck=true;
                                                                                                                }
                                                                                                        }
-                                                                                                       if(!fleshstuck){
+                                                                                                       if(fleshstuck){
+                                                                                                               emit_sound_at(fleshstabremovesound, coords, 128.);
+                                                                                                       } else {
                                                                                                                if(weapons[i].getType()!=staff){
                                                                                                                        emit_sound_at(knifedrawsound, coords, 128.);
                                                                                                                }
                                                                                                        }
-                                                                                                       if(fleshstuck){
-                                                                                                               emit_sound_at(fleshstabremovesound, coords, 128.);
-                                                                                                       }
                                                                                                        weaponactive=0;
                                                                                                        if(weapons[i].owner!=-1){
 
@@ -3411,7 +3415,6 @@ void      Person::DoAnimations(){
                                                                          resume_stream(whooshsound);
                                                                }
                                                                if(targetanimation==sneakattackanim){
-                                                                       float ycoords=oldcoords.y;
                                                                        currentanimation=getCrouch();
                                                                        targetanimation=getCrouch();
                                                                        targetframe=1;
@@ -3428,7 +3431,6 @@ void      Person::DoAnimations(){
                                                                        lastfeint=0;
                                                                }
                                                                if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
-                                                                       float ycoords=oldcoords.y;
                                                                        targetanimation=getIdle();
                                                                        targetframe=0;
                                                                        if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
@@ -3748,7 +3750,6 @@ void      Person::DoStuff(){
        static int howmany;
        static int bloodsize;
        static int startx,starty,endx,endy;
-       static int texdetailint;
        static GLubyte color;
        static XYZ bloodvel;
 
@@ -3960,7 +3961,6 @@ void      Person::DoStuff(){
 
                startx=0;
                starty=0;
-               texdetailint=realtexdetail;
                startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
                starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
                endx=startx+bloodsize;
@@ -4466,15 +4466,6 @@ void     Person::DoStuff(){
                        velocity=0;
                }
 
-               float gLoc[3];
-               float vel[3];
-               gLoc[0]=coords.x;
-               gLoc[1]=coords.y;
-               gLoc[2]=coords.z;
-               vel[0]=velocity.x;
-               vel[1]=velocity.y;
-               vel[2]=velocity.z;
-
                if(findLength(&average)<10&&dead&&skeleton.free){
                        skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
                        if(skeleton.longdead>2000){
@@ -4614,23 +4605,9 @@ void     Person::DoStuff(){
                                if(terrainnormal.z<0)targetrotation=180-targetrotation;
                                rotation=targetrotation;
 
-                               /*if(onterrain){
-                               terrainnormal=terrain.getNormal(coords.x,coords.z);
-                               targettilt2=asin(terrainnormal.y)*180/3.14*-1;
-                               }
-                               else*/
-
-                               /*XYZ otherterrainnormal;
-                               otherterrainnormal=terrain.getNormal(coords.x,coords.y);
-                               otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
-                               if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
-                               targettilt2=asin(otherterrainnormal.y)*180/3.14;
-                               */
-
                                targettilt2=asin(terrainnormal.y)*180/3.14*-1;
 
 
-
                                if(skeleton.forward.y<0){
                                        targetanimation=getupfrombackanim;
                                        targetframe=0;
@@ -4724,9 +4701,6 @@ void      Person::DoStuff(){
                }
                if(skeleton.freefall==0)freefall=0;
 
-               if(!isnormal(velocity.x)&&velocity.x){
-                       int xy=1;
-               }
        }
 
        if(aitype!=passivetype||skeleton.free==1)
@@ -5449,7 +5423,7 @@ int Person::DrawSkeleton(){
                static float M[16];
                static int i,j,k;
                static int weaponattachmuscle;
-               static int weaponrotatemuscle,weaponrotatemuscle2;
+               static int weaponrotatemuscle;
                static XYZ weaponpoint;
                static int start,endthing;
                if((dead!=2||skeleton.free!=2)&&updatedelay<=0){