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"
25 #include "Animation.h"
27 extern float multiplier;
28 extern Animation animation[animation_count];
29 extern OPENAL_SAMPLE *samp[100];
30 extern int channels[100];
31 extern Terrain terrain;
33 extern int environment;
35 extern FRUSTUM frustum;
37 extern float realmultiplier;
39 extern float slomodelay;
40 extern bool cellophane;
41 extern float texdetail;
42 extern float realtexdetail;
43 extern GLubyte bloodText[512*512*3];
44 extern GLubyte wolfbloodText[512*512*3];
45 extern int bloodtoggle;
46 extern Objects objects;
48 extern bool autoslomo;
49 extern float camerashake;
51 extern float terraindetail;
52 extern float viewdistance;
53 extern float blackout;
54 extern int difficulty;
55 extern Weapons weapons;
57 extern float fadestart;
58 extern Person player[maxplayers];
59 extern int numplayers;
61 extern bool winfreeze;
62 extern float flashamount,flashr,flashg,flashb;
63 extern int flashdelay;
64 extern bool showpoints;
65 extern bool immediate;
67 extern bool tilt2weird;
68 extern bool tiltweird;
70 extern bool proportionweird;
71 extern bool vertexweird[6];
72 extern GLubyte texturearray[512*512*3];
73 extern XYZ envsound[30];
74 extern float envsoundvol[30];
75 extern float envsoundlife[30];
76 extern int numenvsounds;
78 extern float bonusvalue;
79 extern float bonustotal;
80 extern float bonustime;
81 extern int tutoriallevel;
82 extern float smoketex;
83 extern int tutorialstage;
84 extern bool reversaltrain;
85 extern bool canattack;
87 extern float damagedealt;
88 extern float damagetaken;
90 extern float hostiletime;
93 extern int numflipfail;
95 extern int numswordattack;
96 extern int numknifeattack;
97 extern int numunarmedattack;
98 extern int numescaped;
99 extern int numflipped;
100 extern int numwallflipped;
101 extern int numthrowkill;
102 extern int numafterkill;
103 extern int numreversals;
104 extern int numattacks;
105 extern int maxalarmed;
106 extern int indialogue;
108 extern bool gamestarted;
110 extern OPENAL_STREAM * strm[20];
111 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
112 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
114 void Person::CheckKick(){
118 float damagemult=1*power;
119 if(creature==wolftype)damagemult=2.5*power;
123 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
124 if(findDistancefast(&coords,&victim->coords)<1.2){
125 if(!victim->skeleton.free){
127 Normalise(&relative);
128 relative=coords+relative*1;
129 if(animation[victim->targetanimation].height!=lowheight){
134 gLoc[0]=victim->coords.x;
135 gLoc[1]=victim->coords.y;
136 gLoc[2]=victim->coords.z;
140 if(tutoriallevel!=1){
141 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
142 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
143 OPENAL_SetVolume(channels[heavyimpactsound], 128);
144 OPENAL_SetPaused(channels[heavyimpactsound], false);
149 Normalise(&relative);
150 for(i=0;i<victim->skeleton.num_joints;i++){
151 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
154 victim->DoDamage(100*damagemult/victim->protectionhigh);
155 if(id==0)camerashake+=.4;
159 targetanimation=backflipanim;
164 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
166 //if(victim->damage>victim->damagetolerance){
174 else if (victim->isCrouch()){
175 targetanimation=rabbitkickreversedanim;
176 currentanimation=rabbitkickreversedanim;
177 victim->currentanimation=rabbitkickreversalanim;
178 victim->targetanimation=rabbitkickreversalanim;
184 victim->oldcoords=victim->coords;
185 coords=victim->coords;
186 victim->targetrotation=targetrotation;
194 void Person::CatchFire(){
195 XYZ flatfacing,flatvelocity;
197 for(int i=0;i<10;i++){
198 howmany=abs(Random()%(skeleton.num_joints));
199 if(!skeleton.free)flatvelocity=velocity;
200 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
201 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
202 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
203 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
216 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
217 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
218 OPENAL_SetVolume(channels[firestartsound], 256);
219 OPENAL_SetPaused(channels[firestartsound], false);
224 //PlaySoundEx( firesound, samp[firesound], NULL, true);
225 PlayStreamEx( stream_firesound, strm[stream_firesound], NULL, true);
226 OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
227 OPENAL_SetVolume(channels[stream_firesound], 256);
228 OPENAL_SetPaused(channels[stream_firesound], false);
235 bool Person::isIdle(){
236 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;
240 bool Person::isSitting(){
241 if(targetanimation==sitanim)return 1;
242 if(targetanimation==sitwallanim)return 1;
246 bool Person::isSleeping(){
247 if(targetanimation==sleepanim)return 1;
248 if(targetanimation==dead1anim)return 1;
249 if(targetanimation==dead2anim)return 1;
250 if(targetanimation==dead3anim)return 1;
251 if(targetanimation==dead4anim)return 1;
255 bool Person::wasIdle(){
256 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;
259 int Person::getIdle(){
260 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
261 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)){
262 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
263 if(creature==rabbittype)return fightidleanim;
264 if(creature==wolftype)return wolfidle;
266 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
267 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
268 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
269 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
270 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
272 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
274 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
275 if(howactive==typesitting)return sitanim;
276 if(howactive==typesittingwall)return sitwallanim;
277 if(howactive==typesleeping)return sleepanim;
278 if(howactive==typedead1)return dead1anim;
279 if(howactive==typedead2)return dead2anim;
280 if(howactive==typedead3)return dead3anim;
281 if(howactive==typedead4)return dead4anim;
282 if(creature==rabbittype)return bounceidleanim;
283 if(creature==wolftype)return wolfidle;
287 bool Person::isCrouch(){
288 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
293 bool Person::wasCrouch(){
294 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
297 int Person::getCrouch(){
298 if(creature==rabbittype)return crouchanim;
299 if(creature==wolftype)return wolfcrouchanim;
303 bool Person::isRun(){
304 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
309 bool Person::wasRun(){
310 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
313 int Person::getRun(){
314 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
315 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
317 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
318 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
322 bool Person::isStop(){
323 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
328 bool Person::wasStop(){
329 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
332 int Person::getStop(){
333 if(creature==rabbittype)return stopanim;
334 if(creature==wolftype)return wolfstopanim;
339 bool Person::isLanding(){
340 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
345 bool Person::wasLanding(){
346 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
349 int Person::getLanding(){
350 if(creature==rabbittype)return landanim;
351 if(creature==wolftype)return wolflandanim;
356 bool Person::isLandhard(){
357 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
362 bool Person::wasLandhard(){
363 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
366 int Person::getLandhard(){
367 if(creature==rabbittype)return landhardanim;
368 if(creature==wolftype)return wolflandhardanim;
373 bool Person::isFlip(){
374 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
378 bool Person::wasFlip(){
379 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
383 bool Person::isWallJump(){
384 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
388 void SolidHitBonus();
389 void SolidHitBonus(){
390 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
395 else if(bonustime<1.5&&bonus==threexcombo){
400 else if(bonustime<1.5&&bonus==twoxcombo){
405 else if(bonustime<1.5&&bonus==solidhit){
417 void Person::DoBlood(float howmuch,int which){
418 static int bleedxint,bleedyint;
420 //if(howmuch&&id==0)blooddimamount=1;
421 if(bloodtoggle&&tutoriallevel!=1){
422 if(bleeding<=0&&spurt){
424 for(int i=0;i<3;i++){
428 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
431 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
433 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
434 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
436 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
437 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
440 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);
441 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);
445 for(int i=0;i<3;i++){
449 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
450 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
453 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
454 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
458 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
460 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);
462 Sprite::setLastSpriteSpecial(3);
467 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
470 int texdetailint=realtexdetail;
471 if(creature==rabbittype)
472 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){
473 bleedxint=abs(Random()%512);
474 bleedyint=abs(Random()%512);
476 if(creature==wolftype)
477 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){
478 bleedxint=abs(Random()%512);
479 bleedyint=abs(Random()%512);
483 bleedy/=realtexdetail;
484 bleedx/=realtexdetail;
485 direction=abs(Random()%2)*2-1;
489 if(bleeding>2)bleeding=2;
492 void Person::DoBloodBig(float howmuch,int which){
493 static int bleedxint,bleedyint,i,j;
495 if(howmuch&&id==0)blooddimamount=1;
497 if(tutoriallevel!=1||id==0)
498 if(aitype!=playercontrolled&&howmuch>0){
509 if(creature==wolftype){
510 int i=abs(Random()%2);
511 if(i==0)whichsound=snarlsound;
512 if(i==1)whichsound=snarl2sound;
513 envsound[numenvsounds]=coords;
514 envsoundvol[numenvsounds]=16;
515 envsoundlife[numenvsounds]=.4;
518 if(creature==rabbittype){
519 int i=abs(Random()%2);
520 if(i==0)whichsound=rabbitpainsound;
521 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
522 envsound[numenvsounds]=coords;
523 envsoundvol[numenvsounds]=16;
524 envsoundlife[numenvsounds]=.4;
526 //if(i==2)whichsound=rabbitpain2sound;
530 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
531 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
532 OPENAL_SetVolume(channels[whichsound], 512);
533 OPENAL_SetPaused(channels[whichsound], false);
537 if(id==0&&howmuch>0){
545 if(bloodtoggle&&decals&&tutoriallevel!=1){
546 if(bleeding<=0&&spurt){
548 for(int i=0;i<3;i++){
552 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
555 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
557 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
558 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
560 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
561 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
564 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);
565 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);
569 int offsetx=0,offsety=0;
572 offsetx=abs(Random()%60);
574 if(which==190||which==185){
576 offsetx=abs(Random()%100)-20;
586 if(which==220||which==215){
587 //offsety=Random()%20;
589 //offsetx=abs(Random()%80);
598 if(creature==rabbittype)
601 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
602 if(i<startx)startx=i;
603 if(j<starty)starty=j;
609 if(creature==wolftype)
612 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
613 if(i<startx)startx=i;
614 if(j<starty)starty=j;
626 if(startx<0)startx=0;
627 if(starty<0)starty=0;
628 if(endx>512-1)endx=512-1;
629 if(endy>512-1)endy=512-1;
630 if(endx<startx)endx=startx;
631 if(endy<starty)endy=starty;
633 startx/=realtexdetail;
634 starty/=realtexdetail;
638 int texdetailint=realtexdetail;
640 if(creature==rabbittype)
641 for(i=startx;i<endx;i++){
642 for(j=starty;j<endy;j++){
643 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){
644 color=Random()%85+170;
645 where=i*skeleton.skinsize*3+j*3;
646 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
647 skeleton.skinText[where+1]=0;
648 skeleton.skinText[where+2]=0;
652 if(creature==wolftype)
653 for(i=startx;i<endx;i++){
654 for(j=starty;j<endy;j++){
655 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){
656 color=Random()%85+170;
657 where=i*skeleton.skinsize*3+j*3;
658 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
659 skeleton.skinText[where+1]=0;
660 skeleton.skinText[where+2]=0;
664 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
665 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
666 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
670 if(creature==rabbittype)
671 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){
672 bleedxint=abs(Random()%512);
673 bleedyint=abs(Random()%512);
675 if(creature==wolftype)
676 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){
677 bleedxint=abs(Random()%512);
678 bleedyint=abs(Random()%512);
680 bleedy=bleedxint+offsetx;
681 bleedx=bleedyint+offsety;
682 bleedy/=realtexdetail;
683 bleedx/=realtexdetail;
684 if(bleedx<0)bleedx=0;
685 if(bleedy<0)bleedy=0;
686 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
687 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
688 direction=abs(Random()%2)*2-1;
691 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
692 deathbleeding+=bleeding;
693 bloodloss+=bleeding*3;
695 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
696 if(abs(Random()%2)==0){aitype=gethelptype;
699 else aitype=attacktypecutoff;
702 if(bleeding>2)bleeding=2;
705 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
706 static int bleedxint,bleedyint,i,j;
708 static XYZ startpoint,endpoint,colpoint,movepoint;
709 static float rotationpoint;
711 static XYZ p1,p2,p3,p0;
715 float coordsx,coordsy;
718 if(bloodtoggle&&decals&&tutoriallevel!=1){
720 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
728 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
731 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
732 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
733 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
735 CrossProduct(p2-p1,p3-p1,&N);
736 CrossProduct(p0-p1,p3-p1,&temp);
737 s = dotproduct(&temp,&N)/findLength(&N);
738 CrossProduct(p2-p1,p1-p0,&temp);
739 t = dotproduct(&temp,&N)/findLength(&N);
742 bary.x=findDistancefast(&p0,&p1);
743 bary.y=findDistancefast(&p0,&p2);
744 bary.z=findDistancefast(&p0,&p3);
746 total=bary.x+bary.y+bary.z;
755 total=bary.x+bary.y+bary.z;
761 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
762 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
763 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
764 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
765 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
766 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
767 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;
768 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;
770 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
771 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
773 if(bleeding<=0&&spurt){
775 for(int i=0;i<3;i++){
779 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
782 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
784 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
785 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
787 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
788 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
791 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);
792 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);
796 int offsetx=0,offsety=0;
799 offsetx=abs(Random()%120);
801 if(which==220||which==215){
803 offsetx=abs(Random()%80);
806 offsetx=(1+coordsy)*512-291;
807 offsety=coordsx*512-437;
814 if(creature==rabbittype)
817 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
818 if(i<startx)startx=i;
819 if(j<starty)starty=j;
825 if(creature==wolftype)
828 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
829 if(i<startx)startx=i;
830 if(j<starty)starty=j;
841 if(startx<0)startx=0;
842 if(starty<0)starty=0;
843 if(endx>512-1)endx=512-1;
844 if(endy>512-1)endy=512-1;
845 if(endx<startx)endx=startx;
846 if(endy<starty)endy=starty;
848 startx/=realtexdetail;
849 starty/=realtexdetail;
853 int texdetailint=realtexdetail;
855 if(creature==rabbittype)
856 for(i=startx;i<endx;i++){
857 for(j=starty;j<endy;j++){
858 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){
859 color=Random()%85+170;
860 where=i*skeleton.skinsize*3+j*3;
861 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
862 skeleton.skinText[where+1]=0;
863 skeleton.skinText[where+2]=0;
865 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){
866 color=Random()%85+170;
867 where=i*skeleton.skinsize*3+j*3;
868 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
869 skeleton.skinText[where+1]=0;
870 skeleton.skinText[where+2]=0;
874 if(creature==wolftype)
875 for(i=startx;i<endx;i++){
876 for(j=starty;j<endy;j++){
877 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){
878 color=Random()%85+170;
879 where=i*skeleton.skinsize*3+j*3;
880 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
881 skeleton.skinText[where+1]=0;
882 skeleton.skinText[where+2]=0;
884 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){
885 color=Random()%85+170;
886 where=i*skeleton.skinsize*3+j*3;
887 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
888 skeleton.skinText[where+1]=0;
889 skeleton.skinText[where+2]=0;
893 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
894 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
895 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
897 bleedy=(1+coordsy)*512;
899 bleedy/=realtexdetail;
900 bleedx/=realtexdetail;
901 if(bleedx<0)bleedx=0;
902 if(bleedy<0)bleedy=0;
903 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
904 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
905 direction=abs(Random()%2)*2-1;
907 if(whichtri==-1)return 0;
909 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
910 deathbleeding+=bleeding;
911 bloodloss+=bleeding*3;
913 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
914 if(abs(Random()%2)==0){aitype=gethelptype;
917 else aitype=attacktypecutoff;
920 if(bleeding>2)bleeding=2;
925 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
928 static int bytesPerPixel=3;
929 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
930 static int newstartx,newstarty,newendx,newendy;
931 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
933 static float sizemult;
935 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
936 texture[i]=skeleton.skinText[i];
939 if((!osx||howmanylevels)){
941 if(startx<0)startx=0;
942 if(starty<0)starty=0;
943 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
944 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
945 if((endx>startx&&endy>starty)||howmanylevels){
952 for(i=startx;i<endx;i++){
953 for(j=starty;j<endy;j++){
954 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
955 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
956 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
960 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
963 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
964 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
965 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
968 newsize=skeleton.skinsize;
971 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
973 /*for(j=1;j<=howmanylevels;j++){
974 if(j==1)texpointer=&skeleton.skinText[0];
975 else texpointer=&texture[0];
977 totalsize=int( newsize*newsize*bytesPerPixel);
978 rowsize=int( newsize*bytesPerPixel );
979 bigstep=bytesPerPixel*newsize*2;
980 smallstep=bytesPerPixel*2;
986 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
993 void Person::Reverse(){
994 if(victim->aitype==playercontrolled||hostiletime>1)
995 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
996 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
997 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
998 if(targetanimation==sweepanim){
999 targetanimation=sweepreversedanim;
1000 currentanimation=sweepreversedanim;
1001 victim->currentanimation=sweepreversalanim;
1002 victim->targetanimation=sweepreversalanim;
1004 if(targetanimation==spinkickanim){
1005 targetanimation=spinkickreversedanim;
1006 currentanimation=spinkickreversedanim;
1007 victim->currentanimation=spinkickreversalanim;
1008 victim->targetanimation=spinkickreversalanim;
1010 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
1011 if(targetanimation==rabbittacklinganim){
1014 victim->currentframe=6;
1015 victim->targetframe=7;
1017 targetanimation=upunchreversedanim;
1018 currentanimation=upunchreversedanim;
1019 victim->currentanimation=upunchreversalanim;
1020 victim->targetanimation=upunchreversalanim;
1022 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1023 if(victim->weaponactive!=-1){
1024 victim->throwtogglekeydown=1;
1025 weapons.owner[victim->weaponids[0]]=-1;
1026 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1027 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1028 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1029 weapons.missed[victim->weaponids[0]]=1;
1030 weapons.freetime[victim->weaponids[0]]=0;
1031 weapons.firstfree[victim->weaponids[0]]=1;
1032 weapons.physics[victim->weaponids[0]]=1;
1033 victim->num_weapons--;
1034 if(victim->num_weapons){
1035 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1036 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1039 victim->weaponactive=-1;
1040 for(int j=0;j<numplayers;j++){
1041 player[j].wentforweapon=0;
1045 targetanimation=staffhitreversedanim;
1046 currentanimation=staffhitreversedanim;
1047 victim->currentanimation=staffhitreversalanim;
1048 victim->targetanimation=staffhitreversalanim;
1050 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1051 if(victim->weaponactive!=-1){
1052 victim->throwtogglekeydown=1;
1053 weapons.owner[victim->weaponids[0]]=-1;
1054 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1055 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1056 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1057 weapons.missed[victim->weaponids[0]]=1;
1058 weapons.freetime[victim->weaponids[0]]=0;
1059 weapons.firstfree[victim->weaponids[0]]=1;
1060 weapons.physics[victim->weaponids[0]]=1;
1061 victim->num_weapons--;
1062 if(victim->num_weapons){
1063 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1064 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1067 victim->weaponactive=-1;
1068 for(int j=0;j<numplayers;j++){
1069 player[j].wentforweapon=0;
1072 targetanimation=staffspinhitreversedanim;
1073 currentanimation=staffspinhitreversedanim;
1074 victim->currentanimation=staffspinhitreversalanim;
1075 victim->targetanimation=staffspinhitreversalanim;
1077 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1078 if(victim->weaponactive!=-1){
1079 victim->throwtogglekeydown=1;
1080 weapons.owner[victim->weaponids[0]]=-1;
1081 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1082 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1083 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1084 weapons.missed[victim->weaponids[0]]=1;
1085 weapons.freetime[victim->weaponids[0]]=0;
1086 weapons.firstfree[victim->weaponids[0]]=1;
1087 weapons.physics[victim->weaponids[0]]=1;
1088 victim->num_weapons--;
1089 if(victim->num_weapons){
1090 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1091 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1094 victim->weaponactive=-1;
1095 for(int j=0;j<numplayers;j++){
1096 player[j].wentforweapon=0;
1099 targetanimation=swordslashreversedanim;
1100 currentanimation=swordslashreversedanim;
1101 victim->currentanimation=swordslashreversalanim;
1102 victim->targetanimation=swordslashreversalanim;
1104 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1105 if(victim->weaponactive!=-1){
1106 victim->throwtogglekeydown=1;
1107 weapons.owner[victim->weaponids[0]]=-1;
1108 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1109 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1110 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1111 weapons.missed[victim->weaponids[0]]=1;
1112 weapons.freetime[victim->weaponids[0]]=0;
1113 weapons.firstfree[victim->weaponids[0]]=1;
1114 weapons.physics[victim->weaponids[0]]=1;
1115 victim->num_weapons--;
1116 if(victim->num_weapons){
1117 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1118 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1121 victim->weaponactive=-1;
1122 for(int j=0;j<numplayers;j++){
1123 player[j].wentforweapon=0;
1126 targetanimation=knifeslashreversedanim;
1127 currentanimation=knifeslashreversedanim;
1128 victim->currentanimation=knifeslashreversalanim;
1129 victim->targetanimation=knifeslashreversalanim;
1131 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1132 victim->targettilt2=targettilt2;
1133 victim->currentframe=currentframe;
1134 victim->targetframe=targetframe;
1135 victim->target=target;
1137 victim->oldcoords=victim->coords;
1138 victim->coords=coords;
1139 victim->targetrotation=targetrotation;
1140 victim->rotation=targetrotation;
1141 victim->victim=this;
1143 if(targetanimation==winduppunchanim){
1144 targetanimation=winduppunchblockedanim;
1145 victim->targetanimation=blockhighleftanim;
1146 victim->targetframe=1;
1148 victim->victim=this;
1149 victim->targetrotation=targetrotation+180;
1151 if(targetanimation==wolfslapanim){
1152 targetanimation=winduppunchblockedanim;
1153 victim->targetanimation=blockhighleftanim;
1154 victim->targetframe=1;
1156 victim->victim=this;
1157 victim->targetrotation=targetrotation+180;
1159 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1160 targetanimation=swordslashparriedanim;
1162 victim->parriedrecently=0;
1163 victim->targetanimation=swordslashparryanim;
1164 victim->targetframe=1;
1166 victim->victim=this;
1167 victim->targetrotation=targetrotation+180;
1169 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1172 gLoc[0]=victim->coords.x;
1173 gLoc[1]=victim->coords.y;
1174 gLoc[2]=victim->coords.z;
1178 if(victim->weaponactive!=-1){
1179 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1180 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1181 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1183 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1184 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1185 OPENAL_SetVolume(channels[swordstaffsound], 512);
1186 OPENAL_SetPaused(channels[swordstaffsound], false);
1189 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1190 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1191 OPENAL_SetVolume(channels[metalhitsound], 512);
1192 OPENAL_SetPaused(channels[metalhitsound], false);
1196 victim->Puff(righthand);
1198 victim->targetframe=0;
1199 victim->targetanimation=staggerbackhighanim;
1200 victim->targetrotation=targetrotation+180;
1202 weapons.owner[victim->weaponids[0]]=-1;
1203 aim=DoRotation(facing,0,90,0)*21;
1205 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1206 weapons.tipvelocity[victim->weaponids[0]]=aim;
1207 weapons.missed[victim->weaponids[0]]=1;
1208 weapons.hitsomething[victim->weaponids[0]]=0;
1209 weapons.freetime[victim->weaponids[0]]=0;
1210 weapons.firstfree[victim->weaponids[0]]=1;
1211 weapons.physics[victim->weaponids[0]]=1;
1212 victim->num_weapons--;
1213 if(victim->num_weapons){
1214 victim->weaponids[0]=victim->weaponids[num_weapons];
1215 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1217 victim->weaponactive=-1;
1218 for(int i=0;i<numplayers;i++){
1219 player[i].wentforweapon=0;
1226 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1227 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1228 OPENAL_SetVolume(channels[metalhitsound], 512);
1229 OPENAL_SetPaused(channels[metalhitsound], false);*/
1232 if(abs(Random()%20)==0){
1241 if(weaponactive!=-1){
1242 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1243 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1244 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1246 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1247 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1248 OPENAL_SetVolume(channels[swordstaffsound], 512);
1249 OPENAL_SetPaused(channels[swordstaffsound], false);
1252 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1253 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1254 OPENAL_SetVolume(channels[metalhitsound], 512);
1255 OPENAL_SetPaused(channels[metalhitsound], false);
1263 targetanimation=staggerbackhighanim;
1264 targetrotation=targetrotation+180;
1266 weapons.owner[weaponids[0]]=-1;
1267 aim=DoRotation(facing,0,90,0)*21;
1269 weapons.velocity[weaponids[0]]=aim*-.2;
1270 weapons.tipvelocity[weaponids[0]]=aim;
1271 weapons.hitsomething[weaponids[0]]=0;
1272 weapons.missed[weaponids[0]]=1;
1273 weapons.freetime[weaponids[0]]=0;
1274 weapons.firstfree[weaponids[0]]=1;
1275 weapons.physics[weaponids[0]]=1;
1278 weaponids[0]=weaponids[num_weapons];
1279 if(weaponstuck==num_weapons)weaponstuck=0;
1282 for(int i=0;i<numplayers;i++){
1283 player[i].wentforweapon=0;
1287 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1288 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1289 OPENAL_SetVolume(channels[metalhitsound], 512);
1290 OPENAL_SetPaused(channels[metalhitsound], false);*/
1294 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1295 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1296 //victim->targetanimation=sweepanim;
1297 victim->targetanimation=dodgebackanim;
1298 victim->targetframe=0;
1300 //victim->velocity=0;
1303 rotatetarget=coords-victim->coords;
1304 Normalise(&rotatetarget);
1305 victim->targetrotation=-asin(0-rotatetarget.x);
1306 victim->targetrotation*=360/6.28;
1307 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1309 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1311 victim->lastattack3=victim->lastattack2;
1312 victim->lastattack2=victim->lastattack;
1313 victim->lastattack=victim->targetanimation;
1317 victim->targetanimation=sweepanim;
1318 victim->targetframe=0;
1322 rotatetarget=coords-victim->coords;
1323 Normalise(&rotatetarget);
1324 victim->targetrotation=-asin(0-rotatetarget.x);
1325 victim->targetrotation*=360/6.28;
1326 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1328 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1330 victim->lastattack3=victim->lastattack2;
1331 victim->lastattack2=victim->lastattack;
1332 victim->lastattack=victim->targetanimation;
1339 if(aitype!=playercontrolled)feint=0;
1340 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1341 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1342 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1344 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1348 void Person::DoDamage(float howmuch){
1349 if(tutoriallevel!=1)damage+=howmuch/power;
1350 if(id!=0)damagedealt+=howmuch/power;
1351 if(id==0)damagetaken+=howmuch/power;
1353 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1354 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1355 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1356 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1357 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1359 if(id==0)camerashake+=howmuch/100;
1360 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1361 if(blackout>1)blackout=1;
1363 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1364 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1365 if(abs(Random()%2)==0){aitype=gethelptype;
1368 else aitype=attacktypecutoff;
1372 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1375 for(int i=0;i<skeleton.num_joints; i++){
1376 if(!skeleton.free)flatvelocity2=velocity;
1377 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1378 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1379 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1380 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1381 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1382 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1383 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1384 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1385 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1396 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1397 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1398 OPENAL_SetVolume(channels[splattersound], 256);
1399 OPENAL_SetPaused(channels[splattersound], false);
1408 if(!dead&&creature==wolftype){
1417 if(tutoriallevel!=1||id==0)
1418 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1429 if(creature==wolftype){
1430 int i=abs(Random()%2);
1431 if(i==0)whichsound=snarlsound;
1432 if(i==1)whichsound=snarl2sound;
1433 envsound[numenvsounds]=coords;
1434 envsoundvol[numenvsounds]=16;
1435 envsoundlife[numenvsounds]=.4;
1438 if(creature==rabbittype){
1439 int i=abs(Random()%2);
1440 if(i==0)whichsound=rabbitpainsound;
1441 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1442 envsound[numenvsounds]=coords;
1443 envsoundvol[numenvsounds]=16;
1444 envsoundlife[numenvsounds]=.4;
1446 //if(i==2)whichsound=rabbitpain2sound;
1450 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1451 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1452 OPENAL_SetVolume(channels[whichsound], 512);
1453 OPENAL_SetPaused(channels[whichsound], false);
1458 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1459 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1462 void Person::DoHead(){
1463 static XYZ rotatearound;
1465 static float lookspeed=500;
1467 if(!freeze&&!winfreeze){
1470 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1471 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1473 while(targetheadrotation>180)targetheadrotation-=360;
1474 while(targetheadrotation<-180)targetheadrotation+=360;
1476 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1477 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1478 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1479 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1481 if(targetheadrotation2>120)targetheadrotation2=120;
1482 if(targetheadrotation2<-120)targetheadrotation2=-120;
1483 if(targetheadrotation>120)targetheadrotation=120;
1484 if(targetheadrotation<-120)targetheadrotation=-120;
1486 if(!isIdle())targetheadrotation2=0;
1488 if(targetheadrotation>80)targetheadrotation=80;
1489 if(targetheadrotation<-80)targetheadrotation=-80;
1490 if(targetheadrotation2>50)targetheadrotation2=50;
1491 if(targetheadrotation2<-50)targetheadrotation2=-50;
1494 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1495 else if(headrotation>targetheadrotation){
1496 headrotation-=multiplier*lookspeed;
1498 else if(headrotation<targetheadrotation){
1499 headrotation+=multiplier*lookspeed;
1502 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1503 else if(headrotation2>targetheadrotation2){
1504 headrotation2-=multiplier*lookspeed/2;
1506 else if(headrotation2<targetheadrotation2){
1507 headrotation2+=multiplier*lookspeed/2;
1510 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1511 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1515 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1516 facing=DoRotation(facing,headrotation2*.4,0,0);
1517 facing=DoRotation(facing,0,headrotation*.4,0);
1520 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1521 facing=DoRotation(facing,headrotation2*.8,0,0);
1522 facing=DoRotation(facing,0,headrotation*.8,0);
1525 if(targetanimation==walkanim){
1526 facing=DoRotation(facing,headrotation2*.6,0,0);
1527 facing=DoRotation(facing,0,headrotation*.6,0);
1530 skeleton.specialforward[0]=facing;
1531 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1533 for(i=0;i<skeleton.num_muscles;i++){
1534 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1536 skeleton.FindRotationMuscle(i,targetanimation);
1542 void Person::RagDoll(bool checkcollision){
1547 if(id==0)numfalls++;
1548 if(id==0&&isFlip())numflipfail++;
1554 facing=DoRotation(facing,0,rotation,0);
1556 skeleton.freetime=0;
1558 skeleton.longdead=0;
1564 skeleton.freefall=1;
1566 if(!isnormal(velocity.x))velocity.x=0;
1567 if(!isnormal(velocity.y))velocity.y=0;
1568 if(!isnormal(velocity.z))velocity.z=0;
1569 if(!isnormal(rotation))rotation=0;
1570 if(!isnormal(coords.x))coords=0;
1571 if(!isnormal(tilt))tilt=0;
1572 if(!isnormal(tilt2))tilt2=0;
1574 for(i=0;i<skeleton.num_joints;i++){
1575 skeleton.joints[i].delay=0;
1576 skeleton.joints[i].locked=0;
1577 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1578 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1579 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1580 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1581 skeleton.joints[i].position.y+=.1;
1582 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1583 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1586 for(i=0;i<skeleton.num_joints;i++){
1587 skeleton.joints[i].velocity=0;
1588 skeleton.joints[i].velchange=0;
1590 skeleton.DoConstraints(&coords,&scale);
1591 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1593 skeleton.DoConstraints(&coords,&scale);
1594 skeleton.DoConstraints(&coords,&scale);
1595 skeleton.DoConstraints(&coords,&scale);
1596 skeleton.DoConstraints(&coords,&scale);
1599 speed=animation[targetanimation].speed[targetframe]*2;
1600 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1601 speed=animation[currentanimation].speed[currentframe]*2;
1603 if(transspeed)speed=transspeed*2;
1607 for(i=0;i<skeleton.num_joints;i++){
1608 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);
1609 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1610 change.x=(float)(Random()%100)/100;
1611 change.y=(float)(Random()%100)/100;
1612 change.z=(float)(Random()%100)/100;
1613 skeleton.joints[i].velocity+=change;
1614 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1616 change.x=(float)(Random()%100)/100;
1617 change.y=(float)(Random()%100)/100;
1618 change.z=(float)(Random()%100)/100;
1619 skeleton.joints[i].velchange+=change;
1620 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1630 for(j=0;j<skeleton.num_joints;j++){
1631 average+=skeleton.joints[j].position;
1635 coords+=average*scale;
1636 for(j=0;j<skeleton.num_joints;j++){
1637 skeleton.joints[j].position-=average;
1640 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1641 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1642 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1643 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1644 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1647 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1648 coords.x=lowpoint.x;
1649 coords.z=lowpoint.z;
1658 for(i=0;i<skeleton.num_joints;i++){
1659 velocity+=skeleton.joints[i].velocity*scale;
1661 velocity/=skeleton.num_joints;
1664 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1665 weapons.owner[weaponids[0]]=-1;
1666 weapons.hitsomething[weaponids[0]]=0;
1667 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1668 weapons.velocity[weaponids[0]].x+=.01;
1669 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1670 weapons.missed[weaponids[0]]=1;
1671 weapons.freetime[weaponids[0]]=0;
1672 weapons.firstfree[weaponids[0]]=1;
1673 weapons.physics[weaponids[0]]=1;
1676 weaponids[0]=weaponids[num_weapons];
1677 if(weaponstuck==num_weapons)weaponstuck=0;
1680 for(i=0;i<numplayers;i++){
1681 player[i].wentforweapon=0;
1686 targetanimation=bounceidleanim;
1687 currentanimation=bounceidleanim;
1695 void Person::FootLand(int which, float opacity){
1696 static XYZ terrainlight;
1697 static XYZ footvel,footpoint;
1698 if(opacity>=1||skiddelay<=0)
1702 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1703 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1704 //footpoint.y=coords.y;
1705 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1707 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1709 if(footvel.y<.8)footvel.y=.8;
1710 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1711 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1712 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1713 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1714 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1715 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1717 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1719 if(footvel.y<.8)footvel.y=.8;
1720 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1721 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1722 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1723 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1724 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);
1726 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1728 if(footvel.y<.8)footvel.y=.8;
1729 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1730 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1731 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1732 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1733 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);
1734 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1736 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1739 if(footvel.y<.8)footvel.y=.8;
1740 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1741 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1742 //footpoint.y=coords.y;
1743 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1747 void Person::Puff(int whichlabel){
1748 static XYZ footvel,footpoint;
1751 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1752 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1756 void Person::DoAnimations(){
1759 static float oldtarget;
1761 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1763 if(targetanimation==tempanim||currentanimation==tempanim){
1764 animation[tempanim]=tempanimation;
1766 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1777 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1778 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1780 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1781 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1783 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1788 targfacing=DoRotation(targfacing,0,targetrotation,0);
1790 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1791 else targetanimation=backflipanim;
1792 crouchtogglekeydown=1;
1796 if(id==0)numflipped++;
1799 if(animation[targetanimation].attack!=reversed)feint=0;
1800 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1801 crouchtogglekeydown=0;
1802 if(aitype==playercontrolled)feint=0;
1806 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1807 if(!isFlip())crouchtogglekeydown=1;
1811 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1812 if(detail)normalsupdatedelay=0;
1816 if(targetanimation==rollanim&&targetframe==3&&onfire){
1826 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1827 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1828 OPENAL_SetVolume(channels[fireendsound], 256);
1829 OPENAL_SetPaused(channels[fireendsound], false);
1830 OPENAL_SetPaused(channels[stream_firesound], true);
1834 if(targetanimation==rabbittacklinganim&&targetframe==1){
1835 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1836 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1837 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1838 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1839 else victim->targetanimation=rabbittackledfrontanim;
1840 victim->targetframe=2;
1842 victim->rotation=rotation;
1843 victim->targetrotation=rotation;
1844 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1845 //victim->DoDamage(30);
1846 if(creature==wolftype){
1850 gLoc[0]=victim->coords.x;
1851 gLoc[1]=victim->coords.y;
1852 gLoc[2]=victim->coords.z;
1856 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
1857 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
1858 OPENAL_SetVolume(channels[clawslicesound], 128);
1859 OPENAL_SetPaused(channels[clawslicesound], false);
1861 victim->DoBloodBig(1/victim->armorhead,210);
1867 if(victim->aitype==gethelptype)bonusvalue=50;
1872 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1873 if(weapons.type[weaponids[0]]==knife){
1874 if(weaponactive==-1)weaponactive=0;
1875 else if(weaponactive==0)weaponactive=-1;
1877 if(weaponactive==-1){
1887 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
1888 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
1889 OPENAL_SetVolume(channels[knifesheathesound], 128);
1890 OPENAL_SetPaused(channels[knifesheathesound], false);
1892 if(weaponactive!=-1){
1902 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1903 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1904 OPENAL_SetVolume(channels[knifedrawsound], 128);
1905 OPENAL_SetPaused(channels[knifedrawsound], false);
1908 drawtogglekeydown=1;
1911 if(tutoriallevel!=1||id==0)
1912 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1923 if(terrain.getOpacity(coords.x,coords.z)<.2){
1924 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1925 else whichsound=footstepsound2;
1926 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1927 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1928 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1934 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1935 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1936 else whichsound=footstepsound4;
1940 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1941 else whichsound=footstepsound4;
1943 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1944 if(animation[targetanimation].attack!=neutral){
1946 if(i==0)whichsound=lowwhooshsound;
1947 if(i==1)whichsound=midwhooshsound;
1948 if(i==2)whichsound=highwhooshsound;
1950 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1952 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1953 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1955 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1956 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1957 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
1958 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
1959 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
1960 OPENAL_SetPaused(channels[whichsound], false);
1963 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1964 envsound[numenvsounds]=coords;
1965 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1966 else envsoundvol[numenvsounds]=6;
1967 envsoundlife[numenvsounds]=.4;
1971 if(animation[targetanimation].label[targetframe]==3){
1973 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1974 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1975 OPENAL_SetVolume(channels[whichsound], 128);
1976 OPENAL_SetPaused(channels[whichsound], false);
1981 if(tutoriallevel!=1||id==0)
1983 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1984 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1994 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1995 if(animation[targetanimation].attack!=neutral){
1997 if(creature==rabbittype){
1998 if(i==0)whichsound=rabbitattacksound;
1999 if(i==1)whichsound=rabbitattack2sound;
2000 if(i==2)whichsound=rabbitattack3sound;
2001 if(i==3)whichsound=rabbitattack4sound;
2003 if(creature==wolftype){
2004 if(i==0)whichsound=barksound;
2005 if(i==1)whichsound=bark2sound;
2006 if(i==2)whichsound=bark3sound;
2007 if(i==3)whichsound=barkgrowlsound;
2011 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2013 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2014 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
2017 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2018 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2019 OPENAL_SetVolume(channels[whichsound], 512);
2020 OPENAL_SetPaused(channels[whichsound], false);
2026 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
2032 currentoffset=targetoffset;
2033 targetframe=currentframe;
2034 currentanimation=targetanimation;
2037 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
2038 for(i=0;i<weapons.numweapons;i++){
2039 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
2040 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
2041 if(findDistancefast(&coords,&weapons.position[i])>=1){
2042 if(weapons.type[i]!=staff){
2051 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2052 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2053 OPENAL_SetVolume(channels[knifedrawsound], 128);
2054 OPENAL_SetPaused(channels[knifedrawsound], false);
2058 weapons.owner[i]=id;
2060 weaponids[num_weapons]=weaponids[0];
2069 static bool willwork;
2070 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2071 for(i=0;i<weapons.numweapons;i++){
2073 if(weapons.owner[i]!=-1)
2074 if(player[weapons.owner[i]].weaponstuck!=-1)
2075 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2076 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2077 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))
2078 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2079 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2089 if(weapons.owner[i]!=-1)
2090 if(victim->weaponstuck!=-1){
2091 if(victim->weaponids[victim->weaponstuck]==i){
2096 if(weapons.type[i]!=staff){
2097 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2098 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2099 OPENAL_SetVolume(channels[knifedrawsound], 128);
2100 OPENAL_SetPaused(channels[knifedrawsound], false);
2104 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2105 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2106 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2107 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2110 if(weapons.owner[i]!=-1){
2112 victim=&player[weapons.owner[i]];
2113 if(victim->num_weapons==1)victim->num_weapons=0;
2114 else victim->num_weapons=1;
2116 //victim->weaponactive=-1;
2117 victim->skeleton.longdead=0;
2118 victim->skeleton.free=1;
2119 victim->skeleton.broken=0;
2121 for(int j=0;j<victim->skeleton.num_joints;j++){
2122 victim->skeleton.joints[j].velchange=0;
2123 victim->skeleton.joints[j].locked=0;
2129 Normalise(&relative);
2130 XYZ footvel,footpoint;
2132 footpoint=weapons.position[i];
2133 if(victim->weaponstuck!=-1){
2134 if(victim->weaponids[victim->weaponstuck]==i){
2135 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2136 weapons.bloody[i]=2;
2137 weapons.blooddrip[i]=5;
2138 victim->weaponstuck=-1;
2141 if(victim->num_weapons>0){
2142 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2143 if(victim->weaponids[0]==i)
2144 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2147 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2148 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2149 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2150 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2152 weapons.owner[i]=id;
2154 weaponids[num_weapons]=weaponids[0];
2163 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2164 if(weaponactive==-1)weaponactive=0;
2165 else if(weaponactive==0){
2169 buffer=weaponids[0];
2170 weaponids[0]=weaponids[1];
2171 weaponids[1]=buffer;
2174 if(weaponactive==-1){
2184 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2185 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2186 OPENAL_SetVolume(channels[knifesheathesound], 128);
2187 OPENAL_SetPaused(channels[knifesheathesound], false);
2189 if(weaponactive!=-1){
2199 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2200 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2201 OPENAL_SetVolume(channels[knifedrawsound], 128);
2202 OPENAL_SetPaused(channels[knifedrawsound], false);
2207 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2208 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2209 Normalise(&rotatetarget);
2210 targetrotation=-asin(0-rotatetarget.x);
2211 targetrotation*=360/6.28;
2212 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2214 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2215 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2220 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2222 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;
2224 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2225 targetanimation=rabbittackleanim;
2236 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2237 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2238 OPENAL_SetVolume(channels[jumpsound], 128);
2239 OPENAL_SetPaused(channels[jumpsound], false);
2248 Normalise(&targetloc);
2250 for(i=0;i<numplayers;i++){
2252 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2253 closestdist=findDistancefast(&targetloc,&player[i].coords);
2258 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2260 victim=&player[closestid];
2261 coords=victim->coords;
2262 currentanimation=rabbittacklinganim;
2263 targetanimation=rabbittacklinganim;
2267 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2268 rotatetarget=coords-victim->coords;
2269 Normalise(&rotatetarget);
2270 targetrotation=-asin(0-rotatetarget.x);
2271 targetrotation*=360/6.28;
2272 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2274 if(targetanimation!=rabbitrunninganim){
2284 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2285 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2286 OPENAL_SetVolume(channels[jumpsound], 128);
2287 OPENAL_SetPaused(channels[jumpsound], false);
2293 float damagemult=1*power;
2294 if(creature==wolftype)damagemult=2.5*power;
2295 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2296 //if(onfire)damagemult=3;
2297 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2298 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2299 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2301 if(id==0)camerashake+=.4;
2302 if(Random()%2||creature==wolftype){
2305 if(creature==wolftype)DoBloodBig(0,250);
2309 gLoc[0]=victim->coords.x;
2310 gLoc[1]=victim->coords.y;
2311 gLoc[2]=victim->coords.z;
2315 if(tutoriallevel!=1){
2316 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2317 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2318 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2319 OPENAL_SetPaused(channels[heavyimpactsound], false);
2321 if(creature==wolftype){
2322 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2323 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2324 OPENAL_SetVolume(channels[clawslicesound], 128);
2325 OPENAL_SetPaused(channels[clawslicesound], false);
2327 victim->DoBloodBig(2/victim->armorhead,175);
2331 relative=victim->coords-coords;
2333 Normalise(&relative);
2334 relative=DoRotation(relative,0,-90,0);
2335 for(i=0;i<victim->skeleton.num_joints;i++){
2336 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2338 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2341 victim->DoDamage(damagemult*100/victim->protectionhead);
2349 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2350 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2352 if(id==0)camerashake+=.4;
2353 if(Random()%2||creature==wolftype){
2355 if(creature==wolftype)DoBloodBig(0,235);
2359 gLoc[0]=victim->coords.x;
2360 gLoc[1]=victim->coords.y;
2361 gLoc[2]=victim->coords.z;
2365 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2366 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2367 OPENAL_SetVolume(channels[whooshhitsound], 512);
2368 OPENAL_SetPaused(channels[whooshhitsound], false);
2369 if(creature==wolftype){
2370 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2371 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2372 OPENAL_SetVolume(channels[clawslicesound], 128);
2373 OPENAL_SetPaused(channels[clawslicesound], false);
2375 victim->DoBloodBig(2,175);
2379 relative=victim->coords-coords;
2381 Normalise(&relative);
2383 Normalise(&relative);
2384 relative=DoRotation(relative,0,90,0);
2385 for(i=0;i<victim->skeleton.num_joints;i++){
2386 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2388 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2391 victim->DoDamage(damagemult*50/victim->protectionhead);
2395 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2396 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2398 if(id==0)camerashake+=.4;
2403 gLoc[0]=victim->coords.x;
2404 gLoc[1]=victim->coords.y;
2405 gLoc[2]=victim->coords.z;
2409 if(tutoriallevel!=1){
2410 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2411 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2412 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2413 OPENAL_SetPaused(channels[heavyimpactsound], false);
2415 if(creature==wolftype){
2416 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2417 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2418 OPENAL_SetVolume(channels[clawslicesound], 128);
2419 OPENAL_SetPaused(channels[clawslicesound], false);
2421 victim->DoBloodBig(2/victim->armorhead,175);
2427 Normalise(&relative);
2428 relative=DoRotation(relative,0,-90,0);
2429 for(i=0;i<victim->skeleton.num_joints;i++){
2430 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2432 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2435 victim->DoDamage(damagemult*150/victim->protectionhead);
2437 if(victim->damage>victim->damagetolerance){
2450 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2451 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2453 if(id==0)camerashake+=.4;
2458 gLoc[0]=victim->coords.x;
2459 gLoc[1]=victim->coords.y;
2460 gLoc[2]=victim->coords.z;
2464 if(tutoriallevel!=1){
2465 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2466 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2467 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2468 OPENAL_SetPaused(channels[heavyimpactsound], false);
2470 if(creature==wolftype){
2471 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2472 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2473 OPENAL_SetVolume(channels[clawslicesound], 128);
2474 OPENAL_SetPaused(channels[clawslicesound], false);
2476 victim->DoBloodBig(2/victim->armorhead,175);
2482 Normalise(&relative);
2483 relative=DoRotation(relative,0,90,0);
2484 for(i=0;i<victim->skeleton.num_joints;i++){
2485 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2487 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2490 victim->DoDamage(damagemult*150/victim->protectionhead);
2492 if(victim->damage>victim->damagetolerance){
2505 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2506 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2508 if(id==0)camerashake+=.4;
2515 gLoc[0]=victim->coords.x;
2516 gLoc[1]=victim->coords.y;
2517 gLoc[2]=victim->coords.z;
2521 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2522 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2523 OPENAL_SetVolume(channels[whooshhitsound], 512);
2524 OPENAL_SetPaused(channels[whooshhitsound], false);
2527 relative=victim->coords-coords;
2529 Normalise(&relative);
2530 for(i=0;i<victim->skeleton.num_joints;i++){
2531 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2533 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2536 victim->DoDamage(damagemult*50/victim->protectionhead);
2540 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2541 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2543 if(id==0)camerashake+=.2;
2546 gLoc[0]=victim->coords.x;
2547 gLoc[1]=victim->coords.y;
2548 gLoc[2]=victim->coords.z;
2552 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2553 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2554 OPENAL_SetVolume(channels[landsound2], 128);
2555 OPENAL_SetPaused(channels[landsound2], false);
2557 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2558 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2559 OPENAL_SetVolume(channels[movewhooshsound], 128);
2560 OPENAL_SetPaused(channels[movewhooshsound], false);
2562 victim->skeleton.longdead=0;
2563 victim->skeleton.free=1;
2564 victim->skeleton.broken=0;
2565 victim->skeleton.spinny=1;
2567 for(i=0;i<victim->skeleton.num_joints;i++){
2568 victim->skeleton.joints[i].velchange=0;
2569 victim->skeleton.joints[i].delay=0;
2570 victim->skeleton.joints[i].locked=0;
2571 //victim->skeleton.joints[i].velocity=0;
2577 Normalise(&relative);
2578 for(i=0;i<victim->skeleton.num_joints;i++){
2579 victim->skeleton.joints[i].velocity.y=relative.y*10;
2580 victim->skeleton.joints[i].position.y+=relative.y*.3;
2581 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2582 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2584 victim->Puff(abdomen);
2585 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2589 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2590 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2592 if(id==0)camerashake+=.4;
2601 if(tutoriallevel!=1){
2602 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2603 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2604 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2605 OPENAL_SetPaused(channels[heavyimpactsound], false);
2608 relative=victim->coords-coords;
2610 Normalise(&relative);
2611 for(i=0;i<victim->skeleton.num_joints;i++){
2612 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2614 victim->Puff(abdomen);
2615 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2619 victim->DoDamage(damagemult*500/victim->protectionhigh);
2620 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2624 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2625 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2627 if(id==0)camerashake+=.4;
2636 if(tutoriallevel!=1){
2637 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2638 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2639 OPENAL_SetVolume(channels[thudsound], 400);
2640 OPENAL_SetPaused(channels[thudsound], false);
2643 victim->skeleton.longdead=0;
2644 victim->skeleton.free=1;
2645 victim->skeleton.broken=0;
2646 victim->skeleton.spinny=1;
2648 for(i=0;i<victim->skeleton.num_joints;i++){
2649 victim->skeleton.joints[i].velchange=0;
2650 //victim->skeleton.joints[i].delay=0;
2651 victim->skeleton.joints[i].locked=0;
2654 relative=victim->coords-coords;
2655 Normalise(&relative);
2657 Normalise(&relative);
2658 for(i=0;i<victim->skeleton.num_joints;i++){
2659 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2661 if(id==0&&!victim->dead){
2665 victim->Puff(abdomen);
2666 victim->DoDamage(damagemult*20/victim->protectionhigh);
2667 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2669 if(!victim->dead)staggerdelay=1.2;
2675 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2676 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2677 //if(id==0)camerashake+=.4;
2688 if(!victim->skeleton.free)hasvictim=0;
2691 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2692 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2693 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2694 OPENAL_SetVolume(channels[knifesheathesound], 128);
2695 OPENAL_SetPaused(channels[knifesheathesound], false);
2698 if(victim&&hasvictim){
2699 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2701 XYZ where,startpoint,endpoint,movepoint,colpoint;
2702 float rotationpoint;
2704 if(weapons.type[weaponids[weaponactive]]==knife){
2705 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2706 where-=victim->coords;
2707 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2714 if(weapons.type[weaponids[weaponactive]]==sword){
2715 where=weapons.position[weaponids[weaponactive]];
2716 where-=victim->coords;
2717 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2719 where=weapons.tippoint[weaponids[weaponactive]];
2720 where-=victim->coords;
2721 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2724 if(weapons.type[weaponids[weaponactive]]==staff){
2725 where=weapons.position[weaponids[weaponactive]];
2726 where-=victim->coords;
2727 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2729 where=weapons.tippoint[weaponids[weaponactive]];
2730 where-=victim->coords;
2731 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2736 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2739 if(victim->dead!=2){
2740 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2741 if(id==0&&!victim->dead){
2742 bonus=FinishedBonus;
2747 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2749 victim->skeleton.longdead=0;
2750 victim->skeleton.free=1;
2751 victim->skeleton.broken=0;
2753 for(i=0;i<victim->skeleton.num_joints;i++){
2754 victim->skeleton.joints[i].velchange=0;
2755 victim->skeleton.joints[i].locked=0;
2756 //victim->skeleton.joints[i].velocity=0;
2758 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2759 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2760 OPENAL_SetVolume(channels[fleshstabsound], 128);
2761 OPENAL_SetPaused(channels[fleshstabsound], false);
2764 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2765 weapons.blooddrip[weaponids[weaponactive]]+=5;
2766 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2770 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2771 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2772 OPENAL_SetVolume(channels[knifesheathesound], 128);
2773 OPENAL_SetPaused(channels[knifesheathesound], false);
2779 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2780 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2781 //if(id==0)camerashake+=.4;
2791 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2792 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2793 OPENAL_SetVolume(channels[knifedrawsound], 128);
2794 OPENAL_SetPaused(channels[knifedrawsound], false);
2797 if(victim&&hasvictim){
2798 XYZ footvel,footpoint;
2800 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2801 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2802 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2803 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2806 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2808 if(weapons.type[weaponids[weaponactive]]==sword){
2809 XYZ where,startpoint,endpoint,movepoint;
2810 float rotationpoint;
2813 where=weapons.position[weaponids[weaponactive]];
2814 where-=victim->coords;
2815 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2817 where=weapons.tippoint[weaponids[weaponactive]];
2818 where-=victim->coords;
2819 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2824 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2825 footpoint+=victim->coords;
2828 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2831 if(weapons.type[weaponids[weaponactive]]==staff){
2832 XYZ where,startpoint,endpoint,movepoint;
2833 float rotationpoint;
2836 where=weapons.position[weaponids[weaponactive]];
2837 where-=victim->coords;
2838 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2840 where=weapons.tippoint[weaponids[weaponactive]];
2841 where-=victim->coords;
2842 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2847 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2848 footpoint+=victim->coords;
2851 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2854 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2856 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2857 victim->skeleton.longdead=0;
2858 victim->skeleton.free=1;
2859 victim->skeleton.broken=0;
2861 for(i=0;i<victim->skeleton.num_joints;i++){
2862 victim->skeleton.joints[i].velchange=0;
2863 victim->skeleton.joints[i].locked=0;
2864 //victim->skeleton.joints[i].velocity=0;
2870 Normalise(&relative);
2871 //victim->Puff(abdomen);
2872 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2874 if(victim->bloodloss<victim->damagetolerance){
2875 victim->bloodloss+=1000;
2879 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2883 if(!hasvictim&&onterrain){
2884 weapons.bloody[weaponids[weaponactive]]=0;
2885 weapons.blooddrip[weaponids[weaponactive]]=0;
2889 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2890 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2892 if(id==0)camerashake+=.4;
2899 gLoc[0]=victim->coords.x;
2900 gLoc[1]=victim->coords.y;
2901 gLoc[2]=victim->coords.z;
2905 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2907 if(tutoriallevel!=1){
2908 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2909 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2910 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2911 OPENAL_SetPaused(channels[heavyimpactsound], false);
2915 if(tutoriallevel!=1){
2916 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2917 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2918 OPENAL_SetVolume(channels[landsound2], 256);
2919 OPENAL_SetPaused(channels[landsound2], false);
2923 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
2926 relative=victim->coords-coords;
2928 Normalise(&relative);
2929 for(i=0;i<victim->skeleton.num_joints;i++){
2930 victim->skeleton.joints[i].velocity=relative*30;
2932 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2934 victim->targetframe=0;
2935 victim->targetanimation=staggerbackhardanim;
2936 victim->targetrotation=targetrotation+180;
2941 victim->Puff(abdomen);
2942 victim->DoDamage(damagemult*60/victim->protectionhigh);
2951 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2952 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2954 if(id==0)camerashake+=.4;
2957 gLoc[0]=victim->coords.x;
2958 gLoc[1]=victim->coords.y;
2959 gLoc[2]=victim->coords.z;
2963 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2964 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2965 if(tutoriallevel!=1){
2966 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2967 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2968 OPENAL_SetVolume(channels[thudsound], 512);
2969 OPENAL_SetPaused(channels[thudsound], false);
2972 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2973 if(tutoriallevel!=1){
2974 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2975 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2976 OPENAL_SetVolume(channels[whooshhitsound], 512);
2977 OPENAL_SetPaused(channels[whooshhitsound], false);
2981 if(tutoriallevel!=1){
2982 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2983 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2984 OPENAL_SetVolume(channels[heavyimpactsound], 256);
2985 OPENAL_SetPaused(channels[heavyimpactsound], false);
2989 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2992 relative=victim->coords-coords;
2994 Normalise(&relative);
2996 Normalise(&relative);
2997 for(i=0;i<victim->skeleton.num_joints;i++){
2998 victim->skeleton.joints[i].velocity=relative*5;
3000 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
3002 victim->targetframe=0;
3003 victim->targetanimation=staggerbackhardanim;
3004 victim->targetrotation=targetrotation+180;
3008 victim->Puff(abdomen);
3009 victim->DoDamage(damagemult*60/victim->protectionhigh);
3017 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
3018 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3019 if(victim->id==0)camerashake+=.4;
3022 gLoc[0]=victim->coords.x;
3023 gLoc[1]=victim->coords.y;
3024 gLoc[2]=victim->coords.z;
3029 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3030 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3031 OPENAL_SetVolume(channels[landsound2], 256);
3032 OPENAL_SetPaused(channels[landsound2], false);
3038 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
3039 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3040 if(victim->id==0)camerashake+=.4;
3043 gLoc[0]=victim->coords.x;
3044 gLoc[1]=victim->coords.y;
3045 gLoc[2]=victim->coords.z;
3050 if(weaponactive!=-1){
3051 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3052 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3053 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3055 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3056 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3057 OPENAL_SetVolume(channels[swordstaffsound], 512);
3058 OPENAL_SetPaused(channels[swordstaffsound], false);
3061 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3062 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3063 OPENAL_SetVolume(channels[metalhitsound], 512);
3064 OPENAL_SetPaused(channels[metalhitsound], false);
3072 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3073 if(weaponactive!=-1){
3076 weapons.owner[weaponids[0]]=-1;
3077 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);
3079 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3080 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3082 weapons.velocity[weaponids[0]]=aim*50;
3083 weapons.tipvelocity[weaponids[0]]=aim*50;
3084 weapons.missed[weaponids[0]]=0;
3085 weapons.hitsomething[weaponids[0]]=0;
3086 weapons.freetime[weaponids[0]]=0;
3087 weapons.firstfree[weaponids[0]]=1;
3088 weapons.physics[weaponids[0]]=0;
3091 weaponids[0]=weaponids[num_weapons];
3097 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3099 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3102 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3110 if(tutoriallevel!=1){
3113 gLoc[0]=victim->coords.x;
3114 gLoc[1]=victim->coords.y;
3115 gLoc[2]=victim->coords.z;
3119 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3120 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3121 OPENAL_SetVolume(channels[knifeslicesound], 512);
3122 OPENAL_SetPaused(channels[knifeslicesound], false);
3124 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3125 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3126 if(victim->id != 0 || difficulty==2){
3127 victim->targetframe=0;
3128 victim->targetanimation=staggerbackhardanim;
3129 victim->targetrotation=targetrotation+180;
3133 victim->lowreversaldelay=0;
3134 victim->highreversaldelay=0;
3135 if(aitype!=playercontrolled)weaponmissdelay=.6;
3137 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3138 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3140 XYZ footvel,footpoint;
3143 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3146 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;
3148 if(tutoriallevel!=1){
3149 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3150 footvel=DoRotation(facing,0,90,0)*.8;
3152 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3153 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3154 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3155 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3157 if(tutoriallevel==1){
3158 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3160 victim->DoDamage(damagemult*0);
3163 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3164 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3165 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3172 if(tutoriallevel!=1){
3173 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3174 else victim->DoBloodBig(2/victim->armorhigh,185);
3175 victim->deathbleeding=1;
3178 gLoc[0]=victim->coords.x;
3179 gLoc[1]=victim->coords.y;
3180 gLoc[2]=victim->coords.z;
3184 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3185 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3186 OPENAL_SetVolume(channels[swordslicesound], 512);
3187 OPENAL_SetPaused(channels[swordslicesound], false);
3189 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3190 //if(animation[victim->targetanimation].attack){
3191 //if(victim->creature==rabbittype){
3192 if(tutoriallevel!=1){
3193 victim->targetframe=0;
3194 victim->targetanimation=staggerbackhardanim;
3195 victim->targetrotation=targetrotation+180;
3201 if(tutoriallevel!=1){
3202 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3203 weapons.blooddrip[weaponids[weaponactive]]+=3;
3205 float bloodlossamount;
3206 bloodlossamount=200+abs((float)(Random()%40))-20;
3207 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3208 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3209 victim->DoDamage(damagemult*0);
3211 XYZ footvel,footpoint;
3214 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3217 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;
3219 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3220 footvel=DoRotation(facing,0,90,0)*.8;
3222 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3223 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3224 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3225 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3233 gLoc[0]=victim->coords.x;
3234 gLoc[1]=victim->coords.y;
3235 gLoc[2]=victim->coords.z;
3239 if(victim->weaponactive!=-1){
3240 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3241 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3242 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3244 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3245 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3246 OPENAL_SetVolume(channels[swordstaffsound], 512);
3247 OPENAL_SetPaused(channels[swordstaffsound], false);
3250 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3251 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3252 OPENAL_SetVolume(channels[metalhitsound], 512);
3253 OPENAL_SetPaused(channels[metalhitsound], false);
3259 victim->Puff(righthand);
3261 victim->targetframe=0;
3262 victim->targetanimation=staggerbackhighanim;
3263 victim->targetrotation=targetrotation+180;
3265 weapons.owner[victim->weaponids[0]]=-1;
3266 aim=DoRotation(facing,0,90,0)*21;
3268 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3269 weapons.tipvelocity[victim->weaponids[0]]=aim;
3270 weapons.missed[victim->weaponids[0]]=1;
3271 weapons.hitsomething[weaponids[0]]=0;
3272 weapons.freetime[victim->weaponids[0]]=0;
3273 weapons.firstfree[victim->weaponids[0]]=1;
3274 weapons.physics[victim->weaponids[0]]=1;
3275 victim->num_weapons--;
3276 if(victim->num_weapons){
3277 victim->weaponids[0]=victim->weaponids[num_weapons];
3278 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3280 victim->weaponactive=-1;
3281 for(i=0;i<numplayers;i++){
3282 player[i].wentforweapon=0;
3285 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3286 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3287 OPENAL_SetVolume(channels[metalhitsound], 512);
3288 OPENAL_SetPaused(channels[metalhitsound], false);*/
3294 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3295 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3296 if(tutoriallevel!=1){
3297 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3299 if(id==0)camerashake+=.4;
3300 if(Random()%2||creature==wolftype){
3305 gLoc[0]=victim->coords.x;
3306 gLoc[1]=victim->coords.y;
3307 gLoc[2]=victim->coords.z;
3311 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3312 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3313 OPENAL_SetVolume(channels[staffheadsound], 256);
3314 OPENAL_SetPaused(channels[staffheadsound], false);
3318 relative=victim->coords-coords;
3320 Normalise(&relative);
3321 relative=DoRotation(relative,0,90,0);
3323 Normalise(&relative);
3324 for(i=0;i<victim->skeleton.num_joints;i++){
3325 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3327 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3328 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3331 if(tutoriallevel!=1){
3332 victim->DoDamage(damagemult*120/victim->protectionhigh);
3343 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3344 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3345 if(tutoriallevel!=1){
3346 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3348 if(id==0)camerashake+=.4;
3349 if(Random()%2||creature==wolftype){
3354 gLoc[0]=victim->coords.x;
3355 gLoc[1]=victim->coords.y;
3356 gLoc[2]=victim->coords.z;
3360 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3361 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3362 OPENAL_SetVolume(channels[staffheadsound], 256);
3363 OPENAL_SetPaused(channels[staffheadsound], false);
3367 relative=victim->coords-coords;
3369 Normalise(&relative);
3370 relative=DoRotation(relative,0,-90,0);
3371 for(i=0;i<victim->skeleton.num_joints;i++){
3372 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3374 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3375 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3378 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3389 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3390 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3392 if(tutoriallevel!=1){
3393 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3394 if(id==0)camerashake+=.4;
3395 if(Random()%2||creature==wolftype){
3400 gLoc[0]=victim->coords.x;
3401 gLoc[1]=victim->coords.y;
3402 gLoc[2]=victim->coords.z;
3406 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3407 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3408 OPENAL_SetVolume(channels[staffbodysound], 256);
3409 OPENAL_SetPaused(channels[staffbodysound], false);
3411 victim->skeleton.longdead=0;
3412 victim->skeleton.free=1;
3413 victim->skeleton.broken=0;
3415 for(i=0;i<victim->skeleton.num_joints;i++){
3416 victim->skeleton.joints[i].velchange=0;
3417 victim->skeleton.joints[i].locked=0;
3418 //victim->skeleton.joints[i].velocity=0;
3424 /*relative=victim->coords-coords;
3426 Normalise(&relative);
3427 relative=DoRotation(relative,0,90,0);*/
3429 Normalise(&relative);
3431 for(i=0;i<victim->skeleton.num_joints;i++){
3432 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3435 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3438 for(i=0;i<victim->skeleton.num_joints;i++){
3439 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3442 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3444 victim->Puff(abdomen);
3445 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3458 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3459 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3461 if(id==0)camerashake+=.4;
3464 gLoc[0]=victim->coords.x;
3465 gLoc[1]=victim->coords.y;
3466 gLoc[2]=victim->coords.z;
3471 relative=victim->coords-coords;
3473 Normalise(&relative);
3479 if(animation[victim->targetanimation].height==lowheight){
3485 for(i=0;i<victim->skeleton.num_joints;i++){
3486 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3488 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3489 if(tutoriallevel!=1){
3490 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3491 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3492 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3493 OPENAL_SetPaused(channels[heavyimpactsound], false);
3496 victim->DoDamage(damagemult*100/victim->protectionhead);
3497 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3498 if(creature==wolftype){
3499 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3500 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3501 OPENAL_SetVolume(channels[clawslicesound], 128);
3502 OPENAL_SetPaused(channels[clawslicesound], false);
3504 victim->DoBloodBig(2/victim->armorhead,175);
3508 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3509 for(i=0;i<victim->skeleton.num_joints;i++){
3510 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3512 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3513 victim->targetframe=0;
3514 victim->targetanimation=staggerbackhighanim;
3515 victim->targetrotation=targetrotation+180;
3517 if(tutoriallevel!=1){
3518 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3519 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3520 OPENAL_SetVolume(channels[landsound2], 128);
3521 OPENAL_SetPaused(channels[landsound2], false);
3523 victim->Puff(abdomen);
3524 victim->DoDamage(damagemult*30/victim->protectionhigh);
3525 if(creature==wolftype){
3526 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3527 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3528 OPENAL_SetVolume(channels[clawslicesound], 128);
3529 OPENAL_SetPaused(channels[clawslicesound], false);
3531 victim->DoBloodBig(2/victim->armorhigh,170);
3538 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3539 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3541 if(id==0)camerashake+=.2;
3544 gLoc[0]=victim->coords.x;
3545 gLoc[1]=victim->coords.y;
3546 gLoc[2]=victim->coords.z;
3550 if(tutoriallevel!=1){
3551 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3552 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3553 OPENAL_SetVolume(channels[landsound2], 128);
3554 OPENAL_SetPaused(channels[landsound2], false);
3557 relative=victim->coords-coords;
3559 Normalise(&relative);
3561 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3564 for(i=0;i<victim->skeleton.num_joints;i++){
3565 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3567 relative=DoRotation(relative,0,-90,0);
3569 for(i=0;i<victim->skeleton.num_joints;i++){
3570 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)
3571 victim->skeleton.joints[i].velocity=relative*80;
3573 victim->Puff(rightankle);
3574 victim->Puff(leftankle);
3575 victim->DoDamage(damagemult*40/victim->protectionlow);
3578 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3579 for(i=0;i<victim->skeleton.num_joints;i++){
3580 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3582 relative=DoRotation(relative,0,-90,0);
3583 for(i=0;i<victim->skeleton.num_joints;i++){
3584 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)
3585 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3587 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3588 victim->targetframe=0;
3589 victim->targetanimation=staggerbackhighanim;
3590 victim->targetrotation=targetrotation+180;
3592 if(tutoriallevel!=1){
3593 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3594 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3595 OPENAL_SetVolume(channels[landsound2], 128);
3596 OPENAL_SetPaused(channels[landsound2], false);
3598 victim->Puff(abdomen);
3599 victim->DoDamage(damagemult*30/victim->protectionlow);
3609 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3610 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3612 if(id==0)camerashake+=.4;
3619 gLoc[0]=victim->coords.x;
3620 gLoc[1]=victim->coords.y;
3621 gLoc[2]=victim->coords.z;
3625 if(tutoriallevel!=1){
3626 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3627 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3628 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3629 OPENAL_SetPaused(channels[heavyimpactsound], false);
3631 if(creature==wolftype){
3632 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3633 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3634 OPENAL_SetVolume(channels[clawslicesound], 128);
3635 OPENAL_SetPaused(channels[clawslicesound], false);
3637 victim->DoBloodBig(2/victim->armorhigh,170);
3641 relative=victim->coords-oldcoords;
3643 Normalise(&relative);
3644 //relative=DoRotation(relative,0,-90,0);
3645 for(i=0;i<victim->skeleton.num_joints;i++){
3646 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3648 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3650 victim->Puff(abdomen);
3651 victim->DoDamage(damagemult*150/victim->protectionhigh);
3660 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3661 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3662 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3663 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3666 weaponids[num_weapons]=weaponids[victim->weaponactive];
3669 weaponids[0]=victim->weaponids[victim->weaponactive];
3670 victim->num_weapons--;
3671 if(victim->num_weapons>0){
3672 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3673 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3675 victim->weaponactive=-1;
3680 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3682 if(id==0)camerashake+=.4;
3689 gLoc[0]=victim->coords.x;
3690 gLoc[1]=victim->coords.y;
3691 gLoc[2]=victim->coords.z;
3695 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3696 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3697 OPENAL_SetVolume(channels[whooshhitsound], 128);
3698 OPENAL_SetPaused(channels[whooshhitsound], false);
3701 relative=victim->coords-oldcoords;
3703 Normalise(&relative);
3704 //relative=DoRotation(relative,0,-90,0);
3705 for(i=0;i<victim->skeleton.num_joints;i++){
3706 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3708 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3711 victim->DoDamage(damagemult*70/victim->protectionhigh);
3714 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3716 if(id==0)camerashake+=.4;
3723 gLoc[0]=victim->coords.x;
3724 gLoc[1]=victim->coords.y;
3725 gLoc[2]=victim->coords.z;
3731 bonus=staffreversebonus;
3736 if(tutoriallevel!=1){
3737 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3738 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3739 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3740 OPENAL_SetPaused(channels[heavyimpactsound], false);
3744 bonus=staffreversebonus;
3750 relative=victim->coords-oldcoords;
3752 Normalise(&relative);
3753 //relative=DoRotation(relative,0,-90,0);
3754 for(i=0;i<victim->skeleton.num_joints;i++){
3755 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3757 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3760 victim->DoDamage(damagemult*70/victim->protectionhigh);
3763 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3769 Normalise(&relative);
3772 for(i=0;i<victim->skeleton.num_joints;i++){
3773 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3775 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3776 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3777 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3778 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3779 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3780 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3781 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3782 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3784 victim->Puff(abdomen);
3785 victim->DoDamage(damagemult*90/victim->protectionhigh);
3795 if(weaponactive!=-1||creature==wolftype)doslice=1;
3796 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3800 gLoc[0]=victim->coords.x;
3801 gLoc[1]=victim->coords.y;
3802 gLoc[2]=victim->coords.z;
3806 if(weaponactive!=-1){
3807 victim->DoBloodBig(2/victim->armorhigh,225);
3808 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3809 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3810 OPENAL_SetVolume(channels[knifeslicesound], 512);
3811 OPENAL_SetPaused(channels[knifeslicesound], false);
3812 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3813 weapons.blooddrip[weaponids[weaponactive]]+=3;
3815 if(weaponactive==-1&&creature==wolftype){
3816 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3817 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3818 OPENAL_SetVolume(channels[clawslicesound], 128);
3819 OPENAL_SetPaused(channels[clawslicesound], false);
3821 victim->DoBloodBig(2/victim->armorhigh,175);
3828 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3834 Normalise(&relative);
3837 for(i=0;i<victim->skeleton.num_joints;i++){
3838 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3840 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
3841 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
3842 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
3843 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
3844 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
3845 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
3846 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
3847 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
3850 bonus=swordreversebonus;
3854 //victim->DoDamage(90);
3856 /*if(weaponactive!=-1){
3859 gLoc[0]=victim->coords.x;
3860 gLoc[1]=victim->coords.y;
3861 gLoc[2]=victim->coords.z;
3865 victim->DoBloodBig(2,225);
3866 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3867 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3868 OPENAL_SetVolume(channels[knifeslicesound], 512);
3869 OPENAL_SetPaused(channels[knifeslicesound], false);
3870 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3871 weapons.blooddrip[weaponids[weaponactive]]+=3;
3875 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3877 if(id==0)camerashake+=.4;
3884 gLoc[0]=victim->coords.x;
3885 gLoc[1]=victim->coords.y;
3886 gLoc[2]=victim->coords.z;
3890 if(tutoriallevel!=1){
3891 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3892 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3893 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3894 OPENAL_SetPaused(channels[heavyimpactsound], false);
3898 relative=victim->coords-oldcoords;
3900 Normalise(&relative);
3901 relative=DoRotation(relative,0,-90,0);
3902 for(i=0;i<victim->skeleton.num_joints;i++){
3903 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3905 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3907 victim->Puff(abdomen);
3908 victim->DoDamage(damagemult*30/victim->protectionhigh);
3917 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
3920 victim->skeleton.spinny=0;
3924 Normalise(&relative);
3925 if(victim->id==0)relative/=30;
3926 for(i=0;i<victim->skeleton.num_joints;i++){
3927 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3929 //victim->DoDamage(1000);
3930 victim->damage=victim->damagetolerance;
3931 victim->permanentdamage=victim->damagetolerance-1;
3934 if(weaponactive!=-1||creature==wolftype)doslice=1;
3935 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3939 gLoc[0]=victim->coords.x;
3940 gLoc[1]=victim->coords.y;
3941 gLoc[2]=victim->coords.z;
3945 if(weaponactive!=-1){
3946 victim->DoBloodBig(200,225);
3947 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3948 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3949 OPENAL_SetVolume(channels[knifeslicesound], 512);
3950 OPENAL_SetPaused(channels[knifeslicesound], false);
3951 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3952 weapons.blooddrip[weaponids[weaponactive]]+=5;
3955 if(creature==wolftype&&weaponactive==-1){
3956 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3957 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3958 OPENAL_SetVolume(channels[clawslicesound], 128);
3959 OPENAL_SetPaused(channels[clawslicesound], false);
3961 victim->DoBloodBig(2,175);
3971 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3972 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3974 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3975 if(targetanimation==knifesneakattackanim){
3976 /*victim->DoBloodBig(200,195);
3981 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3982 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3984 XYZ footvel,footpoint;
3986 footpoint=weapons.tippoint[weaponids[0]];
3987 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3988 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3989 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3990 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3991 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3992 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3993 victim->DoBloodBig(200,195);
4000 //victim->neckspurtamount=5;
4002 if(targetanimation==knifefollowanim){
4008 XYZ footvel,footpoint;
4010 footpoint=weapons.tippoint[weaponids[0]];
4011 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4012 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4013 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4014 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4015 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
4016 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
4019 victim->bloodloss+=10000;
4023 gLoc[0]=victim->coords.x;
4024 gLoc[1]=victim->coords.y;
4025 gLoc[2]=victim->coords.z;
4029 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4030 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4031 OPENAL_SetVolume(channels[fleshstabsound], 512);
4032 OPENAL_SetPaused(channels[fleshstabsound], false);
4033 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4034 weapons.blooddrip[weaponids[weaponactive]]+=5;
4038 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
4041 for(i=0;i<victim->skeleton.num_joints;i++){
4042 victim->skeleton.joints[i].velocity=0;
4044 if(targetanimation==knifefollowanim){
4046 for(i=0;i<victim->skeleton.num_joints;i++){
4047 victim->skeleton.joints[i].velocity=0;
4050 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
4053 gLoc[0]=victim->coords.x;
4054 gLoc[1]=victim->coords.y;
4055 gLoc[2]=victim->coords.z;
4059 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4060 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4061 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4062 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4063 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4064 weapons.blooddrip[weaponids[weaponactive]]+=5;
4066 XYZ footvel,footpoint;
4068 footpoint=weapons.tippoint[weaponids[0]];
4069 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4070 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4071 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4072 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4073 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4074 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4078 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4079 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4088 XYZ footvel,footpoint;
4090 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
4091 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4092 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4093 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4094 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4095 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4096 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4097 victim->DoBloodBig(200,180);
4098 victim->DoBloodBig(200,215);
4099 victim->bloodloss+=10000;
4103 gLoc[0]=victim->coords.x;
4104 gLoc[1]=victim->coords.y;
4105 gLoc[2]=victim->coords.z;
4109 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4110 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4111 OPENAL_SetVolume(channels[fleshstabsound], 512);
4112 OPENAL_SetPaused(channels[fleshstabsound], false);
4113 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4114 weapons.blooddrip[weaponids[weaponactive]]+=5;
4118 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
4121 for(i=0;i<victim->skeleton.num_joints;i++){
4122 victim->skeleton.joints[i].velocity=0;
4124 if(weaponactive!=-1){
4127 gLoc[0]=victim->coords.x;
4128 gLoc[1]=victim->coords.y;
4129 gLoc[2]=victim->coords.z;
4133 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4134 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4135 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4136 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4137 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4138 weapons.blooddrip[weaponids[weaponactive]]+=5;
4140 XYZ footvel,footpoint;
4142 footpoint=weapons.tippoint[weaponids[0]];
4143 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4144 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4145 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4146 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4147 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4148 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4152 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4154 if(id==0)camerashake+=.4;
4161 gLoc[0]=victim->coords.x;
4162 gLoc[1]=victim->coords.y;
4163 gLoc[2]=victim->coords.z;
4167 if(weaponactive==-1){
4168 if(tutoriallevel!=1){
4169 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4170 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4171 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4172 OPENAL_SetPaused(channels[heavyimpactsound], false);
4177 if(weaponactive!=-1||creature==wolftype)doslice=1;
4178 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4180 if(weaponactive!=-1){
4181 victim->DoBloodBig(2/victim->armorhead,225);
4182 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4183 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4184 OPENAL_SetVolume(channels[knifeslicesound], 512);
4185 OPENAL_SetPaused(channels[knifeslicesound], false);
4186 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4187 weapons.blooddrip[weaponids[weaponactive]]+=3;
4189 if(weaponactive==-1&&creature==wolftype){
4190 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4191 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4192 OPENAL_SetVolume(channels[clawslicesound], 128);
4193 OPENAL_SetPaused(channels[clawslicesound], false);
4195 victim->DoBloodBig(2/victim->armorhead,175);
4208 //relative=victim->coords-oldcoords;
4211 Normalise(&relative);
4212 relative=DoRotation(relative,0,90,0);
4214 Normalise(&relative);
4215 for(i=0;i<victim->skeleton.num_joints;i++){
4216 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4218 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4219 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4220 victim->DoDamage(damagemult*100/victim->protectionhead);
4224 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4228 //relative=victim->coords-oldcoords;
4231 Normalise(&relative);
4232 relative=DoRotation(relative,0,90,0);
4234 Normalise(&relative);
4235 for(i=0;i<victim->skeleton.num_joints;i++){
4236 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4238 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4241 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4242 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4253 if(targetframe>animation[currentanimation].numframes-1){
4256 targetanimation=getIdle();
4260 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4261 targetanimation=rollanim;
4272 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4273 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4274 OPENAL_SetVolume(channels[movewhooshsound], 128);
4275 OPENAL_SetPaused(channels[movewhooshsound], false);
4277 if(currentanimation==staggerbackhighanim){
4278 targetanimation=getIdle();
4280 if(currentanimation==staggerbackhardanim){
4281 targetanimation=getIdle();
4283 if(currentanimation==removeknifeanim){
4284 targetanimation=getIdle();
4286 if(currentanimation==crouchremoveknifeanim){
4287 targetanimation=getCrouch();
4289 if(currentanimation==backhandspringanim){
4290 targetanimation=getIdle();
4292 if(currentanimation==dodgebackanim){
4293 targetanimation=getIdle();
4295 if(currentanimation==drawleftanim){
4296 targetanimation=getIdle();
4298 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4299 targetanimation=getIdle();
4300 if(currentanimation==crouchdrawrightanim){
4301 targetanimation=getCrouch();
4303 if(weaponactive==-1)weaponactive=0;
4304 else if(weaponactive==0){
4308 buffer=weaponids[0];
4309 weaponids[0]=weaponids[1];
4310 weaponids[1]=buffer;
4314 if(weaponactive==-1){
4324 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4325 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4326 OPENAL_SetVolume(channels[knifesheathesound], 128);
4327 OPENAL_SetPaused(channels[knifesheathesound], false);
4329 if(weaponactive!=-1){
4339 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4340 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4341 OPENAL_SetVolume(channels[knifedrawsound], 128);
4342 OPENAL_SetPaused(channels[knifedrawsound], false);
4345 if(currentanimation==rollanim){
4346 targetanimation=getCrouch();
4351 if(targetanimation==walljumprightkickanim){
4354 if(targetanimation==walljumpleftkickanim){
4357 targetanimation=jumpdownanim;
4359 if(currentanimation==climbanim){
4360 targetanimation=getCrouch();
4363 if(!isnormal(coords.x))
4374 if(targetanimation==rabbitkickreversalanim){
4375 targetanimation=getCrouch();
4378 if(targetanimation==jumpreversalanim){
4379 targetanimation=getCrouch();
4382 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4383 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4385 float closestdist=-1;
4388 for(i=0;i<numplayers;i++){
4389 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4390 distance=findDistancefast(&player[i].coords,&coords);
4391 if(closestdist==-1||distance<closestdist){
4392 closestdist=distance;
4397 if(closestdist>0&&closest>=0&&closestdist<16){
4398 victim=&player[closest];
4399 targetanimation=walljumprightkickanim;
4401 XYZ rotatetarget=victim->coords-coords;
4402 Normalise(&rotatetarget);
4403 rotation=-asin(0-rotatetarget.x);
4405 if(rotatetarget.z<0)rotation=180-rotation;
4406 targettilt2=-asin(rotatetarget.y)*360/6.28;
4407 velocity=(victim->coords-coords)*4;
4412 if(targetanimation==walljumpbackanim){
4413 targetanimation=backflipanim;
4417 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4419 if(targetanimation==walljumprightanim){
4420 targetanimation=rightflipanim;
4424 velocity=DoRotation(facing,0,30,0)*-8;
4427 if(targetanimation==walljumpfrontanim){
4428 targetanimation=frontflipanim;
4430 //targetrotation-=180;
4435 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4437 if(targetanimation==walljumpleftanim){
4440 float closestdist=-1;
4443 for(i=0;i<numplayers;i++){
4444 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4445 distance=findDistancefast(&player[i].coords,&coords);
4446 if(closestdist==-1||distance<closestdist){
4447 closestdist=distance;
4452 if(closestdist>0&&closest>=0&&closestdist<16){
4453 victim=&player[closest];
4454 targetanimation=walljumpleftkickanim;
4456 XYZ rotatetarget=victim->coords-coords;
4457 Normalise(&rotatetarget);
4458 rotation=-asin(0-rotatetarget.x);
4460 if(rotatetarget.z<0)rotation=180-rotation;
4461 targettilt2=-asin(rotatetarget.y)*360/6.28;
4462 velocity=(victim->coords-coords)*4;
4467 if(targetanimation!=walljumpleftkickanim){
4468 targetanimation=leftflipanim;
4472 velocity=DoRotation(facing,0,-30,0)*-8;
4475 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4477 if(targetanimation==sneakattackanim){
4478 float ycoords=oldcoords.y;
4479 currentanimation=getCrouch();
4480 targetanimation=getCrouch();
4483 targetrotation+=180;
4488 targetheadrotation+=180;
4490 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4494 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4495 float ycoords=oldcoords.y;
4496 targetanimation=getIdle();
4498 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4502 if(currentanimation==knifefollowanim){
4503 targetanimation=getIdle();
4506 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4507 float ycoords=oldcoords.y;
4508 targetanimation=getStop();
4509 targetrotation+=180;
4514 targetheadrotation+=180;
4515 if(!isnormal(coords.x))
4517 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4518 oldcoords=coords+facing*.5;
4519 else if(currentanimation==sweepreversalanim)
4520 oldcoords=coords+facing*1.1;
4521 else if(currentanimation==upunchreversalanim){
4522 oldcoords=coords+facing*1.5;
4523 targetrotation+=180;
4525 targetheadrotation+=180;
4529 else if(currentanimation==knifeslashreversalanim){
4530 oldcoords=coords+facing*.5;
4533 targetheadrotation+=90;
4537 else if(currentanimation==staffspinhitreversalanim){
4538 targetrotation+=180;
4540 targetheadrotation+=180;
4544 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4545 else oldcoords.y=ycoords;
4546 currentoffset=coords-oldcoords;
4552 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4557 if(animation[targetanimation].attack==reversed){
4559 if(targetanimation==sweepreversedanim)targetrotation+=90;
4560 targetanimation=backhandspringanim;
4570 PlaySoundEx( landsound, samp[landsound], NULL, true);
4571 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4572 OPENAL_SetVolume(channels[landsound], 128);
4573 OPENAL_SetPaused(channels[landsound], false);
4575 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4576 targetanimation=rollanim;
4579 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4580 coords.y=oldcoords.y;
4582 if(currentanimation==knifeslashreversedanim){
4583 targetanimation=rollanim;
4588 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4589 coords.y=oldcoords.y;
4593 targetanimation=jumpdownanim;
4595 if(wasLanding())targetanimation=getIdle();
4596 if(wasLandhard())targetanimation=getIdle();
4597 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4598 targetanimation=getIdle();
4600 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4601 coords.y=oldcoords.y;
4602 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4603 targetoffset.y=coords.y;
4604 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4605 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4606 currentoffset.y-=(coords.y-targetoffset.y);
4607 coords.y=targetoffset.y;
4609 normalsupdatedelay=0;
4611 if(currentanimation==upunchanim){
4612 targetanimation=getStop();
4613 normalsupdatedelay=0;
4616 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4617 targetrotation=rotation;
4620 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4621 if(!hasstaff)DoDamage(35);
4624 rabbitkickragdoll=1;
4626 if(currentanimation==rabbitkickreversedanim){
4633 if(id!=0)SolidHitBonus();
4637 targetanimation=rollanim;
4639 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4643 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4649 if(currentanimation==jumpreversedanim){
4656 if(id!=0)SolidHitBonus();
4660 targetanimation=rollanim;
4662 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4667 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){
4668 targetanimation=getupfromfrontanim;
4671 else if(animation[currentanimation].attack==normalattack){
4672 targetanimation=getIdle();
4675 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4676 targetanimation=blockhighleftstrikeanim;
4678 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4679 targetanimation=getIdle();
4682 if(currentanimation==spinkickanim&&victim->skeleton.free){
4683 if(creature==rabbittype)targetanimation=fightidleanim;
4688 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4690 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4691 targetanimation=jumpdownanim;
4696 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4697 if(!isRun()||!wasRun()){
4698 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4699 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4700 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4701 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4703 if(isRun()&&wasRun()){
4706 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4707 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4710 else if(transspeed)target+=multiplier*transspeed*speed*2;
4712 if(!isRun()||!wasRun()){
4713 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4714 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4715 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4716 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4720 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4722 if(target>1){currentframe=targetframe; target=1;}
4724 rot=targetrot*target;
4725 rotation+=rot-oldrot;
4731 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4733 for(i=0;i<skeleton.num_joints;i++){
4734 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4737 skeleton.FindForwards();
4739 for(i=0;i<skeleton.num_muscles;i++){
4740 if(skeleton.muscles[i].visible)
4742 skeleton.FindRotationMuscle(i,targetanimation);
4745 for(i=0;i<skeleton.num_muscles;i++){
4746 if(skeleton.muscles[i].visible)
4748 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4749 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4750 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4755 for(i=0;i<skeleton.num_joints;i++){
4756 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4759 skeleton.FindForwards();
4761 for(i=0;i<skeleton.num_muscles;i++){
4762 if(skeleton.muscles[i].visible)
4764 skeleton.FindRotationMuscle(i,targetanimation);
4767 for(i=0;i<skeleton.num_muscles;i++){
4768 if(skeleton.muscles[i].visible)
4770 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4771 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4772 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4773 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4774 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4775 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4776 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4777 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4778 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4782 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4784 oldcurrentanimation=currentanimation;
4785 oldtargetanimation=targetanimation;
4786 oldtargetframe=targetframe;
4787 oldcurrentframe=currentframe;
4789 for(i=0;i<skeleton.num_joints;i++){
4790 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4791 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4793 offset=currentoffset*(1-target)+targetoffset*target;
4794 for(i=0;i<skeleton.num_muscles;i++){
4795 if(skeleton.muscles[i].visible)
4797 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4798 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4799 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4804 if(isLanding()&&landhard){
4805 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4806 if(id==0)camerashake+=.4;
4807 targetanimation=getLandhard();
4815 //skeleton.DoConstraints();
4818 void Person::DoStuff(){
4819 static XYZ terrainnormal;
4820 static XYZ flatfacing;
4821 static XYZ flatvelocity;
4822 static float flatvelspeed;
4826 static int bloodsize;
4827 static int startx,starty,endx,endy;
4828 static int texdetailint;
4829 static GLubyte color;
4830 static XYZ bloodvel;
4832 onfiredelay-=multiplier;
4833 if(onfiredelay<0&&onfire)
4841 crouchkeydowntime+=multiplier;
4842 if(!crouchkeydown)crouchkeydowntime=0;
4843 jumpkeydowntime+=multiplier;
4844 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
4846 if(hostile||damage>0||bloodloss>0)immobile=0;
4848 if(isIdle()||isRun())targetoffset=0;
4850 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
4852 if(id==0)blooddimamount-=multiplier*.3;
4853 speechdelay-=multiplier;
4854 texupdatedelay-=multiplier;
4855 interestdelay-=multiplier;
4856 flamedelay-=multiplier;
4857 parriedrecently-=multiplier;
4863 if(id==0)speed=1.1*speedmult;
4864 else speed=1.0*speedmult;
4865 if(!skeleton.free)rabbitkickragdoll=0;
4869 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
4870 if(id!=0&&creature==wolftype&&difficulty==2){
4872 if(aitype!=passivetype){
4874 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){
4878 if(scale<0.2)superruntoggle=0;
4879 if(targetanimation==wolfrunninganim&&!superruntoggle){
4880 targetanimation=getRun();
4884 if(weaponactive==-1&&num_weapons>0){
4885 if(weapons.type[weaponids[0]]==staff){
4892 /*if(aitype!=playercontrolled)*///deathbleeding=5;
4893 /*if(aitype!=playercontrolled)*/
4895 if(burnt>.6)burnt=.6;
4896 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
4898 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
4909 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4910 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
4914 while(flamedelay<0&&onfire){
4916 howmany=abs(Random()%(skeleton.num_joints));
4917 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4918 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4919 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4920 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4921 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
4924 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
4926 howmany=abs(Random()%(skeleton.num_joints));
4927 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4928 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4929 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4930 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4931 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
4935 bleeding-=multiplier*.3;
4937 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4938 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
4942 if(neckspurtamount>0){
4943 neckspurtamount-=multiplier;
4944 neckspurtdelay-=multiplier*3;
4945 neckspurtparticledelay-=multiplier*3;
4946 if(neckspurtparticledelay<0&&neckspurtdelay>2){
4950 bloodvel.z=5*neckspurtamount;
4951 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4954 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
4956 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4957 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
4958 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);
4959 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);
4960 neckspurtparticledelay=.05;
4962 if(neckspurtdelay<0){
4967 if(deathbleeding>0&&dead!=2){
4968 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
4969 else bleeddelay-=5*multiplier/4;
4970 if(bleeddelay<0&&bloodtoggle){
4975 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4976 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
4977 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
4978 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);
4981 bloodloss+=deathbleeding*multiplier*80;
4982 deathbleeding-=multiplier*1.6;
4983 //if(id==0)deathbleeding-=multiplier*.2;
4984 if(deathbleeding<0)deathbleeding=0;
4985 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
4986 if(weaponactive!=-1){
4987 weapons.owner[weaponids[0]]=-1;
4988 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4989 weapons.velocity[weaponids[0]].x+=.01;
4990 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4991 weapons.missed[weaponids[0]]=1;
4992 weapons.hitsomething[weaponids[0]]=0;
4993 weapons.freetime[weaponids[0]]=0;
4994 weapons.firstfree[weaponids[0]]=1;
4995 weapons.physics[weaponids[0]]=1;
4998 weaponids[0]=weaponids[num_weapons];
4999 if(weaponstuck==num_weapons)weaponstuck=0;
5002 for(i=0;i<numplayers;i++){
5003 player[i].wentforweapon=0;
5015 if(!dead&&creature==wolftype){
5021 if(targetanimation==knifefollowedanim&&!skeleton.free){
5022 for(i=0;i<skeleton.num_joints;i++){
5023 skeleton.joints[i].velocity=0;
5024 skeleton.joints[i].velocity.y=-2;
5027 if(id!=0&&unconscioustime>.1){
5035 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
5038 bloodsize=5-realtexdetail;
5042 texdetailint=realtexdetail;
5043 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5044 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5045 endx=startx+bloodsize;
5046 endy=starty+bloodsize;
5048 if(startx<0){startx=0;bleeding=0;}
5049 if(starty<0){starty=0;bleeding=0;}
5050 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
5051 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
5052 if(endx<startx)endx=startx;
5053 if(endy<starty)endy=starty;
5055 for(i=startx;i<endx;i++){
5056 for(j=starty;j<endy;j++){
5058 color=Random()%85+170;
5059 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
5060 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
5061 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
5066 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5067 DoMipmaps(0,startx,endx,starty,endy);
5071 bleedy-=4/realtexdetail;
5072 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
5073 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
5076 bleedx+=4*direction/realtexdetail;
5077 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
5078 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
5082 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
5083 righthandmorphness=targetrighthandmorphness;
5084 righthandmorphstart=righthandmorphend;
5086 else if(righthandmorphness>targetrighthandmorphness){
5087 righthandmorphness-=multiplier*4;
5089 else if(righthandmorphness<targetrighthandmorphness){
5090 righthandmorphness+=multiplier*4;
5093 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
5094 lefthandmorphness=targetlefthandmorphness;
5095 lefthandmorphstart=lefthandmorphend;
5097 else if(lefthandmorphness>targetlefthandmorphness){
5098 lefthandmorphness-=multiplier*4;
5100 else if(lefthandmorphness<targetlefthandmorphness){
5101 lefthandmorphness+=multiplier*4;
5104 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
5105 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
5106 tailmorphness=targettailmorphness;
5107 tailmorphstart=tailmorphend;
5109 else if(tailmorphness>targettailmorphness){
5110 tailmorphness-=multiplier*10;
5112 else if(tailmorphness<targettailmorphness){
5113 tailmorphness+=multiplier*10;
5117 if(creature==wolftype){
5118 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
5119 tailmorphness=targettailmorphness;
5120 tailmorphstart=tailmorphend;
5122 else if(tailmorphness>targettailmorphness){
5123 tailmorphness-=multiplier*2;
5125 else if(tailmorphness<targettailmorphness){
5126 tailmorphness+=multiplier*2;
5130 if(headmorphend==3||headmorphstart==3){
5131 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
5132 headmorphness=targetheadmorphness;
5133 headmorphstart=headmorphend;
5135 else if(headmorphness>targetheadmorphness){
5136 headmorphness-=multiplier*7;
5138 else if(headmorphness<targetheadmorphness){
5139 headmorphness+=multiplier*7;
5142 else if(headmorphend==5||headmorphstart==5){
5143 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
5144 headmorphness=targetheadmorphness;
5145 headmorphstart=headmorphend;
5147 else if(headmorphness>targetheadmorphness){
5148 headmorphness-=multiplier*10;
5150 else if(headmorphness<targetheadmorphness){
5151 headmorphness+=multiplier*10;
5155 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5156 headmorphness=targetheadmorphness;
5157 headmorphstart=headmorphend;
5159 else if(headmorphness>targetheadmorphness){
5160 headmorphness-=multiplier*4;
5162 else if(headmorphness<targetheadmorphness){
5163 headmorphness+=multiplier*4;
5167 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5168 chestmorphness=targetchestmorphness;
5169 chestmorphstart=chestmorphend;
5171 else if(chestmorphness>targetchestmorphness){
5172 chestmorphness-=multiplier;
5174 else if(chestmorphness<targetchestmorphness){
5175 chestmorphness+=multiplier;
5178 if(dead!=2&&howactive<=typesleeping){
5179 if(chestmorphstart==0&&chestmorphend==0){
5181 targetchestmorphness=1;
5184 if(chestmorphstart!=0&&chestmorphend!=0){
5186 targetchestmorphness=1;
5188 if(environment==snowyenvironment){
5191 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5192 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5193 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5194 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5195 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5196 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5200 if(!dead&&howactive<typesleeping){
5201 blinkdelay-=multiplier*2;
5202 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5204 targetheadmorphness=1;
5206 blinkdelay=(float)(abs(Random()%40))/5;
5208 if(headmorphstart==3&&headmorphend==3){
5210 targetheadmorphness=1;
5215 twitchdelay-=multiplier*1.5;
5216 if(targetanimation!=hurtidleanim){
5217 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5219 targetheadmorphness=1;
5221 twitchdelay=(float)(abs(Random()%40))/5;
5223 if(headmorphstart==5&&headmorphend==5){
5225 targetheadmorphness=1;
5229 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5230 twitchdelay3-=multiplier*1;
5232 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5233 righthandmorphness=0;
5234 targetrighthandmorphness=1;
5235 righthandmorphend=1;
5236 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5238 if(righthandmorphstart==1&&righthandmorphend==1){
5239 righthandmorphness=0;
5240 targetrighthandmorphness=1;
5241 righthandmorphend=0;
5245 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5246 lefthandmorphness=0;
5247 targetlefthandmorphness=1;
5249 twitchdelay3=(float)(abs(Random()%40))/5;
5251 if(lefthandmorphstart==1&&lefthandmorphend==1){
5252 lefthandmorphness=0;
5253 targetlefthandmorphness=1;
5260 if(creature==rabbittype){
5261 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5262 else twitchdelay2-=multiplier*0.5;
5263 if(howactive<=typesleeping){
5264 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5266 targettailmorphness=1;
5268 twitchdelay2=(float)(abs(Random()%40))/5;
5270 if(tailmorphstart==1&&tailmorphend==1){
5272 targettailmorphness=1;
5275 if(tailmorphstart==2&&tailmorphend==2){
5277 targettailmorphness=1;
5284 if(creature==wolftype){
5285 twitchdelay2-=multiplier*1.5;
5287 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5289 targettailmorphness=1;
5294 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5296 targettailmorphness=1;
5300 if(twitchdelay2<=0){
5301 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5303 targettailmorphness=1;
5306 if(tailmorphstart==1&&tailmorphend==1){
5308 targettailmorphness=1;
5311 if(tailmorphstart==2&&tailmorphend==2){
5313 targettailmorphness=1;
5316 if(tailmorphstart==3&&tailmorphend==3){
5318 targettailmorphness=1;
5321 if(tailmorphstart==4&&tailmorphend==4){
5323 targettailmorphness=1;
5329 if(dead!=1)unconscioustime=0;
5331 if(dead==1||howactive==typesleeping){
5332 unconscioustime+=multiplier;
5333 //If unconscious, close eyes and mouth
5334 if(righthandmorphend!=0)righthandmorphness=0;
5335 righthandmorphend=0;
5336 targetrighthandmorphness=1;
5338 if(lefthandmorphend!=0)lefthandmorphness=0;
5340 targetlefthandmorphness=1;
5342 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5344 targetheadmorphness=1;
5348 if(howactive>typesleeping){
5351 if(bloodtoggle&&!bled){
5352 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5354 if(bloodtoggle&&!bled)
5355 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5356 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5357 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5361 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5366 if(dead==2||howactive>typesleeping){
5367 //If dead, open mouth and hands
5368 if(righthandmorphend!=0)righthandmorphness=0;
5369 righthandmorphend=0;
5370 targetrighthandmorphness=1;
5372 if(lefthandmorphend!=0)lefthandmorphness=0;
5374 targetlefthandmorphness=1;
5376 if(headmorphend!=2)headmorphness=0;
5378 targetheadmorphness=1;
5381 if(stunned>0&&!dead&&headmorphend!=2){
5382 if(headmorphend!=4)headmorphness=0;
5384 targetheadmorphness=1;
5387 if(damage>damagetolerance&&!dead){
5392 if(creature==wolftype){
5400 if(weaponactive!=-1){
5401 weapons.owner[weaponids[0]]=-1;
5402 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5403 weapons.velocity[weaponids[0]].x+=.01;
5404 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5405 weapons.missed[weaponids[0]]=1;
5406 weapons.hitsomething[weaponids[0]]=0;
5407 weapons.freetime[weaponids[0]]=0;
5408 weapons.firstfree[weaponids[0]]=1;
5409 weapons.physics[weaponids[0]]=1;
5412 weaponids[0]=weaponids[num_weapons];
5413 if(weaponstuck==num_weapons)weaponstuck=0;
5416 for(i=0;i<numplayers;i++){
5417 player[i].wentforweapon=0;
5423 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5431 //if(dead)damage-=multiplier/4;
5432 if(!dead)damage-=multiplier*13;
5433 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5434 if(!dead)permanentdamage-=multiplier*4;
5435 if(isIdle()||isCrouch()){
5436 if(!dead)permanentdamage-=multiplier*4;
5437 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5439 if(damage<0)damage=0;
5440 if(permanentdamage<0)permanentdamage=0;
5441 if(superpermanentdamage<0)superpermanentdamage=0;
5442 if(permanentdamage<superpermanentdamage){
5443 permanentdamage=superpermanentdamage;
5445 if(damage<permanentdamage){
5446 damage=permanentdamage;
5448 if(dead==1&&damage<damagetolerance){
5452 for(i=0;i<skeleton.num_joints;i++){
5453 skeleton.joints[i].velocity=0;
5456 if(permanentdamage>damagetolerance&&dead!=2){
5459 if(weaponactive!=-1){
5460 weapons.owner[weaponids[0]]=-1;
5461 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5462 weapons.velocity[weaponids[0]].x+=.01;
5463 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5464 weapons.missed[weaponids[0]]=1;
5465 weapons.hitsomething[weaponids[0]]=0;
5466 weapons.freetime[weaponids[0]]=0;
5467 weapons.firstfree[weaponids[0]]=1;
5468 weapons.physics[weaponids[0]]=1;
5471 weaponids[0]=weaponids[num_weapons];
5472 if(weaponstuck==num_weapons)weaponstuck=0;
5475 for(i=0;i<numplayers;i++){
5476 player[i].wentforweapon=0;
5482 if(!dead&&creature==wolftype){
5488 if(id!=0&&unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance){
5493 if(id!=0&&unconscioustime>.1){
5509 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5510 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5511 OPENAL_SetVolume(channels[breaksound], 512);
5512 OPENAL_SetPaused(channels[breaksound], false);
5513 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5519 if(skeleton.free==1){
5520 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5523 //If knocked over, open hands and close mouth
5524 if(righthandmorphend!=0)righthandmorphness=0;
5525 righthandmorphend=0;
5526 targetrighthandmorphness=1;
5528 if(lefthandmorphend!=0)lefthandmorphness=0;
5530 targetlefthandmorphness=1;
5532 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5533 if(headmorphend!=0)headmorphness=0;
5535 targetheadmorphness=1;
5539 skeleton.DoGravity(&scale);
5541 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5542 if(id!=0&&damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1)){
5547 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5551 for(j=0;j<skeleton.num_joints;j++){
5552 average+=skeleton.joints[j].position;
5556 coords+=average*scale;
5557 for(j=0;j<skeleton.num_joints;j++){
5558 skeleton.joints[j].position-=average;
5560 average/=multiplier;
5562 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5564 for(i=0;i<skeleton.num_joints;i++){
5565 velocity+=skeleton.joints[i].velocity*scale;
5567 velocity/=skeleton.num_joints;
5569 if(!isnormal(velocity.x)&&velocity.x){
5582 if(findLength(&average)<10&&dead&&skeleton.free){
5583 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5584 if(skeleton.longdead>2000){
5585 if(skeleton.longdead>6000){
5586 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5591 if(dead==2&&bloodloss<damagetolerance){
5593 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5595 if(bloodtoggle&&!bled){
5596 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5598 if(bloodtoggle&&!bled)
5599 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5600 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5601 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5605 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5609 if(dead==2&&bloodloss>=damagetolerance){
5611 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5612 if(bleeding<=0)DoBlood(1,255);
5613 if(bloodtoggle&&!bled){
5614 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5616 if(bloodtoggle&&!bled)
5617 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5618 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5619 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5623 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5630 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5632 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5636 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5637 if(velocity.y<-30)canrecover=0;
5638 for(i=0;i<objects.numobjects;i++){
5639 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5640 colviewer=startpoint;
5642 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5650 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5651 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5652 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5653 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5655 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5656 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5657 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5659 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5660 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5661 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5663 Normalise(&terrainnormal);
5665 targetrotation=-asin(0-terrainnormal.x);
5666 targetrotation*=360/6.28;
5667 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5668 rotation=targetrotation;
5670 //if(skeleton.forward.y<0){
5673 //if(skeleton.forward.y>-.3){
5676 targetanimation=flipanim;
5677 crouchtogglekeydown=1;
5682 currentanimation=tempanim;
5685 //tilt2=targettilt2;
5687 //if(middle.y>0)targetoffset.y=middle.y+1;
5689 for(i=0;i<skeleton.num_joints;i++){
5690 tempanimation.position[i][0]=skeleton.joints[i].position;
5691 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5696 if(findLength(&average)<10&&!dead&&skeleton.free){
5697 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5698 if(skeleton.longdead>(damage+500)*1.5){
5699 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5705 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5706 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5707 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5708 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5710 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5711 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5712 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5714 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5715 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5716 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5718 Normalise(&terrainnormal);
5720 targetrotation=-asin(0-terrainnormal.x);
5721 targetrotation*=360/6.28;
5722 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5723 rotation=targetrotation;
5726 terrainnormal=terrain.getNormal(coords.x,coords.z);
5727 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5731 /*XYZ otherterrainnormal;
5732 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5733 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5734 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5735 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5738 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5742 if(skeleton.forward.y<0){
5743 targetanimation=getupfrombackanim;
5747 if(skeleton.forward.y>-.3){
5748 targetanimation=getupfromfrontanim;
5750 targetrotation+=180;
5756 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5757 targetanimation=rollanim;
5758 targetrotation=lookrotation;
5762 if(forwardkeydown)targetrotation+=45;
5763 if(backkeydown)targetrotation-=45;
5767 if(forwardkeydown)targetrotation-=45;
5768 if(backkeydown)targetrotation+=45;
5771 if ( !leftkeydown&&!rightkeydown)
5772 targetrotation+=180;
5774 targetrotation+=180;
5778 if(abs(targettilt2)>50)targettilt2=0;
5779 currentanimation=tempanim;
5784 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5786 for(i=0;i<skeleton.num_joints;i++){
5787 tempanimation.position[i][0]=skeleton.joints[i].position;
5788 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5795 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5796 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5799 tempvelocity=velocity;
5800 Normalise(&tempvelocity);
5801 targetrotation=-asin(0-tempvelocity.x);
5802 targetrotation*=360/6.28;
5803 if(velocity.z<0)targetrotation=180-targetrotation;
5804 //targetrotation+=180;
5807 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5808 targetanimation=rollanim;
5812 targetanimation=backhandspringanim;
5813 targetrotation+=180;
5826 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
5827 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
5828 OPENAL_SetVolume(channels[movewhooshsound], 128);
5829 OPENAL_SetPaused(channels[movewhooshsound], false);
5831 currentanimation=targetanimation;
5832 currentframe=targetframe-1;
5837 rotation=targetrotation;
5844 if(skeleton.freefall==0)freefall=0;
5846 if(!isnormal(velocity.x)&&velocity.x){
5851 if(aitype!=passivetype||skeleton.free==1)
5852 if(findLengthfast(&velocity)>.1)
5853 for(i=0;i<objects.numobjects;i++){
5854 if(objects.type[i]==firetype)
5855 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){
5857 if(!objects.onfire[i]){
5860 gLoc[0]=objects.position[i].x;
5861 gLoc[1]=objects.position[i].y;
5862 gLoc[2]=objects.position[i].z;
5866 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5867 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5868 OPENAL_SetVolume(channels[firestartsound], 256);
5869 OPENAL_SetPaused(channels[firestartsound], false);
5871 objects.onfire[i]=1;
5874 if(objects.onfire[i]){
5879 if(objects.type[i]==bushtype)
5880 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){
5882 if(!objects.onfire[i]){
5885 gLoc[0]=objects.position[i].x;
5886 gLoc[1]=objects.position[i].y;
5887 gLoc[2]=objects.position[i].z;
5891 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5892 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5893 OPENAL_SetVolume(channels[firestartsound], 256);
5894 OPENAL_SetPaused(channels[firestartsound], false);
5896 objects.onfire[i]=1;
5900 if(objects.onfire[i]){
5904 if(objects.messedwith[i]<=0){
5916 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5917 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5918 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5919 OPENAL_SetPaused(channels[bushrustle], false);
5922 envsound[numenvsounds]=coords;
5923 envsoundvol[numenvsounds]=4*findLength(&velocity);
5924 envsoundlife[numenvsounds]=.4;
5929 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5930 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5932 if(environment!=desertenvironment)
5933 for(j=0;j<howmany;j++){
5934 tempvel.x=float(abs(Random()%100)-50)/20;
5935 tempvel.y=float(abs(Random()%100)-50)/20;
5936 tempvel.z=float(abs(Random()%100)-50)/20;
5939 pos.x+=float(abs(Random()%100)-50)/200;
5940 pos.y+=float(abs(Random()%100)-50)/200;
5941 pos.z+=float(abs(Random()%100)-50)/200;
5942 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);
5943 Sprite::setLastSpriteSpecial(1);
5945 howmany=findLength(&velocity)*4;
5947 if(environment==snowyenvironment)
5948 for(j=0;j<howmany;j++){
5949 tempvel.x=float(abs(Random()%100)-50)/20;
5950 tempvel.y=float(abs(Random()%100)-50)/20;
5951 tempvel.z=float(abs(Random()%100)-50)/20;
5954 pos.x+=float(abs(Random()%100)-50)/200;
5955 pos.y+=float(abs(Random()%100)-50)/200;
5956 pos.z+=float(abs(Random()%100)-50)/200;
5957 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5958 Sprite::setLastSpriteSpecial(2);
5961 objects.rotx[i]+=velocity.x*multiplier*6;
5962 objects.roty[i]+=velocity.z*multiplier*6;
5963 objects.messedwith[i]=.5;
5966 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
5967 if(objects.rotation2[i]==0)tempcoord=coords;
5969 tempcoord=coords-objects.position[i];
5970 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
5971 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
5972 tempcoord+=objects.position[i];
5974 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]){
5975 if(objects.messedwith[i]<=0){
5987 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5988 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5989 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5990 OPENAL_SetPaused(channels[bushrustle], false);
5993 envsound[numenvsounds]=coords;
5994 envsoundvol[numenvsounds]=4*findLength(&velocity);
5995 envsoundlife[numenvsounds]=.4;
6000 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6001 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6003 if(environment!=desertenvironment)
6004 for(j=0;j<howmany;j++){
6005 tempvel.x=float(abs(Random()%100)-50)/20;
6006 tempvel.y=float(abs(Random()%100)-50)/20;
6007 tempvel.z=float(abs(Random()%100)-50)/20;
6011 pos.x+=float(abs(Random()%100)-50)/150;
6012 pos.y+=float(abs(Random()%100)-50)/150;
6013 pos.z+=float(abs(Random()%100)-50)/150;
6014 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);
6015 Sprite::setLastSpriteSpecial(1);
6017 howmany=findLength(&velocity)*4;
6019 if(environment==snowyenvironment)
6020 for(j=0;j<howmany;j++){
6021 tempvel.x=float(abs(Random()%100)-50)/20;
6022 tempvel.y=float(abs(Random()%100)-50)/20;
6023 tempvel.z=float(abs(Random()%100)-50)/20;
6027 pos.x+=float(abs(Random()%100)-50)/150;
6028 pos.y+=float(abs(Random()%100)-50)/150;
6029 pos.z+=float(abs(Random()%100)-50)/150;
6030 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6031 Sprite::setLastSpriteSpecial(2);
6034 objects.messedwith[i]=.5;
6042 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
6044 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
6045 if(tutoriallevel==1&&id!=0)play=0;
6046 if(play&&aitype!=playercontrolled){
6058 if(creature==rabbittype){
6059 if(i==0)whichsound=rabbitchitter;
6060 if(i==1)whichsound=rabbitchitter2;
6062 if(creature==wolftype){
6063 if(i==0)whichsound=growlsound;
6064 if(i==1)whichsound=growl2sound;
6070 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
6071 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
6072 OPENAL_SetVolume(channels[whichsound], 512);
6073 OPENAL_SetPaused(channels[whichsound], false);
6077 if(targetanimation==staggerbackhighanim)staggerdelay=1;
6078 if(targetanimation==staggerbackhardanim)staggerdelay=1;
6079 staggerdelay-=multiplier;
6080 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
6081 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
6082 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
6083 targetanimation=getIdle();
6087 weaponmissdelay-=multiplier;
6088 highreversaldelay-=multiplier;
6089 lowreversaldelay-=multiplier;
6090 lastcollide-=multiplier;
6091 skiddelay-=multiplier;
6092 if(!isnormal(velocity.x)&&velocity.x){
6095 if(!isnormal(targettilt)&&targettilt){
6098 if(!isnormal(targettilt2)&&targettilt2){
6101 if(!isnormal(targetrotation)&&targetrotation){
6105 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
6106 //open hands and close mouth
6107 //if(targetanimation!=wolfidle){
6108 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6109 righthandmorphness=0;
6110 righthandmorphend=0;
6111 targetrighthandmorphness=1;
6114 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6115 lefthandmorphness=0;
6117 targetlefthandmorphness=1;
6121 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
6124 targetheadmorphness=1;
6128 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){
6129 //open hands and mouth
6130 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6131 righthandmorphness=0;
6132 righthandmorphend=0;
6133 targetrighthandmorphness=1;
6136 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6137 lefthandmorphness=0;
6139 targetlefthandmorphness=1;
6142 if(headmorphend!=1&&headmorphness==targetheadmorphness){
6145 targetheadmorphness=1;
6149 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
6150 //close hands and mouth
6151 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6152 righthandmorphness=0;
6153 righthandmorphend=1;
6154 targetrighthandmorphness=1;
6157 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6158 lefthandmorphness=0;
6160 targetlefthandmorphness=1;
6163 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6166 targetheadmorphness=1;
6170 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){
6171 //close hands and yell
6172 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6173 righthandmorphness=0;
6174 righthandmorphend=1;
6175 targetrighthandmorphness=1;
6178 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6179 lefthandmorphness=0;
6181 targetlefthandmorphness=1;
6184 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6187 targetheadmorphness=1;
6191 if(speechdelay>.25){
6192 if(headmorphend!=2)headmorphness=0;
6194 targetheadmorphness=1;
6200 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6201 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6205 if(!dead&&targetanimation!=hurtidleanim)
6206 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6207 if(headmorphend!=4||headmorphness==targetheadmorphness){
6210 targetheadmorphness=1;
6214 if(weaponactive!=-1){
6215 if(weapons.type[weaponids[weaponactive]]!=staff){
6216 righthandmorphstart=1;
6217 righthandmorphend=1;
6219 if(weapons.type[weaponids[weaponactive]]==staff){
6220 righthandmorphstart=2;
6221 righthandmorphend=2;
6223 targetrighthandmorphness=1;
6226 terrainnormal=terrain.getNormal(coords.x,coords.z);
6228 if(animation[targetanimation].attack!=reversal){
6229 if(!isnormal(coords.x))
6237 flatfacing=DoRotation(flatfacing,0,rotation,0);
6239 ReflectVector(&facing,terrainnormal);
6242 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6243 if(onterrain)targettilt2=-facing.y*20;
6247 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6248 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6249 flatvelocity=velocity;
6251 flatvelspeed=findLength(&flatvelocity);
6252 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6253 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6254 if(velocity.y<0)targettilt2*=-1;
6255 if(velocity.y<0)targettilt*=-1;
6256 if(targettilt>25)targettilt=25;
6257 if(targettilt<-25)targettilt=-25;
6260 if(targettilt2>45)targettilt2=45;
6261 if(targettilt2<-45)targettilt2=-45;
6262 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6263 else if(tilt2>targettilt2){
6264 tilt2-=multiplier*400;
6266 else if(tilt2<targettilt2){
6267 tilt2+=multiplier*400;
6269 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6270 if(tilt2>25)tilt2=25;
6271 if(tilt2<-25)tilt2=-25;
6274 if(!isnormal(targettilt)&&targettilt){
6277 if(!isnormal(targettilt2)&&targettilt2){
6282 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6283 if(targetanimation==rabbittackleanim){
6284 velocity+=facing*multiplier*speed*700*scale;
6285 velspeed=findLength(&velocity);
6286 if(velspeed>speed*65*scale){
6288 velspeed=speed*65*scale;
6291 velocity.y+=gravity*multiplier*20;
6292 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6293 velspeed=findLength(&velocity);
6294 velocity=flatfacing*velspeed;
6296 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6297 if(isRun()||targetanimation==rabbitkickanim){
6298 velocity+=facing*multiplier*speed*700*scale;
6299 velspeed=findLength(&velocity);
6300 if(velspeed>speed*45*scale){
6302 velspeed=speed*45*scale;
6305 velocity.y+=gravity*multiplier*20;
6306 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6307 velspeed=findLength(&velocity);
6308 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6309 velocity=flatfacing*velspeed;
6313 velocity+=facing*multiplier*speed*700*scale;
6314 velspeed=findLength(&velocity);
6315 if(creature==rabbittype){
6316 if(velspeed>speed*55*scale){
6318 velspeed=speed*55*scale;
6322 if(creature==wolftype){
6323 if(velspeed>speed*75*scale){
6325 velspeed=speed*75*scale;
6329 velocity.y+=gravity*multiplier*20;
6330 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6331 velspeed=findLength(&velocity);
6332 velocity=flatfacing*velspeed;
6335 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6336 velocity+=facing*multiplier*speed*700*scale;
6337 velspeed=findLength(&velocity);
6338 if(velspeed>speed*45*scale){
6340 velspeed=speed*45*scale;
6343 velocity.y+=gravity*multiplier*20;
6344 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6345 velspeed=findLength(&velocity);
6346 velocity=flatfacing*velspeed;
6350 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6351 velocity+=facing*multiplier*speed*700*scale;
6352 velspeed=findLength(&velocity);
6353 if(velspeed>speed*25*scale){
6355 velspeed=speed*25*scale;
6358 velocity.y+=gravity*multiplier*20;
6359 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6360 velspeed=findLength(&velocity);
6361 velocity=flatfacing*velspeed;
6364 if(targetanimation==sneakanim||targetanimation==walkanim){
6365 velocity+=facing*multiplier*speed*700*scale;
6366 velspeed=findLength(&velocity);
6367 if(velspeed>speed*12*scale){
6369 velspeed=speed*12*scale;
6372 velocity.y+=gravity*multiplier*20;
6373 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6374 velspeed=findLength(&velocity);
6375 velocity=flatfacing*velspeed;
6378 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6379 velocity+=facing*multiplier*speed*700*scale;
6380 velspeed=findLength(&velocity);
6381 if(velspeed>speed*2*scale){
6383 velspeed=speed*2*scale;
6386 velocity.y+=gravity*multiplier*20;
6387 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6388 velspeed=findLength(&velocity);
6389 velocity=flatfacing*velspeed;
6393 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6394 velocity-=facing*multiplier*speed*700*scale;
6395 velspeed=findLength(&velocity);
6396 if(velspeed>speed*2*scale){
6398 velspeed=speed*2*scale;
6401 velocity.y+=gravity*multiplier*20;
6402 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6403 velspeed=findLength(&velocity);
6404 velocity=flatfacing*velspeed*-1;
6407 if(targetanimation==fightsidestep){
6408 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6409 velspeed=findLength(&velocity);
6410 if(velspeed>speed*12*scale){
6412 velspeed=speed*12*scale;
6415 velocity.y+=gravity*multiplier*20;
6416 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6417 velspeed=findLength(&velocity);
6418 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6421 if(targetanimation==staggerbackhighanim){
6422 coords-=facing*multiplier*speed*16*scale;
6425 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6426 coords-=facing*multiplier*speed*20*scale;
6430 if(targetanimation==backhandspringanim){
6431 //coords-=facing*multiplier*50*scale;
6432 velocity+=facing*multiplier*speed*700*scale*-1;
6433 velspeed=findLength(&velocity);
6434 if(velspeed>speed*50*scale){
6436 velspeed=speed*50*scale;
6439 velocity.y+=gravity*multiplier*20;
6440 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6441 velspeed=findLength(&velocity);
6442 velocity=flatfacing*velspeed*-1;
6444 if(targetanimation==dodgebackanim){
6445 //coords-=facing*multiplier*50*scale;
6446 velocity+=facing*multiplier*speed*700*scale*-1;
6447 velspeed=findLength(&velocity);
6448 if(velspeed>speed*60*scale){
6450 velspeed=speed*60*scale;
6453 velocity.y+=gravity*multiplier*20;
6454 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6455 velspeed=findLength(&velocity);
6456 velocity=flatfacing*velspeed*-1;
6459 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6460 velspeed=findLength(&velocity);
6464 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6465 velocity.y+=gravity*multiplier;
6468 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6470 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6471 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6473 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6479 OPENAL_SetPaused(channels[whooshsound], true);
6480 OPENAL_SetVolume(channels[whooshsound], 0);
6483 if(targetanimation==jumpdownanim||isFlip()){
6484 if(isFlip())jumppower=-4;
6485 targetanimation=getLanding();
6494 PlaySoundEx( landsound, samp[landsound], NULL, true);
6495 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6496 OPENAL_SetVolume(channels[landsound], 128);
6497 OPENAL_SetPaused(channels[landsound], false);
6500 envsound[numenvsounds]=coords;
6501 envsoundvol[numenvsounds]=16;
6502 envsoundlife[numenvsounds]=.4;
6508 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6509 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6510 coords.y=terrain.getHeight(coords.x,coords.z);
6515 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)){
6516 velspeed=findLength(&velocity);
6518 if(velspeed<multiplier*300*scale){
6520 } else velocity-=velocity/velspeed*multiplier*300*scale;
6521 if(velspeed>5&&(isLanding()||isLandhard())){
6522 skiddingdelay+=multiplier;
6529 else skiddingdelay=0;
6533 velspeed=findLength(&velocity);
6535 if(velspeed<multiplier*600*scale){
6537 } else velocity-=velocity/velspeed*multiplier*600*scale;
6539 if(velspeed>5&&(isLanding()||isLandhard())){
6540 skiddingdelay+=multiplier;
6547 else skiddingdelay=0;
6550 if(skiddingdelay<0)skiddingdelay+=multiplier;
6551 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6561 if(!onterrain||environment==grassyenvironment){
6562 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6563 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6564 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6565 OPENAL_SetPaused(channels[skidsound], false);
6568 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6569 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6570 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6571 OPENAL_SetPaused(channels[snowskidsound], false);
6575 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6576 terrainnormal=victim->coords-coords;
6577 Normalise(&terrainnormal);
6578 targetrotation=-asin(0-terrainnormal.x);
6579 targetrotation*=360/6.28;
6580 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6581 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6584 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6585 targetrotation=victim->targetrotation;
6587 if(targetanimation==rabbittacklinganim){
6588 coords=victim->coords;
6591 skeleton.oldfree=skeleton.free;
6595 midterrain.x=terrain.size*terrain.scale/2;
6596 midterrain.z=terrain.size*terrain.scale/2;
6597 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6599 tempposit=coords-midterrain;
6601 Normalise(&tempposit);
6602 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6603 coords.x=tempposit.x+midterrain.x;
6604 coords.z=tempposit.z+midterrain.z;
6608 int Person::DrawSkeleton(){
6609 int oldplayerdetail;
6610 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6611 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6621 glAlphaFunc(GL_GREATER, 0.0001);
6623 float terrainheight;
6625 if(!isnormal(rotation))rotation=0;
6626 if(!isnormal(tilt))tilt=0;
6627 if(!isnormal(tilt2))tilt2=0;
6628 oldplayerdetail=playerdetail;
6630 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6633 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6636 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6641 if(playerdetail!=oldplayerdetail) {
6643 normalsupdatedelay=0;
6645 static float updatedelaychange;
6646 static float morphness;
6647 static float framemult;
6649 skeleton.FindForwards();
6650 if(howactive==typesittingwall){
6651 skeleton.specialforward[1]=0;
6652 skeleton.specialforward[1].z=1;
6658 static int weaponattachmuscle;
6659 static int weaponrotatemuscle,weaponrotatemuscle2;
6660 static XYZ weaponpoint;
6661 static int start,endthing;
6662 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6663 if(!isSleeping()&&!isSitting()){
6664 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6665 XYZ point,newpoint,change,change2;
6666 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6667 heightleft=terrain.getHeight(point.x,point.z)+.04;
6669 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6670 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6671 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6672 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6673 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6675 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6676 heightright=terrain.getHeight(point.x,point.z)+.04;
6677 point.y=heightright;
6678 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6679 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6680 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6681 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6682 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6683 skeleton.DoConstraints(&coords,&scale);
6685 if(creature==wolftype){
6686 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6687 heightleft=terrain.getHeight(point.x,point.z)+.04;
6689 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6690 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6691 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6692 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6693 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6695 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6696 heightright=terrain.getHeight(point.x,point.z)+.04;
6697 point.y=heightright;
6698 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6699 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6700 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6701 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6702 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6703 skeleton.DoConstraints(&coords,&scale);
6706 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6707 XYZ point,newpoint,change,change2;
6708 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6709 heightleft=terrain.getHeight(point.x,point.z)+.04;
6711 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6712 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6713 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6714 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6715 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6717 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6718 heightright=terrain.getHeight(point.x,point.z)+.04;
6719 point.y=heightright;
6720 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6721 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6722 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6723 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6724 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6725 skeleton.DoConstraints(&coords,&scale);
6727 if(creature==wolftype){
6728 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6729 heightleft=terrain.getHeight(point.x,point.z)+.04;
6731 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6732 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6733 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6734 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6735 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6737 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6738 heightright=terrain.getHeight(point.x,point.z)+.04;
6739 point.y=heightright;
6740 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6741 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6742 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6743 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6744 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6745 skeleton.DoConstraints(&coords,&scale);
6749 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6750 XYZ point,newpoint,change,change2;
6751 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6752 heightleft=terrain.getHeight(point.x,point.z)+.04;
6754 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6755 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6756 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6757 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6758 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6760 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6761 heightright=terrain.getHeight(point.x,point.z)+.04;
6762 point.y=heightright;
6763 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6764 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6765 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6766 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6767 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6768 skeleton.DoConstraints(&coords,&scale);
6770 if(creature==wolftype){
6771 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6772 heightleft=terrain.getHeight(point.x,point.z)+.04;
6774 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6775 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6776 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6777 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6778 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6780 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6781 heightright=terrain.getHeight(point.x,point.z)+.04;
6782 point.y=heightright;
6783 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6784 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6785 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6786 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6787 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6788 skeleton.DoConstraints(&coords,&scale);
6792 if(!skeleton.free&&(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&((targetanimation!=rollanim&&!isFlip())||animation[targetanimation].label[targetframe]==6)&&targetanimation!=getupfromfrontanim&&targetanimation!=wolfrunninganim&&targetanimation!=rabbitrunninganim&&targetanimation!=backhandspringanim&&targetanimation!=walljumpfrontanim&&targetanimation!=hurtidleanim&&!isLandhard()&&!isSleeping()))
6795 targetheadrotation=-targetrotation;
6796 targetheadrotation2=0;
6797 if(animation[targetanimation].attack==3)targetheadrotation+=180;
6799 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6800 skeleton.drawmodel.vertex[i]=0;
6801 skeleton.drawmodel.vertex[i].y=999;
6803 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
6804 skeleton.drawmodellow.vertex[i]=0;
6805 skeleton.drawmodellow.vertex[i].y=999;
6807 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
6808 skeleton.drawmodelclothes.vertex[i]=0;
6809 skeleton.drawmodelclothes.vertex[i].y=999;
6811 for(i=0;i<skeleton.num_muscles;i++){
6812 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
6816 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
6817 morphness=righthandmorphness;
6818 start=righthandmorphstart;
6819 endthing=righthandmorphend;
6821 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
6822 morphness=lefthandmorphness;
6823 start=lefthandmorphstart;
6824 endthing=lefthandmorphend;
6826 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
6827 morphness=headmorphness;
6828 start=headmorphstart;
6829 endthing=headmorphend;
6831 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)){
6832 morphness=chestmorphness;
6833 start=chestmorphstart;
6834 endthing=chestmorphend;
6836 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)){
6837 morphness=tailmorphness;
6838 start=tailmorphstart;
6839 endthing=tailmorphend;
6841 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
6842 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6843 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6846 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6847 if(!skeleton.free)glRotatef(tilt,0,0,1);
6850 glTranslatef(mid.x,mid.y,mid.z);
6852 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6853 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6855 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6856 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6858 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6859 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6861 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
6865 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
6869 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
6873 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
6878 if(playerdetail||skeleton.free==3)
6880 for(j=0;j<skeleton.muscles[i].numvertices;j++)
6882 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
6883 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
6884 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
6885 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
6886 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
6887 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
6888 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
6889 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6891 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6892 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,
6893 (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,
6894 (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);
6895 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)
6896 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,
6897 (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,
6898 (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);
6899 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)
6900 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,
6901 (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,
6902 (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);
6903 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6904 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,
6905 (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,
6906 (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);
6907 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6908 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
6909 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
6910 //if(!isnormal(scale))test=1;
6911 //if(isnormal(scale)){
6912 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
6913 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
6914 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
6922 if(!playerdetail||skeleton.free==3)
6924 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
6926 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
6927 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6929 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6930 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
6931 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
6932 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
6933 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)
6934 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
6935 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
6936 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
6937 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)
6938 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
6939 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
6940 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
6941 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6942 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
6943 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
6944 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
6946 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6947 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
6948 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
6949 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
6956 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
6957 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6959 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6962 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6963 if(!skeleton.free)glRotatef(tilt,0,0,1);
6964 glTranslatef(mid.x,mid.y,mid.z);
6965 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6966 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6968 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6969 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6971 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6972 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6974 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
6975 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6977 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6978 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
6979 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
6980 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
6981 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)
6982 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
6983 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
6984 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
6985 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)
6986 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
6987 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
6988 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
6989 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6990 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
6991 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
6992 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
6993 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6994 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
6995 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
6996 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
7001 updatedelay=1+(float)(Random()%100)/1000;
7003 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
7004 normalsupdatedelay=1;
7005 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
7006 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
7007 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
7011 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
7012 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
7013 if(skeleton.clothes){
7014 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
7019 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
7020 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
7021 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
7022 if(skeleton.free==1)updatedelaychange*=6;
7023 if(id==0)updatedelaychange*=8;
7024 updatedelay+=updatedelaychange;
7026 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7028 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7029 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7030 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
7031 if(!skeleton.free)glRotatef(rotation,0,1,0);
7034 glColor4f(.4,1,.4,1);
7035 glDisable(GL_LIGHTING);
7036 glDisable(GL_TEXTURE_2D);
7039 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7040 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
7046 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
7047 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);
7048 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);
7049 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);
7050 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);
7051 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);
7052 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);
7058 terrainlight=terrain.getLighting(coords.x,coords.z);
7059 distance=findDistancefast(&viewer,&coords);
7060 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
7061 if(distance>1)distance=1;
7063 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
7064 if(terrainheight<1)terrainheight=1;
7065 if(terrainheight>1.7)terrainheight=1.7;
7068 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
7069 glDisable(GL_BLEND);
7070 glAlphaFunc(GL_GREATER, 0.0001);
7071 glEnable(GL_TEXTURE_2D);
7073 glDisable(GL_TEXTURE_2D);
7074 glColor4f(.7,.35,0,.5);
7076 glEnable(GL_LIGHTING);
7079 if(tutoriallevel&&id!=0){
7080 //glDisable(GL_TEXTURE_2D);
7081 glColor4f(.7,.7,.7,0.6);
7083 glEnable(GL_LIGHTING);
7085 if(canattack&&cananger)
7086 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7087 glDisable(GL_TEXTURE_2D);
7088 glColor4f(1,0,0,0.8);
7090 glMatrixMode(GL_TEXTURE);
7092 glTranslatef(0,-smoketex,0);
7093 glTranslatef(-smoketex,0,0);
7097 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7098 else skeleton.drawmodel.draw();
7102 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7103 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7106 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
7107 if(tutoriallevel&&id!=0){
7109 glMatrixMode(GL_MODELVIEW);
7110 glEnable(GL_TEXTURE_2D);
7111 glColor4f(.7,.7,.7,0.6);
7113 glEnable(GL_LIGHTING);
7115 if(canattack&&cananger)
7116 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7117 glDisable(GL_TEXTURE_2D);
7118 glColor4f(1,0,0,0.8);
7120 glMatrixMode(GL_TEXTURE);
7122 glTranslatef(0,-smoketex*.6,0);
7123 glTranslatef(smoketex*.6,0,0);
7126 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7127 else skeleton.drawmodel.draw();
7131 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7132 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7137 if(tutoriallevel&&id!=0){
7139 glMatrixMode(GL_MODELVIEW);
7140 glEnable(GL_TEXTURE_2D);
7142 if(skeleton.clothes){
7145 if(!immediate)skeleton.drawmodelclothes.draw();
7146 if(immediate)skeleton.drawmodelclothes.drawimmediate();
7153 for(k=0;k<num_weapons;k++){
7155 if(weaponactive==k){
7156 if(weapons.type[i]!=staff){
7157 for(j=0;j<skeleton.num_muscles;j++){
7158 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7159 weaponattachmuscle=j;
7162 for(j=0;j<skeleton.num_muscles;j++){
7163 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){
7164 weaponrotatemuscle=j;
7167 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7168 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7170 if(weapons.type[i]==staff){
7171 for(j=0;j<skeleton.num_muscles;j++){
7172 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7173 weaponattachmuscle=j;
7176 for(j=0;j<skeleton.num_muscles;j++){
7177 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){
7178 weaponrotatemuscle=j;
7181 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7182 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7183 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7184 XYZ tempnormthing,vec1,vec2;
7185 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7186 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7187 CrossProduct(&vec1,&vec2,&tempnormthing);
7188 Normalise(&tempnormthing);
7189 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);
7190 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7192 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7193 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7194 Normalise(&weaptargnorm);
7195 weaponpoint-=weaptargnorm*2;
7199 if(weaponactive!=k&&weaponstuck!=k){
7200 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;
7201 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;
7202 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;
7203 for(j=0;j<skeleton.num_muscles;j++){
7204 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){
7205 weaponrotatemuscle=j;
7210 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7211 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7212 for(j=0;j<skeleton.num_muscles;j++){
7213 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){
7214 weaponrotatemuscle=j;
7219 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;
7220 weapons.bigrotation[i]=rotation;
7221 weapons.bigtilt[i]=tilt;
7222 weapons.bigtilt2[i]=tilt2;
7225 weapons.position[i]=weaponpoint*scale+coords;
7226 weapons.bigrotation[i]=0;
7227 weapons.bigtilt[i]=0;
7228 weapons.bigtilt2[i]=0;
7230 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7231 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7232 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7233 if(weaponactive==k){
7234 if(weapons.type[i]==knife){
7235 weapons.smallrotation[i]=180;
7236 weapons.smallrotation2[i]=0;
7237 if(isCrouch()||wasCrouch()){
7238 weapons.smallrotation2[i]=20;
7240 if(targetanimation==hurtidleanim){
7241 weapons.smallrotation2[i]=50;
7243 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7244 XYZ temppoint1,temppoint2,tempforward;
7247 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7248 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7249 distance=findDistance(&temppoint1,&temppoint2);
7250 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7251 weapons.rotation2[i]*=360/6.28;
7254 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7255 weapons.rotation1[i]*=360/6.28;
7256 weapons.rotation3[i]=0;
7257 weapons.smallrotation[i]=-90;
7258 weapons.smallrotation2[i]=0;
7259 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7261 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7262 XYZ temppoint1,temppoint2,tempforward;
7265 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7266 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7267 distance=findDistance(&temppoint1,&temppoint2);
7268 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7269 weapons.rotation2[i]*=360/6.28;
7272 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7273 weapons.rotation1[i]*=360/6.28;
7274 weapons.rotation3[i]=0;
7275 weapons.smallrotation[i]=90;
7276 weapons.smallrotation2[i]=0;
7277 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7279 if(targetanimation==knifethrowanim){
7280 weapons.smallrotation[i]=90;
7281 //weapons.smallrotation2[i]=-90;
7282 weapons.smallrotation2[i]=0;
7283 weapons.rotation1[i]=0;
7284 weapons.rotation2[i]=0;
7285 weapons.rotation3[i]=0;
7287 if(targetanimation==knifesneakattackanim&&targetframe<5){
7288 weapons.smallrotation[i]=-90;
7289 weapons.rotation1[i]=0;
7290 weapons.rotation2[i]=0;
7291 weapons.rotation3[i]=0;
7294 if(weapons.type[i]==sword){
7295 weapons.smallrotation[i]=0;
7296 weapons.smallrotation2[i]=0;
7297 if(targetanimation==knifethrowanim){
7298 weapons.smallrotation[i]=-90;
7299 weapons.smallrotation2[i]=0;
7300 weapons.rotation1[i]=0;
7301 weapons.rotation2[i]=0;
7302 weapons.rotation3[i]=0;
7304 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)){
7305 XYZ temppoint1,temppoint2,tempforward;
7308 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7309 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7310 distance=findDistance(&temppoint1,&temppoint2);
7311 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7312 weapons.rotation2[i]*=360/6.28;
7315 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7316 weapons.rotation1[i]*=360/6.28;
7317 weapons.rotation3[i]=0;
7318 weapons.smallrotation[i]=90;
7319 weapons.smallrotation2[i]=0;
7320 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7323 if(weapons.type[i]==staff){
7324 weapons.smallrotation[i]=100;
7325 weapons.smallrotation2[i]=0;
7326 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7327 XYZ temppoint1,temppoint2,tempforward;
7330 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7331 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7332 distance=findDistance(&temppoint1,&temppoint2);
7333 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7334 weapons.rotation2[i]*=360/6.28;
7337 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7338 weapons.rotation1[i]*=360/6.28;
7339 weapons.rotation3[i]=0;
7340 weapons.smallrotation[i]=90;
7341 weapons.smallrotation2[i]=0;
7342 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7346 if(weaponactive!=k&&weaponstuck!=k){
7347 if(weapons.type[i]==knife){
7348 weapons.smallrotation[i]=-70;
7349 weapons.smallrotation2[i]=10;
7351 if(weapons.type[i]==sword){
7352 weapons.smallrotation[i]=-100;
7353 weapons.smallrotation2[i]=-8;
7355 if(weapons.type[i]==staff){
7356 weapons.smallrotation[i]=-100;
7357 weapons.smallrotation2[i]=-8;
7361 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7362 else weapons.smallrotation[i]=0;
7363 weapons.smallrotation2[i]=10;
7364 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7372 if(skeleton.free)calcrot=1;
7373 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7374 if(currentanimation!=targetanimation)calcrot=1;
7375 //if(id==0)calcrot=1;
7376 if(skeleton.free==2)calcrot=0;
7382 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7385 static float distance;
7386 static float olddistance;
7387 static int intersecting;
7388 static int firstintersecting;
7391 static XYZ start,end;
7392 static float slopethreshold=-.4;
7394 firstintersecting=-1;
7398 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7399 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7401 for (j=0;j<model->TriangleNum;j++){
7402 if(model->facenormals[j].y<=slopethreshold){
7404 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)));
7405 if(distance<radius){
7406 point=*p1-model->facenormals[j]*distance;
7407 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;
7408 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7409 &model->vertex[model->Triangles[j].vertex[1]],
7411 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7412 &model->vertex[model->Triangles[j].vertex[2]],
7414 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7415 &model->vertex[model->Triangles[j].vertex[2]],
7418 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7422 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)){
7423 p1->y=point.y+radius;
7424 if((targetanimation==jumpdownanim||isFlip())){
7425 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7427 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7433 OPENAL_SetPaused(channels[whooshsound], true);
7434 OPENAL_SetVolume(channels[whooshsound], 0);
7437 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7438 if(isFlip())jumppower=-4;
7439 targetanimation=getLanding();
7448 PlaySoundEx( landsound, samp[landsound], NULL, true);
7449 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7450 OPENAL_SetVolume(channels[landsound], 128);
7451 OPENAL_SetPaused(channels[landsound], false);
7454 envsound[numenvsounds]=coords;
7455 envsoundvol[numenvsounds]=16;
7456 envsoundlife[numenvsounds]=.4;
7464 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7467 for (j=0;j<model->TriangleNum;j++){
7468 if(model->facenormals[j].y>slopethreshold){
7472 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)));
7473 if(distance<radius*.5){
7474 point=start-model->facenormals[j]*distance;
7475 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;
7476 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,
7477 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7478 p1->x, p1->y, p1->z, radius/2);
7479 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,
7480 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7481 p1->x, p1->y, p1->z, radius/2);
7482 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,
7483 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7484 p1->x, p1->y, p1->z, radius/2);
7486 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7487 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7489 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7490 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7492 *p1+=model->facenormals[j]*(distance-radius*.5);
7495 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7499 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7501 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7503 return firstintersecting;
7513 currentanimation = 0;
7514 targetanimation = 0;
7515 oldcurrentframe = 0;
7517 oldcurrentanimation = 0;
7518 oldtargetanimation = 0;
7522 parriedrecently = 0;
7526 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7528 currentoffset = 0,targetoffset = 0,offset = 0;
7546 unconscioustime = 0;
7564 rabbitkickenabled = 0;
7573 damagetolerance = 0;
7575 permanentdamage = 0;
7576 superpermanentdamage = 0; lastcollide = 0;
7596 headrotation = 0,headrotation2 = 0;
7597 targetheadrotation = 0,targetheadrotation2 = 0;
7608 normalsupdatedelay = 0;
7613 forwardstogglekeydown = 0;
7618 jumptogglekeydown = 0;
7620 crouchtogglekeydown = 0;
7622 drawtogglekeydown = 0;
7624 throwtogglekeydown = 0;
7630 crouchkeydowntime = 0;
7631 jumpkeydowntime = 0;
7648 whichdirectiondelay = 0;
7649 avoidsomething = 0; avoidwhere = 0;
7657 lefthandmorphness = 0;
7658 righthandmorphness = 0;
7662 targetlefthandmorphness = 0;
7663 targetrighthandmorphness = 0;
7664 targetheadmorphness = 0;
7665 targetchestmorphness = 0;
7666 targettailmorphness = 0;
7667 lefthandmorphstart = 0,lefthandmorphend = 0;
7668 righthandmorphstart = 0,righthandmorphend = 0;
7669 headmorphstart = 0,headmorphend = 0;
7670 chestmorphstart = 0,chestmorphend = 0;
7671 tailmorphstart = 0,tailmorphend = 0;
7673 weaponmissdelay = 0;
7674 highreversaldelay = 0;
7675 lowreversaldelay = 0;
7682 //Skeleton skeleton;
7701 memset(clothes, 0, sizeof(clothes));
7702 memset(clothestintr, 0, sizeof(clothestintr));
7703 memset(clothestintg, 0, sizeof(clothestintg));
7704 memset(clothestintb, 0, sizeof(clothestintb));
7710 onfiredelay = 0; burnt = 0;
7714 updatestuffdelay = 0;
7720 memset(weaponids, 0, sizeof(weaponids));
7724 weaponstuckwhere = 0;
7729 memset(waypoints, 0, sizeof(waypoints));
7730 memset(waypointtype, 0, sizeof(waypointtype));
7733 hastempwaypoint = 0;
7739 finalfinaltarget = 0;
7741 finalpathfindpoint = 0;
7742 targetpathfindpoint = 0;
7743 lastpathfindpoint = 0;
7744 lastpathfindpoint2 = 0;
7745 lastpathfindpoint3 = 0;
7746 lastpathfindpoint4 = 0;
7757 runninghowlong = 0; lastoccluded = 0;
7763 neckspurtparticledelay = 0;
7764 neckspurtamount = 0;
7767 rabbitkickragdoll = 0;
7772 //Animation tempanimation;