2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /**> HEADER FILES <**/
24 #include "openal_wrapper.h"
25 #include "Animation.h"
30 extern float multiplier;
31 extern int channels[100];
32 extern Terrain terrain;
34 extern int environment;
36 extern FRUSTUM frustum;
38 extern float realmultiplier;
40 extern float slomodelay;
41 extern bool cellophane;
42 extern float texdetail;
43 extern float realtexdetail;
44 extern GLubyte bloodText[512*512*3];
45 extern GLubyte wolfbloodText[512*512*3];
46 extern int bloodtoggle;
47 extern Objects objects;
49 extern bool autoslomo;
50 extern float camerashake;
52 extern float terraindetail;
53 extern float viewdistance;
54 extern float blackout;
55 extern int difficulty;
57 extern float fadestart;
59 extern bool winfreeze;
60 extern float flashamount,flashr,flashg,flashb;
61 extern int flashdelay;
62 extern bool showpoints;
63 extern bool immediate;
65 extern bool tilt2weird;
66 extern bool tiltweird;
68 extern bool proportionweird;
69 extern bool vertexweird[6];
70 extern GLubyte texturearray[512*512*3];
71 extern XYZ envsound[30];
72 extern float envsoundvol[30];
73 extern float envsoundlife[30];
74 extern int numenvsounds;
75 extern int tutoriallevel;
76 extern float smoketex;
77 extern int tutorialstage;
78 extern bool reversaltrain;
79 extern bool canattack;
81 extern float damagedealt;
83 extern float hostiletime;
85 extern int indialogue;
87 extern bool gamestarted;
89 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
90 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
92 void Person::CheckKick(){
96 float damagemult=1*power;
97 if(creature==wolftype)damagemult=2.5*power;
101 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
102 if(findDistancefast(&coords,&victim->coords)<1.2){
103 if(!victim->skeleton.free){
105 Normalise(&relative);
106 relative=coords+relative*1;
107 if(animation[victim->targetanimation].height!=lowheight){
112 gLoc[0]=victim->coords.x;
113 gLoc[1]=victim->coords.y;
114 gLoc[2]=victim->coords.z;
118 if(tutoriallevel!=1){
119 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
120 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
121 OPENAL_SetVolume(channels[heavyimpactsound], 128);
122 OPENAL_SetPaused(channels[heavyimpactsound], false);
127 Normalise(&relative);
128 for(i=0;i<victim->skeleton.num_joints;i++){
129 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
132 victim->DoDamage(100*damagemult/victim->protectionhigh);
133 if(id==0)camerashake+=.4;
137 targetanimation=backflipanim;
142 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
144 award_bonus(id, cannon);
146 else if (victim->isCrouch()){
147 targetanimation=rabbitkickreversedanim;
148 currentanimation=rabbitkickreversedanim;
149 victim->currentanimation=rabbitkickreversalanim;
150 victim->targetanimation=rabbitkickreversalanim;
156 victim->oldcoords=victim->coords;
157 coords=victim->coords;
158 victim->targetrotation=targetrotation;
166 void Person::CatchFire(){
167 XYZ flatfacing,flatvelocity;
169 for(int i=0;i<10;i++){
170 howmany=abs(Random()%(skeleton.num_joints));
171 if(!skeleton.free)flatvelocity=velocity;
172 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
173 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
174 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
175 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
188 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
189 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
190 OPENAL_SetVolume(channels[firestartsound], 256);
191 OPENAL_SetPaused(channels[firestartsound], false);
196 //PlaySoundEx( firesound, samp[firesound], NULL, true);
197 PlayStreamEx( stream_firesound, samp[stream_firesound], NULL, true);
198 OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
199 OPENAL_SetVolume(channels[stream_firesound], 256);
200 OPENAL_SetPaused(channels[stream_firesound], false);
207 bool Person::isIdle(){
208 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;
212 bool Person::isSitting(){
213 if(targetanimation==sitanim)return 1;
214 if(targetanimation==sitwallanim)return 1;
218 bool Person::isSleeping(){
219 if(targetanimation==sleepanim)return 1;
220 if(targetanimation==dead1anim)return 1;
221 if(targetanimation==dead2anim)return 1;
222 if(targetanimation==dead3anim)return 1;
223 if(targetanimation==dead4anim)return 1;
227 bool Person::wasIdle(){
228 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;
231 int Person::getIdle(){
232 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
233 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)){
234 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
235 if(creature==rabbittype)return fightidleanim;
236 if(creature==wolftype)return wolfidle;
238 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
239 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
240 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
241 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
242 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
244 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
246 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
247 if(howactive==typesitting)return sitanim;
248 if(howactive==typesittingwall)return sitwallanim;
249 if(howactive==typesleeping)return sleepanim;
250 if(howactive==typedead1)return dead1anim;
251 if(howactive==typedead2)return dead2anim;
252 if(howactive==typedead3)return dead3anim;
253 if(howactive==typedead4)return dead4anim;
254 if(creature==rabbittype)return bounceidleanim;
255 if(creature==wolftype)return wolfidle;
259 bool Person::isCrouch(){
260 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
265 bool Person::wasCrouch(){
266 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
269 int Person::getCrouch(){
270 if(creature==rabbittype)return crouchanim;
271 if(creature==wolftype)return wolfcrouchanim;
275 bool Person::isRun(){
276 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
281 bool Person::wasRun(){
282 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
285 int Person::getRun(){
286 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
287 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
289 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
290 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
294 bool Person::isStop(){
295 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
300 bool Person::wasStop(){
301 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
304 int Person::getStop(){
305 if(creature==rabbittype)return stopanim;
306 if(creature==wolftype)return wolfstopanim;
311 bool Person::isLanding(){
312 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
317 bool Person::wasLanding(){
318 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
321 int Person::getLanding(){
322 if(creature==rabbittype)return landanim;
323 if(creature==wolftype)return wolflandanim;
328 bool Person::isLandhard(){
329 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
334 bool Person::wasLandhard(){
335 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
338 int Person::getLandhard(){
339 if(creature==rabbittype)return landhardanim;
340 if(creature==wolftype)return wolflandhardanim;
345 bool Person::isFlip(){
346 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
350 bool Person::wasFlip(){
351 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
355 bool Person::isWallJump(){
356 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
361 SolidHitBonus(int playerid)
363 if (bonustime < 1.5 && bonus >= solidhit && bonus <= megacombo)
364 award_bonus(playerid, bonus == megacombo ? bonus : bonus + 1);
366 award_bonus(playerid, solidhit);
369 void Person::DoBlood(float howmuch,int which){
370 static int bleedxint,bleedyint;
372 //if(howmuch&&id==0)blooddimamount=1;
373 if(bloodtoggle&&tutoriallevel!=1){
374 if(bleeding<=0&&spurt){
376 for(int i=0;i<3;i++){
380 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
383 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
385 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
386 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
388 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
389 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
392 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);
393 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);
397 for(int i=0;i<3;i++){
401 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
402 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
405 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
406 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
410 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
412 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);
414 Sprite::setLastSpriteSpecial(3);
419 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
422 int texdetailint=realtexdetail;
423 if(creature==rabbittype)
424 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){
425 bleedxint=abs(Random()%512);
426 bleedyint=abs(Random()%512);
428 if(creature==wolftype)
429 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){
430 bleedxint=abs(Random()%512);
431 bleedyint=abs(Random()%512);
435 bleedy/=realtexdetail;
436 bleedx/=realtexdetail;
437 direction=abs(Random()%2)*2-1;
441 if(bleeding>2)bleeding=2;
444 void Person::DoBloodBig(float howmuch,int which){
445 static int bleedxint,bleedyint,i,j;
447 if(howmuch&&id==0)blooddimamount=1;
449 if(tutoriallevel!=1||id==0)
450 if(aitype!=playercontrolled&&howmuch>0){
461 if(creature==wolftype){
462 int i=abs(Random()%2);
463 if(i==0)whichsound=snarlsound;
464 if(i==1)whichsound=snarl2sound;
465 envsound[numenvsounds]=coords;
466 envsoundvol[numenvsounds]=16;
467 envsoundlife[numenvsounds]=.4;
470 if(creature==rabbittype){
471 int i=abs(Random()%2);
472 if(i==0)whichsound=rabbitpainsound;
473 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
474 envsound[numenvsounds]=coords;
475 envsoundvol[numenvsounds]=16;
476 envsoundlife[numenvsounds]=.4;
478 //if(i==2)whichsound=rabbitpain2sound;
482 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
483 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
484 OPENAL_SetVolume(channels[whichsound], 512);
485 OPENAL_SetPaused(channels[whichsound], false);
489 if(id==0&&howmuch>0){
497 if(bloodtoggle&&decals&&tutoriallevel!=1){
498 if(bleeding<=0&&spurt){
500 for(int i=0;i<3;i++){
504 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
507 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
509 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
510 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
512 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
513 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
516 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);
517 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);
521 int offsetx=0,offsety=0;
524 offsetx=abs(Random()%60);
526 if(which==190||which==185){
528 offsetx=abs(Random()%100)-20;
538 if(which==220||which==215){
539 //offsety=Random()%20;
541 //offsetx=abs(Random()%80);
550 if(creature==rabbittype)
553 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
554 if(i<startx)startx=i;
555 if(j<starty)starty=j;
561 if(creature==wolftype)
564 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
565 if(i<startx)startx=i;
566 if(j<starty)starty=j;
578 if(startx<0)startx=0;
579 if(starty<0)starty=0;
580 if(endx>512-1)endx=512-1;
581 if(endy>512-1)endy=512-1;
582 if(endx<startx)endx=startx;
583 if(endy<starty)endy=starty;
585 startx/=realtexdetail;
586 starty/=realtexdetail;
590 int texdetailint=realtexdetail;
592 if(creature==rabbittype)
593 for(i=startx;i<endx;i++){
594 for(j=starty;j<endy;j++){
595 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){
596 color=Random()%85+170;
597 where=i*skeleton.skinsize*3+j*3;
598 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
599 skeleton.skinText[where+1]=0;
600 skeleton.skinText[where+2]=0;
604 if(creature==wolftype)
605 for(i=startx;i<endx;i++){
606 for(j=starty;j<endy;j++){
607 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){
608 color=Random()%85+170;
609 where=i*skeleton.skinsize*3+j*3;
610 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
611 skeleton.skinText[where+1]=0;
612 skeleton.skinText[where+2]=0;
616 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
617 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
618 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
622 if(creature==rabbittype)
623 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){
624 bleedxint=abs(Random()%512);
625 bleedyint=abs(Random()%512);
627 if(creature==wolftype)
628 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){
629 bleedxint=abs(Random()%512);
630 bleedyint=abs(Random()%512);
632 bleedy=bleedxint+offsetx;
633 bleedx=bleedyint+offsety;
634 bleedy/=realtexdetail;
635 bleedx/=realtexdetail;
636 if(bleedx<0)bleedx=0;
637 if(bleedy<0)bleedy=0;
638 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
639 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
640 direction=abs(Random()%2)*2-1;
643 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
644 deathbleeding+=bleeding;
645 bloodloss+=bleeding*3;
647 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
648 if(abs(Random()%2)==0){aitype=gethelptype;
651 else aitype=attacktypecutoff;
654 if(bleeding>2)bleeding=2;
657 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
658 static int bleedxint,bleedyint,i,j;
660 static XYZ startpoint,endpoint,colpoint,movepoint;
661 static float rotationpoint;
663 static XYZ p1,p2,p3,p0;
667 float coordsx,coordsy;
670 if(bloodtoggle&&decals&&tutoriallevel!=1){
672 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
680 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
683 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
684 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
685 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
687 CrossProduct(p2-p1,p3-p1,&N);
688 CrossProduct(p0-p1,p3-p1,&temp);
689 s = dotproduct(&temp,&N)/findLength(&N);
690 CrossProduct(p2-p1,p1-p0,&temp);
691 t = dotproduct(&temp,&N)/findLength(&N);
694 bary.x=findDistancefast(&p0,&p1);
695 bary.y=findDistancefast(&p0,&p2);
696 bary.z=findDistancefast(&p0,&p3);
698 total=bary.x+bary.y+bary.z;
707 total=bary.x+bary.y+bary.z;
713 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
714 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
715 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
716 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
717 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
718 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
719 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;
720 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;
722 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
723 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
725 if(bleeding<=0&&spurt){
727 for(int i=0;i<3;i++){
731 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
734 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
736 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
737 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
739 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
740 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
743 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);
744 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);
748 int offsetx=0,offsety=0;
751 offsetx=abs(Random()%120);
753 if(which==220||which==215){
755 offsetx=abs(Random()%80);
758 offsetx=(1+coordsy)*512-291;
759 offsety=coordsx*512-437;
766 if(creature==rabbittype)
769 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
770 if(i<startx)startx=i;
771 if(j<starty)starty=j;
777 if(creature==wolftype)
780 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
781 if(i<startx)startx=i;
782 if(j<starty)starty=j;
793 if(startx<0)startx=0;
794 if(starty<0)starty=0;
795 if(endx>512-1)endx=512-1;
796 if(endy>512-1)endy=512-1;
797 if(endx<startx)endx=startx;
798 if(endy<starty)endy=starty;
800 startx/=realtexdetail;
801 starty/=realtexdetail;
805 int texdetailint=realtexdetail;
807 if(creature==rabbittype)
808 for(i=startx;i<endx;i++){
809 for(j=starty;j<endy;j++){
810 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){
811 color=Random()%85+170;
812 where=i*skeleton.skinsize*3+j*3;
813 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
814 skeleton.skinText[where+1]=0;
815 skeleton.skinText[where+2]=0;
817 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){
818 color=Random()%85+170;
819 where=i*skeleton.skinsize*3+j*3;
820 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
821 skeleton.skinText[where+1]=0;
822 skeleton.skinText[where+2]=0;
826 if(creature==wolftype)
827 for(i=startx;i<endx;i++){
828 for(j=starty;j<endy;j++){
829 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){
830 color=Random()%85+170;
831 where=i*skeleton.skinsize*3+j*3;
832 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
833 skeleton.skinText[where+1]=0;
834 skeleton.skinText[where+2]=0;
836 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){
837 color=Random()%85+170;
838 where=i*skeleton.skinsize*3+j*3;
839 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
840 skeleton.skinText[where+1]=0;
841 skeleton.skinText[where+2]=0;
845 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
846 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
847 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
849 bleedy=(1+coordsy)*512;
851 bleedy/=realtexdetail;
852 bleedx/=realtexdetail;
853 if(bleedx<0)bleedx=0;
854 if(bleedy<0)bleedy=0;
855 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
856 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
857 direction=abs(Random()%2)*2-1;
859 if(whichtri==-1)return 0;
861 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
862 deathbleeding+=bleeding;
863 bloodloss+=bleeding*3;
865 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
866 if(abs(Random()%2)==0){aitype=gethelptype;
869 else aitype=attacktypecutoff;
872 if(bleeding>2)bleeding=2;
877 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
880 static int bytesPerPixel=3;
881 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
882 static int newstartx,newstarty,newendx,newendy;
883 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
885 static float sizemult;
887 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
888 texture[i]=skeleton.skinText[i];
891 if((!osx||howmanylevels)){
893 if(startx<0)startx=0;
894 if(starty<0)starty=0;
895 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
896 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
897 if((endx>startx&&endy>starty)||howmanylevels){
904 for(i=startx;i<endx;i++){
905 for(j=starty;j<endy;j++){
906 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
907 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
908 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
912 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
915 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
916 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
917 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
920 newsize=skeleton.skinsize;
923 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
925 /*for(j=1;j<=howmanylevels;j++){
926 if(j==1)texpointer=&skeleton.skinText[0];
927 else texpointer=&texture[0];
929 totalsize=int( newsize*newsize*bytesPerPixel);
930 rowsize=int( newsize*bytesPerPixel );
931 bigstep=bytesPerPixel*newsize*2;
932 smallstep=bytesPerPixel*2;
938 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
945 void Person::Reverse(){
946 if(victim->aitype==playercontrolled||hostiletime>1)
947 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
948 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
949 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
950 if(targetanimation==sweepanim){
951 targetanimation=sweepreversedanim;
952 currentanimation=sweepreversedanim;
953 victim->currentanimation=sweepreversalanim;
954 victim->targetanimation=sweepreversalanim;
956 if(targetanimation==spinkickanim){
957 targetanimation=spinkickreversedanim;
958 currentanimation=spinkickreversedanim;
959 victim->currentanimation=spinkickreversalanim;
960 victim->targetanimation=spinkickreversalanim;
962 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
963 if(targetanimation==rabbittacklinganim){
966 victim->currentframe=6;
967 victim->targetframe=7;
969 targetanimation=upunchreversedanim;
970 currentanimation=upunchreversedanim;
971 victim->currentanimation=upunchreversalanim;
972 victim->targetanimation=upunchreversalanim;
974 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
975 if(victim->weaponactive!=-1){
976 victim->throwtogglekeydown=1;
977 weapons.owner[victim->weaponids[0]]=-1;
978 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
979 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
980 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
981 weapons.missed[victim->weaponids[0]]=1;
982 weapons.freetime[victim->weaponids[0]]=0;
983 weapons.firstfree[victim->weaponids[0]]=1;
984 weapons.physics[victim->weaponids[0]]=1;
985 victim->num_weapons--;
986 if(victim->num_weapons){
987 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
988 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
991 victim->weaponactive=-1;
992 for(int j=0;j<numplayers;j++){
993 player[j].wentforweapon=0;
997 targetanimation=staffhitreversedanim;
998 currentanimation=staffhitreversedanim;
999 victim->currentanimation=staffhitreversalanim;
1000 victim->targetanimation=staffhitreversalanim;
1002 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1003 if(victim->weaponactive!=-1){
1004 victim->throwtogglekeydown=1;
1005 weapons.owner[victim->weaponids[0]]=-1;
1006 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1007 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1008 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1009 weapons.missed[victim->weaponids[0]]=1;
1010 weapons.freetime[victim->weaponids[0]]=0;
1011 weapons.firstfree[victim->weaponids[0]]=1;
1012 weapons.physics[victim->weaponids[0]]=1;
1013 victim->num_weapons--;
1014 if(victim->num_weapons){
1015 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1016 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1019 victim->weaponactive=-1;
1020 for(int j=0;j<numplayers;j++){
1021 player[j].wentforweapon=0;
1024 targetanimation=staffspinhitreversedanim;
1025 currentanimation=staffspinhitreversedanim;
1026 victim->currentanimation=staffspinhitreversalanim;
1027 victim->targetanimation=staffspinhitreversalanim;
1029 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1030 if(victim->weaponactive!=-1){
1031 victim->throwtogglekeydown=1;
1032 weapons.owner[victim->weaponids[0]]=-1;
1033 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1034 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1035 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1036 weapons.missed[victim->weaponids[0]]=1;
1037 weapons.freetime[victim->weaponids[0]]=0;
1038 weapons.firstfree[victim->weaponids[0]]=1;
1039 weapons.physics[victim->weaponids[0]]=1;
1040 victim->num_weapons--;
1041 if(victim->num_weapons){
1042 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1043 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1046 victim->weaponactive=-1;
1047 for(int j=0;j<numplayers;j++){
1048 player[j].wentforweapon=0;
1051 targetanimation=swordslashreversedanim;
1052 currentanimation=swordslashreversedanim;
1053 victim->currentanimation=swordslashreversalanim;
1054 victim->targetanimation=swordslashreversalanim;
1056 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1057 if(victim->weaponactive!=-1){
1058 victim->throwtogglekeydown=1;
1059 weapons.owner[victim->weaponids[0]]=-1;
1060 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1061 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1062 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1063 weapons.missed[victim->weaponids[0]]=1;
1064 weapons.freetime[victim->weaponids[0]]=0;
1065 weapons.firstfree[victim->weaponids[0]]=1;
1066 weapons.physics[victim->weaponids[0]]=1;
1067 victim->num_weapons--;
1068 if(victim->num_weapons){
1069 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1070 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1073 victim->weaponactive=-1;
1074 for(int j=0;j<numplayers;j++){
1075 player[j].wentforweapon=0;
1078 targetanimation=knifeslashreversedanim;
1079 currentanimation=knifeslashreversedanim;
1080 victim->currentanimation=knifeslashreversalanim;
1081 victim->targetanimation=knifeslashreversalanim;
1083 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1084 victim->targettilt2=targettilt2;
1085 victim->currentframe=currentframe;
1086 victim->targetframe=targetframe;
1087 victim->target=target;
1089 victim->oldcoords=victim->coords;
1090 victim->coords=coords;
1091 victim->targetrotation=targetrotation;
1092 victim->rotation=targetrotation;
1093 victim->victim=this;
1095 if(targetanimation==winduppunchanim){
1096 targetanimation=winduppunchblockedanim;
1097 victim->targetanimation=blockhighleftanim;
1098 victim->targetframe=1;
1100 victim->victim=this;
1101 victim->targetrotation=targetrotation+180;
1103 if(targetanimation==wolfslapanim){
1104 targetanimation=winduppunchblockedanim;
1105 victim->targetanimation=blockhighleftanim;
1106 victim->targetframe=1;
1108 victim->victim=this;
1109 victim->targetrotation=targetrotation+180;
1111 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1112 targetanimation=swordslashparriedanim;
1114 victim->parriedrecently=0;
1115 victim->targetanimation=swordslashparryanim;
1116 victim->targetframe=1;
1118 victim->victim=this;
1119 victim->targetrotation=targetrotation+180;
1121 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1124 gLoc[0]=victim->coords.x;
1125 gLoc[1]=victim->coords.y;
1126 gLoc[2]=victim->coords.z;
1130 if(victim->weaponactive!=-1){
1131 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1132 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1133 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1135 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1136 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1137 OPENAL_SetVolume(channels[swordstaffsound], 512);
1138 OPENAL_SetPaused(channels[swordstaffsound], false);
1141 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1142 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1143 OPENAL_SetVolume(channels[metalhitsound], 512);
1144 OPENAL_SetPaused(channels[metalhitsound], false);
1148 victim->Puff(righthand);
1150 victim->targetframe=0;
1151 victim->targetanimation=staggerbackhighanim;
1152 victim->targetrotation=targetrotation+180;
1154 weapons.owner[victim->weaponids[0]]=-1;
1155 aim=DoRotation(facing,0,90,0)*21;
1157 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1158 weapons.tipvelocity[victim->weaponids[0]]=aim;
1159 weapons.missed[victim->weaponids[0]]=1;
1160 weapons.hitsomething[victim->weaponids[0]]=0;
1161 weapons.freetime[victim->weaponids[0]]=0;
1162 weapons.firstfree[victim->weaponids[0]]=1;
1163 weapons.physics[victim->weaponids[0]]=1;
1164 victim->num_weapons--;
1165 if(victim->num_weapons){
1166 victim->weaponids[0]=victim->weaponids[num_weapons];
1167 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1169 victim->weaponactive=-1;
1170 for(int i=0;i<numplayers;i++){
1171 player[i].wentforweapon=0;
1178 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1179 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1180 OPENAL_SetVolume(channels[metalhitsound], 512);
1181 OPENAL_SetPaused(channels[metalhitsound], false);*/
1184 if(abs(Random()%20)==0){
1193 if(weaponactive!=-1){
1194 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1195 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1196 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1198 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1199 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1200 OPENAL_SetVolume(channels[swordstaffsound], 512);
1201 OPENAL_SetPaused(channels[swordstaffsound], false);
1204 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1205 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1206 OPENAL_SetVolume(channels[metalhitsound], 512);
1207 OPENAL_SetPaused(channels[metalhitsound], false);
1215 targetanimation=staggerbackhighanim;
1216 targetrotation=targetrotation+180;
1218 weapons.owner[weaponids[0]]=-1;
1219 aim=DoRotation(facing,0,90,0)*21;
1221 weapons.velocity[weaponids[0]]=aim*-.2;
1222 weapons.tipvelocity[weaponids[0]]=aim;
1223 weapons.hitsomething[weaponids[0]]=0;
1224 weapons.missed[weaponids[0]]=1;
1225 weapons.freetime[weaponids[0]]=0;
1226 weapons.firstfree[weaponids[0]]=1;
1227 weapons.physics[weaponids[0]]=1;
1230 weaponids[0]=weaponids[num_weapons];
1231 if(weaponstuck==num_weapons)weaponstuck=0;
1234 for(int i=0;i<numplayers;i++){
1235 player[i].wentforweapon=0;
1239 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1240 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1241 OPENAL_SetVolume(channels[metalhitsound], 512);
1242 OPENAL_SetPaused(channels[metalhitsound], false);*/
1246 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1247 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1248 //victim->targetanimation=sweepanim;
1249 victim->targetanimation=dodgebackanim;
1250 victim->targetframe=0;
1252 //victim->velocity=0;
1255 rotatetarget=coords-victim->coords;
1256 Normalise(&rotatetarget);
1257 victim->targetrotation=-asin(0-rotatetarget.x);
1258 victim->targetrotation*=360/6.28;
1259 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1261 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1263 victim->lastattack3=victim->lastattack2;
1264 victim->lastattack2=victim->lastattack;
1265 victim->lastattack=victim->targetanimation;
1269 victim->targetanimation=sweepanim;
1270 victim->targetframe=0;
1274 rotatetarget=coords-victim->coords;
1275 Normalise(&rotatetarget);
1276 victim->targetrotation=-asin(0-rotatetarget.x);
1277 victim->targetrotation*=360/6.28;
1278 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1280 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1282 victim->lastattack3=victim->lastattack2;
1283 victim->lastattack2=victim->lastattack;
1284 victim->lastattack=victim->targetanimation;
1291 if(aitype!=playercontrolled)feint=0;
1292 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1293 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1294 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1296 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1300 void Person::DoDamage(float howmuch){
1301 if(tutoriallevel!=1)damage+=howmuch/power;
1302 if(id!=0)damagedealt+=howmuch/power;
1303 if(id==0)damagetaken+=howmuch/power;
1305 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1306 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1307 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1308 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1309 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1311 if(id==0)camerashake+=howmuch/100;
1312 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1313 if(blackout>1)blackout=1;
1315 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1316 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1317 if(abs(Random()%2)==0){aitype=gethelptype;
1320 else aitype=attacktypecutoff;
1324 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1327 for(int i=0;i<skeleton.num_joints; i++){
1328 if(!skeleton.free)flatvelocity2=velocity;
1329 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1330 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1331 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1332 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1333 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1334 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1335 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1336 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1337 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1348 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1349 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1350 OPENAL_SetVolume(channels[splattersound], 256);
1351 OPENAL_SetPaused(channels[splattersound], false);
1360 if(!dead&&creature==wolftype){
1361 award_bonus(0, Wolfbonus);
1367 if(tutoriallevel!=1||id==0)
1368 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1379 if(creature==wolftype){
1380 int i=abs(Random()%2);
1381 if(i==0)whichsound=snarlsound;
1382 if(i==1)whichsound=snarl2sound;
1383 envsound[numenvsounds]=coords;
1384 envsoundvol[numenvsounds]=16;
1385 envsoundlife[numenvsounds]=.4;
1388 if(creature==rabbittype){
1389 int i=abs(Random()%2);
1390 if(i==0)whichsound=rabbitpainsound;
1391 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1392 envsound[numenvsounds]=coords;
1393 envsoundvol[numenvsounds]=16;
1394 envsoundlife[numenvsounds]=.4;
1396 //if(i==2)whichsound=rabbitpain2sound;
1400 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1401 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1402 OPENAL_SetVolume(channels[whichsound], 512);
1403 OPENAL_SetPaused(channels[whichsound], false);
1408 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1409 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1412 void Person::DoHead(){
1413 static XYZ rotatearound;
1415 static float lookspeed=500;
1417 if(!freeze&&!winfreeze){
1420 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1421 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1423 while(targetheadrotation>180)targetheadrotation-=360;
1424 while(targetheadrotation<-180)targetheadrotation+=360;
1426 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1427 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1428 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1429 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1431 if(targetheadrotation2>120)targetheadrotation2=120;
1432 if(targetheadrotation2<-120)targetheadrotation2=-120;
1433 if(targetheadrotation>120)targetheadrotation=120;
1434 if(targetheadrotation<-120)targetheadrotation=-120;
1436 if(!isIdle())targetheadrotation2=0;
1438 if(targetheadrotation>80)targetheadrotation=80;
1439 if(targetheadrotation<-80)targetheadrotation=-80;
1440 if(targetheadrotation2>50)targetheadrotation2=50;
1441 if(targetheadrotation2<-50)targetheadrotation2=-50;
1444 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1445 else if(headrotation>targetheadrotation){
1446 headrotation-=multiplier*lookspeed;
1448 else if(headrotation<targetheadrotation){
1449 headrotation+=multiplier*lookspeed;
1452 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1453 else if(headrotation2>targetheadrotation2){
1454 headrotation2-=multiplier*lookspeed/2;
1456 else if(headrotation2<targetheadrotation2){
1457 headrotation2+=multiplier*lookspeed/2;
1460 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1461 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1465 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1466 facing=DoRotation(facing,headrotation2*.4,0,0);
1467 facing=DoRotation(facing,0,headrotation*.4,0);
1470 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1471 facing=DoRotation(facing,headrotation2*.8,0,0);
1472 facing=DoRotation(facing,0,headrotation*.8,0);
1475 if(targetanimation==walkanim){
1476 facing=DoRotation(facing,headrotation2*.6,0,0);
1477 facing=DoRotation(facing,0,headrotation*.6,0);
1480 skeleton.specialforward[0]=facing;
1481 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1483 for(i=0;i<skeleton.num_muscles;i++){
1484 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1486 skeleton.FindRotationMuscle(i,targetanimation);
1492 void Person::RagDoll(bool checkcollision){
1497 if(id==0)numfalls++;
1498 if(id==0&&isFlip())numflipfail++;
1504 facing=DoRotation(facing,0,rotation,0);
1506 skeleton.freetime=0;
1508 skeleton.longdead=0;
1514 skeleton.freefall=1;
1516 if(!isnormal(velocity.x))velocity.x=0;
1517 if(!isnormal(velocity.y))velocity.y=0;
1518 if(!isnormal(velocity.z))velocity.z=0;
1519 if(!isnormal(rotation))rotation=0;
1520 if(!isnormal(coords.x))coords=0;
1521 if(!isnormal(tilt))tilt=0;
1522 if(!isnormal(tilt2))tilt2=0;
1524 for(i=0;i<skeleton.num_joints;i++){
1525 skeleton.joints[i].delay=0;
1526 skeleton.joints[i].locked=0;
1527 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1528 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1529 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1530 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1531 skeleton.joints[i].position.y+=.1;
1532 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1533 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1536 for(i=0;i<skeleton.num_joints;i++){
1537 skeleton.joints[i].velocity=0;
1538 skeleton.joints[i].velchange=0;
1540 skeleton.DoConstraints(&coords,&scale);
1541 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1543 skeleton.DoConstraints(&coords,&scale);
1544 skeleton.DoConstraints(&coords,&scale);
1545 skeleton.DoConstraints(&coords,&scale);
1546 skeleton.DoConstraints(&coords,&scale);
1549 speed=animation[targetanimation].speed[targetframe]*2;
1550 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1551 speed=animation[currentanimation].speed[currentframe]*2;
1553 if(transspeed)speed=transspeed*2;
1557 for(i=0;i<skeleton.num_joints;i++){
1558 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);
1559 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1560 change.x=(float)(Random()%100)/100;
1561 change.y=(float)(Random()%100)/100;
1562 change.z=(float)(Random()%100)/100;
1563 skeleton.joints[i].velocity+=change;
1564 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1566 change.x=(float)(Random()%100)/100;
1567 change.y=(float)(Random()%100)/100;
1568 change.z=(float)(Random()%100)/100;
1569 skeleton.joints[i].velchange+=change;
1570 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1580 for(j=0;j<skeleton.num_joints;j++){
1581 average+=skeleton.joints[j].position;
1585 coords+=average*scale;
1586 for(j=0;j<skeleton.num_joints;j++){
1587 skeleton.joints[j].position-=average;
1590 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1591 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1592 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1593 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1594 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1597 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1598 coords.x=lowpoint.x;
1599 coords.z=lowpoint.z;
1608 for(i=0;i<skeleton.num_joints;i++){
1609 velocity+=skeleton.joints[i].velocity*scale;
1611 velocity/=skeleton.num_joints;
1614 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1615 weapons.owner[weaponids[0]]=-1;
1616 weapons.hitsomething[weaponids[0]]=0;
1617 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1618 weapons.velocity[weaponids[0]].x+=.01;
1619 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1620 weapons.missed[weaponids[0]]=1;
1621 weapons.freetime[weaponids[0]]=0;
1622 weapons.firstfree[weaponids[0]]=1;
1623 weapons.physics[weaponids[0]]=1;
1626 weaponids[0]=weaponids[num_weapons];
1627 if(weaponstuck==num_weapons)weaponstuck=0;
1630 for(i=0;i<numplayers;i++){
1631 player[i].wentforweapon=0;
1636 targetanimation=bounceidleanim;
1637 currentanimation=bounceidleanim;
1645 void Person::FootLand(int which, float opacity){
1646 static XYZ terrainlight;
1647 static XYZ footvel,footpoint;
1648 if(opacity>=1||skiddelay<=0)
1652 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1653 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1654 //footpoint.y=coords.y;
1655 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1657 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1659 if(footvel.y<.8)footvel.y=.8;
1660 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1661 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1662 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1663 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1664 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1665 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1667 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1669 if(footvel.y<.8)footvel.y=.8;
1670 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1671 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1672 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1673 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1674 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);
1676 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1678 if(footvel.y<.8)footvel.y=.8;
1679 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1680 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1681 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1682 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1683 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);
1684 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1686 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1689 if(footvel.y<.8)footvel.y=.8;
1690 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1691 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1692 //footpoint.y=coords.y;
1693 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1697 void Person::Puff(int whichlabel){
1698 static XYZ footvel,footpoint;
1701 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1702 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1706 void Person::DoAnimations(){
1709 static float oldtarget;
1711 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1713 if(targetanimation==tempanim||currentanimation==tempanim){
1714 animation[tempanim]=tempanimation;
1716 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1727 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1728 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1730 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1731 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1733 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1738 targfacing=DoRotation(targfacing,0,targetrotation,0);
1740 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1741 else targetanimation=backflipanim;
1742 crouchtogglekeydown=1;
1746 if(id==0)numflipped++;
1749 if(animation[targetanimation].attack!=reversed)feint=0;
1750 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1751 crouchtogglekeydown=0;
1752 if(aitype==playercontrolled)feint=0;
1756 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1757 if(!isFlip())crouchtogglekeydown=1;
1761 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1762 if(detail)normalsupdatedelay=0;
1766 if(targetanimation==rollanim&&targetframe==3&&onfire){
1776 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1777 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1778 OPENAL_SetVolume(channels[fireendsound], 256);
1779 OPENAL_SetPaused(channels[fireendsound], false);
1780 OPENAL_SetPaused(channels[stream_firesound], true);
1784 if(targetanimation==rabbittacklinganim&&targetframe==1){
1785 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1786 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1787 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1788 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1789 else victim->targetanimation=rabbittackledfrontanim;
1790 victim->targetframe=2;
1792 victim->rotation=rotation;
1793 victim->targetrotation=rotation;
1794 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1795 //victim->DoDamage(30);
1796 if(creature==wolftype){
1800 gLoc[0]=victim->coords.x;
1801 gLoc[1]=victim->coords.y;
1802 gLoc[2]=victim->coords.z;
1806 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
1807 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
1808 OPENAL_SetVolume(channels[clawslicesound], 128);
1809 OPENAL_SetPaused(channels[clawslicesound], false);
1811 victim->DoBloodBig(1/victim->armorhead,210);
1813 award_bonus(id, TackleBonus,
1814 victim->aitype == gethelptype ? 50 : 0);
1818 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1819 if(weapons.type[weaponids[0]]==knife){
1820 if(weaponactive==-1)weaponactive=0;
1821 else if(weaponactive==0)weaponactive=-1;
1823 if(weaponactive==-1){
1833 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
1834 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
1835 OPENAL_SetVolume(channels[knifesheathesound], 128);
1836 OPENAL_SetPaused(channels[knifesheathesound], false);
1838 if(weaponactive!=-1){
1848 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1849 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1850 OPENAL_SetVolume(channels[knifedrawsound], 128);
1851 OPENAL_SetPaused(channels[knifedrawsound], false);
1854 drawtogglekeydown=1;
1857 if(tutoriallevel!=1||id==0)
1858 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1869 if(terrain.getOpacity(coords.x,coords.z)<.2){
1870 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1871 else whichsound=footstepsound2;
1872 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1873 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1874 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1880 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1881 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1882 else whichsound=footstepsound4;
1886 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1887 else whichsound=footstepsound4;
1889 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1890 if(animation[targetanimation].attack!=neutral){
1892 if(i==0)whichsound=lowwhooshsound;
1893 if(i==1)whichsound=midwhooshsound;
1894 if(i==2)whichsound=highwhooshsound;
1896 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1898 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1899 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1901 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1902 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1903 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
1904 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
1905 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
1906 OPENAL_SetPaused(channels[whichsound], false);
1909 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1910 envsound[numenvsounds]=coords;
1911 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1912 else envsoundvol[numenvsounds]=6;
1913 envsoundlife[numenvsounds]=.4;
1917 if(animation[targetanimation].label[targetframe]==3){
1919 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1920 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1921 OPENAL_SetVolume(channels[whichsound], 128);
1922 OPENAL_SetPaused(channels[whichsound], false);
1927 if(tutoriallevel!=1||id==0)
1929 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1930 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1940 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1941 if(animation[targetanimation].attack!=neutral){
1943 if(creature==rabbittype){
1944 if(i==0)whichsound=rabbitattacksound;
1945 if(i==1)whichsound=rabbitattack2sound;
1946 if(i==2)whichsound=rabbitattack3sound;
1947 if(i==3)whichsound=rabbitattack4sound;
1949 if(creature==wolftype){
1950 if(i==0)whichsound=barksound;
1951 if(i==1)whichsound=bark2sound;
1952 if(i==2)whichsound=bark3sound;
1953 if(i==3)whichsound=barkgrowlsound;
1957 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1959 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1960 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
1963 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1964 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1965 OPENAL_SetVolume(channels[whichsound], 512);
1966 OPENAL_SetPaused(channels[whichsound], false);
1972 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
1978 currentoffset=targetoffset;
1979 targetframe=currentframe;
1980 currentanimation=targetanimation;
1983 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
1984 for(i=0;i<weapons.numweapons;i++){
1985 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
1986 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
1987 if(findDistancefast(&coords,&weapons.position[i])>=1){
1988 if(weapons.type[i]!=staff){
1997 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1998 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1999 OPENAL_SetVolume(channels[knifedrawsound], 128);
2000 OPENAL_SetPaused(channels[knifedrawsound], false);
2004 weapons.owner[i]=id;
2006 weaponids[num_weapons]=weaponids[0];
2015 static bool willwork;
2016 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2017 for(i=0;i<weapons.numweapons;i++){
2019 if(weapons.owner[i]!=-1)
2020 if(player[weapons.owner[i]].weaponstuck!=-1)
2021 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2022 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2023 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))
2024 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2025 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2035 if(weapons.owner[i]!=-1)
2036 if(victim->weaponstuck!=-1){
2037 if(victim->weaponids[victim->weaponstuck]==i){
2042 if(weapons.type[i]!=staff){
2043 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2044 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2045 OPENAL_SetVolume(channels[knifedrawsound], 128);
2046 OPENAL_SetPaused(channels[knifedrawsound], false);
2050 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2051 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2052 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2053 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2056 if(weapons.owner[i]!=-1){
2058 victim=&player[weapons.owner[i]];
2059 if(victim->num_weapons==1)victim->num_weapons=0;
2060 else victim->num_weapons=1;
2062 //victim->weaponactive=-1;
2063 victim->skeleton.longdead=0;
2064 victim->skeleton.free=1;
2065 victim->skeleton.broken=0;
2067 for(int j=0;j<victim->skeleton.num_joints;j++){
2068 victim->skeleton.joints[j].velchange=0;
2069 victim->skeleton.joints[j].locked=0;
2075 Normalise(&relative);
2076 XYZ footvel,footpoint;
2078 footpoint=weapons.position[i];
2079 if(victim->weaponstuck!=-1){
2080 if(victim->weaponids[victim->weaponstuck]==i){
2081 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2082 weapons.bloody[i]=2;
2083 weapons.blooddrip[i]=5;
2084 victim->weaponstuck=-1;
2087 if(victim->num_weapons>0){
2088 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2089 if(victim->weaponids[0]==i)
2090 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2093 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2094 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2095 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2096 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2098 weapons.owner[i]=id;
2100 weaponids[num_weapons]=weaponids[0];
2109 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2110 if(weaponactive==-1)weaponactive=0;
2111 else if(weaponactive==0){
2115 buffer=weaponids[0];
2116 weaponids[0]=weaponids[1];
2117 weaponids[1]=buffer;
2120 if(weaponactive==-1){
2130 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2131 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2132 OPENAL_SetVolume(channels[knifesheathesound], 128);
2133 OPENAL_SetPaused(channels[knifesheathesound], false);
2135 if(weaponactive!=-1){
2145 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2146 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2147 OPENAL_SetVolume(channels[knifedrawsound], 128);
2148 OPENAL_SetPaused(channels[knifedrawsound], false);
2153 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2154 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2155 Normalise(&rotatetarget);
2156 targetrotation=-asin(0-rotatetarget.x);
2157 targetrotation*=360/6.28;
2158 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2160 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2161 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2166 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2168 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;
2170 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2171 targetanimation=rabbittackleanim;
2182 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2183 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2184 OPENAL_SetVolume(channels[jumpsound], 128);
2185 OPENAL_SetPaused(channels[jumpsound], false);
2194 Normalise(&targetloc);
2196 for(i=0;i<numplayers;i++){
2198 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2199 closestdist=findDistancefast(&targetloc,&player[i].coords);
2204 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2206 victim=&player[closestid];
2207 coords=victim->coords;
2208 currentanimation=rabbittacklinganim;
2209 targetanimation=rabbittacklinganim;
2213 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2214 rotatetarget=coords-victim->coords;
2215 Normalise(&rotatetarget);
2216 targetrotation=-asin(0-rotatetarget.x);
2217 targetrotation*=360/6.28;
2218 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2220 if(targetanimation!=rabbitrunninganim){
2230 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2231 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2232 OPENAL_SetVolume(channels[jumpsound], 128);
2233 OPENAL_SetPaused(channels[jumpsound], false);
2239 float damagemult=1*power;
2240 if(creature==wolftype)damagemult=2.5*power;
2241 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2242 //if(onfire)damagemult=3;
2243 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2244 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2245 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2247 if(id==0)camerashake+=.4;
2248 if(Random()%2||creature==wolftype){
2251 if(creature==wolftype)DoBloodBig(0,250);
2255 gLoc[0]=victim->coords.x;
2256 gLoc[1]=victim->coords.y;
2257 gLoc[2]=victim->coords.z;
2261 if(tutoriallevel!=1){
2262 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2263 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2264 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2265 OPENAL_SetPaused(channels[heavyimpactsound], false);
2267 if(creature==wolftype){
2268 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2269 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2270 OPENAL_SetVolume(channels[clawslicesound], 128);
2271 OPENAL_SetPaused(channels[clawslicesound], false);
2273 victim->DoBloodBig(2/victim->armorhead,175);
2277 relative=victim->coords-coords;
2279 Normalise(&relative);
2280 relative=DoRotation(relative,0,-90,0);
2281 for(i=0;i<victim->skeleton.num_joints;i++){
2282 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2284 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2287 victim->DoDamage(damagemult*100/victim->protectionhead);
2293 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2294 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2296 if(id==0)camerashake+=.4;
2297 if(Random()%2||creature==wolftype){
2299 if(creature==wolftype)DoBloodBig(0,235);
2303 gLoc[0]=victim->coords.x;
2304 gLoc[1]=victim->coords.y;
2305 gLoc[2]=victim->coords.z;
2309 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2310 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2311 OPENAL_SetVolume(channels[whooshhitsound], 512);
2312 OPENAL_SetPaused(channels[whooshhitsound], false);
2313 if(creature==wolftype){
2314 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2315 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2316 OPENAL_SetVolume(channels[clawslicesound], 128);
2317 OPENAL_SetPaused(channels[clawslicesound], false);
2319 victim->DoBloodBig(2,175);
2323 relative=victim->coords-coords;
2325 Normalise(&relative);
2327 Normalise(&relative);
2328 relative=DoRotation(relative,0,90,0);
2329 for(i=0;i<victim->skeleton.num_joints;i++){
2330 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2332 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2335 victim->DoDamage(damagemult*50/victim->protectionhead);
2339 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2340 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2342 if(id==0)camerashake+=.4;
2347 gLoc[0]=victim->coords.x;
2348 gLoc[1]=victim->coords.y;
2349 gLoc[2]=victim->coords.z;
2353 if(tutoriallevel!=1){
2354 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2355 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2356 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2357 OPENAL_SetPaused(channels[heavyimpactsound], false);
2359 if(creature==wolftype){
2360 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2361 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2362 OPENAL_SetVolume(channels[clawslicesound], 128);
2363 OPENAL_SetPaused(channels[clawslicesound], false);
2365 victim->DoBloodBig(2/victim->armorhead,175);
2371 Normalise(&relative);
2372 relative=DoRotation(relative,0,-90,0);
2373 for(i=0;i<victim->skeleton.num_joints;i++){
2374 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2376 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2379 victim->DoDamage(damagemult*150/victim->protectionhead);
2381 if(victim->damage>victim->damagetolerance)
2382 award_bonus(id, style);
2388 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2389 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2391 if(id==0)camerashake+=.4;
2396 gLoc[0]=victim->coords.x;
2397 gLoc[1]=victim->coords.y;
2398 gLoc[2]=victim->coords.z;
2402 if(tutoriallevel!=1){
2403 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2404 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2405 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2406 OPENAL_SetPaused(channels[heavyimpactsound], false);
2408 if(creature==wolftype){
2409 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2410 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2411 OPENAL_SetVolume(channels[clawslicesound], 128);
2412 OPENAL_SetPaused(channels[clawslicesound], false);
2414 victim->DoBloodBig(2/victim->armorhead,175);
2420 Normalise(&relative);
2421 relative=DoRotation(relative,0,90,0);
2422 for(i=0;i<victim->skeleton.num_joints;i++){
2423 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2425 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2428 victim->DoDamage(damagemult*150/victim->protectionhead);
2430 if(victim->damage>victim->damagetolerance)
2431 award_bonus(id, style);
2437 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2438 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2440 if(id==0)camerashake+=.4;
2447 gLoc[0]=victim->coords.x;
2448 gLoc[1]=victim->coords.y;
2449 gLoc[2]=victim->coords.z;
2453 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2454 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2455 OPENAL_SetVolume(channels[whooshhitsound], 512);
2456 OPENAL_SetPaused(channels[whooshhitsound], false);
2459 relative=victim->coords-coords;
2461 Normalise(&relative);
2462 for(i=0;i<victim->skeleton.num_joints;i++){
2463 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2465 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2468 victim->DoDamage(damagemult*50/victim->protectionhead);
2472 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2473 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2475 if(id==0)camerashake+=.2;
2478 gLoc[0]=victim->coords.x;
2479 gLoc[1]=victim->coords.y;
2480 gLoc[2]=victim->coords.z;
2484 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2485 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2486 OPENAL_SetVolume(channels[landsound2], 128);
2487 OPENAL_SetPaused(channels[landsound2], false);
2489 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2490 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2491 OPENAL_SetVolume(channels[movewhooshsound], 128);
2492 OPENAL_SetPaused(channels[movewhooshsound], false);
2494 victim->skeleton.longdead=0;
2495 victim->skeleton.free=1;
2496 victim->skeleton.broken=0;
2497 victim->skeleton.spinny=1;
2499 for(i=0;i<victim->skeleton.num_joints;i++){
2500 victim->skeleton.joints[i].velchange=0;
2501 victim->skeleton.joints[i].delay=0;
2502 victim->skeleton.joints[i].locked=0;
2503 //victim->skeleton.joints[i].velocity=0;
2509 Normalise(&relative);
2510 for(i=0;i<victim->skeleton.num_joints;i++){
2511 victim->skeleton.joints[i].velocity.y=relative.y*10;
2512 victim->skeleton.joints[i].position.y+=relative.y*.3;
2513 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2514 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2516 victim->Puff(abdomen);
2517 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2521 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2522 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2524 if(id==0)camerashake+=.4;
2533 if(tutoriallevel!=1){
2534 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2535 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2536 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2537 OPENAL_SetPaused(channels[heavyimpactsound], false);
2540 relative=victim->coords-coords;
2542 Normalise(&relative);
2543 for(i=0;i<victim->skeleton.num_joints;i++){
2544 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2546 victim->Puff(abdomen);
2547 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2551 victim->DoDamage(damagemult*500/victim->protectionhigh);
2552 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2556 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2557 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2559 if(id==0)camerashake+=.4;
2568 if(tutoriallevel!=1){
2569 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2570 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2571 OPENAL_SetVolume(channels[thudsound], 400);
2572 OPENAL_SetPaused(channels[thudsound], false);
2575 victim->skeleton.longdead=0;
2576 victim->skeleton.free=1;
2577 victim->skeleton.broken=0;
2578 victim->skeleton.spinny=1;
2580 for(i=0;i<victim->skeleton.num_joints;i++){
2581 victim->skeleton.joints[i].velchange=0;
2582 //victim->skeleton.joints[i].delay=0;
2583 victim->skeleton.joints[i].locked=0;
2586 relative=victim->coords-coords;
2587 Normalise(&relative);
2589 Normalise(&relative);
2590 for(i=0;i<victim->skeleton.num_joints;i++){
2591 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2596 victim->Puff(abdomen);
2597 victim->DoDamage(damagemult*20/victim->protectionhigh);
2598 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2600 if(!victim->dead)staggerdelay=1.2;
2606 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2607 //if(id==0)camerashake+=.4;
2618 if(!victim->skeleton.free)hasvictim=0;
2621 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2622 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2623 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2624 OPENAL_SetVolume(channels[knifesheathesound], 128);
2625 OPENAL_SetPaused(channels[knifesheathesound], false);
2628 if(victim&&hasvictim){
2629 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2631 XYZ where,startpoint,endpoint,movepoint,colpoint;
2632 float rotationpoint;
2634 if(weapons.type[weaponids[weaponactive]]==knife){
2635 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2636 where-=victim->coords;
2637 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2644 if(weapons.type[weaponids[weaponactive]]==sword){
2645 where=weapons.position[weaponids[weaponactive]];
2646 where-=victim->coords;
2647 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2649 where=weapons.tippoint[weaponids[weaponactive]];
2650 where-=victim->coords;
2651 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2654 if(weapons.type[weaponids[weaponactive]]==staff){
2655 where=weapons.position[weaponids[weaponactive]];
2656 where-=victim->coords;
2657 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2659 where=weapons.tippoint[weaponids[weaponactive]];
2660 where-=victim->coords;
2661 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2666 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2669 if(victim->dead!=2){
2670 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2672 award_bonus(id, FinishedBonus);
2674 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2676 victim->skeleton.longdead=0;
2677 victim->skeleton.free=1;
2678 victim->skeleton.broken=0;
2680 for(i=0;i<victim->skeleton.num_joints;i++){
2681 victim->skeleton.joints[i].velchange=0;
2682 victim->skeleton.joints[i].locked=0;
2683 //victim->skeleton.joints[i].velocity=0;
2685 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2686 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2687 OPENAL_SetVolume(channels[fleshstabsound], 128);
2688 OPENAL_SetPaused(channels[fleshstabsound], false);
2691 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2692 weapons.blooddrip[weaponids[weaponactive]]+=5;
2693 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2697 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2698 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2699 OPENAL_SetVolume(channels[knifesheathesound], 128);
2700 OPENAL_SetPaused(channels[knifesheathesound], false);
2706 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2707 //if(id==0)camerashake+=.4;
2717 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2718 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2719 OPENAL_SetVolume(channels[knifedrawsound], 128);
2720 OPENAL_SetPaused(channels[knifedrawsound], false);
2723 if(victim&&hasvictim){
2724 XYZ footvel,footpoint;
2726 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2727 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2728 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2729 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2732 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2734 if(weapons.type[weaponids[weaponactive]]==sword){
2735 XYZ where,startpoint,endpoint,movepoint;
2736 float rotationpoint;
2739 where=weapons.position[weaponids[weaponactive]];
2740 where-=victim->coords;
2741 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2743 where=weapons.tippoint[weaponids[weaponactive]];
2744 where-=victim->coords;
2745 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2750 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2751 footpoint+=victim->coords;
2754 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2757 if(weapons.type[weaponids[weaponactive]]==staff){
2758 XYZ where,startpoint,endpoint,movepoint;
2759 float rotationpoint;
2762 where=weapons.position[weaponids[weaponactive]];
2763 where-=victim->coords;
2764 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2766 where=weapons.tippoint[weaponids[weaponactive]];
2767 where-=victim->coords;
2768 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2773 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2774 footpoint+=victim->coords;
2777 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2780 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2782 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2783 victim->skeleton.longdead=0;
2784 victim->skeleton.free=1;
2785 victim->skeleton.broken=0;
2787 for(i=0;i<victim->skeleton.num_joints;i++){
2788 victim->skeleton.joints[i].velchange=0;
2789 victim->skeleton.joints[i].locked=0;
2790 //victim->skeleton.joints[i].velocity=0;
2796 Normalise(&relative);
2797 //victim->Puff(abdomen);
2798 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2800 if(victim->bloodloss<victim->damagetolerance){
2801 victim->bloodloss+=1000;
2805 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2809 if(!hasvictim&&onterrain){
2810 weapons.bloody[weaponids[weaponactive]]=0;
2811 weapons.blooddrip[weaponids[weaponactive]]=0;
2815 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2816 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2818 if(id==0)camerashake+=.4;
2825 gLoc[0]=victim->coords.x;
2826 gLoc[1]=victim->coords.y;
2827 gLoc[2]=victim->coords.z;
2832 if(tutoriallevel!=1){
2833 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2834 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2835 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2836 OPENAL_SetPaused(channels[heavyimpactsound], false);
2840 if(tutoriallevel!=1){
2841 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2842 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2843 OPENAL_SetVolume(channels[landsound2], 256);
2844 OPENAL_SetPaused(channels[landsound2], false);
2848 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
2851 relative=victim->coords-coords;
2853 Normalise(&relative);
2854 for(i=0;i<victim->skeleton.num_joints;i++){
2855 victim->skeleton.joints[i].velocity=relative*30;
2857 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2859 victim->targetframe=0;
2860 victim->targetanimation=staggerbackhardanim;
2861 victim->targetrotation=targetrotation+180;
2866 victim->Puff(abdomen);
2867 victim->DoDamage(damagemult*60/victim->protectionhigh);
2874 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2875 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2877 if(id==0)camerashake+=.4;
2880 gLoc[0]=victim->coords.x;
2881 gLoc[1]=victim->coords.y;
2882 gLoc[2]=victim->coords.z;
2886 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2887 if(tutoriallevel!=1){
2888 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2889 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2890 OPENAL_SetVolume(channels[thudsound], 512);
2891 OPENAL_SetPaused(channels[thudsound], false);
2894 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2895 if(tutoriallevel!=1){
2896 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2897 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2898 OPENAL_SetVolume(channels[whooshhitsound], 512);
2899 OPENAL_SetPaused(channels[whooshhitsound], false);
2903 if(tutoriallevel!=1){
2904 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2905 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2906 OPENAL_SetVolume(channels[heavyimpactsound], 256);
2907 OPENAL_SetPaused(channels[heavyimpactsound], false);
2911 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2914 relative=victim->coords-coords;
2916 Normalise(&relative);
2918 Normalise(&relative);
2919 for(i=0;i<victim->skeleton.num_joints;i++){
2920 victim->skeleton.joints[i].velocity=relative*5;
2922 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
2924 victim->targetframe=0;
2925 victim->targetanimation=staggerbackhardanim;
2926 victim->targetrotation=targetrotation+180;
2930 victim->Puff(abdomen);
2931 victim->DoDamage(damagemult*60/victim->protectionhigh);
2937 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
2938 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2939 if(victim->id==0)camerashake+=.4;
2942 gLoc[0]=victim->coords.x;
2943 gLoc[1]=victim->coords.y;
2944 gLoc[2]=victim->coords.z;
2949 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2950 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2951 OPENAL_SetVolume(channels[landsound2], 256);
2952 OPENAL_SetPaused(channels[landsound2], false);
2958 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
2959 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2960 if(victim->id==0)camerashake+=.4;
2963 gLoc[0]=victim->coords.x;
2964 gLoc[1]=victim->coords.y;
2965 gLoc[2]=victim->coords.z;
2970 if(weaponactive!=-1){
2971 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
2972 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2973 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2975 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
2976 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
2977 OPENAL_SetVolume(channels[swordstaffsound], 512);
2978 OPENAL_SetPaused(channels[swordstaffsound], false);
2981 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
2982 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
2983 OPENAL_SetVolume(channels[metalhitsound], 512);
2984 OPENAL_SetPaused(channels[metalhitsound], false);
2992 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
2993 if(weaponactive!=-1){
2996 weapons.owner[weaponids[0]]=-1;
2997 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);
2999 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3000 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3002 weapons.velocity[weaponids[0]]=aim*50;
3003 weapons.tipvelocity[weaponids[0]]=aim*50;
3004 weapons.missed[weaponids[0]]=0;
3005 weapons.hitsomething[weaponids[0]]=0;
3006 weapons.freetime[weaponids[0]]=0;
3007 weapons.firstfree[weaponids[0]]=1;
3008 weapons.physics[weaponids[0]]=0;
3011 weaponids[0]=weaponids[num_weapons];
3017 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3019 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3021 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3023 award_bonus(id, Slicebonus);
3024 if(tutoriallevel!=1){
3027 gLoc[0]=victim->coords.x;
3028 gLoc[1]=victim->coords.y;
3029 gLoc[2]=victim->coords.z;
3033 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3034 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3035 OPENAL_SetVolume(channels[knifeslicesound], 512);
3036 OPENAL_SetPaused(channels[knifeslicesound], false);
3038 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3039 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3040 if(victim->id != 0 || difficulty==2){
3041 victim->targetframe=0;
3042 victim->targetanimation=staggerbackhardanim;
3043 victim->targetrotation=targetrotation+180;
3047 victim->lowreversaldelay=0;
3048 victim->highreversaldelay=0;
3049 if(aitype!=playercontrolled)weaponmissdelay=.6;
3051 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3052 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3054 XYZ footvel,footpoint;
3057 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3060 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;
3062 if(tutoriallevel!=1){
3063 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3064 footvel=DoRotation(facing,0,90,0)*.8;
3066 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3067 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3068 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3069 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3071 if(tutoriallevel==1){
3072 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3074 victim->DoDamage(damagemult*0);
3077 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3078 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3079 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3080 award_bonus(id, Slashbonus);
3082 if(tutoriallevel!=1){
3083 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3084 else victim->DoBloodBig(2/victim->armorhigh,185);
3085 victim->deathbleeding=1;
3088 gLoc[0]=victim->coords.x;
3089 gLoc[1]=victim->coords.y;
3090 gLoc[2]=victim->coords.z;
3094 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3095 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3096 OPENAL_SetVolume(channels[swordslicesound], 512);
3097 OPENAL_SetPaused(channels[swordslicesound], false);
3099 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3100 if(tutoriallevel!=1){
3101 victim->targetframe=0;
3102 victim->targetanimation=staggerbackhardanim;
3103 victim->targetrotation=targetrotation+180;
3107 if(tutoriallevel!=1){
3108 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3109 weapons.blooddrip[weaponids[weaponactive]]+=3;
3111 float bloodlossamount;
3112 bloodlossamount=200+abs((float)(Random()%40))-20;
3113 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3114 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3115 victim->DoDamage(damagemult*0);
3117 XYZ footvel,footpoint;
3120 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3123 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;
3125 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3126 footvel=DoRotation(facing,0,90,0)*.8;
3128 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3129 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3130 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3131 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3139 gLoc[0]=victim->coords.x;
3140 gLoc[1]=victim->coords.y;
3141 gLoc[2]=victim->coords.z;
3145 if(victim->weaponactive!=-1){
3146 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3147 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3148 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3150 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3151 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3152 OPENAL_SetVolume(channels[swordstaffsound], 512);
3153 OPENAL_SetPaused(channels[swordstaffsound], false);
3156 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3157 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3158 OPENAL_SetVolume(channels[metalhitsound], 512);
3159 OPENAL_SetPaused(channels[metalhitsound], false);
3165 victim->Puff(righthand);
3167 victim->targetframe=0;
3168 victim->targetanimation=staggerbackhighanim;
3169 victim->targetrotation=targetrotation+180;
3171 weapons.owner[victim->weaponids[0]]=-1;
3172 aim=DoRotation(facing,0,90,0)*21;
3174 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3175 weapons.tipvelocity[victim->weaponids[0]]=aim;
3176 weapons.missed[victim->weaponids[0]]=1;
3177 weapons.hitsomething[weaponids[0]]=0;
3178 weapons.freetime[victim->weaponids[0]]=0;
3179 weapons.firstfree[victim->weaponids[0]]=1;
3180 weapons.physics[victim->weaponids[0]]=1;
3181 victim->num_weapons--;
3182 if(victim->num_weapons){
3183 victim->weaponids[0]=victim->weaponids[num_weapons];
3184 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3186 victim->weaponactive=-1;
3187 for(i=0;i<numplayers;i++){
3188 player[i].wentforweapon=0;
3191 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3192 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3193 OPENAL_SetVolume(channels[metalhitsound], 512);
3194 OPENAL_SetPaused(channels[metalhitsound], false);*/
3200 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3201 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3202 if(tutoriallevel!=1){
3203 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3205 if(id==0)camerashake+=.4;
3206 if(Random()%2||creature==wolftype){
3211 gLoc[0]=victim->coords.x;
3212 gLoc[1]=victim->coords.y;
3213 gLoc[2]=victim->coords.z;
3217 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3218 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3219 OPENAL_SetVolume(channels[staffheadsound], 256);
3220 OPENAL_SetPaused(channels[staffheadsound], false);
3224 relative=victim->coords-coords;
3226 Normalise(&relative);
3227 relative=DoRotation(relative,0,90,0);
3229 Normalise(&relative);
3230 for(i=0;i<victim->skeleton.num_joints;i++){
3231 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3233 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3234 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3237 if(tutoriallevel!=1){
3238 victim->DoDamage(damagemult*120/victim->protectionhigh);
3240 award_bonus(id, solidhit, 30);
3245 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3246 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3247 if(tutoriallevel!=1){
3248 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3250 if(id==0)camerashake+=.4;
3251 if(Random()%2||creature==wolftype){
3256 gLoc[0]=victim->coords.x;
3257 gLoc[1]=victim->coords.y;
3258 gLoc[2]=victim->coords.z;
3262 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3263 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3264 OPENAL_SetVolume(channels[staffheadsound], 256);
3265 OPENAL_SetPaused(channels[staffheadsound], false);
3269 relative=victim->coords-coords;
3271 Normalise(&relative);
3272 relative=DoRotation(relative,0,-90,0);
3273 for(i=0;i<victim->skeleton.num_joints;i++){
3274 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3276 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3277 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3280 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3282 award_bonus(id, solidhit, 60);
3287 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3288 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3290 if(tutoriallevel!=1){
3291 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3292 if(id==0)camerashake+=.4;
3293 if(Random()%2||creature==wolftype){
3298 gLoc[0]=victim->coords.x;
3299 gLoc[1]=victim->coords.y;
3300 gLoc[2]=victim->coords.z;
3304 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3305 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3306 OPENAL_SetVolume(channels[staffbodysound], 256);
3307 OPENAL_SetPaused(channels[staffbodysound], false);
3309 victim->skeleton.longdead=0;
3310 victim->skeleton.free=1;
3311 victim->skeleton.broken=0;
3313 for(i=0;i<victim->skeleton.num_joints;i++){
3314 victim->skeleton.joints[i].velchange=0;
3315 victim->skeleton.joints[i].locked=0;
3316 //victim->skeleton.joints[i].velocity=0;
3322 /*relative=victim->coords-coords;
3324 Normalise(&relative);
3325 relative=DoRotation(relative,0,90,0);*/
3327 Normalise(&relative);
3329 for(i=0;i<victim->skeleton.num_joints;i++){
3330 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3333 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3336 for(i=0;i<victim->skeleton.num_joints;i++){
3337 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3340 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3342 victim->Puff(abdomen);
3343 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3346 award_bonus(id, solidhit, 40);
3352 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3353 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3355 if(id==0)camerashake+=.4;
3358 gLoc[0]=victim->coords.x;
3359 gLoc[1]=victim->coords.y;
3360 gLoc[2]=victim->coords.z;
3365 relative=victim->coords-coords;
3367 Normalise(&relative);
3371 if(animation[victim->targetanimation].height==lowheight){
3377 for(i=0;i<victim->skeleton.num_joints;i++){
3378 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3380 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3381 if(tutoriallevel!=1){
3382 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3383 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3384 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3385 OPENAL_SetPaused(channels[heavyimpactsound], false);
3388 victim->DoDamage(damagemult*100/victim->protectionhead);
3389 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3390 if(creature==wolftype){
3391 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3392 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3393 OPENAL_SetVolume(channels[clawslicesound], 128);
3394 OPENAL_SetPaused(channels[clawslicesound], false);
3396 victim->DoBloodBig(2/victim->armorhead,175);
3400 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3401 for(i=0;i<victim->skeleton.num_joints;i++){
3402 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3404 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3405 victim->targetframe=0;
3406 victim->targetanimation=staggerbackhighanim;
3407 victim->targetrotation=targetrotation+180;
3409 if(tutoriallevel!=1){
3410 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3411 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3412 OPENAL_SetVolume(channels[landsound2], 128);
3413 OPENAL_SetPaused(channels[landsound2], false);
3415 victim->Puff(abdomen);
3416 victim->DoDamage(damagemult*30/victim->protectionhigh);
3417 if(creature==wolftype){
3418 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3419 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3420 OPENAL_SetVolume(channels[clawslicesound], 128);
3421 OPENAL_SetPaused(channels[clawslicesound], false);
3423 victim->DoBloodBig(2/victim->armorhigh,170);
3430 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3431 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3433 if(id==0)camerashake+=.2;
3436 gLoc[0]=victim->coords.x;
3437 gLoc[1]=victim->coords.y;
3438 gLoc[2]=victim->coords.z;
3442 if(tutoriallevel!=1){
3443 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3444 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3445 OPENAL_SetVolume(channels[landsound2], 128);
3446 OPENAL_SetPaused(channels[landsound2], false);
3449 relative=victim->coords-coords;
3451 Normalise(&relative);
3453 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3456 for(i=0;i<victim->skeleton.num_joints;i++){
3457 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3459 relative=DoRotation(relative,0,-90,0);
3461 for(i=0;i<victim->skeleton.num_joints;i++){
3462 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)
3463 victim->skeleton.joints[i].velocity=relative*80;
3465 victim->Puff(rightankle);
3466 victim->Puff(leftankle);
3467 victim->DoDamage(damagemult*40/victim->protectionlow);
3470 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3471 for(i=0;i<victim->skeleton.num_joints;i++){
3472 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3474 relative=DoRotation(relative,0,-90,0);
3475 for(i=0;i<victim->skeleton.num_joints;i++){
3476 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)
3477 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3479 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3480 victim->targetframe=0;
3481 victim->targetanimation=staggerbackhighanim;
3482 victim->targetrotation=targetrotation+180;
3484 if(tutoriallevel!=1){
3485 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3486 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3487 OPENAL_SetVolume(channels[landsound2], 128);
3488 OPENAL_SetPaused(channels[landsound2], false);
3490 victim->Puff(abdomen);
3491 victim->DoDamage(damagemult*30/victim->protectionlow);
3499 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3500 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3502 if(id==0)camerashake+=.4;
3509 gLoc[0]=victim->coords.x;
3510 gLoc[1]=victim->coords.y;
3511 gLoc[2]=victim->coords.z;
3515 if(tutoriallevel!=1){
3516 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3517 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3518 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3519 OPENAL_SetPaused(channels[heavyimpactsound], false);
3521 if(creature==wolftype){
3522 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3523 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3524 OPENAL_SetVolume(channels[clawslicesound], 128);
3525 OPENAL_SetPaused(channels[clawslicesound], false);
3527 victim->DoBloodBig(2/victim->armorhigh,170);
3531 relative=victim->coords-oldcoords;
3533 Normalise(&relative);
3534 //relative=DoRotation(relative,0,-90,0);
3535 for(i=0;i<victim->skeleton.num_joints;i++){
3536 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3538 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3540 victim->Puff(abdomen);
3541 victim->DoDamage(damagemult*150/victim->protectionhigh);
3543 award_bonus(id, Reversal);
3546 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3547 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3548 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3549 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3552 weaponids[num_weapons]=weaponids[victim->weaponactive];
3555 weaponids[0]=victim->weaponids[victim->weaponactive];
3556 victim->num_weapons--;
3557 if(victim->num_weapons>0){
3558 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3559 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3561 victim->weaponactive=-1;
3566 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3568 if(id==0)camerashake+=.4;
3575 gLoc[0]=victim->coords.x;
3576 gLoc[1]=victim->coords.y;
3577 gLoc[2]=victim->coords.z;
3581 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3582 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3583 OPENAL_SetVolume(channels[whooshhitsound], 128);
3584 OPENAL_SetPaused(channels[whooshhitsound], false);
3587 relative=victim->coords-oldcoords;
3589 Normalise(&relative);
3590 //relative=DoRotation(relative,0,-90,0);
3591 for(i=0;i<victim->skeleton.num_joints;i++){
3592 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3594 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3597 victim->DoDamage(damagemult*70/victim->protectionhigh);
3600 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3602 if(id==0)camerashake+=.4;
3609 gLoc[0]=victim->coords.x;
3610 gLoc[1]=victim->coords.y;
3611 gLoc[2]=victim->coords.z;
3616 award_bonus(id, staffreversebonus);
3618 if(tutoriallevel!=1){
3619 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3620 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3621 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3622 OPENAL_SetPaused(channels[heavyimpactsound], false);
3625 award_bonus(id, staffreversebonus); // Huh, again?
3628 relative=victim->coords-oldcoords;
3630 Normalise(&relative);
3631 //relative=DoRotation(relative,0,-90,0);
3632 for(i=0;i<victim->skeleton.num_joints;i++){
3633 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3635 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3638 victim->DoDamage(damagemult*70/victim->protectionhigh);
3641 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3647 Normalise(&relative);
3650 for(i=0;i<victim->skeleton.num_joints;i++){
3651 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3653 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3654 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3655 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3656 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3657 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3658 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3659 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3660 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3662 victim->Puff(abdomen);
3663 victim->DoDamage(damagemult*90/victim->protectionhigh);
3665 award_bonus(id, Reversal);
3669 if(weaponactive!=-1||creature==wolftype)doslice=1;
3670 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3674 gLoc[0]=victim->coords.x;
3675 gLoc[1]=victim->coords.y;
3676 gLoc[2]=victim->coords.z;
3680 if(weaponactive!=-1){
3681 victim->DoBloodBig(2/victim->armorhigh,225);
3682 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3683 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3684 OPENAL_SetVolume(channels[knifeslicesound], 512);
3685 OPENAL_SetPaused(channels[knifeslicesound], false);
3686 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3687 weapons.blooddrip[weaponids[weaponactive]]+=3;
3689 if(weaponactive==-1&&creature==wolftype){
3690 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3691 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3692 OPENAL_SetVolume(channels[clawslicesound], 128);
3693 OPENAL_SetPaused(channels[clawslicesound], false);
3695 victim->DoBloodBig(2/victim->armorhigh,175);
3702 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3708 Normalise(&relative);
3711 for(i=0;i<victim->skeleton.num_joints;i++){
3712 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3714 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
3715 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
3716 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
3717 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
3718 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
3719 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
3720 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
3721 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
3723 award_bonus(id, swordreversebonus);
3726 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3728 if(id==0)camerashake+=.4;
3735 gLoc[0]=victim->coords.x;
3736 gLoc[1]=victim->coords.y;
3737 gLoc[2]=victim->coords.z;
3741 if(tutoriallevel!=1){
3742 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3743 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3744 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3745 OPENAL_SetPaused(channels[heavyimpactsound], false);
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*40;
3756 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3758 victim->Puff(abdomen);
3759 victim->DoDamage(damagemult*30/victim->protectionhigh);
3761 award_bonus(id, Reversal);
3764 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
3767 victim->skeleton.spinny=0;
3771 Normalise(&relative);
3772 if(victim->id==0)relative/=30;
3773 for(i=0;i<victim->skeleton.num_joints;i++){
3774 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3776 //victim->DoDamage(1000);
3777 victim->damage=victim->damagetolerance;
3778 victim->permanentdamage=victim->damagetolerance-1;
3781 if(weaponactive!=-1||creature==wolftype)doslice=1;
3782 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3786 gLoc[0]=victim->coords.x;
3787 gLoc[1]=victim->coords.y;
3788 gLoc[2]=victim->coords.z;
3792 if(weaponactive!=-1){
3793 victim->DoBloodBig(200,225);
3794 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3795 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3796 OPENAL_SetVolume(channels[knifeslicesound], 512);
3797 OPENAL_SetPaused(channels[knifeslicesound], false);
3798 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3799 weapons.blooddrip[weaponids[weaponactive]]+=5;
3802 if(creature==wolftype&&weaponactive==-1){
3803 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3804 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3805 OPENAL_SetVolume(channels[clawslicesound], 128);
3806 OPENAL_SetPaused(channels[clawslicesound], false);
3808 victim->DoBloodBig(2,175);
3811 award_bonus(id, spinecrusher);
3814 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3815 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3817 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3818 if(targetanimation==knifesneakattackanim){
3819 /*victim->DoBloodBig(200,195);
3824 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3825 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3827 XYZ footvel,footpoint;
3829 footpoint=weapons.tippoint[weaponids[0]];
3830 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3831 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3832 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3833 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3834 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3835 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3836 victim->DoBloodBig(200,195);
3837 award_bonus(id, tracheotomy);
3839 if(targetanimation==knifefollowanim){
3840 award_bonus(id, Stabbonus);
3841 XYZ footvel,footpoint;
3843 footpoint=weapons.tippoint[weaponids[0]];
3844 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3845 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3846 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3847 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3848 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3849 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3852 victim->bloodloss+=10000;
3856 gLoc[0]=victim->coords.x;
3857 gLoc[1]=victim->coords.y;
3858 gLoc[2]=victim->coords.z;
3862 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
3863 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
3864 OPENAL_SetVolume(channels[fleshstabsound], 512);
3865 OPENAL_SetPaused(channels[fleshstabsound], false);
3866 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3867 weapons.blooddrip[weaponids[weaponactive]]+=5;
3871 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
3874 for(i=0;i<victim->skeleton.num_joints;i++){
3875 victim->skeleton.joints[i].velocity=0;
3877 if(targetanimation==knifefollowanim){
3879 for(i=0;i<victim->skeleton.num_joints;i++){
3880 victim->skeleton.joints[i].velocity=0;
3883 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
3886 gLoc[0]=victim->coords.x;
3887 gLoc[1]=victim->coords.y;
3888 gLoc[2]=victim->coords.z;
3892 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
3893 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
3894 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
3895 OPENAL_SetPaused(channels[fleshstabremovesound], false);
3896 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3897 weapons.blooddrip[weaponids[weaponactive]]+=5;
3899 XYZ footvel,footpoint;
3901 footpoint=weapons.tippoint[weaponids[0]];
3902 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3903 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3904 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3905 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3906 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3907 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3911 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3912 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3913 award_bonus(id, backstab);
3917 XYZ footvel,footpoint;
3919 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
3920 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3921 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3922 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3923 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3924 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3925 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3926 victim->DoBloodBig(200,180);
3927 victim->DoBloodBig(200,215);
3928 victim->bloodloss+=10000;
3932 gLoc[0]=victim->coords.x;
3933 gLoc[1]=victim->coords.y;
3934 gLoc[2]=victim->coords.z;
3938 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
3939 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
3940 OPENAL_SetVolume(channels[fleshstabsound], 512);
3941 OPENAL_SetPaused(channels[fleshstabsound], false);
3942 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3943 weapons.blooddrip[weaponids[weaponactive]]+=5;
3947 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
3950 for(i=0;i<victim->skeleton.num_joints;i++){
3951 victim->skeleton.joints[i].velocity=0;
3953 if(weaponactive!=-1){
3956 gLoc[0]=victim->coords.x;
3957 gLoc[1]=victim->coords.y;
3958 gLoc[2]=victim->coords.z;
3962 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
3963 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
3964 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
3965 OPENAL_SetPaused(channels[fleshstabremovesound], false);
3966 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3967 weapons.blooddrip[weaponids[weaponactive]]+=5;
3969 XYZ footvel,footpoint;
3971 footpoint=weapons.tippoint[weaponids[0]];
3972 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3973 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3974 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3975 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3976 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3977 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3981 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
3983 if(id==0)camerashake+=.4;
3990 gLoc[0]=victim->coords.x;
3991 gLoc[1]=victim->coords.y;
3992 gLoc[2]=victim->coords.z;
3996 if(weaponactive==-1){
3997 if(tutoriallevel!=1){
3998 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3999 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4000 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4001 OPENAL_SetPaused(channels[heavyimpactsound], false);
4006 if(weaponactive!=-1||creature==wolftype)doslice=1;
4007 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4009 if(weaponactive!=-1){
4010 victim->DoBloodBig(2/victim->armorhead,225);
4011 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4012 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4013 OPENAL_SetVolume(channels[knifeslicesound], 512);
4014 OPENAL_SetPaused(channels[knifeslicesound], false);
4015 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4016 weapons.blooddrip[weaponids[weaponactive]]+=3;
4018 if(weaponactive==-1&&creature==wolftype){
4019 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4020 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4021 OPENAL_SetVolume(channels[clawslicesound], 128);
4022 OPENAL_SetPaused(channels[clawslicesound], false);
4024 victim->DoBloodBig(2/victim->armorhead,175);
4028 award_bonus(id, Reversal);
4033 //relative=victim->coords-oldcoords;
4036 Normalise(&relative);
4037 relative=DoRotation(relative,0,90,0);
4039 Normalise(&relative);
4040 for(i=0;i<victim->skeleton.num_joints;i++){
4041 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4043 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4044 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4045 victim->DoDamage(damagemult*100/victim->protectionhead);
4049 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4053 //relative=victim->coords-oldcoords;
4056 Normalise(&relative);
4057 relative=DoRotation(relative,0,90,0);
4059 Normalise(&relative);
4060 for(i=0;i<victim->skeleton.num_joints;i++){
4061 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4063 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4066 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4067 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4068 award_bonus(id, reverseko);
4074 if(targetframe>animation[currentanimation].numframes-1){
4077 targetanimation=getIdle();
4081 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4082 targetanimation=rollanim;
4093 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4094 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4095 OPENAL_SetVolume(channels[movewhooshsound], 128);
4096 OPENAL_SetPaused(channels[movewhooshsound], false);
4098 if(currentanimation==staggerbackhighanim){
4099 targetanimation=getIdle();
4101 if(currentanimation==staggerbackhardanim){
4102 targetanimation=getIdle();
4104 if(currentanimation==removeknifeanim){
4105 targetanimation=getIdle();
4107 if(currentanimation==crouchremoveknifeanim){
4108 targetanimation=getCrouch();
4110 if(currentanimation==backhandspringanim){
4111 targetanimation=getIdle();
4113 if(currentanimation==dodgebackanim){
4114 targetanimation=getIdle();
4116 if(currentanimation==drawleftanim){
4117 targetanimation=getIdle();
4119 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4120 targetanimation=getIdle();
4121 if(currentanimation==crouchdrawrightanim){
4122 targetanimation=getCrouch();
4124 if(weaponactive==-1)weaponactive=0;
4125 else if(weaponactive==0){
4129 buffer=weaponids[0];
4130 weaponids[0]=weaponids[1];
4131 weaponids[1]=buffer;
4135 if(weaponactive==-1){
4145 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4146 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4147 OPENAL_SetVolume(channels[knifesheathesound], 128);
4148 OPENAL_SetPaused(channels[knifesheathesound], false);
4150 if(weaponactive!=-1){
4160 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4161 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4162 OPENAL_SetVolume(channels[knifedrawsound], 128);
4163 OPENAL_SetPaused(channels[knifedrawsound], false);
4166 if(currentanimation==rollanim){
4167 targetanimation=getCrouch();
4172 if(targetanimation==walljumprightkickanim){
4175 if(targetanimation==walljumpleftkickanim){
4178 targetanimation=jumpdownanim;
4180 if(currentanimation==climbanim){
4181 targetanimation=getCrouch();
4184 if(!isnormal(coords.x))
4195 if(targetanimation==rabbitkickreversalanim){
4196 targetanimation=getCrouch();
4199 if(targetanimation==jumpreversalanim){
4200 targetanimation=getCrouch();
4203 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4204 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4206 float closestdist=-1;
4209 for(i=0;i<numplayers;i++){
4210 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4211 distance=findDistancefast(&player[i].coords,&coords);
4212 if(closestdist==-1||distance<closestdist){
4213 closestdist=distance;
4218 if(closestdist>0&&closest>=0&&closestdist<16){
4219 victim=&player[closest];
4220 targetanimation=walljumprightkickanim;
4222 XYZ rotatetarget=victim->coords-coords;
4223 Normalise(&rotatetarget);
4224 rotation=-asin(0-rotatetarget.x);
4226 if(rotatetarget.z<0)rotation=180-rotation;
4227 targettilt2=-asin(rotatetarget.y)*360/6.28;
4228 velocity=(victim->coords-coords)*4;
4233 if(targetanimation==walljumpbackanim){
4234 targetanimation=backflipanim;
4238 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4240 if(targetanimation==walljumprightanim){
4241 targetanimation=rightflipanim;
4245 velocity=DoRotation(facing,0,30,0)*-8;
4248 if(targetanimation==walljumpfrontanim){
4249 targetanimation=frontflipanim;
4251 //targetrotation-=180;
4256 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4258 if(targetanimation==walljumpleftanim){
4261 float closestdist=-1;
4264 for(i=0;i<numplayers;i++){
4265 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4266 distance=findDistancefast(&player[i].coords,&coords);
4267 if(closestdist==-1||distance<closestdist){
4268 closestdist=distance;
4273 if(closestdist>0&&closest>=0&&closestdist<16){
4274 victim=&player[closest];
4275 targetanimation=walljumpleftkickanim;
4277 XYZ rotatetarget=victim->coords-coords;
4278 Normalise(&rotatetarget);
4279 rotation=-asin(0-rotatetarget.x);
4281 if(rotatetarget.z<0)rotation=180-rotation;
4282 targettilt2=-asin(rotatetarget.y)*360/6.28;
4283 velocity=(victim->coords-coords)*4;
4288 if(targetanimation!=walljumpleftkickanim){
4289 targetanimation=leftflipanim;
4293 velocity=DoRotation(facing,0,-30,0)*-8;
4296 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4298 if(targetanimation==sneakattackanim){
4299 float ycoords=oldcoords.y;
4300 currentanimation=getCrouch();
4301 targetanimation=getCrouch();
4304 targetrotation+=180;
4309 targetheadrotation+=180;
4311 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4315 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4316 float ycoords=oldcoords.y;
4317 targetanimation=getIdle();
4319 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4323 if(currentanimation==knifefollowanim){
4324 targetanimation=getIdle();
4327 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4328 float ycoords=oldcoords.y;
4329 targetanimation=getStop();
4330 targetrotation+=180;
4335 targetheadrotation+=180;
4336 if(!isnormal(coords.x))
4338 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4339 oldcoords=coords+facing*.5;
4340 else if(currentanimation==sweepreversalanim)
4341 oldcoords=coords+facing*1.1;
4342 else if(currentanimation==upunchreversalanim){
4343 oldcoords=coords+facing*1.5;
4344 targetrotation+=180;
4346 targetheadrotation+=180;
4350 else if(currentanimation==knifeslashreversalanim){
4351 oldcoords=coords+facing*.5;
4354 targetheadrotation+=90;
4358 else if(currentanimation==staffspinhitreversalanim){
4359 targetrotation+=180;
4361 targetheadrotation+=180;
4365 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4366 else oldcoords.y=ycoords;
4367 currentoffset=coords-oldcoords;
4373 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4378 if(animation[targetanimation].attack==reversed){
4380 if(targetanimation==sweepreversedanim)targetrotation+=90;
4381 targetanimation=backhandspringanim;
4391 PlaySoundEx( landsound, samp[landsound], NULL, true);
4392 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4393 OPENAL_SetVolume(channels[landsound], 128);
4394 OPENAL_SetPaused(channels[landsound], false);
4396 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4397 targetanimation=rollanim;
4400 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4401 coords.y=oldcoords.y;
4403 if(currentanimation==knifeslashreversedanim){
4404 targetanimation=rollanim;
4409 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4410 coords.y=oldcoords.y;
4414 targetanimation=jumpdownanim;
4416 if(wasLanding())targetanimation=getIdle();
4417 if(wasLandhard())targetanimation=getIdle();
4418 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4419 targetanimation=getIdle();
4421 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4422 coords.y=oldcoords.y;
4423 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4424 targetoffset.y=coords.y;
4425 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4426 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4427 currentoffset.y-=(coords.y-targetoffset.y);
4428 coords.y=targetoffset.y;
4430 normalsupdatedelay=0;
4432 if(currentanimation==upunchanim){
4433 targetanimation=getStop();
4434 normalsupdatedelay=0;
4437 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4438 targetrotation=rotation;
4441 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4442 if(!hasstaff)DoDamage(35);
4445 rabbitkickragdoll=1;
4447 if(currentanimation==rabbitkickreversedanim){
4454 SolidHitBonus(!id); // FIXME: tricky id
4458 targetanimation=rollanim;
4460 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4464 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4470 if(currentanimation==jumpreversedanim){
4477 SolidHitBonus(!id); // FIXME: tricky id
4481 targetanimation=rollanim;
4483 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4488 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){
4489 targetanimation=getupfromfrontanim;
4492 else if(animation[currentanimation].attack==normalattack){
4493 targetanimation=getIdle();
4496 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4497 targetanimation=blockhighleftstrikeanim;
4499 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4500 targetanimation=getIdle();
4503 if(currentanimation==spinkickanim&&victim->skeleton.free){
4504 if(creature==rabbittype)targetanimation=fightidleanim;
4509 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4511 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4512 targetanimation=jumpdownanim;
4517 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4518 if(!isRun()||!wasRun()){
4519 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4520 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4521 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4522 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4524 if(isRun()&&wasRun()){
4527 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4528 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4531 else if(transspeed)target+=multiplier*transspeed*speed*2;
4533 if(!isRun()||!wasRun()){
4534 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4535 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4536 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4537 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4541 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4543 if(target>1){currentframe=targetframe; target=1;}
4545 rot=targetrot*target;
4546 rotation+=rot-oldrot;
4552 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4554 for(i=0;i<skeleton.num_joints;i++){
4555 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4558 skeleton.FindForwards();
4560 for(i=0;i<skeleton.num_muscles;i++){
4561 if(skeleton.muscles[i].visible)
4563 skeleton.FindRotationMuscle(i,targetanimation);
4566 for(i=0;i<skeleton.num_muscles;i++){
4567 if(skeleton.muscles[i].visible)
4569 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4570 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4571 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4576 for(i=0;i<skeleton.num_joints;i++){
4577 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4580 skeleton.FindForwards();
4582 for(i=0;i<skeleton.num_muscles;i++){
4583 if(skeleton.muscles[i].visible)
4585 skeleton.FindRotationMuscle(i,targetanimation);
4588 for(i=0;i<skeleton.num_muscles;i++){
4589 if(skeleton.muscles[i].visible)
4591 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4592 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4593 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4594 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4595 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4596 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4597 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4598 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4599 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4603 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4605 oldcurrentanimation=currentanimation;
4606 oldtargetanimation=targetanimation;
4607 oldtargetframe=targetframe;
4608 oldcurrentframe=currentframe;
4610 for(i=0;i<skeleton.num_joints;i++){
4611 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4612 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4614 offset=currentoffset*(1-target)+targetoffset*target;
4615 for(i=0;i<skeleton.num_muscles;i++){
4616 if(skeleton.muscles[i].visible)
4618 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4619 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4620 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4625 if(isLanding()&&landhard){
4626 if(id==0)camerashake+=.4;
4627 targetanimation=getLandhard();
4634 //skeleton.DoConstraints();
4637 void Person::DoStuff(){
4638 static XYZ terrainnormal;
4639 static XYZ flatfacing;
4640 static XYZ flatvelocity;
4641 static float flatvelspeed;
4645 static int bloodsize;
4646 static int startx,starty,endx,endy;
4647 static int texdetailint;
4648 static GLubyte color;
4649 static XYZ bloodvel;
4651 onfiredelay-=multiplier;
4652 if(onfiredelay<0&&onfire)
4660 crouchkeydowntime+=multiplier;
4661 if(!crouchkeydown)crouchkeydowntime=0;
4662 jumpkeydowntime+=multiplier;
4663 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
4665 if(hostile||damage>0||bloodloss>0)immobile=0;
4667 if(isIdle()||isRun())targetoffset=0;
4669 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
4671 if(id==0)blooddimamount-=multiplier*.3;
4672 speechdelay-=multiplier;
4673 texupdatedelay-=multiplier;
4674 interestdelay-=multiplier;
4675 flamedelay-=multiplier;
4676 parriedrecently-=multiplier;
4682 if(id==0)speed=1.1*speedmult;
4683 else speed=1.0*speedmult;
4684 if(!skeleton.free)rabbitkickragdoll=0;
4688 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
4689 if(id!=0&&creature==wolftype&&difficulty==2){
4691 if(aitype!=passivetype){
4693 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){
4697 if(scale<0.2)superruntoggle=0;
4698 if(targetanimation==wolfrunninganim&&!superruntoggle){
4699 targetanimation=getRun();
4703 if(weaponactive==-1&&num_weapons>0){
4704 if(weapons.type[weaponids[0]]==staff){
4711 /*if(aitype!=playercontrolled)*///deathbleeding=5;
4712 /*if(aitype!=playercontrolled)*/
4714 if(burnt>.6)burnt=.6;
4715 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
4717 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
4728 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4729 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
4733 while(flamedelay<0&&onfire){
4735 howmany=abs(Random()%(skeleton.num_joints));
4736 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4737 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4738 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4739 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4740 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
4743 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
4745 howmany=abs(Random()%(skeleton.num_joints));
4746 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4747 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4748 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4749 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4750 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
4754 bleeding-=multiplier*.3;
4756 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4757 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
4761 if(neckspurtamount>0){
4762 neckspurtamount-=multiplier;
4763 neckspurtdelay-=multiplier*3;
4764 neckspurtparticledelay-=multiplier*3;
4765 if(neckspurtparticledelay<0&&neckspurtdelay>2){
4769 bloodvel.z=5*neckspurtamount;
4770 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4773 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
4775 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4776 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
4777 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);
4778 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);
4779 neckspurtparticledelay=.05;
4781 if(neckspurtdelay<0){
4786 if(deathbleeding>0&&dead!=2){
4787 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
4788 else bleeddelay-=5*multiplier/4;
4789 if(bleeddelay<0&&bloodtoggle){
4794 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4795 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
4796 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
4797 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);
4800 bloodloss+=deathbleeding*multiplier*80;
4801 deathbleeding-=multiplier*1.6;
4802 //if(id==0)deathbleeding-=multiplier*.2;
4803 if(deathbleeding<0)deathbleeding=0;
4804 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
4805 if(weaponactive!=-1){
4806 weapons.owner[weaponids[0]]=-1;
4807 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4808 weapons.velocity[weaponids[0]].x+=.01;
4809 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4810 weapons.missed[weaponids[0]]=1;
4811 weapons.hitsomething[weaponids[0]]=0;
4812 weapons.freetime[weaponids[0]]=0;
4813 weapons.firstfree[weaponids[0]]=1;
4814 weapons.physics[weaponids[0]]=1;
4817 weaponids[0]=weaponids[num_weapons];
4818 if(weaponstuck==num_weapons)weaponstuck=0;
4821 for(i=0;i<numplayers;i++){
4822 player[i].wentforweapon=0;
4834 if(!dead&&creature==wolftype){
4835 award_bonus(0, Wolfbonus);
4838 if(targetanimation==knifefollowedanim&&!skeleton.free){
4839 for(i=0;i<skeleton.num_joints;i++){
4840 skeleton.joints[i].velocity=0;
4841 skeleton.joints[i].velocity.y=-2;
4844 if(id!=0&&unconscioustime>.1){
4852 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
4855 bloodsize=5-realtexdetail;
4859 texdetailint=realtexdetail;
4860 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
4861 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
4862 endx=startx+bloodsize;
4863 endy=starty+bloodsize;
4865 if(startx<0){startx=0;bleeding=0;}
4866 if(starty<0){starty=0;bleeding=0;}
4867 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
4868 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
4869 if(endx<startx)endx=startx;
4870 if(endy<starty)endy=starty;
4872 for(i=startx;i<endx;i++){
4873 for(j=starty;j<endy;j++){
4875 color=Random()%85+170;
4876 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
4877 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
4878 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
4883 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4884 DoMipmaps(0,startx,endx,starty,endy);
4888 bleedy-=4/realtexdetail;
4889 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
4890 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
4893 bleedx+=4*direction/realtexdetail;
4894 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
4895 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
4899 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
4900 righthandmorphness=targetrighthandmorphness;
4901 righthandmorphstart=righthandmorphend;
4903 else if(righthandmorphness>targetrighthandmorphness){
4904 righthandmorphness-=multiplier*4;
4906 else if(righthandmorphness<targetrighthandmorphness){
4907 righthandmorphness+=multiplier*4;
4910 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
4911 lefthandmorphness=targetlefthandmorphness;
4912 lefthandmorphstart=lefthandmorphend;
4914 else if(lefthandmorphness>targetlefthandmorphness){
4915 lefthandmorphness-=multiplier*4;
4917 else if(lefthandmorphness<targetlefthandmorphness){
4918 lefthandmorphness+=multiplier*4;
4921 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
4922 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
4923 tailmorphness=targettailmorphness;
4924 tailmorphstart=tailmorphend;
4926 else if(tailmorphness>targettailmorphness){
4927 tailmorphness-=multiplier*10;
4929 else if(tailmorphness<targettailmorphness){
4930 tailmorphness+=multiplier*10;
4934 if(creature==wolftype){
4935 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
4936 tailmorphness=targettailmorphness;
4937 tailmorphstart=tailmorphend;
4939 else if(tailmorphness>targettailmorphness){
4940 tailmorphness-=multiplier*2;
4942 else if(tailmorphness<targettailmorphness){
4943 tailmorphness+=multiplier*2;
4947 if(headmorphend==3||headmorphstart==3){
4948 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
4949 headmorphness=targetheadmorphness;
4950 headmorphstart=headmorphend;
4952 else if(headmorphness>targetheadmorphness){
4953 headmorphness-=multiplier*7;
4955 else if(headmorphness<targetheadmorphness){
4956 headmorphness+=multiplier*7;
4959 else if(headmorphend==5||headmorphstart==5){
4960 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
4961 headmorphness=targetheadmorphness;
4962 headmorphstart=headmorphend;
4964 else if(headmorphness>targetheadmorphness){
4965 headmorphness-=multiplier*10;
4967 else if(headmorphness<targetheadmorphness){
4968 headmorphness+=multiplier*10;
4972 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
4973 headmorphness=targetheadmorphness;
4974 headmorphstart=headmorphend;
4976 else if(headmorphness>targetheadmorphness){
4977 headmorphness-=multiplier*4;
4979 else if(headmorphness<targetheadmorphness){
4980 headmorphness+=multiplier*4;
4984 if(abs(chestmorphness-targetchestmorphness)<multiplier){
4985 chestmorphness=targetchestmorphness;
4986 chestmorphstart=chestmorphend;
4988 else if(chestmorphness>targetchestmorphness){
4989 chestmorphness-=multiplier;
4991 else if(chestmorphness<targetchestmorphness){
4992 chestmorphness+=multiplier;
4995 if(dead!=2&&howactive<=typesleeping){
4996 if(chestmorphstart==0&&chestmorphend==0){
4998 targetchestmorphness=1;
5001 if(chestmorphstart!=0&&chestmorphend!=0){
5003 targetchestmorphness=1;
5005 if(environment==snowyenvironment){
5008 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5009 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5010 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5011 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5012 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5013 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5017 if(!dead&&howactive<typesleeping){
5018 blinkdelay-=multiplier*2;
5019 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5021 targetheadmorphness=1;
5023 blinkdelay=(float)(abs(Random()%40))/5;
5025 if(headmorphstart==3&&headmorphend==3){
5027 targetheadmorphness=1;
5032 twitchdelay-=multiplier*1.5;
5033 if(targetanimation!=hurtidleanim){
5034 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5036 targetheadmorphness=1;
5038 twitchdelay=(float)(abs(Random()%40))/5;
5040 if(headmorphstart==5&&headmorphend==5){
5042 targetheadmorphness=1;
5046 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5047 twitchdelay3-=multiplier*1;
5049 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5050 righthandmorphness=0;
5051 targetrighthandmorphness=1;
5052 righthandmorphend=1;
5053 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5055 if(righthandmorphstart==1&&righthandmorphend==1){
5056 righthandmorphness=0;
5057 targetrighthandmorphness=1;
5058 righthandmorphend=0;
5062 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5063 lefthandmorphness=0;
5064 targetlefthandmorphness=1;
5066 twitchdelay3=(float)(abs(Random()%40))/5;
5068 if(lefthandmorphstart==1&&lefthandmorphend==1){
5069 lefthandmorphness=0;
5070 targetlefthandmorphness=1;
5077 if(creature==rabbittype){
5078 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5079 else twitchdelay2-=multiplier*0.5;
5080 if(howactive<=typesleeping){
5081 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5083 targettailmorphness=1;
5085 twitchdelay2=(float)(abs(Random()%40))/5;
5087 if(tailmorphstart==1&&tailmorphend==1){
5089 targettailmorphness=1;
5092 if(tailmorphstart==2&&tailmorphend==2){
5094 targettailmorphness=1;
5101 if(creature==wolftype){
5102 twitchdelay2-=multiplier*1.5;
5104 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5106 targettailmorphness=1;
5111 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5113 targettailmorphness=1;
5117 if(twitchdelay2<=0){
5118 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5120 targettailmorphness=1;
5123 if(tailmorphstart==1&&tailmorphend==1){
5125 targettailmorphness=1;
5128 if(tailmorphstart==2&&tailmorphend==2){
5130 targettailmorphness=1;
5133 if(tailmorphstart==3&&tailmorphend==3){
5135 targettailmorphness=1;
5138 if(tailmorphstart==4&&tailmorphend==4){
5140 targettailmorphness=1;
5146 if(dead!=1)unconscioustime=0;
5148 if(dead==1||howactive==typesleeping){
5149 unconscioustime+=multiplier;
5150 //If unconscious, close eyes and mouth
5151 if(righthandmorphend!=0)righthandmorphness=0;
5152 righthandmorphend=0;
5153 targetrighthandmorphness=1;
5155 if(lefthandmorphend!=0)lefthandmorphness=0;
5157 targetlefthandmorphness=1;
5159 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5161 targetheadmorphness=1;
5165 if(howactive>typesleeping){
5168 if(bloodtoggle&&!bled){
5169 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5171 if(bloodtoggle&&!bled)
5172 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5173 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5174 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5178 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5183 if(dead==2||howactive>typesleeping){
5184 //If dead, open mouth and hands
5185 if(righthandmorphend!=0)righthandmorphness=0;
5186 righthandmorphend=0;
5187 targetrighthandmorphness=1;
5189 if(lefthandmorphend!=0)lefthandmorphness=0;
5191 targetlefthandmorphness=1;
5193 if(headmorphend!=2)headmorphness=0;
5195 targetheadmorphness=1;
5198 if(stunned>0&&!dead&&headmorphend!=2){
5199 if(headmorphend!=4)headmorphness=0;
5201 targetheadmorphness=1;
5204 if(damage>damagetolerance&&!dead){
5209 if(creature==wolftype){
5210 award_bonus(0, Wolfbonus);
5215 if(weaponactive!=-1){
5216 weapons.owner[weaponids[0]]=-1;
5217 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5218 weapons.velocity[weaponids[0]].x+=.01;
5219 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5220 weapons.missed[weaponids[0]]=1;
5221 weapons.hitsomething[weaponids[0]]=0;
5222 weapons.freetime[weaponids[0]]=0;
5223 weapons.firstfree[weaponids[0]]=1;
5224 weapons.physics[weaponids[0]]=1;
5227 weaponids[0]=weaponids[num_weapons];
5228 if(weaponstuck==num_weapons)weaponstuck=0;
5231 for(i=0;i<numplayers;i++){
5232 player[i].wentforweapon=0;
5238 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5246 //if(dead)damage-=multiplier/4;
5247 if(!dead)damage-=multiplier*13;
5248 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5249 if(!dead)permanentdamage-=multiplier*4;
5250 if(isIdle()||isCrouch()){
5251 if(!dead)permanentdamage-=multiplier*4;
5252 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5254 if(damage<0)damage=0;
5255 if(permanentdamage<0)permanentdamage=0;
5256 if(superpermanentdamage<0)superpermanentdamage=0;
5257 if(permanentdamage<superpermanentdamage){
5258 permanentdamage=superpermanentdamage;
5260 if(damage<permanentdamage){
5261 damage=permanentdamage;
5263 if(dead==1&&damage<damagetolerance){
5267 for(i=0;i<skeleton.num_joints;i++){
5268 skeleton.joints[i].velocity=0;
5271 if(permanentdamage>damagetolerance&&dead!=2){
5274 if(weaponactive!=-1){
5275 weapons.owner[weaponids[0]]=-1;
5276 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5277 weapons.velocity[weaponids[0]].x+=.01;
5278 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5279 weapons.missed[weaponids[0]]=1;
5280 weapons.hitsomething[weaponids[0]]=0;
5281 weapons.freetime[weaponids[0]]=0;
5282 weapons.firstfree[weaponids[0]]=1;
5283 weapons.physics[weaponids[0]]=1;
5286 weaponids[0]=weaponids[num_weapons];
5287 if(weaponstuck==num_weapons)weaponstuck=0;
5290 for(i=0;i<numplayers;i++){
5291 player[i].wentforweapon=0;
5297 if(!dead&&creature==wolftype){
5298 award_bonus(0, Wolfbonus);
5301 if(unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance)
5302 award_bonus(id, touchofdeath);
5303 if(id!=0&&unconscioustime>.1){
5319 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5320 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5321 OPENAL_SetVolume(channels[breaksound], 512);
5322 OPENAL_SetPaused(channels[breaksound], false);
5323 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5329 if(skeleton.free==1){
5330 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5333 //If knocked over, open hands and close mouth
5334 if(righthandmorphend!=0)righthandmorphness=0;
5335 righthandmorphend=0;
5336 targetrighthandmorphness=1;
5338 if(lefthandmorphend!=0)lefthandmorphness=0;
5340 targetlefthandmorphness=1;
5342 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5343 if(headmorphend!=0)headmorphness=0;
5345 targetheadmorphness=1;
5349 skeleton.DoGravity(&scale);
5351 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5352 if(damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1))
5353 award_bonus(id, deepimpact);
5354 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5358 for(j=0;j<skeleton.num_joints;j++){
5359 average+=skeleton.joints[j].position;
5363 coords+=average*scale;
5364 for(j=0;j<skeleton.num_joints;j++){
5365 skeleton.joints[j].position-=average;
5367 average/=multiplier;
5369 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5371 for(i=0;i<skeleton.num_joints;i++){
5372 velocity+=skeleton.joints[i].velocity*scale;
5374 velocity/=skeleton.num_joints;
5376 if(!isnormal(velocity.x)&&velocity.x){
5389 if(findLength(&average)<10&&dead&&skeleton.free){
5390 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5391 if(skeleton.longdead>2000){
5392 if(skeleton.longdead>6000){
5393 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5398 if(dead==2&&bloodloss<damagetolerance){
5400 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5402 if(bloodtoggle&&!bled){
5403 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5405 if(bloodtoggle&&!bled)
5406 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5407 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5408 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5412 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5416 if(dead==2&&bloodloss>=damagetolerance){
5418 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5419 if(bleeding<=0)DoBlood(1,255);
5420 if(bloodtoggle&&!bled){
5421 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5423 if(bloodtoggle&&!bled)
5424 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5425 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5426 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5430 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5437 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5439 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5443 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5444 if(velocity.y<-30)canrecover=0;
5445 for(i=0;i<objects.numobjects;i++){
5446 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5447 colviewer=startpoint;
5449 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5457 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5458 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5459 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5460 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5462 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5463 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5464 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5466 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5467 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5468 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5470 Normalise(&terrainnormal);
5472 targetrotation=-asin(0-terrainnormal.x);
5473 targetrotation*=360/6.28;
5474 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5475 rotation=targetrotation;
5479 targetanimation=flipanim;
5480 crouchtogglekeydown=1;
5485 currentanimation=tempanim;
5488 //tilt2=targettilt2;
5490 //if(middle.y>0)targetoffset.y=middle.y+1;
5492 for(i=0;i<skeleton.num_joints;i++){
5493 tempanimation.position[i][0]=skeleton.joints[i].position;
5494 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5499 if(findLength(&average)<10&&!dead&&skeleton.free){
5500 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5501 if(skeleton.longdead>(damage+500)*1.5){
5502 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5508 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5509 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5510 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5511 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5513 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5514 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5515 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5517 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5518 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5519 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5521 Normalise(&terrainnormal);
5523 targetrotation=-asin(0-terrainnormal.x);
5524 targetrotation*=360/6.28;
5525 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5526 rotation=targetrotation;
5529 terrainnormal=terrain.getNormal(coords.x,coords.z);
5530 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5534 /*XYZ otherterrainnormal;
5535 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5536 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5537 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5538 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5541 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5545 if(skeleton.forward.y<0){
5546 targetanimation=getupfrombackanim;
5550 if(skeleton.forward.y>-.3){
5551 targetanimation=getupfromfrontanim;
5553 targetrotation+=180;
5559 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5560 targetanimation=rollanim;
5561 targetrotation=lookrotation;
5565 if(forwardkeydown)targetrotation+=45;
5566 if(backkeydown)targetrotation-=45;
5570 if(forwardkeydown)targetrotation-=45;
5571 if(backkeydown)targetrotation+=45;
5574 if ( !leftkeydown&&!rightkeydown)
5575 targetrotation+=180;
5577 targetrotation+=180;
5581 if(abs(targettilt2)>50)targettilt2=0;
5582 currentanimation=tempanim;
5587 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5589 for(i=0;i<skeleton.num_joints;i++){
5590 tempanimation.position[i][0]=skeleton.joints[i].position;
5591 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5598 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5599 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5602 tempvelocity=velocity;
5603 Normalise(&tempvelocity);
5604 targetrotation=-asin(0-tempvelocity.x);
5605 targetrotation*=360/6.28;
5606 if(velocity.z<0)targetrotation=180-targetrotation;
5607 //targetrotation+=180;
5610 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5611 targetanimation=rollanim;
5615 targetanimation=backhandspringanim;
5616 targetrotation+=180;
5629 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
5630 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
5631 OPENAL_SetVolume(channels[movewhooshsound], 128);
5632 OPENAL_SetPaused(channels[movewhooshsound], false);
5634 currentanimation=targetanimation;
5635 currentframe=targetframe-1;
5640 rotation=targetrotation;
5647 if(skeleton.freefall==0)freefall=0;
5649 if(!isnormal(velocity.x)&&velocity.x){
5654 if(aitype!=passivetype||skeleton.free==1)
5655 if(findLengthfast(&velocity)>.1)
5656 for(i=0;i<objects.numobjects;i++){
5657 if(objects.type[i]==firetype)
5658 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){
5660 if(!objects.onfire[i]){
5663 gLoc[0]=objects.position[i].x;
5664 gLoc[1]=objects.position[i].y;
5665 gLoc[2]=objects.position[i].z;
5669 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5670 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5671 OPENAL_SetVolume(channels[firestartsound], 256);
5672 OPENAL_SetPaused(channels[firestartsound], false);
5674 objects.onfire[i]=1;
5677 if(objects.onfire[i]){
5682 if(objects.type[i]==bushtype)
5683 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){
5685 if(!objects.onfire[i]){
5688 gLoc[0]=objects.position[i].x;
5689 gLoc[1]=objects.position[i].y;
5690 gLoc[2]=objects.position[i].z;
5694 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5695 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5696 OPENAL_SetVolume(channels[firestartsound], 256);
5697 OPENAL_SetPaused(channels[firestartsound], false);
5699 objects.onfire[i]=1;
5703 if(objects.onfire[i]){
5707 if(objects.messedwith[i]<=0){
5719 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5720 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5721 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5722 OPENAL_SetPaused(channels[bushrustle], false);
5725 envsound[numenvsounds]=coords;
5726 envsoundvol[numenvsounds]=4*findLength(&velocity);
5727 envsoundlife[numenvsounds]=.4;
5732 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5733 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5735 if(environment!=desertenvironment)
5736 for(j=0;j<howmany;j++){
5737 tempvel.x=float(abs(Random()%100)-50)/20;
5738 tempvel.y=float(abs(Random()%100)-50)/20;
5739 tempvel.z=float(abs(Random()%100)-50)/20;
5742 pos.x+=float(abs(Random()%100)-50)/200;
5743 pos.y+=float(abs(Random()%100)-50)/200;
5744 pos.z+=float(abs(Random()%100)-50)/200;
5745 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);
5746 Sprite::setLastSpriteSpecial(1);
5748 howmany=findLength(&velocity)*4;
5750 if(environment==snowyenvironment)
5751 for(j=0;j<howmany;j++){
5752 tempvel.x=float(abs(Random()%100)-50)/20;
5753 tempvel.y=float(abs(Random()%100)-50)/20;
5754 tempvel.z=float(abs(Random()%100)-50)/20;
5757 pos.x+=float(abs(Random()%100)-50)/200;
5758 pos.y+=float(abs(Random()%100)-50)/200;
5759 pos.z+=float(abs(Random()%100)-50)/200;
5760 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5761 Sprite::setLastSpriteSpecial(2);
5764 objects.rotx[i]+=velocity.x*multiplier*6;
5765 objects.roty[i]+=velocity.z*multiplier*6;
5766 objects.messedwith[i]=.5;
5769 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
5770 if(objects.rotation2[i]==0)tempcoord=coords;
5772 tempcoord=coords-objects.position[i];
5773 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
5774 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
5775 tempcoord+=objects.position[i];
5777 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]){
5778 if(objects.messedwith[i]<=0){
5790 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5791 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5792 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5793 OPENAL_SetPaused(channels[bushrustle], false);
5796 envsound[numenvsounds]=coords;
5797 envsoundvol[numenvsounds]=4*findLength(&velocity);
5798 envsoundlife[numenvsounds]=.4;
5803 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5804 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5806 if(environment!=desertenvironment)
5807 for(j=0;j<howmany;j++){
5808 tempvel.x=float(abs(Random()%100)-50)/20;
5809 tempvel.y=float(abs(Random()%100)-50)/20;
5810 tempvel.z=float(abs(Random()%100)-50)/20;
5814 pos.x+=float(abs(Random()%100)-50)/150;
5815 pos.y+=float(abs(Random()%100)-50)/150;
5816 pos.z+=float(abs(Random()%100)-50)/150;
5817 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);
5818 Sprite::setLastSpriteSpecial(1);
5820 howmany=findLength(&velocity)*4;
5822 if(environment==snowyenvironment)
5823 for(j=0;j<howmany;j++){
5824 tempvel.x=float(abs(Random()%100)-50)/20;
5825 tempvel.y=float(abs(Random()%100)-50)/20;
5826 tempvel.z=float(abs(Random()%100)-50)/20;
5830 pos.x+=float(abs(Random()%100)-50)/150;
5831 pos.y+=float(abs(Random()%100)-50)/150;
5832 pos.z+=float(abs(Random()%100)-50)/150;
5833 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5834 Sprite::setLastSpriteSpecial(2);
5837 objects.messedwith[i]=.5;
5845 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
5847 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
5848 if(tutoriallevel==1&&id!=0)play=0;
5849 if(play&&aitype!=playercontrolled){
5861 if(creature==rabbittype){
5862 if(i==0)whichsound=rabbitchitter;
5863 if(i==1)whichsound=rabbitchitter2;
5865 if(creature==wolftype){
5866 if(i==0)whichsound=growlsound;
5867 if(i==1)whichsound=growl2sound;
5873 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
5874 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
5875 OPENAL_SetVolume(channels[whichsound], 512);
5876 OPENAL_SetPaused(channels[whichsound], false);
5880 if(targetanimation==staggerbackhighanim)staggerdelay=1;
5881 if(targetanimation==staggerbackhardanim)staggerdelay=1;
5882 staggerdelay-=multiplier;
5883 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
5884 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
5885 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
5886 targetanimation=getIdle();
5890 weaponmissdelay-=multiplier;
5891 highreversaldelay-=multiplier;
5892 lowreversaldelay-=multiplier;
5893 lastcollide-=multiplier;
5894 skiddelay-=multiplier;
5895 if(!isnormal(velocity.x)&&velocity.x){
5898 if(!isnormal(targettilt)&&targettilt){
5901 if(!isnormal(targettilt2)&&targettilt2){
5904 if(!isnormal(targetrotation)&&targetrotation){
5908 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
5909 //open hands and close mouth
5910 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
5911 righthandmorphness=0;
5912 righthandmorphend=0;
5913 targetrighthandmorphness=1;
5916 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
5917 lefthandmorphness=0;
5919 targetlefthandmorphness=1;
5922 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
5925 targetheadmorphness=1;
5929 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){
5930 //open hands and mouth
5931 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
5932 righthandmorphness=0;
5933 righthandmorphend=0;
5934 targetrighthandmorphness=1;
5937 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
5938 lefthandmorphness=0;
5940 targetlefthandmorphness=1;
5943 if(headmorphend!=1&&headmorphness==targetheadmorphness){
5946 targetheadmorphness=1;
5950 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
5951 //close hands and mouth
5952 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
5953 righthandmorphness=0;
5954 righthandmorphend=1;
5955 targetrighthandmorphness=1;
5958 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
5959 lefthandmorphness=0;
5961 targetlefthandmorphness=1;
5964 if(headmorphend!=0&&headmorphness==targetheadmorphness){
5967 targetheadmorphness=1;
5971 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){
5972 //close hands and yell
5973 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
5974 righthandmorphness=0;
5975 righthandmorphend=1;
5976 targetrighthandmorphness=1;
5979 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
5980 lefthandmorphness=0;
5982 targetlefthandmorphness=1;
5985 if(headmorphend!=2&&headmorphness==targetheadmorphness){
5988 targetheadmorphness=1;
5992 if(speechdelay>.25){
5993 if(headmorphend!=2)headmorphness=0;
5995 targetheadmorphness=1;
6001 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6002 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6006 if(!dead&&targetanimation!=hurtidleanim)
6007 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6008 if(headmorphend!=4||headmorphness==targetheadmorphness){
6011 targetheadmorphness=1;
6015 if(weaponactive!=-1){
6016 if(weapons.type[weaponids[weaponactive]]!=staff){
6017 righthandmorphstart=1;
6018 righthandmorphend=1;
6020 if(weapons.type[weaponids[weaponactive]]==staff){
6021 righthandmorphstart=2;
6022 righthandmorphend=2;
6024 targetrighthandmorphness=1;
6027 terrainnormal=terrain.getNormal(coords.x,coords.z);
6029 if(animation[targetanimation].attack!=reversal){
6030 if(!isnormal(coords.x))
6038 flatfacing=DoRotation(flatfacing,0,rotation,0);
6040 ReflectVector(&facing,terrainnormal);
6043 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6044 if(onterrain)targettilt2=-facing.y*20;
6048 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6049 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6050 flatvelocity=velocity;
6052 flatvelspeed=findLength(&flatvelocity);
6053 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6054 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6055 if(velocity.y<0)targettilt2*=-1;
6056 if(velocity.y<0)targettilt*=-1;
6057 if(targettilt>25)targettilt=25;
6058 if(targettilt<-25)targettilt=-25;
6061 if(targettilt2>45)targettilt2=45;
6062 if(targettilt2<-45)targettilt2=-45;
6063 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6064 else if(tilt2>targettilt2){
6065 tilt2-=multiplier*400;
6067 else if(tilt2<targettilt2){
6068 tilt2+=multiplier*400;
6070 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6071 if(tilt2>25)tilt2=25;
6072 if(tilt2<-25)tilt2=-25;
6075 if(!isnormal(targettilt)&&targettilt){
6078 if(!isnormal(targettilt2)&&targettilt2){
6083 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6084 if(targetanimation==rabbittackleanim){
6085 velocity+=facing*multiplier*speed*700*scale;
6086 velspeed=findLength(&velocity);
6087 if(velspeed>speed*65*scale){
6089 velspeed=speed*65*scale;
6092 velocity.y+=gravity*multiplier*20;
6093 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6094 velspeed=findLength(&velocity);
6095 velocity=flatfacing*velspeed;
6097 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6098 if(isRun()||targetanimation==rabbitkickanim){
6099 velocity+=facing*multiplier*speed*700*scale;
6100 velspeed=findLength(&velocity);
6101 if(velspeed>speed*45*scale){
6103 velspeed=speed*45*scale;
6106 velocity.y+=gravity*multiplier*20;
6107 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6108 velspeed=findLength(&velocity);
6109 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6110 velocity=flatfacing*velspeed;
6114 velocity+=facing*multiplier*speed*700*scale;
6115 velspeed=findLength(&velocity);
6116 if(creature==rabbittype){
6117 if(velspeed>speed*55*scale){
6119 velspeed=speed*55*scale;
6123 if(creature==wolftype){
6124 if(velspeed>speed*75*scale){
6126 velspeed=speed*75*scale;
6130 velocity.y+=gravity*multiplier*20;
6131 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6132 velspeed=findLength(&velocity);
6133 velocity=flatfacing*velspeed;
6136 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6137 velocity+=facing*multiplier*speed*700*scale;
6138 velspeed=findLength(&velocity);
6139 if(velspeed>speed*45*scale){
6141 velspeed=speed*45*scale;
6144 velocity.y+=gravity*multiplier*20;
6145 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6146 velspeed=findLength(&velocity);
6147 velocity=flatfacing*velspeed;
6151 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6152 velocity+=facing*multiplier*speed*700*scale;
6153 velspeed=findLength(&velocity);
6154 if(velspeed>speed*25*scale){
6156 velspeed=speed*25*scale;
6159 velocity.y+=gravity*multiplier*20;
6160 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6161 velspeed=findLength(&velocity);
6162 velocity=flatfacing*velspeed;
6165 if(targetanimation==sneakanim||targetanimation==walkanim){
6166 velocity+=facing*multiplier*speed*700*scale;
6167 velspeed=findLength(&velocity);
6168 if(velspeed>speed*12*scale){
6170 velspeed=speed*12*scale;
6173 velocity.y+=gravity*multiplier*20;
6174 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6175 velspeed=findLength(&velocity);
6176 velocity=flatfacing*velspeed;
6179 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6180 velocity+=facing*multiplier*speed*700*scale;
6181 velspeed=findLength(&velocity);
6182 if(velspeed>speed*2*scale){
6184 velspeed=speed*2*scale;
6187 velocity.y+=gravity*multiplier*20;
6188 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6189 velspeed=findLength(&velocity);
6190 velocity=flatfacing*velspeed;
6194 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6195 velocity-=facing*multiplier*speed*700*scale;
6196 velspeed=findLength(&velocity);
6197 if(velspeed>speed*2*scale){
6199 velspeed=speed*2*scale;
6202 velocity.y+=gravity*multiplier*20;
6203 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6204 velspeed=findLength(&velocity);
6205 velocity=flatfacing*velspeed*-1;
6208 if(targetanimation==fightsidestep){
6209 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6210 velspeed=findLength(&velocity);
6211 if(velspeed>speed*12*scale){
6213 velspeed=speed*12*scale;
6216 velocity.y+=gravity*multiplier*20;
6217 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6218 velspeed=findLength(&velocity);
6219 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6222 if(targetanimation==staggerbackhighanim){
6223 coords-=facing*multiplier*speed*16*scale;
6226 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6227 coords-=facing*multiplier*speed*20*scale;
6231 if(targetanimation==backhandspringanim){
6232 //coords-=facing*multiplier*50*scale;
6233 velocity+=facing*multiplier*speed*700*scale*-1;
6234 velspeed=findLength(&velocity);
6235 if(velspeed>speed*50*scale){
6237 velspeed=speed*50*scale;
6240 velocity.y+=gravity*multiplier*20;
6241 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6242 velspeed=findLength(&velocity);
6243 velocity=flatfacing*velspeed*-1;
6245 if(targetanimation==dodgebackanim){
6246 //coords-=facing*multiplier*50*scale;
6247 velocity+=facing*multiplier*speed*700*scale*-1;
6248 velspeed=findLength(&velocity);
6249 if(velspeed>speed*60*scale){
6251 velspeed=speed*60*scale;
6254 velocity.y+=gravity*multiplier*20;
6255 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6256 velspeed=findLength(&velocity);
6257 velocity=flatfacing*velspeed*-1;
6260 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6261 velspeed=findLength(&velocity);
6265 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6266 velocity.y+=gravity*multiplier;
6269 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6271 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6272 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6274 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6280 OPENAL_SetPaused(channels[whooshsound], true);
6281 OPENAL_SetVolume(channels[whooshsound], 0);
6284 if(targetanimation==jumpdownanim||isFlip()){
6285 if(isFlip())jumppower=-4;
6286 targetanimation=getLanding();
6295 PlaySoundEx( landsound, samp[landsound], NULL, true);
6296 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6297 OPENAL_SetVolume(channels[landsound], 128);
6298 OPENAL_SetPaused(channels[landsound], false);
6301 envsound[numenvsounds]=coords;
6302 envsoundvol[numenvsounds]=16;
6303 envsoundlife[numenvsounds]=.4;
6309 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6310 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6311 coords.y=terrain.getHeight(coords.x,coords.z);
6316 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)){
6317 velspeed=findLength(&velocity);
6319 if(velspeed<multiplier*300*scale){
6321 } else velocity-=velocity/velspeed*multiplier*300*scale;
6322 if(velspeed>5&&(isLanding()||isLandhard())){
6323 skiddingdelay+=multiplier;
6330 else skiddingdelay=0;
6334 velspeed=findLength(&velocity);
6336 if(velspeed<multiplier*600*scale){
6338 } else velocity-=velocity/velspeed*multiplier*600*scale;
6340 if(velspeed>5&&(isLanding()||isLandhard())){
6341 skiddingdelay+=multiplier;
6348 else skiddingdelay=0;
6351 if(skiddingdelay<0)skiddingdelay+=multiplier;
6352 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6362 if(!onterrain||environment==grassyenvironment){
6363 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6364 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6365 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6366 OPENAL_SetPaused(channels[skidsound], false);
6369 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6370 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6371 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6372 OPENAL_SetPaused(channels[snowskidsound], false);
6376 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6377 terrainnormal=victim->coords-coords;
6378 Normalise(&terrainnormal);
6379 targetrotation=-asin(0-terrainnormal.x);
6380 targetrotation*=360/6.28;
6381 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6382 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6385 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6386 targetrotation=victim->targetrotation;
6388 if(targetanimation==rabbittacklinganim){
6389 coords=victim->coords;
6392 skeleton.oldfree=skeleton.free;
6396 midterrain.x=terrain.size*terrain.scale/2;
6397 midterrain.z=terrain.size*terrain.scale/2;
6398 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6400 tempposit=coords-midterrain;
6402 Normalise(&tempposit);
6403 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6404 coords.x=tempposit.x+midterrain.x;
6405 coords.z=tempposit.z+midterrain.z;
6409 int Person::DrawSkeleton(){
6410 int oldplayerdetail;
6411 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6412 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6422 glAlphaFunc(GL_GREATER, 0.0001);
6424 float terrainheight;
6426 if(!isnormal(rotation))rotation=0;
6427 if(!isnormal(tilt))tilt=0;
6428 if(!isnormal(tilt2))tilt2=0;
6429 oldplayerdetail=playerdetail;
6431 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6434 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6437 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6442 if(playerdetail!=oldplayerdetail) {
6444 normalsupdatedelay=0;
6446 static float updatedelaychange;
6447 static float morphness;
6448 static float framemult;
6450 skeleton.FindForwards();
6451 if(howactive==typesittingwall){
6452 skeleton.specialforward[1]=0;
6453 skeleton.specialforward[1].z=1;
6459 static int weaponattachmuscle;
6460 static int weaponrotatemuscle,weaponrotatemuscle2;
6461 static XYZ weaponpoint;
6462 static int start,endthing;
6463 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6464 if(!isSleeping()&&!isSitting()){
6465 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6466 XYZ point,newpoint,change,change2;
6467 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6468 heightleft=terrain.getHeight(point.x,point.z)+.04;
6470 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6471 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6472 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6473 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6474 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6476 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6477 heightright=terrain.getHeight(point.x,point.z)+.04;
6478 point.y=heightright;
6479 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6480 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6481 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6482 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6483 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6484 skeleton.DoConstraints(&coords,&scale);
6486 if(creature==wolftype){
6487 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6488 heightleft=terrain.getHeight(point.x,point.z)+.04;
6490 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6491 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6492 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6493 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6494 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6496 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6497 heightright=terrain.getHeight(point.x,point.z)+.04;
6498 point.y=heightright;
6499 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6500 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6501 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6502 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6503 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6504 skeleton.DoConstraints(&coords,&scale);
6507 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6508 XYZ point,newpoint,change,change2;
6509 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6510 heightleft=terrain.getHeight(point.x,point.z)+.04;
6512 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6513 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6514 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6515 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6516 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6518 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6519 heightright=terrain.getHeight(point.x,point.z)+.04;
6520 point.y=heightright;
6521 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6522 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6523 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6524 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6525 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6526 skeleton.DoConstraints(&coords,&scale);
6528 if(creature==wolftype){
6529 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6530 heightleft=terrain.getHeight(point.x,point.z)+.04;
6532 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6533 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6534 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6535 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6536 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6538 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6539 heightright=terrain.getHeight(point.x,point.z)+.04;
6540 point.y=heightright;
6541 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6542 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6543 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6544 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6545 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6546 skeleton.DoConstraints(&coords,&scale);
6550 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6551 XYZ point,newpoint,change,change2;
6552 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6553 heightleft=terrain.getHeight(point.x,point.z)+.04;
6555 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6556 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6557 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6558 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6559 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6561 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6562 heightright=terrain.getHeight(point.x,point.z)+.04;
6563 point.y=heightright;
6564 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6565 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6566 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6567 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6568 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6569 skeleton.DoConstraints(&coords,&scale);
6571 if(creature==wolftype){
6572 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6573 heightleft=terrain.getHeight(point.x,point.z)+.04;
6575 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6576 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6577 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6578 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6579 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6581 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6582 heightright=terrain.getHeight(point.x,point.z)+.04;
6583 point.y=heightright;
6584 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6585 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6586 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6587 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6588 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6589 skeleton.DoConstraints(&coords,&scale);
6593 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()))
6596 targetheadrotation=-targetrotation;
6597 targetheadrotation2=0;
6598 if(animation[targetanimation].attack==3)targetheadrotation+=180;
6600 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6601 skeleton.drawmodel.vertex[i]=0;
6602 skeleton.drawmodel.vertex[i].y=999;
6604 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
6605 skeleton.drawmodellow.vertex[i]=0;
6606 skeleton.drawmodellow.vertex[i].y=999;
6608 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
6609 skeleton.drawmodelclothes.vertex[i]=0;
6610 skeleton.drawmodelclothes.vertex[i].y=999;
6612 for(i=0;i<skeleton.num_muscles;i++){
6613 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
6617 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
6618 morphness=righthandmorphness;
6619 start=righthandmorphstart;
6620 endthing=righthandmorphend;
6622 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
6623 morphness=lefthandmorphness;
6624 start=lefthandmorphstart;
6625 endthing=lefthandmorphend;
6627 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
6628 morphness=headmorphness;
6629 start=headmorphstart;
6630 endthing=headmorphend;
6632 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)){
6633 morphness=chestmorphness;
6634 start=chestmorphstart;
6635 endthing=chestmorphend;
6637 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)){
6638 morphness=tailmorphness;
6639 start=tailmorphstart;
6640 endthing=tailmorphend;
6642 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
6643 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6644 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6647 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6648 if(!skeleton.free)glRotatef(tilt,0,0,1);
6651 glTranslatef(mid.x,mid.y,mid.z);
6653 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6654 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6656 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6657 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6659 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6660 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6662 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
6666 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
6670 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
6674 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
6679 if(playerdetail||skeleton.free==3)
6681 for(j=0;j<skeleton.muscles[i].numvertices;j++)
6683 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
6684 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
6685 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
6686 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
6687 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
6688 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
6689 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
6690 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6692 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6693 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,
6694 (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,
6695 (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);
6696 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)
6697 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,
6698 (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,
6699 (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);
6700 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)
6701 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,
6702 (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,
6703 (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);
6704 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6705 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,
6706 (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,
6707 (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);
6708 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6709 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
6710 //if(!isnormal(scale))test=1;
6711 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
6712 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
6713 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
6718 if(!playerdetail||skeleton.free==3)
6720 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
6722 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6724 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6725 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
6726 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
6727 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
6728 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)
6729 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
6730 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
6731 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
6732 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)
6733 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
6734 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
6735 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
6736 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6737 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
6738 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
6739 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
6741 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6742 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
6743 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
6744 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
6750 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
6751 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6753 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6756 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6757 if(!skeleton.free)glRotatef(tilt,0,0,1);
6758 glTranslatef(mid.x,mid.y,mid.z);
6759 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6760 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6762 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6763 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6765 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6766 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6768 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
6769 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6771 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6772 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
6773 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
6774 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
6775 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)
6776 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
6777 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
6778 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
6779 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)
6780 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
6781 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
6782 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
6783 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6784 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
6785 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
6786 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
6787 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6788 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
6789 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
6790 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
6795 updatedelay=1+(float)(Random()%100)/1000;
6797 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
6798 normalsupdatedelay=1;
6799 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
6800 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
6801 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
6805 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
6806 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
6807 if(skeleton.clothes){
6808 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
6813 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
6814 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
6815 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
6816 if(skeleton.free==1)updatedelaychange*=6;
6817 if(id==0)updatedelaychange*=8;
6818 updatedelay+=updatedelaychange;
6820 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6822 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
6823 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
6824 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
6825 if(!skeleton.free)glRotatef(rotation,0,1,0);
6828 glColor4f(.4,1,.4,1);
6829 glDisable(GL_LIGHTING);
6830 glDisable(GL_TEXTURE_2D);
6833 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6834 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
6840 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
6841 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);
6842 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);
6843 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);
6844 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);
6845 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);
6846 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);
6852 terrainlight=terrain.getLighting(coords.x,coords.z);
6853 distance=findDistancefast(&viewer,&coords);
6854 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
6855 if(distance>1)distance=1;
6857 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
6858 if(terrainheight<1)terrainheight=1;
6859 if(terrainheight>1.7)terrainheight=1.7;
6862 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
6863 glDisable(GL_BLEND);
6864 glAlphaFunc(GL_GREATER, 0.0001);
6865 glEnable(GL_TEXTURE_2D);
6867 glDisable(GL_TEXTURE_2D);
6868 glColor4f(.7,.35,0,.5);
6870 glEnable(GL_LIGHTING);
6873 if(tutoriallevel&&id!=0){
6874 //glDisable(GL_TEXTURE_2D);
6875 glColor4f(.7,.7,.7,0.6);
6877 glEnable(GL_LIGHTING);
6879 if(canattack&&cananger)
6880 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
6881 glDisable(GL_TEXTURE_2D);
6882 glColor4f(1,0,0,0.8);
6884 glMatrixMode(GL_TEXTURE);
6886 glTranslatef(0,-smoketex,0);
6887 glTranslatef(-smoketex,0,0);
6891 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
6892 else skeleton.drawmodel.draw();
6896 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
6897 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
6900 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
6901 if(tutoriallevel&&id!=0){
6903 glMatrixMode(GL_MODELVIEW);
6904 glEnable(GL_TEXTURE_2D);
6905 glColor4f(.7,.7,.7,0.6);
6907 glEnable(GL_LIGHTING);
6909 if(canattack&&cananger)
6910 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
6911 glDisable(GL_TEXTURE_2D);
6912 glColor4f(1,0,0,0.8);
6914 glMatrixMode(GL_TEXTURE);
6916 glTranslatef(0,-smoketex*.6,0);
6917 glTranslatef(smoketex*.6,0,0);
6920 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
6921 else skeleton.drawmodel.draw();
6925 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
6926 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
6931 if(tutoriallevel&&id!=0){
6933 glMatrixMode(GL_MODELVIEW);
6934 glEnable(GL_TEXTURE_2D);
6936 if(skeleton.clothes){
6939 if(!immediate)skeleton.drawmodelclothes.draw();
6940 if(immediate)skeleton.drawmodelclothes.drawimmediate();
6947 for(k=0;k<num_weapons;k++){
6949 if(weaponactive==k){
6950 if(weapons.type[i]!=staff){
6951 for(j=0;j<skeleton.num_muscles;j++){
6952 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
6953 weaponattachmuscle=j;
6956 for(j=0;j<skeleton.num_muscles;j++){
6957 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){
6958 weaponrotatemuscle=j;
6961 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
6962 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
6964 if(weapons.type[i]==staff){
6965 for(j=0;j<skeleton.num_muscles;j++){
6966 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
6967 weaponattachmuscle=j;
6970 for(j=0;j<skeleton.num_muscles;j++){
6971 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){
6972 weaponrotatemuscle=j;
6975 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
6976 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
6977 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
6978 XYZ tempnormthing,vec1,vec2;
6979 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
6980 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
6981 CrossProduct(&vec1,&vec2,&tempnormthing);
6982 Normalise(&tempnormthing);
6983 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);
6984 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
6986 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
6987 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6988 Normalise(&weaptargnorm);
6989 weaponpoint-=weaptargnorm*2;
6993 if(weaponactive!=k&&weaponstuck!=k){
6994 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;
6995 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;
6996 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;
6997 for(j=0;j<skeleton.num_muscles;j++){
6998 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){
6999 weaponrotatemuscle=j;
7004 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7005 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7006 for(j=0;j<skeleton.num_muscles;j++){
7007 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){
7008 weaponrotatemuscle=j;
7013 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;
7014 weapons.bigrotation[i]=rotation;
7015 weapons.bigtilt[i]=tilt;
7016 weapons.bigtilt2[i]=tilt2;
7019 weapons.position[i]=weaponpoint*scale+coords;
7020 weapons.bigrotation[i]=0;
7021 weapons.bigtilt[i]=0;
7022 weapons.bigtilt2[i]=0;
7024 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7025 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7026 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7027 if(weaponactive==k){
7028 if(weapons.type[i]==knife){
7029 weapons.smallrotation[i]=180;
7030 weapons.smallrotation2[i]=0;
7031 if(isCrouch()||wasCrouch()){
7032 weapons.smallrotation2[i]=20;
7034 if(targetanimation==hurtidleanim){
7035 weapons.smallrotation2[i]=50;
7037 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7038 XYZ temppoint1,temppoint2,tempforward;
7041 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7042 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7043 distance=findDistance(&temppoint1,&temppoint2);
7044 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7045 weapons.rotation2[i]*=360/6.28;
7048 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7049 weapons.rotation1[i]*=360/6.28;
7050 weapons.rotation3[i]=0;
7051 weapons.smallrotation[i]=-90;
7052 weapons.smallrotation2[i]=0;
7053 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7055 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7056 XYZ temppoint1,temppoint2,tempforward;
7059 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7060 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7061 distance=findDistance(&temppoint1,&temppoint2);
7062 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7063 weapons.rotation2[i]*=360/6.28;
7066 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7067 weapons.rotation1[i]*=360/6.28;
7068 weapons.rotation3[i]=0;
7069 weapons.smallrotation[i]=90;
7070 weapons.smallrotation2[i]=0;
7071 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7073 if(targetanimation==knifethrowanim){
7074 weapons.smallrotation[i]=90;
7075 //weapons.smallrotation2[i]=-90;
7076 weapons.smallrotation2[i]=0;
7077 weapons.rotation1[i]=0;
7078 weapons.rotation2[i]=0;
7079 weapons.rotation3[i]=0;
7081 if(targetanimation==knifesneakattackanim&&targetframe<5){
7082 weapons.smallrotation[i]=-90;
7083 weapons.rotation1[i]=0;
7084 weapons.rotation2[i]=0;
7085 weapons.rotation3[i]=0;
7088 if(weapons.type[i]==sword){
7089 weapons.smallrotation[i]=0;
7090 weapons.smallrotation2[i]=0;
7091 if(targetanimation==knifethrowanim){
7092 weapons.smallrotation[i]=-90;
7093 weapons.smallrotation2[i]=0;
7094 weapons.rotation1[i]=0;
7095 weapons.rotation2[i]=0;
7096 weapons.rotation3[i]=0;
7098 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)){
7099 XYZ temppoint1,temppoint2,tempforward;
7102 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7103 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7104 distance=findDistance(&temppoint1,&temppoint2);
7105 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7106 weapons.rotation2[i]*=360/6.28;
7109 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7110 weapons.rotation1[i]*=360/6.28;
7111 weapons.rotation3[i]=0;
7112 weapons.smallrotation[i]=90;
7113 weapons.smallrotation2[i]=0;
7114 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7117 if(weapons.type[i]==staff){
7118 weapons.smallrotation[i]=100;
7119 weapons.smallrotation2[i]=0;
7120 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7121 XYZ temppoint1,temppoint2,tempforward;
7124 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7125 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7126 distance=findDistance(&temppoint1,&temppoint2);
7127 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7128 weapons.rotation2[i]*=360/6.28;
7131 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7132 weapons.rotation1[i]*=360/6.28;
7133 weapons.rotation3[i]=0;
7134 weapons.smallrotation[i]=90;
7135 weapons.smallrotation2[i]=0;
7136 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7140 if(weaponactive!=k&&weaponstuck!=k){
7141 if(weapons.type[i]==knife){
7142 weapons.smallrotation[i]=-70;
7143 weapons.smallrotation2[i]=10;
7145 if(weapons.type[i]==sword){
7146 weapons.smallrotation[i]=-100;
7147 weapons.smallrotation2[i]=-8;
7149 if(weapons.type[i]==staff){
7150 weapons.smallrotation[i]=-100;
7151 weapons.smallrotation2[i]=-8;
7155 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7156 else weapons.smallrotation[i]=0;
7157 weapons.smallrotation2[i]=10;
7164 if(skeleton.free)calcrot=1;
7165 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7166 if(currentanimation!=targetanimation)calcrot=1;
7167 //if(id==0)calcrot=1;
7168 if(skeleton.free==2)calcrot=0;
7174 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7177 static float distance;
7178 static float olddistance;
7179 static int intersecting;
7180 static int firstintersecting;
7183 static XYZ start,end;
7184 static float slopethreshold=-.4;
7186 firstintersecting=-1;
7190 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7191 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7193 for (j=0;j<model->TriangleNum;j++){
7194 if(model->facenormals[j].y<=slopethreshold){
7196 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)));
7197 if(distance<radius){
7198 point=*p1-model->facenormals[j]*distance;
7199 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;
7200 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7201 &model->vertex[model->Triangles[j].vertex[1]],
7203 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7204 &model->vertex[model->Triangles[j].vertex[2]],
7206 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7207 &model->vertex[model->Triangles[j].vertex[2]],
7210 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7214 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)){
7215 p1->y=point.y+radius;
7216 if((targetanimation==jumpdownanim||isFlip())){
7217 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7219 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7225 OPENAL_SetPaused(channels[whooshsound], true);
7226 OPENAL_SetVolume(channels[whooshsound], 0);
7229 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7230 if(isFlip())jumppower=-4;
7231 targetanimation=getLanding();
7240 PlaySoundEx( landsound, samp[landsound], NULL, true);
7241 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7242 OPENAL_SetVolume(channels[landsound], 128);
7243 OPENAL_SetPaused(channels[landsound], false);
7246 envsound[numenvsounds]=coords;
7247 envsoundvol[numenvsounds]=16;
7248 envsoundlife[numenvsounds]=.4;
7256 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7259 for (j=0;j<model->TriangleNum;j++){
7260 if(model->facenormals[j].y>slopethreshold){
7264 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)));
7265 if(distance<radius*.5){
7266 point=start-model->facenormals[j]*distance;
7267 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;
7268 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,
7269 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7270 p1->x, p1->y, p1->z, radius/2);
7271 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,
7272 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7273 p1->x, p1->y, p1->z, radius/2);
7274 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,
7275 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7276 p1->x, p1->y, p1->z, radius/2);
7278 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7279 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7281 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7282 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7284 *p1+=model->facenormals[j]*(distance-radius*.5);
7287 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7291 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7293 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7295 return firstintersecting;
7305 currentanimation = 0;
7306 targetanimation = 0;
7307 oldcurrentframe = 0;
7309 oldcurrentanimation = 0;
7310 oldtargetanimation = 0;
7314 parriedrecently = 0;
7318 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7320 currentoffset = 0,targetoffset = 0,offset = 0;
7338 unconscioustime = 0;
7356 rabbitkickenabled = 0;
7365 damagetolerance = 0;
7367 permanentdamage = 0;
7368 superpermanentdamage = 0; lastcollide = 0;
7388 headrotation = 0,headrotation2 = 0;
7389 targetheadrotation = 0,targetheadrotation2 = 0;
7400 normalsupdatedelay = 0;
7405 forwardstogglekeydown = 0;
7410 jumptogglekeydown = 0;
7412 crouchtogglekeydown = 0;
7414 drawtogglekeydown = 0;
7416 throwtogglekeydown = 0;
7422 crouchkeydowntime = 0;
7423 jumpkeydowntime = 0;
7440 whichdirectiondelay = 0;
7441 avoidsomething = 0; avoidwhere = 0;
7449 lefthandmorphness = 0;
7450 righthandmorphness = 0;
7454 targetlefthandmorphness = 0;
7455 targetrighthandmorphness = 0;
7456 targetheadmorphness = 0;
7457 targetchestmorphness = 0;
7458 targettailmorphness = 0;
7459 lefthandmorphstart = 0,lefthandmorphend = 0;
7460 righthandmorphstart = 0,righthandmorphend = 0;
7461 headmorphstart = 0,headmorphend = 0;
7462 chestmorphstart = 0,chestmorphend = 0;
7463 tailmorphstart = 0,tailmorphend = 0;
7465 weaponmissdelay = 0;
7466 highreversaldelay = 0;
7467 lowreversaldelay = 0;
7474 //Skeleton skeleton;
7493 memset(clothes, 0, sizeof(clothes));
7494 memset(clothestintr, 0, sizeof(clothestintr));
7495 memset(clothestintg, 0, sizeof(clothestintg));
7496 memset(clothestintb, 0, sizeof(clothestintb));
7502 onfiredelay = 0; burnt = 0;
7506 updatestuffdelay = 0;
7512 memset(weaponids, 0, sizeof(weaponids));
7516 weaponstuckwhere = 0;
7521 memset(waypoints, 0, sizeof(waypoints));
7522 memset(waypointtype, 0, sizeof(waypointtype));
7525 hastempwaypoint = 0;
7531 finalfinaltarget = 0;
7533 finalpathfindpoint = 0;
7534 targetpathfindpoint = 0;
7535 lastpathfindpoint = 0;
7536 lastpathfindpoint2 = 0;
7537 lastpathfindpoint3 = 0;
7538 lastpathfindpoint4 = 0;
7549 runninghowlong = 0; lastoccluded = 0;
7555 neckspurtparticledelay = 0;
7556 neckspurtamount = 0;
7559 rabbitkickragdoll = 0;
7564 //Animation tempanimation;