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);
1824 if(victim->aitype==gethelptype)bonusvalue=50;
1829 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1830 if(weapons.type[weaponids[0]]==knife){
1831 if(weaponactive==-1)weaponactive=0;
1832 else if(weaponactive==0)weaponactive=-1;
1834 if(weaponactive==-1){
1844 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
1845 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
1846 OPENAL_SetVolume(channels[knifesheathesound], 128);
1847 OPENAL_SetPaused(channels[knifesheathesound], false);
1849 if(weaponactive!=-1){
1859 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1860 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1861 OPENAL_SetVolume(channels[knifedrawsound], 128);
1862 OPENAL_SetPaused(channels[knifedrawsound], false);
1865 drawtogglekeydown=1;
1868 if(tutoriallevel!=1||id==0)
1869 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1880 if(terrain.getOpacity(coords.x,coords.z)<.2){
1881 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1882 else whichsound=footstepsound2;
1883 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1884 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1885 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1891 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1892 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1893 else whichsound=footstepsound4;
1897 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1898 else whichsound=footstepsound4;
1900 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1901 if(animation[targetanimation].attack!=neutral){
1903 if(i==0)whichsound=lowwhooshsound;
1904 if(i==1)whichsound=midwhooshsound;
1905 if(i==2)whichsound=highwhooshsound;
1907 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1909 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1910 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1912 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1913 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1914 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
1915 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
1916 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
1917 OPENAL_SetPaused(channels[whichsound], false);
1920 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1921 envsound[numenvsounds]=coords;
1922 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1923 else envsoundvol[numenvsounds]=6;
1924 envsoundlife[numenvsounds]=.4;
1928 if(animation[targetanimation].label[targetframe]==3){
1930 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1931 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1932 OPENAL_SetVolume(channels[whichsound], 128);
1933 OPENAL_SetPaused(channels[whichsound], false);
1938 if(tutoriallevel!=1||id==0)
1940 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1941 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1951 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1952 if(animation[targetanimation].attack!=neutral){
1954 if(creature==rabbittype){
1955 if(i==0)whichsound=rabbitattacksound;
1956 if(i==1)whichsound=rabbitattack2sound;
1957 if(i==2)whichsound=rabbitattack3sound;
1958 if(i==3)whichsound=rabbitattack4sound;
1960 if(creature==wolftype){
1961 if(i==0)whichsound=barksound;
1962 if(i==1)whichsound=bark2sound;
1963 if(i==2)whichsound=bark3sound;
1964 if(i==3)whichsound=barkgrowlsound;
1968 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1970 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1971 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
1974 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1975 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1976 OPENAL_SetVolume(channels[whichsound], 512);
1977 OPENAL_SetPaused(channels[whichsound], false);
1983 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
1989 currentoffset=targetoffset;
1990 targetframe=currentframe;
1991 currentanimation=targetanimation;
1994 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
1995 for(i=0;i<weapons.numweapons;i++){
1996 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
1997 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
1998 if(findDistancefast(&coords,&weapons.position[i])>=1){
1999 if(weapons.type[i]!=staff){
2008 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2009 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2010 OPENAL_SetVolume(channels[knifedrawsound], 128);
2011 OPENAL_SetPaused(channels[knifedrawsound], false);
2015 weapons.owner[i]=id;
2017 weaponids[num_weapons]=weaponids[0];
2026 static bool willwork;
2027 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2028 for(i=0;i<weapons.numweapons;i++){
2030 if(weapons.owner[i]!=-1)
2031 if(player[weapons.owner[i]].weaponstuck!=-1)
2032 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2033 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2034 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))
2035 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2036 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2046 if(weapons.owner[i]!=-1)
2047 if(victim->weaponstuck!=-1){
2048 if(victim->weaponids[victim->weaponstuck]==i){
2053 if(weapons.type[i]!=staff){
2054 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2055 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2056 OPENAL_SetVolume(channels[knifedrawsound], 128);
2057 OPENAL_SetPaused(channels[knifedrawsound], false);
2061 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2062 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2063 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2064 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2067 if(weapons.owner[i]!=-1){
2069 victim=&player[weapons.owner[i]];
2070 if(victim->num_weapons==1)victim->num_weapons=0;
2071 else victim->num_weapons=1;
2073 //victim->weaponactive=-1;
2074 victim->skeleton.longdead=0;
2075 victim->skeleton.free=1;
2076 victim->skeleton.broken=0;
2078 for(int j=0;j<victim->skeleton.num_joints;j++){
2079 victim->skeleton.joints[j].velchange=0;
2080 victim->skeleton.joints[j].locked=0;
2086 Normalise(&relative);
2087 XYZ footvel,footpoint;
2089 footpoint=weapons.position[i];
2090 if(victim->weaponstuck!=-1){
2091 if(victim->weaponids[victim->weaponstuck]==i){
2092 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2093 weapons.bloody[i]=2;
2094 weapons.blooddrip[i]=5;
2095 victim->weaponstuck=-1;
2098 if(victim->num_weapons>0){
2099 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2100 if(victim->weaponids[0]==i)
2101 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2104 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2105 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2106 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2107 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2109 weapons.owner[i]=id;
2111 weaponids[num_weapons]=weaponids[0];
2120 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2121 if(weaponactive==-1)weaponactive=0;
2122 else if(weaponactive==0){
2126 buffer=weaponids[0];
2127 weaponids[0]=weaponids[1];
2128 weaponids[1]=buffer;
2131 if(weaponactive==-1){
2141 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2142 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2143 OPENAL_SetVolume(channels[knifesheathesound], 128);
2144 OPENAL_SetPaused(channels[knifesheathesound], false);
2146 if(weaponactive!=-1){
2156 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2157 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2158 OPENAL_SetVolume(channels[knifedrawsound], 128);
2159 OPENAL_SetPaused(channels[knifedrawsound], false);
2164 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2165 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2166 Normalise(&rotatetarget);
2167 targetrotation=-asin(0-rotatetarget.x);
2168 targetrotation*=360/6.28;
2169 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2171 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2172 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2177 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2179 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;
2181 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2182 targetanimation=rabbittackleanim;
2193 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2194 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2195 OPENAL_SetVolume(channels[jumpsound], 128);
2196 OPENAL_SetPaused(channels[jumpsound], false);
2205 Normalise(&targetloc);
2207 for(i=0;i<numplayers;i++){
2209 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2210 closestdist=findDistancefast(&targetloc,&player[i].coords);
2215 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2217 victim=&player[closestid];
2218 coords=victim->coords;
2219 currentanimation=rabbittacklinganim;
2220 targetanimation=rabbittacklinganim;
2224 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2225 rotatetarget=coords-victim->coords;
2226 Normalise(&rotatetarget);
2227 targetrotation=-asin(0-rotatetarget.x);
2228 targetrotation*=360/6.28;
2229 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2231 if(targetanimation!=rabbitrunninganim){
2241 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2242 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2243 OPENAL_SetVolume(channels[jumpsound], 128);
2244 OPENAL_SetPaused(channels[jumpsound], false);
2250 float damagemult=1*power;
2251 if(creature==wolftype)damagemult=2.5*power;
2252 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2253 //if(onfire)damagemult=3;
2254 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2255 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2256 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2258 if(id==0)camerashake+=.4;
2259 if(Random()%2||creature==wolftype){
2262 if(creature==wolftype)DoBloodBig(0,250);
2266 gLoc[0]=victim->coords.x;
2267 gLoc[1]=victim->coords.y;
2268 gLoc[2]=victim->coords.z;
2272 if(tutoriallevel!=1){
2273 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2274 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2275 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2276 OPENAL_SetPaused(channels[heavyimpactsound], false);
2278 if(creature==wolftype){
2279 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2280 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2281 OPENAL_SetVolume(channels[clawslicesound], 128);
2282 OPENAL_SetPaused(channels[clawslicesound], false);
2284 victim->DoBloodBig(2/victim->armorhead,175);
2288 relative=victim->coords-coords;
2290 Normalise(&relative);
2291 relative=DoRotation(relative,0,-90,0);
2292 for(i=0;i<victim->skeleton.num_joints;i++){
2293 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2295 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2298 victim->DoDamage(damagemult*100/victim->protectionhead);
2306 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2307 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2309 if(id==0)camerashake+=.4;
2310 if(Random()%2||creature==wolftype){
2312 if(creature==wolftype)DoBloodBig(0,235);
2316 gLoc[0]=victim->coords.x;
2317 gLoc[1]=victim->coords.y;
2318 gLoc[2]=victim->coords.z;
2322 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2323 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2324 OPENAL_SetVolume(channels[whooshhitsound], 512);
2325 OPENAL_SetPaused(channels[whooshhitsound], false);
2326 if(creature==wolftype){
2327 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2328 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2329 OPENAL_SetVolume(channels[clawslicesound], 128);
2330 OPENAL_SetPaused(channels[clawslicesound], false);
2332 victim->DoBloodBig(2,175);
2336 relative=victim->coords-coords;
2338 Normalise(&relative);
2340 Normalise(&relative);
2341 relative=DoRotation(relative,0,90,0);
2342 for(i=0;i<victim->skeleton.num_joints;i++){
2343 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2345 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2348 victim->DoDamage(damagemult*50/victim->protectionhead);
2352 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2353 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2355 if(id==0)camerashake+=.4;
2360 gLoc[0]=victim->coords.x;
2361 gLoc[1]=victim->coords.y;
2362 gLoc[2]=victim->coords.z;
2366 if(tutoriallevel!=1){
2367 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2368 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2369 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2370 OPENAL_SetPaused(channels[heavyimpactsound], false);
2372 if(creature==wolftype){
2373 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2374 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2375 OPENAL_SetVolume(channels[clawslicesound], 128);
2376 OPENAL_SetPaused(channels[clawslicesound], false);
2378 victim->DoBloodBig(2/victim->armorhead,175);
2384 Normalise(&relative);
2385 relative=DoRotation(relative,0,-90,0);
2386 for(i=0;i<victim->skeleton.num_joints;i++){
2387 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2389 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2392 victim->DoDamage(damagemult*150/victim->protectionhead);
2394 if(victim->damage>victim->damagetolerance){
2395 award_bonus(id, style);
2403 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2404 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2406 if(id==0)camerashake+=.4;
2411 gLoc[0]=victim->coords.x;
2412 gLoc[1]=victim->coords.y;
2413 gLoc[2]=victim->coords.z;
2417 if(tutoriallevel!=1){
2418 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2419 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2420 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2421 OPENAL_SetPaused(channels[heavyimpactsound], false);
2423 if(creature==wolftype){
2424 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2425 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2426 OPENAL_SetVolume(channels[clawslicesound], 128);
2427 OPENAL_SetPaused(channels[clawslicesound], false);
2429 victim->DoBloodBig(2/victim->armorhead,175);
2435 Normalise(&relative);
2436 relative=DoRotation(relative,0,90,0);
2437 for(i=0;i<victim->skeleton.num_joints;i++){
2438 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2440 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2443 victim->DoDamage(damagemult*150/victim->protectionhead);
2445 if(victim->damage>victim->damagetolerance){
2446 award_bonus(id, style);
2454 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2455 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2457 if(id==0)camerashake+=.4;
2464 gLoc[0]=victim->coords.x;
2465 gLoc[1]=victim->coords.y;
2466 gLoc[2]=victim->coords.z;
2470 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2471 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2472 OPENAL_SetVolume(channels[whooshhitsound], 512);
2473 OPENAL_SetPaused(channels[whooshhitsound], false);
2476 relative=victim->coords-coords;
2478 Normalise(&relative);
2479 for(i=0;i<victim->skeleton.num_joints;i++){
2480 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2482 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2485 victim->DoDamage(damagemult*50/victim->protectionhead);
2489 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2490 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2492 if(id==0)camerashake+=.2;
2495 gLoc[0]=victim->coords.x;
2496 gLoc[1]=victim->coords.y;
2497 gLoc[2]=victim->coords.z;
2501 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2502 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2503 OPENAL_SetVolume(channels[landsound2], 128);
2504 OPENAL_SetPaused(channels[landsound2], false);
2506 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2507 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2508 OPENAL_SetVolume(channels[movewhooshsound], 128);
2509 OPENAL_SetPaused(channels[movewhooshsound], false);
2511 victim->skeleton.longdead=0;
2512 victim->skeleton.free=1;
2513 victim->skeleton.broken=0;
2514 victim->skeleton.spinny=1;
2516 for(i=0;i<victim->skeleton.num_joints;i++){
2517 victim->skeleton.joints[i].velchange=0;
2518 victim->skeleton.joints[i].delay=0;
2519 victim->skeleton.joints[i].locked=0;
2520 //victim->skeleton.joints[i].velocity=0;
2526 Normalise(&relative);
2527 for(i=0;i<victim->skeleton.num_joints;i++){
2528 victim->skeleton.joints[i].velocity.y=relative.y*10;
2529 victim->skeleton.joints[i].position.y+=relative.y*.3;
2530 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2531 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2533 victim->Puff(abdomen);
2534 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2538 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2539 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2541 if(id==0)camerashake+=.4;
2550 if(tutoriallevel!=1){
2551 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2552 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2553 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2554 OPENAL_SetPaused(channels[heavyimpactsound], false);
2557 relative=victim->coords-coords;
2559 Normalise(&relative);
2560 for(i=0;i<victim->skeleton.num_joints;i++){
2561 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2563 victim->Puff(abdomen);
2564 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2568 victim->DoDamage(damagemult*500/victim->protectionhigh);
2569 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2573 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2574 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2576 if(id==0)camerashake+=.4;
2585 if(tutoriallevel!=1){
2586 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2587 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2588 OPENAL_SetVolume(channels[thudsound], 400);
2589 OPENAL_SetPaused(channels[thudsound], false);
2592 victim->skeleton.longdead=0;
2593 victim->skeleton.free=1;
2594 victim->skeleton.broken=0;
2595 victim->skeleton.spinny=1;
2597 for(i=0;i<victim->skeleton.num_joints;i++){
2598 victim->skeleton.joints[i].velchange=0;
2599 //victim->skeleton.joints[i].delay=0;
2600 victim->skeleton.joints[i].locked=0;
2603 relative=victim->coords-coords;
2604 Normalise(&relative);
2606 Normalise(&relative);
2607 for(i=0;i<victim->skeleton.num_joints;i++){
2608 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2610 if(id==0&&!victim->dead){
2614 victim->Puff(abdomen);
2615 victim->DoDamage(damagemult*20/victim->protectionhigh);
2616 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2618 if(!victim->dead)staggerdelay=1.2;
2624 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2625 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2626 //if(id==0)camerashake+=.4;
2637 if(!victim->skeleton.free)hasvictim=0;
2640 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2641 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2642 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2643 OPENAL_SetVolume(channels[knifesheathesound], 128);
2644 OPENAL_SetPaused(channels[knifesheathesound], false);
2647 if(victim&&hasvictim){
2648 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2650 XYZ where,startpoint,endpoint,movepoint,colpoint;
2651 float rotationpoint;
2653 if(weapons.type[weaponids[weaponactive]]==knife){
2654 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2655 where-=victim->coords;
2656 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2663 if(weapons.type[weaponids[weaponactive]]==sword){
2664 where=weapons.position[weaponids[weaponactive]];
2665 where-=victim->coords;
2666 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2668 where=weapons.tippoint[weaponids[weaponactive]];
2669 where-=victim->coords;
2670 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2673 if(weapons.type[weaponids[weaponactive]]==staff){
2674 where=weapons.position[weaponids[weaponactive]];
2675 where-=victim->coords;
2676 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2678 where=weapons.tippoint[weaponids[weaponactive]];
2679 where-=victim->coords;
2680 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2685 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2688 if(victim->dead!=2){
2689 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2691 award_bonus(id, FinishedBonus);
2693 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2695 victim->skeleton.longdead=0;
2696 victim->skeleton.free=1;
2697 victim->skeleton.broken=0;
2699 for(i=0;i<victim->skeleton.num_joints;i++){
2700 victim->skeleton.joints[i].velchange=0;
2701 victim->skeleton.joints[i].locked=0;
2702 //victim->skeleton.joints[i].velocity=0;
2704 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2705 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2706 OPENAL_SetVolume(channels[fleshstabsound], 128);
2707 OPENAL_SetPaused(channels[fleshstabsound], false);
2710 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2711 weapons.blooddrip[weaponids[weaponactive]]+=5;
2712 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2716 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2717 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2718 OPENAL_SetVolume(channels[knifesheathesound], 128);
2719 OPENAL_SetPaused(channels[knifesheathesound], false);
2725 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2726 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2727 //if(id==0)camerashake+=.4;
2737 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2738 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2739 OPENAL_SetVolume(channels[knifedrawsound], 128);
2740 OPENAL_SetPaused(channels[knifedrawsound], false);
2743 if(victim&&hasvictim){
2744 XYZ footvel,footpoint;
2746 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2747 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2748 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2749 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2752 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2754 if(weapons.type[weaponids[weaponactive]]==sword){
2755 XYZ where,startpoint,endpoint,movepoint;
2756 float rotationpoint;
2759 where=weapons.position[weaponids[weaponactive]];
2760 where-=victim->coords;
2761 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2763 where=weapons.tippoint[weaponids[weaponactive]];
2764 where-=victim->coords;
2765 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2770 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2771 footpoint+=victim->coords;
2774 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2777 if(weapons.type[weaponids[weaponactive]]==staff){
2778 XYZ where,startpoint,endpoint,movepoint;
2779 float rotationpoint;
2782 where=weapons.position[weaponids[weaponactive]];
2783 where-=victim->coords;
2784 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2786 where=weapons.tippoint[weaponids[weaponactive]];
2787 where-=victim->coords;
2788 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2793 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2794 footpoint+=victim->coords;
2797 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2800 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2802 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2803 victim->skeleton.longdead=0;
2804 victim->skeleton.free=1;
2805 victim->skeleton.broken=0;
2807 for(i=0;i<victim->skeleton.num_joints;i++){
2808 victim->skeleton.joints[i].velchange=0;
2809 victim->skeleton.joints[i].locked=0;
2810 //victim->skeleton.joints[i].velocity=0;
2816 Normalise(&relative);
2817 //victim->Puff(abdomen);
2818 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2820 if(victim->bloodloss<victim->damagetolerance){
2821 victim->bloodloss+=1000;
2825 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2829 if(!hasvictim&&onterrain){
2830 weapons.bloody[weaponids[weaponactive]]=0;
2831 weapons.blooddrip[weaponids[weaponactive]]=0;
2835 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2836 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2838 if(id==0)camerashake+=.4;
2845 gLoc[0]=victim->coords.x;
2846 gLoc[1]=victim->coords.y;
2847 gLoc[2]=victim->coords.z;
2851 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2853 if(tutoriallevel!=1){
2854 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2855 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2856 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2857 OPENAL_SetPaused(channels[heavyimpactsound], false);
2861 if(tutoriallevel!=1){
2862 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2863 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2864 OPENAL_SetVolume(channels[landsound2], 256);
2865 OPENAL_SetPaused(channels[landsound2], false);
2869 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
2872 relative=victim->coords-coords;
2874 Normalise(&relative);
2875 for(i=0;i<victim->skeleton.num_joints;i++){
2876 victim->skeleton.joints[i].velocity=relative*30;
2878 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2880 victim->targetframe=0;
2881 victim->targetanimation=staggerbackhardanim;
2882 victim->targetrotation=targetrotation+180;
2887 victim->Puff(abdomen);
2888 victim->DoDamage(damagemult*60/victim->protectionhigh);
2897 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2898 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2900 if(id==0)camerashake+=.4;
2903 gLoc[0]=victim->coords.x;
2904 gLoc[1]=victim->coords.y;
2905 gLoc[2]=victim->coords.z;
2909 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2910 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2911 if(tutoriallevel!=1){
2912 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2913 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2914 OPENAL_SetVolume(channels[thudsound], 512);
2915 OPENAL_SetPaused(channels[thudsound], false);
2918 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2919 if(tutoriallevel!=1){
2920 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2921 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2922 OPENAL_SetVolume(channels[whooshhitsound], 512);
2923 OPENAL_SetPaused(channels[whooshhitsound], false);
2927 if(tutoriallevel!=1){
2928 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2929 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2930 OPENAL_SetVolume(channels[heavyimpactsound], 256);
2931 OPENAL_SetPaused(channels[heavyimpactsound], false);
2935 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2938 relative=victim->coords-coords;
2940 Normalise(&relative);
2942 Normalise(&relative);
2943 for(i=0;i<victim->skeleton.num_joints;i++){
2944 victim->skeleton.joints[i].velocity=relative*5;
2946 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
2948 victim->targetframe=0;
2949 victim->targetanimation=staggerbackhardanim;
2950 victim->targetrotation=targetrotation+180;
2954 victim->Puff(abdomen);
2955 victim->DoDamage(damagemult*60/victim->protectionhigh);
2963 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
2964 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2965 if(victim->id==0)camerashake+=.4;
2968 gLoc[0]=victim->coords.x;
2969 gLoc[1]=victim->coords.y;
2970 gLoc[2]=victim->coords.z;
2975 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2976 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2977 OPENAL_SetVolume(channels[landsound2], 256);
2978 OPENAL_SetPaused(channels[landsound2], false);
2984 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
2985 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2986 if(victim->id==0)camerashake+=.4;
2989 gLoc[0]=victim->coords.x;
2990 gLoc[1]=victim->coords.y;
2991 gLoc[2]=victim->coords.z;
2996 if(weaponactive!=-1){
2997 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
2998 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2999 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3001 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3002 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3003 OPENAL_SetVolume(channels[swordstaffsound], 512);
3004 OPENAL_SetPaused(channels[swordstaffsound], false);
3007 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3008 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3009 OPENAL_SetVolume(channels[metalhitsound], 512);
3010 OPENAL_SetPaused(channels[metalhitsound], false);
3018 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3019 if(weaponactive!=-1){
3022 weapons.owner[weaponids[0]]=-1;
3023 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);
3025 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3026 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3028 weapons.velocity[weaponids[0]]=aim*50;
3029 weapons.tipvelocity[weaponids[0]]=aim*50;
3030 weapons.missed[weaponids[0]]=0;
3031 weapons.hitsomething[weaponids[0]]=0;
3032 weapons.freetime[weaponids[0]]=0;
3033 weapons.firstfree[weaponids[0]]=1;
3034 weapons.physics[weaponids[0]]=0;
3037 weaponids[0]=weaponids[num_weapons];
3043 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3045 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3048 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3051 award_bonus(id, Slicebonus);
3052 if(tutoriallevel!=1){
3055 gLoc[0]=victim->coords.x;
3056 gLoc[1]=victim->coords.y;
3057 gLoc[2]=victim->coords.z;
3061 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3062 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3063 OPENAL_SetVolume(channels[knifeslicesound], 512);
3064 OPENAL_SetPaused(channels[knifeslicesound], false);
3066 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3067 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3068 if(victim->id != 0 || difficulty==2){
3069 victim->targetframe=0;
3070 victim->targetanimation=staggerbackhardanim;
3071 victim->targetrotation=targetrotation+180;
3075 victim->lowreversaldelay=0;
3076 victim->highreversaldelay=0;
3077 if(aitype!=playercontrolled)weaponmissdelay=.6;
3079 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3080 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3082 XYZ footvel,footpoint;
3085 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3088 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;
3090 if(tutoriallevel!=1){
3091 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3092 footvel=DoRotation(facing,0,90,0)*.8;
3094 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3095 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3096 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3097 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3099 if(tutoriallevel==1){
3100 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3102 victim->DoDamage(damagemult*0);
3105 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3106 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3107 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3108 award_bonus(id, Slashbonus);
3110 if(tutoriallevel!=1){
3111 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3112 else victim->DoBloodBig(2/victim->armorhigh,185);
3113 victim->deathbleeding=1;
3116 gLoc[0]=victim->coords.x;
3117 gLoc[1]=victim->coords.y;
3118 gLoc[2]=victim->coords.z;
3122 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3123 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3124 OPENAL_SetVolume(channels[swordslicesound], 512);
3125 OPENAL_SetPaused(channels[swordslicesound], false);
3127 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3128 //if(animation[victim->targetanimation].attack){
3129 //if(victim->creature==rabbittype){
3130 if(tutoriallevel!=1){
3131 victim->targetframe=0;
3132 victim->targetanimation=staggerbackhardanim;
3133 victim->targetrotation=targetrotation+180;
3139 if(tutoriallevel!=1){
3140 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3141 weapons.blooddrip[weaponids[weaponactive]]+=3;
3143 float bloodlossamount;
3144 bloodlossamount=200+abs((float)(Random()%40))-20;
3145 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3146 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3147 victim->DoDamage(damagemult*0);
3149 XYZ footvel,footpoint;
3152 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3155 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;
3157 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3158 footvel=DoRotation(facing,0,90,0)*.8;
3160 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3161 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3162 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3163 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3171 gLoc[0]=victim->coords.x;
3172 gLoc[1]=victim->coords.y;
3173 gLoc[2]=victim->coords.z;
3177 if(victim->weaponactive!=-1){
3178 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3179 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3180 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3182 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3183 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3184 OPENAL_SetVolume(channels[swordstaffsound], 512);
3185 OPENAL_SetPaused(channels[swordstaffsound], false);
3188 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3189 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3190 OPENAL_SetVolume(channels[metalhitsound], 512);
3191 OPENAL_SetPaused(channels[metalhitsound], false);
3197 victim->Puff(righthand);
3199 victim->targetframe=0;
3200 victim->targetanimation=staggerbackhighanim;
3201 victim->targetrotation=targetrotation+180;
3203 weapons.owner[victim->weaponids[0]]=-1;
3204 aim=DoRotation(facing,0,90,0)*21;
3206 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3207 weapons.tipvelocity[victim->weaponids[0]]=aim;
3208 weapons.missed[victim->weaponids[0]]=1;
3209 weapons.hitsomething[weaponids[0]]=0;
3210 weapons.freetime[victim->weaponids[0]]=0;
3211 weapons.firstfree[victim->weaponids[0]]=1;
3212 weapons.physics[victim->weaponids[0]]=1;
3213 victim->num_weapons--;
3214 if(victim->num_weapons){
3215 victim->weaponids[0]=victim->weaponids[num_weapons];
3216 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3218 victim->weaponactive=-1;
3219 for(i=0;i<numplayers;i++){
3220 player[i].wentforweapon=0;
3223 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3224 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3225 OPENAL_SetVolume(channels[metalhitsound], 512);
3226 OPENAL_SetPaused(channels[metalhitsound], false);*/
3232 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3233 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3234 if(tutoriallevel!=1){
3235 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3237 if(id==0)camerashake+=.4;
3238 if(Random()%2||creature==wolftype){
3243 gLoc[0]=victim->coords.x;
3244 gLoc[1]=victim->coords.y;
3245 gLoc[2]=victim->coords.z;
3249 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3250 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3251 OPENAL_SetVolume(channels[staffheadsound], 256);
3252 OPENAL_SetPaused(channels[staffheadsound], false);
3256 relative=victim->coords-coords;
3258 Normalise(&relative);
3259 relative=DoRotation(relative,0,90,0);
3261 Normalise(&relative);
3262 for(i=0;i<victim->skeleton.num_joints;i++){
3263 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3265 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3266 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3269 if(tutoriallevel!=1){
3270 victim->DoDamage(damagemult*120/victim->protectionhigh);
3272 award_bonus(id, solidhit, 30);
3277 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3278 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3279 if(tutoriallevel!=1){
3280 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3282 if(id==0)camerashake+=.4;
3283 if(Random()%2||creature==wolftype){
3288 gLoc[0]=victim->coords.x;
3289 gLoc[1]=victim->coords.y;
3290 gLoc[2]=victim->coords.z;
3294 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3295 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3296 OPENAL_SetVolume(channels[staffheadsound], 256);
3297 OPENAL_SetPaused(channels[staffheadsound], false);
3301 relative=victim->coords-coords;
3303 Normalise(&relative);
3304 relative=DoRotation(relative,0,-90,0);
3305 for(i=0;i<victim->skeleton.num_joints;i++){
3306 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3308 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3309 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3312 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3314 award_bonus(id, solidhit, 60);
3319 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3320 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3322 if(tutoriallevel!=1){
3323 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3324 if(id==0)camerashake+=.4;
3325 if(Random()%2||creature==wolftype){
3330 gLoc[0]=victim->coords.x;
3331 gLoc[1]=victim->coords.y;
3332 gLoc[2]=victim->coords.z;
3336 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3337 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3338 OPENAL_SetVolume(channels[staffbodysound], 256);
3339 OPENAL_SetPaused(channels[staffbodysound], false);
3341 victim->skeleton.longdead=0;
3342 victim->skeleton.free=1;
3343 victim->skeleton.broken=0;
3345 for(i=0;i<victim->skeleton.num_joints;i++){
3346 victim->skeleton.joints[i].velchange=0;
3347 victim->skeleton.joints[i].locked=0;
3348 //victim->skeleton.joints[i].velocity=0;
3354 /*relative=victim->coords-coords;
3356 Normalise(&relative);
3357 relative=DoRotation(relative,0,90,0);*/
3359 Normalise(&relative);
3361 for(i=0;i<victim->skeleton.num_joints;i++){
3362 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3365 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3368 for(i=0;i<victim->skeleton.num_joints;i++){
3369 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3372 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3374 victim->Puff(abdomen);
3375 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3378 award_bonus(id, solidhit, 40);
3384 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3385 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3387 if(id==0)camerashake+=.4;
3390 gLoc[0]=victim->coords.x;
3391 gLoc[1]=victim->coords.y;
3392 gLoc[2]=victim->coords.z;
3397 relative=victim->coords-coords;
3399 Normalise(&relative);
3405 if(animation[victim->targetanimation].height==lowheight){
3411 for(i=0;i<victim->skeleton.num_joints;i++){
3412 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3414 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3415 if(tutoriallevel!=1){
3416 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3417 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3418 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3419 OPENAL_SetPaused(channels[heavyimpactsound], false);
3422 victim->DoDamage(damagemult*100/victim->protectionhead);
3423 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3424 if(creature==wolftype){
3425 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3426 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3427 OPENAL_SetVolume(channels[clawslicesound], 128);
3428 OPENAL_SetPaused(channels[clawslicesound], false);
3430 victim->DoBloodBig(2/victim->armorhead,175);
3434 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3435 for(i=0;i<victim->skeleton.num_joints;i++){
3436 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3438 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3439 victim->targetframe=0;
3440 victim->targetanimation=staggerbackhighanim;
3441 victim->targetrotation=targetrotation+180;
3443 if(tutoriallevel!=1){
3444 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3445 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3446 OPENAL_SetVolume(channels[landsound2], 128);
3447 OPENAL_SetPaused(channels[landsound2], false);
3449 victim->Puff(abdomen);
3450 victim->DoDamage(damagemult*30/victim->protectionhigh);
3451 if(creature==wolftype){
3452 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3453 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3454 OPENAL_SetVolume(channels[clawslicesound], 128);
3455 OPENAL_SetPaused(channels[clawslicesound], false);
3457 victim->DoBloodBig(2/victim->armorhigh,170);
3464 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3465 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3467 if(id==0)camerashake+=.2;
3470 gLoc[0]=victim->coords.x;
3471 gLoc[1]=victim->coords.y;
3472 gLoc[2]=victim->coords.z;
3476 if(tutoriallevel!=1){
3477 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3478 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3479 OPENAL_SetVolume(channels[landsound2], 128);
3480 OPENAL_SetPaused(channels[landsound2], false);
3483 relative=victim->coords-coords;
3485 Normalise(&relative);
3487 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3490 for(i=0;i<victim->skeleton.num_joints;i++){
3491 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3493 relative=DoRotation(relative,0,-90,0);
3495 for(i=0;i<victim->skeleton.num_joints;i++){
3496 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)
3497 victim->skeleton.joints[i].velocity=relative*80;
3499 victim->Puff(rightankle);
3500 victim->Puff(leftankle);
3501 victim->DoDamage(damagemult*40/victim->protectionlow);
3504 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3505 for(i=0;i<victim->skeleton.num_joints;i++){
3506 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3508 relative=DoRotation(relative,0,-90,0);
3509 for(i=0;i<victim->skeleton.num_joints;i++){
3510 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)
3511 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3513 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3514 victim->targetframe=0;
3515 victim->targetanimation=staggerbackhighanim;
3516 victim->targetrotation=targetrotation+180;
3518 if(tutoriallevel!=1){
3519 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3520 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3521 OPENAL_SetVolume(channels[landsound2], 128);
3522 OPENAL_SetPaused(channels[landsound2], false);
3524 victim->Puff(abdomen);
3525 victim->DoDamage(damagemult*30/victim->protectionlow);
3535 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3536 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3538 if(id==0)camerashake+=.4;
3545 gLoc[0]=victim->coords.x;
3546 gLoc[1]=victim->coords.y;
3547 gLoc[2]=victim->coords.z;
3551 if(tutoriallevel!=1){
3552 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3553 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3554 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3555 OPENAL_SetPaused(channels[heavyimpactsound], false);
3557 if(creature==wolftype){
3558 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3559 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3560 OPENAL_SetVolume(channels[clawslicesound], 128);
3561 OPENAL_SetPaused(channels[clawslicesound], false);
3563 victim->DoBloodBig(2/victim->armorhigh,170);
3567 relative=victim->coords-oldcoords;
3569 Normalise(&relative);
3570 //relative=DoRotation(relative,0,-90,0);
3571 for(i=0;i<victim->skeleton.num_joints;i++){
3572 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3574 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3576 victim->Puff(abdomen);
3577 victim->DoDamage(damagemult*150/victim->protectionhigh);
3579 award_bonus(id, Reversal);
3582 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3583 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3584 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3585 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3588 weaponids[num_weapons]=weaponids[victim->weaponactive];
3591 weaponids[0]=victim->weaponids[victim->weaponactive];
3592 victim->num_weapons--;
3593 if(victim->num_weapons>0){
3594 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3595 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3597 victim->weaponactive=-1;
3602 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3604 if(id==0)camerashake+=.4;
3611 gLoc[0]=victim->coords.x;
3612 gLoc[1]=victim->coords.y;
3613 gLoc[2]=victim->coords.z;
3617 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3618 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3619 OPENAL_SetVolume(channels[whooshhitsound], 128);
3620 OPENAL_SetPaused(channels[whooshhitsound], false);
3623 relative=victim->coords-oldcoords;
3625 Normalise(&relative);
3626 //relative=DoRotation(relative,0,-90,0);
3627 for(i=0;i<victim->skeleton.num_joints;i++){
3628 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3630 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3633 victim->DoDamage(damagemult*70/victim->protectionhigh);
3636 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3638 if(id==0)camerashake+=.4;
3645 gLoc[0]=victim->coords.x;
3646 gLoc[1]=victim->coords.y;
3647 gLoc[2]=victim->coords.z;
3652 award_bonus(id, staffreversebonus);
3654 if(tutoriallevel!=1){
3655 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3656 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3657 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3658 OPENAL_SetPaused(channels[heavyimpactsound], false);
3661 award_bonus(id, staffreversebonus); // Huh, again?
3664 relative=victim->coords-oldcoords;
3666 Normalise(&relative);
3667 //relative=DoRotation(relative,0,-90,0);
3668 for(i=0;i<victim->skeleton.num_joints;i++){
3669 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3671 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3674 victim->DoDamage(damagemult*70/victim->protectionhigh);
3677 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3683 Normalise(&relative);
3686 for(i=0;i<victim->skeleton.num_joints;i++){
3687 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3689 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3690 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3691 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3692 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3693 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3694 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3695 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3696 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3698 victim->Puff(abdomen);
3699 victim->DoDamage(damagemult*90/victim->protectionhigh);
3701 award_bonus(id, Reversal);
3705 if(weaponactive!=-1||creature==wolftype)doslice=1;
3706 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3710 gLoc[0]=victim->coords.x;
3711 gLoc[1]=victim->coords.y;
3712 gLoc[2]=victim->coords.z;
3716 if(weaponactive!=-1){
3717 victim->DoBloodBig(2/victim->armorhigh,225);
3718 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3719 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3720 OPENAL_SetVolume(channels[knifeslicesound], 512);
3721 OPENAL_SetPaused(channels[knifeslicesound], false);
3722 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3723 weapons.blooddrip[weaponids[weaponactive]]+=3;
3725 if(weaponactive==-1&&creature==wolftype){
3726 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3727 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3728 OPENAL_SetVolume(channels[clawslicesound], 128);
3729 OPENAL_SetPaused(channels[clawslicesound], false);
3731 victim->DoBloodBig(2/victim->armorhigh,175);
3738 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3744 Normalise(&relative);
3747 for(i=0;i<victim->skeleton.num_joints;i++){
3748 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3750 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
3751 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
3752 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
3753 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
3754 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
3755 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
3756 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
3757 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
3759 award_bonus(id, swordreversebonus);
3762 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3764 if(id==0)camerashake+=.4;
3771 gLoc[0]=victim->coords.x;
3772 gLoc[1]=victim->coords.y;
3773 gLoc[2]=victim->coords.z;
3777 if(tutoriallevel!=1){
3778 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3779 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3780 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3781 OPENAL_SetPaused(channels[heavyimpactsound], false);
3785 relative=victim->coords-oldcoords;
3787 Normalise(&relative);
3788 relative=DoRotation(relative,0,-90,0);
3789 for(i=0;i<victim->skeleton.num_joints;i++){
3790 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3792 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3794 victim->Puff(abdomen);
3795 victim->DoDamage(damagemult*30/victim->protectionhigh);
3797 award_bonus(id, Reversal);
3800 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
3803 victim->skeleton.spinny=0;
3807 Normalise(&relative);
3808 if(victim->id==0)relative/=30;
3809 for(i=0;i<victim->skeleton.num_joints;i++){
3810 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3812 //victim->DoDamage(1000);
3813 victim->damage=victim->damagetolerance;
3814 victim->permanentdamage=victim->damagetolerance-1;
3817 if(weaponactive!=-1||creature==wolftype)doslice=1;
3818 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3822 gLoc[0]=victim->coords.x;
3823 gLoc[1]=victim->coords.y;
3824 gLoc[2]=victim->coords.z;
3828 if(weaponactive!=-1){
3829 victim->DoBloodBig(200,225);
3830 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3831 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3832 OPENAL_SetVolume(channels[knifeslicesound], 512);
3833 OPENAL_SetPaused(channels[knifeslicesound], false);
3834 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3835 weapons.blooddrip[weaponids[weaponactive]]+=5;
3838 if(creature==wolftype&&weaponactive==-1){
3839 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3840 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3841 OPENAL_SetVolume(channels[clawslicesound], 128);
3842 OPENAL_SetPaused(channels[clawslicesound], false);
3844 victim->DoBloodBig(2,175);
3847 award_bonus(id, spinecrusher);
3850 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3851 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3853 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3854 if(targetanimation==knifesneakattackanim){
3855 /*victim->DoBloodBig(200,195);
3860 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3861 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3863 XYZ footvel,footpoint;
3865 footpoint=weapons.tippoint[weaponids[0]];
3866 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3867 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3868 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3869 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3870 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3871 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3872 victim->DoBloodBig(200,195);
3873 award_bonus(id, tracheotomy);
3875 if(targetanimation==knifefollowanim){
3876 award_bonus(id, Stabbonus);
3877 XYZ footvel,footpoint;
3879 footpoint=weapons.tippoint[weaponids[0]];
3880 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3881 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3882 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3883 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3884 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3885 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3888 victim->bloodloss+=10000;
3892 gLoc[0]=victim->coords.x;
3893 gLoc[1]=victim->coords.y;
3894 gLoc[2]=victim->coords.z;
3898 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
3899 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
3900 OPENAL_SetVolume(channels[fleshstabsound], 512);
3901 OPENAL_SetPaused(channels[fleshstabsound], false);
3902 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3903 weapons.blooddrip[weaponids[weaponactive]]+=5;
3907 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
3910 for(i=0;i<victim->skeleton.num_joints;i++){
3911 victim->skeleton.joints[i].velocity=0;
3913 if(targetanimation==knifefollowanim){
3915 for(i=0;i<victim->skeleton.num_joints;i++){
3916 victim->skeleton.joints[i].velocity=0;
3919 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
3922 gLoc[0]=victim->coords.x;
3923 gLoc[1]=victim->coords.y;
3924 gLoc[2]=victim->coords.z;
3928 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
3929 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
3930 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
3931 OPENAL_SetPaused(channels[fleshstabremovesound], false);
3932 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3933 weapons.blooddrip[weaponids[weaponactive]]+=5;
3935 XYZ footvel,footpoint;
3937 footpoint=weapons.tippoint[weaponids[0]];
3938 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3939 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3940 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3941 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3942 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3943 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3947 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3948 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3949 award_bonus(id, backstab);
3953 XYZ footvel,footpoint;
3955 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
3956 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3957 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3958 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3959 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3960 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3961 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3962 victim->DoBloodBig(200,180);
3963 victim->DoBloodBig(200,215);
3964 victim->bloodloss+=10000;
3968 gLoc[0]=victim->coords.x;
3969 gLoc[1]=victim->coords.y;
3970 gLoc[2]=victim->coords.z;
3974 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
3975 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
3976 OPENAL_SetVolume(channels[fleshstabsound], 512);
3977 OPENAL_SetPaused(channels[fleshstabsound], false);
3978 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3979 weapons.blooddrip[weaponids[weaponactive]]+=5;
3983 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
3986 for(i=0;i<victim->skeleton.num_joints;i++){
3987 victim->skeleton.joints[i].velocity=0;
3989 if(weaponactive!=-1){
3992 gLoc[0]=victim->coords.x;
3993 gLoc[1]=victim->coords.y;
3994 gLoc[2]=victim->coords.z;
3998 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
3999 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4000 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4001 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4002 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4003 weapons.blooddrip[weaponids[weaponactive]]+=5;
4005 XYZ footvel,footpoint;
4007 footpoint=weapons.tippoint[weaponids[0]];
4008 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4009 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4010 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4011 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4012 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4013 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4017 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4019 if(id==0)camerashake+=.4;
4026 gLoc[0]=victim->coords.x;
4027 gLoc[1]=victim->coords.y;
4028 gLoc[2]=victim->coords.z;
4032 if(weaponactive==-1){
4033 if(tutoriallevel!=1){
4034 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4035 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4036 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4037 OPENAL_SetPaused(channels[heavyimpactsound], false);
4042 if(weaponactive!=-1||creature==wolftype)doslice=1;
4043 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4045 if(weaponactive!=-1){
4046 victim->DoBloodBig(2/victim->armorhead,225);
4047 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4048 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4049 OPENAL_SetVolume(channels[knifeslicesound], 512);
4050 OPENAL_SetPaused(channels[knifeslicesound], false);
4051 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4052 weapons.blooddrip[weaponids[weaponactive]]+=3;
4054 if(weaponactive==-1&&creature==wolftype){
4055 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4056 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4057 OPENAL_SetVolume(channels[clawslicesound], 128);
4058 OPENAL_SetPaused(channels[clawslicesound], false);
4060 victim->DoBloodBig(2/victim->armorhead,175);
4064 award_bonus(id, Reversal);
4069 //relative=victim->coords-oldcoords;
4072 Normalise(&relative);
4073 relative=DoRotation(relative,0,90,0);
4075 Normalise(&relative);
4076 for(i=0;i<victim->skeleton.num_joints;i++){
4077 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4079 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4080 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4081 victim->DoDamage(damagemult*100/victim->protectionhead);
4085 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4089 //relative=victim->coords-oldcoords;
4092 Normalise(&relative);
4093 relative=DoRotation(relative,0,90,0);
4095 Normalise(&relative);
4096 for(i=0;i<victim->skeleton.num_joints;i++){
4097 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4099 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4102 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4103 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4104 award_bonus(id, reverseko);
4110 if(targetframe>animation[currentanimation].numframes-1){
4113 targetanimation=getIdle();
4117 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4118 targetanimation=rollanim;
4129 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4130 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4131 OPENAL_SetVolume(channels[movewhooshsound], 128);
4132 OPENAL_SetPaused(channels[movewhooshsound], false);
4134 if(currentanimation==staggerbackhighanim){
4135 targetanimation=getIdle();
4137 if(currentanimation==staggerbackhardanim){
4138 targetanimation=getIdle();
4140 if(currentanimation==removeknifeanim){
4141 targetanimation=getIdle();
4143 if(currentanimation==crouchremoveknifeanim){
4144 targetanimation=getCrouch();
4146 if(currentanimation==backhandspringanim){
4147 targetanimation=getIdle();
4149 if(currentanimation==dodgebackanim){
4150 targetanimation=getIdle();
4152 if(currentanimation==drawleftanim){
4153 targetanimation=getIdle();
4155 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4156 targetanimation=getIdle();
4157 if(currentanimation==crouchdrawrightanim){
4158 targetanimation=getCrouch();
4160 if(weaponactive==-1)weaponactive=0;
4161 else if(weaponactive==0){
4165 buffer=weaponids[0];
4166 weaponids[0]=weaponids[1];
4167 weaponids[1]=buffer;
4171 if(weaponactive==-1){
4181 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4182 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4183 OPENAL_SetVolume(channels[knifesheathesound], 128);
4184 OPENAL_SetPaused(channels[knifesheathesound], false);
4186 if(weaponactive!=-1){
4196 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4197 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4198 OPENAL_SetVolume(channels[knifedrawsound], 128);
4199 OPENAL_SetPaused(channels[knifedrawsound], false);
4202 if(currentanimation==rollanim){
4203 targetanimation=getCrouch();
4208 if(targetanimation==walljumprightkickanim){
4211 if(targetanimation==walljumpleftkickanim){
4214 targetanimation=jumpdownanim;
4216 if(currentanimation==climbanim){
4217 targetanimation=getCrouch();
4220 if(!isnormal(coords.x))
4231 if(targetanimation==rabbitkickreversalanim){
4232 targetanimation=getCrouch();
4235 if(targetanimation==jumpreversalanim){
4236 targetanimation=getCrouch();
4239 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4240 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4242 float closestdist=-1;
4245 for(i=0;i<numplayers;i++){
4246 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4247 distance=findDistancefast(&player[i].coords,&coords);
4248 if(closestdist==-1||distance<closestdist){
4249 closestdist=distance;
4254 if(closestdist>0&&closest>=0&&closestdist<16){
4255 victim=&player[closest];
4256 targetanimation=walljumprightkickanim;
4258 XYZ rotatetarget=victim->coords-coords;
4259 Normalise(&rotatetarget);
4260 rotation=-asin(0-rotatetarget.x);
4262 if(rotatetarget.z<0)rotation=180-rotation;
4263 targettilt2=-asin(rotatetarget.y)*360/6.28;
4264 velocity=(victim->coords-coords)*4;
4269 if(targetanimation==walljumpbackanim){
4270 targetanimation=backflipanim;
4274 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4276 if(targetanimation==walljumprightanim){
4277 targetanimation=rightflipanim;
4281 velocity=DoRotation(facing,0,30,0)*-8;
4284 if(targetanimation==walljumpfrontanim){
4285 targetanimation=frontflipanim;
4287 //targetrotation-=180;
4292 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4294 if(targetanimation==walljumpleftanim){
4297 float closestdist=-1;
4300 for(i=0;i<numplayers;i++){
4301 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4302 distance=findDistancefast(&player[i].coords,&coords);
4303 if(closestdist==-1||distance<closestdist){
4304 closestdist=distance;
4309 if(closestdist>0&&closest>=0&&closestdist<16){
4310 victim=&player[closest];
4311 targetanimation=walljumpleftkickanim;
4313 XYZ rotatetarget=victim->coords-coords;
4314 Normalise(&rotatetarget);
4315 rotation=-asin(0-rotatetarget.x);
4317 if(rotatetarget.z<0)rotation=180-rotation;
4318 targettilt2=-asin(rotatetarget.y)*360/6.28;
4319 velocity=(victim->coords-coords)*4;
4324 if(targetanimation!=walljumpleftkickanim){
4325 targetanimation=leftflipanim;
4329 velocity=DoRotation(facing,0,-30,0)*-8;
4332 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4334 if(targetanimation==sneakattackanim){
4335 float ycoords=oldcoords.y;
4336 currentanimation=getCrouch();
4337 targetanimation=getCrouch();
4340 targetrotation+=180;
4345 targetheadrotation+=180;
4347 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4351 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4352 float ycoords=oldcoords.y;
4353 targetanimation=getIdle();
4355 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4359 if(currentanimation==knifefollowanim){
4360 targetanimation=getIdle();
4363 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4364 float ycoords=oldcoords.y;
4365 targetanimation=getStop();
4366 targetrotation+=180;
4371 targetheadrotation+=180;
4372 if(!isnormal(coords.x))
4374 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4375 oldcoords=coords+facing*.5;
4376 else if(currentanimation==sweepreversalanim)
4377 oldcoords=coords+facing*1.1;
4378 else if(currentanimation==upunchreversalanim){
4379 oldcoords=coords+facing*1.5;
4380 targetrotation+=180;
4382 targetheadrotation+=180;
4386 else if(currentanimation==knifeslashreversalanim){
4387 oldcoords=coords+facing*.5;
4390 targetheadrotation+=90;
4394 else if(currentanimation==staffspinhitreversalanim){
4395 targetrotation+=180;
4397 targetheadrotation+=180;
4401 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4402 else oldcoords.y=ycoords;
4403 currentoffset=coords-oldcoords;
4409 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4414 if(animation[targetanimation].attack==reversed){
4416 if(targetanimation==sweepreversedanim)targetrotation+=90;
4417 targetanimation=backhandspringanim;
4427 PlaySoundEx( landsound, samp[landsound], NULL, true);
4428 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4429 OPENAL_SetVolume(channels[landsound], 128);
4430 OPENAL_SetPaused(channels[landsound], false);
4432 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4433 targetanimation=rollanim;
4436 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4437 coords.y=oldcoords.y;
4439 if(currentanimation==knifeslashreversedanim){
4440 targetanimation=rollanim;
4445 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4446 coords.y=oldcoords.y;
4450 targetanimation=jumpdownanim;
4452 if(wasLanding())targetanimation=getIdle();
4453 if(wasLandhard())targetanimation=getIdle();
4454 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4455 targetanimation=getIdle();
4457 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4458 coords.y=oldcoords.y;
4459 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4460 targetoffset.y=coords.y;
4461 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4462 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4463 currentoffset.y-=(coords.y-targetoffset.y);
4464 coords.y=targetoffset.y;
4466 normalsupdatedelay=0;
4468 if(currentanimation==upunchanim){
4469 targetanimation=getStop();
4470 normalsupdatedelay=0;
4473 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4474 targetrotation=rotation;
4477 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4478 if(!hasstaff)DoDamage(35);
4481 rabbitkickragdoll=1;
4483 if(currentanimation==rabbitkickreversedanim){
4490 if(id!=0)SolidHitBonus();
4494 targetanimation=rollanim;
4496 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4500 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4506 if(currentanimation==jumpreversedanim){
4513 if(id!=0)SolidHitBonus();
4517 targetanimation=rollanim;
4519 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4524 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){
4525 targetanimation=getupfromfrontanim;
4528 else if(animation[currentanimation].attack==normalattack){
4529 targetanimation=getIdle();
4532 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4533 targetanimation=blockhighleftstrikeanim;
4535 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4536 targetanimation=getIdle();
4539 if(currentanimation==spinkickanim&&victim->skeleton.free){
4540 if(creature==rabbittype)targetanimation=fightidleanim;
4545 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4547 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4548 targetanimation=jumpdownanim;
4553 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4554 if(!isRun()||!wasRun()){
4555 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4556 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4557 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4558 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4560 if(isRun()&&wasRun()){
4563 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4564 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4567 else if(transspeed)target+=multiplier*transspeed*speed*2;
4569 if(!isRun()||!wasRun()){
4570 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4571 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4572 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4573 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4577 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4579 if(target>1){currentframe=targetframe; target=1;}
4581 rot=targetrot*target;
4582 rotation+=rot-oldrot;
4588 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4590 for(i=0;i<skeleton.num_joints;i++){
4591 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4594 skeleton.FindForwards();
4596 for(i=0;i<skeleton.num_muscles;i++){
4597 if(skeleton.muscles[i].visible)
4599 skeleton.FindRotationMuscle(i,targetanimation);
4602 for(i=0;i<skeleton.num_muscles;i++){
4603 if(skeleton.muscles[i].visible)
4605 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4606 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4607 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4612 for(i=0;i<skeleton.num_joints;i++){
4613 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4616 skeleton.FindForwards();
4618 for(i=0;i<skeleton.num_muscles;i++){
4619 if(skeleton.muscles[i].visible)
4621 skeleton.FindRotationMuscle(i,targetanimation);
4624 for(i=0;i<skeleton.num_muscles;i++){
4625 if(skeleton.muscles[i].visible)
4627 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4628 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4629 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4630 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4631 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4632 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4633 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4634 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4635 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4639 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4641 oldcurrentanimation=currentanimation;
4642 oldtargetanimation=targetanimation;
4643 oldtargetframe=targetframe;
4644 oldcurrentframe=currentframe;
4646 for(i=0;i<skeleton.num_joints;i++){
4647 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4648 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4650 offset=currentoffset*(1-target)+targetoffset*target;
4651 for(i=0;i<skeleton.num_muscles;i++){
4652 if(skeleton.muscles[i].visible)
4654 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4655 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4656 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4661 if(isLanding()&&landhard){
4662 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4663 if(id==0)camerashake+=.4;
4664 targetanimation=getLandhard();
4672 //skeleton.DoConstraints();
4675 void Person::DoStuff(){
4676 static XYZ terrainnormal;
4677 static XYZ flatfacing;
4678 static XYZ flatvelocity;
4679 static float flatvelspeed;
4683 static int bloodsize;
4684 static int startx,starty,endx,endy;
4685 static int texdetailint;
4686 static GLubyte color;
4687 static XYZ bloodvel;
4689 onfiredelay-=multiplier;
4690 if(onfiredelay<0&&onfire)
4698 crouchkeydowntime+=multiplier;
4699 if(!crouchkeydown)crouchkeydowntime=0;
4700 jumpkeydowntime+=multiplier;
4701 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
4703 if(hostile||damage>0||bloodloss>0)immobile=0;
4705 if(isIdle()||isRun())targetoffset=0;
4707 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
4709 if(id==0)blooddimamount-=multiplier*.3;
4710 speechdelay-=multiplier;
4711 texupdatedelay-=multiplier;
4712 interestdelay-=multiplier;
4713 flamedelay-=multiplier;
4714 parriedrecently-=multiplier;
4720 if(id==0)speed=1.1*speedmult;
4721 else speed=1.0*speedmult;
4722 if(!skeleton.free)rabbitkickragdoll=0;
4726 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
4727 if(id!=0&&creature==wolftype&&difficulty==2){
4729 if(aitype!=passivetype){
4731 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){
4735 if(scale<0.2)superruntoggle=0;
4736 if(targetanimation==wolfrunninganim&&!superruntoggle){
4737 targetanimation=getRun();
4741 if(weaponactive==-1&&num_weapons>0){
4742 if(weapons.type[weaponids[0]]==staff){
4749 /*if(aitype!=playercontrolled)*///deathbleeding=5;
4750 /*if(aitype!=playercontrolled)*/
4752 if(burnt>.6)burnt=.6;
4753 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
4755 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
4766 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4767 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
4771 while(flamedelay<0&&onfire){
4773 howmany=abs(Random()%(skeleton.num_joints));
4774 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4775 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4776 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4777 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4778 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
4781 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
4783 howmany=abs(Random()%(skeleton.num_joints));
4784 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4785 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4786 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4787 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4788 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
4792 bleeding-=multiplier*.3;
4794 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4795 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
4799 if(neckspurtamount>0){
4800 neckspurtamount-=multiplier;
4801 neckspurtdelay-=multiplier*3;
4802 neckspurtparticledelay-=multiplier*3;
4803 if(neckspurtparticledelay<0&&neckspurtdelay>2){
4807 bloodvel.z=5*neckspurtamount;
4808 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4811 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
4813 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4814 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
4815 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);
4816 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);
4817 neckspurtparticledelay=.05;
4819 if(neckspurtdelay<0){
4824 if(deathbleeding>0&&dead!=2){
4825 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
4826 else bleeddelay-=5*multiplier/4;
4827 if(bleeddelay<0&&bloodtoggle){
4832 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4833 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
4834 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
4835 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);
4838 bloodloss+=deathbleeding*multiplier*80;
4839 deathbleeding-=multiplier*1.6;
4840 //if(id==0)deathbleeding-=multiplier*.2;
4841 if(deathbleeding<0)deathbleeding=0;
4842 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
4843 if(weaponactive!=-1){
4844 weapons.owner[weaponids[0]]=-1;
4845 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4846 weapons.velocity[weaponids[0]].x+=.01;
4847 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4848 weapons.missed[weaponids[0]]=1;
4849 weapons.hitsomething[weaponids[0]]=0;
4850 weapons.freetime[weaponids[0]]=0;
4851 weapons.firstfree[weaponids[0]]=1;
4852 weapons.physics[weaponids[0]]=1;
4855 weaponids[0]=weaponids[num_weapons];
4856 if(weaponstuck==num_weapons)weaponstuck=0;
4859 for(i=0;i<numplayers;i++){
4860 player[i].wentforweapon=0;
4872 if(!dead&&creature==wolftype){
4873 award_bonus(0, Wolfbonus);
4876 if(targetanimation==knifefollowedanim&&!skeleton.free){
4877 for(i=0;i<skeleton.num_joints;i++){
4878 skeleton.joints[i].velocity=0;
4879 skeleton.joints[i].velocity.y=-2;
4882 if(id!=0&&unconscioustime>.1){
4890 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
4893 bloodsize=5-realtexdetail;
4897 texdetailint=realtexdetail;
4898 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
4899 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
4900 endx=startx+bloodsize;
4901 endy=starty+bloodsize;
4903 if(startx<0){startx=0;bleeding=0;}
4904 if(starty<0){starty=0;bleeding=0;}
4905 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
4906 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
4907 if(endx<startx)endx=startx;
4908 if(endy<starty)endy=starty;
4910 for(i=startx;i<endx;i++){
4911 for(j=starty;j<endy;j++){
4913 color=Random()%85+170;
4914 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
4915 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
4916 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
4921 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4922 DoMipmaps(0,startx,endx,starty,endy);
4926 bleedy-=4/realtexdetail;
4927 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
4928 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
4931 bleedx+=4*direction/realtexdetail;
4932 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
4933 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
4937 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
4938 righthandmorphness=targetrighthandmorphness;
4939 righthandmorphstart=righthandmorphend;
4941 else if(righthandmorphness>targetrighthandmorphness){
4942 righthandmorphness-=multiplier*4;
4944 else if(righthandmorphness<targetrighthandmorphness){
4945 righthandmorphness+=multiplier*4;
4948 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
4949 lefthandmorphness=targetlefthandmorphness;
4950 lefthandmorphstart=lefthandmorphend;
4952 else if(lefthandmorphness>targetlefthandmorphness){
4953 lefthandmorphness-=multiplier*4;
4955 else if(lefthandmorphness<targetlefthandmorphness){
4956 lefthandmorphness+=multiplier*4;
4959 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
4960 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
4961 tailmorphness=targettailmorphness;
4962 tailmorphstart=tailmorphend;
4964 else if(tailmorphness>targettailmorphness){
4965 tailmorphness-=multiplier*10;
4967 else if(tailmorphness<targettailmorphness){
4968 tailmorphness+=multiplier*10;
4972 if(creature==wolftype){
4973 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
4974 tailmorphness=targettailmorphness;
4975 tailmorphstart=tailmorphend;
4977 else if(tailmorphness>targettailmorphness){
4978 tailmorphness-=multiplier*2;
4980 else if(tailmorphness<targettailmorphness){
4981 tailmorphness+=multiplier*2;
4985 if(headmorphend==3||headmorphstart==3){
4986 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
4987 headmorphness=targetheadmorphness;
4988 headmorphstart=headmorphend;
4990 else if(headmorphness>targetheadmorphness){
4991 headmorphness-=multiplier*7;
4993 else if(headmorphness<targetheadmorphness){
4994 headmorphness+=multiplier*7;
4997 else if(headmorphend==5||headmorphstart==5){
4998 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
4999 headmorphness=targetheadmorphness;
5000 headmorphstart=headmorphend;
5002 else if(headmorphness>targetheadmorphness){
5003 headmorphness-=multiplier*10;
5005 else if(headmorphness<targetheadmorphness){
5006 headmorphness+=multiplier*10;
5010 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5011 headmorphness=targetheadmorphness;
5012 headmorphstart=headmorphend;
5014 else if(headmorphness>targetheadmorphness){
5015 headmorphness-=multiplier*4;
5017 else if(headmorphness<targetheadmorphness){
5018 headmorphness+=multiplier*4;
5022 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5023 chestmorphness=targetchestmorphness;
5024 chestmorphstart=chestmorphend;
5026 else if(chestmorphness>targetchestmorphness){
5027 chestmorphness-=multiplier;
5029 else if(chestmorphness<targetchestmorphness){
5030 chestmorphness+=multiplier;
5033 if(dead!=2&&howactive<=typesleeping){
5034 if(chestmorphstart==0&&chestmorphend==0){
5036 targetchestmorphness=1;
5039 if(chestmorphstart!=0&&chestmorphend!=0){
5041 targetchestmorphness=1;
5043 if(environment==snowyenvironment){
5046 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5047 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5048 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5049 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5050 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5051 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5055 if(!dead&&howactive<typesleeping){
5056 blinkdelay-=multiplier*2;
5057 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5059 targetheadmorphness=1;
5061 blinkdelay=(float)(abs(Random()%40))/5;
5063 if(headmorphstart==3&&headmorphend==3){
5065 targetheadmorphness=1;
5070 twitchdelay-=multiplier*1.5;
5071 if(targetanimation!=hurtidleanim){
5072 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5074 targetheadmorphness=1;
5076 twitchdelay=(float)(abs(Random()%40))/5;
5078 if(headmorphstart==5&&headmorphend==5){
5080 targetheadmorphness=1;
5084 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5085 twitchdelay3-=multiplier*1;
5087 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5088 righthandmorphness=0;
5089 targetrighthandmorphness=1;
5090 righthandmorphend=1;
5091 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5093 if(righthandmorphstart==1&&righthandmorphend==1){
5094 righthandmorphness=0;
5095 targetrighthandmorphness=1;
5096 righthandmorphend=0;
5100 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5101 lefthandmorphness=0;
5102 targetlefthandmorphness=1;
5104 twitchdelay3=(float)(abs(Random()%40))/5;
5106 if(lefthandmorphstart==1&&lefthandmorphend==1){
5107 lefthandmorphness=0;
5108 targetlefthandmorphness=1;
5115 if(creature==rabbittype){
5116 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5117 else twitchdelay2-=multiplier*0.5;
5118 if(howactive<=typesleeping){
5119 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5121 targettailmorphness=1;
5123 twitchdelay2=(float)(abs(Random()%40))/5;
5125 if(tailmorphstart==1&&tailmorphend==1){
5127 targettailmorphness=1;
5130 if(tailmorphstart==2&&tailmorphend==2){
5132 targettailmorphness=1;
5139 if(creature==wolftype){
5140 twitchdelay2-=multiplier*1.5;
5142 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5144 targettailmorphness=1;
5149 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5151 targettailmorphness=1;
5155 if(twitchdelay2<=0){
5156 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5158 targettailmorphness=1;
5161 if(tailmorphstart==1&&tailmorphend==1){
5163 targettailmorphness=1;
5166 if(tailmorphstart==2&&tailmorphend==2){
5168 targettailmorphness=1;
5171 if(tailmorphstart==3&&tailmorphend==3){
5173 targettailmorphness=1;
5176 if(tailmorphstart==4&&tailmorphend==4){
5178 targettailmorphness=1;
5184 if(dead!=1)unconscioustime=0;
5186 if(dead==1||howactive==typesleeping){
5187 unconscioustime+=multiplier;
5188 //If unconscious, close eyes and mouth
5189 if(righthandmorphend!=0)righthandmorphness=0;
5190 righthandmorphend=0;
5191 targetrighthandmorphness=1;
5193 if(lefthandmorphend!=0)lefthandmorphness=0;
5195 targetlefthandmorphness=1;
5197 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5199 targetheadmorphness=1;
5203 if(howactive>typesleeping){
5206 if(bloodtoggle&&!bled){
5207 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5209 if(bloodtoggle&&!bled)
5210 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5211 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5212 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5216 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5221 if(dead==2||howactive>typesleeping){
5222 //If dead, open mouth and hands
5223 if(righthandmorphend!=0)righthandmorphness=0;
5224 righthandmorphend=0;
5225 targetrighthandmorphness=1;
5227 if(lefthandmorphend!=0)lefthandmorphness=0;
5229 targetlefthandmorphness=1;
5231 if(headmorphend!=2)headmorphness=0;
5233 targetheadmorphness=1;
5236 if(stunned>0&&!dead&&headmorphend!=2){
5237 if(headmorphend!=4)headmorphness=0;
5239 targetheadmorphness=1;
5242 if(damage>damagetolerance&&!dead){
5247 if(creature==wolftype){
5248 award_bonus(0, Wolfbonus);
5253 if(weaponactive!=-1){
5254 weapons.owner[weaponids[0]]=-1;
5255 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5256 weapons.velocity[weaponids[0]].x+=.01;
5257 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5258 weapons.missed[weaponids[0]]=1;
5259 weapons.hitsomething[weaponids[0]]=0;
5260 weapons.freetime[weaponids[0]]=0;
5261 weapons.firstfree[weaponids[0]]=1;
5262 weapons.physics[weaponids[0]]=1;
5265 weaponids[0]=weaponids[num_weapons];
5266 if(weaponstuck==num_weapons)weaponstuck=0;
5269 for(i=0;i<numplayers;i++){
5270 player[i].wentforweapon=0;
5276 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5284 //if(dead)damage-=multiplier/4;
5285 if(!dead)damage-=multiplier*13;
5286 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5287 if(!dead)permanentdamage-=multiplier*4;
5288 if(isIdle()||isCrouch()){
5289 if(!dead)permanentdamage-=multiplier*4;
5290 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5292 if(damage<0)damage=0;
5293 if(permanentdamage<0)permanentdamage=0;
5294 if(superpermanentdamage<0)superpermanentdamage=0;
5295 if(permanentdamage<superpermanentdamage){
5296 permanentdamage=superpermanentdamage;
5298 if(damage<permanentdamage){
5299 damage=permanentdamage;
5301 if(dead==1&&damage<damagetolerance){
5305 for(i=0;i<skeleton.num_joints;i++){
5306 skeleton.joints[i].velocity=0;
5309 if(permanentdamage>damagetolerance&&dead!=2){
5312 if(weaponactive!=-1){
5313 weapons.owner[weaponids[0]]=-1;
5314 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5315 weapons.velocity[weaponids[0]].x+=.01;
5316 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5317 weapons.missed[weaponids[0]]=1;
5318 weapons.hitsomething[weaponids[0]]=0;
5319 weapons.freetime[weaponids[0]]=0;
5320 weapons.firstfree[weaponids[0]]=1;
5321 weapons.physics[weaponids[0]]=1;
5324 weaponids[0]=weaponids[num_weapons];
5325 if(weaponstuck==num_weapons)weaponstuck=0;
5328 for(i=0;i<numplayers;i++){
5329 player[i].wentforweapon=0;
5335 if(!dead&&creature==wolftype){
5336 award_bonus(0, Wolfbonus);
5339 if(unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance)
5340 award_bonus(id, touchofdeath);
5341 if(id!=0&&unconscioustime>.1){
5357 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5358 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5359 OPENAL_SetVolume(channels[breaksound], 512);
5360 OPENAL_SetPaused(channels[breaksound], false);
5361 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5367 if(skeleton.free==1){
5368 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5371 //If knocked over, open hands and close mouth
5372 if(righthandmorphend!=0)righthandmorphness=0;
5373 righthandmorphend=0;
5374 targetrighthandmorphness=1;
5376 if(lefthandmorphend!=0)lefthandmorphness=0;
5378 targetlefthandmorphness=1;
5380 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5381 if(headmorphend!=0)headmorphness=0;
5383 targetheadmorphness=1;
5387 skeleton.DoGravity(&scale);
5389 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5390 if(damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1))
5391 award_bonus(id, deepimpact);
5392 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5396 for(j=0;j<skeleton.num_joints;j++){
5397 average+=skeleton.joints[j].position;
5401 coords+=average*scale;
5402 for(j=0;j<skeleton.num_joints;j++){
5403 skeleton.joints[j].position-=average;
5405 average/=multiplier;
5407 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5409 for(i=0;i<skeleton.num_joints;i++){
5410 velocity+=skeleton.joints[i].velocity*scale;
5412 velocity/=skeleton.num_joints;
5414 if(!isnormal(velocity.x)&&velocity.x){
5427 if(findLength(&average)<10&&dead&&skeleton.free){
5428 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5429 if(skeleton.longdead>2000){
5430 if(skeleton.longdead>6000){
5431 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5436 if(dead==2&&bloodloss<damagetolerance){
5438 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5440 if(bloodtoggle&&!bled){
5441 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5443 if(bloodtoggle&&!bled)
5444 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5445 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5446 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5450 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5454 if(dead==2&&bloodloss>=damagetolerance){
5456 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5457 if(bleeding<=0)DoBlood(1,255);
5458 if(bloodtoggle&&!bled){
5459 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5461 if(bloodtoggle&&!bled)
5462 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5463 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5464 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5468 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5475 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5477 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5481 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5482 if(velocity.y<-30)canrecover=0;
5483 for(i=0;i<objects.numobjects;i++){
5484 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5485 colviewer=startpoint;
5487 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5495 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5496 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5497 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5498 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5500 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5501 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5502 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5504 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5505 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5506 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5508 Normalise(&terrainnormal);
5510 targetrotation=-asin(0-terrainnormal.x);
5511 targetrotation*=360/6.28;
5512 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5513 rotation=targetrotation;
5515 //if(skeleton.forward.y<0){
5518 //if(skeleton.forward.y>-.3){
5521 targetanimation=flipanim;
5522 crouchtogglekeydown=1;
5527 currentanimation=tempanim;
5530 //tilt2=targettilt2;
5532 //if(middle.y>0)targetoffset.y=middle.y+1;
5534 for(i=0;i<skeleton.num_joints;i++){
5535 tempanimation.position[i][0]=skeleton.joints[i].position;
5536 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5541 if(findLength(&average)<10&&!dead&&skeleton.free){
5542 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5543 if(skeleton.longdead>(damage+500)*1.5){
5544 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5550 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5551 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5552 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5553 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5555 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5556 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5557 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5559 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5560 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5561 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5563 Normalise(&terrainnormal);
5565 targetrotation=-asin(0-terrainnormal.x);
5566 targetrotation*=360/6.28;
5567 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5568 rotation=targetrotation;
5571 terrainnormal=terrain.getNormal(coords.x,coords.z);
5572 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5576 /*XYZ otherterrainnormal;
5577 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5578 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5579 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5580 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5583 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5587 if(skeleton.forward.y<0){
5588 targetanimation=getupfrombackanim;
5592 if(skeleton.forward.y>-.3){
5593 targetanimation=getupfromfrontanim;
5595 targetrotation+=180;
5601 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5602 targetanimation=rollanim;
5603 targetrotation=lookrotation;
5607 if(forwardkeydown)targetrotation+=45;
5608 if(backkeydown)targetrotation-=45;
5612 if(forwardkeydown)targetrotation-=45;
5613 if(backkeydown)targetrotation+=45;
5616 if ( !leftkeydown&&!rightkeydown)
5617 targetrotation+=180;
5619 targetrotation+=180;
5623 if(abs(targettilt2)>50)targettilt2=0;
5624 currentanimation=tempanim;
5629 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5631 for(i=0;i<skeleton.num_joints;i++){
5632 tempanimation.position[i][0]=skeleton.joints[i].position;
5633 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5640 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5641 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5644 tempvelocity=velocity;
5645 Normalise(&tempvelocity);
5646 targetrotation=-asin(0-tempvelocity.x);
5647 targetrotation*=360/6.28;
5648 if(velocity.z<0)targetrotation=180-targetrotation;
5649 //targetrotation+=180;
5652 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5653 targetanimation=rollanim;
5657 targetanimation=backhandspringanim;
5658 targetrotation+=180;
5671 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
5672 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
5673 OPENAL_SetVolume(channels[movewhooshsound], 128);
5674 OPENAL_SetPaused(channels[movewhooshsound], false);
5676 currentanimation=targetanimation;
5677 currentframe=targetframe-1;
5682 rotation=targetrotation;
5689 if(skeleton.freefall==0)freefall=0;
5691 if(!isnormal(velocity.x)&&velocity.x){
5696 if(aitype!=passivetype||skeleton.free==1)
5697 if(findLengthfast(&velocity)>.1)
5698 for(i=0;i<objects.numobjects;i++){
5699 if(objects.type[i]==firetype)
5700 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){
5702 if(!objects.onfire[i]){
5705 gLoc[0]=objects.position[i].x;
5706 gLoc[1]=objects.position[i].y;
5707 gLoc[2]=objects.position[i].z;
5711 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5712 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5713 OPENAL_SetVolume(channels[firestartsound], 256);
5714 OPENAL_SetPaused(channels[firestartsound], false);
5716 objects.onfire[i]=1;
5719 if(objects.onfire[i]){
5724 if(objects.type[i]==bushtype)
5725 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){
5727 if(!objects.onfire[i]){
5730 gLoc[0]=objects.position[i].x;
5731 gLoc[1]=objects.position[i].y;
5732 gLoc[2]=objects.position[i].z;
5736 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5737 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5738 OPENAL_SetVolume(channels[firestartsound], 256);
5739 OPENAL_SetPaused(channels[firestartsound], false);
5741 objects.onfire[i]=1;
5745 if(objects.onfire[i]){
5749 if(objects.messedwith[i]<=0){
5761 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5762 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5763 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5764 OPENAL_SetPaused(channels[bushrustle], false);
5767 envsound[numenvsounds]=coords;
5768 envsoundvol[numenvsounds]=4*findLength(&velocity);
5769 envsoundlife[numenvsounds]=.4;
5774 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5775 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5777 if(environment!=desertenvironment)
5778 for(j=0;j<howmany;j++){
5779 tempvel.x=float(abs(Random()%100)-50)/20;
5780 tempvel.y=float(abs(Random()%100)-50)/20;
5781 tempvel.z=float(abs(Random()%100)-50)/20;
5784 pos.x+=float(abs(Random()%100)-50)/200;
5785 pos.y+=float(abs(Random()%100)-50)/200;
5786 pos.z+=float(abs(Random()%100)-50)/200;
5787 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);
5788 Sprite::setLastSpriteSpecial(1);
5790 howmany=findLength(&velocity)*4;
5792 if(environment==snowyenvironment)
5793 for(j=0;j<howmany;j++){
5794 tempvel.x=float(abs(Random()%100)-50)/20;
5795 tempvel.y=float(abs(Random()%100)-50)/20;
5796 tempvel.z=float(abs(Random()%100)-50)/20;
5799 pos.x+=float(abs(Random()%100)-50)/200;
5800 pos.y+=float(abs(Random()%100)-50)/200;
5801 pos.z+=float(abs(Random()%100)-50)/200;
5802 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5803 Sprite::setLastSpriteSpecial(2);
5806 objects.rotx[i]+=velocity.x*multiplier*6;
5807 objects.roty[i]+=velocity.z*multiplier*6;
5808 objects.messedwith[i]=.5;
5811 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
5812 if(objects.rotation2[i]==0)tempcoord=coords;
5814 tempcoord=coords-objects.position[i];
5815 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
5816 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
5817 tempcoord+=objects.position[i];
5819 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]){
5820 if(objects.messedwith[i]<=0){
5832 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5833 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5834 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5835 OPENAL_SetPaused(channels[bushrustle], false);
5838 envsound[numenvsounds]=coords;
5839 envsoundvol[numenvsounds]=4*findLength(&velocity);
5840 envsoundlife[numenvsounds]=.4;
5845 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5846 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5848 if(environment!=desertenvironment)
5849 for(j=0;j<howmany;j++){
5850 tempvel.x=float(abs(Random()%100)-50)/20;
5851 tempvel.y=float(abs(Random()%100)-50)/20;
5852 tempvel.z=float(abs(Random()%100)-50)/20;
5856 pos.x+=float(abs(Random()%100)-50)/150;
5857 pos.y+=float(abs(Random()%100)-50)/150;
5858 pos.z+=float(abs(Random()%100)-50)/150;
5859 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);
5860 Sprite::setLastSpriteSpecial(1);
5862 howmany=findLength(&velocity)*4;
5864 if(environment==snowyenvironment)
5865 for(j=0;j<howmany;j++){
5866 tempvel.x=float(abs(Random()%100)-50)/20;
5867 tempvel.y=float(abs(Random()%100)-50)/20;
5868 tempvel.z=float(abs(Random()%100)-50)/20;
5872 pos.x+=float(abs(Random()%100)-50)/150;
5873 pos.y+=float(abs(Random()%100)-50)/150;
5874 pos.z+=float(abs(Random()%100)-50)/150;
5875 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5876 Sprite::setLastSpriteSpecial(2);
5879 objects.messedwith[i]=.5;
5887 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
5889 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
5890 if(tutoriallevel==1&&id!=0)play=0;
5891 if(play&&aitype!=playercontrolled){
5903 if(creature==rabbittype){
5904 if(i==0)whichsound=rabbitchitter;
5905 if(i==1)whichsound=rabbitchitter2;
5907 if(creature==wolftype){
5908 if(i==0)whichsound=growlsound;
5909 if(i==1)whichsound=growl2sound;
5915 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
5916 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
5917 OPENAL_SetVolume(channels[whichsound], 512);
5918 OPENAL_SetPaused(channels[whichsound], false);
5922 if(targetanimation==staggerbackhighanim)staggerdelay=1;
5923 if(targetanimation==staggerbackhardanim)staggerdelay=1;
5924 staggerdelay-=multiplier;
5925 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
5926 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
5927 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
5928 targetanimation=getIdle();
5932 weaponmissdelay-=multiplier;
5933 highreversaldelay-=multiplier;
5934 lowreversaldelay-=multiplier;
5935 lastcollide-=multiplier;
5936 skiddelay-=multiplier;
5937 if(!isnormal(velocity.x)&&velocity.x){
5940 if(!isnormal(targettilt)&&targettilt){
5943 if(!isnormal(targettilt2)&&targettilt2){
5946 if(!isnormal(targetrotation)&&targetrotation){
5950 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
5951 //open hands and close mouth
5952 //if(targetanimation!=wolfidle){
5953 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
5954 righthandmorphness=0;
5955 righthandmorphend=0;
5956 targetrighthandmorphness=1;
5959 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
5960 lefthandmorphness=0;
5962 targetlefthandmorphness=1;
5966 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
5969 targetheadmorphness=1;
5973 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){
5974 //open hands and mouth
5975 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
5976 righthandmorphness=0;
5977 righthandmorphend=0;
5978 targetrighthandmorphness=1;
5981 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
5982 lefthandmorphness=0;
5984 targetlefthandmorphness=1;
5987 if(headmorphend!=1&&headmorphness==targetheadmorphness){
5990 targetheadmorphness=1;
5994 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
5995 //close hands and mouth
5996 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
5997 righthandmorphness=0;
5998 righthandmorphend=1;
5999 targetrighthandmorphness=1;
6002 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6003 lefthandmorphness=0;
6005 targetlefthandmorphness=1;
6008 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6011 targetheadmorphness=1;
6015 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){
6016 //close hands and yell
6017 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6018 righthandmorphness=0;
6019 righthandmorphend=1;
6020 targetrighthandmorphness=1;
6023 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6024 lefthandmorphness=0;
6026 targetlefthandmorphness=1;
6029 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6032 targetheadmorphness=1;
6036 if(speechdelay>.25){
6037 if(headmorphend!=2)headmorphness=0;
6039 targetheadmorphness=1;
6045 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6046 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6050 if(!dead&&targetanimation!=hurtidleanim)
6051 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6052 if(headmorphend!=4||headmorphness==targetheadmorphness){
6055 targetheadmorphness=1;
6059 if(weaponactive!=-1){
6060 if(weapons.type[weaponids[weaponactive]]!=staff){
6061 righthandmorphstart=1;
6062 righthandmorphend=1;
6064 if(weapons.type[weaponids[weaponactive]]==staff){
6065 righthandmorphstart=2;
6066 righthandmorphend=2;
6068 targetrighthandmorphness=1;
6071 terrainnormal=terrain.getNormal(coords.x,coords.z);
6073 if(animation[targetanimation].attack!=reversal){
6074 if(!isnormal(coords.x))
6082 flatfacing=DoRotation(flatfacing,0,rotation,0);
6084 ReflectVector(&facing,terrainnormal);
6087 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6088 if(onterrain)targettilt2=-facing.y*20;
6092 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6093 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6094 flatvelocity=velocity;
6096 flatvelspeed=findLength(&flatvelocity);
6097 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6098 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6099 if(velocity.y<0)targettilt2*=-1;
6100 if(velocity.y<0)targettilt*=-1;
6101 if(targettilt>25)targettilt=25;
6102 if(targettilt<-25)targettilt=-25;
6105 if(targettilt2>45)targettilt2=45;
6106 if(targettilt2<-45)targettilt2=-45;
6107 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6108 else if(tilt2>targettilt2){
6109 tilt2-=multiplier*400;
6111 else if(tilt2<targettilt2){
6112 tilt2+=multiplier*400;
6114 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6115 if(tilt2>25)tilt2=25;
6116 if(tilt2<-25)tilt2=-25;
6119 if(!isnormal(targettilt)&&targettilt){
6122 if(!isnormal(targettilt2)&&targettilt2){
6127 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6128 if(targetanimation==rabbittackleanim){
6129 velocity+=facing*multiplier*speed*700*scale;
6130 velspeed=findLength(&velocity);
6131 if(velspeed>speed*65*scale){
6133 velspeed=speed*65*scale;
6136 velocity.y+=gravity*multiplier*20;
6137 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6138 velspeed=findLength(&velocity);
6139 velocity=flatfacing*velspeed;
6141 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6142 if(isRun()||targetanimation==rabbitkickanim){
6143 velocity+=facing*multiplier*speed*700*scale;
6144 velspeed=findLength(&velocity);
6145 if(velspeed>speed*45*scale){
6147 velspeed=speed*45*scale;
6150 velocity.y+=gravity*multiplier*20;
6151 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6152 velspeed=findLength(&velocity);
6153 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6154 velocity=flatfacing*velspeed;
6158 velocity+=facing*multiplier*speed*700*scale;
6159 velspeed=findLength(&velocity);
6160 if(creature==rabbittype){
6161 if(velspeed>speed*55*scale){
6163 velspeed=speed*55*scale;
6167 if(creature==wolftype){
6168 if(velspeed>speed*75*scale){
6170 velspeed=speed*75*scale;
6174 velocity.y+=gravity*multiplier*20;
6175 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6176 velspeed=findLength(&velocity);
6177 velocity=flatfacing*velspeed;
6180 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6181 velocity+=facing*multiplier*speed*700*scale;
6182 velspeed=findLength(&velocity);
6183 if(velspeed>speed*45*scale){
6185 velspeed=speed*45*scale;
6188 velocity.y+=gravity*multiplier*20;
6189 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6190 velspeed=findLength(&velocity);
6191 velocity=flatfacing*velspeed;
6195 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6196 velocity+=facing*multiplier*speed*700*scale;
6197 velspeed=findLength(&velocity);
6198 if(velspeed>speed*25*scale){
6200 velspeed=speed*25*scale;
6203 velocity.y+=gravity*multiplier*20;
6204 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6205 velspeed=findLength(&velocity);
6206 velocity=flatfacing*velspeed;
6209 if(targetanimation==sneakanim||targetanimation==walkanim){
6210 velocity+=facing*multiplier*speed*700*scale;
6211 velspeed=findLength(&velocity);
6212 if(velspeed>speed*12*scale){
6214 velspeed=speed*12*scale;
6217 velocity.y+=gravity*multiplier*20;
6218 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6219 velspeed=findLength(&velocity);
6220 velocity=flatfacing*velspeed;
6223 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6224 velocity+=facing*multiplier*speed*700*scale;
6225 velspeed=findLength(&velocity);
6226 if(velspeed>speed*2*scale){
6228 velspeed=speed*2*scale;
6231 velocity.y+=gravity*multiplier*20;
6232 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6233 velspeed=findLength(&velocity);
6234 velocity=flatfacing*velspeed;
6238 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6239 velocity-=facing*multiplier*speed*700*scale;
6240 velspeed=findLength(&velocity);
6241 if(velspeed>speed*2*scale){
6243 velspeed=speed*2*scale;
6246 velocity.y+=gravity*multiplier*20;
6247 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6248 velspeed=findLength(&velocity);
6249 velocity=flatfacing*velspeed*-1;
6252 if(targetanimation==fightsidestep){
6253 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6254 velspeed=findLength(&velocity);
6255 if(velspeed>speed*12*scale){
6257 velspeed=speed*12*scale;
6260 velocity.y+=gravity*multiplier*20;
6261 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6262 velspeed=findLength(&velocity);
6263 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6266 if(targetanimation==staggerbackhighanim){
6267 coords-=facing*multiplier*speed*16*scale;
6270 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6271 coords-=facing*multiplier*speed*20*scale;
6275 if(targetanimation==backhandspringanim){
6276 //coords-=facing*multiplier*50*scale;
6277 velocity+=facing*multiplier*speed*700*scale*-1;
6278 velspeed=findLength(&velocity);
6279 if(velspeed>speed*50*scale){
6281 velspeed=speed*50*scale;
6284 velocity.y+=gravity*multiplier*20;
6285 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6286 velspeed=findLength(&velocity);
6287 velocity=flatfacing*velspeed*-1;
6289 if(targetanimation==dodgebackanim){
6290 //coords-=facing*multiplier*50*scale;
6291 velocity+=facing*multiplier*speed*700*scale*-1;
6292 velspeed=findLength(&velocity);
6293 if(velspeed>speed*60*scale){
6295 velspeed=speed*60*scale;
6298 velocity.y+=gravity*multiplier*20;
6299 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6300 velspeed=findLength(&velocity);
6301 velocity=flatfacing*velspeed*-1;
6304 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6305 velspeed=findLength(&velocity);
6309 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6310 velocity.y+=gravity*multiplier;
6313 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6315 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6316 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6318 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6324 OPENAL_SetPaused(channels[whooshsound], true);
6325 OPENAL_SetVolume(channels[whooshsound], 0);
6328 if(targetanimation==jumpdownanim||isFlip()){
6329 if(isFlip())jumppower=-4;
6330 targetanimation=getLanding();
6339 PlaySoundEx( landsound, samp[landsound], NULL, true);
6340 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6341 OPENAL_SetVolume(channels[landsound], 128);
6342 OPENAL_SetPaused(channels[landsound], false);
6345 envsound[numenvsounds]=coords;
6346 envsoundvol[numenvsounds]=16;
6347 envsoundlife[numenvsounds]=.4;
6353 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6354 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6355 coords.y=terrain.getHeight(coords.x,coords.z);
6360 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)){
6361 velspeed=findLength(&velocity);
6363 if(velspeed<multiplier*300*scale){
6365 } else velocity-=velocity/velspeed*multiplier*300*scale;
6366 if(velspeed>5&&(isLanding()||isLandhard())){
6367 skiddingdelay+=multiplier;
6374 else skiddingdelay=0;
6378 velspeed=findLength(&velocity);
6380 if(velspeed<multiplier*600*scale){
6382 } else velocity-=velocity/velspeed*multiplier*600*scale;
6384 if(velspeed>5&&(isLanding()||isLandhard())){
6385 skiddingdelay+=multiplier;
6392 else skiddingdelay=0;
6395 if(skiddingdelay<0)skiddingdelay+=multiplier;
6396 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6406 if(!onterrain||environment==grassyenvironment){
6407 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6408 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6409 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6410 OPENAL_SetPaused(channels[skidsound], false);
6413 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6414 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6415 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6416 OPENAL_SetPaused(channels[snowskidsound], false);
6420 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6421 terrainnormal=victim->coords-coords;
6422 Normalise(&terrainnormal);
6423 targetrotation=-asin(0-terrainnormal.x);
6424 targetrotation*=360/6.28;
6425 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6426 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6429 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6430 targetrotation=victim->targetrotation;
6432 if(targetanimation==rabbittacklinganim){
6433 coords=victim->coords;
6436 skeleton.oldfree=skeleton.free;
6440 midterrain.x=terrain.size*terrain.scale/2;
6441 midterrain.z=terrain.size*terrain.scale/2;
6442 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6444 tempposit=coords-midterrain;
6446 Normalise(&tempposit);
6447 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6448 coords.x=tempposit.x+midterrain.x;
6449 coords.z=tempposit.z+midterrain.z;
6453 int Person::DrawSkeleton(){
6454 int oldplayerdetail;
6455 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6456 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6466 glAlphaFunc(GL_GREATER, 0.0001);
6468 float terrainheight;
6470 if(!isnormal(rotation))rotation=0;
6471 if(!isnormal(tilt))tilt=0;
6472 if(!isnormal(tilt2))tilt2=0;
6473 oldplayerdetail=playerdetail;
6475 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6478 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6481 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6486 if(playerdetail!=oldplayerdetail) {
6488 normalsupdatedelay=0;
6490 static float updatedelaychange;
6491 static float morphness;
6492 static float framemult;
6494 skeleton.FindForwards();
6495 if(howactive==typesittingwall){
6496 skeleton.specialforward[1]=0;
6497 skeleton.specialforward[1].z=1;
6503 static int weaponattachmuscle;
6504 static int weaponrotatemuscle,weaponrotatemuscle2;
6505 static XYZ weaponpoint;
6506 static int start,endthing;
6507 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6508 if(!isSleeping()&&!isSitting()){
6509 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6510 XYZ point,newpoint,change,change2;
6511 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6512 heightleft=terrain.getHeight(point.x,point.z)+.04;
6514 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6515 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6516 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6517 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6518 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6520 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6521 heightright=terrain.getHeight(point.x,point.z)+.04;
6522 point.y=heightright;
6523 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6524 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6525 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6526 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6527 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6528 skeleton.DoConstraints(&coords,&scale);
6530 if(creature==wolftype){
6531 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6532 heightleft=terrain.getHeight(point.x,point.z)+.04;
6534 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6535 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6536 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6537 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6538 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6540 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6541 heightright=terrain.getHeight(point.x,point.z)+.04;
6542 point.y=heightright;
6543 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6544 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6545 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6546 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6547 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6548 skeleton.DoConstraints(&coords,&scale);
6551 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6552 XYZ point,newpoint,change,change2;
6553 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6554 heightleft=terrain.getHeight(point.x,point.z)+.04;
6556 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6557 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6558 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6559 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6560 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6562 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6563 heightright=terrain.getHeight(point.x,point.z)+.04;
6564 point.y=heightright;
6565 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6566 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6567 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6568 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6569 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6570 skeleton.DoConstraints(&coords,&scale);
6572 if(creature==wolftype){
6573 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6574 heightleft=terrain.getHeight(point.x,point.z)+.04;
6576 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6577 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6578 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6579 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6580 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6582 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6583 heightright=terrain.getHeight(point.x,point.z)+.04;
6584 point.y=heightright;
6585 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6586 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6587 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6588 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6589 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6590 skeleton.DoConstraints(&coords,&scale);
6594 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6595 XYZ point,newpoint,change,change2;
6596 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6597 heightleft=terrain.getHeight(point.x,point.z)+.04;
6599 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6600 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6601 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6602 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6603 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6605 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6606 heightright=terrain.getHeight(point.x,point.z)+.04;
6607 point.y=heightright;
6608 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6609 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6610 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6611 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6612 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6613 skeleton.DoConstraints(&coords,&scale);
6615 if(creature==wolftype){
6616 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6617 heightleft=terrain.getHeight(point.x,point.z)+.04;
6619 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6620 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6621 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6622 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6623 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6625 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6626 heightright=terrain.getHeight(point.x,point.z)+.04;
6627 point.y=heightright;
6628 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6629 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6630 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6631 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6632 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6633 skeleton.DoConstraints(&coords,&scale);
6637 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()))
6640 targetheadrotation=-targetrotation;
6641 targetheadrotation2=0;
6642 if(animation[targetanimation].attack==3)targetheadrotation+=180;
6644 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6645 skeleton.drawmodel.vertex[i]=0;
6646 skeleton.drawmodel.vertex[i].y=999;
6648 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
6649 skeleton.drawmodellow.vertex[i]=0;
6650 skeleton.drawmodellow.vertex[i].y=999;
6652 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
6653 skeleton.drawmodelclothes.vertex[i]=0;
6654 skeleton.drawmodelclothes.vertex[i].y=999;
6656 for(i=0;i<skeleton.num_muscles;i++){
6657 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
6661 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
6662 morphness=righthandmorphness;
6663 start=righthandmorphstart;
6664 endthing=righthandmorphend;
6666 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
6667 morphness=lefthandmorphness;
6668 start=lefthandmorphstart;
6669 endthing=lefthandmorphend;
6671 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
6672 morphness=headmorphness;
6673 start=headmorphstart;
6674 endthing=headmorphend;
6676 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)){
6677 morphness=chestmorphness;
6678 start=chestmorphstart;
6679 endthing=chestmorphend;
6681 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)){
6682 morphness=tailmorphness;
6683 start=tailmorphstart;
6684 endthing=tailmorphend;
6686 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
6687 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6688 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6691 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6692 if(!skeleton.free)glRotatef(tilt,0,0,1);
6695 glTranslatef(mid.x,mid.y,mid.z);
6697 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6698 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6700 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6701 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6703 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6704 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6706 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
6710 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
6714 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
6718 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
6723 if(playerdetail||skeleton.free==3)
6725 for(j=0;j<skeleton.muscles[i].numvertices;j++)
6727 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
6728 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
6729 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
6730 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
6731 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
6732 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
6733 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
6734 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6736 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6737 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,
6738 (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,
6739 (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);
6740 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)
6741 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,
6742 (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,
6743 (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);
6744 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)
6745 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,
6746 (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,
6747 (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);
6748 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6749 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,
6750 (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,
6751 (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);
6752 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6753 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
6754 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
6755 //if(!isnormal(scale))test=1;
6756 //if(isnormal(scale)){
6757 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
6758 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
6759 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
6767 if(!playerdetail||skeleton.free==3)
6769 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
6771 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
6772 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6774 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6775 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
6776 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
6777 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
6778 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)
6779 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
6780 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
6781 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
6782 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)
6783 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
6784 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
6785 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
6786 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6787 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
6788 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
6789 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
6791 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6792 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
6793 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
6794 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
6801 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
6802 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6804 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6807 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6808 if(!skeleton.free)glRotatef(tilt,0,0,1);
6809 glTranslatef(mid.x,mid.y,mid.z);
6810 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6811 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6813 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6814 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6816 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6817 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6819 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
6820 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6822 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6823 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
6824 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
6825 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
6826 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)
6827 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
6828 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
6829 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
6830 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)
6831 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
6832 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
6833 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
6834 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6835 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
6836 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
6837 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
6838 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6839 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
6840 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
6841 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
6846 updatedelay=1+(float)(Random()%100)/1000;
6848 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
6849 normalsupdatedelay=1;
6850 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
6851 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
6852 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
6856 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
6857 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
6858 if(skeleton.clothes){
6859 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
6864 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
6865 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
6866 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
6867 if(skeleton.free==1)updatedelaychange*=6;
6868 if(id==0)updatedelaychange*=8;
6869 updatedelay+=updatedelaychange;
6871 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6873 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
6874 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
6875 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
6876 if(!skeleton.free)glRotatef(rotation,0,1,0);
6879 glColor4f(.4,1,.4,1);
6880 glDisable(GL_LIGHTING);
6881 glDisable(GL_TEXTURE_2D);
6884 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6885 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
6891 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
6892 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);
6893 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);
6894 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);
6895 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);
6896 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);
6897 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);
6903 terrainlight=terrain.getLighting(coords.x,coords.z);
6904 distance=findDistancefast(&viewer,&coords);
6905 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
6906 if(distance>1)distance=1;
6908 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
6909 if(terrainheight<1)terrainheight=1;
6910 if(terrainheight>1.7)terrainheight=1.7;
6913 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
6914 glDisable(GL_BLEND);
6915 glAlphaFunc(GL_GREATER, 0.0001);
6916 glEnable(GL_TEXTURE_2D);
6918 glDisable(GL_TEXTURE_2D);
6919 glColor4f(.7,.35,0,.5);
6921 glEnable(GL_LIGHTING);
6924 if(tutoriallevel&&id!=0){
6925 //glDisable(GL_TEXTURE_2D);
6926 glColor4f(.7,.7,.7,0.6);
6928 glEnable(GL_LIGHTING);
6930 if(canattack&&cananger)
6931 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
6932 glDisable(GL_TEXTURE_2D);
6933 glColor4f(1,0,0,0.8);
6935 glMatrixMode(GL_TEXTURE);
6937 glTranslatef(0,-smoketex,0);
6938 glTranslatef(-smoketex,0,0);
6942 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
6943 else skeleton.drawmodel.draw();
6947 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
6948 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
6951 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
6952 if(tutoriallevel&&id!=0){
6954 glMatrixMode(GL_MODELVIEW);
6955 glEnable(GL_TEXTURE_2D);
6956 glColor4f(.7,.7,.7,0.6);
6958 glEnable(GL_LIGHTING);
6960 if(canattack&&cananger)
6961 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
6962 glDisable(GL_TEXTURE_2D);
6963 glColor4f(1,0,0,0.8);
6965 glMatrixMode(GL_TEXTURE);
6967 glTranslatef(0,-smoketex*.6,0);
6968 glTranslatef(smoketex*.6,0,0);
6971 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
6972 else skeleton.drawmodel.draw();
6976 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
6977 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
6982 if(tutoriallevel&&id!=0){
6984 glMatrixMode(GL_MODELVIEW);
6985 glEnable(GL_TEXTURE_2D);
6987 if(skeleton.clothes){
6990 if(!immediate)skeleton.drawmodelclothes.draw();
6991 if(immediate)skeleton.drawmodelclothes.drawimmediate();
6998 for(k=0;k<num_weapons;k++){
7000 if(weaponactive==k){
7001 if(weapons.type[i]!=staff){
7002 for(j=0;j<skeleton.num_muscles;j++){
7003 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7004 weaponattachmuscle=j;
7007 for(j=0;j<skeleton.num_muscles;j++){
7008 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){
7009 weaponrotatemuscle=j;
7012 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7013 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7015 if(weapons.type[i]==staff){
7016 for(j=0;j<skeleton.num_muscles;j++){
7017 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7018 weaponattachmuscle=j;
7021 for(j=0;j<skeleton.num_muscles;j++){
7022 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){
7023 weaponrotatemuscle=j;
7026 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7027 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7028 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7029 XYZ tempnormthing,vec1,vec2;
7030 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7031 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7032 CrossProduct(&vec1,&vec2,&tempnormthing);
7033 Normalise(&tempnormthing);
7034 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);
7035 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7037 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7038 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7039 Normalise(&weaptargnorm);
7040 weaponpoint-=weaptargnorm*2;
7044 if(weaponactive!=k&&weaponstuck!=k){
7045 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;
7046 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;
7047 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;
7048 for(j=0;j<skeleton.num_muscles;j++){
7049 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){
7050 weaponrotatemuscle=j;
7055 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7056 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7057 for(j=0;j<skeleton.num_muscles;j++){
7058 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){
7059 weaponrotatemuscle=j;
7064 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;
7065 weapons.bigrotation[i]=rotation;
7066 weapons.bigtilt[i]=tilt;
7067 weapons.bigtilt2[i]=tilt2;
7070 weapons.position[i]=weaponpoint*scale+coords;
7071 weapons.bigrotation[i]=0;
7072 weapons.bigtilt[i]=0;
7073 weapons.bigtilt2[i]=0;
7075 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7076 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7077 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7078 if(weaponactive==k){
7079 if(weapons.type[i]==knife){
7080 weapons.smallrotation[i]=180;
7081 weapons.smallrotation2[i]=0;
7082 if(isCrouch()||wasCrouch()){
7083 weapons.smallrotation2[i]=20;
7085 if(targetanimation==hurtidleanim){
7086 weapons.smallrotation2[i]=50;
7088 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7089 XYZ temppoint1,temppoint2,tempforward;
7092 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7093 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7094 distance=findDistance(&temppoint1,&temppoint2);
7095 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7096 weapons.rotation2[i]*=360/6.28;
7099 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7100 weapons.rotation1[i]*=360/6.28;
7101 weapons.rotation3[i]=0;
7102 weapons.smallrotation[i]=-90;
7103 weapons.smallrotation2[i]=0;
7104 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7106 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7107 XYZ temppoint1,temppoint2,tempforward;
7110 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7111 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7112 distance=findDistance(&temppoint1,&temppoint2);
7113 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7114 weapons.rotation2[i]*=360/6.28;
7117 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7118 weapons.rotation1[i]*=360/6.28;
7119 weapons.rotation3[i]=0;
7120 weapons.smallrotation[i]=90;
7121 weapons.smallrotation2[i]=0;
7122 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7124 if(targetanimation==knifethrowanim){
7125 weapons.smallrotation[i]=90;
7126 //weapons.smallrotation2[i]=-90;
7127 weapons.smallrotation2[i]=0;
7128 weapons.rotation1[i]=0;
7129 weapons.rotation2[i]=0;
7130 weapons.rotation3[i]=0;
7132 if(targetanimation==knifesneakattackanim&&targetframe<5){
7133 weapons.smallrotation[i]=-90;
7134 weapons.rotation1[i]=0;
7135 weapons.rotation2[i]=0;
7136 weapons.rotation3[i]=0;
7139 if(weapons.type[i]==sword){
7140 weapons.smallrotation[i]=0;
7141 weapons.smallrotation2[i]=0;
7142 if(targetanimation==knifethrowanim){
7143 weapons.smallrotation[i]=-90;
7144 weapons.smallrotation2[i]=0;
7145 weapons.rotation1[i]=0;
7146 weapons.rotation2[i]=0;
7147 weapons.rotation3[i]=0;
7149 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)){
7150 XYZ temppoint1,temppoint2,tempforward;
7153 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7154 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7155 distance=findDistance(&temppoint1,&temppoint2);
7156 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7157 weapons.rotation2[i]*=360/6.28;
7160 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7161 weapons.rotation1[i]*=360/6.28;
7162 weapons.rotation3[i]=0;
7163 weapons.smallrotation[i]=90;
7164 weapons.smallrotation2[i]=0;
7165 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7168 if(weapons.type[i]==staff){
7169 weapons.smallrotation[i]=100;
7170 weapons.smallrotation2[i]=0;
7171 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7172 XYZ temppoint1,temppoint2,tempforward;
7175 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7176 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7177 distance=findDistance(&temppoint1,&temppoint2);
7178 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7179 weapons.rotation2[i]*=360/6.28;
7182 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7183 weapons.rotation1[i]*=360/6.28;
7184 weapons.rotation3[i]=0;
7185 weapons.smallrotation[i]=90;
7186 weapons.smallrotation2[i]=0;
7187 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7191 if(weaponactive!=k&&weaponstuck!=k){
7192 if(weapons.type[i]==knife){
7193 weapons.smallrotation[i]=-70;
7194 weapons.smallrotation2[i]=10;
7196 if(weapons.type[i]==sword){
7197 weapons.smallrotation[i]=-100;
7198 weapons.smallrotation2[i]=-8;
7200 if(weapons.type[i]==staff){
7201 weapons.smallrotation[i]=-100;
7202 weapons.smallrotation2[i]=-8;
7206 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7207 else weapons.smallrotation[i]=0;
7208 weapons.smallrotation2[i]=10;
7209 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7217 if(skeleton.free)calcrot=1;
7218 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7219 if(currentanimation!=targetanimation)calcrot=1;
7220 //if(id==0)calcrot=1;
7221 if(skeleton.free==2)calcrot=0;
7227 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7230 static float distance;
7231 static float olddistance;
7232 static int intersecting;
7233 static int firstintersecting;
7236 static XYZ start,end;
7237 static float slopethreshold=-.4;
7239 firstintersecting=-1;
7243 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7244 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7246 for (j=0;j<model->TriangleNum;j++){
7247 if(model->facenormals[j].y<=slopethreshold){
7249 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)));
7250 if(distance<radius){
7251 point=*p1-model->facenormals[j]*distance;
7252 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;
7253 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7254 &model->vertex[model->Triangles[j].vertex[1]],
7256 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7257 &model->vertex[model->Triangles[j].vertex[2]],
7259 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7260 &model->vertex[model->Triangles[j].vertex[2]],
7263 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7267 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)){
7268 p1->y=point.y+radius;
7269 if((targetanimation==jumpdownanim||isFlip())){
7270 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7272 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7278 OPENAL_SetPaused(channels[whooshsound], true);
7279 OPENAL_SetVolume(channels[whooshsound], 0);
7282 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7283 if(isFlip())jumppower=-4;
7284 targetanimation=getLanding();
7293 PlaySoundEx( landsound, samp[landsound], NULL, true);
7294 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7295 OPENAL_SetVolume(channels[landsound], 128);
7296 OPENAL_SetPaused(channels[landsound], false);
7299 envsound[numenvsounds]=coords;
7300 envsoundvol[numenvsounds]=16;
7301 envsoundlife[numenvsounds]=.4;
7309 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7312 for (j=0;j<model->TriangleNum;j++){
7313 if(model->facenormals[j].y>slopethreshold){
7317 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)));
7318 if(distance<radius*.5){
7319 point=start-model->facenormals[j]*distance;
7320 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;
7321 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,
7322 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 p1->x, p1->y, p1->z, radius/2);
7324 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,
7325 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7326 p1->x, p1->y, p1->z, radius/2);
7327 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,
7328 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7329 p1->x, p1->y, p1->z, radius/2);
7331 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7332 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7334 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7335 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7337 *p1+=model->facenormals[j]*(distance-radius*.5);
7340 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7344 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7346 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7348 return firstintersecting;
7358 currentanimation = 0;
7359 targetanimation = 0;
7360 oldcurrentframe = 0;
7362 oldcurrentanimation = 0;
7363 oldtargetanimation = 0;
7367 parriedrecently = 0;
7371 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7373 currentoffset = 0,targetoffset = 0,offset = 0;
7391 unconscioustime = 0;
7409 rabbitkickenabled = 0;
7418 damagetolerance = 0;
7420 permanentdamage = 0;
7421 superpermanentdamage = 0; lastcollide = 0;
7441 headrotation = 0,headrotation2 = 0;
7442 targetheadrotation = 0,targetheadrotation2 = 0;
7453 normalsupdatedelay = 0;
7458 forwardstogglekeydown = 0;
7463 jumptogglekeydown = 0;
7465 crouchtogglekeydown = 0;
7467 drawtogglekeydown = 0;
7469 throwtogglekeydown = 0;
7475 crouchkeydowntime = 0;
7476 jumpkeydowntime = 0;
7493 whichdirectiondelay = 0;
7494 avoidsomething = 0; avoidwhere = 0;
7502 lefthandmorphness = 0;
7503 righthandmorphness = 0;
7507 targetlefthandmorphness = 0;
7508 targetrighthandmorphness = 0;
7509 targetheadmorphness = 0;
7510 targetchestmorphness = 0;
7511 targettailmorphness = 0;
7512 lefthandmorphstart = 0,lefthandmorphend = 0;
7513 righthandmorphstart = 0,righthandmorphend = 0;
7514 headmorphstart = 0,headmorphend = 0;
7515 chestmorphstart = 0,chestmorphend = 0;
7516 tailmorphstart = 0,tailmorphend = 0;
7518 weaponmissdelay = 0;
7519 highreversaldelay = 0;
7520 lowreversaldelay = 0;
7527 //Skeleton skeleton;
7546 memset(clothes, 0, sizeof(clothes));
7547 memset(clothestintr, 0, sizeof(clothestintr));
7548 memset(clothestintg, 0, sizeof(clothestintg));
7549 memset(clothestintb, 0, sizeof(clothestintb));
7555 onfiredelay = 0; burnt = 0;
7559 updatestuffdelay = 0;
7565 memset(weaponids, 0, sizeof(weaponids));
7569 weaponstuckwhere = 0;
7574 memset(waypoints, 0, sizeof(waypoints));
7575 memset(waypointtype, 0, sizeof(waypointtype));
7578 hastempwaypoint = 0;
7584 finalfinaltarget = 0;
7586 finalpathfindpoint = 0;
7587 targetpathfindpoint = 0;
7588 lastpathfindpoint = 0;
7589 lastpathfindpoint2 = 0;
7590 lastpathfindpoint3 = 0;
7591 lastpathfindpoint4 = 0;
7602 runninghowlong = 0; lastoccluded = 0;
7608 neckspurtparticledelay = 0;
7609 neckspurtamount = 0;
7612 rabbitkickragdoll = 0;
7617 //Animation tempanimation;