2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /**> HEADER FILES <**/
24 #include "openal_wrapper.h"
25 #include "Animation.h"
27 extern float multiplier;
28 extern OPENAL_SAMPLE *samp[100];
29 extern int channels[100];
30 extern Terrain terrain;
32 extern int environment;
34 extern FRUSTUM frustum;
36 extern float realmultiplier;
38 extern float slomodelay;
39 extern bool cellophane;
40 extern float texdetail;
41 extern float realtexdetail;
42 extern GLubyte bloodText[512*512*3];
43 extern GLubyte wolfbloodText[512*512*3];
44 extern int bloodtoggle;
45 extern Objects objects;
47 extern bool autoslomo;
48 extern float camerashake;
50 extern float terraindetail;
51 extern float viewdistance;
52 extern float blackout;
53 extern int difficulty;
54 extern Weapons weapons;
56 extern float fadestart;
57 extern Person player[maxplayers];
58 extern int numplayers;
60 extern bool winfreeze;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
63 extern bool showpoints;
64 extern bool immediate;
66 extern bool tilt2weird;
67 extern bool tiltweird;
69 extern bool proportionweird;
70 extern bool vertexweird[6];
71 extern GLubyte texturearray[512*512*3];
72 extern XYZ envsound[30];
73 extern float envsoundvol[30];
74 extern float envsoundlife[30];
75 extern int numenvsounds;
77 extern float bonusvalue;
78 extern float bonustotal;
79 extern float bonustime;
80 extern int tutoriallevel;
81 extern float smoketex;
82 extern int tutorialstage;
83 extern bool reversaltrain;
84 extern bool canattack;
86 extern float damagedealt;
87 extern float damagetaken;
89 extern float hostiletime;
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 OPENAL_STREAM * strm[20];
110 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
111 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
113 void Person::CheckKick(){
117 float damagemult=1*power;
118 if(creature==wolftype)damagemult=2.5*power;
122 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
123 if(findDistancefast(&coords,&victim->coords)<1.2){
124 if(!victim->skeleton.free){
126 Normalise(&relative);
127 relative=coords+relative*1;
128 if(animation[victim->targetanimation].height!=lowheight){
133 gLoc[0]=victim->coords.x;
134 gLoc[1]=victim->coords.y;
135 gLoc[2]=victim->coords.z;
139 if(tutoriallevel!=1){
140 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
141 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
142 OPENAL_SetVolume(channels[heavyimpactsound], 128);
143 OPENAL_SetPaused(channels[heavyimpactsound], false);
148 Normalise(&relative);
149 for(i=0;i<victim->skeleton.num_joints;i++){
150 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
153 victim->DoDamage(100*damagemult/victim->protectionhigh);
154 if(id==0)camerashake+=.4;
158 targetanimation=backflipanim;
163 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
165 //if(victim->damage>victim->damagetolerance){
173 else if (victim->isCrouch()){
174 targetanimation=rabbitkickreversedanim;
175 currentanimation=rabbitkickreversedanim;
176 victim->currentanimation=rabbitkickreversalanim;
177 victim->targetanimation=rabbitkickreversalanim;
183 victim->oldcoords=victim->coords;
184 coords=victim->coords;
185 victim->targetrotation=targetrotation;
193 void Person::CatchFire(){
194 XYZ flatfacing,flatvelocity;
196 for(int i=0;i<10;i++){
197 howmany=abs(Random()%(skeleton.num_joints));
198 if(!skeleton.free)flatvelocity=velocity;
199 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
200 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
201 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
202 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
215 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
216 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
217 OPENAL_SetVolume(channels[firestartsound], 256);
218 OPENAL_SetPaused(channels[firestartsound], false);
223 //PlaySoundEx( firesound, samp[firesound], NULL, true);
224 PlayStreamEx( stream_firesound, strm[stream_firesound], NULL, true);
225 OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
226 OPENAL_SetVolume(channels[stream_firesound], 256);
227 OPENAL_SetPaused(channels[stream_firesound], false);
234 bool Person::isIdle(){
235 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;
239 bool Person::isSitting(){
240 if(targetanimation==sitanim)return 1;
241 if(targetanimation==sitwallanim)return 1;
245 bool Person::isSleeping(){
246 if(targetanimation==sleepanim)return 1;
247 if(targetanimation==dead1anim)return 1;
248 if(targetanimation==dead2anim)return 1;
249 if(targetanimation==dead3anim)return 1;
250 if(targetanimation==dead4anim)return 1;
254 bool Person::wasIdle(){
255 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;
258 int Person::getIdle(){
259 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
260 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)){
261 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
262 if(creature==rabbittype)return fightidleanim;
263 if(creature==wolftype)return wolfidle;
265 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
266 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
267 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
268 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
269 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
271 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
273 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
274 if(howactive==typesitting)return sitanim;
275 if(howactive==typesittingwall)return sitwallanim;
276 if(howactive==typesleeping)return sleepanim;
277 if(howactive==typedead1)return dead1anim;
278 if(howactive==typedead2)return dead2anim;
279 if(howactive==typedead3)return dead3anim;
280 if(howactive==typedead4)return dead4anim;
281 if(creature==rabbittype)return bounceidleanim;
282 if(creature==wolftype)return wolfidle;
286 bool Person::isCrouch(){
287 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
292 bool Person::wasCrouch(){
293 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
296 int Person::getCrouch(){
297 if(creature==rabbittype)return crouchanim;
298 if(creature==wolftype)return wolfcrouchanim;
302 bool Person::isRun(){
303 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
308 bool Person::wasRun(){
309 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
312 int Person::getRun(){
313 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
314 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
316 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
317 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
321 bool Person::isStop(){
322 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
327 bool Person::wasStop(){
328 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
331 int Person::getStop(){
332 if(creature==rabbittype)return stopanim;
333 if(creature==wolftype)return wolfstopanim;
338 bool Person::isLanding(){
339 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
344 bool Person::wasLanding(){
345 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
348 int Person::getLanding(){
349 if(creature==rabbittype)return landanim;
350 if(creature==wolftype)return wolflandanim;
355 bool Person::isLandhard(){
356 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
361 bool Person::wasLandhard(){
362 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
365 int Person::getLandhard(){
366 if(creature==rabbittype)return landhardanim;
367 if(creature==wolftype)return wolflandhardanim;
372 bool Person::isFlip(){
373 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
377 bool Person::wasFlip(){
378 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
382 bool Person::isWallJump(){
383 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
387 void SolidHitBonus();
388 void SolidHitBonus(){
389 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
394 else if(bonustime<1.5&&bonus==threexcombo){
399 else if(bonustime<1.5&&bonus==twoxcombo){
404 else if(bonustime<1.5&&bonus==solidhit){
416 void Person::DoBlood(float howmuch,int which){
417 static int bleedxint,bleedyint;
419 //if(howmuch&&id==0)blooddimamount=1;
420 if(bloodtoggle&&tutoriallevel!=1){
421 if(bleeding<=0&&spurt){
423 for(int i=0;i<3;i++){
427 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
430 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
432 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
433 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
435 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
436 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
439 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);
440 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);
444 for(int i=0;i<3;i++){
448 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
449 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
452 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
453 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
457 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
459 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);
461 Sprite::setLastSpriteSpecial(3);
466 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
469 int texdetailint=realtexdetail;
470 if(creature==rabbittype)
471 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){
472 bleedxint=abs(Random()%512);
473 bleedyint=abs(Random()%512);
475 if(creature==wolftype)
476 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){
477 bleedxint=abs(Random()%512);
478 bleedyint=abs(Random()%512);
482 bleedy/=realtexdetail;
483 bleedx/=realtexdetail;
484 direction=abs(Random()%2)*2-1;
488 if(bleeding>2)bleeding=2;
491 void Person::DoBloodBig(float howmuch,int which){
492 static int bleedxint,bleedyint,i,j;
494 if(howmuch&&id==0)blooddimamount=1;
496 if(tutoriallevel!=1||id==0)
497 if(aitype!=playercontrolled&&howmuch>0){
508 if(creature==wolftype){
509 int i=abs(Random()%2);
510 if(i==0)whichsound=snarlsound;
511 if(i==1)whichsound=snarl2sound;
512 envsound[numenvsounds]=coords;
513 envsoundvol[numenvsounds]=16;
514 envsoundlife[numenvsounds]=.4;
517 if(creature==rabbittype){
518 int i=abs(Random()%2);
519 if(i==0)whichsound=rabbitpainsound;
520 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
521 envsound[numenvsounds]=coords;
522 envsoundvol[numenvsounds]=16;
523 envsoundlife[numenvsounds]=.4;
525 //if(i==2)whichsound=rabbitpain2sound;
529 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
530 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
531 OPENAL_SetVolume(channels[whichsound], 512);
532 OPENAL_SetPaused(channels[whichsound], false);
536 if(id==0&&howmuch>0){
544 if(bloodtoggle&&decals&&tutoriallevel!=1){
545 if(bleeding<=0&&spurt){
547 for(int i=0;i<3;i++){
551 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
554 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
556 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
557 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
559 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
560 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
563 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);
564 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);
568 int offsetx=0,offsety=0;
571 offsetx=abs(Random()%60);
573 if(which==190||which==185){
575 offsetx=abs(Random()%100)-20;
585 if(which==220||which==215){
586 //offsety=Random()%20;
588 //offsetx=abs(Random()%80);
597 if(creature==rabbittype)
600 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
601 if(i<startx)startx=i;
602 if(j<starty)starty=j;
608 if(creature==wolftype)
611 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
612 if(i<startx)startx=i;
613 if(j<starty)starty=j;
625 if(startx<0)startx=0;
626 if(starty<0)starty=0;
627 if(endx>512-1)endx=512-1;
628 if(endy>512-1)endy=512-1;
629 if(endx<startx)endx=startx;
630 if(endy<starty)endy=starty;
632 startx/=realtexdetail;
633 starty/=realtexdetail;
637 int texdetailint=realtexdetail;
639 if(creature==rabbittype)
640 for(i=startx;i<endx;i++){
641 for(j=starty;j<endy;j++){
642 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){
643 color=Random()%85+170;
644 where=i*skeleton.skinsize*3+j*3;
645 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
646 skeleton.skinText[where+1]=0;
647 skeleton.skinText[where+2]=0;
651 if(creature==wolftype)
652 for(i=startx;i<endx;i++){
653 for(j=starty;j<endy;j++){
654 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){
655 color=Random()%85+170;
656 where=i*skeleton.skinsize*3+j*3;
657 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
658 skeleton.skinText[where+1]=0;
659 skeleton.skinText[where+2]=0;
663 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
664 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
665 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
669 if(creature==rabbittype)
670 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){
671 bleedxint=abs(Random()%512);
672 bleedyint=abs(Random()%512);
674 if(creature==wolftype)
675 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){
676 bleedxint=abs(Random()%512);
677 bleedyint=abs(Random()%512);
679 bleedy=bleedxint+offsetx;
680 bleedx=bleedyint+offsety;
681 bleedy/=realtexdetail;
682 bleedx/=realtexdetail;
683 if(bleedx<0)bleedx=0;
684 if(bleedy<0)bleedy=0;
685 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
686 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
687 direction=abs(Random()%2)*2-1;
690 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
691 deathbleeding+=bleeding;
692 bloodloss+=bleeding*3;
694 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
695 if(abs(Random()%2)==0){aitype=gethelptype;
698 else aitype=attacktypecutoff;
701 if(bleeding>2)bleeding=2;
704 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
705 static int bleedxint,bleedyint,i,j;
707 static XYZ startpoint,endpoint,colpoint,movepoint;
708 static float rotationpoint;
710 static XYZ p1,p2,p3,p0;
714 float coordsx,coordsy;
717 if(bloodtoggle&&decals&&tutoriallevel!=1){
719 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
727 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
730 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
731 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
732 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
734 CrossProduct(p2-p1,p3-p1,&N);
735 CrossProduct(p0-p1,p3-p1,&temp);
736 s = dotproduct(&temp,&N)/findLength(&N);
737 CrossProduct(p2-p1,p1-p0,&temp);
738 t = dotproduct(&temp,&N)/findLength(&N);
741 bary.x=findDistancefast(&p0,&p1);
742 bary.y=findDistancefast(&p0,&p2);
743 bary.z=findDistancefast(&p0,&p3);
745 total=bary.x+bary.y+bary.z;
754 total=bary.x+bary.y+bary.z;
760 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
761 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
762 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
763 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
764 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
765 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
766 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;
767 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;
769 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
770 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
772 if(bleeding<=0&&spurt){
774 for(int i=0;i<3;i++){
778 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
781 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
783 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
784 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
786 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
787 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
790 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);
791 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);
795 int offsetx=0,offsety=0;
798 offsetx=abs(Random()%120);
800 if(which==220||which==215){
802 offsetx=abs(Random()%80);
805 offsetx=(1+coordsy)*512-291;
806 offsety=coordsx*512-437;
813 if(creature==rabbittype)
816 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
817 if(i<startx)startx=i;
818 if(j<starty)starty=j;
824 if(creature==wolftype)
827 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
828 if(i<startx)startx=i;
829 if(j<starty)starty=j;
840 if(startx<0)startx=0;
841 if(starty<0)starty=0;
842 if(endx>512-1)endx=512-1;
843 if(endy>512-1)endy=512-1;
844 if(endx<startx)endx=startx;
845 if(endy<starty)endy=starty;
847 startx/=realtexdetail;
848 starty/=realtexdetail;
852 int texdetailint=realtexdetail;
854 if(creature==rabbittype)
855 for(i=startx;i<endx;i++){
856 for(j=starty;j<endy;j++){
857 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){
858 color=Random()%85+170;
859 where=i*skeleton.skinsize*3+j*3;
860 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
861 skeleton.skinText[where+1]=0;
862 skeleton.skinText[where+2]=0;
864 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){
865 color=Random()%85+170;
866 where=i*skeleton.skinsize*3+j*3;
867 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
868 skeleton.skinText[where+1]=0;
869 skeleton.skinText[where+2]=0;
873 if(creature==wolftype)
874 for(i=startx;i<endx;i++){
875 for(j=starty;j<endy;j++){
876 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){
877 color=Random()%85+170;
878 where=i*skeleton.skinsize*3+j*3;
879 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
880 skeleton.skinText[where+1]=0;
881 skeleton.skinText[where+2]=0;
883 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){
884 color=Random()%85+170;
885 where=i*skeleton.skinsize*3+j*3;
886 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
887 skeleton.skinText[where+1]=0;
888 skeleton.skinText[where+2]=0;
892 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
893 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
894 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
896 bleedy=(1+coordsy)*512;
898 bleedy/=realtexdetail;
899 bleedx/=realtexdetail;
900 if(bleedx<0)bleedx=0;
901 if(bleedy<0)bleedy=0;
902 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
903 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
904 direction=abs(Random()%2)*2-1;
906 if(whichtri==-1)return 0;
908 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
909 deathbleeding+=bleeding;
910 bloodloss+=bleeding*3;
912 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
913 if(abs(Random()%2)==0){aitype=gethelptype;
916 else aitype=attacktypecutoff;
919 if(bleeding>2)bleeding=2;
924 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
927 static int bytesPerPixel=3;
928 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
929 static int newstartx,newstarty,newendx,newendy;
930 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
932 static float sizemult;
934 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
935 texture[i]=skeleton.skinText[i];
938 if((!osx||howmanylevels)){
940 if(startx<0)startx=0;
941 if(starty<0)starty=0;
942 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
943 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
944 if((endx>startx&&endy>starty)||howmanylevels){
951 for(i=startx;i<endx;i++){
952 for(j=starty;j<endy;j++){
953 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
954 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
955 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
959 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
962 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
963 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
964 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
967 newsize=skeleton.skinsize;
970 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
972 /*for(j=1;j<=howmanylevels;j++){
973 if(j==1)texpointer=&skeleton.skinText[0];
974 else texpointer=&texture[0];
976 totalsize=int( newsize*newsize*bytesPerPixel);
977 rowsize=int( newsize*bytesPerPixel );
978 bigstep=bytesPerPixel*newsize*2;
979 smallstep=bytesPerPixel*2;
985 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
992 void Person::Reverse(){
993 if(victim->aitype==playercontrolled||hostiletime>1)
994 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
995 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
996 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
997 if(targetanimation==sweepanim){
998 targetanimation=sweepreversedanim;
999 currentanimation=sweepreversedanim;
1000 victim->currentanimation=sweepreversalanim;
1001 victim->targetanimation=sweepreversalanim;
1003 if(targetanimation==spinkickanim){
1004 targetanimation=spinkickreversedanim;
1005 currentanimation=spinkickreversedanim;
1006 victim->currentanimation=spinkickreversalanim;
1007 victim->targetanimation=spinkickreversalanim;
1009 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
1010 if(targetanimation==rabbittacklinganim){
1013 victim->currentframe=6;
1014 victim->targetframe=7;
1016 targetanimation=upunchreversedanim;
1017 currentanimation=upunchreversedanim;
1018 victim->currentanimation=upunchreversalanim;
1019 victim->targetanimation=upunchreversalanim;
1021 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1022 if(victim->weaponactive!=-1){
1023 victim->throwtogglekeydown=1;
1024 weapons.owner[victim->weaponids[0]]=-1;
1025 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1026 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1027 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1028 weapons.missed[victim->weaponids[0]]=1;
1029 weapons.freetime[victim->weaponids[0]]=0;
1030 weapons.firstfree[victim->weaponids[0]]=1;
1031 weapons.physics[victim->weaponids[0]]=1;
1032 victim->num_weapons--;
1033 if(victim->num_weapons){
1034 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1035 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1038 victim->weaponactive=-1;
1039 for(int j=0;j<numplayers;j++){
1040 player[j].wentforweapon=0;
1044 targetanimation=staffhitreversedanim;
1045 currentanimation=staffhitreversedanim;
1046 victim->currentanimation=staffhitreversalanim;
1047 victim->targetanimation=staffhitreversalanim;
1049 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1050 if(victim->weaponactive!=-1){
1051 victim->throwtogglekeydown=1;
1052 weapons.owner[victim->weaponids[0]]=-1;
1053 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1054 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1055 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1056 weapons.missed[victim->weaponids[0]]=1;
1057 weapons.freetime[victim->weaponids[0]]=0;
1058 weapons.firstfree[victim->weaponids[0]]=1;
1059 weapons.physics[victim->weaponids[0]]=1;
1060 victim->num_weapons--;
1061 if(victim->num_weapons){
1062 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1063 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1066 victim->weaponactive=-1;
1067 for(int j=0;j<numplayers;j++){
1068 player[j].wentforweapon=0;
1071 targetanimation=staffspinhitreversedanim;
1072 currentanimation=staffspinhitreversedanim;
1073 victim->currentanimation=staffspinhitreversalanim;
1074 victim->targetanimation=staffspinhitreversalanim;
1076 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1077 if(victim->weaponactive!=-1){
1078 victim->throwtogglekeydown=1;
1079 weapons.owner[victim->weaponids[0]]=-1;
1080 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1081 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1082 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1083 weapons.missed[victim->weaponids[0]]=1;
1084 weapons.freetime[victim->weaponids[0]]=0;
1085 weapons.firstfree[victim->weaponids[0]]=1;
1086 weapons.physics[victim->weaponids[0]]=1;
1087 victim->num_weapons--;
1088 if(victim->num_weapons){
1089 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1090 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1093 victim->weaponactive=-1;
1094 for(int j=0;j<numplayers;j++){
1095 player[j].wentforweapon=0;
1098 targetanimation=swordslashreversedanim;
1099 currentanimation=swordslashreversedanim;
1100 victim->currentanimation=swordslashreversalanim;
1101 victim->targetanimation=swordslashreversalanim;
1103 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1104 if(victim->weaponactive!=-1){
1105 victim->throwtogglekeydown=1;
1106 weapons.owner[victim->weaponids[0]]=-1;
1107 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1108 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1109 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1110 weapons.missed[victim->weaponids[0]]=1;
1111 weapons.freetime[victim->weaponids[0]]=0;
1112 weapons.firstfree[victim->weaponids[0]]=1;
1113 weapons.physics[victim->weaponids[0]]=1;
1114 victim->num_weapons--;
1115 if(victim->num_weapons){
1116 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1117 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1120 victim->weaponactive=-1;
1121 for(int j=0;j<numplayers;j++){
1122 player[j].wentforweapon=0;
1125 targetanimation=knifeslashreversedanim;
1126 currentanimation=knifeslashreversedanim;
1127 victim->currentanimation=knifeslashreversalanim;
1128 victim->targetanimation=knifeslashreversalanim;
1130 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1131 victim->targettilt2=targettilt2;
1132 victim->currentframe=currentframe;
1133 victim->targetframe=targetframe;
1134 victim->target=target;
1136 victim->oldcoords=victim->coords;
1137 victim->coords=coords;
1138 victim->targetrotation=targetrotation;
1139 victim->rotation=targetrotation;
1140 victim->victim=this;
1142 if(targetanimation==winduppunchanim){
1143 targetanimation=winduppunchblockedanim;
1144 victim->targetanimation=blockhighleftanim;
1145 victim->targetframe=1;
1147 victim->victim=this;
1148 victim->targetrotation=targetrotation+180;
1150 if(targetanimation==wolfslapanim){
1151 targetanimation=winduppunchblockedanim;
1152 victim->targetanimation=blockhighleftanim;
1153 victim->targetframe=1;
1155 victim->victim=this;
1156 victim->targetrotation=targetrotation+180;
1158 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1159 targetanimation=swordslashparriedanim;
1161 victim->parriedrecently=0;
1162 victim->targetanimation=swordslashparryanim;
1163 victim->targetframe=1;
1165 victim->victim=this;
1166 victim->targetrotation=targetrotation+180;
1168 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1171 gLoc[0]=victim->coords.x;
1172 gLoc[1]=victim->coords.y;
1173 gLoc[2]=victim->coords.z;
1177 if(victim->weaponactive!=-1){
1178 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1179 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1180 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1182 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1183 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1184 OPENAL_SetVolume(channels[swordstaffsound], 512);
1185 OPENAL_SetPaused(channels[swordstaffsound], false);
1188 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1189 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1190 OPENAL_SetVolume(channels[metalhitsound], 512);
1191 OPENAL_SetPaused(channels[metalhitsound], false);
1195 victim->Puff(righthand);
1197 victim->targetframe=0;
1198 victim->targetanimation=staggerbackhighanim;
1199 victim->targetrotation=targetrotation+180;
1201 weapons.owner[victim->weaponids[0]]=-1;
1202 aim=DoRotation(facing,0,90,0)*21;
1204 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1205 weapons.tipvelocity[victim->weaponids[0]]=aim;
1206 weapons.missed[victim->weaponids[0]]=1;
1207 weapons.hitsomething[victim->weaponids[0]]=0;
1208 weapons.freetime[victim->weaponids[0]]=0;
1209 weapons.firstfree[victim->weaponids[0]]=1;
1210 weapons.physics[victim->weaponids[0]]=1;
1211 victim->num_weapons--;
1212 if(victim->num_weapons){
1213 victim->weaponids[0]=victim->weaponids[num_weapons];
1214 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1216 victim->weaponactive=-1;
1217 for(int i=0;i<numplayers;i++){
1218 player[i].wentforweapon=0;
1225 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1226 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1227 OPENAL_SetVolume(channels[metalhitsound], 512);
1228 OPENAL_SetPaused(channels[metalhitsound], false);*/
1231 if(abs(Random()%20)==0){
1240 if(weaponactive!=-1){
1241 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1242 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1243 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1245 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1246 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1247 OPENAL_SetVolume(channels[swordstaffsound], 512);
1248 OPENAL_SetPaused(channels[swordstaffsound], false);
1251 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1252 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1253 OPENAL_SetVolume(channels[metalhitsound], 512);
1254 OPENAL_SetPaused(channels[metalhitsound], false);
1262 targetanimation=staggerbackhighanim;
1263 targetrotation=targetrotation+180;
1265 weapons.owner[weaponids[0]]=-1;
1266 aim=DoRotation(facing,0,90,0)*21;
1268 weapons.velocity[weaponids[0]]=aim*-.2;
1269 weapons.tipvelocity[weaponids[0]]=aim;
1270 weapons.hitsomething[weaponids[0]]=0;
1271 weapons.missed[weaponids[0]]=1;
1272 weapons.freetime[weaponids[0]]=0;
1273 weapons.firstfree[weaponids[0]]=1;
1274 weapons.physics[weaponids[0]]=1;
1277 weaponids[0]=weaponids[num_weapons];
1278 if(weaponstuck==num_weapons)weaponstuck=0;
1281 for(int i=0;i<numplayers;i++){
1282 player[i].wentforweapon=0;
1286 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1287 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1288 OPENAL_SetVolume(channels[metalhitsound], 512);
1289 OPENAL_SetPaused(channels[metalhitsound], false);*/
1293 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1294 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1295 //victim->targetanimation=sweepanim;
1296 victim->targetanimation=dodgebackanim;
1297 victim->targetframe=0;
1299 //victim->velocity=0;
1302 rotatetarget=coords-victim->coords;
1303 Normalise(&rotatetarget);
1304 victim->targetrotation=-asin(0-rotatetarget.x);
1305 victim->targetrotation*=360/6.28;
1306 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1308 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1310 victim->lastattack3=victim->lastattack2;
1311 victim->lastattack2=victim->lastattack;
1312 victim->lastattack=victim->targetanimation;
1316 victim->targetanimation=sweepanim;
1317 victim->targetframe=0;
1321 rotatetarget=coords-victim->coords;
1322 Normalise(&rotatetarget);
1323 victim->targetrotation=-asin(0-rotatetarget.x);
1324 victim->targetrotation*=360/6.28;
1325 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1327 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1329 victim->lastattack3=victim->lastattack2;
1330 victim->lastattack2=victim->lastattack;
1331 victim->lastattack=victim->targetanimation;
1338 if(aitype!=playercontrolled)feint=0;
1339 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1340 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1341 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1343 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1347 void Person::DoDamage(float howmuch){
1348 if(tutoriallevel!=1)damage+=howmuch/power;
1349 if(id!=0)damagedealt+=howmuch/power;
1350 if(id==0)damagetaken+=howmuch/power;
1352 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1353 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1354 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1355 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1356 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1358 if(id==0)camerashake+=howmuch/100;
1359 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1360 if(blackout>1)blackout=1;
1362 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1363 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1364 if(abs(Random()%2)==0){aitype=gethelptype;
1367 else aitype=attacktypecutoff;
1371 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1374 for(int i=0;i<skeleton.num_joints; i++){
1375 if(!skeleton.free)flatvelocity2=velocity;
1376 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1377 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1378 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1379 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1380 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1381 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1382 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1383 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1384 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1395 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1396 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1397 OPENAL_SetVolume(channels[splattersound], 256);
1398 OPENAL_SetPaused(channels[splattersound], false);
1407 if(!dead&&creature==wolftype){
1416 if(tutoriallevel!=1||id==0)
1417 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1428 if(creature==wolftype){
1429 int i=abs(Random()%2);
1430 if(i==0)whichsound=snarlsound;
1431 if(i==1)whichsound=snarl2sound;
1432 envsound[numenvsounds]=coords;
1433 envsoundvol[numenvsounds]=16;
1434 envsoundlife[numenvsounds]=.4;
1437 if(creature==rabbittype){
1438 int i=abs(Random()%2);
1439 if(i==0)whichsound=rabbitpainsound;
1440 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1441 envsound[numenvsounds]=coords;
1442 envsoundvol[numenvsounds]=16;
1443 envsoundlife[numenvsounds]=.4;
1445 //if(i==2)whichsound=rabbitpain2sound;
1449 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1450 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1451 OPENAL_SetVolume(channels[whichsound], 512);
1452 OPENAL_SetPaused(channels[whichsound], false);
1457 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1458 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1461 void Person::DoHead(){
1462 static XYZ rotatearound;
1464 static float lookspeed=500;
1466 if(!freeze&&!winfreeze){
1469 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1470 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1472 while(targetheadrotation>180)targetheadrotation-=360;
1473 while(targetheadrotation<-180)targetheadrotation+=360;
1475 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1476 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1477 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1478 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1480 if(targetheadrotation2>120)targetheadrotation2=120;
1481 if(targetheadrotation2<-120)targetheadrotation2=-120;
1482 if(targetheadrotation>120)targetheadrotation=120;
1483 if(targetheadrotation<-120)targetheadrotation=-120;
1485 if(!isIdle())targetheadrotation2=0;
1487 if(targetheadrotation>80)targetheadrotation=80;
1488 if(targetheadrotation<-80)targetheadrotation=-80;
1489 if(targetheadrotation2>50)targetheadrotation2=50;
1490 if(targetheadrotation2<-50)targetheadrotation2=-50;
1493 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1494 else if(headrotation>targetheadrotation){
1495 headrotation-=multiplier*lookspeed;
1497 else if(headrotation<targetheadrotation){
1498 headrotation+=multiplier*lookspeed;
1501 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1502 else if(headrotation2>targetheadrotation2){
1503 headrotation2-=multiplier*lookspeed/2;
1505 else if(headrotation2<targetheadrotation2){
1506 headrotation2+=multiplier*lookspeed/2;
1509 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1510 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1514 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1515 facing=DoRotation(facing,headrotation2*.4,0,0);
1516 facing=DoRotation(facing,0,headrotation*.4,0);
1519 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1520 facing=DoRotation(facing,headrotation2*.8,0,0);
1521 facing=DoRotation(facing,0,headrotation*.8,0);
1524 if(targetanimation==walkanim){
1525 facing=DoRotation(facing,headrotation2*.6,0,0);
1526 facing=DoRotation(facing,0,headrotation*.6,0);
1529 skeleton.specialforward[0]=facing;
1530 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1532 for(i=0;i<skeleton.num_muscles;i++){
1533 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1535 skeleton.FindRotationMuscle(i,targetanimation);
1541 void Person::RagDoll(bool checkcollision){
1546 if(id==0)numfalls++;
1547 if(id==0&&isFlip())numflipfail++;
1553 facing=DoRotation(facing,0,rotation,0);
1555 skeleton.freetime=0;
1557 skeleton.longdead=0;
1563 skeleton.freefall=1;
1565 if(!isnormal(velocity.x))velocity.x=0;
1566 if(!isnormal(velocity.y))velocity.y=0;
1567 if(!isnormal(velocity.z))velocity.z=0;
1568 if(!isnormal(rotation))rotation=0;
1569 if(!isnormal(coords.x))coords=0;
1570 if(!isnormal(tilt))tilt=0;
1571 if(!isnormal(tilt2))tilt2=0;
1573 for(i=0;i<skeleton.num_joints;i++){
1574 skeleton.joints[i].delay=0;
1575 skeleton.joints[i].locked=0;
1576 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1577 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1578 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1579 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1580 skeleton.joints[i].position.y+=.1;
1581 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1582 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1585 for(i=0;i<skeleton.num_joints;i++){
1586 skeleton.joints[i].velocity=0;
1587 skeleton.joints[i].velchange=0;
1589 skeleton.DoConstraints(&coords,&scale);
1590 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1592 skeleton.DoConstraints(&coords,&scale);
1593 skeleton.DoConstraints(&coords,&scale);
1594 skeleton.DoConstraints(&coords,&scale);
1595 skeleton.DoConstraints(&coords,&scale);
1598 speed=animation[targetanimation].speed[targetframe]*2;
1599 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1600 speed=animation[currentanimation].speed[currentframe]*2;
1602 if(transspeed)speed=transspeed*2;
1606 for(i=0;i<skeleton.num_joints;i++){
1607 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);
1608 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1609 change.x=(float)(Random()%100)/100;
1610 change.y=(float)(Random()%100)/100;
1611 change.z=(float)(Random()%100)/100;
1612 skeleton.joints[i].velocity+=change;
1613 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1615 change.x=(float)(Random()%100)/100;
1616 change.y=(float)(Random()%100)/100;
1617 change.z=(float)(Random()%100)/100;
1618 skeleton.joints[i].velchange+=change;
1619 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1629 for(j=0;j<skeleton.num_joints;j++){
1630 average+=skeleton.joints[j].position;
1634 coords+=average*scale;
1635 for(j=0;j<skeleton.num_joints;j++){
1636 skeleton.joints[j].position-=average;
1639 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1640 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1641 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1642 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1643 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1646 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1647 coords.x=lowpoint.x;
1648 coords.z=lowpoint.z;
1657 for(i=0;i<skeleton.num_joints;i++){
1658 velocity+=skeleton.joints[i].velocity*scale;
1660 velocity/=skeleton.num_joints;
1663 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1664 weapons.owner[weaponids[0]]=-1;
1665 weapons.hitsomething[weaponids[0]]=0;
1666 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1667 weapons.velocity[weaponids[0]].x+=.01;
1668 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1669 weapons.missed[weaponids[0]]=1;
1670 weapons.freetime[weaponids[0]]=0;
1671 weapons.firstfree[weaponids[0]]=1;
1672 weapons.physics[weaponids[0]]=1;
1675 weaponids[0]=weaponids[num_weapons];
1676 if(weaponstuck==num_weapons)weaponstuck=0;
1679 for(i=0;i<numplayers;i++){
1680 player[i].wentforweapon=0;
1685 targetanimation=bounceidleanim;
1686 currentanimation=bounceidleanim;
1694 void Person::FootLand(int which, float opacity){
1695 static XYZ terrainlight;
1696 static XYZ footvel,footpoint;
1697 if(opacity>=1||skiddelay<=0)
1701 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1702 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1703 //footpoint.y=coords.y;
1704 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1706 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1708 if(footvel.y<.8)footvel.y=.8;
1709 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1710 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1711 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1712 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1713 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1714 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1716 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1718 if(footvel.y<.8)footvel.y=.8;
1719 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1720 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1721 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1722 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1723 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);
1725 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1727 if(footvel.y<.8)footvel.y=.8;
1728 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1729 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1730 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1731 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1732 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);
1733 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1735 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1738 if(footvel.y<.8)footvel.y=.8;
1739 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1740 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1741 //footpoint.y=coords.y;
1742 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1746 void Person::Puff(int whichlabel){
1747 static XYZ footvel,footpoint;
1750 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1751 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1755 void Person::DoAnimations(){
1758 static float oldtarget;
1760 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1762 if(targetanimation==tempanim||currentanimation==tempanim){
1763 animation[tempanim]=tempanimation;
1765 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1776 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1777 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1779 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1780 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1782 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1787 targfacing=DoRotation(targfacing,0,targetrotation,0);
1789 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1790 else targetanimation=backflipanim;
1791 crouchtogglekeydown=1;
1795 if(id==0)numflipped++;
1798 if(animation[targetanimation].attack!=reversed)feint=0;
1799 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1800 crouchtogglekeydown=0;
1801 if(aitype==playercontrolled)feint=0;
1805 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1806 if(!isFlip())crouchtogglekeydown=1;
1810 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1811 if(detail)normalsupdatedelay=0;
1815 if(targetanimation==rollanim&&targetframe==3&&onfire){
1825 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1826 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1827 OPENAL_SetVolume(channels[fireendsound], 256);
1828 OPENAL_SetPaused(channels[fireendsound], false);
1829 OPENAL_SetPaused(channels[stream_firesound], true);
1833 if(targetanimation==rabbittacklinganim&&targetframe==1){
1834 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1835 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1836 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1837 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1838 else victim->targetanimation=rabbittackledfrontanim;
1839 victim->targetframe=2;
1841 victim->rotation=rotation;
1842 victim->targetrotation=rotation;
1843 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1844 //victim->DoDamage(30);
1845 if(creature==wolftype){
1849 gLoc[0]=victim->coords.x;
1850 gLoc[1]=victim->coords.y;
1851 gLoc[2]=victim->coords.z;
1855 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
1856 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
1857 OPENAL_SetVolume(channels[clawslicesound], 128);
1858 OPENAL_SetPaused(channels[clawslicesound], false);
1860 victim->DoBloodBig(1/victim->armorhead,210);
1866 if(victim->aitype==gethelptype)bonusvalue=50;
1871 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1872 if(weapons.type[weaponids[0]]==knife){
1873 if(weaponactive==-1)weaponactive=0;
1874 else if(weaponactive==0)weaponactive=-1;
1876 if(weaponactive==-1){
1886 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
1887 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
1888 OPENAL_SetVolume(channels[knifesheathesound], 128);
1889 OPENAL_SetPaused(channels[knifesheathesound], false);
1891 if(weaponactive!=-1){
1901 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1902 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1903 OPENAL_SetVolume(channels[knifedrawsound], 128);
1904 OPENAL_SetPaused(channels[knifedrawsound], false);
1907 drawtogglekeydown=1;
1910 if(tutoriallevel!=1||id==0)
1911 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1922 if(terrain.getOpacity(coords.x,coords.z)<.2){
1923 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1924 else whichsound=footstepsound2;
1925 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1926 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1927 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1933 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1934 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1935 else whichsound=footstepsound4;
1939 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1940 else whichsound=footstepsound4;
1942 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1943 if(animation[targetanimation].attack!=neutral){
1945 if(i==0)whichsound=lowwhooshsound;
1946 if(i==1)whichsound=midwhooshsound;
1947 if(i==2)whichsound=highwhooshsound;
1949 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1951 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1952 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1954 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1955 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1956 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
1957 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
1958 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
1959 OPENAL_SetPaused(channels[whichsound], false);
1962 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1963 envsound[numenvsounds]=coords;
1964 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1965 else envsoundvol[numenvsounds]=6;
1966 envsoundlife[numenvsounds]=.4;
1970 if(animation[targetanimation].label[targetframe]==3){
1972 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1973 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1974 OPENAL_SetVolume(channels[whichsound], 128);
1975 OPENAL_SetPaused(channels[whichsound], false);
1980 if(tutoriallevel!=1||id==0)
1982 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1983 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1993 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1994 if(animation[targetanimation].attack!=neutral){
1996 if(creature==rabbittype){
1997 if(i==0)whichsound=rabbitattacksound;
1998 if(i==1)whichsound=rabbitattack2sound;
1999 if(i==2)whichsound=rabbitattack3sound;
2000 if(i==3)whichsound=rabbitattack4sound;
2002 if(creature==wolftype){
2003 if(i==0)whichsound=barksound;
2004 if(i==1)whichsound=bark2sound;
2005 if(i==2)whichsound=bark3sound;
2006 if(i==3)whichsound=barkgrowlsound;
2010 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2012 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2013 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
2016 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2017 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2018 OPENAL_SetVolume(channels[whichsound], 512);
2019 OPENAL_SetPaused(channels[whichsound], false);
2025 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
2031 currentoffset=targetoffset;
2032 targetframe=currentframe;
2033 currentanimation=targetanimation;
2036 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
2037 for(i=0;i<weapons.numweapons;i++){
2038 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
2039 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
2040 if(findDistancefast(&coords,&weapons.position[i])>=1){
2041 if(weapons.type[i]!=staff){
2050 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2051 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2052 OPENAL_SetVolume(channels[knifedrawsound], 128);
2053 OPENAL_SetPaused(channels[knifedrawsound], false);
2057 weapons.owner[i]=id;
2059 weaponids[num_weapons]=weaponids[0];
2068 static bool willwork;
2069 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2070 for(i=0;i<weapons.numweapons;i++){
2072 if(weapons.owner[i]!=-1)
2073 if(player[weapons.owner[i]].weaponstuck!=-1)
2074 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2075 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2076 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))
2077 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2078 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2088 if(weapons.owner[i]!=-1)
2089 if(victim->weaponstuck!=-1){
2090 if(victim->weaponids[victim->weaponstuck]==i){
2095 if(weapons.type[i]!=staff){
2096 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2097 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2098 OPENAL_SetVolume(channels[knifedrawsound], 128);
2099 OPENAL_SetPaused(channels[knifedrawsound], false);
2103 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2104 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2105 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2106 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2109 if(weapons.owner[i]!=-1){
2111 victim=&player[weapons.owner[i]];
2112 if(victim->num_weapons==1)victim->num_weapons=0;
2113 else victim->num_weapons=1;
2115 //victim->weaponactive=-1;
2116 victim->skeleton.longdead=0;
2117 victim->skeleton.free=1;
2118 victim->skeleton.broken=0;
2120 for(int j=0;j<victim->skeleton.num_joints;j++){
2121 victim->skeleton.joints[j].velchange=0;
2122 victim->skeleton.joints[j].locked=0;
2128 Normalise(&relative);
2129 XYZ footvel,footpoint;
2131 footpoint=weapons.position[i];
2132 if(victim->weaponstuck!=-1){
2133 if(victim->weaponids[victim->weaponstuck]==i){
2134 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2135 weapons.bloody[i]=2;
2136 weapons.blooddrip[i]=5;
2137 victim->weaponstuck=-1;
2140 if(victim->num_weapons>0){
2141 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2142 if(victim->weaponids[0]==i)
2143 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2146 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2147 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2148 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2149 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2151 weapons.owner[i]=id;
2153 weaponids[num_weapons]=weaponids[0];
2162 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2163 if(weaponactive==-1)weaponactive=0;
2164 else if(weaponactive==0){
2168 buffer=weaponids[0];
2169 weaponids[0]=weaponids[1];
2170 weaponids[1]=buffer;
2173 if(weaponactive==-1){
2183 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2184 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2185 OPENAL_SetVolume(channels[knifesheathesound], 128);
2186 OPENAL_SetPaused(channels[knifesheathesound], false);
2188 if(weaponactive!=-1){
2198 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2199 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2200 OPENAL_SetVolume(channels[knifedrawsound], 128);
2201 OPENAL_SetPaused(channels[knifedrawsound], false);
2206 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2207 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2208 Normalise(&rotatetarget);
2209 targetrotation=-asin(0-rotatetarget.x);
2210 targetrotation*=360/6.28;
2211 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2213 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2214 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2219 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2221 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;
2223 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2224 targetanimation=rabbittackleanim;
2235 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2236 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2237 OPENAL_SetVolume(channels[jumpsound], 128);
2238 OPENAL_SetPaused(channels[jumpsound], false);
2247 Normalise(&targetloc);
2249 for(i=0;i<numplayers;i++){
2251 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2252 closestdist=findDistancefast(&targetloc,&player[i].coords);
2257 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2259 victim=&player[closestid];
2260 coords=victim->coords;
2261 currentanimation=rabbittacklinganim;
2262 targetanimation=rabbittacklinganim;
2266 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2267 rotatetarget=coords-victim->coords;
2268 Normalise(&rotatetarget);
2269 targetrotation=-asin(0-rotatetarget.x);
2270 targetrotation*=360/6.28;
2271 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2273 if(targetanimation!=rabbitrunninganim){
2283 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2284 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2285 OPENAL_SetVolume(channels[jumpsound], 128);
2286 OPENAL_SetPaused(channels[jumpsound], false);
2292 float damagemult=1*power;
2293 if(creature==wolftype)damagemult=2.5*power;
2294 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2295 //if(onfire)damagemult=3;
2296 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2297 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2298 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2300 if(id==0)camerashake+=.4;
2301 if(Random()%2||creature==wolftype){
2304 if(creature==wolftype)DoBloodBig(0,250);
2308 gLoc[0]=victim->coords.x;
2309 gLoc[1]=victim->coords.y;
2310 gLoc[2]=victim->coords.z;
2314 if(tutoriallevel!=1){
2315 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2316 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2317 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2318 OPENAL_SetPaused(channels[heavyimpactsound], false);
2320 if(creature==wolftype){
2321 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2322 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2323 OPENAL_SetVolume(channels[clawslicesound], 128);
2324 OPENAL_SetPaused(channels[clawslicesound], false);
2326 victim->DoBloodBig(2/victim->armorhead,175);
2330 relative=victim->coords-coords;
2332 Normalise(&relative);
2333 relative=DoRotation(relative,0,-90,0);
2334 for(i=0;i<victim->skeleton.num_joints;i++){
2335 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2337 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2340 victim->DoDamage(damagemult*100/victim->protectionhead);
2348 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2349 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2351 if(id==0)camerashake+=.4;
2352 if(Random()%2||creature==wolftype){
2354 if(creature==wolftype)DoBloodBig(0,235);
2358 gLoc[0]=victim->coords.x;
2359 gLoc[1]=victim->coords.y;
2360 gLoc[2]=victim->coords.z;
2364 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2365 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2366 OPENAL_SetVolume(channels[whooshhitsound], 512);
2367 OPENAL_SetPaused(channels[whooshhitsound], false);
2368 if(creature==wolftype){
2369 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2370 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2371 OPENAL_SetVolume(channels[clawslicesound], 128);
2372 OPENAL_SetPaused(channels[clawslicesound], false);
2374 victim->DoBloodBig(2,175);
2378 relative=victim->coords-coords;
2380 Normalise(&relative);
2382 Normalise(&relative);
2383 relative=DoRotation(relative,0,90,0);
2384 for(i=0;i<victim->skeleton.num_joints;i++){
2385 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2387 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2390 victim->DoDamage(damagemult*50/victim->protectionhead);
2394 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2395 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2397 if(id==0)camerashake+=.4;
2402 gLoc[0]=victim->coords.x;
2403 gLoc[1]=victim->coords.y;
2404 gLoc[2]=victim->coords.z;
2408 if(tutoriallevel!=1){
2409 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2410 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2411 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2412 OPENAL_SetPaused(channels[heavyimpactsound], false);
2414 if(creature==wolftype){
2415 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2416 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2417 OPENAL_SetVolume(channels[clawslicesound], 128);
2418 OPENAL_SetPaused(channels[clawslicesound], false);
2420 victim->DoBloodBig(2/victim->armorhead,175);
2426 Normalise(&relative);
2427 relative=DoRotation(relative,0,-90,0);
2428 for(i=0;i<victim->skeleton.num_joints;i++){
2429 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2431 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2434 victim->DoDamage(damagemult*150/victim->protectionhead);
2436 if(victim->damage>victim->damagetolerance){
2449 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2450 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2452 if(id==0)camerashake+=.4;
2457 gLoc[0]=victim->coords.x;
2458 gLoc[1]=victim->coords.y;
2459 gLoc[2]=victim->coords.z;
2463 if(tutoriallevel!=1){
2464 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2465 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2466 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2467 OPENAL_SetPaused(channels[heavyimpactsound], false);
2469 if(creature==wolftype){
2470 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2471 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2472 OPENAL_SetVolume(channels[clawslicesound], 128);
2473 OPENAL_SetPaused(channels[clawslicesound], false);
2475 victim->DoBloodBig(2/victim->armorhead,175);
2481 Normalise(&relative);
2482 relative=DoRotation(relative,0,90,0);
2483 for(i=0;i<victim->skeleton.num_joints;i++){
2484 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2486 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2489 victim->DoDamage(damagemult*150/victim->protectionhead);
2491 if(victim->damage>victim->damagetolerance){
2504 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2505 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2507 if(id==0)camerashake+=.4;
2514 gLoc[0]=victim->coords.x;
2515 gLoc[1]=victim->coords.y;
2516 gLoc[2]=victim->coords.z;
2520 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2521 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2522 OPENAL_SetVolume(channels[whooshhitsound], 512);
2523 OPENAL_SetPaused(channels[whooshhitsound], false);
2526 relative=victim->coords-coords;
2528 Normalise(&relative);
2529 for(i=0;i<victim->skeleton.num_joints;i++){
2530 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2532 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2535 victim->DoDamage(damagemult*50/victim->protectionhead);
2539 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2540 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2542 if(id==0)camerashake+=.2;
2545 gLoc[0]=victim->coords.x;
2546 gLoc[1]=victim->coords.y;
2547 gLoc[2]=victim->coords.z;
2551 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2552 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2553 OPENAL_SetVolume(channels[landsound2], 128);
2554 OPENAL_SetPaused(channels[landsound2], false);
2556 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2557 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2558 OPENAL_SetVolume(channels[movewhooshsound], 128);
2559 OPENAL_SetPaused(channels[movewhooshsound], false);
2561 victim->skeleton.longdead=0;
2562 victim->skeleton.free=1;
2563 victim->skeleton.broken=0;
2564 victim->skeleton.spinny=1;
2566 for(i=0;i<victim->skeleton.num_joints;i++){
2567 victim->skeleton.joints[i].velchange=0;
2568 victim->skeleton.joints[i].delay=0;
2569 victim->skeleton.joints[i].locked=0;
2570 //victim->skeleton.joints[i].velocity=0;
2576 Normalise(&relative);
2577 for(i=0;i<victim->skeleton.num_joints;i++){
2578 victim->skeleton.joints[i].velocity.y=relative.y*10;
2579 victim->skeleton.joints[i].position.y+=relative.y*.3;
2580 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2581 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2583 victim->Puff(abdomen);
2584 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2588 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2589 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2591 if(id==0)camerashake+=.4;
2600 if(tutoriallevel!=1){
2601 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2602 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2603 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2604 OPENAL_SetPaused(channels[heavyimpactsound], false);
2607 relative=victim->coords-coords;
2609 Normalise(&relative);
2610 for(i=0;i<victim->skeleton.num_joints;i++){
2611 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2613 victim->Puff(abdomen);
2614 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2618 victim->DoDamage(damagemult*500/victim->protectionhigh);
2619 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2623 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2624 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2626 if(id==0)camerashake+=.4;
2635 if(tutoriallevel!=1){
2636 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2637 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2638 OPENAL_SetVolume(channels[thudsound], 400);
2639 OPENAL_SetPaused(channels[thudsound], false);
2642 victim->skeleton.longdead=0;
2643 victim->skeleton.free=1;
2644 victim->skeleton.broken=0;
2645 victim->skeleton.spinny=1;
2647 for(i=0;i<victim->skeleton.num_joints;i++){
2648 victim->skeleton.joints[i].velchange=0;
2649 //victim->skeleton.joints[i].delay=0;
2650 victim->skeleton.joints[i].locked=0;
2653 relative=victim->coords-coords;
2654 Normalise(&relative);
2656 Normalise(&relative);
2657 for(i=0;i<victim->skeleton.num_joints;i++){
2658 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2660 if(id==0&&!victim->dead){
2664 victim->Puff(abdomen);
2665 victim->DoDamage(damagemult*20/victim->protectionhigh);
2666 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2668 if(!victim->dead)staggerdelay=1.2;
2674 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2675 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2676 //if(id==0)camerashake+=.4;
2687 if(!victim->skeleton.free)hasvictim=0;
2690 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2691 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2692 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2693 OPENAL_SetVolume(channels[knifesheathesound], 128);
2694 OPENAL_SetPaused(channels[knifesheathesound], false);
2697 if(victim&&hasvictim){
2698 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2700 XYZ where,startpoint,endpoint,movepoint,colpoint;
2701 float rotationpoint;
2703 if(weapons.type[weaponids[weaponactive]]==knife){
2704 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2705 where-=victim->coords;
2706 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2713 if(weapons.type[weaponids[weaponactive]]==sword){
2714 where=weapons.position[weaponids[weaponactive]];
2715 where-=victim->coords;
2716 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2718 where=weapons.tippoint[weaponids[weaponactive]];
2719 where-=victim->coords;
2720 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2723 if(weapons.type[weaponids[weaponactive]]==staff){
2724 where=weapons.position[weaponids[weaponactive]];
2725 where-=victim->coords;
2726 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2728 where=weapons.tippoint[weaponids[weaponactive]];
2729 where-=victim->coords;
2730 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2735 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2738 if(victim->dead!=2){
2739 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2740 if(id==0&&!victim->dead){
2741 bonus=FinishedBonus;
2746 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2748 victim->skeleton.longdead=0;
2749 victim->skeleton.free=1;
2750 victim->skeleton.broken=0;
2752 for(i=0;i<victim->skeleton.num_joints;i++){
2753 victim->skeleton.joints[i].velchange=0;
2754 victim->skeleton.joints[i].locked=0;
2755 //victim->skeleton.joints[i].velocity=0;
2757 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2758 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2759 OPENAL_SetVolume(channels[fleshstabsound], 128);
2760 OPENAL_SetPaused(channels[fleshstabsound], false);
2763 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2764 weapons.blooddrip[weaponids[weaponactive]]+=5;
2765 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2769 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2770 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2771 OPENAL_SetVolume(channels[knifesheathesound], 128);
2772 OPENAL_SetPaused(channels[knifesheathesound], false);
2778 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2779 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2780 //if(id==0)camerashake+=.4;
2790 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2791 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2792 OPENAL_SetVolume(channels[knifedrawsound], 128);
2793 OPENAL_SetPaused(channels[knifedrawsound], false);
2796 if(victim&&hasvictim){
2797 XYZ footvel,footpoint;
2799 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2800 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2801 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2802 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2805 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2807 if(weapons.type[weaponids[weaponactive]]==sword){
2808 XYZ where,startpoint,endpoint,movepoint;
2809 float rotationpoint;
2812 where=weapons.position[weaponids[weaponactive]];
2813 where-=victim->coords;
2814 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2816 where=weapons.tippoint[weaponids[weaponactive]];
2817 where-=victim->coords;
2818 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2823 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2824 footpoint+=victim->coords;
2827 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2830 if(weapons.type[weaponids[weaponactive]]==staff){
2831 XYZ where,startpoint,endpoint,movepoint;
2832 float rotationpoint;
2835 where=weapons.position[weaponids[weaponactive]];
2836 where-=victim->coords;
2837 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2839 where=weapons.tippoint[weaponids[weaponactive]];
2840 where-=victim->coords;
2841 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2846 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2847 footpoint+=victim->coords;
2850 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2853 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2855 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2856 victim->skeleton.longdead=0;
2857 victim->skeleton.free=1;
2858 victim->skeleton.broken=0;
2860 for(i=0;i<victim->skeleton.num_joints;i++){
2861 victim->skeleton.joints[i].velchange=0;
2862 victim->skeleton.joints[i].locked=0;
2863 //victim->skeleton.joints[i].velocity=0;
2869 Normalise(&relative);
2870 //victim->Puff(abdomen);
2871 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2873 if(victim->bloodloss<victim->damagetolerance){
2874 victim->bloodloss+=1000;
2878 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2882 if(!hasvictim&&onterrain){
2883 weapons.bloody[weaponids[weaponactive]]=0;
2884 weapons.blooddrip[weaponids[weaponactive]]=0;
2888 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2889 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2891 if(id==0)camerashake+=.4;
2898 gLoc[0]=victim->coords.x;
2899 gLoc[1]=victim->coords.y;
2900 gLoc[2]=victim->coords.z;
2904 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2906 if(tutoriallevel!=1){
2907 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2908 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2909 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2910 OPENAL_SetPaused(channels[heavyimpactsound], false);
2914 if(tutoriallevel!=1){
2915 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2916 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2917 OPENAL_SetVolume(channels[landsound2], 256);
2918 OPENAL_SetPaused(channels[landsound2], false);
2922 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
2925 relative=victim->coords-coords;
2927 Normalise(&relative);
2928 for(i=0;i<victim->skeleton.num_joints;i++){
2929 victim->skeleton.joints[i].velocity=relative*30;
2931 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2933 victim->targetframe=0;
2934 victim->targetanimation=staggerbackhardanim;
2935 victim->targetrotation=targetrotation+180;
2940 victim->Puff(abdomen);
2941 victim->DoDamage(damagemult*60/victim->protectionhigh);
2950 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2951 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2953 if(id==0)camerashake+=.4;
2956 gLoc[0]=victim->coords.x;
2957 gLoc[1]=victim->coords.y;
2958 gLoc[2]=victim->coords.z;
2962 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2963 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2964 if(tutoriallevel!=1){
2965 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2966 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2967 OPENAL_SetVolume(channels[thudsound], 512);
2968 OPENAL_SetPaused(channels[thudsound], false);
2971 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2972 if(tutoriallevel!=1){
2973 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2974 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2975 OPENAL_SetVolume(channels[whooshhitsound], 512);
2976 OPENAL_SetPaused(channels[whooshhitsound], false);
2980 if(tutoriallevel!=1){
2981 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2982 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2983 OPENAL_SetVolume(channels[heavyimpactsound], 256);
2984 OPENAL_SetPaused(channels[heavyimpactsound], false);
2988 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2991 relative=victim->coords-coords;
2993 Normalise(&relative);
2995 Normalise(&relative);
2996 for(i=0;i<victim->skeleton.num_joints;i++){
2997 victim->skeleton.joints[i].velocity=relative*5;
2999 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
3001 victim->targetframe=0;
3002 victim->targetanimation=staggerbackhardanim;
3003 victim->targetrotation=targetrotation+180;
3007 victim->Puff(abdomen);
3008 victim->DoDamage(damagemult*60/victim->protectionhigh);
3016 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
3017 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3018 if(victim->id==0)camerashake+=.4;
3021 gLoc[0]=victim->coords.x;
3022 gLoc[1]=victim->coords.y;
3023 gLoc[2]=victim->coords.z;
3028 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3029 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3030 OPENAL_SetVolume(channels[landsound2], 256);
3031 OPENAL_SetPaused(channels[landsound2], false);
3037 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
3038 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3039 if(victim->id==0)camerashake+=.4;
3042 gLoc[0]=victim->coords.x;
3043 gLoc[1]=victim->coords.y;
3044 gLoc[2]=victim->coords.z;
3049 if(weaponactive!=-1){
3050 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3051 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3052 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3054 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3055 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3056 OPENAL_SetVolume(channels[swordstaffsound], 512);
3057 OPENAL_SetPaused(channels[swordstaffsound], false);
3060 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3061 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3062 OPENAL_SetVolume(channels[metalhitsound], 512);
3063 OPENAL_SetPaused(channels[metalhitsound], false);
3071 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3072 if(weaponactive!=-1){
3075 weapons.owner[weaponids[0]]=-1;
3076 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);
3078 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3079 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3081 weapons.velocity[weaponids[0]]=aim*50;
3082 weapons.tipvelocity[weaponids[0]]=aim*50;
3083 weapons.missed[weaponids[0]]=0;
3084 weapons.hitsomething[weaponids[0]]=0;
3085 weapons.freetime[weaponids[0]]=0;
3086 weapons.firstfree[weaponids[0]]=1;
3087 weapons.physics[weaponids[0]]=0;
3090 weaponids[0]=weaponids[num_weapons];
3096 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3098 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3101 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3109 if(tutoriallevel!=1){
3112 gLoc[0]=victim->coords.x;
3113 gLoc[1]=victim->coords.y;
3114 gLoc[2]=victim->coords.z;
3118 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3119 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3120 OPENAL_SetVolume(channels[knifeslicesound], 512);
3121 OPENAL_SetPaused(channels[knifeslicesound], false);
3123 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3124 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3125 if(victim->id != 0 || difficulty==2){
3126 victim->targetframe=0;
3127 victim->targetanimation=staggerbackhardanim;
3128 victim->targetrotation=targetrotation+180;
3132 victim->lowreversaldelay=0;
3133 victim->highreversaldelay=0;
3134 if(aitype!=playercontrolled)weaponmissdelay=.6;
3136 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3137 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3139 XYZ footvel,footpoint;
3142 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3145 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;
3147 if(tutoriallevel!=1){
3148 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3149 footvel=DoRotation(facing,0,90,0)*.8;
3151 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3152 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3153 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3154 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3156 if(tutoriallevel==1){
3157 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3159 victim->DoDamage(damagemult*0);
3162 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3163 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3164 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3171 if(tutoriallevel!=1){
3172 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3173 else victim->DoBloodBig(2/victim->armorhigh,185);
3174 victim->deathbleeding=1;
3177 gLoc[0]=victim->coords.x;
3178 gLoc[1]=victim->coords.y;
3179 gLoc[2]=victim->coords.z;
3183 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3184 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3185 OPENAL_SetVolume(channels[swordslicesound], 512);
3186 OPENAL_SetPaused(channels[swordslicesound], false);
3188 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3189 //if(animation[victim->targetanimation].attack){
3190 //if(victim->creature==rabbittype){
3191 if(tutoriallevel!=1){
3192 victim->targetframe=0;
3193 victim->targetanimation=staggerbackhardanim;
3194 victim->targetrotation=targetrotation+180;
3200 if(tutoriallevel!=1){
3201 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3202 weapons.blooddrip[weaponids[weaponactive]]+=3;
3204 float bloodlossamount;
3205 bloodlossamount=200+abs((float)(Random()%40))-20;
3206 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3207 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3208 victim->DoDamage(damagemult*0);
3210 XYZ footvel,footpoint;
3213 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3216 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;
3218 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3219 footvel=DoRotation(facing,0,90,0)*.8;
3221 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3222 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3223 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3224 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3232 gLoc[0]=victim->coords.x;
3233 gLoc[1]=victim->coords.y;
3234 gLoc[2]=victim->coords.z;
3238 if(victim->weaponactive!=-1){
3239 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3240 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3241 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3243 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3244 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3245 OPENAL_SetVolume(channels[swordstaffsound], 512);
3246 OPENAL_SetPaused(channels[swordstaffsound], false);
3249 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3250 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3251 OPENAL_SetVolume(channels[metalhitsound], 512);
3252 OPENAL_SetPaused(channels[metalhitsound], false);
3258 victim->Puff(righthand);
3260 victim->targetframe=0;
3261 victim->targetanimation=staggerbackhighanim;
3262 victim->targetrotation=targetrotation+180;
3264 weapons.owner[victim->weaponids[0]]=-1;
3265 aim=DoRotation(facing,0,90,0)*21;
3267 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3268 weapons.tipvelocity[victim->weaponids[0]]=aim;
3269 weapons.missed[victim->weaponids[0]]=1;
3270 weapons.hitsomething[weaponids[0]]=0;
3271 weapons.freetime[victim->weaponids[0]]=0;
3272 weapons.firstfree[victim->weaponids[0]]=1;
3273 weapons.physics[victim->weaponids[0]]=1;
3274 victim->num_weapons--;
3275 if(victim->num_weapons){
3276 victim->weaponids[0]=victim->weaponids[num_weapons];
3277 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3279 victim->weaponactive=-1;
3280 for(i=0;i<numplayers;i++){
3281 player[i].wentforweapon=0;
3284 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3285 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3286 OPENAL_SetVolume(channels[metalhitsound], 512);
3287 OPENAL_SetPaused(channels[metalhitsound], false);*/
3293 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3294 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3295 if(tutoriallevel!=1){
3296 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3298 if(id==0)camerashake+=.4;
3299 if(Random()%2||creature==wolftype){
3304 gLoc[0]=victim->coords.x;
3305 gLoc[1]=victim->coords.y;
3306 gLoc[2]=victim->coords.z;
3310 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3311 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3312 OPENAL_SetVolume(channels[staffheadsound], 256);
3313 OPENAL_SetPaused(channels[staffheadsound], false);
3317 relative=victim->coords-coords;
3319 Normalise(&relative);
3320 relative=DoRotation(relative,0,90,0);
3322 Normalise(&relative);
3323 for(i=0;i<victim->skeleton.num_joints;i++){
3324 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3326 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3327 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3330 if(tutoriallevel!=1){
3331 victim->DoDamage(damagemult*120/victim->protectionhigh);
3342 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3343 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3344 if(tutoriallevel!=1){
3345 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3347 if(id==0)camerashake+=.4;
3348 if(Random()%2||creature==wolftype){
3353 gLoc[0]=victim->coords.x;
3354 gLoc[1]=victim->coords.y;
3355 gLoc[2]=victim->coords.z;
3359 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3360 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3361 OPENAL_SetVolume(channels[staffheadsound], 256);
3362 OPENAL_SetPaused(channels[staffheadsound], false);
3366 relative=victim->coords-coords;
3368 Normalise(&relative);
3369 relative=DoRotation(relative,0,-90,0);
3370 for(i=0;i<victim->skeleton.num_joints;i++){
3371 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3373 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3374 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3377 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3388 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3389 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3391 if(tutoriallevel!=1){
3392 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3393 if(id==0)camerashake+=.4;
3394 if(Random()%2||creature==wolftype){
3399 gLoc[0]=victim->coords.x;
3400 gLoc[1]=victim->coords.y;
3401 gLoc[2]=victim->coords.z;
3405 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3406 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3407 OPENAL_SetVolume(channels[staffbodysound], 256);
3408 OPENAL_SetPaused(channels[staffbodysound], false);
3410 victim->skeleton.longdead=0;
3411 victim->skeleton.free=1;
3412 victim->skeleton.broken=0;
3414 for(i=0;i<victim->skeleton.num_joints;i++){
3415 victim->skeleton.joints[i].velchange=0;
3416 victim->skeleton.joints[i].locked=0;
3417 //victim->skeleton.joints[i].velocity=0;
3423 /*relative=victim->coords-coords;
3425 Normalise(&relative);
3426 relative=DoRotation(relative,0,90,0);*/
3428 Normalise(&relative);
3430 for(i=0;i<victim->skeleton.num_joints;i++){
3431 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3434 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3437 for(i=0;i<victim->skeleton.num_joints;i++){
3438 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3441 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3443 victim->Puff(abdomen);
3444 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3457 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3458 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3460 if(id==0)camerashake+=.4;
3463 gLoc[0]=victim->coords.x;
3464 gLoc[1]=victim->coords.y;
3465 gLoc[2]=victim->coords.z;
3470 relative=victim->coords-coords;
3472 Normalise(&relative);
3478 if(animation[victim->targetanimation].height==lowheight){
3484 for(i=0;i<victim->skeleton.num_joints;i++){
3485 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3487 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3488 if(tutoriallevel!=1){
3489 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3490 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3491 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3492 OPENAL_SetPaused(channels[heavyimpactsound], false);
3495 victim->DoDamage(damagemult*100/victim->protectionhead);
3496 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3497 if(creature==wolftype){
3498 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3499 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3500 OPENAL_SetVolume(channels[clawslicesound], 128);
3501 OPENAL_SetPaused(channels[clawslicesound], false);
3503 victim->DoBloodBig(2/victim->armorhead,175);
3507 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3508 for(i=0;i<victim->skeleton.num_joints;i++){
3509 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3511 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3512 victim->targetframe=0;
3513 victim->targetanimation=staggerbackhighanim;
3514 victim->targetrotation=targetrotation+180;
3516 if(tutoriallevel!=1){
3517 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3518 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3519 OPENAL_SetVolume(channels[landsound2], 128);
3520 OPENAL_SetPaused(channels[landsound2], false);
3522 victim->Puff(abdomen);
3523 victim->DoDamage(damagemult*30/victim->protectionhigh);
3524 if(creature==wolftype){
3525 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3526 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3527 OPENAL_SetVolume(channels[clawslicesound], 128);
3528 OPENAL_SetPaused(channels[clawslicesound], false);
3530 victim->DoBloodBig(2/victim->armorhigh,170);
3537 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3538 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3540 if(id==0)camerashake+=.2;
3543 gLoc[0]=victim->coords.x;
3544 gLoc[1]=victim->coords.y;
3545 gLoc[2]=victim->coords.z;
3549 if(tutoriallevel!=1){
3550 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3551 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3552 OPENAL_SetVolume(channels[landsound2], 128);
3553 OPENAL_SetPaused(channels[landsound2], false);
3556 relative=victim->coords-coords;
3558 Normalise(&relative);
3560 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3563 for(i=0;i<victim->skeleton.num_joints;i++){
3564 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3566 relative=DoRotation(relative,0,-90,0);
3568 for(i=0;i<victim->skeleton.num_joints;i++){
3569 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)
3570 victim->skeleton.joints[i].velocity=relative*80;
3572 victim->Puff(rightankle);
3573 victim->Puff(leftankle);
3574 victim->DoDamage(damagemult*40/victim->protectionlow);
3577 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3578 for(i=0;i<victim->skeleton.num_joints;i++){
3579 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3581 relative=DoRotation(relative,0,-90,0);
3582 for(i=0;i<victim->skeleton.num_joints;i++){
3583 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)
3584 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3586 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3587 victim->targetframe=0;
3588 victim->targetanimation=staggerbackhighanim;
3589 victim->targetrotation=targetrotation+180;
3591 if(tutoriallevel!=1){
3592 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3593 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3594 OPENAL_SetVolume(channels[landsound2], 128);
3595 OPENAL_SetPaused(channels[landsound2], false);
3597 victim->Puff(abdomen);
3598 victim->DoDamage(damagemult*30/victim->protectionlow);
3608 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3609 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3611 if(id==0)camerashake+=.4;
3618 gLoc[0]=victim->coords.x;
3619 gLoc[1]=victim->coords.y;
3620 gLoc[2]=victim->coords.z;
3624 if(tutoriallevel!=1){
3625 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3626 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3627 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3628 OPENAL_SetPaused(channels[heavyimpactsound], false);
3630 if(creature==wolftype){
3631 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3632 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3633 OPENAL_SetVolume(channels[clawslicesound], 128);
3634 OPENAL_SetPaused(channels[clawslicesound], false);
3636 victim->DoBloodBig(2/victim->armorhigh,170);
3640 relative=victim->coords-oldcoords;
3642 Normalise(&relative);
3643 //relative=DoRotation(relative,0,-90,0);
3644 for(i=0;i<victim->skeleton.num_joints;i++){
3645 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3647 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3649 victim->Puff(abdomen);
3650 victim->DoDamage(damagemult*150/victim->protectionhigh);
3659 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3660 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3661 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3662 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3665 weaponids[num_weapons]=weaponids[victim->weaponactive];
3668 weaponids[0]=victim->weaponids[victim->weaponactive];
3669 victim->num_weapons--;
3670 if(victim->num_weapons>0){
3671 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3672 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3674 victim->weaponactive=-1;
3679 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3681 if(id==0)camerashake+=.4;
3688 gLoc[0]=victim->coords.x;
3689 gLoc[1]=victim->coords.y;
3690 gLoc[2]=victim->coords.z;
3694 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3695 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3696 OPENAL_SetVolume(channels[whooshhitsound], 128);
3697 OPENAL_SetPaused(channels[whooshhitsound], false);
3700 relative=victim->coords-oldcoords;
3702 Normalise(&relative);
3703 //relative=DoRotation(relative,0,-90,0);
3704 for(i=0;i<victim->skeleton.num_joints;i++){
3705 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3707 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3710 victim->DoDamage(damagemult*70/victim->protectionhigh);
3713 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3715 if(id==0)camerashake+=.4;
3722 gLoc[0]=victim->coords.x;
3723 gLoc[1]=victim->coords.y;
3724 gLoc[2]=victim->coords.z;
3730 bonus=staffreversebonus;
3735 if(tutoriallevel!=1){
3736 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3737 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3738 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3739 OPENAL_SetPaused(channels[heavyimpactsound], false);
3743 bonus=staffreversebonus;
3749 relative=victim->coords-oldcoords;
3751 Normalise(&relative);
3752 //relative=DoRotation(relative,0,-90,0);
3753 for(i=0;i<victim->skeleton.num_joints;i++){
3754 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3756 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3759 victim->DoDamage(damagemult*70/victim->protectionhigh);
3762 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3768 Normalise(&relative);
3771 for(i=0;i<victim->skeleton.num_joints;i++){
3772 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3774 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3775 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3776 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3777 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3778 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3779 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3780 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3781 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3783 victim->Puff(abdomen);
3784 victim->DoDamage(damagemult*90/victim->protectionhigh);
3794 if(weaponactive!=-1||creature==wolftype)doslice=1;
3795 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3799 gLoc[0]=victim->coords.x;
3800 gLoc[1]=victim->coords.y;
3801 gLoc[2]=victim->coords.z;
3805 if(weaponactive!=-1){
3806 victim->DoBloodBig(2/victim->armorhigh,225);
3807 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3808 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3809 OPENAL_SetVolume(channels[knifeslicesound], 512);
3810 OPENAL_SetPaused(channels[knifeslicesound], false);
3811 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3812 weapons.blooddrip[weaponids[weaponactive]]+=3;
3814 if(weaponactive==-1&&creature==wolftype){
3815 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3816 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3817 OPENAL_SetVolume(channels[clawslicesound], 128);
3818 OPENAL_SetPaused(channels[clawslicesound], false);
3820 victim->DoBloodBig(2/victim->armorhigh,175);
3827 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3833 Normalise(&relative);
3836 for(i=0;i<victim->skeleton.num_joints;i++){
3837 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3839 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
3840 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
3841 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
3842 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
3843 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
3844 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
3845 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
3846 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
3849 bonus=swordreversebonus;
3853 //victim->DoDamage(90);
3855 /*if(weaponactive!=-1){
3858 gLoc[0]=victim->coords.x;
3859 gLoc[1]=victim->coords.y;
3860 gLoc[2]=victim->coords.z;
3864 victim->DoBloodBig(2,225);
3865 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3866 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3867 OPENAL_SetVolume(channels[knifeslicesound], 512);
3868 OPENAL_SetPaused(channels[knifeslicesound], false);
3869 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3870 weapons.blooddrip[weaponids[weaponactive]]+=3;
3874 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3876 if(id==0)camerashake+=.4;
3883 gLoc[0]=victim->coords.x;
3884 gLoc[1]=victim->coords.y;
3885 gLoc[2]=victim->coords.z;
3889 if(tutoriallevel!=1){
3890 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3891 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3892 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3893 OPENAL_SetPaused(channels[heavyimpactsound], false);
3897 relative=victim->coords-oldcoords;
3899 Normalise(&relative);
3900 relative=DoRotation(relative,0,-90,0);
3901 for(i=0;i<victim->skeleton.num_joints;i++){
3902 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3904 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3906 victim->Puff(abdomen);
3907 victim->DoDamage(damagemult*30/victim->protectionhigh);
3916 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
3919 victim->skeleton.spinny=0;
3923 Normalise(&relative);
3924 if(victim->id==0)relative/=30;
3925 for(i=0;i<victim->skeleton.num_joints;i++){
3926 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3928 //victim->DoDamage(1000);
3929 victim->damage=victim->damagetolerance;
3930 victim->permanentdamage=victim->damagetolerance-1;
3933 if(weaponactive!=-1||creature==wolftype)doslice=1;
3934 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3938 gLoc[0]=victim->coords.x;
3939 gLoc[1]=victim->coords.y;
3940 gLoc[2]=victim->coords.z;
3944 if(weaponactive!=-1){
3945 victim->DoBloodBig(200,225);
3946 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3947 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3948 OPENAL_SetVolume(channels[knifeslicesound], 512);
3949 OPENAL_SetPaused(channels[knifeslicesound], false);
3950 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3951 weapons.blooddrip[weaponids[weaponactive]]+=5;
3954 if(creature==wolftype&&weaponactive==-1){
3955 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3956 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3957 OPENAL_SetVolume(channels[clawslicesound], 128);
3958 OPENAL_SetPaused(channels[clawslicesound], false);
3960 victim->DoBloodBig(2,175);
3970 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3971 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3973 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3974 if(targetanimation==knifesneakattackanim){
3975 /*victim->DoBloodBig(200,195);
3980 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3981 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3983 XYZ footvel,footpoint;
3985 footpoint=weapons.tippoint[weaponids[0]];
3986 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3987 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3988 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3989 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3990 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3991 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3992 victim->DoBloodBig(200,195);
3999 //victim->neckspurtamount=5;
4001 if(targetanimation==knifefollowanim){
4007 XYZ footvel,footpoint;
4009 footpoint=weapons.tippoint[weaponids[0]];
4010 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4011 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4012 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4013 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4014 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
4015 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
4018 victim->bloodloss+=10000;
4022 gLoc[0]=victim->coords.x;
4023 gLoc[1]=victim->coords.y;
4024 gLoc[2]=victim->coords.z;
4028 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4029 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4030 OPENAL_SetVolume(channels[fleshstabsound], 512);
4031 OPENAL_SetPaused(channels[fleshstabsound], false);
4032 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4033 weapons.blooddrip[weaponids[weaponactive]]+=5;
4037 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
4040 for(i=0;i<victim->skeleton.num_joints;i++){
4041 victim->skeleton.joints[i].velocity=0;
4043 if(targetanimation==knifefollowanim){
4045 for(i=0;i<victim->skeleton.num_joints;i++){
4046 victim->skeleton.joints[i].velocity=0;
4049 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
4052 gLoc[0]=victim->coords.x;
4053 gLoc[1]=victim->coords.y;
4054 gLoc[2]=victim->coords.z;
4058 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4059 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4060 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4061 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4062 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4063 weapons.blooddrip[weaponids[weaponactive]]+=5;
4065 XYZ footvel,footpoint;
4067 footpoint=weapons.tippoint[weaponids[0]];
4068 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4069 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4070 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4071 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4072 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4073 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4077 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4078 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4087 XYZ footvel,footpoint;
4089 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
4090 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4091 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4092 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4093 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4094 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4095 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4096 victim->DoBloodBig(200,180);
4097 victim->DoBloodBig(200,215);
4098 victim->bloodloss+=10000;
4102 gLoc[0]=victim->coords.x;
4103 gLoc[1]=victim->coords.y;
4104 gLoc[2]=victim->coords.z;
4108 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4109 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4110 OPENAL_SetVolume(channels[fleshstabsound], 512);
4111 OPENAL_SetPaused(channels[fleshstabsound], false);
4112 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4113 weapons.blooddrip[weaponids[weaponactive]]+=5;
4117 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
4120 for(i=0;i<victim->skeleton.num_joints;i++){
4121 victim->skeleton.joints[i].velocity=0;
4123 if(weaponactive!=-1){
4126 gLoc[0]=victim->coords.x;
4127 gLoc[1]=victim->coords.y;
4128 gLoc[2]=victim->coords.z;
4132 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4133 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4134 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4135 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4136 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4137 weapons.blooddrip[weaponids[weaponactive]]+=5;
4139 XYZ footvel,footpoint;
4141 footpoint=weapons.tippoint[weaponids[0]];
4142 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4143 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4144 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4145 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4146 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4147 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4151 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4153 if(id==0)camerashake+=.4;
4160 gLoc[0]=victim->coords.x;
4161 gLoc[1]=victim->coords.y;
4162 gLoc[2]=victim->coords.z;
4166 if(weaponactive==-1){
4167 if(tutoriallevel!=1){
4168 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4169 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4170 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4171 OPENAL_SetPaused(channels[heavyimpactsound], false);
4176 if(weaponactive!=-1||creature==wolftype)doslice=1;
4177 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4179 if(weaponactive!=-1){
4180 victim->DoBloodBig(2/victim->armorhead,225);
4181 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4182 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4183 OPENAL_SetVolume(channels[knifeslicesound], 512);
4184 OPENAL_SetPaused(channels[knifeslicesound], false);
4185 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4186 weapons.blooddrip[weaponids[weaponactive]]+=3;
4188 if(weaponactive==-1&&creature==wolftype){
4189 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4190 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4191 OPENAL_SetVolume(channels[clawslicesound], 128);
4192 OPENAL_SetPaused(channels[clawslicesound], false);
4194 victim->DoBloodBig(2/victim->armorhead,175);
4207 //relative=victim->coords-oldcoords;
4210 Normalise(&relative);
4211 relative=DoRotation(relative,0,90,0);
4213 Normalise(&relative);
4214 for(i=0;i<victim->skeleton.num_joints;i++){
4215 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4217 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4218 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4219 victim->DoDamage(damagemult*100/victim->protectionhead);
4223 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4227 //relative=victim->coords-oldcoords;
4230 Normalise(&relative);
4231 relative=DoRotation(relative,0,90,0);
4233 Normalise(&relative);
4234 for(i=0;i<victim->skeleton.num_joints;i++){
4235 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4237 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4240 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4241 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4252 if(targetframe>animation[currentanimation].numframes-1){
4255 targetanimation=getIdle();
4259 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4260 targetanimation=rollanim;
4271 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4272 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4273 OPENAL_SetVolume(channels[movewhooshsound], 128);
4274 OPENAL_SetPaused(channels[movewhooshsound], false);
4276 if(currentanimation==staggerbackhighanim){
4277 targetanimation=getIdle();
4279 if(currentanimation==staggerbackhardanim){
4280 targetanimation=getIdle();
4282 if(currentanimation==removeknifeanim){
4283 targetanimation=getIdle();
4285 if(currentanimation==crouchremoveknifeanim){
4286 targetanimation=getCrouch();
4288 if(currentanimation==backhandspringanim){
4289 targetanimation=getIdle();
4291 if(currentanimation==dodgebackanim){
4292 targetanimation=getIdle();
4294 if(currentanimation==drawleftanim){
4295 targetanimation=getIdle();
4297 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4298 targetanimation=getIdle();
4299 if(currentanimation==crouchdrawrightanim){
4300 targetanimation=getCrouch();
4302 if(weaponactive==-1)weaponactive=0;
4303 else if(weaponactive==0){
4307 buffer=weaponids[0];
4308 weaponids[0]=weaponids[1];
4309 weaponids[1]=buffer;
4313 if(weaponactive==-1){
4323 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4324 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4325 OPENAL_SetVolume(channels[knifesheathesound], 128);
4326 OPENAL_SetPaused(channels[knifesheathesound], false);
4328 if(weaponactive!=-1){
4338 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4339 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4340 OPENAL_SetVolume(channels[knifedrawsound], 128);
4341 OPENAL_SetPaused(channels[knifedrawsound], false);
4344 if(currentanimation==rollanim){
4345 targetanimation=getCrouch();
4350 if(targetanimation==walljumprightkickanim){
4353 if(targetanimation==walljumpleftkickanim){
4356 targetanimation=jumpdownanim;
4358 if(currentanimation==climbanim){
4359 targetanimation=getCrouch();
4362 if(!isnormal(coords.x))
4373 if(targetanimation==rabbitkickreversalanim){
4374 targetanimation=getCrouch();
4377 if(targetanimation==jumpreversalanim){
4378 targetanimation=getCrouch();
4381 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4382 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4384 float closestdist=-1;
4387 for(i=0;i<numplayers;i++){
4388 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4389 distance=findDistancefast(&player[i].coords,&coords);
4390 if(closestdist==-1||distance<closestdist){
4391 closestdist=distance;
4396 if(closestdist>0&&closest>=0&&closestdist<16){
4397 victim=&player[closest];
4398 targetanimation=walljumprightkickanim;
4400 XYZ rotatetarget=victim->coords-coords;
4401 Normalise(&rotatetarget);
4402 rotation=-asin(0-rotatetarget.x);
4404 if(rotatetarget.z<0)rotation=180-rotation;
4405 targettilt2=-asin(rotatetarget.y)*360/6.28;
4406 velocity=(victim->coords-coords)*4;
4411 if(targetanimation==walljumpbackanim){
4412 targetanimation=backflipanim;
4416 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4418 if(targetanimation==walljumprightanim){
4419 targetanimation=rightflipanim;
4423 velocity=DoRotation(facing,0,30,0)*-8;
4426 if(targetanimation==walljumpfrontanim){
4427 targetanimation=frontflipanim;
4429 //targetrotation-=180;
4434 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4436 if(targetanimation==walljumpleftanim){
4439 float closestdist=-1;
4442 for(i=0;i<numplayers;i++){
4443 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4444 distance=findDistancefast(&player[i].coords,&coords);
4445 if(closestdist==-1||distance<closestdist){
4446 closestdist=distance;
4451 if(closestdist>0&&closest>=0&&closestdist<16){
4452 victim=&player[closest];
4453 targetanimation=walljumpleftkickanim;
4455 XYZ rotatetarget=victim->coords-coords;
4456 Normalise(&rotatetarget);
4457 rotation=-asin(0-rotatetarget.x);
4459 if(rotatetarget.z<0)rotation=180-rotation;
4460 targettilt2=-asin(rotatetarget.y)*360/6.28;
4461 velocity=(victim->coords-coords)*4;
4466 if(targetanimation!=walljumpleftkickanim){
4467 targetanimation=leftflipanim;
4471 velocity=DoRotation(facing,0,-30,0)*-8;
4474 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4476 if(targetanimation==sneakattackanim){
4477 float ycoords=oldcoords.y;
4478 currentanimation=getCrouch();
4479 targetanimation=getCrouch();
4482 targetrotation+=180;
4487 targetheadrotation+=180;
4489 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4493 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4494 float ycoords=oldcoords.y;
4495 targetanimation=getIdle();
4497 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4501 if(currentanimation==knifefollowanim){
4502 targetanimation=getIdle();
4505 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4506 float ycoords=oldcoords.y;
4507 targetanimation=getStop();
4508 targetrotation+=180;
4513 targetheadrotation+=180;
4514 if(!isnormal(coords.x))
4516 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4517 oldcoords=coords+facing*.5;
4518 else if(currentanimation==sweepreversalanim)
4519 oldcoords=coords+facing*1.1;
4520 else if(currentanimation==upunchreversalanim){
4521 oldcoords=coords+facing*1.5;
4522 targetrotation+=180;
4524 targetheadrotation+=180;
4528 else if(currentanimation==knifeslashreversalanim){
4529 oldcoords=coords+facing*.5;
4532 targetheadrotation+=90;
4536 else if(currentanimation==staffspinhitreversalanim){
4537 targetrotation+=180;
4539 targetheadrotation+=180;
4543 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4544 else oldcoords.y=ycoords;
4545 currentoffset=coords-oldcoords;
4551 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4556 if(animation[targetanimation].attack==reversed){
4558 if(targetanimation==sweepreversedanim)targetrotation+=90;
4559 targetanimation=backhandspringanim;
4569 PlaySoundEx( landsound, samp[landsound], NULL, true);
4570 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4571 OPENAL_SetVolume(channels[landsound], 128);
4572 OPENAL_SetPaused(channels[landsound], false);
4574 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4575 targetanimation=rollanim;
4578 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4579 coords.y=oldcoords.y;
4581 if(currentanimation==knifeslashreversedanim){
4582 targetanimation=rollanim;
4587 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4588 coords.y=oldcoords.y;
4592 targetanimation=jumpdownanim;
4594 if(wasLanding())targetanimation=getIdle();
4595 if(wasLandhard())targetanimation=getIdle();
4596 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4597 targetanimation=getIdle();
4599 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4600 coords.y=oldcoords.y;
4601 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4602 targetoffset.y=coords.y;
4603 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4604 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4605 currentoffset.y-=(coords.y-targetoffset.y);
4606 coords.y=targetoffset.y;
4608 normalsupdatedelay=0;
4610 if(currentanimation==upunchanim){
4611 targetanimation=getStop();
4612 normalsupdatedelay=0;
4615 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4616 targetrotation=rotation;
4619 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4620 if(!hasstaff)DoDamage(35);
4623 rabbitkickragdoll=1;
4625 if(currentanimation==rabbitkickreversedanim){
4632 if(id!=0)SolidHitBonus();
4636 targetanimation=rollanim;
4638 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4642 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4648 if(currentanimation==jumpreversedanim){
4655 if(id!=0)SolidHitBonus();
4659 targetanimation=rollanim;
4661 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4666 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){
4667 targetanimation=getupfromfrontanim;
4670 else if(animation[currentanimation].attack==normalattack){
4671 targetanimation=getIdle();
4674 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4675 targetanimation=blockhighleftstrikeanim;
4677 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4678 targetanimation=getIdle();
4681 if(currentanimation==spinkickanim&&victim->skeleton.free){
4682 if(creature==rabbittype)targetanimation=fightidleanim;
4687 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4689 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4690 targetanimation=jumpdownanim;
4695 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4696 if(!isRun()||!wasRun()){
4697 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4698 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4699 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4700 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4702 if(isRun()&&wasRun()){
4705 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4706 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4709 else if(transspeed)target+=multiplier*transspeed*speed*2;
4711 if(!isRun()||!wasRun()){
4712 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4713 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4714 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4715 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4719 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4721 if(target>1){currentframe=targetframe; target=1;}
4723 rot=targetrot*target;
4724 rotation+=rot-oldrot;
4730 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4732 for(i=0;i<skeleton.num_joints;i++){
4733 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4736 skeleton.FindForwards();
4738 for(i=0;i<skeleton.num_muscles;i++){
4739 if(skeleton.muscles[i].visible)
4741 skeleton.FindRotationMuscle(i,targetanimation);
4744 for(i=0;i<skeleton.num_muscles;i++){
4745 if(skeleton.muscles[i].visible)
4747 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4748 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4749 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4754 for(i=0;i<skeleton.num_joints;i++){
4755 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4758 skeleton.FindForwards();
4760 for(i=0;i<skeleton.num_muscles;i++){
4761 if(skeleton.muscles[i].visible)
4763 skeleton.FindRotationMuscle(i,targetanimation);
4766 for(i=0;i<skeleton.num_muscles;i++){
4767 if(skeleton.muscles[i].visible)
4769 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4770 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4771 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4772 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4773 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4774 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4775 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4776 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4777 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4781 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4783 oldcurrentanimation=currentanimation;
4784 oldtargetanimation=targetanimation;
4785 oldtargetframe=targetframe;
4786 oldcurrentframe=currentframe;
4788 for(i=0;i<skeleton.num_joints;i++){
4789 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4790 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4792 offset=currentoffset*(1-target)+targetoffset*target;
4793 for(i=0;i<skeleton.num_muscles;i++){
4794 if(skeleton.muscles[i].visible)
4796 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4797 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4798 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4803 if(isLanding()&&landhard){
4804 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4805 if(id==0)camerashake+=.4;
4806 targetanimation=getLandhard();
4814 //skeleton.DoConstraints();
4817 void Person::DoStuff(){
4818 static XYZ terrainnormal;
4819 static XYZ flatfacing;
4820 static XYZ flatvelocity;
4821 static float flatvelspeed;
4825 static int bloodsize;
4826 static int startx,starty,endx,endy;
4827 static int texdetailint;
4828 static GLubyte color;
4829 static XYZ bloodvel;
4831 onfiredelay-=multiplier;
4832 if(onfiredelay<0&&onfire)
4840 crouchkeydowntime+=multiplier;
4841 if(!crouchkeydown)crouchkeydowntime=0;
4842 jumpkeydowntime+=multiplier;
4843 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
4845 if(hostile||damage>0||bloodloss>0)immobile=0;
4847 if(isIdle()||isRun())targetoffset=0;
4849 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
4851 if(id==0)blooddimamount-=multiplier*.3;
4852 speechdelay-=multiplier;
4853 texupdatedelay-=multiplier;
4854 interestdelay-=multiplier;
4855 flamedelay-=multiplier;
4856 parriedrecently-=multiplier;
4862 if(id==0)speed=1.1*speedmult;
4863 else speed=1.0*speedmult;
4864 if(!skeleton.free)rabbitkickragdoll=0;
4868 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
4869 if(id!=0&&creature==wolftype&&difficulty==2){
4871 if(aitype!=passivetype){
4873 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){
4877 if(scale<0.2)superruntoggle=0;
4878 if(targetanimation==wolfrunninganim&&!superruntoggle){
4879 targetanimation=getRun();
4883 if(weaponactive==-1&&num_weapons>0){
4884 if(weapons.type[weaponids[0]]==staff){
4891 /*if(aitype!=playercontrolled)*///deathbleeding=5;
4892 /*if(aitype!=playercontrolled)*/
4894 if(burnt>.6)burnt=.6;
4895 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
4897 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
4908 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4909 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
4913 while(flamedelay<0&&onfire){
4915 howmany=abs(Random()%(skeleton.num_joints));
4916 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4917 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4918 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4919 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4920 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
4923 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
4925 howmany=abs(Random()%(skeleton.num_joints));
4926 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4927 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4928 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4929 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4930 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
4934 bleeding-=multiplier*.3;
4936 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4937 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
4941 if(neckspurtamount>0){
4942 neckspurtamount-=multiplier;
4943 neckspurtdelay-=multiplier*3;
4944 neckspurtparticledelay-=multiplier*3;
4945 if(neckspurtparticledelay<0&&neckspurtdelay>2){
4949 bloodvel.z=5*neckspurtamount;
4950 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4953 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
4955 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4956 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
4957 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);
4958 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);
4959 neckspurtparticledelay=.05;
4961 if(neckspurtdelay<0){
4966 if(deathbleeding>0&&dead!=2){
4967 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
4968 else bleeddelay-=5*multiplier/4;
4969 if(bleeddelay<0&&bloodtoggle){
4974 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4975 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
4976 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
4977 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);
4980 bloodloss+=deathbleeding*multiplier*80;
4981 deathbleeding-=multiplier*1.6;
4982 //if(id==0)deathbleeding-=multiplier*.2;
4983 if(deathbleeding<0)deathbleeding=0;
4984 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
4985 if(weaponactive!=-1){
4986 weapons.owner[weaponids[0]]=-1;
4987 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4988 weapons.velocity[weaponids[0]].x+=.01;
4989 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4990 weapons.missed[weaponids[0]]=1;
4991 weapons.hitsomething[weaponids[0]]=0;
4992 weapons.freetime[weaponids[0]]=0;
4993 weapons.firstfree[weaponids[0]]=1;
4994 weapons.physics[weaponids[0]]=1;
4997 weaponids[0]=weaponids[num_weapons];
4998 if(weaponstuck==num_weapons)weaponstuck=0;
5001 for(i=0;i<numplayers;i++){
5002 player[i].wentforweapon=0;
5014 if(!dead&&creature==wolftype){
5020 if(targetanimation==knifefollowedanim&&!skeleton.free){
5021 for(i=0;i<skeleton.num_joints;i++){
5022 skeleton.joints[i].velocity=0;
5023 skeleton.joints[i].velocity.y=-2;
5026 if(id!=0&&unconscioustime>.1){
5034 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
5037 bloodsize=5-realtexdetail;
5041 texdetailint=realtexdetail;
5042 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5043 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5044 endx=startx+bloodsize;
5045 endy=starty+bloodsize;
5047 if(startx<0){startx=0;bleeding=0;}
5048 if(starty<0){starty=0;bleeding=0;}
5049 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
5050 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
5051 if(endx<startx)endx=startx;
5052 if(endy<starty)endy=starty;
5054 for(i=startx;i<endx;i++){
5055 for(j=starty;j<endy;j++){
5057 color=Random()%85+170;
5058 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
5059 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
5060 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
5065 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5066 DoMipmaps(0,startx,endx,starty,endy);
5070 bleedy-=4/realtexdetail;
5071 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
5072 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
5075 bleedx+=4*direction/realtexdetail;
5076 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
5077 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
5081 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
5082 righthandmorphness=targetrighthandmorphness;
5083 righthandmorphstart=righthandmorphend;
5085 else if(righthandmorphness>targetrighthandmorphness){
5086 righthandmorphness-=multiplier*4;
5088 else if(righthandmorphness<targetrighthandmorphness){
5089 righthandmorphness+=multiplier*4;
5092 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
5093 lefthandmorphness=targetlefthandmorphness;
5094 lefthandmorphstart=lefthandmorphend;
5096 else if(lefthandmorphness>targetlefthandmorphness){
5097 lefthandmorphness-=multiplier*4;
5099 else if(lefthandmorphness<targetlefthandmorphness){
5100 lefthandmorphness+=multiplier*4;
5103 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
5104 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
5105 tailmorphness=targettailmorphness;
5106 tailmorphstart=tailmorphend;
5108 else if(tailmorphness>targettailmorphness){
5109 tailmorphness-=multiplier*10;
5111 else if(tailmorphness<targettailmorphness){
5112 tailmorphness+=multiplier*10;
5116 if(creature==wolftype){
5117 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
5118 tailmorphness=targettailmorphness;
5119 tailmorphstart=tailmorphend;
5121 else if(tailmorphness>targettailmorphness){
5122 tailmorphness-=multiplier*2;
5124 else if(tailmorphness<targettailmorphness){
5125 tailmorphness+=multiplier*2;
5129 if(headmorphend==3||headmorphstart==3){
5130 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
5131 headmorphness=targetheadmorphness;
5132 headmorphstart=headmorphend;
5134 else if(headmorphness>targetheadmorphness){
5135 headmorphness-=multiplier*7;
5137 else if(headmorphness<targetheadmorphness){
5138 headmorphness+=multiplier*7;
5141 else if(headmorphend==5||headmorphstart==5){
5142 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
5143 headmorphness=targetheadmorphness;
5144 headmorphstart=headmorphend;
5146 else if(headmorphness>targetheadmorphness){
5147 headmorphness-=multiplier*10;
5149 else if(headmorphness<targetheadmorphness){
5150 headmorphness+=multiplier*10;
5154 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5155 headmorphness=targetheadmorphness;
5156 headmorphstart=headmorphend;
5158 else if(headmorphness>targetheadmorphness){
5159 headmorphness-=multiplier*4;
5161 else if(headmorphness<targetheadmorphness){
5162 headmorphness+=multiplier*4;
5166 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5167 chestmorphness=targetchestmorphness;
5168 chestmorphstart=chestmorphend;
5170 else if(chestmorphness>targetchestmorphness){
5171 chestmorphness-=multiplier;
5173 else if(chestmorphness<targetchestmorphness){
5174 chestmorphness+=multiplier;
5177 if(dead!=2&&howactive<=typesleeping){
5178 if(chestmorphstart==0&&chestmorphend==0){
5180 targetchestmorphness=1;
5183 if(chestmorphstart!=0&&chestmorphend!=0){
5185 targetchestmorphness=1;
5187 if(environment==snowyenvironment){
5190 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5191 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5192 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5193 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5194 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5195 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5199 if(!dead&&howactive<typesleeping){
5200 blinkdelay-=multiplier*2;
5201 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5203 targetheadmorphness=1;
5205 blinkdelay=(float)(abs(Random()%40))/5;
5207 if(headmorphstart==3&&headmorphend==3){
5209 targetheadmorphness=1;
5214 twitchdelay-=multiplier*1.5;
5215 if(targetanimation!=hurtidleanim){
5216 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5218 targetheadmorphness=1;
5220 twitchdelay=(float)(abs(Random()%40))/5;
5222 if(headmorphstart==5&&headmorphend==5){
5224 targetheadmorphness=1;
5228 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5229 twitchdelay3-=multiplier*1;
5231 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5232 righthandmorphness=0;
5233 targetrighthandmorphness=1;
5234 righthandmorphend=1;
5235 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5237 if(righthandmorphstart==1&&righthandmorphend==1){
5238 righthandmorphness=0;
5239 targetrighthandmorphness=1;
5240 righthandmorphend=0;
5244 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5245 lefthandmorphness=0;
5246 targetlefthandmorphness=1;
5248 twitchdelay3=(float)(abs(Random()%40))/5;
5250 if(lefthandmorphstart==1&&lefthandmorphend==1){
5251 lefthandmorphness=0;
5252 targetlefthandmorphness=1;
5259 if(creature==rabbittype){
5260 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5261 else twitchdelay2-=multiplier*0.5;
5262 if(howactive<=typesleeping){
5263 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5265 targettailmorphness=1;
5267 twitchdelay2=(float)(abs(Random()%40))/5;
5269 if(tailmorphstart==1&&tailmorphend==1){
5271 targettailmorphness=1;
5274 if(tailmorphstart==2&&tailmorphend==2){
5276 targettailmorphness=1;
5283 if(creature==wolftype){
5284 twitchdelay2-=multiplier*1.5;
5286 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5288 targettailmorphness=1;
5293 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5295 targettailmorphness=1;
5299 if(twitchdelay2<=0){
5300 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5302 targettailmorphness=1;
5305 if(tailmorphstart==1&&tailmorphend==1){
5307 targettailmorphness=1;
5310 if(tailmorphstart==2&&tailmorphend==2){
5312 targettailmorphness=1;
5315 if(tailmorphstart==3&&tailmorphend==3){
5317 targettailmorphness=1;
5320 if(tailmorphstart==4&&tailmorphend==4){
5322 targettailmorphness=1;
5328 if(dead!=1)unconscioustime=0;
5330 if(dead==1||howactive==typesleeping){
5331 unconscioustime+=multiplier;
5332 //If unconscious, close eyes and mouth
5333 if(righthandmorphend!=0)righthandmorphness=0;
5334 righthandmorphend=0;
5335 targetrighthandmorphness=1;
5337 if(lefthandmorphend!=0)lefthandmorphness=0;
5339 targetlefthandmorphness=1;
5341 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5343 targetheadmorphness=1;
5347 if(howactive>typesleeping){
5350 if(bloodtoggle&&!bled){
5351 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5353 if(bloodtoggle&&!bled)
5354 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5355 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5356 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5360 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5365 if(dead==2||howactive>typesleeping){
5366 //If dead, open mouth and hands
5367 if(righthandmorphend!=0)righthandmorphness=0;
5368 righthandmorphend=0;
5369 targetrighthandmorphness=1;
5371 if(lefthandmorphend!=0)lefthandmorphness=0;
5373 targetlefthandmorphness=1;
5375 if(headmorphend!=2)headmorphness=0;
5377 targetheadmorphness=1;
5380 if(stunned>0&&!dead&&headmorphend!=2){
5381 if(headmorphend!=4)headmorphness=0;
5383 targetheadmorphness=1;
5386 if(damage>damagetolerance&&!dead){
5391 if(creature==wolftype){
5399 if(weaponactive!=-1){
5400 weapons.owner[weaponids[0]]=-1;
5401 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5402 weapons.velocity[weaponids[0]].x+=.01;
5403 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5404 weapons.missed[weaponids[0]]=1;
5405 weapons.hitsomething[weaponids[0]]=0;
5406 weapons.freetime[weaponids[0]]=0;
5407 weapons.firstfree[weaponids[0]]=1;
5408 weapons.physics[weaponids[0]]=1;
5411 weaponids[0]=weaponids[num_weapons];
5412 if(weaponstuck==num_weapons)weaponstuck=0;
5415 for(i=0;i<numplayers;i++){
5416 player[i].wentforweapon=0;
5422 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5430 //if(dead)damage-=multiplier/4;
5431 if(!dead)damage-=multiplier*13;
5432 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5433 if(!dead)permanentdamage-=multiplier*4;
5434 if(isIdle()||isCrouch()){
5435 if(!dead)permanentdamage-=multiplier*4;
5436 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5438 if(damage<0)damage=0;
5439 if(permanentdamage<0)permanentdamage=0;
5440 if(superpermanentdamage<0)superpermanentdamage=0;
5441 if(permanentdamage<superpermanentdamage){
5442 permanentdamage=superpermanentdamage;
5444 if(damage<permanentdamage){
5445 damage=permanentdamage;
5447 if(dead==1&&damage<damagetolerance){
5451 for(i=0;i<skeleton.num_joints;i++){
5452 skeleton.joints[i].velocity=0;
5455 if(permanentdamage>damagetolerance&&dead!=2){
5458 if(weaponactive!=-1){
5459 weapons.owner[weaponids[0]]=-1;
5460 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5461 weapons.velocity[weaponids[0]].x+=.01;
5462 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5463 weapons.missed[weaponids[0]]=1;
5464 weapons.hitsomething[weaponids[0]]=0;
5465 weapons.freetime[weaponids[0]]=0;
5466 weapons.firstfree[weaponids[0]]=1;
5467 weapons.physics[weaponids[0]]=1;
5470 weaponids[0]=weaponids[num_weapons];
5471 if(weaponstuck==num_weapons)weaponstuck=0;
5474 for(i=0;i<numplayers;i++){
5475 player[i].wentforweapon=0;
5481 if(!dead&&creature==wolftype){
5487 if(id!=0&&unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance){
5492 if(id!=0&&unconscioustime>.1){
5508 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5509 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5510 OPENAL_SetVolume(channels[breaksound], 512);
5511 OPENAL_SetPaused(channels[breaksound], false);
5512 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5518 if(skeleton.free==1){
5519 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5522 //If knocked over, open hands and close mouth
5523 if(righthandmorphend!=0)righthandmorphness=0;
5524 righthandmorphend=0;
5525 targetrighthandmorphness=1;
5527 if(lefthandmorphend!=0)lefthandmorphness=0;
5529 targetlefthandmorphness=1;
5531 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5532 if(headmorphend!=0)headmorphness=0;
5534 targetheadmorphness=1;
5538 skeleton.DoGravity(&scale);
5540 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5541 if(id!=0&&damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1)){
5546 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5550 for(j=0;j<skeleton.num_joints;j++){
5551 average+=skeleton.joints[j].position;
5555 coords+=average*scale;
5556 for(j=0;j<skeleton.num_joints;j++){
5557 skeleton.joints[j].position-=average;
5559 average/=multiplier;
5561 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5563 for(i=0;i<skeleton.num_joints;i++){
5564 velocity+=skeleton.joints[i].velocity*scale;
5566 velocity/=skeleton.num_joints;
5568 if(!isnormal(velocity.x)&&velocity.x){
5581 if(findLength(&average)<10&&dead&&skeleton.free){
5582 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5583 if(skeleton.longdead>2000){
5584 if(skeleton.longdead>6000){
5585 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5590 if(dead==2&&bloodloss<damagetolerance){
5592 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5594 if(bloodtoggle&&!bled){
5595 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5597 if(bloodtoggle&&!bled)
5598 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5599 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5600 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5604 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5608 if(dead==2&&bloodloss>=damagetolerance){
5610 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5611 if(bleeding<=0)DoBlood(1,255);
5612 if(bloodtoggle&&!bled){
5613 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5615 if(bloodtoggle&&!bled)
5616 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5617 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5618 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5622 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5629 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5631 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5635 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5636 if(velocity.y<-30)canrecover=0;
5637 for(i=0;i<objects.numobjects;i++){
5638 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5639 colviewer=startpoint;
5641 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5649 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5650 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5651 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5652 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5654 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5655 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5656 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5658 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5659 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5660 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5662 Normalise(&terrainnormal);
5664 targetrotation=-asin(0-terrainnormal.x);
5665 targetrotation*=360/6.28;
5666 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5667 rotation=targetrotation;
5669 //if(skeleton.forward.y<0){
5672 //if(skeleton.forward.y>-.3){
5675 targetanimation=flipanim;
5676 crouchtogglekeydown=1;
5681 currentanimation=tempanim;
5684 //tilt2=targettilt2;
5686 //if(middle.y>0)targetoffset.y=middle.y+1;
5688 for(i=0;i<skeleton.num_joints;i++){
5689 tempanimation.position[i][0]=skeleton.joints[i].position;
5690 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5695 if(findLength(&average)<10&&!dead&&skeleton.free){
5696 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5697 if(skeleton.longdead>(damage+500)*1.5){
5698 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5704 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5705 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5706 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5707 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5709 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5710 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5711 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5713 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5714 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5715 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5717 Normalise(&terrainnormal);
5719 targetrotation=-asin(0-terrainnormal.x);
5720 targetrotation*=360/6.28;
5721 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5722 rotation=targetrotation;
5725 terrainnormal=terrain.getNormal(coords.x,coords.z);
5726 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5730 /*XYZ otherterrainnormal;
5731 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5732 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5733 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5734 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5737 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5741 if(skeleton.forward.y<0){
5742 targetanimation=getupfrombackanim;
5746 if(skeleton.forward.y>-.3){
5747 targetanimation=getupfromfrontanim;
5749 targetrotation+=180;
5755 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5756 targetanimation=rollanim;
5757 targetrotation=lookrotation;
5761 if(forwardkeydown)targetrotation+=45;
5762 if(backkeydown)targetrotation-=45;
5766 if(forwardkeydown)targetrotation-=45;
5767 if(backkeydown)targetrotation+=45;
5770 if ( !leftkeydown&&!rightkeydown)
5771 targetrotation+=180;
5773 targetrotation+=180;
5777 if(abs(targettilt2)>50)targettilt2=0;
5778 currentanimation=tempanim;
5783 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5785 for(i=0;i<skeleton.num_joints;i++){
5786 tempanimation.position[i][0]=skeleton.joints[i].position;
5787 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5794 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5795 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5798 tempvelocity=velocity;
5799 Normalise(&tempvelocity);
5800 targetrotation=-asin(0-tempvelocity.x);
5801 targetrotation*=360/6.28;
5802 if(velocity.z<0)targetrotation=180-targetrotation;
5803 //targetrotation+=180;
5806 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5807 targetanimation=rollanim;
5811 targetanimation=backhandspringanim;
5812 targetrotation+=180;
5825 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
5826 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
5827 OPENAL_SetVolume(channels[movewhooshsound], 128);
5828 OPENAL_SetPaused(channels[movewhooshsound], false);
5830 currentanimation=targetanimation;
5831 currentframe=targetframe-1;
5836 rotation=targetrotation;
5843 if(skeleton.freefall==0)freefall=0;
5845 if(!isnormal(velocity.x)&&velocity.x){
5850 if(aitype!=passivetype||skeleton.free==1)
5851 if(findLengthfast(&velocity)>.1)
5852 for(i=0;i<objects.numobjects;i++){
5853 if(objects.type[i]==firetype)
5854 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){
5856 if(!objects.onfire[i]){
5859 gLoc[0]=objects.position[i].x;
5860 gLoc[1]=objects.position[i].y;
5861 gLoc[2]=objects.position[i].z;
5865 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5866 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5867 OPENAL_SetVolume(channels[firestartsound], 256);
5868 OPENAL_SetPaused(channels[firestartsound], false);
5870 objects.onfire[i]=1;
5873 if(objects.onfire[i]){
5878 if(objects.type[i]==bushtype)
5879 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){
5881 if(!objects.onfire[i]){
5884 gLoc[0]=objects.position[i].x;
5885 gLoc[1]=objects.position[i].y;
5886 gLoc[2]=objects.position[i].z;
5890 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5891 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5892 OPENAL_SetVolume(channels[firestartsound], 256);
5893 OPENAL_SetPaused(channels[firestartsound], false);
5895 objects.onfire[i]=1;
5899 if(objects.onfire[i]){
5903 if(objects.messedwith[i]<=0){
5915 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5916 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5917 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5918 OPENAL_SetPaused(channels[bushrustle], false);
5921 envsound[numenvsounds]=coords;
5922 envsoundvol[numenvsounds]=4*findLength(&velocity);
5923 envsoundlife[numenvsounds]=.4;
5928 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5929 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5931 if(environment!=desertenvironment)
5932 for(j=0;j<howmany;j++){
5933 tempvel.x=float(abs(Random()%100)-50)/20;
5934 tempvel.y=float(abs(Random()%100)-50)/20;
5935 tempvel.z=float(abs(Random()%100)-50)/20;
5938 pos.x+=float(abs(Random()%100)-50)/200;
5939 pos.y+=float(abs(Random()%100)-50)/200;
5940 pos.z+=float(abs(Random()%100)-50)/200;
5941 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);
5942 Sprite::setLastSpriteSpecial(1);
5944 howmany=findLength(&velocity)*4;
5946 if(environment==snowyenvironment)
5947 for(j=0;j<howmany;j++){
5948 tempvel.x=float(abs(Random()%100)-50)/20;
5949 tempvel.y=float(abs(Random()%100)-50)/20;
5950 tempvel.z=float(abs(Random()%100)-50)/20;
5953 pos.x+=float(abs(Random()%100)-50)/200;
5954 pos.y+=float(abs(Random()%100)-50)/200;
5955 pos.z+=float(abs(Random()%100)-50)/200;
5956 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5957 Sprite::setLastSpriteSpecial(2);
5960 objects.rotx[i]+=velocity.x*multiplier*6;
5961 objects.roty[i]+=velocity.z*multiplier*6;
5962 objects.messedwith[i]=.5;
5965 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
5966 if(objects.rotation2[i]==0)tempcoord=coords;
5968 tempcoord=coords-objects.position[i];
5969 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
5970 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
5971 tempcoord+=objects.position[i];
5973 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]){
5974 if(objects.messedwith[i]<=0){
5986 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5987 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5988 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5989 OPENAL_SetPaused(channels[bushrustle], false);
5992 envsound[numenvsounds]=coords;
5993 envsoundvol[numenvsounds]=4*findLength(&velocity);
5994 envsoundlife[numenvsounds]=.4;
5999 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6000 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6002 if(environment!=desertenvironment)
6003 for(j=0;j<howmany;j++){
6004 tempvel.x=float(abs(Random()%100)-50)/20;
6005 tempvel.y=float(abs(Random()%100)-50)/20;
6006 tempvel.z=float(abs(Random()%100)-50)/20;
6010 pos.x+=float(abs(Random()%100)-50)/150;
6011 pos.y+=float(abs(Random()%100)-50)/150;
6012 pos.z+=float(abs(Random()%100)-50)/150;
6013 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);
6014 Sprite::setLastSpriteSpecial(1);
6016 howmany=findLength(&velocity)*4;
6018 if(environment==snowyenvironment)
6019 for(j=0;j<howmany;j++){
6020 tempvel.x=float(abs(Random()%100)-50)/20;
6021 tempvel.y=float(abs(Random()%100)-50)/20;
6022 tempvel.z=float(abs(Random()%100)-50)/20;
6026 pos.x+=float(abs(Random()%100)-50)/150;
6027 pos.y+=float(abs(Random()%100)-50)/150;
6028 pos.z+=float(abs(Random()%100)-50)/150;
6029 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6030 Sprite::setLastSpriteSpecial(2);
6033 objects.messedwith[i]=.5;
6041 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
6043 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
6044 if(tutoriallevel==1&&id!=0)play=0;
6045 if(play&&aitype!=playercontrolled){
6057 if(creature==rabbittype){
6058 if(i==0)whichsound=rabbitchitter;
6059 if(i==1)whichsound=rabbitchitter2;
6061 if(creature==wolftype){
6062 if(i==0)whichsound=growlsound;
6063 if(i==1)whichsound=growl2sound;
6069 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
6070 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
6071 OPENAL_SetVolume(channels[whichsound], 512);
6072 OPENAL_SetPaused(channels[whichsound], false);
6076 if(targetanimation==staggerbackhighanim)staggerdelay=1;
6077 if(targetanimation==staggerbackhardanim)staggerdelay=1;
6078 staggerdelay-=multiplier;
6079 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
6080 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
6081 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
6082 targetanimation=getIdle();
6086 weaponmissdelay-=multiplier;
6087 highreversaldelay-=multiplier;
6088 lowreversaldelay-=multiplier;
6089 lastcollide-=multiplier;
6090 skiddelay-=multiplier;
6091 if(!isnormal(velocity.x)&&velocity.x){
6094 if(!isnormal(targettilt)&&targettilt){
6097 if(!isnormal(targettilt2)&&targettilt2){
6100 if(!isnormal(targetrotation)&&targetrotation){
6104 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
6105 //open hands and close mouth
6106 //if(targetanimation!=wolfidle){
6107 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6108 righthandmorphness=0;
6109 righthandmorphend=0;
6110 targetrighthandmorphness=1;
6113 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6114 lefthandmorphness=0;
6116 targetlefthandmorphness=1;
6120 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
6123 targetheadmorphness=1;
6127 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){
6128 //open hands and mouth
6129 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6130 righthandmorphness=0;
6131 righthandmorphend=0;
6132 targetrighthandmorphness=1;
6135 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6136 lefthandmorphness=0;
6138 targetlefthandmorphness=1;
6141 if(headmorphend!=1&&headmorphness==targetheadmorphness){
6144 targetheadmorphness=1;
6148 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
6149 //close hands and mouth
6150 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6151 righthandmorphness=0;
6152 righthandmorphend=1;
6153 targetrighthandmorphness=1;
6156 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6157 lefthandmorphness=0;
6159 targetlefthandmorphness=1;
6162 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6165 targetheadmorphness=1;
6169 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){
6170 //close hands and yell
6171 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6172 righthandmorphness=0;
6173 righthandmorphend=1;
6174 targetrighthandmorphness=1;
6177 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6178 lefthandmorphness=0;
6180 targetlefthandmorphness=1;
6183 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6186 targetheadmorphness=1;
6190 if(speechdelay>.25){
6191 if(headmorphend!=2)headmorphness=0;
6193 targetheadmorphness=1;
6199 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6200 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6204 if(!dead&&targetanimation!=hurtidleanim)
6205 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6206 if(headmorphend!=4||headmorphness==targetheadmorphness){
6209 targetheadmorphness=1;
6213 if(weaponactive!=-1){
6214 if(weapons.type[weaponids[weaponactive]]!=staff){
6215 righthandmorphstart=1;
6216 righthandmorphend=1;
6218 if(weapons.type[weaponids[weaponactive]]==staff){
6219 righthandmorphstart=2;
6220 righthandmorphend=2;
6222 targetrighthandmorphness=1;
6225 terrainnormal=terrain.getNormal(coords.x,coords.z);
6227 if(animation[targetanimation].attack!=reversal){
6228 if(!isnormal(coords.x))
6236 flatfacing=DoRotation(flatfacing,0,rotation,0);
6238 ReflectVector(&facing,terrainnormal);
6241 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6242 if(onterrain)targettilt2=-facing.y*20;
6246 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6247 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6248 flatvelocity=velocity;
6250 flatvelspeed=findLength(&flatvelocity);
6251 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6252 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6253 if(velocity.y<0)targettilt2*=-1;
6254 if(velocity.y<0)targettilt*=-1;
6255 if(targettilt>25)targettilt=25;
6256 if(targettilt<-25)targettilt=-25;
6259 if(targettilt2>45)targettilt2=45;
6260 if(targettilt2<-45)targettilt2=-45;
6261 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6262 else if(tilt2>targettilt2){
6263 tilt2-=multiplier*400;
6265 else if(tilt2<targettilt2){
6266 tilt2+=multiplier*400;
6268 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6269 if(tilt2>25)tilt2=25;
6270 if(tilt2<-25)tilt2=-25;
6273 if(!isnormal(targettilt)&&targettilt){
6276 if(!isnormal(targettilt2)&&targettilt2){
6281 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6282 if(targetanimation==rabbittackleanim){
6283 velocity+=facing*multiplier*speed*700*scale;
6284 velspeed=findLength(&velocity);
6285 if(velspeed>speed*65*scale){
6287 velspeed=speed*65*scale;
6290 velocity.y+=gravity*multiplier*20;
6291 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6292 velspeed=findLength(&velocity);
6293 velocity=flatfacing*velspeed;
6295 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6296 if(isRun()||targetanimation==rabbitkickanim){
6297 velocity+=facing*multiplier*speed*700*scale;
6298 velspeed=findLength(&velocity);
6299 if(velspeed>speed*45*scale){
6301 velspeed=speed*45*scale;
6304 velocity.y+=gravity*multiplier*20;
6305 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6306 velspeed=findLength(&velocity);
6307 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6308 velocity=flatfacing*velspeed;
6312 velocity+=facing*multiplier*speed*700*scale;
6313 velspeed=findLength(&velocity);
6314 if(creature==rabbittype){
6315 if(velspeed>speed*55*scale){
6317 velspeed=speed*55*scale;
6321 if(creature==wolftype){
6322 if(velspeed>speed*75*scale){
6324 velspeed=speed*75*scale;
6328 velocity.y+=gravity*multiplier*20;
6329 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6330 velspeed=findLength(&velocity);
6331 velocity=flatfacing*velspeed;
6334 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6335 velocity+=facing*multiplier*speed*700*scale;
6336 velspeed=findLength(&velocity);
6337 if(velspeed>speed*45*scale){
6339 velspeed=speed*45*scale;
6342 velocity.y+=gravity*multiplier*20;
6343 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6344 velspeed=findLength(&velocity);
6345 velocity=flatfacing*velspeed;
6349 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6350 velocity+=facing*multiplier*speed*700*scale;
6351 velspeed=findLength(&velocity);
6352 if(velspeed>speed*25*scale){
6354 velspeed=speed*25*scale;
6357 velocity.y+=gravity*multiplier*20;
6358 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6359 velspeed=findLength(&velocity);
6360 velocity=flatfacing*velspeed;
6363 if(targetanimation==sneakanim||targetanimation==walkanim){
6364 velocity+=facing*multiplier*speed*700*scale;
6365 velspeed=findLength(&velocity);
6366 if(velspeed>speed*12*scale){
6368 velspeed=speed*12*scale;
6371 velocity.y+=gravity*multiplier*20;
6372 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6373 velspeed=findLength(&velocity);
6374 velocity=flatfacing*velspeed;
6377 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6378 velocity+=facing*multiplier*speed*700*scale;
6379 velspeed=findLength(&velocity);
6380 if(velspeed>speed*2*scale){
6382 velspeed=speed*2*scale;
6385 velocity.y+=gravity*multiplier*20;
6386 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6387 velspeed=findLength(&velocity);
6388 velocity=flatfacing*velspeed;
6392 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6393 velocity-=facing*multiplier*speed*700*scale;
6394 velspeed=findLength(&velocity);
6395 if(velspeed>speed*2*scale){
6397 velspeed=speed*2*scale;
6400 velocity.y+=gravity*multiplier*20;
6401 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6402 velspeed=findLength(&velocity);
6403 velocity=flatfacing*velspeed*-1;
6406 if(targetanimation==fightsidestep){
6407 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6408 velspeed=findLength(&velocity);
6409 if(velspeed>speed*12*scale){
6411 velspeed=speed*12*scale;
6414 velocity.y+=gravity*multiplier*20;
6415 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6416 velspeed=findLength(&velocity);
6417 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6420 if(targetanimation==staggerbackhighanim){
6421 coords-=facing*multiplier*speed*16*scale;
6424 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6425 coords-=facing*multiplier*speed*20*scale;
6429 if(targetanimation==backhandspringanim){
6430 //coords-=facing*multiplier*50*scale;
6431 velocity+=facing*multiplier*speed*700*scale*-1;
6432 velspeed=findLength(&velocity);
6433 if(velspeed>speed*50*scale){
6435 velspeed=speed*50*scale;
6438 velocity.y+=gravity*multiplier*20;
6439 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6440 velspeed=findLength(&velocity);
6441 velocity=flatfacing*velspeed*-1;
6443 if(targetanimation==dodgebackanim){
6444 //coords-=facing*multiplier*50*scale;
6445 velocity+=facing*multiplier*speed*700*scale*-1;
6446 velspeed=findLength(&velocity);
6447 if(velspeed>speed*60*scale){
6449 velspeed=speed*60*scale;
6452 velocity.y+=gravity*multiplier*20;
6453 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6454 velspeed=findLength(&velocity);
6455 velocity=flatfacing*velspeed*-1;
6458 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6459 velspeed=findLength(&velocity);
6463 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6464 velocity.y+=gravity*multiplier;
6467 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6469 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6470 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6472 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6478 OPENAL_SetPaused(channels[whooshsound], true);
6479 OPENAL_SetVolume(channels[whooshsound], 0);
6482 if(targetanimation==jumpdownanim||isFlip()){
6483 if(isFlip())jumppower=-4;
6484 targetanimation=getLanding();
6493 PlaySoundEx( landsound, samp[landsound], NULL, true);
6494 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6495 OPENAL_SetVolume(channels[landsound], 128);
6496 OPENAL_SetPaused(channels[landsound], false);
6499 envsound[numenvsounds]=coords;
6500 envsoundvol[numenvsounds]=16;
6501 envsoundlife[numenvsounds]=.4;
6507 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6508 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6509 coords.y=terrain.getHeight(coords.x,coords.z);
6514 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)){
6515 velspeed=findLength(&velocity);
6517 if(velspeed<multiplier*300*scale){
6519 } else velocity-=velocity/velspeed*multiplier*300*scale;
6520 if(velspeed>5&&(isLanding()||isLandhard())){
6521 skiddingdelay+=multiplier;
6528 else skiddingdelay=0;
6532 velspeed=findLength(&velocity);
6534 if(velspeed<multiplier*600*scale){
6536 } else velocity-=velocity/velspeed*multiplier*600*scale;
6538 if(velspeed>5&&(isLanding()||isLandhard())){
6539 skiddingdelay+=multiplier;
6546 else skiddingdelay=0;
6549 if(skiddingdelay<0)skiddingdelay+=multiplier;
6550 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6560 if(!onterrain||environment==grassyenvironment){
6561 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6562 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6563 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6564 OPENAL_SetPaused(channels[skidsound], false);
6567 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6568 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6569 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6570 OPENAL_SetPaused(channels[snowskidsound], false);
6574 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6575 terrainnormal=victim->coords-coords;
6576 Normalise(&terrainnormal);
6577 targetrotation=-asin(0-terrainnormal.x);
6578 targetrotation*=360/6.28;
6579 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6580 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6583 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6584 targetrotation=victim->targetrotation;
6586 if(targetanimation==rabbittacklinganim){
6587 coords=victim->coords;
6590 skeleton.oldfree=skeleton.free;
6594 midterrain.x=terrain.size*terrain.scale/2;
6595 midterrain.z=terrain.size*terrain.scale/2;
6596 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6598 tempposit=coords-midterrain;
6600 Normalise(&tempposit);
6601 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6602 coords.x=tempposit.x+midterrain.x;
6603 coords.z=tempposit.z+midterrain.z;
6607 int Person::DrawSkeleton(){
6608 int oldplayerdetail;
6609 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6610 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6620 glAlphaFunc(GL_GREATER, 0.0001);
6622 float terrainheight;
6624 if(!isnormal(rotation))rotation=0;
6625 if(!isnormal(tilt))tilt=0;
6626 if(!isnormal(tilt2))tilt2=0;
6627 oldplayerdetail=playerdetail;
6629 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6632 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6635 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6640 if(playerdetail!=oldplayerdetail) {
6642 normalsupdatedelay=0;
6644 static float updatedelaychange;
6645 static float morphness;
6646 static float framemult;
6648 skeleton.FindForwards();
6649 if(howactive==typesittingwall){
6650 skeleton.specialforward[1]=0;
6651 skeleton.specialforward[1].z=1;
6657 static int weaponattachmuscle;
6658 static int weaponrotatemuscle,weaponrotatemuscle2;
6659 static XYZ weaponpoint;
6660 static int start,endthing;
6661 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6662 if(!isSleeping()&&!isSitting()){
6663 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6664 XYZ point,newpoint,change,change2;
6665 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6666 heightleft=terrain.getHeight(point.x,point.z)+.04;
6668 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6669 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6670 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6671 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6672 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6674 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6675 heightright=terrain.getHeight(point.x,point.z)+.04;
6676 point.y=heightright;
6677 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6678 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6679 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6680 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6681 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6682 skeleton.DoConstraints(&coords,&scale);
6684 if(creature==wolftype){
6685 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6686 heightleft=terrain.getHeight(point.x,point.z)+.04;
6688 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6689 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6690 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6691 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6692 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6694 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6695 heightright=terrain.getHeight(point.x,point.z)+.04;
6696 point.y=heightright;
6697 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6698 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6699 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6700 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6701 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6702 skeleton.DoConstraints(&coords,&scale);
6705 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6706 XYZ point,newpoint,change,change2;
6707 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6708 heightleft=terrain.getHeight(point.x,point.z)+.04;
6710 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6711 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6712 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6713 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6714 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6716 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6717 heightright=terrain.getHeight(point.x,point.z)+.04;
6718 point.y=heightright;
6719 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6720 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6721 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6722 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6723 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6724 skeleton.DoConstraints(&coords,&scale);
6726 if(creature==wolftype){
6727 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6728 heightleft=terrain.getHeight(point.x,point.z)+.04;
6730 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6731 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6732 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6733 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6734 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6736 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6737 heightright=terrain.getHeight(point.x,point.z)+.04;
6738 point.y=heightright;
6739 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6740 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6741 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6742 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6743 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6744 skeleton.DoConstraints(&coords,&scale);
6748 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6749 XYZ point,newpoint,change,change2;
6750 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6751 heightleft=terrain.getHeight(point.x,point.z)+.04;
6753 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6754 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6755 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6756 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6757 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6759 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6760 heightright=terrain.getHeight(point.x,point.z)+.04;
6761 point.y=heightright;
6762 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6763 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6764 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6765 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6766 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6767 skeleton.DoConstraints(&coords,&scale);
6769 if(creature==wolftype){
6770 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6771 heightleft=terrain.getHeight(point.x,point.z)+.04;
6773 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6774 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6775 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6776 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6777 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6779 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6780 heightright=terrain.getHeight(point.x,point.z)+.04;
6781 point.y=heightright;
6782 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6783 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6784 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6785 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6786 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6787 skeleton.DoConstraints(&coords,&scale);
6791 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()))
6794 targetheadrotation=-targetrotation;
6795 targetheadrotation2=0;
6796 if(animation[targetanimation].attack==3)targetheadrotation+=180;
6798 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6799 skeleton.drawmodel.vertex[i]=0;
6800 skeleton.drawmodel.vertex[i].y=999;
6802 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
6803 skeleton.drawmodellow.vertex[i]=0;
6804 skeleton.drawmodellow.vertex[i].y=999;
6806 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
6807 skeleton.drawmodelclothes.vertex[i]=0;
6808 skeleton.drawmodelclothes.vertex[i].y=999;
6810 for(i=0;i<skeleton.num_muscles;i++){
6811 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
6815 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
6816 morphness=righthandmorphness;
6817 start=righthandmorphstart;
6818 endthing=righthandmorphend;
6820 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
6821 morphness=lefthandmorphness;
6822 start=lefthandmorphstart;
6823 endthing=lefthandmorphend;
6825 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
6826 morphness=headmorphness;
6827 start=headmorphstart;
6828 endthing=headmorphend;
6830 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)){
6831 morphness=chestmorphness;
6832 start=chestmorphstart;
6833 endthing=chestmorphend;
6835 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)){
6836 morphness=tailmorphness;
6837 start=tailmorphstart;
6838 endthing=tailmorphend;
6840 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
6841 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6842 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6845 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6846 if(!skeleton.free)glRotatef(tilt,0,0,1);
6849 glTranslatef(mid.x,mid.y,mid.z);
6851 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6852 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6854 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6855 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6857 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6858 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6860 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
6864 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
6868 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
6872 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
6877 if(playerdetail||skeleton.free==3)
6879 for(j=0;j<skeleton.muscles[i].numvertices;j++)
6881 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
6882 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
6883 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
6884 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
6885 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
6886 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
6887 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
6888 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6890 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6891 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,
6892 (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,
6893 (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);
6894 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)
6895 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,
6896 (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,
6897 (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);
6898 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)
6899 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,
6900 (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,
6901 (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);
6902 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6903 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,
6904 (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,
6905 (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);
6906 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6907 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
6908 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
6909 //if(!isnormal(scale))test=1;
6910 //if(isnormal(scale)){
6911 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
6912 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
6913 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
6921 if(!playerdetail||skeleton.free==3)
6923 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
6925 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
6926 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6928 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6929 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
6930 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
6931 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
6932 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)
6933 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
6934 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
6935 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
6936 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)
6937 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
6938 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
6939 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
6940 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6941 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
6942 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
6943 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
6945 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6946 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
6947 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
6948 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
6955 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
6956 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6958 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6961 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6962 if(!skeleton.free)glRotatef(tilt,0,0,1);
6963 glTranslatef(mid.x,mid.y,mid.z);
6964 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6965 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6967 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6968 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6970 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6971 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6973 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
6974 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6976 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6977 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
6978 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
6979 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
6980 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)
6981 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
6982 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
6983 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
6984 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)
6985 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
6986 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
6987 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
6988 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6989 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
6990 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
6991 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
6992 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6993 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
6994 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
6995 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
7000 updatedelay=1+(float)(Random()%100)/1000;
7002 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
7003 normalsupdatedelay=1;
7004 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
7005 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
7006 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
7010 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
7011 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
7012 if(skeleton.clothes){
7013 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
7018 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
7019 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
7020 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
7021 if(skeleton.free==1)updatedelaychange*=6;
7022 if(id==0)updatedelaychange*=8;
7023 updatedelay+=updatedelaychange;
7025 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7027 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7028 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7029 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
7030 if(!skeleton.free)glRotatef(rotation,0,1,0);
7033 glColor4f(.4,1,.4,1);
7034 glDisable(GL_LIGHTING);
7035 glDisable(GL_TEXTURE_2D);
7038 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7039 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
7045 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
7046 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);
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[1]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].z);
7049 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[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[2]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].z);
7051 glVertex3f(skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[0]].z);
7057 terrainlight=terrain.getLighting(coords.x,coords.z);
7058 distance=findDistancefast(&viewer,&coords);
7059 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
7060 if(distance>1)distance=1;
7062 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
7063 if(terrainheight<1)terrainheight=1;
7064 if(terrainheight>1.7)terrainheight=1.7;
7067 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
7068 glDisable(GL_BLEND);
7069 glAlphaFunc(GL_GREATER, 0.0001);
7070 glEnable(GL_TEXTURE_2D);
7072 glDisable(GL_TEXTURE_2D);
7073 glColor4f(.7,.35,0,.5);
7075 glEnable(GL_LIGHTING);
7078 if(tutoriallevel&&id!=0){
7079 //glDisable(GL_TEXTURE_2D);
7080 glColor4f(.7,.7,.7,0.6);
7082 glEnable(GL_LIGHTING);
7084 if(canattack&&cananger)
7085 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7086 glDisable(GL_TEXTURE_2D);
7087 glColor4f(1,0,0,0.8);
7089 glMatrixMode(GL_TEXTURE);
7091 glTranslatef(0,-smoketex,0);
7092 glTranslatef(-smoketex,0,0);
7096 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7097 else skeleton.drawmodel.draw();
7101 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7102 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7105 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
7106 if(tutoriallevel&&id!=0){
7108 glMatrixMode(GL_MODELVIEW);
7109 glEnable(GL_TEXTURE_2D);
7110 glColor4f(.7,.7,.7,0.6);
7112 glEnable(GL_LIGHTING);
7114 if(canattack&&cananger)
7115 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7116 glDisable(GL_TEXTURE_2D);
7117 glColor4f(1,0,0,0.8);
7119 glMatrixMode(GL_TEXTURE);
7121 glTranslatef(0,-smoketex*.6,0);
7122 glTranslatef(smoketex*.6,0,0);
7125 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7126 else skeleton.drawmodel.draw();
7130 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7131 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7136 if(tutoriallevel&&id!=0){
7138 glMatrixMode(GL_MODELVIEW);
7139 glEnable(GL_TEXTURE_2D);
7141 if(skeleton.clothes){
7144 if(!immediate)skeleton.drawmodelclothes.draw();
7145 if(immediate)skeleton.drawmodelclothes.drawimmediate();
7152 for(k=0;k<num_weapons;k++){
7154 if(weaponactive==k){
7155 if(weapons.type[i]!=staff){
7156 for(j=0;j<skeleton.num_muscles;j++){
7157 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7158 weaponattachmuscle=j;
7161 for(j=0;j<skeleton.num_muscles;j++){
7162 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){
7163 weaponrotatemuscle=j;
7166 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7167 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7169 if(weapons.type[i]==staff){
7170 for(j=0;j<skeleton.num_muscles;j++){
7171 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7172 weaponattachmuscle=j;
7175 for(j=0;j<skeleton.num_muscles;j++){
7176 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){
7177 weaponrotatemuscle=j;
7180 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7181 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7182 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7183 XYZ tempnormthing,vec1,vec2;
7184 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7185 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7186 CrossProduct(&vec1,&vec2,&tempnormthing);
7187 Normalise(&tempnormthing);
7188 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);
7189 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7191 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7192 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7193 Normalise(&weaptargnorm);
7194 weaponpoint-=weaptargnorm*2;
7198 if(weaponactive!=k&&weaponstuck!=k){
7199 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;
7200 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;
7201 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;
7202 for(j=0;j<skeleton.num_muscles;j++){
7203 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){
7204 weaponrotatemuscle=j;
7209 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7210 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7211 for(j=0;j<skeleton.num_muscles;j++){
7212 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){
7213 weaponrotatemuscle=j;
7218 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;
7219 weapons.bigrotation[i]=rotation;
7220 weapons.bigtilt[i]=tilt;
7221 weapons.bigtilt2[i]=tilt2;
7224 weapons.position[i]=weaponpoint*scale+coords;
7225 weapons.bigrotation[i]=0;
7226 weapons.bigtilt[i]=0;
7227 weapons.bigtilt2[i]=0;
7229 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7230 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7231 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7232 if(weaponactive==k){
7233 if(weapons.type[i]==knife){
7234 weapons.smallrotation[i]=180;
7235 weapons.smallrotation2[i]=0;
7236 if(isCrouch()||wasCrouch()){
7237 weapons.smallrotation2[i]=20;
7239 if(targetanimation==hurtidleanim){
7240 weapons.smallrotation2[i]=50;
7242 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7243 XYZ temppoint1,temppoint2,tempforward;
7246 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7247 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7248 distance=findDistance(&temppoint1,&temppoint2);
7249 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7250 weapons.rotation2[i]*=360/6.28;
7253 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7254 weapons.rotation1[i]*=360/6.28;
7255 weapons.rotation3[i]=0;
7256 weapons.smallrotation[i]=-90;
7257 weapons.smallrotation2[i]=0;
7258 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7260 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7261 XYZ temppoint1,temppoint2,tempforward;
7264 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7265 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7266 distance=findDistance(&temppoint1,&temppoint2);
7267 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7268 weapons.rotation2[i]*=360/6.28;
7271 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7272 weapons.rotation1[i]*=360/6.28;
7273 weapons.rotation3[i]=0;
7274 weapons.smallrotation[i]=90;
7275 weapons.smallrotation2[i]=0;
7276 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7278 if(targetanimation==knifethrowanim){
7279 weapons.smallrotation[i]=90;
7280 //weapons.smallrotation2[i]=-90;
7281 weapons.smallrotation2[i]=0;
7282 weapons.rotation1[i]=0;
7283 weapons.rotation2[i]=0;
7284 weapons.rotation3[i]=0;
7286 if(targetanimation==knifesneakattackanim&&targetframe<5){
7287 weapons.smallrotation[i]=-90;
7288 weapons.rotation1[i]=0;
7289 weapons.rotation2[i]=0;
7290 weapons.rotation3[i]=0;
7293 if(weapons.type[i]==sword){
7294 weapons.smallrotation[i]=0;
7295 weapons.smallrotation2[i]=0;
7296 if(targetanimation==knifethrowanim){
7297 weapons.smallrotation[i]=-90;
7298 weapons.smallrotation2[i]=0;
7299 weapons.rotation1[i]=0;
7300 weapons.rotation2[i]=0;
7301 weapons.rotation3[i]=0;
7303 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)){
7304 XYZ temppoint1,temppoint2,tempforward;
7307 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7308 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7309 distance=findDistance(&temppoint1,&temppoint2);
7310 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7311 weapons.rotation2[i]*=360/6.28;
7314 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7315 weapons.rotation1[i]*=360/6.28;
7316 weapons.rotation3[i]=0;
7317 weapons.smallrotation[i]=90;
7318 weapons.smallrotation2[i]=0;
7319 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7322 if(weapons.type[i]==staff){
7323 weapons.smallrotation[i]=100;
7324 weapons.smallrotation2[i]=0;
7325 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7326 XYZ temppoint1,temppoint2,tempforward;
7329 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7330 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7331 distance=findDistance(&temppoint1,&temppoint2);
7332 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7333 weapons.rotation2[i]*=360/6.28;
7336 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7337 weapons.rotation1[i]*=360/6.28;
7338 weapons.rotation3[i]=0;
7339 weapons.smallrotation[i]=90;
7340 weapons.smallrotation2[i]=0;
7341 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7345 if(weaponactive!=k&&weaponstuck!=k){
7346 if(weapons.type[i]==knife){
7347 weapons.smallrotation[i]=-70;
7348 weapons.smallrotation2[i]=10;
7350 if(weapons.type[i]==sword){
7351 weapons.smallrotation[i]=-100;
7352 weapons.smallrotation2[i]=-8;
7354 if(weapons.type[i]==staff){
7355 weapons.smallrotation[i]=-100;
7356 weapons.smallrotation2[i]=-8;
7360 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7361 else weapons.smallrotation[i]=0;
7362 weapons.smallrotation2[i]=10;
7363 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7371 if(skeleton.free)calcrot=1;
7372 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7373 if(currentanimation!=targetanimation)calcrot=1;
7374 //if(id==0)calcrot=1;
7375 if(skeleton.free==2)calcrot=0;
7381 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7384 static float distance;
7385 static float olddistance;
7386 static int intersecting;
7387 static int firstintersecting;
7390 static XYZ start,end;
7391 static float slopethreshold=-.4;
7393 firstintersecting=-1;
7397 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7398 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7400 for (j=0;j<model->TriangleNum;j++){
7401 if(model->facenormals[j].y<=slopethreshold){
7403 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)));
7404 if(distance<radius){
7405 point=*p1-model->facenormals[j]*distance;
7406 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;
7407 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7408 &model->vertex[model->Triangles[j].vertex[1]],
7410 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7411 &model->vertex[model->Triangles[j].vertex[2]],
7413 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7414 &model->vertex[model->Triangles[j].vertex[2]],
7417 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7421 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)){
7422 p1->y=point.y+radius;
7423 if((targetanimation==jumpdownanim||isFlip())){
7424 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7426 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7432 OPENAL_SetPaused(channels[whooshsound], true);
7433 OPENAL_SetVolume(channels[whooshsound], 0);
7436 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7437 if(isFlip())jumppower=-4;
7438 targetanimation=getLanding();
7447 PlaySoundEx( landsound, samp[landsound], NULL, true);
7448 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7449 OPENAL_SetVolume(channels[landsound], 128);
7450 OPENAL_SetPaused(channels[landsound], false);
7453 envsound[numenvsounds]=coords;
7454 envsoundvol[numenvsounds]=16;
7455 envsoundlife[numenvsounds]=.4;
7463 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7466 for (j=0;j<model->TriangleNum;j++){
7467 if(model->facenormals[j].y>slopethreshold){
7471 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)));
7472 if(distance<radius*.5){
7473 point=start-model->facenormals[j]*distance;
7474 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;
7475 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,
7476 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7477 p1->x, p1->y, p1->z, radius/2);
7478 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,
7479 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7480 p1->x, p1->y, p1->z, radius/2);
7481 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,
7482 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7483 p1->x, p1->y, p1->z, radius/2);
7485 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7486 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7488 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7489 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7491 *p1+=model->facenormals[j]*(distance-radius*.5);
7494 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7498 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7500 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7502 return firstintersecting;
7512 currentanimation = 0;
7513 targetanimation = 0;
7514 oldcurrentframe = 0;
7516 oldcurrentanimation = 0;
7517 oldtargetanimation = 0;
7521 parriedrecently = 0;
7525 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7527 currentoffset = 0,targetoffset = 0,offset = 0;
7545 unconscioustime = 0;
7563 rabbitkickenabled = 0;
7572 damagetolerance = 0;
7574 permanentdamage = 0;
7575 superpermanentdamage = 0; lastcollide = 0;
7595 headrotation = 0,headrotation2 = 0;
7596 targetheadrotation = 0,targetheadrotation2 = 0;
7607 normalsupdatedelay = 0;
7612 forwardstogglekeydown = 0;
7617 jumptogglekeydown = 0;
7619 crouchtogglekeydown = 0;
7621 drawtogglekeydown = 0;
7623 throwtogglekeydown = 0;
7629 crouchkeydowntime = 0;
7630 jumpkeydowntime = 0;
7647 whichdirectiondelay = 0;
7648 avoidsomething = 0; avoidwhere = 0;
7656 lefthandmorphness = 0;
7657 righthandmorphness = 0;
7661 targetlefthandmorphness = 0;
7662 targetrighthandmorphness = 0;
7663 targetheadmorphness = 0;
7664 targetchestmorphness = 0;
7665 targettailmorphness = 0;
7666 lefthandmorphstart = 0,lefthandmorphend = 0;
7667 righthandmorphstart = 0,righthandmorphend = 0;
7668 headmorphstart = 0,headmorphend = 0;
7669 chestmorphstart = 0,chestmorphend = 0;
7670 tailmorphstart = 0,tailmorphend = 0;
7672 weaponmissdelay = 0;
7673 highreversaldelay = 0;
7674 lowreversaldelay = 0;
7681 //Skeleton skeleton;
7700 memset(clothes, 0, sizeof(clothes));
7701 memset(clothestintr, 0, sizeof(clothestintr));
7702 memset(clothestintg, 0, sizeof(clothestintg));
7703 memset(clothestintb, 0, sizeof(clothestintb));
7709 onfiredelay = 0; burnt = 0;
7713 updatestuffdelay = 0;
7719 memset(weaponids, 0, sizeof(weaponids));
7723 weaponstuckwhere = 0;
7728 memset(waypoints, 0, sizeof(waypoints));
7729 memset(waypointtype, 0, sizeof(waypointtype));
7732 hastempwaypoint = 0;
7738 finalfinaltarget = 0;
7740 finalpathfindpoint = 0;
7741 targetpathfindpoint = 0;
7742 lastpathfindpoint = 0;
7743 lastpathfindpoint2 = 0;
7744 lastpathfindpoint3 = 0;
7745 lastpathfindpoint4 = 0;
7756 runninghowlong = 0; lastoccluded = 0;
7762 neckspurtparticledelay = 0;
7763 neckspurtamount = 0;
7766 rabbitkickragdoll = 0;
7771 //Animation tempanimation;