2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /**> HEADER FILES <**/
25 extern float multiplier;
26 extern Animation animation[animation_count];
27 extern FSOUND_SAMPLE *samp[100];
28 extern int channels[100];
29 extern Terrain terrain;
31 extern int environment;
32 extern Sprites sprites;
34 extern FRUSTUM frustum;
36 extern float realmultiplier;
38 extern float slomodelay;
39 extern bool cellophane;
40 extern float texdetail;
41 extern float realtexdetail;
42 extern GLubyte bloodText[512*512*3];
43 extern GLubyte wolfbloodText[512*512*3];
44 extern int bloodtoggle;
45 extern Objects objects;
47 extern bool autoslomo;
48 extern float camerashake;
50 extern float terraindetail;
51 extern float viewdistance;
52 extern float blackout;
53 extern int difficulty;
54 extern Weapons weapons;
56 extern float fadestart;
57 extern Person player[maxplayers];
58 extern int numplayers;
60 extern bool winfreeze;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
63 extern bool showpoints;
64 extern bool immediate;
66 extern bool tilt2weird;
67 extern bool tiltweird;
69 extern bool proportionweird;
70 extern bool vertexweird[6];
71 extern GLubyte texturearray[512*512*3];
72 extern XYZ envsound[30];
73 extern float envsoundvol[30];
74 extern float envsoundlife[30];
75 extern int numenvsounds;
77 extern float bonusvalue;
78 extern float bonustotal;
79 extern float bonustime;
80 extern int tutoriallevel;
81 extern float smoketex;
82 extern int tutorialstage;
83 extern bool reversaltrain;
84 extern bool canattack;
86 extern float damagedealt;
87 extern float damagetaken;
89 extern float hostiletime;
94 extern int numflipfail;
96 extern int numswordattack;
97 extern int numknifeattack;
98 extern int numunarmedattack;
99 extern int numescaped;
100 extern int numflipped;
101 extern int numwallflipped;
102 extern int numthrowkill;
103 extern int numafterkill;
104 extern int numreversals;
105 extern int numattacks;
106 extern int maxalarmed;
107 extern int indialogue;
109 extern bool gamestarted;
111 extern FSOUND_STREAM * strm[20];
112 extern "C" void PlaySoundEx(int channel, FSOUND_SAMPLE *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
113 extern "C" void PlayStreamEx(int chan, FSOUND_STREAM *sptr, FSOUND_DSPUNIT *dsp, signed char startpaused);
115 void Person::CheckKick(){
119 float damagemult=1*power;
120 if(creature==wolftype)damagemult=2.5*power;
124 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
125 if(findDistancefast(&coords,&victim->coords)<1.2){
126 if(!victim->skeleton.free){
128 Normalise(&relative);
129 relative=coords+relative*1;
130 if(animation[victim->targetanimation].height!=lowheight){
135 gLoc[0]=victim->coords.x;
136 gLoc[1]=victim->coords.y;
137 gLoc[2]=victim->coords.z;
141 if(tutoriallevel!=1){
142 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
143 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
144 FSOUND_SetVolume(channels[heavyimpactsound], 128);
145 FSOUND_SetPaused(channels[heavyimpactsound], false);
150 Normalise(&relative);
151 for(i=0;i<victim->skeleton.num_joints;i++){
152 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
155 victim->DoDamage(100*damagemult/victim->protectionhigh);
156 if(id==0)camerashake+=.4;
160 targetanimation=backflipanim;
165 if(id==0)FSOUND_SetPaused(channels[whooshsound], false);
167 //if(victim->damage>victim->damagetolerance){
175 else if (victim->isCrouch()){
176 targetanimation=rabbitkickreversedanim;
177 currentanimation=rabbitkickreversedanim;
178 victim->currentanimation=rabbitkickreversalanim;
179 victim->targetanimation=rabbitkickreversalanim;
185 victim->oldcoords=victim->coords;
186 coords=victim->coords;
187 victim->targetrotation=targetrotation;
195 void Person::CatchFire(){
196 XYZ flatfacing,flatvelocity;
198 for(int i=0;i<10;i++){
199 howmany=abs(Random()%(skeleton.num_joints));
200 if(!skeleton.free)flatvelocity=velocity;
201 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
202 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
203 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
204 sprites.MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
217 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
218 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
219 FSOUND_SetVolume(channels[firestartsound], 256);
220 FSOUND_SetPaused(channels[firestartsound], false);
225 //PlaySoundEx( firesound, samp[firesound], NULL, true);
226 PlayStreamEx( stream_firesound, strm[stream_firesound], NULL, true);
227 FSOUND_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
228 FSOUND_SetVolume(channels[stream_firesound], 256);
229 FSOUND_SetPaused(channels[stream_firesound], false);
236 bool Person::isIdle(){
237 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;
241 bool Person::isSitting(){
242 if(targetanimation==sitanim)return 1;
243 if(targetanimation==sitwallanim)return 1;
247 bool Person::isSleeping(){
248 if(targetanimation==sleepanim)return 1;
249 if(targetanimation==dead1anim)return 1;
250 if(targetanimation==dead2anim)return 1;
251 if(targetanimation==dead3anim)return 1;
252 if(targetanimation==dead4anim)return 1;
256 bool Person::wasIdle(){
257 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;
260 int Person::getIdle(){
261 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
262 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)){
263 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
264 if(creature==rabbittype)return fightidleanim;
265 if(creature==wolftype)return wolfidle;
267 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
268 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
269 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
270 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
271 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
273 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
275 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
276 if(howactive==typesitting)return sitanim;
277 if(howactive==typesittingwall)return sitwallanim;
278 if(howactive==typesleeping)return sleepanim;
279 if(howactive==typedead1)return dead1anim;
280 if(howactive==typedead2)return dead2anim;
281 if(howactive==typedead3)return dead3anim;
282 if(howactive==typedead4)return dead4anim;
283 if(creature==rabbittype)return bounceidleanim;
284 if(creature==wolftype)return wolfidle;
288 bool Person::isCrouch(){
289 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
294 bool Person::wasCrouch(){
295 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
298 int Person::getCrouch(){
299 if(creature==rabbittype)return crouchanim;
300 if(creature==wolftype)return wolfcrouchanim;
304 bool Person::isRun(){
305 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
310 bool Person::wasRun(){
311 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
314 int Person::getRun(){
315 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
316 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
318 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
319 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
323 bool Person::isStop(){
324 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
329 bool Person::wasStop(){
330 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
333 int Person::getStop(){
334 if(creature==rabbittype)return stopanim;
335 if(creature==wolftype)return wolfstopanim;
340 bool Person::isLanding(){
341 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
346 bool Person::wasLanding(){
347 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
350 int Person::getLanding(){
351 if(creature==rabbittype)return landanim;
352 if(creature==wolftype)return wolflandanim;
357 bool Person::isLandhard(){
358 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
363 bool Person::wasLandhard(){
364 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
367 int Person::getLandhard(){
368 if(creature==rabbittype)return landhardanim;
369 if(creature==wolftype)return wolflandhardanim;
374 bool Person::isFlip(){
375 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
379 bool Person::wasFlip(){
380 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
384 bool Person::isWallJump(){
385 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
389 void SolidHitBonus();
390 void SolidHitBonus(){
391 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
396 else if(bonustime<1.5&&bonus==threexcombo){
401 else if(bonustime<1.5&&bonus==twoxcombo){
406 else if(bonustime<1.5&&bonus==solidhit){
418 void Person::DoBlood(float howmuch,int which){
419 static int bleedxint,bleedyint;
421 //if(howmuch&&id==0)blooddimamount=1;
422 if(bloodtoggle&&tutoriallevel!=1){
423 if(bleeding<=0&&spurt){
425 for(int i=0;i<3;i++){
429 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
432 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
434 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
435 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
437 sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
438 sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
441 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);
442 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);
446 for(int i=0;i<3;i++){
451 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
454 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
456 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
457 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
460 sprites.MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
461 sprites.special[sprites.numsprites-1]=3;
464 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);
465 sprites.special[sprites.numsprites-1]=3;
471 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
474 int texdetailint=realtexdetail;
475 if(creature==rabbittype)
476 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){
477 bleedxint=abs(Random()%512);
478 bleedyint=abs(Random()%512);
480 if(creature==wolftype)
481 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){
482 bleedxint=abs(Random()%512);
483 bleedyint=abs(Random()%512);
487 bleedy/=realtexdetail;
488 bleedx/=realtexdetail;
489 direction=abs(Random()%2)*2-1;
493 if(bleeding>2)bleeding=2;
496 void Person::DoBloodBig(float howmuch,int which){
497 static int bleedxint,bleedyint,i,j;
499 if(howmuch&&id==0)blooddimamount=1;
501 if(tutoriallevel!=1||id==0)
502 if(aitype!=playercontrolled&&howmuch>0){
513 if(creature==wolftype){
514 int i=abs(Random()%2);
515 if(i==0)whichsound=snarlsound;
516 if(i==1)whichsound=snarl2sound;
517 envsound[numenvsounds]=coords;
518 envsoundvol[numenvsounds]=16;
519 envsoundlife[numenvsounds]=.4;
522 if(creature==rabbittype){
523 int i=abs(Random()%2);
524 if(i==0)whichsound=rabbitpainsound;
525 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
526 envsound[numenvsounds]=coords;
527 envsoundvol[numenvsounds]=16;
528 envsoundlife[numenvsounds]=.4;
530 //if(i==2)whichsound=rabbitpain2sound;
534 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
535 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
536 FSOUND_SetVolume(channels[whichsound], 512);
537 FSOUND_SetPaused(channels[whichsound], false);
541 if(id==0&&howmuch>0){
549 if(bloodtoggle&&decals&&tutoriallevel!=1){
550 if(bleeding<=0&&spurt){
552 for(int i=0;i<3;i++){
556 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
559 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
561 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
562 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
564 sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
565 sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
568 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);
569 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);
573 int offsetx=0,offsety=0;
576 offsetx=abs(Random()%60);
578 if(which==190||which==185){
580 offsetx=abs(Random()%100)-20;
590 if(which==220||which==215){
591 //offsety=Random()%20;
593 //offsetx=abs(Random()%80);
602 if(creature==rabbittype)
605 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
606 if(i<startx)startx=i;
607 if(j<starty)starty=j;
613 if(creature==wolftype)
616 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
617 if(i<startx)startx=i;
618 if(j<starty)starty=j;
630 if(startx<0)startx=0;
631 if(starty<0)starty=0;
632 if(endx>512-1)endx=512-1;
633 if(endy>512-1)endy=512-1;
634 if(endx<startx)endx=startx;
635 if(endy<starty)endy=starty;
637 startx/=realtexdetail;
638 starty/=realtexdetail;
642 int texdetailint=realtexdetail;
644 if(creature==rabbittype)
645 for(i=startx;i<endx;i++){
646 for(j=starty;j<endy;j++){
647 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){
648 color=Random()%85+170;
649 where=i*skeleton.skinsize*3+j*3;
650 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
651 skeleton.skinText[where+1]=0;
652 skeleton.skinText[where+2]=0;
656 if(creature==wolftype)
657 for(i=startx;i<endx;i++){
658 for(j=starty;j<endy;j++){
659 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){
660 color=Random()%85+170;
661 where=i*skeleton.skinsize*3+j*3;
662 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
663 skeleton.skinText[where+1]=0;
664 skeleton.skinText[where+2]=0;
668 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
669 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
670 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
674 if(creature==rabbittype)
675 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){
676 bleedxint=abs(Random()%512);
677 bleedyint=abs(Random()%512);
679 if(creature==wolftype)
680 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){
681 bleedxint=abs(Random()%512);
682 bleedyint=abs(Random()%512);
684 bleedy=bleedxint+offsetx;
685 bleedx=bleedyint+offsety;
686 bleedy/=realtexdetail;
687 bleedx/=realtexdetail;
688 if(bleedx<0)bleedx=0;
689 if(bleedy<0)bleedy=0;
690 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
691 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
692 direction=abs(Random()%2)*2-1;
695 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
696 deathbleeding+=bleeding;
697 bloodloss+=bleeding*3;
699 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
700 if(abs(Random()%2)==0){aitype=gethelptype;
703 else aitype=attacktypecutoff;
706 if(bleeding>2)bleeding=2;
709 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
710 static int bleedxint,bleedyint,i,j;
712 static XYZ startpoint,endpoint,colpoint,movepoint;
713 static float rotationpoint;
715 static XYZ p1,p2,p3,p0;
719 float coordsx,coordsy;
722 if(bloodtoggle&&decals&&tutoriallevel!=1){
724 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
732 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
735 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
736 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
737 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
739 CrossProduct(p2-p1,p3-p1,&N);
740 CrossProduct(p0-p1,p3-p1,&temp);
741 s = dotproduct(&temp,&N)/findLength(&N);
742 CrossProduct(p2-p1,p1-p0,&temp);
743 t = dotproduct(&temp,&N)/findLength(&N);
746 bary.x=findDistancefast(&p0,&p1);
747 bary.y=findDistancefast(&p0,&p2);
748 bary.z=findDistancefast(&p0,&p3);
750 total=bary.x+bary.y+bary.z;
759 total=bary.x+bary.y+bary.z;
765 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
766 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
767 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
768 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
769 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
770 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
771 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;
772 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;
774 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
775 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
777 if(bleeding<=0&&spurt){
779 for(int i=0;i<3;i++){
783 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
786 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
788 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
789 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
791 sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
792 sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
795 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);
796 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);
800 int offsetx=0,offsety=0;
803 offsetx=abs(Random()%120);
805 if(which==220||which==215){
807 offsetx=abs(Random()%80);
810 offsetx=(1+coordsy)*512-291;
811 offsety=coordsx*512-437;
818 if(creature==rabbittype)
821 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
822 if(i<startx)startx=i;
823 if(j<starty)starty=j;
829 if(creature==wolftype)
832 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
833 if(i<startx)startx=i;
834 if(j<starty)starty=j;
845 if(startx<0)startx=0;
846 if(starty<0)starty=0;
847 if(endx>512-1)endx=512-1;
848 if(endy>512-1)endy=512-1;
849 if(endx<startx)endx=startx;
850 if(endy<starty)endy=starty;
852 startx/=realtexdetail;
853 starty/=realtexdetail;
857 int texdetailint=realtexdetail;
859 if(creature==rabbittype)
860 for(i=startx;i<endx;i++){
861 for(j=starty;j<endy;j++){
862 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){
863 color=Random()%85+170;
864 where=i*skeleton.skinsize*3+j*3;
865 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
866 skeleton.skinText[where+1]=0;
867 skeleton.skinText[where+2]=0;
869 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){
870 color=Random()%85+170;
871 where=i*skeleton.skinsize*3+j*3;
872 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
873 skeleton.skinText[where+1]=0;
874 skeleton.skinText[where+2]=0;
878 if(creature==wolftype)
879 for(i=startx;i<endx;i++){
880 for(j=starty;j<endy;j++){
881 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){
882 color=Random()%85+170;
883 where=i*skeleton.skinsize*3+j*3;
884 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
885 skeleton.skinText[where+1]=0;
886 skeleton.skinText[where+2]=0;
888 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){
889 color=Random()%85+170;
890 where=i*skeleton.skinsize*3+j*3;
891 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
892 skeleton.skinText[where+1]=0;
893 skeleton.skinText[where+2]=0;
897 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
898 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
899 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
901 bleedy=(1+coordsy)*512;
903 bleedy/=realtexdetail;
904 bleedx/=realtexdetail;
905 if(bleedx<0)bleedx=0;
906 if(bleedy<0)bleedy=0;
907 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
908 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
909 direction=abs(Random()%2)*2-1;
911 if(whichtri==-1)return 0;
913 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
914 deathbleeding+=bleeding;
915 bloodloss+=bleeding*3;
917 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
918 if(abs(Random()%2)==0){aitype=gethelptype;
921 else aitype=attacktypecutoff;
924 if(bleeding>2)bleeding=2;
929 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
932 static int bytesPerPixel=3;
933 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
934 static int newstartx,newstarty,newendx,newendy;
935 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
937 static float sizemult;
939 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
940 texture[i]=skeleton.skinText[i];
943 if((!osx||howmanylevels)){
945 if(startx<0)startx=0;
946 if(starty<0)starty=0;
947 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
948 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
949 if((endx>startx&&endy>starty)||howmanylevels){
956 for(i=startx;i<endx;i++){
957 for(j=starty;j<endy;j++){
958 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
959 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
960 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
964 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
967 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
968 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
969 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
972 newsize=skeleton.skinsize;
975 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
977 /*for(j=1;j<=howmanylevels;j++){
978 if(j==1)texpointer=&skeleton.skinText[0];
979 else texpointer=&texture[0];
981 totalsize=int( newsize*newsize*bytesPerPixel);
982 rowsize=int( newsize*bytesPerPixel );
983 bigstep=bytesPerPixel*newsize*2;
984 smallstep=bytesPerPixel*2;
990 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
997 void Person::Reverse(){
998 if(victim->aitype==playercontrolled||hostiletime>1)
999 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
1000 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
1001 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
1002 if(targetanimation==sweepanim){
1003 targetanimation=sweepreversedanim;
1004 currentanimation=sweepreversedanim;
1005 victim->currentanimation=sweepreversalanim;
1006 victim->targetanimation=sweepreversalanim;
1008 if(targetanimation==spinkickanim){
1009 targetanimation=spinkickreversedanim;
1010 currentanimation=spinkickreversedanim;
1011 victim->currentanimation=spinkickreversalanim;
1012 victim->targetanimation=spinkickreversalanim;
1014 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
1015 if(targetanimation==rabbittacklinganim){
1018 victim->currentframe=6;
1019 victim->targetframe=7;
1021 targetanimation=upunchreversedanim;
1022 currentanimation=upunchreversedanim;
1023 victim->currentanimation=upunchreversalanim;
1024 victim->targetanimation=upunchreversalanim;
1026 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1027 if(victim->weaponactive!=-1){
1028 victim->throwtogglekeydown=1;
1029 weapons.owner[victim->weaponids[0]]=-1;
1030 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1031 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1032 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1033 weapons.missed[victim->weaponids[0]]=1;
1034 weapons.freetime[victim->weaponids[0]]=0;
1035 weapons.firstfree[victim->weaponids[0]]=1;
1036 weapons.physics[victim->weaponids[0]]=1;
1037 victim->num_weapons--;
1038 if(victim->num_weapons){
1039 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1040 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1043 victim->weaponactive=-1;
1044 for(int j=0;j<numplayers;j++){
1045 player[j].wentforweapon=0;
1049 targetanimation=staffhitreversedanim;
1050 currentanimation=staffhitreversedanim;
1051 victim->currentanimation=staffhitreversalanim;
1052 victim->targetanimation=staffhitreversalanim;
1054 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1055 if(victim->weaponactive!=-1){
1056 victim->throwtogglekeydown=1;
1057 weapons.owner[victim->weaponids[0]]=-1;
1058 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1059 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1060 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1061 weapons.missed[victim->weaponids[0]]=1;
1062 weapons.freetime[victim->weaponids[0]]=0;
1063 weapons.firstfree[victim->weaponids[0]]=1;
1064 weapons.physics[victim->weaponids[0]]=1;
1065 victim->num_weapons--;
1066 if(victim->num_weapons){
1067 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1068 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1071 victim->weaponactive=-1;
1072 for(int j=0;j<numplayers;j++){
1073 player[j].wentforweapon=0;
1076 targetanimation=staffspinhitreversedanim;
1077 currentanimation=staffspinhitreversedanim;
1078 victim->currentanimation=staffspinhitreversalanim;
1079 victim->targetanimation=staffspinhitreversalanim;
1081 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1082 if(victim->weaponactive!=-1){
1083 victim->throwtogglekeydown=1;
1084 weapons.owner[victim->weaponids[0]]=-1;
1085 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1086 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1087 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1088 weapons.missed[victim->weaponids[0]]=1;
1089 weapons.freetime[victim->weaponids[0]]=0;
1090 weapons.firstfree[victim->weaponids[0]]=1;
1091 weapons.physics[victim->weaponids[0]]=1;
1092 victim->num_weapons--;
1093 if(victim->num_weapons){
1094 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1095 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1098 victim->weaponactive=-1;
1099 for(int j=0;j<numplayers;j++){
1100 player[j].wentforweapon=0;
1103 targetanimation=swordslashreversedanim;
1104 currentanimation=swordslashreversedanim;
1105 victim->currentanimation=swordslashreversalanim;
1106 victim->targetanimation=swordslashreversalanim;
1108 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1109 if(victim->weaponactive!=-1){
1110 victim->throwtogglekeydown=1;
1111 weapons.owner[victim->weaponids[0]]=-1;
1112 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1113 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1114 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1115 weapons.missed[victim->weaponids[0]]=1;
1116 weapons.freetime[victim->weaponids[0]]=0;
1117 weapons.firstfree[victim->weaponids[0]]=1;
1118 weapons.physics[victim->weaponids[0]]=1;
1119 victim->num_weapons--;
1120 if(victim->num_weapons){
1121 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1122 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1125 victim->weaponactive=-1;
1126 for(int j=0;j<numplayers;j++){
1127 player[j].wentforweapon=0;
1130 targetanimation=knifeslashreversedanim;
1131 currentanimation=knifeslashreversedanim;
1132 victim->currentanimation=knifeslashreversalanim;
1133 victim->targetanimation=knifeslashreversalanim;
1135 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1136 victim->targettilt2=targettilt2;
1137 victim->currentframe=currentframe;
1138 victim->targetframe=targetframe;
1139 victim->target=target;
1141 victim->oldcoords=victim->coords;
1142 victim->coords=coords;
1143 victim->targetrotation=targetrotation;
1144 victim->rotation=targetrotation;
1145 victim->victim=this;
1147 if(targetanimation==winduppunchanim){
1148 targetanimation=winduppunchblockedanim;
1149 victim->targetanimation=blockhighleftanim;
1150 victim->targetframe=1;
1152 victim->victim=this;
1153 victim->targetrotation=targetrotation+180;
1155 if(targetanimation==wolfslapanim){
1156 targetanimation=winduppunchblockedanim;
1157 victim->targetanimation=blockhighleftanim;
1158 victim->targetframe=1;
1160 victim->victim=this;
1161 victim->targetrotation=targetrotation+180;
1163 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1164 targetanimation=swordslashparriedanim;
1166 victim->parriedrecently=0;
1167 victim->targetanimation=swordslashparryanim;
1168 victim->targetframe=1;
1170 victim->victim=this;
1171 victim->targetrotation=targetrotation+180;
1173 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1176 gLoc[0]=victim->coords.x;
1177 gLoc[1]=victim->coords.y;
1178 gLoc[2]=victim->coords.z;
1182 if(victim->weaponactive!=-1){
1183 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1184 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1185 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1187 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1188 FSOUND_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1189 FSOUND_SetVolume(channels[swordstaffsound], 512);
1190 FSOUND_SetPaused(channels[swordstaffsound], false);
1193 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1194 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1195 FSOUND_SetVolume(channels[metalhitsound], 512);
1196 FSOUND_SetPaused(channels[metalhitsound], false);
1200 victim->Puff(righthand);
1202 victim->targetframe=0;
1203 victim->targetanimation=staggerbackhighanim;
1204 victim->targetrotation=targetrotation+180;
1206 weapons.owner[victim->weaponids[0]]=-1;
1207 aim=DoRotation(facing,0,90,0)*21;
1209 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1210 weapons.tipvelocity[victim->weaponids[0]]=aim;
1211 weapons.missed[victim->weaponids[0]]=1;
1212 weapons.hitsomething[victim->weaponids[0]]=0;
1213 weapons.freetime[victim->weaponids[0]]=0;
1214 weapons.firstfree[victim->weaponids[0]]=1;
1215 weapons.physics[victim->weaponids[0]]=1;
1216 victim->num_weapons--;
1217 if(victim->num_weapons){
1218 victim->weaponids[0]=victim->weaponids[num_weapons];
1219 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1221 victim->weaponactive=-1;
1222 for(int i=0;i<numplayers;i++){
1223 player[i].wentforweapon=0;
1230 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1231 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1232 FSOUND_SetVolume(channels[metalhitsound], 512);
1233 FSOUND_SetPaused(channels[metalhitsound], false);*/
1236 if(abs(Random()%20)==0){
1245 if(weaponactive!=-1){
1246 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1247 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1248 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1250 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1251 FSOUND_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1252 FSOUND_SetVolume(channels[swordstaffsound], 512);
1253 FSOUND_SetPaused(channels[swordstaffsound], false);
1256 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1257 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1258 FSOUND_SetVolume(channels[metalhitsound], 512);
1259 FSOUND_SetPaused(channels[metalhitsound], false);
1267 targetanimation=staggerbackhighanim;
1268 targetrotation=targetrotation+180;
1270 weapons.owner[weaponids[0]]=-1;
1271 aim=DoRotation(facing,0,90,0)*21;
1273 weapons.velocity[weaponids[0]]=aim*-.2;
1274 weapons.tipvelocity[weaponids[0]]=aim;
1275 weapons.hitsomething[weaponids[0]]=0;
1276 weapons.missed[weaponids[0]]=1;
1277 weapons.freetime[weaponids[0]]=0;
1278 weapons.firstfree[weaponids[0]]=1;
1279 weapons.physics[weaponids[0]]=1;
1282 weaponids[0]=weaponids[num_weapons];
1283 if(weaponstuck==num_weapons)weaponstuck=0;
1286 for(int i=0;i<numplayers;i++){
1287 player[i].wentforweapon=0;
1291 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1292 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1293 FSOUND_SetVolume(channels[metalhitsound], 512);
1294 FSOUND_SetPaused(channels[metalhitsound], false);*/
1298 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1299 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1300 //victim->targetanimation=sweepanim;
1301 victim->targetanimation=dodgebackanim;
1302 victim->targetframe=0;
1304 //victim->velocity=0;
1307 rotatetarget=coords-victim->coords;
1308 Normalise(&rotatetarget);
1309 victim->targetrotation=-asin(0-rotatetarget.x);
1310 victim->targetrotation*=360/6.28;
1311 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1313 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1315 victim->lastattack3=victim->lastattack2;
1316 victim->lastattack2=victim->lastattack;
1317 victim->lastattack=victim->targetanimation;
1321 victim->targetanimation=sweepanim;
1322 victim->targetframe=0;
1326 rotatetarget=coords-victim->coords;
1327 Normalise(&rotatetarget);
1328 victim->targetrotation=-asin(0-rotatetarget.x);
1329 victim->targetrotation*=360/6.28;
1330 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1332 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1334 victim->lastattack3=victim->lastattack2;
1335 victim->lastattack2=victim->lastattack;
1336 victim->lastattack=victim->targetanimation;
1343 if(aitype!=playercontrolled)feint=0;
1344 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1345 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1346 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1348 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1352 void Person::DoDamage(float howmuch){
1353 if(tutoriallevel!=1)damage+=howmuch/power;
1354 if(id!=0)damagedealt+=howmuch/power;
1355 if(id==0)damagetaken+=howmuch/power;
1357 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1358 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1359 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1360 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1361 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1363 if(id==0)camerashake+=howmuch/100;
1364 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1365 if(blackout>1)blackout=1;
1367 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1368 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1369 if(abs(Random()%2)==0){aitype=gethelptype;
1372 else aitype=attacktypecutoff;
1376 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1379 for(int i=0;i<skeleton.num_joints; i++){
1380 if(!skeleton.free)flatvelocity2=velocity;
1381 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1382 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1383 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1384 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1385 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1386 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1387 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1388 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1389 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1400 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1401 FSOUND_3D_SetAttributes(channels[splattersound], gLoc, vel);
1402 FSOUND_SetVolume(channels[splattersound], 256);
1403 FSOUND_SetPaused(channels[splattersound], false);
1412 if(!dead&&creature==wolftype){
1421 if(tutoriallevel!=1||id==0)
1422 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1433 if(creature==wolftype){
1434 int i=abs(Random()%2);
1435 if(i==0)whichsound=snarlsound;
1436 if(i==1)whichsound=snarl2sound;
1437 envsound[numenvsounds]=coords;
1438 envsoundvol[numenvsounds]=16;
1439 envsoundlife[numenvsounds]=.4;
1442 if(creature==rabbittype){
1443 int i=abs(Random()%2);
1444 if(i==0)whichsound=rabbitpainsound;
1445 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1446 envsound[numenvsounds]=coords;
1447 envsoundvol[numenvsounds]=16;
1448 envsoundlife[numenvsounds]=.4;
1450 //if(i==2)whichsound=rabbitpain2sound;
1454 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1455 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
1456 FSOUND_SetVolume(channels[whichsound], 512);
1457 FSOUND_SetPaused(channels[whichsound], false);
1462 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1463 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1466 void Person::DoHead(){
1467 static XYZ rotatearound;
1469 static float lookspeed=500;
1471 if(!freeze&&!winfreeze&&(!mainmenu||!gamestarted)){
1474 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1475 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1477 while(targetheadrotation>180)targetheadrotation-=360;
1478 while(targetheadrotation<-180)targetheadrotation+=360;
1480 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1481 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1482 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1483 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1485 if(targetheadrotation2>120)targetheadrotation2=120;
1486 if(targetheadrotation2<-120)targetheadrotation2=-120;
1487 if(targetheadrotation>120)targetheadrotation=120;
1488 if(targetheadrotation<-120)targetheadrotation=-120;
1490 if(!isIdle())targetheadrotation2=0;
1492 if(targetheadrotation>80)targetheadrotation=80;
1493 if(targetheadrotation<-80)targetheadrotation=-80;
1494 if(targetheadrotation2>50)targetheadrotation2=50;
1495 if(targetheadrotation2<-50)targetheadrotation2=-50;
1498 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1499 else if(headrotation>targetheadrotation){
1500 headrotation-=multiplier*lookspeed;
1502 else if(headrotation<targetheadrotation){
1503 headrotation+=multiplier*lookspeed;
1506 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1507 else if(headrotation2>targetheadrotation2){
1508 headrotation2-=multiplier*lookspeed/2;
1510 else if(headrotation2<targetheadrotation2){
1511 headrotation2+=multiplier*lookspeed/2;
1514 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1515 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1519 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1520 facing=DoRotation(facing,headrotation2*.4,0,0);
1521 facing=DoRotation(facing,0,headrotation*.4,0);
1524 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1525 facing=DoRotation(facing,headrotation2*.8,0,0);
1526 facing=DoRotation(facing,0,headrotation*.8,0);
1529 if(targetanimation==walkanim){
1530 facing=DoRotation(facing,headrotation2*.6,0,0);
1531 facing=DoRotation(facing,0,headrotation*.6,0);
1534 skeleton.specialforward[0]=facing;
1535 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1537 for(i=0;i<skeleton.num_muscles;i++){
1538 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1540 skeleton.FindRotationMuscle(i,targetanimation);
1546 void Person::RagDoll(bool checkcollision){
1551 if(id==0)numfalls++;
1552 if(id==0&&isFlip())numflipfail++;
1558 facing=DoRotation(facing,0,rotation,0);
1560 skeleton.freetime=0;
1562 skeleton.longdead=0;
1568 skeleton.freefall=1;
1570 if(!isnormal(velocity.x))velocity.x=0;
1571 if(!isnormal(velocity.y))velocity.y=0;
1572 if(!isnormal(velocity.z))velocity.z=0;
1573 if(!isnormal(rotation))rotation=0;
1574 if(!isnormal(coords.x))coords=0;
1575 if(!isnormal(tilt))tilt=0;
1576 if(!isnormal(tilt2))tilt2=0;
1578 for(i=0;i<skeleton.num_joints;i++){
1579 skeleton.joints[i].delay=0;
1580 skeleton.joints[i].locked=0;
1581 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1582 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1583 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1584 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1585 skeleton.joints[i].position.y+=.1;
1586 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1587 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1590 for(i=0;i<skeleton.num_joints;i++){
1591 skeleton.joints[i].velocity=0;
1592 skeleton.joints[i].velchange=0;
1594 skeleton.DoConstraints(&coords,&scale);
1595 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1597 skeleton.DoConstraints(&coords,&scale);
1598 skeleton.DoConstraints(&coords,&scale);
1599 skeleton.DoConstraints(&coords,&scale);
1600 skeleton.DoConstraints(&coords,&scale);
1603 speed=animation[targetanimation].speed[targetframe]*2;
1604 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1605 speed=animation[currentanimation].speed[currentframe]*2;
1607 if(transspeed)speed=transspeed*2;
1611 for(i=0;i<skeleton.num_joints;i++){
1612 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);
1613 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1614 change.x=(float)(Random()%100)/100;
1615 change.y=(float)(Random()%100)/100;
1616 change.z=(float)(Random()%100)/100;
1617 skeleton.joints[i].velocity+=change;
1618 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1620 change.x=(float)(Random()%100)/100;
1621 change.y=(float)(Random()%100)/100;
1622 change.z=(float)(Random()%100)/100;
1623 skeleton.joints[i].velchange+=change;
1624 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1634 for(j=0;j<skeleton.num_joints;j++){
1635 average+=skeleton.joints[j].position;
1639 coords+=average*scale;
1640 for(j=0;j<skeleton.num_joints;j++){
1641 skeleton.joints[j].position-=average;
1644 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1645 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1646 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1647 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1648 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1651 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1652 coords.x=lowpoint.x;
1653 coords.z=lowpoint.z;
1662 for(i=0;i<skeleton.num_joints;i++){
1663 velocity+=skeleton.joints[i].velocity*scale;
1665 velocity/=skeleton.num_joints;
1668 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1669 weapons.owner[weaponids[0]]=-1;
1670 weapons.hitsomething[weaponids[0]]=0;
1671 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1672 weapons.velocity[weaponids[0]].x+=.01;
1673 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1674 weapons.missed[weaponids[0]]=1;
1675 weapons.freetime[weaponids[0]]=0;
1676 weapons.firstfree[weaponids[0]]=1;
1677 weapons.physics[weaponids[0]]=1;
1680 weaponids[0]=weaponids[num_weapons];
1681 if(weaponstuck==num_weapons)weaponstuck=0;
1684 for(i=0;i<numplayers;i++){
1685 player[i].wentforweapon=0;
1690 targetanimation=bounceidleanim;
1691 currentanimation=bounceidleanim;
1699 void Person::FootLand(int which, float opacity){
1700 static XYZ terrainlight;
1701 static XYZ footvel,footpoint;
1702 if(opacity>=1||skiddelay<=0)
1706 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1707 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1708 //footpoint.y=coords.y;
1709 if(findDistancefast(&footpoint,&viewer))sprites.MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1711 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1713 if(footvel.y<.8)footvel.y=.8;
1714 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1715 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1716 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1717 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1718 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1719 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1721 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1723 if(footvel.y<.8)footvel.y=.8;
1724 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1725 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1726 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1727 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1728 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);
1730 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1732 if(footvel.y<.8)footvel.y=.8;
1733 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1734 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1735 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1736 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1737 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);
1738 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1740 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1743 if(footvel.y<.8)footvel.y=.8;
1744 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1745 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1746 //footpoint.y=coords.y;
1747 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1751 void Person::Puff(int whichlabel){
1752 static XYZ footvel,footpoint;
1755 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1756 sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1761 HitStruct Person::BulletCollideWithPlayer(XYZ start, XYZ end){
1763 XYZ tempbulletloc[2];
1773 HitStruct hitstruct;
1774 hitstruct.collision=0;
1775 //Make bounding sphere
1778 for(int j=0;j<skeleton.num_joints;j++){
1779 average.x=average.x+skeleton.joints[j].position.x;
1780 average.y=average.y+skeleton.joints[j].position.y;
1781 average.z=average.z+skeleton.joints[j].position.z;
1784 average=average/howmany;
1786 for(int j=0;j<skeleton.num_joints;j++){
1787 if(findDistancefast(average,skeleton.joints[j].position)>distancemax){
1788 distancemax=findDistancefast(average,skeleton.joints[j].position);
1791 distancemax=fast_sqrt(distancemax);
1792 //Collide with player
1793 if(skeleton.free<1){
1796 if(rotation)start=DoRotation(start,0,-rotation,0);
1797 if(rotation)end=DoRotation(end,0,-rotation,0);
1799 tempbulletloc[0]=start;
1800 tempbulletloc[1]=end;
1801 if(sphere_line_intersection(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z,
1802 tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z,
1803 average.x, average.y, average.z, distancemax)){
1804 for(int j=0;j<skeleton.num_joints;j++){
1805 if(skeleton.joints[j].hasparent&&skeleton.joints[j].visible){
1806 tempbulletloc[0]=start;
1807 tempbulletloc[1]=end;
1810 glScalef(1,1/skeleton.joints[j].length,1);
1811 glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
1812 glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
1813 glTranslatef( (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
1814 (-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
1815 (-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
1816 glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
1817 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1818 tempbulletloc[0].x=M[12];
1819 tempbulletloc[0].y=M[13];
1820 tempbulletloc[0].z=M[14];
1824 glScalef(1,1/skeleton.joints[j].length,1);
1825 glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
1826 glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
1827 glTranslatef( (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
1828 (-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
1829 (-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
1830 glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
1831 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1832 tempbulletloc[1].x=M[12];
1833 tempbulletloc[1].y=M[13];
1834 tempbulletloc[1].z=M[14];
1836 collide=skeletonmodels[skeleton.joints[j].modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
1841 glTranslatef( (skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2,
1842 (skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2,
1843 (skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2);
1844 glRotatef(-skeleton.joints[j].rotate1+90,0,1,0);
1845 glRotatef(-skeleton.joints[j].rotate2+90,0,0,1);
1846 glScalef(1,skeleton.joints[j].length,1);
1847 glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
1848 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1849 collisionpoint.x=M[12];
1850 collisionpoint.y=M[13];
1851 collisionpoint.z=M[14];
1853 hitstruct.collision=1;
1854 hitstruct.hitlocation=collisionpoint;
1855 hitstruct.joint1=&skeleton.joints[j];
1856 hitstruct.joint2=skeleton.joints[j].parent;
1860 for(int j=0;j<skeleton.num_muscles;j++){
1861 if(skeleton.muscles[j].visible){
1862 tempbulletloc[0]=start;
1863 tempbulletloc[1]=end;
1866 glScalef(1,1/skeleton.muscles[j].length,1);
1867 glRotatef(skeleton.muscles[j].rotate3,0,1,0);
1868 glRotatef(skeleton.muscles[j].rotate2-90,0,0,1);
1869 glRotatef(skeleton.muscles[j].rotate1-90,0,1,0);
1870 glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2),
1871 (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2),
1872 (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2));
1874 glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
1875 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1876 tempbulletloc[0].x=M[12];
1877 tempbulletloc[0].y=M[13];
1878 tempbulletloc[0].z=M[14];
1882 glScalef(1,1/skeleton.muscles[j].length,1);
1883 glRotatef(skeleton.muscles[j].rotate3,0,1,0);
1884 glRotatef(skeleton.muscles[j].rotate2-90,0,0,1);
1885 glRotatef(skeleton.muscles[j].rotate1-90,0,1,0);
1887 glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2),
1888 (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2),
1889 (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2));
1890 glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
1891 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1892 tempbulletloc[1].x=M[12];
1893 tempbulletloc[1].y=M[13];
1894 tempbulletloc[1].z=M[14];
1896 collide=skeletonmodels[skeleton.muscles[j].parent1->modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
1901 glTranslatef( (skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2,
1902 (skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2,
1903 (skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2);
1904 glRotatef(-skeleton.muscles[j].rotate1+90,0,1,0);
1905 glRotatef(-skeleton.muscles[j].rotate2+90,0,0,1);
1906 glRotatef(-skeleton.muscles[j].rotate3,0,1,0);
1907 glScalef(1,findDistance(skeleton.muscles[j].parent1->position,skeleton.muscles[j].parent2->position),1);
1908 glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
1909 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1910 collisionpoint.x=M[12];
1911 collisionpoint.y=M[13];
1912 collisionpoint.z=M[14];
1914 hitstruct.collision=1;
1915 hitstruct.hitlocation=collisionpoint;
1916 hitstruct.joint1=skeleton.muscles[j].parent1;
1917 hitstruct.joint2=skeleton.muscles[j].parent2;
1922 if(skeleton.free<1){
1923 if(rotation)hitstruct.hitlocation=DoRotation(hitstruct.hitlocation,0,rotation,0);
1924 hitstruct.hitlocation=hitstruct.hitlocation+coords;
1929 void Person::DoAnimations(){
1932 static float oldtarget;
1934 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1936 if(targetanimation==tempanim||currentanimation==tempanim){
1937 animation[tempanim]=tempanimation;
1939 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1950 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1951 FSOUND_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1953 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1954 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1956 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1961 targfacing=DoRotation(targfacing,0,targetrotation,0);
1963 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1964 else targetanimation=backflipanim;
1965 crouchtogglekeydown=1;
1969 if(id==0)numflipped++;
1972 if(animation[targetanimation].attack!=reversed)feint=0;
1973 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1974 crouchtogglekeydown=0;
1975 if(aitype==playercontrolled)feint=0;
1979 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1980 if(!isFlip())crouchtogglekeydown=1;
1984 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1985 if(detail)normalsupdatedelay=0;
1989 if(targetanimation==rollanim&&targetframe==3&&onfire){
1999 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2000 FSOUND_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2001 FSOUND_SetVolume(channels[fireendsound], 256);
2002 FSOUND_SetPaused(channels[fireendsound], false);
2003 FSOUND_SetPaused(channels[stream_firesound], true);
2007 if(targetanimation==rabbittacklinganim&&targetframe==1){
2008 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
2009 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
2010 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
2011 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
2012 else victim->targetanimation=rabbittackledfrontanim;
2013 victim->targetframe=2;
2015 victim->rotation=rotation;
2016 victim->targetrotation=rotation;
2017 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
2018 //victim->DoDamage(30);
2019 if(creature==wolftype){
2023 gLoc[0]=victim->coords.x;
2024 gLoc[1]=victim->coords.y;
2025 gLoc[2]=victim->coords.z;
2029 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2030 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2031 FSOUND_SetVolume(channels[clawslicesound], 128);
2032 FSOUND_SetPaused(channels[clawslicesound], false);
2034 victim->DoBloodBig(1/victim->armorhead,210);
2040 if(victim->aitype==gethelptype)bonusvalue=50;
2045 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
2046 if(weapons.type[weaponids[0]]==knife){
2047 if(weaponactive==-1)weaponactive=0;
2048 else if(weaponactive==0)weaponactive=-1;
2050 if(weaponactive==-1){
2060 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2061 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2062 FSOUND_SetVolume(channels[knifesheathesound], 128);
2063 FSOUND_SetPaused(channels[knifesheathesound], false);
2065 if(weaponactive!=-1){
2075 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2076 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2077 FSOUND_SetVolume(channels[knifedrawsound], 128);
2078 FSOUND_SetPaused(channels[knifedrawsound], false);
2081 drawtogglekeydown=1;
2084 if(tutoriallevel!=1||id==0)
2085 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
2096 if(terrain.getOpacity(coords.x,coords.z)<.2){
2097 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
2098 else whichsound=footstepsound2;
2099 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
2100 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
2101 if(animation[targetanimation].label[targetframe]==3&&isRun()){
2107 if(terrain.getOpacity(coords.x,coords.z)>=.2){
2108 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
2109 else whichsound=footstepsound4;
2113 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
2114 else whichsound=footstepsound4;
2116 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
2117 if(animation[targetanimation].attack!=neutral){
2119 if(i==0)whichsound=lowwhooshsound;
2120 if(i==1)whichsound=midwhooshsound;
2121 if(i==2)whichsound=highwhooshsound;
2123 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2125 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2126 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
2128 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2129 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
2130 if(whichsound!=knifeswishsound)FSOUND_SetVolume(channels[whichsound], 128);
2131 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))FSOUND_SetVolume(channels[whichsound], 256);
2132 if(whichsound==knifeswishsound)FSOUND_SetVolume(channels[whichsound], 512);
2133 FSOUND_SetPaused(channels[whichsound], false);
2136 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
2137 envsound[numenvsounds]=coords;
2138 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
2139 else envsoundvol[numenvsounds]=6;
2140 envsoundlife[numenvsounds]=.4;
2144 if(animation[targetanimation].label[targetframe]==3){
2146 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2147 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
2148 FSOUND_SetVolume(channels[whichsound], 128);
2149 FSOUND_SetPaused(channels[whichsound], false);
2154 if(tutoriallevel!=1||id==0)
2156 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
2157 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
2167 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
2168 if(animation[targetanimation].attack!=neutral){
2170 if(creature==rabbittype){
2171 if(i==0)whichsound=rabbitattacksound;
2172 if(i==1)whichsound=rabbitattack2sound;
2173 if(i==2)whichsound=rabbitattack3sound;
2174 if(i==3)whichsound=rabbitattack4sound;
2176 if(creature==wolftype){
2177 if(i==0)whichsound=barksound;
2178 if(i==1)whichsound=bark2sound;
2179 if(i==2)whichsound=bark3sound;
2180 if(i==3)whichsound=barkgrowlsound;
2184 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2186 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2187 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
2190 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2191 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
2192 FSOUND_SetVolume(channels[whichsound], 512);
2193 FSOUND_SetPaused(channels[whichsound], false);
2199 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
2205 currentoffset=targetoffset;
2206 targetframe=currentframe;
2207 currentanimation=targetanimation;
2210 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
2211 for(i=0;i<weapons.numweapons;i++){
2212 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
2213 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
2214 if(findDistancefast(&coords,&weapons.position[i])>=1){
2215 if(weapons.type[i]!=staff){
2224 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2225 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2226 FSOUND_SetVolume(channels[knifedrawsound], 128);
2227 FSOUND_SetPaused(channels[knifedrawsound], false);
2231 weapons.owner[i]=id;
2233 weaponids[num_weapons]=weaponids[0];
2242 static bool willwork;
2243 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2244 for(i=0;i<weapons.numweapons;i++){
2246 if(weapons.owner[i]!=-1)
2247 if(player[weapons.owner[i]].weaponstuck!=-1)
2248 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2249 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2250 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))
2251 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2252 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2262 if(weapons.owner[i]!=-1)
2263 if(victim->weaponstuck!=-1){
2264 if(victim->weaponids[victim->weaponstuck]==i){
2269 if(weapons.type[i]!=staff){
2270 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2271 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2272 FSOUND_SetVolume(channels[knifedrawsound], 128);
2273 FSOUND_SetPaused(channels[knifedrawsound], false);
2277 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2278 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2279 FSOUND_SetVolume(channels[fleshstabremovesound], 128);
2280 FSOUND_SetPaused(channels[fleshstabremovesound], false);
2283 if(weapons.owner[i]!=-1){
2285 victim=&player[weapons.owner[i]];
2286 if(victim->num_weapons==1)victim->num_weapons=0;
2287 else victim->num_weapons=1;
2289 //victim->weaponactive=-1;
2290 victim->skeleton.longdead=0;
2291 victim->skeleton.free=1;
2292 victim->skeleton.broken=0;
2294 for(int j=0;j<victim->skeleton.num_joints;j++){
2295 victim->skeleton.joints[j].velchange=0;
2296 victim->skeleton.joints[j].locked=0;
2302 Normalise(&relative);
2303 XYZ footvel,footpoint;
2305 footpoint=weapons.position[i];
2306 if(victim->weaponstuck!=-1){
2307 if(victim->weaponids[victim->weaponstuck]==i){
2308 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2309 weapons.bloody[i]=2;
2310 weapons.blooddrip[i]=5;
2311 victim->weaponstuck=-1;
2314 if(victim->num_weapons>0){
2315 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2316 if(victim->weaponids[0]==i)
2317 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2320 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2321 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2322 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2323 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2325 weapons.owner[i]=id;
2327 weaponids[num_weapons]=weaponids[0];
2336 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2337 if(weaponactive==-1)weaponactive=0;
2338 else if(weaponactive==0){
2342 buffer=weaponids[0];
2343 weaponids[0]=weaponids[1];
2344 weaponids[1]=buffer;
2347 if(weaponactive==-1){
2357 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2358 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2359 FSOUND_SetVolume(channels[knifesheathesound], 128);
2360 FSOUND_SetPaused(channels[knifesheathesound], false);
2362 if(weaponactive!=-1){
2372 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2373 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2374 FSOUND_SetVolume(channels[knifedrawsound], 128);
2375 FSOUND_SetPaused(channels[knifedrawsound], false);
2380 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2381 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2382 Normalise(&rotatetarget);
2383 targetrotation=-asin(0-rotatetarget.x);
2384 targetrotation*=360/6.28;
2385 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2387 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2388 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2393 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2395 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;
2397 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2398 targetanimation=rabbittackleanim;
2409 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2410 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2411 FSOUND_SetVolume(channels[jumpsound], 128);
2412 FSOUND_SetPaused(channels[jumpsound], false);
2421 Normalise(&targetloc);
2423 for(i=0;i<numplayers;i++){
2425 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2426 closestdist=findDistancefast(&targetloc,&player[i].coords);
2431 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2433 victim=&player[closestid];
2434 coords=victim->coords;
2435 currentanimation=rabbittacklinganim;
2436 targetanimation=rabbittacklinganim;
2440 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2441 rotatetarget=coords-victim->coords;
2442 Normalise(&rotatetarget);
2443 targetrotation=-asin(0-rotatetarget.x);
2444 targetrotation*=360/6.28;
2445 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2447 if(targetanimation!=rabbitrunninganim){
2457 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2458 FSOUND_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2459 FSOUND_SetVolume(channels[jumpsound], 128);
2460 FSOUND_SetPaused(channels[jumpsound], false);
2466 float damagemult=1*power;
2467 if(creature==wolftype)damagemult=2.5*power;
2468 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2469 //if(onfire)damagemult=3;
2470 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2471 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2472 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2474 if(id==0)camerashake+=.4;
2475 if(Random()%2||creature==wolftype){
2478 if(creature==wolftype)DoBloodBig(0,250);
2482 gLoc[0]=victim->coords.x;
2483 gLoc[1]=victim->coords.y;
2484 gLoc[2]=victim->coords.z;
2488 if(tutoriallevel!=1){
2489 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2490 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2491 FSOUND_SetVolume(channels[heavyimpactsound], 128);
2492 FSOUND_SetPaused(channels[heavyimpactsound], false);
2494 if(creature==wolftype){
2495 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2496 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2497 FSOUND_SetVolume(channels[clawslicesound], 128);
2498 FSOUND_SetPaused(channels[clawslicesound], false);
2500 victim->DoBloodBig(2/victim->armorhead,175);
2504 relative=victim->coords-coords;
2506 Normalise(&relative);
2507 relative=DoRotation(relative,0,-90,0);
2508 for(i=0;i<victim->skeleton.num_joints;i++){
2509 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2511 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2514 victim->DoDamage(damagemult*100/victim->protectionhead);
2522 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2523 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2525 if(id==0)camerashake+=.4;
2526 if(Random()%2||creature==wolftype){
2528 if(creature==wolftype)DoBloodBig(0,235);
2532 gLoc[0]=victim->coords.x;
2533 gLoc[1]=victim->coords.y;
2534 gLoc[2]=victim->coords.z;
2538 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2539 FSOUND_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2540 FSOUND_SetVolume(channels[whooshhitsound], 512);
2541 FSOUND_SetPaused(channels[whooshhitsound], false);
2542 if(creature==wolftype){
2543 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2544 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2545 FSOUND_SetVolume(channels[clawslicesound], 128);
2546 FSOUND_SetPaused(channels[clawslicesound], false);
2548 victim->DoBloodBig(2,175);
2552 relative=victim->coords-coords;
2554 Normalise(&relative);
2556 Normalise(&relative);
2557 relative=DoRotation(relative,0,90,0);
2558 for(i=0;i<victim->skeleton.num_joints;i++){
2559 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2561 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2564 victim->DoDamage(damagemult*50/victim->protectionhead);
2568 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2569 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2571 if(id==0)camerashake+=.4;
2576 gLoc[0]=victim->coords.x;
2577 gLoc[1]=victim->coords.y;
2578 gLoc[2]=victim->coords.z;
2582 if(tutoriallevel!=1){
2583 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2584 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2585 FSOUND_SetVolume(channels[heavyimpactsound], 160);
2586 FSOUND_SetPaused(channels[heavyimpactsound], false);
2588 if(creature==wolftype){
2589 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2590 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2591 FSOUND_SetVolume(channels[clawslicesound], 128);
2592 FSOUND_SetPaused(channels[clawslicesound], false);
2594 victim->DoBloodBig(2/victim->armorhead,175);
2600 Normalise(&relative);
2601 relative=DoRotation(relative,0,-90,0);
2602 for(i=0;i<victim->skeleton.num_joints;i++){
2603 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2605 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2608 victim->DoDamage(damagemult*150/victim->protectionhead);
2610 if(victim->damage>victim->damagetolerance){
2623 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2624 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2626 if(id==0)camerashake+=.4;
2631 gLoc[0]=victim->coords.x;
2632 gLoc[1]=victim->coords.y;
2633 gLoc[2]=victim->coords.z;
2637 if(tutoriallevel!=1){
2638 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2639 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2640 FSOUND_SetVolume(channels[heavyimpactsound], 160);
2641 FSOUND_SetPaused(channels[heavyimpactsound], false);
2643 if(creature==wolftype){
2644 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2645 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2646 FSOUND_SetVolume(channels[clawslicesound], 128);
2647 FSOUND_SetPaused(channels[clawslicesound], false);
2649 victim->DoBloodBig(2/victim->armorhead,175);
2655 Normalise(&relative);
2656 relative=DoRotation(relative,0,90,0);
2657 for(i=0;i<victim->skeleton.num_joints;i++){
2658 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2660 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2663 victim->DoDamage(damagemult*150/victim->protectionhead);
2665 if(victim->damage>victim->damagetolerance){
2678 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2679 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2681 if(id==0)camerashake+=.4;
2688 gLoc[0]=victim->coords.x;
2689 gLoc[1]=victim->coords.y;
2690 gLoc[2]=victim->coords.z;
2694 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2695 FSOUND_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2696 FSOUND_SetVolume(channels[whooshhitsound], 512);
2697 FSOUND_SetPaused(channels[whooshhitsound], false);
2700 relative=victim->coords-coords;
2702 Normalise(&relative);
2703 for(i=0;i<victim->skeleton.num_joints;i++){
2704 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2706 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2709 victim->DoDamage(damagemult*50/victim->protectionhead);
2713 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2714 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2716 if(id==0)camerashake+=.2;
2719 gLoc[0]=victim->coords.x;
2720 gLoc[1]=victim->coords.y;
2721 gLoc[2]=victim->coords.z;
2725 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2726 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
2727 FSOUND_SetVolume(channels[landsound2], 128);
2728 FSOUND_SetPaused(channels[landsound2], false);
2730 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2731 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2732 FSOUND_SetVolume(channels[movewhooshsound], 128);
2733 FSOUND_SetPaused(channels[movewhooshsound], false);
2735 victim->skeleton.longdead=0;
2736 victim->skeleton.free=1;
2737 victim->skeleton.broken=0;
2738 victim->skeleton.spinny=1;
2740 for(i=0;i<victim->skeleton.num_joints;i++){
2741 victim->skeleton.joints[i].velchange=0;
2742 victim->skeleton.joints[i].delay=0;
2743 victim->skeleton.joints[i].locked=0;
2744 //victim->skeleton.joints[i].velocity=0;
2750 Normalise(&relative);
2751 for(i=0;i<victim->skeleton.num_joints;i++){
2752 victim->skeleton.joints[i].velocity.y=relative.y*10;
2753 victim->skeleton.joints[i].position.y+=relative.y*.3;
2754 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2755 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2757 victim->Puff(abdomen);
2758 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2762 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2763 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2765 if(id==0)camerashake+=.4;
2774 if(tutoriallevel!=1){
2775 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2776 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2777 FSOUND_SetVolume(channels[heavyimpactsound], 128);
2778 FSOUND_SetPaused(channels[heavyimpactsound], false);
2781 relative=victim->coords-coords;
2783 Normalise(&relative);
2784 for(i=0;i<victim->skeleton.num_joints;i++){
2785 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2787 victim->Puff(abdomen);
2788 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2792 victim->DoDamage(damagemult*500/victim->protectionhigh);
2793 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2797 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2798 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2800 if(id==0)camerashake+=.4;
2809 if(tutoriallevel!=1){
2810 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2811 FSOUND_3D_SetAttributes(channels[thudsound], gLoc, vel);
2812 FSOUND_SetVolume(channels[thudsound], 400);
2813 FSOUND_SetPaused(channels[thudsound], false);
2816 victim->skeleton.longdead=0;
2817 victim->skeleton.free=1;
2818 victim->skeleton.broken=0;
2819 victim->skeleton.spinny=1;
2821 for(i=0;i<victim->skeleton.num_joints;i++){
2822 victim->skeleton.joints[i].velchange=0;
2823 //victim->skeleton.joints[i].delay=0;
2824 victim->skeleton.joints[i].locked=0;
2827 relative=victim->coords-coords;
2828 Normalise(&relative);
2830 Normalise(&relative);
2831 for(i=0;i<victim->skeleton.num_joints;i++){
2832 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2834 if(id==0&&!victim->dead){
2838 victim->Puff(abdomen);
2839 victim->DoDamage(damagemult*20/victim->protectionhigh);
2840 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2842 if(!victim->dead)staggerdelay=1.2;
2848 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2849 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2850 //if(id==0)camerashake+=.4;
2861 if(!victim->skeleton.free)hasvictim=0;
2864 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2865 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2866 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2867 FSOUND_SetVolume(channels[knifesheathesound], 128);
2868 FSOUND_SetPaused(channels[knifesheathesound], false);
2871 if(victim&&hasvictim){
2872 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2874 XYZ where,startpoint,endpoint,movepoint,colpoint;
2875 float rotationpoint;
2877 if(weapons.type[weaponids[weaponactive]]==knife){
2878 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2879 where-=victim->coords;
2880 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2887 if(weapons.type[weaponids[weaponactive]]==sword){
2888 where=weapons.position[weaponids[weaponactive]];
2889 where-=victim->coords;
2890 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2892 where=weapons.tippoint[weaponids[weaponactive]];
2893 where-=victim->coords;
2894 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2897 if(weapons.type[weaponids[weaponactive]]==staff){
2898 where=weapons.position[weaponids[weaponactive]];
2899 where-=victim->coords;
2900 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2902 where=weapons.tippoint[weaponids[weaponactive]];
2903 where-=victim->coords;
2904 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2909 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2912 if(victim->dead!=2){
2913 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2914 if(id==0&&!victim->dead){
2915 bonus=FinishedBonus;
2920 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2922 victim->skeleton.longdead=0;
2923 victim->skeleton.free=1;
2924 victim->skeleton.broken=0;
2926 for(i=0;i<victim->skeleton.num_joints;i++){
2927 victim->skeleton.joints[i].velchange=0;
2928 victim->skeleton.joints[i].locked=0;
2929 //victim->skeleton.joints[i].velocity=0;
2931 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2932 FSOUND_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2933 FSOUND_SetVolume(channels[fleshstabsound], 128);
2934 FSOUND_SetPaused(channels[fleshstabsound], false);
2937 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2938 weapons.blooddrip[weaponids[weaponactive]]+=5;
2939 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2943 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2944 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2945 FSOUND_SetVolume(channels[knifesheathesound], 128);
2946 FSOUND_SetPaused(channels[knifesheathesound], false);
2952 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2953 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2954 //if(id==0)camerashake+=.4;
2964 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2965 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2966 FSOUND_SetVolume(channels[knifedrawsound], 128);
2967 FSOUND_SetPaused(channels[knifedrawsound], false);
2970 if(victim&&hasvictim){
2971 XYZ footvel,footpoint;
2973 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2974 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2975 FSOUND_SetVolume(channels[fleshstabremovesound], 128);
2976 FSOUND_SetPaused(channels[fleshstabremovesound], false);
2979 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2981 if(weapons.type[weaponids[weaponactive]]==sword){
2982 XYZ where,startpoint,endpoint,movepoint;
2983 float rotationpoint;
2986 where=weapons.position[weaponids[weaponactive]];
2987 where-=victim->coords;
2988 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2990 where=weapons.tippoint[weaponids[weaponactive]];
2991 where-=victim->coords;
2992 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2997 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2998 footpoint+=victim->coords;
3001 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
3004 if(weapons.type[weaponids[weaponactive]]==staff){
3005 XYZ where,startpoint,endpoint,movepoint;
3006 float rotationpoint;
3009 where=weapons.position[weaponids[weaponactive]];
3010 where-=victim->coords;
3011 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
3013 where=weapons.tippoint[weaponids[weaponactive]];
3014 where-=victim->coords;
3015 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
3020 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
3021 footpoint+=victim->coords;
3024 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
3027 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
3029 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
3030 victim->skeleton.longdead=0;
3031 victim->skeleton.free=1;
3032 victim->skeleton.broken=0;
3034 for(i=0;i<victim->skeleton.num_joints;i++){
3035 victim->skeleton.joints[i].velchange=0;
3036 victim->skeleton.joints[i].locked=0;
3037 //victim->skeleton.joints[i].velocity=0;
3043 Normalise(&relative);
3044 //victim->Puff(abdomen);
3045 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
3047 if(victim->bloodloss<victim->damagetolerance){
3048 victim->bloodloss+=1000;
3052 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3056 if(!hasvictim&&onterrain){
3057 weapons.bloody[weaponids[weaponactive]]=0;
3058 weapons.blooddrip[weaponids[weaponactive]]=0;
3062 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
3063 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
3065 if(id==0)camerashake+=.4;
3072 gLoc[0]=victim->coords.x;
3073 gLoc[1]=victim->coords.y;
3074 gLoc[2]=victim->coords.z;
3078 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
3080 if(tutoriallevel!=1){
3081 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3082 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3083 FSOUND_SetVolume(channels[heavyimpactsound], 128);
3084 FSOUND_SetPaused(channels[heavyimpactsound], false);
3088 if(tutoriallevel!=1){
3089 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3090 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
3091 FSOUND_SetVolume(channels[landsound2], 256);
3092 FSOUND_SetPaused(channels[landsound2], false);
3096 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
3099 relative=victim->coords-coords;
3101 Normalise(&relative);
3102 for(i=0;i<victim->skeleton.num_joints;i++){
3103 victim->skeleton.joints[i].velocity=relative*30;
3105 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
3107 victim->targetframe=0;
3108 victim->targetanimation=staggerbackhardanim;
3109 victim->targetrotation=targetrotation+180;
3114 victim->Puff(abdomen);
3115 victim->DoDamage(damagemult*60/victim->protectionhigh);
3124 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
3125 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
3127 if(id==0)camerashake+=.4;
3130 gLoc[0]=victim->coords.x;
3131 gLoc[1]=victim->coords.y;
3132 gLoc[2]=victim->coords.z;
3136 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
3137 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
3138 if(tutoriallevel!=1){
3139 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
3140 FSOUND_3D_SetAttributes(channels[thudsound], gLoc, vel);
3141 FSOUND_SetVolume(channels[thudsound], 512);
3142 FSOUND_SetPaused(channels[thudsound], false);
3145 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
3146 if(tutoriallevel!=1){
3147 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3148 FSOUND_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3149 FSOUND_SetVolume(channels[whooshhitsound], 512);
3150 FSOUND_SetPaused(channels[whooshhitsound], false);
3154 if(tutoriallevel!=1){
3155 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3156 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3157 FSOUND_SetVolume(channels[heavyimpactsound], 256);
3158 FSOUND_SetPaused(channels[heavyimpactsound], false);
3162 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
3165 relative=victim->coords-coords;
3167 Normalise(&relative);
3169 Normalise(&relative);
3170 for(i=0;i<victim->skeleton.num_joints;i++){
3171 victim->skeleton.joints[i].velocity=relative*5;
3173 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
3175 victim->targetframe=0;
3176 victim->targetanimation=staggerbackhardanim;
3177 victim->targetrotation=targetrotation+180;
3181 victim->Puff(abdomen);
3182 victim->DoDamage(damagemult*60/victim->protectionhigh);
3190 if(targetanimation==blockhighleftanim&&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 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3203 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
3204 FSOUND_SetVolume(channels[landsound2], 256);
3205 FSOUND_SetPaused(channels[landsound2], false);
3211 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
3212 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3213 if(victim->id==0)camerashake+=.4;
3216 gLoc[0]=victim->coords.x;
3217 gLoc[1]=victim->coords.y;
3218 gLoc[2]=victim->coords.z;
3223 if(weaponactive!=-1){
3224 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3225 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3226 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3228 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3229 FSOUND_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3230 FSOUND_SetVolume(channels[swordstaffsound], 512);
3231 FSOUND_SetPaused(channels[swordstaffsound], false);
3234 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3235 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3236 FSOUND_SetVolume(channels[metalhitsound], 512);
3237 FSOUND_SetPaused(channels[metalhitsound], false);
3245 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3246 if(weaponactive!=-1){
3249 weapons.owner[weaponids[0]]=-1;
3250 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);
3252 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3253 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3255 weapons.velocity[weaponids[0]]=aim*50;
3256 weapons.tipvelocity[weaponids[0]]=aim*50;
3257 weapons.missed[weaponids[0]]=0;
3258 weapons.hitsomething[weaponids[0]]=0;
3259 weapons.freetime[weaponids[0]]=0;
3260 weapons.firstfree[weaponids[0]]=1;
3261 weapons.physics[weaponids[0]]=0;
3264 weaponids[0]=weaponids[num_weapons];
3270 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3272 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3275 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3283 if(tutoriallevel!=1){
3286 gLoc[0]=victim->coords.x;
3287 gLoc[1]=victim->coords.y;
3288 gLoc[2]=victim->coords.z;
3292 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3293 FSOUND_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3294 FSOUND_SetVolume(channels[knifeslicesound], 512);
3295 FSOUND_SetPaused(channels[knifeslicesound], false);
3297 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3298 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3299 if(victim->id != 0 || difficulty==2){
3300 victim->targetframe=0;
3301 victim->targetanimation=staggerbackhardanim;
3302 victim->targetrotation=targetrotation+180;
3306 victim->lowreversaldelay=0;
3307 victim->highreversaldelay=0;
3308 if(aitype!=playercontrolled)weaponmissdelay=.6;
3310 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3311 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3313 XYZ footvel,footpoint;
3316 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3319 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;
3321 if(tutoriallevel!=1){
3322 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3323 footvel=DoRotation(facing,0,90,0)*.8;
3325 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3326 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3327 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3328 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3330 if(tutoriallevel==1){
3331 sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3333 victim->DoDamage(damagemult*0);
3336 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3337 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3338 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3345 if(tutoriallevel!=1){
3346 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3347 else victim->DoBloodBig(2/victim->armorhigh,185);
3348 victim->deathbleeding=1;
3351 gLoc[0]=victim->coords.x;
3352 gLoc[1]=victim->coords.y;
3353 gLoc[2]=victim->coords.z;
3357 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3358 FSOUND_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3359 FSOUND_SetVolume(channels[swordslicesound], 512);
3360 FSOUND_SetPaused(channels[swordslicesound], false);
3362 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3363 //if(animation[victim->targetanimation].attack){
3364 //if(victim->creature==rabbittype){
3365 if(tutoriallevel!=1){
3366 victim->targetframe=0;
3367 victim->targetanimation=staggerbackhardanim;
3368 victim->targetrotation=targetrotation+180;
3374 if(tutoriallevel!=1){
3375 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3376 weapons.blooddrip[weaponids[weaponactive]]+=3;
3378 float bloodlossamount;
3379 bloodlossamount=200+abs((float)(Random()%40))-20;
3380 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3381 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3382 victim->DoDamage(damagemult*0);
3384 XYZ footvel,footpoint;
3387 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3390 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;
3392 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3393 footvel=DoRotation(facing,0,90,0)*.8;
3395 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3396 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3397 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3398 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3406 gLoc[0]=victim->coords.x;
3407 gLoc[1]=victim->coords.y;
3408 gLoc[2]=victim->coords.z;
3412 if(victim->weaponactive!=-1){
3413 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3414 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3415 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3417 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3418 FSOUND_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3419 FSOUND_SetVolume(channels[swordstaffsound], 512);
3420 FSOUND_SetPaused(channels[swordstaffsound], false);
3423 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3424 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3425 FSOUND_SetVolume(channels[metalhitsound], 512);
3426 FSOUND_SetPaused(channels[metalhitsound], false);
3432 victim->Puff(righthand);
3434 victim->targetframe=0;
3435 victim->targetanimation=staggerbackhighanim;
3436 victim->targetrotation=targetrotation+180;
3438 weapons.owner[victim->weaponids[0]]=-1;
3439 aim=DoRotation(facing,0,90,0)*21;
3441 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3442 weapons.tipvelocity[victim->weaponids[0]]=aim;
3443 weapons.missed[victim->weaponids[0]]=1;
3444 weapons.hitsomething[weaponids[0]]=0;
3445 weapons.freetime[victim->weaponids[0]]=0;
3446 weapons.firstfree[victim->weaponids[0]]=1;
3447 weapons.physics[victim->weaponids[0]]=1;
3448 victim->num_weapons--;
3449 if(victim->num_weapons){
3450 victim->weaponids[0]=victim->weaponids[num_weapons];
3451 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3453 victim->weaponactive=-1;
3454 for(i=0;i<numplayers;i++){
3455 player[i].wentforweapon=0;
3458 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3459 FSOUND_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3460 FSOUND_SetVolume(channels[metalhitsound], 512);
3461 FSOUND_SetPaused(channels[metalhitsound], false);*/
3467 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3468 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3469 if(tutoriallevel!=1){
3470 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3472 if(id==0)camerashake+=.4;
3473 if(Random()%2||creature==wolftype){
3478 gLoc[0]=victim->coords.x;
3479 gLoc[1]=victim->coords.y;
3480 gLoc[2]=victim->coords.z;
3484 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3485 FSOUND_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3486 FSOUND_SetVolume(channels[staffheadsound], 256);
3487 FSOUND_SetPaused(channels[staffheadsound], false);
3491 relative=victim->coords-coords;
3493 Normalise(&relative);
3494 relative=DoRotation(relative,0,90,0);
3496 Normalise(&relative);
3497 for(i=0;i<victim->skeleton.num_joints;i++){
3498 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3500 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3501 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3504 if(tutoriallevel!=1){
3505 victim->DoDamage(damagemult*120/victim->protectionhigh);
3516 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3517 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3518 if(tutoriallevel!=1){
3519 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3521 if(id==0)camerashake+=.4;
3522 if(Random()%2||creature==wolftype){
3527 gLoc[0]=victim->coords.x;
3528 gLoc[1]=victim->coords.y;
3529 gLoc[2]=victim->coords.z;
3533 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3534 FSOUND_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3535 FSOUND_SetVolume(channels[staffheadsound], 256);
3536 FSOUND_SetPaused(channels[staffheadsound], false);
3540 relative=victim->coords-coords;
3542 Normalise(&relative);
3543 relative=DoRotation(relative,0,-90,0);
3544 for(i=0;i<victim->skeleton.num_joints;i++){
3545 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3547 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3548 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3551 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3562 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3563 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3565 if(tutoriallevel!=1){
3566 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3567 if(id==0)camerashake+=.4;
3568 if(Random()%2||creature==wolftype){
3573 gLoc[0]=victim->coords.x;
3574 gLoc[1]=victim->coords.y;
3575 gLoc[2]=victim->coords.z;
3579 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3580 FSOUND_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3581 FSOUND_SetVolume(channels[staffbodysound], 256);
3582 FSOUND_SetPaused(channels[staffbodysound], false);
3584 victim->skeleton.longdead=0;
3585 victim->skeleton.free=1;
3586 victim->skeleton.broken=0;
3588 for(i=0;i<victim->skeleton.num_joints;i++){
3589 victim->skeleton.joints[i].velchange=0;
3590 victim->skeleton.joints[i].locked=0;
3591 //victim->skeleton.joints[i].velocity=0;
3597 /*relative=victim->coords-coords;
3599 Normalise(&relative);
3600 relative=DoRotation(relative,0,90,0);*/
3602 Normalise(&relative);
3604 for(i=0;i<victim->skeleton.num_joints;i++){
3605 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3608 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3611 for(i=0;i<victim->skeleton.num_joints;i++){
3612 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3615 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3617 victim->Puff(abdomen);
3618 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3631 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3632 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3634 if(id==0)camerashake+=.4;
3637 gLoc[0]=victim->coords.x;
3638 gLoc[1]=victim->coords.y;
3639 gLoc[2]=victim->coords.z;
3644 relative=victim->coords-coords;
3646 Normalise(&relative);
3652 if(animation[victim->targetanimation].height==lowheight){
3658 for(i=0;i<victim->skeleton.num_joints;i++){
3659 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3661 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3662 if(tutoriallevel!=1){
3663 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3664 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3665 FSOUND_SetVolume(channels[heavyimpactsound], 128);
3666 FSOUND_SetPaused(channels[heavyimpactsound], false);
3669 victim->DoDamage(damagemult*100/victim->protectionhead);
3670 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3671 if(creature==wolftype){
3672 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3673 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3674 FSOUND_SetVolume(channels[clawslicesound], 128);
3675 FSOUND_SetPaused(channels[clawslicesound], false);
3677 victim->DoBloodBig(2/victim->armorhead,175);
3681 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3682 for(i=0;i<victim->skeleton.num_joints;i++){
3683 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3685 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3686 victim->targetframe=0;
3687 victim->targetanimation=staggerbackhighanim;
3688 victim->targetrotation=targetrotation+180;
3690 if(tutoriallevel!=1){
3691 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3692 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
3693 FSOUND_SetVolume(channels[landsound2], 128);
3694 FSOUND_SetPaused(channels[landsound2], false);
3696 victim->Puff(abdomen);
3697 victim->DoDamage(damagemult*30/victim->protectionhigh);
3698 if(creature==wolftype){
3699 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3700 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3701 FSOUND_SetVolume(channels[clawslicesound], 128);
3702 FSOUND_SetPaused(channels[clawslicesound], false);
3704 victim->DoBloodBig(2/victim->armorhigh,170);
3711 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3712 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3714 if(id==0)camerashake+=.2;
3717 gLoc[0]=victim->coords.x;
3718 gLoc[1]=victim->coords.y;
3719 gLoc[2]=victim->coords.z;
3723 if(tutoriallevel!=1){
3724 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3725 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
3726 FSOUND_SetVolume(channels[landsound2], 128);
3727 FSOUND_SetPaused(channels[landsound2], false);
3730 relative=victim->coords-coords;
3732 Normalise(&relative);
3734 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3737 for(i=0;i<victim->skeleton.num_joints;i++){
3738 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3740 relative=DoRotation(relative,0,-90,0);
3742 for(i=0;i<victim->skeleton.num_joints;i++){
3743 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)
3744 victim->skeleton.joints[i].velocity=relative*80;
3746 victim->Puff(rightankle);
3747 victim->Puff(leftankle);
3748 victim->DoDamage(damagemult*40/victim->protectionlow);
3751 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3752 for(i=0;i<victim->skeleton.num_joints;i++){
3753 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3755 relative=DoRotation(relative,0,-90,0);
3756 for(i=0;i<victim->skeleton.num_joints;i++){
3757 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)
3758 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3760 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3761 victim->targetframe=0;
3762 victim->targetanimation=staggerbackhighanim;
3763 victim->targetrotation=targetrotation+180;
3765 if(tutoriallevel!=1){
3766 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3767 FSOUND_3D_SetAttributes(channels[landsound2], gLoc, vel);
3768 FSOUND_SetVolume(channels[landsound2], 128);
3769 FSOUND_SetPaused(channels[landsound2], false);
3771 victim->Puff(abdomen);
3772 victim->DoDamage(damagemult*30/victim->protectionlow);
3782 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3783 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3785 if(id==0)camerashake+=.4;
3792 gLoc[0]=victim->coords.x;
3793 gLoc[1]=victim->coords.y;
3794 gLoc[2]=victim->coords.z;
3798 if(tutoriallevel!=1){
3799 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3800 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3801 FSOUND_SetVolume(channels[heavyimpactsound], 128);
3802 FSOUND_SetPaused(channels[heavyimpactsound], false);
3804 if(creature==wolftype){
3805 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3806 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3807 FSOUND_SetVolume(channels[clawslicesound], 128);
3808 FSOUND_SetPaused(channels[clawslicesound], false);
3810 victim->DoBloodBig(2/victim->armorhigh,170);
3814 relative=victim->coords-oldcoords;
3816 Normalise(&relative);
3817 //relative=DoRotation(relative,0,-90,0);
3818 for(i=0;i<victim->skeleton.num_joints;i++){
3819 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3821 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3823 victim->Puff(abdomen);
3824 victim->DoDamage(damagemult*150/victim->protectionhigh);
3833 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3834 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3835 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3836 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3839 weaponids[num_weapons]=weaponids[victim->weaponactive];
3842 weaponids[0]=victim->weaponids[victim->weaponactive];
3843 victim->num_weapons--;
3844 if(victim->num_weapons>0){
3845 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3846 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3848 victim->weaponactive=-1;
3853 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3855 if(id==0)camerashake+=.4;
3862 gLoc[0]=victim->coords.x;
3863 gLoc[1]=victim->coords.y;
3864 gLoc[2]=victim->coords.z;
3868 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3869 FSOUND_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3870 FSOUND_SetVolume(channels[whooshhitsound], 128);
3871 FSOUND_SetPaused(channels[whooshhitsound], false);
3874 relative=victim->coords-oldcoords;
3876 Normalise(&relative);
3877 //relative=DoRotation(relative,0,-90,0);
3878 for(i=0;i<victim->skeleton.num_joints;i++){
3879 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3881 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3884 victim->DoDamage(damagemult*70/victim->protectionhigh);
3887 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3889 if(id==0)camerashake+=.4;
3896 gLoc[0]=victim->coords.x;
3897 gLoc[1]=victim->coords.y;
3898 gLoc[2]=victim->coords.z;
3904 bonus=staffreversebonus;
3909 if(tutoriallevel!=1){
3910 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3911 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3912 FSOUND_SetVolume(channels[heavyimpactsound], 128);
3913 FSOUND_SetPaused(channels[heavyimpactsound], false);
3917 bonus=staffreversebonus;
3923 relative=victim->coords-oldcoords;
3925 Normalise(&relative);
3926 //relative=DoRotation(relative,0,-90,0);
3927 for(i=0;i<victim->skeleton.num_joints;i++){
3928 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3930 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3933 victim->DoDamage(damagemult*70/victim->protectionhigh);
3936 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3942 Normalise(&relative);
3945 for(i=0;i<victim->skeleton.num_joints;i++){
3946 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3948 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3949 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3950 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3951 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3952 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3953 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3954 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3955 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3957 victim->Puff(abdomen);
3958 victim->DoDamage(damagemult*90/victim->protectionhigh);
3968 if(weaponactive!=-1||creature==wolftype)doslice=1;
3969 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3973 gLoc[0]=victim->coords.x;
3974 gLoc[1]=victim->coords.y;
3975 gLoc[2]=victim->coords.z;
3979 if(weaponactive!=-1){
3980 victim->DoBloodBig(2/victim->armorhigh,225);
3981 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3982 FSOUND_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3983 FSOUND_SetVolume(channels[knifeslicesound], 512);
3984 FSOUND_SetPaused(channels[knifeslicesound], false);
3985 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3986 weapons.blooddrip[weaponids[weaponactive]]+=3;
3988 if(weaponactive==-1&&creature==wolftype){
3989 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3990 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3991 FSOUND_SetVolume(channels[clawslicesound], 128);
3992 FSOUND_SetPaused(channels[clawslicesound], false);
3994 victim->DoBloodBig(2/victim->armorhigh,175);
4001 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
4007 Normalise(&relative);
4010 for(i=0;i<victim->skeleton.num_joints;i++){
4011 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
4013 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
4014 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
4015 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
4016 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
4017 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
4018 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
4019 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
4020 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
4023 bonus=swordreversebonus;
4027 //victim->DoDamage(90);
4029 /*if(weaponactive!=-1){
4032 gLoc[0]=victim->coords.x;
4033 gLoc[1]=victim->coords.y;
4034 gLoc[2]=victim->coords.z;
4038 victim->DoBloodBig(2,225);
4039 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4040 FSOUND_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4041 FSOUND_SetVolume(channels[knifeslicesound], 512);
4042 FSOUND_SetPaused(channels[knifeslicesound], false);
4043 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4044 weapons.blooddrip[weaponids[weaponactive]]+=3;
4048 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
4050 if(id==0)camerashake+=.4;
4057 gLoc[0]=victim->coords.x;
4058 gLoc[1]=victim->coords.y;
4059 gLoc[2]=victim->coords.z;
4063 if(tutoriallevel!=1){
4064 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4065 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4066 FSOUND_SetVolume(channels[heavyimpactsound], 128);
4067 FSOUND_SetPaused(channels[heavyimpactsound], false);
4071 relative=victim->coords-oldcoords;
4073 Normalise(&relative);
4074 relative=DoRotation(relative,0,-90,0);
4075 for(i=0;i<victim->skeleton.num_joints;i++){
4076 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
4078 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
4080 victim->Puff(abdomen);
4081 victim->DoDamage(damagemult*30/victim->protectionhigh);
4090 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
4093 victim->skeleton.spinny=0;
4097 Normalise(&relative);
4098 if(victim->id==0)relative/=30;
4099 for(i=0;i<victim->skeleton.num_joints;i++){
4100 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
4102 //victim->DoDamage(1000);
4103 victim->damage=victim->damagetolerance;
4104 victim->permanentdamage=victim->damagetolerance-1;
4107 if(weaponactive!=-1||creature==wolftype)doslice=1;
4108 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4112 gLoc[0]=victim->coords.x;
4113 gLoc[1]=victim->coords.y;
4114 gLoc[2]=victim->coords.z;
4118 if(weaponactive!=-1){
4119 victim->DoBloodBig(200,225);
4120 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4121 FSOUND_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4122 FSOUND_SetVolume(channels[knifeslicesound], 512);
4123 FSOUND_SetPaused(channels[knifeslicesound], false);
4124 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4125 weapons.blooddrip[weaponids[weaponactive]]+=5;
4128 if(creature==wolftype&&weaponactive==-1){
4129 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4130 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4131 FSOUND_SetVolume(channels[clawslicesound], 128);
4132 FSOUND_SetPaused(channels[clawslicesound], false);
4134 victim->DoBloodBig(2,175);
4144 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4145 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4147 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
4148 if(targetanimation==knifesneakattackanim){
4149 /*victim->DoBloodBig(200,195);
4154 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4155 sprites.MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
4157 XYZ footvel,footpoint;
4159 footpoint=weapons.tippoint[weaponids[0]];
4160 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4161 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4162 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4163 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4164 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4165 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4166 victim->DoBloodBig(200,195);
4173 //victim->neckspurtamount=5;
4175 if(targetanimation==knifefollowanim){
4181 XYZ footvel,footpoint;
4183 footpoint=weapons.tippoint[weaponids[0]];
4184 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4185 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4186 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4187 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4188 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
4189 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
4192 victim->bloodloss+=10000;
4196 gLoc[0]=victim->coords.x;
4197 gLoc[1]=victim->coords.y;
4198 gLoc[2]=victim->coords.z;
4202 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4203 FSOUND_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4204 FSOUND_SetVolume(channels[fleshstabsound], 512);
4205 FSOUND_SetPaused(channels[fleshstabsound], false);
4206 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4207 weapons.blooddrip[weaponids[weaponactive]]+=5;
4211 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
4214 for(i=0;i<victim->skeleton.num_joints;i++){
4215 victim->skeleton.joints[i].velocity=0;
4217 if(targetanimation==knifefollowanim){
4219 for(i=0;i<victim->skeleton.num_joints;i++){
4220 victim->skeleton.joints[i].velocity=0;
4223 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
4226 gLoc[0]=victim->coords.x;
4227 gLoc[1]=victim->coords.y;
4228 gLoc[2]=victim->coords.z;
4232 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4233 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4234 FSOUND_SetVolume(channels[fleshstabremovesound], 512);
4235 FSOUND_SetPaused(channels[fleshstabremovesound], false);
4236 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4237 weapons.blooddrip[weaponids[weaponactive]]+=5;
4239 XYZ footvel,footpoint;
4241 footpoint=weapons.tippoint[weaponids[0]];
4242 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4243 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4244 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4245 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4246 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4247 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4251 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4252 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4261 XYZ footvel,footpoint;
4263 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
4264 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4265 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4266 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4267 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4268 sprites.MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4269 sprites.MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4270 victim->DoBloodBig(200,180);
4271 victim->DoBloodBig(200,215);
4272 victim->bloodloss+=10000;
4276 gLoc[0]=victim->coords.x;
4277 gLoc[1]=victim->coords.y;
4278 gLoc[2]=victim->coords.z;
4282 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4283 FSOUND_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4284 FSOUND_SetVolume(channels[fleshstabsound], 512);
4285 FSOUND_SetPaused(channels[fleshstabsound], false);
4286 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4287 weapons.blooddrip[weaponids[weaponactive]]+=5;
4291 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
4294 for(i=0;i<victim->skeleton.num_joints;i++){
4295 victim->skeleton.joints[i].velocity=0;
4297 if(weaponactive!=-1){
4300 gLoc[0]=victim->coords.x;
4301 gLoc[1]=victim->coords.y;
4302 gLoc[2]=victim->coords.z;
4306 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4307 FSOUND_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4308 FSOUND_SetVolume(channels[fleshstabremovesound], 512);
4309 FSOUND_SetPaused(channels[fleshstabremovesound], false);
4310 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4311 weapons.blooddrip[weaponids[weaponactive]]+=5;
4313 XYZ footvel,footpoint;
4315 footpoint=weapons.tippoint[weaponids[0]];
4316 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4317 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4318 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4319 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4320 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4321 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4325 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4327 if(id==0)camerashake+=.4;
4334 gLoc[0]=victim->coords.x;
4335 gLoc[1]=victim->coords.y;
4336 gLoc[2]=victim->coords.z;
4340 if(weaponactive==-1){
4341 if(tutoriallevel!=1){
4342 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4343 FSOUND_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4344 FSOUND_SetVolume(channels[heavyimpactsound], 128);
4345 FSOUND_SetPaused(channels[heavyimpactsound], false);
4350 if(weaponactive!=-1||creature==wolftype)doslice=1;
4351 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4353 if(weaponactive!=-1){
4354 victim->DoBloodBig(2/victim->armorhead,225);
4355 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4356 FSOUND_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4357 FSOUND_SetVolume(channels[knifeslicesound], 512);
4358 FSOUND_SetPaused(channels[knifeslicesound], false);
4359 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4360 weapons.blooddrip[weaponids[weaponactive]]+=3;
4362 if(weaponactive==-1&&creature==wolftype){
4363 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4364 FSOUND_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4365 FSOUND_SetVolume(channels[clawslicesound], 128);
4366 FSOUND_SetPaused(channels[clawslicesound], false);
4368 victim->DoBloodBig(2/victim->armorhead,175);
4381 //relative=victim->coords-oldcoords;
4384 Normalise(&relative);
4385 relative=DoRotation(relative,0,90,0);
4387 Normalise(&relative);
4388 for(i=0;i<victim->skeleton.num_joints;i++){
4389 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4391 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4392 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4393 victim->DoDamage(damagemult*100/victim->protectionhead);
4397 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4401 //relative=victim->coords-oldcoords;
4404 Normalise(&relative);
4405 relative=DoRotation(relative,0,90,0);
4407 Normalise(&relative);
4408 for(i=0;i<victim->skeleton.num_joints;i++){
4409 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4411 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4414 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4415 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4426 if(targetframe>animation[currentanimation].numframes-1){
4429 targetanimation=getIdle();
4433 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4434 targetanimation=rollanim;
4445 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4446 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4447 FSOUND_SetVolume(channels[movewhooshsound], 128);
4448 FSOUND_SetPaused(channels[movewhooshsound], false);
4450 if(currentanimation==staggerbackhighanim){
4451 targetanimation=getIdle();
4453 if(currentanimation==staggerbackhardanim){
4454 targetanimation=getIdle();
4456 if(currentanimation==removeknifeanim){
4457 targetanimation=getIdle();
4459 if(currentanimation==crouchremoveknifeanim){
4460 targetanimation=getCrouch();
4462 if(currentanimation==backhandspringanim){
4463 targetanimation=getIdle();
4465 if(currentanimation==dodgebackanim){
4466 targetanimation=getIdle();
4468 if(currentanimation==drawleftanim){
4469 targetanimation=getIdle();
4471 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4472 targetanimation=getIdle();
4473 if(currentanimation==crouchdrawrightanim){
4474 targetanimation=getCrouch();
4476 if(weaponactive==-1)weaponactive=0;
4477 else if(weaponactive==0){
4481 buffer=weaponids[0];
4482 weaponids[0]=weaponids[1];
4483 weaponids[1]=buffer;
4487 if(weaponactive==-1){
4497 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4498 FSOUND_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4499 FSOUND_SetVolume(channels[knifesheathesound], 128);
4500 FSOUND_SetPaused(channels[knifesheathesound], false);
4502 if(weaponactive!=-1){
4512 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4513 FSOUND_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4514 FSOUND_SetVolume(channels[knifedrawsound], 128);
4515 FSOUND_SetPaused(channels[knifedrawsound], false);
4518 if(currentanimation==rollanim){
4519 targetanimation=getCrouch();
4524 if(targetanimation==walljumprightkickanim){
4527 if(targetanimation==walljumpleftkickanim){
4530 targetanimation=jumpdownanim;
4532 if(currentanimation==climbanim){
4533 targetanimation=getCrouch();
4536 if(!isnormal(coords.x))
4547 if(targetanimation==rabbitkickreversalanim){
4548 targetanimation=getCrouch();
4551 if(targetanimation==jumpreversalanim){
4552 targetanimation=getCrouch();
4555 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4556 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4558 float closestdist=-1;
4561 for(i=0;i<numplayers;i++){
4562 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4563 distance=findDistancefast(&player[i].coords,&coords);
4564 if(closestdist==-1||distance<closestdist){
4565 closestdist=distance;
4570 if(closestdist>0&&closest>=0&&closestdist<16){
4571 victim=&player[closest];
4572 targetanimation=walljumprightkickanim;
4574 XYZ rotatetarget=victim->coords-coords;
4575 Normalise(&rotatetarget);
4576 rotation=-asin(0-rotatetarget.x);
4578 if(rotatetarget.z<0)rotation=180-rotation;
4579 targettilt2=-asin(rotatetarget.y)*360/6.28;
4580 velocity=(victim->coords-coords)*4;
4585 if(targetanimation==walljumpbackanim){
4586 targetanimation=backflipanim;
4590 if(id==0)FSOUND_SetPaused(channels[whooshsound], false);
4592 if(targetanimation==walljumprightanim){
4593 targetanimation=rightflipanim;
4597 velocity=DoRotation(facing,0,30,0)*-8;
4600 if(targetanimation==walljumpfrontanim){
4601 targetanimation=frontflipanim;
4603 //targetrotation-=180;
4608 if(id==0)FSOUND_SetPaused(channels[whooshsound], false);
4610 if(targetanimation==walljumpleftanim){
4613 float closestdist=-1;
4616 for(i=0;i<numplayers;i++){
4617 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4618 distance=findDistancefast(&player[i].coords,&coords);
4619 if(closestdist==-1||distance<closestdist){
4620 closestdist=distance;
4625 if(closestdist>0&&closest>=0&&closestdist<16){
4626 victim=&player[closest];
4627 targetanimation=walljumpleftkickanim;
4629 XYZ rotatetarget=victim->coords-coords;
4630 Normalise(&rotatetarget);
4631 rotation=-asin(0-rotatetarget.x);
4633 if(rotatetarget.z<0)rotation=180-rotation;
4634 targettilt2=-asin(rotatetarget.y)*360/6.28;
4635 velocity=(victim->coords-coords)*4;
4640 if(targetanimation!=walljumpleftkickanim){
4641 targetanimation=leftflipanim;
4645 velocity=DoRotation(facing,0,-30,0)*-8;
4648 if(id==0)FSOUND_SetPaused(channels[whooshsound], false);
4650 if(targetanimation==sneakattackanim){
4651 float ycoords=oldcoords.y;
4652 currentanimation=getCrouch();
4653 targetanimation=getCrouch();
4656 targetrotation+=180;
4661 targetheadrotation+=180;
4663 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4667 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4668 float ycoords=oldcoords.y;
4669 targetanimation=getIdle();
4671 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4675 if(currentanimation==knifefollowanim){
4676 targetanimation=getIdle();
4679 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4680 float ycoords=oldcoords.y;
4681 targetanimation=getStop();
4682 targetrotation+=180;
4687 targetheadrotation+=180;
4688 if(!isnormal(coords.x))
4690 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4691 oldcoords=coords+facing*.5;
4692 else if(currentanimation==sweepreversalanim)
4693 oldcoords=coords+facing*1.1;
4694 else if(currentanimation==upunchreversalanim){
4695 oldcoords=coords+facing*1.5;
4696 targetrotation+=180;
4698 targetheadrotation+=180;
4702 else if(currentanimation==knifeslashreversalanim){
4703 oldcoords=coords+facing*.5;
4706 targetheadrotation+=90;
4710 else if(currentanimation==staffspinhitreversalanim){
4711 targetrotation+=180;
4713 targetheadrotation+=180;
4717 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4718 else oldcoords.y=ycoords;
4719 currentoffset=coords-oldcoords;
4725 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4730 if(animation[targetanimation].attack==reversed){
4732 if(targetanimation==sweepreversedanim)targetrotation+=90;
4733 targetanimation=backhandspringanim;
4743 PlaySoundEx( landsound, samp[landsound], NULL, true);
4744 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
4745 FSOUND_SetVolume(channels[landsound], 128);
4746 FSOUND_SetPaused(channels[landsound], false);
4748 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4749 targetanimation=rollanim;
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;
4755 if(currentanimation==knifeslashreversedanim){
4756 targetanimation=rollanim;
4761 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4762 coords.y=oldcoords.y;
4766 targetanimation=jumpdownanim;
4768 if(wasLanding())targetanimation=getIdle();
4769 if(wasLandhard())targetanimation=getIdle();
4770 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4771 targetanimation=getIdle();
4773 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4774 coords.y=oldcoords.y;
4775 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4776 targetoffset.y=coords.y;
4777 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4778 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4779 currentoffset.y-=(coords.y-targetoffset.y);
4780 coords.y=targetoffset.y;
4782 normalsupdatedelay=0;
4784 if(currentanimation==upunchanim){
4785 targetanimation=getStop();
4786 normalsupdatedelay=0;
4789 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4790 targetrotation=rotation;
4793 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4794 if(!hasstaff)DoDamage(35);
4797 rabbitkickragdoll=1;
4799 if(currentanimation==rabbitkickreversedanim){
4806 if(id!=0)SolidHitBonus();
4810 targetanimation=rollanim;
4812 if(id==0)FSOUND_SetPaused(channels[whooshsound], true);
4816 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4822 if(currentanimation==jumpreversedanim){
4829 if(id!=0)SolidHitBonus();
4833 targetanimation=rollanim;
4835 if(id==0)FSOUND_SetPaused(channels[whooshsound], true);
4840 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){
4841 targetanimation=getupfromfrontanim;
4844 else if(animation[currentanimation].attack==normalattack){
4845 targetanimation=getIdle();
4848 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4849 targetanimation=blockhighleftstrikeanim;
4851 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4852 targetanimation=getIdle();
4855 if(currentanimation==spinkickanim&&victim->skeleton.free){
4856 if(creature==rabbittype)targetanimation=fightidleanim;
4861 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4863 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4864 targetanimation=jumpdownanim;
4869 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4870 if(!isRun()||!wasRun()){
4871 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4872 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4873 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4874 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4876 if(isRun()&&wasRun()){
4879 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4880 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4883 else if(transspeed)target+=multiplier*transspeed*speed*2;
4885 if(!isRun()||!wasRun()){
4886 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4887 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4888 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4889 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4893 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4895 if(target>1){currentframe=targetframe; target=1;}
4897 rot=targetrot*target;
4898 rotation+=rot-oldrot;
4904 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4906 for(i=0;i<skeleton.num_joints;i++){
4907 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4910 skeleton.FindForwards();
4912 for(i=0;i<skeleton.num_muscles;i++){
4913 if(skeleton.muscles[i].visible)
4915 skeleton.FindRotationMuscle(i,targetanimation);
4918 for(i=0;i<skeleton.num_muscles;i++){
4919 if(skeleton.muscles[i].visible)
4921 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4922 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4923 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4928 for(i=0;i<skeleton.num_joints;i++){
4929 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4932 skeleton.FindForwards();
4934 for(i=0;i<skeleton.num_muscles;i++){
4935 if(skeleton.muscles[i].visible)
4937 skeleton.FindRotationMuscle(i,targetanimation);
4940 for(i=0;i<skeleton.num_muscles;i++){
4941 if(skeleton.muscles[i].visible)
4943 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4944 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4945 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4946 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4947 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4948 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4949 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4950 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4951 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4955 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4957 oldcurrentanimation=currentanimation;
4958 oldtargetanimation=targetanimation;
4959 oldtargetframe=targetframe;
4960 oldcurrentframe=currentframe;
4962 for(i=0;i<skeleton.num_joints;i++){
4963 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4964 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4966 offset=currentoffset*(1-target)+targetoffset*target;
4967 for(i=0;i<skeleton.num_muscles;i++){
4968 if(skeleton.muscles[i].visible)
4970 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4971 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4972 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4977 if(isLanding()&&landhard){
4978 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4979 if(id==0)camerashake+=.4;
4980 targetanimation=getLandhard();
4988 //skeleton.DoConstraints();
4991 void Person::DoStuff(){
4992 static XYZ terrainnormal;
4993 static XYZ flatfacing;
4994 static XYZ flatvelocity;
4995 static float flatvelspeed;
4999 static int bloodsize;
5000 static int startx,starty,endx,endy;
5001 static int texdetailint;
5002 static GLubyte color;
5003 static XYZ bloodvel;
5005 onfiredelay-=multiplier;
5006 if(onfiredelay<0&&onfire)
5014 crouchkeydowntime+=multiplier;
5015 if(!crouchkeydown)crouchkeydowntime=0;
5016 jumpkeydowntime+=multiplier;
5017 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
5019 if(hostile||damage>0||bloodloss>0)immobile=0;
5021 if(isIdle()||isRun())targetoffset=0;
5023 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
5025 if(id==0)blooddimamount-=multiplier*.3;
5026 speechdelay-=multiplier;
5027 texupdatedelay-=multiplier;
5028 interestdelay-=multiplier;
5029 flamedelay-=multiplier;
5030 parriedrecently-=multiplier;
5036 if(id==0)speed=1.1*speedmult;
5037 else speed=1.0*speedmult;
5038 if(!skeleton.free)rabbitkickragdoll=0;
5042 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
5043 if(id!=0&&creature==wolftype&&difficulty==2){
5045 if(aitype!=passivetype){
5047 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){
5051 if(scale<0.2)superruntoggle=0;
5052 if(targetanimation==wolfrunninganim&&!superruntoggle){
5053 targetanimation=getRun();
5056 /*static float toggledelay;
5057 toggledelay-=multiplier;
5060 if(Random()%3==0)superruntoggle=1-superruntoggle;
5063 if(weaponactive==-1&&num_weapons>0){
5064 if(weapons.type[weaponids[0]]==staff){
5071 /*if(aitype!=playercontrolled)*///deathbleeding=5;
5072 /*if(aitype!=playercontrolled)*/
5074 if(burnt>.6)burnt=.6;
5075 FSOUND_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
5077 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5088 FSOUND_3D_SetAttributes(channels[whooshsound], gLoc, vel);
5089 FSOUND_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
5093 while(flamedelay<0&&onfire){
5095 howmany=abs(Random()%(skeleton.num_joints));
5096 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
5097 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
5098 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
5099 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
5100 sprites.MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5103 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
5105 howmany=abs(Random()%(skeleton.num_joints));
5106 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
5107 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
5108 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
5109 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
5110 sprites.MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
5114 bleeding-=multiplier*.3;
5116 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5117 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
5121 if(neckspurtamount>0){
5122 neckspurtamount-=multiplier;
5123 neckspurtdelay-=multiplier*3;
5124 neckspurtparticledelay-=multiplier*3;
5125 if(neckspurtparticledelay<0&&neckspurtdelay>2){
5129 bloodvel.z=5*neckspurtamount;
5130 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
5133 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
5135 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
5136 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
5137 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);
5138 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);
5139 neckspurtparticledelay=.05;
5141 if(neckspurtdelay<0){
5146 if(deathbleeding>0&&dead!=2){
5147 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
5148 else bleeddelay-=5*multiplier/4;
5149 if(bleeddelay<0&&bloodtoggle){
5154 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
5155 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
5156 if(skeleton.free)sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
5157 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);
5161 bloodloss+=deathbleeding*40;
5164 bloodloss+=deathbleeding*multiplier*80;
5165 deathbleeding-=multiplier*1.6;
5166 //if(id==0)deathbleeding-=multiplier*.2;
5167 if(deathbleeding<0)deathbleeding=0;
5168 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
5169 if(weaponactive!=-1){
5170 weapons.owner[weaponids[0]]=-1;
5171 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5172 weapons.velocity[weaponids[0]].x+=.01;
5173 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5174 weapons.missed[weaponids[0]]=1;
5175 weapons.hitsomething[weaponids[0]]=0;
5176 weapons.freetime[weaponids[0]]=0;
5177 weapons.firstfree[weaponids[0]]=1;
5178 weapons.physics[weaponids[0]]=1;
5181 weaponids[0]=weaponids[num_weapons];
5182 if(weaponstuck==num_weapons)weaponstuck=0;
5185 for(i=0;i<numplayers;i++){
5186 player[i].wentforweapon=0;
5198 if(!dead&&creature==wolftype){
5204 if(targetanimation==knifefollowedanim&&!skeleton.free){
5205 for(i=0;i<skeleton.num_joints;i++){
5206 skeleton.joints[i].velocity=0;
5207 skeleton.joints[i].velocity.y=-2;
5210 if(id!=0&&unconscioustime>.1){
5218 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
5221 bloodsize=5-realtexdetail;
5225 texdetailint=realtexdetail;
5226 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5227 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5228 endx=startx+bloodsize;
5229 endy=starty+bloodsize;
5231 if(startx<0){startx=0;bleeding=0;}
5232 if(starty<0){starty=0;bleeding=0;}
5233 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
5234 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
5235 if(endx<startx)endx=startx;
5236 if(endy<starty)endy=starty;
5242 for(i=startx;i<endx;i++){
5243 for(j=starty;j<endy;j++){
5245 color=Random()%85+170;
5246 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
5247 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
5248 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
5253 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5254 DoMipmaps(0,startx,endx,starty,endy);
5258 bleedy-=4/realtexdetail;
5259 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
5260 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
5263 bleedx+=4*direction/realtexdetail;
5264 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
5265 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
5269 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
5270 righthandmorphness=targetrighthandmorphness;
5271 righthandmorphstart=righthandmorphend;
5273 else if(righthandmorphness>targetrighthandmorphness){
5274 righthandmorphness-=multiplier*4;
5276 else if(righthandmorphness<targetrighthandmorphness){
5277 righthandmorphness+=multiplier*4;
5280 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
5281 lefthandmorphness=targetlefthandmorphness;
5282 lefthandmorphstart=lefthandmorphend;
5284 else if(lefthandmorphness>targetlefthandmorphness){
5285 lefthandmorphness-=multiplier*4;
5287 else if(lefthandmorphness<targetlefthandmorphness){
5288 lefthandmorphness+=multiplier*4;
5291 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
5292 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
5293 tailmorphness=targettailmorphness;
5294 tailmorphstart=tailmorphend;
5296 else if(tailmorphness>targettailmorphness){
5297 tailmorphness-=multiplier*10;
5299 else if(tailmorphness<targettailmorphness){
5300 tailmorphness+=multiplier*10;
5304 if(creature==wolftype){
5305 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
5306 tailmorphness=targettailmorphness;
5307 tailmorphstart=tailmorphend;
5309 else if(tailmorphness>targettailmorphness){
5310 tailmorphness-=multiplier*2;
5312 else if(tailmorphness<targettailmorphness){
5313 tailmorphness+=multiplier*2;
5317 if(headmorphend==3||headmorphstart==3){
5318 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
5319 headmorphness=targetheadmorphness;
5320 headmorphstart=headmorphend;
5322 else if(headmorphness>targetheadmorphness){
5323 headmorphness-=multiplier*7;
5325 else if(headmorphness<targetheadmorphness){
5326 headmorphness+=multiplier*7;
5329 else if(headmorphend==5||headmorphstart==5){
5330 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
5331 headmorphness=targetheadmorphness;
5332 headmorphstart=headmorphend;
5334 else if(headmorphness>targetheadmorphness){
5335 headmorphness-=multiplier*10;
5337 else if(headmorphness<targetheadmorphness){
5338 headmorphness+=multiplier*10;
5342 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5343 headmorphness=targetheadmorphness;
5344 headmorphstart=headmorphend;
5346 else if(headmorphness>targetheadmorphness){
5347 headmorphness-=multiplier*4;
5349 else if(headmorphness<targetheadmorphness){
5350 headmorphness+=multiplier*4;
5354 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5355 chestmorphness=targetchestmorphness;
5356 chestmorphstart=chestmorphend;
5358 else if(chestmorphness>targetchestmorphness){
5359 chestmorphness-=multiplier;
5361 else if(chestmorphness<targetchestmorphness){
5362 chestmorphness+=multiplier;
5365 if(dead!=2&&howactive<=typesleeping){
5366 if(chestmorphstart==0&&chestmorphend==0){
5368 targetchestmorphness=1;
5371 if(chestmorphstart!=0&&chestmorphend!=0){
5373 targetchestmorphness=1;
5375 if(environment==snowyenvironment){
5378 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5379 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5380 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5381 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5382 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5383 sprites.MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5387 if(!dead&&howactive<typesleeping){
5388 blinkdelay-=multiplier*2;
5389 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5391 targetheadmorphness=1;
5393 blinkdelay=(float)(abs(Random()%40))/5;
5395 if(headmorphstart==3&&headmorphend==3){
5397 targetheadmorphness=1;
5402 twitchdelay-=multiplier*1.5;
5403 if(targetanimation!=hurtidleanim){
5404 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5406 targetheadmorphness=1;
5408 twitchdelay=(float)(abs(Random()%40))/5;
5410 if(headmorphstart==5&&headmorphend==5){
5412 targetheadmorphness=1;
5416 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5417 twitchdelay3-=multiplier*1;
5419 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5420 righthandmorphness=0;
5421 targetrighthandmorphness=1;
5422 righthandmorphend=1;
5423 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5425 if(righthandmorphstart==1&&righthandmorphend==1){
5426 righthandmorphness=0;
5427 targetrighthandmorphness=1;
5428 righthandmorphend=0;
5432 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5433 lefthandmorphness=0;
5434 targetlefthandmorphness=1;
5436 twitchdelay3=(float)(abs(Random()%40))/5;
5438 if(lefthandmorphstart==1&&lefthandmorphend==1){
5439 lefthandmorphness=0;
5440 targetlefthandmorphness=1;
5447 if(creature==rabbittype){
5448 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5449 else twitchdelay2-=multiplier*0.5;
5450 if(howactive<=typesleeping){
5451 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5453 targettailmorphness=1;
5455 twitchdelay2=(float)(abs(Random()%40))/5;
5457 if(tailmorphstart==1&&tailmorphend==1){
5459 targettailmorphness=1;
5462 if(tailmorphstart==2&&tailmorphend==2){
5464 targettailmorphness=1;
5471 if(creature==wolftype){
5472 twitchdelay2-=multiplier*1.5;
5474 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5476 targettailmorphness=1;
5481 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5483 targettailmorphness=1;
5487 if(twitchdelay2<=0){
5488 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5490 targettailmorphness=1;
5493 if(tailmorphstart==1&&tailmorphend==1){
5495 targettailmorphness=1;
5498 if(tailmorphstart==2&&tailmorphend==2){
5500 targettailmorphness=1;
5503 if(tailmorphstart==3&&tailmorphend==3){
5505 targettailmorphness=1;
5508 if(tailmorphstart==4&&tailmorphend==4){
5510 targettailmorphness=1;
5516 if(dead!=1)unconscioustime=0;
5518 if(dead==1||howactive==typesleeping){
5519 unconscioustime+=multiplier;
5520 //If unconscious, close eyes and mouth
5521 if(righthandmorphend!=0)righthandmorphness=0;
5522 righthandmorphend=0;
5523 targetrighthandmorphness=1;
5525 if(lefthandmorphend!=0)lefthandmorphness=0;
5527 targetlefthandmorphness=1;
5529 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5531 targetheadmorphness=1;
5535 if(howactive>typesleeping){
5538 if(bloodtoggle&&!bled){
5539 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5541 if(bloodtoggle&&!bled)
5542 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5543 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5544 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5548 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5553 if(dead==2||howactive>typesleeping){
5554 //If dead, open mouth and hands
5555 if(righthandmorphend!=0)righthandmorphness=0;
5556 righthandmorphend=0;
5557 targetrighthandmorphness=1;
5559 if(lefthandmorphend!=0)lefthandmorphness=0;
5561 targetlefthandmorphness=1;
5563 if(headmorphend!=2)headmorphness=0;
5565 targetheadmorphness=1;
5568 if(stunned>0&&!dead&&headmorphend!=2){
5569 if(headmorphend!=4)headmorphness=0;
5571 targetheadmorphness=1;
5574 if(damage>damagetolerance&&!dead){
5579 if(creature==wolftype){
5587 if(weaponactive!=-1){
5588 weapons.owner[weaponids[0]]=-1;
5589 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5590 weapons.velocity[weaponids[0]].x+=.01;
5591 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5592 weapons.missed[weaponids[0]]=1;
5593 weapons.hitsomething[weaponids[0]]=0;
5594 weapons.freetime[weaponids[0]]=0;
5595 weapons.firstfree[weaponids[0]]=1;
5596 weapons.physics[weaponids[0]]=1;
5599 weaponids[0]=weaponids[num_weapons];
5600 if(weaponstuck==num_weapons)weaponstuck=0;
5603 for(i=0;i<numplayers;i++){
5604 player[i].wentforweapon=0;
5610 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5618 if(bloodloss<damagetolerance)
5619 for(i=0;i<skeleton.num_joints;i++){
5620 skeleton.joints[i].velocity*=1.5;
5624 //if(dead)damage-=multiplier/4;
5625 if(!dead)damage-=multiplier*13;
5626 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5627 if(!dead)permanentdamage-=multiplier*4;
5628 if(isIdle()||isCrouch()){
5629 if(!dead)permanentdamage-=multiplier*4;
5630 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5632 if(damage<0)damage=0;
5633 if(permanentdamage<0)permanentdamage=0;
5634 if(superpermanentdamage<0)superpermanentdamage=0;
5635 if(permanentdamage<superpermanentdamage){
5636 permanentdamage=superpermanentdamage;
5638 if(damage<permanentdamage){
5639 damage=permanentdamage;
5641 if(dead==1&&damage<damagetolerance){
5645 for(i=0;i<skeleton.num_joints;i++){
5646 skeleton.joints[i].velocity=0;
5649 if(permanentdamage>damagetolerance&&dead!=2){
5652 if(weaponactive!=-1){
5653 weapons.owner[weaponids[0]]=-1;
5654 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5655 weapons.velocity[weaponids[0]].x+=.01;
5656 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5657 weapons.missed[weaponids[0]]=1;
5658 weapons.hitsomething[weaponids[0]]=0;
5659 weapons.freetime[weaponids[0]]=0;
5660 weapons.firstfree[weaponids[0]]=1;
5661 weapons.physics[weaponids[0]]=1;
5664 weaponids[0]=weaponids[num_weapons];
5665 if(weaponstuck==num_weapons)weaponstuck=0;
5668 for(i=0;i<numplayers;i++){
5669 player[i].wentforweapon=0;
5675 if(!dead&&creature==wolftype){
5681 if(id!=0&&unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance){
5686 if(id!=0&&unconscioustime>.1){
5702 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5703 FSOUND_3D_SetAttributes(channels[breaksound], gLoc, vel);
5704 FSOUND_SetVolume(channels[breaksound], 512);
5705 FSOUND_SetPaused(channels[breaksound], false);
5706 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5712 if(skeleton.free==1){
5713 if(id==0)FSOUND_SetPaused(channels[whooshsound], true);
5716 //If knocked over, open hands and close mouth
5717 if(righthandmorphend!=0)righthandmorphness=0;
5718 righthandmorphend=0;
5719 targetrighthandmorphness=1;
5721 if(lefthandmorphend!=0)lefthandmorphness=0;
5723 targetlefthandmorphness=1;
5725 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5726 if(headmorphend!=0)headmorphness=0;
5728 targetheadmorphness=1;
5732 skeleton.DoGravity(&scale);
5734 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5735 if(id!=0&&damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1)){
5740 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5744 for(j=0;j<skeleton.num_joints;j++){
5745 average+=skeleton.joints[j].position;
5749 coords+=average*scale;
5750 for(j=0;j<skeleton.num_joints;j++){
5751 skeleton.joints[j].position-=average;
5753 average/=multiplier;
5755 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5757 for(i=0;i<skeleton.num_joints;i++){
5758 velocity+=skeleton.joints[i].velocity*scale;
5760 velocity/=skeleton.num_joints;
5762 if(!isnormal(velocity.x)&&velocity.x){
5775 if(findLength(&average)<10&&dead&&skeleton.free){
5776 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5777 if(skeleton.longdead>2000){
5778 if(skeleton.longdead>6000){
5779 if(id==0)FSOUND_SetPaused(channels[whooshsound], true);
5784 if(dead==2&&bloodloss<damagetolerance){
5786 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5788 if(bloodtoggle&&!bled){
5789 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5791 if(bloodtoggle&&!bled)
5792 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5793 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5794 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5798 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5802 if(dead==2&&bloodloss>=damagetolerance){
5804 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5805 if(bleeding<=0)DoBlood(1,255);
5806 if(bloodtoggle&&!bled){
5807 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5809 if(bloodtoggle&&!bled)
5810 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5811 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5812 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5816 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5823 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5825 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5829 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5830 if(velocity.y<-30)canrecover=0;
5831 for(i=0;i<objects.numobjects;i++){
5832 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5833 colviewer=startpoint;
5835 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5843 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5844 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5845 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5846 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5848 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5849 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5850 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5852 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5853 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5854 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5856 Normalise(&terrainnormal);
5858 targetrotation=-asin(0-terrainnormal.x);
5859 targetrotation*=360/6.28;
5860 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5861 rotation=targetrotation;
5863 //if(skeleton.forward.y<0){
5866 //if(skeleton.forward.y>-.3){
5869 targetanimation=flipanim;
5870 crouchtogglekeydown=1;
5875 currentanimation=tempanim;
5878 //tilt2=targettilt2;
5880 //if(middle.y>0)targetoffset.y=middle.y+1;
5882 for(i=0;i<skeleton.num_joints;i++){
5883 tempanimation.position[i][0]=skeleton.joints[i].position;
5884 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5889 if(findLength(&average)<10&&!dead&&skeleton.free){
5890 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5891 if(skeleton.longdead>(damage+500)*1.5){
5892 if(id==0)FSOUND_SetPaused(channels[whooshsound], true);
5898 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5899 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5900 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5901 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5903 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5904 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5905 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5907 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5908 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5909 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5911 Normalise(&terrainnormal);
5913 targetrotation=-asin(0-terrainnormal.x);
5914 targetrotation*=360/6.28;
5915 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5916 rotation=targetrotation;
5919 terrainnormal=terrain.getNormal(coords.x,coords.z);
5920 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5924 /*XYZ otherterrainnormal;
5925 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5926 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5927 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5928 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5931 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5935 if(skeleton.forward.y<0){
5936 targetanimation=getupfrombackanim;
5940 if(skeleton.forward.y>-.3){
5941 targetanimation=getupfromfrontanim;
5943 targetrotation+=180;
5949 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5950 targetanimation=rollanim;
5951 targetrotation=lookrotation;
5955 if(forwardkeydown)targetrotation+=45;
5956 if(backkeydown)targetrotation-=45;
5960 if(forwardkeydown)targetrotation-=45;
5961 if(backkeydown)targetrotation+=45;
5964 if ( !leftkeydown&&!rightkeydown)
5965 targetrotation+=180;
5967 targetrotation+=180;
5971 if(abs(targettilt2)>50)targettilt2=0;
5972 currentanimation=tempanim;
5977 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5979 for(i=0;i<skeleton.num_joints;i++){
5980 tempanimation.position[i][0]=skeleton.joints[i].position;
5981 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5988 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5989 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5992 tempvelocity=velocity;
5993 Normalise(&tempvelocity);
5994 targetrotation=-asin(0-tempvelocity.x);
5995 targetrotation*=360/6.28;
5996 if(velocity.z<0)targetrotation=180-targetrotation;
5997 //targetrotation+=180;
6000 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
6001 targetanimation=rollanim;
6005 targetanimation=backhandspringanim;
6006 targetrotation+=180;
6019 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6020 FSOUND_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6021 FSOUND_SetVolume(channels[movewhooshsound], 128);
6022 FSOUND_SetPaused(channels[movewhooshsound], false);
6024 currentanimation=targetanimation;
6025 currentframe=targetframe-1;
6030 rotation=targetrotation;
6037 if(skeleton.freefall==0)freefall=0;
6039 if(!isnormal(velocity.x)&&velocity.x){
6044 if(aitype!=passivetype||skeleton.free==1)
6045 if(findLengthfast(&velocity)>.1)
6046 for(i=0;i<objects.numobjects;i++){
6047 if(objects.type[i]==firetype)
6048 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){
6050 if(!objects.onfire[i]){
6053 gLoc[0]=objects.position[i].x;
6054 gLoc[1]=objects.position[i].y;
6055 gLoc[2]=objects.position[i].z;
6059 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
6060 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6061 FSOUND_SetVolume(channels[firestartsound], 256);
6062 FSOUND_SetPaused(channels[firestartsound], false);
6064 objects.onfire[i]=1;
6067 if(objects.onfire[i]){
6072 if(objects.type[i]==bushtype)
6073 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){
6075 if(!objects.onfire[i]){
6078 gLoc[0]=objects.position[i].x;
6079 gLoc[1]=objects.position[i].y;
6080 gLoc[2]=objects.position[i].z;
6084 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
6085 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6086 FSOUND_SetVolume(channels[firestartsound], 256);
6087 FSOUND_SetPaused(channels[firestartsound], false);
6089 objects.onfire[i]=1;
6093 if(objects.onfire[i]){
6097 if(objects.messedwith[i]<=0){
6109 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
6110 FSOUND_3D_SetAttributes(channels[bushrustle], gLoc, vel);
6111 FSOUND_SetVolume(channels[bushrustle], 40*findLength(&velocity));
6112 FSOUND_SetPaused(channels[bushrustle], false);
6115 envsound[numenvsounds]=coords;
6116 envsoundvol[numenvsounds]=4*findLength(&velocity);
6117 envsoundlife[numenvsounds]=.4;
6122 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6123 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6125 if(environment!=desertenvironment)
6126 for(j=0;j<howmany;j++){
6127 tempvel.x=float(abs(Random()%100)-50)/20;
6128 tempvel.y=float(abs(Random()%100)-50)/20;
6129 tempvel.z=float(abs(Random()%100)-50)/20;
6132 pos.x+=float(abs(Random()%100)-50)/200;
6133 pos.y+=float(abs(Random()%100)-50)/200;
6134 pos.z+=float(abs(Random()%100)-50)/200;
6135 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);
6136 sprites.special[sprites.numsprites-1]=1;
6138 howmany=findLength(&velocity)*4;
6140 if(environment==snowyenvironment)
6141 for(j=0;j<howmany;j++){
6142 tempvel.x=float(abs(Random()%100)-50)/20;
6143 tempvel.y=float(abs(Random()%100)-50)/20;
6144 tempvel.z=float(abs(Random()%100)-50)/20;
6147 pos.x+=float(abs(Random()%100)-50)/200;
6148 pos.y+=float(abs(Random()%100)-50)/200;
6149 pos.z+=float(abs(Random()%100)-50)/200;
6150 sprites.MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6151 sprites.special[sprites.numsprites-1]=2;
6154 objects.rotx[i]+=velocity.x*multiplier*6;
6155 objects.roty[i]+=velocity.z*multiplier*6;
6156 objects.messedwith[i]=.5;
6159 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
6160 if(objects.rotation2[i]==0)tempcoord=coords;
6162 tempcoord=coords-objects.position[i];
6163 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
6164 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
6165 tempcoord+=objects.position[i];
6167 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]){
6169 if(!objects.onfire[i]){
6172 gLoc[0]=objects.position[i].x;
6173 gLoc[1]=objects.position[i].y;
6174 gLoc[2]=objects.position[i].z;
6178 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
6179 FSOUND_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6180 FSOUND_SetVolume(channels[firestartsound], 256);
6181 FSOUND_SetPaused(channels[firestartsound], false);
6182 objects.onfire[i]=1;
6185 if(objects.messedwith[i]<=0){
6197 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
6198 FSOUND_3D_SetAttributes(channels[bushrustle], gLoc, vel);
6199 FSOUND_SetVolume(channels[bushrustle], 40*findLength(&velocity));
6200 FSOUND_SetPaused(channels[bushrustle], false);
6203 envsound[numenvsounds]=coords;
6204 envsoundvol[numenvsounds]=4*findLength(&velocity);
6205 envsoundlife[numenvsounds]=.4;
6210 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6211 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6213 if(environment!=desertenvironment)
6214 for(j=0;j<howmany;j++){
6215 tempvel.x=float(abs(Random()%100)-50)/20;
6216 tempvel.y=float(abs(Random()%100)-50)/20;
6217 tempvel.z=float(abs(Random()%100)-50)/20;
6221 pos.x+=float(abs(Random()%100)-50)/150;
6222 pos.y+=float(abs(Random()%100)-50)/150;
6223 pos.z+=float(abs(Random()%100)-50)/150;
6224 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);
6225 sprites.special[sprites.numsprites-1]=1;
6227 howmany=findLength(&velocity)*4;
6229 if(environment==snowyenvironment)
6230 for(j=0;j<howmany;j++){
6231 tempvel.x=float(abs(Random()%100)-50)/20;
6232 tempvel.y=float(abs(Random()%100)-50)/20;
6233 tempvel.z=float(abs(Random()%100)-50)/20;
6237 pos.x+=float(abs(Random()%100)-50)/150;
6238 pos.y+=float(abs(Random()%100)-50)/150;
6239 pos.z+=float(abs(Random()%100)-50)/150;
6240 sprites.MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6241 sprites.special[sprites.numsprites-1]=2;
6244 objects.messedwith[i]=.5;
6252 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
6254 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
6255 if(tutoriallevel==1&&id!=0)play=0;
6256 if(play&&aitype!=playercontrolled){
6268 if(creature==rabbittype){
6269 if(i==0)whichsound=rabbitchitter;
6270 if(i==1)whichsound=rabbitchitter2;
6272 if(creature==wolftype){
6273 if(i==0)whichsound=growlsound;
6274 if(i==1)whichsound=growl2sound;
6278 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
6279 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
6282 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
6283 FSOUND_3D_SetAttributes(channels[whichsound], gLoc, vel);
6284 FSOUND_SetVolume(channels[whichsound], 512);
6285 FSOUND_SetPaused(channels[whichsound], false);
6289 if(targetanimation==staggerbackhighanim)staggerdelay=1;
6290 if(targetanimation==staggerbackhardanim)staggerdelay=1;
6291 staggerdelay-=multiplier;
6292 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
6293 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
6294 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
6295 targetanimation=getIdle();
6299 weaponmissdelay-=multiplier;
6300 highreversaldelay-=multiplier;
6301 lowreversaldelay-=multiplier;
6302 lastcollide-=multiplier;
6303 skiddelay-=multiplier;
6304 if(!isnormal(velocity.x)&&velocity.x){
6307 if(!isnormal(targettilt)&&targettilt){
6310 if(!isnormal(targettilt2)&&targettilt2){
6313 if(!isnormal(targetrotation)&&targetrotation){
6317 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
6318 //open hands and close mouth
6319 //if(targetanimation!=wolfidle){
6320 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6321 righthandmorphness=0;
6322 righthandmorphend=0;
6323 targetrighthandmorphness=1;
6326 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6327 lefthandmorphness=0;
6329 targetlefthandmorphness=1;
6333 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
6336 targetheadmorphness=1;
6340 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){
6341 //open hands and mouth
6342 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6343 righthandmorphness=0;
6344 righthandmorphend=0;
6345 targetrighthandmorphness=1;
6348 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6349 lefthandmorphness=0;
6351 targetlefthandmorphness=1;
6354 if(headmorphend!=1&&headmorphness==targetheadmorphness){
6357 targetheadmorphness=1;
6361 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
6362 //close hands and mouth
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!=0&&headmorphness==targetheadmorphness){
6378 targetheadmorphness=1;
6382 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){
6383 //close hands and yell
6384 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6385 righthandmorphness=0;
6386 righthandmorphend=1;
6387 targetrighthandmorphness=1;
6390 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6391 lefthandmorphness=0;
6393 targetlefthandmorphness=1;
6396 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6399 targetheadmorphness=1;
6403 if(speechdelay>.25){
6404 if(headmorphend!=2)headmorphness=0;
6406 targetheadmorphness=1;
6412 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6413 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6417 if(!dead&&targetanimation!=hurtidleanim)
6418 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6419 if(headmorphend!=4||headmorphness==targetheadmorphness){
6422 targetheadmorphness=1;
6426 if(weaponactive!=-1){
6427 if(weapons.type[weaponids[weaponactive]]!=staff){
6428 righthandmorphstart=1;
6429 righthandmorphend=1;
6431 if(weapons.type[weaponids[weaponactive]]==staff){
6432 righthandmorphstart=2;
6433 righthandmorphend=2;
6435 targetrighthandmorphness=1;
6438 terrainnormal=terrain.getNormal(coords.x,coords.z);
6440 if(animation[targetanimation].attack!=reversal){
6441 if(!isnormal(coords.x))
6449 flatfacing=DoRotation(flatfacing,0,rotation,0);
6451 ReflectVector(&facing,&terrainnormal);
6454 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6455 if(onterrain)targettilt2=-facing.y*20;
6459 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6460 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6461 flatvelocity=velocity;
6463 flatvelspeed=findLength(&flatvelocity);
6464 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6465 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6466 if(velocity.y<0)targettilt2*=-1;
6467 if(velocity.y<0)targettilt*=-1;
6468 if(targettilt>25)targettilt=25;
6469 if(targettilt<-25)targettilt=-25;
6472 if(targettilt2>45)targettilt2=45;
6473 if(targettilt2<-45)targettilt2=-45;
6474 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6475 else if(tilt2>targettilt2){
6476 tilt2-=multiplier*400;
6478 else if(tilt2<targettilt2){
6479 tilt2+=multiplier*400;
6481 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6482 if(tilt2>25)tilt2=25;
6483 if(tilt2<-25)tilt2=-25;
6486 if(!isnormal(targettilt)&&targettilt){
6489 if(!isnormal(targettilt2)&&targettilt2){
6494 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6495 if(targetanimation==rabbittackleanim){
6496 velocity+=facing*multiplier*speed*700*scale;
6497 velspeed=findLength(&velocity);
6498 if(velspeed>speed*65*scale){
6500 velspeed=speed*65*scale;
6503 velocity.y+=gravity*multiplier*20;
6504 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6505 velspeed=findLength(&velocity);
6506 velocity=flatfacing*velspeed;
6508 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6509 if(isRun()||targetanimation==rabbitkickanim){
6510 velocity+=facing*multiplier*speed*700*scale;
6511 velspeed=findLength(&velocity);
6512 if(velspeed>speed*45*scale){
6514 velspeed=speed*45*scale;
6517 velocity.y+=gravity*multiplier*20;
6518 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6519 velspeed=findLength(&velocity);
6520 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6521 velocity=flatfacing*velspeed;
6525 velocity+=facing*multiplier*speed*700*scale;
6526 velspeed=findLength(&velocity);
6527 if(creature==rabbittype){
6528 if(velspeed>speed*55*scale){
6530 velspeed=speed*55*scale;
6534 if(creature==wolftype){
6535 if(velspeed>speed*75*scale){
6537 velspeed=speed*75*scale;
6541 velocity.y+=gravity*multiplier*20;
6542 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6543 velspeed=findLength(&velocity);
6544 velocity=flatfacing*velspeed;
6547 /*if(creature==wolftype)
6549 velocity+=facing*multiplier*speed*700*scale;
6550 velspeed=findLength(&velocity);
6551 if(velspeed>speed*55*scale){
6553 velspeed=speed*55*scale;
6556 velocity.y+=gravity*multiplier*20;
6557 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6558 velspeed=findLength(&velocity);
6559 velocity=flatfacing*velspeed;
6562 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6563 velocity+=facing*multiplier*speed*700*scale;
6564 velspeed=findLength(&velocity);
6565 if(velspeed>speed*45*scale){
6567 velspeed=speed*45*scale;
6570 velocity.y+=gravity*multiplier*20;
6571 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6572 velspeed=findLength(&velocity);
6573 velocity=flatfacing*velspeed;
6577 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6578 velocity+=facing*multiplier*speed*700*scale;
6579 velspeed=findLength(&velocity);
6580 if(velspeed>speed*25*scale){
6582 velspeed=speed*25*scale;
6585 velocity.y+=gravity*multiplier*20;
6586 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6587 velspeed=findLength(&velocity);
6588 velocity=flatfacing*velspeed;
6591 if(targetanimation==sneakanim||targetanimation==walkanim){
6592 velocity+=facing*multiplier*speed*700*scale;
6593 velspeed=findLength(&velocity);
6594 if(velspeed>speed*12*scale){
6596 velspeed=speed*12*scale;
6599 velocity.y+=gravity*multiplier*20;
6600 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6601 velspeed=findLength(&velocity);
6602 velocity=flatfacing*velspeed;
6605 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6606 velocity+=facing*multiplier*speed*700*scale;
6607 velspeed=findLength(&velocity);
6608 if(velspeed>speed*2*scale){
6610 velspeed=speed*2*scale;
6613 velocity.y+=gravity*multiplier*20;
6614 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6615 velspeed=findLength(&velocity);
6616 velocity=flatfacing*velspeed;
6620 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6621 velocity-=facing*multiplier*speed*700*scale;
6622 velspeed=findLength(&velocity);
6623 if(velspeed>speed*2*scale){
6625 velspeed=speed*2*scale;
6628 velocity.y+=gravity*multiplier*20;
6629 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6630 velspeed=findLength(&velocity);
6631 velocity=flatfacing*velspeed*-1;
6634 if(targetanimation==fightsidestep){
6635 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6636 velspeed=findLength(&velocity);
6637 if(velspeed>speed*12*scale){
6639 velspeed=speed*12*scale;
6642 velocity.y+=gravity*multiplier*20;
6643 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6644 velspeed=findLength(&velocity);
6645 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6648 if(targetanimation==staggerbackhighanim){
6649 coords-=facing*multiplier*speed*16*scale;
6652 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6653 coords-=facing*multiplier*speed*20*scale;
6657 if(targetanimation==backhandspringanim){
6658 //coords-=facing*multiplier*50*scale;
6659 velocity+=facing*multiplier*speed*700*scale*-1;
6660 velspeed=findLength(&velocity);
6661 if(velspeed>speed*50*scale){
6663 velspeed=speed*50*scale;
6666 velocity.y+=gravity*multiplier*20;
6667 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6668 velspeed=findLength(&velocity);
6669 velocity=flatfacing*velspeed*-1;
6671 if(targetanimation==dodgebackanim){
6672 //coords-=facing*multiplier*50*scale;
6673 velocity+=facing*multiplier*speed*700*scale*-1;
6674 velspeed=findLength(&velocity);
6675 if(velspeed>speed*60*scale){
6677 velspeed=speed*60*scale;
6680 velocity.y+=gravity*multiplier*20;
6681 ReflectVector(&velocity,&terrain.getNormal(coords.x,coords.z));
6682 velspeed=findLength(&velocity);
6683 velocity=flatfacing*velspeed*-1;
6686 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6687 velspeed=findLength(&velocity);
6691 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6692 velocity.y+=gravity*multiplier;
6695 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6697 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6698 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6700 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6706 FSOUND_SetPaused(channels[whooshsound], true);
6707 FSOUND_SetVolume(channels[whooshsound], 0);
6710 if(targetanimation==jumpdownanim||isFlip()){
6711 if(isFlip())jumppower=-4;
6712 targetanimation=getLanding();
6721 PlaySoundEx( landsound, samp[landsound], NULL, true);
6722 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
6723 FSOUND_SetVolume(channels[landsound], 128);
6724 FSOUND_SetPaused(channels[landsound], false);
6727 envsound[numenvsounds]=coords;
6728 envsoundvol[numenvsounds]=16;
6729 envsoundlife[numenvsounds]=.4;
6735 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6736 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6737 coords.y=terrain.getHeight(coords.x,coords.z);
6742 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)){
6743 velspeed=findLength(&velocity);
6745 if(velspeed<multiplier*300*scale){
6747 } else velocity-=velocity/velspeed*multiplier*300*scale;
6748 if(velspeed>5&&(isLanding()||isLandhard())){
6749 skiddingdelay+=multiplier;
6756 else skiddingdelay=0;
6760 velspeed=findLength(&velocity);
6762 if(velspeed<multiplier*600*scale){
6764 } else velocity-=velocity/velspeed*multiplier*600*scale;
6766 if(velspeed>5&&(isLanding()||isLandhard())){
6767 skiddingdelay+=multiplier;
6774 else skiddingdelay=0;
6777 if(skiddingdelay<0)skiddingdelay+=multiplier;
6778 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6788 if(!onterrain||environment==grassyenvironment){
6789 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6790 FSOUND_3D_SetAttributes(channels[skidsound], gLoc, vel);
6791 FSOUND_SetVolume(channels[skidsound], 128*velspeed/10);
6792 FSOUND_SetPaused(channels[skidsound], false);
6795 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6796 FSOUND_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6797 FSOUND_SetVolume(channels[snowskidsound], 128*velspeed/10);
6798 FSOUND_SetPaused(channels[snowskidsound], false);
6802 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6803 terrainnormal=victim->coords-coords;
6804 Normalise(&terrainnormal);
6805 targetrotation=-asin(0-terrainnormal.x);
6806 targetrotation*=360/6.28;
6807 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6808 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6811 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6812 targetrotation=victim->targetrotation;
6814 if(targetanimation==rabbittacklinganim){
6815 coords=victim->coords;
6818 skeleton.oldfree=skeleton.free;
6822 midterrain.x=terrain.size*terrain.scale/2;
6823 midterrain.z=terrain.size*terrain.scale/2;
6824 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6826 tempposit=coords-midterrain;
6828 Normalise(&tempposit);
6829 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6830 coords.x=tempposit.x+midterrain.x;
6831 coords.z=tempposit.z+midterrain.z;
6835 int Person::DrawSkeleton(){
6836 int oldplayerdetail;
6837 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6838 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6848 glAlphaFunc(GL_GREATER, 0.0001);
6850 float terrainheight;
6852 if(!isnormal(rotation))rotation=0;
6853 if(!isnormal(tilt))tilt=0;
6854 if(!isnormal(tilt2))tilt2=0;
6855 oldplayerdetail=playerdetail;
6857 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6860 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6863 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6866 if(id==0)playerdetail=1;
6867 if(playerdetail!=oldplayerdetail)updatedelay=0;
6868 if(playerdetail!=oldplayerdetail)normalsupdatedelay=0;
6869 static float updatedelaychange;
6870 static float morphness;
6871 static float framemult;
6873 skeleton.FindForwards();
6874 if(howactive==typesittingwall){
6875 skeleton.specialforward[1]=0;
6876 skeleton.specialforward[1].z=1;
6882 static int weaponattachmuscle;
6883 static int weaponrotatemuscle,weaponrotatemuscle2;
6884 static XYZ weaponpoint;
6885 static int start,endthing;
6886 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6887 if(!isSleeping()&&!isSitting()){
6888 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6889 XYZ point,newpoint,change,change2;
6890 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6891 heightleft=terrain.getHeight(point.x,point.z)+.04;
6893 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6894 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6895 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6896 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6897 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6899 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6900 heightright=terrain.getHeight(point.x,point.z)+.04;
6901 point.y=heightright;
6902 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6903 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6904 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6905 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6906 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6907 skeleton.DoConstraints(&coords,&scale);
6909 if(creature==wolftype){
6910 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6911 heightleft=terrain.getHeight(point.x,point.z)+.04;
6913 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6914 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6915 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6916 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6917 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6919 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6920 heightright=terrain.getHeight(point.x,point.z)+.04;
6921 point.y=heightright;
6922 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6923 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6924 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6925 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6926 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6927 skeleton.DoConstraints(&coords,&scale);
6930 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6931 XYZ point,newpoint,change,change2;
6932 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6933 heightleft=terrain.getHeight(point.x,point.z)+.04;
6935 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6936 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6937 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6938 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6939 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6941 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6942 heightright=terrain.getHeight(point.x,point.z)+.04;
6943 point.y=heightright;
6944 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6945 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6946 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6947 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6948 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6949 skeleton.DoConstraints(&coords,&scale);
6951 if(creature==wolftype){
6952 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6953 heightleft=terrain.getHeight(point.x,point.z)+.04;
6955 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6956 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6957 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6958 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6959 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6961 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6962 heightright=terrain.getHeight(point.x,point.z)+.04;
6963 point.y=heightright;
6964 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6965 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6966 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6967 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6968 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6969 skeleton.DoConstraints(&coords,&scale);
6973 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6974 XYZ point,newpoint,change,change2;
6975 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6976 heightleft=terrain.getHeight(point.x,point.z)+.04;
6978 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6979 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6980 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6981 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6982 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6984 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6985 heightright=terrain.getHeight(point.x,point.z)+.04;
6986 point.y=heightright;
6987 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6988 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6989 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6990 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6991 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6992 skeleton.DoConstraints(&coords,&scale);
6994 if(creature==wolftype){
6995 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6996 heightleft=terrain.getHeight(point.x,point.z)+.04;
6998 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6999 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
7000 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
7001 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
7002 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
7004 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
7005 heightright=terrain.getHeight(point.x,point.z)+.04;
7006 point.y=heightright;
7007 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
7008 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
7009 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
7010 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
7011 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
7012 skeleton.DoConstraints(&coords,&scale);
7016 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();
7018 targetheadrotation=-targetrotation;
7019 targetheadrotation2=0;
7020 if(animation[targetanimation].attack==3)targetheadrotation+=180;
7022 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7023 skeleton.drawmodel.vertex[i]=0;
7024 skeleton.drawmodel.vertex[i].y=999;
7026 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
7027 skeleton.drawmodellow.vertex[i]=0;
7028 skeleton.drawmodellow.vertex[i].y=999;
7030 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
7031 skeleton.drawmodelclothes.vertex[i]=0;
7032 skeleton.drawmodelclothes.vertex[i].y=999;
7034 for(i=0;i<skeleton.num_muscles;i++){
7035 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
7039 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
7040 morphness=righthandmorphness;
7041 start=righthandmorphstart;
7042 endthing=righthandmorphend;
7044 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
7045 morphness=lefthandmorphness;
7046 start=lefthandmorphstart;
7047 endthing=lefthandmorphend;
7049 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
7050 morphness=headmorphness;
7051 start=headmorphstart;
7052 endthing=headmorphend;
7054 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)){
7055 morphness=chestmorphness;
7056 start=chestmorphstart;
7057 endthing=chestmorphend;
7059 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)){
7060 morphness=tailmorphness;
7061 start=tailmorphstart;
7062 endthing=tailmorphend;
7064 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
7065 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
7066 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7069 if(!skeleton.free)glRotatef(tilt2,1,0,0);
7070 if(!skeleton.free)glRotatef(tilt,0,0,1);
7073 glTranslatef(mid.x,mid.y,mid.z);
7075 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
7076 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
7078 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
7079 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
7081 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
7082 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
7084 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
7088 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
7092 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
7096 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
7101 if(playerdetail||skeleton.free==3)
7103 for(j=0;j<skeleton.muscles[i].numvertices;j++)
7105 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
7106 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
7107 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
7108 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
7109 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
7110 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
7111 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
7112 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7114 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7115 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,
7116 (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,
7117 (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);
7118 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)
7119 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,
7120 (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,
7121 (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);
7122 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)
7123 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,
7124 (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,
7125 (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);
7126 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7127 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,
7128 (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,
7129 (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);
7130 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7131 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
7132 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
7133 //if(!isnormal(scale))test=1;
7134 //if(isnormal(scale)){
7135 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
7136 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
7137 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
7145 if(!playerdetail||skeleton.free==3)
7147 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
7149 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
7150 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7152 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7153 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
7154 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
7155 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
7156 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)
7157 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
7158 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
7159 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
7160 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)
7161 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
7162 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
7163 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
7164 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7165 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
7166 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
7167 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
7169 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7170 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
7171 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
7172 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
7179 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
7180 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
7182 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7185 if(!skeleton.free)glRotatef(tilt2,1,0,0);
7186 if(!skeleton.free)glRotatef(tilt,0,0,1);
7187 glTranslatef(mid.x,mid.y,mid.z);
7188 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
7189 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
7191 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
7192 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
7194 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
7195 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
7197 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
7198 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7200 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7201 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
7202 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
7203 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
7204 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)
7205 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
7206 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
7207 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
7208 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)
7209 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
7210 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
7211 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
7212 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7213 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
7214 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
7215 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
7216 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7217 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
7218 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
7219 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
7224 updatedelay=1+(float)(Random()%100)/1000;
7226 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
7227 normalsupdatedelay=1;
7228 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
7229 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
7230 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
7234 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
7235 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
7236 if(skeleton.clothes){
7237 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
7242 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
7243 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
7244 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
7245 if(skeleton.free==1)updatedelaychange*=6;
7246 if(id==0)updatedelaychange*=8;
7247 updatedelay+=updatedelaychange;
7249 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7251 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7252 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7253 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
7254 if(!skeleton.free)glRotatef(rotation,0,1,0);
7257 glColor4f(.4,1,.4,1);
7258 glDisable(GL_LIGHTING);
7259 glDisable(GL_TEXTURE_2D);
7262 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7263 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
7269 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
7270 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);
7271 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);
7272 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);
7273 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);
7274 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);
7275 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);
7281 terrainlight=terrain.getLighting(coords.x,coords.z);
7282 distance=findDistancefast(&viewer,&coords);
7283 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
7284 if(distance>1)distance=1;
7286 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
7287 if(terrainheight<1)terrainheight=1;
7288 if(terrainheight>1.7)terrainheight=1.7;
7291 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
7292 glDisable(GL_BLEND);
7293 glAlphaFunc(GL_GREATER, 0.0001);
7294 glEnable(GL_TEXTURE_2D);
7296 glDisable(GL_TEXTURE_2D);
7297 glColor4f(.7,.35,0,.5);
7299 glEnable(GL_LIGHTING);
7302 if(tutoriallevel&&id!=0){
7303 //glDisable(GL_TEXTURE_2D);
7304 glColor4f(.7,.7,.7,0.6);
7306 glEnable(GL_LIGHTING);
7308 if(canattack&&cananger)
7309 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7310 glDisable(GL_TEXTURE_2D);
7311 glColor4f(1,0,0,0.8);
7313 glMatrixMode(GL_TEXTURE);
7315 glTranslatef(0,-smoketex,0);
7316 glTranslatef(-smoketex,0,0);
7320 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(sprites.cloudimpacttexture);
7321 else skeleton.drawmodel.draw();
7325 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(sprites.cloudimpacttexture);
7326 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7329 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
7330 if(tutoriallevel&&id!=0){
7332 glMatrixMode(GL_MODELVIEW);
7333 glEnable(GL_TEXTURE_2D);
7334 glColor4f(.7,.7,.7,0.6);
7336 glEnable(GL_LIGHTING);
7338 if(canattack&&cananger)
7339 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7340 glDisable(GL_TEXTURE_2D);
7341 glColor4f(1,0,0,0.8);
7343 glMatrixMode(GL_TEXTURE);
7345 glTranslatef(0,-smoketex*.6,0);
7346 glTranslatef(smoketex*.6,0,0);
7349 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(sprites.cloudimpacttexture);
7350 else skeleton.drawmodel.draw();
7354 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(sprites.cloudimpacttexture);
7355 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7360 if(tutoriallevel&&id!=0){
7362 glMatrixMode(GL_MODELVIEW);
7363 glEnable(GL_TEXTURE_2D);
7365 if(skeleton.clothes){
7368 if(!immediate)skeleton.drawmodelclothes.draw();
7369 if(immediate)skeleton.drawmodelclothes.drawimmediate();
7376 for(k=0;k<num_weapons;k++){
7378 if(weaponactive==k){
7379 if(weapons.type[i]!=staff){
7380 for(j=0;j<skeleton.num_muscles;j++){
7381 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7382 weaponattachmuscle=j;
7385 for(j=0;j<skeleton.num_muscles;j++){
7386 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){
7387 weaponrotatemuscle=j;
7390 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7391 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7393 if(weapons.type[i]==staff){
7394 for(j=0;j<skeleton.num_muscles;j++){
7395 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7396 weaponattachmuscle=j;
7399 for(j=0;j<skeleton.num_muscles;j++){
7400 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){
7401 weaponrotatemuscle=j;
7404 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7405 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7406 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7407 XYZ tempnormthing,vec1,vec2;
7408 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7409 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7410 CrossProduct(&vec1,&vec2,&tempnormthing);
7411 Normalise(&tempnormthing);
7412 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);
7413 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7415 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7416 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7417 Normalise(&weaptargnorm);
7418 weaponpoint-=weaptargnorm*2;
7422 if(weaponactive!=k&&weaponstuck!=k){
7423 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;
7424 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;
7425 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;
7426 for(j=0;j<skeleton.num_muscles;j++){
7427 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){
7428 weaponrotatemuscle=j;
7433 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7434 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7435 for(j=0;j<skeleton.num_muscles;j++){
7436 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){
7437 weaponrotatemuscle=j;
7442 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;
7443 weapons.bigrotation[i]=rotation;
7444 weapons.bigtilt[i]=tilt;
7445 weapons.bigtilt2[i]=tilt2;
7448 weapons.position[i]=weaponpoint*scale+coords;
7449 weapons.bigrotation[i]=0;
7450 weapons.bigtilt[i]=0;
7451 weapons.bigtilt2[i]=0;
7453 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7454 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7455 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7456 if(weaponactive==k){
7457 if(weapons.type[i]==knife){
7458 weapons.smallrotation[i]=180;
7459 weapons.smallrotation2[i]=0;
7460 if(isCrouch()||wasCrouch()){
7461 weapons.smallrotation2[i]=20;
7463 if(targetanimation==hurtidleanim){
7464 weapons.smallrotation2[i]=50;
7466 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7467 XYZ temppoint1,temppoint2,tempforward;
7470 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7471 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7472 distance=findDistance(&temppoint1,&temppoint2);
7473 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7474 weapons.rotation2[i]*=360/6.28;
7477 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7478 weapons.rotation1[i]*=360/6.28;
7479 weapons.rotation3[i]=0;
7480 weapons.smallrotation[i]=-90;
7481 weapons.smallrotation2[i]=0;
7482 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7484 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7485 XYZ temppoint1,temppoint2,tempforward;
7488 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7489 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7490 distance=findDistance(&temppoint1,&temppoint2);
7491 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7492 weapons.rotation2[i]*=360/6.28;
7495 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7496 weapons.rotation1[i]*=360/6.28;
7497 weapons.rotation3[i]=0;
7498 weapons.smallrotation[i]=90;
7499 weapons.smallrotation2[i]=0;
7500 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7502 if(targetanimation==knifethrowanim){
7503 weapons.smallrotation[i]=90;
7504 //weapons.smallrotation2[i]=-90;
7505 weapons.smallrotation2[i]=0;
7506 weapons.rotation1[i]=0;
7507 weapons.rotation2[i]=0;
7508 weapons.rotation3[i]=0;
7510 if(targetanimation==knifesneakattackanim&&targetframe<5){
7511 weapons.smallrotation[i]=-90;
7512 weapons.rotation1[i]=0;
7513 weapons.rotation2[i]=0;
7514 weapons.rotation3[i]=0;
7517 if(weapons.type[i]==sword){
7518 weapons.smallrotation[i]=0;
7519 weapons.smallrotation2[i]=0;
7520 if(targetanimation==knifethrowanim){
7521 weapons.smallrotation[i]=-90;
7522 weapons.smallrotation2[i]=0;
7523 weapons.rotation1[i]=0;
7524 weapons.rotation2[i]=0;
7525 weapons.rotation3[i]=0;
7527 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)){
7528 XYZ temppoint1,temppoint2,tempforward;
7531 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7532 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7533 distance=findDistance(&temppoint1,&temppoint2);
7534 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7535 weapons.rotation2[i]*=360/6.28;
7538 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7539 weapons.rotation1[i]*=360/6.28;
7540 weapons.rotation3[i]=0;
7541 weapons.smallrotation[i]=90;
7542 weapons.smallrotation2[i]=0;
7543 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7546 if(weapons.type[i]==staff){
7547 weapons.smallrotation[i]=100;
7548 weapons.smallrotation2[i]=0;
7549 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7550 XYZ temppoint1,temppoint2,tempforward;
7553 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7554 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7555 distance=findDistance(&temppoint1,&temppoint2);
7556 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7557 weapons.rotation2[i]*=360/6.28;
7560 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7561 weapons.rotation1[i]*=360/6.28;
7562 weapons.rotation3[i]=0;
7563 weapons.smallrotation[i]=90;
7564 weapons.smallrotation2[i]=0;
7565 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7569 if(weaponactive!=k&&weaponstuck!=k){
7570 if(weapons.type[i]==knife){
7571 weapons.smallrotation[i]=-70;
7572 weapons.smallrotation2[i]=10;
7574 if(weapons.type[i]==sword){
7575 weapons.smallrotation[i]=-100;
7576 weapons.smallrotation2[i]=-8;
7578 if(weapons.type[i]==staff){
7579 weapons.smallrotation[i]=-100;
7580 weapons.smallrotation2[i]=-8;
7584 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7585 else weapons.smallrotation[i]=0;
7586 weapons.smallrotation2[i]=10;
7587 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7595 if(skeleton.free)calcrot=1;
7596 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7597 if(currentanimation!=targetanimation)calcrot=1;
7598 //if(id==0)calcrot=1;
7599 if(skeleton.free==2)calcrot=0;
7605 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7608 static float distance;
7609 static float olddistance;
7610 static int intersecting;
7611 static int firstintersecting;
7614 static XYZ start,end;
7615 static float slopethreshold=-.4;
7617 firstintersecting=-1;
7621 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7622 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7624 for (j=0;j<model->TriangleNum;j++){
7625 if(model->facenormals[j].y<=slopethreshold){
7627 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)));
7628 if(distance<radius){
7629 point=*p1-model->facenormals[j]*distance;
7630 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;
7631 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7632 &model->vertex[model->Triangles[j].vertex[1]],
7634 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7635 &model->vertex[model->Triangles[j].vertex[2]],
7637 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7638 &model->vertex[model->Triangles[j].vertex[2]],
7641 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7645 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)){
7646 p1->y=point.y+radius;
7647 if((targetanimation==jumpdownanim||isFlip())){
7648 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7650 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7656 FSOUND_SetPaused(channels[whooshsound], true);
7657 FSOUND_SetVolume(channels[whooshsound], 0);
7660 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7661 if(isFlip())jumppower=-4;
7662 targetanimation=getLanding();
7671 PlaySoundEx( landsound, samp[landsound], NULL, true);
7672 FSOUND_3D_SetAttributes(channels[landsound], gLoc, vel);
7673 FSOUND_SetVolume(channels[landsound], 128);
7674 FSOUND_SetPaused(channels[landsound], false);
7677 envsound[numenvsounds]=coords;
7678 envsoundvol[numenvsounds]=16;
7679 envsoundlife[numenvsounds]=.4;
7687 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7690 for (j=0;j<model->TriangleNum;j++){
7691 if(model->facenormals[j].y>slopethreshold){
7695 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)));
7696 if(distance<radius*.5){
7697 point=start-model->facenormals[j]*distance;
7698 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;
7699 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,
7700 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7701 p1->x, p1->y, p1->z, radius/2);
7702 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,
7703 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7704 p1->x, p1->y, p1->z, radius/2);
7705 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,
7706 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7707 p1->x, p1->y, p1->z, radius/2);
7709 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7710 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7712 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7713 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7715 *p1+=model->facenormals[j]*(distance-radius*.5);
7718 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7722 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7724 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7726 return firstintersecting;
7736 currentanimation = 0;
7737 targetanimation = 0;
7738 oldcurrentframe = 0;
7740 oldcurrentanimation = 0;
7741 oldtargetanimation = 0;
7745 parriedrecently = 0;
7749 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7751 currentoffset = 0,targetoffset = 0,offset = 0;
7769 unconscioustime = 0;
7787 rabbitkickenabled = 0;
7796 damagetolerance = 0;
7798 permanentdamage = 0;
7799 superpermanentdamage = 0; lastcollide = 0;
7819 headrotation = 0,headrotation2 = 0;
7820 targetheadrotation = 0,targetheadrotation2 = 0;
7831 normalsupdatedelay = 0;
7836 forwardstogglekeydown = 0;
7841 jumptogglekeydown = 0;
7843 crouchtogglekeydown = 0;
7845 drawtogglekeydown = 0;
7847 throwtogglekeydown = 0;
7853 crouchkeydowntime = 0;
7854 jumpkeydowntime = 0;
7871 whichdirectiondelay = 0;
7872 avoidsomething = 0; avoidwhere = 0;
7880 lefthandmorphness = 0;
7881 righthandmorphness = 0;
7885 targetlefthandmorphness = 0;
7886 targetrighthandmorphness = 0;
7887 targetheadmorphness = 0;
7888 targetchestmorphness = 0;
7889 targettailmorphness = 0;
7890 lefthandmorphstart = 0,lefthandmorphend = 0;
7891 righthandmorphstart = 0,righthandmorphend = 0;
7892 headmorphstart = 0,headmorphend = 0;
7893 chestmorphstart = 0,chestmorphend = 0;
7894 tailmorphstart = 0,tailmorphend = 0;
7896 weaponmissdelay = 0;
7897 highreversaldelay = 0;
7898 lowreversaldelay = 0;
7905 //Skeleton skeleton;
7924 memset(clothes, 0, sizeof(clothes));
7925 memset(clothestintr, 0, sizeof(clothestintr));
7926 memset(clothestintg, 0, sizeof(clothestintg));
7927 memset(clothestintb, 0, sizeof(clothestintb));
7933 onfiredelay = 0; burnt = 0;
7937 updatestuffdelay = 0;
7943 memset(weaponids, 0, sizeof(weaponids));
7947 weaponstuckwhere = 0;
7952 memset(waypoints, 0, sizeof(waypoints));
7953 memset(waypointtype, 0, sizeof(waypointtype));
7956 hastempwaypoint = 0;
7962 finalfinaltarget = 0;
7964 finalpathfindpoint = 0;
7965 targetpathfindpoint = 0;
7966 lastpathfindpoint = 0;
7967 lastpathfindpoint2 = 0;
7968 lastpathfindpoint3 = 0;
7969 lastpathfindpoint4 = 0;
7980 runninghowlong = 0; lastoccluded = 0;
7986 neckspurtparticledelay = 0;
7987 neckspurtamount = 0;
7990 rabbitkickragdoll = 0;
7995 //Animation tempanimation;