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;
360 void SolidHitBonus(){
361 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
362 award_bonus(0, megacombo);
364 else if(bonustime<1.5&&bonus==threexcombo){
365 award_bonus(0, fourxcombo);
367 else if(bonustime<1.5&&bonus==twoxcombo){
368 award_bonus(0, threexcombo);
370 else if(bonustime<1.5&&bonus==solidhit){
371 award_bonus(0, twoxcombo);
374 award_bonus(0, solidhit);
378 void Person::DoBlood(float howmuch,int which){
379 static int bleedxint,bleedyint;
381 //if(howmuch&&id==0)blooddimamount=1;
382 if(bloodtoggle&&tutoriallevel!=1){
383 if(bleeding<=0&&spurt){
385 for(int i=0;i<3;i++){
389 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
392 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
394 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
395 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
397 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
398 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
401 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);
402 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);
406 for(int i=0;i<3;i++){
410 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
411 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
414 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
415 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
419 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
421 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);
423 Sprite::setLastSpriteSpecial(3);
428 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
431 int texdetailint=realtexdetail;
432 if(creature==rabbittype)
433 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){
434 bleedxint=abs(Random()%512);
435 bleedyint=abs(Random()%512);
437 if(creature==wolftype)
438 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){
439 bleedxint=abs(Random()%512);
440 bleedyint=abs(Random()%512);
444 bleedy/=realtexdetail;
445 bleedx/=realtexdetail;
446 direction=abs(Random()%2)*2-1;
450 if(bleeding>2)bleeding=2;
453 void Person::DoBloodBig(float howmuch,int which){
454 static int bleedxint,bleedyint,i,j;
456 if(howmuch&&id==0)blooddimamount=1;
458 if(tutoriallevel!=1||id==0)
459 if(aitype!=playercontrolled&&howmuch>0){
470 if(creature==wolftype){
471 int i=abs(Random()%2);
472 if(i==0)whichsound=snarlsound;
473 if(i==1)whichsound=snarl2sound;
474 envsound[numenvsounds]=coords;
475 envsoundvol[numenvsounds]=16;
476 envsoundlife[numenvsounds]=.4;
479 if(creature==rabbittype){
480 int i=abs(Random()%2);
481 if(i==0)whichsound=rabbitpainsound;
482 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
483 envsound[numenvsounds]=coords;
484 envsoundvol[numenvsounds]=16;
485 envsoundlife[numenvsounds]=.4;
487 //if(i==2)whichsound=rabbitpain2sound;
491 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
492 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
493 OPENAL_SetVolume(channels[whichsound], 512);
494 OPENAL_SetPaused(channels[whichsound], false);
498 if(id==0&&howmuch>0){
506 if(bloodtoggle&&decals&&tutoriallevel!=1){
507 if(bleeding<=0&&spurt){
509 for(int i=0;i<3;i++){
513 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
516 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
518 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
519 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
521 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
522 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
525 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);
526 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);
530 int offsetx=0,offsety=0;
533 offsetx=abs(Random()%60);
535 if(which==190||which==185){
537 offsetx=abs(Random()%100)-20;
547 if(which==220||which==215){
548 //offsety=Random()%20;
550 //offsetx=abs(Random()%80);
559 if(creature==rabbittype)
562 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
563 if(i<startx)startx=i;
564 if(j<starty)starty=j;
570 if(creature==wolftype)
573 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
574 if(i<startx)startx=i;
575 if(j<starty)starty=j;
587 if(startx<0)startx=0;
588 if(starty<0)starty=0;
589 if(endx>512-1)endx=512-1;
590 if(endy>512-1)endy=512-1;
591 if(endx<startx)endx=startx;
592 if(endy<starty)endy=starty;
594 startx/=realtexdetail;
595 starty/=realtexdetail;
599 int texdetailint=realtexdetail;
601 if(creature==rabbittype)
602 for(i=startx;i<endx;i++){
603 for(j=starty;j<endy;j++){
604 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){
605 color=Random()%85+170;
606 where=i*skeleton.skinsize*3+j*3;
607 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
608 skeleton.skinText[where+1]=0;
609 skeleton.skinText[where+2]=0;
613 if(creature==wolftype)
614 for(i=startx;i<endx;i++){
615 for(j=starty;j<endy;j++){
616 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){
617 color=Random()%85+170;
618 where=i*skeleton.skinsize*3+j*3;
619 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
620 skeleton.skinText[where+1]=0;
621 skeleton.skinText[where+2]=0;
625 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
626 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
627 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
631 if(creature==rabbittype)
632 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){
633 bleedxint=abs(Random()%512);
634 bleedyint=abs(Random()%512);
636 if(creature==wolftype)
637 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){
638 bleedxint=abs(Random()%512);
639 bleedyint=abs(Random()%512);
641 bleedy=bleedxint+offsetx;
642 bleedx=bleedyint+offsety;
643 bleedy/=realtexdetail;
644 bleedx/=realtexdetail;
645 if(bleedx<0)bleedx=0;
646 if(bleedy<0)bleedy=0;
647 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
648 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
649 direction=abs(Random()%2)*2-1;
652 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
653 deathbleeding+=bleeding;
654 bloodloss+=bleeding*3;
656 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
657 if(abs(Random()%2)==0){aitype=gethelptype;
660 else aitype=attacktypecutoff;
663 if(bleeding>2)bleeding=2;
666 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
667 static int bleedxint,bleedyint,i,j;
669 static XYZ startpoint,endpoint,colpoint,movepoint;
670 static float rotationpoint;
672 static XYZ p1,p2,p3,p0;
676 float coordsx,coordsy;
679 if(bloodtoggle&&decals&&tutoriallevel!=1){
681 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
689 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
692 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
693 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
694 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
696 CrossProduct(p2-p1,p3-p1,&N);
697 CrossProduct(p0-p1,p3-p1,&temp);
698 s = dotproduct(&temp,&N)/findLength(&N);
699 CrossProduct(p2-p1,p1-p0,&temp);
700 t = dotproduct(&temp,&N)/findLength(&N);
703 bary.x=findDistancefast(&p0,&p1);
704 bary.y=findDistancefast(&p0,&p2);
705 bary.z=findDistancefast(&p0,&p3);
707 total=bary.x+bary.y+bary.z;
716 total=bary.x+bary.y+bary.z;
722 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
723 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
724 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
725 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
726 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
727 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
728 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;
729 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;
731 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
732 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
734 if(bleeding<=0&&spurt){
736 for(int i=0;i<3;i++){
740 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
743 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
745 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
746 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
748 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
749 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
752 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);
753 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);
757 int offsetx=0,offsety=0;
760 offsetx=abs(Random()%120);
762 if(which==220||which==215){
764 offsetx=abs(Random()%80);
767 offsetx=(1+coordsy)*512-291;
768 offsety=coordsx*512-437;
775 if(creature==rabbittype)
778 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
779 if(i<startx)startx=i;
780 if(j<starty)starty=j;
786 if(creature==wolftype)
789 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
790 if(i<startx)startx=i;
791 if(j<starty)starty=j;
802 if(startx<0)startx=0;
803 if(starty<0)starty=0;
804 if(endx>512-1)endx=512-1;
805 if(endy>512-1)endy=512-1;
806 if(endx<startx)endx=startx;
807 if(endy<starty)endy=starty;
809 startx/=realtexdetail;
810 starty/=realtexdetail;
814 int texdetailint=realtexdetail;
816 if(creature==rabbittype)
817 for(i=startx;i<endx;i++){
818 for(j=starty;j<endy;j++){
819 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){
820 color=Random()%85+170;
821 where=i*skeleton.skinsize*3+j*3;
822 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
823 skeleton.skinText[where+1]=0;
824 skeleton.skinText[where+2]=0;
826 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){
827 color=Random()%85+170;
828 where=i*skeleton.skinsize*3+j*3;
829 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
830 skeleton.skinText[where+1]=0;
831 skeleton.skinText[where+2]=0;
835 if(creature==wolftype)
836 for(i=startx;i<endx;i++){
837 for(j=starty;j<endy;j++){
838 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){
839 color=Random()%85+170;
840 where=i*skeleton.skinsize*3+j*3;
841 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
842 skeleton.skinText[where+1]=0;
843 skeleton.skinText[where+2]=0;
845 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){
846 color=Random()%85+170;
847 where=i*skeleton.skinsize*3+j*3;
848 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
849 skeleton.skinText[where+1]=0;
850 skeleton.skinText[where+2]=0;
854 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
855 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
856 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
858 bleedy=(1+coordsy)*512;
860 bleedy/=realtexdetail;
861 bleedx/=realtexdetail;
862 if(bleedx<0)bleedx=0;
863 if(bleedy<0)bleedy=0;
864 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
865 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
866 direction=abs(Random()%2)*2-1;
868 if(whichtri==-1)return 0;
870 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
871 deathbleeding+=bleeding;
872 bloodloss+=bleeding*3;
874 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
875 if(abs(Random()%2)==0){aitype=gethelptype;
878 else aitype=attacktypecutoff;
881 if(bleeding>2)bleeding=2;
886 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
889 static int bytesPerPixel=3;
890 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
891 static int newstartx,newstarty,newendx,newendy;
892 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
894 static float sizemult;
896 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
897 texture[i]=skeleton.skinText[i];
900 if((!osx||howmanylevels)){
902 if(startx<0)startx=0;
903 if(starty<0)starty=0;
904 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
905 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
906 if((endx>startx&&endy>starty)||howmanylevels){
913 for(i=startx;i<endx;i++){
914 for(j=starty;j<endy;j++){
915 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
916 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
917 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
921 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
924 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
925 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
926 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
929 newsize=skeleton.skinsize;
932 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
934 /*for(j=1;j<=howmanylevels;j++){
935 if(j==1)texpointer=&skeleton.skinText[0];
936 else texpointer=&texture[0];
938 totalsize=int( newsize*newsize*bytesPerPixel);
939 rowsize=int( newsize*bytesPerPixel );
940 bigstep=bytesPerPixel*newsize*2;
941 smallstep=bytesPerPixel*2;
947 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
954 void Person::Reverse(){
955 if(victim->aitype==playercontrolled||hostiletime>1)
956 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
957 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
958 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
959 if(targetanimation==sweepanim){
960 targetanimation=sweepreversedanim;
961 currentanimation=sweepreversedanim;
962 victim->currentanimation=sweepreversalanim;
963 victim->targetanimation=sweepreversalanim;
965 if(targetanimation==spinkickanim){
966 targetanimation=spinkickreversedanim;
967 currentanimation=spinkickreversedanim;
968 victim->currentanimation=spinkickreversalanim;
969 victim->targetanimation=spinkickreversalanim;
971 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
972 if(targetanimation==rabbittacklinganim){
975 victim->currentframe=6;
976 victim->targetframe=7;
978 targetanimation=upunchreversedanim;
979 currentanimation=upunchreversedanim;
980 victim->currentanimation=upunchreversalanim;
981 victim->targetanimation=upunchreversalanim;
983 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
984 if(victim->weaponactive!=-1){
985 victim->throwtogglekeydown=1;
986 weapons.owner[victim->weaponids[0]]=-1;
987 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
988 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
989 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
990 weapons.missed[victim->weaponids[0]]=1;
991 weapons.freetime[victim->weaponids[0]]=0;
992 weapons.firstfree[victim->weaponids[0]]=1;
993 weapons.physics[victim->weaponids[0]]=1;
994 victim->num_weapons--;
995 if(victim->num_weapons){
996 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
997 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1000 victim->weaponactive=-1;
1001 for(int j=0;j<numplayers;j++){
1002 player[j].wentforweapon=0;
1006 targetanimation=staffhitreversedanim;
1007 currentanimation=staffhitreversedanim;
1008 victim->currentanimation=staffhitreversalanim;
1009 victim->targetanimation=staffhitreversalanim;
1011 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1012 if(victim->weaponactive!=-1){
1013 victim->throwtogglekeydown=1;
1014 weapons.owner[victim->weaponids[0]]=-1;
1015 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1016 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1017 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1018 weapons.missed[victim->weaponids[0]]=1;
1019 weapons.freetime[victim->weaponids[0]]=0;
1020 weapons.firstfree[victim->weaponids[0]]=1;
1021 weapons.physics[victim->weaponids[0]]=1;
1022 victim->num_weapons--;
1023 if(victim->num_weapons){
1024 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1025 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1028 victim->weaponactive=-1;
1029 for(int j=0;j<numplayers;j++){
1030 player[j].wentforweapon=0;
1033 targetanimation=staffspinhitreversedanim;
1034 currentanimation=staffspinhitreversedanim;
1035 victim->currentanimation=staffspinhitreversalanim;
1036 victim->targetanimation=staffspinhitreversalanim;
1038 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1039 if(victim->weaponactive!=-1){
1040 victim->throwtogglekeydown=1;
1041 weapons.owner[victim->weaponids[0]]=-1;
1042 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1043 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1044 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1045 weapons.missed[victim->weaponids[0]]=1;
1046 weapons.freetime[victim->weaponids[0]]=0;
1047 weapons.firstfree[victim->weaponids[0]]=1;
1048 weapons.physics[victim->weaponids[0]]=1;
1049 victim->num_weapons--;
1050 if(victim->num_weapons){
1051 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1052 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1055 victim->weaponactive=-1;
1056 for(int j=0;j<numplayers;j++){
1057 player[j].wentforweapon=0;
1060 targetanimation=swordslashreversedanim;
1061 currentanimation=swordslashreversedanim;
1062 victim->currentanimation=swordslashreversalanim;
1063 victim->targetanimation=swordslashreversalanim;
1065 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1066 if(victim->weaponactive!=-1){
1067 victim->throwtogglekeydown=1;
1068 weapons.owner[victim->weaponids[0]]=-1;
1069 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1070 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1071 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1072 weapons.missed[victim->weaponids[0]]=1;
1073 weapons.freetime[victim->weaponids[0]]=0;
1074 weapons.firstfree[victim->weaponids[0]]=1;
1075 weapons.physics[victim->weaponids[0]]=1;
1076 victim->num_weapons--;
1077 if(victim->num_weapons){
1078 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1079 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1082 victim->weaponactive=-1;
1083 for(int j=0;j<numplayers;j++){
1084 player[j].wentforweapon=0;
1087 targetanimation=knifeslashreversedanim;
1088 currentanimation=knifeslashreversedanim;
1089 victim->currentanimation=knifeslashreversalanim;
1090 victim->targetanimation=knifeslashreversalanim;
1092 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1093 victim->targettilt2=targettilt2;
1094 victim->currentframe=currentframe;
1095 victim->targetframe=targetframe;
1096 victim->target=target;
1098 victim->oldcoords=victim->coords;
1099 victim->coords=coords;
1100 victim->targetrotation=targetrotation;
1101 victim->rotation=targetrotation;
1102 victim->victim=this;
1104 if(targetanimation==winduppunchanim){
1105 targetanimation=winduppunchblockedanim;
1106 victim->targetanimation=blockhighleftanim;
1107 victim->targetframe=1;
1109 victim->victim=this;
1110 victim->targetrotation=targetrotation+180;
1112 if(targetanimation==wolfslapanim){
1113 targetanimation=winduppunchblockedanim;
1114 victim->targetanimation=blockhighleftanim;
1115 victim->targetframe=1;
1117 victim->victim=this;
1118 victim->targetrotation=targetrotation+180;
1120 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1121 targetanimation=swordslashparriedanim;
1123 victim->parriedrecently=0;
1124 victim->targetanimation=swordslashparryanim;
1125 victim->targetframe=1;
1127 victim->victim=this;
1128 victim->targetrotation=targetrotation+180;
1130 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1133 gLoc[0]=victim->coords.x;
1134 gLoc[1]=victim->coords.y;
1135 gLoc[2]=victim->coords.z;
1139 if(victim->weaponactive!=-1){
1140 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1141 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1142 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1144 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1145 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1146 OPENAL_SetVolume(channels[swordstaffsound], 512);
1147 OPENAL_SetPaused(channels[swordstaffsound], false);
1150 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1151 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1152 OPENAL_SetVolume(channels[metalhitsound], 512);
1153 OPENAL_SetPaused(channels[metalhitsound], false);
1157 victim->Puff(righthand);
1159 victim->targetframe=0;
1160 victim->targetanimation=staggerbackhighanim;
1161 victim->targetrotation=targetrotation+180;
1163 weapons.owner[victim->weaponids[0]]=-1;
1164 aim=DoRotation(facing,0,90,0)*21;
1166 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1167 weapons.tipvelocity[victim->weaponids[0]]=aim;
1168 weapons.missed[victim->weaponids[0]]=1;
1169 weapons.hitsomething[victim->weaponids[0]]=0;
1170 weapons.freetime[victim->weaponids[0]]=0;
1171 weapons.firstfree[victim->weaponids[0]]=1;
1172 weapons.physics[victim->weaponids[0]]=1;
1173 victim->num_weapons--;
1174 if(victim->num_weapons){
1175 victim->weaponids[0]=victim->weaponids[num_weapons];
1176 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1178 victim->weaponactive=-1;
1179 for(int i=0;i<numplayers;i++){
1180 player[i].wentforweapon=0;
1187 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1188 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1189 OPENAL_SetVolume(channels[metalhitsound], 512);
1190 OPENAL_SetPaused(channels[metalhitsound], false);*/
1193 if(abs(Random()%20)==0){
1202 if(weaponactive!=-1){
1203 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1204 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1205 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1207 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1208 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1209 OPENAL_SetVolume(channels[swordstaffsound], 512);
1210 OPENAL_SetPaused(channels[swordstaffsound], false);
1213 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1214 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1215 OPENAL_SetVolume(channels[metalhitsound], 512);
1216 OPENAL_SetPaused(channels[metalhitsound], false);
1224 targetanimation=staggerbackhighanim;
1225 targetrotation=targetrotation+180;
1227 weapons.owner[weaponids[0]]=-1;
1228 aim=DoRotation(facing,0,90,0)*21;
1230 weapons.velocity[weaponids[0]]=aim*-.2;
1231 weapons.tipvelocity[weaponids[0]]=aim;
1232 weapons.hitsomething[weaponids[0]]=0;
1233 weapons.missed[weaponids[0]]=1;
1234 weapons.freetime[weaponids[0]]=0;
1235 weapons.firstfree[weaponids[0]]=1;
1236 weapons.physics[weaponids[0]]=1;
1239 weaponids[0]=weaponids[num_weapons];
1240 if(weaponstuck==num_weapons)weaponstuck=0;
1243 for(int i=0;i<numplayers;i++){
1244 player[i].wentforweapon=0;
1248 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1249 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1250 OPENAL_SetVolume(channels[metalhitsound], 512);
1251 OPENAL_SetPaused(channels[metalhitsound], false);*/
1255 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1256 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1257 //victim->targetanimation=sweepanim;
1258 victim->targetanimation=dodgebackanim;
1259 victim->targetframe=0;
1261 //victim->velocity=0;
1264 rotatetarget=coords-victim->coords;
1265 Normalise(&rotatetarget);
1266 victim->targetrotation=-asin(0-rotatetarget.x);
1267 victim->targetrotation*=360/6.28;
1268 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1270 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1272 victim->lastattack3=victim->lastattack2;
1273 victim->lastattack2=victim->lastattack;
1274 victim->lastattack=victim->targetanimation;
1278 victim->targetanimation=sweepanim;
1279 victim->targetframe=0;
1283 rotatetarget=coords-victim->coords;
1284 Normalise(&rotatetarget);
1285 victim->targetrotation=-asin(0-rotatetarget.x);
1286 victim->targetrotation*=360/6.28;
1287 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1289 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1291 victim->lastattack3=victim->lastattack2;
1292 victim->lastattack2=victim->lastattack;
1293 victim->lastattack=victim->targetanimation;
1300 if(aitype!=playercontrolled)feint=0;
1301 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1302 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1303 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1305 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1309 void Person::DoDamage(float howmuch){
1310 if(tutoriallevel!=1)damage+=howmuch/power;
1311 if(id!=0)damagedealt+=howmuch/power;
1312 if(id==0)damagetaken+=howmuch/power;
1314 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1315 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1316 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1317 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1318 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1320 if(id==0)camerashake+=howmuch/100;
1321 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1322 if(blackout>1)blackout=1;
1324 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1325 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1326 if(abs(Random()%2)==0){aitype=gethelptype;
1329 else aitype=attacktypecutoff;
1333 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1336 for(int i=0;i<skeleton.num_joints; i++){
1337 if(!skeleton.free)flatvelocity2=velocity;
1338 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1339 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1340 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1341 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1342 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1343 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1344 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1345 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1346 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1357 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1358 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1359 OPENAL_SetVolume(channels[splattersound], 256);
1360 OPENAL_SetPaused(channels[splattersound], false);
1369 if(!dead&&creature==wolftype){
1370 award_bonus(0, Wolfbonus);
1376 if(tutoriallevel!=1||id==0)
1377 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1388 if(creature==wolftype){
1389 int i=abs(Random()%2);
1390 if(i==0)whichsound=snarlsound;
1391 if(i==1)whichsound=snarl2sound;
1392 envsound[numenvsounds]=coords;
1393 envsoundvol[numenvsounds]=16;
1394 envsoundlife[numenvsounds]=.4;
1397 if(creature==rabbittype){
1398 int i=abs(Random()%2);
1399 if(i==0)whichsound=rabbitpainsound;
1400 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1401 envsound[numenvsounds]=coords;
1402 envsoundvol[numenvsounds]=16;
1403 envsoundlife[numenvsounds]=.4;
1405 //if(i==2)whichsound=rabbitpain2sound;
1409 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1410 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1411 OPENAL_SetVolume(channels[whichsound], 512);
1412 OPENAL_SetPaused(channels[whichsound], false);
1417 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1418 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1421 void Person::DoHead(){
1422 static XYZ rotatearound;
1424 static float lookspeed=500;
1426 if(!freeze&&!winfreeze){
1429 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1430 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1432 while(targetheadrotation>180)targetheadrotation-=360;
1433 while(targetheadrotation<-180)targetheadrotation+=360;
1435 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1436 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1437 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1438 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1440 if(targetheadrotation2>120)targetheadrotation2=120;
1441 if(targetheadrotation2<-120)targetheadrotation2=-120;
1442 if(targetheadrotation>120)targetheadrotation=120;
1443 if(targetheadrotation<-120)targetheadrotation=-120;
1445 if(!isIdle())targetheadrotation2=0;
1447 if(targetheadrotation>80)targetheadrotation=80;
1448 if(targetheadrotation<-80)targetheadrotation=-80;
1449 if(targetheadrotation2>50)targetheadrotation2=50;
1450 if(targetheadrotation2<-50)targetheadrotation2=-50;
1453 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1454 else if(headrotation>targetheadrotation){
1455 headrotation-=multiplier*lookspeed;
1457 else if(headrotation<targetheadrotation){
1458 headrotation+=multiplier*lookspeed;
1461 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1462 else if(headrotation2>targetheadrotation2){
1463 headrotation2-=multiplier*lookspeed/2;
1465 else if(headrotation2<targetheadrotation2){
1466 headrotation2+=multiplier*lookspeed/2;
1469 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1470 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1474 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1475 facing=DoRotation(facing,headrotation2*.4,0,0);
1476 facing=DoRotation(facing,0,headrotation*.4,0);
1479 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1480 facing=DoRotation(facing,headrotation2*.8,0,0);
1481 facing=DoRotation(facing,0,headrotation*.8,0);
1484 if(targetanimation==walkanim){
1485 facing=DoRotation(facing,headrotation2*.6,0,0);
1486 facing=DoRotation(facing,0,headrotation*.6,0);
1489 skeleton.specialforward[0]=facing;
1490 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1492 for(i=0;i<skeleton.num_muscles;i++){
1493 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1495 skeleton.FindRotationMuscle(i,targetanimation);
1501 void Person::RagDoll(bool checkcollision){
1506 if(id==0)numfalls++;
1507 if(id==0&&isFlip())numflipfail++;
1513 facing=DoRotation(facing,0,rotation,0);
1515 skeleton.freetime=0;
1517 skeleton.longdead=0;
1523 skeleton.freefall=1;
1525 if(!isnormal(velocity.x))velocity.x=0;
1526 if(!isnormal(velocity.y))velocity.y=0;
1527 if(!isnormal(velocity.z))velocity.z=0;
1528 if(!isnormal(rotation))rotation=0;
1529 if(!isnormal(coords.x))coords=0;
1530 if(!isnormal(tilt))tilt=0;
1531 if(!isnormal(tilt2))tilt2=0;
1533 for(i=0;i<skeleton.num_joints;i++){
1534 skeleton.joints[i].delay=0;
1535 skeleton.joints[i].locked=0;
1536 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1537 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1538 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1539 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1540 skeleton.joints[i].position.y+=.1;
1541 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1542 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1545 for(i=0;i<skeleton.num_joints;i++){
1546 skeleton.joints[i].velocity=0;
1547 skeleton.joints[i].velchange=0;
1549 skeleton.DoConstraints(&coords,&scale);
1550 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1552 skeleton.DoConstraints(&coords,&scale);
1553 skeleton.DoConstraints(&coords,&scale);
1554 skeleton.DoConstraints(&coords,&scale);
1555 skeleton.DoConstraints(&coords,&scale);
1558 speed=animation[targetanimation].speed[targetframe]*2;
1559 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1560 speed=animation[currentanimation].speed[currentframe]*2;
1562 if(transspeed)speed=transspeed*2;
1566 for(i=0;i<skeleton.num_joints;i++){
1567 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);
1568 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1569 change.x=(float)(Random()%100)/100;
1570 change.y=(float)(Random()%100)/100;
1571 change.z=(float)(Random()%100)/100;
1572 skeleton.joints[i].velocity+=change;
1573 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1575 change.x=(float)(Random()%100)/100;
1576 change.y=(float)(Random()%100)/100;
1577 change.z=(float)(Random()%100)/100;
1578 skeleton.joints[i].velchange+=change;
1579 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1589 for(j=0;j<skeleton.num_joints;j++){
1590 average+=skeleton.joints[j].position;
1594 coords+=average*scale;
1595 for(j=0;j<skeleton.num_joints;j++){
1596 skeleton.joints[j].position-=average;
1599 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1600 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1601 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1602 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1603 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1606 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1607 coords.x=lowpoint.x;
1608 coords.z=lowpoint.z;
1617 for(i=0;i<skeleton.num_joints;i++){
1618 velocity+=skeleton.joints[i].velocity*scale;
1620 velocity/=skeleton.num_joints;
1623 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1624 weapons.owner[weaponids[0]]=-1;
1625 weapons.hitsomething[weaponids[0]]=0;
1626 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1627 weapons.velocity[weaponids[0]].x+=.01;
1628 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1629 weapons.missed[weaponids[0]]=1;
1630 weapons.freetime[weaponids[0]]=0;
1631 weapons.firstfree[weaponids[0]]=1;
1632 weapons.physics[weaponids[0]]=1;
1635 weaponids[0]=weaponids[num_weapons];
1636 if(weaponstuck==num_weapons)weaponstuck=0;
1639 for(i=0;i<numplayers;i++){
1640 player[i].wentforweapon=0;
1645 targetanimation=bounceidleanim;
1646 currentanimation=bounceidleanim;
1654 void Person::FootLand(int which, float opacity){
1655 static XYZ terrainlight;
1656 static XYZ footvel,footpoint;
1657 if(opacity>=1||skiddelay<=0)
1661 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1662 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1663 //footpoint.y=coords.y;
1664 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1666 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1668 if(footvel.y<.8)footvel.y=.8;
1669 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1670 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1671 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1672 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1673 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1674 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1676 else if(environment==grassyenvironment&&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*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5*opacity);
1685 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1687 if(footvel.y<.8)footvel.y=.8;
1688 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1689 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1690 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1691 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1692 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);
1693 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1695 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1698 if(footvel.y<.8)footvel.y=.8;
1699 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1700 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1701 //footpoint.y=coords.y;
1702 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1706 void Person::Puff(int whichlabel){
1707 static XYZ footvel,footpoint;
1710 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1711 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1715 void Person::DoAnimations(){
1718 static float oldtarget;
1720 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1722 if(targetanimation==tempanim||currentanimation==tempanim){
1723 animation[tempanim]=tempanimation;
1725 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1736 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1737 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1739 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1740 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1742 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1747 targfacing=DoRotation(targfacing,0,targetrotation,0);
1749 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1750 else targetanimation=backflipanim;
1751 crouchtogglekeydown=1;
1755 if(id==0)numflipped++;
1758 if(animation[targetanimation].attack!=reversed)feint=0;
1759 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1760 crouchtogglekeydown=0;
1761 if(aitype==playercontrolled)feint=0;
1765 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1766 if(!isFlip())crouchtogglekeydown=1;
1770 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1771 if(detail)normalsupdatedelay=0;
1775 if(targetanimation==rollanim&&targetframe==3&&onfire){
1785 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1786 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1787 OPENAL_SetVolume(channels[fireendsound], 256);
1788 OPENAL_SetPaused(channels[fireendsound], false);
1789 OPENAL_SetPaused(channels[stream_firesound], true);
1793 if(targetanimation==rabbittacklinganim&&targetframe==1){
1794 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1795 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1796 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1797 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1798 else victim->targetanimation=rabbittackledfrontanim;
1799 victim->targetframe=2;
1801 victim->rotation=rotation;
1802 victim->targetrotation=rotation;
1803 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1804 //victim->DoDamage(30);
1805 if(creature==wolftype){
1809 gLoc[0]=victim->coords.x;
1810 gLoc[1]=victim->coords.y;
1811 gLoc[2]=victim->coords.z;
1815 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
1816 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
1817 OPENAL_SetVolume(channels[clawslicesound], 128);
1818 OPENAL_SetPaused(channels[clawslicesound], false);
1820 victim->DoBloodBig(1/victim->armorhead,210);
1822 award_bonus(id, TackleBonus,
1823 victim->aitype == gethelptype ? 50 : 0);
1827 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1828 if(weapons.type[weaponids[0]]==knife){
1829 if(weaponactive==-1)weaponactive=0;
1830 else if(weaponactive==0)weaponactive=-1;
1832 if(weaponactive==-1){
1842 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
1843 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
1844 OPENAL_SetVolume(channels[knifesheathesound], 128);
1845 OPENAL_SetPaused(channels[knifesheathesound], false);
1847 if(weaponactive!=-1){
1857 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1858 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1859 OPENAL_SetVolume(channels[knifedrawsound], 128);
1860 OPENAL_SetPaused(channels[knifedrawsound], false);
1863 drawtogglekeydown=1;
1866 if(tutoriallevel!=1||id==0)
1867 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1878 if(terrain.getOpacity(coords.x,coords.z)<.2){
1879 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1880 else whichsound=footstepsound2;
1881 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1882 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1883 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1889 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1890 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1891 else whichsound=footstepsound4;
1895 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1896 else whichsound=footstepsound4;
1898 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1899 if(animation[targetanimation].attack!=neutral){
1901 if(i==0)whichsound=lowwhooshsound;
1902 if(i==1)whichsound=midwhooshsound;
1903 if(i==2)whichsound=highwhooshsound;
1905 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1907 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1908 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1910 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1911 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1912 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
1913 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
1914 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
1915 OPENAL_SetPaused(channels[whichsound], false);
1918 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1919 envsound[numenvsounds]=coords;
1920 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1921 else envsoundvol[numenvsounds]=6;
1922 envsoundlife[numenvsounds]=.4;
1926 if(animation[targetanimation].label[targetframe]==3){
1928 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1929 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1930 OPENAL_SetVolume(channels[whichsound], 128);
1931 OPENAL_SetPaused(channels[whichsound], false);
1936 if(tutoriallevel!=1||id==0)
1938 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1939 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1949 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1950 if(animation[targetanimation].attack!=neutral){
1952 if(creature==rabbittype){
1953 if(i==0)whichsound=rabbitattacksound;
1954 if(i==1)whichsound=rabbitattack2sound;
1955 if(i==2)whichsound=rabbitattack3sound;
1956 if(i==3)whichsound=rabbitattack4sound;
1958 if(creature==wolftype){
1959 if(i==0)whichsound=barksound;
1960 if(i==1)whichsound=bark2sound;
1961 if(i==2)whichsound=bark3sound;
1962 if(i==3)whichsound=barkgrowlsound;
1966 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1968 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1969 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
1972 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1973 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1974 OPENAL_SetVolume(channels[whichsound], 512);
1975 OPENAL_SetPaused(channels[whichsound], false);
1981 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
1987 currentoffset=targetoffset;
1988 targetframe=currentframe;
1989 currentanimation=targetanimation;
1992 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
1993 for(i=0;i<weapons.numweapons;i++){
1994 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
1995 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
1996 if(findDistancefast(&coords,&weapons.position[i])>=1){
1997 if(weapons.type[i]!=staff){
2006 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2007 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2008 OPENAL_SetVolume(channels[knifedrawsound], 128);
2009 OPENAL_SetPaused(channels[knifedrawsound], false);
2013 weapons.owner[i]=id;
2015 weaponids[num_weapons]=weaponids[0];
2024 static bool willwork;
2025 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2026 for(i=0;i<weapons.numweapons;i++){
2028 if(weapons.owner[i]!=-1)
2029 if(player[weapons.owner[i]].weaponstuck!=-1)
2030 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2031 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2032 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))
2033 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2034 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2044 if(weapons.owner[i]!=-1)
2045 if(victim->weaponstuck!=-1){
2046 if(victim->weaponids[victim->weaponstuck]==i){
2051 if(weapons.type[i]!=staff){
2052 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2053 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2054 OPENAL_SetVolume(channels[knifedrawsound], 128);
2055 OPENAL_SetPaused(channels[knifedrawsound], false);
2059 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2060 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2061 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2062 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2065 if(weapons.owner[i]!=-1){
2067 victim=&player[weapons.owner[i]];
2068 if(victim->num_weapons==1)victim->num_weapons=0;
2069 else victim->num_weapons=1;
2071 //victim->weaponactive=-1;
2072 victim->skeleton.longdead=0;
2073 victim->skeleton.free=1;
2074 victim->skeleton.broken=0;
2076 for(int j=0;j<victim->skeleton.num_joints;j++){
2077 victim->skeleton.joints[j].velchange=0;
2078 victim->skeleton.joints[j].locked=0;
2084 Normalise(&relative);
2085 XYZ footvel,footpoint;
2087 footpoint=weapons.position[i];
2088 if(victim->weaponstuck!=-1){
2089 if(victim->weaponids[victim->weaponstuck]==i){
2090 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2091 weapons.bloody[i]=2;
2092 weapons.blooddrip[i]=5;
2093 victim->weaponstuck=-1;
2096 if(victim->num_weapons>0){
2097 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2098 if(victim->weaponids[0]==i)
2099 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2102 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2103 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2104 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2105 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2107 weapons.owner[i]=id;
2109 weaponids[num_weapons]=weaponids[0];
2118 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2119 if(weaponactive==-1)weaponactive=0;
2120 else if(weaponactive==0){
2124 buffer=weaponids[0];
2125 weaponids[0]=weaponids[1];
2126 weaponids[1]=buffer;
2129 if(weaponactive==-1){
2139 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2140 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2141 OPENAL_SetVolume(channels[knifesheathesound], 128);
2142 OPENAL_SetPaused(channels[knifesheathesound], false);
2144 if(weaponactive!=-1){
2154 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2155 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2156 OPENAL_SetVolume(channels[knifedrawsound], 128);
2157 OPENAL_SetPaused(channels[knifedrawsound], false);
2162 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2163 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2164 Normalise(&rotatetarget);
2165 targetrotation=-asin(0-rotatetarget.x);
2166 targetrotation*=360/6.28;
2167 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2169 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2170 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2175 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2177 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;
2179 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2180 targetanimation=rabbittackleanim;
2191 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2192 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2193 OPENAL_SetVolume(channels[jumpsound], 128);
2194 OPENAL_SetPaused(channels[jumpsound], false);
2203 Normalise(&targetloc);
2205 for(i=0;i<numplayers;i++){
2207 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2208 closestdist=findDistancefast(&targetloc,&player[i].coords);
2213 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2215 victim=&player[closestid];
2216 coords=victim->coords;
2217 currentanimation=rabbittacklinganim;
2218 targetanimation=rabbittacklinganim;
2222 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2223 rotatetarget=coords-victim->coords;
2224 Normalise(&rotatetarget);
2225 targetrotation=-asin(0-rotatetarget.x);
2226 targetrotation*=360/6.28;
2227 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2229 if(targetanimation!=rabbitrunninganim){
2239 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2240 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2241 OPENAL_SetVolume(channels[jumpsound], 128);
2242 OPENAL_SetPaused(channels[jumpsound], false);
2248 float damagemult=1*power;
2249 if(creature==wolftype)damagemult=2.5*power;
2250 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2251 //if(onfire)damagemult=3;
2252 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2253 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2254 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2256 if(id==0)camerashake+=.4;
2257 if(Random()%2||creature==wolftype){
2260 if(creature==wolftype)DoBloodBig(0,250);
2264 gLoc[0]=victim->coords.x;
2265 gLoc[1]=victim->coords.y;
2266 gLoc[2]=victim->coords.z;
2270 if(tutoriallevel!=1){
2271 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2272 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2273 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2274 OPENAL_SetPaused(channels[heavyimpactsound], false);
2276 if(creature==wolftype){
2277 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2278 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2279 OPENAL_SetVolume(channels[clawslicesound], 128);
2280 OPENAL_SetPaused(channels[clawslicesound], false);
2282 victim->DoBloodBig(2/victim->armorhead,175);
2286 relative=victim->coords-coords;
2288 Normalise(&relative);
2289 relative=DoRotation(relative,0,-90,0);
2290 for(i=0;i<victim->skeleton.num_joints;i++){
2291 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2293 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2296 victim->DoDamage(damagemult*100/victim->protectionhead);
2304 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2305 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2307 if(id==0)camerashake+=.4;
2308 if(Random()%2||creature==wolftype){
2310 if(creature==wolftype)DoBloodBig(0,235);
2314 gLoc[0]=victim->coords.x;
2315 gLoc[1]=victim->coords.y;
2316 gLoc[2]=victim->coords.z;
2320 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2321 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2322 OPENAL_SetVolume(channels[whooshhitsound], 512);
2323 OPENAL_SetPaused(channels[whooshhitsound], false);
2324 if(creature==wolftype){
2325 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2326 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2327 OPENAL_SetVolume(channels[clawslicesound], 128);
2328 OPENAL_SetPaused(channels[clawslicesound], false);
2330 victim->DoBloodBig(2,175);
2334 relative=victim->coords-coords;
2336 Normalise(&relative);
2338 Normalise(&relative);
2339 relative=DoRotation(relative,0,90,0);
2340 for(i=0;i<victim->skeleton.num_joints;i++){
2341 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2343 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2346 victim->DoDamage(damagemult*50/victim->protectionhead);
2350 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2351 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2353 if(id==0)camerashake+=.4;
2358 gLoc[0]=victim->coords.x;
2359 gLoc[1]=victim->coords.y;
2360 gLoc[2]=victim->coords.z;
2364 if(tutoriallevel!=1){
2365 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2366 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2367 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2368 OPENAL_SetPaused(channels[heavyimpactsound], false);
2370 if(creature==wolftype){
2371 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2372 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2373 OPENAL_SetVolume(channels[clawslicesound], 128);
2374 OPENAL_SetPaused(channels[clawslicesound], false);
2376 victim->DoBloodBig(2/victim->armorhead,175);
2382 Normalise(&relative);
2383 relative=DoRotation(relative,0,-90,0);
2384 for(i=0;i<victim->skeleton.num_joints;i++){
2385 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2387 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2390 victim->DoDamage(damagemult*150/victim->protectionhead);
2392 if(victim->damage>victim->damagetolerance){
2393 award_bonus(id, style);
2401 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2402 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2404 if(id==0)camerashake+=.4;
2409 gLoc[0]=victim->coords.x;
2410 gLoc[1]=victim->coords.y;
2411 gLoc[2]=victim->coords.z;
2415 if(tutoriallevel!=1){
2416 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2417 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2418 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2419 OPENAL_SetPaused(channels[heavyimpactsound], false);
2421 if(creature==wolftype){
2422 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2423 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2424 OPENAL_SetVolume(channels[clawslicesound], 128);
2425 OPENAL_SetPaused(channels[clawslicesound], false);
2427 victim->DoBloodBig(2/victim->armorhead,175);
2433 Normalise(&relative);
2434 relative=DoRotation(relative,0,90,0);
2435 for(i=0;i<victim->skeleton.num_joints;i++){
2436 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2438 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2441 victim->DoDamage(damagemult*150/victim->protectionhead);
2443 if(victim->damage>victim->damagetolerance){
2444 award_bonus(id, style);
2452 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2453 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2455 if(id==0)camerashake+=.4;
2462 gLoc[0]=victim->coords.x;
2463 gLoc[1]=victim->coords.y;
2464 gLoc[2]=victim->coords.z;
2468 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2469 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2470 OPENAL_SetVolume(channels[whooshhitsound], 512);
2471 OPENAL_SetPaused(channels[whooshhitsound], false);
2474 relative=victim->coords-coords;
2476 Normalise(&relative);
2477 for(i=0;i<victim->skeleton.num_joints;i++){
2478 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2480 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2483 victim->DoDamage(damagemult*50/victim->protectionhead);
2487 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2488 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2490 if(id==0)camerashake+=.2;
2493 gLoc[0]=victim->coords.x;
2494 gLoc[1]=victim->coords.y;
2495 gLoc[2]=victim->coords.z;
2499 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2500 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2501 OPENAL_SetVolume(channels[landsound2], 128);
2502 OPENAL_SetPaused(channels[landsound2], false);
2504 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2505 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2506 OPENAL_SetVolume(channels[movewhooshsound], 128);
2507 OPENAL_SetPaused(channels[movewhooshsound], false);
2509 victim->skeleton.longdead=0;
2510 victim->skeleton.free=1;
2511 victim->skeleton.broken=0;
2512 victim->skeleton.spinny=1;
2514 for(i=0;i<victim->skeleton.num_joints;i++){
2515 victim->skeleton.joints[i].velchange=0;
2516 victim->skeleton.joints[i].delay=0;
2517 victim->skeleton.joints[i].locked=0;
2518 //victim->skeleton.joints[i].velocity=0;
2524 Normalise(&relative);
2525 for(i=0;i<victim->skeleton.num_joints;i++){
2526 victim->skeleton.joints[i].velocity.y=relative.y*10;
2527 victim->skeleton.joints[i].position.y+=relative.y*.3;
2528 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2529 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2531 victim->Puff(abdomen);
2532 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2536 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2537 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2539 if(id==0)camerashake+=.4;
2548 if(tutoriallevel!=1){
2549 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2550 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2551 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2552 OPENAL_SetPaused(channels[heavyimpactsound], false);
2555 relative=victim->coords-coords;
2557 Normalise(&relative);
2558 for(i=0;i<victim->skeleton.num_joints;i++){
2559 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2561 victim->Puff(abdomen);
2562 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2566 victim->DoDamage(damagemult*500/victim->protectionhigh);
2567 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2571 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2572 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2574 if(id==0)camerashake+=.4;
2583 if(tutoriallevel!=1){
2584 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2585 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2586 OPENAL_SetVolume(channels[thudsound], 400);
2587 OPENAL_SetPaused(channels[thudsound], false);
2590 victim->skeleton.longdead=0;
2591 victim->skeleton.free=1;
2592 victim->skeleton.broken=0;
2593 victim->skeleton.spinny=1;
2595 for(i=0;i<victim->skeleton.num_joints;i++){
2596 victim->skeleton.joints[i].velchange=0;
2597 //victim->skeleton.joints[i].delay=0;
2598 victim->skeleton.joints[i].locked=0;
2601 relative=victim->coords-coords;
2602 Normalise(&relative);
2604 Normalise(&relative);
2605 for(i=0;i<victim->skeleton.num_joints;i++){
2606 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2608 if(id==0&&!victim->dead){
2612 victim->Puff(abdomen);
2613 victim->DoDamage(damagemult*20/victim->protectionhigh);
2614 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2616 if(!victim->dead)staggerdelay=1.2;
2622 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2623 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2624 //if(id==0)camerashake+=.4;
2635 if(!victim->skeleton.free)hasvictim=0;
2638 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2639 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2640 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2641 OPENAL_SetVolume(channels[knifesheathesound], 128);
2642 OPENAL_SetPaused(channels[knifesheathesound], false);
2645 if(victim&&hasvictim){
2646 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2648 XYZ where,startpoint,endpoint,movepoint,colpoint;
2649 float rotationpoint;
2651 if(weapons.type[weaponids[weaponactive]]==knife){
2652 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2653 where-=victim->coords;
2654 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2661 if(weapons.type[weaponids[weaponactive]]==sword){
2662 where=weapons.position[weaponids[weaponactive]];
2663 where-=victim->coords;
2664 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2666 where=weapons.tippoint[weaponids[weaponactive]];
2667 where-=victim->coords;
2668 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2671 if(weapons.type[weaponids[weaponactive]]==staff){
2672 where=weapons.position[weaponids[weaponactive]];
2673 where-=victim->coords;
2674 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2676 where=weapons.tippoint[weaponids[weaponactive]];
2677 where-=victim->coords;
2678 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2683 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2686 if(victim->dead!=2){
2687 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2689 award_bonus(id, FinishedBonus);
2691 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2693 victim->skeleton.longdead=0;
2694 victim->skeleton.free=1;
2695 victim->skeleton.broken=0;
2697 for(i=0;i<victim->skeleton.num_joints;i++){
2698 victim->skeleton.joints[i].velchange=0;
2699 victim->skeleton.joints[i].locked=0;
2700 //victim->skeleton.joints[i].velocity=0;
2702 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2703 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2704 OPENAL_SetVolume(channels[fleshstabsound], 128);
2705 OPENAL_SetPaused(channels[fleshstabsound], false);
2708 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2709 weapons.blooddrip[weaponids[weaponactive]]+=5;
2710 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2714 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2715 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2716 OPENAL_SetVolume(channels[knifesheathesound], 128);
2717 OPENAL_SetPaused(channels[knifesheathesound], false);
2723 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2724 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2725 //if(id==0)camerashake+=.4;
2735 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2736 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2737 OPENAL_SetVolume(channels[knifedrawsound], 128);
2738 OPENAL_SetPaused(channels[knifedrawsound], false);
2741 if(victim&&hasvictim){
2742 XYZ footvel,footpoint;
2744 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2745 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2746 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2747 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2750 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2752 if(weapons.type[weaponids[weaponactive]]==sword){
2753 XYZ where,startpoint,endpoint,movepoint;
2754 float rotationpoint;
2757 where=weapons.position[weaponids[weaponactive]];
2758 where-=victim->coords;
2759 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2761 where=weapons.tippoint[weaponids[weaponactive]];
2762 where-=victim->coords;
2763 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2768 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2769 footpoint+=victim->coords;
2772 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2775 if(weapons.type[weaponids[weaponactive]]==staff){
2776 XYZ where,startpoint,endpoint,movepoint;
2777 float rotationpoint;
2780 where=weapons.position[weaponids[weaponactive]];
2781 where-=victim->coords;
2782 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2784 where=weapons.tippoint[weaponids[weaponactive]];
2785 where-=victim->coords;
2786 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2791 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2792 footpoint+=victim->coords;
2795 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2798 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2800 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2801 victim->skeleton.longdead=0;
2802 victim->skeleton.free=1;
2803 victim->skeleton.broken=0;
2805 for(i=0;i<victim->skeleton.num_joints;i++){
2806 victim->skeleton.joints[i].velchange=0;
2807 victim->skeleton.joints[i].locked=0;
2808 //victim->skeleton.joints[i].velocity=0;
2814 Normalise(&relative);
2815 //victim->Puff(abdomen);
2816 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2818 if(victim->bloodloss<victim->damagetolerance){
2819 victim->bloodloss+=1000;
2823 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2827 if(!hasvictim&&onterrain){
2828 weapons.bloody[weaponids[weaponactive]]=0;
2829 weapons.blooddrip[weaponids[weaponactive]]=0;
2833 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2834 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2836 if(id==0)camerashake+=.4;
2843 gLoc[0]=victim->coords.x;
2844 gLoc[1]=victim->coords.y;
2845 gLoc[2]=victim->coords.z;
2849 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2851 if(tutoriallevel!=1){
2852 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2853 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2854 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2855 OPENAL_SetPaused(channels[heavyimpactsound], false);
2859 if(tutoriallevel!=1){
2860 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2861 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2862 OPENAL_SetVolume(channels[landsound2], 256);
2863 OPENAL_SetPaused(channels[landsound2], false);
2867 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
2870 relative=victim->coords-coords;
2872 Normalise(&relative);
2873 for(i=0;i<victim->skeleton.num_joints;i++){
2874 victim->skeleton.joints[i].velocity=relative*30;
2876 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2878 victim->targetframe=0;
2879 victim->targetanimation=staggerbackhardanim;
2880 victim->targetrotation=targetrotation+180;
2885 victim->Puff(abdomen);
2886 victim->DoDamage(damagemult*60/victim->protectionhigh);
2895 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2896 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2898 if(id==0)camerashake+=.4;
2901 gLoc[0]=victim->coords.x;
2902 gLoc[1]=victim->coords.y;
2903 gLoc[2]=victim->coords.z;
2907 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2908 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2909 if(tutoriallevel!=1){
2910 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2911 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2912 OPENAL_SetVolume(channels[thudsound], 512);
2913 OPENAL_SetPaused(channels[thudsound], false);
2916 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2917 if(tutoriallevel!=1){
2918 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2919 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2920 OPENAL_SetVolume(channels[whooshhitsound], 512);
2921 OPENAL_SetPaused(channels[whooshhitsound], false);
2925 if(tutoriallevel!=1){
2926 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2927 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2928 OPENAL_SetVolume(channels[heavyimpactsound], 256);
2929 OPENAL_SetPaused(channels[heavyimpactsound], false);
2933 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2936 relative=victim->coords-coords;
2938 Normalise(&relative);
2940 Normalise(&relative);
2941 for(i=0;i<victim->skeleton.num_joints;i++){
2942 victim->skeleton.joints[i].velocity=relative*5;
2944 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
2946 victim->targetframe=0;
2947 victim->targetanimation=staggerbackhardanim;
2948 victim->targetrotation=targetrotation+180;
2952 victim->Puff(abdomen);
2953 victim->DoDamage(damagemult*60/victim->protectionhigh);
2961 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
2962 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2963 if(victim->id==0)camerashake+=.4;
2966 gLoc[0]=victim->coords.x;
2967 gLoc[1]=victim->coords.y;
2968 gLoc[2]=victim->coords.z;
2973 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2974 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2975 OPENAL_SetVolume(channels[landsound2], 256);
2976 OPENAL_SetPaused(channels[landsound2], false);
2982 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
2983 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2984 if(victim->id==0)camerashake+=.4;
2987 gLoc[0]=victim->coords.x;
2988 gLoc[1]=victim->coords.y;
2989 gLoc[2]=victim->coords.z;
2994 if(weaponactive!=-1){
2995 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
2996 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2997 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2999 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3000 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3001 OPENAL_SetVolume(channels[swordstaffsound], 512);
3002 OPENAL_SetPaused(channels[swordstaffsound], false);
3005 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3006 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3007 OPENAL_SetVolume(channels[metalhitsound], 512);
3008 OPENAL_SetPaused(channels[metalhitsound], false);
3016 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3017 if(weaponactive!=-1){
3020 weapons.owner[weaponids[0]]=-1;
3021 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);
3023 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3024 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3026 weapons.velocity[weaponids[0]]=aim*50;
3027 weapons.tipvelocity[weaponids[0]]=aim*50;
3028 weapons.missed[weaponids[0]]=0;
3029 weapons.hitsomething[weaponids[0]]=0;
3030 weapons.freetime[weaponids[0]]=0;
3031 weapons.firstfree[weaponids[0]]=1;
3032 weapons.physics[weaponids[0]]=0;
3035 weaponids[0]=weaponids[num_weapons];
3041 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3043 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3046 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3049 award_bonus(id, Slicebonus);
3050 if(tutoriallevel!=1){
3053 gLoc[0]=victim->coords.x;
3054 gLoc[1]=victim->coords.y;
3055 gLoc[2]=victim->coords.z;
3059 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3060 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3061 OPENAL_SetVolume(channels[knifeslicesound], 512);
3062 OPENAL_SetPaused(channels[knifeslicesound], false);
3064 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3065 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3066 if(victim->id != 0 || difficulty==2){
3067 victim->targetframe=0;
3068 victim->targetanimation=staggerbackhardanim;
3069 victim->targetrotation=targetrotation+180;
3073 victim->lowreversaldelay=0;
3074 victim->highreversaldelay=0;
3075 if(aitype!=playercontrolled)weaponmissdelay=.6;
3077 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3078 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3080 XYZ footvel,footpoint;
3083 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3086 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;
3088 if(tutoriallevel!=1){
3089 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3090 footvel=DoRotation(facing,0,90,0)*.8;
3092 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3093 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3094 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3095 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3097 if(tutoriallevel==1){
3098 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3100 victim->DoDamage(damagemult*0);
3103 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3104 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3105 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3106 award_bonus(id, Slashbonus);
3108 if(tutoriallevel!=1){
3109 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3110 else victim->DoBloodBig(2/victim->armorhigh,185);
3111 victim->deathbleeding=1;
3114 gLoc[0]=victim->coords.x;
3115 gLoc[1]=victim->coords.y;
3116 gLoc[2]=victim->coords.z;
3120 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3121 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3122 OPENAL_SetVolume(channels[swordslicesound], 512);
3123 OPENAL_SetPaused(channels[swordslicesound], false);
3125 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3126 //if(animation[victim->targetanimation].attack){
3127 //if(victim->creature==rabbittype){
3128 if(tutoriallevel!=1){
3129 victim->targetframe=0;
3130 victim->targetanimation=staggerbackhardanim;
3131 victim->targetrotation=targetrotation+180;
3137 if(tutoriallevel!=1){
3138 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3139 weapons.blooddrip[weaponids[weaponactive]]+=3;
3141 float bloodlossamount;
3142 bloodlossamount=200+abs((float)(Random()%40))-20;
3143 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3144 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3145 victim->DoDamage(damagemult*0);
3147 XYZ footvel,footpoint;
3150 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3153 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;
3155 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3156 footvel=DoRotation(facing,0,90,0)*.8;
3158 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3159 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3160 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3161 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3169 gLoc[0]=victim->coords.x;
3170 gLoc[1]=victim->coords.y;
3171 gLoc[2]=victim->coords.z;
3175 if(victim->weaponactive!=-1){
3176 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3177 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3178 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3180 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3181 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3182 OPENAL_SetVolume(channels[swordstaffsound], 512);
3183 OPENAL_SetPaused(channels[swordstaffsound], false);
3186 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3187 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3188 OPENAL_SetVolume(channels[metalhitsound], 512);
3189 OPENAL_SetPaused(channels[metalhitsound], false);
3195 victim->Puff(righthand);
3197 victim->targetframe=0;
3198 victim->targetanimation=staggerbackhighanim;
3199 victim->targetrotation=targetrotation+180;
3201 weapons.owner[victim->weaponids[0]]=-1;
3202 aim=DoRotation(facing,0,90,0)*21;
3204 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3205 weapons.tipvelocity[victim->weaponids[0]]=aim;
3206 weapons.missed[victim->weaponids[0]]=1;
3207 weapons.hitsomething[weaponids[0]]=0;
3208 weapons.freetime[victim->weaponids[0]]=0;
3209 weapons.firstfree[victim->weaponids[0]]=1;
3210 weapons.physics[victim->weaponids[0]]=1;
3211 victim->num_weapons--;
3212 if(victim->num_weapons){
3213 victim->weaponids[0]=victim->weaponids[num_weapons];
3214 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3216 victim->weaponactive=-1;
3217 for(i=0;i<numplayers;i++){
3218 player[i].wentforweapon=0;
3221 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3222 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3223 OPENAL_SetVolume(channels[metalhitsound], 512);
3224 OPENAL_SetPaused(channels[metalhitsound], false);*/
3230 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3231 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3232 if(tutoriallevel!=1){
3233 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3235 if(id==0)camerashake+=.4;
3236 if(Random()%2||creature==wolftype){
3241 gLoc[0]=victim->coords.x;
3242 gLoc[1]=victim->coords.y;
3243 gLoc[2]=victim->coords.z;
3247 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3248 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3249 OPENAL_SetVolume(channels[staffheadsound], 256);
3250 OPENAL_SetPaused(channels[staffheadsound], false);
3254 relative=victim->coords-coords;
3256 Normalise(&relative);
3257 relative=DoRotation(relative,0,90,0);
3259 Normalise(&relative);
3260 for(i=0;i<victim->skeleton.num_joints;i++){
3261 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3263 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3264 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3267 if(tutoriallevel!=1){
3268 victim->DoDamage(damagemult*120/victim->protectionhigh);
3270 award_bonus(id, solidhit, 30);
3275 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3276 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3277 if(tutoriallevel!=1){
3278 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3280 if(id==0)camerashake+=.4;
3281 if(Random()%2||creature==wolftype){
3286 gLoc[0]=victim->coords.x;
3287 gLoc[1]=victim->coords.y;
3288 gLoc[2]=victim->coords.z;
3292 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3293 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3294 OPENAL_SetVolume(channels[staffheadsound], 256);
3295 OPENAL_SetPaused(channels[staffheadsound], false);
3299 relative=victim->coords-coords;
3301 Normalise(&relative);
3302 relative=DoRotation(relative,0,-90,0);
3303 for(i=0;i<victim->skeleton.num_joints;i++){
3304 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3306 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3307 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3310 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3312 award_bonus(id, solidhit, 60);
3317 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3318 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3320 if(tutoriallevel!=1){
3321 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3322 if(id==0)camerashake+=.4;
3323 if(Random()%2||creature==wolftype){
3328 gLoc[0]=victim->coords.x;
3329 gLoc[1]=victim->coords.y;
3330 gLoc[2]=victim->coords.z;
3334 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3335 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3336 OPENAL_SetVolume(channels[staffbodysound], 256);
3337 OPENAL_SetPaused(channels[staffbodysound], false);
3339 victim->skeleton.longdead=0;
3340 victim->skeleton.free=1;
3341 victim->skeleton.broken=0;
3343 for(i=0;i<victim->skeleton.num_joints;i++){
3344 victim->skeleton.joints[i].velchange=0;
3345 victim->skeleton.joints[i].locked=0;
3346 //victim->skeleton.joints[i].velocity=0;
3352 /*relative=victim->coords-coords;
3354 Normalise(&relative);
3355 relative=DoRotation(relative,0,90,0);*/
3357 Normalise(&relative);
3359 for(i=0;i<victim->skeleton.num_joints;i++){
3360 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3363 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3366 for(i=0;i<victim->skeleton.num_joints;i++){
3367 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3370 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3372 victim->Puff(abdomen);
3373 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3376 award_bonus(id, solidhit, 40);
3382 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3383 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3385 if(id==0)camerashake+=.4;
3388 gLoc[0]=victim->coords.x;
3389 gLoc[1]=victim->coords.y;
3390 gLoc[2]=victim->coords.z;
3395 relative=victim->coords-coords;
3397 Normalise(&relative);
3403 if(animation[victim->targetanimation].height==lowheight){
3409 for(i=0;i<victim->skeleton.num_joints;i++){
3410 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3412 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3413 if(tutoriallevel!=1){
3414 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3415 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3416 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3417 OPENAL_SetPaused(channels[heavyimpactsound], false);
3420 victim->DoDamage(damagemult*100/victim->protectionhead);
3421 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3422 if(creature==wolftype){
3423 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3424 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3425 OPENAL_SetVolume(channels[clawslicesound], 128);
3426 OPENAL_SetPaused(channels[clawslicesound], false);
3428 victim->DoBloodBig(2/victim->armorhead,175);
3432 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3433 for(i=0;i<victim->skeleton.num_joints;i++){
3434 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3436 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3437 victim->targetframe=0;
3438 victim->targetanimation=staggerbackhighanim;
3439 victim->targetrotation=targetrotation+180;
3441 if(tutoriallevel!=1){
3442 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3443 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3444 OPENAL_SetVolume(channels[landsound2], 128);
3445 OPENAL_SetPaused(channels[landsound2], false);
3447 victim->Puff(abdomen);
3448 victim->DoDamage(damagemult*30/victim->protectionhigh);
3449 if(creature==wolftype){
3450 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3451 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3452 OPENAL_SetVolume(channels[clawslicesound], 128);
3453 OPENAL_SetPaused(channels[clawslicesound], false);
3455 victim->DoBloodBig(2/victim->armorhigh,170);
3462 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3463 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3465 if(id==0)camerashake+=.2;
3468 gLoc[0]=victim->coords.x;
3469 gLoc[1]=victim->coords.y;
3470 gLoc[2]=victim->coords.z;
3474 if(tutoriallevel!=1){
3475 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3476 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3477 OPENAL_SetVolume(channels[landsound2], 128);
3478 OPENAL_SetPaused(channels[landsound2], false);
3481 relative=victim->coords-coords;
3483 Normalise(&relative);
3485 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3488 for(i=0;i<victim->skeleton.num_joints;i++){
3489 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3491 relative=DoRotation(relative,0,-90,0);
3493 for(i=0;i<victim->skeleton.num_joints;i++){
3494 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)
3495 victim->skeleton.joints[i].velocity=relative*80;
3497 victim->Puff(rightankle);
3498 victim->Puff(leftankle);
3499 victim->DoDamage(damagemult*40/victim->protectionlow);
3502 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3503 for(i=0;i<victim->skeleton.num_joints;i++){
3504 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3506 relative=DoRotation(relative,0,-90,0);
3507 for(i=0;i<victim->skeleton.num_joints;i++){
3508 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)
3509 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3511 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3512 victim->targetframe=0;
3513 victim->targetanimation=staggerbackhighanim;
3514 victim->targetrotation=targetrotation+180;
3516 if(tutoriallevel!=1){
3517 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3518 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3519 OPENAL_SetVolume(channels[landsound2], 128);
3520 OPENAL_SetPaused(channels[landsound2], false);
3522 victim->Puff(abdomen);
3523 victim->DoDamage(damagemult*30/victim->protectionlow);
3533 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3534 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3536 if(id==0)camerashake+=.4;
3543 gLoc[0]=victim->coords.x;
3544 gLoc[1]=victim->coords.y;
3545 gLoc[2]=victim->coords.z;
3549 if(tutoriallevel!=1){
3550 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3551 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3552 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3553 OPENAL_SetPaused(channels[heavyimpactsound], false);
3555 if(creature==wolftype){
3556 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3557 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3558 OPENAL_SetVolume(channels[clawslicesound], 128);
3559 OPENAL_SetPaused(channels[clawslicesound], false);
3561 victim->DoBloodBig(2/victim->armorhigh,170);
3565 relative=victim->coords-oldcoords;
3567 Normalise(&relative);
3568 //relative=DoRotation(relative,0,-90,0);
3569 for(i=0;i<victim->skeleton.num_joints;i++){
3570 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3572 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3574 victim->Puff(abdomen);
3575 victim->DoDamage(damagemult*150/victim->protectionhigh);
3577 award_bonus(id, Reversal);
3580 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3581 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3582 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3583 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3586 weaponids[num_weapons]=weaponids[victim->weaponactive];
3589 weaponids[0]=victim->weaponids[victim->weaponactive];
3590 victim->num_weapons--;
3591 if(victim->num_weapons>0){
3592 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3593 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3595 victim->weaponactive=-1;
3600 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3602 if(id==0)camerashake+=.4;
3609 gLoc[0]=victim->coords.x;
3610 gLoc[1]=victim->coords.y;
3611 gLoc[2]=victim->coords.z;
3615 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3616 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3617 OPENAL_SetVolume(channels[whooshhitsound], 128);
3618 OPENAL_SetPaused(channels[whooshhitsound], false);
3621 relative=victim->coords-oldcoords;
3623 Normalise(&relative);
3624 //relative=DoRotation(relative,0,-90,0);
3625 for(i=0;i<victim->skeleton.num_joints;i++){
3626 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3628 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3631 victim->DoDamage(damagemult*70/victim->protectionhigh);
3634 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3636 if(id==0)camerashake+=.4;
3643 gLoc[0]=victim->coords.x;
3644 gLoc[1]=victim->coords.y;
3645 gLoc[2]=victim->coords.z;
3650 award_bonus(id, staffreversebonus);
3652 if(tutoriallevel!=1){
3653 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3654 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3655 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3656 OPENAL_SetPaused(channels[heavyimpactsound], false);
3659 award_bonus(id, staffreversebonus); // Huh, again?
3662 relative=victim->coords-oldcoords;
3664 Normalise(&relative);
3665 //relative=DoRotation(relative,0,-90,0);
3666 for(i=0;i<victim->skeleton.num_joints;i++){
3667 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3669 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3672 victim->DoDamage(damagemult*70/victim->protectionhigh);
3675 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3681 Normalise(&relative);
3684 for(i=0;i<victim->skeleton.num_joints;i++){
3685 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3687 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3688 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3689 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3690 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3691 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3692 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3693 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3694 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3696 victim->Puff(abdomen);
3697 victim->DoDamage(damagemult*90/victim->protectionhigh);
3699 award_bonus(id, Reversal);
3703 if(weaponactive!=-1||creature==wolftype)doslice=1;
3704 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3708 gLoc[0]=victim->coords.x;
3709 gLoc[1]=victim->coords.y;
3710 gLoc[2]=victim->coords.z;
3714 if(weaponactive!=-1){
3715 victim->DoBloodBig(2/victim->armorhigh,225);
3716 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3717 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3718 OPENAL_SetVolume(channels[knifeslicesound], 512);
3719 OPENAL_SetPaused(channels[knifeslicesound], false);
3720 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3721 weapons.blooddrip[weaponids[weaponactive]]+=3;
3723 if(weaponactive==-1&&creature==wolftype){
3724 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3725 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3726 OPENAL_SetVolume(channels[clawslicesound], 128);
3727 OPENAL_SetPaused(channels[clawslicesound], false);
3729 victim->DoBloodBig(2/victim->armorhigh,175);
3736 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3742 Normalise(&relative);
3745 for(i=0;i<victim->skeleton.num_joints;i++){
3746 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3748 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
3749 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
3750 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
3751 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
3752 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
3753 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
3754 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
3755 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
3757 award_bonus(id, swordreversebonus);
3760 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3762 if(id==0)camerashake+=.4;
3769 gLoc[0]=victim->coords.x;
3770 gLoc[1]=victim->coords.y;
3771 gLoc[2]=victim->coords.z;
3775 if(tutoriallevel!=1){
3776 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3777 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3778 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3779 OPENAL_SetPaused(channels[heavyimpactsound], false);
3783 relative=victim->coords-oldcoords;
3785 Normalise(&relative);
3786 relative=DoRotation(relative,0,-90,0);
3787 for(i=0;i<victim->skeleton.num_joints;i++){
3788 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3790 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3792 victim->Puff(abdomen);
3793 victim->DoDamage(damagemult*30/victim->protectionhigh);
3795 award_bonus(id, Reversal);
3798 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
3801 victim->skeleton.spinny=0;
3805 Normalise(&relative);
3806 if(victim->id==0)relative/=30;
3807 for(i=0;i<victim->skeleton.num_joints;i++){
3808 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3810 //victim->DoDamage(1000);
3811 victim->damage=victim->damagetolerance;
3812 victim->permanentdamage=victim->damagetolerance-1;
3815 if(weaponactive!=-1||creature==wolftype)doslice=1;
3816 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3820 gLoc[0]=victim->coords.x;
3821 gLoc[1]=victim->coords.y;
3822 gLoc[2]=victim->coords.z;
3826 if(weaponactive!=-1){
3827 victim->DoBloodBig(200,225);
3828 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3829 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3830 OPENAL_SetVolume(channels[knifeslicesound], 512);
3831 OPENAL_SetPaused(channels[knifeslicesound], false);
3832 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3833 weapons.blooddrip[weaponids[weaponactive]]+=5;
3836 if(creature==wolftype&&weaponactive==-1){
3837 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3838 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3839 OPENAL_SetVolume(channels[clawslicesound], 128);
3840 OPENAL_SetPaused(channels[clawslicesound], false);
3842 victim->DoBloodBig(2,175);
3845 award_bonus(id, spinecrusher);
3848 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3849 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3851 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3852 if(targetanimation==knifesneakattackanim){
3853 /*victim->DoBloodBig(200,195);
3858 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3859 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3861 XYZ footvel,footpoint;
3863 footpoint=weapons.tippoint[weaponids[0]];
3864 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3865 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3866 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3867 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3868 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3869 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3870 victim->DoBloodBig(200,195);
3871 award_bonus(id, tracheotomy);
3873 if(targetanimation==knifefollowanim){
3874 award_bonus(id, Stabbonus);
3875 XYZ footvel,footpoint;
3877 footpoint=weapons.tippoint[weaponids[0]];
3878 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3879 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3880 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3881 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3882 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3883 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3886 victim->bloodloss+=10000;
3890 gLoc[0]=victim->coords.x;
3891 gLoc[1]=victim->coords.y;
3892 gLoc[2]=victim->coords.z;
3896 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
3897 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
3898 OPENAL_SetVolume(channels[fleshstabsound], 512);
3899 OPENAL_SetPaused(channels[fleshstabsound], false);
3900 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3901 weapons.blooddrip[weaponids[weaponactive]]+=5;
3905 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
3908 for(i=0;i<victim->skeleton.num_joints;i++){
3909 victim->skeleton.joints[i].velocity=0;
3911 if(targetanimation==knifefollowanim){
3913 for(i=0;i<victim->skeleton.num_joints;i++){
3914 victim->skeleton.joints[i].velocity=0;
3917 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
3920 gLoc[0]=victim->coords.x;
3921 gLoc[1]=victim->coords.y;
3922 gLoc[2]=victim->coords.z;
3926 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
3927 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
3928 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
3929 OPENAL_SetPaused(channels[fleshstabremovesound], false);
3930 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3931 weapons.blooddrip[weaponids[weaponactive]]+=5;
3933 XYZ footvel,footpoint;
3935 footpoint=weapons.tippoint[weaponids[0]];
3936 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3937 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3938 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3939 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3940 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3941 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3945 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3946 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3947 award_bonus(id, backstab);
3951 XYZ footvel,footpoint;
3953 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
3954 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3955 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3956 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3957 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3958 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3959 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3960 victim->DoBloodBig(200,180);
3961 victim->DoBloodBig(200,215);
3962 victim->bloodloss+=10000;
3966 gLoc[0]=victim->coords.x;
3967 gLoc[1]=victim->coords.y;
3968 gLoc[2]=victim->coords.z;
3972 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
3973 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
3974 OPENAL_SetVolume(channels[fleshstabsound], 512);
3975 OPENAL_SetPaused(channels[fleshstabsound], false);
3976 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3977 weapons.blooddrip[weaponids[weaponactive]]+=5;
3981 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
3984 for(i=0;i<victim->skeleton.num_joints;i++){
3985 victim->skeleton.joints[i].velocity=0;
3987 if(weaponactive!=-1){
3990 gLoc[0]=victim->coords.x;
3991 gLoc[1]=victim->coords.y;
3992 gLoc[2]=victim->coords.z;
3996 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
3997 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
3998 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
3999 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4000 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4001 weapons.blooddrip[weaponids[weaponactive]]+=5;
4003 XYZ footvel,footpoint;
4005 footpoint=weapons.tippoint[weaponids[0]];
4006 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4007 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4008 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4009 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4010 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4011 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4015 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4017 if(id==0)camerashake+=.4;
4024 gLoc[0]=victim->coords.x;
4025 gLoc[1]=victim->coords.y;
4026 gLoc[2]=victim->coords.z;
4030 if(weaponactive==-1){
4031 if(tutoriallevel!=1){
4032 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4033 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4034 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4035 OPENAL_SetPaused(channels[heavyimpactsound], false);
4040 if(weaponactive!=-1||creature==wolftype)doslice=1;
4041 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4043 if(weaponactive!=-1){
4044 victim->DoBloodBig(2/victim->armorhead,225);
4045 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4046 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4047 OPENAL_SetVolume(channels[knifeslicesound], 512);
4048 OPENAL_SetPaused(channels[knifeslicesound], false);
4049 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4050 weapons.blooddrip[weaponids[weaponactive]]+=3;
4052 if(weaponactive==-1&&creature==wolftype){
4053 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4054 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4055 OPENAL_SetVolume(channels[clawslicesound], 128);
4056 OPENAL_SetPaused(channels[clawslicesound], false);
4058 victim->DoBloodBig(2/victim->armorhead,175);
4062 award_bonus(id, Reversal);
4067 //relative=victim->coords-oldcoords;
4070 Normalise(&relative);
4071 relative=DoRotation(relative,0,90,0);
4073 Normalise(&relative);
4074 for(i=0;i<victim->skeleton.num_joints;i++){
4075 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4077 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4078 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4079 victim->DoDamage(damagemult*100/victim->protectionhead);
4083 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4087 //relative=victim->coords-oldcoords;
4090 Normalise(&relative);
4091 relative=DoRotation(relative,0,90,0);
4093 Normalise(&relative);
4094 for(i=0;i<victim->skeleton.num_joints;i++){
4095 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4097 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4100 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4101 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4102 award_bonus(id, reverseko);
4108 if(targetframe>animation[currentanimation].numframes-1){
4111 targetanimation=getIdle();
4115 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4116 targetanimation=rollanim;
4127 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4128 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4129 OPENAL_SetVolume(channels[movewhooshsound], 128);
4130 OPENAL_SetPaused(channels[movewhooshsound], false);
4132 if(currentanimation==staggerbackhighanim){
4133 targetanimation=getIdle();
4135 if(currentanimation==staggerbackhardanim){
4136 targetanimation=getIdle();
4138 if(currentanimation==removeknifeanim){
4139 targetanimation=getIdle();
4141 if(currentanimation==crouchremoveknifeanim){
4142 targetanimation=getCrouch();
4144 if(currentanimation==backhandspringanim){
4145 targetanimation=getIdle();
4147 if(currentanimation==dodgebackanim){
4148 targetanimation=getIdle();
4150 if(currentanimation==drawleftanim){
4151 targetanimation=getIdle();
4153 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4154 targetanimation=getIdle();
4155 if(currentanimation==crouchdrawrightanim){
4156 targetanimation=getCrouch();
4158 if(weaponactive==-1)weaponactive=0;
4159 else if(weaponactive==0){
4163 buffer=weaponids[0];
4164 weaponids[0]=weaponids[1];
4165 weaponids[1]=buffer;
4169 if(weaponactive==-1){
4179 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4180 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4181 OPENAL_SetVolume(channels[knifesheathesound], 128);
4182 OPENAL_SetPaused(channels[knifesheathesound], false);
4184 if(weaponactive!=-1){
4194 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4195 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4196 OPENAL_SetVolume(channels[knifedrawsound], 128);
4197 OPENAL_SetPaused(channels[knifedrawsound], false);
4200 if(currentanimation==rollanim){
4201 targetanimation=getCrouch();
4206 if(targetanimation==walljumprightkickanim){
4209 if(targetanimation==walljumpleftkickanim){
4212 targetanimation=jumpdownanim;
4214 if(currentanimation==climbanim){
4215 targetanimation=getCrouch();
4218 if(!isnormal(coords.x))
4229 if(targetanimation==rabbitkickreversalanim){
4230 targetanimation=getCrouch();
4233 if(targetanimation==jumpreversalanim){
4234 targetanimation=getCrouch();
4237 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4238 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4240 float closestdist=-1;
4243 for(i=0;i<numplayers;i++){
4244 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4245 distance=findDistancefast(&player[i].coords,&coords);
4246 if(closestdist==-1||distance<closestdist){
4247 closestdist=distance;
4252 if(closestdist>0&&closest>=0&&closestdist<16){
4253 victim=&player[closest];
4254 targetanimation=walljumprightkickanim;
4256 XYZ rotatetarget=victim->coords-coords;
4257 Normalise(&rotatetarget);
4258 rotation=-asin(0-rotatetarget.x);
4260 if(rotatetarget.z<0)rotation=180-rotation;
4261 targettilt2=-asin(rotatetarget.y)*360/6.28;
4262 velocity=(victim->coords-coords)*4;
4267 if(targetanimation==walljumpbackanim){
4268 targetanimation=backflipanim;
4272 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4274 if(targetanimation==walljumprightanim){
4275 targetanimation=rightflipanim;
4279 velocity=DoRotation(facing,0,30,0)*-8;
4282 if(targetanimation==walljumpfrontanim){
4283 targetanimation=frontflipanim;
4285 //targetrotation-=180;
4290 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4292 if(targetanimation==walljumpleftanim){
4295 float closestdist=-1;
4298 for(i=0;i<numplayers;i++){
4299 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4300 distance=findDistancefast(&player[i].coords,&coords);
4301 if(closestdist==-1||distance<closestdist){
4302 closestdist=distance;
4307 if(closestdist>0&&closest>=0&&closestdist<16){
4308 victim=&player[closest];
4309 targetanimation=walljumpleftkickanim;
4311 XYZ rotatetarget=victim->coords-coords;
4312 Normalise(&rotatetarget);
4313 rotation=-asin(0-rotatetarget.x);
4315 if(rotatetarget.z<0)rotation=180-rotation;
4316 targettilt2=-asin(rotatetarget.y)*360/6.28;
4317 velocity=(victim->coords-coords)*4;
4322 if(targetanimation!=walljumpleftkickanim){
4323 targetanimation=leftflipanim;
4327 velocity=DoRotation(facing,0,-30,0)*-8;
4330 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4332 if(targetanimation==sneakattackanim){
4333 float ycoords=oldcoords.y;
4334 currentanimation=getCrouch();
4335 targetanimation=getCrouch();
4338 targetrotation+=180;
4343 targetheadrotation+=180;
4345 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4349 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4350 float ycoords=oldcoords.y;
4351 targetanimation=getIdle();
4353 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4357 if(currentanimation==knifefollowanim){
4358 targetanimation=getIdle();
4361 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4362 float ycoords=oldcoords.y;
4363 targetanimation=getStop();
4364 targetrotation+=180;
4369 targetheadrotation+=180;
4370 if(!isnormal(coords.x))
4372 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4373 oldcoords=coords+facing*.5;
4374 else if(currentanimation==sweepreversalanim)
4375 oldcoords=coords+facing*1.1;
4376 else if(currentanimation==upunchreversalanim){
4377 oldcoords=coords+facing*1.5;
4378 targetrotation+=180;
4380 targetheadrotation+=180;
4384 else if(currentanimation==knifeslashreversalanim){
4385 oldcoords=coords+facing*.5;
4388 targetheadrotation+=90;
4392 else if(currentanimation==staffspinhitreversalanim){
4393 targetrotation+=180;
4395 targetheadrotation+=180;
4399 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4400 else oldcoords.y=ycoords;
4401 currentoffset=coords-oldcoords;
4407 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4412 if(animation[targetanimation].attack==reversed){
4414 if(targetanimation==sweepreversedanim)targetrotation+=90;
4415 targetanimation=backhandspringanim;
4425 PlaySoundEx( landsound, samp[landsound], NULL, true);
4426 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4427 OPENAL_SetVolume(channels[landsound], 128);
4428 OPENAL_SetPaused(channels[landsound], false);
4430 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4431 targetanimation=rollanim;
4434 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4435 coords.y=oldcoords.y;
4437 if(currentanimation==knifeslashreversedanim){
4438 targetanimation=rollanim;
4443 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4444 coords.y=oldcoords.y;
4448 targetanimation=jumpdownanim;
4450 if(wasLanding())targetanimation=getIdle();
4451 if(wasLandhard())targetanimation=getIdle();
4452 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4453 targetanimation=getIdle();
4455 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4456 coords.y=oldcoords.y;
4457 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4458 targetoffset.y=coords.y;
4459 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4460 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4461 currentoffset.y-=(coords.y-targetoffset.y);
4462 coords.y=targetoffset.y;
4464 normalsupdatedelay=0;
4466 if(currentanimation==upunchanim){
4467 targetanimation=getStop();
4468 normalsupdatedelay=0;
4471 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4472 targetrotation=rotation;
4475 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4476 if(!hasstaff)DoDamage(35);
4479 rabbitkickragdoll=1;
4481 if(currentanimation==rabbitkickreversedanim){
4488 if(id!=0)SolidHitBonus();
4492 targetanimation=rollanim;
4494 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4498 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4504 if(currentanimation==jumpreversedanim){
4511 if(id!=0)SolidHitBonus();
4515 targetanimation=rollanim;
4517 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4522 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){
4523 targetanimation=getupfromfrontanim;
4526 else if(animation[currentanimation].attack==normalattack){
4527 targetanimation=getIdle();
4530 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4531 targetanimation=blockhighleftstrikeanim;
4533 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4534 targetanimation=getIdle();
4537 if(currentanimation==spinkickanim&&victim->skeleton.free){
4538 if(creature==rabbittype)targetanimation=fightidleanim;
4543 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4545 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4546 targetanimation=jumpdownanim;
4551 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4552 if(!isRun()||!wasRun()){
4553 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4554 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4555 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4556 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4558 if(isRun()&&wasRun()){
4561 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4562 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4565 else if(transspeed)target+=multiplier*transspeed*speed*2;
4567 if(!isRun()||!wasRun()){
4568 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4569 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4570 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4571 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4575 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4577 if(target>1){currentframe=targetframe; target=1;}
4579 rot=targetrot*target;
4580 rotation+=rot-oldrot;
4586 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4588 for(i=0;i<skeleton.num_joints;i++){
4589 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4592 skeleton.FindForwards();
4594 for(i=0;i<skeleton.num_muscles;i++){
4595 if(skeleton.muscles[i].visible)
4597 skeleton.FindRotationMuscle(i,targetanimation);
4600 for(i=0;i<skeleton.num_muscles;i++){
4601 if(skeleton.muscles[i].visible)
4603 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4604 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4605 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4610 for(i=0;i<skeleton.num_joints;i++){
4611 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4614 skeleton.FindForwards();
4616 for(i=0;i<skeleton.num_muscles;i++){
4617 if(skeleton.muscles[i].visible)
4619 skeleton.FindRotationMuscle(i,targetanimation);
4622 for(i=0;i<skeleton.num_muscles;i++){
4623 if(skeleton.muscles[i].visible)
4625 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4626 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4627 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4628 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4629 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4630 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4631 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4632 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4633 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4637 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4639 oldcurrentanimation=currentanimation;
4640 oldtargetanimation=targetanimation;
4641 oldtargetframe=targetframe;
4642 oldcurrentframe=currentframe;
4644 for(i=0;i<skeleton.num_joints;i++){
4645 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4646 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4648 offset=currentoffset*(1-target)+targetoffset*target;
4649 for(i=0;i<skeleton.num_muscles;i++){
4650 if(skeleton.muscles[i].visible)
4652 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4653 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4654 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4659 if(isLanding()&&landhard){
4660 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4661 if(id==0)camerashake+=.4;
4662 targetanimation=getLandhard();
4670 //skeleton.DoConstraints();
4673 void Person::DoStuff(){
4674 static XYZ terrainnormal;
4675 static XYZ flatfacing;
4676 static XYZ flatvelocity;
4677 static float flatvelspeed;
4681 static int bloodsize;
4682 static int startx,starty,endx,endy;
4683 static int texdetailint;
4684 static GLubyte color;
4685 static XYZ bloodvel;
4687 onfiredelay-=multiplier;
4688 if(onfiredelay<0&&onfire)
4696 crouchkeydowntime+=multiplier;
4697 if(!crouchkeydown)crouchkeydowntime=0;
4698 jumpkeydowntime+=multiplier;
4699 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
4701 if(hostile||damage>0||bloodloss>0)immobile=0;
4703 if(isIdle()||isRun())targetoffset=0;
4705 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
4707 if(id==0)blooddimamount-=multiplier*.3;
4708 speechdelay-=multiplier;
4709 texupdatedelay-=multiplier;
4710 interestdelay-=multiplier;
4711 flamedelay-=multiplier;
4712 parriedrecently-=multiplier;
4718 if(id==0)speed=1.1*speedmult;
4719 else speed=1.0*speedmult;
4720 if(!skeleton.free)rabbitkickragdoll=0;
4724 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
4725 if(id!=0&&creature==wolftype&&difficulty==2){
4727 if(aitype!=passivetype){
4729 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){
4733 if(scale<0.2)superruntoggle=0;
4734 if(targetanimation==wolfrunninganim&&!superruntoggle){
4735 targetanimation=getRun();
4739 if(weaponactive==-1&&num_weapons>0){
4740 if(weapons.type[weaponids[0]]==staff){
4747 /*if(aitype!=playercontrolled)*///deathbleeding=5;
4748 /*if(aitype!=playercontrolled)*/
4750 if(burnt>.6)burnt=.6;
4751 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
4753 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
4764 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4765 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
4769 while(flamedelay<0&&onfire){
4771 howmany=abs(Random()%(skeleton.num_joints));
4772 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4773 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4774 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4775 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4776 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
4779 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
4781 howmany=abs(Random()%(skeleton.num_joints));
4782 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4783 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4784 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4785 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4786 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
4790 bleeding-=multiplier*.3;
4792 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4793 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
4797 if(neckspurtamount>0){
4798 neckspurtamount-=multiplier;
4799 neckspurtdelay-=multiplier*3;
4800 neckspurtparticledelay-=multiplier*3;
4801 if(neckspurtparticledelay<0&&neckspurtdelay>2){
4805 bloodvel.z=5*neckspurtamount;
4806 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4809 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
4811 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4812 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
4813 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);
4814 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);
4815 neckspurtparticledelay=.05;
4817 if(neckspurtdelay<0){
4822 if(deathbleeding>0&&dead!=2){
4823 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
4824 else bleeddelay-=5*multiplier/4;
4825 if(bleeddelay<0&&bloodtoggle){
4830 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4831 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
4832 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
4833 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);
4836 bloodloss+=deathbleeding*multiplier*80;
4837 deathbleeding-=multiplier*1.6;
4838 //if(id==0)deathbleeding-=multiplier*.2;
4839 if(deathbleeding<0)deathbleeding=0;
4840 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
4841 if(weaponactive!=-1){
4842 weapons.owner[weaponids[0]]=-1;
4843 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4844 weapons.velocity[weaponids[0]].x+=.01;
4845 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4846 weapons.missed[weaponids[0]]=1;
4847 weapons.hitsomething[weaponids[0]]=0;
4848 weapons.freetime[weaponids[0]]=0;
4849 weapons.firstfree[weaponids[0]]=1;
4850 weapons.physics[weaponids[0]]=1;
4853 weaponids[0]=weaponids[num_weapons];
4854 if(weaponstuck==num_weapons)weaponstuck=0;
4857 for(i=0;i<numplayers;i++){
4858 player[i].wentforweapon=0;
4870 if(!dead&&creature==wolftype){
4871 award_bonus(0, Wolfbonus);
4874 if(targetanimation==knifefollowedanim&&!skeleton.free){
4875 for(i=0;i<skeleton.num_joints;i++){
4876 skeleton.joints[i].velocity=0;
4877 skeleton.joints[i].velocity.y=-2;
4880 if(id!=0&&unconscioustime>.1){
4888 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
4891 bloodsize=5-realtexdetail;
4895 texdetailint=realtexdetail;
4896 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
4897 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
4898 endx=startx+bloodsize;
4899 endy=starty+bloodsize;
4901 if(startx<0){startx=0;bleeding=0;}
4902 if(starty<0){starty=0;bleeding=0;}
4903 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
4904 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
4905 if(endx<startx)endx=startx;
4906 if(endy<starty)endy=starty;
4908 for(i=startx;i<endx;i++){
4909 for(j=starty;j<endy;j++){
4911 color=Random()%85+170;
4912 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
4913 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
4914 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
4919 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4920 DoMipmaps(0,startx,endx,starty,endy);
4924 bleedy-=4/realtexdetail;
4925 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
4926 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
4929 bleedx+=4*direction/realtexdetail;
4930 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
4931 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
4935 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
4936 righthandmorphness=targetrighthandmorphness;
4937 righthandmorphstart=righthandmorphend;
4939 else if(righthandmorphness>targetrighthandmorphness){
4940 righthandmorphness-=multiplier*4;
4942 else if(righthandmorphness<targetrighthandmorphness){
4943 righthandmorphness+=multiplier*4;
4946 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
4947 lefthandmorphness=targetlefthandmorphness;
4948 lefthandmorphstart=lefthandmorphend;
4950 else if(lefthandmorphness>targetlefthandmorphness){
4951 lefthandmorphness-=multiplier*4;
4953 else if(lefthandmorphness<targetlefthandmorphness){
4954 lefthandmorphness+=multiplier*4;
4957 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
4958 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
4959 tailmorphness=targettailmorphness;
4960 tailmorphstart=tailmorphend;
4962 else if(tailmorphness>targettailmorphness){
4963 tailmorphness-=multiplier*10;
4965 else if(tailmorphness<targettailmorphness){
4966 tailmorphness+=multiplier*10;
4970 if(creature==wolftype){
4971 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
4972 tailmorphness=targettailmorphness;
4973 tailmorphstart=tailmorphend;
4975 else if(tailmorphness>targettailmorphness){
4976 tailmorphness-=multiplier*2;
4978 else if(tailmorphness<targettailmorphness){
4979 tailmorphness+=multiplier*2;
4983 if(headmorphend==3||headmorphstart==3){
4984 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
4985 headmorphness=targetheadmorphness;
4986 headmorphstart=headmorphend;
4988 else if(headmorphness>targetheadmorphness){
4989 headmorphness-=multiplier*7;
4991 else if(headmorphness<targetheadmorphness){
4992 headmorphness+=multiplier*7;
4995 else if(headmorphend==5||headmorphstart==5){
4996 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
4997 headmorphness=targetheadmorphness;
4998 headmorphstart=headmorphend;
5000 else if(headmorphness>targetheadmorphness){
5001 headmorphness-=multiplier*10;
5003 else if(headmorphness<targetheadmorphness){
5004 headmorphness+=multiplier*10;
5008 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5009 headmorphness=targetheadmorphness;
5010 headmorphstart=headmorphend;
5012 else if(headmorphness>targetheadmorphness){
5013 headmorphness-=multiplier*4;
5015 else if(headmorphness<targetheadmorphness){
5016 headmorphness+=multiplier*4;
5020 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5021 chestmorphness=targetchestmorphness;
5022 chestmorphstart=chestmorphend;
5024 else if(chestmorphness>targetchestmorphness){
5025 chestmorphness-=multiplier;
5027 else if(chestmorphness<targetchestmorphness){
5028 chestmorphness+=multiplier;
5031 if(dead!=2&&howactive<=typesleeping){
5032 if(chestmorphstart==0&&chestmorphend==0){
5034 targetchestmorphness=1;
5037 if(chestmorphstart!=0&&chestmorphend!=0){
5039 targetchestmorphness=1;
5041 if(environment==snowyenvironment){
5044 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5045 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5046 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5047 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5048 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5049 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5053 if(!dead&&howactive<typesleeping){
5054 blinkdelay-=multiplier*2;
5055 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5057 targetheadmorphness=1;
5059 blinkdelay=(float)(abs(Random()%40))/5;
5061 if(headmorphstart==3&&headmorphend==3){
5063 targetheadmorphness=1;
5068 twitchdelay-=multiplier*1.5;
5069 if(targetanimation!=hurtidleanim){
5070 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5072 targetheadmorphness=1;
5074 twitchdelay=(float)(abs(Random()%40))/5;
5076 if(headmorphstart==5&&headmorphend==5){
5078 targetheadmorphness=1;
5082 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5083 twitchdelay3-=multiplier*1;
5085 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5086 righthandmorphness=0;
5087 targetrighthandmorphness=1;
5088 righthandmorphend=1;
5089 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5091 if(righthandmorphstart==1&&righthandmorphend==1){
5092 righthandmorphness=0;
5093 targetrighthandmorphness=1;
5094 righthandmorphend=0;
5098 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5099 lefthandmorphness=0;
5100 targetlefthandmorphness=1;
5102 twitchdelay3=(float)(abs(Random()%40))/5;
5104 if(lefthandmorphstart==1&&lefthandmorphend==1){
5105 lefthandmorphness=0;
5106 targetlefthandmorphness=1;
5113 if(creature==rabbittype){
5114 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5115 else twitchdelay2-=multiplier*0.5;
5116 if(howactive<=typesleeping){
5117 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5119 targettailmorphness=1;
5121 twitchdelay2=(float)(abs(Random()%40))/5;
5123 if(tailmorphstart==1&&tailmorphend==1){
5125 targettailmorphness=1;
5128 if(tailmorphstart==2&&tailmorphend==2){
5130 targettailmorphness=1;
5137 if(creature==wolftype){
5138 twitchdelay2-=multiplier*1.5;
5140 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5142 targettailmorphness=1;
5147 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5149 targettailmorphness=1;
5153 if(twitchdelay2<=0){
5154 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5156 targettailmorphness=1;
5159 if(tailmorphstart==1&&tailmorphend==1){
5161 targettailmorphness=1;
5164 if(tailmorphstart==2&&tailmorphend==2){
5166 targettailmorphness=1;
5169 if(tailmorphstart==3&&tailmorphend==3){
5171 targettailmorphness=1;
5174 if(tailmorphstart==4&&tailmorphend==4){
5176 targettailmorphness=1;
5182 if(dead!=1)unconscioustime=0;
5184 if(dead==1||howactive==typesleeping){
5185 unconscioustime+=multiplier;
5186 //If unconscious, close eyes and mouth
5187 if(righthandmorphend!=0)righthandmorphness=0;
5188 righthandmorphend=0;
5189 targetrighthandmorphness=1;
5191 if(lefthandmorphend!=0)lefthandmorphness=0;
5193 targetlefthandmorphness=1;
5195 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5197 targetheadmorphness=1;
5201 if(howactive>typesleeping){
5204 if(bloodtoggle&&!bled){
5205 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5207 if(bloodtoggle&&!bled)
5208 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5209 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5210 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5214 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5219 if(dead==2||howactive>typesleeping){
5220 //If dead, open mouth and hands
5221 if(righthandmorphend!=0)righthandmorphness=0;
5222 righthandmorphend=0;
5223 targetrighthandmorphness=1;
5225 if(lefthandmorphend!=0)lefthandmorphness=0;
5227 targetlefthandmorphness=1;
5229 if(headmorphend!=2)headmorphness=0;
5231 targetheadmorphness=1;
5234 if(stunned>0&&!dead&&headmorphend!=2){
5235 if(headmorphend!=4)headmorphness=0;
5237 targetheadmorphness=1;
5240 if(damage>damagetolerance&&!dead){
5245 if(creature==wolftype){
5246 award_bonus(0, Wolfbonus);
5251 if(weaponactive!=-1){
5252 weapons.owner[weaponids[0]]=-1;
5253 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5254 weapons.velocity[weaponids[0]].x+=.01;
5255 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5256 weapons.missed[weaponids[0]]=1;
5257 weapons.hitsomething[weaponids[0]]=0;
5258 weapons.freetime[weaponids[0]]=0;
5259 weapons.firstfree[weaponids[0]]=1;
5260 weapons.physics[weaponids[0]]=1;
5263 weaponids[0]=weaponids[num_weapons];
5264 if(weaponstuck==num_weapons)weaponstuck=0;
5267 for(i=0;i<numplayers;i++){
5268 player[i].wentforweapon=0;
5274 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5282 //if(dead)damage-=multiplier/4;
5283 if(!dead)damage-=multiplier*13;
5284 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5285 if(!dead)permanentdamage-=multiplier*4;
5286 if(isIdle()||isCrouch()){
5287 if(!dead)permanentdamage-=multiplier*4;
5288 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5290 if(damage<0)damage=0;
5291 if(permanentdamage<0)permanentdamage=0;
5292 if(superpermanentdamage<0)superpermanentdamage=0;
5293 if(permanentdamage<superpermanentdamage){
5294 permanentdamage=superpermanentdamage;
5296 if(damage<permanentdamage){
5297 damage=permanentdamage;
5299 if(dead==1&&damage<damagetolerance){
5303 for(i=0;i<skeleton.num_joints;i++){
5304 skeleton.joints[i].velocity=0;
5307 if(permanentdamage>damagetolerance&&dead!=2){
5310 if(weaponactive!=-1){
5311 weapons.owner[weaponids[0]]=-1;
5312 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5313 weapons.velocity[weaponids[0]].x+=.01;
5314 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5315 weapons.missed[weaponids[0]]=1;
5316 weapons.hitsomething[weaponids[0]]=0;
5317 weapons.freetime[weaponids[0]]=0;
5318 weapons.firstfree[weaponids[0]]=1;
5319 weapons.physics[weaponids[0]]=1;
5322 weaponids[0]=weaponids[num_weapons];
5323 if(weaponstuck==num_weapons)weaponstuck=0;
5326 for(i=0;i<numplayers;i++){
5327 player[i].wentforweapon=0;
5333 if(!dead&&creature==wolftype){
5334 award_bonus(0, Wolfbonus);
5337 if(unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance)
5338 award_bonus(id, touchofdeath);
5339 if(id!=0&&unconscioustime>.1){
5355 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5356 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5357 OPENAL_SetVolume(channels[breaksound], 512);
5358 OPENAL_SetPaused(channels[breaksound], false);
5359 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5365 if(skeleton.free==1){
5366 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5369 //If knocked over, open hands and close mouth
5370 if(righthandmorphend!=0)righthandmorphness=0;
5371 righthandmorphend=0;
5372 targetrighthandmorphness=1;
5374 if(lefthandmorphend!=0)lefthandmorphness=0;
5376 targetlefthandmorphness=1;
5378 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5379 if(headmorphend!=0)headmorphness=0;
5381 targetheadmorphness=1;
5385 skeleton.DoGravity(&scale);
5387 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5388 if(damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1))
5389 award_bonus(id, deepimpact);
5390 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5394 for(j=0;j<skeleton.num_joints;j++){
5395 average+=skeleton.joints[j].position;
5399 coords+=average*scale;
5400 for(j=0;j<skeleton.num_joints;j++){
5401 skeleton.joints[j].position-=average;
5403 average/=multiplier;
5405 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5407 for(i=0;i<skeleton.num_joints;i++){
5408 velocity+=skeleton.joints[i].velocity*scale;
5410 velocity/=skeleton.num_joints;
5412 if(!isnormal(velocity.x)&&velocity.x){
5425 if(findLength(&average)<10&&dead&&skeleton.free){
5426 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5427 if(skeleton.longdead>2000){
5428 if(skeleton.longdead>6000){
5429 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5434 if(dead==2&&bloodloss<damagetolerance){
5436 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5438 if(bloodtoggle&&!bled){
5439 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5441 if(bloodtoggle&&!bled)
5442 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5443 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5444 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5448 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5452 if(dead==2&&bloodloss>=damagetolerance){
5454 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5455 if(bleeding<=0)DoBlood(1,255);
5456 if(bloodtoggle&&!bled){
5457 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5459 if(bloodtoggle&&!bled)
5460 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5461 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5462 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5466 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5473 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5475 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5479 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5480 if(velocity.y<-30)canrecover=0;
5481 for(i=0;i<objects.numobjects;i++){
5482 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5483 colviewer=startpoint;
5485 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5493 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5494 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5495 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5496 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5498 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5499 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5500 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5502 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5503 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5504 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5506 Normalise(&terrainnormal);
5508 targetrotation=-asin(0-terrainnormal.x);
5509 targetrotation*=360/6.28;
5510 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5511 rotation=targetrotation;
5513 //if(skeleton.forward.y<0){
5516 //if(skeleton.forward.y>-.3){
5519 targetanimation=flipanim;
5520 crouchtogglekeydown=1;
5525 currentanimation=tempanim;
5528 //tilt2=targettilt2;
5530 //if(middle.y>0)targetoffset.y=middle.y+1;
5532 for(i=0;i<skeleton.num_joints;i++){
5533 tempanimation.position[i][0]=skeleton.joints[i].position;
5534 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5539 if(findLength(&average)<10&&!dead&&skeleton.free){
5540 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5541 if(skeleton.longdead>(damage+500)*1.5){
5542 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5548 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5549 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5550 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5551 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5553 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5554 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5555 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5557 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5558 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5559 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5561 Normalise(&terrainnormal);
5563 targetrotation=-asin(0-terrainnormal.x);
5564 targetrotation*=360/6.28;
5565 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5566 rotation=targetrotation;
5569 terrainnormal=terrain.getNormal(coords.x,coords.z);
5570 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5574 /*XYZ otherterrainnormal;
5575 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5576 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5577 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5578 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5581 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5585 if(skeleton.forward.y<0){
5586 targetanimation=getupfrombackanim;
5590 if(skeleton.forward.y>-.3){
5591 targetanimation=getupfromfrontanim;
5593 targetrotation+=180;
5599 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5600 targetanimation=rollanim;
5601 targetrotation=lookrotation;
5605 if(forwardkeydown)targetrotation+=45;
5606 if(backkeydown)targetrotation-=45;
5610 if(forwardkeydown)targetrotation-=45;
5611 if(backkeydown)targetrotation+=45;
5614 if ( !leftkeydown&&!rightkeydown)
5615 targetrotation+=180;
5617 targetrotation+=180;
5621 if(abs(targettilt2)>50)targettilt2=0;
5622 currentanimation=tempanim;
5627 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5629 for(i=0;i<skeleton.num_joints;i++){
5630 tempanimation.position[i][0]=skeleton.joints[i].position;
5631 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5638 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5639 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5642 tempvelocity=velocity;
5643 Normalise(&tempvelocity);
5644 targetrotation=-asin(0-tempvelocity.x);
5645 targetrotation*=360/6.28;
5646 if(velocity.z<0)targetrotation=180-targetrotation;
5647 //targetrotation+=180;
5650 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5651 targetanimation=rollanim;
5655 targetanimation=backhandspringanim;
5656 targetrotation+=180;
5669 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
5670 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
5671 OPENAL_SetVolume(channels[movewhooshsound], 128);
5672 OPENAL_SetPaused(channels[movewhooshsound], false);
5674 currentanimation=targetanimation;
5675 currentframe=targetframe-1;
5680 rotation=targetrotation;
5687 if(skeleton.freefall==0)freefall=0;
5689 if(!isnormal(velocity.x)&&velocity.x){
5694 if(aitype!=passivetype||skeleton.free==1)
5695 if(findLengthfast(&velocity)>.1)
5696 for(i=0;i<objects.numobjects;i++){
5697 if(objects.type[i]==firetype)
5698 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){
5700 if(!objects.onfire[i]){
5703 gLoc[0]=objects.position[i].x;
5704 gLoc[1]=objects.position[i].y;
5705 gLoc[2]=objects.position[i].z;
5709 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5710 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5711 OPENAL_SetVolume(channels[firestartsound], 256);
5712 OPENAL_SetPaused(channels[firestartsound], false);
5714 objects.onfire[i]=1;
5717 if(objects.onfire[i]){
5722 if(objects.type[i]==bushtype)
5723 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){
5725 if(!objects.onfire[i]){
5728 gLoc[0]=objects.position[i].x;
5729 gLoc[1]=objects.position[i].y;
5730 gLoc[2]=objects.position[i].z;
5734 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5735 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5736 OPENAL_SetVolume(channels[firestartsound], 256);
5737 OPENAL_SetPaused(channels[firestartsound], false);
5739 objects.onfire[i]=1;
5743 if(objects.onfire[i]){
5747 if(objects.messedwith[i]<=0){
5759 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5760 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5761 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5762 OPENAL_SetPaused(channels[bushrustle], false);
5765 envsound[numenvsounds]=coords;
5766 envsoundvol[numenvsounds]=4*findLength(&velocity);
5767 envsoundlife[numenvsounds]=.4;
5772 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5773 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5775 if(environment!=desertenvironment)
5776 for(j=0;j<howmany;j++){
5777 tempvel.x=float(abs(Random()%100)-50)/20;
5778 tempvel.y=float(abs(Random()%100)-50)/20;
5779 tempvel.z=float(abs(Random()%100)-50)/20;
5782 pos.x+=float(abs(Random()%100)-50)/200;
5783 pos.y+=float(abs(Random()%100)-50)/200;
5784 pos.z+=float(abs(Random()%100)-50)/200;
5785 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);
5786 Sprite::setLastSpriteSpecial(1);
5788 howmany=findLength(&velocity)*4;
5790 if(environment==snowyenvironment)
5791 for(j=0;j<howmany;j++){
5792 tempvel.x=float(abs(Random()%100)-50)/20;
5793 tempvel.y=float(abs(Random()%100)-50)/20;
5794 tempvel.z=float(abs(Random()%100)-50)/20;
5797 pos.x+=float(abs(Random()%100)-50)/200;
5798 pos.y+=float(abs(Random()%100)-50)/200;
5799 pos.z+=float(abs(Random()%100)-50)/200;
5800 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5801 Sprite::setLastSpriteSpecial(2);
5804 objects.rotx[i]+=velocity.x*multiplier*6;
5805 objects.roty[i]+=velocity.z*multiplier*6;
5806 objects.messedwith[i]=.5;
5809 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
5810 if(objects.rotation2[i]==0)tempcoord=coords;
5812 tempcoord=coords-objects.position[i];
5813 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
5814 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
5815 tempcoord+=objects.position[i];
5817 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]){
5818 if(objects.messedwith[i]<=0){
5830 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5831 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5832 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5833 OPENAL_SetPaused(channels[bushrustle], false);
5836 envsound[numenvsounds]=coords;
5837 envsoundvol[numenvsounds]=4*findLength(&velocity);
5838 envsoundlife[numenvsounds]=.4;
5843 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5844 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5846 if(environment!=desertenvironment)
5847 for(j=0;j<howmany;j++){
5848 tempvel.x=float(abs(Random()%100)-50)/20;
5849 tempvel.y=float(abs(Random()%100)-50)/20;
5850 tempvel.z=float(abs(Random()%100)-50)/20;
5854 pos.x+=float(abs(Random()%100)-50)/150;
5855 pos.y+=float(abs(Random()%100)-50)/150;
5856 pos.z+=float(abs(Random()%100)-50)/150;
5857 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);
5858 Sprite::setLastSpriteSpecial(1);
5860 howmany=findLength(&velocity)*4;
5862 if(environment==snowyenvironment)
5863 for(j=0;j<howmany;j++){
5864 tempvel.x=float(abs(Random()%100)-50)/20;
5865 tempvel.y=float(abs(Random()%100)-50)/20;
5866 tempvel.z=float(abs(Random()%100)-50)/20;
5870 pos.x+=float(abs(Random()%100)-50)/150;
5871 pos.y+=float(abs(Random()%100)-50)/150;
5872 pos.z+=float(abs(Random()%100)-50)/150;
5873 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5874 Sprite::setLastSpriteSpecial(2);
5877 objects.messedwith[i]=.5;
5885 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
5887 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
5888 if(tutoriallevel==1&&id!=0)play=0;
5889 if(play&&aitype!=playercontrolled){
5901 if(creature==rabbittype){
5902 if(i==0)whichsound=rabbitchitter;
5903 if(i==1)whichsound=rabbitchitter2;
5905 if(creature==wolftype){
5906 if(i==0)whichsound=growlsound;
5907 if(i==1)whichsound=growl2sound;
5913 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
5914 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
5915 OPENAL_SetVolume(channels[whichsound], 512);
5916 OPENAL_SetPaused(channels[whichsound], false);
5920 if(targetanimation==staggerbackhighanim)staggerdelay=1;
5921 if(targetanimation==staggerbackhardanim)staggerdelay=1;
5922 staggerdelay-=multiplier;
5923 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
5924 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
5925 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
5926 targetanimation=getIdle();
5930 weaponmissdelay-=multiplier;
5931 highreversaldelay-=multiplier;
5932 lowreversaldelay-=multiplier;
5933 lastcollide-=multiplier;
5934 skiddelay-=multiplier;
5935 if(!isnormal(velocity.x)&&velocity.x){
5938 if(!isnormal(targettilt)&&targettilt){
5941 if(!isnormal(targettilt2)&&targettilt2){
5944 if(!isnormal(targetrotation)&&targetrotation){
5948 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
5949 //open hands and close mouth
5950 //if(targetanimation!=wolfidle){
5951 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
5952 righthandmorphness=0;
5953 righthandmorphend=0;
5954 targetrighthandmorphness=1;
5957 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
5958 lefthandmorphness=0;
5960 targetlefthandmorphness=1;
5964 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
5967 targetheadmorphness=1;
5971 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){
5972 //open hands and mouth
5973 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
5974 righthandmorphness=0;
5975 righthandmorphend=0;
5976 targetrighthandmorphness=1;
5979 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
5980 lefthandmorphness=0;
5982 targetlefthandmorphness=1;
5985 if(headmorphend!=1&&headmorphness==targetheadmorphness){
5988 targetheadmorphness=1;
5992 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
5993 //close hands and mouth
5994 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
5995 righthandmorphness=0;
5996 righthandmorphend=1;
5997 targetrighthandmorphness=1;
6000 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6001 lefthandmorphness=0;
6003 targetlefthandmorphness=1;
6006 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6009 targetheadmorphness=1;
6013 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){
6014 //close hands and yell
6015 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6016 righthandmorphness=0;
6017 righthandmorphend=1;
6018 targetrighthandmorphness=1;
6021 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6022 lefthandmorphness=0;
6024 targetlefthandmorphness=1;
6027 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6030 targetheadmorphness=1;
6034 if(speechdelay>.25){
6035 if(headmorphend!=2)headmorphness=0;
6037 targetheadmorphness=1;
6043 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6044 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6048 if(!dead&&targetanimation!=hurtidleanim)
6049 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6050 if(headmorphend!=4||headmorphness==targetheadmorphness){
6053 targetheadmorphness=1;
6057 if(weaponactive!=-1){
6058 if(weapons.type[weaponids[weaponactive]]!=staff){
6059 righthandmorphstart=1;
6060 righthandmorphend=1;
6062 if(weapons.type[weaponids[weaponactive]]==staff){
6063 righthandmorphstart=2;
6064 righthandmorphend=2;
6066 targetrighthandmorphness=1;
6069 terrainnormal=terrain.getNormal(coords.x,coords.z);
6071 if(animation[targetanimation].attack!=reversal){
6072 if(!isnormal(coords.x))
6080 flatfacing=DoRotation(flatfacing,0,rotation,0);
6082 ReflectVector(&facing,terrainnormal);
6085 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6086 if(onterrain)targettilt2=-facing.y*20;
6090 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6091 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6092 flatvelocity=velocity;
6094 flatvelspeed=findLength(&flatvelocity);
6095 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6096 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6097 if(velocity.y<0)targettilt2*=-1;
6098 if(velocity.y<0)targettilt*=-1;
6099 if(targettilt>25)targettilt=25;
6100 if(targettilt<-25)targettilt=-25;
6103 if(targettilt2>45)targettilt2=45;
6104 if(targettilt2<-45)targettilt2=-45;
6105 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6106 else if(tilt2>targettilt2){
6107 tilt2-=multiplier*400;
6109 else if(tilt2<targettilt2){
6110 tilt2+=multiplier*400;
6112 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6113 if(tilt2>25)tilt2=25;
6114 if(tilt2<-25)tilt2=-25;
6117 if(!isnormal(targettilt)&&targettilt){
6120 if(!isnormal(targettilt2)&&targettilt2){
6125 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6126 if(targetanimation==rabbittackleanim){
6127 velocity+=facing*multiplier*speed*700*scale;
6128 velspeed=findLength(&velocity);
6129 if(velspeed>speed*65*scale){
6131 velspeed=speed*65*scale;
6134 velocity.y+=gravity*multiplier*20;
6135 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6136 velspeed=findLength(&velocity);
6137 velocity=flatfacing*velspeed;
6139 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6140 if(isRun()||targetanimation==rabbitkickanim){
6141 velocity+=facing*multiplier*speed*700*scale;
6142 velspeed=findLength(&velocity);
6143 if(velspeed>speed*45*scale){
6145 velspeed=speed*45*scale;
6148 velocity.y+=gravity*multiplier*20;
6149 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6150 velspeed=findLength(&velocity);
6151 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6152 velocity=flatfacing*velspeed;
6156 velocity+=facing*multiplier*speed*700*scale;
6157 velspeed=findLength(&velocity);
6158 if(creature==rabbittype){
6159 if(velspeed>speed*55*scale){
6161 velspeed=speed*55*scale;
6165 if(creature==wolftype){
6166 if(velspeed>speed*75*scale){
6168 velspeed=speed*75*scale;
6172 velocity.y+=gravity*multiplier*20;
6173 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6174 velspeed=findLength(&velocity);
6175 velocity=flatfacing*velspeed;
6178 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6179 velocity+=facing*multiplier*speed*700*scale;
6180 velspeed=findLength(&velocity);
6181 if(velspeed>speed*45*scale){
6183 velspeed=speed*45*scale;
6186 velocity.y+=gravity*multiplier*20;
6187 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6188 velspeed=findLength(&velocity);
6189 velocity=flatfacing*velspeed;
6193 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6194 velocity+=facing*multiplier*speed*700*scale;
6195 velspeed=findLength(&velocity);
6196 if(velspeed>speed*25*scale){
6198 velspeed=speed*25*scale;
6201 velocity.y+=gravity*multiplier*20;
6202 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6203 velspeed=findLength(&velocity);
6204 velocity=flatfacing*velspeed;
6207 if(targetanimation==sneakanim||targetanimation==walkanim){
6208 velocity+=facing*multiplier*speed*700*scale;
6209 velspeed=findLength(&velocity);
6210 if(velspeed>speed*12*scale){
6212 velspeed=speed*12*scale;
6215 velocity.y+=gravity*multiplier*20;
6216 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6217 velspeed=findLength(&velocity);
6218 velocity=flatfacing*velspeed;
6221 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6222 velocity+=facing*multiplier*speed*700*scale;
6223 velspeed=findLength(&velocity);
6224 if(velspeed>speed*2*scale){
6226 velspeed=speed*2*scale;
6229 velocity.y+=gravity*multiplier*20;
6230 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6231 velspeed=findLength(&velocity);
6232 velocity=flatfacing*velspeed;
6236 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6237 velocity-=facing*multiplier*speed*700*scale;
6238 velspeed=findLength(&velocity);
6239 if(velspeed>speed*2*scale){
6241 velspeed=speed*2*scale;
6244 velocity.y+=gravity*multiplier*20;
6245 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6246 velspeed=findLength(&velocity);
6247 velocity=flatfacing*velspeed*-1;
6250 if(targetanimation==fightsidestep){
6251 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6252 velspeed=findLength(&velocity);
6253 if(velspeed>speed*12*scale){
6255 velspeed=speed*12*scale;
6258 velocity.y+=gravity*multiplier*20;
6259 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6260 velspeed=findLength(&velocity);
6261 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6264 if(targetanimation==staggerbackhighanim){
6265 coords-=facing*multiplier*speed*16*scale;
6268 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6269 coords-=facing*multiplier*speed*20*scale;
6273 if(targetanimation==backhandspringanim){
6274 //coords-=facing*multiplier*50*scale;
6275 velocity+=facing*multiplier*speed*700*scale*-1;
6276 velspeed=findLength(&velocity);
6277 if(velspeed>speed*50*scale){
6279 velspeed=speed*50*scale;
6282 velocity.y+=gravity*multiplier*20;
6283 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6284 velspeed=findLength(&velocity);
6285 velocity=flatfacing*velspeed*-1;
6287 if(targetanimation==dodgebackanim){
6288 //coords-=facing*multiplier*50*scale;
6289 velocity+=facing*multiplier*speed*700*scale*-1;
6290 velspeed=findLength(&velocity);
6291 if(velspeed>speed*60*scale){
6293 velspeed=speed*60*scale;
6296 velocity.y+=gravity*multiplier*20;
6297 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6298 velspeed=findLength(&velocity);
6299 velocity=flatfacing*velspeed*-1;
6302 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6303 velspeed=findLength(&velocity);
6307 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6308 velocity.y+=gravity*multiplier;
6311 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6313 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6314 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6316 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6322 OPENAL_SetPaused(channels[whooshsound], true);
6323 OPENAL_SetVolume(channels[whooshsound], 0);
6326 if(targetanimation==jumpdownanim||isFlip()){
6327 if(isFlip())jumppower=-4;
6328 targetanimation=getLanding();
6337 PlaySoundEx( landsound, samp[landsound], NULL, true);
6338 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6339 OPENAL_SetVolume(channels[landsound], 128);
6340 OPENAL_SetPaused(channels[landsound], false);
6343 envsound[numenvsounds]=coords;
6344 envsoundvol[numenvsounds]=16;
6345 envsoundlife[numenvsounds]=.4;
6351 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6352 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6353 coords.y=terrain.getHeight(coords.x,coords.z);
6358 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)){
6359 velspeed=findLength(&velocity);
6361 if(velspeed<multiplier*300*scale){
6363 } else velocity-=velocity/velspeed*multiplier*300*scale;
6364 if(velspeed>5&&(isLanding()||isLandhard())){
6365 skiddingdelay+=multiplier;
6372 else skiddingdelay=0;
6376 velspeed=findLength(&velocity);
6378 if(velspeed<multiplier*600*scale){
6380 } else velocity-=velocity/velspeed*multiplier*600*scale;
6382 if(velspeed>5&&(isLanding()||isLandhard())){
6383 skiddingdelay+=multiplier;
6390 else skiddingdelay=0;
6393 if(skiddingdelay<0)skiddingdelay+=multiplier;
6394 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6404 if(!onterrain||environment==grassyenvironment){
6405 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6406 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6407 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6408 OPENAL_SetPaused(channels[skidsound], false);
6411 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6412 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6413 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6414 OPENAL_SetPaused(channels[snowskidsound], false);
6418 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6419 terrainnormal=victim->coords-coords;
6420 Normalise(&terrainnormal);
6421 targetrotation=-asin(0-terrainnormal.x);
6422 targetrotation*=360/6.28;
6423 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6424 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6427 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6428 targetrotation=victim->targetrotation;
6430 if(targetanimation==rabbittacklinganim){
6431 coords=victim->coords;
6434 skeleton.oldfree=skeleton.free;
6438 midterrain.x=terrain.size*terrain.scale/2;
6439 midterrain.z=terrain.size*terrain.scale/2;
6440 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6442 tempposit=coords-midterrain;
6444 Normalise(&tempposit);
6445 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6446 coords.x=tempposit.x+midterrain.x;
6447 coords.z=tempposit.z+midterrain.z;
6451 int Person::DrawSkeleton(){
6452 int oldplayerdetail;
6453 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6454 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6464 glAlphaFunc(GL_GREATER, 0.0001);
6466 float terrainheight;
6468 if(!isnormal(rotation))rotation=0;
6469 if(!isnormal(tilt))tilt=0;
6470 if(!isnormal(tilt2))tilt2=0;
6471 oldplayerdetail=playerdetail;
6473 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6476 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6479 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6484 if(playerdetail!=oldplayerdetail) {
6486 normalsupdatedelay=0;
6488 static float updatedelaychange;
6489 static float morphness;
6490 static float framemult;
6492 skeleton.FindForwards();
6493 if(howactive==typesittingwall){
6494 skeleton.specialforward[1]=0;
6495 skeleton.specialforward[1].z=1;
6501 static int weaponattachmuscle;
6502 static int weaponrotatemuscle,weaponrotatemuscle2;
6503 static XYZ weaponpoint;
6504 static int start,endthing;
6505 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6506 if(!isSleeping()&&!isSitting()){
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);
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);
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);
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);
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);
6549 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6550 XYZ point,newpoint,change,change2;
6551 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6552 heightleft=terrain.getHeight(point.x,point.z)+.04;
6554 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6555 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6556 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6557 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6558 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6560 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6561 heightright=terrain.getHeight(point.x,point.z)+.04;
6562 point.y=heightright;
6563 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6564 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6565 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6566 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6567 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6568 skeleton.DoConstraints(&coords,&scale);
6570 if(creature==wolftype){
6571 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6572 heightleft=terrain.getHeight(point.x,point.z)+.04;
6574 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6575 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6576 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6577 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6578 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6580 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6581 heightright=terrain.getHeight(point.x,point.z)+.04;
6582 point.y=heightright;
6583 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6584 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6585 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6586 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6587 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6588 skeleton.DoConstraints(&coords,&scale);
6592 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6593 XYZ point,newpoint,change,change2;
6594 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6595 heightleft=terrain.getHeight(point.x,point.z)+.04;
6597 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6598 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6599 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6600 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6601 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6603 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6604 heightright=terrain.getHeight(point.x,point.z)+.04;
6605 point.y=heightright;
6606 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6607 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6608 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6609 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6610 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6611 skeleton.DoConstraints(&coords,&scale);
6613 if(creature==wolftype){
6614 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6615 heightleft=terrain.getHeight(point.x,point.z)+.04;
6617 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6618 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6619 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6620 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6621 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6623 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6624 heightright=terrain.getHeight(point.x,point.z)+.04;
6625 point.y=heightright;
6626 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6627 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6628 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6629 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6630 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6631 skeleton.DoConstraints(&coords,&scale);
6635 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()))
6638 targetheadrotation=-targetrotation;
6639 targetheadrotation2=0;
6640 if(animation[targetanimation].attack==3)targetheadrotation+=180;
6642 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6643 skeleton.drawmodel.vertex[i]=0;
6644 skeleton.drawmodel.vertex[i].y=999;
6646 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
6647 skeleton.drawmodellow.vertex[i]=0;
6648 skeleton.drawmodellow.vertex[i].y=999;
6650 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
6651 skeleton.drawmodelclothes.vertex[i]=0;
6652 skeleton.drawmodelclothes.vertex[i].y=999;
6654 for(i=0;i<skeleton.num_muscles;i++){
6655 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
6659 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
6660 morphness=righthandmorphness;
6661 start=righthandmorphstart;
6662 endthing=righthandmorphend;
6664 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
6665 morphness=lefthandmorphness;
6666 start=lefthandmorphstart;
6667 endthing=lefthandmorphend;
6669 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
6670 morphness=headmorphness;
6671 start=headmorphstart;
6672 endthing=headmorphend;
6674 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)){
6675 morphness=chestmorphness;
6676 start=chestmorphstart;
6677 endthing=chestmorphend;
6679 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)){
6680 morphness=tailmorphness;
6681 start=tailmorphstart;
6682 endthing=tailmorphend;
6684 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
6685 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6686 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6689 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6690 if(!skeleton.free)glRotatef(tilt,0,0,1);
6693 glTranslatef(mid.x,mid.y,mid.z);
6695 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6696 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6698 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6699 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6701 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6702 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6704 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
6708 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
6712 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
6716 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
6721 if(playerdetail||skeleton.free==3)
6723 for(j=0;j<skeleton.muscles[i].numvertices;j++)
6725 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
6726 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
6727 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
6728 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
6729 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
6730 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
6731 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
6732 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6734 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6735 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,
6736 (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,
6737 (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);
6738 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)
6739 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,
6740 (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,
6741 (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);
6742 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)
6743 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,
6744 (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,
6745 (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);
6746 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6747 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,
6748 (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,
6749 (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);
6750 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6751 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
6752 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
6753 //if(!isnormal(scale))test=1;
6754 //if(isnormal(scale)){
6755 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
6756 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
6757 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
6765 if(!playerdetail||skeleton.free==3)
6767 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
6769 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
6770 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6772 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6773 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
6774 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
6775 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
6776 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)
6777 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
6778 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
6779 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
6780 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)
6781 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
6782 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
6783 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
6784 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6785 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
6786 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
6787 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
6789 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6790 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
6791 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
6792 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
6799 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
6800 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6802 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6805 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6806 if(!skeleton.free)glRotatef(tilt,0,0,1);
6807 glTranslatef(mid.x,mid.y,mid.z);
6808 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6809 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6811 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6812 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6814 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6815 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6817 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
6818 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6820 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6821 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
6822 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
6823 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
6824 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)
6825 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
6826 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
6827 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
6828 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)
6829 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
6830 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
6831 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
6832 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6833 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
6834 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
6835 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
6836 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6837 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
6838 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
6839 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
6844 updatedelay=1+(float)(Random()%100)/1000;
6846 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
6847 normalsupdatedelay=1;
6848 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
6849 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
6850 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
6854 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
6855 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
6856 if(skeleton.clothes){
6857 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
6862 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
6863 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
6864 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
6865 if(skeleton.free==1)updatedelaychange*=6;
6866 if(id==0)updatedelaychange*=8;
6867 updatedelay+=updatedelaychange;
6869 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6871 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
6872 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
6873 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
6874 if(!skeleton.free)glRotatef(rotation,0,1,0);
6877 glColor4f(.4,1,.4,1);
6878 glDisable(GL_LIGHTING);
6879 glDisable(GL_TEXTURE_2D);
6882 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6883 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
6889 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
6890 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);
6891 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);
6892 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);
6893 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);
6894 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);
6895 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);
6901 terrainlight=terrain.getLighting(coords.x,coords.z);
6902 distance=findDistancefast(&viewer,&coords);
6903 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
6904 if(distance>1)distance=1;
6906 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
6907 if(terrainheight<1)terrainheight=1;
6908 if(terrainheight>1.7)terrainheight=1.7;
6911 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
6912 glDisable(GL_BLEND);
6913 glAlphaFunc(GL_GREATER, 0.0001);
6914 glEnable(GL_TEXTURE_2D);
6916 glDisable(GL_TEXTURE_2D);
6917 glColor4f(.7,.35,0,.5);
6919 glEnable(GL_LIGHTING);
6922 if(tutoriallevel&&id!=0){
6923 //glDisable(GL_TEXTURE_2D);
6924 glColor4f(.7,.7,.7,0.6);
6926 glEnable(GL_LIGHTING);
6928 if(canattack&&cananger)
6929 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
6930 glDisable(GL_TEXTURE_2D);
6931 glColor4f(1,0,0,0.8);
6933 glMatrixMode(GL_TEXTURE);
6935 glTranslatef(0,-smoketex,0);
6936 glTranslatef(-smoketex,0,0);
6940 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
6941 else skeleton.drawmodel.draw();
6945 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
6946 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
6949 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
6950 if(tutoriallevel&&id!=0){
6952 glMatrixMode(GL_MODELVIEW);
6953 glEnable(GL_TEXTURE_2D);
6954 glColor4f(.7,.7,.7,0.6);
6956 glEnable(GL_LIGHTING);
6958 if(canattack&&cananger)
6959 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
6960 glDisable(GL_TEXTURE_2D);
6961 glColor4f(1,0,0,0.8);
6963 glMatrixMode(GL_TEXTURE);
6965 glTranslatef(0,-smoketex*.6,0);
6966 glTranslatef(smoketex*.6,0,0);
6969 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
6970 else skeleton.drawmodel.draw();
6974 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
6975 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
6980 if(tutoriallevel&&id!=0){
6982 glMatrixMode(GL_MODELVIEW);
6983 glEnable(GL_TEXTURE_2D);
6985 if(skeleton.clothes){
6988 if(!immediate)skeleton.drawmodelclothes.draw();
6989 if(immediate)skeleton.drawmodelclothes.drawimmediate();
6996 for(k=0;k<num_weapons;k++){
6998 if(weaponactive==k){
6999 if(weapons.type[i]!=staff){
7000 for(j=0;j<skeleton.num_muscles;j++){
7001 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7002 weaponattachmuscle=j;
7005 for(j=0;j<skeleton.num_muscles;j++){
7006 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){
7007 weaponrotatemuscle=j;
7010 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7011 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7013 if(weapons.type[i]==staff){
7014 for(j=0;j<skeleton.num_muscles;j++){
7015 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7016 weaponattachmuscle=j;
7019 for(j=0;j<skeleton.num_muscles;j++){
7020 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){
7021 weaponrotatemuscle=j;
7024 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7025 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7026 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7027 XYZ tempnormthing,vec1,vec2;
7028 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7029 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7030 CrossProduct(&vec1,&vec2,&tempnormthing);
7031 Normalise(&tempnormthing);
7032 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);
7033 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7035 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7036 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7037 Normalise(&weaptargnorm);
7038 weaponpoint-=weaptargnorm*2;
7042 if(weaponactive!=k&&weaponstuck!=k){
7043 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;
7044 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;
7045 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;
7046 for(j=0;j<skeleton.num_muscles;j++){
7047 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){
7048 weaponrotatemuscle=j;
7053 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7054 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7055 for(j=0;j<skeleton.num_muscles;j++){
7056 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){
7057 weaponrotatemuscle=j;
7062 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;
7063 weapons.bigrotation[i]=rotation;
7064 weapons.bigtilt[i]=tilt;
7065 weapons.bigtilt2[i]=tilt2;
7068 weapons.position[i]=weaponpoint*scale+coords;
7069 weapons.bigrotation[i]=0;
7070 weapons.bigtilt[i]=0;
7071 weapons.bigtilt2[i]=0;
7073 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7074 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7075 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7076 if(weaponactive==k){
7077 if(weapons.type[i]==knife){
7078 weapons.smallrotation[i]=180;
7079 weapons.smallrotation2[i]=0;
7080 if(isCrouch()||wasCrouch()){
7081 weapons.smallrotation2[i]=20;
7083 if(targetanimation==hurtidleanim){
7084 weapons.smallrotation2[i]=50;
7086 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7087 XYZ temppoint1,temppoint2,tempforward;
7090 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7091 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7092 distance=findDistance(&temppoint1,&temppoint2);
7093 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7094 weapons.rotation2[i]*=360/6.28;
7097 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7098 weapons.rotation1[i]*=360/6.28;
7099 weapons.rotation3[i]=0;
7100 weapons.smallrotation[i]=-90;
7101 weapons.smallrotation2[i]=0;
7102 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7104 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7105 XYZ temppoint1,temppoint2,tempforward;
7108 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7109 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7110 distance=findDistance(&temppoint1,&temppoint2);
7111 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7112 weapons.rotation2[i]*=360/6.28;
7115 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7116 weapons.rotation1[i]*=360/6.28;
7117 weapons.rotation3[i]=0;
7118 weapons.smallrotation[i]=90;
7119 weapons.smallrotation2[i]=0;
7120 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7122 if(targetanimation==knifethrowanim){
7123 weapons.smallrotation[i]=90;
7124 //weapons.smallrotation2[i]=-90;
7125 weapons.smallrotation2[i]=0;
7126 weapons.rotation1[i]=0;
7127 weapons.rotation2[i]=0;
7128 weapons.rotation3[i]=0;
7130 if(targetanimation==knifesneakattackanim&&targetframe<5){
7131 weapons.smallrotation[i]=-90;
7132 weapons.rotation1[i]=0;
7133 weapons.rotation2[i]=0;
7134 weapons.rotation3[i]=0;
7137 if(weapons.type[i]==sword){
7138 weapons.smallrotation[i]=0;
7139 weapons.smallrotation2[i]=0;
7140 if(targetanimation==knifethrowanim){
7141 weapons.smallrotation[i]=-90;
7142 weapons.smallrotation2[i]=0;
7143 weapons.rotation1[i]=0;
7144 weapons.rotation2[i]=0;
7145 weapons.rotation3[i]=0;
7147 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)){
7148 XYZ temppoint1,temppoint2,tempforward;
7151 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7152 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7153 distance=findDistance(&temppoint1,&temppoint2);
7154 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7155 weapons.rotation2[i]*=360/6.28;
7158 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7159 weapons.rotation1[i]*=360/6.28;
7160 weapons.rotation3[i]=0;
7161 weapons.smallrotation[i]=90;
7162 weapons.smallrotation2[i]=0;
7163 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7166 if(weapons.type[i]==staff){
7167 weapons.smallrotation[i]=100;
7168 weapons.smallrotation2[i]=0;
7169 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7170 XYZ temppoint1,temppoint2,tempforward;
7173 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7174 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7175 distance=findDistance(&temppoint1,&temppoint2);
7176 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7177 weapons.rotation2[i]*=360/6.28;
7180 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7181 weapons.rotation1[i]*=360/6.28;
7182 weapons.rotation3[i]=0;
7183 weapons.smallrotation[i]=90;
7184 weapons.smallrotation2[i]=0;
7185 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7189 if(weaponactive!=k&&weaponstuck!=k){
7190 if(weapons.type[i]==knife){
7191 weapons.smallrotation[i]=-70;
7192 weapons.smallrotation2[i]=10;
7194 if(weapons.type[i]==sword){
7195 weapons.smallrotation[i]=-100;
7196 weapons.smallrotation2[i]=-8;
7198 if(weapons.type[i]==staff){
7199 weapons.smallrotation[i]=-100;
7200 weapons.smallrotation2[i]=-8;
7204 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7205 else weapons.smallrotation[i]=0;
7206 weapons.smallrotation2[i]=10;
7207 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7215 if(skeleton.free)calcrot=1;
7216 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7217 if(currentanimation!=targetanimation)calcrot=1;
7218 //if(id==0)calcrot=1;
7219 if(skeleton.free==2)calcrot=0;
7225 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7228 static float distance;
7229 static float olddistance;
7230 static int intersecting;
7231 static int firstintersecting;
7234 static XYZ start,end;
7235 static float slopethreshold=-.4;
7237 firstintersecting=-1;
7241 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7242 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7244 for (j=0;j<model->TriangleNum;j++){
7245 if(model->facenormals[j].y<=slopethreshold){
7247 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)));
7248 if(distance<radius){
7249 point=*p1-model->facenormals[j]*distance;
7250 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;
7251 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7252 &model->vertex[model->Triangles[j].vertex[1]],
7254 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7255 &model->vertex[model->Triangles[j].vertex[2]],
7257 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7258 &model->vertex[model->Triangles[j].vertex[2]],
7261 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7265 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)){
7266 p1->y=point.y+radius;
7267 if((targetanimation==jumpdownanim||isFlip())){
7268 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7270 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7276 OPENAL_SetPaused(channels[whooshsound], true);
7277 OPENAL_SetVolume(channels[whooshsound], 0);
7280 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7281 if(isFlip())jumppower=-4;
7282 targetanimation=getLanding();
7291 PlaySoundEx( landsound, samp[landsound], NULL, true);
7292 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7293 OPENAL_SetVolume(channels[landsound], 128);
7294 OPENAL_SetPaused(channels[landsound], false);
7297 envsound[numenvsounds]=coords;
7298 envsoundvol[numenvsounds]=16;
7299 envsoundlife[numenvsounds]=.4;
7307 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7310 for (j=0;j<model->TriangleNum;j++){
7311 if(model->facenormals[j].y>slopethreshold){
7315 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)));
7316 if(distance<radius*.5){
7317 point=start-model->facenormals[j]*distance;
7318 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;
7319 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,
7320 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7321 p1->x, p1->y, p1->z, radius/2);
7322 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,
7323 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7324 p1->x, p1->y, p1->z, radius/2);
7325 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,
7326 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7327 p1->x, p1->y, p1->z, radius/2);
7329 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7330 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7332 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7333 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7335 *p1+=model->facenormals[j]*(distance-radius*.5);
7338 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7342 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7344 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7346 return firstintersecting;
7356 currentanimation = 0;
7357 targetanimation = 0;
7358 oldcurrentframe = 0;
7360 oldcurrentanimation = 0;
7361 oldtargetanimation = 0;
7365 parriedrecently = 0;
7369 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7371 currentoffset = 0,targetoffset = 0,offset = 0;
7389 unconscioustime = 0;
7407 rabbitkickenabled = 0;
7416 damagetolerance = 0;
7418 permanentdamage = 0;
7419 superpermanentdamage = 0; lastcollide = 0;
7439 headrotation = 0,headrotation2 = 0;
7440 targetheadrotation = 0,targetheadrotation2 = 0;
7451 normalsupdatedelay = 0;
7456 forwardstogglekeydown = 0;
7461 jumptogglekeydown = 0;
7463 crouchtogglekeydown = 0;
7465 drawtogglekeydown = 0;
7467 throwtogglekeydown = 0;
7473 crouchkeydowntime = 0;
7474 jumpkeydowntime = 0;
7491 whichdirectiondelay = 0;
7492 avoidsomething = 0; avoidwhere = 0;
7500 lefthandmorphness = 0;
7501 righthandmorphness = 0;
7505 targetlefthandmorphness = 0;
7506 targetrighthandmorphness = 0;
7507 targetheadmorphness = 0;
7508 targetchestmorphness = 0;
7509 targettailmorphness = 0;
7510 lefthandmorphstart = 0,lefthandmorphend = 0;
7511 righthandmorphstart = 0,righthandmorphend = 0;
7512 headmorphstart = 0,headmorphend = 0;
7513 chestmorphstart = 0,chestmorphend = 0;
7514 tailmorphstart = 0,tailmorphend = 0;
7516 weaponmissdelay = 0;
7517 highreversaldelay = 0;
7518 lowreversaldelay = 0;
7525 //Skeleton skeleton;
7544 memset(clothes, 0, sizeof(clothes));
7545 memset(clothestintr, 0, sizeof(clothestintr));
7546 memset(clothestintg, 0, sizeof(clothestintg));
7547 memset(clothestintb, 0, sizeof(clothestintb));
7553 onfiredelay = 0; burnt = 0;
7557 updatestuffdelay = 0;
7563 memset(weaponids, 0, sizeof(weaponids));
7567 weaponstuckwhere = 0;
7572 memset(waypoints, 0, sizeof(waypoints));
7573 memset(waypointtype, 0, sizeof(waypointtype));
7576 hastempwaypoint = 0;
7582 finalfinaltarget = 0;
7584 finalpathfindpoint = 0;
7585 targetpathfindpoint = 0;
7586 lastpathfindpoint = 0;
7587 lastpathfindpoint2 = 0;
7588 lastpathfindpoint3 = 0;
7589 lastpathfindpoint4 = 0;
7600 runninghowlong = 0; lastoccluded = 0;
7606 neckspurtparticledelay = 0;
7607 neckspurtamount = 0;
7610 rabbitkickragdoll = 0;
7615 //Animation tempanimation;