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"
28 extern float multiplier;
29 extern int channels[100];
30 extern Terrain terrain;
32 extern int environment;
34 extern FRUSTUM frustum;
36 extern float realmultiplier;
38 extern float slomodelay;
39 extern bool cellophane;
40 extern float texdetail;
41 extern float realtexdetail;
42 extern GLubyte bloodText[512*512*3];
43 extern GLubyte wolfbloodText[512*512*3];
44 extern int bloodtoggle;
45 extern Objects objects;
47 extern bool autoslomo;
48 extern float camerashake;
50 extern float terraindetail;
51 extern float viewdistance;
52 extern float blackout;
53 extern int difficulty;
54 extern Weapons weapons;
56 extern float fadestart;
57 extern Person player[maxplayers];
58 extern int numplayers;
60 extern bool winfreeze;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
63 extern bool showpoints;
64 extern bool immediate;
66 extern bool tilt2weird;
67 extern bool tiltweird;
69 extern bool proportionweird;
70 extern bool vertexweird[6];
71 extern GLubyte texturearray[512*512*3];
72 extern XYZ envsound[30];
73 extern float envsoundvol[30];
74 extern float envsoundlife[30];
75 extern int numenvsounds;
77 extern float bonusvalue;
78 extern float bonustotal;
79 extern float bonustime;
80 extern int tutoriallevel;
81 extern float smoketex;
82 extern int tutorialstage;
83 extern bool reversaltrain;
84 extern bool canattack;
86 extern float damagedealt;
87 extern float damagetaken;
89 extern float hostiletime;
92 extern int numflipfail;
94 extern int numswordattack;
95 extern int numknifeattack;
96 extern int numunarmedattack;
97 extern int numescaped;
98 extern int numflipped;
99 extern int numwallflipped;
100 extern int numthrowkill;
101 extern int numafterkill;
102 extern int numreversals;
103 extern int numattacks;
104 extern int maxalarmed;
105 extern int indialogue;
107 extern bool gamestarted;
109 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
110 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
112 void Person::CheckKick(){
116 float damagemult=1*power;
117 if(creature==wolftype)damagemult=2.5*power;
121 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
122 if(findDistancefast(&coords,&victim->coords)<1.2){
123 if(!victim->skeleton.free){
125 Normalise(&relative);
126 relative=coords+relative*1;
127 if(animation[victim->targetanimation].height!=lowheight){
132 gLoc[0]=victim->coords.x;
133 gLoc[1]=victim->coords.y;
134 gLoc[2]=victim->coords.z;
138 if(tutoriallevel!=1){
139 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
140 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
141 OPENAL_SetVolume(channels[heavyimpactsound], 128);
142 OPENAL_SetPaused(channels[heavyimpactsound], false);
147 Normalise(&relative);
148 for(i=0;i<victim->skeleton.num_joints;i++){
149 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
152 victim->DoDamage(100*damagemult/victim->protectionhigh);
153 if(id==0)camerashake+=.4;
157 targetanimation=backflipanim;
162 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
164 //if(victim->damage>victim->damagetolerance){
172 else if (victim->isCrouch()){
173 targetanimation=rabbitkickreversedanim;
174 currentanimation=rabbitkickreversedanim;
175 victim->currentanimation=rabbitkickreversalanim;
176 victim->targetanimation=rabbitkickreversalanim;
182 victim->oldcoords=victim->coords;
183 coords=victim->coords;
184 victim->targetrotation=targetrotation;
192 void Person::CatchFire(){
193 XYZ flatfacing,flatvelocity;
195 for(int i=0;i<10;i++){
196 howmany=abs(Random()%(skeleton.num_joints));
197 if(!skeleton.free)flatvelocity=velocity;
198 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
199 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
200 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
201 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
214 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
215 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
216 OPENAL_SetVolume(channels[firestartsound], 256);
217 OPENAL_SetPaused(channels[firestartsound], false);
222 //PlaySoundEx( firesound, samp[firesound], NULL, true);
223 PlayStreamEx( stream_firesound, samp[stream_firesound], NULL, true);
224 OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
225 OPENAL_SetVolume(channels[stream_firesound], 256);
226 OPENAL_SetPaused(channels[stream_firesound], false);
233 bool Person::isIdle(){
234 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;
238 bool Person::isSitting(){
239 if(targetanimation==sitanim)return 1;
240 if(targetanimation==sitwallanim)return 1;
244 bool Person::isSleeping(){
245 if(targetanimation==sleepanim)return 1;
246 if(targetanimation==dead1anim)return 1;
247 if(targetanimation==dead2anim)return 1;
248 if(targetanimation==dead3anim)return 1;
249 if(targetanimation==dead4anim)return 1;
253 bool Person::wasIdle(){
254 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;
257 int Person::getIdle(){
258 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
259 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)){
260 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
261 if(creature==rabbittype)return fightidleanim;
262 if(creature==wolftype)return wolfidle;
264 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
265 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
266 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
267 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
268 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
270 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
272 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
273 if(howactive==typesitting)return sitanim;
274 if(howactive==typesittingwall)return sitwallanim;
275 if(howactive==typesleeping)return sleepanim;
276 if(howactive==typedead1)return dead1anim;
277 if(howactive==typedead2)return dead2anim;
278 if(howactive==typedead3)return dead3anim;
279 if(howactive==typedead4)return dead4anim;
280 if(creature==rabbittype)return bounceidleanim;
281 if(creature==wolftype)return wolfidle;
285 bool Person::isCrouch(){
286 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
291 bool Person::wasCrouch(){
292 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
295 int Person::getCrouch(){
296 if(creature==rabbittype)return crouchanim;
297 if(creature==wolftype)return wolfcrouchanim;
301 bool Person::isRun(){
302 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
307 bool Person::wasRun(){
308 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
311 int Person::getRun(){
312 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
313 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
315 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
316 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
320 bool Person::isStop(){
321 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
326 bool Person::wasStop(){
327 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
330 int Person::getStop(){
331 if(creature==rabbittype)return stopanim;
332 if(creature==wolftype)return wolfstopanim;
337 bool Person::isLanding(){
338 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
343 bool Person::wasLanding(){
344 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
347 int Person::getLanding(){
348 if(creature==rabbittype)return landanim;
349 if(creature==wolftype)return wolflandanim;
354 bool Person::isLandhard(){
355 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
360 bool Person::wasLandhard(){
361 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
364 int Person::getLandhard(){
365 if(creature==rabbittype)return landhardanim;
366 if(creature==wolftype)return wolflandhardanim;
371 bool Person::isFlip(){
372 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
376 bool Person::wasFlip(){
377 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
381 bool Person::isWallJump(){
382 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
386 void SolidHitBonus();
387 void SolidHitBonus(){
388 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
393 else if(bonustime<1.5&&bonus==threexcombo){
398 else if(bonustime<1.5&&bonus==twoxcombo){
403 else if(bonustime<1.5&&bonus==solidhit){
415 void Person::DoBlood(float howmuch,int which){
416 static int bleedxint,bleedyint;
418 //if(howmuch&&id==0)blooddimamount=1;
419 if(bloodtoggle&&tutoriallevel!=1){
420 if(bleeding<=0&&spurt){
422 for(int i=0;i<3;i++){
426 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
429 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
431 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
432 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
434 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
435 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
438 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);
439 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);
443 for(int i=0;i<3;i++){
447 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
448 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
451 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
452 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
456 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
458 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);
460 Sprite::setLastSpriteSpecial(3);
465 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
468 int texdetailint=realtexdetail;
469 if(creature==rabbittype)
470 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){
471 bleedxint=abs(Random()%512);
472 bleedyint=abs(Random()%512);
474 if(creature==wolftype)
475 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){
476 bleedxint=abs(Random()%512);
477 bleedyint=abs(Random()%512);
481 bleedy/=realtexdetail;
482 bleedx/=realtexdetail;
483 direction=abs(Random()%2)*2-1;
487 if(bleeding>2)bleeding=2;
490 void Person::DoBloodBig(float howmuch,int which){
491 static int bleedxint,bleedyint,i,j;
493 if(howmuch&&id==0)blooddimamount=1;
495 if(tutoriallevel!=1||id==0)
496 if(aitype!=playercontrolled&&howmuch>0){
507 if(creature==wolftype){
508 int i=abs(Random()%2);
509 if(i==0)whichsound=snarlsound;
510 if(i==1)whichsound=snarl2sound;
511 envsound[numenvsounds]=coords;
512 envsoundvol[numenvsounds]=16;
513 envsoundlife[numenvsounds]=.4;
516 if(creature==rabbittype){
517 int i=abs(Random()%2);
518 if(i==0)whichsound=rabbitpainsound;
519 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
520 envsound[numenvsounds]=coords;
521 envsoundvol[numenvsounds]=16;
522 envsoundlife[numenvsounds]=.4;
524 //if(i==2)whichsound=rabbitpain2sound;
528 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
529 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
530 OPENAL_SetVolume(channels[whichsound], 512);
531 OPENAL_SetPaused(channels[whichsound], false);
535 if(id==0&&howmuch>0){
543 if(bloodtoggle&&decals&&tutoriallevel!=1){
544 if(bleeding<=0&&spurt){
546 for(int i=0;i<3;i++){
550 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
553 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
555 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
556 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
558 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
559 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
562 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);
563 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);
567 int offsetx=0,offsety=0;
570 offsetx=abs(Random()%60);
572 if(which==190||which==185){
574 offsetx=abs(Random()%100)-20;
584 if(which==220||which==215){
585 //offsety=Random()%20;
587 //offsetx=abs(Random()%80);
596 if(creature==rabbittype)
599 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
600 if(i<startx)startx=i;
601 if(j<starty)starty=j;
607 if(creature==wolftype)
610 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
611 if(i<startx)startx=i;
612 if(j<starty)starty=j;
624 if(startx<0)startx=0;
625 if(starty<0)starty=0;
626 if(endx>512-1)endx=512-1;
627 if(endy>512-1)endy=512-1;
628 if(endx<startx)endx=startx;
629 if(endy<starty)endy=starty;
631 startx/=realtexdetail;
632 starty/=realtexdetail;
636 int texdetailint=realtexdetail;
638 if(creature==rabbittype)
639 for(i=startx;i<endx;i++){
640 for(j=starty;j<endy;j++){
641 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){
642 color=Random()%85+170;
643 where=i*skeleton.skinsize*3+j*3;
644 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
645 skeleton.skinText[where+1]=0;
646 skeleton.skinText[where+2]=0;
650 if(creature==wolftype)
651 for(i=startx;i<endx;i++){
652 for(j=starty;j<endy;j++){
653 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){
654 color=Random()%85+170;
655 where=i*skeleton.skinsize*3+j*3;
656 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
657 skeleton.skinText[where+1]=0;
658 skeleton.skinText[where+2]=0;
662 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
663 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
664 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
668 if(creature==rabbittype)
669 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){
670 bleedxint=abs(Random()%512);
671 bleedyint=abs(Random()%512);
673 if(creature==wolftype)
674 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){
675 bleedxint=abs(Random()%512);
676 bleedyint=abs(Random()%512);
678 bleedy=bleedxint+offsetx;
679 bleedx=bleedyint+offsety;
680 bleedy/=realtexdetail;
681 bleedx/=realtexdetail;
682 if(bleedx<0)bleedx=0;
683 if(bleedy<0)bleedy=0;
684 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
685 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
686 direction=abs(Random()%2)*2-1;
689 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
690 deathbleeding+=bleeding;
691 bloodloss+=bleeding*3;
693 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
694 if(abs(Random()%2)==0){aitype=gethelptype;
697 else aitype=attacktypecutoff;
700 if(bleeding>2)bleeding=2;
703 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
704 static int bleedxint,bleedyint,i,j;
706 static XYZ startpoint,endpoint,colpoint,movepoint;
707 static float rotationpoint;
709 static XYZ p1,p2,p3,p0;
713 float coordsx,coordsy;
716 if(bloodtoggle&&decals&&tutoriallevel!=1){
718 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
726 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
729 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
730 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
731 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
733 CrossProduct(p2-p1,p3-p1,&N);
734 CrossProduct(p0-p1,p3-p1,&temp);
735 s = dotproduct(&temp,&N)/findLength(&N);
736 CrossProduct(p2-p1,p1-p0,&temp);
737 t = dotproduct(&temp,&N)/findLength(&N);
740 bary.x=findDistancefast(&p0,&p1);
741 bary.y=findDistancefast(&p0,&p2);
742 bary.z=findDistancefast(&p0,&p3);
744 total=bary.x+bary.y+bary.z;
753 total=bary.x+bary.y+bary.z;
759 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
760 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
761 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
762 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
763 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
764 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
765 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;
766 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;
768 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
769 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
771 if(bleeding<=0&&spurt){
773 for(int i=0;i<3;i++){
777 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
780 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
782 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
783 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
785 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
786 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
789 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);
790 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);
794 int offsetx=0,offsety=0;
797 offsetx=abs(Random()%120);
799 if(which==220||which==215){
801 offsetx=abs(Random()%80);
804 offsetx=(1+coordsy)*512-291;
805 offsety=coordsx*512-437;
812 if(creature==rabbittype)
815 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
816 if(i<startx)startx=i;
817 if(j<starty)starty=j;
823 if(creature==wolftype)
826 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
827 if(i<startx)startx=i;
828 if(j<starty)starty=j;
839 if(startx<0)startx=0;
840 if(starty<0)starty=0;
841 if(endx>512-1)endx=512-1;
842 if(endy>512-1)endy=512-1;
843 if(endx<startx)endx=startx;
844 if(endy<starty)endy=starty;
846 startx/=realtexdetail;
847 starty/=realtexdetail;
851 int texdetailint=realtexdetail;
853 if(creature==rabbittype)
854 for(i=startx;i<endx;i++){
855 for(j=starty;j<endy;j++){
856 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){
857 color=Random()%85+170;
858 where=i*skeleton.skinsize*3+j*3;
859 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
860 skeleton.skinText[where+1]=0;
861 skeleton.skinText[where+2]=0;
863 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){
864 color=Random()%85+170;
865 where=i*skeleton.skinsize*3+j*3;
866 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
867 skeleton.skinText[where+1]=0;
868 skeleton.skinText[where+2]=0;
872 if(creature==wolftype)
873 for(i=startx;i<endx;i++){
874 for(j=starty;j<endy;j++){
875 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){
876 color=Random()%85+170;
877 where=i*skeleton.skinsize*3+j*3;
878 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
879 skeleton.skinText[where+1]=0;
880 skeleton.skinText[where+2]=0;
882 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){
883 color=Random()%85+170;
884 where=i*skeleton.skinsize*3+j*3;
885 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
886 skeleton.skinText[where+1]=0;
887 skeleton.skinText[where+2]=0;
891 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
892 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
893 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
895 bleedy=(1+coordsy)*512;
897 bleedy/=realtexdetail;
898 bleedx/=realtexdetail;
899 if(bleedx<0)bleedx=0;
900 if(bleedy<0)bleedy=0;
901 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
902 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
903 direction=abs(Random()%2)*2-1;
905 if(whichtri==-1)return 0;
907 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
908 deathbleeding+=bleeding;
909 bloodloss+=bleeding*3;
911 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
912 if(abs(Random()%2)==0){aitype=gethelptype;
915 else aitype=attacktypecutoff;
918 if(bleeding>2)bleeding=2;
923 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
926 static int bytesPerPixel=3;
927 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
928 static int newstartx,newstarty,newendx,newendy;
929 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
931 static float sizemult;
933 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
934 texture[i]=skeleton.skinText[i];
937 if((!osx||howmanylevels)){
939 if(startx<0)startx=0;
940 if(starty<0)starty=0;
941 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
942 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
943 if((endx>startx&&endy>starty)||howmanylevels){
950 for(i=startx;i<endx;i++){
951 for(j=starty;j<endy;j++){
952 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
953 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
954 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
958 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
961 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
962 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
963 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
966 newsize=skeleton.skinsize;
969 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
971 /*for(j=1;j<=howmanylevels;j++){
972 if(j==1)texpointer=&skeleton.skinText[0];
973 else texpointer=&texture[0];
975 totalsize=int( newsize*newsize*bytesPerPixel);
976 rowsize=int( newsize*bytesPerPixel );
977 bigstep=bytesPerPixel*newsize*2;
978 smallstep=bytesPerPixel*2;
984 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
991 void Person::Reverse(){
992 if(victim->aitype==playercontrolled||hostiletime>1)
993 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
994 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
995 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
996 if(targetanimation==sweepanim){
997 targetanimation=sweepreversedanim;
998 currentanimation=sweepreversedanim;
999 victim->currentanimation=sweepreversalanim;
1000 victim->targetanimation=sweepreversalanim;
1002 if(targetanimation==spinkickanim){
1003 targetanimation=spinkickreversedanim;
1004 currentanimation=spinkickreversedanim;
1005 victim->currentanimation=spinkickreversalanim;
1006 victim->targetanimation=spinkickreversalanim;
1008 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
1009 if(targetanimation==rabbittacklinganim){
1012 victim->currentframe=6;
1013 victim->targetframe=7;
1015 targetanimation=upunchreversedanim;
1016 currentanimation=upunchreversedanim;
1017 victim->currentanimation=upunchreversalanim;
1018 victim->targetanimation=upunchreversalanim;
1020 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1021 if(victim->weaponactive!=-1){
1022 victim->throwtogglekeydown=1;
1023 weapons.owner[victim->weaponids[0]]=-1;
1024 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1025 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1026 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1027 weapons.missed[victim->weaponids[0]]=1;
1028 weapons.freetime[victim->weaponids[0]]=0;
1029 weapons.firstfree[victim->weaponids[0]]=1;
1030 weapons.physics[victim->weaponids[0]]=1;
1031 victim->num_weapons--;
1032 if(victim->num_weapons){
1033 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1034 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1037 victim->weaponactive=-1;
1038 for(int j=0;j<numplayers;j++){
1039 player[j].wentforweapon=0;
1043 targetanimation=staffhitreversedanim;
1044 currentanimation=staffhitreversedanim;
1045 victim->currentanimation=staffhitreversalanim;
1046 victim->targetanimation=staffhitreversalanim;
1048 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1049 if(victim->weaponactive!=-1){
1050 victim->throwtogglekeydown=1;
1051 weapons.owner[victim->weaponids[0]]=-1;
1052 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1053 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1054 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1055 weapons.missed[victim->weaponids[0]]=1;
1056 weapons.freetime[victim->weaponids[0]]=0;
1057 weapons.firstfree[victim->weaponids[0]]=1;
1058 weapons.physics[victim->weaponids[0]]=1;
1059 victim->num_weapons--;
1060 if(victim->num_weapons){
1061 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1062 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1065 victim->weaponactive=-1;
1066 for(int j=0;j<numplayers;j++){
1067 player[j].wentforweapon=0;
1070 targetanimation=staffspinhitreversedanim;
1071 currentanimation=staffspinhitreversedanim;
1072 victim->currentanimation=staffspinhitreversalanim;
1073 victim->targetanimation=staffspinhitreversalanim;
1075 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1076 if(victim->weaponactive!=-1){
1077 victim->throwtogglekeydown=1;
1078 weapons.owner[victim->weaponids[0]]=-1;
1079 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1080 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1081 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1082 weapons.missed[victim->weaponids[0]]=1;
1083 weapons.freetime[victim->weaponids[0]]=0;
1084 weapons.firstfree[victim->weaponids[0]]=1;
1085 weapons.physics[victim->weaponids[0]]=1;
1086 victim->num_weapons--;
1087 if(victim->num_weapons){
1088 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1089 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1092 victim->weaponactive=-1;
1093 for(int j=0;j<numplayers;j++){
1094 player[j].wentforweapon=0;
1097 targetanimation=swordslashreversedanim;
1098 currentanimation=swordslashreversedanim;
1099 victim->currentanimation=swordslashreversalanim;
1100 victim->targetanimation=swordslashreversalanim;
1102 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1103 if(victim->weaponactive!=-1){
1104 victim->throwtogglekeydown=1;
1105 weapons.owner[victim->weaponids[0]]=-1;
1106 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1107 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1108 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1109 weapons.missed[victim->weaponids[0]]=1;
1110 weapons.freetime[victim->weaponids[0]]=0;
1111 weapons.firstfree[victim->weaponids[0]]=1;
1112 weapons.physics[victim->weaponids[0]]=1;
1113 victim->num_weapons--;
1114 if(victim->num_weapons){
1115 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1116 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1119 victim->weaponactive=-1;
1120 for(int j=0;j<numplayers;j++){
1121 player[j].wentforweapon=0;
1124 targetanimation=knifeslashreversedanim;
1125 currentanimation=knifeslashreversedanim;
1126 victim->currentanimation=knifeslashreversalanim;
1127 victim->targetanimation=knifeslashreversalanim;
1129 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1130 victim->targettilt2=targettilt2;
1131 victim->currentframe=currentframe;
1132 victim->targetframe=targetframe;
1133 victim->target=target;
1135 victim->oldcoords=victim->coords;
1136 victim->coords=coords;
1137 victim->targetrotation=targetrotation;
1138 victim->rotation=targetrotation;
1139 victim->victim=this;
1141 if(targetanimation==winduppunchanim){
1142 targetanimation=winduppunchblockedanim;
1143 victim->targetanimation=blockhighleftanim;
1144 victim->targetframe=1;
1146 victim->victim=this;
1147 victim->targetrotation=targetrotation+180;
1149 if(targetanimation==wolfslapanim){
1150 targetanimation=winduppunchblockedanim;
1151 victim->targetanimation=blockhighleftanim;
1152 victim->targetframe=1;
1154 victim->victim=this;
1155 victim->targetrotation=targetrotation+180;
1157 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1158 targetanimation=swordslashparriedanim;
1160 victim->parriedrecently=0;
1161 victim->targetanimation=swordslashparryanim;
1162 victim->targetframe=1;
1164 victim->victim=this;
1165 victim->targetrotation=targetrotation+180;
1167 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1170 gLoc[0]=victim->coords.x;
1171 gLoc[1]=victim->coords.y;
1172 gLoc[2]=victim->coords.z;
1176 if(victim->weaponactive!=-1){
1177 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1178 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1179 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1181 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1182 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1183 OPENAL_SetVolume(channels[swordstaffsound], 512);
1184 OPENAL_SetPaused(channels[swordstaffsound], false);
1187 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1188 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1189 OPENAL_SetVolume(channels[metalhitsound], 512);
1190 OPENAL_SetPaused(channels[metalhitsound], false);
1194 victim->Puff(righthand);
1196 victim->targetframe=0;
1197 victim->targetanimation=staggerbackhighanim;
1198 victim->targetrotation=targetrotation+180;
1200 weapons.owner[victim->weaponids[0]]=-1;
1201 aim=DoRotation(facing,0,90,0)*21;
1203 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1204 weapons.tipvelocity[victim->weaponids[0]]=aim;
1205 weapons.missed[victim->weaponids[0]]=1;
1206 weapons.hitsomething[victim->weaponids[0]]=0;
1207 weapons.freetime[victim->weaponids[0]]=0;
1208 weapons.firstfree[victim->weaponids[0]]=1;
1209 weapons.physics[victim->weaponids[0]]=1;
1210 victim->num_weapons--;
1211 if(victim->num_weapons){
1212 victim->weaponids[0]=victim->weaponids[num_weapons];
1213 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1215 victim->weaponactive=-1;
1216 for(int i=0;i<numplayers;i++){
1217 player[i].wentforweapon=0;
1224 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1225 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1226 OPENAL_SetVolume(channels[metalhitsound], 512);
1227 OPENAL_SetPaused(channels[metalhitsound], false);*/
1230 if(abs(Random()%20)==0){
1239 if(weaponactive!=-1){
1240 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1241 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1242 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1244 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1245 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1246 OPENAL_SetVolume(channels[swordstaffsound], 512);
1247 OPENAL_SetPaused(channels[swordstaffsound], false);
1250 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1251 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1252 OPENAL_SetVolume(channels[metalhitsound], 512);
1253 OPENAL_SetPaused(channels[metalhitsound], false);
1261 targetanimation=staggerbackhighanim;
1262 targetrotation=targetrotation+180;
1264 weapons.owner[weaponids[0]]=-1;
1265 aim=DoRotation(facing,0,90,0)*21;
1267 weapons.velocity[weaponids[0]]=aim*-.2;
1268 weapons.tipvelocity[weaponids[0]]=aim;
1269 weapons.hitsomething[weaponids[0]]=0;
1270 weapons.missed[weaponids[0]]=1;
1271 weapons.freetime[weaponids[0]]=0;
1272 weapons.firstfree[weaponids[0]]=1;
1273 weapons.physics[weaponids[0]]=1;
1276 weaponids[0]=weaponids[num_weapons];
1277 if(weaponstuck==num_weapons)weaponstuck=0;
1280 for(int i=0;i<numplayers;i++){
1281 player[i].wentforweapon=0;
1285 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1286 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1287 OPENAL_SetVolume(channels[metalhitsound], 512);
1288 OPENAL_SetPaused(channels[metalhitsound], false);*/
1292 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1293 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1294 //victim->targetanimation=sweepanim;
1295 victim->targetanimation=dodgebackanim;
1296 victim->targetframe=0;
1298 //victim->velocity=0;
1301 rotatetarget=coords-victim->coords;
1302 Normalise(&rotatetarget);
1303 victim->targetrotation=-asin(0-rotatetarget.x);
1304 victim->targetrotation*=360/6.28;
1305 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1307 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1309 victim->lastattack3=victim->lastattack2;
1310 victim->lastattack2=victim->lastattack;
1311 victim->lastattack=victim->targetanimation;
1315 victim->targetanimation=sweepanim;
1316 victim->targetframe=0;
1320 rotatetarget=coords-victim->coords;
1321 Normalise(&rotatetarget);
1322 victim->targetrotation=-asin(0-rotatetarget.x);
1323 victim->targetrotation*=360/6.28;
1324 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1326 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1328 victim->lastattack3=victim->lastattack2;
1329 victim->lastattack2=victim->lastattack;
1330 victim->lastattack=victim->targetanimation;
1337 if(aitype!=playercontrolled)feint=0;
1338 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1339 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1340 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1342 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1346 void Person::DoDamage(float howmuch){
1347 if(tutoriallevel!=1)damage+=howmuch/power;
1348 if(id!=0)damagedealt+=howmuch/power;
1349 if(id==0)damagetaken+=howmuch/power;
1351 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1352 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1353 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1354 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1355 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1357 if(id==0)camerashake+=howmuch/100;
1358 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1359 if(blackout>1)blackout=1;
1361 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1362 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1363 if(abs(Random()%2)==0){aitype=gethelptype;
1366 else aitype=attacktypecutoff;
1370 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1373 for(int i=0;i<skeleton.num_joints; i++){
1374 if(!skeleton.free)flatvelocity2=velocity;
1375 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1376 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1377 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1378 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1379 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1380 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1381 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1382 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1383 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1394 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1395 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1396 OPENAL_SetVolume(channels[splattersound], 256);
1397 OPENAL_SetPaused(channels[splattersound], false);
1406 if(!dead&&creature==wolftype){
1415 if(tutoriallevel!=1||id==0)
1416 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1427 if(creature==wolftype){
1428 int i=abs(Random()%2);
1429 if(i==0)whichsound=snarlsound;
1430 if(i==1)whichsound=snarl2sound;
1431 envsound[numenvsounds]=coords;
1432 envsoundvol[numenvsounds]=16;
1433 envsoundlife[numenvsounds]=.4;
1436 if(creature==rabbittype){
1437 int i=abs(Random()%2);
1438 if(i==0)whichsound=rabbitpainsound;
1439 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1440 envsound[numenvsounds]=coords;
1441 envsoundvol[numenvsounds]=16;
1442 envsoundlife[numenvsounds]=.4;
1444 //if(i==2)whichsound=rabbitpain2sound;
1448 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1449 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1450 OPENAL_SetVolume(channels[whichsound], 512);
1451 OPENAL_SetPaused(channels[whichsound], false);
1456 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1457 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1460 void Person::DoHead(){
1461 static XYZ rotatearound;
1463 static float lookspeed=500;
1465 if(!freeze&&!winfreeze){
1468 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1469 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1471 while(targetheadrotation>180)targetheadrotation-=360;
1472 while(targetheadrotation<-180)targetheadrotation+=360;
1474 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1475 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1476 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1477 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1479 if(targetheadrotation2>120)targetheadrotation2=120;
1480 if(targetheadrotation2<-120)targetheadrotation2=-120;
1481 if(targetheadrotation>120)targetheadrotation=120;
1482 if(targetheadrotation<-120)targetheadrotation=-120;
1484 if(!isIdle())targetheadrotation2=0;
1486 if(targetheadrotation>80)targetheadrotation=80;
1487 if(targetheadrotation<-80)targetheadrotation=-80;
1488 if(targetheadrotation2>50)targetheadrotation2=50;
1489 if(targetheadrotation2<-50)targetheadrotation2=-50;
1492 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1493 else if(headrotation>targetheadrotation){
1494 headrotation-=multiplier*lookspeed;
1496 else if(headrotation<targetheadrotation){
1497 headrotation+=multiplier*lookspeed;
1500 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1501 else if(headrotation2>targetheadrotation2){
1502 headrotation2-=multiplier*lookspeed/2;
1504 else if(headrotation2<targetheadrotation2){
1505 headrotation2+=multiplier*lookspeed/2;
1508 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1509 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1513 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1514 facing=DoRotation(facing,headrotation2*.4,0,0);
1515 facing=DoRotation(facing,0,headrotation*.4,0);
1518 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1519 facing=DoRotation(facing,headrotation2*.8,0,0);
1520 facing=DoRotation(facing,0,headrotation*.8,0);
1523 if(targetanimation==walkanim){
1524 facing=DoRotation(facing,headrotation2*.6,0,0);
1525 facing=DoRotation(facing,0,headrotation*.6,0);
1528 skeleton.specialforward[0]=facing;
1529 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1531 for(i=0;i<skeleton.num_muscles;i++){
1532 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1534 skeleton.FindRotationMuscle(i,targetanimation);
1540 void Person::RagDoll(bool checkcollision){
1545 if(id==0)numfalls++;
1546 if(id==0&&isFlip())numflipfail++;
1552 facing=DoRotation(facing,0,rotation,0);
1554 skeleton.freetime=0;
1556 skeleton.longdead=0;
1562 skeleton.freefall=1;
1564 if(!isnormal(velocity.x))velocity.x=0;
1565 if(!isnormal(velocity.y))velocity.y=0;
1566 if(!isnormal(velocity.z))velocity.z=0;
1567 if(!isnormal(rotation))rotation=0;
1568 if(!isnormal(coords.x))coords=0;
1569 if(!isnormal(tilt))tilt=0;
1570 if(!isnormal(tilt2))tilt2=0;
1572 for(i=0;i<skeleton.num_joints;i++){
1573 skeleton.joints[i].delay=0;
1574 skeleton.joints[i].locked=0;
1575 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1576 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1577 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1578 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1579 skeleton.joints[i].position.y+=.1;
1580 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1581 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1584 for(i=0;i<skeleton.num_joints;i++){
1585 skeleton.joints[i].velocity=0;
1586 skeleton.joints[i].velchange=0;
1588 skeleton.DoConstraints(&coords,&scale);
1589 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1591 skeleton.DoConstraints(&coords,&scale);
1592 skeleton.DoConstraints(&coords,&scale);
1593 skeleton.DoConstraints(&coords,&scale);
1594 skeleton.DoConstraints(&coords,&scale);
1597 speed=animation[targetanimation].speed[targetframe]*2;
1598 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1599 speed=animation[currentanimation].speed[currentframe]*2;
1601 if(transspeed)speed=transspeed*2;
1605 for(i=0;i<skeleton.num_joints;i++){
1606 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);
1607 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1608 change.x=(float)(Random()%100)/100;
1609 change.y=(float)(Random()%100)/100;
1610 change.z=(float)(Random()%100)/100;
1611 skeleton.joints[i].velocity+=change;
1612 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1614 change.x=(float)(Random()%100)/100;
1615 change.y=(float)(Random()%100)/100;
1616 change.z=(float)(Random()%100)/100;
1617 skeleton.joints[i].velchange+=change;
1618 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1628 for(j=0;j<skeleton.num_joints;j++){
1629 average+=skeleton.joints[j].position;
1633 coords+=average*scale;
1634 for(j=0;j<skeleton.num_joints;j++){
1635 skeleton.joints[j].position-=average;
1638 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1639 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1640 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1641 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1642 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1645 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1646 coords.x=lowpoint.x;
1647 coords.z=lowpoint.z;
1656 for(i=0;i<skeleton.num_joints;i++){
1657 velocity+=skeleton.joints[i].velocity*scale;
1659 velocity/=skeleton.num_joints;
1662 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1663 weapons.owner[weaponids[0]]=-1;
1664 weapons.hitsomething[weaponids[0]]=0;
1665 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1666 weapons.velocity[weaponids[0]].x+=.01;
1667 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1668 weapons.missed[weaponids[0]]=1;
1669 weapons.freetime[weaponids[0]]=0;
1670 weapons.firstfree[weaponids[0]]=1;
1671 weapons.physics[weaponids[0]]=1;
1674 weaponids[0]=weaponids[num_weapons];
1675 if(weaponstuck==num_weapons)weaponstuck=0;
1678 for(i=0;i<numplayers;i++){
1679 player[i].wentforweapon=0;
1684 targetanimation=bounceidleanim;
1685 currentanimation=bounceidleanim;
1693 void Person::FootLand(int which, float opacity){
1694 static XYZ terrainlight;
1695 static XYZ footvel,footpoint;
1696 if(opacity>=1||skiddelay<=0)
1700 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1701 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1702 //footpoint.y=coords.y;
1703 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1705 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1707 if(footvel.y<.8)footvel.y=.8;
1708 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1709 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1710 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1711 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1712 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1713 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1715 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1717 if(footvel.y<.8)footvel.y=.8;
1718 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1719 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1720 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1721 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1722 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);
1724 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1726 if(footvel.y<.8)footvel.y=.8;
1727 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1728 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1729 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1730 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1731 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);
1732 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1734 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1737 if(footvel.y<.8)footvel.y=.8;
1738 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1739 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1740 //footpoint.y=coords.y;
1741 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1745 void Person::Puff(int whichlabel){
1746 static XYZ footvel,footpoint;
1749 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1750 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1754 void Person::DoAnimations(){
1757 static float oldtarget;
1759 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1761 if(targetanimation==tempanim||currentanimation==tempanim){
1762 animation[tempanim]=tempanimation;
1764 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1775 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1776 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1778 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1779 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1781 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1786 targfacing=DoRotation(targfacing,0,targetrotation,0);
1788 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1789 else targetanimation=backflipanim;
1790 crouchtogglekeydown=1;
1794 if(id==0)numflipped++;
1797 if(animation[targetanimation].attack!=reversed)feint=0;
1798 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1799 crouchtogglekeydown=0;
1800 if(aitype==playercontrolled)feint=0;
1804 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1805 if(!isFlip())crouchtogglekeydown=1;
1809 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1810 if(detail)normalsupdatedelay=0;
1814 if(targetanimation==rollanim&&targetframe==3&&onfire){
1824 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1825 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1826 OPENAL_SetVolume(channels[fireendsound], 256);
1827 OPENAL_SetPaused(channels[fireendsound], false);
1828 OPENAL_SetPaused(channels[stream_firesound], true);
1832 if(targetanimation==rabbittacklinganim&&targetframe==1){
1833 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1834 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1835 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1836 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1837 else victim->targetanimation=rabbittackledfrontanim;
1838 victim->targetframe=2;
1840 victim->rotation=rotation;
1841 victim->targetrotation=rotation;
1842 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1843 //victim->DoDamage(30);
1844 if(creature==wolftype){
1848 gLoc[0]=victim->coords.x;
1849 gLoc[1]=victim->coords.y;
1850 gLoc[2]=victim->coords.z;
1854 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
1855 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
1856 OPENAL_SetVolume(channels[clawslicesound], 128);
1857 OPENAL_SetPaused(channels[clawslicesound], false);
1859 victim->DoBloodBig(1/victim->armorhead,210);
1865 if(victim->aitype==gethelptype)bonusvalue=50;
1870 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1871 if(weapons.type[weaponids[0]]==knife){
1872 if(weaponactive==-1)weaponactive=0;
1873 else if(weaponactive==0)weaponactive=-1;
1875 if(weaponactive==-1){
1885 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
1886 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
1887 OPENAL_SetVolume(channels[knifesheathesound], 128);
1888 OPENAL_SetPaused(channels[knifesheathesound], false);
1890 if(weaponactive!=-1){
1900 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1901 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1902 OPENAL_SetVolume(channels[knifedrawsound], 128);
1903 OPENAL_SetPaused(channels[knifedrawsound], false);
1906 drawtogglekeydown=1;
1909 if(tutoriallevel!=1||id==0)
1910 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1921 if(terrain.getOpacity(coords.x,coords.z)<.2){
1922 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1923 else whichsound=footstepsound2;
1924 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1925 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1926 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1932 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1933 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1934 else whichsound=footstepsound4;
1938 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1939 else whichsound=footstepsound4;
1941 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1942 if(animation[targetanimation].attack!=neutral){
1944 if(i==0)whichsound=lowwhooshsound;
1945 if(i==1)whichsound=midwhooshsound;
1946 if(i==2)whichsound=highwhooshsound;
1948 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1950 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1951 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1953 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1954 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1955 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
1956 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
1957 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
1958 OPENAL_SetPaused(channels[whichsound], false);
1961 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1962 envsound[numenvsounds]=coords;
1963 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1964 else envsoundvol[numenvsounds]=6;
1965 envsoundlife[numenvsounds]=.4;
1969 if(animation[targetanimation].label[targetframe]==3){
1971 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1972 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1973 OPENAL_SetVolume(channels[whichsound], 128);
1974 OPENAL_SetPaused(channels[whichsound], false);
1979 if(tutoriallevel!=1||id==0)
1981 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1982 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1992 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1993 if(animation[targetanimation].attack!=neutral){
1995 if(creature==rabbittype){
1996 if(i==0)whichsound=rabbitattacksound;
1997 if(i==1)whichsound=rabbitattack2sound;
1998 if(i==2)whichsound=rabbitattack3sound;
1999 if(i==3)whichsound=rabbitattack4sound;
2001 if(creature==wolftype){
2002 if(i==0)whichsound=barksound;
2003 if(i==1)whichsound=bark2sound;
2004 if(i==2)whichsound=bark3sound;
2005 if(i==3)whichsound=barkgrowlsound;
2009 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2011 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2012 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
2015 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2016 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2017 OPENAL_SetVolume(channels[whichsound], 512);
2018 OPENAL_SetPaused(channels[whichsound], false);
2024 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
2030 currentoffset=targetoffset;
2031 targetframe=currentframe;
2032 currentanimation=targetanimation;
2035 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
2036 for(i=0;i<weapons.numweapons;i++){
2037 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
2038 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
2039 if(findDistancefast(&coords,&weapons.position[i])>=1){
2040 if(weapons.type[i]!=staff){
2049 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2050 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2051 OPENAL_SetVolume(channels[knifedrawsound], 128);
2052 OPENAL_SetPaused(channels[knifedrawsound], false);
2056 weapons.owner[i]=id;
2058 weaponids[num_weapons]=weaponids[0];
2067 static bool willwork;
2068 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2069 for(i=0;i<weapons.numweapons;i++){
2071 if(weapons.owner[i]!=-1)
2072 if(player[weapons.owner[i]].weaponstuck!=-1)
2073 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2074 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2075 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))
2076 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2077 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2087 if(weapons.owner[i]!=-1)
2088 if(victim->weaponstuck!=-1){
2089 if(victim->weaponids[victim->weaponstuck]==i){
2094 if(weapons.type[i]!=staff){
2095 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2096 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2097 OPENAL_SetVolume(channels[knifedrawsound], 128);
2098 OPENAL_SetPaused(channels[knifedrawsound], false);
2102 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2103 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2104 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2105 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2108 if(weapons.owner[i]!=-1){
2110 victim=&player[weapons.owner[i]];
2111 if(victim->num_weapons==1)victim->num_weapons=0;
2112 else victim->num_weapons=1;
2114 //victim->weaponactive=-1;
2115 victim->skeleton.longdead=0;
2116 victim->skeleton.free=1;
2117 victim->skeleton.broken=0;
2119 for(int j=0;j<victim->skeleton.num_joints;j++){
2120 victim->skeleton.joints[j].velchange=0;
2121 victim->skeleton.joints[j].locked=0;
2127 Normalise(&relative);
2128 XYZ footvel,footpoint;
2130 footpoint=weapons.position[i];
2131 if(victim->weaponstuck!=-1){
2132 if(victim->weaponids[victim->weaponstuck]==i){
2133 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2134 weapons.bloody[i]=2;
2135 weapons.blooddrip[i]=5;
2136 victim->weaponstuck=-1;
2139 if(victim->num_weapons>0){
2140 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2141 if(victim->weaponids[0]==i)
2142 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2145 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2146 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2147 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2148 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2150 weapons.owner[i]=id;
2152 weaponids[num_weapons]=weaponids[0];
2161 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2162 if(weaponactive==-1)weaponactive=0;
2163 else if(weaponactive==0){
2167 buffer=weaponids[0];
2168 weaponids[0]=weaponids[1];
2169 weaponids[1]=buffer;
2172 if(weaponactive==-1){
2182 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2183 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2184 OPENAL_SetVolume(channels[knifesheathesound], 128);
2185 OPENAL_SetPaused(channels[knifesheathesound], false);
2187 if(weaponactive!=-1){
2197 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2198 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2199 OPENAL_SetVolume(channels[knifedrawsound], 128);
2200 OPENAL_SetPaused(channels[knifedrawsound], false);
2205 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2206 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2207 Normalise(&rotatetarget);
2208 targetrotation=-asin(0-rotatetarget.x);
2209 targetrotation*=360/6.28;
2210 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2212 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2213 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2218 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2220 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;
2222 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2223 targetanimation=rabbittackleanim;
2234 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2235 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2236 OPENAL_SetVolume(channels[jumpsound], 128);
2237 OPENAL_SetPaused(channels[jumpsound], false);
2246 Normalise(&targetloc);
2248 for(i=0;i<numplayers;i++){
2250 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2251 closestdist=findDistancefast(&targetloc,&player[i].coords);
2256 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2258 victim=&player[closestid];
2259 coords=victim->coords;
2260 currentanimation=rabbittacklinganim;
2261 targetanimation=rabbittacklinganim;
2265 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2266 rotatetarget=coords-victim->coords;
2267 Normalise(&rotatetarget);
2268 targetrotation=-asin(0-rotatetarget.x);
2269 targetrotation*=360/6.28;
2270 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2272 if(targetanimation!=rabbitrunninganim){
2282 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2283 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2284 OPENAL_SetVolume(channels[jumpsound], 128);
2285 OPENAL_SetPaused(channels[jumpsound], false);
2291 float damagemult=1*power;
2292 if(creature==wolftype)damagemult=2.5*power;
2293 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2294 //if(onfire)damagemult=3;
2295 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2296 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2297 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2299 if(id==0)camerashake+=.4;
2300 if(Random()%2||creature==wolftype){
2303 if(creature==wolftype)DoBloodBig(0,250);
2307 gLoc[0]=victim->coords.x;
2308 gLoc[1]=victim->coords.y;
2309 gLoc[2]=victim->coords.z;
2313 if(tutoriallevel!=1){
2314 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2315 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2316 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2317 OPENAL_SetPaused(channels[heavyimpactsound], false);
2319 if(creature==wolftype){
2320 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2321 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2322 OPENAL_SetVolume(channels[clawslicesound], 128);
2323 OPENAL_SetPaused(channels[clawslicesound], false);
2325 victim->DoBloodBig(2/victim->armorhead,175);
2329 relative=victim->coords-coords;
2331 Normalise(&relative);
2332 relative=DoRotation(relative,0,-90,0);
2333 for(i=0;i<victim->skeleton.num_joints;i++){
2334 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2336 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2339 victim->DoDamage(damagemult*100/victim->protectionhead);
2347 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2348 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2350 if(id==0)camerashake+=.4;
2351 if(Random()%2||creature==wolftype){
2353 if(creature==wolftype)DoBloodBig(0,235);
2357 gLoc[0]=victim->coords.x;
2358 gLoc[1]=victim->coords.y;
2359 gLoc[2]=victim->coords.z;
2363 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2364 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2365 OPENAL_SetVolume(channels[whooshhitsound], 512);
2366 OPENAL_SetPaused(channels[whooshhitsound], false);
2367 if(creature==wolftype){
2368 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2369 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2370 OPENAL_SetVolume(channels[clawslicesound], 128);
2371 OPENAL_SetPaused(channels[clawslicesound], false);
2373 victim->DoBloodBig(2,175);
2377 relative=victim->coords-coords;
2379 Normalise(&relative);
2381 Normalise(&relative);
2382 relative=DoRotation(relative,0,90,0);
2383 for(i=0;i<victim->skeleton.num_joints;i++){
2384 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2386 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2389 victim->DoDamage(damagemult*50/victim->protectionhead);
2393 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2394 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2396 if(id==0)camerashake+=.4;
2401 gLoc[0]=victim->coords.x;
2402 gLoc[1]=victim->coords.y;
2403 gLoc[2]=victim->coords.z;
2407 if(tutoriallevel!=1){
2408 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2409 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2410 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2411 OPENAL_SetPaused(channels[heavyimpactsound], false);
2413 if(creature==wolftype){
2414 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2415 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2416 OPENAL_SetVolume(channels[clawslicesound], 128);
2417 OPENAL_SetPaused(channels[clawslicesound], false);
2419 victim->DoBloodBig(2/victim->armorhead,175);
2425 Normalise(&relative);
2426 relative=DoRotation(relative,0,-90,0);
2427 for(i=0;i<victim->skeleton.num_joints;i++){
2428 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2430 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2433 victim->DoDamage(damagemult*150/victim->protectionhead);
2435 if(victim->damage>victim->damagetolerance){
2448 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2449 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2451 if(id==0)camerashake+=.4;
2456 gLoc[0]=victim->coords.x;
2457 gLoc[1]=victim->coords.y;
2458 gLoc[2]=victim->coords.z;
2462 if(tutoriallevel!=1){
2463 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2464 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2465 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2466 OPENAL_SetPaused(channels[heavyimpactsound], false);
2468 if(creature==wolftype){
2469 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2470 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2471 OPENAL_SetVolume(channels[clawslicesound], 128);
2472 OPENAL_SetPaused(channels[clawslicesound], false);
2474 victim->DoBloodBig(2/victim->armorhead,175);
2480 Normalise(&relative);
2481 relative=DoRotation(relative,0,90,0);
2482 for(i=0;i<victim->skeleton.num_joints;i++){
2483 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2485 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2488 victim->DoDamage(damagemult*150/victim->protectionhead);
2490 if(victim->damage>victim->damagetolerance){
2503 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2504 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2506 if(id==0)camerashake+=.4;
2513 gLoc[0]=victim->coords.x;
2514 gLoc[1]=victim->coords.y;
2515 gLoc[2]=victim->coords.z;
2519 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2520 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2521 OPENAL_SetVolume(channels[whooshhitsound], 512);
2522 OPENAL_SetPaused(channels[whooshhitsound], false);
2525 relative=victim->coords-coords;
2527 Normalise(&relative);
2528 for(i=0;i<victim->skeleton.num_joints;i++){
2529 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2531 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2534 victim->DoDamage(damagemult*50/victim->protectionhead);
2538 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2539 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2541 if(id==0)camerashake+=.2;
2544 gLoc[0]=victim->coords.x;
2545 gLoc[1]=victim->coords.y;
2546 gLoc[2]=victim->coords.z;
2550 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2551 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2552 OPENAL_SetVolume(channels[landsound2], 128);
2553 OPENAL_SetPaused(channels[landsound2], false);
2555 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2556 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2557 OPENAL_SetVolume(channels[movewhooshsound], 128);
2558 OPENAL_SetPaused(channels[movewhooshsound], false);
2560 victim->skeleton.longdead=0;
2561 victim->skeleton.free=1;
2562 victim->skeleton.broken=0;
2563 victim->skeleton.spinny=1;
2565 for(i=0;i<victim->skeleton.num_joints;i++){
2566 victim->skeleton.joints[i].velchange=0;
2567 victim->skeleton.joints[i].delay=0;
2568 victim->skeleton.joints[i].locked=0;
2569 //victim->skeleton.joints[i].velocity=0;
2575 Normalise(&relative);
2576 for(i=0;i<victim->skeleton.num_joints;i++){
2577 victim->skeleton.joints[i].velocity.y=relative.y*10;
2578 victim->skeleton.joints[i].position.y+=relative.y*.3;
2579 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2580 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2582 victim->Puff(abdomen);
2583 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2587 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2588 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2590 if(id==0)camerashake+=.4;
2599 if(tutoriallevel!=1){
2600 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2601 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2602 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2603 OPENAL_SetPaused(channels[heavyimpactsound], false);
2606 relative=victim->coords-coords;
2608 Normalise(&relative);
2609 for(i=0;i<victim->skeleton.num_joints;i++){
2610 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2612 victim->Puff(abdomen);
2613 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2617 victim->DoDamage(damagemult*500/victim->protectionhigh);
2618 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2622 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2623 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2625 if(id==0)camerashake+=.4;
2634 if(tutoriallevel!=1){
2635 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2636 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2637 OPENAL_SetVolume(channels[thudsound], 400);
2638 OPENAL_SetPaused(channels[thudsound], false);
2641 victim->skeleton.longdead=0;
2642 victim->skeleton.free=1;
2643 victim->skeleton.broken=0;
2644 victim->skeleton.spinny=1;
2646 for(i=0;i<victim->skeleton.num_joints;i++){
2647 victim->skeleton.joints[i].velchange=0;
2648 //victim->skeleton.joints[i].delay=0;
2649 victim->skeleton.joints[i].locked=0;
2652 relative=victim->coords-coords;
2653 Normalise(&relative);
2655 Normalise(&relative);
2656 for(i=0;i<victim->skeleton.num_joints;i++){
2657 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2659 if(id==0&&!victim->dead){
2663 victim->Puff(abdomen);
2664 victim->DoDamage(damagemult*20/victim->protectionhigh);
2665 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2667 if(!victim->dead)staggerdelay=1.2;
2673 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2674 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2675 //if(id==0)camerashake+=.4;
2686 if(!victim->skeleton.free)hasvictim=0;
2689 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2690 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2691 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2692 OPENAL_SetVolume(channels[knifesheathesound], 128);
2693 OPENAL_SetPaused(channels[knifesheathesound], false);
2696 if(victim&&hasvictim){
2697 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2699 XYZ where,startpoint,endpoint,movepoint,colpoint;
2700 float rotationpoint;
2702 if(weapons.type[weaponids[weaponactive]]==knife){
2703 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2704 where-=victim->coords;
2705 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2712 if(weapons.type[weaponids[weaponactive]]==sword){
2713 where=weapons.position[weaponids[weaponactive]];
2714 where-=victim->coords;
2715 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2717 where=weapons.tippoint[weaponids[weaponactive]];
2718 where-=victim->coords;
2719 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2722 if(weapons.type[weaponids[weaponactive]]==staff){
2723 where=weapons.position[weaponids[weaponactive]];
2724 where-=victim->coords;
2725 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2727 where=weapons.tippoint[weaponids[weaponactive]];
2728 where-=victim->coords;
2729 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2734 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2737 if(victim->dead!=2){
2738 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2739 if(id==0&&!victim->dead){
2740 bonus=FinishedBonus;
2745 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2747 victim->skeleton.longdead=0;
2748 victim->skeleton.free=1;
2749 victim->skeleton.broken=0;
2751 for(i=0;i<victim->skeleton.num_joints;i++){
2752 victim->skeleton.joints[i].velchange=0;
2753 victim->skeleton.joints[i].locked=0;
2754 //victim->skeleton.joints[i].velocity=0;
2756 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2757 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2758 OPENAL_SetVolume(channels[fleshstabsound], 128);
2759 OPENAL_SetPaused(channels[fleshstabsound], false);
2762 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2763 weapons.blooddrip[weaponids[weaponactive]]+=5;
2764 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2768 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2769 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2770 OPENAL_SetVolume(channels[knifesheathesound], 128);
2771 OPENAL_SetPaused(channels[knifesheathesound], false);
2777 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2778 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2779 //if(id==0)camerashake+=.4;
2789 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2790 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2791 OPENAL_SetVolume(channels[knifedrawsound], 128);
2792 OPENAL_SetPaused(channels[knifedrawsound], false);
2795 if(victim&&hasvictim){
2796 XYZ footvel,footpoint;
2798 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2799 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2800 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2801 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2804 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2806 if(weapons.type[weaponids[weaponactive]]==sword){
2807 XYZ where,startpoint,endpoint,movepoint;
2808 float rotationpoint;
2811 where=weapons.position[weaponids[weaponactive]];
2812 where-=victim->coords;
2813 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2815 where=weapons.tippoint[weaponids[weaponactive]];
2816 where-=victim->coords;
2817 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2822 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2823 footpoint+=victim->coords;
2826 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2829 if(weapons.type[weaponids[weaponactive]]==staff){
2830 XYZ where,startpoint,endpoint,movepoint;
2831 float rotationpoint;
2834 where=weapons.position[weaponids[weaponactive]];
2835 where-=victim->coords;
2836 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2838 where=weapons.tippoint[weaponids[weaponactive]];
2839 where-=victim->coords;
2840 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2845 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2846 footpoint+=victim->coords;
2849 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2852 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2854 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2855 victim->skeleton.longdead=0;
2856 victim->skeleton.free=1;
2857 victim->skeleton.broken=0;
2859 for(i=0;i<victim->skeleton.num_joints;i++){
2860 victim->skeleton.joints[i].velchange=0;
2861 victim->skeleton.joints[i].locked=0;
2862 //victim->skeleton.joints[i].velocity=0;
2868 Normalise(&relative);
2869 //victim->Puff(abdomen);
2870 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2872 if(victim->bloodloss<victim->damagetolerance){
2873 victim->bloodloss+=1000;
2877 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2881 if(!hasvictim&&onterrain){
2882 weapons.bloody[weaponids[weaponactive]]=0;
2883 weapons.blooddrip[weaponids[weaponactive]]=0;
2887 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2888 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2890 if(id==0)camerashake+=.4;
2897 gLoc[0]=victim->coords.x;
2898 gLoc[1]=victim->coords.y;
2899 gLoc[2]=victim->coords.z;
2903 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2905 if(tutoriallevel!=1){
2906 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2907 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2908 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2909 OPENAL_SetPaused(channels[heavyimpactsound], false);
2913 if(tutoriallevel!=1){
2914 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2915 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2916 OPENAL_SetVolume(channels[landsound2], 256);
2917 OPENAL_SetPaused(channels[landsound2], false);
2921 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
2924 relative=victim->coords-coords;
2926 Normalise(&relative);
2927 for(i=0;i<victim->skeleton.num_joints;i++){
2928 victim->skeleton.joints[i].velocity=relative*30;
2930 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2932 victim->targetframe=0;
2933 victim->targetanimation=staggerbackhardanim;
2934 victim->targetrotation=targetrotation+180;
2939 victim->Puff(abdomen);
2940 victim->DoDamage(damagemult*60/victim->protectionhigh);
2949 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2950 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2952 if(id==0)camerashake+=.4;
2955 gLoc[0]=victim->coords.x;
2956 gLoc[1]=victim->coords.y;
2957 gLoc[2]=victim->coords.z;
2961 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2962 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2963 if(tutoriallevel!=1){
2964 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2965 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2966 OPENAL_SetVolume(channels[thudsound], 512);
2967 OPENAL_SetPaused(channels[thudsound], false);
2970 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2971 if(tutoriallevel!=1){
2972 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2973 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2974 OPENAL_SetVolume(channels[whooshhitsound], 512);
2975 OPENAL_SetPaused(channels[whooshhitsound], false);
2979 if(tutoriallevel!=1){
2980 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2981 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2982 OPENAL_SetVolume(channels[heavyimpactsound], 256);
2983 OPENAL_SetPaused(channels[heavyimpactsound], false);
2987 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2990 relative=victim->coords-coords;
2992 Normalise(&relative);
2994 Normalise(&relative);
2995 for(i=0;i<victim->skeleton.num_joints;i++){
2996 victim->skeleton.joints[i].velocity=relative*5;
2998 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
3000 victim->targetframe=0;
3001 victim->targetanimation=staggerbackhardanim;
3002 victim->targetrotation=targetrotation+180;
3006 victim->Puff(abdomen);
3007 victim->DoDamage(damagemult*60/victim->protectionhigh);
3015 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
3016 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3017 if(victim->id==0)camerashake+=.4;
3020 gLoc[0]=victim->coords.x;
3021 gLoc[1]=victim->coords.y;
3022 gLoc[2]=victim->coords.z;
3027 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3028 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3029 OPENAL_SetVolume(channels[landsound2], 256);
3030 OPENAL_SetPaused(channels[landsound2], false);
3036 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
3037 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3038 if(victim->id==0)camerashake+=.4;
3041 gLoc[0]=victim->coords.x;
3042 gLoc[1]=victim->coords.y;
3043 gLoc[2]=victim->coords.z;
3048 if(weaponactive!=-1){
3049 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3050 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3051 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3053 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3054 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3055 OPENAL_SetVolume(channels[swordstaffsound], 512);
3056 OPENAL_SetPaused(channels[swordstaffsound], false);
3059 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3060 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3061 OPENAL_SetVolume(channels[metalhitsound], 512);
3062 OPENAL_SetPaused(channels[metalhitsound], false);
3070 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3071 if(weaponactive!=-1){
3074 weapons.owner[weaponids[0]]=-1;
3075 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);
3077 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3078 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3080 weapons.velocity[weaponids[0]]=aim*50;
3081 weapons.tipvelocity[weaponids[0]]=aim*50;
3082 weapons.missed[weaponids[0]]=0;
3083 weapons.hitsomething[weaponids[0]]=0;
3084 weapons.freetime[weaponids[0]]=0;
3085 weapons.firstfree[weaponids[0]]=1;
3086 weapons.physics[weaponids[0]]=0;
3089 weaponids[0]=weaponids[num_weapons];
3095 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3097 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3100 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3108 if(tutoriallevel!=1){
3111 gLoc[0]=victim->coords.x;
3112 gLoc[1]=victim->coords.y;
3113 gLoc[2]=victim->coords.z;
3117 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3118 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3119 OPENAL_SetVolume(channels[knifeslicesound], 512);
3120 OPENAL_SetPaused(channels[knifeslicesound], false);
3122 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3123 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3124 if(victim->id != 0 || difficulty==2){
3125 victim->targetframe=0;
3126 victim->targetanimation=staggerbackhardanim;
3127 victim->targetrotation=targetrotation+180;
3131 victim->lowreversaldelay=0;
3132 victim->highreversaldelay=0;
3133 if(aitype!=playercontrolled)weaponmissdelay=.6;
3135 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3136 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3138 XYZ footvel,footpoint;
3141 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3144 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;
3146 if(tutoriallevel!=1){
3147 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3148 footvel=DoRotation(facing,0,90,0)*.8;
3150 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3151 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3152 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3153 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3155 if(tutoriallevel==1){
3156 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3158 victim->DoDamage(damagemult*0);
3161 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3162 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3163 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3170 if(tutoriallevel!=1){
3171 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3172 else victim->DoBloodBig(2/victim->armorhigh,185);
3173 victim->deathbleeding=1;
3176 gLoc[0]=victim->coords.x;
3177 gLoc[1]=victim->coords.y;
3178 gLoc[2]=victim->coords.z;
3182 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3183 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3184 OPENAL_SetVolume(channels[swordslicesound], 512);
3185 OPENAL_SetPaused(channels[swordslicesound], false);
3187 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3188 //if(animation[victim->targetanimation].attack){
3189 //if(victim->creature==rabbittype){
3190 if(tutoriallevel!=1){
3191 victim->targetframe=0;
3192 victim->targetanimation=staggerbackhardanim;
3193 victim->targetrotation=targetrotation+180;
3199 if(tutoriallevel!=1){
3200 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3201 weapons.blooddrip[weaponids[weaponactive]]+=3;
3203 float bloodlossamount;
3204 bloodlossamount=200+abs((float)(Random()%40))-20;
3205 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3206 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3207 victim->DoDamage(damagemult*0);
3209 XYZ footvel,footpoint;
3212 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3215 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;
3217 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3218 footvel=DoRotation(facing,0,90,0)*.8;
3220 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3221 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3222 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3223 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3231 gLoc[0]=victim->coords.x;
3232 gLoc[1]=victim->coords.y;
3233 gLoc[2]=victim->coords.z;
3237 if(victim->weaponactive!=-1){
3238 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3239 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3240 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3242 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3243 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3244 OPENAL_SetVolume(channels[swordstaffsound], 512);
3245 OPENAL_SetPaused(channels[swordstaffsound], false);
3248 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3249 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3250 OPENAL_SetVolume(channels[metalhitsound], 512);
3251 OPENAL_SetPaused(channels[metalhitsound], false);
3257 victim->Puff(righthand);
3259 victim->targetframe=0;
3260 victim->targetanimation=staggerbackhighanim;
3261 victim->targetrotation=targetrotation+180;
3263 weapons.owner[victim->weaponids[0]]=-1;
3264 aim=DoRotation(facing,0,90,0)*21;
3266 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3267 weapons.tipvelocity[victim->weaponids[0]]=aim;
3268 weapons.missed[victim->weaponids[0]]=1;
3269 weapons.hitsomething[weaponids[0]]=0;
3270 weapons.freetime[victim->weaponids[0]]=0;
3271 weapons.firstfree[victim->weaponids[0]]=1;
3272 weapons.physics[victim->weaponids[0]]=1;
3273 victim->num_weapons--;
3274 if(victim->num_weapons){
3275 victim->weaponids[0]=victim->weaponids[num_weapons];
3276 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3278 victim->weaponactive=-1;
3279 for(i=0;i<numplayers;i++){
3280 player[i].wentforweapon=0;
3283 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3284 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3285 OPENAL_SetVolume(channels[metalhitsound], 512);
3286 OPENAL_SetPaused(channels[metalhitsound], false);*/
3292 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3293 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3294 if(tutoriallevel!=1){
3295 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3297 if(id==0)camerashake+=.4;
3298 if(Random()%2||creature==wolftype){
3303 gLoc[0]=victim->coords.x;
3304 gLoc[1]=victim->coords.y;
3305 gLoc[2]=victim->coords.z;
3309 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3310 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3311 OPENAL_SetVolume(channels[staffheadsound], 256);
3312 OPENAL_SetPaused(channels[staffheadsound], false);
3316 relative=victim->coords-coords;
3318 Normalise(&relative);
3319 relative=DoRotation(relative,0,90,0);
3321 Normalise(&relative);
3322 for(i=0;i<victim->skeleton.num_joints;i++){
3323 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3325 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3326 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3329 if(tutoriallevel!=1){
3330 victim->DoDamage(damagemult*120/victim->protectionhigh);
3341 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3342 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3343 if(tutoriallevel!=1){
3344 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3346 if(id==0)camerashake+=.4;
3347 if(Random()%2||creature==wolftype){
3352 gLoc[0]=victim->coords.x;
3353 gLoc[1]=victim->coords.y;
3354 gLoc[2]=victim->coords.z;
3358 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3359 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3360 OPENAL_SetVolume(channels[staffheadsound], 256);
3361 OPENAL_SetPaused(channels[staffheadsound], false);
3365 relative=victim->coords-coords;
3367 Normalise(&relative);
3368 relative=DoRotation(relative,0,-90,0);
3369 for(i=0;i<victim->skeleton.num_joints;i++){
3370 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3372 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3373 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3376 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3387 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3388 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3390 if(tutoriallevel!=1){
3391 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3392 if(id==0)camerashake+=.4;
3393 if(Random()%2||creature==wolftype){
3398 gLoc[0]=victim->coords.x;
3399 gLoc[1]=victim->coords.y;
3400 gLoc[2]=victim->coords.z;
3404 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3405 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3406 OPENAL_SetVolume(channels[staffbodysound], 256);
3407 OPENAL_SetPaused(channels[staffbodysound], false);
3409 victim->skeleton.longdead=0;
3410 victim->skeleton.free=1;
3411 victim->skeleton.broken=0;
3413 for(i=0;i<victim->skeleton.num_joints;i++){
3414 victim->skeleton.joints[i].velchange=0;
3415 victim->skeleton.joints[i].locked=0;
3416 //victim->skeleton.joints[i].velocity=0;
3422 /*relative=victim->coords-coords;
3424 Normalise(&relative);
3425 relative=DoRotation(relative,0,90,0);*/
3427 Normalise(&relative);
3429 for(i=0;i<victim->skeleton.num_joints;i++){
3430 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3433 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3436 for(i=0;i<victim->skeleton.num_joints;i++){
3437 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3440 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3442 victim->Puff(abdomen);
3443 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3456 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3457 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3459 if(id==0)camerashake+=.4;
3462 gLoc[0]=victim->coords.x;
3463 gLoc[1]=victim->coords.y;
3464 gLoc[2]=victim->coords.z;
3469 relative=victim->coords-coords;
3471 Normalise(&relative);
3477 if(animation[victim->targetanimation].height==lowheight){
3483 for(i=0;i<victim->skeleton.num_joints;i++){
3484 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3486 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3487 if(tutoriallevel!=1){
3488 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3489 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3490 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3491 OPENAL_SetPaused(channels[heavyimpactsound], false);
3494 victim->DoDamage(damagemult*100/victim->protectionhead);
3495 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3496 if(creature==wolftype){
3497 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3498 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3499 OPENAL_SetVolume(channels[clawslicesound], 128);
3500 OPENAL_SetPaused(channels[clawslicesound], false);
3502 victim->DoBloodBig(2/victim->armorhead,175);
3506 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3507 for(i=0;i<victim->skeleton.num_joints;i++){
3508 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3510 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3511 victim->targetframe=0;
3512 victim->targetanimation=staggerbackhighanim;
3513 victim->targetrotation=targetrotation+180;
3515 if(tutoriallevel!=1){
3516 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3517 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3518 OPENAL_SetVolume(channels[landsound2], 128);
3519 OPENAL_SetPaused(channels[landsound2], false);
3521 victim->Puff(abdomen);
3522 victim->DoDamage(damagemult*30/victim->protectionhigh);
3523 if(creature==wolftype){
3524 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3525 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3526 OPENAL_SetVolume(channels[clawslicesound], 128);
3527 OPENAL_SetPaused(channels[clawslicesound], false);
3529 victim->DoBloodBig(2/victim->armorhigh,170);
3536 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3537 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3539 if(id==0)camerashake+=.2;
3542 gLoc[0]=victim->coords.x;
3543 gLoc[1]=victim->coords.y;
3544 gLoc[2]=victim->coords.z;
3548 if(tutoriallevel!=1){
3549 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3550 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3551 OPENAL_SetVolume(channels[landsound2], 128);
3552 OPENAL_SetPaused(channels[landsound2], false);
3555 relative=victim->coords-coords;
3557 Normalise(&relative);
3559 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3562 for(i=0;i<victim->skeleton.num_joints;i++){
3563 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3565 relative=DoRotation(relative,0,-90,0);
3567 for(i=0;i<victim->skeleton.num_joints;i++){
3568 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)
3569 victim->skeleton.joints[i].velocity=relative*80;
3571 victim->Puff(rightankle);
3572 victim->Puff(leftankle);
3573 victim->DoDamage(damagemult*40/victim->protectionlow);
3576 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3577 for(i=0;i<victim->skeleton.num_joints;i++){
3578 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3580 relative=DoRotation(relative,0,-90,0);
3581 for(i=0;i<victim->skeleton.num_joints;i++){
3582 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)
3583 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3585 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3586 victim->targetframe=0;
3587 victim->targetanimation=staggerbackhighanim;
3588 victim->targetrotation=targetrotation+180;
3590 if(tutoriallevel!=1){
3591 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3592 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3593 OPENAL_SetVolume(channels[landsound2], 128);
3594 OPENAL_SetPaused(channels[landsound2], false);
3596 victim->Puff(abdomen);
3597 victim->DoDamage(damagemult*30/victim->protectionlow);
3607 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3608 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3610 if(id==0)camerashake+=.4;
3617 gLoc[0]=victim->coords.x;
3618 gLoc[1]=victim->coords.y;
3619 gLoc[2]=victim->coords.z;
3623 if(tutoriallevel!=1){
3624 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3625 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3626 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3627 OPENAL_SetPaused(channels[heavyimpactsound], false);
3629 if(creature==wolftype){
3630 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3631 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3632 OPENAL_SetVolume(channels[clawslicesound], 128);
3633 OPENAL_SetPaused(channels[clawslicesound], false);
3635 victim->DoBloodBig(2/victim->armorhigh,170);
3639 relative=victim->coords-oldcoords;
3641 Normalise(&relative);
3642 //relative=DoRotation(relative,0,-90,0);
3643 for(i=0;i<victim->skeleton.num_joints;i++){
3644 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3646 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3648 victim->Puff(abdomen);
3649 victim->DoDamage(damagemult*150/victim->protectionhigh);
3658 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3659 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3660 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3661 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3664 weaponids[num_weapons]=weaponids[victim->weaponactive];
3667 weaponids[0]=victim->weaponids[victim->weaponactive];
3668 victim->num_weapons--;
3669 if(victim->num_weapons>0){
3670 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3671 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3673 victim->weaponactive=-1;
3678 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3680 if(id==0)camerashake+=.4;
3687 gLoc[0]=victim->coords.x;
3688 gLoc[1]=victim->coords.y;
3689 gLoc[2]=victim->coords.z;
3693 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3694 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3695 OPENAL_SetVolume(channels[whooshhitsound], 128);
3696 OPENAL_SetPaused(channels[whooshhitsound], false);
3699 relative=victim->coords-oldcoords;
3701 Normalise(&relative);
3702 //relative=DoRotation(relative,0,-90,0);
3703 for(i=0;i<victim->skeleton.num_joints;i++){
3704 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3706 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3709 victim->DoDamage(damagemult*70/victim->protectionhigh);
3712 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3714 if(id==0)camerashake+=.4;
3721 gLoc[0]=victim->coords.x;
3722 gLoc[1]=victim->coords.y;
3723 gLoc[2]=victim->coords.z;
3729 bonus=staffreversebonus;
3734 if(tutoriallevel!=1){
3735 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3736 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3737 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3738 OPENAL_SetPaused(channels[heavyimpactsound], false);
3742 bonus=staffreversebonus;
3748 relative=victim->coords-oldcoords;
3750 Normalise(&relative);
3751 //relative=DoRotation(relative,0,-90,0);
3752 for(i=0;i<victim->skeleton.num_joints;i++){
3753 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3755 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3758 victim->DoDamage(damagemult*70/victim->protectionhigh);
3761 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3767 Normalise(&relative);
3770 for(i=0;i<victim->skeleton.num_joints;i++){
3771 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3773 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3774 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3775 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3776 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3777 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3778 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3779 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3780 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3782 victim->Puff(abdomen);
3783 victim->DoDamage(damagemult*90/victim->protectionhigh);
3793 if(weaponactive!=-1||creature==wolftype)doslice=1;
3794 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3798 gLoc[0]=victim->coords.x;
3799 gLoc[1]=victim->coords.y;
3800 gLoc[2]=victim->coords.z;
3804 if(weaponactive!=-1){
3805 victim->DoBloodBig(2/victim->armorhigh,225);
3806 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3807 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3808 OPENAL_SetVolume(channels[knifeslicesound], 512);
3809 OPENAL_SetPaused(channels[knifeslicesound], false);
3810 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3811 weapons.blooddrip[weaponids[weaponactive]]+=3;
3813 if(weaponactive==-1&&creature==wolftype){
3814 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3815 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3816 OPENAL_SetVolume(channels[clawslicesound], 128);
3817 OPENAL_SetPaused(channels[clawslicesound], false);
3819 victim->DoBloodBig(2/victim->armorhigh,175);
3826 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3832 Normalise(&relative);
3835 for(i=0;i<victim->skeleton.num_joints;i++){
3836 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3838 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
3839 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
3840 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
3841 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
3842 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
3843 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
3844 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
3845 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
3848 bonus=swordreversebonus;
3852 //victim->DoDamage(90);
3854 /*if(weaponactive!=-1){
3857 gLoc[0]=victim->coords.x;
3858 gLoc[1]=victim->coords.y;
3859 gLoc[2]=victim->coords.z;
3863 victim->DoBloodBig(2,225);
3864 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3865 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3866 OPENAL_SetVolume(channels[knifeslicesound], 512);
3867 OPENAL_SetPaused(channels[knifeslicesound], false);
3868 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3869 weapons.blooddrip[weaponids[weaponactive]]+=3;
3873 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3875 if(id==0)camerashake+=.4;
3882 gLoc[0]=victim->coords.x;
3883 gLoc[1]=victim->coords.y;
3884 gLoc[2]=victim->coords.z;
3888 if(tutoriallevel!=1){
3889 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3890 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3891 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3892 OPENAL_SetPaused(channels[heavyimpactsound], false);
3896 relative=victim->coords-oldcoords;
3898 Normalise(&relative);
3899 relative=DoRotation(relative,0,-90,0);
3900 for(i=0;i<victim->skeleton.num_joints;i++){
3901 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3903 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3905 victim->Puff(abdomen);
3906 victim->DoDamage(damagemult*30/victim->protectionhigh);
3915 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
3918 victim->skeleton.spinny=0;
3922 Normalise(&relative);
3923 if(victim->id==0)relative/=30;
3924 for(i=0;i<victim->skeleton.num_joints;i++){
3925 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3927 //victim->DoDamage(1000);
3928 victim->damage=victim->damagetolerance;
3929 victim->permanentdamage=victim->damagetolerance-1;
3932 if(weaponactive!=-1||creature==wolftype)doslice=1;
3933 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3937 gLoc[0]=victim->coords.x;
3938 gLoc[1]=victim->coords.y;
3939 gLoc[2]=victim->coords.z;
3943 if(weaponactive!=-1){
3944 victim->DoBloodBig(200,225);
3945 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3946 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3947 OPENAL_SetVolume(channels[knifeslicesound], 512);
3948 OPENAL_SetPaused(channels[knifeslicesound], false);
3949 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3950 weapons.blooddrip[weaponids[weaponactive]]+=5;
3953 if(creature==wolftype&&weaponactive==-1){
3954 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3955 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3956 OPENAL_SetVolume(channels[clawslicesound], 128);
3957 OPENAL_SetPaused(channels[clawslicesound], false);
3959 victim->DoBloodBig(2,175);
3969 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3970 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3972 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3973 if(targetanimation==knifesneakattackanim){
3974 /*victim->DoBloodBig(200,195);
3979 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3980 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3982 XYZ footvel,footpoint;
3984 footpoint=weapons.tippoint[weaponids[0]];
3985 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3986 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3987 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3988 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3989 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3990 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3991 victim->DoBloodBig(200,195);
3998 //victim->neckspurtamount=5;
4000 if(targetanimation==knifefollowanim){
4006 XYZ footvel,footpoint;
4008 footpoint=weapons.tippoint[weaponids[0]];
4009 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4010 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4011 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4012 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4013 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
4014 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
4017 victim->bloodloss+=10000;
4021 gLoc[0]=victim->coords.x;
4022 gLoc[1]=victim->coords.y;
4023 gLoc[2]=victim->coords.z;
4027 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4028 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4029 OPENAL_SetVolume(channels[fleshstabsound], 512);
4030 OPENAL_SetPaused(channels[fleshstabsound], false);
4031 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4032 weapons.blooddrip[weaponids[weaponactive]]+=5;
4036 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
4039 for(i=0;i<victim->skeleton.num_joints;i++){
4040 victim->skeleton.joints[i].velocity=0;
4042 if(targetanimation==knifefollowanim){
4044 for(i=0;i<victim->skeleton.num_joints;i++){
4045 victim->skeleton.joints[i].velocity=0;
4048 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
4051 gLoc[0]=victim->coords.x;
4052 gLoc[1]=victim->coords.y;
4053 gLoc[2]=victim->coords.z;
4057 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4058 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4059 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4060 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4061 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4062 weapons.blooddrip[weaponids[weaponactive]]+=5;
4064 XYZ footvel,footpoint;
4066 footpoint=weapons.tippoint[weaponids[0]];
4067 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4068 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4069 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4070 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4071 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4072 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4076 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4077 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4086 XYZ footvel,footpoint;
4088 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
4089 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4090 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4091 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4092 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4093 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4094 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4095 victim->DoBloodBig(200,180);
4096 victim->DoBloodBig(200,215);
4097 victim->bloodloss+=10000;
4101 gLoc[0]=victim->coords.x;
4102 gLoc[1]=victim->coords.y;
4103 gLoc[2]=victim->coords.z;
4107 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4108 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4109 OPENAL_SetVolume(channels[fleshstabsound], 512);
4110 OPENAL_SetPaused(channels[fleshstabsound], false);
4111 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4112 weapons.blooddrip[weaponids[weaponactive]]+=5;
4116 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
4119 for(i=0;i<victim->skeleton.num_joints;i++){
4120 victim->skeleton.joints[i].velocity=0;
4122 if(weaponactive!=-1){
4125 gLoc[0]=victim->coords.x;
4126 gLoc[1]=victim->coords.y;
4127 gLoc[2]=victim->coords.z;
4131 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4132 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4133 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4134 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4135 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4136 weapons.blooddrip[weaponids[weaponactive]]+=5;
4138 XYZ footvel,footpoint;
4140 footpoint=weapons.tippoint[weaponids[0]];
4141 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4142 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4143 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4144 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4145 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4146 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4150 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4152 if(id==0)camerashake+=.4;
4159 gLoc[0]=victim->coords.x;
4160 gLoc[1]=victim->coords.y;
4161 gLoc[2]=victim->coords.z;
4165 if(weaponactive==-1){
4166 if(tutoriallevel!=1){
4167 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4168 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4169 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4170 OPENAL_SetPaused(channels[heavyimpactsound], false);
4175 if(weaponactive!=-1||creature==wolftype)doslice=1;
4176 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4178 if(weaponactive!=-1){
4179 victim->DoBloodBig(2/victim->armorhead,225);
4180 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4181 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4182 OPENAL_SetVolume(channels[knifeslicesound], 512);
4183 OPENAL_SetPaused(channels[knifeslicesound], false);
4184 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4185 weapons.blooddrip[weaponids[weaponactive]]+=3;
4187 if(weaponactive==-1&&creature==wolftype){
4188 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4189 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4190 OPENAL_SetVolume(channels[clawslicesound], 128);
4191 OPENAL_SetPaused(channels[clawslicesound], false);
4193 victim->DoBloodBig(2/victim->armorhead,175);
4206 //relative=victim->coords-oldcoords;
4209 Normalise(&relative);
4210 relative=DoRotation(relative,0,90,0);
4212 Normalise(&relative);
4213 for(i=0;i<victim->skeleton.num_joints;i++){
4214 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4216 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4217 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4218 victim->DoDamage(damagemult*100/victim->protectionhead);
4222 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4226 //relative=victim->coords-oldcoords;
4229 Normalise(&relative);
4230 relative=DoRotation(relative,0,90,0);
4232 Normalise(&relative);
4233 for(i=0;i<victim->skeleton.num_joints;i++){
4234 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4236 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4239 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4240 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4251 if(targetframe>animation[currentanimation].numframes-1){
4254 targetanimation=getIdle();
4258 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4259 targetanimation=rollanim;
4270 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4271 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4272 OPENAL_SetVolume(channels[movewhooshsound], 128);
4273 OPENAL_SetPaused(channels[movewhooshsound], false);
4275 if(currentanimation==staggerbackhighanim){
4276 targetanimation=getIdle();
4278 if(currentanimation==staggerbackhardanim){
4279 targetanimation=getIdle();
4281 if(currentanimation==removeknifeanim){
4282 targetanimation=getIdle();
4284 if(currentanimation==crouchremoveknifeanim){
4285 targetanimation=getCrouch();
4287 if(currentanimation==backhandspringanim){
4288 targetanimation=getIdle();
4290 if(currentanimation==dodgebackanim){
4291 targetanimation=getIdle();
4293 if(currentanimation==drawleftanim){
4294 targetanimation=getIdle();
4296 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4297 targetanimation=getIdle();
4298 if(currentanimation==crouchdrawrightanim){
4299 targetanimation=getCrouch();
4301 if(weaponactive==-1)weaponactive=0;
4302 else if(weaponactive==0){
4306 buffer=weaponids[0];
4307 weaponids[0]=weaponids[1];
4308 weaponids[1]=buffer;
4312 if(weaponactive==-1){
4322 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4323 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4324 OPENAL_SetVolume(channels[knifesheathesound], 128);
4325 OPENAL_SetPaused(channels[knifesheathesound], false);
4327 if(weaponactive!=-1){
4337 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4338 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4339 OPENAL_SetVolume(channels[knifedrawsound], 128);
4340 OPENAL_SetPaused(channels[knifedrawsound], false);
4343 if(currentanimation==rollanim){
4344 targetanimation=getCrouch();
4349 if(targetanimation==walljumprightkickanim){
4352 if(targetanimation==walljumpleftkickanim){
4355 targetanimation=jumpdownanim;
4357 if(currentanimation==climbanim){
4358 targetanimation=getCrouch();
4361 if(!isnormal(coords.x))
4372 if(targetanimation==rabbitkickreversalanim){
4373 targetanimation=getCrouch();
4376 if(targetanimation==jumpreversalanim){
4377 targetanimation=getCrouch();
4380 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4381 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4383 float closestdist=-1;
4386 for(i=0;i<numplayers;i++){
4387 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4388 distance=findDistancefast(&player[i].coords,&coords);
4389 if(closestdist==-1||distance<closestdist){
4390 closestdist=distance;
4395 if(closestdist>0&&closest>=0&&closestdist<16){
4396 victim=&player[closest];
4397 targetanimation=walljumprightkickanim;
4399 XYZ rotatetarget=victim->coords-coords;
4400 Normalise(&rotatetarget);
4401 rotation=-asin(0-rotatetarget.x);
4403 if(rotatetarget.z<0)rotation=180-rotation;
4404 targettilt2=-asin(rotatetarget.y)*360/6.28;
4405 velocity=(victim->coords-coords)*4;
4410 if(targetanimation==walljumpbackanim){
4411 targetanimation=backflipanim;
4415 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4417 if(targetanimation==walljumprightanim){
4418 targetanimation=rightflipanim;
4422 velocity=DoRotation(facing,0,30,0)*-8;
4425 if(targetanimation==walljumpfrontanim){
4426 targetanimation=frontflipanim;
4428 //targetrotation-=180;
4433 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4435 if(targetanimation==walljumpleftanim){
4438 float closestdist=-1;
4441 for(i=0;i<numplayers;i++){
4442 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4443 distance=findDistancefast(&player[i].coords,&coords);
4444 if(closestdist==-1||distance<closestdist){
4445 closestdist=distance;
4450 if(closestdist>0&&closest>=0&&closestdist<16){
4451 victim=&player[closest];
4452 targetanimation=walljumpleftkickanim;
4454 XYZ rotatetarget=victim->coords-coords;
4455 Normalise(&rotatetarget);
4456 rotation=-asin(0-rotatetarget.x);
4458 if(rotatetarget.z<0)rotation=180-rotation;
4459 targettilt2=-asin(rotatetarget.y)*360/6.28;
4460 velocity=(victim->coords-coords)*4;
4465 if(targetanimation!=walljumpleftkickanim){
4466 targetanimation=leftflipanim;
4470 velocity=DoRotation(facing,0,-30,0)*-8;
4473 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4475 if(targetanimation==sneakattackanim){
4476 float ycoords=oldcoords.y;
4477 currentanimation=getCrouch();
4478 targetanimation=getCrouch();
4481 targetrotation+=180;
4486 targetheadrotation+=180;
4488 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4492 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4493 float ycoords=oldcoords.y;
4494 targetanimation=getIdle();
4496 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4500 if(currentanimation==knifefollowanim){
4501 targetanimation=getIdle();
4504 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4505 float ycoords=oldcoords.y;
4506 targetanimation=getStop();
4507 targetrotation+=180;
4512 targetheadrotation+=180;
4513 if(!isnormal(coords.x))
4515 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4516 oldcoords=coords+facing*.5;
4517 else if(currentanimation==sweepreversalanim)
4518 oldcoords=coords+facing*1.1;
4519 else if(currentanimation==upunchreversalanim){
4520 oldcoords=coords+facing*1.5;
4521 targetrotation+=180;
4523 targetheadrotation+=180;
4527 else if(currentanimation==knifeslashreversalanim){
4528 oldcoords=coords+facing*.5;
4531 targetheadrotation+=90;
4535 else if(currentanimation==staffspinhitreversalanim){
4536 targetrotation+=180;
4538 targetheadrotation+=180;
4542 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4543 else oldcoords.y=ycoords;
4544 currentoffset=coords-oldcoords;
4550 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4555 if(animation[targetanimation].attack==reversed){
4557 if(targetanimation==sweepreversedanim)targetrotation+=90;
4558 targetanimation=backhandspringanim;
4568 PlaySoundEx( landsound, samp[landsound], NULL, true);
4569 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4570 OPENAL_SetVolume(channels[landsound], 128);
4571 OPENAL_SetPaused(channels[landsound], false);
4573 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4574 targetanimation=rollanim;
4577 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4578 coords.y=oldcoords.y;
4580 if(currentanimation==knifeslashreversedanim){
4581 targetanimation=rollanim;
4586 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4587 coords.y=oldcoords.y;
4591 targetanimation=jumpdownanim;
4593 if(wasLanding())targetanimation=getIdle();
4594 if(wasLandhard())targetanimation=getIdle();
4595 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4596 targetanimation=getIdle();
4598 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4599 coords.y=oldcoords.y;
4600 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4601 targetoffset.y=coords.y;
4602 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4603 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4604 currentoffset.y-=(coords.y-targetoffset.y);
4605 coords.y=targetoffset.y;
4607 normalsupdatedelay=0;
4609 if(currentanimation==upunchanim){
4610 targetanimation=getStop();
4611 normalsupdatedelay=0;
4614 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4615 targetrotation=rotation;
4618 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4619 if(!hasstaff)DoDamage(35);
4622 rabbitkickragdoll=1;
4624 if(currentanimation==rabbitkickreversedanim){
4631 if(id!=0)SolidHitBonus();
4635 targetanimation=rollanim;
4637 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4641 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4647 if(currentanimation==jumpreversedanim){
4654 if(id!=0)SolidHitBonus();
4658 targetanimation=rollanim;
4660 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4665 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){
4666 targetanimation=getupfromfrontanim;
4669 else if(animation[currentanimation].attack==normalattack){
4670 targetanimation=getIdle();
4673 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4674 targetanimation=blockhighleftstrikeanim;
4676 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4677 targetanimation=getIdle();
4680 if(currentanimation==spinkickanim&&victim->skeleton.free){
4681 if(creature==rabbittype)targetanimation=fightidleanim;
4686 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4688 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4689 targetanimation=jumpdownanim;
4694 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4695 if(!isRun()||!wasRun()){
4696 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4697 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4698 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4699 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4701 if(isRun()&&wasRun()){
4704 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4705 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4708 else if(transspeed)target+=multiplier*transspeed*speed*2;
4710 if(!isRun()||!wasRun()){
4711 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4712 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4713 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4714 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4718 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4720 if(target>1){currentframe=targetframe; target=1;}
4722 rot=targetrot*target;
4723 rotation+=rot-oldrot;
4729 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4731 for(i=0;i<skeleton.num_joints;i++){
4732 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4735 skeleton.FindForwards();
4737 for(i=0;i<skeleton.num_muscles;i++){
4738 if(skeleton.muscles[i].visible)
4740 skeleton.FindRotationMuscle(i,targetanimation);
4743 for(i=0;i<skeleton.num_muscles;i++){
4744 if(skeleton.muscles[i].visible)
4746 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4747 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4748 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4753 for(i=0;i<skeleton.num_joints;i++){
4754 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4757 skeleton.FindForwards();
4759 for(i=0;i<skeleton.num_muscles;i++){
4760 if(skeleton.muscles[i].visible)
4762 skeleton.FindRotationMuscle(i,targetanimation);
4765 for(i=0;i<skeleton.num_muscles;i++){
4766 if(skeleton.muscles[i].visible)
4768 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4769 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4770 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4771 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4772 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4773 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4774 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4775 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4776 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4780 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4782 oldcurrentanimation=currentanimation;
4783 oldtargetanimation=targetanimation;
4784 oldtargetframe=targetframe;
4785 oldcurrentframe=currentframe;
4787 for(i=0;i<skeleton.num_joints;i++){
4788 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4789 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4791 offset=currentoffset*(1-target)+targetoffset*target;
4792 for(i=0;i<skeleton.num_muscles;i++){
4793 if(skeleton.muscles[i].visible)
4795 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4796 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4797 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4802 if(isLanding()&&landhard){
4803 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4804 if(id==0)camerashake+=.4;
4805 targetanimation=getLandhard();
4813 //skeleton.DoConstraints();
4816 void Person::DoStuff(){
4817 static XYZ terrainnormal;
4818 static XYZ flatfacing;
4819 static XYZ flatvelocity;
4820 static float flatvelspeed;
4824 static int bloodsize;
4825 static int startx,starty,endx,endy;
4826 static int texdetailint;
4827 static GLubyte color;
4828 static XYZ bloodvel;
4830 onfiredelay-=multiplier;
4831 if(onfiredelay<0&&onfire)
4839 crouchkeydowntime+=multiplier;
4840 if(!crouchkeydown)crouchkeydowntime=0;
4841 jumpkeydowntime+=multiplier;
4842 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
4844 if(hostile||damage>0||bloodloss>0)immobile=0;
4846 if(isIdle()||isRun())targetoffset=0;
4848 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
4850 if(id==0)blooddimamount-=multiplier*.3;
4851 speechdelay-=multiplier;
4852 texupdatedelay-=multiplier;
4853 interestdelay-=multiplier;
4854 flamedelay-=multiplier;
4855 parriedrecently-=multiplier;
4861 if(id==0)speed=1.1*speedmult;
4862 else speed=1.0*speedmult;
4863 if(!skeleton.free)rabbitkickragdoll=0;
4867 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
4868 if(id!=0&&creature==wolftype&&difficulty==2){
4870 if(aitype!=passivetype){
4872 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){
4876 if(scale<0.2)superruntoggle=0;
4877 if(targetanimation==wolfrunninganim&&!superruntoggle){
4878 targetanimation=getRun();
4882 if(weaponactive==-1&&num_weapons>0){
4883 if(weapons.type[weaponids[0]]==staff){
4890 /*if(aitype!=playercontrolled)*///deathbleeding=5;
4891 /*if(aitype!=playercontrolled)*/
4893 if(burnt>.6)burnt=.6;
4894 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
4896 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
4907 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4908 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
4912 while(flamedelay<0&&onfire){
4914 howmany=abs(Random()%(skeleton.num_joints));
4915 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4916 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4917 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4918 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4919 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
4922 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
4924 howmany=abs(Random()%(skeleton.num_joints));
4925 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4926 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4927 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4928 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4929 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
4933 bleeding-=multiplier*.3;
4935 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4936 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
4940 if(neckspurtamount>0){
4941 neckspurtamount-=multiplier;
4942 neckspurtdelay-=multiplier*3;
4943 neckspurtparticledelay-=multiplier*3;
4944 if(neckspurtparticledelay<0&&neckspurtdelay>2){
4948 bloodvel.z=5*neckspurtamount;
4949 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4952 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
4954 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4955 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
4956 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);
4957 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);
4958 neckspurtparticledelay=.05;
4960 if(neckspurtdelay<0){
4965 if(deathbleeding>0&&dead!=2){
4966 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
4967 else bleeddelay-=5*multiplier/4;
4968 if(bleeddelay<0&&bloodtoggle){
4973 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4974 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
4975 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
4976 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);
4979 bloodloss+=deathbleeding*multiplier*80;
4980 deathbleeding-=multiplier*1.6;
4981 //if(id==0)deathbleeding-=multiplier*.2;
4982 if(deathbleeding<0)deathbleeding=0;
4983 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
4984 if(weaponactive!=-1){
4985 weapons.owner[weaponids[0]]=-1;
4986 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4987 weapons.velocity[weaponids[0]].x+=.01;
4988 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4989 weapons.missed[weaponids[0]]=1;
4990 weapons.hitsomething[weaponids[0]]=0;
4991 weapons.freetime[weaponids[0]]=0;
4992 weapons.firstfree[weaponids[0]]=1;
4993 weapons.physics[weaponids[0]]=1;
4996 weaponids[0]=weaponids[num_weapons];
4997 if(weaponstuck==num_weapons)weaponstuck=0;
5000 for(i=0;i<numplayers;i++){
5001 player[i].wentforweapon=0;
5013 if(!dead&&creature==wolftype){
5019 if(targetanimation==knifefollowedanim&&!skeleton.free){
5020 for(i=0;i<skeleton.num_joints;i++){
5021 skeleton.joints[i].velocity=0;
5022 skeleton.joints[i].velocity.y=-2;
5025 if(id!=0&&unconscioustime>.1){
5033 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
5036 bloodsize=5-realtexdetail;
5040 texdetailint=realtexdetail;
5041 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5042 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5043 endx=startx+bloodsize;
5044 endy=starty+bloodsize;
5046 if(startx<0){startx=0;bleeding=0;}
5047 if(starty<0){starty=0;bleeding=0;}
5048 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
5049 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
5050 if(endx<startx)endx=startx;
5051 if(endy<starty)endy=starty;
5053 for(i=startx;i<endx;i++){
5054 for(j=starty;j<endy;j++){
5056 color=Random()%85+170;
5057 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
5058 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
5059 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
5064 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5065 DoMipmaps(0,startx,endx,starty,endy);
5069 bleedy-=4/realtexdetail;
5070 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
5071 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
5074 bleedx+=4*direction/realtexdetail;
5075 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
5076 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
5080 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
5081 righthandmorphness=targetrighthandmorphness;
5082 righthandmorphstart=righthandmorphend;
5084 else if(righthandmorphness>targetrighthandmorphness){
5085 righthandmorphness-=multiplier*4;
5087 else if(righthandmorphness<targetrighthandmorphness){
5088 righthandmorphness+=multiplier*4;
5091 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
5092 lefthandmorphness=targetlefthandmorphness;
5093 lefthandmorphstart=lefthandmorphend;
5095 else if(lefthandmorphness>targetlefthandmorphness){
5096 lefthandmorphness-=multiplier*4;
5098 else if(lefthandmorphness<targetlefthandmorphness){
5099 lefthandmorphness+=multiplier*4;
5102 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
5103 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
5104 tailmorphness=targettailmorphness;
5105 tailmorphstart=tailmorphend;
5107 else if(tailmorphness>targettailmorphness){
5108 tailmorphness-=multiplier*10;
5110 else if(tailmorphness<targettailmorphness){
5111 tailmorphness+=multiplier*10;
5115 if(creature==wolftype){
5116 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
5117 tailmorphness=targettailmorphness;
5118 tailmorphstart=tailmorphend;
5120 else if(tailmorphness>targettailmorphness){
5121 tailmorphness-=multiplier*2;
5123 else if(tailmorphness<targettailmorphness){
5124 tailmorphness+=multiplier*2;
5128 if(headmorphend==3||headmorphstart==3){
5129 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
5130 headmorphness=targetheadmorphness;
5131 headmorphstart=headmorphend;
5133 else if(headmorphness>targetheadmorphness){
5134 headmorphness-=multiplier*7;
5136 else if(headmorphness<targetheadmorphness){
5137 headmorphness+=multiplier*7;
5140 else if(headmorphend==5||headmorphstart==5){
5141 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
5142 headmorphness=targetheadmorphness;
5143 headmorphstart=headmorphend;
5145 else if(headmorphness>targetheadmorphness){
5146 headmorphness-=multiplier*10;
5148 else if(headmorphness<targetheadmorphness){
5149 headmorphness+=multiplier*10;
5153 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5154 headmorphness=targetheadmorphness;
5155 headmorphstart=headmorphend;
5157 else if(headmorphness>targetheadmorphness){
5158 headmorphness-=multiplier*4;
5160 else if(headmorphness<targetheadmorphness){
5161 headmorphness+=multiplier*4;
5165 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5166 chestmorphness=targetchestmorphness;
5167 chestmorphstart=chestmorphend;
5169 else if(chestmorphness>targetchestmorphness){
5170 chestmorphness-=multiplier;
5172 else if(chestmorphness<targetchestmorphness){
5173 chestmorphness+=multiplier;
5176 if(dead!=2&&howactive<=typesleeping){
5177 if(chestmorphstart==0&&chestmorphend==0){
5179 targetchestmorphness=1;
5182 if(chestmorphstart!=0&&chestmorphend!=0){
5184 targetchestmorphness=1;
5186 if(environment==snowyenvironment){
5189 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5190 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5191 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5192 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5193 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5194 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5198 if(!dead&&howactive<typesleeping){
5199 blinkdelay-=multiplier*2;
5200 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5202 targetheadmorphness=1;
5204 blinkdelay=(float)(abs(Random()%40))/5;
5206 if(headmorphstart==3&&headmorphend==3){
5208 targetheadmorphness=1;
5213 twitchdelay-=multiplier*1.5;
5214 if(targetanimation!=hurtidleanim){
5215 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5217 targetheadmorphness=1;
5219 twitchdelay=(float)(abs(Random()%40))/5;
5221 if(headmorphstart==5&&headmorphend==5){
5223 targetheadmorphness=1;
5227 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5228 twitchdelay3-=multiplier*1;
5230 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5231 righthandmorphness=0;
5232 targetrighthandmorphness=1;
5233 righthandmorphend=1;
5234 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5236 if(righthandmorphstart==1&&righthandmorphend==1){
5237 righthandmorphness=0;
5238 targetrighthandmorphness=1;
5239 righthandmorphend=0;
5243 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5244 lefthandmorphness=0;
5245 targetlefthandmorphness=1;
5247 twitchdelay3=(float)(abs(Random()%40))/5;
5249 if(lefthandmorphstart==1&&lefthandmorphend==1){
5250 lefthandmorphness=0;
5251 targetlefthandmorphness=1;
5258 if(creature==rabbittype){
5259 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5260 else twitchdelay2-=multiplier*0.5;
5261 if(howactive<=typesleeping){
5262 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5264 targettailmorphness=1;
5266 twitchdelay2=(float)(abs(Random()%40))/5;
5268 if(tailmorphstart==1&&tailmorphend==1){
5270 targettailmorphness=1;
5273 if(tailmorphstart==2&&tailmorphend==2){
5275 targettailmorphness=1;
5282 if(creature==wolftype){
5283 twitchdelay2-=multiplier*1.5;
5285 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5287 targettailmorphness=1;
5292 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5294 targettailmorphness=1;
5298 if(twitchdelay2<=0){
5299 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5301 targettailmorphness=1;
5304 if(tailmorphstart==1&&tailmorphend==1){
5306 targettailmorphness=1;
5309 if(tailmorphstart==2&&tailmorphend==2){
5311 targettailmorphness=1;
5314 if(tailmorphstart==3&&tailmorphend==3){
5316 targettailmorphness=1;
5319 if(tailmorphstart==4&&tailmorphend==4){
5321 targettailmorphness=1;
5327 if(dead!=1)unconscioustime=0;
5329 if(dead==1||howactive==typesleeping){
5330 unconscioustime+=multiplier;
5331 //If unconscious, close eyes and mouth
5332 if(righthandmorphend!=0)righthandmorphness=0;
5333 righthandmorphend=0;
5334 targetrighthandmorphness=1;
5336 if(lefthandmorphend!=0)lefthandmorphness=0;
5338 targetlefthandmorphness=1;
5340 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5342 targetheadmorphness=1;
5346 if(howactive>typesleeping){
5349 if(bloodtoggle&&!bled){
5350 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5352 if(bloodtoggle&&!bled)
5353 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5354 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5355 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5359 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5364 if(dead==2||howactive>typesleeping){
5365 //If dead, open mouth and hands
5366 if(righthandmorphend!=0)righthandmorphness=0;
5367 righthandmorphend=0;
5368 targetrighthandmorphness=1;
5370 if(lefthandmorphend!=0)lefthandmorphness=0;
5372 targetlefthandmorphness=1;
5374 if(headmorphend!=2)headmorphness=0;
5376 targetheadmorphness=1;
5379 if(stunned>0&&!dead&&headmorphend!=2){
5380 if(headmorphend!=4)headmorphness=0;
5382 targetheadmorphness=1;
5385 if(damage>damagetolerance&&!dead){
5390 if(creature==wolftype){
5398 if(weaponactive!=-1){
5399 weapons.owner[weaponids[0]]=-1;
5400 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5401 weapons.velocity[weaponids[0]].x+=.01;
5402 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5403 weapons.missed[weaponids[0]]=1;
5404 weapons.hitsomething[weaponids[0]]=0;
5405 weapons.freetime[weaponids[0]]=0;
5406 weapons.firstfree[weaponids[0]]=1;
5407 weapons.physics[weaponids[0]]=1;
5410 weaponids[0]=weaponids[num_weapons];
5411 if(weaponstuck==num_weapons)weaponstuck=0;
5414 for(i=0;i<numplayers;i++){
5415 player[i].wentforweapon=0;
5421 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5429 //if(dead)damage-=multiplier/4;
5430 if(!dead)damage-=multiplier*13;
5431 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5432 if(!dead)permanentdamage-=multiplier*4;
5433 if(isIdle()||isCrouch()){
5434 if(!dead)permanentdamage-=multiplier*4;
5435 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5437 if(damage<0)damage=0;
5438 if(permanentdamage<0)permanentdamage=0;
5439 if(superpermanentdamage<0)superpermanentdamage=0;
5440 if(permanentdamage<superpermanentdamage){
5441 permanentdamage=superpermanentdamage;
5443 if(damage<permanentdamage){
5444 damage=permanentdamage;
5446 if(dead==1&&damage<damagetolerance){
5450 for(i=0;i<skeleton.num_joints;i++){
5451 skeleton.joints[i].velocity=0;
5454 if(permanentdamage>damagetolerance&&dead!=2){
5457 if(weaponactive!=-1){
5458 weapons.owner[weaponids[0]]=-1;
5459 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5460 weapons.velocity[weaponids[0]].x+=.01;
5461 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5462 weapons.missed[weaponids[0]]=1;
5463 weapons.hitsomething[weaponids[0]]=0;
5464 weapons.freetime[weaponids[0]]=0;
5465 weapons.firstfree[weaponids[0]]=1;
5466 weapons.physics[weaponids[0]]=1;
5469 weaponids[0]=weaponids[num_weapons];
5470 if(weaponstuck==num_weapons)weaponstuck=0;
5473 for(i=0;i<numplayers;i++){
5474 player[i].wentforweapon=0;
5480 if(!dead&&creature==wolftype){
5486 if(id!=0&&unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance){
5491 if(id!=0&&unconscioustime>.1){
5507 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5508 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5509 OPENAL_SetVolume(channels[breaksound], 512);
5510 OPENAL_SetPaused(channels[breaksound], false);
5511 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5517 if(skeleton.free==1){
5518 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5521 //If knocked over, open hands and close mouth
5522 if(righthandmorphend!=0)righthandmorphness=0;
5523 righthandmorphend=0;
5524 targetrighthandmorphness=1;
5526 if(lefthandmorphend!=0)lefthandmorphness=0;
5528 targetlefthandmorphness=1;
5530 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5531 if(headmorphend!=0)headmorphness=0;
5533 targetheadmorphness=1;
5537 skeleton.DoGravity(&scale);
5539 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5540 if(id!=0&&damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1)){
5545 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5549 for(j=0;j<skeleton.num_joints;j++){
5550 average+=skeleton.joints[j].position;
5554 coords+=average*scale;
5555 for(j=0;j<skeleton.num_joints;j++){
5556 skeleton.joints[j].position-=average;
5558 average/=multiplier;
5560 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5562 for(i=0;i<skeleton.num_joints;i++){
5563 velocity+=skeleton.joints[i].velocity*scale;
5565 velocity/=skeleton.num_joints;
5567 if(!isnormal(velocity.x)&&velocity.x){
5580 if(findLength(&average)<10&&dead&&skeleton.free){
5581 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5582 if(skeleton.longdead>2000){
5583 if(skeleton.longdead>6000){
5584 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5589 if(dead==2&&bloodloss<damagetolerance){
5591 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5593 if(bloodtoggle&&!bled){
5594 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5596 if(bloodtoggle&&!bled)
5597 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5598 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5599 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5603 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5607 if(dead==2&&bloodloss>=damagetolerance){
5609 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5610 if(bleeding<=0)DoBlood(1,255);
5611 if(bloodtoggle&&!bled){
5612 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5614 if(bloodtoggle&&!bled)
5615 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5616 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5617 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5621 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5628 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5630 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5634 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5635 if(velocity.y<-30)canrecover=0;
5636 for(i=0;i<objects.numobjects;i++){
5637 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5638 colviewer=startpoint;
5640 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5648 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5649 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5650 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5651 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5653 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5654 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5655 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5657 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5658 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5659 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5661 Normalise(&terrainnormal);
5663 targetrotation=-asin(0-terrainnormal.x);
5664 targetrotation*=360/6.28;
5665 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5666 rotation=targetrotation;
5668 //if(skeleton.forward.y<0){
5671 //if(skeleton.forward.y>-.3){
5674 targetanimation=flipanim;
5675 crouchtogglekeydown=1;
5680 currentanimation=tempanim;
5683 //tilt2=targettilt2;
5685 //if(middle.y>0)targetoffset.y=middle.y+1;
5687 for(i=0;i<skeleton.num_joints;i++){
5688 tempanimation.position[i][0]=skeleton.joints[i].position;
5689 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5694 if(findLength(&average)<10&&!dead&&skeleton.free){
5695 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5696 if(skeleton.longdead>(damage+500)*1.5){
5697 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5703 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5704 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5705 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5706 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5708 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5709 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5710 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5712 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5713 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5714 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5716 Normalise(&terrainnormal);
5718 targetrotation=-asin(0-terrainnormal.x);
5719 targetrotation*=360/6.28;
5720 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5721 rotation=targetrotation;
5724 terrainnormal=terrain.getNormal(coords.x,coords.z);
5725 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5729 /*XYZ otherterrainnormal;
5730 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5731 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5732 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5733 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5736 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5740 if(skeleton.forward.y<0){
5741 targetanimation=getupfrombackanim;
5745 if(skeleton.forward.y>-.3){
5746 targetanimation=getupfromfrontanim;
5748 targetrotation+=180;
5754 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5755 targetanimation=rollanim;
5756 targetrotation=lookrotation;
5760 if(forwardkeydown)targetrotation+=45;
5761 if(backkeydown)targetrotation-=45;
5765 if(forwardkeydown)targetrotation-=45;
5766 if(backkeydown)targetrotation+=45;
5769 if ( !leftkeydown&&!rightkeydown)
5770 targetrotation+=180;
5772 targetrotation+=180;
5776 if(abs(targettilt2)>50)targettilt2=0;
5777 currentanimation=tempanim;
5782 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5784 for(i=0;i<skeleton.num_joints;i++){
5785 tempanimation.position[i][0]=skeleton.joints[i].position;
5786 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5793 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5794 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5797 tempvelocity=velocity;
5798 Normalise(&tempvelocity);
5799 targetrotation=-asin(0-tempvelocity.x);
5800 targetrotation*=360/6.28;
5801 if(velocity.z<0)targetrotation=180-targetrotation;
5802 //targetrotation+=180;
5805 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5806 targetanimation=rollanim;
5810 targetanimation=backhandspringanim;
5811 targetrotation+=180;
5824 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
5825 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
5826 OPENAL_SetVolume(channels[movewhooshsound], 128);
5827 OPENAL_SetPaused(channels[movewhooshsound], false);
5829 currentanimation=targetanimation;
5830 currentframe=targetframe-1;
5835 rotation=targetrotation;
5842 if(skeleton.freefall==0)freefall=0;
5844 if(!isnormal(velocity.x)&&velocity.x){
5849 if(aitype!=passivetype||skeleton.free==1)
5850 if(findLengthfast(&velocity)>.1)
5851 for(i=0;i<objects.numobjects;i++){
5852 if(objects.type[i]==firetype)
5853 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){
5855 if(!objects.onfire[i]){
5858 gLoc[0]=objects.position[i].x;
5859 gLoc[1]=objects.position[i].y;
5860 gLoc[2]=objects.position[i].z;
5864 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5865 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5866 OPENAL_SetVolume(channels[firestartsound], 256);
5867 OPENAL_SetPaused(channels[firestartsound], false);
5869 objects.onfire[i]=1;
5872 if(objects.onfire[i]){
5877 if(objects.type[i]==bushtype)
5878 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){
5880 if(!objects.onfire[i]){
5883 gLoc[0]=objects.position[i].x;
5884 gLoc[1]=objects.position[i].y;
5885 gLoc[2]=objects.position[i].z;
5889 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5890 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5891 OPENAL_SetVolume(channels[firestartsound], 256);
5892 OPENAL_SetPaused(channels[firestartsound], false);
5894 objects.onfire[i]=1;
5898 if(objects.onfire[i]){
5902 if(objects.messedwith[i]<=0){
5914 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5915 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5916 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5917 OPENAL_SetPaused(channels[bushrustle], false);
5920 envsound[numenvsounds]=coords;
5921 envsoundvol[numenvsounds]=4*findLength(&velocity);
5922 envsoundlife[numenvsounds]=.4;
5927 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5928 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5930 if(environment!=desertenvironment)
5931 for(j=0;j<howmany;j++){
5932 tempvel.x=float(abs(Random()%100)-50)/20;
5933 tempvel.y=float(abs(Random()%100)-50)/20;
5934 tempvel.z=float(abs(Random()%100)-50)/20;
5937 pos.x+=float(abs(Random()%100)-50)/200;
5938 pos.y+=float(abs(Random()%100)-50)/200;
5939 pos.z+=float(abs(Random()%100)-50)/200;
5940 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);
5941 Sprite::setLastSpriteSpecial(1);
5943 howmany=findLength(&velocity)*4;
5945 if(environment==snowyenvironment)
5946 for(j=0;j<howmany;j++){
5947 tempvel.x=float(abs(Random()%100)-50)/20;
5948 tempvel.y=float(abs(Random()%100)-50)/20;
5949 tempvel.z=float(abs(Random()%100)-50)/20;
5952 pos.x+=float(abs(Random()%100)-50)/200;
5953 pos.y+=float(abs(Random()%100)-50)/200;
5954 pos.z+=float(abs(Random()%100)-50)/200;
5955 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5956 Sprite::setLastSpriteSpecial(2);
5959 objects.rotx[i]+=velocity.x*multiplier*6;
5960 objects.roty[i]+=velocity.z*multiplier*6;
5961 objects.messedwith[i]=.5;
5964 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
5965 if(objects.rotation2[i]==0)tempcoord=coords;
5967 tempcoord=coords-objects.position[i];
5968 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
5969 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
5970 tempcoord+=objects.position[i];
5972 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]){
5973 if(objects.messedwith[i]<=0){
5985 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5986 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5987 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5988 OPENAL_SetPaused(channels[bushrustle], false);
5991 envsound[numenvsounds]=coords;
5992 envsoundvol[numenvsounds]=4*findLength(&velocity);
5993 envsoundlife[numenvsounds]=.4;
5998 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5999 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6001 if(environment!=desertenvironment)
6002 for(j=0;j<howmany;j++){
6003 tempvel.x=float(abs(Random()%100)-50)/20;
6004 tempvel.y=float(abs(Random()%100)-50)/20;
6005 tempvel.z=float(abs(Random()%100)-50)/20;
6009 pos.x+=float(abs(Random()%100)-50)/150;
6010 pos.y+=float(abs(Random()%100)-50)/150;
6011 pos.z+=float(abs(Random()%100)-50)/150;
6012 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);
6013 Sprite::setLastSpriteSpecial(1);
6015 howmany=findLength(&velocity)*4;
6017 if(environment==snowyenvironment)
6018 for(j=0;j<howmany;j++){
6019 tempvel.x=float(abs(Random()%100)-50)/20;
6020 tempvel.y=float(abs(Random()%100)-50)/20;
6021 tempvel.z=float(abs(Random()%100)-50)/20;
6025 pos.x+=float(abs(Random()%100)-50)/150;
6026 pos.y+=float(abs(Random()%100)-50)/150;
6027 pos.z+=float(abs(Random()%100)-50)/150;
6028 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6029 Sprite::setLastSpriteSpecial(2);
6032 objects.messedwith[i]=.5;
6040 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
6042 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
6043 if(tutoriallevel==1&&id!=0)play=0;
6044 if(play&&aitype!=playercontrolled){
6056 if(creature==rabbittype){
6057 if(i==0)whichsound=rabbitchitter;
6058 if(i==1)whichsound=rabbitchitter2;
6060 if(creature==wolftype){
6061 if(i==0)whichsound=growlsound;
6062 if(i==1)whichsound=growl2sound;
6068 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
6069 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
6070 OPENAL_SetVolume(channels[whichsound], 512);
6071 OPENAL_SetPaused(channels[whichsound], false);
6075 if(targetanimation==staggerbackhighanim)staggerdelay=1;
6076 if(targetanimation==staggerbackhardanim)staggerdelay=1;
6077 staggerdelay-=multiplier;
6078 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
6079 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
6080 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
6081 targetanimation=getIdle();
6085 weaponmissdelay-=multiplier;
6086 highreversaldelay-=multiplier;
6087 lowreversaldelay-=multiplier;
6088 lastcollide-=multiplier;
6089 skiddelay-=multiplier;
6090 if(!isnormal(velocity.x)&&velocity.x){
6093 if(!isnormal(targettilt)&&targettilt){
6096 if(!isnormal(targettilt2)&&targettilt2){
6099 if(!isnormal(targetrotation)&&targetrotation){
6103 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
6104 //open hands and close mouth
6105 //if(targetanimation!=wolfidle){
6106 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6107 righthandmorphness=0;
6108 righthandmorphend=0;
6109 targetrighthandmorphness=1;
6112 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6113 lefthandmorphness=0;
6115 targetlefthandmorphness=1;
6119 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
6122 targetheadmorphness=1;
6126 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){
6127 //open hands and mouth
6128 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6129 righthandmorphness=0;
6130 righthandmorphend=0;
6131 targetrighthandmorphness=1;
6134 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6135 lefthandmorphness=0;
6137 targetlefthandmorphness=1;
6140 if(headmorphend!=1&&headmorphness==targetheadmorphness){
6143 targetheadmorphness=1;
6147 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
6148 //close hands and mouth
6149 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6150 righthandmorphness=0;
6151 righthandmorphend=1;
6152 targetrighthandmorphness=1;
6155 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6156 lefthandmorphness=0;
6158 targetlefthandmorphness=1;
6161 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6164 targetheadmorphness=1;
6168 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){
6169 //close hands and yell
6170 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6171 righthandmorphness=0;
6172 righthandmorphend=1;
6173 targetrighthandmorphness=1;
6176 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6177 lefthandmorphness=0;
6179 targetlefthandmorphness=1;
6182 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6185 targetheadmorphness=1;
6189 if(speechdelay>.25){
6190 if(headmorphend!=2)headmorphness=0;
6192 targetheadmorphness=1;
6198 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6199 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6203 if(!dead&&targetanimation!=hurtidleanim)
6204 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6205 if(headmorphend!=4||headmorphness==targetheadmorphness){
6208 targetheadmorphness=1;
6212 if(weaponactive!=-1){
6213 if(weapons.type[weaponids[weaponactive]]!=staff){
6214 righthandmorphstart=1;
6215 righthandmorphend=1;
6217 if(weapons.type[weaponids[weaponactive]]==staff){
6218 righthandmorphstart=2;
6219 righthandmorphend=2;
6221 targetrighthandmorphness=1;
6224 terrainnormal=terrain.getNormal(coords.x,coords.z);
6226 if(animation[targetanimation].attack!=reversal){
6227 if(!isnormal(coords.x))
6235 flatfacing=DoRotation(flatfacing,0,rotation,0);
6237 ReflectVector(&facing,terrainnormal);
6240 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6241 if(onterrain)targettilt2=-facing.y*20;
6245 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6246 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6247 flatvelocity=velocity;
6249 flatvelspeed=findLength(&flatvelocity);
6250 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6251 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6252 if(velocity.y<0)targettilt2*=-1;
6253 if(velocity.y<0)targettilt*=-1;
6254 if(targettilt>25)targettilt=25;
6255 if(targettilt<-25)targettilt=-25;
6258 if(targettilt2>45)targettilt2=45;
6259 if(targettilt2<-45)targettilt2=-45;
6260 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6261 else if(tilt2>targettilt2){
6262 tilt2-=multiplier*400;
6264 else if(tilt2<targettilt2){
6265 tilt2+=multiplier*400;
6267 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6268 if(tilt2>25)tilt2=25;
6269 if(tilt2<-25)tilt2=-25;
6272 if(!isnormal(targettilt)&&targettilt){
6275 if(!isnormal(targettilt2)&&targettilt2){
6280 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6281 if(targetanimation==rabbittackleanim){
6282 velocity+=facing*multiplier*speed*700*scale;
6283 velspeed=findLength(&velocity);
6284 if(velspeed>speed*65*scale){
6286 velspeed=speed*65*scale;
6289 velocity.y+=gravity*multiplier*20;
6290 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6291 velspeed=findLength(&velocity);
6292 velocity=flatfacing*velspeed;
6294 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6295 if(isRun()||targetanimation==rabbitkickanim){
6296 velocity+=facing*multiplier*speed*700*scale;
6297 velspeed=findLength(&velocity);
6298 if(velspeed>speed*45*scale){
6300 velspeed=speed*45*scale;
6303 velocity.y+=gravity*multiplier*20;
6304 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6305 velspeed=findLength(&velocity);
6306 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6307 velocity=flatfacing*velspeed;
6311 velocity+=facing*multiplier*speed*700*scale;
6312 velspeed=findLength(&velocity);
6313 if(creature==rabbittype){
6314 if(velspeed>speed*55*scale){
6316 velspeed=speed*55*scale;
6320 if(creature==wolftype){
6321 if(velspeed>speed*75*scale){
6323 velspeed=speed*75*scale;
6327 velocity.y+=gravity*multiplier*20;
6328 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6329 velspeed=findLength(&velocity);
6330 velocity=flatfacing*velspeed;
6333 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6334 velocity+=facing*multiplier*speed*700*scale;
6335 velspeed=findLength(&velocity);
6336 if(velspeed>speed*45*scale){
6338 velspeed=speed*45*scale;
6341 velocity.y+=gravity*multiplier*20;
6342 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6343 velspeed=findLength(&velocity);
6344 velocity=flatfacing*velspeed;
6348 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6349 velocity+=facing*multiplier*speed*700*scale;
6350 velspeed=findLength(&velocity);
6351 if(velspeed>speed*25*scale){
6353 velspeed=speed*25*scale;
6356 velocity.y+=gravity*multiplier*20;
6357 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6358 velspeed=findLength(&velocity);
6359 velocity=flatfacing*velspeed;
6362 if(targetanimation==sneakanim||targetanimation==walkanim){
6363 velocity+=facing*multiplier*speed*700*scale;
6364 velspeed=findLength(&velocity);
6365 if(velspeed>speed*12*scale){
6367 velspeed=speed*12*scale;
6370 velocity.y+=gravity*multiplier*20;
6371 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6372 velspeed=findLength(&velocity);
6373 velocity=flatfacing*velspeed;
6376 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6377 velocity+=facing*multiplier*speed*700*scale;
6378 velspeed=findLength(&velocity);
6379 if(velspeed>speed*2*scale){
6381 velspeed=speed*2*scale;
6384 velocity.y+=gravity*multiplier*20;
6385 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6386 velspeed=findLength(&velocity);
6387 velocity=flatfacing*velspeed;
6391 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6392 velocity-=facing*multiplier*speed*700*scale;
6393 velspeed=findLength(&velocity);
6394 if(velspeed>speed*2*scale){
6396 velspeed=speed*2*scale;
6399 velocity.y+=gravity*multiplier*20;
6400 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6401 velspeed=findLength(&velocity);
6402 velocity=flatfacing*velspeed*-1;
6405 if(targetanimation==fightsidestep){
6406 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6407 velspeed=findLength(&velocity);
6408 if(velspeed>speed*12*scale){
6410 velspeed=speed*12*scale;
6413 velocity.y+=gravity*multiplier*20;
6414 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6415 velspeed=findLength(&velocity);
6416 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6419 if(targetanimation==staggerbackhighanim){
6420 coords-=facing*multiplier*speed*16*scale;
6423 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6424 coords-=facing*multiplier*speed*20*scale;
6428 if(targetanimation==backhandspringanim){
6429 //coords-=facing*multiplier*50*scale;
6430 velocity+=facing*multiplier*speed*700*scale*-1;
6431 velspeed=findLength(&velocity);
6432 if(velspeed>speed*50*scale){
6434 velspeed=speed*50*scale;
6437 velocity.y+=gravity*multiplier*20;
6438 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6439 velspeed=findLength(&velocity);
6440 velocity=flatfacing*velspeed*-1;
6442 if(targetanimation==dodgebackanim){
6443 //coords-=facing*multiplier*50*scale;
6444 velocity+=facing*multiplier*speed*700*scale*-1;
6445 velspeed=findLength(&velocity);
6446 if(velspeed>speed*60*scale){
6448 velspeed=speed*60*scale;
6451 velocity.y+=gravity*multiplier*20;
6452 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6453 velspeed=findLength(&velocity);
6454 velocity=flatfacing*velspeed*-1;
6457 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6458 velspeed=findLength(&velocity);
6462 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6463 velocity.y+=gravity*multiplier;
6466 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6468 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6469 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6471 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6477 OPENAL_SetPaused(channels[whooshsound], true);
6478 OPENAL_SetVolume(channels[whooshsound], 0);
6481 if(targetanimation==jumpdownanim||isFlip()){
6482 if(isFlip())jumppower=-4;
6483 targetanimation=getLanding();
6492 PlaySoundEx( landsound, samp[landsound], NULL, true);
6493 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6494 OPENAL_SetVolume(channels[landsound], 128);
6495 OPENAL_SetPaused(channels[landsound], false);
6498 envsound[numenvsounds]=coords;
6499 envsoundvol[numenvsounds]=16;
6500 envsoundlife[numenvsounds]=.4;
6506 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6507 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6508 coords.y=terrain.getHeight(coords.x,coords.z);
6513 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)){
6514 velspeed=findLength(&velocity);
6516 if(velspeed<multiplier*300*scale){
6518 } else velocity-=velocity/velspeed*multiplier*300*scale;
6519 if(velspeed>5&&(isLanding()||isLandhard())){
6520 skiddingdelay+=multiplier;
6527 else skiddingdelay=0;
6531 velspeed=findLength(&velocity);
6533 if(velspeed<multiplier*600*scale){
6535 } else velocity-=velocity/velspeed*multiplier*600*scale;
6537 if(velspeed>5&&(isLanding()||isLandhard())){
6538 skiddingdelay+=multiplier;
6545 else skiddingdelay=0;
6548 if(skiddingdelay<0)skiddingdelay+=multiplier;
6549 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6559 if(!onterrain||environment==grassyenvironment){
6560 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6561 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6562 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6563 OPENAL_SetPaused(channels[skidsound], false);
6566 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6567 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6568 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6569 OPENAL_SetPaused(channels[snowskidsound], false);
6573 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6574 terrainnormal=victim->coords-coords;
6575 Normalise(&terrainnormal);
6576 targetrotation=-asin(0-terrainnormal.x);
6577 targetrotation*=360/6.28;
6578 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6579 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6582 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6583 targetrotation=victim->targetrotation;
6585 if(targetanimation==rabbittacklinganim){
6586 coords=victim->coords;
6589 skeleton.oldfree=skeleton.free;
6593 midterrain.x=terrain.size*terrain.scale/2;
6594 midterrain.z=terrain.size*terrain.scale/2;
6595 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6597 tempposit=coords-midterrain;
6599 Normalise(&tempposit);
6600 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6601 coords.x=tempposit.x+midterrain.x;
6602 coords.z=tempposit.z+midterrain.z;
6606 int Person::DrawSkeleton(){
6607 int oldplayerdetail;
6608 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6609 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6619 glAlphaFunc(GL_GREATER, 0.0001);
6621 float terrainheight;
6623 if(!isnormal(rotation))rotation=0;
6624 if(!isnormal(tilt))tilt=0;
6625 if(!isnormal(tilt2))tilt2=0;
6626 oldplayerdetail=playerdetail;
6628 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6631 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6634 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6639 if(playerdetail!=oldplayerdetail) {
6641 normalsupdatedelay=0;
6643 static float updatedelaychange;
6644 static float morphness;
6645 static float framemult;
6647 skeleton.FindForwards();
6648 if(howactive==typesittingwall){
6649 skeleton.specialforward[1]=0;
6650 skeleton.specialforward[1].z=1;
6656 static int weaponattachmuscle;
6657 static int weaponrotatemuscle,weaponrotatemuscle2;
6658 static XYZ weaponpoint;
6659 static int start,endthing;
6660 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6661 if(!isSleeping()&&!isSitting()){
6662 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6663 XYZ point,newpoint,change,change2;
6664 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6665 heightleft=terrain.getHeight(point.x,point.z)+.04;
6667 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6668 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6669 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6670 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6671 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6673 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6674 heightright=terrain.getHeight(point.x,point.z)+.04;
6675 point.y=heightright;
6676 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6677 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6678 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6679 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6680 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6681 skeleton.DoConstraints(&coords,&scale);
6683 if(creature==wolftype){
6684 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6685 heightleft=terrain.getHeight(point.x,point.z)+.04;
6687 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6688 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6689 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6690 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6691 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6693 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6694 heightright=terrain.getHeight(point.x,point.z)+.04;
6695 point.y=heightright;
6696 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6697 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6698 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6699 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6700 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6701 skeleton.DoConstraints(&coords,&scale);
6704 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6705 XYZ point,newpoint,change,change2;
6706 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6707 heightleft=terrain.getHeight(point.x,point.z)+.04;
6709 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6710 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6711 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6712 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6713 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6715 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6716 heightright=terrain.getHeight(point.x,point.z)+.04;
6717 point.y=heightright;
6718 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6719 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6720 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6721 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6722 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6723 skeleton.DoConstraints(&coords,&scale);
6725 if(creature==wolftype){
6726 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6727 heightleft=terrain.getHeight(point.x,point.z)+.04;
6729 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6730 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6731 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6732 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6733 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6735 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6736 heightright=terrain.getHeight(point.x,point.z)+.04;
6737 point.y=heightright;
6738 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6739 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6740 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6741 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6742 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6743 skeleton.DoConstraints(&coords,&scale);
6747 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6748 XYZ point,newpoint,change,change2;
6749 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6750 heightleft=terrain.getHeight(point.x,point.z)+.04;
6752 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6753 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6754 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6755 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6756 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6758 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6759 heightright=terrain.getHeight(point.x,point.z)+.04;
6760 point.y=heightright;
6761 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6762 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6763 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6764 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6765 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6766 skeleton.DoConstraints(&coords,&scale);
6768 if(creature==wolftype){
6769 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6770 heightleft=terrain.getHeight(point.x,point.z)+.04;
6772 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6773 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6774 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6775 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6776 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6778 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6779 heightright=terrain.getHeight(point.x,point.z)+.04;
6780 point.y=heightright;
6781 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6782 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6783 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6784 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6785 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6786 skeleton.DoConstraints(&coords,&scale);
6790 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()))
6793 targetheadrotation=-targetrotation;
6794 targetheadrotation2=0;
6795 if(animation[targetanimation].attack==3)targetheadrotation+=180;
6797 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6798 skeleton.drawmodel.vertex[i]=0;
6799 skeleton.drawmodel.vertex[i].y=999;
6801 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
6802 skeleton.drawmodellow.vertex[i]=0;
6803 skeleton.drawmodellow.vertex[i].y=999;
6805 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
6806 skeleton.drawmodelclothes.vertex[i]=0;
6807 skeleton.drawmodelclothes.vertex[i].y=999;
6809 for(i=0;i<skeleton.num_muscles;i++){
6810 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
6814 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
6815 morphness=righthandmorphness;
6816 start=righthandmorphstart;
6817 endthing=righthandmorphend;
6819 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
6820 morphness=lefthandmorphness;
6821 start=lefthandmorphstart;
6822 endthing=lefthandmorphend;
6824 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
6825 morphness=headmorphness;
6826 start=headmorphstart;
6827 endthing=headmorphend;
6829 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)){
6830 morphness=chestmorphness;
6831 start=chestmorphstart;
6832 endthing=chestmorphend;
6834 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)){
6835 morphness=tailmorphness;
6836 start=tailmorphstart;
6837 endthing=tailmorphend;
6839 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
6840 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6841 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6844 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6845 if(!skeleton.free)glRotatef(tilt,0,0,1);
6848 glTranslatef(mid.x,mid.y,mid.z);
6850 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6851 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6853 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6854 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6856 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6857 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6859 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
6863 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
6867 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
6871 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
6876 if(playerdetail||skeleton.free==3)
6878 for(j=0;j<skeleton.muscles[i].numvertices;j++)
6880 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
6881 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
6882 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
6883 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
6884 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
6885 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
6886 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
6887 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6889 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6890 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,
6891 (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,
6892 (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);
6893 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)
6894 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,
6895 (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,
6896 (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);
6897 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)
6898 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,
6899 (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,
6900 (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);
6901 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6902 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,
6903 (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,
6904 (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);
6905 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6906 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
6907 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
6908 //if(!isnormal(scale))test=1;
6909 //if(isnormal(scale)){
6910 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
6911 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
6912 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
6920 if(!playerdetail||skeleton.free==3)
6922 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
6924 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
6925 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6927 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6928 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
6929 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
6930 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
6931 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)
6932 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
6933 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
6934 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
6935 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)
6936 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
6937 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
6938 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
6939 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6940 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
6941 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
6942 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
6944 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6945 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
6946 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
6947 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
6954 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
6955 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6957 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6960 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6961 if(!skeleton.free)glRotatef(tilt,0,0,1);
6962 glTranslatef(mid.x,mid.y,mid.z);
6963 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6964 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6966 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6967 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6969 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6970 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6972 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
6973 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6975 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6976 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
6977 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
6978 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
6979 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)
6980 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
6981 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
6982 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
6983 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)
6984 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
6985 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
6986 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
6987 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6988 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
6989 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
6990 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
6991 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6992 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
6993 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
6994 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
6999 updatedelay=1+(float)(Random()%100)/1000;
7001 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
7002 normalsupdatedelay=1;
7003 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
7004 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
7005 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
7009 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
7010 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
7011 if(skeleton.clothes){
7012 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
7017 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
7018 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
7019 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
7020 if(skeleton.free==1)updatedelaychange*=6;
7021 if(id==0)updatedelaychange*=8;
7022 updatedelay+=updatedelaychange;
7024 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7026 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7027 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7028 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
7029 if(!skeleton.free)glRotatef(rotation,0,1,0);
7032 glColor4f(.4,1,.4,1);
7033 glDisable(GL_LIGHTING);
7034 glDisable(GL_TEXTURE_2D);
7037 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7038 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
7044 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
7045 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);
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[1]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].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[2]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].z);
7050 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);
7056 terrainlight=terrain.getLighting(coords.x,coords.z);
7057 distance=findDistancefast(&viewer,&coords);
7058 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
7059 if(distance>1)distance=1;
7061 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
7062 if(terrainheight<1)terrainheight=1;
7063 if(terrainheight>1.7)terrainheight=1.7;
7066 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
7067 glDisable(GL_BLEND);
7068 glAlphaFunc(GL_GREATER, 0.0001);
7069 glEnable(GL_TEXTURE_2D);
7071 glDisable(GL_TEXTURE_2D);
7072 glColor4f(.7,.35,0,.5);
7074 glEnable(GL_LIGHTING);
7077 if(tutoriallevel&&id!=0){
7078 //glDisable(GL_TEXTURE_2D);
7079 glColor4f(.7,.7,.7,0.6);
7081 glEnable(GL_LIGHTING);
7083 if(canattack&&cananger)
7084 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7085 glDisable(GL_TEXTURE_2D);
7086 glColor4f(1,0,0,0.8);
7088 glMatrixMode(GL_TEXTURE);
7090 glTranslatef(0,-smoketex,0);
7091 glTranslatef(-smoketex,0,0);
7095 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7096 else skeleton.drawmodel.draw();
7100 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7101 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7104 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
7105 if(tutoriallevel&&id!=0){
7107 glMatrixMode(GL_MODELVIEW);
7108 glEnable(GL_TEXTURE_2D);
7109 glColor4f(.7,.7,.7,0.6);
7111 glEnable(GL_LIGHTING);
7113 if(canattack&&cananger)
7114 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7115 glDisable(GL_TEXTURE_2D);
7116 glColor4f(1,0,0,0.8);
7118 glMatrixMode(GL_TEXTURE);
7120 glTranslatef(0,-smoketex*.6,0);
7121 glTranslatef(smoketex*.6,0,0);
7124 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7125 else skeleton.drawmodel.draw();
7129 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7130 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7135 if(tutoriallevel&&id!=0){
7137 glMatrixMode(GL_MODELVIEW);
7138 glEnable(GL_TEXTURE_2D);
7140 if(skeleton.clothes){
7143 if(!immediate)skeleton.drawmodelclothes.draw();
7144 if(immediate)skeleton.drawmodelclothes.drawimmediate();
7151 for(k=0;k<num_weapons;k++){
7153 if(weaponactive==k){
7154 if(weapons.type[i]!=staff){
7155 for(j=0;j<skeleton.num_muscles;j++){
7156 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7157 weaponattachmuscle=j;
7160 for(j=0;j<skeleton.num_muscles;j++){
7161 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){
7162 weaponrotatemuscle=j;
7165 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7166 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7168 if(weapons.type[i]==staff){
7169 for(j=0;j<skeleton.num_muscles;j++){
7170 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7171 weaponattachmuscle=j;
7174 for(j=0;j<skeleton.num_muscles;j++){
7175 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){
7176 weaponrotatemuscle=j;
7179 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7180 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7181 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7182 XYZ tempnormthing,vec1,vec2;
7183 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7184 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7185 CrossProduct(&vec1,&vec2,&tempnormthing);
7186 Normalise(&tempnormthing);
7187 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);
7188 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7190 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7191 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7192 Normalise(&weaptargnorm);
7193 weaponpoint-=weaptargnorm*2;
7197 if(weaponactive!=k&&weaponstuck!=k){
7198 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;
7199 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;
7200 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;
7201 for(j=0;j<skeleton.num_muscles;j++){
7202 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){
7203 weaponrotatemuscle=j;
7208 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7209 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7210 for(j=0;j<skeleton.num_muscles;j++){
7211 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){
7212 weaponrotatemuscle=j;
7217 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;
7218 weapons.bigrotation[i]=rotation;
7219 weapons.bigtilt[i]=tilt;
7220 weapons.bigtilt2[i]=tilt2;
7223 weapons.position[i]=weaponpoint*scale+coords;
7224 weapons.bigrotation[i]=0;
7225 weapons.bigtilt[i]=0;
7226 weapons.bigtilt2[i]=0;
7228 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7229 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7230 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7231 if(weaponactive==k){
7232 if(weapons.type[i]==knife){
7233 weapons.smallrotation[i]=180;
7234 weapons.smallrotation2[i]=0;
7235 if(isCrouch()||wasCrouch()){
7236 weapons.smallrotation2[i]=20;
7238 if(targetanimation==hurtidleanim){
7239 weapons.smallrotation2[i]=50;
7241 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7242 XYZ temppoint1,temppoint2,tempforward;
7245 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7246 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7247 distance=findDistance(&temppoint1,&temppoint2);
7248 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7249 weapons.rotation2[i]*=360/6.28;
7252 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7253 weapons.rotation1[i]*=360/6.28;
7254 weapons.rotation3[i]=0;
7255 weapons.smallrotation[i]=-90;
7256 weapons.smallrotation2[i]=0;
7257 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7259 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7260 XYZ temppoint1,temppoint2,tempforward;
7263 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7264 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7265 distance=findDistance(&temppoint1,&temppoint2);
7266 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7267 weapons.rotation2[i]*=360/6.28;
7270 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7271 weapons.rotation1[i]*=360/6.28;
7272 weapons.rotation3[i]=0;
7273 weapons.smallrotation[i]=90;
7274 weapons.smallrotation2[i]=0;
7275 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7277 if(targetanimation==knifethrowanim){
7278 weapons.smallrotation[i]=90;
7279 //weapons.smallrotation2[i]=-90;
7280 weapons.smallrotation2[i]=0;
7281 weapons.rotation1[i]=0;
7282 weapons.rotation2[i]=0;
7283 weapons.rotation3[i]=0;
7285 if(targetanimation==knifesneakattackanim&&targetframe<5){
7286 weapons.smallrotation[i]=-90;
7287 weapons.rotation1[i]=0;
7288 weapons.rotation2[i]=0;
7289 weapons.rotation3[i]=0;
7292 if(weapons.type[i]==sword){
7293 weapons.smallrotation[i]=0;
7294 weapons.smallrotation2[i]=0;
7295 if(targetanimation==knifethrowanim){
7296 weapons.smallrotation[i]=-90;
7297 weapons.smallrotation2[i]=0;
7298 weapons.rotation1[i]=0;
7299 weapons.rotation2[i]=0;
7300 weapons.rotation3[i]=0;
7302 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)){
7303 XYZ temppoint1,temppoint2,tempforward;
7306 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7307 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7308 distance=findDistance(&temppoint1,&temppoint2);
7309 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7310 weapons.rotation2[i]*=360/6.28;
7313 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7314 weapons.rotation1[i]*=360/6.28;
7315 weapons.rotation3[i]=0;
7316 weapons.smallrotation[i]=90;
7317 weapons.smallrotation2[i]=0;
7318 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7321 if(weapons.type[i]==staff){
7322 weapons.smallrotation[i]=100;
7323 weapons.smallrotation2[i]=0;
7324 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7325 XYZ temppoint1,temppoint2,tempforward;
7328 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7329 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7330 distance=findDistance(&temppoint1,&temppoint2);
7331 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7332 weapons.rotation2[i]*=360/6.28;
7335 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7336 weapons.rotation1[i]*=360/6.28;
7337 weapons.rotation3[i]=0;
7338 weapons.smallrotation[i]=90;
7339 weapons.smallrotation2[i]=0;
7340 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7344 if(weaponactive!=k&&weaponstuck!=k){
7345 if(weapons.type[i]==knife){
7346 weapons.smallrotation[i]=-70;
7347 weapons.smallrotation2[i]=10;
7349 if(weapons.type[i]==sword){
7350 weapons.smallrotation[i]=-100;
7351 weapons.smallrotation2[i]=-8;
7353 if(weapons.type[i]==staff){
7354 weapons.smallrotation[i]=-100;
7355 weapons.smallrotation2[i]=-8;
7359 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7360 else weapons.smallrotation[i]=0;
7361 weapons.smallrotation2[i]=10;
7362 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7370 if(skeleton.free)calcrot=1;
7371 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7372 if(currentanimation!=targetanimation)calcrot=1;
7373 //if(id==0)calcrot=1;
7374 if(skeleton.free==2)calcrot=0;
7380 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7383 static float distance;
7384 static float olddistance;
7385 static int intersecting;
7386 static int firstintersecting;
7389 static XYZ start,end;
7390 static float slopethreshold=-.4;
7392 firstintersecting=-1;
7396 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7397 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7399 for (j=0;j<model->TriangleNum;j++){
7400 if(model->facenormals[j].y<=slopethreshold){
7402 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)));
7403 if(distance<radius){
7404 point=*p1-model->facenormals[j]*distance;
7405 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;
7406 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7407 &model->vertex[model->Triangles[j].vertex[1]],
7409 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7410 &model->vertex[model->Triangles[j].vertex[2]],
7412 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7413 &model->vertex[model->Triangles[j].vertex[2]],
7416 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7420 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)){
7421 p1->y=point.y+radius;
7422 if((targetanimation==jumpdownanim||isFlip())){
7423 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7425 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7431 OPENAL_SetPaused(channels[whooshsound], true);
7432 OPENAL_SetVolume(channels[whooshsound], 0);
7435 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7436 if(isFlip())jumppower=-4;
7437 targetanimation=getLanding();
7446 PlaySoundEx( landsound, samp[landsound], NULL, true);
7447 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7448 OPENAL_SetVolume(channels[landsound], 128);
7449 OPENAL_SetPaused(channels[landsound], false);
7452 envsound[numenvsounds]=coords;
7453 envsoundvol[numenvsounds]=16;
7454 envsoundlife[numenvsounds]=.4;
7462 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7465 for (j=0;j<model->TriangleNum;j++){
7466 if(model->facenormals[j].y>slopethreshold){
7470 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)));
7471 if(distance<radius*.5){
7472 point=start-model->facenormals[j]*distance;
7473 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;
7474 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,
7475 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7476 p1->x, p1->y, p1->z, radius/2);
7477 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,
7478 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7479 p1->x, p1->y, p1->z, radius/2);
7480 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,
7481 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7482 p1->x, p1->y, p1->z, radius/2);
7484 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7485 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7487 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7488 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7490 *p1+=model->facenormals[j]*(distance-radius*.5);
7493 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7497 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7499 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7501 return firstintersecting;
7511 currentanimation = 0;
7512 targetanimation = 0;
7513 oldcurrentframe = 0;
7515 oldcurrentanimation = 0;
7516 oldtargetanimation = 0;
7520 parriedrecently = 0;
7524 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7526 currentoffset = 0,targetoffset = 0,offset = 0;
7544 unconscioustime = 0;
7562 rabbitkickenabled = 0;
7571 damagetolerance = 0;
7573 permanentdamage = 0;
7574 superpermanentdamage = 0; lastcollide = 0;
7594 headrotation = 0,headrotation2 = 0;
7595 targetheadrotation = 0,targetheadrotation2 = 0;
7606 normalsupdatedelay = 0;
7611 forwardstogglekeydown = 0;
7616 jumptogglekeydown = 0;
7618 crouchtogglekeydown = 0;
7620 drawtogglekeydown = 0;
7622 throwtogglekeydown = 0;
7628 crouchkeydowntime = 0;
7629 jumpkeydowntime = 0;
7646 whichdirectiondelay = 0;
7647 avoidsomething = 0; avoidwhere = 0;
7655 lefthandmorphness = 0;
7656 righthandmorphness = 0;
7660 targetlefthandmorphness = 0;
7661 targetrighthandmorphness = 0;
7662 targetheadmorphness = 0;
7663 targetchestmorphness = 0;
7664 targettailmorphness = 0;
7665 lefthandmorphstart = 0,lefthandmorphend = 0;
7666 righthandmorphstart = 0,righthandmorphend = 0;
7667 headmorphstart = 0,headmorphend = 0;
7668 chestmorphstart = 0,chestmorphend = 0;
7669 tailmorphstart = 0,tailmorphend = 0;
7671 weaponmissdelay = 0;
7672 highreversaldelay = 0;
7673 lowreversaldelay = 0;
7680 //Skeleton skeleton;
7699 memset(clothes, 0, sizeof(clothes));
7700 memset(clothestintr, 0, sizeof(clothestintr));
7701 memset(clothestintg, 0, sizeof(clothestintg));
7702 memset(clothestintb, 0, sizeof(clothestintb));
7708 onfiredelay = 0; burnt = 0;
7712 updatestuffdelay = 0;
7718 memset(weaponids, 0, sizeof(weaponids));
7722 weaponstuckwhere = 0;
7727 memset(waypoints, 0, sizeof(waypoints));
7728 memset(waypointtype, 0, sizeof(waypointtype));
7731 hastempwaypoint = 0;
7737 finalfinaltarget = 0;
7739 finalpathfindpoint = 0;
7740 targetpathfindpoint = 0;
7741 lastpathfindpoint = 0;
7742 lastpathfindpoint2 = 0;
7743 lastpathfindpoint3 = 0;
7744 lastpathfindpoint4 = 0;
7755 runninghowlong = 0; lastoccluded = 0;
7761 neckspurtparticledelay = 0;
7762 neckspurtamount = 0;
7765 rabbitkickragdoll = 0;
7770 //Animation tempanimation;