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;
34 extern FRUSTUM frustum;
36 extern float realmultiplier;
38 extern float slomodelay;
39 extern bool cellophane;
40 extern float texdetail;
41 extern float realtexdetail;
42 extern GLubyte bloodText[512*512*3];
43 extern GLubyte wolfbloodText[512*512*3];
44 extern int bloodtoggle;
45 extern Objects objects;
47 extern bool autoslomo;
48 extern float camerashake;
50 extern float terraindetail;
51 extern float viewdistance;
52 extern float blackout;
53 extern int difficulty;
54 extern Weapons weapons;
56 extern float fadestart;
57 extern Person player[maxplayers];
58 extern int numplayers;
60 extern bool winfreeze;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
63 extern bool showpoints;
64 extern bool immediate;
66 extern bool tilt2weird;
67 extern bool tiltweird;
69 extern bool proportionweird;
70 extern bool vertexweird[6];
71 extern GLubyte texturearray[512*512*3];
72 extern XYZ envsound[30];
73 extern float envsoundvol[30];
74 extern float envsoundlife[30];
75 extern int numenvsounds;
77 extern float bonusvalue;
78 extern float bonustotal;
79 extern float bonustime;
80 extern int tutoriallevel;
81 extern float smoketex;
82 extern int tutorialstage;
83 extern bool reversaltrain;
84 extern bool canattack;
86 extern float damagedealt;
87 extern float damagetaken;
89 extern float hostiletime;
94 extern int numflipfail;
96 extern int numswordattack;
97 extern int numknifeattack;
98 extern int numunarmedattack;
99 extern int numescaped;
100 extern int numflipped;
101 extern int numwallflipped;
102 extern int numthrowkill;
103 extern int numafterkill;
104 extern int numreversals;
105 extern int numattacks;
106 extern int maxalarmed;
107 extern int indialogue;
109 extern bool gamestarted;
111 extern OPENAL_STREAM * strm[20];
112 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
113 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
115 void Person::CheckKick(){
119 float damagemult=1*power;
120 if(creature==wolftype)damagemult=2.5*power;
124 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
125 if(findDistancefast(&coords,&victim->coords)<1.2){
126 if(!victim->skeleton.free){
128 Normalise(&relative);
129 relative=coords+relative*1;
130 if(animation[victim->targetanimation].height!=lowheight){
135 gLoc[0]=victim->coords.x;
136 gLoc[1]=victim->coords.y;
137 gLoc[2]=victim->coords.z;
141 if(tutoriallevel!=1){
142 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
143 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
144 OPENAL_SetVolume(channels[heavyimpactsound], 128);
145 OPENAL_SetPaused(channels[heavyimpactsound], false);
150 Normalise(&relative);
151 for(i=0;i<victim->skeleton.num_joints;i++){
152 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
155 victim->DoDamage(100*damagemult/victim->protectionhigh);
156 if(id==0)camerashake+=.4;
160 targetanimation=backflipanim;
165 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
167 //if(victim->damage>victim->damagetolerance){
175 else if (victim->isCrouch()){
176 targetanimation=rabbitkickreversedanim;
177 currentanimation=rabbitkickreversedanim;
178 victim->currentanimation=rabbitkickreversalanim;
179 victim->targetanimation=rabbitkickreversalanim;
185 victim->oldcoords=victim->coords;
186 coords=victim->coords;
187 victim->targetrotation=targetrotation;
195 void Person::CatchFire(){
196 XYZ flatfacing,flatvelocity;
198 for(int i=0;i<10;i++){
199 howmany=abs(Random()%(skeleton.num_joints));
200 if(!skeleton.free)flatvelocity=velocity;
201 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
202 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
203 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
204 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
217 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
218 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
219 OPENAL_SetVolume(channels[firestartsound], 256);
220 OPENAL_SetPaused(channels[firestartsound], false);
225 //PlaySoundEx( firesound, samp[firesound], NULL, true);
226 PlayStreamEx( stream_firesound, strm[stream_firesound], NULL, true);
227 OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
228 OPENAL_SetVolume(channels[stream_firesound], 256);
229 OPENAL_SetPaused(channels[stream_firesound], false);
236 bool Person::isIdle(){
237 if(targetanimation==sleepanim||targetanimation==sitanim||targetanimation==talkidleanim||targetanimation==hurtidleanim||targetanimation==bounceidleanim||targetanimation==talkidleanim||targetanimation==fightidleanim||targetanimation==knifefightidleanim||targetanimation==swordfightidleanim||targetanimation==swordfightidlebothanim||targetanimation==fightsidestep||targetanimation==wolfidle)return 1;
241 bool Person::isSitting(){
242 if(targetanimation==sitanim)return 1;
243 if(targetanimation==sitwallanim)return 1;
247 bool Person::isSleeping(){
248 if(targetanimation==sleepanim)return 1;
249 if(targetanimation==dead1anim)return 1;
250 if(targetanimation==dead2anim)return 1;
251 if(targetanimation==dead3anim)return 1;
252 if(targetanimation==dead4anim)return 1;
256 bool Person::wasIdle(){
257 if(currentanimation==sleepanim||currentanimation==talkidleanim||currentanimation==sitanim||currentanimation==hurtidleanim||currentanimation==bounceidleanim||currentanimation==fightidleanim||currentanimation==swordfightidleanim||currentanimation==swordfightidlebothanim||currentanimation==knifefightidleanim||currentanimation==fightsidestep||currentanimation==wolfidle)return 1;
260 int Person::getIdle(){
261 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
262 if(hasvictim&&victim!=this/*||(id==0&&attackkeydown)*/)if(/*(id==0&&attackkeydown)||*/(!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers)){
263 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
264 if(creature==rabbittype)return fightidleanim;
265 if(creature==wolftype)return wolfidle;
267 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
268 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
269 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
270 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
271 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
273 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
275 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
276 if(howactive==typesitting)return sitanim;
277 if(howactive==typesittingwall)return sitwallanim;
278 if(howactive==typesleeping)return sleepanim;
279 if(howactive==typedead1)return dead1anim;
280 if(howactive==typedead2)return dead2anim;
281 if(howactive==typedead3)return dead3anim;
282 if(howactive==typedead4)return dead4anim;
283 if(creature==rabbittype)return bounceidleanim;
284 if(creature==wolftype)return wolfidle;
288 bool Person::isCrouch(){
289 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
294 bool Person::wasCrouch(){
295 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
298 int Person::getCrouch(){
299 if(creature==rabbittype)return crouchanim;
300 if(creature==wolftype)return wolfcrouchanim;
304 bool Person::isRun(){
305 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
310 bool Person::wasRun(){
311 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
314 int Person::getRun(){
315 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
316 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
318 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
319 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
323 bool Person::isStop(){
324 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
329 bool Person::wasStop(){
330 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
333 int Person::getStop(){
334 if(creature==rabbittype)return stopanim;
335 if(creature==wolftype)return wolfstopanim;
340 bool Person::isLanding(){
341 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
346 bool Person::wasLanding(){
347 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
350 int Person::getLanding(){
351 if(creature==rabbittype)return landanim;
352 if(creature==wolftype)return wolflandanim;
357 bool Person::isLandhard(){
358 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
363 bool Person::wasLandhard(){
364 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
367 int Person::getLandhard(){
368 if(creature==rabbittype)return landhardanim;
369 if(creature==wolftype)return wolflandhardanim;
374 bool Person::isFlip(){
375 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
379 bool Person::wasFlip(){
380 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
384 bool Person::isWallJump(){
385 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
389 void SolidHitBonus();
390 void SolidHitBonus(){
391 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
396 else if(bonustime<1.5&&bonus==threexcombo){
401 else if(bonustime<1.5&&bonus==twoxcombo){
406 else if(bonustime<1.5&&bonus==solidhit){
418 void Person::DoBlood(float howmuch,int which){
419 static int bleedxint,bleedyint;
421 //if(howmuch&&id==0)blooddimamount=1;
422 if(bloodtoggle&&tutoriallevel!=1){
423 if(bleeding<=0&&spurt){
425 for(int i=0;i<3;i++){
429 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
432 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
434 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
435 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
437 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
438 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
441 Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
442 Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
446 for(int i=0;i<3;i++){
450 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
451 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
454 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
455 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
459 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
461 Sprite::MakeSprite(splintersprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
463 Sprite::setLastSpriteSpecial(3);
468 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
471 int texdetailint=realtexdetail;
472 if(creature==rabbittype)
473 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){
474 bleedxint=abs(Random()%512);
475 bleedyint=abs(Random()%512);
477 if(creature==wolftype)
478 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){
479 bleedxint=abs(Random()%512);
480 bleedyint=abs(Random()%512);
484 bleedy/=realtexdetail;
485 bleedx/=realtexdetail;
486 direction=abs(Random()%2)*2-1;
490 if(bleeding>2)bleeding=2;
493 void Person::DoBloodBig(float howmuch,int which){
494 static int bleedxint,bleedyint,i,j;
496 if(howmuch&&id==0)blooddimamount=1;
498 if(tutoriallevel!=1||id==0)
499 if(aitype!=playercontrolled&&howmuch>0){
510 if(creature==wolftype){
511 int i=abs(Random()%2);
512 if(i==0)whichsound=snarlsound;
513 if(i==1)whichsound=snarl2sound;
514 envsound[numenvsounds]=coords;
515 envsoundvol[numenvsounds]=16;
516 envsoundlife[numenvsounds]=.4;
519 if(creature==rabbittype){
520 int i=abs(Random()%2);
521 if(i==0)whichsound=rabbitpainsound;
522 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
523 envsound[numenvsounds]=coords;
524 envsoundvol[numenvsounds]=16;
525 envsoundlife[numenvsounds]=.4;
527 //if(i==2)whichsound=rabbitpain2sound;
531 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
532 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
533 OPENAL_SetVolume(channels[whichsound], 512);
534 OPENAL_SetPaused(channels[whichsound], false);
538 if(id==0&&howmuch>0){
546 if(bloodtoggle&&decals&&tutoriallevel!=1){
547 if(bleeding<=0&&spurt){
549 for(int i=0;i<3;i++){
553 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
556 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
558 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
559 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
561 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
562 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
565 Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
566 Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
570 int offsetx=0,offsety=0;
573 offsetx=abs(Random()%60);
575 if(which==190||which==185){
577 offsetx=abs(Random()%100)-20;
587 if(which==220||which==215){
588 //offsety=Random()%20;
590 //offsetx=abs(Random()%80);
599 if(creature==rabbittype)
602 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
603 if(i<startx)startx=i;
604 if(j<starty)starty=j;
610 if(creature==wolftype)
613 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
614 if(i<startx)startx=i;
615 if(j<starty)starty=j;
627 if(startx<0)startx=0;
628 if(starty<0)starty=0;
629 if(endx>512-1)endx=512-1;
630 if(endy>512-1)endy=512-1;
631 if(endx<startx)endx=startx;
632 if(endy<starty)endy=starty;
634 startx/=realtexdetail;
635 starty/=realtexdetail;
639 int texdetailint=realtexdetail;
641 if(creature==rabbittype)
642 for(i=startx;i<endx;i++){
643 for(j=starty;j<endy;j++){
644 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){
645 color=Random()%85+170;
646 where=i*skeleton.skinsize*3+j*3;
647 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
648 skeleton.skinText[where+1]=0;
649 skeleton.skinText[where+2]=0;
653 if(creature==wolftype)
654 for(i=startx;i<endx;i++){
655 for(j=starty;j<endy;j++){
656 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){
657 color=Random()%85+170;
658 where=i*skeleton.skinsize*3+j*3;
659 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
660 skeleton.skinText[where+1]=0;
661 skeleton.skinText[where+2]=0;
665 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
666 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
667 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
671 if(creature==rabbittype)
672 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){
673 bleedxint=abs(Random()%512);
674 bleedyint=abs(Random()%512);
676 if(creature==wolftype)
677 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){
678 bleedxint=abs(Random()%512);
679 bleedyint=abs(Random()%512);
681 bleedy=bleedxint+offsetx;
682 bleedx=bleedyint+offsety;
683 bleedy/=realtexdetail;
684 bleedx/=realtexdetail;
685 if(bleedx<0)bleedx=0;
686 if(bleedy<0)bleedy=0;
687 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
688 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
689 direction=abs(Random()%2)*2-1;
692 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
693 deathbleeding+=bleeding;
694 bloodloss+=bleeding*3;
696 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
697 if(abs(Random()%2)==0){aitype=gethelptype;
700 else aitype=attacktypecutoff;
703 if(bleeding>2)bleeding=2;
706 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
707 static int bleedxint,bleedyint,i,j;
709 static XYZ startpoint,endpoint,colpoint,movepoint;
710 static float rotationpoint;
712 static XYZ p1,p2,p3,p0;
716 float coordsx,coordsy;
719 if(bloodtoggle&&decals&&tutoriallevel!=1){
721 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
729 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
732 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
733 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
734 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
736 CrossProduct(p2-p1,p3-p1,&N);
737 CrossProduct(p0-p1,p3-p1,&temp);
738 s = dotproduct(&temp,&N)/findLength(&N);
739 CrossProduct(p2-p1,p1-p0,&temp);
740 t = dotproduct(&temp,&N)/findLength(&N);
743 bary.x=findDistancefast(&p0,&p1);
744 bary.y=findDistancefast(&p0,&p2);
745 bary.z=findDistancefast(&p0,&p3);
747 total=bary.x+bary.y+bary.z;
756 total=bary.x+bary.y+bary.z;
762 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
763 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
764 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
765 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
766 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
767 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
768 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;
769 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;
771 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
772 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
774 if(bleeding<=0&&spurt){
776 for(int i=0;i<3;i++){
780 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
783 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
785 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
786 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
788 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
789 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
792 Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
793 Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
797 int offsetx=0,offsety=0;
800 offsetx=abs(Random()%120);
802 if(which==220||which==215){
804 offsetx=abs(Random()%80);
807 offsetx=(1+coordsy)*512-291;
808 offsety=coordsx*512-437;
815 if(creature==rabbittype)
818 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
819 if(i<startx)startx=i;
820 if(j<starty)starty=j;
826 if(creature==wolftype)
829 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
830 if(i<startx)startx=i;
831 if(j<starty)starty=j;
842 if(startx<0)startx=0;
843 if(starty<0)starty=0;
844 if(endx>512-1)endx=512-1;
845 if(endy>512-1)endy=512-1;
846 if(endx<startx)endx=startx;
847 if(endy<starty)endy=starty;
849 startx/=realtexdetail;
850 starty/=realtexdetail;
854 int texdetailint=realtexdetail;
856 if(creature==rabbittype)
857 for(i=startx;i<endx;i++){
858 for(j=starty;j<endy;j++){
859 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){
860 color=Random()%85+170;
861 where=i*skeleton.skinsize*3+j*3;
862 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
863 skeleton.skinText[where+1]=0;
864 skeleton.skinText[where+2]=0;
866 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){
867 color=Random()%85+170;
868 where=i*skeleton.skinsize*3+j*3;
869 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
870 skeleton.skinText[where+1]=0;
871 skeleton.skinText[where+2]=0;
875 if(creature==wolftype)
876 for(i=startx;i<endx;i++){
877 for(j=starty;j<endy;j++){
878 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){
879 color=Random()%85+170;
880 where=i*skeleton.skinsize*3+j*3;
881 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
882 skeleton.skinText[where+1]=0;
883 skeleton.skinText[where+2]=0;
885 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){
886 color=Random()%85+170;
887 where=i*skeleton.skinsize*3+j*3;
888 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
889 skeleton.skinText[where+1]=0;
890 skeleton.skinText[where+2]=0;
894 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
895 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
896 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
898 bleedy=(1+coordsy)*512;
900 bleedy/=realtexdetail;
901 bleedx/=realtexdetail;
902 if(bleedx<0)bleedx=0;
903 if(bleedy<0)bleedy=0;
904 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
905 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
906 direction=abs(Random()%2)*2-1;
908 if(whichtri==-1)return 0;
910 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
911 deathbleeding+=bleeding;
912 bloodloss+=bleeding*3;
914 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
915 if(abs(Random()%2)==0){aitype=gethelptype;
918 else aitype=attacktypecutoff;
921 if(bleeding>2)bleeding=2;
926 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
929 static int bytesPerPixel=3;
930 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
931 static int newstartx,newstarty,newendx,newendy;
932 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
934 static float sizemult;
936 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
937 texture[i]=skeleton.skinText[i];
940 if((!osx||howmanylevels)){
942 if(startx<0)startx=0;
943 if(starty<0)starty=0;
944 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
945 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
946 if((endx>startx&&endy>starty)||howmanylevels){
953 for(i=startx;i<endx;i++){
954 for(j=starty;j<endy;j++){
955 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
956 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
957 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
961 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
964 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
965 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
966 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
969 newsize=skeleton.skinsize;
972 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
974 /*for(j=1;j<=howmanylevels;j++){
975 if(j==1)texpointer=&skeleton.skinText[0];
976 else texpointer=&texture[0];
978 totalsize=int( newsize*newsize*bytesPerPixel);
979 rowsize=int( newsize*bytesPerPixel );
980 bigstep=bytesPerPixel*newsize*2;
981 smallstep=bytesPerPixel*2;
987 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
994 void Person::Reverse(){
995 if(victim->aitype==playercontrolled||hostiletime>1)
996 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
997 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
998 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
999 if(targetanimation==sweepanim){
1000 targetanimation=sweepreversedanim;
1001 currentanimation=sweepreversedanim;
1002 victim->currentanimation=sweepreversalanim;
1003 victim->targetanimation=sweepreversalanim;
1005 if(targetanimation==spinkickanim){
1006 targetanimation=spinkickreversedanim;
1007 currentanimation=spinkickreversedanim;
1008 victim->currentanimation=spinkickreversalanim;
1009 victim->targetanimation=spinkickreversalanim;
1011 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
1012 if(targetanimation==rabbittacklinganim){
1015 victim->currentframe=6;
1016 victim->targetframe=7;
1018 targetanimation=upunchreversedanim;
1019 currentanimation=upunchreversedanim;
1020 victim->currentanimation=upunchreversalanim;
1021 victim->targetanimation=upunchreversalanim;
1023 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1024 if(victim->weaponactive!=-1){
1025 victim->throwtogglekeydown=1;
1026 weapons.owner[victim->weaponids[0]]=-1;
1027 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1028 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1029 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1030 weapons.missed[victim->weaponids[0]]=1;
1031 weapons.freetime[victim->weaponids[0]]=0;
1032 weapons.firstfree[victim->weaponids[0]]=1;
1033 weapons.physics[victim->weaponids[0]]=1;
1034 victim->num_weapons--;
1035 if(victim->num_weapons){
1036 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1037 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1040 victim->weaponactive=-1;
1041 for(int j=0;j<numplayers;j++){
1042 player[j].wentforweapon=0;
1046 targetanimation=staffhitreversedanim;
1047 currentanimation=staffhitreversedanim;
1048 victim->currentanimation=staffhitreversalanim;
1049 victim->targetanimation=staffhitreversalanim;
1051 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1052 if(victim->weaponactive!=-1){
1053 victim->throwtogglekeydown=1;
1054 weapons.owner[victim->weaponids[0]]=-1;
1055 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1056 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1057 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1058 weapons.missed[victim->weaponids[0]]=1;
1059 weapons.freetime[victim->weaponids[0]]=0;
1060 weapons.firstfree[victim->weaponids[0]]=1;
1061 weapons.physics[victim->weaponids[0]]=1;
1062 victim->num_weapons--;
1063 if(victim->num_weapons){
1064 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1065 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1068 victim->weaponactive=-1;
1069 for(int j=0;j<numplayers;j++){
1070 player[j].wentforweapon=0;
1073 targetanimation=staffspinhitreversedanim;
1074 currentanimation=staffspinhitreversedanim;
1075 victim->currentanimation=staffspinhitreversalanim;
1076 victim->targetanimation=staffspinhitreversalanim;
1078 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1079 if(victim->weaponactive!=-1){
1080 victim->throwtogglekeydown=1;
1081 weapons.owner[victim->weaponids[0]]=-1;
1082 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1083 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1084 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1085 weapons.missed[victim->weaponids[0]]=1;
1086 weapons.freetime[victim->weaponids[0]]=0;
1087 weapons.firstfree[victim->weaponids[0]]=1;
1088 weapons.physics[victim->weaponids[0]]=1;
1089 victim->num_weapons--;
1090 if(victim->num_weapons){
1091 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1092 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1095 victim->weaponactive=-1;
1096 for(int j=0;j<numplayers;j++){
1097 player[j].wentforweapon=0;
1100 targetanimation=swordslashreversedanim;
1101 currentanimation=swordslashreversedanim;
1102 victim->currentanimation=swordslashreversalanim;
1103 victim->targetanimation=swordslashreversalanim;
1105 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1106 if(victim->weaponactive!=-1){
1107 victim->throwtogglekeydown=1;
1108 weapons.owner[victim->weaponids[0]]=-1;
1109 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1110 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1111 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1112 weapons.missed[victim->weaponids[0]]=1;
1113 weapons.freetime[victim->weaponids[0]]=0;
1114 weapons.firstfree[victim->weaponids[0]]=1;
1115 weapons.physics[victim->weaponids[0]]=1;
1116 victim->num_weapons--;
1117 if(victim->num_weapons){
1118 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1119 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1122 victim->weaponactive=-1;
1123 for(int j=0;j<numplayers;j++){
1124 player[j].wentforweapon=0;
1127 targetanimation=knifeslashreversedanim;
1128 currentanimation=knifeslashreversedanim;
1129 victim->currentanimation=knifeslashreversalanim;
1130 victim->targetanimation=knifeslashreversalanim;
1132 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1133 victim->targettilt2=targettilt2;
1134 victim->currentframe=currentframe;
1135 victim->targetframe=targetframe;
1136 victim->target=target;
1138 victim->oldcoords=victim->coords;
1139 victim->coords=coords;
1140 victim->targetrotation=targetrotation;
1141 victim->rotation=targetrotation;
1142 victim->victim=this;
1144 if(targetanimation==winduppunchanim){
1145 targetanimation=winduppunchblockedanim;
1146 victim->targetanimation=blockhighleftanim;
1147 victim->targetframe=1;
1149 victim->victim=this;
1150 victim->targetrotation=targetrotation+180;
1152 if(targetanimation==wolfslapanim){
1153 targetanimation=winduppunchblockedanim;
1154 victim->targetanimation=blockhighleftanim;
1155 victim->targetframe=1;
1157 victim->victim=this;
1158 victim->targetrotation=targetrotation+180;
1160 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1161 targetanimation=swordslashparriedanim;
1163 victim->parriedrecently=0;
1164 victim->targetanimation=swordslashparryanim;
1165 victim->targetframe=1;
1167 victim->victim=this;
1168 victim->targetrotation=targetrotation+180;
1170 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1173 gLoc[0]=victim->coords.x;
1174 gLoc[1]=victim->coords.y;
1175 gLoc[2]=victim->coords.z;
1179 if(victim->weaponactive!=-1){
1180 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1181 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1182 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1184 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1185 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1186 OPENAL_SetVolume(channels[swordstaffsound], 512);
1187 OPENAL_SetPaused(channels[swordstaffsound], false);
1190 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1191 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1192 OPENAL_SetVolume(channels[metalhitsound], 512);
1193 OPENAL_SetPaused(channels[metalhitsound], false);
1197 victim->Puff(righthand);
1199 victim->targetframe=0;
1200 victim->targetanimation=staggerbackhighanim;
1201 victim->targetrotation=targetrotation+180;
1203 weapons.owner[victim->weaponids[0]]=-1;
1204 aim=DoRotation(facing,0,90,0)*21;
1206 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1207 weapons.tipvelocity[victim->weaponids[0]]=aim;
1208 weapons.missed[victim->weaponids[0]]=1;
1209 weapons.hitsomething[victim->weaponids[0]]=0;
1210 weapons.freetime[victim->weaponids[0]]=0;
1211 weapons.firstfree[victim->weaponids[0]]=1;
1212 weapons.physics[victim->weaponids[0]]=1;
1213 victim->num_weapons--;
1214 if(victim->num_weapons){
1215 victim->weaponids[0]=victim->weaponids[num_weapons];
1216 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1218 victim->weaponactive=-1;
1219 for(int i=0;i<numplayers;i++){
1220 player[i].wentforweapon=0;
1227 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1228 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1229 OPENAL_SetVolume(channels[metalhitsound], 512);
1230 OPENAL_SetPaused(channels[metalhitsound], false);*/
1233 if(abs(Random()%20)==0){
1242 if(weaponactive!=-1){
1243 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1244 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1245 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1247 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1248 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1249 OPENAL_SetVolume(channels[swordstaffsound], 512);
1250 OPENAL_SetPaused(channels[swordstaffsound], false);
1253 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1254 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1255 OPENAL_SetVolume(channels[metalhitsound], 512);
1256 OPENAL_SetPaused(channels[metalhitsound], false);
1264 targetanimation=staggerbackhighanim;
1265 targetrotation=targetrotation+180;
1267 weapons.owner[weaponids[0]]=-1;
1268 aim=DoRotation(facing,0,90,0)*21;
1270 weapons.velocity[weaponids[0]]=aim*-.2;
1271 weapons.tipvelocity[weaponids[0]]=aim;
1272 weapons.hitsomething[weaponids[0]]=0;
1273 weapons.missed[weaponids[0]]=1;
1274 weapons.freetime[weaponids[0]]=0;
1275 weapons.firstfree[weaponids[0]]=1;
1276 weapons.physics[weaponids[0]]=1;
1279 weaponids[0]=weaponids[num_weapons];
1280 if(weaponstuck==num_weapons)weaponstuck=0;
1283 for(int i=0;i<numplayers;i++){
1284 player[i].wentforweapon=0;
1288 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1289 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1290 OPENAL_SetVolume(channels[metalhitsound], 512);
1291 OPENAL_SetPaused(channels[metalhitsound], false);*/
1295 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1296 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1297 //victim->targetanimation=sweepanim;
1298 victim->targetanimation=dodgebackanim;
1299 victim->targetframe=0;
1301 //victim->velocity=0;
1304 rotatetarget=coords-victim->coords;
1305 Normalise(&rotatetarget);
1306 victim->targetrotation=-asin(0-rotatetarget.x);
1307 victim->targetrotation*=360/6.28;
1308 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1310 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1312 victim->lastattack3=victim->lastattack2;
1313 victim->lastattack2=victim->lastattack;
1314 victim->lastattack=victim->targetanimation;
1318 victim->targetanimation=sweepanim;
1319 victim->targetframe=0;
1323 rotatetarget=coords-victim->coords;
1324 Normalise(&rotatetarget);
1325 victim->targetrotation=-asin(0-rotatetarget.x);
1326 victim->targetrotation*=360/6.28;
1327 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1329 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1331 victim->lastattack3=victim->lastattack2;
1332 victim->lastattack2=victim->lastattack;
1333 victim->lastattack=victim->targetanimation;
1340 if(aitype!=playercontrolled)feint=0;
1341 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1342 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1343 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1345 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1349 void Person::DoDamage(float howmuch){
1350 if(tutoriallevel!=1)damage+=howmuch/power;
1351 if(id!=0)damagedealt+=howmuch/power;
1352 if(id==0)damagetaken+=howmuch/power;
1354 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1355 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1356 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1357 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1358 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1360 if(id==0)camerashake+=howmuch/100;
1361 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1362 if(blackout>1)blackout=1;
1364 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1365 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1366 if(abs(Random()%2)==0){aitype=gethelptype;
1369 else aitype=attacktypecutoff;
1373 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1376 for(int i=0;i<skeleton.num_joints; i++){
1377 if(!skeleton.free)flatvelocity2=velocity;
1378 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1379 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1380 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1381 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1382 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1383 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1384 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1385 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1386 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1397 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1398 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1399 OPENAL_SetVolume(channels[splattersound], 256);
1400 OPENAL_SetPaused(channels[splattersound], false);
1409 if(!dead&&creature==wolftype){
1418 if(tutoriallevel!=1||id==0)
1419 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1430 if(creature==wolftype){
1431 int i=abs(Random()%2);
1432 if(i==0)whichsound=snarlsound;
1433 if(i==1)whichsound=snarl2sound;
1434 envsound[numenvsounds]=coords;
1435 envsoundvol[numenvsounds]=16;
1436 envsoundlife[numenvsounds]=.4;
1439 if(creature==rabbittype){
1440 int i=abs(Random()%2);
1441 if(i==0)whichsound=rabbitpainsound;
1442 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1443 envsound[numenvsounds]=coords;
1444 envsoundvol[numenvsounds]=16;
1445 envsoundlife[numenvsounds]=.4;
1447 //if(i==2)whichsound=rabbitpain2sound;
1451 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1452 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1453 OPENAL_SetVolume(channels[whichsound], 512);
1454 OPENAL_SetPaused(channels[whichsound], false);
1459 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1460 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1463 void Person::DoHead(){
1464 static XYZ rotatearound;
1466 static float lookspeed=500;
1468 if(!freeze&&!winfreeze&&(!mainmenu||!gamestarted)){
1471 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1472 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1474 while(targetheadrotation>180)targetheadrotation-=360;
1475 while(targetheadrotation<-180)targetheadrotation+=360;
1477 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1478 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1479 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1480 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1482 if(targetheadrotation2>120)targetheadrotation2=120;
1483 if(targetheadrotation2<-120)targetheadrotation2=-120;
1484 if(targetheadrotation>120)targetheadrotation=120;
1485 if(targetheadrotation<-120)targetheadrotation=-120;
1487 if(!isIdle())targetheadrotation2=0;
1489 if(targetheadrotation>80)targetheadrotation=80;
1490 if(targetheadrotation<-80)targetheadrotation=-80;
1491 if(targetheadrotation2>50)targetheadrotation2=50;
1492 if(targetheadrotation2<-50)targetheadrotation2=-50;
1495 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1496 else if(headrotation>targetheadrotation){
1497 headrotation-=multiplier*lookspeed;
1499 else if(headrotation<targetheadrotation){
1500 headrotation+=multiplier*lookspeed;
1503 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1504 else if(headrotation2>targetheadrotation2){
1505 headrotation2-=multiplier*lookspeed/2;
1507 else if(headrotation2<targetheadrotation2){
1508 headrotation2+=multiplier*lookspeed/2;
1511 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1512 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1516 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1517 facing=DoRotation(facing,headrotation2*.4,0,0);
1518 facing=DoRotation(facing,0,headrotation*.4,0);
1521 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1522 facing=DoRotation(facing,headrotation2*.8,0,0);
1523 facing=DoRotation(facing,0,headrotation*.8,0);
1526 if(targetanimation==walkanim){
1527 facing=DoRotation(facing,headrotation2*.6,0,0);
1528 facing=DoRotation(facing,0,headrotation*.6,0);
1531 skeleton.specialforward[0]=facing;
1532 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1534 for(i=0;i<skeleton.num_muscles;i++){
1535 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1537 skeleton.FindRotationMuscle(i,targetanimation);
1543 void Person::RagDoll(bool checkcollision){
1548 if(id==0)numfalls++;
1549 if(id==0&&isFlip())numflipfail++;
1555 facing=DoRotation(facing,0,rotation,0);
1557 skeleton.freetime=0;
1559 skeleton.longdead=0;
1565 skeleton.freefall=1;
1567 if(!isnormal(velocity.x))velocity.x=0;
1568 if(!isnormal(velocity.y))velocity.y=0;
1569 if(!isnormal(velocity.z))velocity.z=0;
1570 if(!isnormal(rotation))rotation=0;
1571 if(!isnormal(coords.x))coords=0;
1572 if(!isnormal(tilt))tilt=0;
1573 if(!isnormal(tilt2))tilt2=0;
1575 for(i=0;i<skeleton.num_joints;i++){
1576 skeleton.joints[i].delay=0;
1577 skeleton.joints[i].locked=0;
1578 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1579 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1580 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1581 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1582 skeleton.joints[i].position.y+=.1;
1583 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1584 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1587 for(i=0;i<skeleton.num_joints;i++){
1588 skeleton.joints[i].velocity=0;
1589 skeleton.joints[i].velchange=0;
1591 skeleton.DoConstraints(&coords,&scale);
1592 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1594 skeleton.DoConstraints(&coords,&scale);
1595 skeleton.DoConstraints(&coords,&scale);
1596 skeleton.DoConstraints(&coords,&scale);
1597 skeleton.DoConstraints(&coords,&scale);
1600 speed=animation[targetanimation].speed[targetframe]*2;
1601 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1602 speed=animation[currentanimation].speed[currentframe]*2;
1604 if(transspeed)speed=transspeed*2;
1608 for(i=0;i<skeleton.num_joints;i++){
1609 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);
1610 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1611 change.x=(float)(Random()%100)/100;
1612 change.y=(float)(Random()%100)/100;
1613 change.z=(float)(Random()%100)/100;
1614 skeleton.joints[i].velocity+=change;
1615 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1617 change.x=(float)(Random()%100)/100;
1618 change.y=(float)(Random()%100)/100;
1619 change.z=(float)(Random()%100)/100;
1620 skeleton.joints[i].velchange+=change;
1621 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1631 for(j=0;j<skeleton.num_joints;j++){
1632 average+=skeleton.joints[j].position;
1636 coords+=average*scale;
1637 for(j=0;j<skeleton.num_joints;j++){
1638 skeleton.joints[j].position-=average;
1641 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1642 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1643 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1644 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1645 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1648 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1649 coords.x=lowpoint.x;
1650 coords.z=lowpoint.z;
1659 for(i=0;i<skeleton.num_joints;i++){
1660 velocity+=skeleton.joints[i].velocity*scale;
1662 velocity/=skeleton.num_joints;
1665 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1666 weapons.owner[weaponids[0]]=-1;
1667 weapons.hitsomething[weaponids[0]]=0;
1668 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1669 weapons.velocity[weaponids[0]].x+=.01;
1670 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1671 weapons.missed[weaponids[0]]=1;
1672 weapons.freetime[weaponids[0]]=0;
1673 weapons.firstfree[weaponids[0]]=1;
1674 weapons.physics[weaponids[0]]=1;
1677 weaponids[0]=weaponids[num_weapons];
1678 if(weaponstuck==num_weapons)weaponstuck=0;
1681 for(i=0;i<numplayers;i++){
1682 player[i].wentforweapon=0;
1687 targetanimation=bounceidleanim;
1688 currentanimation=bounceidleanim;
1696 void Person::FootLand(int which, float opacity){
1697 static XYZ terrainlight;
1698 static XYZ footvel,footpoint;
1699 if(opacity>=1||skiddelay<=0)
1703 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1704 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1705 //footpoint.y=coords.y;
1706 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1708 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1710 if(footvel.y<.8)footvel.y=.8;
1711 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1712 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1713 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1714 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1715 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1716 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1718 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1720 if(footvel.y<.8)footvel.y=.8;
1721 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1722 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1723 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1724 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1725 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5*opacity);
1727 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1729 if(footvel.y<.8)footvel.y=.8;
1730 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1731 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1732 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1733 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1734 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7*opacity);
1735 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1737 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1740 if(footvel.y<.8)footvel.y=.8;
1741 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1742 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1743 //footpoint.y=coords.y;
1744 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1748 void Person::Puff(int whichlabel){
1749 static XYZ footvel,footpoint;
1752 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1753 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1758 HitStruct Person::BulletCollideWithPlayer(XYZ start, XYZ end){
1760 XYZ tempbulletloc[2];
1770 HitStruct hitstruct;
1771 hitstruct.collision=0;
1772 //Make bounding sphere
1775 for(int j=0;j<skeleton.num_joints;j++){
1776 average.x=average.x+skeleton.joints[j].position.x;
1777 average.y=average.y+skeleton.joints[j].position.y;
1778 average.z=average.z+skeleton.joints[j].position.z;
1781 average=average/howmany;
1783 for(int j=0;j<skeleton.num_joints;j++){
1784 if(findDistancefast(average,skeleton.joints[j].position)>distancemax){
1785 distancemax=findDistancefast(average,skeleton.joints[j].position);
1788 distancemax=fast_sqrt(distancemax);
1789 //Collide with player
1790 if(skeleton.free<1){
1793 if(rotation)start=DoRotation(start,0,-rotation,0);
1794 if(rotation)end=DoRotation(end,0,-rotation,0);
1796 tempbulletloc[0]=start;
1797 tempbulletloc[1]=end;
1798 if(sphere_line_intersection(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z,
1799 tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z,
1800 average.x, average.y, average.z, distancemax)){
1801 for(int j=0;j<skeleton.num_joints;j++){
1802 if(skeleton.joints[j].hasparent&&skeleton.joints[j].visible){
1803 tempbulletloc[0]=start;
1804 tempbulletloc[1]=end;
1807 glScalef(1,1/skeleton.joints[j].length,1);
1808 glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
1809 glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
1810 glTranslatef( (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
1811 (-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
1812 (-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
1813 glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
1814 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1815 tempbulletloc[0].x=M[12];
1816 tempbulletloc[0].y=M[13];
1817 tempbulletloc[0].z=M[14];
1821 glScalef(1,1/skeleton.joints[j].length,1);
1822 glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
1823 glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
1824 glTranslatef( (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
1825 (-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
1826 (-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
1827 glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
1828 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1829 tempbulletloc[1].x=M[12];
1830 tempbulletloc[1].y=M[13];
1831 tempbulletloc[1].z=M[14];
1833 collide=skeletonmodels[skeleton.joints[j].modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
1838 glTranslatef( (skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2,
1839 (skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2,
1840 (skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2);
1841 glRotatef(-skeleton.joints[j].rotate1+90,0,1,0);
1842 glRotatef(-skeleton.joints[j].rotate2+90,0,0,1);
1843 glScalef(1,skeleton.joints[j].length,1);
1844 glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
1845 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1846 collisionpoint.x=M[12];
1847 collisionpoint.y=M[13];
1848 collisionpoint.z=M[14];
1850 hitstruct.collision=1;
1851 hitstruct.hitlocation=collisionpoint;
1852 hitstruct.joint1=&skeleton.joints[j];
1853 hitstruct.joint2=skeleton.joints[j].parent;
1857 for(int j=0;j<skeleton.num_muscles;j++){
1858 if(skeleton.muscles[j].visible){
1859 tempbulletloc[0]=start;
1860 tempbulletloc[1]=end;
1863 glScalef(1,1/skeleton.muscles[j].length,1);
1864 glRotatef(skeleton.muscles[j].rotate3,0,1,0);
1865 glRotatef(skeleton.muscles[j].rotate2-90,0,0,1);
1866 glRotatef(skeleton.muscles[j].rotate1-90,0,1,0);
1867 glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2),
1868 (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2),
1869 (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2));
1871 glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
1872 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1873 tempbulletloc[0].x=M[12];
1874 tempbulletloc[0].y=M[13];
1875 tempbulletloc[0].z=M[14];
1879 glScalef(1,1/skeleton.muscles[j].length,1);
1880 glRotatef(skeleton.muscles[j].rotate3,0,1,0);
1881 glRotatef(skeleton.muscles[j].rotate2-90,0,0,1);
1882 glRotatef(skeleton.muscles[j].rotate1-90,0,1,0);
1884 glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2),
1885 (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2),
1886 (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2));
1887 glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
1888 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1889 tempbulletloc[1].x=M[12];
1890 tempbulletloc[1].y=M[13];
1891 tempbulletloc[1].z=M[14];
1893 collide=skeletonmodels[skeleton.muscles[j].parent1->modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
1898 glTranslatef( (skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2,
1899 (skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2,
1900 (skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2);
1901 glRotatef(-skeleton.muscles[j].rotate1+90,0,1,0);
1902 glRotatef(-skeleton.muscles[j].rotate2+90,0,0,1);
1903 glRotatef(-skeleton.muscles[j].rotate3,0,1,0);
1904 glScalef(1,findDistance(skeleton.muscles[j].parent1->position,skeleton.muscles[j].parent2->position),1);
1905 glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
1906 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1907 collisionpoint.x=M[12];
1908 collisionpoint.y=M[13];
1909 collisionpoint.z=M[14];
1911 hitstruct.collision=1;
1912 hitstruct.hitlocation=collisionpoint;
1913 hitstruct.joint1=skeleton.muscles[j].parent1;
1914 hitstruct.joint2=skeleton.muscles[j].parent2;
1919 if(skeleton.free<1){
1920 if(rotation)hitstruct.hitlocation=DoRotation(hitstruct.hitlocation,0,rotation,0);
1921 hitstruct.hitlocation=hitstruct.hitlocation+coords;
1926 void Person::DoAnimations(){
1929 static float oldtarget;
1931 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1933 if(targetanimation==tempanim||currentanimation==tempanim){
1934 animation[tempanim]=tempanimation;
1936 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1947 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1948 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1950 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1951 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1953 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1958 targfacing=DoRotation(targfacing,0,targetrotation,0);
1960 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1961 else targetanimation=backflipanim;
1962 crouchtogglekeydown=1;
1966 if(id==0)numflipped++;
1969 if(animation[targetanimation].attack!=reversed)feint=0;
1970 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1971 crouchtogglekeydown=0;
1972 if(aitype==playercontrolled)feint=0;
1976 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1977 if(!isFlip())crouchtogglekeydown=1;
1981 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1982 if(detail)normalsupdatedelay=0;
1986 if(targetanimation==rollanim&&targetframe==3&&onfire){
1996 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1997 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1998 OPENAL_SetVolume(channels[fireendsound], 256);
1999 OPENAL_SetPaused(channels[fireendsound], false);
2000 OPENAL_SetPaused(channels[stream_firesound], true);
2004 if(targetanimation==rabbittacklinganim&&targetframe==1){
2005 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
2006 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
2007 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
2008 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
2009 else victim->targetanimation=rabbittackledfrontanim;
2010 victim->targetframe=2;
2012 victim->rotation=rotation;
2013 victim->targetrotation=rotation;
2014 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
2015 //victim->DoDamage(30);
2016 if(creature==wolftype){
2020 gLoc[0]=victim->coords.x;
2021 gLoc[1]=victim->coords.y;
2022 gLoc[2]=victim->coords.z;
2026 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2027 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2028 OPENAL_SetVolume(channels[clawslicesound], 128);
2029 OPENAL_SetPaused(channels[clawslicesound], false);
2031 victim->DoBloodBig(1/victim->armorhead,210);
2037 if(victim->aitype==gethelptype)bonusvalue=50;
2042 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
2043 if(weapons.type[weaponids[0]]==knife){
2044 if(weaponactive==-1)weaponactive=0;
2045 else if(weaponactive==0)weaponactive=-1;
2047 if(weaponactive==-1){
2057 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2058 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2059 OPENAL_SetVolume(channels[knifesheathesound], 128);
2060 OPENAL_SetPaused(channels[knifesheathesound], false);
2062 if(weaponactive!=-1){
2072 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2073 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2074 OPENAL_SetVolume(channels[knifedrawsound], 128);
2075 OPENAL_SetPaused(channels[knifedrawsound], false);
2078 drawtogglekeydown=1;
2081 if(tutoriallevel!=1||id==0)
2082 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
2093 if(terrain.getOpacity(coords.x,coords.z)<.2){
2094 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
2095 else whichsound=footstepsound2;
2096 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
2097 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
2098 if(animation[targetanimation].label[targetframe]==3&&isRun()){
2104 if(terrain.getOpacity(coords.x,coords.z)>=.2){
2105 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
2106 else whichsound=footstepsound4;
2110 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
2111 else whichsound=footstepsound4;
2113 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
2114 if(animation[targetanimation].attack!=neutral){
2116 if(i==0)whichsound=lowwhooshsound;
2117 if(i==1)whichsound=midwhooshsound;
2118 if(i==2)whichsound=highwhooshsound;
2120 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2122 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2123 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
2125 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2126 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2127 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
2128 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
2129 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
2130 OPENAL_SetPaused(channels[whichsound], false);
2133 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
2134 envsound[numenvsounds]=coords;
2135 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
2136 else envsoundvol[numenvsounds]=6;
2137 envsoundlife[numenvsounds]=.4;
2141 if(animation[targetanimation].label[targetframe]==3){
2143 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2144 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2145 OPENAL_SetVolume(channels[whichsound], 128);
2146 OPENAL_SetPaused(channels[whichsound], false);
2151 if(tutoriallevel!=1||id==0)
2153 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
2154 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
2164 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
2165 if(animation[targetanimation].attack!=neutral){
2167 if(creature==rabbittype){
2168 if(i==0)whichsound=rabbitattacksound;
2169 if(i==1)whichsound=rabbitattack2sound;
2170 if(i==2)whichsound=rabbitattack3sound;
2171 if(i==3)whichsound=rabbitattack4sound;
2173 if(creature==wolftype){
2174 if(i==0)whichsound=barksound;
2175 if(i==1)whichsound=bark2sound;
2176 if(i==2)whichsound=bark3sound;
2177 if(i==3)whichsound=barkgrowlsound;
2181 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2183 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2184 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
2187 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2188 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2189 OPENAL_SetVolume(channels[whichsound], 512);
2190 OPENAL_SetPaused(channels[whichsound], false);
2196 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
2202 currentoffset=targetoffset;
2203 targetframe=currentframe;
2204 currentanimation=targetanimation;
2207 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
2208 for(i=0;i<weapons.numweapons;i++){
2209 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
2210 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
2211 if(findDistancefast(&coords,&weapons.position[i])>=1){
2212 if(weapons.type[i]!=staff){
2221 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2222 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2223 OPENAL_SetVolume(channels[knifedrawsound], 128);
2224 OPENAL_SetPaused(channels[knifedrawsound], false);
2228 weapons.owner[i]=id;
2230 weaponids[num_weapons]=weaponids[0];
2239 static bool willwork;
2240 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2241 for(i=0;i<weapons.numweapons;i++){
2243 if(weapons.owner[i]!=-1)
2244 if(player[weapons.owner[i]].weaponstuck!=-1)
2245 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2246 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2247 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))
2248 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2249 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2259 if(weapons.owner[i]!=-1)
2260 if(victim->weaponstuck!=-1){
2261 if(victim->weaponids[victim->weaponstuck]==i){
2266 if(weapons.type[i]!=staff){
2267 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2268 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2269 OPENAL_SetVolume(channels[knifedrawsound], 128);
2270 OPENAL_SetPaused(channels[knifedrawsound], false);
2274 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2275 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2276 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2277 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2280 if(weapons.owner[i]!=-1){
2282 victim=&player[weapons.owner[i]];
2283 if(victim->num_weapons==1)victim->num_weapons=0;
2284 else victim->num_weapons=1;
2286 //victim->weaponactive=-1;
2287 victim->skeleton.longdead=0;
2288 victim->skeleton.free=1;
2289 victim->skeleton.broken=0;
2291 for(int j=0;j<victim->skeleton.num_joints;j++){
2292 victim->skeleton.joints[j].velchange=0;
2293 victim->skeleton.joints[j].locked=0;
2299 Normalise(&relative);
2300 XYZ footvel,footpoint;
2302 footpoint=weapons.position[i];
2303 if(victim->weaponstuck!=-1){
2304 if(victim->weaponids[victim->weaponstuck]==i){
2305 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2306 weapons.bloody[i]=2;
2307 weapons.blooddrip[i]=5;
2308 victim->weaponstuck=-1;
2311 if(victim->num_weapons>0){
2312 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2313 if(victim->weaponids[0]==i)
2314 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2317 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2318 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2319 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2320 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2322 weapons.owner[i]=id;
2324 weaponids[num_weapons]=weaponids[0];
2333 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2334 if(weaponactive==-1)weaponactive=0;
2335 else if(weaponactive==0){
2339 buffer=weaponids[0];
2340 weaponids[0]=weaponids[1];
2341 weaponids[1]=buffer;
2344 if(weaponactive==-1){
2354 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2355 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2356 OPENAL_SetVolume(channels[knifesheathesound], 128);
2357 OPENAL_SetPaused(channels[knifesheathesound], false);
2359 if(weaponactive!=-1){
2369 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2370 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2371 OPENAL_SetVolume(channels[knifedrawsound], 128);
2372 OPENAL_SetPaused(channels[knifedrawsound], false);
2377 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2378 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2379 Normalise(&rotatetarget);
2380 targetrotation=-asin(0-rotatetarget.x);
2381 targetrotation*=360/6.28;
2382 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2384 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2385 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2390 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2392 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;
2394 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2395 targetanimation=rabbittackleanim;
2406 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2407 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2408 OPENAL_SetVolume(channels[jumpsound], 128);
2409 OPENAL_SetPaused(channels[jumpsound], false);
2418 Normalise(&targetloc);
2420 for(i=0;i<numplayers;i++){
2422 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2423 closestdist=findDistancefast(&targetloc,&player[i].coords);
2428 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2430 victim=&player[closestid];
2431 coords=victim->coords;
2432 currentanimation=rabbittacklinganim;
2433 targetanimation=rabbittacklinganim;
2437 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2438 rotatetarget=coords-victim->coords;
2439 Normalise(&rotatetarget);
2440 targetrotation=-asin(0-rotatetarget.x);
2441 targetrotation*=360/6.28;
2442 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2444 if(targetanimation!=rabbitrunninganim){
2454 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2455 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2456 OPENAL_SetVolume(channels[jumpsound], 128);
2457 OPENAL_SetPaused(channels[jumpsound], false);
2463 float damagemult=1*power;
2464 if(creature==wolftype)damagemult=2.5*power;
2465 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2466 //if(onfire)damagemult=3;
2467 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2468 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2469 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2471 if(id==0)camerashake+=.4;
2472 if(Random()%2||creature==wolftype){
2475 if(creature==wolftype)DoBloodBig(0,250);
2479 gLoc[0]=victim->coords.x;
2480 gLoc[1]=victim->coords.y;
2481 gLoc[2]=victim->coords.z;
2485 if(tutoriallevel!=1){
2486 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2487 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2488 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2489 OPENAL_SetPaused(channels[heavyimpactsound], false);
2491 if(creature==wolftype){
2492 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2493 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2494 OPENAL_SetVolume(channels[clawslicesound], 128);
2495 OPENAL_SetPaused(channels[clawslicesound], false);
2497 victim->DoBloodBig(2/victim->armorhead,175);
2501 relative=victim->coords-coords;
2503 Normalise(&relative);
2504 relative=DoRotation(relative,0,-90,0);
2505 for(i=0;i<victim->skeleton.num_joints;i++){
2506 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2508 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2511 victim->DoDamage(damagemult*100/victim->protectionhead);
2519 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2520 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2522 if(id==0)camerashake+=.4;
2523 if(Random()%2||creature==wolftype){
2525 if(creature==wolftype)DoBloodBig(0,235);
2529 gLoc[0]=victim->coords.x;
2530 gLoc[1]=victim->coords.y;
2531 gLoc[2]=victim->coords.z;
2535 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2536 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2537 OPENAL_SetVolume(channels[whooshhitsound], 512);
2538 OPENAL_SetPaused(channels[whooshhitsound], false);
2539 if(creature==wolftype){
2540 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2541 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2542 OPENAL_SetVolume(channels[clawslicesound], 128);
2543 OPENAL_SetPaused(channels[clawslicesound], false);
2545 victim->DoBloodBig(2,175);
2549 relative=victim->coords-coords;
2551 Normalise(&relative);
2553 Normalise(&relative);
2554 relative=DoRotation(relative,0,90,0);
2555 for(i=0;i<victim->skeleton.num_joints;i++){
2556 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2558 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2561 victim->DoDamage(damagemult*50/victim->protectionhead);
2565 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2566 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2568 if(id==0)camerashake+=.4;
2573 gLoc[0]=victim->coords.x;
2574 gLoc[1]=victim->coords.y;
2575 gLoc[2]=victim->coords.z;
2579 if(tutoriallevel!=1){
2580 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2581 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2582 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2583 OPENAL_SetPaused(channels[heavyimpactsound], false);
2585 if(creature==wolftype){
2586 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2587 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2588 OPENAL_SetVolume(channels[clawslicesound], 128);
2589 OPENAL_SetPaused(channels[clawslicesound], false);
2591 victim->DoBloodBig(2/victim->armorhead,175);
2597 Normalise(&relative);
2598 relative=DoRotation(relative,0,-90,0);
2599 for(i=0;i<victim->skeleton.num_joints;i++){
2600 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2602 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2605 victim->DoDamage(damagemult*150/victim->protectionhead);
2607 if(victim->damage>victim->damagetolerance){
2620 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2621 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2623 if(id==0)camerashake+=.4;
2628 gLoc[0]=victim->coords.x;
2629 gLoc[1]=victim->coords.y;
2630 gLoc[2]=victim->coords.z;
2634 if(tutoriallevel!=1){
2635 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2636 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2637 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2638 OPENAL_SetPaused(channels[heavyimpactsound], false);
2640 if(creature==wolftype){
2641 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2642 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2643 OPENAL_SetVolume(channels[clawslicesound], 128);
2644 OPENAL_SetPaused(channels[clawslicesound], false);
2646 victim->DoBloodBig(2/victim->armorhead,175);
2652 Normalise(&relative);
2653 relative=DoRotation(relative,0,90,0);
2654 for(i=0;i<victim->skeleton.num_joints;i++){
2655 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2657 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2660 victim->DoDamage(damagemult*150/victim->protectionhead);
2662 if(victim->damage>victim->damagetolerance){
2675 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2676 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2678 if(id==0)camerashake+=.4;
2685 gLoc[0]=victim->coords.x;
2686 gLoc[1]=victim->coords.y;
2687 gLoc[2]=victim->coords.z;
2691 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2692 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2693 OPENAL_SetVolume(channels[whooshhitsound], 512);
2694 OPENAL_SetPaused(channels[whooshhitsound], false);
2697 relative=victim->coords-coords;
2699 Normalise(&relative);
2700 for(i=0;i<victim->skeleton.num_joints;i++){
2701 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2703 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2706 victim->DoDamage(damagemult*50/victim->protectionhead);
2710 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2711 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2713 if(id==0)camerashake+=.2;
2716 gLoc[0]=victim->coords.x;
2717 gLoc[1]=victim->coords.y;
2718 gLoc[2]=victim->coords.z;
2722 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2723 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2724 OPENAL_SetVolume(channels[landsound2], 128);
2725 OPENAL_SetPaused(channels[landsound2], false);
2727 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2728 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2729 OPENAL_SetVolume(channels[movewhooshsound], 128);
2730 OPENAL_SetPaused(channels[movewhooshsound], false);
2732 victim->skeleton.longdead=0;
2733 victim->skeleton.free=1;
2734 victim->skeleton.broken=0;
2735 victim->skeleton.spinny=1;
2737 for(i=0;i<victim->skeleton.num_joints;i++){
2738 victim->skeleton.joints[i].velchange=0;
2739 victim->skeleton.joints[i].delay=0;
2740 victim->skeleton.joints[i].locked=0;
2741 //victim->skeleton.joints[i].velocity=0;
2747 Normalise(&relative);
2748 for(i=0;i<victim->skeleton.num_joints;i++){
2749 victim->skeleton.joints[i].velocity.y=relative.y*10;
2750 victim->skeleton.joints[i].position.y+=relative.y*.3;
2751 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2752 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2754 victim->Puff(abdomen);
2755 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2759 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2760 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2762 if(id==0)camerashake+=.4;
2771 if(tutoriallevel!=1){
2772 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2773 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2774 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2775 OPENAL_SetPaused(channels[heavyimpactsound], false);
2778 relative=victim->coords-coords;
2780 Normalise(&relative);
2781 for(i=0;i<victim->skeleton.num_joints;i++){
2782 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2784 victim->Puff(abdomen);
2785 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2789 victim->DoDamage(damagemult*500/victim->protectionhigh);
2790 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2794 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2795 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2797 if(id==0)camerashake+=.4;
2806 if(tutoriallevel!=1){
2807 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2808 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2809 OPENAL_SetVolume(channels[thudsound], 400);
2810 OPENAL_SetPaused(channels[thudsound], false);
2813 victim->skeleton.longdead=0;
2814 victim->skeleton.free=1;
2815 victim->skeleton.broken=0;
2816 victim->skeleton.spinny=1;
2818 for(i=0;i<victim->skeleton.num_joints;i++){
2819 victim->skeleton.joints[i].velchange=0;
2820 //victim->skeleton.joints[i].delay=0;
2821 victim->skeleton.joints[i].locked=0;
2824 relative=victim->coords-coords;
2825 Normalise(&relative);
2827 Normalise(&relative);
2828 for(i=0;i<victim->skeleton.num_joints;i++){
2829 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2831 if(id==0&&!victim->dead){
2835 victim->Puff(abdomen);
2836 victim->DoDamage(damagemult*20/victim->protectionhigh);
2837 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2839 if(!victim->dead)staggerdelay=1.2;
2845 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2846 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2847 //if(id==0)camerashake+=.4;
2858 if(!victim->skeleton.free)hasvictim=0;
2861 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2862 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2863 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2864 OPENAL_SetVolume(channels[knifesheathesound], 128);
2865 OPENAL_SetPaused(channels[knifesheathesound], false);
2868 if(victim&&hasvictim){
2869 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2871 XYZ where,startpoint,endpoint,movepoint,colpoint;
2872 float rotationpoint;
2874 if(weapons.type[weaponids[weaponactive]]==knife){
2875 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2876 where-=victim->coords;
2877 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2884 if(weapons.type[weaponids[weaponactive]]==sword){
2885 where=weapons.position[weaponids[weaponactive]];
2886 where-=victim->coords;
2887 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2889 where=weapons.tippoint[weaponids[weaponactive]];
2890 where-=victim->coords;
2891 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2894 if(weapons.type[weaponids[weaponactive]]==staff){
2895 where=weapons.position[weaponids[weaponactive]];
2896 where-=victim->coords;
2897 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2899 where=weapons.tippoint[weaponids[weaponactive]];
2900 where-=victim->coords;
2901 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2906 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2909 if(victim->dead!=2){
2910 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2911 if(id==0&&!victim->dead){
2912 bonus=FinishedBonus;
2917 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2919 victim->skeleton.longdead=0;
2920 victim->skeleton.free=1;
2921 victim->skeleton.broken=0;
2923 for(i=0;i<victim->skeleton.num_joints;i++){
2924 victim->skeleton.joints[i].velchange=0;
2925 victim->skeleton.joints[i].locked=0;
2926 //victim->skeleton.joints[i].velocity=0;
2928 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2929 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2930 OPENAL_SetVolume(channels[fleshstabsound], 128);
2931 OPENAL_SetPaused(channels[fleshstabsound], false);
2934 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2935 weapons.blooddrip[weaponids[weaponactive]]+=5;
2936 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2940 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2941 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2942 OPENAL_SetVolume(channels[knifesheathesound], 128);
2943 OPENAL_SetPaused(channels[knifesheathesound], false);
2949 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2950 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2951 //if(id==0)camerashake+=.4;
2961 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2962 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2963 OPENAL_SetVolume(channels[knifedrawsound], 128);
2964 OPENAL_SetPaused(channels[knifedrawsound], false);
2967 if(victim&&hasvictim){
2968 XYZ footvel,footpoint;
2970 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2971 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2972 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2973 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2976 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2978 if(weapons.type[weaponids[weaponactive]]==sword){
2979 XYZ where,startpoint,endpoint,movepoint;
2980 float rotationpoint;
2983 where=weapons.position[weaponids[weaponactive]];
2984 where-=victim->coords;
2985 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2987 where=weapons.tippoint[weaponids[weaponactive]];
2988 where-=victim->coords;
2989 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2994 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2995 footpoint+=victim->coords;
2998 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
3001 if(weapons.type[weaponids[weaponactive]]==staff){
3002 XYZ where,startpoint,endpoint,movepoint;
3003 float rotationpoint;
3006 where=weapons.position[weaponids[weaponactive]];
3007 where-=victim->coords;
3008 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
3010 where=weapons.tippoint[weaponids[weaponactive]];
3011 where-=victim->coords;
3012 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
3017 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
3018 footpoint+=victim->coords;
3021 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
3024 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
3026 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
3027 victim->skeleton.longdead=0;
3028 victim->skeleton.free=1;
3029 victim->skeleton.broken=0;
3031 for(i=0;i<victim->skeleton.num_joints;i++){
3032 victim->skeleton.joints[i].velchange=0;
3033 victim->skeleton.joints[i].locked=0;
3034 //victim->skeleton.joints[i].velocity=0;
3040 Normalise(&relative);
3041 //victim->Puff(abdomen);
3042 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
3044 if(victim->bloodloss<victim->damagetolerance){
3045 victim->bloodloss+=1000;
3049 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3053 if(!hasvictim&&onterrain){
3054 weapons.bloody[weaponids[weaponactive]]=0;
3055 weapons.blooddrip[weaponids[weaponactive]]=0;
3059 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
3060 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
3062 if(id==0)camerashake+=.4;
3069 gLoc[0]=victim->coords.x;
3070 gLoc[1]=victim->coords.y;
3071 gLoc[2]=victim->coords.z;
3075 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
3077 if(tutoriallevel!=1){
3078 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3079 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3080 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3081 OPENAL_SetPaused(channels[heavyimpactsound], false);
3085 if(tutoriallevel!=1){
3086 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3087 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3088 OPENAL_SetVolume(channels[landsound2], 256);
3089 OPENAL_SetPaused(channels[landsound2], false);
3093 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
3096 relative=victim->coords-coords;
3098 Normalise(&relative);
3099 for(i=0;i<victim->skeleton.num_joints;i++){
3100 victim->skeleton.joints[i].velocity=relative*30;
3102 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
3104 victim->targetframe=0;
3105 victim->targetanimation=staggerbackhardanim;
3106 victim->targetrotation=targetrotation+180;
3111 victim->Puff(abdomen);
3112 victim->DoDamage(damagemult*60/victim->protectionhigh);
3121 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
3122 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
3124 if(id==0)camerashake+=.4;
3127 gLoc[0]=victim->coords.x;
3128 gLoc[1]=victim->coords.y;
3129 gLoc[2]=victim->coords.z;
3133 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
3134 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
3135 if(tutoriallevel!=1){
3136 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
3137 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
3138 OPENAL_SetVolume(channels[thudsound], 512);
3139 OPENAL_SetPaused(channels[thudsound], false);
3142 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
3143 if(tutoriallevel!=1){
3144 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3145 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3146 OPENAL_SetVolume(channels[whooshhitsound], 512);
3147 OPENAL_SetPaused(channels[whooshhitsound], false);
3151 if(tutoriallevel!=1){
3152 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3153 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3154 OPENAL_SetVolume(channels[heavyimpactsound], 256);
3155 OPENAL_SetPaused(channels[heavyimpactsound], false);
3159 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
3162 relative=victim->coords-coords;
3164 Normalise(&relative);
3166 Normalise(&relative);
3167 for(i=0;i<victim->skeleton.num_joints;i++){
3168 victim->skeleton.joints[i].velocity=relative*5;
3170 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
3172 victim->targetframe=0;
3173 victim->targetanimation=staggerbackhardanim;
3174 victim->targetrotation=targetrotation+180;
3178 victim->Puff(abdomen);
3179 victim->DoDamage(damagemult*60/victim->protectionhigh);
3187 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
3188 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3189 if(victim->id==0)camerashake+=.4;
3192 gLoc[0]=victim->coords.x;
3193 gLoc[1]=victim->coords.y;
3194 gLoc[2]=victim->coords.z;
3199 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3200 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3201 OPENAL_SetVolume(channels[landsound2], 256);
3202 OPENAL_SetPaused(channels[landsound2], false);
3208 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
3209 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3210 if(victim->id==0)camerashake+=.4;
3213 gLoc[0]=victim->coords.x;
3214 gLoc[1]=victim->coords.y;
3215 gLoc[2]=victim->coords.z;
3220 if(weaponactive!=-1){
3221 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3222 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3223 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3225 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3226 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3227 OPENAL_SetVolume(channels[swordstaffsound], 512);
3228 OPENAL_SetPaused(channels[swordstaffsound], false);
3231 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3232 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3233 OPENAL_SetVolume(channels[metalhitsound], 512);
3234 OPENAL_SetPaused(channels[metalhitsound], false);
3242 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3243 if(weaponactive!=-1){
3246 weapons.owner[weaponids[0]]=-1;
3247 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);
3249 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3250 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3252 weapons.velocity[weaponids[0]]=aim*50;
3253 weapons.tipvelocity[weaponids[0]]=aim*50;
3254 weapons.missed[weaponids[0]]=0;
3255 weapons.hitsomething[weaponids[0]]=0;
3256 weapons.freetime[weaponids[0]]=0;
3257 weapons.firstfree[weaponids[0]]=1;
3258 weapons.physics[weaponids[0]]=0;
3261 weaponids[0]=weaponids[num_weapons];
3267 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3269 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3272 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3280 if(tutoriallevel!=1){
3283 gLoc[0]=victim->coords.x;
3284 gLoc[1]=victim->coords.y;
3285 gLoc[2]=victim->coords.z;
3289 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3290 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3291 OPENAL_SetVolume(channels[knifeslicesound], 512);
3292 OPENAL_SetPaused(channels[knifeslicesound], false);
3294 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3295 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3296 if(victim->id != 0 || difficulty==2){
3297 victim->targetframe=0;
3298 victim->targetanimation=staggerbackhardanim;
3299 victim->targetrotation=targetrotation+180;
3303 victim->lowreversaldelay=0;
3304 victim->highreversaldelay=0;
3305 if(aitype!=playercontrolled)weaponmissdelay=.6;
3307 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3308 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3310 XYZ footvel,footpoint;
3313 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3316 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;
3318 if(tutoriallevel!=1){
3319 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3320 footvel=DoRotation(facing,0,90,0)*.8;
3322 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3323 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3324 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3325 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3327 if(tutoriallevel==1){
3328 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3330 victim->DoDamage(damagemult*0);
3333 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3334 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3335 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3342 if(tutoriallevel!=1){
3343 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3344 else victim->DoBloodBig(2/victim->armorhigh,185);
3345 victim->deathbleeding=1;
3348 gLoc[0]=victim->coords.x;
3349 gLoc[1]=victim->coords.y;
3350 gLoc[2]=victim->coords.z;
3354 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3355 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3356 OPENAL_SetVolume(channels[swordslicesound], 512);
3357 OPENAL_SetPaused(channels[swordslicesound], false);
3359 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3360 //if(animation[victim->targetanimation].attack){
3361 //if(victim->creature==rabbittype){
3362 if(tutoriallevel!=1){
3363 victim->targetframe=0;
3364 victim->targetanimation=staggerbackhardanim;
3365 victim->targetrotation=targetrotation+180;
3371 if(tutoriallevel!=1){
3372 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3373 weapons.blooddrip[weaponids[weaponactive]]+=3;
3375 float bloodlossamount;
3376 bloodlossamount=200+abs((float)(Random()%40))-20;
3377 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3378 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3379 victim->DoDamage(damagemult*0);
3381 XYZ footvel,footpoint;
3384 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3387 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;
3389 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3390 footvel=DoRotation(facing,0,90,0)*.8;
3392 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3393 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3394 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3395 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3403 gLoc[0]=victim->coords.x;
3404 gLoc[1]=victim->coords.y;
3405 gLoc[2]=victim->coords.z;
3409 if(victim->weaponactive!=-1){
3410 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3411 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3412 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3414 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3415 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3416 OPENAL_SetVolume(channels[swordstaffsound], 512);
3417 OPENAL_SetPaused(channels[swordstaffsound], false);
3420 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3421 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3422 OPENAL_SetVolume(channels[metalhitsound], 512);
3423 OPENAL_SetPaused(channels[metalhitsound], false);
3429 victim->Puff(righthand);
3431 victim->targetframe=0;
3432 victim->targetanimation=staggerbackhighanim;
3433 victim->targetrotation=targetrotation+180;
3435 weapons.owner[victim->weaponids[0]]=-1;
3436 aim=DoRotation(facing,0,90,0)*21;
3438 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3439 weapons.tipvelocity[victim->weaponids[0]]=aim;
3440 weapons.missed[victim->weaponids[0]]=1;
3441 weapons.hitsomething[weaponids[0]]=0;
3442 weapons.freetime[victim->weaponids[0]]=0;
3443 weapons.firstfree[victim->weaponids[0]]=1;
3444 weapons.physics[victim->weaponids[0]]=1;
3445 victim->num_weapons--;
3446 if(victim->num_weapons){
3447 victim->weaponids[0]=victim->weaponids[num_weapons];
3448 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3450 victim->weaponactive=-1;
3451 for(i=0;i<numplayers;i++){
3452 player[i].wentforweapon=0;
3455 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3456 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3457 OPENAL_SetVolume(channels[metalhitsound], 512);
3458 OPENAL_SetPaused(channels[metalhitsound], false);*/
3464 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3465 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3466 if(tutoriallevel!=1){
3467 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3469 if(id==0)camerashake+=.4;
3470 if(Random()%2||creature==wolftype){
3475 gLoc[0]=victim->coords.x;
3476 gLoc[1]=victim->coords.y;
3477 gLoc[2]=victim->coords.z;
3481 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3482 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3483 OPENAL_SetVolume(channels[staffheadsound], 256);
3484 OPENAL_SetPaused(channels[staffheadsound], false);
3488 relative=victim->coords-coords;
3490 Normalise(&relative);
3491 relative=DoRotation(relative,0,90,0);
3493 Normalise(&relative);
3494 for(i=0;i<victim->skeleton.num_joints;i++){
3495 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3497 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3498 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3501 if(tutoriallevel!=1){
3502 victim->DoDamage(damagemult*120/victim->protectionhigh);
3513 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3514 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3515 if(tutoriallevel!=1){
3516 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3518 if(id==0)camerashake+=.4;
3519 if(Random()%2||creature==wolftype){
3524 gLoc[0]=victim->coords.x;
3525 gLoc[1]=victim->coords.y;
3526 gLoc[2]=victim->coords.z;
3530 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3531 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3532 OPENAL_SetVolume(channels[staffheadsound], 256);
3533 OPENAL_SetPaused(channels[staffheadsound], false);
3537 relative=victim->coords-coords;
3539 Normalise(&relative);
3540 relative=DoRotation(relative,0,-90,0);
3541 for(i=0;i<victim->skeleton.num_joints;i++){
3542 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3544 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3545 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3548 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3559 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3560 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3562 if(tutoriallevel!=1){
3563 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3564 if(id==0)camerashake+=.4;
3565 if(Random()%2||creature==wolftype){
3570 gLoc[0]=victim->coords.x;
3571 gLoc[1]=victim->coords.y;
3572 gLoc[2]=victim->coords.z;
3576 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3577 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3578 OPENAL_SetVolume(channels[staffbodysound], 256);
3579 OPENAL_SetPaused(channels[staffbodysound], false);
3581 victim->skeleton.longdead=0;
3582 victim->skeleton.free=1;
3583 victim->skeleton.broken=0;
3585 for(i=0;i<victim->skeleton.num_joints;i++){
3586 victim->skeleton.joints[i].velchange=0;
3587 victim->skeleton.joints[i].locked=0;
3588 //victim->skeleton.joints[i].velocity=0;
3594 /*relative=victim->coords-coords;
3596 Normalise(&relative);
3597 relative=DoRotation(relative,0,90,0);*/
3599 Normalise(&relative);
3601 for(i=0;i<victim->skeleton.num_joints;i++){
3602 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3605 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3608 for(i=0;i<victim->skeleton.num_joints;i++){
3609 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3612 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3614 victim->Puff(abdomen);
3615 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3628 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3629 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3631 if(id==0)camerashake+=.4;
3634 gLoc[0]=victim->coords.x;
3635 gLoc[1]=victim->coords.y;
3636 gLoc[2]=victim->coords.z;
3641 relative=victim->coords-coords;
3643 Normalise(&relative);
3649 if(animation[victim->targetanimation].height==lowheight){
3655 for(i=0;i<victim->skeleton.num_joints;i++){
3656 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3658 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3659 if(tutoriallevel!=1){
3660 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3661 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3662 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3663 OPENAL_SetPaused(channels[heavyimpactsound], false);
3666 victim->DoDamage(damagemult*100/victim->protectionhead);
3667 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3668 if(creature==wolftype){
3669 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3670 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3671 OPENAL_SetVolume(channels[clawslicesound], 128);
3672 OPENAL_SetPaused(channels[clawslicesound], false);
3674 victim->DoBloodBig(2/victim->armorhead,175);
3678 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3679 for(i=0;i<victim->skeleton.num_joints;i++){
3680 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3682 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3683 victim->targetframe=0;
3684 victim->targetanimation=staggerbackhighanim;
3685 victim->targetrotation=targetrotation+180;
3687 if(tutoriallevel!=1){
3688 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3689 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3690 OPENAL_SetVolume(channels[landsound2], 128);
3691 OPENAL_SetPaused(channels[landsound2], false);
3693 victim->Puff(abdomen);
3694 victim->DoDamage(damagemult*30/victim->protectionhigh);
3695 if(creature==wolftype){
3696 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3697 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3698 OPENAL_SetVolume(channels[clawslicesound], 128);
3699 OPENAL_SetPaused(channels[clawslicesound], false);
3701 victim->DoBloodBig(2/victim->armorhigh,170);
3708 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3709 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3711 if(id==0)camerashake+=.2;
3714 gLoc[0]=victim->coords.x;
3715 gLoc[1]=victim->coords.y;
3716 gLoc[2]=victim->coords.z;
3720 if(tutoriallevel!=1){
3721 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3722 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3723 OPENAL_SetVolume(channels[landsound2], 128);
3724 OPENAL_SetPaused(channels[landsound2], false);
3727 relative=victim->coords-coords;
3729 Normalise(&relative);
3731 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3734 for(i=0;i<victim->skeleton.num_joints;i++){
3735 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3737 relative=DoRotation(relative,0,-90,0);
3739 for(i=0;i<victim->skeleton.num_joints;i++){
3740 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)
3741 victim->skeleton.joints[i].velocity=relative*80;
3743 victim->Puff(rightankle);
3744 victim->Puff(leftankle);
3745 victim->DoDamage(damagemult*40/victim->protectionlow);
3748 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3749 for(i=0;i<victim->skeleton.num_joints;i++){
3750 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3752 relative=DoRotation(relative,0,-90,0);
3753 for(i=0;i<victim->skeleton.num_joints;i++){
3754 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)
3755 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3757 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3758 victim->targetframe=0;
3759 victim->targetanimation=staggerbackhighanim;
3760 victim->targetrotation=targetrotation+180;
3762 if(tutoriallevel!=1){
3763 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3764 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3765 OPENAL_SetVolume(channels[landsound2], 128);
3766 OPENAL_SetPaused(channels[landsound2], false);
3768 victim->Puff(abdomen);
3769 victim->DoDamage(damagemult*30/victim->protectionlow);
3779 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3780 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3782 if(id==0)camerashake+=.4;
3789 gLoc[0]=victim->coords.x;
3790 gLoc[1]=victim->coords.y;
3791 gLoc[2]=victim->coords.z;
3795 if(tutoriallevel!=1){
3796 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3797 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3798 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3799 OPENAL_SetPaused(channels[heavyimpactsound], false);
3801 if(creature==wolftype){
3802 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3803 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3804 OPENAL_SetVolume(channels[clawslicesound], 128);
3805 OPENAL_SetPaused(channels[clawslicesound], false);
3807 victim->DoBloodBig(2/victim->armorhigh,170);
3811 relative=victim->coords-oldcoords;
3813 Normalise(&relative);
3814 //relative=DoRotation(relative,0,-90,0);
3815 for(i=0;i<victim->skeleton.num_joints;i++){
3816 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3818 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3820 victim->Puff(abdomen);
3821 victim->DoDamage(damagemult*150/victim->protectionhigh);
3830 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3831 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3832 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3833 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3836 weaponids[num_weapons]=weaponids[victim->weaponactive];
3839 weaponids[0]=victim->weaponids[victim->weaponactive];
3840 victim->num_weapons--;
3841 if(victim->num_weapons>0){
3842 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3843 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3845 victim->weaponactive=-1;
3850 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3852 if(id==0)camerashake+=.4;
3859 gLoc[0]=victim->coords.x;
3860 gLoc[1]=victim->coords.y;
3861 gLoc[2]=victim->coords.z;
3865 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3866 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3867 OPENAL_SetVolume(channels[whooshhitsound], 128);
3868 OPENAL_SetPaused(channels[whooshhitsound], false);
3871 relative=victim->coords-oldcoords;
3873 Normalise(&relative);
3874 //relative=DoRotation(relative,0,-90,0);
3875 for(i=0;i<victim->skeleton.num_joints;i++){
3876 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3878 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3881 victim->DoDamage(damagemult*70/victim->protectionhigh);
3884 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3886 if(id==0)camerashake+=.4;
3893 gLoc[0]=victim->coords.x;
3894 gLoc[1]=victim->coords.y;
3895 gLoc[2]=victim->coords.z;
3901 bonus=staffreversebonus;
3906 if(tutoriallevel!=1){
3907 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3908 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3909 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3910 OPENAL_SetPaused(channels[heavyimpactsound], false);
3914 bonus=staffreversebonus;
3920 relative=victim->coords-oldcoords;
3922 Normalise(&relative);
3923 //relative=DoRotation(relative,0,-90,0);
3924 for(i=0;i<victim->skeleton.num_joints;i++){
3925 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3927 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3930 victim->DoDamage(damagemult*70/victim->protectionhigh);
3933 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3939 Normalise(&relative);
3942 for(i=0;i<victim->skeleton.num_joints;i++){
3943 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3945 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3946 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3947 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3948 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3949 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3950 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3951 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3952 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3954 victim->Puff(abdomen);
3955 victim->DoDamage(damagemult*90/victim->protectionhigh);
3965 if(weaponactive!=-1||creature==wolftype)doslice=1;
3966 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3970 gLoc[0]=victim->coords.x;
3971 gLoc[1]=victim->coords.y;
3972 gLoc[2]=victim->coords.z;
3976 if(weaponactive!=-1){
3977 victim->DoBloodBig(2/victim->armorhigh,225);
3978 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3979 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3980 OPENAL_SetVolume(channels[knifeslicesound], 512);
3981 OPENAL_SetPaused(channels[knifeslicesound], false);
3982 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3983 weapons.blooddrip[weaponids[weaponactive]]+=3;
3985 if(weaponactive==-1&&creature==wolftype){
3986 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3987 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3988 OPENAL_SetVolume(channels[clawslicesound], 128);
3989 OPENAL_SetPaused(channels[clawslicesound], false);
3991 victim->DoBloodBig(2/victim->armorhigh,175);
3998 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
4004 Normalise(&relative);
4007 for(i=0;i<victim->skeleton.num_joints;i++){
4008 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
4010 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
4011 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
4012 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
4013 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
4014 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
4015 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
4016 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
4017 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
4020 bonus=swordreversebonus;
4024 //victim->DoDamage(90);
4026 /*if(weaponactive!=-1){
4029 gLoc[0]=victim->coords.x;
4030 gLoc[1]=victim->coords.y;
4031 gLoc[2]=victim->coords.z;
4035 victim->DoBloodBig(2,225);
4036 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4037 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4038 OPENAL_SetVolume(channels[knifeslicesound], 512);
4039 OPENAL_SetPaused(channels[knifeslicesound], false);
4040 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4041 weapons.blooddrip[weaponids[weaponactive]]+=3;
4045 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
4047 if(id==0)camerashake+=.4;
4054 gLoc[0]=victim->coords.x;
4055 gLoc[1]=victim->coords.y;
4056 gLoc[2]=victim->coords.z;
4060 if(tutoriallevel!=1){
4061 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4062 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4063 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4064 OPENAL_SetPaused(channels[heavyimpactsound], false);
4068 relative=victim->coords-oldcoords;
4070 Normalise(&relative);
4071 relative=DoRotation(relative,0,-90,0);
4072 for(i=0;i<victim->skeleton.num_joints;i++){
4073 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
4075 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
4077 victim->Puff(abdomen);
4078 victim->DoDamage(damagemult*30/victim->protectionhigh);
4087 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
4090 victim->skeleton.spinny=0;
4094 Normalise(&relative);
4095 if(victim->id==0)relative/=30;
4096 for(i=0;i<victim->skeleton.num_joints;i++){
4097 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
4099 //victim->DoDamage(1000);
4100 victim->damage=victim->damagetolerance;
4101 victim->permanentdamage=victim->damagetolerance-1;
4104 if(weaponactive!=-1||creature==wolftype)doslice=1;
4105 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4109 gLoc[0]=victim->coords.x;
4110 gLoc[1]=victim->coords.y;
4111 gLoc[2]=victim->coords.z;
4115 if(weaponactive!=-1){
4116 victim->DoBloodBig(200,225);
4117 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4118 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4119 OPENAL_SetVolume(channels[knifeslicesound], 512);
4120 OPENAL_SetPaused(channels[knifeslicesound], false);
4121 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4122 weapons.blooddrip[weaponids[weaponactive]]+=5;
4125 if(creature==wolftype&&weaponactive==-1){
4126 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4127 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4128 OPENAL_SetVolume(channels[clawslicesound], 128);
4129 OPENAL_SetPaused(channels[clawslicesound], false);
4131 victim->DoBloodBig(2,175);
4141 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4142 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4144 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
4145 if(targetanimation==knifesneakattackanim){
4146 /*victim->DoBloodBig(200,195);
4151 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4152 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
4154 XYZ footvel,footpoint;
4156 footpoint=weapons.tippoint[weaponids[0]];
4157 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4158 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4159 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4160 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4161 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4162 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4163 victim->DoBloodBig(200,195);
4170 //victim->neckspurtamount=5;
4172 if(targetanimation==knifefollowanim){
4178 XYZ footvel,footpoint;
4180 footpoint=weapons.tippoint[weaponids[0]];
4181 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4182 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4183 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4184 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4185 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
4186 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
4189 victim->bloodloss+=10000;
4193 gLoc[0]=victim->coords.x;
4194 gLoc[1]=victim->coords.y;
4195 gLoc[2]=victim->coords.z;
4199 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4200 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4201 OPENAL_SetVolume(channels[fleshstabsound], 512);
4202 OPENAL_SetPaused(channels[fleshstabsound], false);
4203 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4204 weapons.blooddrip[weaponids[weaponactive]]+=5;
4208 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
4211 for(i=0;i<victim->skeleton.num_joints;i++){
4212 victim->skeleton.joints[i].velocity=0;
4214 if(targetanimation==knifefollowanim){
4216 for(i=0;i<victim->skeleton.num_joints;i++){
4217 victim->skeleton.joints[i].velocity=0;
4220 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
4223 gLoc[0]=victim->coords.x;
4224 gLoc[1]=victim->coords.y;
4225 gLoc[2]=victim->coords.z;
4229 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4230 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4231 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4232 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4233 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4234 weapons.blooddrip[weaponids[weaponactive]]+=5;
4236 XYZ footvel,footpoint;
4238 footpoint=weapons.tippoint[weaponids[0]];
4239 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4240 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4241 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4242 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4243 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4244 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4248 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4249 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4258 XYZ footvel,footpoint;
4260 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
4261 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4262 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4263 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4264 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4265 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4266 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4267 victim->DoBloodBig(200,180);
4268 victim->DoBloodBig(200,215);
4269 victim->bloodloss+=10000;
4273 gLoc[0]=victim->coords.x;
4274 gLoc[1]=victim->coords.y;
4275 gLoc[2]=victim->coords.z;
4279 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4280 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4281 OPENAL_SetVolume(channels[fleshstabsound], 512);
4282 OPENAL_SetPaused(channels[fleshstabsound], false);
4283 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4284 weapons.blooddrip[weaponids[weaponactive]]+=5;
4288 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
4291 for(i=0;i<victim->skeleton.num_joints;i++){
4292 victim->skeleton.joints[i].velocity=0;
4294 if(weaponactive!=-1){
4297 gLoc[0]=victim->coords.x;
4298 gLoc[1]=victim->coords.y;
4299 gLoc[2]=victim->coords.z;
4303 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4304 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4305 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4306 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4307 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4308 weapons.blooddrip[weaponids[weaponactive]]+=5;
4310 XYZ footvel,footpoint;
4312 footpoint=weapons.tippoint[weaponids[0]];
4313 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4314 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4315 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4316 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4317 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4318 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4322 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4324 if(id==0)camerashake+=.4;
4331 gLoc[0]=victim->coords.x;
4332 gLoc[1]=victim->coords.y;
4333 gLoc[2]=victim->coords.z;
4337 if(weaponactive==-1){
4338 if(tutoriallevel!=1){
4339 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4340 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4341 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4342 OPENAL_SetPaused(channels[heavyimpactsound], false);
4347 if(weaponactive!=-1||creature==wolftype)doslice=1;
4348 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4350 if(weaponactive!=-1){
4351 victim->DoBloodBig(2/victim->armorhead,225);
4352 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4353 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4354 OPENAL_SetVolume(channels[knifeslicesound], 512);
4355 OPENAL_SetPaused(channels[knifeslicesound], false);
4356 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4357 weapons.blooddrip[weaponids[weaponactive]]+=3;
4359 if(weaponactive==-1&&creature==wolftype){
4360 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4361 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4362 OPENAL_SetVolume(channels[clawslicesound], 128);
4363 OPENAL_SetPaused(channels[clawslicesound], false);
4365 victim->DoBloodBig(2/victim->armorhead,175);
4378 //relative=victim->coords-oldcoords;
4381 Normalise(&relative);
4382 relative=DoRotation(relative,0,90,0);
4384 Normalise(&relative);
4385 for(i=0;i<victim->skeleton.num_joints;i++){
4386 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4388 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4389 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4390 victim->DoDamage(damagemult*100/victim->protectionhead);
4394 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4398 //relative=victim->coords-oldcoords;
4401 Normalise(&relative);
4402 relative=DoRotation(relative,0,90,0);
4404 Normalise(&relative);
4405 for(i=0;i<victim->skeleton.num_joints;i++){
4406 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4408 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4411 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4412 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4423 if(targetframe>animation[currentanimation].numframes-1){
4426 targetanimation=getIdle();
4430 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4431 targetanimation=rollanim;
4442 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4443 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4444 OPENAL_SetVolume(channels[movewhooshsound], 128);
4445 OPENAL_SetPaused(channels[movewhooshsound], false);
4447 if(currentanimation==staggerbackhighanim){
4448 targetanimation=getIdle();
4450 if(currentanimation==staggerbackhardanim){
4451 targetanimation=getIdle();
4453 if(currentanimation==removeknifeanim){
4454 targetanimation=getIdle();
4456 if(currentanimation==crouchremoveknifeanim){
4457 targetanimation=getCrouch();
4459 if(currentanimation==backhandspringanim){
4460 targetanimation=getIdle();
4462 if(currentanimation==dodgebackanim){
4463 targetanimation=getIdle();
4465 if(currentanimation==drawleftanim){
4466 targetanimation=getIdle();
4468 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4469 targetanimation=getIdle();
4470 if(currentanimation==crouchdrawrightanim){
4471 targetanimation=getCrouch();
4473 if(weaponactive==-1)weaponactive=0;
4474 else if(weaponactive==0){
4478 buffer=weaponids[0];
4479 weaponids[0]=weaponids[1];
4480 weaponids[1]=buffer;
4484 if(weaponactive==-1){
4494 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4495 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4496 OPENAL_SetVolume(channels[knifesheathesound], 128);
4497 OPENAL_SetPaused(channels[knifesheathesound], false);
4499 if(weaponactive!=-1){
4509 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4510 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4511 OPENAL_SetVolume(channels[knifedrawsound], 128);
4512 OPENAL_SetPaused(channels[knifedrawsound], false);
4515 if(currentanimation==rollanim){
4516 targetanimation=getCrouch();
4521 if(targetanimation==walljumprightkickanim){
4524 if(targetanimation==walljumpleftkickanim){
4527 targetanimation=jumpdownanim;
4529 if(currentanimation==climbanim){
4530 targetanimation=getCrouch();
4533 if(!isnormal(coords.x))
4544 if(targetanimation==rabbitkickreversalanim){
4545 targetanimation=getCrouch();
4548 if(targetanimation==jumpreversalanim){
4549 targetanimation=getCrouch();
4552 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4553 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4555 float closestdist=-1;
4558 for(i=0;i<numplayers;i++){
4559 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4560 distance=findDistancefast(&player[i].coords,&coords);
4561 if(closestdist==-1||distance<closestdist){
4562 closestdist=distance;
4567 if(closestdist>0&&closest>=0&&closestdist<16){
4568 victim=&player[closest];
4569 targetanimation=walljumprightkickanim;
4571 XYZ rotatetarget=victim->coords-coords;
4572 Normalise(&rotatetarget);
4573 rotation=-asin(0-rotatetarget.x);
4575 if(rotatetarget.z<0)rotation=180-rotation;
4576 targettilt2=-asin(rotatetarget.y)*360/6.28;
4577 velocity=(victim->coords-coords)*4;
4582 if(targetanimation==walljumpbackanim){
4583 targetanimation=backflipanim;
4587 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4589 if(targetanimation==walljumprightanim){
4590 targetanimation=rightflipanim;
4594 velocity=DoRotation(facing,0,30,0)*-8;
4597 if(targetanimation==walljumpfrontanim){
4598 targetanimation=frontflipanim;
4600 //targetrotation-=180;
4605 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4607 if(targetanimation==walljumpleftanim){
4610 float closestdist=-1;
4613 for(i=0;i<numplayers;i++){
4614 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4615 distance=findDistancefast(&player[i].coords,&coords);
4616 if(closestdist==-1||distance<closestdist){
4617 closestdist=distance;
4622 if(closestdist>0&&closest>=0&&closestdist<16){
4623 victim=&player[closest];
4624 targetanimation=walljumpleftkickanim;
4626 XYZ rotatetarget=victim->coords-coords;
4627 Normalise(&rotatetarget);
4628 rotation=-asin(0-rotatetarget.x);
4630 if(rotatetarget.z<0)rotation=180-rotation;
4631 targettilt2=-asin(rotatetarget.y)*360/6.28;
4632 velocity=(victim->coords-coords)*4;
4637 if(targetanimation!=walljumpleftkickanim){
4638 targetanimation=leftflipanim;
4642 velocity=DoRotation(facing,0,-30,0)*-8;
4645 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4647 if(targetanimation==sneakattackanim){
4648 float ycoords=oldcoords.y;
4649 currentanimation=getCrouch();
4650 targetanimation=getCrouch();
4653 targetrotation+=180;
4658 targetheadrotation+=180;
4660 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4664 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4665 float ycoords=oldcoords.y;
4666 targetanimation=getIdle();
4668 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4672 if(currentanimation==knifefollowanim){
4673 targetanimation=getIdle();
4676 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4677 float ycoords=oldcoords.y;
4678 targetanimation=getStop();
4679 targetrotation+=180;
4684 targetheadrotation+=180;
4685 if(!isnormal(coords.x))
4687 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4688 oldcoords=coords+facing*.5;
4689 else if(currentanimation==sweepreversalanim)
4690 oldcoords=coords+facing*1.1;
4691 else if(currentanimation==upunchreversalanim){
4692 oldcoords=coords+facing*1.5;
4693 targetrotation+=180;
4695 targetheadrotation+=180;
4699 else if(currentanimation==knifeslashreversalanim){
4700 oldcoords=coords+facing*.5;
4703 targetheadrotation+=90;
4707 else if(currentanimation==staffspinhitreversalanim){
4708 targetrotation+=180;
4710 targetheadrotation+=180;
4714 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4715 else oldcoords.y=ycoords;
4716 currentoffset=coords-oldcoords;
4722 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4727 if(animation[targetanimation].attack==reversed){
4729 if(targetanimation==sweepreversedanim)targetrotation+=90;
4730 targetanimation=backhandspringanim;
4740 PlaySoundEx( landsound, samp[landsound], NULL, true);
4741 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4742 OPENAL_SetVolume(channels[landsound], 128);
4743 OPENAL_SetPaused(channels[landsound], false);
4745 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4746 targetanimation=rollanim;
4749 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4750 coords.y=oldcoords.y;
4752 if(currentanimation==knifeslashreversedanim){
4753 targetanimation=rollanim;
4758 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4759 coords.y=oldcoords.y;
4763 targetanimation=jumpdownanim;
4765 if(wasLanding())targetanimation=getIdle();
4766 if(wasLandhard())targetanimation=getIdle();
4767 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4768 targetanimation=getIdle();
4770 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4771 coords.y=oldcoords.y;
4772 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4773 targetoffset.y=coords.y;
4774 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4775 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4776 currentoffset.y-=(coords.y-targetoffset.y);
4777 coords.y=targetoffset.y;
4779 normalsupdatedelay=0;
4781 if(currentanimation==upunchanim){
4782 targetanimation=getStop();
4783 normalsupdatedelay=0;
4786 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4787 targetrotation=rotation;
4790 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4791 if(!hasstaff)DoDamage(35);
4794 rabbitkickragdoll=1;
4796 if(currentanimation==rabbitkickreversedanim){
4803 if(id!=0)SolidHitBonus();
4807 targetanimation=rollanim;
4809 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4813 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4819 if(currentanimation==jumpreversedanim){
4826 if(id!=0)SolidHitBonus();
4830 targetanimation=rollanim;
4832 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4837 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){
4838 targetanimation=getupfromfrontanim;
4841 else if(animation[currentanimation].attack==normalattack){
4842 targetanimation=getIdle();
4845 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4846 targetanimation=blockhighleftstrikeanim;
4848 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4849 targetanimation=getIdle();
4852 if(currentanimation==spinkickanim&&victim->skeleton.free){
4853 if(creature==rabbittype)targetanimation=fightidleanim;
4858 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4860 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4861 targetanimation=jumpdownanim;
4866 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4867 if(!isRun()||!wasRun()){
4868 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4869 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4870 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4871 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4873 if(isRun()&&wasRun()){
4876 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4877 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4880 else if(transspeed)target+=multiplier*transspeed*speed*2;
4882 if(!isRun()||!wasRun()){
4883 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4884 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4885 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4886 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4890 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4892 if(target>1){currentframe=targetframe; target=1;}
4894 rot=targetrot*target;
4895 rotation+=rot-oldrot;
4901 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4903 for(i=0;i<skeleton.num_joints;i++){
4904 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4907 skeleton.FindForwards();
4909 for(i=0;i<skeleton.num_muscles;i++){
4910 if(skeleton.muscles[i].visible)
4912 skeleton.FindRotationMuscle(i,targetanimation);
4915 for(i=0;i<skeleton.num_muscles;i++){
4916 if(skeleton.muscles[i].visible)
4918 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4919 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4920 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4925 for(i=0;i<skeleton.num_joints;i++){
4926 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4929 skeleton.FindForwards();
4931 for(i=0;i<skeleton.num_muscles;i++){
4932 if(skeleton.muscles[i].visible)
4934 skeleton.FindRotationMuscle(i,targetanimation);
4937 for(i=0;i<skeleton.num_muscles;i++){
4938 if(skeleton.muscles[i].visible)
4940 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4941 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4942 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4943 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4944 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4945 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4946 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4947 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4948 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4952 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4954 oldcurrentanimation=currentanimation;
4955 oldtargetanimation=targetanimation;
4956 oldtargetframe=targetframe;
4957 oldcurrentframe=currentframe;
4959 for(i=0;i<skeleton.num_joints;i++){
4960 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4961 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4963 offset=currentoffset*(1-target)+targetoffset*target;
4964 for(i=0;i<skeleton.num_muscles;i++){
4965 if(skeleton.muscles[i].visible)
4967 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4968 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4969 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4974 if(isLanding()&&landhard){
4975 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4976 if(id==0)camerashake+=.4;
4977 targetanimation=getLandhard();
4985 //skeleton.DoConstraints();
4988 void Person::DoStuff(){
4989 static XYZ terrainnormal;
4990 static XYZ flatfacing;
4991 static XYZ flatvelocity;
4992 static float flatvelspeed;
4996 static int bloodsize;
4997 static int startx,starty,endx,endy;
4998 static int texdetailint;
4999 static GLubyte color;
5000 static XYZ bloodvel;
5002 onfiredelay-=multiplier;
5003 if(onfiredelay<0&&onfire)
5011 crouchkeydowntime+=multiplier;
5012 if(!crouchkeydown)crouchkeydowntime=0;
5013 jumpkeydowntime+=multiplier;
5014 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
5016 if(hostile||damage>0||bloodloss>0)immobile=0;
5018 if(isIdle()||isRun())targetoffset=0;
5020 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
5022 if(id==0)blooddimamount-=multiplier*.3;
5023 speechdelay-=multiplier;
5024 texupdatedelay-=multiplier;
5025 interestdelay-=multiplier;
5026 flamedelay-=multiplier;
5027 parriedrecently-=multiplier;
5033 if(id==0)speed=1.1*speedmult;
5034 else speed=1.0*speedmult;
5035 if(!skeleton.free)rabbitkickragdoll=0;
5039 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
5040 if(id!=0&&creature==wolftype&&difficulty==2){
5042 if(aitype!=passivetype){
5044 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){
5048 if(scale<0.2)superruntoggle=0;
5049 if(targetanimation==wolfrunninganim&&!superruntoggle){
5050 targetanimation=getRun();
5053 /*static float toggledelay;
5054 toggledelay-=multiplier;
5057 if(Random()%3==0)superruntoggle=1-superruntoggle;
5060 if(weaponactive==-1&&num_weapons>0){
5061 if(weapons.type[weaponids[0]]==staff){
5068 /*if(aitype!=playercontrolled)*///deathbleeding=5;
5069 /*if(aitype!=playercontrolled)*/
5071 if(burnt>.6)burnt=.6;
5072 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
5074 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5085 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
5086 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
5090 while(flamedelay<0&&onfire){
5092 howmany=abs(Random()%(skeleton.num_joints));
5093 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
5094 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
5095 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
5096 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
5097 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5100 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
5102 howmany=abs(Random()%(skeleton.num_joints));
5103 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
5104 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
5105 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
5106 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
5107 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
5111 bleeding-=multiplier*.3;
5113 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5114 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
5118 if(neckspurtamount>0){
5119 neckspurtamount-=multiplier;
5120 neckspurtdelay-=multiplier*3;
5121 neckspurtparticledelay-=multiplier*3;
5122 if(neckspurtparticledelay<0&&neckspurtdelay>2){
5126 bloodvel.z=5*neckspurtamount;
5127 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
5130 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
5132 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
5133 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
5134 if(skeleton.free)Sprite::MakeSprite(bloodsprite, (skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5)*scale+coords,bloodvel, 1,1,1, .05, .9);
5135 if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position+(skeleton.joints[skeleton.jointlabels[neck]].position-skeleton.joints[skeleton.jointlabels[head]].position)/5,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, .9);
5136 neckspurtparticledelay=.05;
5138 if(neckspurtdelay<0){
5143 if(deathbleeding>0&&dead!=2){
5144 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
5145 else bleeddelay-=5*multiplier/4;
5146 if(bleeddelay<0&&bloodtoggle){
5151 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
5152 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
5153 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
5154 if(!skeleton.free)Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
5158 bloodloss+=deathbleeding*40;
5161 bloodloss+=deathbleeding*multiplier*80;
5162 deathbleeding-=multiplier*1.6;
5163 //if(id==0)deathbleeding-=multiplier*.2;
5164 if(deathbleeding<0)deathbleeding=0;
5165 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
5166 if(weaponactive!=-1){
5167 weapons.owner[weaponids[0]]=-1;
5168 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5169 weapons.velocity[weaponids[0]].x+=.01;
5170 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5171 weapons.missed[weaponids[0]]=1;
5172 weapons.hitsomething[weaponids[0]]=0;
5173 weapons.freetime[weaponids[0]]=0;
5174 weapons.firstfree[weaponids[0]]=1;
5175 weapons.physics[weaponids[0]]=1;
5178 weaponids[0]=weaponids[num_weapons];
5179 if(weaponstuck==num_weapons)weaponstuck=0;
5182 for(i=0;i<numplayers;i++){
5183 player[i].wentforweapon=0;
5195 if(!dead&&creature==wolftype){
5201 if(targetanimation==knifefollowedanim&&!skeleton.free){
5202 for(i=0;i<skeleton.num_joints;i++){
5203 skeleton.joints[i].velocity=0;
5204 skeleton.joints[i].velocity.y=-2;
5207 if(id!=0&&unconscioustime>.1){
5215 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
5218 bloodsize=5-realtexdetail;
5222 texdetailint=realtexdetail;
5223 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5224 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5225 endx=startx+bloodsize;
5226 endy=starty+bloodsize;
5228 if(startx<0){startx=0;bleeding=0;}
5229 if(starty<0){starty=0;bleeding=0;}
5230 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
5231 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
5232 if(endx<startx)endx=startx;
5233 if(endy<starty)endy=starty;
5239 for(i=startx;i<endx;i++){
5240 for(j=starty;j<endy;j++){
5242 color=Random()%85+170;
5243 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
5244 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
5245 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
5250 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5251 DoMipmaps(0,startx,endx,starty,endy);
5255 bleedy-=4/realtexdetail;
5256 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
5257 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
5260 bleedx+=4*direction/realtexdetail;
5261 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
5262 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
5266 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
5267 righthandmorphness=targetrighthandmorphness;
5268 righthandmorphstart=righthandmorphend;
5270 else if(righthandmorphness>targetrighthandmorphness){
5271 righthandmorphness-=multiplier*4;
5273 else if(righthandmorphness<targetrighthandmorphness){
5274 righthandmorphness+=multiplier*4;
5277 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
5278 lefthandmorphness=targetlefthandmorphness;
5279 lefthandmorphstart=lefthandmorphend;
5281 else if(lefthandmorphness>targetlefthandmorphness){
5282 lefthandmorphness-=multiplier*4;
5284 else if(lefthandmorphness<targetlefthandmorphness){
5285 lefthandmorphness+=multiplier*4;
5288 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
5289 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
5290 tailmorphness=targettailmorphness;
5291 tailmorphstart=tailmorphend;
5293 else if(tailmorphness>targettailmorphness){
5294 tailmorphness-=multiplier*10;
5296 else if(tailmorphness<targettailmorphness){
5297 tailmorphness+=multiplier*10;
5301 if(creature==wolftype){
5302 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
5303 tailmorphness=targettailmorphness;
5304 tailmorphstart=tailmorphend;
5306 else if(tailmorphness>targettailmorphness){
5307 tailmorphness-=multiplier*2;
5309 else if(tailmorphness<targettailmorphness){
5310 tailmorphness+=multiplier*2;
5314 if(headmorphend==3||headmorphstart==3){
5315 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
5316 headmorphness=targetheadmorphness;
5317 headmorphstart=headmorphend;
5319 else if(headmorphness>targetheadmorphness){
5320 headmorphness-=multiplier*7;
5322 else if(headmorphness<targetheadmorphness){
5323 headmorphness+=multiplier*7;
5326 else if(headmorphend==5||headmorphstart==5){
5327 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
5328 headmorphness=targetheadmorphness;
5329 headmorphstart=headmorphend;
5331 else if(headmorphness>targetheadmorphness){
5332 headmorphness-=multiplier*10;
5334 else if(headmorphness<targetheadmorphness){
5335 headmorphness+=multiplier*10;
5339 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5340 headmorphness=targetheadmorphness;
5341 headmorphstart=headmorphend;
5343 else if(headmorphness>targetheadmorphness){
5344 headmorphness-=multiplier*4;
5346 else if(headmorphness<targetheadmorphness){
5347 headmorphness+=multiplier*4;
5351 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5352 chestmorphness=targetchestmorphness;
5353 chestmorphstart=chestmorphend;
5355 else if(chestmorphness>targetchestmorphness){
5356 chestmorphness-=multiplier;
5358 else if(chestmorphness<targetchestmorphness){
5359 chestmorphness+=multiplier;
5362 if(dead!=2&&howactive<=typesleeping){
5363 if(chestmorphstart==0&&chestmorphend==0){
5365 targetchestmorphness=1;
5368 if(chestmorphstart!=0&&chestmorphend!=0){
5370 targetchestmorphness=1;
5372 if(environment==snowyenvironment){
5375 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5376 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5377 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5378 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5379 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5380 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5384 if(!dead&&howactive<typesleeping){
5385 blinkdelay-=multiplier*2;
5386 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5388 targetheadmorphness=1;
5390 blinkdelay=(float)(abs(Random()%40))/5;
5392 if(headmorphstart==3&&headmorphend==3){
5394 targetheadmorphness=1;
5399 twitchdelay-=multiplier*1.5;
5400 if(targetanimation!=hurtidleanim){
5401 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5403 targetheadmorphness=1;
5405 twitchdelay=(float)(abs(Random()%40))/5;
5407 if(headmorphstart==5&&headmorphend==5){
5409 targetheadmorphness=1;
5413 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5414 twitchdelay3-=multiplier*1;
5416 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5417 righthandmorphness=0;
5418 targetrighthandmorphness=1;
5419 righthandmorphend=1;
5420 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5422 if(righthandmorphstart==1&&righthandmorphend==1){
5423 righthandmorphness=0;
5424 targetrighthandmorphness=1;
5425 righthandmorphend=0;
5429 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5430 lefthandmorphness=0;
5431 targetlefthandmorphness=1;
5433 twitchdelay3=(float)(abs(Random()%40))/5;
5435 if(lefthandmorphstart==1&&lefthandmorphend==1){
5436 lefthandmorphness=0;
5437 targetlefthandmorphness=1;
5444 if(creature==rabbittype){
5445 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5446 else twitchdelay2-=multiplier*0.5;
5447 if(howactive<=typesleeping){
5448 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5450 targettailmorphness=1;
5452 twitchdelay2=(float)(abs(Random()%40))/5;
5454 if(tailmorphstart==1&&tailmorphend==1){
5456 targettailmorphness=1;
5459 if(tailmorphstart==2&&tailmorphend==2){
5461 targettailmorphness=1;
5468 if(creature==wolftype){
5469 twitchdelay2-=multiplier*1.5;
5471 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5473 targettailmorphness=1;
5478 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5480 targettailmorphness=1;
5484 if(twitchdelay2<=0){
5485 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5487 targettailmorphness=1;
5490 if(tailmorphstart==1&&tailmorphend==1){
5492 targettailmorphness=1;
5495 if(tailmorphstart==2&&tailmorphend==2){
5497 targettailmorphness=1;
5500 if(tailmorphstart==3&&tailmorphend==3){
5502 targettailmorphness=1;
5505 if(tailmorphstart==4&&tailmorphend==4){
5507 targettailmorphness=1;
5513 if(dead!=1)unconscioustime=0;
5515 if(dead==1||howactive==typesleeping){
5516 unconscioustime+=multiplier;
5517 //If unconscious, close eyes and mouth
5518 if(righthandmorphend!=0)righthandmorphness=0;
5519 righthandmorphend=0;
5520 targetrighthandmorphness=1;
5522 if(lefthandmorphend!=0)lefthandmorphness=0;
5524 targetlefthandmorphness=1;
5526 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5528 targetheadmorphness=1;
5532 if(howactive>typesleeping){
5535 if(bloodtoggle&&!bled){
5536 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5538 if(bloodtoggle&&!bled)
5539 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5540 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5541 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5545 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5550 if(dead==2||howactive>typesleeping){
5551 //If dead, open mouth and hands
5552 if(righthandmorphend!=0)righthandmorphness=0;
5553 righthandmorphend=0;
5554 targetrighthandmorphness=1;
5556 if(lefthandmorphend!=0)lefthandmorphness=0;
5558 targetlefthandmorphness=1;
5560 if(headmorphend!=2)headmorphness=0;
5562 targetheadmorphness=1;
5565 if(stunned>0&&!dead&&headmorphend!=2){
5566 if(headmorphend!=4)headmorphness=0;
5568 targetheadmorphness=1;
5571 if(damage>damagetolerance&&!dead){
5576 if(creature==wolftype){
5584 if(weaponactive!=-1){
5585 weapons.owner[weaponids[0]]=-1;
5586 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5587 weapons.velocity[weaponids[0]].x+=.01;
5588 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5589 weapons.missed[weaponids[0]]=1;
5590 weapons.hitsomething[weaponids[0]]=0;
5591 weapons.freetime[weaponids[0]]=0;
5592 weapons.firstfree[weaponids[0]]=1;
5593 weapons.physics[weaponids[0]]=1;
5596 weaponids[0]=weaponids[num_weapons];
5597 if(weaponstuck==num_weapons)weaponstuck=0;
5600 for(i=0;i<numplayers;i++){
5601 player[i].wentforweapon=0;
5607 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5615 if(bloodloss<damagetolerance)
5616 for(i=0;i<skeleton.num_joints;i++){
5617 skeleton.joints[i].velocity*=1.5;
5621 //if(dead)damage-=multiplier/4;
5622 if(!dead)damage-=multiplier*13;
5623 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5624 if(!dead)permanentdamage-=multiplier*4;
5625 if(isIdle()||isCrouch()){
5626 if(!dead)permanentdamage-=multiplier*4;
5627 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5629 if(damage<0)damage=0;
5630 if(permanentdamage<0)permanentdamage=0;
5631 if(superpermanentdamage<0)superpermanentdamage=0;
5632 if(permanentdamage<superpermanentdamage){
5633 permanentdamage=superpermanentdamage;
5635 if(damage<permanentdamage){
5636 damage=permanentdamage;
5638 if(dead==1&&damage<damagetolerance){
5642 for(i=0;i<skeleton.num_joints;i++){
5643 skeleton.joints[i].velocity=0;
5646 if(permanentdamage>damagetolerance&&dead!=2){
5649 if(weaponactive!=-1){
5650 weapons.owner[weaponids[0]]=-1;
5651 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5652 weapons.velocity[weaponids[0]].x+=.01;
5653 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5654 weapons.missed[weaponids[0]]=1;
5655 weapons.hitsomething[weaponids[0]]=0;
5656 weapons.freetime[weaponids[0]]=0;
5657 weapons.firstfree[weaponids[0]]=1;
5658 weapons.physics[weaponids[0]]=1;
5661 weaponids[0]=weaponids[num_weapons];
5662 if(weaponstuck==num_weapons)weaponstuck=0;
5665 for(i=0;i<numplayers;i++){
5666 player[i].wentforweapon=0;
5672 if(!dead&&creature==wolftype){
5678 if(id!=0&&unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance){
5683 if(id!=0&&unconscioustime>.1){
5699 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5700 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5701 OPENAL_SetVolume(channels[breaksound], 512);
5702 OPENAL_SetPaused(channels[breaksound], false);
5703 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5709 if(skeleton.free==1){
5710 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5713 //If knocked over, open hands and close mouth
5714 if(righthandmorphend!=0)righthandmorphness=0;
5715 righthandmorphend=0;
5716 targetrighthandmorphness=1;
5718 if(lefthandmorphend!=0)lefthandmorphness=0;
5720 targetlefthandmorphness=1;
5722 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5723 if(headmorphend!=0)headmorphness=0;
5725 targetheadmorphness=1;
5729 skeleton.DoGravity(&scale);
5731 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5732 if(id!=0&&damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1)){
5737 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5741 for(j=0;j<skeleton.num_joints;j++){
5742 average+=skeleton.joints[j].position;
5746 coords+=average*scale;
5747 for(j=0;j<skeleton.num_joints;j++){
5748 skeleton.joints[j].position-=average;
5750 average/=multiplier;
5752 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5754 for(i=0;i<skeleton.num_joints;i++){
5755 velocity+=skeleton.joints[i].velocity*scale;
5757 velocity/=skeleton.num_joints;
5759 if(!isnormal(velocity.x)&&velocity.x){
5772 if(findLength(&average)<10&&dead&&skeleton.free){
5773 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5774 if(skeleton.longdead>2000){
5775 if(skeleton.longdead>6000){
5776 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5781 if(dead==2&&bloodloss<damagetolerance){
5783 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5785 if(bloodtoggle&&!bled){
5786 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5788 if(bloodtoggle&&!bled)
5789 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5790 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5791 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5795 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5799 if(dead==2&&bloodloss>=damagetolerance){
5801 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5802 if(bleeding<=0)DoBlood(1,255);
5803 if(bloodtoggle&&!bled){
5804 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5806 if(bloodtoggle&&!bled)
5807 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5808 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5809 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5813 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5820 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5822 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5826 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5827 if(velocity.y<-30)canrecover=0;
5828 for(i=0;i<objects.numobjects;i++){
5829 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5830 colviewer=startpoint;
5832 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5840 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5841 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5842 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5843 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5845 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5846 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5847 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5849 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5850 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5851 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5853 Normalise(&terrainnormal);
5855 targetrotation=-asin(0-terrainnormal.x);
5856 targetrotation*=360/6.28;
5857 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5858 rotation=targetrotation;
5860 //if(skeleton.forward.y<0){
5863 //if(skeleton.forward.y>-.3){
5866 targetanimation=flipanim;
5867 crouchtogglekeydown=1;
5872 currentanimation=tempanim;
5875 //tilt2=targettilt2;
5877 //if(middle.y>0)targetoffset.y=middle.y+1;
5879 for(i=0;i<skeleton.num_joints;i++){
5880 tempanimation.position[i][0]=skeleton.joints[i].position;
5881 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5886 if(findLength(&average)<10&&!dead&&skeleton.free){
5887 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5888 if(skeleton.longdead>(damage+500)*1.5){
5889 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5895 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5896 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5897 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5898 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5900 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5901 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5902 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5904 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5905 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5906 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5908 Normalise(&terrainnormal);
5910 targetrotation=-asin(0-terrainnormal.x);
5911 targetrotation*=360/6.28;
5912 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5913 rotation=targetrotation;
5916 terrainnormal=terrain.getNormal(coords.x,coords.z);
5917 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5921 /*XYZ otherterrainnormal;
5922 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5923 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5924 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5925 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5928 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5932 if(skeleton.forward.y<0){
5933 targetanimation=getupfrombackanim;
5937 if(skeleton.forward.y>-.3){
5938 targetanimation=getupfromfrontanim;
5940 targetrotation+=180;
5946 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5947 targetanimation=rollanim;
5948 targetrotation=lookrotation;
5952 if(forwardkeydown)targetrotation+=45;
5953 if(backkeydown)targetrotation-=45;
5957 if(forwardkeydown)targetrotation-=45;
5958 if(backkeydown)targetrotation+=45;
5961 if ( !leftkeydown&&!rightkeydown)
5962 targetrotation+=180;
5964 targetrotation+=180;
5968 if(abs(targettilt2)>50)targettilt2=0;
5969 currentanimation=tempanim;
5974 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5976 for(i=0;i<skeleton.num_joints;i++){
5977 tempanimation.position[i][0]=skeleton.joints[i].position;
5978 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5985 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5986 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5989 tempvelocity=velocity;
5990 Normalise(&tempvelocity);
5991 targetrotation=-asin(0-tempvelocity.x);
5992 targetrotation*=360/6.28;
5993 if(velocity.z<0)targetrotation=180-targetrotation;
5994 //targetrotation+=180;
5997 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5998 targetanimation=rollanim;
6002 targetanimation=backhandspringanim;
6003 targetrotation+=180;
6016 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
6017 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
6018 OPENAL_SetVolume(channels[movewhooshsound], 128);
6019 OPENAL_SetPaused(channels[movewhooshsound], false);
6021 currentanimation=targetanimation;
6022 currentframe=targetframe-1;
6027 rotation=targetrotation;
6034 if(skeleton.freefall==0)freefall=0;
6036 if(!isnormal(velocity.x)&&velocity.x){
6041 if(aitype!=passivetype||skeleton.free==1)
6042 if(findLengthfast(&velocity)>.1)
6043 for(i=0;i<objects.numobjects;i++){
6044 if(objects.type[i]==firetype)
6045 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){
6047 if(!objects.onfire[i]){
6050 gLoc[0]=objects.position[i].x;
6051 gLoc[1]=objects.position[i].y;
6052 gLoc[2]=objects.position[i].z;
6056 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
6057 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6058 OPENAL_SetVolume(channels[firestartsound], 256);
6059 OPENAL_SetPaused(channels[firestartsound], false);
6061 objects.onfire[i]=1;
6064 if(objects.onfire[i]){
6069 if(objects.type[i]==bushtype)
6070 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){
6072 if(!objects.onfire[i]){
6075 gLoc[0]=objects.position[i].x;
6076 gLoc[1]=objects.position[i].y;
6077 gLoc[2]=objects.position[i].z;
6081 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
6082 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6083 OPENAL_SetVolume(channels[firestartsound], 256);
6084 OPENAL_SetPaused(channels[firestartsound], false);
6086 objects.onfire[i]=1;
6090 if(objects.onfire[i]){
6094 if(objects.messedwith[i]<=0){
6106 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
6107 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
6108 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
6109 OPENAL_SetPaused(channels[bushrustle], false);
6112 envsound[numenvsounds]=coords;
6113 envsoundvol[numenvsounds]=4*findLength(&velocity);
6114 envsoundlife[numenvsounds]=.4;
6119 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6120 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6122 if(environment!=desertenvironment)
6123 for(j=0;j<howmany;j++){
6124 tempvel.x=float(abs(Random()%100)-50)/20;
6125 tempvel.y=float(abs(Random()%100)-50)/20;
6126 tempvel.z=float(abs(Random()%100)-50)/20;
6129 pos.x+=float(abs(Random()%100)-50)/200;
6130 pos.y+=float(abs(Random()%100)-50)/200;
6131 pos.z+=float(abs(Random()%100)-50)/200;
6132 Sprite::MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
6133 Sprite::setLastSpriteSpecial(1);
6135 howmany=findLength(&velocity)*4;
6137 if(environment==snowyenvironment)
6138 for(j=0;j<howmany;j++){
6139 tempvel.x=float(abs(Random()%100)-50)/20;
6140 tempvel.y=float(abs(Random()%100)-50)/20;
6141 tempvel.z=float(abs(Random()%100)-50)/20;
6144 pos.x+=float(abs(Random()%100)-50)/200;
6145 pos.y+=float(abs(Random()%100)-50)/200;
6146 pos.z+=float(abs(Random()%100)-50)/200;
6147 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6148 Sprite::setLastSpriteSpecial(2);
6151 objects.rotx[i]+=velocity.x*multiplier*6;
6152 objects.roty[i]+=velocity.z*multiplier*6;
6153 objects.messedwith[i]=.5;
6156 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
6157 if(objects.rotation2[i]==0)tempcoord=coords;
6159 tempcoord=coords-objects.position[i];
6160 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
6161 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
6162 tempcoord+=objects.position[i];
6164 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]){
6165 if(objects.messedwith[i]<=0){
6177 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
6178 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
6179 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
6180 OPENAL_SetPaused(channels[bushrustle], false);
6183 envsound[numenvsounds]=coords;
6184 envsoundvol[numenvsounds]=4*findLength(&velocity);
6185 envsoundlife[numenvsounds]=.4;
6190 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6191 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6193 if(environment!=desertenvironment)
6194 for(j=0;j<howmany;j++){
6195 tempvel.x=float(abs(Random()%100)-50)/20;
6196 tempvel.y=float(abs(Random()%100)-50)/20;
6197 tempvel.z=float(abs(Random()%100)-50)/20;
6201 pos.x+=float(abs(Random()%100)-50)/150;
6202 pos.y+=float(abs(Random()%100)-50)/150;
6203 pos.z+=float(abs(Random()%100)-50)/150;
6204 Sprite::MakeSprite(splintersprite, pos,tempvel*.5+velocity*float(abs(Random()%100))/100, 165/255+float(abs(Random()%100)-50)/400,0,0, .2+float(abs(Random()%100)-50)/1300, 1);
6205 Sprite::setLastSpriteSpecial(1);
6207 howmany=findLength(&velocity)*4;
6209 if(environment==snowyenvironment)
6210 for(j=0;j<howmany;j++){
6211 tempvel.x=float(abs(Random()%100)-50)/20;
6212 tempvel.y=float(abs(Random()%100)-50)/20;
6213 tempvel.z=float(abs(Random()%100)-50)/20;
6217 pos.x+=float(abs(Random()%100)-50)/150;
6218 pos.y+=float(abs(Random()%100)-50)/150;
6219 pos.z+=float(abs(Random()%100)-50)/150;
6220 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6221 Sprite::setLastSpriteSpecial(2);
6224 objects.messedwith[i]=.5;
6232 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
6234 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
6235 if(tutoriallevel==1&&id!=0)play=0;
6236 if(play&&aitype!=playercontrolled){
6248 if(creature==rabbittype){
6249 if(i==0)whichsound=rabbitchitter;
6250 if(i==1)whichsound=rabbitchitter2;
6252 if(creature==wolftype){
6253 if(i==0)whichsound=growlsound;
6254 if(i==1)whichsound=growl2sound;
6260 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
6261 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
6262 OPENAL_SetVolume(channels[whichsound], 512);
6263 OPENAL_SetPaused(channels[whichsound], false);
6267 if(targetanimation==staggerbackhighanim)staggerdelay=1;
6268 if(targetanimation==staggerbackhardanim)staggerdelay=1;
6269 staggerdelay-=multiplier;
6270 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
6271 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
6272 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
6273 targetanimation=getIdle();
6277 weaponmissdelay-=multiplier;
6278 highreversaldelay-=multiplier;
6279 lowreversaldelay-=multiplier;
6280 lastcollide-=multiplier;
6281 skiddelay-=multiplier;
6282 if(!isnormal(velocity.x)&&velocity.x){
6285 if(!isnormal(targettilt)&&targettilt){
6288 if(!isnormal(targettilt2)&&targettilt2){
6291 if(!isnormal(targetrotation)&&targetrotation){
6295 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
6296 //open hands and close mouth
6297 //if(targetanimation!=wolfidle){
6298 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6299 righthandmorphness=0;
6300 righthandmorphend=0;
6301 targetrighthandmorphness=1;
6304 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6305 lefthandmorphness=0;
6307 targetlefthandmorphness=1;
6311 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
6314 targetheadmorphness=1;
6318 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){
6319 //open hands and mouth
6320 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6321 righthandmorphness=0;
6322 righthandmorphend=0;
6323 targetrighthandmorphness=1;
6326 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6327 lefthandmorphness=0;
6329 targetlefthandmorphness=1;
6332 if(headmorphend!=1&&headmorphness==targetheadmorphness){
6335 targetheadmorphness=1;
6339 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
6340 //close hands and mouth
6341 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6342 righthandmorphness=0;
6343 righthandmorphend=1;
6344 targetrighthandmorphness=1;
6347 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6348 lefthandmorphness=0;
6350 targetlefthandmorphness=1;
6353 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6356 targetheadmorphness=1;
6360 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){
6361 //close hands and yell
6362 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6363 righthandmorphness=0;
6364 righthandmorphend=1;
6365 targetrighthandmorphness=1;
6368 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6369 lefthandmorphness=0;
6371 targetlefthandmorphness=1;
6374 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6377 targetheadmorphness=1;
6381 if(speechdelay>.25){
6382 if(headmorphend!=2)headmorphness=0;
6384 targetheadmorphness=1;
6390 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6391 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6395 if(!dead&&targetanimation!=hurtidleanim)
6396 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6397 if(headmorphend!=4||headmorphness==targetheadmorphness){
6400 targetheadmorphness=1;
6404 if(weaponactive!=-1){
6405 if(weapons.type[weaponids[weaponactive]]!=staff){
6406 righthandmorphstart=1;
6407 righthandmorphend=1;
6409 if(weapons.type[weaponids[weaponactive]]==staff){
6410 righthandmorphstart=2;
6411 righthandmorphend=2;
6413 targetrighthandmorphness=1;
6416 terrainnormal=terrain.getNormal(coords.x,coords.z);
6418 if(animation[targetanimation].attack!=reversal){
6419 if(!isnormal(coords.x))
6427 flatfacing=DoRotation(flatfacing,0,rotation,0);
6429 ReflectVector(&facing,terrainnormal);
6432 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6433 if(onterrain)targettilt2=-facing.y*20;
6437 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6438 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6439 flatvelocity=velocity;
6441 flatvelspeed=findLength(&flatvelocity);
6442 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6443 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6444 if(velocity.y<0)targettilt2*=-1;
6445 if(velocity.y<0)targettilt*=-1;
6446 if(targettilt>25)targettilt=25;
6447 if(targettilt<-25)targettilt=-25;
6450 if(targettilt2>45)targettilt2=45;
6451 if(targettilt2<-45)targettilt2=-45;
6452 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6453 else if(tilt2>targettilt2){
6454 tilt2-=multiplier*400;
6456 else if(tilt2<targettilt2){
6457 tilt2+=multiplier*400;
6459 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6460 if(tilt2>25)tilt2=25;
6461 if(tilt2<-25)tilt2=-25;
6464 if(!isnormal(targettilt)&&targettilt){
6467 if(!isnormal(targettilt2)&&targettilt2){
6472 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6473 if(targetanimation==rabbittackleanim){
6474 velocity+=facing*multiplier*speed*700*scale;
6475 velspeed=findLength(&velocity);
6476 if(velspeed>speed*65*scale){
6478 velspeed=speed*65*scale;
6481 velocity.y+=gravity*multiplier*20;
6482 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6483 velspeed=findLength(&velocity);
6484 velocity=flatfacing*velspeed;
6486 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6487 if(isRun()||targetanimation==rabbitkickanim){
6488 velocity+=facing*multiplier*speed*700*scale;
6489 velspeed=findLength(&velocity);
6490 if(velspeed>speed*45*scale){
6492 velspeed=speed*45*scale;
6495 velocity.y+=gravity*multiplier*20;
6496 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6497 velspeed=findLength(&velocity);
6498 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6499 velocity=flatfacing*velspeed;
6503 velocity+=facing*multiplier*speed*700*scale;
6504 velspeed=findLength(&velocity);
6505 if(creature==rabbittype){
6506 if(velspeed>speed*55*scale){
6508 velspeed=speed*55*scale;
6512 if(creature==wolftype){
6513 if(velspeed>speed*75*scale){
6515 velspeed=speed*75*scale;
6519 velocity.y+=gravity*multiplier*20;
6520 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6521 velspeed=findLength(&velocity);
6522 velocity=flatfacing*velspeed;
6525 /*if(creature==wolftype)
6527 velocity+=facing*multiplier*speed*700*scale;
6528 velspeed=findLength(&velocity);
6529 if(velspeed>speed*55*scale){
6531 velspeed=speed*55*scale;
6534 velocity.y+=gravity*multiplier*20;
6535 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6536 velspeed=findLength(&velocity);
6537 velocity=flatfacing*velspeed;
6540 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6541 velocity+=facing*multiplier*speed*700*scale;
6542 velspeed=findLength(&velocity);
6543 if(velspeed>speed*45*scale){
6545 velspeed=speed*45*scale;
6548 velocity.y+=gravity*multiplier*20;
6549 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6550 velspeed=findLength(&velocity);
6551 velocity=flatfacing*velspeed;
6555 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6556 velocity+=facing*multiplier*speed*700*scale;
6557 velspeed=findLength(&velocity);
6558 if(velspeed>speed*25*scale){
6560 velspeed=speed*25*scale;
6563 velocity.y+=gravity*multiplier*20;
6564 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6565 velspeed=findLength(&velocity);
6566 velocity=flatfacing*velspeed;
6569 if(targetanimation==sneakanim||targetanimation==walkanim){
6570 velocity+=facing*multiplier*speed*700*scale;
6571 velspeed=findLength(&velocity);
6572 if(velspeed>speed*12*scale){
6574 velspeed=speed*12*scale;
6577 velocity.y+=gravity*multiplier*20;
6578 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6579 velspeed=findLength(&velocity);
6580 velocity=flatfacing*velspeed;
6583 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6584 velocity+=facing*multiplier*speed*700*scale;
6585 velspeed=findLength(&velocity);
6586 if(velspeed>speed*2*scale){
6588 velspeed=speed*2*scale;
6591 velocity.y+=gravity*multiplier*20;
6592 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6593 velspeed=findLength(&velocity);
6594 velocity=flatfacing*velspeed;
6598 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6599 velocity-=facing*multiplier*speed*700*scale;
6600 velspeed=findLength(&velocity);
6601 if(velspeed>speed*2*scale){
6603 velspeed=speed*2*scale;
6606 velocity.y+=gravity*multiplier*20;
6607 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6608 velspeed=findLength(&velocity);
6609 velocity=flatfacing*velspeed*-1;
6612 if(targetanimation==fightsidestep){
6613 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6614 velspeed=findLength(&velocity);
6615 if(velspeed>speed*12*scale){
6617 velspeed=speed*12*scale;
6620 velocity.y+=gravity*multiplier*20;
6621 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6622 velspeed=findLength(&velocity);
6623 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6626 if(targetanimation==staggerbackhighanim){
6627 coords-=facing*multiplier*speed*16*scale;
6630 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6631 coords-=facing*multiplier*speed*20*scale;
6635 if(targetanimation==backhandspringanim){
6636 //coords-=facing*multiplier*50*scale;
6637 velocity+=facing*multiplier*speed*700*scale*-1;
6638 velspeed=findLength(&velocity);
6639 if(velspeed>speed*50*scale){
6641 velspeed=speed*50*scale;
6644 velocity.y+=gravity*multiplier*20;
6645 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6646 velspeed=findLength(&velocity);
6647 velocity=flatfacing*velspeed*-1;
6649 if(targetanimation==dodgebackanim){
6650 //coords-=facing*multiplier*50*scale;
6651 velocity+=facing*multiplier*speed*700*scale*-1;
6652 velspeed=findLength(&velocity);
6653 if(velspeed>speed*60*scale){
6655 velspeed=speed*60*scale;
6658 velocity.y+=gravity*multiplier*20;
6659 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6660 velspeed=findLength(&velocity);
6661 velocity=flatfacing*velspeed*-1;
6664 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6665 velspeed=findLength(&velocity);
6669 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6670 velocity.y+=gravity*multiplier;
6673 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6675 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6676 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6678 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6684 OPENAL_SetPaused(channels[whooshsound], true);
6685 OPENAL_SetVolume(channels[whooshsound], 0);
6688 if(targetanimation==jumpdownanim||isFlip()){
6689 if(isFlip())jumppower=-4;
6690 targetanimation=getLanding();
6699 PlaySoundEx( landsound, samp[landsound], NULL, true);
6700 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6701 OPENAL_SetVolume(channels[landsound], 128);
6702 OPENAL_SetPaused(channels[landsound], false);
6705 envsound[numenvsounds]=coords;
6706 envsoundvol[numenvsounds]=16;
6707 envsoundlife[numenvsounds]=.4;
6713 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6714 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6715 coords.y=terrain.getHeight(coords.x,coords.z);
6720 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)){
6721 velspeed=findLength(&velocity);
6723 if(velspeed<multiplier*300*scale){
6725 } else velocity-=velocity/velspeed*multiplier*300*scale;
6726 if(velspeed>5&&(isLanding()||isLandhard())){
6727 skiddingdelay+=multiplier;
6734 else skiddingdelay=0;
6738 velspeed=findLength(&velocity);
6740 if(velspeed<multiplier*600*scale){
6742 } else velocity-=velocity/velspeed*multiplier*600*scale;
6744 if(velspeed>5&&(isLanding()||isLandhard())){
6745 skiddingdelay+=multiplier;
6752 else skiddingdelay=0;
6755 if(skiddingdelay<0)skiddingdelay+=multiplier;
6756 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6766 if(!onterrain||environment==grassyenvironment){
6767 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6768 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6769 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6770 OPENAL_SetPaused(channels[skidsound], false);
6773 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6774 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6775 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6776 OPENAL_SetPaused(channels[snowskidsound], false);
6780 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6781 terrainnormal=victim->coords-coords;
6782 Normalise(&terrainnormal);
6783 targetrotation=-asin(0-terrainnormal.x);
6784 targetrotation*=360/6.28;
6785 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6786 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6789 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6790 targetrotation=victim->targetrotation;
6792 if(targetanimation==rabbittacklinganim){
6793 coords=victim->coords;
6796 skeleton.oldfree=skeleton.free;
6800 midterrain.x=terrain.size*terrain.scale/2;
6801 midterrain.z=terrain.size*terrain.scale/2;
6802 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6804 tempposit=coords-midterrain;
6806 Normalise(&tempposit);
6807 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6808 coords.x=tempposit.x+midterrain.x;
6809 coords.z=tempposit.z+midterrain.z;
6813 int Person::DrawSkeleton(){
6814 int oldplayerdetail;
6815 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6816 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6826 glAlphaFunc(GL_GREATER, 0.0001);
6828 float terrainheight;
6830 if(!isnormal(rotation))rotation=0;
6831 if(!isnormal(tilt))tilt=0;
6832 if(!isnormal(tilt2))tilt2=0;
6833 oldplayerdetail=playerdetail;
6835 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6838 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6841 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6844 if(id==0)playerdetail=1;
6845 if(playerdetail!=oldplayerdetail)updatedelay=0;
6846 if(playerdetail!=oldplayerdetail)normalsupdatedelay=0;
6847 static float updatedelaychange;
6848 static float morphness;
6849 static float framemult;
6851 skeleton.FindForwards();
6852 if(howactive==typesittingwall){
6853 skeleton.specialforward[1]=0;
6854 skeleton.specialforward[1].z=1;
6860 static int weaponattachmuscle;
6861 static int weaponrotatemuscle,weaponrotatemuscle2;
6862 static XYZ weaponpoint;
6863 static int start,endthing;
6864 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6865 if(!isSleeping()&&!isSitting()){
6866 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6867 XYZ point,newpoint,change,change2;
6868 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6869 heightleft=terrain.getHeight(point.x,point.z)+.04;
6871 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6872 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6873 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6874 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6875 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6877 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6878 heightright=terrain.getHeight(point.x,point.z)+.04;
6879 point.y=heightright;
6880 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6881 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6882 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6883 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6884 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6885 skeleton.DoConstraints(&coords,&scale);
6887 if(creature==wolftype){
6888 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6889 heightleft=terrain.getHeight(point.x,point.z)+.04;
6891 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6892 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6893 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6894 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6895 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6897 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6898 heightright=terrain.getHeight(point.x,point.z)+.04;
6899 point.y=heightright;
6900 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6901 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6902 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6903 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6904 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6905 skeleton.DoConstraints(&coords,&scale);
6908 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6909 XYZ point,newpoint,change,change2;
6910 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6911 heightleft=terrain.getHeight(point.x,point.z)+.04;
6913 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6914 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6915 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6916 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6917 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6919 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6920 heightright=terrain.getHeight(point.x,point.z)+.04;
6921 point.y=heightright;
6922 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6923 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6924 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6925 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6926 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6927 skeleton.DoConstraints(&coords,&scale);
6929 if(creature==wolftype){
6930 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6931 heightleft=terrain.getHeight(point.x,point.z)+.04;
6933 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6934 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6935 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6936 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6937 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6939 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6940 heightright=terrain.getHeight(point.x,point.z)+.04;
6941 point.y=heightright;
6942 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6943 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6944 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6945 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6946 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6947 skeleton.DoConstraints(&coords,&scale);
6951 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6952 XYZ point,newpoint,change,change2;
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)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*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)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*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);
6972 if(creature==wolftype){
6973 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6974 heightleft=terrain.getHeight(point.x,point.z)+.04;
6976 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6977 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6978 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6979 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6980 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6982 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6983 heightright=terrain.getHeight(point.x,point.z)+.04;
6984 point.y=heightright;
6985 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6986 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6987 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6988 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6989 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6990 skeleton.DoConstraints(&coords,&scale);
6994 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();
6996 targetheadrotation=-targetrotation;
6997 targetheadrotation2=0;
6998 if(animation[targetanimation].attack==3)targetheadrotation+=180;
7000 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7001 skeleton.drawmodel.vertex[i]=0;
7002 skeleton.drawmodel.vertex[i].y=999;
7004 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
7005 skeleton.drawmodellow.vertex[i]=0;
7006 skeleton.drawmodellow.vertex[i].y=999;
7008 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
7009 skeleton.drawmodelclothes.vertex[i]=0;
7010 skeleton.drawmodelclothes.vertex[i].y=999;
7012 for(i=0;i<skeleton.num_muscles;i++){
7013 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
7017 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
7018 morphness=righthandmorphness;
7019 start=righthandmorphstart;
7020 endthing=righthandmorphend;
7022 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
7023 morphness=lefthandmorphness;
7024 start=lefthandmorphstart;
7025 endthing=lefthandmorphend;
7027 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
7028 morphness=headmorphness;
7029 start=headmorphstart;
7030 endthing=headmorphend;
7032 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)){
7033 morphness=chestmorphness;
7034 start=chestmorphstart;
7035 endthing=chestmorphend;
7037 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)){
7038 morphness=tailmorphness;
7039 start=tailmorphstart;
7040 endthing=tailmorphend;
7042 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
7043 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
7044 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7047 if(!skeleton.free)glRotatef(tilt2,1,0,0);
7048 if(!skeleton.free)glRotatef(tilt,0,0,1);
7051 glTranslatef(mid.x,mid.y,mid.z);
7053 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
7054 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
7056 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
7057 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
7059 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
7060 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
7062 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
7066 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
7070 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
7074 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
7079 if(playerdetail||skeleton.free==3)
7081 for(j=0;j<skeleton.muscles[i].numvertices;j++)
7083 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
7084 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
7085 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
7086 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
7087 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
7088 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
7089 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
7090 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7092 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7093 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,
7094 (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,
7095 (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);
7096 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)
7097 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,
7098 (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,
7099 (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);
7100 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)
7101 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,
7102 (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,
7103 (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);
7104 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7105 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,
7106 (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,
7107 (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);
7108 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7109 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
7110 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
7111 //if(!isnormal(scale))test=1;
7112 //if(isnormal(scale)){
7113 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
7114 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
7115 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
7123 if(!playerdetail||skeleton.free==3)
7125 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
7127 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
7128 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7130 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7131 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
7132 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
7133 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
7134 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)
7135 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
7136 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
7137 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
7138 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)
7139 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
7140 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
7141 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
7142 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7143 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
7144 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
7145 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
7147 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7148 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
7149 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
7150 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
7157 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
7158 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
7160 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7163 if(!skeleton.free)glRotatef(tilt2,1,0,0);
7164 if(!skeleton.free)glRotatef(tilt,0,0,1);
7165 glTranslatef(mid.x,mid.y,mid.z);
7166 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
7167 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
7169 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
7170 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
7172 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
7173 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
7175 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
7176 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7178 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7179 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
7180 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
7181 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
7182 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)
7183 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
7184 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
7185 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
7186 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)
7187 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
7188 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
7189 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
7190 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7191 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
7192 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
7193 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
7194 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7195 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
7196 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
7197 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
7202 updatedelay=1+(float)(Random()%100)/1000;
7204 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
7205 normalsupdatedelay=1;
7206 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
7207 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
7208 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
7212 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
7213 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
7214 if(skeleton.clothes){
7215 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
7220 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
7221 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
7222 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
7223 if(skeleton.free==1)updatedelaychange*=6;
7224 if(id==0)updatedelaychange*=8;
7225 updatedelay+=updatedelaychange;
7227 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7229 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7230 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7231 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
7232 if(!skeleton.free)glRotatef(rotation,0,1,0);
7235 glColor4f(.4,1,.4,1);
7236 glDisable(GL_LIGHTING);
7237 glDisable(GL_TEXTURE_2D);
7240 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7241 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
7247 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
7248 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);
7249 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);
7250 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].z);
7251 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].z);
7252 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].z);
7253 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].z);
7259 terrainlight=terrain.getLighting(coords.x,coords.z);
7260 distance=findDistancefast(&viewer,&coords);
7261 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
7262 if(distance>1)distance=1;
7264 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
7265 if(terrainheight<1)terrainheight=1;
7266 if(terrainheight>1.7)terrainheight=1.7;
7269 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
7270 glDisable(GL_BLEND);
7271 glAlphaFunc(GL_GREATER, 0.0001);
7272 glEnable(GL_TEXTURE_2D);
7274 glDisable(GL_TEXTURE_2D);
7275 glColor4f(.7,.35,0,.5);
7277 glEnable(GL_LIGHTING);
7280 if(tutoriallevel&&id!=0){
7281 //glDisable(GL_TEXTURE_2D);
7282 glColor4f(.7,.7,.7,0.6);
7284 glEnable(GL_LIGHTING);
7286 if(canattack&&cananger)
7287 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7288 glDisable(GL_TEXTURE_2D);
7289 glColor4f(1,0,0,0.8);
7291 glMatrixMode(GL_TEXTURE);
7293 glTranslatef(0,-smoketex,0);
7294 glTranslatef(-smoketex,0,0);
7298 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7299 else skeleton.drawmodel.draw();
7303 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7304 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7307 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
7308 if(tutoriallevel&&id!=0){
7310 glMatrixMode(GL_MODELVIEW);
7311 glEnable(GL_TEXTURE_2D);
7312 glColor4f(.7,.7,.7,0.6);
7314 glEnable(GL_LIGHTING);
7316 if(canattack&&cananger)
7317 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7318 glDisable(GL_TEXTURE_2D);
7319 glColor4f(1,0,0,0.8);
7321 glMatrixMode(GL_TEXTURE);
7323 glTranslatef(0,-smoketex*.6,0);
7324 glTranslatef(smoketex*.6,0,0);
7327 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7328 else skeleton.drawmodel.draw();
7332 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7333 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7338 if(tutoriallevel&&id!=0){
7340 glMatrixMode(GL_MODELVIEW);
7341 glEnable(GL_TEXTURE_2D);
7343 if(skeleton.clothes){
7346 if(!immediate)skeleton.drawmodelclothes.draw();
7347 if(immediate)skeleton.drawmodelclothes.drawimmediate();
7354 for(k=0;k<num_weapons;k++){
7356 if(weaponactive==k){
7357 if(weapons.type[i]!=staff){
7358 for(j=0;j<skeleton.num_muscles;j++){
7359 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7360 weaponattachmuscle=j;
7363 for(j=0;j<skeleton.num_muscles;j++){
7364 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){
7365 weaponrotatemuscle=j;
7368 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7369 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7371 if(weapons.type[i]==staff){
7372 for(j=0;j<skeleton.num_muscles;j++){
7373 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7374 weaponattachmuscle=j;
7377 for(j=0;j<skeleton.num_muscles;j++){
7378 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){
7379 weaponrotatemuscle=j;
7382 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7383 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7384 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7385 XYZ tempnormthing,vec1,vec2;
7386 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7387 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7388 CrossProduct(&vec1,&vec2,&tempnormthing);
7389 Normalise(&tempnormthing);
7390 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);
7391 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7393 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7394 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7395 Normalise(&weaptargnorm);
7396 weaponpoint-=weaptargnorm*2;
7400 if(weaponactive!=k&&weaponstuck!=k){
7401 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;
7402 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;
7403 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;
7404 for(j=0;j<skeleton.num_muscles;j++){
7405 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){
7406 weaponrotatemuscle=j;
7411 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7412 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7413 for(j=0;j<skeleton.num_muscles;j++){
7414 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){
7415 weaponrotatemuscle=j;
7420 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;
7421 weapons.bigrotation[i]=rotation;
7422 weapons.bigtilt[i]=tilt;
7423 weapons.bigtilt2[i]=tilt2;
7426 weapons.position[i]=weaponpoint*scale+coords;
7427 weapons.bigrotation[i]=0;
7428 weapons.bigtilt[i]=0;
7429 weapons.bigtilt2[i]=0;
7431 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7432 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7433 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7434 if(weaponactive==k){
7435 if(weapons.type[i]==knife){
7436 weapons.smallrotation[i]=180;
7437 weapons.smallrotation2[i]=0;
7438 if(isCrouch()||wasCrouch()){
7439 weapons.smallrotation2[i]=20;
7441 if(targetanimation==hurtidleanim){
7442 weapons.smallrotation2[i]=50;
7444 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7445 XYZ temppoint1,temppoint2,tempforward;
7448 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7449 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7450 distance=findDistance(&temppoint1,&temppoint2);
7451 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7452 weapons.rotation2[i]*=360/6.28;
7455 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7456 weapons.rotation1[i]*=360/6.28;
7457 weapons.rotation3[i]=0;
7458 weapons.smallrotation[i]=-90;
7459 weapons.smallrotation2[i]=0;
7460 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7462 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7463 XYZ temppoint1,temppoint2,tempforward;
7466 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7467 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7468 distance=findDistance(&temppoint1,&temppoint2);
7469 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7470 weapons.rotation2[i]*=360/6.28;
7473 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7474 weapons.rotation1[i]*=360/6.28;
7475 weapons.rotation3[i]=0;
7476 weapons.smallrotation[i]=90;
7477 weapons.smallrotation2[i]=0;
7478 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7480 if(targetanimation==knifethrowanim){
7481 weapons.smallrotation[i]=90;
7482 //weapons.smallrotation2[i]=-90;
7483 weapons.smallrotation2[i]=0;
7484 weapons.rotation1[i]=0;
7485 weapons.rotation2[i]=0;
7486 weapons.rotation3[i]=0;
7488 if(targetanimation==knifesneakattackanim&&targetframe<5){
7489 weapons.smallrotation[i]=-90;
7490 weapons.rotation1[i]=0;
7491 weapons.rotation2[i]=0;
7492 weapons.rotation3[i]=0;
7495 if(weapons.type[i]==sword){
7496 weapons.smallrotation[i]=0;
7497 weapons.smallrotation2[i]=0;
7498 if(targetanimation==knifethrowanim){
7499 weapons.smallrotation[i]=-90;
7500 weapons.smallrotation2[i]=0;
7501 weapons.rotation1[i]=0;
7502 weapons.rotation2[i]=0;
7503 weapons.rotation3[i]=0;
7505 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)){
7506 XYZ temppoint1,temppoint2,tempforward;
7509 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7510 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7511 distance=findDistance(&temppoint1,&temppoint2);
7512 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7513 weapons.rotation2[i]*=360/6.28;
7516 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7517 weapons.rotation1[i]*=360/6.28;
7518 weapons.rotation3[i]=0;
7519 weapons.smallrotation[i]=90;
7520 weapons.smallrotation2[i]=0;
7521 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7524 if(weapons.type[i]==staff){
7525 weapons.smallrotation[i]=100;
7526 weapons.smallrotation2[i]=0;
7527 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7528 XYZ temppoint1,temppoint2,tempforward;
7531 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7532 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7533 distance=findDistance(&temppoint1,&temppoint2);
7534 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7535 weapons.rotation2[i]*=360/6.28;
7538 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7539 weapons.rotation1[i]*=360/6.28;
7540 weapons.rotation3[i]=0;
7541 weapons.smallrotation[i]=90;
7542 weapons.smallrotation2[i]=0;
7543 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7547 if(weaponactive!=k&&weaponstuck!=k){
7548 if(weapons.type[i]==knife){
7549 weapons.smallrotation[i]=-70;
7550 weapons.smallrotation2[i]=10;
7552 if(weapons.type[i]==sword){
7553 weapons.smallrotation[i]=-100;
7554 weapons.smallrotation2[i]=-8;
7556 if(weapons.type[i]==staff){
7557 weapons.smallrotation[i]=-100;
7558 weapons.smallrotation2[i]=-8;
7562 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7563 else weapons.smallrotation[i]=0;
7564 weapons.smallrotation2[i]=10;
7565 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7573 if(skeleton.free)calcrot=1;
7574 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7575 if(currentanimation!=targetanimation)calcrot=1;
7576 //if(id==0)calcrot=1;
7577 if(skeleton.free==2)calcrot=0;
7583 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7586 static float distance;
7587 static float olddistance;
7588 static int intersecting;
7589 static int firstintersecting;
7592 static XYZ start,end;
7593 static float slopethreshold=-.4;
7595 firstintersecting=-1;
7599 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7600 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7602 for (j=0;j<model->TriangleNum;j++){
7603 if(model->facenormals[j].y<=slopethreshold){
7605 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)));
7606 if(distance<radius){
7607 point=*p1-model->facenormals[j]*distance;
7608 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;
7609 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7610 &model->vertex[model->Triangles[j].vertex[1]],
7612 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7613 &model->vertex[model->Triangles[j].vertex[2]],
7615 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7616 &model->vertex[model->Triangles[j].vertex[2]],
7619 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7623 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)){
7624 p1->y=point.y+radius;
7625 if((targetanimation==jumpdownanim||isFlip())){
7626 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7628 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7634 OPENAL_SetPaused(channels[whooshsound], true);
7635 OPENAL_SetVolume(channels[whooshsound], 0);
7638 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7639 if(isFlip())jumppower=-4;
7640 targetanimation=getLanding();
7649 PlaySoundEx( landsound, samp[landsound], NULL, true);
7650 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7651 OPENAL_SetVolume(channels[landsound], 128);
7652 OPENAL_SetPaused(channels[landsound], false);
7655 envsound[numenvsounds]=coords;
7656 envsoundvol[numenvsounds]=16;
7657 envsoundlife[numenvsounds]=.4;
7665 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7668 for (j=0;j<model->TriangleNum;j++){
7669 if(model->facenormals[j].y>slopethreshold){
7673 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)));
7674 if(distance<radius*.5){
7675 point=start-model->facenormals[j]*distance;
7676 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;
7677 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,
7678 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7679 p1->x, p1->y, p1->z, radius/2);
7680 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,
7681 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7682 p1->x, p1->y, p1->z, radius/2);
7683 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,
7684 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7685 p1->x, p1->y, p1->z, radius/2);
7687 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7688 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7690 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7691 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7693 *p1+=model->facenormals[j]*(distance-radius*.5);
7696 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7700 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7702 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7704 return firstintersecting;
7714 currentanimation = 0;
7715 targetanimation = 0;
7716 oldcurrentframe = 0;
7718 oldcurrentanimation = 0;
7719 oldtargetanimation = 0;
7723 parriedrecently = 0;
7727 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7729 currentoffset = 0,targetoffset = 0,offset = 0;
7747 unconscioustime = 0;
7765 rabbitkickenabled = 0;
7774 damagetolerance = 0;
7776 permanentdamage = 0;
7777 superpermanentdamage = 0; lastcollide = 0;
7797 headrotation = 0,headrotation2 = 0;
7798 targetheadrotation = 0,targetheadrotation2 = 0;
7809 normalsupdatedelay = 0;
7814 forwardstogglekeydown = 0;
7819 jumptogglekeydown = 0;
7821 crouchtogglekeydown = 0;
7823 drawtogglekeydown = 0;
7825 throwtogglekeydown = 0;
7831 crouchkeydowntime = 0;
7832 jumpkeydowntime = 0;
7849 whichdirectiondelay = 0;
7850 avoidsomething = 0; avoidwhere = 0;
7858 lefthandmorphness = 0;
7859 righthandmorphness = 0;
7863 targetlefthandmorphness = 0;
7864 targetrighthandmorphness = 0;
7865 targetheadmorphness = 0;
7866 targetchestmorphness = 0;
7867 targettailmorphness = 0;
7868 lefthandmorphstart = 0,lefthandmorphend = 0;
7869 righthandmorphstart = 0,righthandmorphend = 0;
7870 headmorphstart = 0,headmorphend = 0;
7871 chestmorphstart = 0,chestmorphend = 0;
7872 tailmorphstart = 0,tailmorphend = 0;
7874 weaponmissdelay = 0;
7875 highreversaldelay = 0;
7876 lowreversaldelay = 0;
7883 //Skeleton skeleton;
7902 memset(clothes, 0, sizeof(clothes));
7903 memset(clothestintr, 0, sizeof(clothestintr));
7904 memset(clothestintg, 0, sizeof(clothestintg));
7905 memset(clothestintb, 0, sizeof(clothestintb));
7911 onfiredelay = 0; burnt = 0;
7915 updatestuffdelay = 0;
7921 memset(weaponids, 0, sizeof(weaponids));
7925 weaponstuckwhere = 0;
7930 memset(waypoints, 0, sizeof(waypoints));
7931 memset(waypointtype, 0, sizeof(waypointtype));
7934 hastempwaypoint = 0;
7940 finalfinaltarget = 0;
7942 finalpathfindpoint = 0;
7943 targetpathfindpoint = 0;
7944 lastpathfindpoint = 0;
7945 lastpathfindpoint2 = 0;
7946 lastpathfindpoint3 = 0;
7947 lastpathfindpoint4 = 0;
7958 runninghowlong = 0; lastoccluded = 0;
7964 neckspurtparticledelay = 0;
7965 neckspurtamount = 0;
7968 rabbitkickragdoll = 0;
7973 //Animation tempanimation;