4 extern float multiplier;
5 extern Animation animation[animation_count];
6 extern FSOUND_SAMPLE *samp[100];
7 extern int channels[100];
8 extern Terrain terrain;
10 extern int environment;
11 extern Sprites sprites;
13 extern FRUSTUM frustum;
15 extern float realmultiplier;
17 extern float slomodelay;
18 extern bool cellophane;
19 extern float texdetail;
20 extern float realtexdetail;
21 extern GLubyte bloodText[512*512*3];
22 extern GLubyte wolfbloodText[512*512*3];
23 extern int bloodtoggle;
24 extern Objects objects;
26 extern bool autoslomo;
27 extern float camerashake;
29 extern float terraindetail;
30 extern float viewdistance;
31 extern float blackout;
32 extern int difficulty;
33 extern Weapons weapons;
35 extern float fadestart;
36 extern Person player[maxplayers];
37 extern int numplayers;
39 extern bool winfreeze;
40 extern float flashamount,flashr,flashg,flashb;
41 extern int flashdelay;
42 extern bool showpoints;
43 extern bool immediate;
45 extern bool tilt2weird;
46 extern bool tiltweird;
48 extern bool proportionweird;
49 extern bool vertexweird[6];
50 extern GLubyte texturearray[512*512*3];
51 extern XYZ envsound[30];
52 extern float envsoundvol[30];
53 extern float envsoundlife[30];
54 extern int numenvsounds;
56 extern float bonusvalue;
57 extern float bonustotal;
58 extern float bonustime;
59 extern int tutoriallevel;
60 extern float smoketex;
61 extern int tutorialstage;
62 extern bool reversaltrain;
63 extern bool canattack;
65 extern float damagedealt;
66 extern float damagetaken;
68 extern float hostiletime;
73 extern int numflipfail;
75 extern int numswordattack;
76 extern int numknifeattack;
77 extern int numunarmedattack;
78 extern int numescaped;
79 extern int numflipped;
80 extern int numwallflipped;
81 extern int numthrowkill;
82 extern int numafterkill;
83 extern int numreversals;
84 extern int numattacks;
85 extern int maxalarmed;
86 extern int indialogue;
88 extern bool gamestarted;
90 extern FSOUND_STREAM * strm[20];
91 extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
92 extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
94 void Person::CheckKick(){
98 float damagemult=1*power;
99 if(creature==wolftype)damagemult=2.5*power;
103 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
104 if(findDistancefast(&coords,&victim->coords)<1.2){
105 if(!victim->skeleton.free){
107 Normalise(&relative);
108 relative=coords+relative*1;
109 if(animation[victim->targetanimation].height!=lowheight){
114 gLoc[0]=victim->coords.x;
115 gLoc[1]=victim->coords.y;
116 gLoc[2]=victim->coords.z;
120 if(tutoriallevel!=1){
121 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
122 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
123 FSOUND_SetVolume(channels[heavyimpactsound], 128);
124 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
129 Normalise(&relative);
130 for(i=0;i<victim->skeleton.num_joints;i++){
131 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
134 victim->DoDamage(100*damagemult/victim->protectionhigh);
135 if(id==0)camerashake+=.4;
139 targetanimation=backflipanim;
144 if(id==0)FSOUND_SetPaused(channels[whooshsound], FALSE);
146 //if(victim->damage>victim->damagetolerance){
154 else if (victim->isCrouch()){
155 targetanimation=rabbitkickreversedanim;
156 currentanimation=rabbitkickreversedanim;
157 victim->currentanimation=rabbitkickreversalanim;
158 victim->targetanimation=rabbitkickreversalanim;
164 victim->oldcoords=victim->coords;
165 coords=victim->coords;
166 victim->targetrotation=targetrotation;
174 void Person::CatchFire(){
175 XYZ flatfacing,flatvelocity;
177 for(int i=0;i<10;i++){
178 howmany=abs(Random()%(skeleton.num_joints));
179 if(!skeleton.free)flatvelocity=velocity;
180 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
181 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
182 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
183 sprites.MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
196 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
197 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
198 FSOUND_SetVolume(channels[firestartsound], 256);
199 FSOUND_SetPaused(channels[firestartsound], FALSE);
204 //PlaySoundEx( firesound, samp[firesound], NULL, TRUE);
205 PlayStreamEx( stream_firesound, strm[stream_firesound], NULL, TRUE);
206 FSOUND_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
207 FSOUND_SetVolume(channels[stream_firesound], 256);
208 FSOUND_SetPaused(channels[stream_firesound], FALSE);
215 bool Person::isIdle(){
216 if(targetanimation==sleepanim||targetanimation==sitanim||targetanimation==talkidleanim||targetanimation==hurtidleanim||targetanimation==bounceidleanim||targetanimation==talkidleanim||targetanimation==fightidleanim||targetanimation==knifefightidleanim||targetanimation==swordfightidleanim||targetanimation==swordfightidlebothanim||targetanimation==fightsidestep||targetanimation==wolfidle)return 1;
220 bool Person::isSitting(){
221 if(targetanimation==sitanim)return 1;
222 if(targetanimation==sitwallanim)return 1;
226 bool Person::isSleeping(){
227 if(targetanimation==sleepanim)return 1;
228 if(targetanimation==dead1anim)return 1;
229 if(targetanimation==dead2anim)return 1;
230 if(targetanimation==dead3anim)return 1;
231 if(targetanimation==dead4anim)return 1;
235 bool Person::wasIdle(){
236 if(currentanimation==sleepanim||currentanimation==talkidleanim||currentanimation==sitanim||currentanimation==hurtidleanim||currentanimation==bounceidleanim||currentanimation==fightidleanim||currentanimation==swordfightidleanim||currentanimation==swordfightidlebothanim||currentanimation==knifefightidleanim||currentanimation==fightsidestep||currentanimation==wolfidle)return 1;
239 int Person::getIdle(){
240 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
241 if(hasvictim&&victim!=this/*||(id==0&&attackkeydown)*/)if(/*(id==0&&attackkeydown)||*/(!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers)){
242 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
243 if(creature==rabbittype)return fightidleanim;
244 if(creature==wolftype)return wolfidle;
246 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
247 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
248 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
249 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
250 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
252 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
254 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
255 if(howactive==typesitting)return sitanim;
256 if(howactive==typesittingwall)return sitwallanim;
257 if(howactive==typesleeping)return sleepanim;
258 if(howactive==typedead1)return dead1anim;
259 if(howactive==typedead2)return dead2anim;
260 if(howactive==typedead3)return dead3anim;
261 if(howactive==typedead4)return dead4anim;
262 if(creature==rabbittype)return bounceidleanim;
263 if(creature==wolftype)return wolfidle;
267 bool Person::isCrouch(){
268 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
273 bool Person::wasCrouch(){
274 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
277 int Person::getCrouch(){
278 if(creature==rabbittype)return crouchanim;
279 if(creature==wolftype)return wolfcrouchanim;
283 bool Person::isRun(){
284 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
289 bool Person::wasRun(){
290 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
293 int Person::getRun(){
294 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
295 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
297 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
298 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
302 bool Person::isStop(){
303 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
308 bool Person::wasStop(){
309 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
312 int Person::getStop(){
313 if(creature==rabbittype)return stopanim;
314 if(creature==wolftype)return wolfstopanim;
319 bool Person::isLanding(){
320 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
325 bool Person::wasLanding(){
326 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
329 int Person::getLanding(){
330 if(creature==rabbittype)return landanim;
331 if(creature==wolftype)return wolflandanim;
336 bool Person::isLandhard(){
337 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
342 bool Person::wasLandhard(){
343 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
346 int Person::getLandhard(){
347 if(creature==rabbittype)return landhardanim;
348 if(creature==wolftype)return wolflandhardanim;
353 bool Person::isFlip(){
354 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
358 bool Person::wasFlip(){
359 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
363 bool Person::isWallJump(){
364 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
368 void SolidHitBonus();
369 void SolidHitBonus(){
370 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
375 else if(bonustime<1.5&&bonus==threexcombo){
380 else if(bonustime<1.5&&bonus==twoxcombo){
385 else if(bonustime<1.5&&bonus==solidhit){
397 void Person::DoBlood(float howmuch,int which){
398 static int bleedxint,bleedyint;
400 //if(howmuch&&id==0)blooddimamount=1;
401 if(bloodtoggle&&tutoriallevel!=1){
402 if(bleeding<=0&&spurt){
404 for(int i=0;i<3;i++){
408 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
411 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
413 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
414 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
416 sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
417 sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
420 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);
421 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);
425 for(int i=0;i<3;i++){
430 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
433 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
435 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
436 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
439 sprites.MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
440 sprites.special[sprites.numsprites-1]=3;
443 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);
444 sprites.special[sprites.numsprites-1]=3;
450 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
453 int texdetailint=realtexdetail;
454 if(creature==rabbittype)
455 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){
456 bleedxint=abs(Random()%512);
457 bleedyint=abs(Random()%512);
459 if(creature==wolftype)
460 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){
461 bleedxint=abs(Random()%512);
462 bleedyint=abs(Random()%512);
466 bleedy/=realtexdetail;
467 bleedx/=realtexdetail;
468 direction=abs(Random()%2)*2-1;
472 if(bleeding>2)bleeding=2;
475 void Person::DoBloodBig(float howmuch,int which){
476 static int bleedxint,bleedyint,i,j;
478 if(howmuch&&id==0)blooddimamount=1;
480 if(tutoriallevel!=1||id==0)
481 if(aitype!=playercontrolled&&howmuch>0){
492 if(creature==wolftype){
493 int i=abs(Random()%2);
494 if(i==0)whichsound=snarlsound;
495 if(i==1)whichsound=snarl2sound;
496 envsound[numenvsounds]=coords;
497 envsoundvol[numenvsounds]=16;
498 envsoundlife[numenvsounds]=.4;
501 if(creature==rabbittype){
502 int i=abs(Random()%2);
503 if(i==0)whichsound=rabbitpainsound;
504 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
505 envsound[numenvsounds]=coords;
506 envsoundvol[numenvsounds]=16;
507 envsoundlife[numenvsounds]=.4;
509 //if(i==2)whichsound=rabbitpain2sound;
513 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
514 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
515 FSOUND_SetVolume(channels[whichsound], 512);
516 FSOUND_SetPaused(channels[whichsound], FALSE);
520 if(id==0&&howmuch>0){
528 if(bloodtoggle&&decals&&tutoriallevel!=1){
529 if(bleeding<=0&&spurt){
531 for(int i=0;i<3;i++){
535 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
538 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
540 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
541 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
543 sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
544 sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
547 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);
548 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);
552 int offsetx=0,offsety=0;
555 offsetx=abs(Random()%60);
557 if(which==190||which==185){
559 offsetx=abs(Random()%100)-20;
569 if(which==220||which==215){
570 //offsety=Random()%20;
572 //offsetx=abs(Random()%80);
581 if(creature==rabbittype)
584 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
585 if(i<startx)startx=i;
586 if(j<starty)starty=j;
592 if(creature==wolftype)
595 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
596 if(i<startx)startx=i;
597 if(j<starty)starty=j;
609 if(startx<0)startx=0;
610 if(starty<0)starty=0;
611 if(endx>512-1)endx=512-1;
612 if(endy>512-1)endy=512-1;
613 if(endx<startx)endx=startx;
614 if(endy<starty)endy=starty;
616 startx/=realtexdetail;
617 starty/=realtexdetail;
621 int texdetailint=realtexdetail;
623 if(creature==rabbittype)
624 for(i=startx;i<endx;i++){
625 for(j=starty;j<endy;j++){
626 if(bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=which+4&&bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=which-4){
627 color=Random()%85+170;
628 where=i*skeleton.skinsize*3+j*3;
629 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
630 skeleton.skinText[where+1]=0;
631 skeleton.skinText[where+2]=0;
635 if(creature==wolftype)
636 for(i=startx;i<endx;i++){
637 for(j=starty;j<endy;j++){
638 if(wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=which+4&&wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=which-4){
639 color=Random()%85+170;
640 where=i*skeleton.skinsize*3+j*3;
641 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
642 skeleton.skinText[where+1]=0;
643 skeleton.skinText[where+2]=0;
647 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
648 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
649 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
653 if(creature==rabbittype)
654 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){
655 bleedxint=abs(Random()%512);
656 bleedyint=abs(Random()%512);
658 if(creature==wolftype)
659 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){
660 bleedxint=abs(Random()%512);
661 bleedyint=abs(Random()%512);
663 bleedy=bleedxint+offsetx;
664 bleedx=bleedyint+offsety;
665 bleedy/=realtexdetail;
666 bleedx/=realtexdetail;
667 if(bleedx<0)bleedx=0;
668 if(bleedy<0)bleedy=0;
669 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
670 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
671 direction=abs(Random()%2)*2-1;
674 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
675 deathbleeding+=bleeding;
676 bloodloss+=bleeding*3;
678 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
679 if(abs(Random()%2)==0){aitype=gethelptype;
682 else aitype=attacktypecutoff;
685 if(bleeding>2)bleeding=2;
688 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
689 static int bleedxint,bleedyint,i,j;
691 static XYZ startpoint,endpoint,colpoint,movepoint;
692 static float rotationpoint;
694 static XYZ p1,p2,p3,p0;
698 float coordsx,coordsy;
701 if(bloodtoggle&&decals&&tutoriallevel!=1){
703 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
711 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
714 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
715 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
716 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
718 CrossProduct(p2-p1,p3-p1,&N);
719 CrossProduct(p0-p1,p3-p1,&temp);
720 s = dotproduct(&temp,&N)/findLength(&N);
721 CrossProduct(p2-p1,p1-p0,&temp);
722 t = dotproduct(&temp,&N)/findLength(&N);
725 bary.x=findDistancefast(&p0,&p1);
726 bary.y=findDistancefast(&p0,&p2);
727 bary.z=findDistancefast(&p0,&p3);
729 total=bary.x+bary.y+bary.z;
738 total=bary.x+bary.y+bary.z;
744 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
745 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
746 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
747 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
748 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
749 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
750 coordsx=skeleton.drawmodel.Triangles[whichtri].gx[0]*bary.x+skeleton.drawmodel.Triangles[whichtri].gx[1]*bary.y+skeleton.drawmodel.Triangles[whichtri].gx[2]*bary.z;
751 coordsy=skeleton.drawmodel.Triangles[whichtri].gy[0]*bary.x+skeleton.drawmodel.Triangles[whichtri].gy[1]*bary.y+skeleton.drawmodel.Triangles[whichtri].gy[2]*bary.z;
753 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
754 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
756 if(bleeding<=0&&spurt){
758 for(int i=0;i<3;i++){
762 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
765 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
767 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
768 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
770 sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
771 sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
774 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);
775 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);
779 int offsetx=0,offsety=0;
782 offsetx=abs(Random()%120);
784 if(which==220||which==215){
786 offsetx=abs(Random()%80);
789 offsetx=(1+coordsy)*512-291;
790 offsety=coordsx*512-437;
797 if(creature==rabbittype)
800 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
801 if(i<startx)startx=i;
802 if(j<starty)starty=j;
808 if(creature==wolftype)
811 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
812 if(i<startx)startx=i;
813 if(j<starty)starty=j;
824 if(startx<0)startx=0;
825 if(starty<0)starty=0;
826 if(endx>512-1)endx=512-1;
827 if(endy>512-1)endy=512-1;
828 if(endx<startx)endx=startx;
829 if(endy<starty)endy=starty;
831 startx/=realtexdetail;
832 starty/=realtexdetail;
836 int texdetailint=realtexdetail;
838 if(creature==rabbittype)
839 for(i=startx;i<endx;i++){
840 for(j=starty;j<endy;j++){
841 if(bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=which+4&&bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=which-4){
842 color=Random()%85+170;
843 where=i*skeleton.skinsize*3+j*3;
844 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
845 skeleton.skinText[where+1]=0;
846 skeleton.skinText[where+2]=0;
848 else if(bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=160+4&&bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=160-4){
849 color=Random()%85+170;
850 where=i*skeleton.skinsize*3+j*3;
851 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
852 skeleton.skinText[where+1]=0;
853 skeleton.skinText[where+2]=0;
857 if(creature==wolftype)
858 for(i=startx;i<endx;i++){
859 for(j=starty;j<endy;j++){
860 if(wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=which+4&&wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=which-4){
861 color=Random()%85+170;
862 where=i*skeleton.skinsize*3+j*3;
863 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
864 skeleton.skinText[where+1]=0;
865 skeleton.skinText[where+2]=0;
867 else if(wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=160+4&&wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=160-4){
868 color=Random()%85+170;
869 where=i*skeleton.skinsize*3+j*3;
870 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
871 skeleton.skinText[where+1]=0;
872 skeleton.skinText[where+2]=0;
876 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
877 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
878 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
880 bleedy=(1+coordsy)*512;
882 bleedy/=realtexdetail;
883 bleedx/=realtexdetail;
884 if(bleedx<0)bleedx=0;
885 if(bleedy<0)bleedy=0;
886 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
887 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
888 direction=abs(Random()%2)*2-1;
890 if(whichtri==-1)return 0;
892 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
893 deathbleeding+=bleeding;
894 bloodloss+=bleeding*3;
896 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
897 if(abs(Random()%2)==0){aitype=gethelptype;
900 else aitype=attacktypecutoff;
903 if(bleeding>2)bleeding=2;
908 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
911 static int bytesPerPixel=3;
912 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
913 static int newstartx,newstarty,newendx,newendy;
914 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
916 static float sizemult;
918 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
919 texture[i]=skeleton.skinText[i];
922 if((!osx||howmanylevels)){
924 if(startx<0)startx=0;
925 if(starty<0)starty=0;
926 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
927 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
928 if((endx>startx&&endy>starty)||howmanylevels){
935 for(i=startx;i<endx;i++){
936 for(j=starty;j<endy;j++){
937 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
938 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
939 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
943 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
946 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
947 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
948 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
951 newsize=skeleton.skinsize;
954 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
956 /*for(j=1;j<=howmanylevels;j++){
957 if(j==1)texpointer=&skeleton.skinText[0];
958 else texpointer=&texture[0];
960 totalsize=int( newsize*newsize*bytesPerPixel);
961 rowsize=int( newsize*bytesPerPixel );
962 bigstep=bytesPerPixel*newsize*2;
963 smallstep=bytesPerPixel*2;
969 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
976 void Person::Reverse(){
977 if(victim->aitype==playercontrolled||hostiletime>1)
978 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
979 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
980 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
981 if(targetanimation==sweepanim){
982 targetanimation=sweepreversedanim;
983 currentanimation=sweepreversedanim;
984 victim->currentanimation=sweepreversalanim;
985 victim->targetanimation=sweepreversalanim;
987 if(targetanimation==spinkickanim){
988 targetanimation=spinkickreversedanim;
989 currentanimation=spinkickreversedanim;
990 victim->currentanimation=spinkickreversalanim;
991 victim->targetanimation=spinkickreversalanim;
993 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
994 if(targetanimation==rabbittacklinganim){
997 victim->currentframe=6;
998 victim->targetframe=7;
1000 targetanimation=upunchreversedanim;
1001 currentanimation=upunchreversedanim;
1002 victim->currentanimation=upunchreversalanim;
1003 victim->targetanimation=upunchreversalanim;
1005 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1006 if(victim->weaponactive!=-1){
1007 victim->throwtogglekeydown=1;
1008 weapons.owner[victim->weaponids[0]]=-1;
1009 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1010 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1011 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1012 weapons.missed[victim->weaponids[0]]=1;
1013 weapons.freetime[victim->weaponids[0]]=0;
1014 weapons.firstfree[victim->weaponids[0]]=1;
1015 weapons.physics[victim->weaponids[0]]=1;
1016 victim->num_weapons--;
1017 if(victim->num_weapons){
1018 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1019 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1022 victim->weaponactive=-1;
1023 for(int j=0;j<numplayers;j++){
1024 player[j].wentforweapon=0;
1028 targetanimation=staffhitreversedanim;
1029 currentanimation=staffhitreversedanim;
1030 victim->currentanimation=staffhitreversalanim;
1031 victim->targetanimation=staffhitreversalanim;
1033 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1034 if(victim->weaponactive!=-1){
1035 victim->throwtogglekeydown=1;
1036 weapons.owner[victim->weaponids[0]]=-1;
1037 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1038 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1039 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1040 weapons.missed[victim->weaponids[0]]=1;
1041 weapons.freetime[victim->weaponids[0]]=0;
1042 weapons.firstfree[victim->weaponids[0]]=1;
1043 weapons.physics[victim->weaponids[0]]=1;
1044 victim->num_weapons--;
1045 if(victim->num_weapons){
1046 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1047 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1050 victim->weaponactive=-1;
1051 for(int j=0;j<numplayers;j++){
1052 player[j].wentforweapon=0;
1055 targetanimation=staffspinhitreversedanim;
1056 currentanimation=staffspinhitreversedanim;
1057 victim->currentanimation=staffspinhitreversalanim;
1058 victim->targetanimation=staffspinhitreversalanim;
1060 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1061 if(victim->weaponactive!=-1){
1062 victim->throwtogglekeydown=1;
1063 weapons.owner[victim->weaponids[0]]=-1;
1064 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1065 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1066 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1067 weapons.missed[victim->weaponids[0]]=1;
1068 weapons.freetime[victim->weaponids[0]]=0;
1069 weapons.firstfree[victim->weaponids[0]]=1;
1070 weapons.physics[victim->weaponids[0]]=1;
1071 victim->num_weapons--;
1072 if(victim->num_weapons){
1073 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1074 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1077 victim->weaponactive=-1;
1078 for(int j=0;j<numplayers;j++){
1079 player[j].wentforweapon=0;
1082 targetanimation=swordslashreversedanim;
1083 currentanimation=swordslashreversedanim;
1084 victim->currentanimation=swordslashreversalanim;
1085 victim->targetanimation=swordslashreversalanim;
1087 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1088 if(victim->weaponactive!=-1){
1089 victim->throwtogglekeydown=1;
1090 weapons.owner[victim->weaponids[0]]=-1;
1091 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1092 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1093 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1094 weapons.missed[victim->weaponids[0]]=1;
1095 weapons.freetime[victim->weaponids[0]]=0;
1096 weapons.firstfree[victim->weaponids[0]]=1;
1097 weapons.physics[victim->weaponids[0]]=1;
1098 victim->num_weapons--;
1099 if(victim->num_weapons){
1100 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1101 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1104 victim->weaponactive=-1;
1105 for(int j=0;j<numplayers;j++){
1106 player[j].wentforweapon=0;
1109 targetanimation=knifeslashreversedanim;
1110 currentanimation=knifeslashreversedanim;
1111 victim->currentanimation=knifeslashreversalanim;
1112 victim->targetanimation=knifeslashreversalanim;
1114 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1115 victim->targettilt2=targettilt2;
1116 victim->currentframe=currentframe;
1117 victim->targetframe=targetframe;
1118 victim->target=target;
1120 victim->oldcoords=victim->coords;
1121 victim->coords=coords;
1122 victim->targetrotation=targetrotation;
1123 victim->rotation=targetrotation;
1124 victim->victim=this;
1126 if(targetanimation==winduppunchanim){
1127 targetanimation=winduppunchblockedanim;
1128 victim->targetanimation=blockhighleftanim;
1129 victim->targetframe=1;
1131 victim->victim=this;
1132 victim->targetrotation=targetrotation+180;
1134 if(targetanimation==wolfslapanim){
1135 targetanimation=winduppunchblockedanim;
1136 victim->targetanimation=blockhighleftanim;
1137 victim->targetframe=1;
1139 victim->victim=this;
1140 victim->targetrotation=targetrotation+180;
1142 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1143 targetanimation=swordslashparriedanim;
1145 victim->parriedrecently=0;
1146 victim->targetanimation=swordslashparryanim;
1147 victim->targetframe=1;
1149 victim->victim=this;
1150 victim->targetrotation=targetrotation+180;
1152 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1155 gLoc[0]=victim->coords.x;
1156 gLoc[1]=victim->coords.y;
1157 gLoc[2]=victim->coords.z;
1161 if(victim->weaponactive!=-1){
1162 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1163 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1164 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1166 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, TRUE);
1167 FSOUND_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1168 FSOUND_SetVolume(channels[swordstaffsound], 512);
1169 FSOUND_SetPaused(channels[swordstaffsound], FALSE);
1172 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, TRUE);
1173 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1174 FSOUND_SetVolume(channels[metalhitsound], 512);
1175 FSOUND_SetPaused(channels[metalhitsound], FALSE);
1179 victim->Puff(righthand);
1181 victim->targetframe=0;
1182 victim->targetanimation=staggerbackhighanim;
1183 victim->targetrotation=targetrotation+180;
1185 weapons.owner[victim->weaponids[0]]=-1;
1186 aim=DoRotation(facing,0,90,0)*21;
1188 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1189 weapons.tipvelocity[victim->weaponids[0]]=aim;
1190 weapons.missed[victim->weaponids[0]]=1;
1191 weapons.hitsomething[victim->weaponids[0]]=0;
1192 weapons.freetime[victim->weaponids[0]]=0;
1193 weapons.firstfree[victim->weaponids[0]]=1;
1194 weapons.physics[victim->weaponids[0]]=1;
1195 victim->num_weapons--;
1196 if(victim->num_weapons){
1197 victim->weaponids[0]=victim->weaponids[num_weapons];
1198 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1200 victim->weaponactive=-1;
1201 for(int i=0;i<numplayers;i++){
1202 player[i].wentforweapon=0;
1209 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, TRUE);
1210 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1211 FSOUND_SetVolume(channels[metalhitsound], 512);
1212 FSOUND_SetPaused(channels[metalhitsound], FALSE);*/
1215 if(abs(Random()%20)==0){
1224 if(weaponactive!=-1){
1225 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1226 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1227 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1229 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, TRUE);
1230 FSOUND_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1231 FSOUND_SetVolume(channels[swordstaffsound], 512);
1232 FSOUND_SetPaused(channels[swordstaffsound], FALSE);
1235 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, TRUE);
1236 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1237 FSOUND_SetVolume(channels[metalhitsound], 512);
1238 FSOUND_SetPaused(channels[metalhitsound], FALSE);
1246 targetanimation=staggerbackhighanim;
1247 targetrotation=targetrotation+180;
1249 weapons.owner[weaponids[0]]=-1;
1250 aim=DoRotation(facing,0,90,0)*21;
1252 weapons.velocity[weaponids[0]]=aim*-.2;
1253 weapons.tipvelocity[weaponids[0]]=aim;
1254 weapons.hitsomething[weaponids[0]]=0;
1255 weapons.missed[weaponids[0]]=1;
1256 weapons.freetime[weaponids[0]]=0;
1257 weapons.firstfree[weaponids[0]]=1;
1258 weapons.physics[weaponids[0]]=1;
1261 weaponids[0]=weaponids[num_weapons];
1262 if(weaponstuck==num_weapons)weaponstuck=0;
1265 for(int i=0;i<numplayers;i++){
1266 player[i].wentforweapon=0;
1270 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, TRUE);
1271 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1272 FSOUND_SetVolume(channels[metalhitsound], 512);
1273 FSOUND_SetPaused(channels[metalhitsound], FALSE);*/
1277 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1278 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1279 //victim->targetanimation=sweepanim;
1280 victim->targetanimation=dodgebackanim;
1281 victim->targetframe=0;
1283 //victim->velocity=0;
1286 rotatetarget=coords-victim->coords;
1287 Normalise(&rotatetarget);
1288 victim->targetrotation=-asin(0-rotatetarget.x);
1289 victim->targetrotation*=360/6.28;
1290 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1292 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1294 victim->lastattack3=victim->lastattack2;
1295 victim->lastattack2=victim->lastattack;
1296 victim->lastattack=victim->targetanimation;
1300 victim->targetanimation=sweepanim;
1301 victim->targetframe=0;
1305 rotatetarget=coords-victim->coords;
1306 Normalise(&rotatetarget);
1307 victim->targetrotation=-asin(0-rotatetarget.x);
1308 victim->targetrotation*=360/6.28;
1309 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1311 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1313 victim->lastattack3=victim->lastattack2;
1314 victim->lastattack2=victim->lastattack;
1315 victim->lastattack=victim->targetanimation;
1322 if(aitype!=playercontrolled)feint=0;
1323 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1324 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1325 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1327 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1331 void Person::DoDamage(float howmuch){
1332 if(tutoriallevel!=1)damage+=howmuch/power;
1333 if(id!=0)damagedealt+=howmuch/power;
1334 if(id==0)damagetaken+=howmuch/power;
1336 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1337 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1338 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1339 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1340 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1342 if(id==0)camerashake+=howmuch/100;
1343 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1344 if(blackout>1)blackout=1;
1346 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1347 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1348 if(abs(Random()%2)==0){aitype=gethelptype;
1351 else aitype=attacktypecutoff;
1355 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1358 for(int i=0;i<skeleton.num_joints; i++){
1359 if(!skeleton.free)flatvelocity2=velocity;
1360 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1361 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1362 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1363 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1364 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1365 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1366 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1367 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1368 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1379 PlaySoundEx( splattersound, samp[splattersound], NULL, TRUE);
1380 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
1381 FSOUND_SetVolume(channels[splattersound], 256);
1382 FSOUND_SetPaused(channels[splattersound], FALSE);
1391 if(!dead&&creature==wolftype){
1400 if(tutoriallevel!=1||id==0)
1401 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1412 if(creature==wolftype){
1413 int i=abs(Random()%2);
1414 if(i==0)whichsound=snarlsound;
1415 if(i==1)whichsound=snarl2sound;
1416 envsound[numenvsounds]=coords;
1417 envsoundvol[numenvsounds]=16;
1418 envsoundlife[numenvsounds]=.4;
1421 if(creature==rabbittype){
1422 int i=abs(Random()%2);
1423 if(i==0)whichsound=rabbitpainsound;
1424 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1425 envsound[numenvsounds]=coords;
1426 envsoundvol[numenvsounds]=16;
1427 envsoundlife[numenvsounds]=.4;
1429 //if(i==2)whichsound=rabbitpain2sound;
1433 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
1434 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
1435 FSOUND_SetVolume(channels[whichsound], 512);
1436 FSOUND_SetPaused(channels[whichsound], FALSE);
1441 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1442 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1445 void Person::DoHead(){
1446 static XYZ rotatearound;
1448 static float lookspeed=500;
1450 if(!freeze&&!winfreeze&&(!mainmenu||!gamestarted)){
1453 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1454 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1456 while(targetheadrotation>180)targetheadrotation-=360;
1457 while(targetheadrotation<-180)targetheadrotation+=360;
1459 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1460 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1461 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1462 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1464 if(targetheadrotation2>120)targetheadrotation2=120;
1465 if(targetheadrotation2<-120)targetheadrotation2=-120;
1466 if(targetheadrotation>120)targetheadrotation=120;
1467 if(targetheadrotation<-120)targetheadrotation=-120;
1469 if(!isIdle())targetheadrotation2=0;
1471 if(targetheadrotation>80)targetheadrotation=80;
1472 if(targetheadrotation<-80)targetheadrotation=-80;
1473 if(targetheadrotation2>50)targetheadrotation2=50;
1474 if(targetheadrotation2<-50)targetheadrotation2=-50;
1477 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1478 else if(headrotation>targetheadrotation){
1479 headrotation-=multiplier*lookspeed;
1481 else if(headrotation<targetheadrotation){
1482 headrotation+=multiplier*lookspeed;
1485 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1486 else if(headrotation2>targetheadrotation2){
1487 headrotation2-=multiplier*lookspeed/2;
1489 else if(headrotation2<targetheadrotation2){
1490 headrotation2+=multiplier*lookspeed/2;
1493 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1494 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1498 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1499 facing=DoRotation(facing,headrotation2*.4,0,0);
1500 facing=DoRotation(facing,0,headrotation*.4,0);
1503 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1504 facing=DoRotation(facing,headrotation2*.8,0,0);
1505 facing=DoRotation(facing,0,headrotation*.8,0);
1508 if(targetanimation==walkanim){
1509 facing=DoRotation(facing,headrotation2*.6,0,0);
1510 facing=DoRotation(facing,0,headrotation*.6,0);
1513 skeleton.specialforward[0]=facing;
1514 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1516 for(i=0;i<skeleton.num_muscles;i++){
1517 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1519 skeleton.FindRotationMuscle(i,targetanimation);
1525 void Person::RagDoll(bool checkcollision){
1530 if(id==0)numfalls++;
1531 if(id==0&&isFlip())numflipfail++;
1537 facing=DoRotation(facing,0,rotation,0);
1539 skeleton.freetime=0;
1541 skeleton.longdead=0;
1547 skeleton.freefall=1;
1549 if(!isnormal(velocity.x))velocity.x=0;
1550 if(!isnormal(velocity.y))velocity.y=0;
1551 if(!isnormal(velocity.z))velocity.z=0;
1552 if(!isnormal(rotation))rotation=0;
1553 if(!isnormal(coords.x))coords=0;
1554 if(!isnormal(tilt))tilt=0;
1555 if(!isnormal(tilt2))tilt2=0;
1557 for(i=0;i<skeleton.num_joints;i++){
1558 skeleton.joints[i].delay=0;
1559 skeleton.joints[i].locked=0;
1560 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1561 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1562 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1563 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1564 skeleton.joints[i].position.y+=.1;
1565 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1566 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1569 for(i=0;i<skeleton.num_joints;i++){
1570 skeleton.joints[i].velocity=0;
1571 skeleton.joints[i].velchange=0;
1573 skeleton.DoConstraints(&coords,&scale);
1574 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1576 skeleton.DoConstraints(&coords,&scale);
1577 skeleton.DoConstraints(&coords,&scale);
1578 skeleton.DoConstraints(&coords,&scale);
1579 skeleton.DoConstraints(&coords,&scale);
1582 speed=animation[targetanimation].speed[targetframe]*2;
1583 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1584 speed=animation[currentanimation].speed[currentframe]*2;
1586 if(transspeed)speed=transspeed*2;
1590 for(i=0;i<skeleton.num_joints;i++){
1591 if((animation[currentanimation].attack!=reversed||currentanimation==swordslashreversedanim)&¤tanimation!=rabbitkickanim&&!isLanding()&&!wasLanding()&&animation[currentanimation].height==animation[targetanimation].height)skeleton.joints[i].velocity=velocity/scale+facing*5+DoRotation(DoRotation(DoRotation((animation[targetanimation].position[i][targetframe]-animation[currentanimation].position[i][currentframe])*speed,0,0,tilt),tilt2,0,0),0,rotation,0);
1592 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1593 change.x=(float)(Random()%100)/100;
1594 change.y=(float)(Random()%100)/100;
1595 change.z=(float)(Random()%100)/100;
1596 skeleton.joints[i].velocity+=change;
1597 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1599 change.x=(float)(Random()%100)/100;
1600 change.y=(float)(Random()%100)/100;
1601 change.z=(float)(Random()%100)/100;
1602 skeleton.joints[i].velchange+=change;
1603 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1613 for(j=0;j<skeleton.num_joints;j++){
1614 average+=skeleton.joints[j].position;
1618 coords+=average*scale;
1619 for(j=0;j<skeleton.num_joints;j++){
1620 skeleton.joints[j].position-=average;
1623 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1624 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1625 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1626 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1627 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1630 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1631 coords.x=lowpoint.x;
1632 coords.z=lowpoint.z;
1641 for(i=0;i<skeleton.num_joints;i++){
1642 velocity+=skeleton.joints[i].velocity*scale;
1644 velocity/=skeleton.num_joints;
1647 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1648 weapons.owner[weaponids[0]]=-1;
1649 weapons.hitsomething[weaponids[0]]=0;
1650 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1651 weapons.velocity[weaponids[0]].x+=.01;
1652 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1653 weapons.missed[weaponids[0]]=1;
1654 weapons.freetime[weaponids[0]]=0;
1655 weapons.firstfree[weaponids[0]]=1;
1656 weapons.physics[weaponids[0]]=1;
1659 weaponids[0]=weaponids[num_weapons];
1660 if(weaponstuck==num_weapons)weaponstuck=0;
1663 for(i=0;i<numplayers;i++){
1664 player[i].wentforweapon=0;
1669 targetanimation=bounceidleanim;
1670 currentanimation=bounceidleanim;
1678 void Person::FootLand(int which, float opacity){
1679 static XYZ terrainlight;
1680 static XYZ footvel,footpoint;
1681 if(opacity>=1||skiddelay<=0)
1685 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1686 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1687 //footpoint.y=coords.y;
1688 if(findDistancefast(&footpoint,&viewer))sprites.MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1690 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1692 if(footvel.y<.8)footvel.y=.8;
1693 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1694 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1695 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1696 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1697 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1698 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1700 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1702 if(footvel.y<.8)footvel.y=.8;
1703 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1704 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1705 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1706 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1707 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);
1709 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1711 if(footvel.y<.8)footvel.y=.8;
1712 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1713 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1714 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1715 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1716 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);
1717 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1719 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1722 if(footvel.y<.8)footvel.y=.8;
1723 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1724 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1725 //footpoint.y=coords.y;
1726 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1730 void Person::Puff(int whichlabel){
1731 static XYZ footvel,footpoint;
1734 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1735 sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1740 HitStruct Person::BulletCollideWithPlayer(XYZ start, XYZ end){
1742 XYZ tempbulletloc[2];
1752 HitStruct hitstruct;
1753 hitstruct.collision=0;
1754 //Make bounding sphere
1757 for(int j=0;j<skeleton.num_joints;j++){
1758 average.x=average.x+skeleton.joints[j].position.x;
1759 average.y=average.y+skeleton.joints[j].position.y;
1760 average.z=average.z+skeleton.joints[j].position.z;
1763 average=average/howmany;
1765 for(int j=0;j<skeleton.num_joints;j++){
1766 if(findDistancefast(average,skeleton.joints[j].position)>distancemax){
1767 distancemax=findDistancefast(average,skeleton.joints[j].position);
1770 distancemax=fast_sqrt(distancemax);
1771 //Collide with player
1772 if(skeleton.free<1){
1775 if(rotation)start=DoRotation(start,0,-rotation,0);
1776 if(rotation)end=DoRotation(end,0,-rotation,0);
1778 tempbulletloc[0]=start;
1779 tempbulletloc[1]=end;
1780 if(sphere_line_intersection(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z,
1781 tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z,
1782 average.x, average.y, average.z, distancemax)){
1783 for(int j=0;j<skeleton.num_joints;j++){
1784 if(skeleton.joints[j].hasparent&&skeleton.joints[j].visible){
1785 tempbulletloc[0]=start;
1786 tempbulletloc[1]=end;
1789 glScalef(1,1/skeleton.joints[j].length,1);
1790 glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
1791 glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
1792 glTranslatef( (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
1793 (-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
1794 (-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
1795 glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
1796 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1797 tempbulletloc[0].x=M[12];
1798 tempbulletloc[0].y=M[13];
1799 tempbulletloc[0].z=M[14];
1803 glScalef(1,1/skeleton.joints[j].length,1);
1804 glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
1805 glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
1806 glTranslatef( (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
1807 (-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
1808 (-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
1809 glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
1810 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1811 tempbulletloc[1].x=M[12];
1812 tempbulletloc[1].y=M[13];
1813 tempbulletloc[1].z=M[14];
1815 collide=skeletonmodels[skeleton.joints[j].modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
1820 glTranslatef( (skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2,
1821 (skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2,
1822 (skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2);
1823 glRotatef(-skeleton.joints[j].rotate1+90,0,1,0);
1824 glRotatef(-skeleton.joints[j].rotate2+90,0,0,1);
1825 glScalef(1,skeleton.joints[j].length,1);
1826 glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
1827 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1828 collisionpoint.x=M[12];
1829 collisionpoint.y=M[13];
1830 collisionpoint.z=M[14];
1832 hitstruct.collision=1;
1833 hitstruct.hitlocation=collisionpoint;
1834 hitstruct.joint1=&skeleton.joints[j];
1835 hitstruct.joint2=skeleton.joints[j].parent;
1839 for(int j=0;j<skeleton.num_muscles;j++){
1840 if(skeleton.muscles[j].visible){
1841 tempbulletloc[0]=start;
1842 tempbulletloc[1]=end;
1845 glScalef(1,1/skeleton.muscles[j].length,1);
1846 glRotatef(skeleton.muscles[j].rotate3,0,1,0);
1847 glRotatef(skeleton.muscles[j].rotate2-90,0,0,1);
1848 glRotatef(skeleton.muscles[j].rotate1-90,0,1,0);
1849 glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2),
1850 (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2),
1851 (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2));
1853 glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
1854 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1855 tempbulletloc[0].x=M[12];
1856 tempbulletloc[0].y=M[13];
1857 tempbulletloc[0].z=M[14];
1861 glScalef(1,1/skeleton.muscles[j].length,1);
1862 glRotatef(skeleton.muscles[j].rotate3,0,1,0);
1863 glRotatef(skeleton.muscles[j].rotate2-90,0,0,1);
1864 glRotatef(skeleton.muscles[j].rotate1-90,0,1,0);
1866 glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2),
1867 (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2),
1868 (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2));
1869 glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
1870 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1871 tempbulletloc[1].x=M[12];
1872 tempbulletloc[1].y=M[13];
1873 tempbulletloc[1].z=M[14];
1875 collide=skeletonmodels[skeleton.muscles[j].parent1->modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
1880 glTranslatef( (skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2,
1881 (skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2,
1882 (skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2);
1883 glRotatef(-skeleton.muscles[j].rotate1+90,0,1,0);
1884 glRotatef(-skeleton.muscles[j].rotate2+90,0,0,1);
1885 glRotatef(-skeleton.muscles[j].rotate3,0,1,0);
1886 glScalef(1,findDistance(skeleton.muscles[j].parent1->position,skeleton.muscles[j].parent2->position),1);
1887 glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
1888 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1889 collisionpoint.x=M[12];
1890 collisionpoint.y=M[13];
1891 collisionpoint.z=M[14];
1893 hitstruct.collision=1;
1894 hitstruct.hitlocation=collisionpoint;
1895 hitstruct.joint1=skeleton.muscles[j].parent1;
1896 hitstruct.joint2=skeleton.muscles[j].parent2;
1901 if(skeleton.free<1){
1902 if(rotation)hitstruct.hitlocation=DoRotation(hitstruct.hitlocation,0,rotation,0);
1903 hitstruct.hitlocation=hitstruct.hitlocation+coords;
1908 void Person::DoAnimations(){
1911 static float oldtarget;
1913 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1915 if(targetanimation==tempanim||currentanimation==tempanim){
1916 animation[tempanim]=tempanimation;
1918 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1929 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1930 FSOUND_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1932 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1933 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1935 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1940 targfacing=DoRotation(targfacing,0,targetrotation,0);
1942 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1943 else targetanimation=backflipanim;
1944 crouchtogglekeydown=1;
1948 if(id==0)numflipped++;
1951 if(animation[targetanimation].attack!=reversed)feint=0;
1952 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1953 crouchtogglekeydown=0;
1954 if(aitype==playercontrolled)feint=0;
1958 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1959 if(!isFlip())crouchtogglekeydown=1;
1963 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1964 if(detail)normalsupdatedelay=0;
1968 if(targetanimation==rollanim&&targetframe==3&&onfire){
1978 PlaySoundEx( fireendsound, samp[fireendsound], NULL, TRUE);
1979 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1980 FSOUND_SetVolume(channels[fireendsound], 256);
1981 FSOUND_SetPaused(channels[fireendsound], FALSE);
1982 FSOUND_SetPaused(channels[stream_firesound], TRUE);
1986 if(targetanimation==rabbittacklinganim&&targetframe==1){
1987 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1988 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1989 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1990 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1991 else victim->targetanimation=rabbittackledfrontanim;
1992 victim->targetframe=2;
1994 victim->rotation=rotation;
1995 victim->targetrotation=rotation;
1996 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1997 //victim->DoDamage(30);
1998 if(creature==wolftype){
2002 gLoc[0]=victim->coords.x;
2003 gLoc[1]=victim->coords.y;
2004 gLoc[2]=victim->coords.z;
2008 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, TRUE);
2009 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2010 FSOUND_SetVolume(channels[clawslicesound], 128);
2011 FSOUND_SetPaused(channels[clawslicesound], FALSE);
2013 victim->DoBloodBig(1/victim->armorhead,210);
2019 if(victim->aitype==gethelptype)bonusvalue=50;
2024 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
2025 if(weapons.type[weaponids[0]]==knife){
2026 if(weaponactive==-1)weaponactive=0;
2027 else if(weaponactive==0)weaponactive=-1;
2029 if(weaponactive==-1){
2039 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, TRUE);
2040 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2041 FSOUND_SetVolume(channels[knifesheathesound], 128);
2042 FSOUND_SetPaused(channels[knifesheathesound], FALSE);
2044 if(weaponactive!=-1){
2054 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
2055 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2056 FSOUND_SetVolume(channels[knifedrawsound], 128);
2057 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
2060 drawtogglekeydown=1;
2063 if(tutoriallevel!=1||id==0)
2064 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
2075 if(terrain.getOpacity(coords.x,coords.z)<.2){
2076 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
2077 else whichsound=footstepsound2;
2078 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
2079 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
2080 if(animation[targetanimation].label[targetframe]==3&&isRun()){
2086 if(terrain.getOpacity(coords.x,coords.z)>=.2){
2087 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
2088 else whichsound=footstepsound4;
2092 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
2093 else whichsound=footstepsound4;
2095 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
2096 if(animation[targetanimation].attack!=neutral){
2098 if(i==0)whichsound=lowwhooshsound;
2099 if(i==1)whichsound=midwhooshsound;
2100 if(i==2)whichsound=highwhooshsound;
2102 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2104 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2105 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
2107 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
2108 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
2109 if(whichsound!=knifeswishsound)FSOUND_SetVolume(channels[whichsound], 128);
2110 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))FSOUND_SetVolume(channels[whichsound], 256);
2111 if(whichsound==knifeswishsound)FSOUND_SetVolume(channels[whichsound], 512);
2112 FSOUND_SetPaused(channels[whichsound], FALSE);
2115 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
2116 envsound[numenvsounds]=coords;
2117 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
2118 else envsoundvol[numenvsounds]=6;
2119 envsoundlife[numenvsounds]=.4;
2123 if(animation[targetanimation].label[targetframe]==3){
2125 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
2126 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
2127 FSOUND_SetVolume(channels[whichsound], 128);
2128 FSOUND_SetPaused(channels[whichsound], FALSE);
2133 if(tutoriallevel!=1||id==0)
2135 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
2136 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
2146 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
2147 if(animation[targetanimation].attack!=neutral){
2149 if(creature==rabbittype){
2150 if(i==0)whichsound=rabbitattacksound;
2151 if(i==1)whichsound=rabbitattack2sound;
2152 if(i==2)whichsound=rabbitattack3sound;
2153 if(i==3)whichsound=rabbitattack4sound;
2155 if(creature==wolftype){
2156 if(i==0)whichsound=barksound;
2157 if(i==1)whichsound=bark2sound;
2158 if(i==2)whichsound=bark3sound;
2159 if(i==3)whichsound=barkgrowlsound;
2163 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2165 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2166 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
2169 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
2170 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
2171 FSOUND_SetVolume(channels[whichsound], 512);
2172 FSOUND_SetPaused(channels[whichsound], FALSE);
2178 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
2184 currentoffset=targetoffset;
2185 targetframe=currentframe;
2186 currentanimation=targetanimation;
2189 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
2190 for(i=0;i<weapons.numweapons;i++){
2191 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
2192 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
2193 if(findDistancefast(&coords,&weapons.position[i])>=1){
2194 if(weapons.type[i]!=staff){
2203 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
2204 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2205 FSOUND_SetVolume(channels[knifedrawsound], 128);
2206 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
2210 weapons.owner[i]=id;
2212 weaponids[num_weapons]=weaponids[0];
2221 static bool willwork;
2222 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2223 for(i=0;i<weapons.numweapons;i++){
2225 if(weapons.owner[i]!=-1)
2226 if(player[weapons.owner[i]].weaponstuck!=-1)
2227 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2228 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2229 if((/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)||(hasvictim&&weapons.owner[i]==victim->id&&victim->skeleton.free))
2230 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2231 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2241 if(weapons.owner[i]!=-1)
2242 if(victim->weaponstuck!=-1){
2243 if(victim->weaponids[victim->weaponstuck]==i){
2248 if(weapons.type[i]!=staff){
2249 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
2250 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2251 FSOUND_SetVolume(channels[knifedrawsound], 128);
2252 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
2256 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, TRUE);
2257 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2258 FSOUND_SetVolume(channels[fleshstabremovesound], 128);
2259 FSOUND_SetPaused(channels[fleshstabremovesound], FALSE);
2262 if(weapons.owner[i]!=-1){
2264 victim=&player[weapons.owner[i]];
2265 if(victim->num_weapons==1)victim->num_weapons=0;
2266 else victim->num_weapons=1;
2268 //victim->weaponactive=-1;
2269 victim->skeleton.longdead=0;
2270 victim->skeleton.free=1;
2271 victim->skeleton.broken=0;
2273 for(int j=0;j<victim->skeleton.num_joints;j++){
2274 victim->skeleton.joints[j].velchange=0;
2275 victim->skeleton.joints[j].locked=0;
2281 Normalise(&relative);
2282 XYZ footvel,footpoint;
2284 footpoint=weapons.position[i];
2285 if(victim->weaponstuck!=-1){
2286 if(victim->weaponids[victim->weaponstuck]==i){
2287 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2288 weapons.bloody[i]=2;
2289 weapons.blooddrip[i]=5;
2290 victim->weaponstuck=-1;
2293 if(victim->num_weapons>0){
2294 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2295 if(victim->weaponids[0]==i)
2296 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2299 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2300 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2301 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2302 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2304 weapons.owner[i]=id;
2306 weaponids[num_weapons]=weaponids[0];
2315 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2316 if(weaponactive==-1)weaponactive=0;
2317 else if(weaponactive==0){
2321 buffer=weaponids[0];
2322 weaponids[0]=weaponids[1];
2323 weaponids[1]=buffer;
2326 if(weaponactive==-1){
2336 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, TRUE);
2337 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2338 FSOUND_SetVolume(channels[knifesheathesound], 128);
2339 FSOUND_SetPaused(channels[knifesheathesound], FALSE);
2341 if(weaponactive!=-1){
2351 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
2352 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2353 FSOUND_SetVolume(channels[knifedrawsound], 128);
2354 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
2359 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2360 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2361 Normalise(&rotatetarget);
2362 targetrotation=-asin(0-rotatetarget.x);
2363 targetrotation*=360/6.28;
2364 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2366 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2367 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2372 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2374 if(findDistancefast(&victim->coords,&/*player[i].*/coords)<5&&victim->aitype==gethelptype&&(attackkeydown)&&!victim->skeleton.free&&victim->isRun()&&victim->runninghowlong>=1)dojumpattack=1; if(!hostile)dojumpattack=0;
2376 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2377 targetanimation=rabbittackleanim;
2388 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
2389 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2390 FSOUND_SetVolume(channels[jumpsound], 128);
2391 FSOUND_SetPaused(channels[jumpsound], FALSE);
2400 Normalise(&targetloc);
2402 for(i=0;i<numplayers;i++){
2404 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2405 closestdist=findDistancefast(&targetloc,&player[i].coords);
2410 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2412 victim=&player[closestid];
2413 coords=victim->coords;
2414 currentanimation=rabbittacklinganim;
2415 targetanimation=rabbittacklinganim;
2419 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2420 rotatetarget=coords-victim->coords;
2421 Normalise(&rotatetarget);
2422 targetrotation=-asin(0-rotatetarget.x);
2423 targetrotation*=360/6.28;
2424 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2426 if(targetanimation!=rabbitrunninganim){
2436 PlaySoundEx( jumpsound, samp[jumpsound], NULL, TRUE);
2437 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2438 FSOUND_SetVolume(channels[jumpsound], 128);
2439 FSOUND_SetPaused(channels[jumpsound], FALSE);
2445 float damagemult=1*power;
2446 if(creature==wolftype)damagemult=2.5*power;
2447 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2448 //if(onfire)damagemult=3;
2449 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2450 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2451 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2453 if(id==0)camerashake+=.4;
2454 if(Random()%2||creature==wolftype){
2457 if(creature==wolftype)DoBloodBig(0,250);
2461 gLoc[0]=victim->coords.x;
2462 gLoc[1]=victim->coords.y;
2463 gLoc[2]=victim->coords.z;
2467 if(tutoriallevel!=1){
2468 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
2469 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2470 FSOUND_SetVolume(channels[heavyimpactsound], 128);
2471 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
2473 if(creature==wolftype){
2474 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, TRUE);
2475 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2476 FSOUND_SetVolume(channels[clawslicesound], 128);
2477 FSOUND_SetPaused(channels[clawslicesound], FALSE);
2479 victim->DoBloodBig(2/victim->armorhead,175);
2483 relative=victim->coords-coords;
2485 Normalise(&relative);
2486 relative=DoRotation(relative,0,-90,0);
2487 for(i=0;i<victim->skeleton.num_joints;i++){
2488 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2490 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2493 victim->DoDamage(damagemult*100/victim->protectionhead);
2501 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2502 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2504 if(id==0)camerashake+=.4;
2505 if(Random()%2||creature==wolftype){
2507 if(creature==wolftype)DoBloodBig(0,235);
2511 gLoc[0]=victim->coords.x;
2512 gLoc[1]=victim->coords.y;
2513 gLoc[2]=victim->coords.z;
2517 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, TRUE);
2518 FSOUND_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2519 FSOUND_SetVolume(channels[whooshhitsound], 512);
2520 FSOUND_SetPaused(channels[whooshhitsound], FALSE);
2521 if(creature==wolftype){
2522 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, TRUE);
2523 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2524 FSOUND_SetVolume(channels[clawslicesound], 128);
2525 FSOUND_SetPaused(channels[clawslicesound], FALSE);
2527 victim->DoBloodBig(2,175);
2531 relative=victim->coords-coords;
2533 Normalise(&relative);
2535 Normalise(&relative);
2536 relative=DoRotation(relative,0,90,0);
2537 for(i=0;i<victim->skeleton.num_joints;i++){
2538 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2540 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2543 victim->DoDamage(damagemult*50/victim->protectionhead);
2547 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2548 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2550 if(id==0)camerashake+=.4;
2555 gLoc[0]=victim->coords.x;
2556 gLoc[1]=victim->coords.y;
2557 gLoc[2]=victim->coords.z;
2561 if(tutoriallevel!=1){
2562 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
2563 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2564 FSOUND_SetVolume(channels[heavyimpactsound], 160);
2565 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
2567 if(creature==wolftype){
2568 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, TRUE);
2569 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2570 FSOUND_SetVolume(channels[clawslicesound], 128);
2571 FSOUND_SetPaused(channels[clawslicesound], FALSE);
2573 victim->DoBloodBig(2/victim->armorhead,175);
2579 Normalise(&relative);
2580 relative=DoRotation(relative,0,-90,0);
2581 for(i=0;i<victim->skeleton.num_joints;i++){
2582 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2584 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2587 victim->DoDamage(damagemult*150/victim->protectionhead);
2589 if(victim->damage>victim->damagetolerance){
2602 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2603 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2605 if(id==0)camerashake+=.4;
2610 gLoc[0]=victim->coords.x;
2611 gLoc[1]=victim->coords.y;
2612 gLoc[2]=victim->coords.z;
2616 if(tutoriallevel!=1){
2617 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
2618 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2619 FSOUND_SetVolume(channels[heavyimpactsound], 160);
2620 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
2622 if(creature==wolftype){
2623 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, TRUE);
2624 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2625 FSOUND_SetVolume(channels[clawslicesound], 128);
2626 FSOUND_SetPaused(channels[clawslicesound], FALSE);
2628 victim->DoBloodBig(2/victim->armorhead,175);
2634 Normalise(&relative);
2635 relative=DoRotation(relative,0,90,0);
2636 for(i=0;i<victim->skeleton.num_joints;i++){
2637 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2639 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2642 victim->DoDamage(damagemult*150/victim->protectionhead);
2644 if(victim->damage>victim->damagetolerance){
2657 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2658 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2660 if(id==0)camerashake+=.4;
2667 gLoc[0]=victim->coords.x;
2668 gLoc[1]=victim->coords.y;
2669 gLoc[2]=victim->coords.z;
2673 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, TRUE);
2674 FSOUND_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2675 FSOUND_SetVolume(channels[whooshhitsound], 512);
2676 FSOUND_SetPaused(channels[whooshhitsound], FALSE);
2679 relative=victim->coords-coords;
2681 Normalise(&relative);
2682 for(i=0;i<victim->skeleton.num_joints;i++){
2683 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2685 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2688 victim->DoDamage(damagemult*50/victim->protectionhead);
2692 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2693 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2695 if(id==0)camerashake+=.2;
2698 gLoc[0]=victim->coords.x;
2699 gLoc[1]=victim->coords.y;
2700 gLoc[2]=victim->coords.z;
2704 /*PlaySoundEx( landsound2, samp[landsound2], NULL, TRUE);
2705 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
2706 FSOUND_SetVolume(channels[landsound2], 128);
2707 FSOUND_SetPaused(channels[landsound2], FALSE);
2709 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
2710 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2711 FSOUND_SetVolume(channels[movewhooshsound], 128);
2712 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
2714 victim->skeleton.longdead=0;
2715 victim->skeleton.free=1;
2716 victim->skeleton.broken=0;
2717 victim->skeleton.spinny=1;
2719 for(i=0;i<victim->skeleton.num_joints;i++){
2720 victim->skeleton.joints[i].velchange=0;
2721 victim->skeleton.joints[i].delay=0;
2722 victim->skeleton.joints[i].locked=0;
2723 //victim->skeleton.joints[i].velocity=0;
2729 Normalise(&relative);
2730 for(i=0;i<victim->skeleton.num_joints;i++){
2731 victim->skeleton.joints[i].velocity.y=relative.y*10;
2732 victim->skeleton.joints[i].position.y+=relative.y*.3;
2733 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2734 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2736 victim->Puff(abdomen);
2737 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2741 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2742 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2744 if(id==0)camerashake+=.4;
2753 if(tutoriallevel!=1){
2754 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
2755 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2756 FSOUND_SetVolume(channels[heavyimpactsound], 128);
2757 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
2760 relative=victim->coords-coords;
2762 Normalise(&relative);
2763 for(i=0;i<victim->skeleton.num_joints;i++){
2764 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2766 victim->Puff(abdomen);
2767 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2771 victim->DoDamage(damagemult*500/victim->protectionhigh);
2772 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2776 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2777 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2779 if(id==0)camerashake+=.4;
2788 if(tutoriallevel!=1){
2789 PlaySoundEx( thudsound, samp[thudsound], NULL, TRUE);
2790 FSOUND_3D_SetAttributes(channels[thudsound], gLoc, vel);
2791 FSOUND_SetVolume(channels[thudsound], 400);
2792 FSOUND_SetPaused(channels[thudsound], FALSE);
2795 victim->skeleton.longdead=0;
2796 victim->skeleton.free=1;
2797 victim->skeleton.broken=0;
2798 victim->skeleton.spinny=1;
2800 for(i=0;i<victim->skeleton.num_joints;i++){
2801 victim->skeleton.joints[i].velchange=0;
2802 //victim->skeleton.joints[i].delay=0;
2803 victim->skeleton.joints[i].locked=0;
2806 relative=victim->coords-coords;
2807 Normalise(&relative);
2809 Normalise(&relative);
2810 for(i=0;i<victim->skeleton.num_joints;i++){
2811 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2813 if(id==0&&!victim->dead){
2817 victim->Puff(abdomen);
2818 victim->DoDamage(damagemult*20/victim->protectionhigh);
2819 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2821 if(!victim->dead)staggerdelay=1.2;
2827 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2828 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2829 //if(id==0)camerashake+=.4;
2840 if(!victim->skeleton.free)hasvictim=0;
2843 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2844 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, TRUE);
2845 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2846 FSOUND_SetVolume(channels[knifesheathesound], 128);
2847 FSOUND_SetPaused(channels[knifesheathesound], FALSE);
2850 if(victim&&hasvictim){
2851 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2853 XYZ where,startpoint,endpoint,movepoint,colpoint;
2854 float rotationpoint;
2856 if(weapons.type[weaponids[weaponactive]]==knife){
2857 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2858 where-=victim->coords;
2859 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2866 if(weapons.type[weaponids[weaponactive]]==sword){
2867 where=weapons.position[weaponids[weaponactive]];
2868 where-=victim->coords;
2869 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2871 where=weapons.tippoint[weaponids[weaponactive]];
2872 where-=victim->coords;
2873 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2876 if(weapons.type[weaponids[weaponactive]]==staff){
2877 where=weapons.position[weaponids[weaponactive]];
2878 where-=victim->coords;
2879 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2881 where=weapons.tippoint[weaponids[weaponactive]];
2882 where-=victim->coords;
2883 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2888 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2891 if(victim->dead!=2){
2892 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2893 if(id==0&&!victim->dead){
2894 bonus=FinishedBonus;
2899 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2901 victim->skeleton.longdead=0;
2902 victim->skeleton.free=1;
2903 victim->skeleton.broken=0;
2905 for(i=0;i<victim->skeleton.num_joints;i++){
2906 victim->skeleton.joints[i].velchange=0;
2907 victim->skeleton.joints[i].locked=0;
2908 //victim->skeleton.joints[i].velocity=0;
2910 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, TRUE);
2911 FSOUND_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2912 FSOUND_SetVolume(channels[fleshstabsound], 128);
2913 FSOUND_SetPaused(channels[fleshstabsound], FALSE);
2916 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2917 weapons.blooddrip[weaponids[weaponactive]]+=5;
2918 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2922 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, TRUE);
2923 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2924 FSOUND_SetVolume(channels[knifesheathesound], 128);
2925 FSOUND_SetPaused(channels[knifesheathesound], FALSE);
2931 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2932 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2933 //if(id==0)camerashake+=.4;
2943 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
2944 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2945 FSOUND_SetVolume(channels[knifedrawsound], 128);
2946 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
2949 if(victim&&hasvictim){
2950 XYZ footvel,footpoint;
2952 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, TRUE);
2953 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2954 FSOUND_SetVolume(channels[fleshstabremovesound], 128);
2955 FSOUND_SetPaused(channels[fleshstabremovesound], FALSE);
2958 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2960 if(weapons.type[weaponids[weaponactive]]==sword){
2961 XYZ where,startpoint,endpoint,movepoint;
2962 float rotationpoint;
2965 where=weapons.position[weaponids[weaponactive]];
2966 where-=victim->coords;
2967 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2969 where=weapons.tippoint[weaponids[weaponactive]];
2970 where-=victim->coords;
2971 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2976 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2977 footpoint+=victim->coords;
2980 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2983 if(weapons.type[weaponids[weaponactive]]==staff){
2984 XYZ where,startpoint,endpoint,movepoint;
2985 float rotationpoint;
2988 where=weapons.position[weaponids[weaponactive]];
2989 where-=victim->coords;
2990 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2992 where=weapons.tippoint[weaponids[weaponactive]];
2993 where-=victim->coords;
2994 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2999 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
3000 footpoint+=victim->coords;
3003 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
3006 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
3008 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
3009 victim->skeleton.longdead=0;
3010 victim->skeleton.free=1;
3011 victim->skeleton.broken=0;
3013 for(i=0;i<victim->skeleton.num_joints;i++){
3014 victim->skeleton.joints[i].velchange=0;
3015 victim->skeleton.joints[i].locked=0;
3016 //victim->skeleton.joints[i].velocity=0;
3022 Normalise(&relative);
3023 //victim->Puff(abdomen);
3024 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
3026 if(victim->bloodloss<victim->damagetolerance){
3027 victim->bloodloss+=1000;
3031 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3035 if(!hasvictim&&onterrain){
3036 weapons.bloody[weaponids[weaponactive]]=0;
3037 weapons.blooddrip[weaponids[weaponactive]]=0;
3041 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
3042 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
3044 if(id==0)camerashake+=.4;
3051 gLoc[0]=victim->coords.x;
3052 gLoc[1]=victim->coords.y;
3053 gLoc[2]=victim->coords.z;
3057 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
3059 if(tutoriallevel!=1){
3060 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
3061 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3062 FSOUND_SetVolume(channels[heavyimpactsound], 128);
3063 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
3067 if(tutoriallevel!=1){
3068 PlaySoundEx( landsound2, samp[landsound2], NULL, TRUE);
3069 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
3070 FSOUND_SetVolume(channels[landsound2], 256);
3071 FSOUND_SetPaused(channels[landsound2], FALSE);
3075 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
3078 relative=victim->coords-coords;
3080 Normalise(&relative);
3081 for(i=0;i<victim->skeleton.num_joints;i++){
3082 victim->skeleton.joints[i].velocity=relative*30;
3084 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
3086 victim->targetframe=0;
3087 victim->targetanimation=staggerbackhardanim;
3088 victim->targetrotation=targetrotation+180;
3093 victim->Puff(abdomen);
3094 victim->DoDamage(damagemult*60/victim->protectionhigh);
3103 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
3104 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
3106 if(id==0)camerashake+=.4;
3109 gLoc[0]=victim->coords.x;
3110 gLoc[1]=victim->coords.y;
3111 gLoc[2]=victim->coords.z;
3115 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
3116 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
3117 if(tutoriallevel!=1){
3118 PlaySoundEx( thudsound, samp[thudsound], NULL, TRUE);
3119 FSOUND_3D_SetAttributes(channels[thudsound], gLoc, vel);
3120 FSOUND_SetVolume(channels[thudsound], 512);
3121 FSOUND_SetPaused(channels[thudsound], FALSE);
3124 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
3125 if(tutoriallevel!=1){
3126 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, TRUE);
3127 FSOUND_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3128 FSOUND_SetVolume(channels[whooshhitsound], 512);
3129 FSOUND_SetPaused(channels[whooshhitsound], FALSE);
3133 if(tutoriallevel!=1){
3134 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
3135 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3136 FSOUND_SetVolume(channels[heavyimpactsound], 256);
3137 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
3141 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
3144 relative=victim->coords-coords;
3146 Normalise(&relative);
3148 Normalise(&relative);
3149 for(i=0;i<victim->skeleton.num_joints;i++){
3150 victim->skeleton.joints[i].velocity=relative*5;
3152 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
3154 victim->targetframe=0;
3155 victim->targetanimation=staggerbackhardanim;
3156 victim->targetrotation=targetrotation+180;
3160 victim->Puff(abdomen);
3161 victim->DoDamage(damagemult*60/victim->protectionhigh);
3169 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
3170 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3171 if(victim->id==0)camerashake+=.4;
3174 gLoc[0]=victim->coords.x;
3175 gLoc[1]=victim->coords.y;
3176 gLoc[2]=victim->coords.z;
3181 PlaySoundEx( landsound2, samp[landsound2], NULL, TRUE);
3182 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
3183 FSOUND_SetVolume(channels[landsound2], 256);
3184 FSOUND_SetPaused(channels[landsound2], FALSE);
3190 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
3191 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3192 if(victim->id==0)camerashake+=.4;
3195 gLoc[0]=victim->coords.x;
3196 gLoc[1]=victim->coords.y;
3197 gLoc[2]=victim->coords.z;
3202 if(weaponactive!=-1){
3203 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3204 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3205 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3207 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, TRUE);
3208 FSOUND_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3209 FSOUND_SetVolume(channels[swordstaffsound], 512);
3210 FSOUND_SetPaused(channels[swordstaffsound], FALSE);
3213 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, TRUE);
3214 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3215 FSOUND_SetVolume(channels[metalhitsound], 512);
3216 FSOUND_SetPaused(channels[metalhitsound], FALSE);
3224 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3225 if(weaponactive!=-1){
3228 weapons.owner[weaponids[0]]=-1;
3229 aim=victim->coords+DoRotation(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position,0,victim->rotation,0)*victim->scale+victim->velocity*findDistance(&victim->coords,&coords)/50-(coords+DoRotation(skeleton.joints[skeleton.jointlabels[righthand]].position,0,rotation,0)*scale);
3231 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3232 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3234 weapons.velocity[weaponids[0]]=aim*50;
3235 weapons.tipvelocity[weaponids[0]]=aim*50;
3236 weapons.missed[weaponids[0]]=0;
3237 weapons.hitsomething[weaponids[0]]=0;
3238 weapons.freetime[weaponids[0]]=0;
3239 weapons.firstfree[weaponids[0]]=1;
3240 weapons.physics[weaponids[0]]=0;
3243 weaponids[0]=weaponids[num_weapons];
3249 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3251 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3254 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3262 if(tutoriallevel!=1){
3265 gLoc[0]=victim->coords.x;
3266 gLoc[1]=victim->coords.y;
3267 gLoc[2]=victim->coords.z;
3271 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, TRUE);
3272 FSOUND_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3273 FSOUND_SetVolume(channels[knifeslicesound], 512);
3274 FSOUND_SetPaused(channels[knifeslicesound], FALSE);
3276 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3277 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3278 if(victim->id != 0 || difficulty==2){
3279 victim->targetframe=0;
3280 victim->targetanimation=staggerbackhardanim;
3281 victim->targetrotation=targetrotation+180;
3285 victim->lowreversaldelay=0;
3286 victim->highreversaldelay=0;
3287 if(aitype!=playercontrolled)weaponmissdelay=.6;
3289 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3290 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3292 XYZ footvel,footpoint;
3295 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3298 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;
3300 if(tutoriallevel!=1){
3301 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3302 footvel=DoRotation(facing,0,90,0)*.8;
3304 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3305 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3306 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3307 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3309 if(tutoriallevel==1){
3310 sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3312 victim->DoDamage(damagemult*0);
3315 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3316 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3317 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3324 if(tutoriallevel!=1){
3325 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3326 else victim->DoBloodBig(2/victim->armorhigh,185);
3327 victim->deathbleeding=1;
3330 gLoc[0]=victim->coords.x;
3331 gLoc[1]=victim->coords.y;
3332 gLoc[2]=victim->coords.z;
3336 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, TRUE);
3337 FSOUND_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3338 FSOUND_SetVolume(channels[swordslicesound], 512);
3339 FSOUND_SetPaused(channels[swordslicesound], FALSE);
3341 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3342 //if(animation[victim->targetanimation].attack){
3343 //if(victim->creature==rabbittype){
3344 if(tutoriallevel!=1){
3345 victim->targetframe=0;
3346 victim->targetanimation=staggerbackhardanim;
3347 victim->targetrotation=targetrotation+180;
3353 if(tutoriallevel!=1){
3354 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3355 weapons.blooddrip[weaponids[weaponactive]]+=3;
3357 float bloodlossamount;
3358 bloodlossamount=200+abs((float)(Random()%40))-20;
3359 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3360 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3361 victim->DoDamage(damagemult*0);
3363 XYZ footvel,footpoint;
3366 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3369 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;
3371 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3372 footvel=DoRotation(facing,0,90,0)*.8;
3374 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3375 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3376 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3377 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3385 gLoc[0]=victim->coords.x;
3386 gLoc[1]=victim->coords.y;
3387 gLoc[2]=victim->coords.z;
3391 if(victim->weaponactive!=-1){
3392 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3393 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3394 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3396 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, TRUE);
3397 FSOUND_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3398 FSOUND_SetVolume(channels[swordstaffsound], 512);
3399 FSOUND_SetPaused(channels[swordstaffsound], FALSE);
3402 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, TRUE);
3403 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3404 FSOUND_SetVolume(channels[metalhitsound], 512);
3405 FSOUND_SetPaused(channels[metalhitsound], FALSE);
3411 victim->Puff(righthand);
3413 victim->targetframe=0;
3414 victim->targetanimation=staggerbackhighanim;
3415 victim->targetrotation=targetrotation+180;
3417 weapons.owner[victim->weaponids[0]]=-1;
3418 aim=DoRotation(facing,0,90,0)*21;
3420 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3421 weapons.tipvelocity[victim->weaponids[0]]=aim;
3422 weapons.missed[victim->weaponids[0]]=1;
3423 weapons.hitsomething[weaponids[0]]=0;
3424 weapons.freetime[victim->weaponids[0]]=0;
3425 weapons.firstfree[victim->weaponids[0]]=1;
3426 weapons.physics[victim->weaponids[0]]=1;
3427 victim->num_weapons--;
3428 if(victim->num_weapons){
3429 victim->weaponids[0]=victim->weaponids[num_weapons];
3430 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3432 victim->weaponactive=-1;
3433 for(i=0;i<numplayers;i++){
3434 player[i].wentforweapon=0;
3437 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, TRUE);
3438 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3439 FSOUND_SetVolume(channels[metalhitsound], 512);
3440 FSOUND_SetPaused(channels[metalhitsound], FALSE);*/
3446 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3447 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3448 if(tutoriallevel!=1){
3449 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3451 if(id==0)camerashake+=.4;
3452 if(Random()%2||creature==wolftype){
3457 gLoc[0]=victim->coords.x;
3458 gLoc[1]=victim->coords.y;
3459 gLoc[2]=victim->coords.z;
3463 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, TRUE);
3464 FSOUND_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3465 FSOUND_SetVolume(channels[staffheadsound], 256);
3466 FSOUND_SetPaused(channels[staffheadsound], FALSE);
3470 relative=victim->coords-coords;
3472 Normalise(&relative);
3473 relative=DoRotation(relative,0,90,0);
3475 Normalise(&relative);
3476 for(i=0;i<victim->skeleton.num_joints;i++){
3477 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3479 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3480 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3483 if(tutoriallevel!=1){
3484 victim->DoDamage(damagemult*120/victim->protectionhigh);
3495 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3496 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3497 if(tutoriallevel!=1){
3498 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3500 if(id==0)camerashake+=.4;
3501 if(Random()%2||creature==wolftype){
3506 gLoc[0]=victim->coords.x;
3507 gLoc[1]=victim->coords.y;
3508 gLoc[2]=victim->coords.z;
3512 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, TRUE);
3513 FSOUND_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3514 FSOUND_SetVolume(channels[staffheadsound], 256);
3515 FSOUND_SetPaused(channels[staffheadsound], FALSE);
3519 relative=victim->coords-coords;
3521 Normalise(&relative);
3522 relative=DoRotation(relative,0,-90,0);
3523 for(i=0;i<victim->skeleton.num_joints;i++){
3524 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3526 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3527 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3530 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3541 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3542 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3544 if(tutoriallevel!=1){
3545 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3546 if(id==0)camerashake+=.4;
3547 if(Random()%2||creature==wolftype){
3552 gLoc[0]=victim->coords.x;
3553 gLoc[1]=victim->coords.y;
3554 gLoc[2]=victim->coords.z;
3558 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, TRUE);
3559 FSOUND_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3560 FSOUND_SetVolume(channels[staffbodysound], 256);
3561 FSOUND_SetPaused(channels[staffbodysound], FALSE);
3563 victim->skeleton.longdead=0;
3564 victim->skeleton.free=1;
3565 victim->skeleton.broken=0;
3567 for(i=0;i<victim->skeleton.num_joints;i++){
3568 victim->skeleton.joints[i].velchange=0;
3569 victim->skeleton.joints[i].locked=0;
3570 //victim->skeleton.joints[i].velocity=0;
3576 /*relative=victim->coords-coords;
3578 Normalise(&relative);
3579 relative=DoRotation(relative,0,90,0);*/
3581 Normalise(&relative);
3583 for(i=0;i<victim->skeleton.num_joints;i++){
3584 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3587 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3590 for(i=0;i<victim->skeleton.num_joints;i++){
3591 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3594 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3596 victim->Puff(abdomen);
3597 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3610 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3611 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3613 if(id==0)camerashake+=.4;
3616 gLoc[0]=victim->coords.x;
3617 gLoc[1]=victim->coords.y;
3618 gLoc[2]=victim->coords.z;
3623 relative=victim->coords-coords;
3625 Normalise(&relative);
3631 if(animation[victim->targetanimation].height==lowheight){
3637 for(i=0;i<victim->skeleton.num_joints;i++){
3638 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3640 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3641 if(tutoriallevel!=1){
3642 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
3643 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3644 FSOUND_SetVolume(channels[heavyimpactsound], 128);
3645 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
3648 victim->DoDamage(damagemult*100/victim->protectionhead);
3649 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3650 if(creature==wolftype){
3651 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, TRUE);
3652 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3653 FSOUND_SetVolume(channels[clawslicesound], 128);
3654 FSOUND_SetPaused(channels[clawslicesound], FALSE);
3656 victim->DoBloodBig(2/victim->armorhead,175);
3660 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3661 for(i=0;i<victim->skeleton.num_joints;i++){
3662 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3664 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3665 victim->targetframe=0;
3666 victim->targetanimation=staggerbackhighanim;
3667 victim->targetrotation=targetrotation+180;
3669 if(tutoriallevel!=1){
3670 PlaySoundEx( landsound2, samp[landsound2], NULL, TRUE);
3671 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
3672 FSOUND_SetVolume(channels[landsound2], 128);
3673 FSOUND_SetPaused(channels[landsound2], FALSE);
3675 victim->Puff(abdomen);
3676 victim->DoDamage(damagemult*30/victim->protectionhigh);
3677 if(creature==wolftype){
3678 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, TRUE);
3679 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3680 FSOUND_SetVolume(channels[clawslicesound], 128);
3681 FSOUND_SetPaused(channels[clawslicesound], FALSE);
3683 victim->DoBloodBig(2/victim->armorhigh,170);
3690 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3691 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3693 if(id==0)camerashake+=.2;
3696 gLoc[0]=victim->coords.x;
3697 gLoc[1]=victim->coords.y;
3698 gLoc[2]=victim->coords.z;
3702 if(tutoriallevel!=1){
3703 PlaySoundEx( landsound2, samp[landsound2], NULL, TRUE);
3704 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
3705 FSOUND_SetVolume(channels[landsound2], 128);
3706 FSOUND_SetPaused(channels[landsound2], FALSE);
3709 relative=victim->coords-coords;
3711 Normalise(&relative);
3713 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3716 for(i=0;i<victim->skeleton.num_joints;i++){
3717 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3719 relative=DoRotation(relative,0,-90,0);
3721 for(i=0;i<victim->skeleton.num_joints;i++){
3722 if(victim->skeleton.joints[i].label==leftfoot||victim->skeleton.joints[i].label==rightfoot||victim->skeleton.joints[i].label==leftankle||victim->skeleton.joints[i].label==rightankle)
3723 victim->skeleton.joints[i].velocity=relative*80;
3725 victim->Puff(rightankle);
3726 victim->Puff(leftankle);
3727 victim->DoDamage(damagemult*40/victim->protectionlow);
3730 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3731 for(i=0;i<victim->skeleton.num_joints;i++){
3732 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3734 relative=DoRotation(relative,0,-90,0);
3735 for(i=0;i<victim->skeleton.num_joints;i++){
3736 if(victim->skeleton.joints[i].label==leftfoot||victim->skeleton.joints[i].label==rightfoot||victim->skeleton.joints[i].label==leftankle||victim->skeleton.joints[i].label==rightankle)
3737 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3739 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3740 victim->targetframe=0;
3741 victim->targetanimation=staggerbackhighanim;
3742 victim->targetrotation=targetrotation+180;
3744 if(tutoriallevel!=1){
3745 PlaySoundEx( landsound2, samp[landsound2], NULL, TRUE);
3746 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
3747 FSOUND_SetVolume(channels[landsound2], 128);
3748 FSOUND_SetPaused(channels[landsound2], FALSE);
3750 victim->Puff(abdomen);
3751 victim->DoDamage(damagemult*30/victim->protectionlow);
3761 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3762 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3764 if(id==0)camerashake+=.4;
3771 gLoc[0]=victim->coords.x;
3772 gLoc[1]=victim->coords.y;
3773 gLoc[2]=victim->coords.z;
3777 if(tutoriallevel!=1){
3778 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
3779 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3780 FSOUND_SetVolume(channels[heavyimpactsound], 128);
3781 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
3783 if(creature==wolftype){
3784 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, TRUE);
3785 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3786 FSOUND_SetVolume(channels[clawslicesound], 128);
3787 FSOUND_SetPaused(channels[clawslicesound], FALSE);
3789 victim->DoBloodBig(2/victim->armorhigh,170);
3793 relative=victim->coords-oldcoords;
3795 Normalise(&relative);
3796 //relative=DoRotation(relative,0,-90,0);
3797 for(i=0;i<victim->skeleton.num_joints;i++){
3798 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3800 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3802 victim->Puff(abdomen);
3803 victim->DoDamage(damagemult*150/victim->protectionhigh);
3812 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3813 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3814 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3815 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3818 weaponids[num_weapons]=weaponids[victim->weaponactive];
3821 weaponids[0]=victim->weaponids[victim->weaponactive];
3822 victim->num_weapons--;
3823 if(victim->num_weapons>0){
3824 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3825 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3827 victim->weaponactive=-1;
3832 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3834 if(id==0)camerashake+=.4;
3841 gLoc[0]=victim->coords.x;
3842 gLoc[1]=victim->coords.y;
3843 gLoc[2]=victim->coords.z;
3847 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, TRUE);
3848 FSOUND_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3849 FSOUND_SetVolume(channels[whooshhitsound], 128);
3850 FSOUND_SetPaused(channels[whooshhitsound], FALSE);
3853 relative=victim->coords-oldcoords;
3855 Normalise(&relative);
3856 //relative=DoRotation(relative,0,-90,0);
3857 for(i=0;i<victim->skeleton.num_joints;i++){
3858 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3860 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3863 victim->DoDamage(damagemult*70/victim->protectionhigh);
3866 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3868 if(id==0)camerashake+=.4;
3875 gLoc[0]=victim->coords.x;
3876 gLoc[1]=victim->coords.y;
3877 gLoc[2]=victim->coords.z;
3883 bonus=staffreversebonus;
3888 if(tutoriallevel!=1){
3889 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
3890 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3891 FSOUND_SetVolume(channels[heavyimpactsound], 128);
3892 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
3896 bonus=staffreversebonus;
3902 relative=victim->coords-oldcoords;
3904 Normalise(&relative);
3905 //relative=DoRotation(relative,0,-90,0);
3906 for(i=0;i<victim->skeleton.num_joints;i++){
3907 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3909 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3912 victim->DoDamage(damagemult*70/victim->protectionhigh);
3915 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3921 Normalise(&relative);
3924 for(i=0;i<victim->skeleton.num_joints;i++){
3925 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3927 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3928 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3929 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3930 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3931 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3932 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3933 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3934 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3936 victim->Puff(abdomen);
3937 victim->DoDamage(damagemult*90/victim->protectionhigh);
3947 if(weaponactive!=-1||creature==wolftype)doslice=1;
3948 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3952 gLoc[0]=victim->coords.x;
3953 gLoc[1]=victim->coords.y;
3954 gLoc[2]=victim->coords.z;
3958 if(weaponactive!=-1){
3959 victim->DoBloodBig(2/victim->armorhigh,225);
3960 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, TRUE);
3961 FSOUND_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3962 FSOUND_SetVolume(channels[knifeslicesound], 512);
3963 FSOUND_SetPaused(channels[knifeslicesound], FALSE);
3964 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3965 weapons.blooddrip[weaponids[weaponactive]]+=3;
3967 if(weaponactive==-1&&creature==wolftype){
3968 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, TRUE);
3969 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3970 FSOUND_SetVolume(channels[clawslicesound], 128);
3971 FSOUND_SetPaused(channels[clawslicesound], FALSE);
3973 victim->DoBloodBig(2/victim->armorhigh,175);
3980 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3986 Normalise(&relative);
3989 for(i=0;i<victim->skeleton.num_joints;i++){
3990 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3992 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
3993 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
3994 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
3995 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
3996 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
3997 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
3998 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
3999 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
4002 bonus=swordreversebonus;
4006 //victim->DoDamage(90);
4008 /*if(weaponactive!=-1){
4011 gLoc[0]=victim->coords.x;
4012 gLoc[1]=victim->coords.y;
4013 gLoc[2]=victim->coords.z;
4017 victim->DoBloodBig(2,225);
4018 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, TRUE);
4019 FSOUND_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4020 FSOUND_SetVolume(channels[knifeslicesound], 512);
4021 FSOUND_SetPaused(channels[knifeslicesound], FALSE);
4022 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4023 weapons.blooddrip[weaponids[weaponactive]]+=3;
4027 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
4029 if(id==0)camerashake+=.4;
4036 gLoc[0]=victim->coords.x;
4037 gLoc[1]=victim->coords.y;
4038 gLoc[2]=victim->coords.z;
4042 if(tutoriallevel!=1){
4043 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
4044 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4045 FSOUND_SetVolume(channels[heavyimpactsound], 128);
4046 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
4050 relative=victim->coords-oldcoords;
4052 Normalise(&relative);
4053 relative=DoRotation(relative,0,-90,0);
4054 for(i=0;i<victim->skeleton.num_joints;i++){
4055 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
4057 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
4059 victim->Puff(abdomen);
4060 victim->DoDamage(damagemult*30/victim->protectionhigh);
4069 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
4072 victim->skeleton.spinny=0;
4076 Normalise(&relative);
4077 if(victim->id==0)relative/=30;
4078 for(i=0;i<victim->skeleton.num_joints;i++){
4079 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
4081 //victim->DoDamage(1000);
4082 victim->damage=victim->damagetolerance;
4083 victim->permanentdamage=victim->damagetolerance-1;
4086 if(weaponactive!=-1||creature==wolftype)doslice=1;
4087 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4091 gLoc[0]=victim->coords.x;
4092 gLoc[1]=victim->coords.y;
4093 gLoc[2]=victim->coords.z;
4097 if(weaponactive!=-1){
4098 victim->DoBloodBig(200,225);
4099 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, TRUE);
4100 FSOUND_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4101 FSOUND_SetVolume(channels[knifeslicesound], 512);
4102 FSOUND_SetPaused(channels[knifeslicesound], FALSE);
4103 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4104 weapons.blooddrip[weaponids[weaponactive]]+=5;
4107 if(creature==wolftype&&weaponactive==-1){
4108 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, TRUE);
4109 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4110 FSOUND_SetVolume(channels[clawslicesound], 128);
4111 FSOUND_SetPaused(channels[clawslicesound], FALSE);
4113 victim->DoBloodBig(2,175);
4123 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4124 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4126 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
4127 if(targetanimation==knifesneakattackanim){
4128 /*victim->DoBloodBig(200,195);
4133 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4134 sprites.MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
4136 XYZ footvel,footpoint;
4138 footpoint=weapons.tippoint[weaponids[0]];
4139 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4140 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4141 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4142 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4143 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4144 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4145 victim->DoBloodBig(200,195);
4152 //victim->neckspurtamount=5;
4154 if(targetanimation==knifefollowanim){
4160 XYZ footvel,footpoint;
4162 footpoint=weapons.tippoint[weaponids[0]];
4163 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4164 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4165 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4166 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4167 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
4168 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
4171 victim->bloodloss+=10000;
4175 gLoc[0]=victim->coords.x;
4176 gLoc[1]=victim->coords.y;
4177 gLoc[2]=victim->coords.z;
4181 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, TRUE);
4182 FSOUND_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4183 FSOUND_SetVolume(channels[fleshstabsound], 512);
4184 FSOUND_SetPaused(channels[fleshstabsound], FALSE);
4185 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4186 weapons.blooddrip[weaponids[weaponactive]]+=5;
4190 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
4193 for(i=0;i<victim->skeleton.num_joints;i++){
4194 victim->skeleton.joints[i].velocity=0;
4196 if(targetanimation==knifefollowanim){
4198 for(i=0;i<victim->skeleton.num_joints;i++){
4199 victim->skeleton.joints[i].velocity=0;
4202 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
4205 gLoc[0]=victim->coords.x;
4206 gLoc[1]=victim->coords.y;
4207 gLoc[2]=victim->coords.z;
4211 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, TRUE);
4212 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4213 FSOUND_SetVolume(channels[fleshstabremovesound], 512);
4214 FSOUND_SetPaused(channels[fleshstabremovesound], FALSE);
4215 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4216 weapons.blooddrip[weaponids[weaponactive]]+=5;
4218 XYZ footvel,footpoint;
4220 footpoint=weapons.tippoint[weaponids[0]];
4221 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4222 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4223 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4224 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4225 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4226 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4230 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4231 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4240 XYZ footvel,footpoint;
4242 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
4243 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4244 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4245 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4246 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4247 sprites.MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4248 sprites.MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4249 victim->DoBloodBig(200,180);
4250 victim->DoBloodBig(200,215);
4251 victim->bloodloss+=10000;
4255 gLoc[0]=victim->coords.x;
4256 gLoc[1]=victim->coords.y;
4257 gLoc[2]=victim->coords.z;
4261 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, TRUE);
4262 FSOUND_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4263 FSOUND_SetVolume(channels[fleshstabsound], 512);
4264 FSOUND_SetPaused(channels[fleshstabsound], FALSE);
4265 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4266 weapons.blooddrip[weaponids[weaponactive]]+=5;
4270 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
4273 for(i=0;i<victim->skeleton.num_joints;i++){
4274 victim->skeleton.joints[i].velocity=0;
4276 if(weaponactive!=-1){
4279 gLoc[0]=victim->coords.x;
4280 gLoc[1]=victim->coords.y;
4281 gLoc[2]=victim->coords.z;
4285 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, TRUE);
4286 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4287 FSOUND_SetVolume(channels[fleshstabremovesound], 512);
4288 FSOUND_SetPaused(channels[fleshstabremovesound], FALSE);
4289 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4290 weapons.blooddrip[weaponids[weaponactive]]+=5;
4292 XYZ footvel,footpoint;
4294 footpoint=weapons.tippoint[weaponids[0]];
4295 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4296 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4297 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4298 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4299 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4300 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4304 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4306 if(id==0)camerashake+=.4;
4313 gLoc[0]=victim->coords.x;
4314 gLoc[1]=victim->coords.y;
4315 gLoc[2]=victim->coords.z;
4319 if(weaponactive==-1){
4320 if(tutoriallevel!=1){
4321 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, TRUE);
4322 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4323 FSOUND_SetVolume(channels[heavyimpactsound], 128);
4324 FSOUND_SetPaused(channels[heavyimpactsound], FALSE);
4329 if(weaponactive!=-1||creature==wolftype)doslice=1;
4330 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4332 if(weaponactive!=-1){
4333 victim->DoBloodBig(2/victim->armorhead,225);
4334 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, TRUE);
4335 FSOUND_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4336 FSOUND_SetVolume(channels[knifeslicesound], 512);
4337 FSOUND_SetPaused(channels[knifeslicesound], FALSE);
4338 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4339 weapons.blooddrip[weaponids[weaponactive]]+=3;
4341 if(weaponactive==-1&&creature==wolftype){
4342 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, TRUE);
4343 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4344 FSOUND_SetVolume(channels[clawslicesound], 128);
4345 FSOUND_SetPaused(channels[clawslicesound], FALSE);
4347 victim->DoBloodBig(2/victim->armorhead,175);
4360 //relative=victim->coords-oldcoords;
4363 Normalise(&relative);
4364 relative=DoRotation(relative,0,90,0);
4366 Normalise(&relative);
4367 for(i=0;i<victim->skeleton.num_joints;i++){
4368 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4370 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4371 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4372 victim->DoDamage(damagemult*100/victim->protectionhead);
4376 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4380 //relative=victim->coords-oldcoords;
4383 Normalise(&relative);
4384 relative=DoRotation(relative,0,90,0);
4386 Normalise(&relative);
4387 for(i=0;i<victim->skeleton.num_joints;i++){
4388 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4390 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4393 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4394 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4405 if(targetframe>animation[currentanimation].numframes-1){
4408 targetanimation=getIdle();
4412 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4413 targetanimation=rollanim;
4424 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
4425 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4426 FSOUND_SetVolume(channels[movewhooshsound], 128);
4427 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
4429 if(currentanimation==staggerbackhighanim){
4430 targetanimation=getIdle();
4432 if(currentanimation==staggerbackhardanim){
4433 targetanimation=getIdle();
4435 if(currentanimation==removeknifeanim){
4436 targetanimation=getIdle();
4438 if(currentanimation==crouchremoveknifeanim){
4439 targetanimation=getCrouch();
4441 if(currentanimation==backhandspringanim){
4442 targetanimation=getIdle();
4444 if(currentanimation==dodgebackanim){
4445 targetanimation=getIdle();
4447 if(currentanimation==drawleftanim){
4448 targetanimation=getIdle();
4450 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4451 targetanimation=getIdle();
4452 if(currentanimation==crouchdrawrightanim){
4453 targetanimation=getCrouch();
4455 if(weaponactive==-1)weaponactive=0;
4456 else if(weaponactive==0){
4460 buffer=weaponids[0];
4461 weaponids[0]=weaponids[1];
4462 weaponids[1]=buffer;
4466 if(weaponactive==-1){
4476 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, TRUE);
4477 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4478 FSOUND_SetVolume(channels[knifesheathesound], 128);
4479 FSOUND_SetPaused(channels[knifesheathesound], FALSE);
4481 if(weaponactive!=-1){
4491 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, TRUE);
4492 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4493 FSOUND_SetVolume(channels[knifedrawsound], 128);
4494 FSOUND_SetPaused(channels[knifedrawsound], FALSE);
4497 if(currentanimation==rollanim){
4498 targetanimation=getCrouch();
4503 if(targetanimation==walljumprightkickanim){
4506 if(targetanimation==walljumpleftkickanim){
4509 targetanimation=jumpdownanim;
4511 if(currentanimation==climbanim){
4512 targetanimation=getCrouch();
4515 if(!isnormal(coords.x))
4526 if(targetanimation==rabbitkickreversalanim){
4527 targetanimation=getCrouch();
4530 if(targetanimation==jumpreversalanim){
4531 targetanimation=getCrouch();
4534 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4535 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4537 float closestdist=-1;
4540 for(i=0;i<numplayers;i++){
4541 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4542 distance=findDistancefast(&player[i].coords,&coords);
4543 if(closestdist==-1||distance<closestdist){
4544 closestdist=distance;
4549 if(closestdist>0&&closest>=0&&closestdist<16){
4550 victim=&player[closest];
4551 targetanimation=walljumprightkickanim;
4553 XYZ rotatetarget=victim->coords-coords;
4554 Normalise(&rotatetarget);
4555 rotation=-asin(0-rotatetarget.x);
4557 if(rotatetarget.z<0)rotation=180-rotation;
4558 targettilt2=-asin(rotatetarget.y)*360/6.28;
4559 velocity=(victim->coords-coords)*4;
4564 if(targetanimation==walljumpbackanim){
4565 targetanimation=backflipanim;
4569 if(id==0)FSOUND_SetPaused(channels[whooshsound], FALSE);
4571 if(targetanimation==walljumprightanim){
4572 targetanimation=rightflipanim;
4576 velocity=DoRotation(facing,0,30,0)*-8;
4579 if(targetanimation==walljumpfrontanim){
4580 targetanimation=frontflipanim;
4582 //targetrotation-=180;
4587 if(id==0)FSOUND_SetPaused(channels[whooshsound], FALSE);
4589 if(targetanimation==walljumpleftanim){
4592 float closestdist=-1;
4595 for(i=0;i<numplayers;i++){
4596 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4597 distance=findDistancefast(&player[i].coords,&coords);
4598 if(closestdist==-1||distance<closestdist){
4599 closestdist=distance;
4604 if(closestdist>0&&closest>=0&&closestdist<16){
4605 victim=&player[closest];
4606 targetanimation=walljumpleftkickanim;
4608 XYZ rotatetarget=victim->coords-coords;
4609 Normalise(&rotatetarget);
4610 rotation=-asin(0-rotatetarget.x);
4612 if(rotatetarget.z<0)rotation=180-rotation;
4613 targettilt2=-asin(rotatetarget.y)*360/6.28;
4614 velocity=(victim->coords-coords)*4;
4619 if(targetanimation!=walljumpleftkickanim){
4620 targetanimation=leftflipanim;
4624 velocity=DoRotation(facing,0,-30,0)*-8;
4627 if(id==0)FSOUND_SetPaused(channels[whooshsound], FALSE);
4629 if(targetanimation==sneakattackanim){
4630 float ycoords=oldcoords.y;
4631 currentanimation=getCrouch();
4632 targetanimation=getCrouch();
4635 targetrotation+=180;
4640 targetheadrotation+=180;
4642 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4646 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4647 float ycoords=oldcoords.y;
4648 targetanimation=getIdle();
4650 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4654 if(currentanimation==knifefollowanim){
4655 targetanimation=getIdle();
4658 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4659 float ycoords=oldcoords.y;
4660 targetanimation=getStop();
4661 targetrotation+=180;
4666 targetheadrotation+=180;
4667 if(!isnormal(coords.x))
4669 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4670 oldcoords=coords+facing*.5;
4671 else if(currentanimation==sweepreversalanim)
4672 oldcoords=coords+facing*1.1;
4673 else if(currentanimation==upunchreversalanim){
4674 oldcoords=coords+facing*1.5;
4675 targetrotation+=180;
4677 targetheadrotation+=180;
4681 else if(currentanimation==knifeslashreversalanim){
4682 oldcoords=coords+facing*.5;
4685 targetheadrotation+=90;
4689 else if(currentanimation==staffspinhitreversalanim){
4690 targetrotation+=180;
4692 targetheadrotation+=180;
4696 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4697 else oldcoords.y=ycoords;
4698 currentoffset=coords-oldcoords;
4704 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4709 if(animation[targetanimation].attack==reversed){
4711 if(targetanimation==sweepreversedanim)targetrotation+=90;
4712 targetanimation=backhandspringanim;
4722 PlaySoundEx( landsound, samp[landsound], NULL, TRUE);
4723 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
4724 FSOUND_SetVolume(channels[landsound], 128);
4725 FSOUND_SetPaused(channels[landsound], FALSE);
4727 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4728 targetanimation=rollanim;
4731 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4732 coords.y=oldcoords.y;
4734 if(currentanimation==knifeslashreversedanim){
4735 targetanimation=rollanim;
4740 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4741 coords.y=oldcoords.y;
4745 targetanimation=jumpdownanim;
4747 if(wasLanding())targetanimation=getIdle();
4748 if(wasLandhard())targetanimation=getIdle();
4749 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4750 targetanimation=getIdle();
4752 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4753 coords.y=oldcoords.y;
4754 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4755 targetoffset.y=coords.y;
4756 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4757 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4758 currentoffset.y-=(coords.y-targetoffset.y);
4759 coords.y=targetoffset.y;
4761 normalsupdatedelay=0;
4763 if(currentanimation==upunchanim){
4764 targetanimation=getStop();
4765 normalsupdatedelay=0;
4768 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4769 targetrotation=rotation;
4772 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4773 if(!hasstaff)DoDamage(35);
4776 rabbitkickragdoll=1;
4778 if(currentanimation==rabbitkickreversedanim){
4785 if(id!=0)SolidHitBonus();
4789 targetanimation=rollanim;
4791 if(id==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
4795 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4801 if(currentanimation==jumpreversedanim){
4808 if(id!=0)SolidHitBonus();
4812 targetanimation=rollanim;
4814 if(id==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
4819 if(animation[currentanimation].attack==normalattack&&!victim->skeleton.free&&victim->targetanimation!=staggerbackhighanim&&victim->targetanimation!=staggerbackhardanim&&targetanimation!=winduppunchblockedanim&&targetanimation!=blockhighleftanim&&targetanimation!=swordslashparryanim&&targetanimation!=swordslashparriedanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim){
4820 targetanimation=getupfromfrontanim;
4823 else if(animation[currentanimation].attack==normalattack){
4824 targetanimation=getIdle();
4827 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4828 targetanimation=blockhighleftstrikeanim;
4830 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4831 targetanimation=getIdle();
4834 if(currentanimation==spinkickanim&&victim->skeleton.free){
4835 if(creature==rabbittype)targetanimation=fightidleanim;
4840 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4842 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4843 targetanimation=jumpdownanim;
4848 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4849 if(!isRun()||!wasRun()){
4850 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4851 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4852 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4853 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4855 if(isRun()&&wasRun()){
4858 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4859 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4862 else if(transspeed)target+=multiplier*transspeed*speed*2;
4864 if(!isRun()||!wasRun()){
4865 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4866 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4867 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4868 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4872 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4874 if(target>1){currentframe=targetframe; target=1;}
4876 rot=targetrot*target;
4877 rotation+=rot-oldrot;
4883 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4885 for(i=0;i<skeleton.num_joints;i++){
4886 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4889 skeleton.FindForwards();
4891 for(i=0;i<skeleton.num_muscles;i++){
4892 if(skeleton.muscles[i].visible)
4894 skeleton.FindRotationMuscle(i,targetanimation);
4897 for(i=0;i<skeleton.num_muscles;i++){
4898 if(skeleton.muscles[i].visible)
4900 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4901 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4902 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4907 for(i=0;i<skeleton.num_joints;i++){
4908 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4911 skeleton.FindForwards();
4913 for(i=0;i<skeleton.num_muscles;i++){
4914 if(skeleton.muscles[i].visible)
4916 skeleton.FindRotationMuscle(i,targetanimation);
4919 for(i=0;i<skeleton.num_muscles;i++){
4920 if(skeleton.muscles[i].visible)
4922 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4923 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4924 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4925 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4926 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4927 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4928 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4929 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4930 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4934 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4936 oldcurrentanimation=currentanimation;
4937 oldtargetanimation=targetanimation;
4938 oldtargetframe=targetframe;
4939 oldcurrentframe=currentframe;
4941 for(i=0;i<skeleton.num_joints;i++){
4942 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4943 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4945 offset=currentoffset*(1-target)+targetoffset*target;
4946 for(i=0;i<skeleton.num_muscles;i++){
4947 if(skeleton.muscles[i].visible)
4949 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4950 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4951 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4956 if(isLanding()&&landhard){
4957 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4958 if(id==0)camerashake+=.4;
4959 targetanimation=getLandhard();
4967 //skeleton.DoConstraints();
4970 void Person::DoStuff(){
4971 static XYZ terrainnormal;
4972 static XYZ flatfacing;
4973 static XYZ flatvelocity;
4974 static float flatvelspeed;
4978 static int bloodsize;
4979 static int startx,starty,endx,endy;
4980 static int texdetailint;
4981 static GLubyte color;
4982 static XYZ bloodvel;
4984 onfiredelay-=multiplier;
4985 if(onfiredelay<0&&onfire)
4993 crouchkeydowntime+=multiplier;
4994 if(!crouchkeydown)crouchkeydowntime=0;
4995 jumpkeydowntime+=multiplier;
4996 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
4998 if(hostile||damage>0||bloodloss>0)immobile=0;
5000 if(isIdle()||isRun())targetoffset=0;
5002 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
5004 if(id==0)blooddimamount-=multiplier*.3;
5005 speechdelay-=multiplier;
5006 texupdatedelay-=multiplier;
5007 interestdelay-=multiplier;
5008 flamedelay-=multiplier;
5009 parriedrecently-=multiplier;
5015 if(id==0)speed=1.1*speedmult;
5016 else speed=1.0*speedmult;
5017 if(!skeleton.free)rabbitkickragdoll=0;
5021 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
5022 if(id!=0&&creature==wolftype&&difficulty==2){
5024 if(aitype!=passivetype){
5026 if(aitype==attacktypecutoff&&(player[0].isIdle()||player[0].isCrouch()||player[0].skeleton.free||player[0].targetanimation==getupfrombackanim||player[0].targetanimation==getupfromfrontanim||player[0].targetanimation==sneakanim)&&findDistancefast(&coords,&player[0].coords)<16){
5030 if(scale<0.2)superruntoggle=0;
5031 if(targetanimation==wolfrunninganim&&!superruntoggle){
5032 targetanimation=getRun();
5035 /*static float toggledelay;
5036 toggledelay-=multiplier;
5039 if(Random()%3==0)superruntoggle=1-superruntoggle;
5042 if(weaponactive==-1&&num_weapons>0){
5043 if(weapons.type[weaponids[0]]==staff){
5050 /*if(aitype!=playercontrolled)*///deathbleeding=5;
5051 /*if(aitype!=playercontrolled)*/
5053 if(burnt>.6)burnt=.6;
5054 FSOUND_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
5056 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5067 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
5068 FSOUND_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
5072 while(flamedelay<0&&onfire){
5074 howmany=abs(Random()%(skeleton.num_joints));
5075 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
5076 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
5077 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
5078 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
5079 sprites.MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5082 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
5084 howmany=abs(Random()%(skeleton.num_joints));
5085 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
5086 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
5087 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
5088 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
5089 sprites.MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
5093 bleeding-=multiplier*.3;
5095 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5096 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
5100 if(neckspurtamount>0){
5101 neckspurtamount-=multiplier;
5102 neckspurtdelay-=multiplier*3;
5103 neckspurtparticledelay-=multiplier*3;
5104 if(neckspurtparticledelay<0&&neckspurtdelay>2){
5108 bloodvel.z=5*neckspurtamount;
5109 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
5112 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
5114 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
5115 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
5116 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);
5117 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);
5118 neckspurtparticledelay=.05;
5120 if(neckspurtdelay<0){
5125 if(deathbleeding>0&&dead!=2){
5126 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
5127 else bleeddelay-=5*multiplier/4;
5128 if(bleeddelay<0&&bloodtoggle){
5133 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
5134 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
5135 if(skeleton.free)sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
5136 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);
5140 bloodloss+=deathbleeding*40;
5143 bloodloss+=deathbleeding*multiplier*80;
5144 deathbleeding-=multiplier*1.6;
5145 //if(id==0)deathbleeding-=multiplier*.2;
5146 if(deathbleeding<0)deathbleeding=0;
5147 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
5148 if(weaponactive!=-1){
5149 weapons.owner[weaponids[0]]=-1;
5150 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5151 weapons.velocity[weaponids[0]].x+=.01;
5152 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5153 weapons.missed[weaponids[0]]=1;
5154 weapons.hitsomething[weaponids[0]]=0;
5155 weapons.freetime[weaponids[0]]=0;
5156 weapons.firstfree[weaponids[0]]=1;
5157 weapons.physics[weaponids[0]]=1;
5160 weaponids[0]=weaponids[num_weapons];
5161 if(weaponstuck==num_weapons)weaponstuck=0;
5164 for(i=0;i<numplayers;i++){
5165 player[i].wentforweapon=0;
5177 if(!dead&&creature==wolftype){
5183 if(targetanimation==knifefollowedanim&&!skeleton.free){
5184 for(i=0;i<skeleton.num_joints;i++){
5185 skeleton.joints[i].velocity=0;
5186 skeleton.joints[i].velocity.y=-2;
5189 if(id!=0&&unconscioustime>.1){
5197 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
5200 bloodsize=5-realtexdetail;
5204 texdetailint=realtexdetail;
5205 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5206 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5207 endx=startx+bloodsize;
5208 endy=starty+bloodsize;
5210 if(startx<0){startx=0;bleeding=0;}
5211 if(starty<0){starty=0;bleeding=0;}
5212 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
5213 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
5214 if(endx<startx)endx=startx;
5215 if(endy<starty)endy=starty;
5221 for(i=startx;i<endx;i++){
5222 for(j=starty;j<endy;j++){
5224 color=Random()%85+170;
5225 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
5226 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
5227 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
5232 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5233 DoMipmaps(0,startx,endx,starty,endy);
5237 bleedy-=4/realtexdetail;
5238 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
5239 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
5242 bleedx+=4*direction/realtexdetail;
5243 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
5244 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
5248 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
5249 righthandmorphness=targetrighthandmorphness;
5250 righthandmorphstart=righthandmorphend;
5252 else if(righthandmorphness>targetrighthandmorphness){
5253 righthandmorphness-=multiplier*4;
5255 else if(righthandmorphness<targetrighthandmorphness){
5256 righthandmorphness+=multiplier*4;
5259 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
5260 lefthandmorphness=targetlefthandmorphness;
5261 lefthandmorphstart=lefthandmorphend;
5263 else if(lefthandmorphness>targetlefthandmorphness){
5264 lefthandmorphness-=multiplier*4;
5266 else if(lefthandmorphness<targetlefthandmorphness){
5267 lefthandmorphness+=multiplier*4;
5270 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
5271 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
5272 tailmorphness=targettailmorphness;
5273 tailmorphstart=tailmorphend;
5275 else if(tailmorphness>targettailmorphness){
5276 tailmorphness-=multiplier*10;
5278 else if(tailmorphness<targettailmorphness){
5279 tailmorphness+=multiplier*10;
5283 if(creature==wolftype){
5284 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
5285 tailmorphness=targettailmorphness;
5286 tailmorphstart=tailmorphend;
5288 else if(tailmorphness>targettailmorphness){
5289 tailmorphness-=multiplier*2;
5291 else if(tailmorphness<targettailmorphness){
5292 tailmorphness+=multiplier*2;
5296 if(headmorphend==3||headmorphstart==3){
5297 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
5298 headmorphness=targetheadmorphness;
5299 headmorphstart=headmorphend;
5301 else if(headmorphness>targetheadmorphness){
5302 headmorphness-=multiplier*7;
5304 else if(headmorphness<targetheadmorphness){
5305 headmorphness+=multiplier*7;
5308 else if(headmorphend==5||headmorphstart==5){
5309 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
5310 headmorphness=targetheadmorphness;
5311 headmorphstart=headmorphend;
5313 else if(headmorphness>targetheadmorphness){
5314 headmorphness-=multiplier*10;
5316 else if(headmorphness<targetheadmorphness){
5317 headmorphness+=multiplier*10;
5321 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5322 headmorphness=targetheadmorphness;
5323 headmorphstart=headmorphend;
5325 else if(headmorphness>targetheadmorphness){
5326 headmorphness-=multiplier*4;
5328 else if(headmorphness<targetheadmorphness){
5329 headmorphness+=multiplier*4;
5333 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5334 chestmorphness=targetchestmorphness;
5335 chestmorphstart=chestmorphend;
5337 else if(chestmorphness>targetchestmorphness){
5338 chestmorphness-=multiplier;
5340 else if(chestmorphness<targetchestmorphness){
5341 chestmorphness+=multiplier;
5344 if(dead!=2&&howactive<=typesleeping){
5345 if(chestmorphstart==0&&chestmorphend==0){
5347 targetchestmorphness=1;
5350 if(chestmorphstart!=0&&chestmorphend!=0){
5352 targetchestmorphness=1;
5354 if(environment==snowyenvironment){
5357 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5358 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5359 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5360 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5361 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5362 sprites.MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5366 if(!dead&&howactive<typesleeping){
5367 blinkdelay-=multiplier*2;
5368 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5370 targetheadmorphness=1;
5372 blinkdelay=(float)(abs(Random()%40))/5;
5374 if(headmorphstart==3&&headmorphend==3){
5376 targetheadmorphness=1;
5381 twitchdelay-=multiplier*1.5;
5382 if(targetanimation!=hurtidleanim){
5383 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5385 targetheadmorphness=1;
5387 twitchdelay=(float)(abs(Random()%40))/5;
5389 if(headmorphstart==5&&headmorphend==5){
5391 targetheadmorphness=1;
5395 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5396 twitchdelay3-=multiplier*1;
5398 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5399 righthandmorphness=0;
5400 targetrighthandmorphness=1;
5401 righthandmorphend=1;
5402 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5404 if(righthandmorphstart==1&&righthandmorphend==1){
5405 righthandmorphness=0;
5406 targetrighthandmorphness=1;
5407 righthandmorphend=0;
5411 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5412 lefthandmorphness=0;
5413 targetlefthandmorphness=1;
5415 twitchdelay3=(float)(abs(Random()%40))/5;
5417 if(lefthandmorphstart==1&&lefthandmorphend==1){
5418 lefthandmorphness=0;
5419 targetlefthandmorphness=1;
5426 if(creature==rabbittype){
5427 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5428 else twitchdelay2-=multiplier*0.5;
5429 if(howactive<=typesleeping){
5430 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5432 targettailmorphness=1;
5434 twitchdelay2=(float)(abs(Random()%40))/5;
5436 if(tailmorphstart==1&&tailmorphend==1){
5438 targettailmorphness=1;
5441 if(tailmorphstart==2&&tailmorphend==2){
5443 targettailmorphness=1;
5450 if(creature==wolftype){
5451 twitchdelay2-=multiplier*1.5;
5453 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5455 targettailmorphness=1;
5460 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5462 targettailmorphness=1;
5466 if(twitchdelay2<=0){
5467 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5469 targettailmorphness=1;
5472 if(tailmorphstart==1&&tailmorphend==1){
5474 targettailmorphness=1;
5477 if(tailmorphstart==2&&tailmorphend==2){
5479 targettailmorphness=1;
5482 if(tailmorphstart==3&&tailmorphend==3){
5484 targettailmorphness=1;
5487 if(tailmorphstart==4&&tailmorphend==4){
5489 targettailmorphness=1;
5495 if(dead!=1)unconscioustime=0;
5497 if(dead==1||howactive==typesleeping){
5498 unconscioustime+=multiplier;
5499 //If unconscious, close eyes and mouth
5500 if(righthandmorphend!=0)righthandmorphness=0;
5501 righthandmorphend=0;
5502 targetrighthandmorphness=1;
5504 if(lefthandmorphend!=0)lefthandmorphness=0;
5506 targetlefthandmorphness=1;
5508 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5510 targetheadmorphness=1;
5514 if(howactive>typesleeping){
5517 if(bloodtoggle&&!bled){
5518 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5520 if(bloodtoggle&&!bled)
5521 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5522 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5523 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5527 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5532 if(dead==2||howactive>typesleeping){
5533 //If dead, open mouth and hands
5534 if(righthandmorphend!=0)righthandmorphness=0;
5535 righthandmorphend=0;
5536 targetrighthandmorphness=1;
5538 if(lefthandmorphend!=0)lefthandmorphness=0;
5540 targetlefthandmorphness=1;
5542 if(headmorphend!=2)headmorphness=0;
5544 targetheadmorphness=1;
5547 if(stunned>0&&!dead&&headmorphend!=2){
5548 if(headmorphend!=4)headmorphness=0;
5550 targetheadmorphness=1;
5553 if(damage>damagetolerance&&!dead){
5558 if(creature==wolftype){
5566 if(weaponactive!=-1){
5567 weapons.owner[weaponids[0]]=-1;
5568 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5569 weapons.velocity[weaponids[0]].x+=.01;
5570 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5571 weapons.missed[weaponids[0]]=1;
5572 weapons.hitsomething[weaponids[0]]=0;
5573 weapons.freetime[weaponids[0]]=0;
5574 weapons.firstfree[weaponids[0]]=1;
5575 weapons.physics[weaponids[0]]=1;
5578 weaponids[0]=weaponids[num_weapons];
5579 if(weaponstuck==num_weapons)weaponstuck=0;
5582 for(i=0;i<numplayers;i++){
5583 player[i].wentforweapon=0;
5589 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5597 if(bloodloss<damagetolerance)
5598 for(i=0;i<skeleton.num_joints;i++){
5599 skeleton.joints[i].velocity*=1.5;
5603 //if(dead)damage-=multiplier/4;
5604 if(!dead)damage-=multiplier*13;
5605 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5606 if(!dead)permanentdamage-=multiplier*4;
5607 if(isIdle()||isCrouch()){
5608 if(!dead)permanentdamage-=multiplier*4;
5609 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5611 if(damage<0)damage=0;
5612 if(permanentdamage<0)permanentdamage=0;
5613 if(superpermanentdamage<0)superpermanentdamage=0;
5614 if(permanentdamage<superpermanentdamage){
5615 permanentdamage=superpermanentdamage;
5617 if(damage<permanentdamage){
5618 damage=permanentdamage;
5620 if(dead==1&&damage<damagetolerance){
5624 for(i=0;i<skeleton.num_joints;i++){
5625 skeleton.joints[i].velocity=0;
5628 if(permanentdamage>damagetolerance&&dead!=2){
5631 if(weaponactive!=-1){
5632 weapons.owner[weaponids[0]]=-1;
5633 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5634 weapons.velocity[weaponids[0]].x+=.01;
5635 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5636 weapons.missed[weaponids[0]]=1;
5637 weapons.hitsomething[weaponids[0]]=0;
5638 weapons.freetime[weaponids[0]]=0;
5639 weapons.firstfree[weaponids[0]]=1;
5640 weapons.physics[weaponids[0]]=1;
5643 weaponids[0]=weaponids[num_weapons];
5644 if(weaponstuck==num_weapons)weaponstuck=0;
5647 for(i=0;i<numplayers;i++){
5648 player[i].wentforweapon=0;
5654 if(!dead&&creature==wolftype){
5660 if(id!=0&&unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance){
5665 if(id!=0&&unconscioustime>.1){
5681 PlaySoundEx( breaksound, samp[breaksound], NULL, TRUE);
5682 FSOUND_3D_SetAttributes(channels[breaksound], gLoc, vel);
5683 FSOUND_SetVolume(channels[breaksound], 512);
5684 FSOUND_SetPaused(channels[breaksound], FALSE);
5685 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5691 if(skeleton.free==1){
5692 if(id==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
5695 //If knocked over, open hands and close mouth
5696 if(righthandmorphend!=0)righthandmorphness=0;
5697 righthandmorphend=0;
5698 targetrighthandmorphness=1;
5700 if(lefthandmorphend!=0)lefthandmorphness=0;
5702 targetlefthandmorphness=1;
5704 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5705 if(headmorphend!=0)headmorphness=0;
5707 targetheadmorphness=1;
5711 skeleton.DoGravity(&scale);
5713 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5714 if(id!=0&&damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1)){
5719 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5723 for(j=0;j<skeleton.num_joints;j++){
5724 average+=skeleton.joints[j].position;
5728 coords+=average*scale;
5729 for(j=0;j<skeleton.num_joints;j++){
5730 skeleton.joints[j].position-=average;
5732 average/=multiplier;
5734 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5736 for(i=0;i<skeleton.num_joints;i++){
5737 velocity+=skeleton.joints[i].velocity*scale;
5739 velocity/=skeleton.num_joints;
5741 if(!isnormal(velocity.x)&&velocity.x){
5754 if(findLength(&average)<10&&dead&&skeleton.free){
5755 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5756 if(skeleton.longdead>2000){
5757 if(skeleton.longdead>6000){
5758 if(id==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
5763 if(dead==2&&bloodloss<damagetolerance){
5765 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5767 if(bloodtoggle&&!bled){
5768 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5770 if(bloodtoggle&&!bled)
5771 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5772 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5773 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5777 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5781 if(dead==2&&bloodloss>=damagetolerance){
5783 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5784 if(bleeding<=0)DoBlood(1,255);
5785 if(bloodtoggle&&!bled){
5786 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5788 if(bloodtoggle&&!bled)
5789 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5790 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5791 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5795 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5802 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5804 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5808 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5809 if(velocity.y<-30)canrecover=0;
5810 for(i=0;i<objects.numobjects;i++){
5811 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5812 colviewer=startpoint;
5814 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5822 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5823 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5824 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5825 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5827 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5828 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5829 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5831 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5832 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5833 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5835 Normalise(&terrainnormal);
5837 targetrotation=-asin(0-terrainnormal.x);
5838 targetrotation*=360/6.28;
5839 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5840 rotation=targetrotation;
5842 //if(skeleton.forward.y<0){
5845 //if(skeleton.forward.y>-.3){
5848 targetanimation=flipanim;
5849 crouchtogglekeydown=1;
5854 currentanimation=tempanim;
5857 //tilt2=targettilt2;
5859 //if(middle.y>0)targetoffset.y=middle.y+1;
5861 for(i=0;i<skeleton.num_joints;i++){
5862 tempanimation.position[i][0]=skeleton.joints[i].position;
5863 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5868 if(findLength(&average)<10&&!dead&&skeleton.free){
5869 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5870 if(skeleton.longdead>(damage+500)*1.5){
5871 if(id==0)FSOUND_SetPaused(channels[whooshsound], TRUE);
5877 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5878 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5879 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5880 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5882 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5883 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5884 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5886 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5887 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5888 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5890 Normalise(&terrainnormal);
5892 targetrotation=-asin(0-terrainnormal.x);
5893 targetrotation*=360/6.28;
5894 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5895 rotation=targetrotation;
5898 terrainnormal=terrain.getNormal(coords.x,coords.z);
5899 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5903 /*XYZ otherterrainnormal;
5904 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5905 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5906 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5907 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5910 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5914 if(skeleton.forward.y<0){
5915 targetanimation=getupfrombackanim;
5919 if(skeleton.forward.y>-.3){
5920 targetanimation=getupfromfrontanim;
5922 targetrotation+=180;
5928 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5929 targetanimation=rollanim;
5930 targetrotation=lookrotation;
5934 if(forwardkeydown)targetrotation+=45;
5935 if(backkeydown)targetrotation-=45;
5939 if(forwardkeydown)targetrotation-=45;
5940 if(backkeydown)targetrotation+=45;
5943 if ( !leftkeydown&&!rightkeydown)
5944 targetrotation+=180;
5946 targetrotation+=180;
5950 if(abs(targettilt2)>50)targettilt2=0;
5951 currentanimation=tempanim;
5956 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5958 for(i=0;i<skeleton.num_joints;i++){
5959 tempanimation.position[i][0]=skeleton.joints[i].position;
5960 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5967 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5968 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5971 tempvelocity=velocity;
5972 Normalise(&tempvelocity);
5973 targetrotation=-asin(0-tempvelocity.x);
5974 targetrotation*=360/6.28;
5975 if(velocity.z<0)targetrotation=180-targetrotation;
5976 //targetrotation+=180;
5979 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5980 targetanimation=rollanim;
5984 targetanimation=backhandspringanim;
5985 targetrotation+=180;
5998 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, TRUE);
5999 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6000 FSOUND_SetVolume(channels[movewhooshsound], 128);
6001 FSOUND_SetPaused(channels[movewhooshsound], FALSE);
6003 currentanimation=targetanimation;
6004 currentframe=targetframe-1;
6009 rotation=targetrotation;
6016 if(skeleton.freefall==0)freefall=0;
6018 if(!isnormal(velocity.x)&&velocity.x){
6023 if(aitype!=passivetype||skeleton.free==1)
6024 if(findLengthfast(&velocity)>.1)
6025 for(i=0;i<objects.numobjects;i++){
6026 if(objects.type[i]==firetype)
6027 if(findDistancefastflat(&coords,&objects.position[i])<objects.scale[i]*objects.scale[i]*12&&findDistancefast(&coords,&objects.position[i])<objects.scale[i]*objects.scale[i]*49){
6029 if(!objects.onfire[i]){
6032 gLoc[0]=objects.position[i].x;
6033 gLoc[1]=objects.position[i].y;
6034 gLoc[2]=objects.position[i].z;
6038 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
6039 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6040 FSOUND_SetVolume(channels[firestartsound], 256);
6041 FSOUND_SetPaused(channels[firestartsound], FALSE);
6043 objects.onfire[i]=1;
6046 if(objects.onfire[i]){
6051 if(objects.type[i]==bushtype)
6052 if(findDistancefastflat(&coords,&objects.position[i])<objects.scale[i]*objects.scale[i]*12&&findDistancefast(&coords,&objects.position[i])<objects.scale[i]*objects.scale[i]*49){
6054 if(!objects.onfire[i]){
6057 gLoc[0]=objects.position[i].x;
6058 gLoc[1]=objects.position[i].y;
6059 gLoc[2]=objects.position[i].z;
6063 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
6064 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6065 FSOUND_SetVolume(channels[firestartsound], 256);
6066 FSOUND_SetPaused(channels[firestartsound], FALSE);
6068 objects.onfire[i]=1;
6072 if(objects.onfire[i]){
6076 if(objects.messedwith[i]<=0){
6088 PlaySoundEx( bushrustle, samp[bushrustle], NULL, TRUE);
6089 FSOUND_3D_SetAttributes(channels[bushrustle], gLoc, vel);
6090 FSOUND_SetVolume(channels[bushrustle], 40*findLength(&velocity));
6091 FSOUND_SetPaused(channels[bushrustle], FALSE);
6094 envsound[numenvsounds]=coords;
6095 envsoundvol[numenvsounds]=4*findLength(&velocity);
6096 envsoundlife[numenvsounds]=.4;
6101 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6102 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6104 if(environment!=desertenvironment)
6105 for(j=0;j<howmany;j++){
6106 tempvel.x=float(abs(Random()%100)-50)/20;
6107 tempvel.y=float(abs(Random()%100)-50)/20;
6108 tempvel.z=float(abs(Random()%100)-50)/20;
6111 pos.x+=float(abs(Random()%100)-50)/200;
6112 pos.y+=float(abs(Random()%100)-50)/200;
6113 pos.z+=float(abs(Random()%100)-50)/200;
6114 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);
6115 sprites.special[sprites.numsprites-1]=1;
6117 howmany=findLength(&velocity)*4;
6119 if(environment==snowyenvironment)
6120 for(j=0;j<howmany;j++){
6121 tempvel.x=float(abs(Random()%100)-50)/20;
6122 tempvel.y=float(abs(Random()%100)-50)/20;
6123 tempvel.z=float(abs(Random()%100)-50)/20;
6126 pos.x+=float(abs(Random()%100)-50)/200;
6127 pos.y+=float(abs(Random()%100)-50)/200;
6128 pos.z+=float(abs(Random()%100)-50)/200;
6129 sprites.MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6130 sprites.special[sprites.numsprites-1]=2;
6133 objects.rotx[i]+=velocity.x*multiplier*6;
6134 objects.roty[i]+=velocity.z*multiplier*6;
6135 objects.messedwith[i]=.5;
6138 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
6139 if(objects.rotation2[i]==0)tempcoord=coords;
6141 tempcoord=coords-objects.position[i];
6142 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
6143 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
6144 tempcoord+=objects.position[i];
6146 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]){
6148 if(!objects.onfire[i]){
6151 gLoc[0]=objects.position[i].x;
6152 gLoc[1]=objects.position[i].y;
6153 gLoc[2]=objects.position[i].z;
6157 PlaySoundEx( firestartsound, samp[firestartsound], NULL, TRUE);
6158 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6159 FSOUND_SetVolume(channels[firestartsound], 256);
6160 FSOUND_SetPaused(channels[firestartsound], FALSE);
6161 objects.onfire[i]=1;
6164 if(objects.messedwith[i]<=0){
6176 PlaySoundEx( bushrustle, samp[bushrustle], NULL, TRUE);
6177 FSOUND_3D_SetAttributes(channels[bushrustle], gLoc, vel);
6178 FSOUND_SetVolume(channels[bushrustle], 40*findLength(&velocity));
6179 FSOUND_SetPaused(channels[bushrustle], FALSE);
6182 envsound[numenvsounds]=coords;
6183 envsoundvol[numenvsounds]=4*findLength(&velocity);
6184 envsoundlife[numenvsounds]=.4;
6189 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6190 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6192 if(environment!=desertenvironment)
6193 for(j=0;j<howmany;j++){
6194 tempvel.x=float(abs(Random()%100)-50)/20;
6195 tempvel.y=float(abs(Random()%100)-50)/20;
6196 tempvel.z=float(abs(Random()%100)-50)/20;
6200 pos.x+=float(abs(Random()%100)-50)/150;
6201 pos.y+=float(abs(Random()%100)-50)/150;
6202 pos.z+=float(abs(Random()%100)-50)/150;
6203 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);
6204 sprites.special[sprites.numsprites-1]=1;
6206 howmany=findLength(&velocity)*4;
6208 if(environment==snowyenvironment)
6209 for(j=0;j<howmany;j++){
6210 tempvel.x=float(abs(Random()%100)-50)/20;
6211 tempvel.y=float(abs(Random()%100)-50)/20;
6212 tempvel.z=float(abs(Random()%100)-50)/20;
6216 pos.x+=float(abs(Random()%100)-50)/150;
6217 pos.y+=float(abs(Random()%100)-50)/150;
6218 pos.z+=float(abs(Random()%100)-50)/150;
6219 sprites.MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6220 sprites.special[sprites.numsprites-1]=2;
6223 objects.messedwith[i]=.5;
6231 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
6233 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
6234 if(tutoriallevel==1&&id!=0)play=0;
6235 if(play&&aitype!=playercontrolled){
6247 if(creature==rabbittype){
6248 if(i==0)whichsound=rabbitchitter;
6249 if(i==1)whichsound=rabbitchitter2;
6251 if(creature==wolftype){
6252 if(i==0)whichsound=growlsound;
6253 if(i==1)whichsound=growl2sound;
6257 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
6258 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
6261 PlaySoundEx( whichsound, samp[whichsound], NULL, TRUE);
6262 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
6263 FSOUND_SetVolume(channels[whichsound], 512);
6264 FSOUND_SetPaused(channels[whichsound], FALSE);
6268 if(targetanimation==staggerbackhighanim)staggerdelay=1;
6269 if(targetanimation==staggerbackhardanim)staggerdelay=1;
6270 staggerdelay-=multiplier;
6271 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
6272 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
6273 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
6274 targetanimation=getIdle();
6278 weaponmissdelay-=multiplier;
6279 highreversaldelay-=multiplier;
6280 lowreversaldelay-=multiplier;
6281 lastcollide-=multiplier;
6282 skiddelay-=multiplier;
6283 if(!isnormal(velocity.x)&&velocity.x){
6286 if(!isnormal(targettilt)&&targettilt){
6289 if(!isnormal(targettilt2)&&targettilt2){
6292 if(!isnormal(targetrotation)&&targetrotation){
6296 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
6297 //open hands and close mouth
6298 //if(targetanimation!=wolfidle){
6299 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6300 righthandmorphness=0;
6301 righthandmorphend=0;
6302 targetrighthandmorphness=1;
6305 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6306 lefthandmorphness=0;
6308 targetlefthandmorphness=1;
6312 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
6315 targetheadmorphness=1;
6319 if(targetanimation==rollanim||targetanimation==dodgebackanim||targetanimation==removeknifeanim||targetanimation==knifefightidleanim||targetanimation==swordfightidleanim||targetanimation==blockhighleftstrikeanim||targetanimation==crouchremoveknifeanim||targetanimation==sneakanim||targetanimation==sweepanim||targetanimation==spinkickreversedanim||targetanimation==jumpdownanim||isWallJump()||isFlip()||targetanimation==climbanim||isRun()||targetanimation==getupfrombackanim||targetanimation==getupfromfrontanim){
6320 //open hands and mouth
6321 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6322 righthandmorphness=0;
6323 righthandmorphend=0;
6324 targetrighthandmorphness=1;
6327 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6328 lefthandmorphness=0;
6330 targetlefthandmorphness=1;
6333 if(headmorphend!=1&&headmorphness==targetheadmorphness){
6336 targetheadmorphness=1;
6340 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
6341 //close hands and mouth
6342 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6343 righthandmorphness=0;
6344 righthandmorphend=1;
6345 targetrighthandmorphness=1;
6348 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6349 lefthandmorphness=0;
6351 targetlefthandmorphness=1;
6354 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6357 targetheadmorphness=1;
6361 if(targetanimation==spinkickanim||targetanimation==staffspinhitreversalanim||targetanimation==staffspinhitreversedanim||targetanimation==staffhitreversalanim||targetanimation==staffhitreversedanim||targetanimation==hurtidleanim||targetanimation==winduppunchanim||targetanimation==swordslashreversalanim||targetanimation==swordslashreversedanim||targetanimation==knifeslashreversalanim||targetanimation==knifeslashreversedanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==knifefollowedanim||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==upunchanim||targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim||targetanimation==staffgroundsmashanim||targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==lowkickanim||targetanimation==sweepreversedanim||targetanimation==rabbitkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversalanim||targetanimation==jumpreversedanim){
6362 //close hands and yell
6363 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6364 righthandmorphness=0;
6365 righthandmorphend=1;
6366 targetrighthandmorphness=1;
6369 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6370 lefthandmorphness=0;
6372 targetlefthandmorphness=1;
6375 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6378 targetheadmorphness=1;
6382 if(speechdelay>.25){
6383 if(headmorphend!=2)headmorphness=0;
6385 targetheadmorphness=1;
6391 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6392 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6396 if(!dead&&targetanimation!=hurtidleanim)
6397 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6398 if(headmorphend!=4||headmorphness==targetheadmorphness){
6401 targetheadmorphness=1;
6405 if(weaponactive!=-1){
6406 if(weapons.type[weaponids[weaponactive]]!=staff){
6407 righthandmorphstart=1;
6408 righthandmorphend=1;
6410 if(weapons.type[weaponids[weaponactive]]==staff){
6411 righthandmorphstart=2;
6412 righthandmorphend=2;
6414 targetrighthandmorphness=1;
6417 terrainnormal=terrain.getNormal(coords.x,coords.z);
6419 if(animation[targetanimation].attack!=reversal){
6420 if(!isnormal(coords.x))
6428 flatfacing=DoRotation(flatfacing,0,rotation,0);
6430 ReflectVector(&facing,&terrainnormal);
6433 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6434 if(onterrain)targettilt2=-facing.y*20;
6438 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6439 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6440 flatvelocity=velocity;
6442 flatvelspeed=findLength(&flatvelocity);
6443 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6444 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6445 if(velocity.y<0)targettilt2*=-1;
6446 if(velocity.y<0)targettilt*=-1;
6447 if(targettilt>25)targettilt=25;
6448 if(targettilt<-25)targettilt=-25;
6451 if(targettilt2>45)targettilt2=45;
6452 if(targettilt2<-45)targettilt2=-45;
6453 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6454 else if(tilt2>targettilt2){
6455 tilt2-=multiplier*400;
6457 else if(tilt2<targettilt2){
6458 tilt2+=multiplier*400;
6460 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6461 if(tilt2>25)tilt2=25;
6462 if(tilt2<-25)tilt2=-25;
6465 if(!isnormal(targettilt)&&targettilt){
6468 if(!isnormal(targettilt2)&&targettilt2){
6473 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6474 if(targetanimation==rabbittackleanim){
6475 velocity+=facing*multiplier*speed*700*scale;
6476 velspeed=findLength(&velocity);
6477 if(velspeed>speed*65*scale){
6479 velspeed=speed*65*scale;
6482 velocity.y+=gravity*multiplier*20;
6483 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6484 velspeed=findLength(&velocity);
6485 velocity=flatfacing*velspeed;
6487 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6488 if(isRun()||targetanimation==rabbitkickanim){
6489 velocity+=facing*multiplier*speed*700*scale;
6490 velspeed=findLength(&velocity);
6491 if(velspeed>speed*45*scale){
6493 velspeed=speed*45*scale;
6496 velocity.y+=gravity*multiplier*20;
6497 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6498 velspeed=findLength(&velocity);
6499 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6500 velocity=flatfacing*velspeed;
6504 velocity+=facing*multiplier*speed*700*scale;
6505 velspeed=findLength(&velocity);
6506 if(creature==rabbittype){
6507 if(velspeed>speed*55*scale){
6509 velspeed=speed*55*scale;
6513 if(creature==wolftype){
6514 if(velspeed>speed*75*scale){
6516 velspeed=speed*75*scale;
6520 velocity.y+=gravity*multiplier*20;
6521 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6522 velspeed=findLength(&velocity);
6523 velocity=flatfacing*velspeed;
6526 /*if(creature==wolftype)
6528 velocity+=facing*multiplier*speed*700*scale;
6529 velspeed=findLength(&velocity);
6530 if(velspeed>speed*55*scale){
6532 velspeed=speed*55*scale;
6535 velocity.y+=gravity*multiplier*20;
6536 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6537 velspeed=findLength(&velocity);
6538 velocity=flatfacing*velspeed;
6541 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6542 velocity+=facing*multiplier*speed*700*scale;
6543 velspeed=findLength(&velocity);
6544 if(velspeed>speed*45*scale){
6546 velspeed=speed*45*scale;
6549 velocity.y+=gravity*multiplier*20;
6550 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6551 velspeed=findLength(&velocity);
6552 velocity=flatfacing*velspeed;
6556 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6557 velocity+=facing*multiplier*speed*700*scale;
6558 velspeed=findLength(&velocity);
6559 if(velspeed>speed*25*scale){
6561 velspeed=speed*25*scale;
6564 velocity.y+=gravity*multiplier*20;
6565 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6566 velspeed=findLength(&velocity);
6567 velocity=flatfacing*velspeed;
6570 if(targetanimation==sneakanim||targetanimation==walkanim){
6571 velocity+=facing*multiplier*speed*700*scale;
6572 velspeed=findLength(&velocity);
6573 if(velspeed>speed*12*scale){
6575 velspeed=speed*12*scale;
6578 velocity.y+=gravity*multiplier*20;
6579 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6580 velspeed=findLength(&velocity);
6581 velocity=flatfacing*velspeed;
6584 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6585 velocity+=facing*multiplier*speed*700*scale;
6586 velspeed=findLength(&velocity);
6587 if(velspeed>speed*2*scale){
6589 velspeed=speed*2*scale;
6592 velocity.y+=gravity*multiplier*20;
6593 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6594 velspeed=findLength(&velocity);
6595 velocity=flatfacing*velspeed;
6599 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6600 velocity-=facing*multiplier*speed*700*scale;
6601 velspeed=findLength(&velocity);
6602 if(velspeed>speed*2*scale){
6604 velspeed=speed*2*scale;
6607 velocity.y+=gravity*multiplier*20;
6608 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6609 velspeed=findLength(&velocity);
6610 velocity=flatfacing*velspeed*-1;
6613 if(targetanimation==fightsidestep){
6614 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6615 velspeed=findLength(&velocity);
6616 if(velspeed>speed*12*scale){
6618 velspeed=speed*12*scale;
6621 velocity.y+=gravity*multiplier*20;
6622 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6623 velspeed=findLength(&velocity);
6624 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6627 if(targetanimation==staggerbackhighanim){
6628 coords-=facing*multiplier*speed*16*scale;
6631 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6632 coords-=facing*multiplier*speed*20*scale;
6636 if(targetanimation==backhandspringanim){
6637 //coords-=facing*multiplier*50*scale;
6638 velocity+=facing*multiplier*speed*700*scale*-1;
6639 velspeed=findLength(&velocity);
6640 if(velspeed>speed*50*scale){
6642 velspeed=speed*50*scale;
6645 velocity.y+=gravity*multiplier*20;
6646 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6647 velspeed=findLength(&velocity);
6648 velocity=flatfacing*velspeed*-1;
6650 if(targetanimation==dodgebackanim){
6651 //coords-=facing*multiplier*50*scale;
6652 velocity+=facing*multiplier*speed*700*scale*-1;
6653 velspeed=findLength(&velocity);
6654 if(velspeed>speed*60*scale){
6656 velspeed=speed*60*scale;
6659 velocity.y+=gravity*multiplier*20;
6660 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6661 velspeed=findLength(&velocity);
6662 velocity=flatfacing*velspeed*-1;
6665 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6666 velspeed=findLength(&velocity);
6670 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6671 velocity.y+=gravity*multiplier;
6674 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6676 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6677 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6679 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6685 FSOUND_SetPaused(channels[whooshsound], TRUE);
6686 FSOUND_SetVolume(channels[whooshsound], 0);
6689 if(targetanimation==jumpdownanim||isFlip()){
6690 if(isFlip())jumppower=-4;
6691 targetanimation=getLanding();
6700 PlaySoundEx( landsound, samp[landsound], NULL, TRUE);
6701 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
6702 FSOUND_SetVolume(channels[landsound], 128);
6703 FSOUND_SetPaused(channels[landsound], FALSE);
6706 envsound[numenvsounds]=coords;
6707 envsoundvol[numenvsounds]=16;
6708 envsoundlife[numenvsounds]=.4;
6714 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6715 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6716 coords.y=terrain.getHeight(coords.x,coords.z);
6721 if(isIdle()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||isStop()||targetanimation==removeknifeanim||targetanimation==crouchremoveknifeanim||isLanding()||isCrouch()||animation[targetanimation].attack||(targetanimation==rollanim&&animation[targetanimation].label[targetframe]==6)){
6722 velspeed=findLength(&velocity);
6724 if(velspeed<multiplier*300*scale){
6726 } else velocity-=velocity/velspeed*multiplier*300*scale;
6727 if(velspeed>5&&(isLanding()||isLandhard())){
6728 skiddingdelay+=multiplier;
6735 else skiddingdelay=0;
6739 velspeed=findLength(&velocity);
6741 if(velspeed<multiplier*600*scale){
6743 } else velocity-=velocity/velspeed*multiplier*600*scale;
6745 if(velspeed>5&&(isLanding()||isLandhard())){
6746 skiddingdelay+=multiplier;
6753 else skiddingdelay=0;
6756 if(skiddingdelay<0)skiddingdelay+=multiplier;
6757 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6767 if(!onterrain||environment==grassyenvironment){
6768 PlaySoundEx( skidsound, samp[skidsound], NULL, TRUE);
6769 FSOUND_3D_SetAttributes(channels[skidsound], gLoc, vel);
6770 FSOUND_SetVolume(channels[skidsound], 128*velspeed/10);
6771 FSOUND_SetPaused(channels[skidsound], FALSE);
6774 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, TRUE);
6775 FSOUND_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6776 FSOUND_SetVolume(channels[snowskidsound], 128*velspeed/10);
6777 FSOUND_SetPaused(channels[snowskidsound], FALSE);
6781 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6782 terrainnormal=victim->coords-coords;
6783 Normalise(&terrainnormal);
6784 targetrotation=-asin(0-terrainnormal.x);
6785 targetrotation*=360/6.28;
6786 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6787 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6790 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6791 targetrotation=victim->targetrotation;
6793 if(targetanimation==rabbittacklinganim){
6794 coords=victim->coords;
6797 skeleton.oldfree=skeleton.free;
6801 midterrain.x=terrain.size*terrain.scale/2;
6802 midterrain.z=terrain.size*terrain.scale/2;
6803 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6805 tempposit=coords-midterrain;
6807 Normalise(&tempposit);
6808 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6809 coords.x=tempposit.x+midterrain.x;
6810 coords.z=tempposit.z+midterrain.z;
6814 int Person::DrawSkeleton(){
6815 int oldplayerdetail;
6816 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6817 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6827 glAlphaFunc(GL_GREATER, 0.0001);
6829 float terrainheight;
6831 if(!isnormal(rotation))rotation=0;
6832 if(!isnormal(tilt))tilt=0;
6833 if(!isnormal(tilt2))tilt2=0;
6834 oldplayerdetail=playerdetail;
6836 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6839 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6842 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6845 if(id==0)playerdetail=1;
6846 if(playerdetail!=oldplayerdetail)updatedelay=0;
6847 if(playerdetail!=oldplayerdetail)normalsupdatedelay=0;
6848 static float updatedelaychange;
6849 static float morphness;
6850 static float framemult;
6852 skeleton.FindForwards();
6853 if(howactive==typesittingwall){
6854 skeleton.specialforward[1]=0;
6855 skeleton.specialforward[1].z=1;
6861 static int weaponattachmuscle;
6862 static int weaponrotatemuscle,weaponrotatemuscle2;
6863 static XYZ weaponpoint;
6864 static int start,endthing;
6865 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6866 if(!isSleeping()&&!isSitting()){
6867 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6868 XYZ point,newpoint,change,change2;
6869 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6870 heightleft=terrain.getHeight(point.x,point.z)+.04;
6872 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6873 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6874 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6875 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6876 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6878 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6879 heightright=terrain.getHeight(point.x,point.z)+.04;
6880 point.y=heightright;
6881 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6882 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6883 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6884 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6885 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6886 skeleton.DoConstraints(&coords,&scale);
6888 if(creature==wolftype){
6889 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6890 heightleft=terrain.getHeight(point.x,point.z)+.04;
6892 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6893 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6894 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6895 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6896 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6898 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6899 heightright=terrain.getHeight(point.x,point.z)+.04;
6900 point.y=heightright;
6901 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6902 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6903 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6904 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6905 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6906 skeleton.DoConstraints(&coords,&scale);
6909 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6910 XYZ point,newpoint,change,change2;
6911 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6912 heightleft=terrain.getHeight(point.x,point.z)+.04;
6914 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6915 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6916 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6917 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6918 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6920 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6921 heightright=terrain.getHeight(point.x,point.z)+.04;
6922 point.y=heightright;
6923 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6924 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6925 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6926 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6927 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6928 skeleton.DoConstraints(&coords,&scale);
6930 if(creature==wolftype){
6931 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6932 heightleft=terrain.getHeight(point.x,point.z)+.04;
6934 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6935 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6936 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6937 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6938 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6940 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6941 heightright=terrain.getHeight(point.x,point.z)+.04;
6942 point.y=heightright;
6943 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6944 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6945 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6946 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6947 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6948 skeleton.DoConstraints(&coords,&scale);
6952 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6953 XYZ point,newpoint,change,change2;
6954 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6955 heightleft=terrain.getHeight(point.x,point.z)+.04;
6957 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6958 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6959 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6960 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6961 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6963 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6964 heightright=terrain.getHeight(point.x,point.z)+.04;
6965 point.y=heightright;
6966 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6967 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6968 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6969 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6970 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6971 skeleton.DoConstraints(&coords,&scale);
6973 if(creature==wolftype){
6974 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6975 heightleft=terrain.getHeight(point.x,point.z)+.04;
6977 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6978 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6979 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6980 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6981 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6983 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6984 heightright=terrain.getHeight(point.x,point.z)+.04;
6985 point.y=heightright;
6986 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6987 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6988 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6989 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6990 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6991 skeleton.DoConstraints(&coords,&scale);
6995 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();
6997 targetheadrotation=-targetrotation;
6998 targetheadrotation2=0;
6999 if(animation[targetanimation].attack==3)targetheadrotation+=180;
7001 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7002 skeleton.drawmodel.vertex[i]=0;
7003 skeleton.drawmodel.vertex[i].y=999;
7005 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
7006 skeleton.drawmodellow.vertex[i]=0;
7007 skeleton.drawmodellow.vertex[i].y=999;
7009 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
7010 skeleton.drawmodelclothes.vertex[i]=0;
7011 skeleton.drawmodelclothes.vertex[i].y=999;
7013 for(i=0;i<skeleton.num_muscles;i++){
7014 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
7018 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
7019 morphness=righthandmorphness;
7020 start=righthandmorphstart;
7021 endthing=righthandmorphend;
7023 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
7024 morphness=lefthandmorphness;
7025 start=lefthandmorphstart;
7026 endthing=lefthandmorphend;
7028 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
7029 morphness=headmorphness;
7030 start=headmorphstart;
7031 endthing=headmorphend;
7033 if((skeleton.muscles[i].parent1->label==neck&&skeleton.muscles[i].parent2->label==abdomen)||(skeleton.muscles[i].parent2->label==neck&&skeleton.muscles[i].parent1->label==abdomen)){
7034 morphness=chestmorphness;
7035 start=chestmorphstart;
7036 endthing=chestmorphend;
7038 if((skeleton.muscles[i].parent1->label==groin&&skeleton.muscles[i].parent2->label==abdomen)||(skeleton.muscles[i].parent2->label==groin&&skeleton.muscles[i].parent1->label==abdomen)){
7039 morphness=tailmorphness;
7040 start=tailmorphstart;
7041 endthing=tailmorphend;
7043 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
7044 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
7045 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7048 if(!skeleton.free)glRotatef(tilt2,1,0,0);
7049 if(!skeleton.free)glRotatef(tilt,0,0,1);
7052 glTranslatef(mid.x,mid.y,mid.z);
7054 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
7055 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
7057 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
7058 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
7060 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
7061 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
7063 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
7067 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
7071 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
7075 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
7080 if(playerdetail||skeleton.free==3)
7082 for(j=0;j<skeleton.muscles[i].numvertices;j++)
7084 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
7085 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
7086 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
7087 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
7088 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
7089 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
7090 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
7091 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7093 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7094 glTranslatef((skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x*morphness)*proportionbody.x,
7095 (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y*morphness)*proportionbody.y,
7096 (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z*morphness)*proportionbody.z);
7097 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent1->label==leftwrist||skeleton.muscles[i].parent1->label==rightwrist||skeleton.muscles[i].parent1->label==leftelbow||skeleton.muscles[i].parent1->label==rightelbow||skeleton.muscles[i].parent2->label==leftelbow||skeleton.muscles[i].parent2->label==rightelbow)
7098 glTranslatef((skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x*morphness)*proportionarms.x,
7099 (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y*morphness)*proportionarms.y,
7100 (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z*morphness)*proportionarms.z);
7101 if(skeleton.muscles[i].parent1->label==leftfoot||skeleton.muscles[i].parent1->label==rightfoot||skeleton.muscles[i].parent1->label==leftankle||skeleton.muscles[i].parent1->label==rightankle||skeleton.muscles[i].parent1->label==leftknee||skeleton.muscles[i].parent1->label==rightknee||skeleton.muscles[i].parent2->label==leftknee||skeleton.muscles[i].parent2->label==rightknee)
7102 glTranslatef((skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x*morphness)*proportionlegs.x,
7103 (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y*morphness)*proportionlegs.y,
7104 (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z*morphness)*proportionlegs.z);
7105 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7106 glTranslatef((skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x*morphness)*proportionhead.x,
7107 (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y*morphness)*proportionhead.y,
7108 (skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z*(1-morphness)+skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z*morphness)*proportionhead.z);
7109 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7110 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
7111 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
7112 //if(!isnormal(scale))test=1;
7113 //if(isnormal(scale)){
7114 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
7115 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
7116 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
7124 if(!playerdetail||skeleton.free==3)
7126 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
7128 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
7129 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7131 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7132 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
7133 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
7134 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
7135 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent1->label==leftwrist||skeleton.muscles[i].parent1->label==rightwrist||skeleton.muscles[i].parent1->label==leftelbow||skeleton.muscles[i].parent1->label==rightelbow||skeleton.muscles[i].parent2->label==leftelbow||skeleton.muscles[i].parent2->label==rightelbow)
7136 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
7137 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
7138 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
7139 if(skeleton.muscles[i].parent1->label==leftfoot||skeleton.muscles[i].parent1->label==rightfoot||skeleton.muscles[i].parent1->label==leftankle||skeleton.muscles[i].parent1->label==rightankle||skeleton.muscles[i].parent1->label==leftknee||skeleton.muscles[i].parent1->label==rightknee||skeleton.muscles[i].parent2->label==leftknee||skeleton.muscles[i].parent2->label==rightknee)
7140 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
7141 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
7142 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
7143 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7144 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
7145 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
7146 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
7148 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7149 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
7150 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
7151 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
7158 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
7159 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
7161 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7164 if(!skeleton.free)glRotatef(tilt2,1,0,0);
7165 if(!skeleton.free)glRotatef(tilt,0,0,1);
7166 glTranslatef(mid.x,mid.y,mid.z);
7167 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
7168 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
7170 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
7171 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
7173 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
7174 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
7176 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
7177 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7179 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7180 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
7181 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
7182 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
7183 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent1->label==leftwrist||skeleton.muscles[i].parent1->label==rightwrist||skeleton.muscles[i].parent1->label==leftelbow||skeleton.muscles[i].parent1->label==rightelbow||skeleton.muscles[i].parent2->label==leftelbow||skeleton.muscles[i].parent2->label==rightelbow)
7184 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
7185 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
7186 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
7187 if(skeleton.muscles[i].parent1->label==leftfoot||skeleton.muscles[i].parent1->label==rightfoot||skeleton.muscles[i].parent1->label==leftankle||skeleton.muscles[i].parent1->label==rightankle||skeleton.muscles[i].parent1->label==leftknee||skeleton.muscles[i].parent1->label==rightknee||skeleton.muscles[i].parent2->label==leftknee||skeleton.muscles[i].parent2->label==rightknee)
7188 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
7189 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
7190 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
7191 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7192 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
7193 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
7194 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
7195 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7196 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
7197 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
7198 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
7203 updatedelay=1+(float)(Random()%100)/1000;
7205 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
7206 normalsupdatedelay=1;
7207 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
7208 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
7209 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
7213 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
7214 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
7215 if(skeleton.clothes){
7216 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
7221 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
7222 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
7223 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
7224 if(skeleton.free==1)updatedelaychange*=6;
7225 if(id==0)updatedelaychange*=8;
7226 updatedelay+=updatedelaychange;
7228 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7230 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7231 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7232 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
7233 if(!skeleton.free)glRotatef(rotation,0,1,0);
7236 glColor4f(.4,1,.4,1);
7237 glDisable(GL_LIGHTING);
7238 glDisable(GL_TEXTURE_2D);
7241 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7242 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
7248 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
7249 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].z);
7250 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].z);
7251 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].z);
7252 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].z);
7253 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].z);
7254 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].z);
7260 terrainlight=terrain.getLighting(coords.x,coords.z);
7261 distance=findDistancefast(&viewer,&coords);
7262 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
7263 if(distance>1)distance=1;
7265 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
7266 if(terrainheight<1)terrainheight=1;
7267 if(terrainheight>1.7)terrainheight=1.7;
7270 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
7271 glDisable(GL_BLEND);
7272 glAlphaFunc(GL_GREATER, 0.0001);
7273 glEnable(GL_TEXTURE_2D);
7275 glDisable(GL_TEXTURE_2D);
7276 glColor4f(.7,.35,0,.5);
7278 glEnable(GL_LIGHTING);
7281 if(tutoriallevel&&id!=0){
7282 //glDisable(GL_TEXTURE_2D);
7283 glColor4f(.7,.7,.7,0.6);
7285 glEnable(GL_LIGHTING);
7287 if(canattack&&cananger)
7288 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7289 glDisable(GL_TEXTURE_2D);
7290 glColor4f(1,0,0,0.8);
7292 glMatrixMode(GL_TEXTURE);
7294 glTranslatef(0,-smoketex,0);
7295 glTranslatef(-smoketex,0,0);
7299 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(sprites.cloudimpacttexture);
7300 else skeleton.drawmodel.draw();
7304 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(sprites.cloudimpacttexture);
7305 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7308 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
7309 if(tutoriallevel&&id!=0){
7311 glMatrixMode(GL_MODELVIEW);
7312 glEnable(GL_TEXTURE_2D);
7313 glColor4f(.7,.7,.7,0.6);
7315 glEnable(GL_LIGHTING);
7317 if(canattack&&cananger)
7318 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7319 glDisable(GL_TEXTURE_2D);
7320 glColor4f(1,0,0,0.8);
7322 glMatrixMode(GL_TEXTURE);
7324 glTranslatef(0,-smoketex*.6,0);
7325 glTranslatef(smoketex*.6,0,0);
7328 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(sprites.cloudimpacttexture);
7329 else skeleton.drawmodel.draw();
7333 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(sprites.cloudimpacttexture);
7334 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7339 if(tutoriallevel&&id!=0){
7341 glMatrixMode(GL_MODELVIEW);
7342 glEnable(GL_TEXTURE_2D);
7344 if(skeleton.clothes){
7347 if(!immediate)skeleton.drawmodelclothes.draw();
7348 if(immediate)skeleton.drawmodelclothes.drawimmediate();
7355 for(k=0;k<num_weapons;k++){
7357 if(weaponactive==k){
7358 if(weapons.type[i]!=staff){
7359 for(j=0;j<skeleton.num_muscles;j++){
7360 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7361 weaponattachmuscle=j;
7364 for(j=0;j<skeleton.num_muscles;j++){
7365 if((skeleton.muscles[j].parent1->label==rightwrist||skeleton.muscles[j].parent2->label==rightwrist)&&(skeleton.muscles[j].parent1->label!=righthand&&skeleton.muscles[j].parent2->label!=righthand)&&skeleton.muscles[j].numvertices>0){
7366 weaponrotatemuscle=j;
7369 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7370 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7372 if(weapons.type[i]==staff){
7373 for(j=0;j<skeleton.num_muscles;j++){
7374 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7375 weaponattachmuscle=j;
7378 for(j=0;j<skeleton.num_muscles;j++){
7379 if((skeleton.muscles[j].parent1->label==rightelbow||skeleton.muscles[j].parent2->label==rightelbow)&&(skeleton.muscles[j].parent1->label!=rightshoulder&&skeleton.muscles[j].parent2->label!=rightshoulder)&&skeleton.muscles[j].numvertices>0){
7380 weaponrotatemuscle=j;
7383 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7384 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7385 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7386 XYZ tempnormthing,vec1,vec2;
7387 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7388 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7389 CrossProduct(&vec1,&vec2,&tempnormthing);
7390 Normalise(&tempnormthing);
7391 if(targetanimation!=staffhitanim&¤tanimation!=staffhitanim&&targetanimation!=staffgroundsmashanim&¤tanimation!=staffgroundsmashanim&&targetanimation!=staffspinhitanim&¤tanimation!=staffspinhitanim)weaponpoint+=tempnormthing*.1-skeleton.specialforward[1]*.3+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7392 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7394 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7395 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7396 Normalise(&weaptargnorm);
7397 weaponpoint-=weaptargnorm*2;
7401 if(weaponactive!=k&&weaponstuck!=k){
7402 if(weapons.type[i]==knife)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[righthip]].position-skeleton.joints[skeleton.jointlabels[lefthip]].position)*.1+(skeleton.joints[skeleton.jointlabels[rightshoulder]].position-skeleton.joints[skeleton.jointlabels[leftshoulder]].position)*.35;
7403 if(weapons.type[i]==sword)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[lefthip]].position-skeleton.joints[skeleton.jointlabels[righthip]].position)*.09+(skeleton.joints[skeleton.jointlabels[leftshoulder]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position)*.33;
7404 if(weapons.type[i]==staff)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position+(skeleton.joints[skeleton.jointlabels[lefthip]].position-skeleton.joints[skeleton.jointlabels[righthip]].position)*.09+(skeleton.joints[skeleton.jointlabels[leftshoulder]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position)*.33;
7405 for(j=0;j<skeleton.num_muscles;j++){
7406 if((skeleton.muscles[j].parent1->label==abdomen||skeleton.muscles[j].parent2->label==abdomen)&&(skeleton.muscles[j].parent1->label==neck||skeleton.muscles[j].parent2->label==neck)&&skeleton.muscles[j].numvertices>0){
7407 weaponrotatemuscle=j;
7412 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7413 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7414 for(j=0;j<skeleton.num_muscles;j++){
7415 if((skeleton.muscles[j].parent1->label==abdomen||skeleton.muscles[j].parent2->label==abdomen)&&(skeleton.muscles[j].parent1->label==neck||skeleton.muscles[j].parent2->label==neck)&&skeleton.muscles[j].numvertices>0){
7416 weaponrotatemuscle=j;
7421 weapons.position[i]=DoRotation(DoRotation(DoRotation(weaponpoint,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords+currentoffset*(1-target)*scale+targetoffset*target*scale;
7422 weapons.bigrotation[i]=rotation;
7423 weapons.bigtilt[i]=tilt;
7424 weapons.bigtilt2[i]=tilt2;
7427 weapons.position[i]=weaponpoint*scale+coords;
7428 weapons.bigrotation[i]=0;
7429 weapons.bigtilt[i]=0;
7430 weapons.bigtilt2[i]=0;
7432 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7433 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7434 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7435 if(weaponactive==k){
7436 if(weapons.type[i]==knife){
7437 weapons.smallrotation[i]=180;
7438 weapons.smallrotation2[i]=0;
7439 if(isCrouch()||wasCrouch()){
7440 weapons.smallrotation2[i]=20;
7442 if(targetanimation==hurtidleanim){
7443 weapons.smallrotation2[i]=50;
7445 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7446 XYZ temppoint1,temppoint2,tempforward;
7449 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7450 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7451 distance=findDistance(&temppoint1,&temppoint2);
7452 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7453 weapons.rotation2[i]*=360/6.28;
7456 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7457 weapons.rotation1[i]*=360/6.28;
7458 weapons.rotation3[i]=0;
7459 weapons.smallrotation[i]=-90;
7460 weapons.smallrotation2[i]=0;
7461 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7463 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7464 XYZ temppoint1,temppoint2,tempforward;
7467 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7468 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7469 distance=findDistance(&temppoint1,&temppoint2);
7470 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7471 weapons.rotation2[i]*=360/6.28;
7474 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7475 weapons.rotation1[i]*=360/6.28;
7476 weapons.rotation3[i]=0;
7477 weapons.smallrotation[i]=90;
7478 weapons.smallrotation2[i]=0;
7479 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7481 if(targetanimation==knifethrowanim){
7482 weapons.smallrotation[i]=90;
7483 //weapons.smallrotation2[i]=-90;
7484 weapons.smallrotation2[i]=0;
7485 weapons.rotation1[i]=0;
7486 weapons.rotation2[i]=0;
7487 weapons.rotation3[i]=0;
7489 if(targetanimation==knifesneakattackanim&&targetframe<5){
7490 weapons.smallrotation[i]=-90;
7491 weapons.rotation1[i]=0;
7492 weapons.rotation2[i]=0;
7493 weapons.rotation3[i]=0;
7496 if(weapons.type[i]==sword){
7497 weapons.smallrotation[i]=0;
7498 weapons.smallrotation2[i]=0;
7499 if(targetanimation==knifethrowanim){
7500 weapons.smallrotation[i]=-90;
7501 weapons.smallrotation2[i]=0;
7502 weapons.rotation1[i]=0;
7503 weapons.rotation2[i]=0;
7504 weapons.rotation3[i]=0;
7506 if((targetanimation==swordgroundstabanim&¤tanimation==swordgroundstabanim)||(targetanimation==swordsneakattackanim&¤tanimation==swordsneakattackanim)||(targetanimation==swordslashparryanim&¤tanimation==swordslashparryanim)||(targetanimation==swordslashparriedanim&¤tanimation==swordslashparriedanim)||(targetanimation==swordslashreversalanim&¤tanimation==swordslashreversalanim)||(targetanimation==swordslashreversedanim&¤tanimation==swordslashreversedanim)||(targetanimation==knifeslashreversalanim&¤tanimation==knifeslashreversalanim)||(targetanimation==knifeslashreversedanim&¤tanimation==knifeslashreversedanim)||(targetanimation==swordslashanim&¤tanimation==swordslashanim)||(targetanimation==drawleftanim&¤tanimation==drawleftanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7507 XYZ temppoint1,temppoint2,tempforward;
7510 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7511 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7512 distance=findDistance(&temppoint1,&temppoint2);
7513 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7514 weapons.rotation2[i]*=360/6.28;
7517 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7518 weapons.rotation1[i]*=360/6.28;
7519 weapons.rotation3[i]=0;
7520 weapons.smallrotation[i]=90;
7521 weapons.smallrotation2[i]=0;
7522 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7525 if(weapons.type[i]==staff){
7526 weapons.smallrotation[i]=100;
7527 weapons.smallrotation2[i]=0;
7528 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7529 XYZ temppoint1,temppoint2,tempforward;
7532 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7533 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7534 distance=findDistance(&temppoint1,&temppoint2);
7535 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7536 weapons.rotation2[i]*=360/6.28;
7539 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7540 weapons.rotation1[i]*=360/6.28;
7541 weapons.rotation3[i]=0;
7542 weapons.smallrotation[i]=90;
7543 weapons.smallrotation2[i]=0;
7544 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7548 if(weaponactive!=k&&weaponstuck!=k){
7549 if(weapons.type[i]==knife){
7550 weapons.smallrotation[i]=-70;
7551 weapons.smallrotation2[i]=10;
7553 if(weapons.type[i]==sword){
7554 weapons.smallrotation[i]=-100;
7555 weapons.smallrotation2[i]=-8;
7557 if(weapons.type[i]==staff){
7558 weapons.smallrotation[i]=-100;
7559 weapons.smallrotation2[i]=-8;
7563 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7564 else weapons.smallrotation[i]=0;
7565 weapons.smallrotation2[i]=10;
7566 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7574 if(skeleton.free)calcrot=1;
7575 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7576 if(currentanimation!=targetanimation)calcrot=1;
7577 //if(id==0)calcrot=1;
7578 if(skeleton.free==2)calcrot=0;
7584 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7587 static float distance;
7588 static float olddistance;
7589 static int intersecting;
7590 static int firstintersecting;
7593 static XYZ start,end;
7594 static float slopethreshold=-.4;
7596 firstintersecting=-1;
7600 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7601 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7603 for (j=0;j<model->TriangleNum;j++){
7604 if(model->facenormals[j].y<=slopethreshold){
7606 distance=abs((model->facenormals[j].x*p1->x)+(model->facenormals[j].y*p1->y)+(model->facenormals[j].z*p1->z)-((model->facenormals[j].x*model->vertex[model->Triangles[j].vertex[0]].x)+(model->facenormals[j].y*model->vertex[model->Triangles[j].vertex[0]].y)+(model->facenormals[j].z*model->vertex[model->Triangles[j].vertex[0]].z)));
7607 if(distance<radius){
7608 point=*p1-model->facenormals[j]*distance;
7609 if(PointInTriangle( &point, model->facenormals[j], &model->vertex[model->Triangles[j].vertex[0]], &model->vertex[model->Triangles[j].vertex[1]], &model->vertex[model->Triangles[j].vertex[2]]))intersecting=1;
7610 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7611 &model->vertex[model->Triangles[j].vertex[1]],
7613 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7614 &model->vertex[model->Triangles[j].vertex[2]],
7616 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7617 &model->vertex[model->Triangles[j].vertex[2]],
7620 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7624 if(LineFacetd(&start,&end,&model->vertex[model->Triangles[j].vertex[0]],&model->vertex[model->Triangles[j].vertex[1]],&model->vertex[model->Triangles[j].vertex[2]],&model->facenormals[j],&point)){
7625 p1->y=point.y+radius;
7626 if((targetanimation==jumpdownanim||isFlip())){
7627 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7629 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7635 FSOUND_SetPaused(channels[whooshsound], TRUE);
7636 FSOUND_SetVolume(channels[whooshsound], 0);
7639 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7640 if(isFlip())jumppower=-4;
7641 targetanimation=getLanding();
7650 PlaySoundEx( landsound, samp[landsound], NULL, TRUE);
7651 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
7652 FSOUND_SetVolume(channels[landsound], 128);
7653 FSOUND_SetPaused(channels[landsound], FALSE);
7656 envsound[numenvsounds]=coords;
7657 envsoundvol[numenvsounds]=16;
7658 envsoundlife[numenvsounds]=.4;
7666 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7669 for (j=0;j<model->TriangleNum;j++){
7670 if(model->facenormals[j].y>slopethreshold){
7674 distance=abs((model->facenormals[j].x*start.x)+(model->facenormals[j].y*start.y)+(model->facenormals[j].z*start.z)-((model->facenormals[j].x*model->vertex[model->Triangles[j].vertex[0]].x)+(model->facenormals[j].y*model->vertex[model->Triangles[j].vertex[0]].y)+(model->facenormals[j].z*model->vertex[model->Triangles[j].vertex[0]].z)));
7675 if(distance<radius*.5){
7676 point=start-model->facenormals[j]*distance;
7677 if(PointInTriangle( &point, model->facenormals[j], &model->vertex[model->Triangles[j].vertex[0]], &model->vertex[model->Triangles[j].vertex[1]], &model->vertex[model->Triangles[j].vertex[2]]))intersecting=1;
7678 if(!intersecting)intersecting=sphere_line_intersection(model->vertex[model->Triangles[j].vertex[0]].x,model->vertex[model->Triangles[j].vertex[0]].y,model->vertex[model->Triangles[j].vertex[0]].z,
7679 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7680 p1->x, p1->y, p1->z, radius/2);
7681 if(!intersecting)intersecting=sphere_line_intersection(model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7682 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7683 p1->x, p1->y, p1->z, radius/2);
7684 if(!intersecting)intersecting=sphere_line_intersection(model->vertex[model->Triangles[j].vertex[0]].x,model->vertex[model->Triangles[j].vertex[0]].y,model->vertex[model->Triangles[j].vertex[0]].z,
7685 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7686 p1->x, p1->y, p1->z, radius/2);
7688 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7689 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7691 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7692 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7694 *p1+=model->facenormals[j]*(distance-radius*.5);
7697 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7701 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7703 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7705 return firstintersecting;
7715 currentanimation = 0;
7716 targetanimation = 0;
7717 oldcurrentframe = 0;
7719 oldcurrentanimation = 0;
7720 oldtargetanimation = 0;
7724 parriedrecently = 0;
7728 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7730 currentoffset = 0,targetoffset = 0,offset = 0;
7748 unconscioustime = 0;
7766 rabbitkickenabled = 0;
7775 damagetolerance = 0;
7777 permanentdamage = 0;
7778 superpermanentdamage = 0; lastcollide = 0;
7798 headrotation = 0,headrotation2 = 0;
7799 targetheadrotation = 0,targetheadrotation2 = 0;
7810 normalsupdatedelay = 0;
7815 forwardstogglekeydown = 0;
7820 jumptogglekeydown = 0;
7822 crouchtogglekeydown = 0;
7824 drawtogglekeydown = 0;
7826 throwtogglekeydown = 0;
7832 crouchkeydowntime = 0;
7833 jumpkeydowntime = 0;
7850 whichdirectiondelay = 0;
7851 avoidsomething = 0; avoidwhere = 0;
7859 lefthandmorphness = 0;
7860 righthandmorphness = 0;
7864 targetlefthandmorphness = 0;
7865 targetrighthandmorphness = 0;
7866 targetheadmorphness = 0;
7867 targetchestmorphness = 0;
7868 targettailmorphness = 0;
7869 lefthandmorphstart = 0,lefthandmorphend = 0;
7870 righthandmorphstart = 0,righthandmorphend = 0;
7871 headmorphstart = 0,headmorphend = 0;
7872 chestmorphstart = 0,chestmorphend = 0;
7873 tailmorphstart = 0,tailmorphend = 0;
7875 weaponmissdelay = 0;
7876 highreversaldelay = 0;
7877 lowreversaldelay = 0;
7884 //Skeleton skeleton;
7903 memset(clothes, 0, sizeof(clothes));
7904 memset(clothestintr, 0, sizeof(clothestintr));
7905 memset(clothestintg, 0, sizeof(clothestintg));
7906 memset(clothestintb, 0, sizeof(clothestintb));
7912 onfiredelay = 0; burnt = 0;
7916 updatestuffdelay = 0;
7922 memset(weaponids, 0, sizeof(weaponids));
7926 weaponstuckwhere = 0;
7931 memset(waypoints, 0, sizeof(waypoints));
7932 memset(waypointtype, 0, sizeof(waypointtype));
7935 hastempwaypoint = 0;
7941 finalfinaltarget = 0;
7943 finalpathfindpoint = 0;
7944 targetpathfindpoint = 0;
7945 lastpathfindpoint = 0;
7946 lastpathfindpoint2 = 0;
7947 lastpathfindpoint3 = 0;
7948 lastpathfindpoint4 = 0;
7959 runninghowlong = 0; lastoccluded = 0;
7965 neckspurtparticledelay = 0;
7966 neckspurtamount = 0;
7969 rabbitkickragdoll = 0;
7974 //Animation tempanimation;