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 <**/
24 #include "openal_wrapper.h"
26 extern float multiplier;
27 extern Animation animation[animation_count];
28 extern OPENAL_SAMPLE *samp[100];
29 extern int channels[100];
30 extern Terrain terrain;
32 extern int environment;
33 extern Sprites sprites;
35 extern FRUSTUM frustum;
37 extern float realmultiplier;
39 extern float slomodelay;
40 extern bool cellophane;
41 extern float texdetail;
42 extern float realtexdetail;
43 extern GLubyte bloodText[512*512*3];
44 extern GLubyte wolfbloodText[512*512*3];
45 extern int bloodtoggle;
46 extern Objects objects;
48 extern bool autoslomo;
49 extern float camerashake;
51 extern float terraindetail;
52 extern float viewdistance;
53 extern float blackout;
54 extern int difficulty;
55 extern Weapons weapons;
57 extern float fadestart;
58 extern Person player[maxplayers];
59 extern int numplayers;
61 extern bool winfreeze;
62 extern float flashamount,flashr,flashg,flashb;
63 extern int flashdelay;
64 extern bool showpoints;
65 extern bool immediate;
67 extern bool tilt2weird;
68 extern bool tiltweird;
70 extern bool proportionweird;
71 extern bool vertexweird[6];
72 extern GLubyte texturearray[512*512*3];
73 extern XYZ envsound[30];
74 extern float envsoundvol[30];
75 extern float envsoundlife[30];
76 extern int numenvsounds;
78 extern float bonusvalue;
79 extern float bonustotal;
80 extern float bonustime;
81 extern int tutoriallevel;
82 extern float smoketex;
83 extern int tutorialstage;
84 extern bool reversaltrain;
85 extern bool canattack;
87 extern float damagedealt;
88 extern float damagetaken;
90 extern float hostiletime;
95 extern int numflipfail;
97 extern int numswordattack;
98 extern int numknifeattack;
99 extern int numunarmedattack;
100 extern int numescaped;
101 extern int numflipped;
102 extern int numwallflipped;
103 extern int numthrowkill;
104 extern int numafterkill;
105 extern int numreversals;
106 extern int numattacks;
107 extern int maxalarmed;
108 extern int indialogue;
110 extern bool gamestarted;
112 extern OPENAL_STREAM * strm[20];
113 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
114 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
116 void Person::CheckKick(){
120 float damagemult=1*power;
121 if(creature==wolftype)damagemult=2.5*power;
125 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
126 if(findDistancefast(&coords,&victim->coords)<1.2){
127 if(!victim->skeleton.free){
129 Normalise(&relative);
130 relative=coords+relative*1;
131 if(animation[victim->targetanimation].height!=lowheight){
136 gLoc[0]=victim->coords.x;
137 gLoc[1]=victim->coords.y;
138 gLoc[2]=victim->coords.z;
142 if(tutoriallevel!=1){
143 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
144 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
145 OPENAL_SetVolume(channels[heavyimpactsound], 128);
146 OPENAL_SetPaused(channels[heavyimpactsound], false);
151 Normalise(&relative);
152 for(i=0;i<victim->skeleton.num_joints;i++){
153 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
156 victim->DoDamage(100*damagemult/victim->protectionhigh);
157 if(id==0)camerashake+=.4;
161 targetanimation=backflipanim;
166 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
168 //if(victim->damage>victim->damagetolerance){
176 else if (victim->isCrouch()){
177 targetanimation=rabbitkickreversedanim;
178 currentanimation=rabbitkickreversedanim;
179 victim->currentanimation=rabbitkickreversalanim;
180 victim->targetanimation=rabbitkickreversalanim;
186 victim->oldcoords=victim->coords;
187 coords=victim->coords;
188 victim->targetrotation=targetrotation;
196 void Person::CatchFire(){
197 XYZ flatfacing,flatvelocity;
199 for(int i=0;i<10;i++){
200 howmany=abs(Random()%(skeleton.num_joints));
201 if(!skeleton.free)flatvelocity=velocity;
202 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
203 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
204 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
205 sprites.MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
218 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
219 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
220 OPENAL_SetVolume(channels[firestartsound], 256);
221 OPENAL_SetPaused(channels[firestartsound], false);
226 //PlaySoundEx( firesound, samp[firesound], NULL, true);
227 PlayStreamEx( stream_firesound, strm[stream_firesound], NULL, true);
228 OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
229 OPENAL_SetVolume(channels[stream_firesound], 256);
230 OPENAL_SetPaused(channels[stream_firesound], false);
237 bool Person::isIdle(){
238 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;
242 bool Person::isSitting(){
243 if(targetanimation==sitanim)return 1;
244 if(targetanimation==sitwallanim)return 1;
248 bool Person::isSleeping(){
249 if(targetanimation==sleepanim)return 1;
250 if(targetanimation==dead1anim)return 1;
251 if(targetanimation==dead2anim)return 1;
252 if(targetanimation==dead3anim)return 1;
253 if(targetanimation==dead4anim)return 1;
257 bool Person::wasIdle(){
258 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;
261 int Person::getIdle(){
262 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
263 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)){
264 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
265 if(creature==rabbittype)return fightidleanim;
266 if(creature==wolftype)return wolfidle;
268 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
269 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
270 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
271 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
272 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
274 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
276 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
277 if(howactive==typesitting)return sitanim;
278 if(howactive==typesittingwall)return sitwallanim;
279 if(howactive==typesleeping)return sleepanim;
280 if(howactive==typedead1)return dead1anim;
281 if(howactive==typedead2)return dead2anim;
282 if(howactive==typedead3)return dead3anim;
283 if(howactive==typedead4)return dead4anim;
284 if(creature==rabbittype)return bounceidleanim;
285 if(creature==wolftype)return wolfidle;
289 bool Person::isCrouch(){
290 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
295 bool Person::wasCrouch(){
296 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
299 int Person::getCrouch(){
300 if(creature==rabbittype)return crouchanim;
301 if(creature==wolftype)return wolfcrouchanim;
305 bool Person::isRun(){
306 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
311 bool Person::wasRun(){
312 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
315 int Person::getRun(){
316 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
317 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
319 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
320 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
324 bool Person::isStop(){
325 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
330 bool Person::wasStop(){
331 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
334 int Person::getStop(){
335 if(creature==rabbittype)return stopanim;
336 if(creature==wolftype)return wolfstopanim;
341 bool Person::isLanding(){
342 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
347 bool Person::wasLanding(){
348 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
351 int Person::getLanding(){
352 if(creature==rabbittype)return landanim;
353 if(creature==wolftype)return wolflandanim;
358 bool Person::isLandhard(){
359 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
364 bool Person::wasLandhard(){
365 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
368 int Person::getLandhard(){
369 if(creature==rabbittype)return landhardanim;
370 if(creature==wolftype)return wolflandhardanim;
375 bool Person::isFlip(){
376 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
380 bool Person::wasFlip(){
381 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
385 bool Person::isWallJump(){
386 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
390 void SolidHitBonus();
391 void SolidHitBonus(){
392 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
397 else if(bonustime<1.5&&bonus==threexcombo){
402 else if(bonustime<1.5&&bonus==twoxcombo){
407 else if(bonustime<1.5&&bonus==solidhit){
419 void Person::DoBlood(float howmuch,int which){
420 static int bleedxint,bleedyint;
422 //if(howmuch&&id==0)blooddimamount=1;
423 if(bloodtoggle&&tutoriallevel!=1){
424 if(bleeding<=0&&spurt){
426 for(int i=0;i<3;i++){
430 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
433 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
435 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
436 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
438 sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
439 sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
442 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);
443 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);
447 for(int i=0;i<3;i++){
452 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
455 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
457 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
458 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
461 sprites.MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
462 sprites.special[sprites.numsprites-1]=3;
465 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);
466 sprites.special[sprites.numsprites-1]=3;
472 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
475 int texdetailint=realtexdetail;
476 if(creature==rabbittype)
477 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){
478 bleedxint=abs(Random()%512);
479 bleedyint=abs(Random()%512);
481 if(creature==wolftype)
482 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){
483 bleedxint=abs(Random()%512);
484 bleedyint=abs(Random()%512);
488 bleedy/=realtexdetail;
489 bleedx/=realtexdetail;
490 direction=abs(Random()%2)*2-1;
494 if(bleeding>2)bleeding=2;
497 void Person::DoBloodBig(float howmuch,int which){
498 static int bleedxint,bleedyint,i,j;
500 if(howmuch&&id==0)blooddimamount=1;
502 if(tutoriallevel!=1||id==0)
503 if(aitype!=playercontrolled&&howmuch>0){
514 if(creature==wolftype){
515 int i=abs(Random()%2);
516 if(i==0)whichsound=snarlsound;
517 if(i==1)whichsound=snarl2sound;
518 envsound[numenvsounds]=coords;
519 envsoundvol[numenvsounds]=16;
520 envsoundlife[numenvsounds]=.4;
523 if(creature==rabbittype){
524 int i=abs(Random()%2);
525 if(i==0)whichsound=rabbitpainsound;
526 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
527 envsound[numenvsounds]=coords;
528 envsoundvol[numenvsounds]=16;
529 envsoundlife[numenvsounds]=.4;
531 //if(i==2)whichsound=rabbitpain2sound;
535 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
536 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
537 OPENAL_SetVolume(channels[whichsound], 512);
538 OPENAL_SetPaused(channels[whichsound], false);
542 if(id==0&&howmuch>0){
550 if(bloodtoggle&&decals&&tutoriallevel!=1){
551 if(bleeding<=0&&spurt){
553 for(int i=0;i<3;i++){
557 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
560 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
562 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
563 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
565 sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
566 sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
569 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);
570 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);
574 int offsetx=0,offsety=0;
577 offsetx=abs(Random()%60);
579 if(which==190||which==185){
581 offsetx=abs(Random()%100)-20;
591 if(which==220||which==215){
592 //offsety=Random()%20;
594 //offsetx=abs(Random()%80);
603 if(creature==rabbittype)
606 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
607 if(i<startx)startx=i;
608 if(j<starty)starty=j;
614 if(creature==wolftype)
617 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
618 if(i<startx)startx=i;
619 if(j<starty)starty=j;
631 if(startx<0)startx=0;
632 if(starty<0)starty=0;
633 if(endx>512-1)endx=512-1;
634 if(endy>512-1)endy=512-1;
635 if(endx<startx)endx=startx;
636 if(endy<starty)endy=starty;
638 startx/=realtexdetail;
639 starty/=realtexdetail;
643 int texdetailint=realtexdetail;
645 if(creature==rabbittype)
646 for(i=startx;i<endx;i++){
647 for(j=starty;j<endy;j++){
648 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){
649 color=Random()%85+170;
650 where=i*skeleton.skinsize*3+j*3;
651 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
652 skeleton.skinText[where+1]=0;
653 skeleton.skinText[where+2]=0;
657 if(creature==wolftype)
658 for(i=startx;i<endx;i++){
659 for(j=starty;j<endy;j++){
660 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){
661 color=Random()%85+170;
662 where=i*skeleton.skinsize*3+j*3;
663 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
664 skeleton.skinText[where+1]=0;
665 skeleton.skinText[where+2]=0;
669 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
670 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
671 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
675 if(creature==rabbittype)
676 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){
677 bleedxint=abs(Random()%512);
678 bleedyint=abs(Random()%512);
680 if(creature==wolftype)
681 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){
682 bleedxint=abs(Random()%512);
683 bleedyint=abs(Random()%512);
685 bleedy=bleedxint+offsetx;
686 bleedx=bleedyint+offsety;
687 bleedy/=realtexdetail;
688 bleedx/=realtexdetail;
689 if(bleedx<0)bleedx=0;
690 if(bleedy<0)bleedy=0;
691 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
692 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
693 direction=abs(Random()%2)*2-1;
696 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
697 deathbleeding+=bleeding;
698 bloodloss+=bleeding*3;
700 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
701 if(abs(Random()%2)==0){aitype=gethelptype;
704 else aitype=attacktypecutoff;
707 if(bleeding>2)bleeding=2;
710 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
711 static int bleedxint,bleedyint,i,j;
713 static XYZ startpoint,endpoint,colpoint,movepoint;
714 static float rotationpoint;
716 static XYZ p1,p2,p3,p0;
720 float coordsx,coordsy;
723 if(bloodtoggle&&decals&&tutoriallevel!=1){
725 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
733 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
736 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
737 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
738 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
740 CrossProduct(p2-p1,p3-p1,&N);
741 CrossProduct(p0-p1,p3-p1,&temp);
742 s = dotproduct(&temp,&N)/findLength(&N);
743 CrossProduct(p2-p1,p1-p0,&temp);
744 t = dotproduct(&temp,&N)/findLength(&N);
747 bary.x=findDistancefast(&p0,&p1);
748 bary.y=findDistancefast(&p0,&p2);
749 bary.z=findDistancefast(&p0,&p3);
751 total=bary.x+bary.y+bary.z;
760 total=bary.x+bary.y+bary.z;
766 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
767 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
768 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
769 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
770 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
771 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
772 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;
773 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;
775 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
776 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
778 if(bleeding<=0&&spurt){
780 for(int i=0;i<3;i++){
784 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
787 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
789 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
790 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
792 sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
793 sprites.MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
796 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);
797 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);
801 int offsetx=0,offsety=0;
804 offsetx=abs(Random()%120);
806 if(which==220||which==215){
808 offsetx=abs(Random()%80);
811 offsetx=(1+coordsy)*512-291;
812 offsety=coordsx*512-437;
819 if(creature==rabbittype)
822 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
823 if(i<startx)startx=i;
824 if(j<starty)starty=j;
830 if(creature==wolftype)
833 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
834 if(i<startx)startx=i;
835 if(j<starty)starty=j;
846 if(startx<0)startx=0;
847 if(starty<0)starty=0;
848 if(endx>512-1)endx=512-1;
849 if(endy>512-1)endy=512-1;
850 if(endx<startx)endx=startx;
851 if(endy<starty)endy=starty;
853 startx/=realtexdetail;
854 starty/=realtexdetail;
858 int texdetailint=realtexdetail;
860 if(creature==rabbittype)
861 for(i=startx;i<endx;i++){
862 for(j=starty;j<endy;j++){
863 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){
864 color=Random()%85+170;
865 where=i*skeleton.skinsize*3+j*3;
866 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
867 skeleton.skinText[where+1]=0;
868 skeleton.skinText[where+2]=0;
870 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){
871 color=Random()%85+170;
872 where=i*skeleton.skinsize*3+j*3;
873 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
874 skeleton.skinText[where+1]=0;
875 skeleton.skinText[where+2]=0;
879 if(creature==wolftype)
880 for(i=startx;i<endx;i++){
881 for(j=starty;j<endy;j++){
882 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){
883 color=Random()%85+170;
884 where=i*skeleton.skinsize*3+j*3;
885 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
886 skeleton.skinText[where+1]=0;
887 skeleton.skinText[where+2]=0;
889 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){
890 color=Random()%85+170;
891 where=i*skeleton.skinsize*3+j*3;
892 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
893 skeleton.skinText[where+1]=0;
894 skeleton.skinText[where+2]=0;
898 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
899 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
900 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
902 bleedy=(1+coordsy)*512;
904 bleedy/=realtexdetail;
905 bleedx/=realtexdetail;
906 if(bleedx<0)bleedx=0;
907 if(bleedy<0)bleedy=0;
908 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
909 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
910 direction=abs(Random()%2)*2-1;
912 if(whichtri==-1)return 0;
914 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
915 deathbleeding+=bleeding;
916 bloodloss+=bleeding*3;
918 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
919 if(abs(Random()%2)==0){aitype=gethelptype;
922 else aitype=attacktypecutoff;
925 if(bleeding>2)bleeding=2;
930 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
933 static int bytesPerPixel=3;
934 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
935 static int newstartx,newstarty,newendx,newendy;
936 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
938 static float sizemult;
940 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
941 texture[i]=skeleton.skinText[i];
944 if((!osx||howmanylevels)){
946 if(startx<0)startx=0;
947 if(starty<0)starty=0;
948 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
949 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
950 if((endx>startx&&endy>starty)||howmanylevels){
957 for(i=startx;i<endx;i++){
958 for(j=starty;j<endy;j++){
959 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
960 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
961 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
965 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
968 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
969 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
970 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
973 newsize=skeleton.skinsize;
976 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
978 /*for(j=1;j<=howmanylevels;j++){
979 if(j==1)texpointer=&skeleton.skinText[0];
980 else texpointer=&texture[0];
982 totalsize=int( newsize*newsize*bytesPerPixel);
983 rowsize=int( newsize*bytesPerPixel );
984 bigstep=bytesPerPixel*newsize*2;
985 smallstep=bytesPerPixel*2;
991 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
998 void Person::Reverse(){
999 if(victim->aitype==playercontrolled||hostiletime>1)
1000 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
1001 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
1002 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
1003 if(targetanimation==sweepanim){
1004 targetanimation=sweepreversedanim;
1005 currentanimation=sweepreversedanim;
1006 victim->currentanimation=sweepreversalanim;
1007 victim->targetanimation=sweepreversalanim;
1009 if(targetanimation==spinkickanim){
1010 targetanimation=spinkickreversedanim;
1011 currentanimation=spinkickreversedanim;
1012 victim->currentanimation=spinkickreversalanim;
1013 victim->targetanimation=spinkickreversalanim;
1015 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
1016 if(targetanimation==rabbittacklinganim){
1019 victim->currentframe=6;
1020 victim->targetframe=7;
1022 targetanimation=upunchreversedanim;
1023 currentanimation=upunchreversedanim;
1024 victim->currentanimation=upunchreversalanim;
1025 victim->targetanimation=upunchreversalanim;
1027 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1028 if(victim->weaponactive!=-1){
1029 victim->throwtogglekeydown=1;
1030 weapons.owner[victim->weaponids[0]]=-1;
1031 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1032 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1033 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1034 weapons.missed[victim->weaponids[0]]=1;
1035 weapons.freetime[victim->weaponids[0]]=0;
1036 weapons.firstfree[victim->weaponids[0]]=1;
1037 weapons.physics[victim->weaponids[0]]=1;
1038 victim->num_weapons--;
1039 if(victim->num_weapons){
1040 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1041 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1044 victim->weaponactive=-1;
1045 for(int j=0;j<numplayers;j++){
1046 player[j].wentforweapon=0;
1050 targetanimation=staffhitreversedanim;
1051 currentanimation=staffhitreversedanim;
1052 victim->currentanimation=staffhitreversalanim;
1053 victim->targetanimation=staffhitreversalanim;
1055 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1056 if(victim->weaponactive!=-1){
1057 victim->throwtogglekeydown=1;
1058 weapons.owner[victim->weaponids[0]]=-1;
1059 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1060 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1061 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1062 weapons.missed[victim->weaponids[0]]=1;
1063 weapons.freetime[victim->weaponids[0]]=0;
1064 weapons.firstfree[victim->weaponids[0]]=1;
1065 weapons.physics[victim->weaponids[0]]=1;
1066 victim->num_weapons--;
1067 if(victim->num_weapons){
1068 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1069 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1072 victim->weaponactive=-1;
1073 for(int j=0;j<numplayers;j++){
1074 player[j].wentforweapon=0;
1077 targetanimation=staffspinhitreversedanim;
1078 currentanimation=staffspinhitreversedanim;
1079 victim->currentanimation=staffspinhitreversalanim;
1080 victim->targetanimation=staffspinhitreversalanim;
1082 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1083 if(victim->weaponactive!=-1){
1084 victim->throwtogglekeydown=1;
1085 weapons.owner[victim->weaponids[0]]=-1;
1086 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1087 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1088 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1089 weapons.missed[victim->weaponids[0]]=1;
1090 weapons.freetime[victim->weaponids[0]]=0;
1091 weapons.firstfree[victim->weaponids[0]]=1;
1092 weapons.physics[victim->weaponids[0]]=1;
1093 victim->num_weapons--;
1094 if(victim->num_weapons){
1095 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1096 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1099 victim->weaponactive=-1;
1100 for(int j=0;j<numplayers;j++){
1101 player[j].wentforweapon=0;
1104 targetanimation=swordslashreversedanim;
1105 currentanimation=swordslashreversedanim;
1106 victim->currentanimation=swordslashreversalanim;
1107 victim->targetanimation=swordslashreversalanim;
1109 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1110 if(victim->weaponactive!=-1){
1111 victim->throwtogglekeydown=1;
1112 weapons.owner[victim->weaponids[0]]=-1;
1113 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1114 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1115 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1116 weapons.missed[victim->weaponids[0]]=1;
1117 weapons.freetime[victim->weaponids[0]]=0;
1118 weapons.firstfree[victim->weaponids[0]]=1;
1119 weapons.physics[victim->weaponids[0]]=1;
1120 victim->num_weapons--;
1121 if(victim->num_weapons){
1122 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1123 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1126 victim->weaponactive=-1;
1127 for(int j=0;j<numplayers;j++){
1128 player[j].wentforweapon=0;
1131 targetanimation=knifeslashreversedanim;
1132 currentanimation=knifeslashreversedanim;
1133 victim->currentanimation=knifeslashreversalanim;
1134 victim->targetanimation=knifeslashreversalanim;
1136 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1137 victim->targettilt2=targettilt2;
1138 victim->currentframe=currentframe;
1139 victim->targetframe=targetframe;
1140 victim->target=target;
1142 victim->oldcoords=victim->coords;
1143 victim->coords=coords;
1144 victim->targetrotation=targetrotation;
1145 victim->rotation=targetrotation;
1146 victim->victim=this;
1148 if(targetanimation==winduppunchanim){
1149 targetanimation=winduppunchblockedanim;
1150 victim->targetanimation=blockhighleftanim;
1151 victim->targetframe=1;
1153 victim->victim=this;
1154 victim->targetrotation=targetrotation+180;
1156 if(targetanimation==wolfslapanim){
1157 targetanimation=winduppunchblockedanim;
1158 victim->targetanimation=blockhighleftanim;
1159 victim->targetframe=1;
1161 victim->victim=this;
1162 victim->targetrotation=targetrotation+180;
1164 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1165 targetanimation=swordslashparriedanim;
1167 victim->parriedrecently=0;
1168 victim->targetanimation=swordslashparryanim;
1169 victim->targetframe=1;
1171 victim->victim=this;
1172 victim->targetrotation=targetrotation+180;
1174 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1177 gLoc[0]=victim->coords.x;
1178 gLoc[1]=victim->coords.y;
1179 gLoc[2]=victim->coords.z;
1183 if(victim->weaponactive!=-1){
1184 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1185 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1186 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1188 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1189 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1190 OPENAL_SetVolume(channels[swordstaffsound], 512);
1191 OPENAL_SetPaused(channels[swordstaffsound], false);
1194 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1195 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1196 OPENAL_SetVolume(channels[metalhitsound], 512);
1197 OPENAL_SetPaused(channels[metalhitsound], false);
1201 victim->Puff(righthand);
1203 victim->targetframe=0;
1204 victim->targetanimation=staggerbackhighanim;
1205 victim->targetrotation=targetrotation+180;
1207 weapons.owner[victim->weaponids[0]]=-1;
1208 aim=DoRotation(facing,0,90,0)*21;
1210 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1211 weapons.tipvelocity[victim->weaponids[0]]=aim;
1212 weapons.missed[victim->weaponids[0]]=1;
1213 weapons.hitsomething[victim->weaponids[0]]=0;
1214 weapons.freetime[victim->weaponids[0]]=0;
1215 weapons.firstfree[victim->weaponids[0]]=1;
1216 weapons.physics[victim->weaponids[0]]=1;
1217 victim->num_weapons--;
1218 if(victim->num_weapons){
1219 victim->weaponids[0]=victim->weaponids[num_weapons];
1220 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1222 victim->weaponactive=-1;
1223 for(int i=0;i<numplayers;i++){
1224 player[i].wentforweapon=0;
1231 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1232 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1233 OPENAL_SetVolume(channels[metalhitsound], 512);
1234 OPENAL_SetPaused(channels[metalhitsound], false);*/
1237 if(abs(Random()%20)==0){
1246 if(weaponactive!=-1){
1247 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1248 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1249 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1251 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1252 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1253 OPENAL_SetVolume(channels[swordstaffsound], 512);
1254 OPENAL_SetPaused(channels[swordstaffsound], false);
1257 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1258 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1259 OPENAL_SetVolume(channels[metalhitsound], 512);
1260 OPENAL_SetPaused(channels[metalhitsound], false);
1268 targetanimation=staggerbackhighanim;
1269 targetrotation=targetrotation+180;
1271 weapons.owner[weaponids[0]]=-1;
1272 aim=DoRotation(facing,0,90,0)*21;
1274 weapons.velocity[weaponids[0]]=aim*-.2;
1275 weapons.tipvelocity[weaponids[0]]=aim;
1276 weapons.hitsomething[weaponids[0]]=0;
1277 weapons.missed[weaponids[0]]=1;
1278 weapons.freetime[weaponids[0]]=0;
1279 weapons.firstfree[weaponids[0]]=1;
1280 weapons.physics[weaponids[0]]=1;
1283 weaponids[0]=weaponids[num_weapons];
1284 if(weaponstuck==num_weapons)weaponstuck=0;
1287 for(int i=0;i<numplayers;i++){
1288 player[i].wentforweapon=0;
1292 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1293 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1294 OPENAL_SetVolume(channels[metalhitsound], 512);
1295 OPENAL_SetPaused(channels[metalhitsound], false);*/
1299 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1300 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1301 //victim->targetanimation=sweepanim;
1302 victim->targetanimation=dodgebackanim;
1303 victim->targetframe=0;
1305 //victim->velocity=0;
1308 rotatetarget=coords-victim->coords;
1309 Normalise(&rotatetarget);
1310 victim->targetrotation=-asin(0-rotatetarget.x);
1311 victim->targetrotation*=360/6.28;
1312 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1314 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1316 victim->lastattack3=victim->lastattack2;
1317 victim->lastattack2=victim->lastattack;
1318 victim->lastattack=victim->targetanimation;
1322 victim->targetanimation=sweepanim;
1323 victim->targetframe=0;
1327 rotatetarget=coords-victim->coords;
1328 Normalise(&rotatetarget);
1329 victim->targetrotation=-asin(0-rotatetarget.x);
1330 victim->targetrotation*=360/6.28;
1331 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1333 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1335 victim->lastattack3=victim->lastattack2;
1336 victim->lastattack2=victim->lastattack;
1337 victim->lastattack=victim->targetanimation;
1344 if(aitype!=playercontrolled)feint=0;
1345 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1346 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1347 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1349 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1353 void Person::DoDamage(float howmuch){
1354 if(tutoriallevel!=1)damage+=howmuch/power;
1355 if(id!=0)damagedealt+=howmuch/power;
1356 if(id==0)damagetaken+=howmuch/power;
1358 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1359 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1360 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1361 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1362 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1364 if(id==0)camerashake+=howmuch/100;
1365 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1366 if(blackout>1)blackout=1;
1368 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1369 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1370 if(abs(Random()%2)==0){aitype=gethelptype;
1373 else aitype=attacktypecutoff;
1377 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1380 for(int i=0;i<skeleton.num_joints; i++){
1381 if(!skeleton.free)flatvelocity2=velocity;
1382 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1383 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1384 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1385 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1386 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1387 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1388 sprites.MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1389 sprites.MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1390 sprites.MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1401 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1402 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1403 OPENAL_SetVolume(channels[splattersound], 256);
1404 OPENAL_SetPaused(channels[splattersound], false);
1413 if(!dead&&creature==wolftype){
1422 if(tutoriallevel!=1||id==0)
1423 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1434 if(creature==wolftype){
1435 int i=abs(Random()%2);
1436 if(i==0)whichsound=snarlsound;
1437 if(i==1)whichsound=snarl2sound;
1438 envsound[numenvsounds]=coords;
1439 envsoundvol[numenvsounds]=16;
1440 envsoundlife[numenvsounds]=.4;
1443 if(creature==rabbittype){
1444 int i=abs(Random()%2);
1445 if(i==0)whichsound=rabbitpainsound;
1446 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1447 envsound[numenvsounds]=coords;
1448 envsoundvol[numenvsounds]=16;
1449 envsoundlife[numenvsounds]=.4;
1451 //if(i==2)whichsound=rabbitpain2sound;
1455 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1456 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1457 OPENAL_SetVolume(channels[whichsound], 512);
1458 OPENAL_SetPaused(channels[whichsound], false);
1463 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1464 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1467 void Person::DoHead(){
1468 static XYZ rotatearound;
1470 static float lookspeed=500;
1472 if(!freeze&&!winfreeze&&(!mainmenu||!gamestarted)){
1475 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1476 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1478 while(targetheadrotation>180)targetheadrotation-=360;
1479 while(targetheadrotation<-180)targetheadrotation+=360;
1481 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1482 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1483 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1484 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1486 if(targetheadrotation2>120)targetheadrotation2=120;
1487 if(targetheadrotation2<-120)targetheadrotation2=-120;
1488 if(targetheadrotation>120)targetheadrotation=120;
1489 if(targetheadrotation<-120)targetheadrotation=-120;
1491 if(!isIdle())targetheadrotation2=0;
1493 if(targetheadrotation>80)targetheadrotation=80;
1494 if(targetheadrotation<-80)targetheadrotation=-80;
1495 if(targetheadrotation2>50)targetheadrotation2=50;
1496 if(targetheadrotation2<-50)targetheadrotation2=-50;
1499 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1500 else if(headrotation>targetheadrotation){
1501 headrotation-=multiplier*lookspeed;
1503 else if(headrotation<targetheadrotation){
1504 headrotation+=multiplier*lookspeed;
1507 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1508 else if(headrotation2>targetheadrotation2){
1509 headrotation2-=multiplier*lookspeed/2;
1511 else if(headrotation2<targetheadrotation2){
1512 headrotation2+=multiplier*lookspeed/2;
1515 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1516 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1520 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1521 facing=DoRotation(facing,headrotation2*.4,0,0);
1522 facing=DoRotation(facing,0,headrotation*.4,0);
1525 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1526 facing=DoRotation(facing,headrotation2*.8,0,0);
1527 facing=DoRotation(facing,0,headrotation*.8,0);
1530 if(targetanimation==walkanim){
1531 facing=DoRotation(facing,headrotation2*.6,0,0);
1532 facing=DoRotation(facing,0,headrotation*.6,0);
1535 skeleton.specialforward[0]=facing;
1536 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1538 for(i=0;i<skeleton.num_muscles;i++){
1539 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1541 skeleton.FindRotationMuscle(i,targetanimation);
1547 void Person::RagDoll(bool checkcollision){
1552 if(id==0)numfalls++;
1553 if(id==0&&isFlip())numflipfail++;
1559 facing=DoRotation(facing,0,rotation,0);
1561 skeleton.freetime=0;
1563 skeleton.longdead=0;
1569 skeleton.freefall=1;
1571 if(!isnormal(velocity.x))velocity.x=0;
1572 if(!isnormal(velocity.y))velocity.y=0;
1573 if(!isnormal(velocity.z))velocity.z=0;
1574 if(!isnormal(rotation))rotation=0;
1575 if(!isnormal(coords.x))coords=0;
1576 if(!isnormal(tilt))tilt=0;
1577 if(!isnormal(tilt2))tilt2=0;
1579 for(i=0;i<skeleton.num_joints;i++){
1580 skeleton.joints[i].delay=0;
1581 skeleton.joints[i].locked=0;
1582 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1583 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1584 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1585 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1586 skeleton.joints[i].position.y+=.1;
1587 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1588 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1591 for(i=0;i<skeleton.num_joints;i++){
1592 skeleton.joints[i].velocity=0;
1593 skeleton.joints[i].velchange=0;
1595 skeleton.DoConstraints(&coords,&scale);
1596 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1598 skeleton.DoConstraints(&coords,&scale);
1599 skeleton.DoConstraints(&coords,&scale);
1600 skeleton.DoConstraints(&coords,&scale);
1601 skeleton.DoConstraints(&coords,&scale);
1604 speed=animation[targetanimation].speed[targetframe]*2;
1605 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1606 speed=animation[currentanimation].speed[currentframe]*2;
1608 if(transspeed)speed=transspeed*2;
1612 for(i=0;i<skeleton.num_joints;i++){
1613 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);
1614 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1615 change.x=(float)(Random()%100)/100;
1616 change.y=(float)(Random()%100)/100;
1617 change.z=(float)(Random()%100)/100;
1618 skeleton.joints[i].velocity+=change;
1619 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1621 change.x=(float)(Random()%100)/100;
1622 change.y=(float)(Random()%100)/100;
1623 change.z=(float)(Random()%100)/100;
1624 skeleton.joints[i].velchange+=change;
1625 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1635 for(j=0;j<skeleton.num_joints;j++){
1636 average+=skeleton.joints[j].position;
1640 coords+=average*scale;
1641 for(j=0;j<skeleton.num_joints;j++){
1642 skeleton.joints[j].position-=average;
1645 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1646 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1647 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1648 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1649 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1652 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1653 coords.x=lowpoint.x;
1654 coords.z=lowpoint.z;
1663 for(i=0;i<skeleton.num_joints;i++){
1664 velocity+=skeleton.joints[i].velocity*scale;
1666 velocity/=skeleton.num_joints;
1669 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1670 weapons.owner[weaponids[0]]=-1;
1671 weapons.hitsomething[weaponids[0]]=0;
1672 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1673 weapons.velocity[weaponids[0]].x+=.01;
1674 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1675 weapons.missed[weaponids[0]]=1;
1676 weapons.freetime[weaponids[0]]=0;
1677 weapons.firstfree[weaponids[0]]=1;
1678 weapons.physics[weaponids[0]]=1;
1681 weaponids[0]=weaponids[num_weapons];
1682 if(weaponstuck==num_weapons)weaponstuck=0;
1685 for(i=0;i<numplayers;i++){
1686 player[i].wentforweapon=0;
1691 targetanimation=bounceidleanim;
1692 currentanimation=bounceidleanim;
1700 void Person::FootLand(int which, float opacity){
1701 static XYZ terrainlight;
1702 static XYZ footvel,footpoint;
1703 if(opacity>=1||skiddelay<=0)
1707 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1708 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1709 //footpoint.y=coords.y;
1710 if(findDistancefast(&footpoint,&viewer))sprites.MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1712 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1714 if(footvel.y<.8)footvel.y=.8;
1715 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1716 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1717 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1718 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1719 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1720 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1722 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1724 if(footvel.y<.8)footvel.y=.8;
1725 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1726 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1727 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1728 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1729 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);
1731 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1733 if(footvel.y<.8)footvel.y=.8;
1734 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1735 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1736 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1737 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1738 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);
1739 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1741 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1744 if(footvel.y<.8)footvel.y=.8;
1745 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1746 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1747 //footpoint.y=coords.y;
1748 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)sprites.MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1752 void Person::Puff(int whichlabel){
1753 static XYZ footvel,footpoint;
1756 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1757 sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1762 HitStruct Person::BulletCollideWithPlayer(XYZ start, XYZ end){
1764 XYZ tempbulletloc[2];
1774 HitStruct hitstruct;
1775 hitstruct.collision=0;
1776 //Make bounding sphere
1779 for(int j=0;j<skeleton.num_joints;j++){
1780 average.x=average.x+skeleton.joints[j].position.x;
1781 average.y=average.y+skeleton.joints[j].position.y;
1782 average.z=average.z+skeleton.joints[j].position.z;
1785 average=average/howmany;
1787 for(int j=0;j<skeleton.num_joints;j++){
1788 if(findDistancefast(average,skeleton.joints[j].position)>distancemax){
1789 distancemax=findDistancefast(average,skeleton.joints[j].position);
1792 distancemax=fast_sqrt(distancemax);
1793 //Collide with player
1794 if(skeleton.free<1){
1797 if(rotation)start=DoRotation(start,0,-rotation,0);
1798 if(rotation)end=DoRotation(end,0,-rotation,0);
1800 tempbulletloc[0]=start;
1801 tempbulletloc[1]=end;
1802 if(sphere_line_intersection(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z,
1803 tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z,
1804 average.x, average.y, average.z, distancemax)){
1805 for(int j=0;j<skeleton.num_joints;j++){
1806 if(skeleton.joints[j].hasparent&&skeleton.joints[j].visible){
1807 tempbulletloc[0]=start;
1808 tempbulletloc[1]=end;
1811 glScalef(1,1/skeleton.joints[j].length,1);
1812 glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
1813 glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
1814 glTranslatef( (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
1815 (-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
1816 (-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
1817 glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
1818 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1819 tempbulletloc[0].x=M[12];
1820 tempbulletloc[0].y=M[13];
1821 tempbulletloc[0].z=M[14];
1825 glScalef(1,1/skeleton.joints[j].length,1);
1826 glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
1827 glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
1828 glTranslatef( (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
1829 (-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
1830 (-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
1831 glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
1832 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1833 tempbulletloc[1].x=M[12];
1834 tempbulletloc[1].y=M[13];
1835 tempbulletloc[1].z=M[14];
1837 collide=skeletonmodels[skeleton.joints[j].modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
1842 glTranslatef( (skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2,
1843 (skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2,
1844 (skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2);
1845 glRotatef(-skeleton.joints[j].rotate1+90,0,1,0);
1846 glRotatef(-skeleton.joints[j].rotate2+90,0,0,1);
1847 glScalef(1,skeleton.joints[j].length,1);
1848 glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
1849 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1850 collisionpoint.x=M[12];
1851 collisionpoint.y=M[13];
1852 collisionpoint.z=M[14];
1854 hitstruct.collision=1;
1855 hitstruct.hitlocation=collisionpoint;
1856 hitstruct.joint1=&skeleton.joints[j];
1857 hitstruct.joint2=skeleton.joints[j].parent;
1861 for(int j=0;j<skeleton.num_muscles;j++){
1862 if(skeleton.muscles[j].visible){
1863 tempbulletloc[0]=start;
1864 tempbulletloc[1]=end;
1867 glScalef(1,1/skeleton.muscles[j].length,1);
1868 glRotatef(skeleton.muscles[j].rotate3,0,1,0);
1869 glRotatef(skeleton.muscles[j].rotate2-90,0,0,1);
1870 glRotatef(skeleton.muscles[j].rotate1-90,0,1,0);
1871 glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2),
1872 (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2),
1873 (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2));
1875 glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
1876 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1877 tempbulletloc[0].x=M[12];
1878 tempbulletloc[0].y=M[13];
1879 tempbulletloc[0].z=M[14];
1883 glScalef(1,1/skeleton.muscles[j].length,1);
1884 glRotatef(skeleton.muscles[j].rotate3,0,1,0);
1885 glRotatef(skeleton.muscles[j].rotate2-90,0,0,1);
1886 glRotatef(skeleton.muscles[j].rotate1-90,0,1,0);
1888 glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2),
1889 (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2),
1890 (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2));
1891 glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
1892 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1893 tempbulletloc[1].x=M[12];
1894 tempbulletloc[1].y=M[13];
1895 tempbulletloc[1].z=M[14];
1897 collide=skeletonmodels[skeleton.muscles[j].parent1->modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
1902 glTranslatef( (skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2,
1903 (skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2,
1904 (skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2);
1905 glRotatef(-skeleton.muscles[j].rotate1+90,0,1,0);
1906 glRotatef(-skeleton.muscles[j].rotate2+90,0,0,1);
1907 glRotatef(-skeleton.muscles[j].rotate3,0,1,0);
1908 glScalef(1,findDistance(skeleton.muscles[j].parent1->position,skeleton.muscles[j].parent2->position),1);
1909 glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
1910 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1911 collisionpoint.x=M[12];
1912 collisionpoint.y=M[13];
1913 collisionpoint.z=M[14];
1915 hitstruct.collision=1;
1916 hitstruct.hitlocation=collisionpoint;
1917 hitstruct.joint1=skeleton.muscles[j].parent1;
1918 hitstruct.joint2=skeleton.muscles[j].parent2;
1923 if(skeleton.free<1){
1924 if(rotation)hitstruct.hitlocation=DoRotation(hitstruct.hitlocation,0,rotation,0);
1925 hitstruct.hitlocation=hitstruct.hitlocation+coords;
1930 void Person::DoAnimations(){
1933 static float oldtarget;
1935 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1937 if(targetanimation==tempanim||currentanimation==tempanim){
1938 animation[tempanim]=tempanimation;
1940 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1951 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1952 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1954 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1955 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1957 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1962 targfacing=DoRotation(targfacing,0,targetrotation,0);
1964 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1965 else targetanimation=backflipanim;
1966 crouchtogglekeydown=1;
1970 if(id==0)numflipped++;
1973 if(animation[targetanimation].attack!=reversed)feint=0;
1974 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1975 crouchtogglekeydown=0;
1976 if(aitype==playercontrolled)feint=0;
1980 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1981 if(!isFlip())crouchtogglekeydown=1;
1985 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1986 if(detail)normalsupdatedelay=0;
1990 if(targetanimation==rollanim&&targetframe==3&&onfire){
2000 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
2001 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
2002 OPENAL_SetVolume(channels[fireendsound], 256);
2003 OPENAL_SetPaused(channels[fireendsound], false);
2004 OPENAL_SetPaused(channels[stream_firesound], true);
2008 if(targetanimation==rabbittacklinganim&&targetframe==1){
2009 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
2010 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
2011 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
2012 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
2013 else victim->targetanimation=rabbittackledfrontanim;
2014 victim->targetframe=2;
2016 victim->rotation=rotation;
2017 victim->targetrotation=rotation;
2018 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
2019 //victim->DoDamage(30);
2020 if(creature==wolftype){
2024 gLoc[0]=victim->coords.x;
2025 gLoc[1]=victim->coords.y;
2026 gLoc[2]=victim->coords.z;
2030 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2031 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2032 OPENAL_SetVolume(channels[clawslicesound], 128);
2033 OPENAL_SetPaused(channels[clawslicesound], false);
2035 victim->DoBloodBig(1/victim->armorhead,210);
2041 if(victim->aitype==gethelptype)bonusvalue=50;
2046 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
2047 if(weapons.type[weaponids[0]]==knife){
2048 if(weaponactive==-1)weaponactive=0;
2049 else if(weaponactive==0)weaponactive=-1;
2051 if(weaponactive==-1){
2061 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2062 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2063 OPENAL_SetVolume(channels[knifesheathesound], 128);
2064 OPENAL_SetPaused(channels[knifesheathesound], false);
2066 if(weaponactive!=-1){
2076 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2077 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2078 OPENAL_SetVolume(channels[knifedrawsound], 128);
2079 OPENAL_SetPaused(channels[knifedrawsound], false);
2082 drawtogglekeydown=1;
2085 if(tutoriallevel!=1||id==0)
2086 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
2097 if(terrain.getOpacity(coords.x,coords.z)<.2){
2098 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
2099 else whichsound=footstepsound2;
2100 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
2101 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
2102 if(animation[targetanimation].label[targetframe]==3&&isRun()){
2108 if(terrain.getOpacity(coords.x,coords.z)>=.2){
2109 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
2110 else whichsound=footstepsound4;
2114 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
2115 else whichsound=footstepsound4;
2117 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
2118 if(animation[targetanimation].attack!=neutral){
2120 if(i==0)whichsound=lowwhooshsound;
2121 if(i==1)whichsound=midwhooshsound;
2122 if(i==2)whichsound=highwhooshsound;
2124 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2126 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2127 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
2129 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2130 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2131 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
2132 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
2133 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
2134 OPENAL_SetPaused(channels[whichsound], false);
2137 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
2138 envsound[numenvsounds]=coords;
2139 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
2140 else envsoundvol[numenvsounds]=6;
2141 envsoundlife[numenvsounds]=.4;
2145 if(animation[targetanimation].label[targetframe]==3){
2147 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2148 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2149 OPENAL_SetVolume(channels[whichsound], 128);
2150 OPENAL_SetPaused(channels[whichsound], false);
2155 if(tutoriallevel!=1||id==0)
2157 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
2158 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
2168 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
2169 if(animation[targetanimation].attack!=neutral){
2171 if(creature==rabbittype){
2172 if(i==0)whichsound=rabbitattacksound;
2173 if(i==1)whichsound=rabbitattack2sound;
2174 if(i==2)whichsound=rabbitattack3sound;
2175 if(i==3)whichsound=rabbitattack4sound;
2177 if(creature==wolftype){
2178 if(i==0)whichsound=barksound;
2179 if(i==1)whichsound=bark2sound;
2180 if(i==2)whichsound=bark3sound;
2181 if(i==3)whichsound=barkgrowlsound;
2185 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2187 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2188 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
2191 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2192 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2193 OPENAL_SetVolume(channels[whichsound], 512);
2194 OPENAL_SetPaused(channels[whichsound], false);
2200 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
2206 currentoffset=targetoffset;
2207 targetframe=currentframe;
2208 currentanimation=targetanimation;
2211 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
2212 for(i=0;i<weapons.numweapons;i++){
2213 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
2214 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
2215 if(findDistancefast(&coords,&weapons.position[i])>=1){
2216 if(weapons.type[i]!=staff){
2225 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2226 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2227 OPENAL_SetVolume(channels[knifedrawsound], 128);
2228 OPENAL_SetPaused(channels[knifedrawsound], false);
2232 weapons.owner[i]=id;
2234 weaponids[num_weapons]=weaponids[0];
2243 static bool willwork;
2244 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2245 for(i=0;i<weapons.numweapons;i++){
2247 if(weapons.owner[i]!=-1)
2248 if(player[weapons.owner[i]].weaponstuck!=-1)
2249 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2250 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2251 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))
2252 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2253 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2263 if(weapons.owner[i]!=-1)
2264 if(victim->weaponstuck!=-1){
2265 if(victim->weaponids[victim->weaponstuck]==i){
2270 if(weapons.type[i]!=staff){
2271 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2272 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2273 OPENAL_SetVolume(channels[knifedrawsound], 128);
2274 OPENAL_SetPaused(channels[knifedrawsound], false);
2278 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2279 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2280 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2281 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2284 if(weapons.owner[i]!=-1){
2286 victim=&player[weapons.owner[i]];
2287 if(victim->num_weapons==1)victim->num_weapons=0;
2288 else victim->num_weapons=1;
2290 //victim->weaponactive=-1;
2291 victim->skeleton.longdead=0;
2292 victim->skeleton.free=1;
2293 victim->skeleton.broken=0;
2295 for(int j=0;j<victim->skeleton.num_joints;j++){
2296 victim->skeleton.joints[j].velchange=0;
2297 victim->skeleton.joints[j].locked=0;
2303 Normalise(&relative);
2304 XYZ footvel,footpoint;
2306 footpoint=weapons.position[i];
2307 if(victim->weaponstuck!=-1){
2308 if(victim->weaponids[victim->weaponstuck]==i){
2309 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2310 weapons.bloody[i]=2;
2311 weapons.blooddrip[i]=5;
2312 victim->weaponstuck=-1;
2315 if(victim->num_weapons>0){
2316 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2317 if(victim->weaponids[0]==i)
2318 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2321 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2322 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2323 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2324 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2326 weapons.owner[i]=id;
2328 weaponids[num_weapons]=weaponids[0];
2337 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2338 if(weaponactive==-1)weaponactive=0;
2339 else if(weaponactive==0){
2343 buffer=weaponids[0];
2344 weaponids[0]=weaponids[1];
2345 weaponids[1]=buffer;
2348 if(weaponactive==-1){
2358 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2359 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2360 OPENAL_SetVolume(channels[knifesheathesound], 128);
2361 OPENAL_SetPaused(channels[knifesheathesound], false);
2363 if(weaponactive!=-1){
2373 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2374 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2375 OPENAL_SetVolume(channels[knifedrawsound], 128);
2376 OPENAL_SetPaused(channels[knifedrawsound], false);
2381 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2382 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2383 Normalise(&rotatetarget);
2384 targetrotation=-asin(0-rotatetarget.x);
2385 targetrotation*=360/6.28;
2386 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2388 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2389 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2394 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2396 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;
2398 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2399 targetanimation=rabbittackleanim;
2410 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2411 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2412 OPENAL_SetVolume(channels[jumpsound], 128);
2413 OPENAL_SetPaused(channels[jumpsound], false);
2422 Normalise(&targetloc);
2424 for(i=0;i<numplayers;i++){
2426 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2427 closestdist=findDistancefast(&targetloc,&player[i].coords);
2432 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2434 victim=&player[closestid];
2435 coords=victim->coords;
2436 currentanimation=rabbittacklinganim;
2437 targetanimation=rabbittacklinganim;
2441 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2442 rotatetarget=coords-victim->coords;
2443 Normalise(&rotatetarget);
2444 targetrotation=-asin(0-rotatetarget.x);
2445 targetrotation*=360/6.28;
2446 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2448 if(targetanimation!=rabbitrunninganim){
2458 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2459 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2460 OPENAL_SetVolume(channels[jumpsound], 128);
2461 OPENAL_SetPaused(channels[jumpsound], false);
2467 float damagemult=1*power;
2468 if(creature==wolftype)damagemult=2.5*power;
2469 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2470 //if(onfire)damagemult=3;
2471 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2472 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2473 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2475 if(id==0)camerashake+=.4;
2476 if(Random()%2||creature==wolftype){
2479 if(creature==wolftype)DoBloodBig(0,250);
2483 gLoc[0]=victim->coords.x;
2484 gLoc[1]=victim->coords.y;
2485 gLoc[2]=victim->coords.z;
2489 if(tutoriallevel!=1){
2490 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2491 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2492 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2493 OPENAL_SetPaused(channels[heavyimpactsound], false);
2495 if(creature==wolftype){
2496 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2497 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2498 OPENAL_SetVolume(channels[clawslicesound], 128);
2499 OPENAL_SetPaused(channels[clawslicesound], false);
2501 victim->DoBloodBig(2/victim->armorhead,175);
2505 relative=victim->coords-coords;
2507 Normalise(&relative);
2508 relative=DoRotation(relative,0,-90,0);
2509 for(i=0;i<victim->skeleton.num_joints;i++){
2510 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2512 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2515 victim->DoDamage(damagemult*100/victim->protectionhead);
2523 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2524 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2526 if(id==0)camerashake+=.4;
2527 if(Random()%2||creature==wolftype){
2529 if(creature==wolftype)DoBloodBig(0,235);
2533 gLoc[0]=victim->coords.x;
2534 gLoc[1]=victim->coords.y;
2535 gLoc[2]=victim->coords.z;
2539 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2540 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2541 OPENAL_SetVolume(channels[whooshhitsound], 512);
2542 OPENAL_SetPaused(channels[whooshhitsound], false);
2543 if(creature==wolftype){
2544 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2545 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2546 OPENAL_SetVolume(channels[clawslicesound], 128);
2547 OPENAL_SetPaused(channels[clawslicesound], false);
2549 victim->DoBloodBig(2,175);
2553 relative=victim->coords-coords;
2555 Normalise(&relative);
2557 Normalise(&relative);
2558 relative=DoRotation(relative,0,90,0);
2559 for(i=0;i<victim->skeleton.num_joints;i++){
2560 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2562 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2565 victim->DoDamage(damagemult*50/victim->protectionhead);
2569 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2570 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2572 if(id==0)camerashake+=.4;
2577 gLoc[0]=victim->coords.x;
2578 gLoc[1]=victim->coords.y;
2579 gLoc[2]=victim->coords.z;
2583 if(tutoriallevel!=1){
2584 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2585 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2586 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2587 OPENAL_SetPaused(channels[heavyimpactsound], false);
2589 if(creature==wolftype){
2590 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2591 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2592 OPENAL_SetVolume(channels[clawslicesound], 128);
2593 OPENAL_SetPaused(channels[clawslicesound], false);
2595 victim->DoBloodBig(2/victim->armorhead,175);
2601 Normalise(&relative);
2602 relative=DoRotation(relative,0,-90,0);
2603 for(i=0;i<victim->skeleton.num_joints;i++){
2604 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2606 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2609 victim->DoDamage(damagemult*150/victim->protectionhead);
2611 if(victim->damage>victim->damagetolerance){
2624 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2625 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2627 if(id==0)camerashake+=.4;
2632 gLoc[0]=victim->coords.x;
2633 gLoc[1]=victim->coords.y;
2634 gLoc[2]=victim->coords.z;
2638 if(tutoriallevel!=1){
2639 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2640 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2641 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2642 OPENAL_SetPaused(channels[heavyimpactsound], false);
2644 if(creature==wolftype){
2645 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2646 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2647 OPENAL_SetVolume(channels[clawslicesound], 128);
2648 OPENAL_SetPaused(channels[clawslicesound], false);
2650 victim->DoBloodBig(2/victim->armorhead,175);
2656 Normalise(&relative);
2657 relative=DoRotation(relative,0,90,0);
2658 for(i=0;i<victim->skeleton.num_joints;i++){
2659 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2661 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2664 victim->DoDamage(damagemult*150/victim->protectionhead);
2666 if(victim->damage>victim->damagetolerance){
2679 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2680 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2682 if(id==0)camerashake+=.4;
2689 gLoc[0]=victim->coords.x;
2690 gLoc[1]=victim->coords.y;
2691 gLoc[2]=victim->coords.z;
2695 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2696 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2697 OPENAL_SetVolume(channels[whooshhitsound], 512);
2698 OPENAL_SetPaused(channels[whooshhitsound], false);
2701 relative=victim->coords-coords;
2703 Normalise(&relative);
2704 for(i=0;i<victim->skeleton.num_joints;i++){
2705 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2707 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2710 victim->DoDamage(damagemult*50/victim->protectionhead);
2714 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2715 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2717 if(id==0)camerashake+=.2;
2720 gLoc[0]=victim->coords.x;
2721 gLoc[1]=victim->coords.y;
2722 gLoc[2]=victim->coords.z;
2726 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2727 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2728 OPENAL_SetVolume(channels[landsound2], 128);
2729 OPENAL_SetPaused(channels[landsound2], false);
2731 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2732 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2733 OPENAL_SetVolume(channels[movewhooshsound], 128);
2734 OPENAL_SetPaused(channels[movewhooshsound], false);
2736 victim->skeleton.longdead=0;
2737 victim->skeleton.free=1;
2738 victim->skeleton.broken=0;
2739 victim->skeleton.spinny=1;
2741 for(i=0;i<victim->skeleton.num_joints;i++){
2742 victim->skeleton.joints[i].velchange=0;
2743 victim->skeleton.joints[i].delay=0;
2744 victim->skeleton.joints[i].locked=0;
2745 //victim->skeleton.joints[i].velocity=0;
2751 Normalise(&relative);
2752 for(i=0;i<victim->skeleton.num_joints;i++){
2753 victim->skeleton.joints[i].velocity.y=relative.y*10;
2754 victim->skeleton.joints[i].position.y+=relative.y*.3;
2755 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2756 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2758 victim->Puff(abdomen);
2759 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2763 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2764 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2766 if(id==0)camerashake+=.4;
2775 if(tutoriallevel!=1){
2776 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2777 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2778 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2779 OPENAL_SetPaused(channels[heavyimpactsound], false);
2782 relative=victim->coords-coords;
2784 Normalise(&relative);
2785 for(i=0;i<victim->skeleton.num_joints;i++){
2786 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2788 victim->Puff(abdomen);
2789 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2793 victim->DoDamage(damagemult*500/victim->protectionhigh);
2794 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2798 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2799 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2801 if(id==0)camerashake+=.4;
2810 if(tutoriallevel!=1){
2811 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2812 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2813 OPENAL_SetVolume(channels[thudsound], 400);
2814 OPENAL_SetPaused(channels[thudsound], false);
2817 victim->skeleton.longdead=0;
2818 victim->skeleton.free=1;
2819 victim->skeleton.broken=0;
2820 victim->skeleton.spinny=1;
2822 for(i=0;i<victim->skeleton.num_joints;i++){
2823 victim->skeleton.joints[i].velchange=0;
2824 //victim->skeleton.joints[i].delay=0;
2825 victim->skeleton.joints[i].locked=0;
2828 relative=victim->coords-coords;
2829 Normalise(&relative);
2831 Normalise(&relative);
2832 for(i=0;i<victim->skeleton.num_joints;i++){
2833 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2835 if(id==0&&!victim->dead){
2839 victim->Puff(abdomen);
2840 victim->DoDamage(damagemult*20/victim->protectionhigh);
2841 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2843 if(!victim->dead)staggerdelay=1.2;
2849 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2850 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2851 //if(id==0)camerashake+=.4;
2862 if(!victim->skeleton.free)hasvictim=0;
2865 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2866 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2867 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2868 OPENAL_SetVolume(channels[knifesheathesound], 128);
2869 OPENAL_SetPaused(channels[knifesheathesound], false);
2872 if(victim&&hasvictim){
2873 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2875 XYZ where,startpoint,endpoint,movepoint,colpoint;
2876 float rotationpoint;
2878 if(weapons.type[weaponids[weaponactive]]==knife){
2879 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2880 where-=victim->coords;
2881 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2888 if(weapons.type[weaponids[weaponactive]]==sword){
2889 where=weapons.position[weaponids[weaponactive]];
2890 where-=victim->coords;
2891 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2893 where=weapons.tippoint[weaponids[weaponactive]];
2894 where-=victim->coords;
2895 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2898 if(weapons.type[weaponids[weaponactive]]==staff){
2899 where=weapons.position[weaponids[weaponactive]];
2900 where-=victim->coords;
2901 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2903 where=weapons.tippoint[weaponids[weaponactive]];
2904 where-=victim->coords;
2905 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2910 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2913 if(victim->dead!=2){
2914 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2915 if(id==0&&!victim->dead){
2916 bonus=FinishedBonus;
2921 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2923 victim->skeleton.longdead=0;
2924 victim->skeleton.free=1;
2925 victim->skeleton.broken=0;
2927 for(i=0;i<victim->skeleton.num_joints;i++){
2928 victim->skeleton.joints[i].velchange=0;
2929 victim->skeleton.joints[i].locked=0;
2930 //victim->skeleton.joints[i].velocity=0;
2932 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2933 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2934 OPENAL_SetVolume(channels[fleshstabsound], 128);
2935 OPENAL_SetPaused(channels[fleshstabsound], false);
2938 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2939 weapons.blooddrip[weaponids[weaponactive]]+=5;
2940 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2944 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2945 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2946 OPENAL_SetVolume(channels[knifesheathesound], 128);
2947 OPENAL_SetPaused(channels[knifesheathesound], false);
2953 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2954 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2955 //if(id==0)camerashake+=.4;
2965 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2966 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2967 OPENAL_SetVolume(channels[knifedrawsound], 128);
2968 OPENAL_SetPaused(channels[knifedrawsound], false);
2971 if(victim&&hasvictim){
2972 XYZ footvel,footpoint;
2974 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2975 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2976 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2977 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2980 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2982 if(weapons.type[weaponids[weaponactive]]==sword){
2983 XYZ where,startpoint,endpoint,movepoint;
2984 float rotationpoint;
2987 where=weapons.position[weaponids[weaponactive]];
2988 where-=victim->coords;
2989 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2991 where=weapons.tippoint[weaponids[weaponactive]];
2992 where-=victim->coords;
2993 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2998 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2999 footpoint+=victim->coords;
3002 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
3005 if(weapons.type[weaponids[weaponactive]]==staff){
3006 XYZ where,startpoint,endpoint,movepoint;
3007 float rotationpoint;
3010 where=weapons.position[weaponids[weaponactive]];
3011 where-=victim->coords;
3012 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
3014 where=weapons.tippoint[weaponids[weaponactive]];
3015 where-=victim->coords;
3016 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
3021 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
3022 footpoint+=victim->coords;
3025 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
3028 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
3030 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
3031 victim->skeleton.longdead=0;
3032 victim->skeleton.free=1;
3033 victim->skeleton.broken=0;
3035 for(i=0;i<victim->skeleton.num_joints;i++){
3036 victim->skeleton.joints[i].velchange=0;
3037 victim->skeleton.joints[i].locked=0;
3038 //victim->skeleton.joints[i].velocity=0;
3044 Normalise(&relative);
3045 //victim->Puff(abdomen);
3046 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
3048 if(victim->bloodloss<victim->damagetolerance){
3049 victim->bloodloss+=1000;
3053 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3057 if(!hasvictim&&onterrain){
3058 weapons.bloody[weaponids[weaponactive]]=0;
3059 weapons.blooddrip[weaponids[weaponactive]]=0;
3063 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
3064 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
3066 if(id==0)camerashake+=.4;
3073 gLoc[0]=victim->coords.x;
3074 gLoc[1]=victim->coords.y;
3075 gLoc[2]=victim->coords.z;
3079 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
3081 if(tutoriallevel!=1){
3082 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3083 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3084 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3085 OPENAL_SetPaused(channels[heavyimpactsound], false);
3089 if(tutoriallevel!=1){
3090 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3091 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3092 OPENAL_SetVolume(channels[landsound2], 256);
3093 OPENAL_SetPaused(channels[landsound2], false);
3097 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
3100 relative=victim->coords-coords;
3102 Normalise(&relative);
3103 for(i=0;i<victim->skeleton.num_joints;i++){
3104 victim->skeleton.joints[i].velocity=relative*30;
3106 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
3108 victim->targetframe=0;
3109 victim->targetanimation=staggerbackhardanim;
3110 victim->targetrotation=targetrotation+180;
3115 victim->Puff(abdomen);
3116 victim->DoDamage(damagemult*60/victim->protectionhigh);
3125 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
3126 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
3128 if(id==0)camerashake+=.4;
3131 gLoc[0]=victim->coords.x;
3132 gLoc[1]=victim->coords.y;
3133 gLoc[2]=victim->coords.z;
3137 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
3138 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
3139 if(tutoriallevel!=1){
3140 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
3141 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
3142 OPENAL_SetVolume(channels[thudsound], 512);
3143 OPENAL_SetPaused(channels[thudsound], false);
3146 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
3147 if(tutoriallevel!=1){
3148 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3149 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3150 OPENAL_SetVolume(channels[whooshhitsound], 512);
3151 OPENAL_SetPaused(channels[whooshhitsound], false);
3155 if(tutoriallevel!=1){
3156 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3157 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3158 OPENAL_SetVolume(channels[heavyimpactsound], 256);
3159 OPENAL_SetPaused(channels[heavyimpactsound], false);
3163 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
3166 relative=victim->coords-coords;
3168 Normalise(&relative);
3170 Normalise(&relative);
3171 for(i=0;i<victim->skeleton.num_joints;i++){
3172 victim->skeleton.joints[i].velocity=relative*5;
3174 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
3176 victim->targetframe=0;
3177 victim->targetanimation=staggerbackhardanim;
3178 victim->targetrotation=targetrotation+180;
3182 victim->Puff(abdomen);
3183 victim->DoDamage(damagemult*60/victim->protectionhigh);
3191 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
3192 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3193 if(victim->id==0)camerashake+=.4;
3196 gLoc[0]=victim->coords.x;
3197 gLoc[1]=victim->coords.y;
3198 gLoc[2]=victim->coords.z;
3203 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3204 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3205 OPENAL_SetVolume(channels[landsound2], 256);
3206 OPENAL_SetPaused(channels[landsound2], false);
3212 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
3213 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3214 if(victim->id==0)camerashake+=.4;
3217 gLoc[0]=victim->coords.x;
3218 gLoc[1]=victim->coords.y;
3219 gLoc[2]=victim->coords.z;
3224 if(weaponactive!=-1){
3225 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3226 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3227 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3229 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3230 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3231 OPENAL_SetVolume(channels[swordstaffsound], 512);
3232 OPENAL_SetPaused(channels[swordstaffsound], false);
3235 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3236 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3237 OPENAL_SetVolume(channels[metalhitsound], 512);
3238 OPENAL_SetPaused(channels[metalhitsound], false);
3246 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3247 if(weaponactive!=-1){
3250 weapons.owner[weaponids[0]]=-1;
3251 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);
3253 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3254 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3256 weapons.velocity[weaponids[0]]=aim*50;
3257 weapons.tipvelocity[weaponids[0]]=aim*50;
3258 weapons.missed[weaponids[0]]=0;
3259 weapons.hitsomething[weaponids[0]]=0;
3260 weapons.freetime[weaponids[0]]=0;
3261 weapons.firstfree[weaponids[0]]=1;
3262 weapons.physics[weaponids[0]]=0;
3265 weaponids[0]=weaponids[num_weapons];
3271 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3273 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3276 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3284 if(tutoriallevel!=1){
3287 gLoc[0]=victim->coords.x;
3288 gLoc[1]=victim->coords.y;
3289 gLoc[2]=victim->coords.z;
3293 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3294 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3295 OPENAL_SetVolume(channels[knifeslicesound], 512);
3296 OPENAL_SetPaused(channels[knifeslicesound], false);
3298 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3299 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3300 if(victim->id != 0 || difficulty==2){
3301 victim->targetframe=0;
3302 victim->targetanimation=staggerbackhardanim;
3303 victim->targetrotation=targetrotation+180;
3307 victim->lowreversaldelay=0;
3308 victim->highreversaldelay=0;
3309 if(aitype!=playercontrolled)weaponmissdelay=.6;
3311 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3312 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3314 XYZ footvel,footpoint;
3317 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3320 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;
3322 if(tutoriallevel!=1){
3323 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3324 footvel=DoRotation(facing,0,90,0)*.8;
3326 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3327 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3328 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3329 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3331 if(tutoriallevel==1){
3332 sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3334 victim->DoDamage(damagemult*0);
3337 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3338 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3339 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3346 if(tutoriallevel!=1){
3347 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3348 else victim->DoBloodBig(2/victim->armorhigh,185);
3349 victim->deathbleeding=1;
3352 gLoc[0]=victim->coords.x;
3353 gLoc[1]=victim->coords.y;
3354 gLoc[2]=victim->coords.z;
3358 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3359 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3360 OPENAL_SetVolume(channels[swordslicesound], 512);
3361 OPENAL_SetPaused(channels[swordslicesound], false);
3363 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3364 //if(animation[victim->targetanimation].attack){
3365 //if(victim->creature==rabbittype){
3366 if(tutoriallevel!=1){
3367 victim->targetframe=0;
3368 victim->targetanimation=staggerbackhardanim;
3369 victim->targetrotation=targetrotation+180;
3375 if(tutoriallevel!=1){
3376 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3377 weapons.blooddrip[weaponids[weaponactive]]+=3;
3379 float bloodlossamount;
3380 bloodlossamount=200+abs((float)(Random()%40))-20;
3381 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3382 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3383 victim->DoDamage(damagemult*0);
3385 XYZ footvel,footpoint;
3388 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3391 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;
3393 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3394 footvel=DoRotation(facing,0,90,0)*.8;
3396 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3397 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3398 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3399 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3407 gLoc[0]=victim->coords.x;
3408 gLoc[1]=victim->coords.y;
3409 gLoc[2]=victim->coords.z;
3413 if(victim->weaponactive!=-1){
3414 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3415 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3416 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3418 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3419 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3420 OPENAL_SetVolume(channels[swordstaffsound], 512);
3421 OPENAL_SetPaused(channels[swordstaffsound], false);
3424 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3425 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3426 OPENAL_SetVolume(channels[metalhitsound], 512);
3427 OPENAL_SetPaused(channels[metalhitsound], false);
3433 victim->Puff(righthand);
3435 victim->targetframe=0;
3436 victim->targetanimation=staggerbackhighanim;
3437 victim->targetrotation=targetrotation+180;
3439 weapons.owner[victim->weaponids[0]]=-1;
3440 aim=DoRotation(facing,0,90,0)*21;
3442 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3443 weapons.tipvelocity[victim->weaponids[0]]=aim;
3444 weapons.missed[victim->weaponids[0]]=1;
3445 weapons.hitsomething[weaponids[0]]=0;
3446 weapons.freetime[victim->weaponids[0]]=0;
3447 weapons.firstfree[victim->weaponids[0]]=1;
3448 weapons.physics[victim->weaponids[0]]=1;
3449 victim->num_weapons--;
3450 if(victim->num_weapons){
3451 victim->weaponids[0]=victim->weaponids[num_weapons];
3452 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3454 victim->weaponactive=-1;
3455 for(i=0;i<numplayers;i++){
3456 player[i].wentforweapon=0;
3459 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3460 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3461 OPENAL_SetVolume(channels[metalhitsound], 512);
3462 OPENAL_SetPaused(channels[metalhitsound], false);*/
3468 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3469 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3470 if(tutoriallevel!=1){
3471 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3473 if(id==0)camerashake+=.4;
3474 if(Random()%2||creature==wolftype){
3479 gLoc[0]=victim->coords.x;
3480 gLoc[1]=victim->coords.y;
3481 gLoc[2]=victim->coords.z;
3485 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3486 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3487 OPENAL_SetVolume(channels[staffheadsound], 256);
3488 OPENAL_SetPaused(channels[staffheadsound], false);
3492 relative=victim->coords-coords;
3494 Normalise(&relative);
3495 relative=DoRotation(relative,0,90,0);
3497 Normalise(&relative);
3498 for(i=0;i<victim->skeleton.num_joints;i++){
3499 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3501 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3502 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3505 if(tutoriallevel!=1){
3506 victim->DoDamage(damagemult*120/victim->protectionhigh);
3517 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3518 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3519 if(tutoriallevel!=1){
3520 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3522 if(id==0)camerashake+=.4;
3523 if(Random()%2||creature==wolftype){
3528 gLoc[0]=victim->coords.x;
3529 gLoc[1]=victim->coords.y;
3530 gLoc[2]=victim->coords.z;
3534 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3535 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3536 OPENAL_SetVolume(channels[staffheadsound], 256);
3537 OPENAL_SetPaused(channels[staffheadsound], false);
3541 relative=victim->coords-coords;
3543 Normalise(&relative);
3544 relative=DoRotation(relative,0,-90,0);
3545 for(i=0;i<victim->skeleton.num_joints;i++){
3546 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3548 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3549 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3552 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3563 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3564 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3566 if(tutoriallevel!=1){
3567 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3568 if(id==0)camerashake+=.4;
3569 if(Random()%2||creature==wolftype){
3574 gLoc[0]=victim->coords.x;
3575 gLoc[1]=victim->coords.y;
3576 gLoc[2]=victim->coords.z;
3580 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3581 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3582 OPENAL_SetVolume(channels[staffbodysound], 256);
3583 OPENAL_SetPaused(channels[staffbodysound], false);
3585 victim->skeleton.longdead=0;
3586 victim->skeleton.free=1;
3587 victim->skeleton.broken=0;
3589 for(i=0;i<victim->skeleton.num_joints;i++){
3590 victim->skeleton.joints[i].velchange=0;
3591 victim->skeleton.joints[i].locked=0;
3592 //victim->skeleton.joints[i].velocity=0;
3598 /*relative=victim->coords-coords;
3600 Normalise(&relative);
3601 relative=DoRotation(relative,0,90,0);*/
3603 Normalise(&relative);
3605 for(i=0;i<victim->skeleton.num_joints;i++){
3606 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3609 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3612 for(i=0;i<victim->skeleton.num_joints;i++){
3613 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3616 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3618 victim->Puff(abdomen);
3619 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3632 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3633 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3635 if(id==0)camerashake+=.4;
3638 gLoc[0]=victim->coords.x;
3639 gLoc[1]=victim->coords.y;
3640 gLoc[2]=victim->coords.z;
3645 relative=victim->coords-coords;
3647 Normalise(&relative);
3653 if(animation[victim->targetanimation].height==lowheight){
3659 for(i=0;i<victim->skeleton.num_joints;i++){
3660 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3662 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3663 if(tutoriallevel!=1){
3664 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3665 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3666 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3667 OPENAL_SetPaused(channels[heavyimpactsound], false);
3670 victim->DoDamage(damagemult*100/victim->protectionhead);
3671 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3672 if(creature==wolftype){
3673 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3674 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3675 OPENAL_SetVolume(channels[clawslicesound], 128);
3676 OPENAL_SetPaused(channels[clawslicesound], false);
3678 victim->DoBloodBig(2/victim->armorhead,175);
3682 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3683 for(i=0;i<victim->skeleton.num_joints;i++){
3684 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3686 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3687 victim->targetframe=0;
3688 victim->targetanimation=staggerbackhighanim;
3689 victim->targetrotation=targetrotation+180;
3691 if(tutoriallevel!=1){
3692 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3693 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3694 OPENAL_SetVolume(channels[landsound2], 128);
3695 OPENAL_SetPaused(channels[landsound2], false);
3697 victim->Puff(abdomen);
3698 victim->DoDamage(damagemult*30/victim->protectionhigh);
3699 if(creature==wolftype){
3700 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3701 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3702 OPENAL_SetVolume(channels[clawslicesound], 128);
3703 OPENAL_SetPaused(channels[clawslicesound], false);
3705 victim->DoBloodBig(2/victim->armorhigh,170);
3712 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3713 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3715 if(id==0)camerashake+=.2;
3718 gLoc[0]=victim->coords.x;
3719 gLoc[1]=victim->coords.y;
3720 gLoc[2]=victim->coords.z;
3724 if(tutoriallevel!=1){
3725 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3726 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3727 OPENAL_SetVolume(channels[landsound2], 128);
3728 OPENAL_SetPaused(channels[landsound2], false);
3731 relative=victim->coords-coords;
3733 Normalise(&relative);
3735 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3738 for(i=0;i<victim->skeleton.num_joints;i++){
3739 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3741 relative=DoRotation(relative,0,-90,0);
3743 for(i=0;i<victim->skeleton.num_joints;i++){
3744 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)
3745 victim->skeleton.joints[i].velocity=relative*80;
3747 victim->Puff(rightankle);
3748 victim->Puff(leftankle);
3749 victim->DoDamage(damagemult*40/victim->protectionlow);
3752 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3753 for(i=0;i<victim->skeleton.num_joints;i++){
3754 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3756 relative=DoRotation(relative,0,-90,0);
3757 for(i=0;i<victim->skeleton.num_joints;i++){
3758 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)
3759 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3761 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3762 victim->targetframe=0;
3763 victim->targetanimation=staggerbackhighanim;
3764 victim->targetrotation=targetrotation+180;
3766 if(tutoriallevel!=1){
3767 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3768 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3769 OPENAL_SetVolume(channels[landsound2], 128);
3770 OPENAL_SetPaused(channels[landsound2], false);
3772 victim->Puff(abdomen);
3773 victim->DoDamage(damagemult*30/victim->protectionlow);
3783 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3784 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3786 if(id==0)camerashake+=.4;
3793 gLoc[0]=victim->coords.x;
3794 gLoc[1]=victim->coords.y;
3795 gLoc[2]=victim->coords.z;
3799 if(tutoriallevel!=1){
3800 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3801 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3802 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3803 OPENAL_SetPaused(channels[heavyimpactsound], false);
3805 if(creature==wolftype){
3806 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3807 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3808 OPENAL_SetVolume(channels[clawslicesound], 128);
3809 OPENAL_SetPaused(channels[clawslicesound], false);
3811 victim->DoBloodBig(2/victim->armorhigh,170);
3815 relative=victim->coords-oldcoords;
3817 Normalise(&relative);
3818 //relative=DoRotation(relative,0,-90,0);
3819 for(i=0;i<victim->skeleton.num_joints;i++){
3820 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3822 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3824 victim->Puff(abdomen);
3825 victim->DoDamage(damagemult*150/victim->protectionhigh);
3834 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3835 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3836 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3837 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3840 weaponids[num_weapons]=weaponids[victim->weaponactive];
3843 weaponids[0]=victim->weaponids[victim->weaponactive];
3844 victim->num_weapons--;
3845 if(victim->num_weapons>0){
3846 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3847 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3849 victim->weaponactive=-1;
3854 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3856 if(id==0)camerashake+=.4;
3863 gLoc[0]=victim->coords.x;
3864 gLoc[1]=victim->coords.y;
3865 gLoc[2]=victim->coords.z;
3869 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3870 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3871 OPENAL_SetVolume(channels[whooshhitsound], 128);
3872 OPENAL_SetPaused(channels[whooshhitsound], false);
3875 relative=victim->coords-oldcoords;
3877 Normalise(&relative);
3878 //relative=DoRotation(relative,0,-90,0);
3879 for(i=0;i<victim->skeleton.num_joints;i++){
3880 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3882 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3885 victim->DoDamage(damagemult*70/victim->protectionhigh);
3888 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3890 if(id==0)camerashake+=.4;
3897 gLoc[0]=victim->coords.x;
3898 gLoc[1]=victim->coords.y;
3899 gLoc[2]=victim->coords.z;
3905 bonus=staffreversebonus;
3910 if(tutoriallevel!=1){
3911 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3912 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3913 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3914 OPENAL_SetPaused(channels[heavyimpactsound], false);
3918 bonus=staffreversebonus;
3924 relative=victim->coords-oldcoords;
3926 Normalise(&relative);
3927 //relative=DoRotation(relative,0,-90,0);
3928 for(i=0;i<victim->skeleton.num_joints;i++){
3929 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3931 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3934 victim->DoDamage(damagemult*70/victim->protectionhigh);
3937 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3943 Normalise(&relative);
3946 for(i=0;i<victim->skeleton.num_joints;i++){
3947 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3949 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3950 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3951 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3952 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3953 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3954 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3955 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3956 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3958 victim->Puff(abdomen);
3959 victim->DoDamage(damagemult*90/victim->protectionhigh);
3969 if(weaponactive!=-1||creature==wolftype)doslice=1;
3970 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3974 gLoc[0]=victim->coords.x;
3975 gLoc[1]=victim->coords.y;
3976 gLoc[2]=victim->coords.z;
3980 if(weaponactive!=-1){
3981 victim->DoBloodBig(2/victim->armorhigh,225);
3982 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3983 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3984 OPENAL_SetVolume(channels[knifeslicesound], 512);
3985 OPENAL_SetPaused(channels[knifeslicesound], false);
3986 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3987 weapons.blooddrip[weaponids[weaponactive]]+=3;
3989 if(weaponactive==-1&&creature==wolftype){
3990 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3991 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3992 OPENAL_SetVolume(channels[clawslicesound], 128);
3993 OPENAL_SetPaused(channels[clawslicesound], false);
3995 victim->DoBloodBig(2/victim->armorhigh,175);
4002 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
4008 Normalise(&relative);
4011 for(i=0;i<victim->skeleton.num_joints;i++){
4012 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
4014 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
4015 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
4016 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
4017 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
4018 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
4019 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
4020 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
4021 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
4024 bonus=swordreversebonus;
4028 //victim->DoDamage(90);
4030 /*if(weaponactive!=-1){
4033 gLoc[0]=victim->coords.x;
4034 gLoc[1]=victim->coords.y;
4035 gLoc[2]=victim->coords.z;
4039 victim->DoBloodBig(2,225);
4040 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4041 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4042 OPENAL_SetVolume(channels[knifeslicesound], 512);
4043 OPENAL_SetPaused(channels[knifeslicesound], false);
4044 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4045 weapons.blooddrip[weaponids[weaponactive]]+=3;
4049 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
4051 if(id==0)camerashake+=.4;
4058 gLoc[0]=victim->coords.x;
4059 gLoc[1]=victim->coords.y;
4060 gLoc[2]=victim->coords.z;
4064 if(tutoriallevel!=1){
4065 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4066 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4067 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4068 OPENAL_SetPaused(channels[heavyimpactsound], false);
4072 relative=victim->coords-oldcoords;
4074 Normalise(&relative);
4075 relative=DoRotation(relative,0,-90,0);
4076 for(i=0;i<victim->skeleton.num_joints;i++){
4077 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
4079 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
4081 victim->Puff(abdomen);
4082 victim->DoDamage(damagemult*30/victim->protectionhigh);
4091 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
4094 victim->skeleton.spinny=0;
4098 Normalise(&relative);
4099 if(victim->id==0)relative/=30;
4100 for(i=0;i<victim->skeleton.num_joints;i++){
4101 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
4103 //victim->DoDamage(1000);
4104 victim->damage=victim->damagetolerance;
4105 victim->permanentdamage=victim->damagetolerance-1;
4108 if(weaponactive!=-1||creature==wolftype)doslice=1;
4109 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4113 gLoc[0]=victim->coords.x;
4114 gLoc[1]=victim->coords.y;
4115 gLoc[2]=victim->coords.z;
4119 if(weaponactive!=-1){
4120 victim->DoBloodBig(200,225);
4121 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4122 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4123 OPENAL_SetVolume(channels[knifeslicesound], 512);
4124 OPENAL_SetPaused(channels[knifeslicesound], false);
4125 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4126 weapons.blooddrip[weaponids[weaponactive]]+=5;
4129 if(creature==wolftype&&weaponactive==-1){
4130 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4131 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4132 OPENAL_SetVolume(channels[clawslicesound], 128);
4133 OPENAL_SetPaused(channels[clawslicesound], false);
4135 victim->DoBloodBig(2,175);
4145 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4146 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4148 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
4149 if(targetanimation==knifesneakattackanim){
4150 /*victim->DoBloodBig(200,195);
4155 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4156 sprites.MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
4158 XYZ footvel,footpoint;
4160 footpoint=weapons.tippoint[weaponids[0]];
4161 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4162 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4163 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4164 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4165 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4166 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4167 victim->DoBloodBig(200,195);
4174 //victim->neckspurtamount=5;
4176 if(targetanimation==knifefollowanim){
4182 XYZ footvel,footpoint;
4184 footpoint=weapons.tippoint[weaponids[0]];
4185 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4186 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4187 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4188 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4189 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
4190 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
4193 victim->bloodloss+=10000;
4197 gLoc[0]=victim->coords.x;
4198 gLoc[1]=victim->coords.y;
4199 gLoc[2]=victim->coords.z;
4203 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4204 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4205 OPENAL_SetVolume(channels[fleshstabsound], 512);
4206 OPENAL_SetPaused(channels[fleshstabsound], false);
4207 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4208 weapons.blooddrip[weaponids[weaponactive]]+=5;
4212 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
4215 for(i=0;i<victim->skeleton.num_joints;i++){
4216 victim->skeleton.joints[i].velocity=0;
4218 if(targetanimation==knifefollowanim){
4220 for(i=0;i<victim->skeleton.num_joints;i++){
4221 victim->skeleton.joints[i].velocity=0;
4224 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
4227 gLoc[0]=victim->coords.x;
4228 gLoc[1]=victim->coords.y;
4229 gLoc[2]=victim->coords.z;
4233 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4234 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4235 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4236 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4237 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4238 weapons.blooddrip[weaponids[weaponactive]]+=5;
4240 XYZ footvel,footpoint;
4242 footpoint=weapons.tippoint[weaponids[0]];
4243 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4244 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4245 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4246 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4247 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4248 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4252 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4253 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4262 XYZ footvel,footpoint;
4264 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
4265 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4266 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4267 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4268 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4269 sprites.MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4270 sprites.MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4271 victim->DoBloodBig(200,180);
4272 victim->DoBloodBig(200,215);
4273 victim->bloodloss+=10000;
4277 gLoc[0]=victim->coords.x;
4278 gLoc[1]=victim->coords.y;
4279 gLoc[2]=victim->coords.z;
4283 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4284 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4285 OPENAL_SetVolume(channels[fleshstabsound], 512);
4286 OPENAL_SetPaused(channels[fleshstabsound], false);
4287 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4288 weapons.blooddrip[weaponids[weaponactive]]+=5;
4292 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
4295 for(i=0;i<victim->skeleton.num_joints;i++){
4296 victim->skeleton.joints[i].velocity=0;
4298 if(weaponactive!=-1){
4301 gLoc[0]=victim->coords.x;
4302 gLoc[1]=victim->coords.y;
4303 gLoc[2]=victim->coords.z;
4307 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4308 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4309 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4310 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4311 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4312 weapons.blooddrip[weaponids[weaponactive]]+=5;
4314 XYZ footvel,footpoint;
4316 footpoint=weapons.tippoint[weaponids[0]];
4317 if(bloodtoggle)sprites.MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4318 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4319 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4320 sprites.MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4321 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4322 sprites.MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4326 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4328 if(id==0)camerashake+=.4;
4335 gLoc[0]=victim->coords.x;
4336 gLoc[1]=victim->coords.y;
4337 gLoc[2]=victim->coords.z;
4341 if(weaponactive==-1){
4342 if(tutoriallevel!=1){
4343 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4344 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4345 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4346 OPENAL_SetPaused(channels[heavyimpactsound], false);
4351 if(weaponactive!=-1||creature==wolftype)doslice=1;
4352 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4354 if(weaponactive!=-1){
4355 victim->DoBloodBig(2/victim->armorhead,225);
4356 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4357 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4358 OPENAL_SetVolume(channels[knifeslicesound], 512);
4359 OPENAL_SetPaused(channels[knifeslicesound], false);
4360 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4361 weapons.blooddrip[weaponids[weaponactive]]+=3;
4363 if(weaponactive==-1&&creature==wolftype){
4364 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4365 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4366 OPENAL_SetVolume(channels[clawslicesound], 128);
4367 OPENAL_SetPaused(channels[clawslicesound], false);
4369 victim->DoBloodBig(2/victim->armorhead,175);
4382 //relative=victim->coords-oldcoords;
4385 Normalise(&relative);
4386 relative=DoRotation(relative,0,90,0);
4388 Normalise(&relative);
4389 for(i=0;i<victim->skeleton.num_joints;i++){
4390 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4392 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4393 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4394 victim->DoDamage(damagemult*100/victim->protectionhead);
4398 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4402 //relative=victim->coords-oldcoords;
4405 Normalise(&relative);
4406 relative=DoRotation(relative,0,90,0);
4408 Normalise(&relative);
4409 for(i=0;i<victim->skeleton.num_joints;i++){
4410 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4412 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4415 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4416 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4427 if(targetframe>animation[currentanimation].numframes-1){
4430 targetanimation=getIdle();
4434 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4435 targetanimation=rollanim;
4446 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4447 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4448 OPENAL_SetVolume(channels[movewhooshsound], 128);
4449 OPENAL_SetPaused(channels[movewhooshsound], false);
4451 if(currentanimation==staggerbackhighanim){
4452 targetanimation=getIdle();
4454 if(currentanimation==staggerbackhardanim){
4455 targetanimation=getIdle();
4457 if(currentanimation==removeknifeanim){
4458 targetanimation=getIdle();
4460 if(currentanimation==crouchremoveknifeanim){
4461 targetanimation=getCrouch();
4463 if(currentanimation==backhandspringanim){
4464 targetanimation=getIdle();
4466 if(currentanimation==dodgebackanim){
4467 targetanimation=getIdle();
4469 if(currentanimation==drawleftanim){
4470 targetanimation=getIdle();
4472 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4473 targetanimation=getIdle();
4474 if(currentanimation==crouchdrawrightanim){
4475 targetanimation=getCrouch();
4477 if(weaponactive==-1)weaponactive=0;
4478 else if(weaponactive==0){
4482 buffer=weaponids[0];
4483 weaponids[0]=weaponids[1];
4484 weaponids[1]=buffer;
4488 if(weaponactive==-1){
4498 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4499 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4500 OPENAL_SetVolume(channels[knifesheathesound], 128);
4501 OPENAL_SetPaused(channels[knifesheathesound], false);
4503 if(weaponactive!=-1){
4513 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4514 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4515 OPENAL_SetVolume(channels[knifedrawsound], 128);
4516 OPENAL_SetPaused(channels[knifedrawsound], false);
4519 if(currentanimation==rollanim){
4520 targetanimation=getCrouch();
4525 if(targetanimation==walljumprightkickanim){
4528 if(targetanimation==walljumpleftkickanim){
4531 targetanimation=jumpdownanim;
4533 if(currentanimation==climbanim){
4534 targetanimation=getCrouch();
4537 if(!isnormal(coords.x))
4548 if(targetanimation==rabbitkickreversalanim){
4549 targetanimation=getCrouch();
4552 if(targetanimation==jumpreversalanim){
4553 targetanimation=getCrouch();
4556 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4557 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4559 float closestdist=-1;
4562 for(i=0;i<numplayers;i++){
4563 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4564 distance=findDistancefast(&player[i].coords,&coords);
4565 if(closestdist==-1||distance<closestdist){
4566 closestdist=distance;
4571 if(closestdist>0&&closest>=0&&closestdist<16){
4572 victim=&player[closest];
4573 targetanimation=walljumprightkickanim;
4575 XYZ rotatetarget=victim->coords-coords;
4576 Normalise(&rotatetarget);
4577 rotation=-asin(0-rotatetarget.x);
4579 if(rotatetarget.z<0)rotation=180-rotation;
4580 targettilt2=-asin(rotatetarget.y)*360/6.28;
4581 velocity=(victim->coords-coords)*4;
4586 if(targetanimation==walljumpbackanim){
4587 targetanimation=backflipanim;
4591 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4593 if(targetanimation==walljumprightanim){
4594 targetanimation=rightflipanim;
4598 velocity=DoRotation(facing,0,30,0)*-8;
4601 if(targetanimation==walljumpfrontanim){
4602 targetanimation=frontflipanim;
4604 //targetrotation-=180;
4609 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4611 if(targetanimation==walljumpleftanim){
4614 float closestdist=-1;
4617 for(i=0;i<numplayers;i++){
4618 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4619 distance=findDistancefast(&player[i].coords,&coords);
4620 if(closestdist==-1||distance<closestdist){
4621 closestdist=distance;
4626 if(closestdist>0&&closest>=0&&closestdist<16){
4627 victim=&player[closest];
4628 targetanimation=walljumpleftkickanim;
4630 XYZ rotatetarget=victim->coords-coords;
4631 Normalise(&rotatetarget);
4632 rotation=-asin(0-rotatetarget.x);
4634 if(rotatetarget.z<0)rotation=180-rotation;
4635 targettilt2=-asin(rotatetarget.y)*360/6.28;
4636 velocity=(victim->coords-coords)*4;
4641 if(targetanimation!=walljumpleftkickanim){
4642 targetanimation=leftflipanim;
4646 velocity=DoRotation(facing,0,-30,0)*-8;
4649 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4651 if(targetanimation==sneakattackanim){
4652 float ycoords=oldcoords.y;
4653 currentanimation=getCrouch();
4654 targetanimation=getCrouch();
4657 targetrotation+=180;
4662 targetheadrotation+=180;
4664 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4668 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4669 float ycoords=oldcoords.y;
4670 targetanimation=getIdle();
4672 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4676 if(currentanimation==knifefollowanim){
4677 targetanimation=getIdle();
4680 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4681 float ycoords=oldcoords.y;
4682 targetanimation=getStop();
4683 targetrotation+=180;
4688 targetheadrotation+=180;
4689 if(!isnormal(coords.x))
4691 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4692 oldcoords=coords+facing*.5;
4693 else if(currentanimation==sweepreversalanim)
4694 oldcoords=coords+facing*1.1;
4695 else if(currentanimation==upunchreversalanim){
4696 oldcoords=coords+facing*1.5;
4697 targetrotation+=180;
4699 targetheadrotation+=180;
4703 else if(currentanimation==knifeslashreversalanim){
4704 oldcoords=coords+facing*.5;
4707 targetheadrotation+=90;
4711 else if(currentanimation==staffspinhitreversalanim){
4712 targetrotation+=180;
4714 targetheadrotation+=180;
4718 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4719 else oldcoords.y=ycoords;
4720 currentoffset=coords-oldcoords;
4726 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4731 if(animation[targetanimation].attack==reversed){
4733 if(targetanimation==sweepreversedanim)targetrotation+=90;
4734 targetanimation=backhandspringanim;
4744 PlaySoundEx( landsound, samp[landsound], NULL, true);
4745 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4746 OPENAL_SetVolume(channels[landsound], 128);
4747 OPENAL_SetPaused(channels[landsound], false);
4749 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4750 targetanimation=rollanim;
4753 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4754 coords.y=oldcoords.y;
4756 if(currentanimation==knifeslashreversedanim){
4757 targetanimation=rollanim;
4762 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4763 coords.y=oldcoords.y;
4767 targetanimation=jumpdownanim;
4769 if(wasLanding())targetanimation=getIdle();
4770 if(wasLandhard())targetanimation=getIdle();
4771 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4772 targetanimation=getIdle();
4774 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4775 coords.y=oldcoords.y;
4776 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4777 targetoffset.y=coords.y;
4778 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4779 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4780 currentoffset.y-=(coords.y-targetoffset.y);
4781 coords.y=targetoffset.y;
4783 normalsupdatedelay=0;
4785 if(currentanimation==upunchanim){
4786 targetanimation=getStop();
4787 normalsupdatedelay=0;
4790 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4791 targetrotation=rotation;
4794 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4795 if(!hasstaff)DoDamage(35);
4798 rabbitkickragdoll=1;
4800 if(currentanimation==rabbitkickreversedanim){
4807 if(id!=0)SolidHitBonus();
4811 targetanimation=rollanim;
4813 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4817 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4823 if(currentanimation==jumpreversedanim){
4830 if(id!=0)SolidHitBonus();
4834 targetanimation=rollanim;
4836 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4841 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){
4842 targetanimation=getupfromfrontanim;
4845 else if(animation[currentanimation].attack==normalattack){
4846 targetanimation=getIdle();
4849 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4850 targetanimation=blockhighleftstrikeanim;
4852 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4853 targetanimation=getIdle();
4856 if(currentanimation==spinkickanim&&victim->skeleton.free){
4857 if(creature==rabbittype)targetanimation=fightidleanim;
4862 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4864 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4865 targetanimation=jumpdownanim;
4870 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4871 if(!isRun()||!wasRun()){
4872 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4873 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4874 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4875 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4877 if(isRun()&&wasRun()){
4880 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4881 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4884 else if(transspeed)target+=multiplier*transspeed*speed*2;
4886 if(!isRun()||!wasRun()){
4887 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4888 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4889 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4890 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4894 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4896 if(target>1){currentframe=targetframe; target=1;}
4898 rot=targetrot*target;
4899 rotation+=rot-oldrot;
4905 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4907 for(i=0;i<skeleton.num_joints;i++){
4908 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4911 skeleton.FindForwards();
4913 for(i=0;i<skeleton.num_muscles;i++){
4914 if(skeleton.muscles[i].visible)
4916 skeleton.FindRotationMuscle(i,targetanimation);
4919 for(i=0;i<skeleton.num_muscles;i++){
4920 if(skeleton.muscles[i].visible)
4922 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4923 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4924 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4929 for(i=0;i<skeleton.num_joints;i++){
4930 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4933 skeleton.FindForwards();
4935 for(i=0;i<skeleton.num_muscles;i++){
4936 if(skeleton.muscles[i].visible)
4938 skeleton.FindRotationMuscle(i,targetanimation);
4941 for(i=0;i<skeleton.num_muscles;i++){
4942 if(skeleton.muscles[i].visible)
4944 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4945 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4946 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4947 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4948 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4949 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4950 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4951 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4952 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4956 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4958 oldcurrentanimation=currentanimation;
4959 oldtargetanimation=targetanimation;
4960 oldtargetframe=targetframe;
4961 oldcurrentframe=currentframe;
4963 for(i=0;i<skeleton.num_joints;i++){
4964 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4965 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4967 offset=currentoffset*(1-target)+targetoffset*target;
4968 for(i=0;i<skeleton.num_muscles;i++){
4969 if(skeleton.muscles[i].visible)
4971 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4972 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4973 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4978 if(isLanding()&&landhard){
4979 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4980 if(id==0)camerashake+=.4;
4981 targetanimation=getLandhard();
4989 //skeleton.DoConstraints();
4992 void Person::DoStuff(){
4993 static XYZ terrainnormal;
4994 static XYZ flatfacing;
4995 static XYZ flatvelocity;
4996 static float flatvelspeed;
5000 static int bloodsize;
5001 static int startx,starty,endx,endy;
5002 static int texdetailint;
5003 static GLubyte color;
5004 static XYZ bloodvel;
5006 onfiredelay-=multiplier;
5007 if(onfiredelay<0&&onfire)
5015 crouchkeydowntime+=multiplier;
5016 if(!crouchkeydown)crouchkeydowntime=0;
5017 jumpkeydowntime+=multiplier;
5018 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
5020 if(hostile||damage>0||bloodloss>0)immobile=0;
5022 if(isIdle()||isRun())targetoffset=0;
5024 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
5026 if(id==0)blooddimamount-=multiplier*.3;
5027 speechdelay-=multiplier;
5028 texupdatedelay-=multiplier;
5029 interestdelay-=multiplier;
5030 flamedelay-=multiplier;
5031 parriedrecently-=multiplier;
5037 if(id==0)speed=1.1*speedmult;
5038 else speed=1.0*speedmult;
5039 if(!skeleton.free)rabbitkickragdoll=0;
5043 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
5044 if(id!=0&&creature==wolftype&&difficulty==2){
5046 if(aitype!=passivetype){
5048 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){
5052 if(scale<0.2)superruntoggle=0;
5053 if(targetanimation==wolfrunninganim&&!superruntoggle){
5054 targetanimation=getRun();
5057 /*static float toggledelay;
5058 toggledelay-=multiplier;
5061 if(Random()%3==0)superruntoggle=1-superruntoggle;
5064 if(weaponactive==-1&&num_weapons>0){
5065 if(weapons.type[weaponids[0]]==staff){
5072 /*if(aitype!=playercontrolled)*///deathbleeding=5;
5073 /*if(aitype!=playercontrolled)*/
5075 if(burnt>.6)burnt=.6;
5076 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
5078 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5089 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
5090 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
5094 while(flamedelay<0&&onfire){
5096 howmany=abs(Random()%(skeleton.num_joints));
5097 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
5098 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
5099 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
5100 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
5101 sprites.MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5104 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
5106 howmany=abs(Random()%(skeleton.num_joints));
5107 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
5108 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
5109 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
5110 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
5111 sprites.MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
5115 bleeding-=multiplier*.3;
5117 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5118 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
5122 if(neckspurtamount>0){
5123 neckspurtamount-=multiplier;
5124 neckspurtdelay-=multiplier*3;
5125 neckspurtparticledelay-=multiplier*3;
5126 if(neckspurtparticledelay<0&&neckspurtdelay>2){
5130 bloodvel.z=5*neckspurtamount;
5131 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
5134 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
5136 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
5137 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
5138 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);
5139 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);
5140 neckspurtparticledelay=.05;
5142 if(neckspurtdelay<0){
5147 if(deathbleeding>0&&dead!=2){
5148 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
5149 else bleeddelay-=5*multiplier/4;
5150 if(bleeddelay<0&&bloodtoggle){
5155 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
5156 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
5157 if(skeleton.free)sprites.MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
5158 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);
5162 bloodloss+=deathbleeding*40;
5165 bloodloss+=deathbleeding*multiplier*80;
5166 deathbleeding-=multiplier*1.6;
5167 //if(id==0)deathbleeding-=multiplier*.2;
5168 if(deathbleeding<0)deathbleeding=0;
5169 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
5170 if(weaponactive!=-1){
5171 weapons.owner[weaponids[0]]=-1;
5172 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5173 weapons.velocity[weaponids[0]].x+=.01;
5174 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5175 weapons.missed[weaponids[0]]=1;
5176 weapons.hitsomething[weaponids[0]]=0;
5177 weapons.freetime[weaponids[0]]=0;
5178 weapons.firstfree[weaponids[0]]=1;
5179 weapons.physics[weaponids[0]]=1;
5182 weaponids[0]=weaponids[num_weapons];
5183 if(weaponstuck==num_weapons)weaponstuck=0;
5186 for(i=0;i<numplayers;i++){
5187 player[i].wentforweapon=0;
5199 if(!dead&&creature==wolftype){
5205 if(targetanimation==knifefollowedanim&&!skeleton.free){
5206 for(i=0;i<skeleton.num_joints;i++){
5207 skeleton.joints[i].velocity=0;
5208 skeleton.joints[i].velocity.y=-2;
5211 if(id!=0&&unconscioustime>.1){
5219 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
5222 bloodsize=5-realtexdetail;
5226 texdetailint=realtexdetail;
5227 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5228 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5229 endx=startx+bloodsize;
5230 endy=starty+bloodsize;
5232 if(startx<0){startx=0;bleeding=0;}
5233 if(starty<0){starty=0;bleeding=0;}
5234 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
5235 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
5236 if(endx<startx)endx=startx;
5237 if(endy<starty)endy=starty;
5243 for(i=startx;i<endx;i++){
5244 for(j=starty;j<endy;j++){
5246 color=Random()%85+170;
5247 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
5248 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
5249 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
5254 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5255 DoMipmaps(0,startx,endx,starty,endy);
5259 bleedy-=4/realtexdetail;
5260 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
5261 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
5264 bleedx+=4*direction/realtexdetail;
5265 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
5266 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
5270 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
5271 righthandmorphness=targetrighthandmorphness;
5272 righthandmorphstart=righthandmorphend;
5274 else if(righthandmorphness>targetrighthandmorphness){
5275 righthandmorphness-=multiplier*4;
5277 else if(righthandmorphness<targetrighthandmorphness){
5278 righthandmorphness+=multiplier*4;
5281 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
5282 lefthandmorphness=targetlefthandmorphness;
5283 lefthandmorphstart=lefthandmorphend;
5285 else if(lefthandmorphness>targetlefthandmorphness){
5286 lefthandmorphness-=multiplier*4;
5288 else if(lefthandmorphness<targetlefthandmorphness){
5289 lefthandmorphness+=multiplier*4;
5292 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
5293 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
5294 tailmorphness=targettailmorphness;
5295 tailmorphstart=tailmorphend;
5297 else if(tailmorphness>targettailmorphness){
5298 tailmorphness-=multiplier*10;
5300 else if(tailmorphness<targettailmorphness){
5301 tailmorphness+=multiplier*10;
5305 if(creature==wolftype){
5306 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
5307 tailmorphness=targettailmorphness;
5308 tailmorphstart=tailmorphend;
5310 else if(tailmorphness>targettailmorphness){
5311 tailmorphness-=multiplier*2;
5313 else if(tailmorphness<targettailmorphness){
5314 tailmorphness+=multiplier*2;
5318 if(headmorphend==3||headmorphstart==3){
5319 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
5320 headmorphness=targetheadmorphness;
5321 headmorphstart=headmorphend;
5323 else if(headmorphness>targetheadmorphness){
5324 headmorphness-=multiplier*7;
5326 else if(headmorphness<targetheadmorphness){
5327 headmorphness+=multiplier*7;
5330 else if(headmorphend==5||headmorphstart==5){
5331 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
5332 headmorphness=targetheadmorphness;
5333 headmorphstart=headmorphend;
5335 else if(headmorphness>targetheadmorphness){
5336 headmorphness-=multiplier*10;
5338 else if(headmorphness<targetheadmorphness){
5339 headmorphness+=multiplier*10;
5343 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5344 headmorphness=targetheadmorphness;
5345 headmorphstart=headmorphend;
5347 else if(headmorphness>targetheadmorphness){
5348 headmorphness-=multiplier*4;
5350 else if(headmorphness<targetheadmorphness){
5351 headmorphness+=multiplier*4;
5355 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5356 chestmorphness=targetchestmorphness;
5357 chestmorphstart=chestmorphend;
5359 else if(chestmorphness>targetchestmorphness){
5360 chestmorphness-=multiplier;
5362 else if(chestmorphness<targetchestmorphness){
5363 chestmorphness+=multiplier;
5366 if(dead!=2&&howactive<=typesleeping){
5367 if(chestmorphstart==0&&chestmorphend==0){
5369 targetchestmorphness=1;
5372 if(chestmorphstart!=0&&chestmorphend!=0){
5374 targetchestmorphness=1;
5376 if(environment==snowyenvironment){
5379 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5380 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5381 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5382 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5383 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5384 sprites.MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5388 if(!dead&&howactive<typesleeping){
5389 blinkdelay-=multiplier*2;
5390 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5392 targetheadmorphness=1;
5394 blinkdelay=(float)(abs(Random()%40))/5;
5396 if(headmorphstart==3&&headmorphend==3){
5398 targetheadmorphness=1;
5403 twitchdelay-=multiplier*1.5;
5404 if(targetanimation!=hurtidleanim){
5405 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5407 targetheadmorphness=1;
5409 twitchdelay=(float)(abs(Random()%40))/5;
5411 if(headmorphstart==5&&headmorphend==5){
5413 targetheadmorphness=1;
5417 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5418 twitchdelay3-=multiplier*1;
5420 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5421 righthandmorphness=0;
5422 targetrighthandmorphness=1;
5423 righthandmorphend=1;
5424 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5426 if(righthandmorphstart==1&&righthandmorphend==1){
5427 righthandmorphness=0;
5428 targetrighthandmorphness=1;
5429 righthandmorphend=0;
5433 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5434 lefthandmorphness=0;
5435 targetlefthandmorphness=1;
5437 twitchdelay3=(float)(abs(Random()%40))/5;
5439 if(lefthandmorphstart==1&&lefthandmorphend==1){
5440 lefthandmorphness=0;
5441 targetlefthandmorphness=1;
5448 if(creature==rabbittype){
5449 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5450 else twitchdelay2-=multiplier*0.5;
5451 if(howactive<=typesleeping){
5452 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5454 targettailmorphness=1;
5456 twitchdelay2=(float)(abs(Random()%40))/5;
5458 if(tailmorphstart==1&&tailmorphend==1){
5460 targettailmorphness=1;
5463 if(tailmorphstart==2&&tailmorphend==2){
5465 targettailmorphness=1;
5472 if(creature==wolftype){
5473 twitchdelay2-=multiplier*1.5;
5475 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5477 targettailmorphness=1;
5482 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5484 targettailmorphness=1;
5488 if(twitchdelay2<=0){
5489 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5491 targettailmorphness=1;
5494 if(tailmorphstart==1&&tailmorphend==1){
5496 targettailmorphness=1;
5499 if(tailmorphstart==2&&tailmorphend==2){
5501 targettailmorphness=1;
5504 if(tailmorphstart==3&&tailmorphend==3){
5506 targettailmorphness=1;
5509 if(tailmorphstart==4&&tailmorphend==4){
5511 targettailmorphness=1;
5517 if(dead!=1)unconscioustime=0;
5519 if(dead==1||howactive==typesleeping){
5520 unconscioustime+=multiplier;
5521 //If unconscious, close eyes and mouth
5522 if(righthandmorphend!=0)righthandmorphness=0;
5523 righthandmorphend=0;
5524 targetrighthandmorphness=1;
5526 if(lefthandmorphend!=0)lefthandmorphness=0;
5528 targetlefthandmorphness=1;
5530 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5532 targetheadmorphness=1;
5536 if(howactive>typesleeping){
5539 if(bloodtoggle&&!bled){
5540 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5542 if(bloodtoggle&&!bled)
5543 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5544 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5545 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5549 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5554 if(dead==2||howactive>typesleeping){
5555 //If dead, open mouth and hands
5556 if(righthandmorphend!=0)righthandmorphness=0;
5557 righthandmorphend=0;
5558 targetrighthandmorphness=1;
5560 if(lefthandmorphend!=0)lefthandmorphness=0;
5562 targetlefthandmorphness=1;
5564 if(headmorphend!=2)headmorphness=0;
5566 targetheadmorphness=1;
5569 if(stunned>0&&!dead&&headmorphend!=2){
5570 if(headmorphend!=4)headmorphness=0;
5572 targetheadmorphness=1;
5575 if(damage>damagetolerance&&!dead){
5580 if(creature==wolftype){
5588 if(weaponactive!=-1){
5589 weapons.owner[weaponids[0]]=-1;
5590 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5591 weapons.velocity[weaponids[0]].x+=.01;
5592 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5593 weapons.missed[weaponids[0]]=1;
5594 weapons.hitsomething[weaponids[0]]=0;
5595 weapons.freetime[weaponids[0]]=0;
5596 weapons.firstfree[weaponids[0]]=1;
5597 weapons.physics[weaponids[0]]=1;
5600 weaponids[0]=weaponids[num_weapons];
5601 if(weaponstuck==num_weapons)weaponstuck=0;
5604 for(i=0;i<numplayers;i++){
5605 player[i].wentforweapon=0;
5611 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5619 if(bloodloss<damagetolerance)
5620 for(i=0;i<skeleton.num_joints;i++){
5621 skeleton.joints[i].velocity*=1.5;
5625 //if(dead)damage-=multiplier/4;
5626 if(!dead)damage-=multiplier*13;
5627 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5628 if(!dead)permanentdamage-=multiplier*4;
5629 if(isIdle()||isCrouch()){
5630 if(!dead)permanentdamage-=multiplier*4;
5631 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5633 if(damage<0)damage=0;
5634 if(permanentdamage<0)permanentdamage=0;
5635 if(superpermanentdamage<0)superpermanentdamage=0;
5636 if(permanentdamage<superpermanentdamage){
5637 permanentdamage=superpermanentdamage;
5639 if(damage<permanentdamage){
5640 damage=permanentdamage;
5642 if(dead==1&&damage<damagetolerance){
5646 for(i=0;i<skeleton.num_joints;i++){
5647 skeleton.joints[i].velocity=0;
5650 if(permanentdamage>damagetolerance&&dead!=2){
5653 if(weaponactive!=-1){
5654 weapons.owner[weaponids[0]]=-1;
5655 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5656 weapons.velocity[weaponids[0]].x+=.01;
5657 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5658 weapons.missed[weaponids[0]]=1;
5659 weapons.hitsomething[weaponids[0]]=0;
5660 weapons.freetime[weaponids[0]]=0;
5661 weapons.firstfree[weaponids[0]]=1;
5662 weapons.physics[weaponids[0]]=1;
5665 weaponids[0]=weaponids[num_weapons];
5666 if(weaponstuck==num_weapons)weaponstuck=0;
5669 for(i=0;i<numplayers;i++){
5670 player[i].wentforweapon=0;
5676 if(!dead&&creature==wolftype){
5682 if(id!=0&&unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance){
5687 if(id!=0&&unconscioustime>.1){
5703 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5704 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5705 OPENAL_SetVolume(channels[breaksound], 512);
5706 OPENAL_SetPaused(channels[breaksound], false);
5707 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5713 if(skeleton.free==1){
5714 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5717 //If knocked over, open hands and close mouth
5718 if(righthandmorphend!=0)righthandmorphness=0;
5719 righthandmorphend=0;
5720 targetrighthandmorphness=1;
5722 if(lefthandmorphend!=0)lefthandmorphness=0;
5724 targetlefthandmorphness=1;
5726 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5727 if(headmorphend!=0)headmorphness=0;
5729 targetheadmorphness=1;
5733 skeleton.DoGravity(&scale);
5735 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5736 if(id!=0&&damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1)){
5741 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5745 for(j=0;j<skeleton.num_joints;j++){
5746 average+=skeleton.joints[j].position;
5750 coords+=average*scale;
5751 for(j=0;j<skeleton.num_joints;j++){
5752 skeleton.joints[j].position-=average;
5754 average/=multiplier;
5756 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5758 for(i=0;i<skeleton.num_joints;i++){
5759 velocity+=skeleton.joints[i].velocity*scale;
5761 velocity/=skeleton.num_joints;
5763 if(!isnormal(velocity.x)&&velocity.x){
5776 if(findLength(&average)<10&&dead&&skeleton.free){
5777 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5778 if(skeleton.longdead>2000){
5779 if(skeleton.longdead>6000){
5780 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5785 if(dead==2&&bloodloss<damagetolerance){
5787 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5789 if(bloodtoggle&&!bled){
5790 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5792 if(bloodtoggle&&!bled)
5793 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5794 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5795 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5799 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5803 if(dead==2&&bloodloss>=damagetolerance){
5805 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5806 if(bleeding<=0)DoBlood(1,255);
5807 if(bloodtoggle&&!bled){
5808 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5810 if(bloodtoggle&&!bled)
5811 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5812 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5813 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5817 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5824 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5826 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5830 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5831 if(velocity.y<-30)canrecover=0;
5832 for(i=0;i<objects.numobjects;i++){
5833 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5834 colviewer=startpoint;
5836 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5844 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5845 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5846 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5847 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5849 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5850 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5851 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5853 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5854 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5855 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5857 Normalise(&terrainnormal);
5859 targetrotation=-asin(0-terrainnormal.x);
5860 targetrotation*=360/6.28;
5861 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5862 rotation=targetrotation;
5864 //if(skeleton.forward.y<0){
5867 //if(skeleton.forward.y>-.3){
5870 targetanimation=flipanim;
5871 crouchtogglekeydown=1;
5876 currentanimation=tempanim;
5879 //tilt2=targettilt2;
5881 //if(middle.y>0)targetoffset.y=middle.y+1;
5883 for(i=0;i<skeleton.num_joints;i++){
5884 tempanimation.position[i][0]=skeleton.joints[i].position;
5885 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5890 if(findLength(&average)<10&&!dead&&skeleton.free){
5891 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5892 if(skeleton.longdead>(damage+500)*1.5){
5893 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5899 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5900 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5901 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5902 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5904 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5905 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5906 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5908 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5909 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5910 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5912 Normalise(&terrainnormal);
5914 targetrotation=-asin(0-terrainnormal.x);
5915 targetrotation*=360/6.28;
5916 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5917 rotation=targetrotation;
5920 terrainnormal=terrain.getNormal(coords.x,coords.z);
5921 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5925 /*XYZ otherterrainnormal;
5926 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5927 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5928 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5929 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5932 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5936 if(skeleton.forward.y<0){
5937 targetanimation=getupfrombackanim;
5941 if(skeleton.forward.y>-.3){
5942 targetanimation=getupfromfrontanim;
5944 targetrotation+=180;
5950 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5951 targetanimation=rollanim;
5952 targetrotation=lookrotation;
5956 if(forwardkeydown)targetrotation+=45;
5957 if(backkeydown)targetrotation-=45;
5961 if(forwardkeydown)targetrotation-=45;
5962 if(backkeydown)targetrotation+=45;
5965 if ( !leftkeydown&&!rightkeydown)
5966 targetrotation+=180;
5968 targetrotation+=180;
5972 if(abs(targettilt2)>50)targettilt2=0;
5973 currentanimation=tempanim;
5978 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5980 for(i=0;i<skeleton.num_joints;i++){
5981 tempanimation.position[i][0]=skeleton.joints[i].position;
5982 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5989 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5990 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5993 tempvelocity=velocity;
5994 Normalise(&tempvelocity);
5995 targetrotation=-asin(0-tempvelocity.x);
5996 targetrotation*=360/6.28;
5997 if(velocity.z<0)targetrotation=180-targetrotation;
5998 //targetrotation+=180;
6001 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
6002 targetanimation=rollanim;
6006 targetanimation=backhandspringanim;
6007 targetrotation+=180;
6020 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6021 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6022 OPENAL_SetVolume(channels[movewhooshsound], 128);
6023 OPENAL_SetPaused(channels[movewhooshsound], false);
6025 currentanimation=targetanimation;
6026 currentframe=targetframe-1;
6031 rotation=targetrotation;
6038 if(skeleton.freefall==0)freefall=0;
6040 if(!isnormal(velocity.x)&&velocity.x){
6045 if(aitype!=passivetype||skeleton.free==1)
6046 if(findLengthfast(&velocity)>.1)
6047 for(i=0;i<objects.numobjects;i++){
6048 if(objects.type[i]==firetype)
6049 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){
6051 if(!objects.onfire[i]){
6054 gLoc[0]=objects.position[i].x;
6055 gLoc[1]=objects.position[i].y;
6056 gLoc[2]=objects.position[i].z;
6060 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
6061 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6062 OPENAL_SetVolume(channels[firestartsound], 256);
6063 OPENAL_SetPaused(channels[firestartsound], false);
6065 objects.onfire[i]=1;
6068 if(objects.onfire[i]){
6073 if(objects.type[i]==bushtype)
6074 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){
6076 if(!objects.onfire[i]){
6079 gLoc[0]=objects.position[i].x;
6080 gLoc[1]=objects.position[i].y;
6081 gLoc[2]=objects.position[i].z;
6085 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
6086 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6087 OPENAL_SetVolume(channels[firestartsound], 256);
6088 OPENAL_SetPaused(channels[firestartsound], false);
6090 objects.onfire[i]=1;
6094 if(objects.onfire[i]){
6098 if(objects.messedwith[i]<=0){
6110 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
6111 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
6112 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
6113 OPENAL_SetPaused(channels[bushrustle], false);
6116 envsound[numenvsounds]=coords;
6117 envsoundvol[numenvsounds]=4*findLength(&velocity);
6118 envsoundlife[numenvsounds]=.4;
6123 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6124 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6126 if(environment!=desertenvironment)
6127 for(j=0;j<howmany;j++){
6128 tempvel.x=float(abs(Random()%100)-50)/20;
6129 tempvel.y=float(abs(Random()%100)-50)/20;
6130 tempvel.z=float(abs(Random()%100)-50)/20;
6133 pos.x+=float(abs(Random()%100)-50)/200;
6134 pos.y+=float(abs(Random()%100)-50)/200;
6135 pos.z+=float(abs(Random()%100)-50)/200;
6136 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);
6137 sprites.special[sprites.numsprites-1]=1;
6139 howmany=findLength(&velocity)*4;
6141 if(environment==snowyenvironment)
6142 for(j=0;j<howmany;j++){
6143 tempvel.x=float(abs(Random()%100)-50)/20;
6144 tempvel.y=float(abs(Random()%100)-50)/20;
6145 tempvel.z=float(abs(Random()%100)-50)/20;
6148 pos.x+=float(abs(Random()%100)-50)/200;
6149 pos.y+=float(abs(Random()%100)-50)/200;
6150 pos.z+=float(abs(Random()%100)-50)/200;
6151 sprites.MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6152 sprites.special[sprites.numsprites-1]=2;
6155 objects.rotx[i]+=velocity.x*multiplier*6;
6156 objects.roty[i]+=velocity.z*multiplier*6;
6157 objects.messedwith[i]=.5;
6160 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
6161 if(objects.rotation2[i]==0)tempcoord=coords;
6163 tempcoord=coords-objects.position[i];
6164 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
6165 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
6166 tempcoord+=objects.position[i];
6168 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]){
6170 if(!objects.onfire[i]){
6173 gLoc[0]=objects.position[i].x;
6174 gLoc[1]=objects.position[i].y;
6175 gLoc[2]=objects.position[i].z;
6179 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
6180 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6181 OPENAL_SetVolume(channels[firestartsound], 256);
6182 OPENAL_SetPaused(channels[firestartsound], false);
6183 objects.onfire[i]=1;
6186 if(objects.messedwith[i]<=0){
6198 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
6199 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
6200 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
6201 OPENAL_SetPaused(channels[bushrustle], false);
6204 envsound[numenvsounds]=coords;
6205 envsoundvol[numenvsounds]=4*findLength(&velocity);
6206 envsoundlife[numenvsounds]=.4;
6211 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6212 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6214 if(environment!=desertenvironment)
6215 for(j=0;j<howmany;j++){
6216 tempvel.x=float(abs(Random()%100)-50)/20;
6217 tempvel.y=float(abs(Random()%100)-50)/20;
6218 tempvel.z=float(abs(Random()%100)-50)/20;
6222 pos.x+=float(abs(Random()%100)-50)/150;
6223 pos.y+=float(abs(Random()%100)-50)/150;
6224 pos.z+=float(abs(Random()%100)-50)/150;
6225 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);
6226 sprites.special[sprites.numsprites-1]=1;
6228 howmany=findLength(&velocity)*4;
6230 if(environment==snowyenvironment)
6231 for(j=0;j<howmany;j++){
6232 tempvel.x=float(abs(Random()%100)-50)/20;
6233 tempvel.y=float(abs(Random()%100)-50)/20;
6234 tempvel.z=float(abs(Random()%100)-50)/20;
6238 pos.x+=float(abs(Random()%100)-50)/150;
6239 pos.y+=float(abs(Random()%100)-50)/150;
6240 pos.z+=float(abs(Random()%100)-50)/150;
6241 sprites.MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6242 sprites.special[sprites.numsprites-1]=2;
6245 objects.messedwith[i]=.5;
6253 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
6255 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
6256 if(tutoriallevel==1&&id!=0)play=0;
6257 if(play&&aitype!=playercontrolled){
6269 if(creature==rabbittype){
6270 if(i==0)whichsound=rabbitchitter;
6271 if(i==1)whichsound=rabbitchitter2;
6273 if(creature==wolftype){
6274 if(i==0)whichsound=growlsound;
6275 if(i==1)whichsound=growl2sound;
6279 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
6280 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
6283 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
6284 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
6285 OPENAL_SetVolume(channels[whichsound], 512);
6286 OPENAL_SetPaused(channels[whichsound], false);
6290 if(targetanimation==staggerbackhighanim)staggerdelay=1;
6291 if(targetanimation==staggerbackhardanim)staggerdelay=1;
6292 staggerdelay-=multiplier;
6293 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
6294 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
6295 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
6296 targetanimation=getIdle();
6300 weaponmissdelay-=multiplier;
6301 highreversaldelay-=multiplier;
6302 lowreversaldelay-=multiplier;
6303 lastcollide-=multiplier;
6304 skiddelay-=multiplier;
6305 if(!isnormal(velocity.x)&&velocity.x){
6308 if(!isnormal(targettilt)&&targettilt){
6311 if(!isnormal(targettilt2)&&targettilt2){
6314 if(!isnormal(targetrotation)&&targetrotation){
6318 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
6319 //open hands and close mouth
6320 //if(targetanimation!=wolfidle){
6321 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6322 righthandmorphness=0;
6323 righthandmorphend=0;
6324 targetrighthandmorphness=1;
6327 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6328 lefthandmorphness=0;
6330 targetlefthandmorphness=1;
6334 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
6337 targetheadmorphness=1;
6341 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){
6342 //open hands and mouth
6343 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6344 righthandmorphness=0;
6345 righthandmorphend=0;
6346 targetrighthandmorphness=1;
6349 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6350 lefthandmorphness=0;
6352 targetlefthandmorphness=1;
6355 if(headmorphend!=1&&headmorphness==targetheadmorphness){
6358 targetheadmorphness=1;
6362 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
6363 //close hands and mouth
6364 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6365 righthandmorphness=0;
6366 righthandmorphend=1;
6367 targetrighthandmorphness=1;
6370 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6371 lefthandmorphness=0;
6373 targetlefthandmorphness=1;
6376 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6379 targetheadmorphness=1;
6383 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){
6384 //close hands and yell
6385 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6386 righthandmorphness=0;
6387 righthandmorphend=1;
6388 targetrighthandmorphness=1;
6391 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6392 lefthandmorphness=0;
6394 targetlefthandmorphness=1;
6397 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6400 targetheadmorphness=1;
6404 if(speechdelay>.25){
6405 if(headmorphend!=2)headmorphness=0;
6407 targetheadmorphness=1;
6413 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6414 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6418 if(!dead&&targetanimation!=hurtidleanim)
6419 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6420 if(headmorphend!=4||headmorphness==targetheadmorphness){
6423 targetheadmorphness=1;
6427 if(weaponactive!=-1){
6428 if(weapons.type[weaponids[weaponactive]]!=staff){
6429 righthandmorphstart=1;
6430 righthandmorphend=1;
6432 if(weapons.type[weaponids[weaponactive]]==staff){
6433 righthandmorphstart=2;
6434 righthandmorphend=2;
6436 targetrighthandmorphness=1;
6439 terrainnormal=terrain.getNormal(coords.x,coords.z);
6441 if(animation[targetanimation].attack!=reversal){
6442 if(!isnormal(coords.x))
6450 flatfacing=DoRotation(flatfacing,0,rotation,0);
6452 ReflectVector(&facing,terrainnormal);
6455 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6456 if(onterrain)targettilt2=-facing.y*20;
6460 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6461 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6462 flatvelocity=velocity;
6464 flatvelspeed=findLength(&flatvelocity);
6465 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6466 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6467 if(velocity.y<0)targettilt2*=-1;
6468 if(velocity.y<0)targettilt*=-1;
6469 if(targettilt>25)targettilt=25;
6470 if(targettilt<-25)targettilt=-25;
6473 if(targettilt2>45)targettilt2=45;
6474 if(targettilt2<-45)targettilt2=-45;
6475 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6476 else if(tilt2>targettilt2){
6477 tilt2-=multiplier*400;
6479 else if(tilt2<targettilt2){
6480 tilt2+=multiplier*400;
6482 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6483 if(tilt2>25)tilt2=25;
6484 if(tilt2<-25)tilt2=-25;
6487 if(!isnormal(targettilt)&&targettilt){
6490 if(!isnormal(targettilt2)&&targettilt2){
6495 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6496 if(targetanimation==rabbittackleanim){
6497 velocity+=facing*multiplier*speed*700*scale;
6498 velspeed=findLength(&velocity);
6499 if(velspeed>speed*65*scale){
6501 velspeed=speed*65*scale;
6504 velocity.y+=gravity*multiplier*20;
6505 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6506 velspeed=findLength(&velocity);
6507 velocity=flatfacing*velspeed;
6509 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6510 if(isRun()||targetanimation==rabbitkickanim){
6511 velocity+=facing*multiplier*speed*700*scale;
6512 velspeed=findLength(&velocity);
6513 if(velspeed>speed*45*scale){
6515 velspeed=speed*45*scale;
6518 velocity.y+=gravity*multiplier*20;
6519 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6520 velspeed=findLength(&velocity);
6521 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6522 velocity=flatfacing*velspeed;
6526 velocity+=facing*multiplier*speed*700*scale;
6527 velspeed=findLength(&velocity);
6528 if(creature==rabbittype){
6529 if(velspeed>speed*55*scale){
6531 velspeed=speed*55*scale;
6535 if(creature==wolftype){
6536 if(velspeed>speed*75*scale){
6538 velspeed=speed*75*scale;
6542 velocity.y+=gravity*multiplier*20;
6543 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6544 velspeed=findLength(&velocity);
6545 velocity=flatfacing*velspeed;
6548 /*if(creature==wolftype)
6550 velocity+=facing*multiplier*speed*700*scale;
6551 velspeed=findLength(&velocity);
6552 if(velspeed>speed*55*scale){
6554 velspeed=speed*55*scale;
6557 velocity.y+=gravity*multiplier*20;
6558 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6559 velspeed=findLength(&velocity);
6560 velocity=flatfacing*velspeed;
6563 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6564 velocity+=facing*multiplier*speed*700*scale;
6565 velspeed=findLength(&velocity);
6566 if(velspeed>speed*45*scale){
6568 velspeed=speed*45*scale;
6571 velocity.y+=gravity*multiplier*20;
6572 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6573 velspeed=findLength(&velocity);
6574 velocity=flatfacing*velspeed;
6578 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6579 velocity+=facing*multiplier*speed*700*scale;
6580 velspeed=findLength(&velocity);
6581 if(velspeed>speed*25*scale){
6583 velspeed=speed*25*scale;
6586 velocity.y+=gravity*multiplier*20;
6587 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6588 velspeed=findLength(&velocity);
6589 velocity=flatfacing*velspeed;
6592 if(targetanimation==sneakanim||targetanimation==walkanim){
6593 velocity+=facing*multiplier*speed*700*scale;
6594 velspeed=findLength(&velocity);
6595 if(velspeed>speed*12*scale){
6597 velspeed=speed*12*scale;
6600 velocity.y+=gravity*multiplier*20;
6601 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6602 velspeed=findLength(&velocity);
6603 velocity=flatfacing*velspeed;
6606 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6607 velocity+=facing*multiplier*speed*700*scale;
6608 velspeed=findLength(&velocity);
6609 if(velspeed>speed*2*scale){
6611 velspeed=speed*2*scale;
6614 velocity.y+=gravity*multiplier*20;
6615 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6616 velspeed=findLength(&velocity);
6617 velocity=flatfacing*velspeed;
6621 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6622 velocity-=facing*multiplier*speed*700*scale;
6623 velspeed=findLength(&velocity);
6624 if(velspeed>speed*2*scale){
6626 velspeed=speed*2*scale;
6629 velocity.y+=gravity*multiplier*20;
6630 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6631 velspeed=findLength(&velocity);
6632 velocity=flatfacing*velspeed*-1;
6635 if(targetanimation==fightsidestep){
6636 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6637 velspeed=findLength(&velocity);
6638 if(velspeed>speed*12*scale){
6640 velspeed=speed*12*scale;
6643 velocity.y+=gravity*multiplier*20;
6644 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6645 velspeed=findLength(&velocity);
6646 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6649 if(targetanimation==staggerbackhighanim){
6650 coords-=facing*multiplier*speed*16*scale;
6653 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6654 coords-=facing*multiplier*speed*20*scale;
6658 if(targetanimation==backhandspringanim){
6659 //coords-=facing*multiplier*50*scale;
6660 velocity+=facing*multiplier*speed*700*scale*-1;
6661 velspeed=findLength(&velocity);
6662 if(velspeed>speed*50*scale){
6664 velspeed=speed*50*scale;
6667 velocity.y+=gravity*multiplier*20;
6668 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6669 velspeed=findLength(&velocity);
6670 velocity=flatfacing*velspeed*-1;
6672 if(targetanimation==dodgebackanim){
6673 //coords-=facing*multiplier*50*scale;
6674 velocity+=facing*multiplier*speed*700*scale*-1;
6675 velspeed=findLength(&velocity);
6676 if(velspeed>speed*60*scale){
6678 velspeed=speed*60*scale;
6681 velocity.y+=gravity*multiplier*20;
6682 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6683 velspeed=findLength(&velocity);
6684 velocity=flatfacing*velspeed*-1;
6687 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6688 velspeed=findLength(&velocity);
6692 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6693 velocity.y+=gravity*multiplier;
6696 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6698 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6699 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6701 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6707 OPENAL_SetPaused(channels[whooshsound], true);
6708 OPENAL_SetVolume(channels[whooshsound], 0);
6711 if(targetanimation==jumpdownanim||isFlip()){
6712 if(isFlip())jumppower=-4;
6713 targetanimation=getLanding();
6722 PlaySoundEx( landsound, samp[landsound], NULL, true);
6723 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6724 OPENAL_SetVolume(channels[landsound], 128);
6725 OPENAL_SetPaused(channels[landsound], false);
6728 envsound[numenvsounds]=coords;
6729 envsoundvol[numenvsounds]=16;
6730 envsoundlife[numenvsounds]=.4;
6736 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6737 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6738 coords.y=terrain.getHeight(coords.x,coords.z);
6743 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)){
6744 velspeed=findLength(&velocity);
6746 if(velspeed<multiplier*300*scale){
6748 } else velocity-=velocity/velspeed*multiplier*300*scale;
6749 if(velspeed>5&&(isLanding()||isLandhard())){
6750 skiddingdelay+=multiplier;
6757 else skiddingdelay=0;
6761 velspeed=findLength(&velocity);
6763 if(velspeed<multiplier*600*scale){
6765 } else velocity-=velocity/velspeed*multiplier*600*scale;
6767 if(velspeed>5&&(isLanding()||isLandhard())){
6768 skiddingdelay+=multiplier;
6775 else skiddingdelay=0;
6778 if(skiddingdelay<0)skiddingdelay+=multiplier;
6779 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6789 if(!onterrain||environment==grassyenvironment){
6790 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6791 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6792 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6793 OPENAL_SetPaused(channels[skidsound], false);
6796 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6797 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6798 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6799 OPENAL_SetPaused(channels[snowskidsound], false);
6803 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6804 terrainnormal=victim->coords-coords;
6805 Normalise(&terrainnormal);
6806 targetrotation=-asin(0-terrainnormal.x);
6807 targetrotation*=360/6.28;
6808 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6809 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6812 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6813 targetrotation=victim->targetrotation;
6815 if(targetanimation==rabbittacklinganim){
6816 coords=victim->coords;
6819 skeleton.oldfree=skeleton.free;
6823 midterrain.x=terrain.size*terrain.scale/2;
6824 midterrain.z=terrain.size*terrain.scale/2;
6825 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6827 tempposit=coords-midterrain;
6829 Normalise(&tempposit);
6830 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6831 coords.x=tempposit.x+midterrain.x;
6832 coords.z=tempposit.z+midterrain.z;
6836 int Person::DrawSkeleton(){
6837 int oldplayerdetail;
6838 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6839 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6849 glAlphaFunc(GL_GREATER, 0.0001);
6851 float terrainheight;
6853 if(!isnormal(rotation))rotation=0;
6854 if(!isnormal(tilt))tilt=0;
6855 if(!isnormal(tilt2))tilt2=0;
6856 oldplayerdetail=playerdetail;
6858 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6861 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6864 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6867 if(id==0)playerdetail=1;
6868 if(playerdetail!=oldplayerdetail)updatedelay=0;
6869 if(playerdetail!=oldplayerdetail)normalsupdatedelay=0;
6870 static float updatedelaychange;
6871 static float morphness;
6872 static float framemult;
6874 skeleton.FindForwards();
6875 if(howactive==typesittingwall){
6876 skeleton.specialforward[1]=0;
6877 skeleton.specialforward[1].z=1;
6883 static int weaponattachmuscle;
6884 static int weaponrotatemuscle,weaponrotatemuscle2;
6885 static XYZ weaponpoint;
6886 static int start,endthing;
6887 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6888 if(!isSleeping()&&!isSitting()){
6889 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6890 XYZ point,newpoint,change,change2;
6891 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6892 heightleft=terrain.getHeight(point.x,point.z)+.04;
6894 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6895 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6896 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6897 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6898 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6900 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6901 heightright=terrain.getHeight(point.x,point.z)+.04;
6902 point.y=heightright;
6903 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6904 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6905 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6906 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6907 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6908 skeleton.DoConstraints(&coords,&scale);
6910 if(creature==wolftype){
6911 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6912 heightleft=terrain.getHeight(point.x,point.z)+.04;
6914 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6915 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6916 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6917 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6918 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6920 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6921 heightright=terrain.getHeight(point.x,point.z)+.04;
6922 point.y=heightright;
6923 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6924 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6925 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6926 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6927 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6928 skeleton.DoConstraints(&coords,&scale);
6931 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6932 XYZ point,newpoint,change,change2;
6933 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6934 heightleft=terrain.getHeight(point.x,point.z)+.04;
6936 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6937 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6938 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6939 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6940 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6942 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6943 heightright=terrain.getHeight(point.x,point.z)+.04;
6944 point.y=heightright;
6945 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6946 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6947 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6948 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6949 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6950 skeleton.DoConstraints(&coords,&scale);
6952 if(creature==wolftype){
6953 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6954 heightleft=terrain.getHeight(point.x,point.z)+.04;
6956 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6957 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6958 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6959 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6960 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6962 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6963 heightright=terrain.getHeight(point.x,point.z)+.04;
6964 point.y=heightright;
6965 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6966 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6967 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6968 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6969 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6970 skeleton.DoConstraints(&coords,&scale);
6974 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6975 XYZ point,newpoint,change,change2;
6976 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6977 heightleft=terrain.getHeight(point.x,point.z)+.04;
6979 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6980 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6981 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6982 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6983 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6985 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6986 heightright=terrain.getHeight(point.x,point.z)+.04;
6987 point.y=heightright;
6988 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6989 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6990 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6991 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6992 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6993 skeleton.DoConstraints(&coords,&scale);
6995 if(creature==wolftype){
6996 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6997 heightleft=terrain.getHeight(point.x,point.z)+.04;
6999 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
7000 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
7001 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
7002 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
7003 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
7005 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
7006 heightright=terrain.getHeight(point.x,point.z)+.04;
7007 point.y=heightright;
7008 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
7009 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
7010 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
7011 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
7012 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
7013 skeleton.DoConstraints(&coords,&scale);
7017 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();
7019 targetheadrotation=-targetrotation;
7020 targetheadrotation2=0;
7021 if(animation[targetanimation].attack==3)targetheadrotation+=180;
7023 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7024 skeleton.drawmodel.vertex[i]=0;
7025 skeleton.drawmodel.vertex[i].y=999;
7027 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
7028 skeleton.drawmodellow.vertex[i]=0;
7029 skeleton.drawmodellow.vertex[i].y=999;
7031 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
7032 skeleton.drawmodelclothes.vertex[i]=0;
7033 skeleton.drawmodelclothes.vertex[i].y=999;
7035 for(i=0;i<skeleton.num_muscles;i++){
7036 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
7040 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
7041 morphness=righthandmorphness;
7042 start=righthandmorphstart;
7043 endthing=righthandmorphend;
7045 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
7046 morphness=lefthandmorphness;
7047 start=lefthandmorphstart;
7048 endthing=lefthandmorphend;
7050 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
7051 morphness=headmorphness;
7052 start=headmorphstart;
7053 endthing=headmorphend;
7055 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)){
7056 morphness=chestmorphness;
7057 start=chestmorphstart;
7058 endthing=chestmorphend;
7060 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)){
7061 morphness=tailmorphness;
7062 start=tailmorphstart;
7063 endthing=tailmorphend;
7065 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
7066 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
7067 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7070 if(!skeleton.free)glRotatef(tilt2,1,0,0);
7071 if(!skeleton.free)glRotatef(tilt,0,0,1);
7074 glTranslatef(mid.x,mid.y,mid.z);
7076 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
7077 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
7079 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
7080 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
7082 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
7083 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
7085 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
7089 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
7093 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
7097 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
7102 if(playerdetail||skeleton.free==3)
7104 for(j=0;j<skeleton.muscles[i].numvertices;j++)
7106 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
7107 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
7108 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
7109 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
7110 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
7111 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
7112 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
7113 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7115 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7116 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,
7117 (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,
7118 (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);
7119 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)
7120 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,
7121 (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,
7122 (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);
7123 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)
7124 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,
7125 (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,
7126 (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);
7127 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7128 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,
7129 (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,
7130 (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);
7131 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7132 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
7133 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
7134 //if(!isnormal(scale))test=1;
7135 //if(isnormal(scale)){
7136 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
7137 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
7138 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
7146 if(!playerdetail||skeleton.free==3)
7148 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
7150 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
7151 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7153 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7154 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
7155 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
7156 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
7157 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)
7158 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
7159 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
7160 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
7161 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)
7162 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
7163 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
7164 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
7165 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7166 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
7167 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
7168 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
7170 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7171 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
7172 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
7173 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
7180 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
7181 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
7183 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7186 if(!skeleton.free)glRotatef(tilt2,1,0,0);
7187 if(!skeleton.free)glRotatef(tilt,0,0,1);
7188 glTranslatef(mid.x,mid.y,mid.z);
7189 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
7190 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
7192 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
7193 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
7195 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
7196 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
7198 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
7199 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7201 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7202 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
7203 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
7204 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
7205 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)
7206 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
7207 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
7208 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
7209 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)
7210 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
7211 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
7212 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
7213 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7214 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
7215 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
7216 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
7217 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7218 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
7219 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
7220 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
7225 updatedelay=1+(float)(Random()%100)/1000;
7227 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
7228 normalsupdatedelay=1;
7229 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
7230 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
7231 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
7235 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
7236 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
7237 if(skeleton.clothes){
7238 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
7243 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
7244 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
7245 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
7246 if(skeleton.free==1)updatedelaychange*=6;
7247 if(id==0)updatedelaychange*=8;
7248 updatedelay+=updatedelaychange;
7250 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7252 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7253 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7254 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
7255 if(!skeleton.free)glRotatef(rotation,0,1,0);
7258 glColor4f(.4,1,.4,1);
7259 glDisable(GL_LIGHTING);
7260 glDisable(GL_TEXTURE_2D);
7263 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7264 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
7270 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
7271 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);
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[1]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].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[2]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].z);
7276 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);
7282 terrainlight=terrain.getLighting(coords.x,coords.z);
7283 distance=findDistancefast(&viewer,&coords);
7284 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
7285 if(distance>1)distance=1;
7287 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
7288 if(terrainheight<1)terrainheight=1;
7289 if(terrainheight>1.7)terrainheight=1.7;
7292 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
7293 glDisable(GL_BLEND);
7294 glAlphaFunc(GL_GREATER, 0.0001);
7295 glEnable(GL_TEXTURE_2D);
7297 glDisable(GL_TEXTURE_2D);
7298 glColor4f(.7,.35,0,.5);
7300 glEnable(GL_LIGHTING);
7303 if(tutoriallevel&&id!=0){
7304 //glDisable(GL_TEXTURE_2D);
7305 glColor4f(.7,.7,.7,0.6);
7307 glEnable(GL_LIGHTING);
7309 if(canattack&&cananger)
7310 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7311 glDisable(GL_TEXTURE_2D);
7312 glColor4f(1,0,0,0.8);
7314 glMatrixMode(GL_TEXTURE);
7316 glTranslatef(0,-smoketex,0);
7317 glTranslatef(-smoketex,0,0);
7321 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(sprites.cloudimpacttexture);
7322 else skeleton.drawmodel.draw();
7326 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(sprites.cloudimpacttexture);
7327 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7330 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
7331 if(tutoriallevel&&id!=0){
7333 glMatrixMode(GL_MODELVIEW);
7334 glEnable(GL_TEXTURE_2D);
7335 glColor4f(.7,.7,.7,0.6);
7337 glEnable(GL_LIGHTING);
7339 if(canattack&&cananger)
7340 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7341 glDisable(GL_TEXTURE_2D);
7342 glColor4f(1,0,0,0.8);
7344 glMatrixMode(GL_TEXTURE);
7346 glTranslatef(0,-smoketex*.6,0);
7347 glTranslatef(smoketex*.6,0,0);
7350 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(sprites.cloudimpacttexture);
7351 else skeleton.drawmodel.draw();
7355 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(sprites.cloudimpacttexture);
7356 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7361 if(tutoriallevel&&id!=0){
7363 glMatrixMode(GL_MODELVIEW);
7364 glEnable(GL_TEXTURE_2D);
7366 if(skeleton.clothes){
7369 if(!immediate)skeleton.drawmodelclothes.draw();
7370 if(immediate)skeleton.drawmodelclothes.drawimmediate();
7377 for(k=0;k<num_weapons;k++){
7379 if(weaponactive==k){
7380 if(weapons.type[i]!=staff){
7381 for(j=0;j<skeleton.num_muscles;j++){
7382 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7383 weaponattachmuscle=j;
7386 for(j=0;j<skeleton.num_muscles;j++){
7387 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){
7388 weaponrotatemuscle=j;
7391 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7392 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7394 if(weapons.type[i]==staff){
7395 for(j=0;j<skeleton.num_muscles;j++){
7396 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7397 weaponattachmuscle=j;
7400 for(j=0;j<skeleton.num_muscles;j++){
7401 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){
7402 weaponrotatemuscle=j;
7405 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7406 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7407 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7408 XYZ tempnormthing,vec1,vec2;
7409 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7410 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7411 CrossProduct(&vec1,&vec2,&tempnormthing);
7412 Normalise(&tempnormthing);
7413 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);
7414 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7416 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7417 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7418 Normalise(&weaptargnorm);
7419 weaponpoint-=weaptargnorm*2;
7423 if(weaponactive!=k&&weaponstuck!=k){
7424 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;
7425 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;
7426 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;
7427 for(j=0;j<skeleton.num_muscles;j++){
7428 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){
7429 weaponrotatemuscle=j;
7434 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7435 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7436 for(j=0;j<skeleton.num_muscles;j++){
7437 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){
7438 weaponrotatemuscle=j;
7443 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;
7444 weapons.bigrotation[i]=rotation;
7445 weapons.bigtilt[i]=tilt;
7446 weapons.bigtilt2[i]=tilt2;
7449 weapons.position[i]=weaponpoint*scale+coords;
7450 weapons.bigrotation[i]=0;
7451 weapons.bigtilt[i]=0;
7452 weapons.bigtilt2[i]=0;
7454 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7455 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7456 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7457 if(weaponactive==k){
7458 if(weapons.type[i]==knife){
7459 weapons.smallrotation[i]=180;
7460 weapons.smallrotation2[i]=0;
7461 if(isCrouch()||wasCrouch()){
7462 weapons.smallrotation2[i]=20;
7464 if(targetanimation==hurtidleanim){
7465 weapons.smallrotation2[i]=50;
7467 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7468 XYZ temppoint1,temppoint2,tempforward;
7471 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7472 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7473 distance=findDistance(&temppoint1,&temppoint2);
7474 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7475 weapons.rotation2[i]*=360/6.28;
7478 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7479 weapons.rotation1[i]*=360/6.28;
7480 weapons.rotation3[i]=0;
7481 weapons.smallrotation[i]=-90;
7482 weapons.smallrotation2[i]=0;
7483 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7485 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7486 XYZ temppoint1,temppoint2,tempforward;
7489 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7490 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7491 distance=findDistance(&temppoint1,&temppoint2);
7492 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7493 weapons.rotation2[i]*=360/6.28;
7496 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7497 weapons.rotation1[i]*=360/6.28;
7498 weapons.rotation3[i]=0;
7499 weapons.smallrotation[i]=90;
7500 weapons.smallrotation2[i]=0;
7501 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7503 if(targetanimation==knifethrowanim){
7504 weapons.smallrotation[i]=90;
7505 //weapons.smallrotation2[i]=-90;
7506 weapons.smallrotation2[i]=0;
7507 weapons.rotation1[i]=0;
7508 weapons.rotation2[i]=0;
7509 weapons.rotation3[i]=0;
7511 if(targetanimation==knifesneakattackanim&&targetframe<5){
7512 weapons.smallrotation[i]=-90;
7513 weapons.rotation1[i]=0;
7514 weapons.rotation2[i]=0;
7515 weapons.rotation3[i]=0;
7518 if(weapons.type[i]==sword){
7519 weapons.smallrotation[i]=0;
7520 weapons.smallrotation2[i]=0;
7521 if(targetanimation==knifethrowanim){
7522 weapons.smallrotation[i]=-90;
7523 weapons.smallrotation2[i]=0;
7524 weapons.rotation1[i]=0;
7525 weapons.rotation2[i]=0;
7526 weapons.rotation3[i]=0;
7528 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)){
7529 XYZ temppoint1,temppoint2,tempforward;
7532 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7533 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7534 distance=findDistance(&temppoint1,&temppoint2);
7535 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7536 weapons.rotation2[i]*=360/6.28;
7539 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7540 weapons.rotation1[i]*=360/6.28;
7541 weapons.rotation3[i]=0;
7542 weapons.smallrotation[i]=90;
7543 weapons.smallrotation2[i]=0;
7544 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7547 if(weapons.type[i]==staff){
7548 weapons.smallrotation[i]=100;
7549 weapons.smallrotation2[i]=0;
7550 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7551 XYZ temppoint1,temppoint2,tempforward;
7554 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7555 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7556 distance=findDistance(&temppoint1,&temppoint2);
7557 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7558 weapons.rotation2[i]*=360/6.28;
7561 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7562 weapons.rotation1[i]*=360/6.28;
7563 weapons.rotation3[i]=0;
7564 weapons.smallrotation[i]=90;
7565 weapons.smallrotation2[i]=0;
7566 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7570 if(weaponactive!=k&&weaponstuck!=k){
7571 if(weapons.type[i]==knife){
7572 weapons.smallrotation[i]=-70;
7573 weapons.smallrotation2[i]=10;
7575 if(weapons.type[i]==sword){
7576 weapons.smallrotation[i]=-100;
7577 weapons.smallrotation2[i]=-8;
7579 if(weapons.type[i]==staff){
7580 weapons.smallrotation[i]=-100;
7581 weapons.smallrotation2[i]=-8;
7585 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7586 else weapons.smallrotation[i]=0;
7587 weapons.smallrotation2[i]=10;
7588 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7596 if(skeleton.free)calcrot=1;
7597 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7598 if(currentanimation!=targetanimation)calcrot=1;
7599 //if(id==0)calcrot=1;
7600 if(skeleton.free==2)calcrot=0;
7606 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7609 static float distance;
7610 static float olddistance;
7611 static int intersecting;
7612 static int firstintersecting;
7615 static XYZ start,end;
7616 static float slopethreshold=-.4;
7618 firstintersecting=-1;
7622 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7623 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7625 for (j=0;j<model->TriangleNum;j++){
7626 if(model->facenormals[j].y<=slopethreshold){
7628 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)));
7629 if(distance<radius){
7630 point=*p1-model->facenormals[j]*distance;
7631 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;
7632 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7633 &model->vertex[model->Triangles[j].vertex[1]],
7635 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7636 &model->vertex[model->Triangles[j].vertex[2]],
7638 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7639 &model->vertex[model->Triangles[j].vertex[2]],
7642 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7646 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)){
7647 p1->y=point.y+radius;
7648 if((targetanimation==jumpdownanim||isFlip())){
7649 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7651 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7657 OPENAL_SetPaused(channels[whooshsound], true);
7658 OPENAL_SetVolume(channels[whooshsound], 0);
7661 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7662 if(isFlip())jumppower=-4;
7663 targetanimation=getLanding();
7672 PlaySoundEx( landsound, samp[landsound], NULL, true);
7673 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7674 OPENAL_SetVolume(channels[landsound], 128);
7675 OPENAL_SetPaused(channels[landsound], false);
7678 envsound[numenvsounds]=coords;
7679 envsoundvol[numenvsounds]=16;
7680 envsoundlife[numenvsounds]=.4;
7688 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7691 for (j=0;j<model->TriangleNum;j++){
7692 if(model->facenormals[j].y>slopethreshold){
7696 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)));
7697 if(distance<radius*.5){
7698 point=start-model->facenormals[j]*distance;
7699 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;
7700 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,
7701 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7702 p1->x, p1->y, p1->z, radius/2);
7703 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,
7704 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7705 p1->x, p1->y, p1->z, radius/2);
7706 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,
7707 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7708 p1->x, p1->y, p1->z, radius/2);
7710 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7711 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7713 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7714 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7716 *p1+=model->facenormals[j]*(distance-radius*.5);
7719 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7723 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7725 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7727 return firstintersecting;
7737 currentanimation = 0;
7738 targetanimation = 0;
7739 oldcurrentframe = 0;
7741 oldcurrentanimation = 0;
7742 oldtargetanimation = 0;
7746 parriedrecently = 0;
7750 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7752 currentoffset = 0,targetoffset = 0,offset = 0;
7770 unconscioustime = 0;
7788 rabbitkickenabled = 0;
7797 damagetolerance = 0;
7799 permanentdamage = 0;
7800 superpermanentdamage = 0; lastcollide = 0;
7820 headrotation = 0,headrotation2 = 0;
7821 targetheadrotation = 0,targetheadrotation2 = 0;
7832 normalsupdatedelay = 0;
7837 forwardstogglekeydown = 0;
7842 jumptogglekeydown = 0;
7844 crouchtogglekeydown = 0;
7846 drawtogglekeydown = 0;
7848 throwtogglekeydown = 0;
7854 crouchkeydowntime = 0;
7855 jumpkeydowntime = 0;
7872 whichdirectiondelay = 0;
7873 avoidsomething = 0; avoidwhere = 0;
7881 lefthandmorphness = 0;
7882 righthandmorphness = 0;
7886 targetlefthandmorphness = 0;
7887 targetrighthandmorphness = 0;
7888 targetheadmorphness = 0;
7889 targetchestmorphness = 0;
7890 targettailmorphness = 0;
7891 lefthandmorphstart = 0,lefthandmorphend = 0;
7892 righthandmorphstart = 0,righthandmorphend = 0;
7893 headmorphstart = 0,headmorphend = 0;
7894 chestmorphstart = 0,chestmorphend = 0;
7895 tailmorphstart = 0,tailmorphend = 0;
7897 weaponmissdelay = 0;
7898 highreversaldelay = 0;
7899 lowreversaldelay = 0;
7906 //Skeleton skeleton;
7925 memset(clothes, 0, sizeof(clothes));
7926 memset(clothestintr, 0, sizeof(clothestintr));
7927 memset(clothestintg, 0, sizeof(clothestintg));
7928 memset(clothestintb, 0, sizeof(clothestintb));
7934 onfiredelay = 0; burnt = 0;
7938 updatestuffdelay = 0;
7944 memset(weaponids, 0, sizeof(weaponids));
7948 weaponstuckwhere = 0;
7953 memset(waypoints, 0, sizeof(waypoints));
7954 memset(waypointtype, 0, sizeof(waypointtype));
7957 hastempwaypoint = 0;
7963 finalfinaltarget = 0;
7965 finalpathfindpoint = 0;
7966 targetpathfindpoint = 0;
7967 lastpathfindpoint = 0;
7968 lastpathfindpoint2 = 0;
7969 lastpathfindpoint3 = 0;
7970 lastpathfindpoint4 = 0;
7981 runninghowlong = 0; lastoccluded = 0;
7987 neckspurtparticledelay = 0;
7988 neckspurtamount = 0;
7991 rabbitkickragdoll = 0;
7996 //Animation tempanimation;