]> git.jsancho.org Git - lugaru.git/blobdiff - Source/Person.cpp
Cleanup sound loading
[lugaru.git] / Source / Person.cpp
index 388f787891bdefac4cf35e26175a7380f6eef0da..b9e61813b4c34900d6da5d67fc3922efca118018 100644 (file)
@@ -22,15 +22,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 /**> HEADER FILES <**/
 #include "Person.h"
 #include "openal_wrapper.h"
+#include "Animation.h"
+#include "Sounds.h"
 
 extern float multiplier;
-extern Animation animation[animation_count];
-extern OPENAL_SAMPLE   *samp[100];
 extern int channels[100];
 extern Terrain terrain;
 extern float gravity;
 extern int environment;
-extern Sprites sprites;
 extern int detail;
 extern FRUSTUM frustum;
 extern XYZ viewer;
@@ -89,8 +88,6 @@ extern float damagetaken;
 extern int hostile;
 extern float hostiletime;
 
-extern int mainmenu;
-
 extern int numfalls;
 extern int numflipfail;
 extern int numseen;
@@ -202,7 +199,7 @@ void Person::CatchFire(){
                if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
                if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
                if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
-               sprites.MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
+               Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
        }
 
        onfiredelay=0.5;
@@ -435,36 +432,33 @@ void Person::DoBlood(float howmuch,int which){
                                if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
                                if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
                                if(skeleton.free){
-                                       sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
-                                       sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
+                                       Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
+                                       Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
                                }
                                if(!skeleton.free){
-                                       sprites.MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
-                                       sprites.MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
+                                       Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+                                       Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
                                }
                        }
                        if(Random()%2==0)
                                for(int i=0;i<3;i++){
                                        if(Random()%2!=0){
                                                bloodvel=0;
-                                               if(!skeleton.free){
+                                               if(skeleton.free) {
+                                                       bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
+                                                       bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+                                               } else {
                                                        bloodvel.z=10;
                                                        bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
+                                                       bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
                                                }
-                                               if(skeleton.free){
-                                                       bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
-                                               }
-                                               if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
-                                               if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
                                                bloodvel*=.2;
                                                if(skeleton.free){
-                                                       sprites.MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
-                                                       sprites.special[sprites.numsprites-1]=3;
-                                               }
-                                               if(!skeleton.free){
-                                                       sprites.MakeSprite(splintersprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
-                                                       sprites.special[sprites.numsprites-1]=3;
+                                                       Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
+                                               } else {
+                                                       Sprite::MakeSprite(splintersprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
                                                }
+                                               Sprite::setLastSpriteSpecial(3);
                                        }
                                }
                }
@@ -478,16 +472,16 @@ void Person::DoBlood(float howmuch,int which){
                                        bleedxint=abs(Random()%512);
                                        bleedyint=abs(Random()%512);
                                }
-                               if(creature==wolftype)
-                                       while(wolfbloodText[bleedxint*512*3+bleedyint*3+0]>which+4||wolfbloodText[bleedxint*512*3+bleedyint*3+0]<which-4||bleedxint<10||bleedyint<10||bleedxint>500||bleedyint>500){
-                                               bleedxint=abs(Random()%512);
-                                               bleedyint=abs(Random()%512);
-                                       }
-                                       bleedy=bleedxint;
-                                       bleedx=bleedyint;
-                                       bleedy/=realtexdetail;
-                                       bleedx/=realtexdetail;
-                                       direction=abs(Random()%2)*2-1;
+                       if(creature==wolftype)
+                               while(wolfbloodText[bleedxint*512*3+bleedyint*3+0]>which+4||wolfbloodText[bleedxint*512*3+bleedyint*3+0]<which-4||bleedxint<10||bleedyint<10||bleedxint>500||bleedyint>500){
+                                       bleedxint=abs(Random()%512);
+                                       bleedyint=abs(Random()%512);
+                               }
+                       bleedy=bleedxint;
+                       bleedx=bleedyint;
+                       bleedy/=realtexdetail;
+                       bleedx/=realtexdetail;
+                       direction=abs(Random()%2)*2-1;
                }
 
        }
@@ -562,12 +556,12 @@ void Person::DoBloodBig(float howmuch,int which){
                                        if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
                                        if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
                                        if(skeleton.free){
-                                               sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
-                                               sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
+                                               Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
+                                               Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
                                        }
                                        if(!skeleton.free){
-                                               sprites.MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
-                                               sprites.MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
+                                               Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+                                               Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
                                        }
                                }
                        }
@@ -789,12 +783,12 @@ bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
                                        if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
                                        if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
                                        if(skeleton.free){
-                                               sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
-                                               sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
+                                               Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
+                                               Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
                                        }
                                        if(!skeleton.free){
-                                               sprites.MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
-                                               sprites.MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
+                                               Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+                                               Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
                                        }
                                }
                        }
@@ -1385,9 +1379,9 @@ void Person::DoDamage(float howmuch){
                        flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
                        flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
                        flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
-                       sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
-                       sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
-                       sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
+                       Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
+                       Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
+                       Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
                }
 
                float gLoc[3];
@@ -1469,7 +1463,7 @@ void Person::DoHead(){
        static XYZ facing;
        static float lookspeed=500;
 
-       if(!freeze&&!winfreeze&&(!mainmenu||!gamestarted)){
+       if(!freeze&&!winfreeze){
 
                //head facing
                targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
@@ -1707,7 +1701,7 @@ void Person::FootLand(int which, float opacity){
                        if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
                        if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
                        //footpoint.y=coords.y;
-                       if(findDistancefast(&footpoint,&viewer))sprites.MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
+                       if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
                }
                else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
                        footvel=velocity/5;
@@ -1716,7 +1710,7 @@ void Person::FootLand(int which, float opacity){
                        if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
                        footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
                        terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
-                       if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
+                       if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
                        if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
                }
                else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
@@ -1726,7 +1720,7 @@ void Person::FootLand(int which, float opacity){
                        if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
                        footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
                        terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
-                       if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5*opacity);
+                       if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5*opacity);
                }
                else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
                        footvel=velocity/5;
@@ -1735,7 +1729,7 @@ void Person::FootLand(int which, float opacity){
                        if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
                        footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
                        terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
-                       if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7*opacity);
+                       if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7*opacity);
                        if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
                }
                else if(isLanding()||targetanimation==jumpupanim||isLandhard())
@@ -1745,7 +1739,7 @@ void Person::FootLand(int which, float opacity){
                        if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
                        if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
                        //footpoint.y=coords.y;
-                       if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
+                       if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
                }
 }
 
@@ -1754,179 +1748,10 @@ void Person::Puff(int whichlabel){
 
        footvel=0;
        footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
-       sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
+       Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
 }
 
 
-/*
-HitStruct      Person::BulletCollideWithPlayer(XYZ start, XYZ end){
-float damage=20;
-XYZ tempbulletloc[2];
-XYZ collisionpoint;
-XYZ sparkpos;
-GLfloat M[16];
-int collide;
-float howfar;
-XYZ average;
-XYZ facing;
-int howmany;
-float distancemax;
-HitStruct hitstruct;
-hitstruct.collision=0;
-//Make bounding sphere
-average=0;
-howmany=0;
-for(int j=0;j<skeleton.num_joints;j++){
-average.x=average.x+skeleton.joints[j].position.x;
-average.y=average.y+skeleton.joints[j].position.y;
-average.z=average.z+skeleton.joints[j].position.z;
-howmany++;
-}
-average=average/howmany;
-distancemax=0;
-for(int j=0;j<skeleton.num_joints;j++){
-if(findDistancefast(average,skeleton.joints[j].position)>distancemax){
-distancemax=findDistancefast(average,skeleton.joints[j].position);
-}
-}
-distancemax=fast_sqrt(distancemax);
-//Collide with player
-if(skeleton.free<1){
-start=start-coords;
-end=end-coords;
-if(rotation)start=DoRotation(start,0,-rotation,0);
-if(rotation)end=DoRotation(end,0,-rotation,0);
-}
-tempbulletloc[0]=start;
-tempbulletloc[1]=end;
-if(sphere_line_intersection(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z,
-tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z,
-average.x, average.y, average.z, distancemax)){
-for(int j=0;j<skeleton.num_joints;j++){
-if(skeleton.joints[j].hasparent&&skeleton.joints[j].visible){
-tempbulletloc[0]=start;
-tempbulletloc[1]=end;
-glPushMatrix();
-glLoadIdentity();
-glScalef(1,1/skeleton.joints[j].length,1);
-glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
-glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
-glTranslatef(  (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
-(-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
-(-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
-glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
-glGetFloatv(GL_MODELVIEW_MATRIX,M);
-tempbulletloc[0].x=M[12];
-tempbulletloc[0].y=M[13];
-tempbulletloc[0].z=M[14];
-glPopMatrix();
-glPushMatrix();
-glLoadIdentity();
-glScalef(1,1/skeleton.joints[j].length,1);
-glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
-glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
-glTranslatef(  (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
-(-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
-(-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
-glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
-glGetFloatv(GL_MODELVIEW_MATRIX,M);
-tempbulletloc[1].x=M[12];
-tempbulletloc[1].y=M[13];
-tempbulletloc[1].z=M[14];
-glPopMatrix();
-collide=skeletonmodels[skeleton.joints[j].modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
-if(collide!=-1)
-{
-glPushMatrix();
-glLoadIdentity();
-glTranslatef(  (skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2,
-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2,
-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2);
-glRotatef(-skeleton.joints[j].rotate1+90,0,1,0);
-glRotatef(-skeleton.joints[j].rotate2+90,0,0,1);
-glScalef(1,skeleton.joints[j].length,1);
-glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
-glGetFloatv(GL_MODELVIEW_MATRIX,M);
-collisionpoint.x=M[12];
-collisionpoint.y=M[13];
-collisionpoint.z=M[14];
-glPopMatrix();
-hitstruct.collision=1;
-hitstruct.hitlocation=collisionpoint;
-hitstruct.joint1=&skeleton.joints[j];
-hitstruct.joint2=skeleton.joints[j].parent;
-}
-}
-}
-for(int j=0;j<skeleton.num_muscles;j++){
-if(skeleton.muscles[j].visible){
-tempbulletloc[0]=start;
-tempbulletloc[1]=end;
-glPushMatrix();
-glLoadIdentity();
-glScalef(1,1/skeleton.muscles[j].length,1);
-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));
-
-glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
-glGetFloatv(GL_MODELVIEW_MATRIX,M);
-tempbulletloc[0].x=M[12];
-tempbulletloc[0].y=M[13];
-tempbulletloc[0].z=M[14];
-glPopMatrix();
-glPushMatrix();
-glLoadIdentity();
-glScalef(1,1/skeleton.muscles[j].length,1);
-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));
-glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
-glGetFloatv(GL_MODELVIEW_MATRIX,M);
-tempbulletloc[1].x=M[12];
-tempbulletloc[1].y=M[13];
-tempbulletloc[1].z=M[14];
-glPopMatrix();
-collide=skeletonmodels[skeleton.muscles[j].parent1->modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
-if(collide!=-1)
-{
-glPushMatrix();
-glLoadIdentity();
-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);
-glRotatef(-skeleton.muscles[j].rotate1+90,0,1,0);
-glRotatef(-skeleton.muscles[j].rotate2+90,0,0,1);
-glRotatef(-skeleton.muscles[j].rotate3,0,1,0);
-glScalef(1,findDistance(skeleton.muscles[j].parent1->position,skeleton.muscles[j].parent2->position),1);
-glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
-glGetFloatv(GL_MODELVIEW_MATRIX,M);
-collisionpoint.x=M[12];
-collisionpoint.y=M[13];
-collisionpoint.z=M[14];
-glPopMatrix();
-hitstruct.collision=1;
-hitstruct.hitlocation=collisionpoint;
-hitstruct.joint1=skeleton.muscles[j].parent1;
-hitstruct.joint2=skeleton.muscles[j].parent2;
-}
-}
-}
-}
-if(skeleton.free<1){
-if(rotation)hitstruct.hitlocation=DoRotation(hitstruct.hitlocation,0,rotation,0);
-hitstruct.hitlocation=hitstruct.hitlocation+coords;
-}
-return hitstruct;
-}
-*/
 void   Person::DoAnimations(){
        if(!skeleton.free){
                int i = 0;
@@ -2306,7 +2131,7 @@ void      Person::DoAnimations(){
                                                                                                                footpoint=weapons.position[i];
                                                                                                                if(victim->weaponstuck!=-1){
                                                                                                                        if(victim->weaponids[victim->weaponstuck]==i){
-                                                                                                                               if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
+                                                                                                                               if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
                                                                                                                                weapons.bloody[i]=2;
                                                                                                                                weapons.blooddrip[i]=5;
                                                                                                                                victim->weaponstuck=-1;
@@ -3043,7 +2868,7 @@ void      Person::DoAnimations(){
                                                                                                relative.y=10;
                                                                                                Normalise(&relative);
                                                                                                //victim->Puff(abdomen);
-                                                                                               if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
+                                                                                               if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
 
                                                                                                if(victim->bloodloss<victim->damagetolerance){
                                                                                                        victim->bloodloss+=1000;
@@ -3320,16 +3145,16 @@ void    Person::DoAnimations(){
                                                                                                footpoint=DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2,0,victim->rotation,0)*victim->scale+victim->coords;
                                                                                        }
                                                                                        if(tutoriallevel!=1){
-                                                                                               if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
+                                                                                               if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
                                                                                                footvel=DoRotation(facing,0,90,0)*.8;
                                                                                                //footvel.y-=.3;
-                                                                                               sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                                               sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                                               sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
-                                                                                               sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
+                                                                                               Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                                               Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                                               Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
+                                                                                               Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
                                                                                        }
                                                                                        if(tutoriallevel==1){
-                                                                                               sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
+                                                                                               Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
                                                                                        }
                                                                                        victim->DoDamage(damagemult*0);
                                                                                }
@@ -3390,13 +3215,13 @@ void    Person::DoAnimations(){
                                                                                                if(!skeleton.free){
                                                                                                        footpoint=DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2,0,victim->rotation,0)*victim->scale+victim->coords;
                                                                                                }
-                                                                                               if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+                                                                                               if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
                                                                                                footvel=DoRotation(facing,0,90,0)*.8;
                                                                                                footvel.y-=.3;
-                                                                                               sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                                               sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                                               sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
-                                                                                               sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
+                                                                                               Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                                               Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                                               Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
+                                                                                               Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
                                                                                        }
                                                                                }
                                                                                else {
@@ -4153,17 +3978,17 @@ void    Person::DoAnimations(){
                                                                                        bloodvel.z=20;
                                                                                        bloodvel.y=5;
                                                                                        bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
-                                                                                       sprites.MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+                                                                                       Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
                                                                                        */
                                                                                        XYZ footvel,footpoint;
                                                                                        footvel=0;
                                                                                        footpoint=weapons.tippoint[weaponids[0]];
-                                                                                       if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+                                                                                       if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
                                                                                        footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
-                                                                                       sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                                       sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                                       sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
-                                                                                       sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
+                                                                                       Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                                       Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                                       Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
+                                                                                       Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
                                                                                        victim->DoBloodBig(200,195);
                                                                                        if(id==0){
                                                                                                bonus=tracheotomy;
@@ -4182,12 +4007,12 @@ void    Person::DoAnimations(){
                                                                                        XYZ footvel,footpoint;
                                                                                        footvel=0;
                                                                                        footpoint=weapons.tippoint[weaponids[0]];
-                                                                                       if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+                                                                                       if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
                                                                                        footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
-                                                                                       sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                                       sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                                       sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
-                                                                                       sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
+                                                                                       Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                                       Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                                       Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
+                                                                                       Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
 
                                                                                }
                                                                                victim->bloodloss+=10000;
@@ -4240,12 +4065,12 @@ void    Person::DoAnimations(){
                                                                                XYZ footvel,footpoint;
                                                                                footvel=0;
                                                                                footpoint=weapons.tippoint[weaponids[0]];
-                                                                               if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+                                                                               if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
                                                                                footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
-                                                                               sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                               sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                               sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
-                                                                               sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
+                                                                               Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                               Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                               Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
+                                                                               Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
                                                                        }
                                                                }
 
@@ -4262,12 +4087,12 @@ void    Person::DoAnimations(){
                                                                                XYZ footvel,footpoint;
                                                                                footvel=0;
                                                                                footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
-                                                                               if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+                                                                               if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
                                                                                footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
-                                                                               sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                               sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                               sprites.MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
-                                                                               sprites.MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
+                                                                               Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                               Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                               Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
+                                                                               Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
                                                                                victim->DoBloodBig(200,180);
                                                                                victim->DoBloodBig(200,215);
                                                                                victim->bloodloss+=10000;
@@ -4314,12 +4139,12 @@ void    Person::DoAnimations(){
                                                                                XYZ footvel,footpoint;
                                                                                footvel=0;
                                                                                footpoint=weapons.tippoint[weaponids[0]];
-                                                                               if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
+                                                                               if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
                                                                                footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
-                                                                               sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                               sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
-                                                                               sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
-                                                                               sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
+                                                                               Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                               Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
+                                                                               Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
+                                                                               Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
                                                                        }
                                                                }
 
@@ -5054,12 +4879,6 @@ void     Person::DoStuff(){
                        targetanimation=getRun();
                        targetframe=0;
                }
-               /*static float toggledelay;
-               toggledelay-=multiplier;
-               if(toggledelay<0){
-               toggledelay=1;
-               if(Random()%3==0)superruntoggle=1-superruntoggle;
-               }*/
        }
        if(weaponactive==-1&&num_weapons>0){
                if(weapons.type[weaponids[0]]==staff){
@@ -5098,7 +4917,7 @@ void      Person::DoStuff(){
                if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
                if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
                if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
-               sprites.MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
+               Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
        }
 
        while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
@@ -5108,7 +4927,7 @@ void      Person::DoStuff(){
                if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
                if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
                if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
-               sprites.MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
+               Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
        }
 
        if(bleeding>0){
@@ -5135,8 +4954,8 @@ void      Person::DoStuff(){
                        }
                        if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
                        if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
-                       if(skeleton.free)sprites.MakeSprite(bloodsprite, (skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5)*scale+coords,bloodvel, 1,1,1, .05, .9);
-                       if(!skeleton.free)sprites.MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, .9);
+                       if(skeleton.free)Sprite::MakeSprite(bloodsprite, (skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5)*scale+coords,bloodvel, 1,1,1, .05, .9);
+                       if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, .9);
                        neckspurtparticledelay=.05;
                }
                if(neckspurtdelay<0){
@@ -5154,14 +4973,10 @@ void    Person::DoStuff(){
                                bloodvel=0;
                                if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
                                if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
-                               if(skeleton.free)sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
-                               if(!skeleton.free)sprites.MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
+                               if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
+                               if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
                        }
                }
-               /*if(id==0){
-               bloodloss+=deathbleeding*40;
-               deathbleeding=0;
-               }*/
                bloodloss+=deathbleeding*multiplier*80;
                deathbleeding-=multiplier*1.6;
                //if(id==0)deathbleeding-=multiplier*.2;
@@ -5235,10 +5050,6 @@ void     Person::DoStuff(){
                if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
                if(endx<startx)endx=startx;
                if(endy<starty)endy=starty;
-               /*int startx=0;
-               int starty=0;
-               int endx=256;
-               int endy=256;*/
 
                for(i=startx;i<endx;i++){
                        for(j=starty;j<endy;j++){
@@ -5381,7 +5192,7 @@ void      Person::DoStuff(){
                                if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
                                if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
                                if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
-                               sprites.MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
+                               Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
                        }
                }
 
@@ -5614,12 +5425,6 @@ void     Person::DoStuff(){
                }
 
                damage+=20;
-
-               /*
-               if(bloodloss<damagetolerance)
-               for(i=0;i<skeleton.num_joints;i++){
-               skeleton.joints[i].velocity*=1.5;
-               }*/
        }
 
        //if(dead)damage-=multiplier/4;
@@ -6133,8 +5938,8 @@ void      Person::DoStuff(){
                                                                                        pos.x+=float(abs(Random()%100)-50)/200;
                                                                                        pos.y+=float(abs(Random()%100)-50)/200;
                                                                                        pos.z+=float(abs(Random()%100)-50)/200;
-                                                                                       sprites.MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
-                                                                                       sprites.special[sprites.numsprites-1]=1;
+                                                                                       Sprite::MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
+                                                                                       Sprite::setLastSpriteSpecial(1);
                                                                                }
                                                                                howmany=findLength(&velocity)*4;
                                                                                if(detail==2)
@@ -6148,8 +5953,8 @@ void      Person::DoStuff(){
                                                                                                        pos.x+=float(abs(Random()%100)-50)/200;
                                                                                                        pos.y+=float(abs(Random()%100)-50)/200;
                                                                                                        pos.z+=float(abs(Random()%100)-50)/200;
-                                                                                                       sprites.MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
-                                                                                                       sprites.special[sprites.numsprites-1]=2;
+                                                                                                       Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
+                                                                                                       Sprite::setLastSpriteSpecial(2);
                                                                                                }
                                                        }
                                                        objects.rotx[i]+=velocity.x*multiplier*6;
@@ -6166,23 +5971,6 @@ void     Person::DoStuff(){
                                                                tempcoord+=objects.position[i];
                                                        }
                                                        if(findDistancefastflat(&tempcoord,&objects.position[i])<objects.scale[i]*objects.scale[i]*8&&findDistancefast(&tempcoord,&objects.position[i])<objects.scale[i]*objects.scale[i]*300&&tempcoord.y>objects.position[i].y+3*objects.scale[i]){
-                                                               /*if(onfire){
-                                                               if(!objects.onfire[i]){
-                                                               float gLoc[3];
-                                                               float vel[3];
-                                                               gLoc[0]=objects.position[i].x;
-                                                               gLoc[1]=objects.position[i].y;
-                                                               gLoc[2]=objects.position[i].z;
-                                                               vel[0]=0;
-                                                               vel[1]=0;
-                                                               vel[2]=0;
-                                                               PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
-                                                               OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
-                                                               OPENAL_SetVolume(channels[firestartsound], 256);
-                                                               OPENAL_SetPaused(channels[firestartsound], false);
-                                                               objects.onfire[i]=1;
-                                                               }
-                                                               }*/
                                                                if(objects.messedwith[i]<=0){
                                                                        XYZ tempvel;
                                                                        XYZ pos;
@@ -6222,8 +6010,8 @@ void      Person::DoStuff(){
                                                                                                pos.x+=float(abs(Random()%100)-50)/150;
                                                                                                pos.y+=float(abs(Random()%100)-50)/150;
                                                                                                pos.z+=float(abs(Random()%100)-50)/150;
-                                                                                               sprites.MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
-                                                                                               sprites.special[sprites.numsprites-1]=1;
+                                                                                               Sprite::MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
+                                                                                               Sprite::setLastSpriteSpecial(1);
                                                                                        }
                                                                                        howmany=findLength(&velocity)*4;
                                                                                        if(detail==2)
@@ -6238,8 +6026,8 @@ void      Person::DoStuff(){
                                                                                                                pos.x+=float(abs(Random()%100)-50)/150;
                                                                                                                pos.y+=float(abs(Random()%100)-50)/150;
                                                                                                                pos.z+=float(abs(Random()%100)-50)/150;
-                                                                                                               sprites.MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
-                                                                                                               sprites.special[sprites.numsprites-1]=2;
+                                                                                                               Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
+                                                                                                               Sprite::setLastSpriteSpecial(2);
                                                                                                        }
                                                                }
                                                                objects.messedwith[i]=.5;
@@ -6276,8 +6064,6 @@ void      Person::DoStuff(){
                                                }
                                        }
                                        speechdelay=.3;
-                                       //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
-                                       //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
 
                                        if(whichsound!=-1){
                                                PlaySoundEx( whichsound, samp[whichsound], NULL, true);
@@ -6449,7 +6235,7 @@ void      Person::DoStuff(){
 
                                        flatfacing=DoRotation(flatfacing,0,rotation,0);
                                        facing=flatfacing;
-                                       ReflectVector(&facing,&terrainnormal);
+                                       ReflectVector(&facing,terrainnormal);
                                        Normalise(&facing);
 
                                        if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
@@ -6502,7 +6288,7 @@ void      Person::DoStuff(){
                                                        velocity*=velspeed;
                                                }
                                                velocity.y+=gravity*multiplier*20;
-                                               ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
+                                               ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
                                                velspeed=findLength(&velocity);
                                                velocity=flatfacing*velspeed;
                                        }
@@ -6516,7 +6302,7 @@ void      Person::DoStuff(){
                                                                velocity*=velspeed;
                                                        }
                                                        velocity.y+=gravity*multiplier*20;
-                                                       ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
+                                                       ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
                                                        velspeed=findLength(&velocity);
                                                        if(velspeed<speed*30*scale)velspeed=speed*30*scale;
                                                        velocity=flatfacing*velspeed;
@@ -6540,26 +6326,11 @@ void    Person::DoStuff(){
                                                        }
                                                }
                                                velocity.y+=gravity*multiplier*20;
-                                               ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
+                                               ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
                                                velspeed=findLength(&velocity);
                                                velocity=flatfacing*velspeed;
                                        }
 
-                                       /*if(creature==wolftype)
-                                       if(isRun()){
-                                       velocity+=facing*multiplier*speed*700*scale;
-                                       velspeed=findLength(&velocity);
-                                       if(velspeed>speed*55*scale){
-                                       velocity/=velspeed;
-                                       velspeed=speed*55*scale;
-                                       velocity*=velspeed;
-                                       }
-                                       velocity.y+=gravity*multiplier*20;
-                                       ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
-                                       velspeed=findLength(&velocity);
-                                       velocity=flatfacing*velspeed;
-                                       }*/
-
                                        if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
                                                velocity+=facing*multiplier*speed*700*scale;
                                                velspeed=findLength(&velocity);
@@ -6569,7 +6340,7 @@ void      Person::DoStuff(){
                                                        velocity*=velspeed;
                                                }
                                                velocity.y+=gravity*multiplier*20;
-                                               ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
+                                               ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
                                                velspeed=findLength(&velocity);
                                                velocity=flatfacing*velspeed;
                                        }
@@ -6584,7 +6355,7 @@ void      Person::DoStuff(){
                                        velocity*=velspeed;
                                        }
                                        velocity.y+=gravity*multiplier*20;
-                                       ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
+                                       ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
                                        velspeed=findLength(&velocity);
                                        velocity=flatfacing*velspeed;
                                        }*/
@@ -6598,7 +6369,7 @@ void      Person::DoStuff(){
                                                        velocity*=velspeed;
                                                }
                                                velocity.y+=gravity*multiplier*20;
-                                               ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
+                                               ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
                                                velspeed=findLength(&velocity);
                                                velocity=flatfacing*velspeed;
                                        }
@@ -6612,7 +6383,7 @@ void      Person::DoStuff(){
                                                        velocity*=velspeed;
                                                }
                                                velocity.y+=gravity*multiplier*20;
-                                               ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
+                                               ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
                                                velspeed=findLength(&velocity);
                                                velocity=flatfacing*velspeed;
                                        }
@@ -6627,7 +6398,7 @@ void      Person::DoStuff(){
                                                        velocity*=velspeed;
                                                }
                                                velocity.y+=gravity*multiplier*20;
-                                               ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
+                                               ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
                                                velspeed=findLength(&velocity);
                                                velocity=flatfacing*velspeed*-1;
                                        }
@@ -6641,7 +6412,7 @@ void      Person::DoStuff(){
                                                        velocity*=velspeed;
                                                }
                                                velocity.y+=gravity*multiplier*20;
-                                               ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
+                                               ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
                                                velspeed=findLength(&velocity);
                                                velocity=DoRotation(flatfacing*velspeed,0,-90,0);
                                        }
@@ -6665,7 +6436,7 @@ void      Person::DoStuff(){
                                                        velocity*=velspeed;
                                                }
                                                velocity.y+=gravity*multiplier*20;
-                                               ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
+                                               ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
                                                velspeed=findLength(&velocity);
                                                velocity=flatfacing*velspeed*-1;
                                        }
@@ -6679,7 +6450,7 @@ void      Person::DoStuff(){
                                                        velocity*=velspeed;
                                                }
                                                velocity.y+=gravity*multiplier*20;
-                                               ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
+                                               ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
                                                velspeed=findLength(&velocity);
                                                velocity=flatfacing*velspeed*-1;
                                        }
@@ -6864,9 +6635,12 @@ int Person::DrawSkeleton(){
                if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
                        playerdetail=1;
                }
-               if(id==0)playerdetail=1;
-               if(playerdetail!=oldplayerdetail)updatedelay=0;
-               if(playerdetail!=oldplayerdetail)normalsupdatedelay=0;
+               if(id==0)
+                       playerdetail=1;
+               if(playerdetail!=oldplayerdetail) {
+                       updatedelay=0;
+                       normalsupdatedelay=0;
+               }
                static float updatedelaychange;
                static float morphness;
                static float framemult;
@@ -7014,7 +6788,8 @@ int Person::DrawSkeleton(){
                                        }
                                }
                        }
-                       if(!skeleton.free&&(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfrombackanim&&((targetanimation!=rollanim&&!isFlip())||animation[targetanimation].label[targetframe]==6)&&targetanimation!=getupfromfrontanim&&targetanimation!=wolfrunninganim&&targetanimation!=rabbitrunninganim&&targetanimation!=backhandspringanim&&targetanimation!=walljumpfrontanim&&targetanimation!=hurtidleanim&&!isLandhard()&&!isSleeping()))DoHead();
+                       if(!skeleton.free&&(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&((targetanimation!=rollanim&&!isFlip())||animation[targetanimation].label[targetframe]==6)&&targetanimation!=getupfromfrontanim&&targetanimation!=wolfrunninganim&&targetanimation!=rabbitrunninganim&&targetanimation!=backhandspringanim&&targetanimation!=walljumpfrontanim&&targetanimation!=hurtidleanim&&!isLandhard()&&!isSleeping()))
+                               DoHead();
                        else {
                                targetheadrotation=-targetrotation;
                                targetheadrotation2=0;
@@ -7318,12 +7093,12 @@ int Person::DrawSkeleton(){
                        }
                        if(playerdetail){
                                if(!showpoints){
-                                       if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(sprites.cloudimpacttexture);
+                                       if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
                                        else skeleton.drawmodel.draw();
                                }
                        }
                        if(!playerdetail){
-                               if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(sprites.cloudimpacttexture);
+                               if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
                                else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
                        }
 
@@ -7347,12 +7122,12 @@ int Person::DrawSkeleton(){
                                                glTranslatef(smoketex*.6,0,0);
                                                if(playerdetail){
                                                        if(!showpoints){
-                                                               if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(sprites.cloudimpacttexture);
+                                                               if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
                                                                else skeleton.drawmodel.draw();
                                                        }
                                                }
                                                if(!playerdetail){
-                                                       if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(sprites.cloudimpacttexture);
+                                                       if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
                                                        else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
                                                }
                                }