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"
30 extern float multiplier;
31 extern int channels[100];
32 extern Terrain terrain;
34 extern int environment;
36 extern FRUSTUM frustum;
38 extern float realmultiplier;
40 extern float slomodelay;
41 extern bool cellophane;
42 extern float texdetail;
43 extern float realtexdetail;
44 extern GLubyte bloodText[512*512*3];
45 extern GLubyte wolfbloodText[512*512*3];
46 extern int bloodtoggle;
47 extern Objects objects;
49 extern bool autoslomo;
50 extern float camerashake;
52 extern float terraindetail;
53 extern float viewdistance;
54 extern float blackout;
55 extern int difficulty;
57 extern float fadestart;
59 extern bool winfreeze;
60 extern float flashamount,flashr,flashg,flashb;
61 extern int flashdelay;
62 extern bool showpoints;
63 extern bool immediate;
65 extern bool tilt2weird;
66 extern bool tiltweird;
68 extern bool proportionweird;
69 extern bool vertexweird[6];
70 extern GLubyte texturearray[512*512*3];
71 extern XYZ envsound[30];
72 extern float envsoundvol[30];
73 extern float envsoundlife[30];
74 extern int numenvsounds;
76 extern float bonusvalue;
77 extern float bonustotal;
78 extern float bonustime;
79 extern int tutoriallevel;
80 extern float smoketex;
81 extern int tutorialstage;
82 extern bool reversaltrain;
83 extern bool canattack;
85 extern float damagedealt;
86 extern float damagetaken;
88 extern float hostiletime;
91 extern int numflipfail;
93 extern int numswordattack;
94 extern int numknifeattack;
95 extern int numunarmedattack;
96 extern int numescaped;
97 extern int numflipped;
98 extern int numwallflipped;
99 extern int numthrowkill;
100 extern int numafterkill;
101 extern int numreversals;
102 extern int numattacks;
103 extern int maxalarmed;
104 extern int indialogue;
106 extern bool gamestarted;
108 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
109 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
111 void Person::CheckKick(){
115 float damagemult=1*power;
116 if(creature==wolftype)damagemult=2.5*power;
120 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
121 if(findDistancefast(&coords,&victim->coords)<1.2){
122 if(!victim->skeleton.free){
124 Normalise(&relative);
125 relative=coords+relative*1;
126 if(animation[victim->targetanimation].height!=lowheight){
131 gLoc[0]=victim->coords.x;
132 gLoc[1]=victim->coords.y;
133 gLoc[2]=victim->coords.z;
137 if(tutoriallevel!=1){
138 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
139 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
140 OPENAL_SetVolume(channels[heavyimpactsound], 128);
141 OPENAL_SetPaused(channels[heavyimpactsound], false);
146 Normalise(&relative);
147 for(i=0;i<victim->skeleton.num_joints;i++){
148 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
151 victim->DoDamage(100*damagemult/victim->protectionhigh);
152 if(id==0)camerashake+=.4;
156 targetanimation=backflipanim;
161 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
163 //if(victim->damage>victim->damagetolerance){
171 else if (victim->isCrouch()){
172 targetanimation=rabbitkickreversedanim;
173 currentanimation=rabbitkickreversedanim;
174 victim->currentanimation=rabbitkickreversalanim;
175 victim->targetanimation=rabbitkickreversalanim;
181 victim->oldcoords=victim->coords;
182 coords=victim->coords;
183 victim->targetrotation=targetrotation;
191 void Person::CatchFire(){
192 XYZ flatfacing,flatvelocity;
194 for(int i=0;i<10;i++){
195 howmany=abs(Random()%(skeleton.num_joints));
196 if(!skeleton.free)flatvelocity=velocity;
197 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
198 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
199 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
200 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
213 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
214 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
215 OPENAL_SetVolume(channels[firestartsound], 256);
216 OPENAL_SetPaused(channels[firestartsound], false);
221 //PlaySoundEx( firesound, samp[firesound], NULL, true);
222 PlayStreamEx( stream_firesound, samp[stream_firesound], NULL, true);
223 OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
224 OPENAL_SetVolume(channels[stream_firesound], 256);
225 OPENAL_SetPaused(channels[stream_firesound], false);
232 bool Person::isIdle(){
233 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;
237 bool Person::isSitting(){
238 if(targetanimation==sitanim)return 1;
239 if(targetanimation==sitwallanim)return 1;
243 bool Person::isSleeping(){
244 if(targetanimation==sleepanim)return 1;
245 if(targetanimation==dead1anim)return 1;
246 if(targetanimation==dead2anim)return 1;
247 if(targetanimation==dead3anim)return 1;
248 if(targetanimation==dead4anim)return 1;
252 bool Person::wasIdle(){
253 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;
256 int Person::getIdle(){
257 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
258 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)){
259 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
260 if(creature==rabbittype)return fightidleanim;
261 if(creature==wolftype)return wolfidle;
263 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
264 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
265 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
266 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
267 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
269 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
271 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
272 if(howactive==typesitting)return sitanim;
273 if(howactive==typesittingwall)return sitwallanim;
274 if(howactive==typesleeping)return sleepanim;
275 if(howactive==typedead1)return dead1anim;
276 if(howactive==typedead2)return dead2anim;
277 if(howactive==typedead3)return dead3anim;
278 if(howactive==typedead4)return dead4anim;
279 if(creature==rabbittype)return bounceidleanim;
280 if(creature==wolftype)return wolfidle;
284 bool Person::isCrouch(){
285 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
290 bool Person::wasCrouch(){
291 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
294 int Person::getCrouch(){
295 if(creature==rabbittype)return crouchanim;
296 if(creature==wolftype)return wolfcrouchanim;
300 bool Person::isRun(){
301 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
306 bool Person::wasRun(){
307 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
310 int Person::getRun(){
311 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
312 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
314 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
315 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
319 bool Person::isStop(){
320 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
325 bool Person::wasStop(){
326 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
329 int Person::getStop(){
330 if(creature==rabbittype)return stopanim;
331 if(creature==wolftype)return wolfstopanim;
336 bool Person::isLanding(){
337 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
342 bool Person::wasLanding(){
343 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
346 int Person::getLanding(){
347 if(creature==rabbittype)return landanim;
348 if(creature==wolftype)return wolflandanim;
353 bool Person::isLandhard(){
354 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
359 bool Person::wasLandhard(){
360 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
363 int Person::getLandhard(){
364 if(creature==rabbittype)return landhardanim;
365 if(creature==wolftype)return wolflandhardanim;
370 bool Person::isFlip(){
371 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
375 bool Person::wasFlip(){
376 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
380 bool Person::isWallJump(){
381 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
385 void SolidHitBonus();
386 void SolidHitBonus(){
387 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
392 else if(bonustime<1.5&&bonus==threexcombo){
397 else if(bonustime<1.5&&bonus==twoxcombo){
402 else if(bonustime<1.5&&bonus==solidhit){
414 void Person::DoBlood(float howmuch,int which){
415 static int bleedxint,bleedyint;
417 //if(howmuch&&id==0)blooddimamount=1;
418 if(bloodtoggle&&tutoriallevel!=1){
419 if(bleeding<=0&&spurt){
421 for(int i=0;i<3;i++){
425 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
428 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
430 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
431 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
433 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
434 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
437 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);
438 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);
442 for(int i=0;i<3;i++){
446 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
447 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
450 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
451 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
455 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
457 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);
459 Sprite::setLastSpriteSpecial(3);
464 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
467 int texdetailint=realtexdetail;
468 if(creature==rabbittype)
469 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){
470 bleedxint=abs(Random()%512);
471 bleedyint=abs(Random()%512);
473 if(creature==wolftype)
474 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){
475 bleedxint=abs(Random()%512);
476 bleedyint=abs(Random()%512);
480 bleedy/=realtexdetail;
481 bleedx/=realtexdetail;
482 direction=abs(Random()%2)*2-1;
486 if(bleeding>2)bleeding=2;
489 void Person::DoBloodBig(float howmuch,int which){
490 static int bleedxint,bleedyint,i,j;
492 if(howmuch&&id==0)blooddimamount=1;
494 if(tutoriallevel!=1||id==0)
495 if(aitype!=playercontrolled&&howmuch>0){
506 if(creature==wolftype){
507 int i=abs(Random()%2);
508 if(i==0)whichsound=snarlsound;
509 if(i==1)whichsound=snarl2sound;
510 envsound[numenvsounds]=coords;
511 envsoundvol[numenvsounds]=16;
512 envsoundlife[numenvsounds]=.4;
515 if(creature==rabbittype){
516 int i=abs(Random()%2);
517 if(i==0)whichsound=rabbitpainsound;
518 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
519 envsound[numenvsounds]=coords;
520 envsoundvol[numenvsounds]=16;
521 envsoundlife[numenvsounds]=.4;
523 //if(i==2)whichsound=rabbitpain2sound;
527 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
528 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
529 OPENAL_SetVolume(channels[whichsound], 512);
530 OPENAL_SetPaused(channels[whichsound], false);
534 if(id==0&&howmuch>0){
542 if(bloodtoggle&&decals&&tutoriallevel!=1){
543 if(bleeding<=0&&spurt){
545 for(int i=0;i<3;i++){
549 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
552 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
554 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
555 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
557 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
558 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
561 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);
562 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);
566 int offsetx=0,offsety=0;
569 offsetx=abs(Random()%60);
571 if(which==190||which==185){
573 offsetx=abs(Random()%100)-20;
583 if(which==220||which==215){
584 //offsety=Random()%20;
586 //offsetx=abs(Random()%80);
595 if(creature==rabbittype)
598 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
599 if(i<startx)startx=i;
600 if(j<starty)starty=j;
606 if(creature==wolftype)
609 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
610 if(i<startx)startx=i;
611 if(j<starty)starty=j;
623 if(startx<0)startx=0;
624 if(starty<0)starty=0;
625 if(endx>512-1)endx=512-1;
626 if(endy>512-1)endy=512-1;
627 if(endx<startx)endx=startx;
628 if(endy<starty)endy=starty;
630 startx/=realtexdetail;
631 starty/=realtexdetail;
635 int texdetailint=realtexdetail;
637 if(creature==rabbittype)
638 for(i=startx;i<endx;i++){
639 for(j=starty;j<endy;j++){
640 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){
641 color=Random()%85+170;
642 where=i*skeleton.skinsize*3+j*3;
643 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
644 skeleton.skinText[where+1]=0;
645 skeleton.skinText[where+2]=0;
649 if(creature==wolftype)
650 for(i=startx;i<endx;i++){
651 for(j=starty;j<endy;j++){
652 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){
653 color=Random()%85+170;
654 where=i*skeleton.skinsize*3+j*3;
655 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
656 skeleton.skinText[where+1]=0;
657 skeleton.skinText[where+2]=0;
661 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
662 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
663 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
667 if(creature==rabbittype)
668 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){
669 bleedxint=abs(Random()%512);
670 bleedyint=abs(Random()%512);
672 if(creature==wolftype)
673 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){
674 bleedxint=abs(Random()%512);
675 bleedyint=abs(Random()%512);
677 bleedy=bleedxint+offsetx;
678 bleedx=bleedyint+offsety;
679 bleedy/=realtexdetail;
680 bleedx/=realtexdetail;
681 if(bleedx<0)bleedx=0;
682 if(bleedy<0)bleedy=0;
683 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
684 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
685 direction=abs(Random()%2)*2-1;
688 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
689 deathbleeding+=bleeding;
690 bloodloss+=bleeding*3;
692 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
693 if(abs(Random()%2)==0){aitype=gethelptype;
696 else aitype=attacktypecutoff;
699 if(bleeding>2)bleeding=2;
702 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
703 static int bleedxint,bleedyint,i,j;
705 static XYZ startpoint,endpoint,colpoint,movepoint;
706 static float rotationpoint;
708 static XYZ p1,p2,p3,p0;
712 float coordsx,coordsy;
715 if(bloodtoggle&&decals&&tutoriallevel!=1){
717 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
725 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
728 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
729 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
730 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
732 CrossProduct(p2-p1,p3-p1,&N);
733 CrossProduct(p0-p1,p3-p1,&temp);
734 s = dotproduct(&temp,&N)/findLength(&N);
735 CrossProduct(p2-p1,p1-p0,&temp);
736 t = dotproduct(&temp,&N)/findLength(&N);
739 bary.x=findDistancefast(&p0,&p1);
740 bary.y=findDistancefast(&p0,&p2);
741 bary.z=findDistancefast(&p0,&p3);
743 total=bary.x+bary.y+bary.z;
752 total=bary.x+bary.y+bary.z;
758 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
759 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
760 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
761 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
762 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
763 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
764 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;
765 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;
767 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
768 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
770 if(bleeding<=0&&spurt){
772 for(int i=0;i<3;i++){
776 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
779 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
781 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
782 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
784 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
785 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
788 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);
789 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);
793 int offsetx=0,offsety=0;
796 offsetx=abs(Random()%120);
798 if(which==220||which==215){
800 offsetx=abs(Random()%80);
803 offsetx=(1+coordsy)*512-291;
804 offsety=coordsx*512-437;
811 if(creature==rabbittype)
814 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
815 if(i<startx)startx=i;
816 if(j<starty)starty=j;
822 if(creature==wolftype)
825 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
826 if(i<startx)startx=i;
827 if(j<starty)starty=j;
838 if(startx<0)startx=0;
839 if(starty<0)starty=0;
840 if(endx>512-1)endx=512-1;
841 if(endy>512-1)endy=512-1;
842 if(endx<startx)endx=startx;
843 if(endy<starty)endy=starty;
845 startx/=realtexdetail;
846 starty/=realtexdetail;
850 int texdetailint=realtexdetail;
852 if(creature==rabbittype)
853 for(i=startx;i<endx;i++){
854 for(j=starty;j<endy;j++){
855 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){
856 color=Random()%85+170;
857 where=i*skeleton.skinsize*3+j*3;
858 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
859 skeleton.skinText[where+1]=0;
860 skeleton.skinText[where+2]=0;
862 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){
863 color=Random()%85+170;
864 where=i*skeleton.skinsize*3+j*3;
865 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
866 skeleton.skinText[where+1]=0;
867 skeleton.skinText[where+2]=0;
871 if(creature==wolftype)
872 for(i=startx;i<endx;i++){
873 for(j=starty;j<endy;j++){
874 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){
875 color=Random()%85+170;
876 where=i*skeleton.skinsize*3+j*3;
877 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
878 skeleton.skinText[where+1]=0;
879 skeleton.skinText[where+2]=0;
881 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){
882 color=Random()%85+170;
883 where=i*skeleton.skinsize*3+j*3;
884 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
885 skeleton.skinText[where+1]=0;
886 skeleton.skinText[where+2]=0;
890 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
891 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
892 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
894 bleedy=(1+coordsy)*512;
896 bleedy/=realtexdetail;
897 bleedx/=realtexdetail;
898 if(bleedx<0)bleedx=0;
899 if(bleedy<0)bleedy=0;
900 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
901 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
902 direction=abs(Random()%2)*2-1;
904 if(whichtri==-1)return 0;
906 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
907 deathbleeding+=bleeding;
908 bloodloss+=bleeding*3;
910 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
911 if(abs(Random()%2)==0){aitype=gethelptype;
914 else aitype=attacktypecutoff;
917 if(bleeding>2)bleeding=2;
922 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
925 static int bytesPerPixel=3;
926 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
927 static int newstartx,newstarty,newendx,newendy;
928 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
930 static float sizemult;
932 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
933 texture[i]=skeleton.skinText[i];
936 if((!osx||howmanylevels)){
938 if(startx<0)startx=0;
939 if(starty<0)starty=0;
940 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
941 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
942 if((endx>startx&&endy>starty)||howmanylevels){
949 for(i=startx;i<endx;i++){
950 for(j=starty;j<endy;j++){
951 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
952 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
953 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
957 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
960 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
961 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
962 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
965 newsize=skeleton.skinsize;
968 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
970 /*for(j=1;j<=howmanylevels;j++){
971 if(j==1)texpointer=&skeleton.skinText[0];
972 else texpointer=&texture[0];
974 totalsize=int( newsize*newsize*bytesPerPixel);
975 rowsize=int( newsize*bytesPerPixel );
976 bigstep=bytesPerPixel*newsize*2;
977 smallstep=bytesPerPixel*2;
983 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
990 void Person::Reverse(){
991 if(victim->aitype==playercontrolled||hostiletime>1)
992 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
993 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
994 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
995 if(targetanimation==sweepanim){
996 targetanimation=sweepreversedanim;
997 currentanimation=sweepreversedanim;
998 victim->currentanimation=sweepreversalanim;
999 victim->targetanimation=sweepreversalanim;
1001 if(targetanimation==spinkickanim){
1002 targetanimation=spinkickreversedanim;
1003 currentanimation=spinkickreversedanim;
1004 victim->currentanimation=spinkickreversalanim;
1005 victim->targetanimation=spinkickreversalanim;
1007 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
1008 if(targetanimation==rabbittacklinganim){
1011 victim->currentframe=6;
1012 victim->targetframe=7;
1014 targetanimation=upunchreversedanim;
1015 currentanimation=upunchreversedanim;
1016 victim->currentanimation=upunchreversalanim;
1017 victim->targetanimation=upunchreversalanim;
1019 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1020 if(victim->weaponactive!=-1){
1021 victim->throwtogglekeydown=1;
1022 weapons.owner[victim->weaponids[0]]=-1;
1023 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1024 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1025 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1026 weapons.missed[victim->weaponids[0]]=1;
1027 weapons.freetime[victim->weaponids[0]]=0;
1028 weapons.firstfree[victim->weaponids[0]]=1;
1029 weapons.physics[victim->weaponids[0]]=1;
1030 victim->num_weapons--;
1031 if(victim->num_weapons){
1032 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1033 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1036 victim->weaponactive=-1;
1037 for(int j=0;j<numplayers;j++){
1038 player[j].wentforweapon=0;
1042 targetanimation=staffhitreversedanim;
1043 currentanimation=staffhitreversedanim;
1044 victim->currentanimation=staffhitreversalanim;
1045 victim->targetanimation=staffhitreversalanim;
1047 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1048 if(victim->weaponactive!=-1){
1049 victim->throwtogglekeydown=1;
1050 weapons.owner[victim->weaponids[0]]=-1;
1051 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1052 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1053 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1054 weapons.missed[victim->weaponids[0]]=1;
1055 weapons.freetime[victim->weaponids[0]]=0;
1056 weapons.firstfree[victim->weaponids[0]]=1;
1057 weapons.physics[victim->weaponids[0]]=1;
1058 victim->num_weapons--;
1059 if(victim->num_weapons){
1060 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1061 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1064 victim->weaponactive=-1;
1065 for(int j=0;j<numplayers;j++){
1066 player[j].wentforweapon=0;
1069 targetanimation=staffspinhitreversedanim;
1070 currentanimation=staffspinhitreversedanim;
1071 victim->currentanimation=staffspinhitreversalanim;
1072 victim->targetanimation=staffspinhitreversalanim;
1074 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1075 if(victim->weaponactive!=-1){
1076 victim->throwtogglekeydown=1;
1077 weapons.owner[victim->weaponids[0]]=-1;
1078 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1079 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1080 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1081 weapons.missed[victim->weaponids[0]]=1;
1082 weapons.freetime[victim->weaponids[0]]=0;
1083 weapons.firstfree[victim->weaponids[0]]=1;
1084 weapons.physics[victim->weaponids[0]]=1;
1085 victim->num_weapons--;
1086 if(victim->num_weapons){
1087 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1088 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1091 victim->weaponactive=-1;
1092 for(int j=0;j<numplayers;j++){
1093 player[j].wentforweapon=0;
1096 targetanimation=swordslashreversedanim;
1097 currentanimation=swordslashreversedanim;
1098 victim->currentanimation=swordslashreversalanim;
1099 victim->targetanimation=swordslashreversalanim;
1101 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1102 if(victim->weaponactive!=-1){
1103 victim->throwtogglekeydown=1;
1104 weapons.owner[victim->weaponids[0]]=-1;
1105 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1106 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1107 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1108 weapons.missed[victim->weaponids[0]]=1;
1109 weapons.freetime[victim->weaponids[0]]=0;
1110 weapons.firstfree[victim->weaponids[0]]=1;
1111 weapons.physics[victim->weaponids[0]]=1;
1112 victim->num_weapons--;
1113 if(victim->num_weapons){
1114 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1115 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1118 victim->weaponactive=-1;
1119 for(int j=0;j<numplayers;j++){
1120 player[j].wentforweapon=0;
1123 targetanimation=knifeslashreversedanim;
1124 currentanimation=knifeslashreversedanim;
1125 victim->currentanimation=knifeslashreversalanim;
1126 victim->targetanimation=knifeslashreversalanim;
1128 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1129 victim->targettilt2=targettilt2;
1130 victim->currentframe=currentframe;
1131 victim->targetframe=targetframe;
1132 victim->target=target;
1134 victim->oldcoords=victim->coords;
1135 victim->coords=coords;
1136 victim->targetrotation=targetrotation;
1137 victim->rotation=targetrotation;
1138 victim->victim=this;
1140 if(targetanimation==winduppunchanim){
1141 targetanimation=winduppunchblockedanim;
1142 victim->targetanimation=blockhighleftanim;
1143 victim->targetframe=1;
1145 victim->victim=this;
1146 victim->targetrotation=targetrotation+180;
1148 if(targetanimation==wolfslapanim){
1149 targetanimation=winduppunchblockedanim;
1150 victim->targetanimation=blockhighleftanim;
1151 victim->targetframe=1;
1153 victim->victim=this;
1154 victim->targetrotation=targetrotation+180;
1156 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1157 targetanimation=swordslashparriedanim;
1159 victim->parriedrecently=0;
1160 victim->targetanimation=swordslashparryanim;
1161 victim->targetframe=1;
1163 victim->victim=this;
1164 victim->targetrotation=targetrotation+180;
1166 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1169 gLoc[0]=victim->coords.x;
1170 gLoc[1]=victim->coords.y;
1171 gLoc[2]=victim->coords.z;
1175 if(victim->weaponactive!=-1){
1176 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1177 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1178 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1180 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1181 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1182 OPENAL_SetVolume(channels[swordstaffsound], 512);
1183 OPENAL_SetPaused(channels[swordstaffsound], false);
1186 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1187 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1188 OPENAL_SetVolume(channels[metalhitsound], 512);
1189 OPENAL_SetPaused(channels[metalhitsound], false);
1193 victim->Puff(righthand);
1195 victim->targetframe=0;
1196 victim->targetanimation=staggerbackhighanim;
1197 victim->targetrotation=targetrotation+180;
1199 weapons.owner[victim->weaponids[0]]=-1;
1200 aim=DoRotation(facing,0,90,0)*21;
1202 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1203 weapons.tipvelocity[victim->weaponids[0]]=aim;
1204 weapons.missed[victim->weaponids[0]]=1;
1205 weapons.hitsomething[victim->weaponids[0]]=0;
1206 weapons.freetime[victim->weaponids[0]]=0;
1207 weapons.firstfree[victim->weaponids[0]]=1;
1208 weapons.physics[victim->weaponids[0]]=1;
1209 victim->num_weapons--;
1210 if(victim->num_weapons){
1211 victim->weaponids[0]=victim->weaponids[num_weapons];
1212 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1214 victim->weaponactive=-1;
1215 for(int i=0;i<numplayers;i++){
1216 player[i].wentforweapon=0;
1223 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1224 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1225 OPENAL_SetVolume(channels[metalhitsound], 512);
1226 OPENAL_SetPaused(channels[metalhitsound], false);*/
1229 if(abs(Random()%20)==0){
1238 if(weaponactive!=-1){
1239 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1240 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1241 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1243 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1244 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1245 OPENAL_SetVolume(channels[swordstaffsound], 512);
1246 OPENAL_SetPaused(channels[swordstaffsound], false);
1249 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1250 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1251 OPENAL_SetVolume(channels[metalhitsound], 512);
1252 OPENAL_SetPaused(channels[metalhitsound], false);
1260 targetanimation=staggerbackhighanim;
1261 targetrotation=targetrotation+180;
1263 weapons.owner[weaponids[0]]=-1;
1264 aim=DoRotation(facing,0,90,0)*21;
1266 weapons.velocity[weaponids[0]]=aim*-.2;
1267 weapons.tipvelocity[weaponids[0]]=aim;
1268 weapons.hitsomething[weaponids[0]]=0;
1269 weapons.missed[weaponids[0]]=1;
1270 weapons.freetime[weaponids[0]]=0;
1271 weapons.firstfree[weaponids[0]]=1;
1272 weapons.physics[weaponids[0]]=1;
1275 weaponids[0]=weaponids[num_weapons];
1276 if(weaponstuck==num_weapons)weaponstuck=0;
1279 for(int i=0;i<numplayers;i++){
1280 player[i].wentforweapon=0;
1284 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1285 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1286 OPENAL_SetVolume(channels[metalhitsound], 512);
1287 OPENAL_SetPaused(channels[metalhitsound], false);*/
1291 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1292 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1293 //victim->targetanimation=sweepanim;
1294 victim->targetanimation=dodgebackanim;
1295 victim->targetframe=0;
1297 //victim->velocity=0;
1300 rotatetarget=coords-victim->coords;
1301 Normalise(&rotatetarget);
1302 victim->targetrotation=-asin(0-rotatetarget.x);
1303 victim->targetrotation*=360/6.28;
1304 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1306 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1308 victim->lastattack3=victim->lastattack2;
1309 victim->lastattack2=victim->lastattack;
1310 victim->lastattack=victim->targetanimation;
1314 victim->targetanimation=sweepanim;
1315 victim->targetframe=0;
1319 rotatetarget=coords-victim->coords;
1320 Normalise(&rotatetarget);
1321 victim->targetrotation=-asin(0-rotatetarget.x);
1322 victim->targetrotation*=360/6.28;
1323 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1325 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1327 victim->lastattack3=victim->lastattack2;
1328 victim->lastattack2=victim->lastattack;
1329 victim->lastattack=victim->targetanimation;
1336 if(aitype!=playercontrolled)feint=0;
1337 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1338 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1339 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1341 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1345 void Person::DoDamage(float howmuch){
1346 if(tutoriallevel!=1)damage+=howmuch/power;
1347 if(id!=0)damagedealt+=howmuch/power;
1348 if(id==0)damagetaken+=howmuch/power;
1350 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1351 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1352 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1353 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1354 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1356 if(id==0)camerashake+=howmuch/100;
1357 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1358 if(blackout>1)blackout=1;
1360 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1361 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1362 if(abs(Random()%2)==0){aitype=gethelptype;
1365 else aitype=attacktypecutoff;
1369 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1372 for(int i=0;i<skeleton.num_joints; i++){
1373 if(!skeleton.free)flatvelocity2=velocity;
1374 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1375 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1376 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1377 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1378 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1379 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1380 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1381 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1382 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1393 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1394 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1395 OPENAL_SetVolume(channels[splattersound], 256);
1396 OPENAL_SetPaused(channels[splattersound], false);
1405 if(!dead&&creature==wolftype){
1414 if(tutoriallevel!=1||id==0)
1415 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1426 if(creature==wolftype){
1427 int i=abs(Random()%2);
1428 if(i==0)whichsound=snarlsound;
1429 if(i==1)whichsound=snarl2sound;
1430 envsound[numenvsounds]=coords;
1431 envsoundvol[numenvsounds]=16;
1432 envsoundlife[numenvsounds]=.4;
1435 if(creature==rabbittype){
1436 int i=abs(Random()%2);
1437 if(i==0)whichsound=rabbitpainsound;
1438 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1439 envsound[numenvsounds]=coords;
1440 envsoundvol[numenvsounds]=16;
1441 envsoundlife[numenvsounds]=.4;
1443 //if(i==2)whichsound=rabbitpain2sound;
1447 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1448 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1449 OPENAL_SetVolume(channels[whichsound], 512);
1450 OPENAL_SetPaused(channels[whichsound], false);
1455 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1456 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1459 void Person::DoHead(){
1460 static XYZ rotatearound;
1462 static float lookspeed=500;
1464 if(!freeze&&!winfreeze){
1467 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1468 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1470 while(targetheadrotation>180)targetheadrotation-=360;
1471 while(targetheadrotation<-180)targetheadrotation+=360;
1473 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1474 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1475 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1476 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1478 if(targetheadrotation2>120)targetheadrotation2=120;
1479 if(targetheadrotation2<-120)targetheadrotation2=-120;
1480 if(targetheadrotation>120)targetheadrotation=120;
1481 if(targetheadrotation<-120)targetheadrotation=-120;
1483 if(!isIdle())targetheadrotation2=0;
1485 if(targetheadrotation>80)targetheadrotation=80;
1486 if(targetheadrotation<-80)targetheadrotation=-80;
1487 if(targetheadrotation2>50)targetheadrotation2=50;
1488 if(targetheadrotation2<-50)targetheadrotation2=-50;
1491 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1492 else if(headrotation>targetheadrotation){
1493 headrotation-=multiplier*lookspeed;
1495 else if(headrotation<targetheadrotation){
1496 headrotation+=multiplier*lookspeed;
1499 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1500 else if(headrotation2>targetheadrotation2){
1501 headrotation2-=multiplier*lookspeed/2;
1503 else if(headrotation2<targetheadrotation2){
1504 headrotation2+=multiplier*lookspeed/2;
1507 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1508 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1512 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1513 facing=DoRotation(facing,headrotation2*.4,0,0);
1514 facing=DoRotation(facing,0,headrotation*.4,0);
1517 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1518 facing=DoRotation(facing,headrotation2*.8,0,0);
1519 facing=DoRotation(facing,0,headrotation*.8,0);
1522 if(targetanimation==walkanim){
1523 facing=DoRotation(facing,headrotation2*.6,0,0);
1524 facing=DoRotation(facing,0,headrotation*.6,0);
1527 skeleton.specialforward[0]=facing;
1528 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1530 for(i=0;i<skeleton.num_muscles;i++){
1531 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1533 skeleton.FindRotationMuscle(i,targetanimation);
1539 void Person::RagDoll(bool checkcollision){
1544 if(id==0)numfalls++;
1545 if(id==0&&isFlip())numflipfail++;
1551 facing=DoRotation(facing,0,rotation,0);
1553 skeleton.freetime=0;
1555 skeleton.longdead=0;
1561 skeleton.freefall=1;
1563 if(!isnormal(velocity.x))velocity.x=0;
1564 if(!isnormal(velocity.y))velocity.y=0;
1565 if(!isnormal(velocity.z))velocity.z=0;
1566 if(!isnormal(rotation))rotation=0;
1567 if(!isnormal(coords.x))coords=0;
1568 if(!isnormal(tilt))tilt=0;
1569 if(!isnormal(tilt2))tilt2=0;
1571 for(i=0;i<skeleton.num_joints;i++){
1572 skeleton.joints[i].delay=0;
1573 skeleton.joints[i].locked=0;
1574 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1575 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1576 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1577 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1578 skeleton.joints[i].position.y+=.1;
1579 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1580 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1583 for(i=0;i<skeleton.num_joints;i++){
1584 skeleton.joints[i].velocity=0;
1585 skeleton.joints[i].velchange=0;
1587 skeleton.DoConstraints(&coords,&scale);
1588 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1590 skeleton.DoConstraints(&coords,&scale);
1591 skeleton.DoConstraints(&coords,&scale);
1592 skeleton.DoConstraints(&coords,&scale);
1593 skeleton.DoConstraints(&coords,&scale);
1596 speed=animation[targetanimation].speed[targetframe]*2;
1597 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1598 speed=animation[currentanimation].speed[currentframe]*2;
1600 if(transspeed)speed=transspeed*2;
1604 for(i=0;i<skeleton.num_joints;i++){
1605 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);
1606 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1607 change.x=(float)(Random()%100)/100;
1608 change.y=(float)(Random()%100)/100;
1609 change.z=(float)(Random()%100)/100;
1610 skeleton.joints[i].velocity+=change;
1611 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1613 change.x=(float)(Random()%100)/100;
1614 change.y=(float)(Random()%100)/100;
1615 change.z=(float)(Random()%100)/100;
1616 skeleton.joints[i].velchange+=change;
1617 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1627 for(j=0;j<skeleton.num_joints;j++){
1628 average+=skeleton.joints[j].position;
1632 coords+=average*scale;
1633 for(j=0;j<skeleton.num_joints;j++){
1634 skeleton.joints[j].position-=average;
1637 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1638 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1639 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1640 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1641 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1644 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1645 coords.x=lowpoint.x;
1646 coords.z=lowpoint.z;
1655 for(i=0;i<skeleton.num_joints;i++){
1656 velocity+=skeleton.joints[i].velocity*scale;
1658 velocity/=skeleton.num_joints;
1661 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1662 weapons.owner[weaponids[0]]=-1;
1663 weapons.hitsomething[weaponids[0]]=0;
1664 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1665 weapons.velocity[weaponids[0]].x+=.01;
1666 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1667 weapons.missed[weaponids[0]]=1;
1668 weapons.freetime[weaponids[0]]=0;
1669 weapons.firstfree[weaponids[0]]=1;
1670 weapons.physics[weaponids[0]]=1;
1673 weaponids[0]=weaponids[num_weapons];
1674 if(weaponstuck==num_weapons)weaponstuck=0;
1677 for(i=0;i<numplayers;i++){
1678 player[i].wentforweapon=0;
1683 targetanimation=bounceidleanim;
1684 currentanimation=bounceidleanim;
1692 void Person::FootLand(int which, float opacity){
1693 static XYZ terrainlight;
1694 static XYZ footvel,footpoint;
1695 if(opacity>=1||skiddelay<=0)
1699 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1700 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1701 //footpoint.y=coords.y;
1702 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1704 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1706 if(footvel.y<.8)footvel.y=.8;
1707 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1708 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1709 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1710 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1711 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1712 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1714 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1716 if(footvel.y<.8)footvel.y=.8;
1717 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1718 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1719 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1720 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1721 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);
1723 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1725 if(footvel.y<.8)footvel.y=.8;
1726 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1727 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1728 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1729 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1730 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);
1731 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1733 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1736 if(footvel.y<.8)footvel.y=.8;
1737 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1738 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1739 //footpoint.y=coords.y;
1740 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1744 void Person::Puff(int whichlabel){
1745 static XYZ footvel,footpoint;
1748 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1749 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1753 void Person::DoAnimations(){
1756 static float oldtarget;
1758 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1760 if(targetanimation==tempanim||currentanimation==tempanim){
1761 animation[tempanim]=tempanimation;
1763 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1774 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1775 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1777 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1778 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1780 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1785 targfacing=DoRotation(targfacing,0,targetrotation,0);
1787 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1788 else targetanimation=backflipanim;
1789 crouchtogglekeydown=1;
1793 if(id==0)numflipped++;
1796 if(animation[targetanimation].attack!=reversed)feint=0;
1797 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1798 crouchtogglekeydown=0;
1799 if(aitype==playercontrolled)feint=0;
1803 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1804 if(!isFlip())crouchtogglekeydown=1;
1808 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1809 if(detail)normalsupdatedelay=0;
1813 if(targetanimation==rollanim&&targetframe==3&&onfire){
1823 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1824 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1825 OPENAL_SetVolume(channels[fireendsound], 256);
1826 OPENAL_SetPaused(channels[fireendsound], false);
1827 OPENAL_SetPaused(channels[stream_firesound], true);
1831 if(targetanimation==rabbittacklinganim&&targetframe==1){
1832 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1833 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1834 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1835 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1836 else victim->targetanimation=rabbittackledfrontanim;
1837 victim->targetframe=2;
1839 victim->rotation=rotation;
1840 victim->targetrotation=rotation;
1841 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1842 //victim->DoDamage(30);
1843 if(creature==wolftype){
1847 gLoc[0]=victim->coords.x;
1848 gLoc[1]=victim->coords.y;
1849 gLoc[2]=victim->coords.z;
1853 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
1854 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
1855 OPENAL_SetVolume(channels[clawslicesound], 128);
1856 OPENAL_SetPaused(channels[clawslicesound], false);
1858 victim->DoBloodBig(1/victim->armorhead,210);
1864 if(victim->aitype==gethelptype)bonusvalue=50;
1869 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1870 if(weapons.type[weaponids[0]]==knife){
1871 if(weaponactive==-1)weaponactive=0;
1872 else if(weaponactive==0)weaponactive=-1;
1874 if(weaponactive==-1){
1884 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
1885 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
1886 OPENAL_SetVolume(channels[knifesheathesound], 128);
1887 OPENAL_SetPaused(channels[knifesheathesound], false);
1889 if(weaponactive!=-1){
1899 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1900 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1901 OPENAL_SetVolume(channels[knifedrawsound], 128);
1902 OPENAL_SetPaused(channels[knifedrawsound], false);
1905 drawtogglekeydown=1;
1908 if(tutoriallevel!=1||id==0)
1909 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1920 if(terrain.getOpacity(coords.x,coords.z)<.2){
1921 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1922 else whichsound=footstepsound2;
1923 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1924 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1925 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1931 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1932 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1933 else whichsound=footstepsound4;
1937 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1938 else whichsound=footstepsound4;
1940 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1941 if(animation[targetanimation].attack!=neutral){
1943 if(i==0)whichsound=lowwhooshsound;
1944 if(i==1)whichsound=midwhooshsound;
1945 if(i==2)whichsound=highwhooshsound;
1947 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1949 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1950 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1952 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1953 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1954 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
1955 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
1956 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
1957 OPENAL_SetPaused(channels[whichsound], false);
1960 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1961 envsound[numenvsounds]=coords;
1962 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1963 else envsoundvol[numenvsounds]=6;
1964 envsoundlife[numenvsounds]=.4;
1968 if(animation[targetanimation].label[targetframe]==3){
1970 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1971 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1972 OPENAL_SetVolume(channels[whichsound], 128);
1973 OPENAL_SetPaused(channels[whichsound], false);
1978 if(tutoriallevel!=1||id==0)
1980 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1981 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1991 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1992 if(animation[targetanimation].attack!=neutral){
1994 if(creature==rabbittype){
1995 if(i==0)whichsound=rabbitattacksound;
1996 if(i==1)whichsound=rabbitattack2sound;
1997 if(i==2)whichsound=rabbitattack3sound;
1998 if(i==3)whichsound=rabbitattack4sound;
2000 if(creature==wolftype){
2001 if(i==0)whichsound=barksound;
2002 if(i==1)whichsound=bark2sound;
2003 if(i==2)whichsound=bark3sound;
2004 if(i==3)whichsound=barkgrowlsound;
2008 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2010 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2011 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
2014 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2015 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2016 OPENAL_SetVolume(channels[whichsound], 512);
2017 OPENAL_SetPaused(channels[whichsound], false);
2023 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
2029 currentoffset=targetoffset;
2030 targetframe=currentframe;
2031 currentanimation=targetanimation;
2034 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
2035 for(i=0;i<weapons.numweapons;i++){
2036 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
2037 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
2038 if(findDistancefast(&coords,&weapons.position[i])>=1){
2039 if(weapons.type[i]!=staff){
2048 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2049 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2050 OPENAL_SetVolume(channels[knifedrawsound], 128);
2051 OPENAL_SetPaused(channels[knifedrawsound], false);
2055 weapons.owner[i]=id;
2057 weaponids[num_weapons]=weaponids[0];
2066 static bool willwork;
2067 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2068 for(i=0;i<weapons.numweapons;i++){
2070 if(weapons.owner[i]!=-1)
2071 if(player[weapons.owner[i]].weaponstuck!=-1)
2072 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2073 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2074 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))
2075 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2076 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2086 if(weapons.owner[i]!=-1)
2087 if(victim->weaponstuck!=-1){
2088 if(victim->weaponids[victim->weaponstuck]==i){
2093 if(weapons.type[i]!=staff){
2094 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2095 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2096 OPENAL_SetVolume(channels[knifedrawsound], 128);
2097 OPENAL_SetPaused(channels[knifedrawsound], false);
2101 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2102 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2103 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2104 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2107 if(weapons.owner[i]!=-1){
2109 victim=&player[weapons.owner[i]];
2110 if(victim->num_weapons==1)victim->num_weapons=0;
2111 else victim->num_weapons=1;
2113 //victim->weaponactive=-1;
2114 victim->skeleton.longdead=0;
2115 victim->skeleton.free=1;
2116 victim->skeleton.broken=0;
2118 for(int j=0;j<victim->skeleton.num_joints;j++){
2119 victim->skeleton.joints[j].velchange=0;
2120 victim->skeleton.joints[j].locked=0;
2126 Normalise(&relative);
2127 XYZ footvel,footpoint;
2129 footpoint=weapons.position[i];
2130 if(victim->weaponstuck!=-1){
2131 if(victim->weaponids[victim->weaponstuck]==i){
2132 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2133 weapons.bloody[i]=2;
2134 weapons.blooddrip[i]=5;
2135 victim->weaponstuck=-1;
2138 if(victim->num_weapons>0){
2139 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2140 if(victim->weaponids[0]==i)
2141 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2144 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2145 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2146 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2147 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2149 weapons.owner[i]=id;
2151 weaponids[num_weapons]=weaponids[0];
2160 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2161 if(weaponactive==-1)weaponactive=0;
2162 else if(weaponactive==0){
2166 buffer=weaponids[0];
2167 weaponids[0]=weaponids[1];
2168 weaponids[1]=buffer;
2171 if(weaponactive==-1){
2181 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2182 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2183 OPENAL_SetVolume(channels[knifesheathesound], 128);
2184 OPENAL_SetPaused(channels[knifesheathesound], false);
2186 if(weaponactive!=-1){
2196 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2197 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2198 OPENAL_SetVolume(channels[knifedrawsound], 128);
2199 OPENAL_SetPaused(channels[knifedrawsound], false);
2204 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2205 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2206 Normalise(&rotatetarget);
2207 targetrotation=-asin(0-rotatetarget.x);
2208 targetrotation*=360/6.28;
2209 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2211 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2212 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2217 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2219 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;
2221 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2222 targetanimation=rabbittackleanim;
2233 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2234 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2235 OPENAL_SetVolume(channels[jumpsound], 128);
2236 OPENAL_SetPaused(channels[jumpsound], false);
2245 Normalise(&targetloc);
2247 for(i=0;i<numplayers;i++){
2249 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2250 closestdist=findDistancefast(&targetloc,&player[i].coords);
2255 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2257 victim=&player[closestid];
2258 coords=victim->coords;
2259 currentanimation=rabbittacklinganim;
2260 targetanimation=rabbittacklinganim;
2264 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2265 rotatetarget=coords-victim->coords;
2266 Normalise(&rotatetarget);
2267 targetrotation=-asin(0-rotatetarget.x);
2268 targetrotation*=360/6.28;
2269 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2271 if(targetanimation!=rabbitrunninganim){
2281 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2282 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2283 OPENAL_SetVolume(channels[jumpsound], 128);
2284 OPENAL_SetPaused(channels[jumpsound], false);
2290 float damagemult=1*power;
2291 if(creature==wolftype)damagemult=2.5*power;
2292 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2293 //if(onfire)damagemult=3;
2294 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2295 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2296 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2298 if(id==0)camerashake+=.4;
2299 if(Random()%2||creature==wolftype){
2302 if(creature==wolftype)DoBloodBig(0,250);
2306 gLoc[0]=victim->coords.x;
2307 gLoc[1]=victim->coords.y;
2308 gLoc[2]=victim->coords.z;
2312 if(tutoriallevel!=1){
2313 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2314 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2315 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2316 OPENAL_SetPaused(channels[heavyimpactsound], false);
2318 if(creature==wolftype){
2319 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2320 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2321 OPENAL_SetVolume(channels[clawslicesound], 128);
2322 OPENAL_SetPaused(channels[clawslicesound], false);
2324 victim->DoBloodBig(2/victim->armorhead,175);
2328 relative=victim->coords-coords;
2330 Normalise(&relative);
2331 relative=DoRotation(relative,0,-90,0);
2332 for(i=0;i<victim->skeleton.num_joints;i++){
2333 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2335 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2338 victim->DoDamage(damagemult*100/victim->protectionhead);
2346 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2347 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2349 if(id==0)camerashake+=.4;
2350 if(Random()%2||creature==wolftype){
2352 if(creature==wolftype)DoBloodBig(0,235);
2356 gLoc[0]=victim->coords.x;
2357 gLoc[1]=victim->coords.y;
2358 gLoc[2]=victim->coords.z;
2362 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2363 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2364 OPENAL_SetVolume(channels[whooshhitsound], 512);
2365 OPENAL_SetPaused(channels[whooshhitsound], false);
2366 if(creature==wolftype){
2367 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2368 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2369 OPENAL_SetVolume(channels[clawslicesound], 128);
2370 OPENAL_SetPaused(channels[clawslicesound], false);
2372 victim->DoBloodBig(2,175);
2376 relative=victim->coords-coords;
2378 Normalise(&relative);
2380 Normalise(&relative);
2381 relative=DoRotation(relative,0,90,0);
2382 for(i=0;i<victim->skeleton.num_joints;i++){
2383 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2385 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2388 victim->DoDamage(damagemult*50/victim->protectionhead);
2392 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2393 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2395 if(id==0)camerashake+=.4;
2400 gLoc[0]=victim->coords.x;
2401 gLoc[1]=victim->coords.y;
2402 gLoc[2]=victim->coords.z;
2406 if(tutoriallevel!=1){
2407 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2408 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2409 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2410 OPENAL_SetPaused(channels[heavyimpactsound], false);
2412 if(creature==wolftype){
2413 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2414 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2415 OPENAL_SetVolume(channels[clawslicesound], 128);
2416 OPENAL_SetPaused(channels[clawslicesound], false);
2418 victim->DoBloodBig(2/victim->armorhead,175);
2424 Normalise(&relative);
2425 relative=DoRotation(relative,0,-90,0);
2426 for(i=0;i<victim->skeleton.num_joints;i++){
2427 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2429 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2432 victim->DoDamage(damagemult*150/victim->protectionhead);
2434 if(victim->damage>victim->damagetolerance){
2447 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2448 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2450 if(id==0)camerashake+=.4;
2455 gLoc[0]=victim->coords.x;
2456 gLoc[1]=victim->coords.y;
2457 gLoc[2]=victim->coords.z;
2461 if(tutoriallevel!=1){
2462 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2463 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2464 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2465 OPENAL_SetPaused(channels[heavyimpactsound], false);
2467 if(creature==wolftype){
2468 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2469 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2470 OPENAL_SetVolume(channels[clawslicesound], 128);
2471 OPENAL_SetPaused(channels[clawslicesound], false);
2473 victim->DoBloodBig(2/victim->armorhead,175);
2479 Normalise(&relative);
2480 relative=DoRotation(relative,0,90,0);
2481 for(i=0;i<victim->skeleton.num_joints;i++){
2482 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2484 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2487 victim->DoDamage(damagemult*150/victim->protectionhead);
2489 if(victim->damage>victim->damagetolerance){
2502 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2503 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2505 if(id==0)camerashake+=.4;
2512 gLoc[0]=victim->coords.x;
2513 gLoc[1]=victim->coords.y;
2514 gLoc[2]=victim->coords.z;
2518 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2519 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2520 OPENAL_SetVolume(channels[whooshhitsound], 512);
2521 OPENAL_SetPaused(channels[whooshhitsound], false);
2524 relative=victim->coords-coords;
2526 Normalise(&relative);
2527 for(i=0;i<victim->skeleton.num_joints;i++){
2528 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2530 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2533 victim->DoDamage(damagemult*50/victim->protectionhead);
2537 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2538 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2540 if(id==0)camerashake+=.2;
2543 gLoc[0]=victim->coords.x;
2544 gLoc[1]=victim->coords.y;
2545 gLoc[2]=victim->coords.z;
2549 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2550 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2551 OPENAL_SetVolume(channels[landsound2], 128);
2552 OPENAL_SetPaused(channels[landsound2], false);
2554 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2555 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2556 OPENAL_SetVolume(channels[movewhooshsound], 128);
2557 OPENAL_SetPaused(channels[movewhooshsound], false);
2559 victim->skeleton.longdead=0;
2560 victim->skeleton.free=1;
2561 victim->skeleton.broken=0;
2562 victim->skeleton.spinny=1;
2564 for(i=0;i<victim->skeleton.num_joints;i++){
2565 victim->skeleton.joints[i].velchange=0;
2566 victim->skeleton.joints[i].delay=0;
2567 victim->skeleton.joints[i].locked=0;
2568 //victim->skeleton.joints[i].velocity=0;
2574 Normalise(&relative);
2575 for(i=0;i<victim->skeleton.num_joints;i++){
2576 victim->skeleton.joints[i].velocity.y=relative.y*10;
2577 victim->skeleton.joints[i].position.y+=relative.y*.3;
2578 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2579 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2581 victim->Puff(abdomen);
2582 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2586 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2587 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2589 if(id==0)camerashake+=.4;
2598 if(tutoriallevel!=1){
2599 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2600 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2601 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2602 OPENAL_SetPaused(channels[heavyimpactsound], false);
2605 relative=victim->coords-coords;
2607 Normalise(&relative);
2608 for(i=0;i<victim->skeleton.num_joints;i++){
2609 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2611 victim->Puff(abdomen);
2612 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2616 victim->DoDamage(damagemult*500/victim->protectionhigh);
2617 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2621 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2622 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2624 if(id==0)camerashake+=.4;
2633 if(tutoriallevel!=1){
2634 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2635 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2636 OPENAL_SetVolume(channels[thudsound], 400);
2637 OPENAL_SetPaused(channels[thudsound], false);
2640 victim->skeleton.longdead=0;
2641 victim->skeleton.free=1;
2642 victim->skeleton.broken=0;
2643 victim->skeleton.spinny=1;
2645 for(i=0;i<victim->skeleton.num_joints;i++){
2646 victim->skeleton.joints[i].velchange=0;
2647 //victim->skeleton.joints[i].delay=0;
2648 victim->skeleton.joints[i].locked=0;
2651 relative=victim->coords-coords;
2652 Normalise(&relative);
2654 Normalise(&relative);
2655 for(i=0;i<victim->skeleton.num_joints;i++){
2656 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2658 if(id==0&&!victim->dead){
2662 victim->Puff(abdomen);
2663 victim->DoDamage(damagemult*20/victim->protectionhigh);
2664 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2666 if(!victim->dead)staggerdelay=1.2;
2672 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2673 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2674 //if(id==0)camerashake+=.4;
2685 if(!victim->skeleton.free)hasvictim=0;
2688 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2689 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2690 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2691 OPENAL_SetVolume(channels[knifesheathesound], 128);
2692 OPENAL_SetPaused(channels[knifesheathesound], false);
2695 if(victim&&hasvictim){
2696 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2698 XYZ where,startpoint,endpoint,movepoint,colpoint;
2699 float rotationpoint;
2701 if(weapons.type[weaponids[weaponactive]]==knife){
2702 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2703 where-=victim->coords;
2704 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2711 if(weapons.type[weaponids[weaponactive]]==sword){
2712 where=weapons.position[weaponids[weaponactive]];
2713 where-=victim->coords;
2714 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2716 where=weapons.tippoint[weaponids[weaponactive]];
2717 where-=victim->coords;
2718 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2721 if(weapons.type[weaponids[weaponactive]]==staff){
2722 where=weapons.position[weaponids[weaponactive]];
2723 where-=victim->coords;
2724 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2726 where=weapons.tippoint[weaponids[weaponactive]];
2727 where-=victim->coords;
2728 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2733 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2736 if(victim->dead!=2){
2737 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2738 if(id==0&&!victim->dead){
2739 bonus=FinishedBonus;
2744 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2746 victim->skeleton.longdead=0;
2747 victim->skeleton.free=1;
2748 victim->skeleton.broken=0;
2750 for(i=0;i<victim->skeleton.num_joints;i++){
2751 victim->skeleton.joints[i].velchange=0;
2752 victim->skeleton.joints[i].locked=0;
2753 //victim->skeleton.joints[i].velocity=0;
2755 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2756 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2757 OPENAL_SetVolume(channels[fleshstabsound], 128);
2758 OPENAL_SetPaused(channels[fleshstabsound], false);
2761 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2762 weapons.blooddrip[weaponids[weaponactive]]+=5;
2763 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2767 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2768 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2769 OPENAL_SetVolume(channels[knifesheathesound], 128);
2770 OPENAL_SetPaused(channels[knifesheathesound], false);
2776 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2777 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2778 //if(id==0)camerashake+=.4;
2788 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2789 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2790 OPENAL_SetVolume(channels[knifedrawsound], 128);
2791 OPENAL_SetPaused(channels[knifedrawsound], false);
2794 if(victim&&hasvictim){
2795 XYZ footvel,footpoint;
2797 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2798 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2799 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2800 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2803 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2805 if(weapons.type[weaponids[weaponactive]]==sword){
2806 XYZ where,startpoint,endpoint,movepoint;
2807 float rotationpoint;
2810 where=weapons.position[weaponids[weaponactive]];
2811 where-=victim->coords;
2812 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2814 where=weapons.tippoint[weaponids[weaponactive]];
2815 where-=victim->coords;
2816 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2821 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2822 footpoint+=victim->coords;
2825 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2828 if(weapons.type[weaponids[weaponactive]]==staff){
2829 XYZ where,startpoint,endpoint,movepoint;
2830 float rotationpoint;
2833 where=weapons.position[weaponids[weaponactive]];
2834 where-=victim->coords;
2835 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2837 where=weapons.tippoint[weaponids[weaponactive]];
2838 where-=victim->coords;
2839 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2844 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2845 footpoint+=victim->coords;
2848 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2851 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2853 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2854 victim->skeleton.longdead=0;
2855 victim->skeleton.free=1;
2856 victim->skeleton.broken=0;
2858 for(i=0;i<victim->skeleton.num_joints;i++){
2859 victim->skeleton.joints[i].velchange=0;
2860 victim->skeleton.joints[i].locked=0;
2861 //victim->skeleton.joints[i].velocity=0;
2867 Normalise(&relative);
2868 //victim->Puff(abdomen);
2869 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2871 if(victim->bloodloss<victim->damagetolerance){
2872 victim->bloodloss+=1000;
2876 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2880 if(!hasvictim&&onterrain){
2881 weapons.bloody[weaponids[weaponactive]]=0;
2882 weapons.blooddrip[weaponids[weaponactive]]=0;
2886 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2887 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2889 if(id==0)camerashake+=.4;
2896 gLoc[0]=victim->coords.x;
2897 gLoc[1]=victim->coords.y;
2898 gLoc[2]=victim->coords.z;
2902 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2904 if(tutoriallevel!=1){
2905 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2906 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2907 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2908 OPENAL_SetPaused(channels[heavyimpactsound], false);
2912 if(tutoriallevel!=1){
2913 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2914 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2915 OPENAL_SetVolume(channels[landsound2], 256);
2916 OPENAL_SetPaused(channels[landsound2], false);
2920 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
2923 relative=victim->coords-coords;
2925 Normalise(&relative);
2926 for(i=0;i<victim->skeleton.num_joints;i++){
2927 victim->skeleton.joints[i].velocity=relative*30;
2929 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2931 victim->targetframe=0;
2932 victim->targetanimation=staggerbackhardanim;
2933 victim->targetrotation=targetrotation+180;
2938 victim->Puff(abdomen);
2939 victim->DoDamage(damagemult*60/victim->protectionhigh);
2948 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2949 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2951 if(id==0)camerashake+=.4;
2954 gLoc[0]=victim->coords.x;
2955 gLoc[1]=victim->coords.y;
2956 gLoc[2]=victim->coords.z;
2960 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2961 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2962 if(tutoriallevel!=1){
2963 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2964 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2965 OPENAL_SetVolume(channels[thudsound], 512);
2966 OPENAL_SetPaused(channels[thudsound], false);
2969 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2970 if(tutoriallevel!=1){
2971 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2972 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2973 OPENAL_SetVolume(channels[whooshhitsound], 512);
2974 OPENAL_SetPaused(channels[whooshhitsound], false);
2978 if(tutoriallevel!=1){
2979 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2980 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2981 OPENAL_SetVolume(channels[heavyimpactsound], 256);
2982 OPENAL_SetPaused(channels[heavyimpactsound], false);
2986 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2989 relative=victim->coords-coords;
2991 Normalise(&relative);
2993 Normalise(&relative);
2994 for(i=0;i<victim->skeleton.num_joints;i++){
2995 victim->skeleton.joints[i].velocity=relative*5;
2997 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
2999 victim->targetframe=0;
3000 victim->targetanimation=staggerbackhardanim;
3001 victim->targetrotation=targetrotation+180;
3005 victim->Puff(abdomen);
3006 victim->DoDamage(damagemult*60/victim->protectionhigh);
3014 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
3015 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3016 if(victim->id==0)camerashake+=.4;
3019 gLoc[0]=victim->coords.x;
3020 gLoc[1]=victim->coords.y;
3021 gLoc[2]=victim->coords.z;
3026 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3027 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3028 OPENAL_SetVolume(channels[landsound2], 256);
3029 OPENAL_SetPaused(channels[landsound2], false);
3035 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
3036 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3037 if(victim->id==0)camerashake+=.4;
3040 gLoc[0]=victim->coords.x;
3041 gLoc[1]=victim->coords.y;
3042 gLoc[2]=victim->coords.z;
3047 if(weaponactive!=-1){
3048 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3049 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3050 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3052 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3053 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3054 OPENAL_SetVolume(channels[swordstaffsound], 512);
3055 OPENAL_SetPaused(channels[swordstaffsound], false);
3058 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3059 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3060 OPENAL_SetVolume(channels[metalhitsound], 512);
3061 OPENAL_SetPaused(channels[metalhitsound], false);
3069 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3070 if(weaponactive!=-1){
3073 weapons.owner[weaponids[0]]=-1;
3074 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);
3076 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3077 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3079 weapons.velocity[weaponids[0]]=aim*50;
3080 weapons.tipvelocity[weaponids[0]]=aim*50;
3081 weapons.missed[weaponids[0]]=0;
3082 weapons.hitsomething[weaponids[0]]=0;
3083 weapons.freetime[weaponids[0]]=0;
3084 weapons.firstfree[weaponids[0]]=1;
3085 weapons.physics[weaponids[0]]=0;
3088 weaponids[0]=weaponids[num_weapons];
3094 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3096 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3099 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3107 if(tutoriallevel!=1){
3110 gLoc[0]=victim->coords.x;
3111 gLoc[1]=victim->coords.y;
3112 gLoc[2]=victim->coords.z;
3116 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3117 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3118 OPENAL_SetVolume(channels[knifeslicesound], 512);
3119 OPENAL_SetPaused(channels[knifeslicesound], false);
3121 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3122 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3123 if(victim->id != 0 || difficulty==2){
3124 victim->targetframe=0;
3125 victim->targetanimation=staggerbackhardanim;
3126 victim->targetrotation=targetrotation+180;
3130 victim->lowreversaldelay=0;
3131 victim->highreversaldelay=0;
3132 if(aitype!=playercontrolled)weaponmissdelay=.6;
3134 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3135 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3137 XYZ footvel,footpoint;
3140 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3143 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;
3145 if(tutoriallevel!=1){
3146 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3147 footvel=DoRotation(facing,0,90,0)*.8;
3149 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3150 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3151 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3152 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3154 if(tutoriallevel==1){
3155 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3157 victim->DoDamage(damagemult*0);
3160 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3161 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3162 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3169 if(tutoriallevel!=1){
3170 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3171 else victim->DoBloodBig(2/victim->armorhigh,185);
3172 victim->deathbleeding=1;
3175 gLoc[0]=victim->coords.x;
3176 gLoc[1]=victim->coords.y;
3177 gLoc[2]=victim->coords.z;
3181 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3182 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3183 OPENAL_SetVolume(channels[swordslicesound], 512);
3184 OPENAL_SetPaused(channels[swordslicesound], false);
3186 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3187 //if(animation[victim->targetanimation].attack){
3188 //if(victim->creature==rabbittype){
3189 if(tutoriallevel!=1){
3190 victim->targetframe=0;
3191 victim->targetanimation=staggerbackhardanim;
3192 victim->targetrotation=targetrotation+180;
3198 if(tutoriallevel!=1){
3199 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3200 weapons.blooddrip[weaponids[weaponactive]]+=3;
3202 float bloodlossamount;
3203 bloodlossamount=200+abs((float)(Random()%40))-20;
3204 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3205 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3206 victim->DoDamage(damagemult*0);
3208 XYZ footvel,footpoint;
3211 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3214 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;
3216 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3217 footvel=DoRotation(facing,0,90,0)*.8;
3219 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3220 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3221 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3222 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3230 gLoc[0]=victim->coords.x;
3231 gLoc[1]=victim->coords.y;
3232 gLoc[2]=victim->coords.z;
3236 if(victim->weaponactive!=-1){
3237 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3238 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3239 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3241 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3242 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3243 OPENAL_SetVolume(channels[swordstaffsound], 512);
3244 OPENAL_SetPaused(channels[swordstaffsound], false);
3247 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3248 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3249 OPENAL_SetVolume(channels[metalhitsound], 512);
3250 OPENAL_SetPaused(channels[metalhitsound], false);
3256 victim->Puff(righthand);
3258 victim->targetframe=0;
3259 victim->targetanimation=staggerbackhighanim;
3260 victim->targetrotation=targetrotation+180;
3262 weapons.owner[victim->weaponids[0]]=-1;
3263 aim=DoRotation(facing,0,90,0)*21;
3265 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3266 weapons.tipvelocity[victim->weaponids[0]]=aim;
3267 weapons.missed[victim->weaponids[0]]=1;
3268 weapons.hitsomething[weaponids[0]]=0;
3269 weapons.freetime[victim->weaponids[0]]=0;
3270 weapons.firstfree[victim->weaponids[0]]=1;
3271 weapons.physics[victim->weaponids[0]]=1;
3272 victim->num_weapons--;
3273 if(victim->num_weapons){
3274 victim->weaponids[0]=victim->weaponids[num_weapons];
3275 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3277 victim->weaponactive=-1;
3278 for(i=0;i<numplayers;i++){
3279 player[i].wentforweapon=0;
3282 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3283 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3284 OPENAL_SetVolume(channels[metalhitsound], 512);
3285 OPENAL_SetPaused(channels[metalhitsound], false);*/
3291 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3292 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3293 if(tutoriallevel!=1){
3294 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3296 if(id==0)camerashake+=.4;
3297 if(Random()%2||creature==wolftype){
3302 gLoc[0]=victim->coords.x;
3303 gLoc[1]=victim->coords.y;
3304 gLoc[2]=victim->coords.z;
3308 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3309 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3310 OPENAL_SetVolume(channels[staffheadsound], 256);
3311 OPENAL_SetPaused(channels[staffheadsound], false);
3315 relative=victim->coords-coords;
3317 Normalise(&relative);
3318 relative=DoRotation(relative,0,90,0);
3320 Normalise(&relative);
3321 for(i=0;i<victim->skeleton.num_joints;i++){
3322 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3324 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3325 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3328 if(tutoriallevel!=1){
3329 victim->DoDamage(damagemult*120/victim->protectionhigh);
3340 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3341 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3342 if(tutoriallevel!=1){
3343 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3345 if(id==0)camerashake+=.4;
3346 if(Random()%2||creature==wolftype){
3351 gLoc[0]=victim->coords.x;
3352 gLoc[1]=victim->coords.y;
3353 gLoc[2]=victim->coords.z;
3357 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3358 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3359 OPENAL_SetVolume(channels[staffheadsound], 256);
3360 OPENAL_SetPaused(channels[staffheadsound], false);
3364 relative=victim->coords-coords;
3366 Normalise(&relative);
3367 relative=DoRotation(relative,0,-90,0);
3368 for(i=0;i<victim->skeleton.num_joints;i++){
3369 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3371 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3372 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3375 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3386 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3387 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3389 if(tutoriallevel!=1){
3390 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3391 if(id==0)camerashake+=.4;
3392 if(Random()%2||creature==wolftype){
3397 gLoc[0]=victim->coords.x;
3398 gLoc[1]=victim->coords.y;
3399 gLoc[2]=victim->coords.z;
3403 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3404 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3405 OPENAL_SetVolume(channels[staffbodysound], 256);
3406 OPENAL_SetPaused(channels[staffbodysound], false);
3408 victim->skeleton.longdead=0;
3409 victim->skeleton.free=1;
3410 victim->skeleton.broken=0;
3412 for(i=0;i<victim->skeleton.num_joints;i++){
3413 victim->skeleton.joints[i].velchange=0;
3414 victim->skeleton.joints[i].locked=0;
3415 //victim->skeleton.joints[i].velocity=0;
3421 /*relative=victim->coords-coords;
3423 Normalise(&relative);
3424 relative=DoRotation(relative,0,90,0);*/
3426 Normalise(&relative);
3428 for(i=0;i<victim->skeleton.num_joints;i++){
3429 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3432 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3435 for(i=0;i<victim->skeleton.num_joints;i++){
3436 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3439 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3441 victim->Puff(abdomen);
3442 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3455 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3456 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3458 if(id==0)camerashake+=.4;
3461 gLoc[0]=victim->coords.x;
3462 gLoc[1]=victim->coords.y;
3463 gLoc[2]=victim->coords.z;
3468 relative=victim->coords-coords;
3470 Normalise(&relative);
3476 if(animation[victim->targetanimation].height==lowheight){
3482 for(i=0;i<victim->skeleton.num_joints;i++){
3483 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3485 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3486 if(tutoriallevel!=1){
3487 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3488 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3489 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3490 OPENAL_SetPaused(channels[heavyimpactsound], false);
3493 victim->DoDamage(damagemult*100/victim->protectionhead);
3494 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3495 if(creature==wolftype){
3496 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3497 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3498 OPENAL_SetVolume(channels[clawslicesound], 128);
3499 OPENAL_SetPaused(channels[clawslicesound], false);
3501 victim->DoBloodBig(2/victim->armorhead,175);
3505 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3506 for(i=0;i<victim->skeleton.num_joints;i++){
3507 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3509 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3510 victim->targetframe=0;
3511 victim->targetanimation=staggerbackhighanim;
3512 victim->targetrotation=targetrotation+180;
3514 if(tutoriallevel!=1){
3515 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3516 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3517 OPENAL_SetVolume(channels[landsound2], 128);
3518 OPENAL_SetPaused(channels[landsound2], false);
3520 victim->Puff(abdomen);
3521 victim->DoDamage(damagemult*30/victim->protectionhigh);
3522 if(creature==wolftype){
3523 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3524 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3525 OPENAL_SetVolume(channels[clawslicesound], 128);
3526 OPENAL_SetPaused(channels[clawslicesound], false);
3528 victim->DoBloodBig(2/victim->armorhigh,170);
3535 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3536 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3538 if(id==0)camerashake+=.2;
3541 gLoc[0]=victim->coords.x;
3542 gLoc[1]=victim->coords.y;
3543 gLoc[2]=victim->coords.z;
3547 if(tutoriallevel!=1){
3548 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3549 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3550 OPENAL_SetVolume(channels[landsound2], 128);
3551 OPENAL_SetPaused(channels[landsound2], false);
3554 relative=victim->coords-coords;
3556 Normalise(&relative);
3558 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3561 for(i=0;i<victim->skeleton.num_joints;i++){
3562 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3564 relative=DoRotation(relative,0,-90,0);
3566 for(i=0;i<victim->skeleton.num_joints;i++){
3567 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)
3568 victim->skeleton.joints[i].velocity=relative*80;
3570 victim->Puff(rightankle);
3571 victim->Puff(leftankle);
3572 victim->DoDamage(damagemult*40/victim->protectionlow);
3575 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3576 for(i=0;i<victim->skeleton.num_joints;i++){
3577 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3579 relative=DoRotation(relative,0,-90,0);
3580 for(i=0;i<victim->skeleton.num_joints;i++){
3581 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)
3582 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3584 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3585 victim->targetframe=0;
3586 victim->targetanimation=staggerbackhighanim;
3587 victim->targetrotation=targetrotation+180;
3589 if(tutoriallevel!=1){
3590 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3591 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3592 OPENAL_SetVolume(channels[landsound2], 128);
3593 OPENAL_SetPaused(channels[landsound2], false);
3595 victim->Puff(abdomen);
3596 victim->DoDamage(damagemult*30/victim->protectionlow);
3606 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3607 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3609 if(id==0)camerashake+=.4;
3616 gLoc[0]=victim->coords.x;
3617 gLoc[1]=victim->coords.y;
3618 gLoc[2]=victim->coords.z;
3622 if(tutoriallevel!=1){
3623 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3624 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3625 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3626 OPENAL_SetPaused(channels[heavyimpactsound], false);
3628 if(creature==wolftype){
3629 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3630 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3631 OPENAL_SetVolume(channels[clawslicesound], 128);
3632 OPENAL_SetPaused(channels[clawslicesound], false);
3634 victim->DoBloodBig(2/victim->armorhigh,170);
3638 relative=victim->coords-oldcoords;
3640 Normalise(&relative);
3641 //relative=DoRotation(relative,0,-90,0);
3642 for(i=0;i<victim->skeleton.num_joints;i++){
3643 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3645 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3647 victim->Puff(abdomen);
3648 victim->DoDamage(damagemult*150/victim->protectionhigh);
3657 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3658 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3659 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3660 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3663 weaponids[num_weapons]=weaponids[victim->weaponactive];
3666 weaponids[0]=victim->weaponids[victim->weaponactive];
3667 victim->num_weapons--;
3668 if(victim->num_weapons>0){
3669 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3670 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3672 victim->weaponactive=-1;
3677 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3679 if(id==0)camerashake+=.4;
3686 gLoc[0]=victim->coords.x;
3687 gLoc[1]=victim->coords.y;
3688 gLoc[2]=victim->coords.z;
3692 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3693 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3694 OPENAL_SetVolume(channels[whooshhitsound], 128);
3695 OPENAL_SetPaused(channels[whooshhitsound], false);
3698 relative=victim->coords-oldcoords;
3700 Normalise(&relative);
3701 //relative=DoRotation(relative,0,-90,0);
3702 for(i=0;i<victim->skeleton.num_joints;i++){
3703 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3705 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3708 victim->DoDamage(damagemult*70/victim->protectionhigh);
3711 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3713 if(id==0)camerashake+=.4;
3720 gLoc[0]=victim->coords.x;
3721 gLoc[1]=victim->coords.y;
3722 gLoc[2]=victim->coords.z;
3728 bonus=staffreversebonus;
3733 if(tutoriallevel!=1){
3734 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3735 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3736 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3737 OPENAL_SetPaused(channels[heavyimpactsound], false);
3741 bonus=staffreversebonus;
3747 relative=victim->coords-oldcoords;
3749 Normalise(&relative);
3750 //relative=DoRotation(relative,0,-90,0);
3751 for(i=0;i<victim->skeleton.num_joints;i++){
3752 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3754 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3757 victim->DoDamage(damagemult*70/victim->protectionhigh);
3760 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3766 Normalise(&relative);
3769 for(i=0;i<victim->skeleton.num_joints;i++){
3770 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3772 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3773 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3774 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3775 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3776 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3777 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3778 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3779 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3781 victim->Puff(abdomen);
3782 victim->DoDamage(damagemult*90/victim->protectionhigh);
3792 if(weaponactive!=-1||creature==wolftype)doslice=1;
3793 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3797 gLoc[0]=victim->coords.x;
3798 gLoc[1]=victim->coords.y;
3799 gLoc[2]=victim->coords.z;
3803 if(weaponactive!=-1){
3804 victim->DoBloodBig(2/victim->armorhigh,225);
3805 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3806 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3807 OPENAL_SetVolume(channels[knifeslicesound], 512);
3808 OPENAL_SetPaused(channels[knifeslicesound], false);
3809 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3810 weapons.blooddrip[weaponids[weaponactive]]+=3;
3812 if(weaponactive==-1&&creature==wolftype){
3813 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3814 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3815 OPENAL_SetVolume(channels[clawslicesound], 128);
3816 OPENAL_SetPaused(channels[clawslicesound], false);
3818 victim->DoBloodBig(2/victim->armorhigh,175);
3825 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3831 Normalise(&relative);
3834 for(i=0;i<victim->skeleton.num_joints;i++){
3835 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3837 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
3838 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
3839 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
3840 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
3841 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
3842 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
3843 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
3844 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
3847 bonus=swordreversebonus;
3851 //victim->DoDamage(90);
3853 /*if(weaponactive!=-1){
3856 gLoc[0]=victim->coords.x;
3857 gLoc[1]=victim->coords.y;
3858 gLoc[2]=victim->coords.z;
3862 victim->DoBloodBig(2,225);
3863 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3864 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3865 OPENAL_SetVolume(channels[knifeslicesound], 512);
3866 OPENAL_SetPaused(channels[knifeslicesound], false);
3867 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3868 weapons.blooddrip[weaponids[weaponactive]]+=3;
3872 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3874 if(id==0)camerashake+=.4;
3881 gLoc[0]=victim->coords.x;
3882 gLoc[1]=victim->coords.y;
3883 gLoc[2]=victim->coords.z;
3887 if(tutoriallevel!=1){
3888 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3889 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3890 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3891 OPENAL_SetPaused(channels[heavyimpactsound], false);
3895 relative=victim->coords-oldcoords;
3897 Normalise(&relative);
3898 relative=DoRotation(relative,0,-90,0);
3899 for(i=0;i<victim->skeleton.num_joints;i++){
3900 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3902 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3904 victim->Puff(abdomen);
3905 victim->DoDamage(damagemult*30/victim->protectionhigh);
3914 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
3917 victim->skeleton.spinny=0;
3921 Normalise(&relative);
3922 if(victim->id==0)relative/=30;
3923 for(i=0;i<victim->skeleton.num_joints;i++){
3924 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3926 //victim->DoDamage(1000);
3927 victim->damage=victim->damagetolerance;
3928 victim->permanentdamage=victim->damagetolerance-1;
3931 if(weaponactive!=-1||creature==wolftype)doslice=1;
3932 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3936 gLoc[0]=victim->coords.x;
3937 gLoc[1]=victim->coords.y;
3938 gLoc[2]=victim->coords.z;
3942 if(weaponactive!=-1){
3943 victim->DoBloodBig(200,225);
3944 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3945 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3946 OPENAL_SetVolume(channels[knifeslicesound], 512);
3947 OPENAL_SetPaused(channels[knifeslicesound], false);
3948 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3949 weapons.blooddrip[weaponids[weaponactive]]+=5;
3952 if(creature==wolftype&&weaponactive==-1){
3953 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3954 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3955 OPENAL_SetVolume(channels[clawslicesound], 128);
3956 OPENAL_SetPaused(channels[clawslicesound], false);
3958 victim->DoBloodBig(2,175);
3968 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3969 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3971 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3972 if(targetanimation==knifesneakattackanim){
3973 /*victim->DoBloodBig(200,195);
3978 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3979 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3981 XYZ footvel,footpoint;
3983 footpoint=weapons.tippoint[weaponids[0]];
3984 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3985 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3986 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3987 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3988 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3989 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3990 victim->DoBloodBig(200,195);
3997 //victim->neckspurtamount=5;
3999 if(targetanimation==knifefollowanim){
4005 XYZ footvel,footpoint;
4007 footpoint=weapons.tippoint[weaponids[0]];
4008 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4009 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4010 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4011 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4012 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
4013 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
4016 victim->bloodloss+=10000;
4020 gLoc[0]=victim->coords.x;
4021 gLoc[1]=victim->coords.y;
4022 gLoc[2]=victim->coords.z;
4026 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4027 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4028 OPENAL_SetVolume(channels[fleshstabsound], 512);
4029 OPENAL_SetPaused(channels[fleshstabsound], false);
4030 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4031 weapons.blooddrip[weaponids[weaponactive]]+=5;
4035 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
4038 for(i=0;i<victim->skeleton.num_joints;i++){
4039 victim->skeleton.joints[i].velocity=0;
4041 if(targetanimation==knifefollowanim){
4043 for(i=0;i<victim->skeleton.num_joints;i++){
4044 victim->skeleton.joints[i].velocity=0;
4047 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
4050 gLoc[0]=victim->coords.x;
4051 gLoc[1]=victim->coords.y;
4052 gLoc[2]=victim->coords.z;
4056 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4057 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4058 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4059 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4060 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4061 weapons.blooddrip[weaponids[weaponactive]]+=5;
4063 XYZ footvel,footpoint;
4065 footpoint=weapons.tippoint[weaponids[0]];
4066 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4067 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4068 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4069 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4070 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4071 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4075 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4076 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4085 XYZ footvel,footpoint;
4087 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
4088 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4089 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4090 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4091 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4092 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4093 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4094 victim->DoBloodBig(200,180);
4095 victim->DoBloodBig(200,215);
4096 victim->bloodloss+=10000;
4100 gLoc[0]=victim->coords.x;
4101 gLoc[1]=victim->coords.y;
4102 gLoc[2]=victim->coords.z;
4106 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4107 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4108 OPENAL_SetVolume(channels[fleshstabsound], 512);
4109 OPENAL_SetPaused(channels[fleshstabsound], false);
4110 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4111 weapons.blooddrip[weaponids[weaponactive]]+=5;
4115 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
4118 for(i=0;i<victim->skeleton.num_joints;i++){
4119 victim->skeleton.joints[i].velocity=0;
4121 if(weaponactive!=-1){
4124 gLoc[0]=victim->coords.x;
4125 gLoc[1]=victim->coords.y;
4126 gLoc[2]=victim->coords.z;
4130 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4131 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4132 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4133 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4134 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4135 weapons.blooddrip[weaponids[weaponactive]]+=5;
4137 XYZ footvel,footpoint;
4139 footpoint=weapons.tippoint[weaponids[0]];
4140 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4141 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4142 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4143 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4144 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4145 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4149 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4151 if(id==0)camerashake+=.4;
4158 gLoc[0]=victim->coords.x;
4159 gLoc[1]=victim->coords.y;
4160 gLoc[2]=victim->coords.z;
4164 if(weaponactive==-1){
4165 if(tutoriallevel!=1){
4166 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4167 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4168 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4169 OPENAL_SetPaused(channels[heavyimpactsound], false);
4174 if(weaponactive!=-1||creature==wolftype)doslice=1;
4175 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4177 if(weaponactive!=-1){
4178 victim->DoBloodBig(2/victim->armorhead,225);
4179 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4180 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4181 OPENAL_SetVolume(channels[knifeslicesound], 512);
4182 OPENAL_SetPaused(channels[knifeslicesound], false);
4183 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4184 weapons.blooddrip[weaponids[weaponactive]]+=3;
4186 if(weaponactive==-1&&creature==wolftype){
4187 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4188 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4189 OPENAL_SetVolume(channels[clawslicesound], 128);
4190 OPENAL_SetPaused(channels[clawslicesound], false);
4192 victim->DoBloodBig(2/victim->armorhead,175);
4205 //relative=victim->coords-oldcoords;
4208 Normalise(&relative);
4209 relative=DoRotation(relative,0,90,0);
4211 Normalise(&relative);
4212 for(i=0;i<victim->skeleton.num_joints;i++){
4213 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4215 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4216 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4217 victim->DoDamage(damagemult*100/victim->protectionhead);
4221 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4225 //relative=victim->coords-oldcoords;
4228 Normalise(&relative);
4229 relative=DoRotation(relative,0,90,0);
4231 Normalise(&relative);
4232 for(i=0;i<victim->skeleton.num_joints;i++){
4233 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4235 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4238 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4239 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4250 if(targetframe>animation[currentanimation].numframes-1){
4253 targetanimation=getIdle();
4257 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4258 targetanimation=rollanim;
4269 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4270 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4271 OPENAL_SetVolume(channels[movewhooshsound], 128);
4272 OPENAL_SetPaused(channels[movewhooshsound], false);
4274 if(currentanimation==staggerbackhighanim){
4275 targetanimation=getIdle();
4277 if(currentanimation==staggerbackhardanim){
4278 targetanimation=getIdle();
4280 if(currentanimation==removeknifeanim){
4281 targetanimation=getIdle();
4283 if(currentanimation==crouchremoveknifeanim){
4284 targetanimation=getCrouch();
4286 if(currentanimation==backhandspringanim){
4287 targetanimation=getIdle();
4289 if(currentanimation==dodgebackanim){
4290 targetanimation=getIdle();
4292 if(currentanimation==drawleftanim){
4293 targetanimation=getIdle();
4295 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4296 targetanimation=getIdle();
4297 if(currentanimation==crouchdrawrightanim){
4298 targetanimation=getCrouch();
4300 if(weaponactive==-1)weaponactive=0;
4301 else if(weaponactive==0){
4305 buffer=weaponids[0];
4306 weaponids[0]=weaponids[1];
4307 weaponids[1]=buffer;
4311 if(weaponactive==-1){
4321 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4322 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4323 OPENAL_SetVolume(channels[knifesheathesound], 128);
4324 OPENAL_SetPaused(channels[knifesheathesound], false);
4326 if(weaponactive!=-1){
4336 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4337 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4338 OPENAL_SetVolume(channels[knifedrawsound], 128);
4339 OPENAL_SetPaused(channels[knifedrawsound], false);
4342 if(currentanimation==rollanim){
4343 targetanimation=getCrouch();
4348 if(targetanimation==walljumprightkickanim){
4351 if(targetanimation==walljumpleftkickanim){
4354 targetanimation=jumpdownanim;
4356 if(currentanimation==climbanim){
4357 targetanimation=getCrouch();
4360 if(!isnormal(coords.x))
4371 if(targetanimation==rabbitkickreversalanim){
4372 targetanimation=getCrouch();
4375 if(targetanimation==jumpreversalanim){
4376 targetanimation=getCrouch();
4379 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4380 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4382 float closestdist=-1;
4385 for(i=0;i<numplayers;i++){
4386 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4387 distance=findDistancefast(&player[i].coords,&coords);
4388 if(closestdist==-1||distance<closestdist){
4389 closestdist=distance;
4394 if(closestdist>0&&closest>=0&&closestdist<16){
4395 victim=&player[closest];
4396 targetanimation=walljumprightkickanim;
4398 XYZ rotatetarget=victim->coords-coords;
4399 Normalise(&rotatetarget);
4400 rotation=-asin(0-rotatetarget.x);
4402 if(rotatetarget.z<0)rotation=180-rotation;
4403 targettilt2=-asin(rotatetarget.y)*360/6.28;
4404 velocity=(victim->coords-coords)*4;
4409 if(targetanimation==walljumpbackanim){
4410 targetanimation=backflipanim;
4414 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4416 if(targetanimation==walljumprightanim){
4417 targetanimation=rightflipanim;
4421 velocity=DoRotation(facing,0,30,0)*-8;
4424 if(targetanimation==walljumpfrontanim){
4425 targetanimation=frontflipanim;
4427 //targetrotation-=180;
4432 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4434 if(targetanimation==walljumpleftanim){
4437 float closestdist=-1;
4440 for(i=0;i<numplayers;i++){
4441 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4442 distance=findDistancefast(&player[i].coords,&coords);
4443 if(closestdist==-1||distance<closestdist){
4444 closestdist=distance;
4449 if(closestdist>0&&closest>=0&&closestdist<16){
4450 victim=&player[closest];
4451 targetanimation=walljumpleftkickanim;
4453 XYZ rotatetarget=victim->coords-coords;
4454 Normalise(&rotatetarget);
4455 rotation=-asin(0-rotatetarget.x);
4457 if(rotatetarget.z<0)rotation=180-rotation;
4458 targettilt2=-asin(rotatetarget.y)*360/6.28;
4459 velocity=(victim->coords-coords)*4;
4464 if(targetanimation!=walljumpleftkickanim){
4465 targetanimation=leftflipanim;
4469 velocity=DoRotation(facing,0,-30,0)*-8;
4472 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4474 if(targetanimation==sneakattackanim){
4475 float ycoords=oldcoords.y;
4476 currentanimation=getCrouch();
4477 targetanimation=getCrouch();
4480 targetrotation+=180;
4485 targetheadrotation+=180;
4487 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4491 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4492 float ycoords=oldcoords.y;
4493 targetanimation=getIdle();
4495 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4499 if(currentanimation==knifefollowanim){
4500 targetanimation=getIdle();
4503 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4504 float ycoords=oldcoords.y;
4505 targetanimation=getStop();
4506 targetrotation+=180;
4511 targetheadrotation+=180;
4512 if(!isnormal(coords.x))
4514 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4515 oldcoords=coords+facing*.5;
4516 else if(currentanimation==sweepreversalanim)
4517 oldcoords=coords+facing*1.1;
4518 else if(currentanimation==upunchreversalanim){
4519 oldcoords=coords+facing*1.5;
4520 targetrotation+=180;
4522 targetheadrotation+=180;
4526 else if(currentanimation==knifeslashreversalanim){
4527 oldcoords=coords+facing*.5;
4530 targetheadrotation+=90;
4534 else if(currentanimation==staffspinhitreversalanim){
4535 targetrotation+=180;
4537 targetheadrotation+=180;
4541 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4542 else oldcoords.y=ycoords;
4543 currentoffset=coords-oldcoords;
4549 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4554 if(animation[targetanimation].attack==reversed){
4556 if(targetanimation==sweepreversedanim)targetrotation+=90;
4557 targetanimation=backhandspringanim;
4567 PlaySoundEx( landsound, samp[landsound], NULL, true);
4568 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4569 OPENAL_SetVolume(channels[landsound], 128);
4570 OPENAL_SetPaused(channels[landsound], false);
4572 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4573 targetanimation=rollanim;
4576 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4577 coords.y=oldcoords.y;
4579 if(currentanimation==knifeslashreversedanim){
4580 targetanimation=rollanim;
4585 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4586 coords.y=oldcoords.y;
4590 targetanimation=jumpdownanim;
4592 if(wasLanding())targetanimation=getIdle();
4593 if(wasLandhard())targetanimation=getIdle();
4594 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4595 targetanimation=getIdle();
4597 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4598 coords.y=oldcoords.y;
4599 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4600 targetoffset.y=coords.y;
4601 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4602 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4603 currentoffset.y-=(coords.y-targetoffset.y);
4604 coords.y=targetoffset.y;
4606 normalsupdatedelay=0;
4608 if(currentanimation==upunchanim){
4609 targetanimation=getStop();
4610 normalsupdatedelay=0;
4613 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4614 targetrotation=rotation;
4617 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4618 if(!hasstaff)DoDamage(35);
4621 rabbitkickragdoll=1;
4623 if(currentanimation==rabbitkickreversedanim){
4630 if(id!=0)SolidHitBonus();
4634 targetanimation=rollanim;
4636 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4640 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4646 if(currentanimation==jumpreversedanim){
4653 if(id!=0)SolidHitBonus();
4657 targetanimation=rollanim;
4659 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4664 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){
4665 targetanimation=getupfromfrontanim;
4668 else if(animation[currentanimation].attack==normalattack){
4669 targetanimation=getIdle();
4672 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4673 targetanimation=blockhighleftstrikeanim;
4675 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4676 targetanimation=getIdle();
4679 if(currentanimation==spinkickanim&&victim->skeleton.free){
4680 if(creature==rabbittype)targetanimation=fightidleanim;
4685 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4687 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4688 targetanimation=jumpdownanim;
4693 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4694 if(!isRun()||!wasRun()){
4695 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4696 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4697 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4698 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4700 if(isRun()&&wasRun()){
4703 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4704 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4707 else if(transspeed)target+=multiplier*transspeed*speed*2;
4709 if(!isRun()||!wasRun()){
4710 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4711 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4712 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4713 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4717 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4719 if(target>1){currentframe=targetframe; target=1;}
4721 rot=targetrot*target;
4722 rotation+=rot-oldrot;
4728 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4730 for(i=0;i<skeleton.num_joints;i++){
4731 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4734 skeleton.FindForwards();
4736 for(i=0;i<skeleton.num_muscles;i++){
4737 if(skeleton.muscles[i].visible)
4739 skeleton.FindRotationMuscle(i,targetanimation);
4742 for(i=0;i<skeleton.num_muscles;i++){
4743 if(skeleton.muscles[i].visible)
4745 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4746 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4747 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4752 for(i=0;i<skeleton.num_joints;i++){
4753 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4756 skeleton.FindForwards();
4758 for(i=0;i<skeleton.num_muscles;i++){
4759 if(skeleton.muscles[i].visible)
4761 skeleton.FindRotationMuscle(i,targetanimation);
4764 for(i=0;i<skeleton.num_muscles;i++){
4765 if(skeleton.muscles[i].visible)
4767 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4768 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4769 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4770 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4771 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4772 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4773 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4774 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4775 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4779 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4781 oldcurrentanimation=currentanimation;
4782 oldtargetanimation=targetanimation;
4783 oldtargetframe=targetframe;
4784 oldcurrentframe=currentframe;
4786 for(i=0;i<skeleton.num_joints;i++){
4787 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4788 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4790 offset=currentoffset*(1-target)+targetoffset*target;
4791 for(i=0;i<skeleton.num_muscles;i++){
4792 if(skeleton.muscles[i].visible)
4794 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4795 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4796 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4801 if(isLanding()&&landhard){
4802 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4803 if(id==0)camerashake+=.4;
4804 targetanimation=getLandhard();
4812 //skeleton.DoConstraints();
4815 void Person::DoStuff(){
4816 static XYZ terrainnormal;
4817 static XYZ flatfacing;
4818 static XYZ flatvelocity;
4819 static float flatvelspeed;
4823 static int bloodsize;
4824 static int startx,starty,endx,endy;
4825 static int texdetailint;
4826 static GLubyte color;
4827 static XYZ bloodvel;
4829 onfiredelay-=multiplier;
4830 if(onfiredelay<0&&onfire)
4838 crouchkeydowntime+=multiplier;
4839 if(!crouchkeydown)crouchkeydowntime=0;
4840 jumpkeydowntime+=multiplier;
4841 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
4843 if(hostile||damage>0||bloodloss>0)immobile=0;
4845 if(isIdle()||isRun())targetoffset=0;
4847 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
4849 if(id==0)blooddimamount-=multiplier*.3;
4850 speechdelay-=multiplier;
4851 texupdatedelay-=multiplier;
4852 interestdelay-=multiplier;
4853 flamedelay-=multiplier;
4854 parriedrecently-=multiplier;
4860 if(id==0)speed=1.1*speedmult;
4861 else speed=1.0*speedmult;
4862 if(!skeleton.free)rabbitkickragdoll=0;
4866 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
4867 if(id!=0&&creature==wolftype&&difficulty==2){
4869 if(aitype!=passivetype){
4871 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){
4875 if(scale<0.2)superruntoggle=0;
4876 if(targetanimation==wolfrunninganim&&!superruntoggle){
4877 targetanimation=getRun();
4881 if(weaponactive==-1&&num_weapons>0){
4882 if(weapons.type[weaponids[0]]==staff){
4889 /*if(aitype!=playercontrolled)*///deathbleeding=5;
4890 /*if(aitype!=playercontrolled)*/
4892 if(burnt>.6)burnt=.6;
4893 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
4895 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
4906 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4907 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
4911 while(flamedelay<0&&onfire){
4913 howmany=abs(Random()%(skeleton.num_joints));
4914 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4915 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4916 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4917 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4918 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
4921 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
4923 howmany=abs(Random()%(skeleton.num_joints));
4924 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4925 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4926 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4927 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4928 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
4932 bleeding-=multiplier*.3;
4934 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4935 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
4939 if(neckspurtamount>0){
4940 neckspurtamount-=multiplier;
4941 neckspurtdelay-=multiplier*3;
4942 neckspurtparticledelay-=multiplier*3;
4943 if(neckspurtparticledelay<0&&neckspurtdelay>2){
4947 bloodvel.z=5*neckspurtamount;
4948 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4951 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
4953 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4954 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
4955 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);
4956 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);
4957 neckspurtparticledelay=.05;
4959 if(neckspurtdelay<0){
4964 if(deathbleeding>0&&dead!=2){
4965 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
4966 else bleeddelay-=5*multiplier/4;
4967 if(bleeddelay<0&&bloodtoggle){
4972 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4973 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
4974 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
4975 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);
4978 bloodloss+=deathbleeding*multiplier*80;
4979 deathbleeding-=multiplier*1.6;
4980 //if(id==0)deathbleeding-=multiplier*.2;
4981 if(deathbleeding<0)deathbleeding=0;
4982 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
4983 if(weaponactive!=-1){
4984 weapons.owner[weaponids[0]]=-1;
4985 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4986 weapons.velocity[weaponids[0]].x+=.01;
4987 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4988 weapons.missed[weaponids[0]]=1;
4989 weapons.hitsomething[weaponids[0]]=0;
4990 weapons.freetime[weaponids[0]]=0;
4991 weapons.firstfree[weaponids[0]]=1;
4992 weapons.physics[weaponids[0]]=1;
4995 weaponids[0]=weaponids[num_weapons];
4996 if(weaponstuck==num_weapons)weaponstuck=0;
4999 for(i=0;i<numplayers;i++){
5000 player[i].wentforweapon=0;
5012 if(!dead&&creature==wolftype){
5018 if(targetanimation==knifefollowedanim&&!skeleton.free){
5019 for(i=0;i<skeleton.num_joints;i++){
5020 skeleton.joints[i].velocity=0;
5021 skeleton.joints[i].velocity.y=-2;
5024 if(id!=0&&unconscioustime>.1){
5032 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
5035 bloodsize=5-realtexdetail;
5039 texdetailint=realtexdetail;
5040 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5041 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5042 endx=startx+bloodsize;
5043 endy=starty+bloodsize;
5045 if(startx<0){startx=0;bleeding=0;}
5046 if(starty<0){starty=0;bleeding=0;}
5047 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
5048 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
5049 if(endx<startx)endx=startx;
5050 if(endy<starty)endy=starty;
5052 for(i=startx;i<endx;i++){
5053 for(j=starty;j<endy;j++){
5055 color=Random()%85+170;
5056 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
5057 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
5058 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
5063 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5064 DoMipmaps(0,startx,endx,starty,endy);
5068 bleedy-=4/realtexdetail;
5069 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
5070 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
5073 bleedx+=4*direction/realtexdetail;
5074 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
5075 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
5079 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
5080 righthandmorphness=targetrighthandmorphness;
5081 righthandmorphstart=righthandmorphend;
5083 else if(righthandmorphness>targetrighthandmorphness){
5084 righthandmorphness-=multiplier*4;
5086 else if(righthandmorphness<targetrighthandmorphness){
5087 righthandmorphness+=multiplier*4;
5090 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
5091 lefthandmorphness=targetlefthandmorphness;
5092 lefthandmorphstart=lefthandmorphend;
5094 else if(lefthandmorphness>targetlefthandmorphness){
5095 lefthandmorphness-=multiplier*4;
5097 else if(lefthandmorphness<targetlefthandmorphness){
5098 lefthandmorphness+=multiplier*4;
5101 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
5102 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
5103 tailmorphness=targettailmorphness;
5104 tailmorphstart=tailmorphend;
5106 else if(tailmorphness>targettailmorphness){
5107 tailmorphness-=multiplier*10;
5109 else if(tailmorphness<targettailmorphness){
5110 tailmorphness+=multiplier*10;
5114 if(creature==wolftype){
5115 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
5116 tailmorphness=targettailmorphness;
5117 tailmorphstart=tailmorphend;
5119 else if(tailmorphness>targettailmorphness){
5120 tailmorphness-=multiplier*2;
5122 else if(tailmorphness<targettailmorphness){
5123 tailmorphness+=multiplier*2;
5127 if(headmorphend==3||headmorphstart==3){
5128 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
5129 headmorphness=targetheadmorphness;
5130 headmorphstart=headmorphend;
5132 else if(headmorphness>targetheadmorphness){
5133 headmorphness-=multiplier*7;
5135 else if(headmorphness<targetheadmorphness){
5136 headmorphness+=multiplier*7;
5139 else if(headmorphend==5||headmorphstart==5){
5140 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
5141 headmorphness=targetheadmorphness;
5142 headmorphstart=headmorphend;
5144 else if(headmorphness>targetheadmorphness){
5145 headmorphness-=multiplier*10;
5147 else if(headmorphness<targetheadmorphness){
5148 headmorphness+=multiplier*10;
5152 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5153 headmorphness=targetheadmorphness;
5154 headmorphstart=headmorphend;
5156 else if(headmorphness>targetheadmorphness){
5157 headmorphness-=multiplier*4;
5159 else if(headmorphness<targetheadmorphness){
5160 headmorphness+=multiplier*4;
5164 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5165 chestmorphness=targetchestmorphness;
5166 chestmorphstart=chestmorphend;
5168 else if(chestmorphness>targetchestmorphness){
5169 chestmorphness-=multiplier;
5171 else if(chestmorphness<targetchestmorphness){
5172 chestmorphness+=multiplier;
5175 if(dead!=2&&howactive<=typesleeping){
5176 if(chestmorphstart==0&&chestmorphend==0){
5178 targetchestmorphness=1;
5181 if(chestmorphstart!=0&&chestmorphend!=0){
5183 targetchestmorphness=1;
5185 if(environment==snowyenvironment){
5188 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5189 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5190 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5191 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5192 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5193 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5197 if(!dead&&howactive<typesleeping){
5198 blinkdelay-=multiplier*2;
5199 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5201 targetheadmorphness=1;
5203 blinkdelay=(float)(abs(Random()%40))/5;
5205 if(headmorphstart==3&&headmorphend==3){
5207 targetheadmorphness=1;
5212 twitchdelay-=multiplier*1.5;
5213 if(targetanimation!=hurtidleanim){
5214 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5216 targetheadmorphness=1;
5218 twitchdelay=(float)(abs(Random()%40))/5;
5220 if(headmorphstart==5&&headmorphend==5){
5222 targetheadmorphness=1;
5226 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5227 twitchdelay3-=multiplier*1;
5229 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5230 righthandmorphness=0;
5231 targetrighthandmorphness=1;
5232 righthandmorphend=1;
5233 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5235 if(righthandmorphstart==1&&righthandmorphend==1){
5236 righthandmorphness=0;
5237 targetrighthandmorphness=1;
5238 righthandmorphend=0;
5242 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5243 lefthandmorphness=0;
5244 targetlefthandmorphness=1;
5246 twitchdelay3=(float)(abs(Random()%40))/5;
5248 if(lefthandmorphstart==1&&lefthandmorphend==1){
5249 lefthandmorphness=0;
5250 targetlefthandmorphness=1;
5257 if(creature==rabbittype){
5258 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5259 else twitchdelay2-=multiplier*0.5;
5260 if(howactive<=typesleeping){
5261 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5263 targettailmorphness=1;
5265 twitchdelay2=(float)(abs(Random()%40))/5;
5267 if(tailmorphstart==1&&tailmorphend==1){
5269 targettailmorphness=1;
5272 if(tailmorphstart==2&&tailmorphend==2){
5274 targettailmorphness=1;
5281 if(creature==wolftype){
5282 twitchdelay2-=multiplier*1.5;
5284 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5286 targettailmorphness=1;
5291 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5293 targettailmorphness=1;
5297 if(twitchdelay2<=0){
5298 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5300 targettailmorphness=1;
5303 if(tailmorphstart==1&&tailmorphend==1){
5305 targettailmorphness=1;
5308 if(tailmorphstart==2&&tailmorphend==2){
5310 targettailmorphness=1;
5313 if(tailmorphstart==3&&tailmorphend==3){
5315 targettailmorphness=1;
5318 if(tailmorphstart==4&&tailmorphend==4){
5320 targettailmorphness=1;
5326 if(dead!=1)unconscioustime=0;
5328 if(dead==1||howactive==typesleeping){
5329 unconscioustime+=multiplier;
5330 //If unconscious, close eyes and mouth
5331 if(righthandmorphend!=0)righthandmorphness=0;
5332 righthandmorphend=0;
5333 targetrighthandmorphness=1;
5335 if(lefthandmorphend!=0)lefthandmorphness=0;
5337 targetlefthandmorphness=1;
5339 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5341 targetheadmorphness=1;
5345 if(howactive>typesleeping){
5348 if(bloodtoggle&&!bled){
5349 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5351 if(bloodtoggle&&!bled)
5352 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5353 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5354 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5358 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5363 if(dead==2||howactive>typesleeping){
5364 //If dead, open mouth and hands
5365 if(righthandmorphend!=0)righthandmorphness=0;
5366 righthandmorphend=0;
5367 targetrighthandmorphness=1;
5369 if(lefthandmorphend!=0)lefthandmorphness=0;
5371 targetlefthandmorphness=1;
5373 if(headmorphend!=2)headmorphness=0;
5375 targetheadmorphness=1;
5378 if(stunned>0&&!dead&&headmorphend!=2){
5379 if(headmorphend!=4)headmorphness=0;
5381 targetheadmorphness=1;
5384 if(damage>damagetolerance&&!dead){
5389 if(creature==wolftype){
5397 if(weaponactive!=-1){
5398 weapons.owner[weaponids[0]]=-1;
5399 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5400 weapons.velocity[weaponids[0]].x+=.01;
5401 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5402 weapons.missed[weaponids[0]]=1;
5403 weapons.hitsomething[weaponids[0]]=0;
5404 weapons.freetime[weaponids[0]]=0;
5405 weapons.firstfree[weaponids[0]]=1;
5406 weapons.physics[weaponids[0]]=1;
5409 weaponids[0]=weaponids[num_weapons];
5410 if(weaponstuck==num_weapons)weaponstuck=0;
5413 for(i=0;i<numplayers;i++){
5414 player[i].wentforweapon=0;
5420 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5428 //if(dead)damage-=multiplier/4;
5429 if(!dead)damage-=multiplier*13;
5430 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5431 if(!dead)permanentdamage-=multiplier*4;
5432 if(isIdle()||isCrouch()){
5433 if(!dead)permanentdamage-=multiplier*4;
5434 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5436 if(damage<0)damage=0;
5437 if(permanentdamage<0)permanentdamage=0;
5438 if(superpermanentdamage<0)superpermanentdamage=0;
5439 if(permanentdamage<superpermanentdamage){
5440 permanentdamage=superpermanentdamage;
5442 if(damage<permanentdamage){
5443 damage=permanentdamage;
5445 if(dead==1&&damage<damagetolerance){
5449 for(i=0;i<skeleton.num_joints;i++){
5450 skeleton.joints[i].velocity=0;
5453 if(permanentdamage>damagetolerance&&dead!=2){
5456 if(weaponactive!=-1){
5457 weapons.owner[weaponids[0]]=-1;
5458 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5459 weapons.velocity[weaponids[0]].x+=.01;
5460 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5461 weapons.missed[weaponids[0]]=1;
5462 weapons.hitsomething[weaponids[0]]=0;
5463 weapons.freetime[weaponids[0]]=0;
5464 weapons.firstfree[weaponids[0]]=1;
5465 weapons.physics[weaponids[0]]=1;
5468 weaponids[0]=weaponids[num_weapons];
5469 if(weaponstuck==num_weapons)weaponstuck=0;
5472 for(i=0;i<numplayers;i++){
5473 player[i].wentforweapon=0;
5479 if(!dead&&creature==wolftype){
5485 if(id!=0&&unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance){
5490 if(id!=0&&unconscioustime>.1){
5506 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5507 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5508 OPENAL_SetVolume(channels[breaksound], 512);
5509 OPENAL_SetPaused(channels[breaksound], false);
5510 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5516 if(skeleton.free==1){
5517 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5520 //If knocked over, open hands and close mouth
5521 if(righthandmorphend!=0)righthandmorphness=0;
5522 righthandmorphend=0;
5523 targetrighthandmorphness=1;
5525 if(lefthandmorphend!=0)lefthandmorphness=0;
5527 targetlefthandmorphness=1;
5529 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5530 if(headmorphend!=0)headmorphness=0;
5532 targetheadmorphness=1;
5536 skeleton.DoGravity(&scale);
5538 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5539 if(id!=0&&damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1)){
5544 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5548 for(j=0;j<skeleton.num_joints;j++){
5549 average+=skeleton.joints[j].position;
5553 coords+=average*scale;
5554 for(j=0;j<skeleton.num_joints;j++){
5555 skeleton.joints[j].position-=average;
5557 average/=multiplier;
5559 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5561 for(i=0;i<skeleton.num_joints;i++){
5562 velocity+=skeleton.joints[i].velocity*scale;
5564 velocity/=skeleton.num_joints;
5566 if(!isnormal(velocity.x)&&velocity.x){
5579 if(findLength(&average)<10&&dead&&skeleton.free){
5580 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5581 if(skeleton.longdead>2000){
5582 if(skeleton.longdead>6000){
5583 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5588 if(dead==2&&bloodloss<damagetolerance){
5590 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5592 if(bloodtoggle&&!bled){
5593 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5595 if(bloodtoggle&&!bled)
5596 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5597 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5598 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5602 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5606 if(dead==2&&bloodloss>=damagetolerance){
5608 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5609 if(bleeding<=0)DoBlood(1,255);
5610 if(bloodtoggle&&!bled){
5611 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5613 if(bloodtoggle&&!bled)
5614 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5615 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5616 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5620 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5627 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5629 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5633 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5634 if(velocity.y<-30)canrecover=0;
5635 for(i=0;i<objects.numobjects;i++){
5636 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5637 colviewer=startpoint;
5639 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5647 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5648 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5649 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5650 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5652 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5653 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5654 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5656 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5657 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5658 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5660 Normalise(&terrainnormal);
5662 targetrotation=-asin(0-terrainnormal.x);
5663 targetrotation*=360/6.28;
5664 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5665 rotation=targetrotation;
5667 //if(skeleton.forward.y<0){
5670 //if(skeleton.forward.y>-.3){
5673 targetanimation=flipanim;
5674 crouchtogglekeydown=1;
5679 currentanimation=tempanim;
5682 //tilt2=targettilt2;
5684 //if(middle.y>0)targetoffset.y=middle.y+1;
5686 for(i=0;i<skeleton.num_joints;i++){
5687 tempanimation.position[i][0]=skeleton.joints[i].position;
5688 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5693 if(findLength(&average)<10&&!dead&&skeleton.free){
5694 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5695 if(skeleton.longdead>(damage+500)*1.5){
5696 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5702 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5703 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5704 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5705 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5707 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5708 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5709 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5711 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5712 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5713 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5715 Normalise(&terrainnormal);
5717 targetrotation=-asin(0-terrainnormal.x);
5718 targetrotation*=360/6.28;
5719 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5720 rotation=targetrotation;
5723 terrainnormal=terrain.getNormal(coords.x,coords.z);
5724 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5728 /*XYZ otherterrainnormal;
5729 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5730 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5731 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5732 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5735 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5739 if(skeleton.forward.y<0){
5740 targetanimation=getupfrombackanim;
5744 if(skeleton.forward.y>-.3){
5745 targetanimation=getupfromfrontanim;
5747 targetrotation+=180;
5753 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5754 targetanimation=rollanim;
5755 targetrotation=lookrotation;
5759 if(forwardkeydown)targetrotation+=45;
5760 if(backkeydown)targetrotation-=45;
5764 if(forwardkeydown)targetrotation-=45;
5765 if(backkeydown)targetrotation+=45;
5768 if ( !leftkeydown&&!rightkeydown)
5769 targetrotation+=180;
5771 targetrotation+=180;
5775 if(abs(targettilt2)>50)targettilt2=0;
5776 currentanimation=tempanim;
5781 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5783 for(i=0;i<skeleton.num_joints;i++){
5784 tempanimation.position[i][0]=skeleton.joints[i].position;
5785 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5792 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5793 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5796 tempvelocity=velocity;
5797 Normalise(&tempvelocity);
5798 targetrotation=-asin(0-tempvelocity.x);
5799 targetrotation*=360/6.28;
5800 if(velocity.z<0)targetrotation=180-targetrotation;
5801 //targetrotation+=180;
5804 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5805 targetanimation=rollanim;
5809 targetanimation=backhandspringanim;
5810 targetrotation+=180;
5823 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
5824 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
5825 OPENAL_SetVolume(channels[movewhooshsound], 128);
5826 OPENAL_SetPaused(channels[movewhooshsound], false);
5828 currentanimation=targetanimation;
5829 currentframe=targetframe-1;
5834 rotation=targetrotation;
5841 if(skeleton.freefall==0)freefall=0;
5843 if(!isnormal(velocity.x)&&velocity.x){
5848 if(aitype!=passivetype||skeleton.free==1)
5849 if(findLengthfast(&velocity)>.1)
5850 for(i=0;i<objects.numobjects;i++){
5851 if(objects.type[i]==firetype)
5852 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){
5854 if(!objects.onfire[i]){
5857 gLoc[0]=objects.position[i].x;
5858 gLoc[1]=objects.position[i].y;
5859 gLoc[2]=objects.position[i].z;
5863 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5864 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5865 OPENAL_SetVolume(channels[firestartsound], 256);
5866 OPENAL_SetPaused(channels[firestartsound], false);
5868 objects.onfire[i]=1;
5871 if(objects.onfire[i]){
5876 if(objects.type[i]==bushtype)
5877 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){
5879 if(!objects.onfire[i]){
5882 gLoc[0]=objects.position[i].x;
5883 gLoc[1]=objects.position[i].y;
5884 gLoc[2]=objects.position[i].z;
5888 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5889 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5890 OPENAL_SetVolume(channels[firestartsound], 256);
5891 OPENAL_SetPaused(channels[firestartsound], false);
5893 objects.onfire[i]=1;
5897 if(objects.onfire[i]){
5901 if(objects.messedwith[i]<=0){
5913 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5914 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5915 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5916 OPENAL_SetPaused(channels[bushrustle], false);
5919 envsound[numenvsounds]=coords;
5920 envsoundvol[numenvsounds]=4*findLength(&velocity);
5921 envsoundlife[numenvsounds]=.4;
5926 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5927 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5929 if(environment!=desertenvironment)
5930 for(j=0;j<howmany;j++){
5931 tempvel.x=float(abs(Random()%100)-50)/20;
5932 tempvel.y=float(abs(Random()%100)-50)/20;
5933 tempvel.z=float(abs(Random()%100)-50)/20;
5936 pos.x+=float(abs(Random()%100)-50)/200;
5937 pos.y+=float(abs(Random()%100)-50)/200;
5938 pos.z+=float(abs(Random()%100)-50)/200;
5939 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);
5940 Sprite::setLastSpriteSpecial(1);
5942 howmany=findLength(&velocity)*4;
5944 if(environment==snowyenvironment)
5945 for(j=0;j<howmany;j++){
5946 tempvel.x=float(abs(Random()%100)-50)/20;
5947 tempvel.y=float(abs(Random()%100)-50)/20;
5948 tempvel.z=float(abs(Random()%100)-50)/20;
5951 pos.x+=float(abs(Random()%100)-50)/200;
5952 pos.y+=float(abs(Random()%100)-50)/200;
5953 pos.z+=float(abs(Random()%100)-50)/200;
5954 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5955 Sprite::setLastSpriteSpecial(2);
5958 objects.rotx[i]+=velocity.x*multiplier*6;
5959 objects.roty[i]+=velocity.z*multiplier*6;
5960 objects.messedwith[i]=.5;
5963 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
5964 if(objects.rotation2[i]==0)tempcoord=coords;
5966 tempcoord=coords-objects.position[i];
5967 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
5968 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
5969 tempcoord+=objects.position[i];
5971 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]){
5972 if(objects.messedwith[i]<=0){
5984 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5985 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5986 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5987 OPENAL_SetPaused(channels[bushrustle], false);
5990 envsound[numenvsounds]=coords;
5991 envsoundvol[numenvsounds]=4*findLength(&velocity);
5992 envsoundlife[numenvsounds]=.4;
5997 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5998 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6000 if(environment!=desertenvironment)
6001 for(j=0;j<howmany;j++){
6002 tempvel.x=float(abs(Random()%100)-50)/20;
6003 tempvel.y=float(abs(Random()%100)-50)/20;
6004 tempvel.z=float(abs(Random()%100)-50)/20;
6008 pos.x+=float(abs(Random()%100)-50)/150;
6009 pos.y+=float(abs(Random()%100)-50)/150;
6010 pos.z+=float(abs(Random()%100)-50)/150;
6011 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);
6012 Sprite::setLastSpriteSpecial(1);
6014 howmany=findLength(&velocity)*4;
6016 if(environment==snowyenvironment)
6017 for(j=0;j<howmany;j++){
6018 tempvel.x=float(abs(Random()%100)-50)/20;
6019 tempvel.y=float(abs(Random()%100)-50)/20;
6020 tempvel.z=float(abs(Random()%100)-50)/20;
6024 pos.x+=float(abs(Random()%100)-50)/150;
6025 pos.y+=float(abs(Random()%100)-50)/150;
6026 pos.z+=float(abs(Random()%100)-50)/150;
6027 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6028 Sprite::setLastSpriteSpecial(2);
6031 objects.messedwith[i]=.5;
6039 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
6041 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
6042 if(tutoriallevel==1&&id!=0)play=0;
6043 if(play&&aitype!=playercontrolled){
6055 if(creature==rabbittype){
6056 if(i==0)whichsound=rabbitchitter;
6057 if(i==1)whichsound=rabbitchitter2;
6059 if(creature==wolftype){
6060 if(i==0)whichsound=growlsound;
6061 if(i==1)whichsound=growl2sound;
6067 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
6068 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
6069 OPENAL_SetVolume(channels[whichsound], 512);
6070 OPENAL_SetPaused(channels[whichsound], false);
6074 if(targetanimation==staggerbackhighanim)staggerdelay=1;
6075 if(targetanimation==staggerbackhardanim)staggerdelay=1;
6076 staggerdelay-=multiplier;
6077 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
6078 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
6079 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
6080 targetanimation=getIdle();
6084 weaponmissdelay-=multiplier;
6085 highreversaldelay-=multiplier;
6086 lowreversaldelay-=multiplier;
6087 lastcollide-=multiplier;
6088 skiddelay-=multiplier;
6089 if(!isnormal(velocity.x)&&velocity.x){
6092 if(!isnormal(targettilt)&&targettilt){
6095 if(!isnormal(targettilt2)&&targettilt2){
6098 if(!isnormal(targetrotation)&&targetrotation){
6102 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
6103 //open hands and close mouth
6104 //if(targetanimation!=wolfidle){
6105 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6106 righthandmorphness=0;
6107 righthandmorphend=0;
6108 targetrighthandmorphness=1;
6111 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6112 lefthandmorphness=0;
6114 targetlefthandmorphness=1;
6118 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
6121 targetheadmorphness=1;
6125 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){
6126 //open hands and mouth
6127 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6128 righthandmorphness=0;
6129 righthandmorphend=0;
6130 targetrighthandmorphness=1;
6133 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6134 lefthandmorphness=0;
6136 targetlefthandmorphness=1;
6139 if(headmorphend!=1&&headmorphness==targetheadmorphness){
6142 targetheadmorphness=1;
6146 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
6147 //close hands and mouth
6148 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6149 righthandmorphness=0;
6150 righthandmorphend=1;
6151 targetrighthandmorphness=1;
6154 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6155 lefthandmorphness=0;
6157 targetlefthandmorphness=1;
6160 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6163 targetheadmorphness=1;
6167 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){
6168 //close hands and yell
6169 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6170 righthandmorphness=0;
6171 righthandmorphend=1;
6172 targetrighthandmorphness=1;
6175 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6176 lefthandmorphness=0;
6178 targetlefthandmorphness=1;
6181 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6184 targetheadmorphness=1;
6188 if(speechdelay>.25){
6189 if(headmorphend!=2)headmorphness=0;
6191 targetheadmorphness=1;
6197 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6198 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6202 if(!dead&&targetanimation!=hurtidleanim)
6203 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6204 if(headmorphend!=4||headmorphness==targetheadmorphness){
6207 targetheadmorphness=1;
6211 if(weaponactive!=-1){
6212 if(weapons.type[weaponids[weaponactive]]!=staff){
6213 righthandmorphstart=1;
6214 righthandmorphend=1;
6216 if(weapons.type[weaponids[weaponactive]]==staff){
6217 righthandmorphstart=2;
6218 righthandmorphend=2;
6220 targetrighthandmorphness=1;
6223 terrainnormal=terrain.getNormal(coords.x,coords.z);
6225 if(animation[targetanimation].attack!=reversal){
6226 if(!isnormal(coords.x))
6234 flatfacing=DoRotation(flatfacing,0,rotation,0);
6236 ReflectVector(&facing,terrainnormal);
6239 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6240 if(onterrain)targettilt2=-facing.y*20;
6244 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6245 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6246 flatvelocity=velocity;
6248 flatvelspeed=findLength(&flatvelocity);
6249 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6250 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6251 if(velocity.y<0)targettilt2*=-1;
6252 if(velocity.y<0)targettilt*=-1;
6253 if(targettilt>25)targettilt=25;
6254 if(targettilt<-25)targettilt=-25;
6257 if(targettilt2>45)targettilt2=45;
6258 if(targettilt2<-45)targettilt2=-45;
6259 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6260 else if(tilt2>targettilt2){
6261 tilt2-=multiplier*400;
6263 else if(tilt2<targettilt2){
6264 tilt2+=multiplier*400;
6266 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6267 if(tilt2>25)tilt2=25;
6268 if(tilt2<-25)tilt2=-25;
6271 if(!isnormal(targettilt)&&targettilt){
6274 if(!isnormal(targettilt2)&&targettilt2){
6279 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6280 if(targetanimation==rabbittackleanim){
6281 velocity+=facing*multiplier*speed*700*scale;
6282 velspeed=findLength(&velocity);
6283 if(velspeed>speed*65*scale){
6285 velspeed=speed*65*scale;
6288 velocity.y+=gravity*multiplier*20;
6289 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6290 velspeed=findLength(&velocity);
6291 velocity=flatfacing*velspeed;
6293 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6294 if(isRun()||targetanimation==rabbitkickanim){
6295 velocity+=facing*multiplier*speed*700*scale;
6296 velspeed=findLength(&velocity);
6297 if(velspeed>speed*45*scale){
6299 velspeed=speed*45*scale;
6302 velocity.y+=gravity*multiplier*20;
6303 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6304 velspeed=findLength(&velocity);
6305 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6306 velocity=flatfacing*velspeed;
6310 velocity+=facing*multiplier*speed*700*scale;
6311 velspeed=findLength(&velocity);
6312 if(creature==rabbittype){
6313 if(velspeed>speed*55*scale){
6315 velspeed=speed*55*scale;
6319 if(creature==wolftype){
6320 if(velspeed>speed*75*scale){
6322 velspeed=speed*75*scale;
6326 velocity.y+=gravity*multiplier*20;
6327 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6328 velspeed=findLength(&velocity);
6329 velocity=flatfacing*velspeed;
6332 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6333 velocity+=facing*multiplier*speed*700*scale;
6334 velspeed=findLength(&velocity);
6335 if(velspeed>speed*45*scale){
6337 velspeed=speed*45*scale;
6340 velocity.y+=gravity*multiplier*20;
6341 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6342 velspeed=findLength(&velocity);
6343 velocity=flatfacing*velspeed;
6347 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6348 velocity+=facing*multiplier*speed*700*scale;
6349 velspeed=findLength(&velocity);
6350 if(velspeed>speed*25*scale){
6352 velspeed=speed*25*scale;
6355 velocity.y+=gravity*multiplier*20;
6356 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6357 velspeed=findLength(&velocity);
6358 velocity=flatfacing*velspeed;
6361 if(targetanimation==sneakanim||targetanimation==walkanim){
6362 velocity+=facing*multiplier*speed*700*scale;
6363 velspeed=findLength(&velocity);
6364 if(velspeed>speed*12*scale){
6366 velspeed=speed*12*scale;
6369 velocity.y+=gravity*multiplier*20;
6370 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6371 velspeed=findLength(&velocity);
6372 velocity=flatfacing*velspeed;
6375 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6376 velocity+=facing*multiplier*speed*700*scale;
6377 velspeed=findLength(&velocity);
6378 if(velspeed>speed*2*scale){
6380 velspeed=speed*2*scale;
6383 velocity.y+=gravity*multiplier*20;
6384 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6385 velspeed=findLength(&velocity);
6386 velocity=flatfacing*velspeed;
6390 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6391 velocity-=facing*multiplier*speed*700*scale;
6392 velspeed=findLength(&velocity);
6393 if(velspeed>speed*2*scale){
6395 velspeed=speed*2*scale;
6398 velocity.y+=gravity*multiplier*20;
6399 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6400 velspeed=findLength(&velocity);
6401 velocity=flatfacing*velspeed*-1;
6404 if(targetanimation==fightsidestep){
6405 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6406 velspeed=findLength(&velocity);
6407 if(velspeed>speed*12*scale){
6409 velspeed=speed*12*scale;
6412 velocity.y+=gravity*multiplier*20;
6413 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6414 velspeed=findLength(&velocity);
6415 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6418 if(targetanimation==staggerbackhighanim){
6419 coords-=facing*multiplier*speed*16*scale;
6422 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6423 coords-=facing*multiplier*speed*20*scale;
6427 if(targetanimation==backhandspringanim){
6428 //coords-=facing*multiplier*50*scale;
6429 velocity+=facing*multiplier*speed*700*scale*-1;
6430 velspeed=findLength(&velocity);
6431 if(velspeed>speed*50*scale){
6433 velspeed=speed*50*scale;
6436 velocity.y+=gravity*multiplier*20;
6437 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6438 velspeed=findLength(&velocity);
6439 velocity=flatfacing*velspeed*-1;
6441 if(targetanimation==dodgebackanim){
6442 //coords-=facing*multiplier*50*scale;
6443 velocity+=facing*multiplier*speed*700*scale*-1;
6444 velspeed=findLength(&velocity);
6445 if(velspeed>speed*60*scale){
6447 velspeed=speed*60*scale;
6450 velocity.y+=gravity*multiplier*20;
6451 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6452 velspeed=findLength(&velocity);
6453 velocity=flatfacing*velspeed*-1;
6456 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6457 velspeed=findLength(&velocity);
6461 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6462 velocity.y+=gravity*multiplier;
6465 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6467 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6468 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6470 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6476 OPENAL_SetPaused(channels[whooshsound], true);
6477 OPENAL_SetVolume(channels[whooshsound], 0);
6480 if(targetanimation==jumpdownanim||isFlip()){
6481 if(isFlip())jumppower=-4;
6482 targetanimation=getLanding();
6491 PlaySoundEx( landsound, samp[landsound], NULL, true);
6492 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6493 OPENAL_SetVolume(channels[landsound], 128);
6494 OPENAL_SetPaused(channels[landsound], false);
6497 envsound[numenvsounds]=coords;
6498 envsoundvol[numenvsounds]=16;
6499 envsoundlife[numenvsounds]=.4;
6505 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6506 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6507 coords.y=terrain.getHeight(coords.x,coords.z);
6512 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)){
6513 velspeed=findLength(&velocity);
6515 if(velspeed<multiplier*300*scale){
6517 } else velocity-=velocity/velspeed*multiplier*300*scale;
6518 if(velspeed>5&&(isLanding()||isLandhard())){
6519 skiddingdelay+=multiplier;
6526 else skiddingdelay=0;
6530 velspeed=findLength(&velocity);
6532 if(velspeed<multiplier*600*scale){
6534 } else velocity-=velocity/velspeed*multiplier*600*scale;
6536 if(velspeed>5&&(isLanding()||isLandhard())){
6537 skiddingdelay+=multiplier;
6544 else skiddingdelay=0;
6547 if(skiddingdelay<0)skiddingdelay+=multiplier;
6548 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6558 if(!onterrain||environment==grassyenvironment){
6559 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6560 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6561 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6562 OPENAL_SetPaused(channels[skidsound], false);
6565 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6566 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6567 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6568 OPENAL_SetPaused(channels[snowskidsound], false);
6572 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6573 terrainnormal=victim->coords-coords;
6574 Normalise(&terrainnormal);
6575 targetrotation=-asin(0-terrainnormal.x);
6576 targetrotation*=360/6.28;
6577 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6578 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6581 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6582 targetrotation=victim->targetrotation;
6584 if(targetanimation==rabbittacklinganim){
6585 coords=victim->coords;
6588 skeleton.oldfree=skeleton.free;
6592 midterrain.x=terrain.size*terrain.scale/2;
6593 midterrain.z=terrain.size*terrain.scale/2;
6594 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6596 tempposit=coords-midterrain;
6598 Normalise(&tempposit);
6599 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6600 coords.x=tempposit.x+midterrain.x;
6601 coords.z=tempposit.z+midterrain.z;
6605 int Person::DrawSkeleton(){
6606 int oldplayerdetail;
6607 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6608 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6618 glAlphaFunc(GL_GREATER, 0.0001);
6620 float terrainheight;
6622 if(!isnormal(rotation))rotation=0;
6623 if(!isnormal(tilt))tilt=0;
6624 if(!isnormal(tilt2))tilt2=0;
6625 oldplayerdetail=playerdetail;
6627 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6630 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6633 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6638 if(playerdetail!=oldplayerdetail) {
6640 normalsupdatedelay=0;
6642 static float updatedelaychange;
6643 static float morphness;
6644 static float framemult;
6646 skeleton.FindForwards();
6647 if(howactive==typesittingwall){
6648 skeleton.specialforward[1]=0;
6649 skeleton.specialforward[1].z=1;
6655 static int weaponattachmuscle;
6656 static int weaponrotatemuscle,weaponrotatemuscle2;
6657 static XYZ weaponpoint;
6658 static int start,endthing;
6659 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6660 if(!isSleeping()&&!isSitting()){
6661 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6662 XYZ point,newpoint,change,change2;
6663 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6664 heightleft=terrain.getHeight(point.x,point.z)+.04;
6666 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6667 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6668 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6669 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6670 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6672 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6673 heightright=terrain.getHeight(point.x,point.z)+.04;
6674 point.y=heightright;
6675 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6676 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6677 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6678 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6679 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6680 skeleton.DoConstraints(&coords,&scale);
6682 if(creature==wolftype){
6683 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6684 heightleft=terrain.getHeight(point.x,point.z)+.04;
6686 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6687 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6688 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6689 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6690 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6692 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6693 heightright=terrain.getHeight(point.x,point.z)+.04;
6694 point.y=heightright;
6695 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6696 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6697 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6698 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6699 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6700 skeleton.DoConstraints(&coords,&scale);
6703 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6704 XYZ point,newpoint,change,change2;
6705 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6706 heightleft=terrain.getHeight(point.x,point.z)+.04;
6708 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6709 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6710 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6711 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6712 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6714 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6715 heightright=terrain.getHeight(point.x,point.z)+.04;
6716 point.y=heightright;
6717 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6718 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6719 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6720 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6721 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6722 skeleton.DoConstraints(&coords,&scale);
6724 if(creature==wolftype){
6725 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6726 heightleft=terrain.getHeight(point.x,point.z)+.04;
6728 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6729 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6730 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6731 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6732 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6734 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6735 heightright=terrain.getHeight(point.x,point.z)+.04;
6736 point.y=heightright;
6737 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6738 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6739 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6740 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6741 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6742 skeleton.DoConstraints(&coords,&scale);
6746 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6747 XYZ point,newpoint,change,change2;
6748 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6749 heightleft=terrain.getHeight(point.x,point.z)+.04;
6751 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6752 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6753 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6754 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6755 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6757 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6758 heightright=terrain.getHeight(point.x,point.z)+.04;
6759 point.y=heightright;
6760 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6761 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6762 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6763 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6764 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6765 skeleton.DoConstraints(&coords,&scale);
6767 if(creature==wolftype){
6768 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6769 heightleft=terrain.getHeight(point.x,point.z)+.04;
6771 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6772 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6773 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6774 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6775 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6777 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6778 heightright=terrain.getHeight(point.x,point.z)+.04;
6779 point.y=heightright;
6780 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6781 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6782 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6783 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6784 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6785 skeleton.DoConstraints(&coords,&scale);
6789 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()))
6792 targetheadrotation=-targetrotation;
6793 targetheadrotation2=0;
6794 if(animation[targetanimation].attack==3)targetheadrotation+=180;
6796 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6797 skeleton.drawmodel.vertex[i]=0;
6798 skeleton.drawmodel.vertex[i].y=999;
6800 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
6801 skeleton.drawmodellow.vertex[i]=0;
6802 skeleton.drawmodellow.vertex[i].y=999;
6804 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
6805 skeleton.drawmodelclothes.vertex[i]=0;
6806 skeleton.drawmodelclothes.vertex[i].y=999;
6808 for(i=0;i<skeleton.num_muscles;i++){
6809 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
6813 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
6814 morphness=righthandmorphness;
6815 start=righthandmorphstart;
6816 endthing=righthandmorphend;
6818 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
6819 morphness=lefthandmorphness;
6820 start=lefthandmorphstart;
6821 endthing=lefthandmorphend;
6823 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
6824 morphness=headmorphness;
6825 start=headmorphstart;
6826 endthing=headmorphend;
6828 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)){
6829 morphness=chestmorphness;
6830 start=chestmorphstart;
6831 endthing=chestmorphend;
6833 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)){
6834 morphness=tailmorphness;
6835 start=tailmorphstart;
6836 endthing=tailmorphend;
6838 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
6839 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6840 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6843 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6844 if(!skeleton.free)glRotatef(tilt,0,0,1);
6847 glTranslatef(mid.x,mid.y,mid.z);
6849 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6850 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6852 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6853 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6855 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6856 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6858 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
6862 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
6866 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
6870 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
6875 if(playerdetail||skeleton.free==3)
6877 for(j=0;j<skeleton.muscles[i].numvertices;j++)
6879 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
6880 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
6881 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
6882 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
6883 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
6884 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
6885 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
6886 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6888 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6889 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,
6890 (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,
6891 (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);
6892 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)
6893 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,
6894 (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,
6895 (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);
6896 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)
6897 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,
6898 (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,
6899 (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);
6900 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6901 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,
6902 (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,
6903 (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);
6904 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6905 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
6906 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
6907 //if(!isnormal(scale))test=1;
6908 //if(isnormal(scale)){
6909 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
6910 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
6911 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
6919 if(!playerdetail||skeleton.free==3)
6921 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
6923 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
6924 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6926 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6927 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
6928 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
6929 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
6930 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)
6931 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
6932 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
6933 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
6934 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)
6935 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
6936 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
6937 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
6938 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6939 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
6940 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
6941 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
6943 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6944 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
6945 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
6946 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
6953 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
6954 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6956 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6959 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6960 if(!skeleton.free)glRotatef(tilt,0,0,1);
6961 glTranslatef(mid.x,mid.y,mid.z);
6962 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6963 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6965 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6966 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6968 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6969 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6971 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
6972 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6974 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6975 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
6976 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
6977 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
6978 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)
6979 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
6980 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
6981 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
6982 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)
6983 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
6984 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
6985 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
6986 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6987 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
6988 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
6989 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
6990 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6991 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
6992 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
6993 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
6998 updatedelay=1+(float)(Random()%100)/1000;
7000 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
7001 normalsupdatedelay=1;
7002 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
7003 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
7004 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
7008 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
7009 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
7010 if(skeleton.clothes){
7011 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
7016 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
7017 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
7018 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
7019 if(skeleton.free==1)updatedelaychange*=6;
7020 if(id==0)updatedelaychange*=8;
7021 updatedelay+=updatedelaychange;
7023 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7025 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7026 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7027 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
7028 if(!skeleton.free)glRotatef(rotation,0,1,0);
7031 glColor4f(.4,1,.4,1);
7032 glDisable(GL_LIGHTING);
7033 glDisable(GL_TEXTURE_2D);
7036 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7037 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
7043 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
7044 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);
7045 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);
7046 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);
7047 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);
7048 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);
7049 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);
7055 terrainlight=terrain.getLighting(coords.x,coords.z);
7056 distance=findDistancefast(&viewer,&coords);
7057 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
7058 if(distance>1)distance=1;
7060 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
7061 if(terrainheight<1)terrainheight=1;
7062 if(terrainheight>1.7)terrainheight=1.7;
7065 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
7066 glDisable(GL_BLEND);
7067 glAlphaFunc(GL_GREATER, 0.0001);
7068 glEnable(GL_TEXTURE_2D);
7070 glDisable(GL_TEXTURE_2D);
7071 glColor4f(.7,.35,0,.5);
7073 glEnable(GL_LIGHTING);
7076 if(tutoriallevel&&id!=0){
7077 //glDisable(GL_TEXTURE_2D);
7078 glColor4f(.7,.7,.7,0.6);
7080 glEnable(GL_LIGHTING);
7082 if(canattack&&cananger)
7083 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7084 glDisable(GL_TEXTURE_2D);
7085 glColor4f(1,0,0,0.8);
7087 glMatrixMode(GL_TEXTURE);
7089 glTranslatef(0,-smoketex,0);
7090 glTranslatef(-smoketex,0,0);
7094 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7095 else skeleton.drawmodel.draw();
7099 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7100 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7103 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
7104 if(tutoriallevel&&id!=0){
7106 glMatrixMode(GL_MODELVIEW);
7107 glEnable(GL_TEXTURE_2D);
7108 glColor4f(.7,.7,.7,0.6);
7110 glEnable(GL_LIGHTING);
7112 if(canattack&&cananger)
7113 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7114 glDisable(GL_TEXTURE_2D);
7115 glColor4f(1,0,0,0.8);
7117 glMatrixMode(GL_TEXTURE);
7119 glTranslatef(0,-smoketex*.6,0);
7120 glTranslatef(smoketex*.6,0,0);
7123 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7124 else skeleton.drawmodel.draw();
7128 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7129 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7134 if(tutoriallevel&&id!=0){
7136 glMatrixMode(GL_MODELVIEW);
7137 glEnable(GL_TEXTURE_2D);
7139 if(skeleton.clothes){
7142 if(!immediate)skeleton.drawmodelclothes.draw();
7143 if(immediate)skeleton.drawmodelclothes.drawimmediate();
7150 for(k=0;k<num_weapons;k++){
7152 if(weaponactive==k){
7153 if(weapons.type[i]!=staff){
7154 for(j=0;j<skeleton.num_muscles;j++){
7155 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7156 weaponattachmuscle=j;
7159 for(j=0;j<skeleton.num_muscles;j++){
7160 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){
7161 weaponrotatemuscle=j;
7164 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7165 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7167 if(weapons.type[i]==staff){
7168 for(j=0;j<skeleton.num_muscles;j++){
7169 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7170 weaponattachmuscle=j;
7173 for(j=0;j<skeleton.num_muscles;j++){
7174 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){
7175 weaponrotatemuscle=j;
7178 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7179 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7180 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7181 XYZ tempnormthing,vec1,vec2;
7182 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7183 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7184 CrossProduct(&vec1,&vec2,&tempnormthing);
7185 Normalise(&tempnormthing);
7186 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);
7187 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7189 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7190 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7191 Normalise(&weaptargnorm);
7192 weaponpoint-=weaptargnorm*2;
7196 if(weaponactive!=k&&weaponstuck!=k){
7197 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;
7198 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;
7199 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;
7200 for(j=0;j<skeleton.num_muscles;j++){
7201 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){
7202 weaponrotatemuscle=j;
7207 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7208 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7209 for(j=0;j<skeleton.num_muscles;j++){
7210 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){
7211 weaponrotatemuscle=j;
7216 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;
7217 weapons.bigrotation[i]=rotation;
7218 weapons.bigtilt[i]=tilt;
7219 weapons.bigtilt2[i]=tilt2;
7222 weapons.position[i]=weaponpoint*scale+coords;
7223 weapons.bigrotation[i]=0;
7224 weapons.bigtilt[i]=0;
7225 weapons.bigtilt2[i]=0;
7227 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7228 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7229 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7230 if(weaponactive==k){
7231 if(weapons.type[i]==knife){
7232 weapons.smallrotation[i]=180;
7233 weapons.smallrotation2[i]=0;
7234 if(isCrouch()||wasCrouch()){
7235 weapons.smallrotation2[i]=20;
7237 if(targetanimation==hurtidleanim){
7238 weapons.smallrotation2[i]=50;
7240 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7241 XYZ temppoint1,temppoint2,tempforward;
7244 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7245 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7246 distance=findDistance(&temppoint1,&temppoint2);
7247 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7248 weapons.rotation2[i]*=360/6.28;
7251 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7252 weapons.rotation1[i]*=360/6.28;
7253 weapons.rotation3[i]=0;
7254 weapons.smallrotation[i]=-90;
7255 weapons.smallrotation2[i]=0;
7256 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7258 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7259 XYZ temppoint1,temppoint2,tempforward;
7262 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7263 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7264 distance=findDistance(&temppoint1,&temppoint2);
7265 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7266 weapons.rotation2[i]*=360/6.28;
7269 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7270 weapons.rotation1[i]*=360/6.28;
7271 weapons.rotation3[i]=0;
7272 weapons.smallrotation[i]=90;
7273 weapons.smallrotation2[i]=0;
7274 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7276 if(targetanimation==knifethrowanim){
7277 weapons.smallrotation[i]=90;
7278 //weapons.smallrotation2[i]=-90;
7279 weapons.smallrotation2[i]=0;
7280 weapons.rotation1[i]=0;
7281 weapons.rotation2[i]=0;
7282 weapons.rotation3[i]=0;
7284 if(targetanimation==knifesneakattackanim&&targetframe<5){
7285 weapons.smallrotation[i]=-90;
7286 weapons.rotation1[i]=0;
7287 weapons.rotation2[i]=0;
7288 weapons.rotation3[i]=0;
7291 if(weapons.type[i]==sword){
7292 weapons.smallrotation[i]=0;
7293 weapons.smallrotation2[i]=0;
7294 if(targetanimation==knifethrowanim){
7295 weapons.smallrotation[i]=-90;
7296 weapons.smallrotation2[i]=0;
7297 weapons.rotation1[i]=0;
7298 weapons.rotation2[i]=0;
7299 weapons.rotation3[i]=0;
7301 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)){
7302 XYZ temppoint1,temppoint2,tempforward;
7305 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7306 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7307 distance=findDistance(&temppoint1,&temppoint2);
7308 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7309 weapons.rotation2[i]*=360/6.28;
7312 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7313 weapons.rotation1[i]*=360/6.28;
7314 weapons.rotation3[i]=0;
7315 weapons.smallrotation[i]=90;
7316 weapons.smallrotation2[i]=0;
7317 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7320 if(weapons.type[i]==staff){
7321 weapons.smallrotation[i]=100;
7322 weapons.smallrotation2[i]=0;
7323 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7324 XYZ temppoint1,temppoint2,tempforward;
7327 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7328 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7329 distance=findDistance(&temppoint1,&temppoint2);
7330 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7331 weapons.rotation2[i]*=360/6.28;
7334 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7335 weapons.rotation1[i]*=360/6.28;
7336 weapons.rotation3[i]=0;
7337 weapons.smallrotation[i]=90;
7338 weapons.smallrotation2[i]=0;
7339 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7343 if(weaponactive!=k&&weaponstuck!=k){
7344 if(weapons.type[i]==knife){
7345 weapons.smallrotation[i]=-70;
7346 weapons.smallrotation2[i]=10;
7348 if(weapons.type[i]==sword){
7349 weapons.smallrotation[i]=-100;
7350 weapons.smallrotation2[i]=-8;
7352 if(weapons.type[i]==staff){
7353 weapons.smallrotation[i]=-100;
7354 weapons.smallrotation2[i]=-8;
7358 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7359 else weapons.smallrotation[i]=0;
7360 weapons.smallrotation2[i]=10;
7361 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7369 if(skeleton.free)calcrot=1;
7370 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7371 if(currentanimation!=targetanimation)calcrot=1;
7372 //if(id==0)calcrot=1;
7373 if(skeleton.free==2)calcrot=0;
7379 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7382 static float distance;
7383 static float olddistance;
7384 static int intersecting;
7385 static int firstintersecting;
7388 static XYZ start,end;
7389 static float slopethreshold=-.4;
7391 firstintersecting=-1;
7395 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7396 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7398 for (j=0;j<model->TriangleNum;j++){
7399 if(model->facenormals[j].y<=slopethreshold){
7401 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)));
7402 if(distance<radius){
7403 point=*p1-model->facenormals[j]*distance;
7404 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;
7405 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7406 &model->vertex[model->Triangles[j].vertex[1]],
7408 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7409 &model->vertex[model->Triangles[j].vertex[2]],
7411 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7412 &model->vertex[model->Triangles[j].vertex[2]],
7415 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7419 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)){
7420 p1->y=point.y+radius;
7421 if((targetanimation==jumpdownanim||isFlip())){
7422 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7424 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7430 OPENAL_SetPaused(channels[whooshsound], true);
7431 OPENAL_SetVolume(channels[whooshsound], 0);
7434 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7435 if(isFlip())jumppower=-4;
7436 targetanimation=getLanding();
7445 PlaySoundEx( landsound, samp[landsound], NULL, true);
7446 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7447 OPENAL_SetVolume(channels[landsound], 128);
7448 OPENAL_SetPaused(channels[landsound], false);
7451 envsound[numenvsounds]=coords;
7452 envsoundvol[numenvsounds]=16;
7453 envsoundlife[numenvsounds]=.4;
7461 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7464 for (j=0;j<model->TriangleNum;j++){
7465 if(model->facenormals[j].y>slopethreshold){
7469 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)));
7470 if(distance<radius*.5){
7471 point=start-model->facenormals[j]*distance;
7472 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;
7473 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,
7474 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7475 p1->x, p1->y, p1->z, radius/2);
7476 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,
7477 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7478 p1->x, p1->y, p1->z, radius/2);
7479 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,
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);
7483 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7484 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7486 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7487 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7489 *p1+=model->facenormals[j]*(distance-radius*.5);
7492 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7496 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7498 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7500 return firstintersecting;
7510 currentanimation = 0;
7511 targetanimation = 0;
7512 oldcurrentframe = 0;
7514 oldcurrentanimation = 0;
7515 oldtargetanimation = 0;
7519 parriedrecently = 0;
7523 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7525 currentoffset = 0,targetoffset = 0,offset = 0;
7543 unconscioustime = 0;
7561 rabbitkickenabled = 0;
7570 damagetolerance = 0;
7572 permanentdamage = 0;
7573 superpermanentdamage = 0; lastcollide = 0;
7593 headrotation = 0,headrotation2 = 0;
7594 targetheadrotation = 0,targetheadrotation2 = 0;
7605 normalsupdatedelay = 0;
7610 forwardstogglekeydown = 0;
7615 jumptogglekeydown = 0;
7617 crouchtogglekeydown = 0;
7619 drawtogglekeydown = 0;
7621 throwtogglekeydown = 0;
7627 crouchkeydowntime = 0;
7628 jumpkeydowntime = 0;
7645 whichdirectiondelay = 0;
7646 avoidsomething = 0; avoidwhere = 0;
7654 lefthandmorphness = 0;
7655 righthandmorphness = 0;
7659 targetlefthandmorphness = 0;
7660 targetrighthandmorphness = 0;
7661 targetheadmorphness = 0;
7662 targetchestmorphness = 0;
7663 targettailmorphness = 0;
7664 lefthandmorphstart = 0,lefthandmorphend = 0;
7665 righthandmorphstart = 0,righthandmorphend = 0;
7666 headmorphstart = 0,headmorphend = 0;
7667 chestmorphstart = 0,chestmorphend = 0;
7668 tailmorphstart = 0,tailmorphend = 0;
7670 weaponmissdelay = 0;
7671 highreversaldelay = 0;
7672 lowreversaldelay = 0;
7679 //Skeleton skeleton;
7698 memset(clothes, 0, sizeof(clothes));
7699 memset(clothestintr, 0, sizeof(clothestintr));
7700 memset(clothestintg, 0, sizeof(clothestintg));
7701 memset(clothestintb, 0, sizeof(clothestintb));
7707 onfiredelay = 0; burnt = 0;
7711 updatestuffdelay = 0;
7717 memset(weaponids, 0, sizeof(weaponids));
7721 weaponstuckwhere = 0;
7726 memset(waypoints, 0, sizeof(waypoints));
7727 memset(waypointtype, 0, sizeof(waypointtype));
7730 hastempwaypoint = 0;
7736 finalfinaltarget = 0;
7738 finalpathfindpoint = 0;
7739 targetpathfindpoint = 0;
7740 lastpathfindpoint = 0;
7741 lastpathfindpoint2 = 0;
7742 lastpathfindpoint3 = 0;
7743 lastpathfindpoint4 = 0;
7754 runninghowlong = 0; lastoccluded = 0;
7760 neckspurtparticledelay = 0;
7761 neckspurtamount = 0;
7764 rabbitkickragdoll = 0;
7769 //Animation tempanimation;