2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /**> HEADER FILES <**/
24 #include "openal_wrapper.h"
25 #include "Animation.h"
30 extern float multiplier;
31 extern int channels[100];
32 extern Terrain terrain;
34 extern int environment;
36 extern FRUSTUM frustum;
38 extern float realmultiplier;
40 extern float slomodelay;
41 extern bool cellophane;
42 extern float texdetail;
43 extern float realtexdetail;
44 extern GLubyte bloodText[512*512*3];
45 extern GLubyte wolfbloodText[512*512*3];
46 extern int bloodtoggle;
47 extern Objects objects;
49 extern bool autoslomo;
50 extern float camerashake;
52 extern float terraindetail;
53 extern float viewdistance;
54 extern float blackout;
55 extern int difficulty;
57 extern float fadestart;
59 extern bool winfreeze;
60 extern float flashamount,flashr,flashg,flashb;
61 extern int flashdelay;
62 extern bool showpoints;
63 extern bool immediate;
65 extern bool tilt2weird;
66 extern bool tiltweird;
68 extern bool proportionweird;
69 extern bool vertexweird[6];
70 extern GLubyte texturearray[512*512*3];
71 extern XYZ envsound[30];
72 extern float envsoundvol[30];
73 extern float envsoundlife[30];
74 extern int numenvsounds;
75 extern int tutoriallevel;
76 extern float smoketex;
77 extern int tutorialstage;
78 extern bool reversaltrain;
79 extern bool canattack;
81 extern float damagedealt;
83 extern float hostiletime;
85 extern int indialogue;
87 extern bool gamestarted;
89 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
90 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
92 void Person::CheckKick(){
96 float damagemult=1*power;
97 if(creature==wolftype)damagemult=2.5*power;
101 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
102 if(findDistancefast(&coords,&victim->coords)<1.2){
103 if(!victim->skeleton.free){
105 Normalise(&relative);
106 relative=coords+relative*1;
107 if(animation[victim->targetanimation].height!=lowheight){
112 gLoc[0]=victim->coords.x;
113 gLoc[1]=victim->coords.y;
114 gLoc[2]=victim->coords.z;
118 if(tutoriallevel!=1){
119 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
120 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
121 OPENAL_SetVolume(channels[heavyimpactsound], 128);
122 OPENAL_SetPaused(channels[heavyimpactsound], false);
127 Normalise(&relative);
128 for(i=0;i<victim->skeleton.num_joints;i++){
129 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
132 victim->DoDamage(100*damagemult/victim->protectionhigh);
133 if(id==0)camerashake+=.4;
137 targetanimation=backflipanim;
142 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
144 award_bonus(id, cannon);
146 else if (victim->isCrouch()){
147 targetanimation=rabbitkickreversedanim;
148 currentanimation=rabbitkickreversedanim;
149 victim->currentanimation=rabbitkickreversalanim;
150 victim->targetanimation=rabbitkickreversalanim;
156 victim->oldcoords=victim->coords;
157 coords=victim->coords;
158 victim->targetrotation=targetrotation;
166 void Person::CatchFire(){
167 XYZ flatfacing,flatvelocity;
169 for(int i=0;i<10;i++){
170 howmany=abs(Random()%(skeleton.num_joints));
171 if(!skeleton.free)flatvelocity=velocity;
172 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
173 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
174 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
175 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
188 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
189 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
190 OPENAL_SetVolume(channels[firestartsound], 256);
191 OPENAL_SetPaused(channels[firestartsound], false);
196 //PlaySoundEx( firesound, samp[firesound], NULL, true);
197 PlayStreamEx( stream_firesound, samp[stream_firesound], NULL, true);
198 OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
199 OPENAL_SetVolume(channels[stream_firesound], 256);
200 OPENAL_SetPaused(channels[stream_firesound], false);
207 bool Person::isIdle(){
208 if(targetanimation==sleepanim||targetanimation==sitanim||targetanimation==talkidleanim||targetanimation==hurtidleanim||targetanimation==bounceidleanim||targetanimation==talkidleanim||targetanimation==fightidleanim||targetanimation==knifefightidleanim||targetanimation==swordfightidleanim||targetanimation==swordfightidlebothanim||targetanimation==fightsidestep||targetanimation==wolfidle)return 1;
212 bool Person::isSitting(){
213 if(targetanimation==sitanim)return 1;
214 if(targetanimation==sitwallanim)return 1;
218 bool Person::isSleeping(){
219 if(targetanimation==sleepanim)return 1;
220 if(targetanimation==dead1anim)return 1;
221 if(targetanimation==dead2anim)return 1;
222 if(targetanimation==dead3anim)return 1;
223 if(targetanimation==dead4anim)return 1;
227 bool Person::wasIdle(){
228 if(currentanimation==sleepanim||currentanimation==talkidleanim||currentanimation==sitanim||currentanimation==hurtidleanim||currentanimation==bounceidleanim||currentanimation==fightidleanim||currentanimation==swordfightidleanim||currentanimation==swordfightidlebothanim||currentanimation==knifefightidleanim||currentanimation==fightsidestep||currentanimation==wolfidle)return 1;
231 int Person::getIdle(){
232 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
233 if(hasvictim&&victim!=this/*||(id==0&&attackkeydown)*/)if(/*(id==0&&attackkeydown)||*/(!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers)){
234 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
235 if(creature==rabbittype)return fightidleanim;
236 if(creature==wolftype)return wolfidle;
238 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
239 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
240 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
241 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
242 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
244 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
246 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
247 if(howactive==typesitting)return sitanim;
248 if(howactive==typesittingwall)return sitwallanim;
249 if(howactive==typesleeping)return sleepanim;
250 if(howactive==typedead1)return dead1anim;
251 if(howactive==typedead2)return dead2anim;
252 if(howactive==typedead3)return dead3anim;
253 if(howactive==typedead4)return dead4anim;
254 if(creature==rabbittype)return bounceidleanim;
255 if(creature==wolftype)return wolfidle;
259 bool Person::isCrouch(){
260 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
265 bool Person::wasCrouch(){
266 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
269 int Person::getCrouch(){
270 if(creature==rabbittype)return crouchanim;
271 if(creature==wolftype)return wolfcrouchanim;
275 bool Person::isRun(){
276 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
281 bool Person::wasRun(){
282 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
285 int Person::getRun(){
286 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
287 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
289 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
290 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
294 bool Person::isStop(){
295 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
300 bool Person::wasStop(){
301 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
304 int Person::getStop(){
305 if(creature==rabbittype)return stopanim;
306 if(creature==wolftype)return wolfstopanim;
311 bool Person::isLanding(){
312 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
317 bool Person::wasLanding(){
318 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
321 int Person::getLanding(){
322 if(creature==rabbittype)return landanim;
323 if(creature==wolftype)return wolflandanim;
328 bool Person::isLandhard(){
329 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
334 bool Person::wasLandhard(){
335 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
338 int Person::getLandhard(){
339 if(creature==rabbittype)return landhardanim;
340 if(creature==wolftype)return wolflandhardanim;
345 bool Person::isFlip(){
346 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
350 bool Person::wasFlip(){
351 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
355 bool Person::isWallJump(){
356 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
361 SolidHitBonus(int playerid)
363 if (bonustime < 1.5 && bonus >= solidhit && bonus <= megacombo)
364 award_bonus(playerid, bonus == megacombo ? bonus : bonus + 1);
366 award_bonus(playerid, solidhit);
369 void Person::DoBlood(float howmuch,int which){
370 static int bleedxint,bleedyint;
372 //if(howmuch&&id==0)blooddimamount=1;
373 if(bloodtoggle&&tutoriallevel!=1){
374 if(bleeding<=0&&spurt){
376 for(int i=0;i<3;i++){
380 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
383 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
385 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
386 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
388 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
389 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
392 Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
393 Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
397 for(int i=0;i<3;i++){
401 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
402 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
405 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
406 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
410 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
412 Sprite::MakeSprite(splintersprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
414 Sprite::setLastSpriteSpecial(3);
419 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
422 int texdetailint=realtexdetail;
423 if(creature==rabbittype)
424 while(bloodText[bleedxint*512*3+bleedyint*3+0]>which+4||bloodText[bleedxint*512*3+bleedyint*3+0]<which-4||bleedxint<10||bleedyint<10||bleedxint>500||bleedyint>500){
425 bleedxint=abs(Random()%512);
426 bleedyint=abs(Random()%512);
428 if(creature==wolftype)
429 while(wolfbloodText[bleedxint*512*3+bleedyint*3+0]>which+4||wolfbloodText[bleedxint*512*3+bleedyint*3+0]<which-4||bleedxint<10||bleedyint<10||bleedxint>500||bleedyint>500){
430 bleedxint=abs(Random()%512);
431 bleedyint=abs(Random()%512);
435 bleedy/=realtexdetail;
436 bleedx/=realtexdetail;
437 direction=abs(Random()%2)*2-1;
441 if(bleeding>2)bleeding=2;
444 void Person::DoBloodBig(float howmuch,int which){
445 static int bleedxint,bleedyint,i,j;
447 if(howmuch&&id==0)blooddimamount=1;
449 if(tutoriallevel!=1||id==0)
450 if(aitype!=playercontrolled&&howmuch>0){
461 if(creature==wolftype){
462 int i=abs(Random()%2);
463 if(i==0)whichsound=snarlsound;
464 if(i==1)whichsound=snarl2sound;
465 envsound[numenvsounds]=coords;
466 envsoundvol[numenvsounds]=16;
467 envsoundlife[numenvsounds]=.4;
470 if(creature==rabbittype){
471 int i=abs(Random()%2);
472 if(i==0)whichsound=rabbitpainsound;
473 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
474 envsound[numenvsounds]=coords;
475 envsoundvol[numenvsounds]=16;
476 envsoundlife[numenvsounds]=.4;
478 //if(i==2)whichsound=rabbitpain2sound;
482 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
483 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
484 OPENAL_SetVolume(channels[whichsound], 512);
485 OPENAL_SetPaused(channels[whichsound], false);
489 if(id==0&&howmuch>0){
497 if(bloodtoggle&&decals&&tutoriallevel!=1){
498 if(bleeding<=0&&spurt){
500 for(int i=0;i<3;i++){
504 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
507 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
509 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
510 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
512 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
513 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
516 Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
517 Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
521 int offsetx=0,offsety=0;
524 offsetx=abs(Random()%60);
526 if(which==190||which==185){
528 offsetx=abs(Random()%100)-20;
538 if(which==220||which==215){
539 //offsety=Random()%20;
541 //offsetx=abs(Random()%80);
550 if(creature==rabbittype)
553 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
554 if(i<startx)startx=i;
555 if(j<starty)starty=j;
561 if(creature==wolftype)
564 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
565 if(i<startx)startx=i;
566 if(j<starty)starty=j;
578 if(startx<0)startx=0;
579 if(starty<0)starty=0;
580 if(endx>512-1)endx=512-1;
581 if(endy>512-1)endy=512-1;
582 if(endx<startx)endx=startx;
583 if(endy<starty)endy=starty;
585 startx/=realtexdetail;
586 starty/=realtexdetail;
590 int texdetailint=realtexdetail;
592 if(creature==rabbittype)
593 for(i=startx;i<endx;i++){
594 for(j=starty;j<endy;j++){
595 if(bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=which+4&&bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=which-4){
596 color=Random()%85+170;
597 where=i*skeleton.skinsize*3+j*3;
598 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
599 skeleton.skinText[where+1]=0;
600 skeleton.skinText[where+2]=0;
604 if(creature==wolftype)
605 for(i=startx;i<endx;i++){
606 for(j=starty;j<endy;j++){
607 if(wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=which+4&&wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=which-4){
608 color=Random()%85+170;
609 where=i*skeleton.skinsize*3+j*3;
610 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
611 skeleton.skinText[where+1]=0;
612 skeleton.skinText[where+2]=0;
616 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
617 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
618 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
622 if(creature==rabbittype)
623 while(bloodText[bleedxint*512*3+bleedyint*3+0]>which+4||bloodText[bleedxint*512*3+bleedyint*3+0]<which-4||bleedxint<10||bleedyint<10||bleedxint>500||bleedyint>500){
624 bleedxint=abs(Random()%512);
625 bleedyint=abs(Random()%512);
627 if(creature==wolftype)
628 while(wolfbloodText[bleedxint*512*3+bleedyint*3+0]>which+4||wolfbloodText[bleedxint*512*3+bleedyint*3+0]<which-4||bleedxint<10||bleedyint<10||bleedxint>500||bleedyint>500){
629 bleedxint=abs(Random()%512);
630 bleedyint=abs(Random()%512);
632 bleedy=bleedxint+offsetx;
633 bleedx=bleedyint+offsety;
634 bleedy/=realtexdetail;
635 bleedx/=realtexdetail;
636 if(bleedx<0)bleedx=0;
637 if(bleedy<0)bleedy=0;
638 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
639 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
640 direction=abs(Random()%2)*2-1;
643 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
644 deathbleeding+=bleeding;
645 bloodloss+=bleeding*3;
647 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
648 if(abs(Random()%2)==0){aitype=gethelptype;
651 else aitype=attacktypecutoff;
654 if(bleeding>2)bleeding=2;
657 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
658 static int bleedxint,bleedyint,i,j;
660 static XYZ startpoint,endpoint,colpoint,movepoint;
661 static float rotationpoint;
663 static XYZ p1,p2,p3,p0;
667 float coordsx,coordsy;
670 if(bloodtoggle&&decals&&tutoriallevel!=1){
672 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
680 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
683 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
684 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
685 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
687 CrossProduct(p2-p1,p3-p1,&N);
688 CrossProduct(p0-p1,p3-p1,&temp);
689 s = dotproduct(&temp,&N)/findLength(&N);
690 CrossProduct(p2-p1,p1-p0,&temp);
691 t = dotproduct(&temp,&N)/findLength(&N);
694 bary.x=findDistancefast(&p0,&p1);
695 bary.y=findDistancefast(&p0,&p2);
696 bary.z=findDistancefast(&p0,&p3);
698 total=bary.x+bary.y+bary.z;
707 total=bary.x+bary.y+bary.z;
713 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
714 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
715 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
716 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
717 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
718 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
719 coordsx=skeleton.drawmodel.Triangles[whichtri].gx[0]*bary.x+skeleton.drawmodel.Triangles[whichtri].gx[1]*bary.y+skeleton.drawmodel.Triangles[whichtri].gx[2]*bary.z;
720 coordsy=skeleton.drawmodel.Triangles[whichtri].gy[0]*bary.x+skeleton.drawmodel.Triangles[whichtri].gy[1]*bary.y+skeleton.drawmodel.Triangles[whichtri].gy[2]*bary.z;
722 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
723 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
725 if(bleeding<=0&&spurt){
727 for(int i=0;i<3;i++){
731 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
734 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
736 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
737 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
739 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
740 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
743 Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
744 Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .3, 1);
748 int offsetx=0,offsety=0;
751 offsetx=abs(Random()%120);
753 if(which==220||which==215){
755 offsetx=abs(Random()%80);
758 offsetx=(1+coordsy)*512-291;
759 offsety=coordsx*512-437;
766 if(creature==rabbittype)
769 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
770 if(i<startx)startx=i;
771 if(j<starty)starty=j;
777 if(creature==wolftype)
780 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
781 if(i<startx)startx=i;
782 if(j<starty)starty=j;
793 if(startx<0)startx=0;
794 if(starty<0)starty=0;
795 if(endx>512-1)endx=512-1;
796 if(endy>512-1)endy=512-1;
797 if(endx<startx)endx=startx;
798 if(endy<starty)endy=starty;
800 startx/=realtexdetail;
801 starty/=realtexdetail;
805 int texdetailint=realtexdetail;
807 if(creature==rabbittype)
808 for(i=startx;i<endx;i++){
809 for(j=starty;j<endy;j++){
810 if(bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=which+4&&bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=which-4){
811 color=Random()%85+170;
812 where=i*skeleton.skinsize*3+j*3;
813 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
814 skeleton.skinText[where+1]=0;
815 skeleton.skinText[where+2]=0;
817 else if(bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=160+4&&bloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=160-4){
818 color=Random()%85+170;
819 where=i*skeleton.skinsize*3+j*3;
820 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
821 skeleton.skinText[where+1]=0;
822 skeleton.skinText[where+2]=0;
826 if(creature==wolftype)
827 for(i=startx;i<endx;i++){
828 for(j=starty;j<endy;j++){
829 if(wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=which+4&&wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=which-4){
830 color=Random()%85+170;
831 where=i*skeleton.skinsize*3+j*3;
832 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
833 skeleton.skinText[where+1]=0;
834 skeleton.skinText[where+2]=0;
836 else if(wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]<=160+4&&wolfbloodText[(i*texdetailint-offsetx)*512*3+(j*texdetailint-offsety)*3+0]>=160-4){
837 color=Random()%85+170;
838 where=i*skeleton.skinsize*3+j*3;
839 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
840 skeleton.skinText[where+1]=0;
841 skeleton.skinText[where+2]=0;
845 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
846 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
847 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
849 bleedy=(1+coordsy)*512;
851 bleedy/=realtexdetail;
852 bleedx/=realtexdetail;
853 if(bleedx<0)bleedx=0;
854 if(bleedy<0)bleedy=0;
855 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
856 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
857 direction=abs(Random()%2)*2-1;
859 if(whichtri==-1)return 0;
861 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
862 deathbleeding+=bleeding;
863 bloodloss+=bleeding*3;
865 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
866 if(abs(Random()%2)==0){aitype=gethelptype;
869 else aitype=attacktypecutoff;
872 if(bleeding>2)bleeding=2;
877 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
880 static int bytesPerPixel=3;
881 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
882 static int newstartx,newstarty,newendx,newendy;
883 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
885 static float sizemult;
887 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
888 texture[i]=skeleton.skinText[i];
891 if((!osx||howmanylevels)){
893 if(startx<0)startx=0;
894 if(starty<0)starty=0;
895 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
896 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
897 if((endx>startx&&endy>starty)||howmanylevels){
904 for(i=startx;i<endx;i++){
905 for(j=starty;j<endy;j++){
906 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
907 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
908 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
912 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
915 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
916 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
917 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
920 newsize=skeleton.skinsize;
923 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
925 /*for(j=1;j<=howmanylevels;j++){
926 if(j==1)texpointer=&skeleton.skinText[0];
927 else texpointer=&texture[0];
929 totalsize=int( newsize*newsize*bytesPerPixel);
930 rowsize=int( newsize*bytesPerPixel );
931 bigstep=bytesPerPixel*newsize*2;
932 smallstep=bytesPerPixel*2;
938 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
945 void Person::Reverse(){
946 if(victim->aitype==playercontrolled||hostiletime>1)
947 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
948 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
949 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
950 if(targetanimation==sweepanim){
951 targetanimation=sweepreversedanim;
952 currentanimation=sweepreversedanim;
953 victim->currentanimation=sweepreversalanim;
954 victim->targetanimation=sweepreversalanim;
956 if(targetanimation==spinkickanim){
957 targetanimation=spinkickreversedanim;
958 currentanimation=spinkickreversedanim;
959 victim->currentanimation=spinkickreversalanim;
960 victim->targetanimation=spinkickreversalanim;
962 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
963 if(targetanimation==rabbittacklinganim){
966 victim->currentframe=6;
967 victim->targetframe=7;
969 targetanimation=upunchreversedanim;
970 currentanimation=upunchreversedanim;
971 victim->currentanimation=upunchreversalanim;
972 victim->targetanimation=upunchreversalanim;
974 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
975 if(victim->weaponactive!=-1){
976 victim->throwtogglekeydown=1;
977 weapons.owner[victim->weaponids[0]]=-1;
978 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
979 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
980 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
981 weapons.missed[victim->weaponids[0]]=1;
982 weapons.freetime[victim->weaponids[0]]=0;
983 weapons.firstfree[victim->weaponids[0]]=1;
984 weapons.physics[victim->weaponids[0]]=1;
985 victim->num_weapons--;
986 if(victim->num_weapons){
987 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
988 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
991 victim->weaponactive=-1;
992 for(int j=0;j<numplayers;j++){
993 player[j].wentforweapon=0;
997 targetanimation=staffhitreversedanim;
998 currentanimation=staffhitreversedanim;
999 victim->currentanimation=staffhitreversalanim;
1000 victim->targetanimation=staffhitreversalanim;
1002 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1003 if(victim->weaponactive!=-1){
1004 victim->throwtogglekeydown=1;
1005 weapons.owner[victim->weaponids[0]]=-1;
1006 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1007 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1008 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1009 weapons.missed[victim->weaponids[0]]=1;
1010 weapons.freetime[victim->weaponids[0]]=0;
1011 weapons.firstfree[victim->weaponids[0]]=1;
1012 weapons.physics[victim->weaponids[0]]=1;
1013 victim->num_weapons--;
1014 if(victim->num_weapons){
1015 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1016 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1019 victim->weaponactive=-1;
1020 for(int j=0;j<numplayers;j++){
1021 player[j].wentforweapon=0;
1024 targetanimation=staffspinhitreversedanim;
1025 currentanimation=staffspinhitreversedanim;
1026 victim->currentanimation=staffspinhitreversalanim;
1027 victim->targetanimation=staffspinhitreversalanim;
1029 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1030 if(victim->weaponactive!=-1){
1031 victim->throwtogglekeydown=1;
1032 weapons.owner[victim->weaponids[0]]=-1;
1033 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1034 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1035 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1036 weapons.missed[victim->weaponids[0]]=1;
1037 weapons.freetime[victim->weaponids[0]]=0;
1038 weapons.firstfree[victim->weaponids[0]]=1;
1039 weapons.physics[victim->weaponids[0]]=1;
1040 victim->num_weapons--;
1041 if(victim->num_weapons){
1042 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1043 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1046 victim->weaponactive=-1;
1047 for(int j=0;j<numplayers;j++){
1048 player[j].wentforweapon=0;
1051 targetanimation=swordslashreversedanim;
1052 currentanimation=swordslashreversedanim;
1053 victim->currentanimation=swordslashreversalanim;
1054 victim->targetanimation=swordslashreversalanim;
1056 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1057 if(victim->weaponactive!=-1){
1058 victim->throwtogglekeydown=1;
1059 weapons.owner[victim->weaponids[0]]=-1;
1060 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1061 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1062 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1063 weapons.missed[victim->weaponids[0]]=1;
1064 weapons.freetime[victim->weaponids[0]]=0;
1065 weapons.firstfree[victim->weaponids[0]]=1;
1066 weapons.physics[victim->weaponids[0]]=1;
1067 victim->num_weapons--;
1068 if(victim->num_weapons){
1069 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1070 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1073 victim->weaponactive=-1;
1074 for(int j=0;j<numplayers;j++){
1075 player[j].wentforweapon=0;
1078 targetanimation=knifeslashreversedanim;
1079 currentanimation=knifeslashreversedanim;
1080 victim->currentanimation=knifeslashreversalanim;
1081 victim->targetanimation=knifeslashreversalanim;
1083 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1084 victim->targettilt2=targettilt2;
1085 victim->currentframe=currentframe;
1086 victim->targetframe=targetframe;
1087 victim->target=target;
1089 victim->oldcoords=victim->coords;
1090 victim->coords=coords;
1091 victim->targetrotation=targetrotation;
1092 victim->rotation=targetrotation;
1093 victim->victim=this;
1095 if(targetanimation==winduppunchanim){
1096 targetanimation=winduppunchblockedanim;
1097 victim->targetanimation=blockhighleftanim;
1098 victim->targetframe=1;
1100 victim->victim=this;
1101 victim->targetrotation=targetrotation+180;
1103 if(targetanimation==wolfslapanim){
1104 targetanimation=winduppunchblockedanim;
1105 victim->targetanimation=blockhighleftanim;
1106 victim->targetframe=1;
1108 victim->victim=this;
1109 victim->targetrotation=targetrotation+180;
1111 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1112 targetanimation=swordslashparriedanim;
1114 victim->parriedrecently=0;
1115 victim->targetanimation=swordslashparryanim;
1116 victim->targetframe=1;
1118 victim->victim=this;
1119 victim->targetrotation=targetrotation+180;
1121 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1124 gLoc[0]=victim->coords.x;
1125 gLoc[1]=victim->coords.y;
1126 gLoc[2]=victim->coords.z;
1130 if(victim->weaponactive!=-1){
1131 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1132 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1133 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1135 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1136 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1137 OPENAL_SetVolume(channels[swordstaffsound], 512);
1138 OPENAL_SetPaused(channels[swordstaffsound], false);
1141 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1142 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1143 OPENAL_SetVolume(channels[metalhitsound], 512);
1144 OPENAL_SetPaused(channels[metalhitsound], false);
1148 victim->Puff(righthand);
1150 victim->targetframe=0;
1151 victim->targetanimation=staggerbackhighanim;
1152 victim->targetrotation=targetrotation+180;
1154 weapons.owner[victim->weaponids[0]]=-1;
1155 aim=DoRotation(facing,0,90,0)*21;
1157 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1158 weapons.tipvelocity[victim->weaponids[0]]=aim;
1159 weapons.missed[victim->weaponids[0]]=1;
1160 weapons.hitsomething[victim->weaponids[0]]=0;
1161 weapons.freetime[victim->weaponids[0]]=0;
1162 weapons.firstfree[victim->weaponids[0]]=1;
1163 weapons.physics[victim->weaponids[0]]=1;
1164 victim->num_weapons--;
1165 if(victim->num_weapons){
1166 victim->weaponids[0]=victim->weaponids[num_weapons];
1167 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1169 victim->weaponactive=-1;
1170 for(int i=0;i<numplayers;i++){
1171 player[i].wentforweapon=0;
1178 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1179 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1180 OPENAL_SetVolume(channels[metalhitsound], 512);
1181 OPENAL_SetPaused(channels[metalhitsound], false);*/
1184 if(abs(Random()%20)==0){
1193 if(weaponactive!=-1){
1194 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1195 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1196 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1198 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1199 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1200 OPENAL_SetVolume(channels[swordstaffsound], 512);
1201 OPENAL_SetPaused(channels[swordstaffsound], false);
1204 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1205 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1206 OPENAL_SetVolume(channels[metalhitsound], 512);
1207 OPENAL_SetPaused(channels[metalhitsound], false);
1215 targetanimation=staggerbackhighanim;
1216 targetrotation=targetrotation+180;
1218 weapons.owner[weaponids[0]]=-1;
1219 aim=DoRotation(facing,0,90,0)*21;
1221 weapons.velocity[weaponids[0]]=aim*-.2;
1222 weapons.tipvelocity[weaponids[0]]=aim;
1223 weapons.hitsomething[weaponids[0]]=0;
1224 weapons.missed[weaponids[0]]=1;
1225 weapons.freetime[weaponids[0]]=0;
1226 weapons.firstfree[weaponids[0]]=1;
1227 weapons.physics[weaponids[0]]=1;
1230 weaponids[0]=weaponids[num_weapons];
1231 if(weaponstuck==num_weapons)weaponstuck=0;
1234 for(int i=0;i<numplayers;i++){
1235 player[i].wentforweapon=0;
1239 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1240 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1241 OPENAL_SetVolume(channels[metalhitsound], 512);
1242 OPENAL_SetPaused(channels[metalhitsound], false);*/
1246 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1247 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1248 //victim->targetanimation=sweepanim;
1249 victim->targetanimation=dodgebackanim;
1250 victim->targetframe=0;
1252 //victim->velocity=0;
1255 rotatetarget=coords-victim->coords;
1256 Normalise(&rotatetarget);
1257 victim->targetrotation=-asin(0-rotatetarget.x);
1258 victim->targetrotation*=360/6.28;
1259 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1261 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1263 victim->lastattack3=victim->lastattack2;
1264 victim->lastattack2=victim->lastattack;
1265 victim->lastattack=victim->targetanimation;
1269 victim->targetanimation=sweepanim;
1270 victim->targetframe=0;
1274 rotatetarget=coords-victim->coords;
1275 Normalise(&rotatetarget);
1276 victim->targetrotation=-asin(0-rotatetarget.x);
1277 victim->targetrotation*=360/6.28;
1278 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1280 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1282 victim->lastattack3=victim->lastattack2;
1283 victim->lastattack2=victim->lastattack;
1284 victim->lastattack=victim->targetanimation;
1291 if(aitype!=playercontrolled)feint=0;
1292 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1293 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1294 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1296 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1300 void Person::DoDamage(float howmuch){
1301 if(tutoriallevel!=1)damage+=howmuch/power;
1302 if(id!=0)damagedealt+=howmuch/power;
1303 if(id==0)damagetaken+=howmuch/power;
1305 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1306 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1307 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1308 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1309 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1311 if(id==0)camerashake+=howmuch/100;
1312 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1313 if(blackout>1)blackout=1;
1315 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1316 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1317 if(abs(Random()%2)==0){aitype=gethelptype;
1320 else aitype=attacktypecutoff;
1324 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1327 for(int i=0;i<skeleton.num_joints; i++){
1328 if(!skeleton.free)flatvelocity2=velocity;
1329 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1330 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1331 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1332 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1333 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1334 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1335 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1336 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1337 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1348 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1349 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1350 OPENAL_SetVolume(channels[splattersound], 256);
1351 OPENAL_SetPaused(channels[splattersound], false);
1360 if(!dead&&creature==wolftype){
1361 award_bonus(0, Wolfbonus);
1367 if(tutoriallevel!=1||id==0)
1368 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1379 if(creature==wolftype){
1380 int i=abs(Random()%2);
1381 if(i==0)whichsound=snarlsound;
1382 if(i==1)whichsound=snarl2sound;
1383 envsound[numenvsounds]=coords;
1384 envsoundvol[numenvsounds]=16;
1385 envsoundlife[numenvsounds]=.4;
1388 if(creature==rabbittype){
1389 int i=abs(Random()%2);
1390 if(i==0)whichsound=rabbitpainsound;
1391 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1392 envsound[numenvsounds]=coords;
1393 envsoundvol[numenvsounds]=16;
1394 envsoundlife[numenvsounds]=.4;
1396 //if(i==2)whichsound=rabbitpain2sound;
1400 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1401 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1402 OPENAL_SetVolume(channels[whichsound], 512);
1403 OPENAL_SetPaused(channels[whichsound], false);
1408 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1409 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1412 void Person::DoHead(){
1413 static XYZ rotatearound;
1415 static float lookspeed=500;
1417 if(!freeze&&!winfreeze){
1420 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1421 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1423 while(targetheadrotation>180)targetheadrotation-=360;
1424 while(targetheadrotation<-180)targetheadrotation+=360;
1426 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1427 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1428 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1429 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1431 if(targetheadrotation2>120)targetheadrotation2=120;
1432 if(targetheadrotation2<-120)targetheadrotation2=-120;
1433 if(targetheadrotation>120)targetheadrotation=120;
1434 if(targetheadrotation<-120)targetheadrotation=-120;
1436 if(!isIdle())targetheadrotation2=0;
1438 if(targetheadrotation>80)targetheadrotation=80;
1439 if(targetheadrotation<-80)targetheadrotation=-80;
1440 if(targetheadrotation2>50)targetheadrotation2=50;
1441 if(targetheadrotation2<-50)targetheadrotation2=-50;
1444 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1445 else if(headrotation>targetheadrotation){
1446 headrotation-=multiplier*lookspeed;
1448 else if(headrotation<targetheadrotation){
1449 headrotation+=multiplier*lookspeed;
1452 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1453 else if(headrotation2>targetheadrotation2){
1454 headrotation2-=multiplier*lookspeed/2;
1456 else if(headrotation2<targetheadrotation2){
1457 headrotation2+=multiplier*lookspeed/2;
1460 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1461 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1465 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1466 facing=DoRotation(facing,headrotation2*.4,0,0);
1467 facing=DoRotation(facing,0,headrotation*.4,0);
1470 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1471 facing=DoRotation(facing,headrotation2*.8,0,0);
1472 facing=DoRotation(facing,0,headrotation*.8,0);
1475 if(targetanimation==walkanim){
1476 facing=DoRotation(facing,headrotation2*.6,0,0);
1477 facing=DoRotation(facing,0,headrotation*.6,0);
1480 skeleton.specialforward[0]=facing;
1481 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1483 for(i=0;i<skeleton.num_muscles;i++){
1484 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1486 skeleton.FindRotationMuscle(i,targetanimation);
1492 void Person::RagDoll(bool checkcollision){
1497 if(id==0)numfalls++;
1498 if(id==0&&isFlip())numflipfail++;
1504 facing=DoRotation(facing,0,rotation,0);
1506 skeleton.freetime=0;
1508 skeleton.longdead=0;
1514 skeleton.freefall=1;
1516 if(!isnormal(velocity.x))velocity.x=0;
1517 if(!isnormal(velocity.y))velocity.y=0;
1518 if(!isnormal(velocity.z))velocity.z=0;
1519 if(!isnormal(rotation))rotation=0;
1520 if(!isnormal(coords.x))coords=0;
1521 if(!isnormal(tilt))tilt=0;
1522 if(!isnormal(tilt2))tilt2=0;
1524 for(i=0;i<skeleton.num_joints;i++){
1525 skeleton.joints[i].delay=0;
1526 skeleton.joints[i].locked=0;
1527 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1528 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1529 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1530 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1531 skeleton.joints[i].position.y+=.1;
1532 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1533 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1536 for(i=0;i<skeleton.num_joints;i++){
1537 skeleton.joints[i].velocity=0;
1538 skeleton.joints[i].velchange=0;
1540 skeleton.DoConstraints(&coords,&scale);
1541 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1543 skeleton.DoConstraints(&coords,&scale);
1544 skeleton.DoConstraints(&coords,&scale);
1545 skeleton.DoConstraints(&coords,&scale);
1546 skeleton.DoConstraints(&coords,&scale);
1549 speed=animation[targetanimation].speed[targetframe]*2;
1550 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1551 speed=animation[currentanimation].speed[currentframe]*2;
1553 if(transspeed)speed=transspeed*2;
1557 for(i=0;i<skeleton.num_joints;i++){
1558 if((animation[currentanimation].attack!=reversed||currentanimation==swordslashreversedanim)&¤tanimation!=rabbitkickanim&&!isLanding()&&!wasLanding()&&animation[currentanimation].height==animation[targetanimation].height)skeleton.joints[i].velocity=velocity/scale+facing*5+DoRotation(DoRotation(DoRotation((animation[targetanimation].position[i][targetframe]-animation[currentanimation].position[i][currentframe])*speed,0,0,tilt),tilt2,0,0),0,rotation,0);
1559 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1560 change.x=(float)(Random()%100)/100;
1561 change.y=(float)(Random()%100)/100;
1562 change.z=(float)(Random()%100)/100;
1563 skeleton.joints[i].velocity+=change;
1564 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1566 change.x=(float)(Random()%100)/100;
1567 change.y=(float)(Random()%100)/100;
1568 change.z=(float)(Random()%100)/100;
1569 skeleton.joints[i].velchange+=change;
1570 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1580 for(j=0;j<skeleton.num_joints;j++){
1581 average+=skeleton.joints[j].position;
1585 coords+=average*scale;
1586 for(j=0;j<skeleton.num_joints;j++){
1587 skeleton.joints[j].position-=average;
1590 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1591 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1592 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1593 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1594 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1597 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1598 coords.x=lowpoint.x;
1599 coords.z=lowpoint.z;
1608 for(i=0;i<skeleton.num_joints;i++){
1609 velocity+=skeleton.joints[i].velocity*scale;
1611 velocity/=skeleton.num_joints;
1614 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1615 weapons.owner[weaponids[0]]=-1;
1616 weapons.hitsomething[weaponids[0]]=0;
1617 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1618 weapons.velocity[weaponids[0]].x+=.01;
1619 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1620 weapons.missed[weaponids[0]]=1;
1621 weapons.freetime[weaponids[0]]=0;
1622 weapons.firstfree[weaponids[0]]=1;
1623 weapons.physics[weaponids[0]]=1;
1626 weaponids[0]=weaponids[num_weapons];
1627 if(weaponstuck==num_weapons)weaponstuck=0;
1630 for(i=0;i<numplayers;i++){
1631 player[i].wentforweapon=0;
1636 targetanimation=bounceidleanim;
1637 currentanimation=bounceidleanim;
1645 void Person::FootLand(int which, float opacity){
1646 static XYZ terrainlight;
1647 static XYZ footvel,footpoint;
1648 if(opacity>=1||skiddelay<=0)
1652 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1653 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1654 //footpoint.y=coords.y;
1655 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1657 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1659 if(footvel.y<.8)footvel.y=.8;
1660 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1661 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1662 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1663 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1664 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1665 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1667 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1669 if(footvel.y<.8)footvel.y=.8;
1670 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1671 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1672 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1673 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1674 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*90/255,terrainlight.y*70/255,terrainlight.z*8/255, .5, .5*opacity);
1676 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1678 if(footvel.y<.8)footvel.y=.8;
1679 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1680 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1681 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1682 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1683 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x*190/255,terrainlight.y*170/255,terrainlight.z*108/255, .5, .7*opacity);
1684 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1686 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1689 if(footvel.y<.8)footvel.y=.8;
1690 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1691 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1692 //footpoint.y=coords.y;
1693 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1697 void Person::Puff(int whichlabel){
1698 static XYZ footvel,footpoint;
1701 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1702 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1706 void Person::DoAnimations(){
1709 static float oldtarget;
1711 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1713 if(targetanimation==tempanim||currentanimation==tempanim){
1714 animation[tempanim]=tempanimation;
1716 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1727 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1728 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1730 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1731 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1733 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1738 targfacing=DoRotation(targfacing,0,targetrotation,0);
1740 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1741 else targetanimation=backflipanim;
1742 crouchtogglekeydown=1;
1746 if(id==0)numflipped++;
1749 if(animation[targetanimation].attack!=reversed)feint=0;
1750 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1751 crouchtogglekeydown=0;
1752 if(aitype==playercontrolled)feint=0;
1756 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1757 if(!isFlip())crouchtogglekeydown=1;
1761 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1762 if(detail)normalsupdatedelay=0;
1766 if(targetanimation==rollanim&&targetframe==3&&onfire){
1776 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1777 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1778 OPENAL_SetVolume(channels[fireendsound], 256);
1779 OPENAL_SetPaused(channels[fireendsound], false);
1780 OPENAL_SetPaused(channels[stream_firesound], true);
1784 if(targetanimation==rabbittacklinganim&&targetframe==1){
1785 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1786 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1787 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1788 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1789 else victim->targetanimation=rabbittackledfrontanim;
1790 victim->targetframe=2;
1792 victim->rotation=rotation;
1793 victim->targetrotation=rotation;
1794 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1795 //victim->DoDamage(30);
1796 if(creature==wolftype){
1800 gLoc[0]=victim->coords.x;
1801 gLoc[1]=victim->coords.y;
1802 gLoc[2]=victim->coords.z;
1806 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
1807 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
1808 OPENAL_SetVolume(channels[clawslicesound], 128);
1809 OPENAL_SetPaused(channels[clawslicesound], false);
1811 victim->DoBloodBig(1/victim->armorhead,210);
1813 award_bonus(id, TackleBonus,
1814 victim->aitype == gethelptype ? 50 : 0);
1818 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1819 if(weapons.type[weaponids[0]]==knife){
1820 if(weaponactive==-1)weaponactive=0;
1821 else if(weaponactive==0)weaponactive=-1;
1823 if(weaponactive==-1){
1833 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
1834 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
1835 OPENAL_SetVolume(channels[knifesheathesound], 128);
1836 OPENAL_SetPaused(channels[knifesheathesound], false);
1838 if(weaponactive!=-1){
1848 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1849 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1850 OPENAL_SetVolume(channels[knifedrawsound], 128);
1851 OPENAL_SetPaused(channels[knifedrawsound], false);
1854 drawtogglekeydown=1;
1857 if(tutoriallevel!=1||id==0)
1858 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1869 if(terrain.getOpacity(coords.x,coords.z)<.2){
1870 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1871 else whichsound=footstepsound2;
1872 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1873 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1874 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1880 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1881 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1882 else whichsound=footstepsound4;
1886 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1887 else whichsound=footstepsound4;
1889 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1890 if(animation[targetanimation].attack!=neutral){
1892 if(i==0)whichsound=lowwhooshsound;
1893 if(i==1)whichsound=midwhooshsound;
1894 if(i==2)whichsound=highwhooshsound;
1896 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1898 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1899 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1901 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1902 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1903 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
1904 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
1905 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
1906 OPENAL_SetPaused(channels[whichsound], false);
1909 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1910 envsound[numenvsounds]=coords;
1911 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1912 else envsoundvol[numenvsounds]=6;
1913 envsoundlife[numenvsounds]=.4;
1917 if(animation[targetanimation].label[targetframe]==3){
1919 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1920 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1921 OPENAL_SetVolume(channels[whichsound], 128);
1922 OPENAL_SetPaused(channels[whichsound], false);
1927 if(tutoriallevel!=1||id==0)
1929 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1930 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1940 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1941 if(animation[targetanimation].attack!=neutral){
1943 if(creature==rabbittype){
1944 if(i==0)whichsound=rabbitattacksound;
1945 if(i==1)whichsound=rabbitattack2sound;
1946 if(i==2)whichsound=rabbitattack3sound;
1947 if(i==3)whichsound=rabbitattack4sound;
1949 if(creature==wolftype){
1950 if(i==0)whichsound=barksound;
1951 if(i==1)whichsound=bark2sound;
1952 if(i==2)whichsound=bark3sound;
1953 if(i==3)whichsound=barkgrowlsound;
1957 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1959 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1960 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
1963 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1964 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1965 OPENAL_SetVolume(channels[whichsound], 512);
1966 OPENAL_SetPaused(channels[whichsound], false);
1972 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
1978 currentoffset=targetoffset;
1979 targetframe=currentframe;
1980 currentanimation=targetanimation;
1983 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
1984 for(i=0;i<weapons.numweapons;i++){
1985 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
1986 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
1987 if(findDistancefast(&coords,&weapons.position[i])>=1){
1988 if(weapons.type[i]!=staff){
1997 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1998 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1999 OPENAL_SetVolume(channels[knifedrawsound], 128);
2000 OPENAL_SetPaused(channels[knifedrawsound], false);
2004 weapons.owner[i]=id;
2006 weaponids[num_weapons]=weaponids[0];
2015 static bool willwork;
2016 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2017 for(i=0;i<weapons.numweapons;i++){
2019 if(weapons.owner[i]!=-1)
2020 if(player[weapons.owner[i]].weaponstuck!=-1)
2021 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2022 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2023 if((/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)||(hasvictim&&weapons.owner[i]==victim->id&&victim->skeleton.free))
2024 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2025 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2035 if(weapons.owner[i]!=-1)
2036 if(victim->weaponstuck!=-1){
2037 if(victim->weaponids[victim->weaponstuck]==i){
2042 if(weapons.type[i]!=staff){
2043 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2044 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2045 OPENAL_SetVolume(channels[knifedrawsound], 128);
2046 OPENAL_SetPaused(channels[knifedrawsound], false);
2050 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2051 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2052 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2053 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2056 if(weapons.owner[i]!=-1){
2058 victim=&player[weapons.owner[i]];
2059 if(victim->num_weapons==1)victim->num_weapons=0;
2060 else victim->num_weapons=1;
2062 //victim->weaponactive=-1;
2063 victim->skeleton.longdead=0;
2064 victim->skeleton.free=1;
2065 victim->skeleton.broken=0;
2067 for(int j=0;j<victim->skeleton.num_joints;j++){
2068 victim->skeleton.joints[j].velchange=0;
2069 victim->skeleton.joints[j].locked=0;
2075 Normalise(&relative);
2076 XYZ footvel,footpoint;
2078 footpoint=weapons.position[i];
2079 if(victim->weaponstuck!=-1){
2080 if(victim->weaponids[victim->weaponstuck]==i){
2081 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2082 weapons.bloody[i]=2;
2083 weapons.blooddrip[i]=5;
2084 victim->weaponstuck=-1;
2087 if(victim->num_weapons>0){
2088 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2089 if(victim->weaponids[0]==i)
2090 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2093 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2094 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2095 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2096 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2098 weapons.owner[i]=id;
2100 weaponids[num_weapons]=weaponids[0];
2109 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2110 if(weaponactive==-1)weaponactive=0;
2111 else if(weaponactive==0){
2115 buffer=weaponids[0];
2116 weaponids[0]=weaponids[1];
2117 weaponids[1]=buffer;
2120 if(weaponactive==-1){
2130 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2131 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2132 OPENAL_SetVolume(channels[knifesheathesound], 128);
2133 OPENAL_SetPaused(channels[knifesheathesound], false);
2135 if(weaponactive!=-1){
2145 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2146 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2147 OPENAL_SetVolume(channels[knifedrawsound], 128);
2148 OPENAL_SetPaused(channels[knifedrawsound], false);
2153 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2154 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2155 Normalise(&rotatetarget);
2156 targetrotation=-asin(0-rotatetarget.x);
2157 targetrotation*=360/6.28;
2158 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2160 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2161 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2166 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2168 if(findDistancefast(&victim->coords,&/*player[i].*/coords)<5&&victim->aitype==gethelptype&&(attackkeydown)&&!victim->skeleton.free&&victim->isRun()&&victim->runninghowlong>=1)dojumpattack=1; if(!hostile)dojumpattack=0;
2170 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2171 targetanimation=rabbittackleanim;
2182 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2183 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2184 OPENAL_SetVolume(channels[jumpsound], 128);
2185 OPENAL_SetPaused(channels[jumpsound], false);
2194 Normalise(&targetloc);
2196 for(i=0;i<numplayers;i++){
2198 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2199 closestdist=findDistancefast(&targetloc,&player[i].coords);
2204 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2206 victim=&player[closestid];
2207 coords=victim->coords;
2208 currentanimation=rabbittacklinganim;
2209 targetanimation=rabbittacklinganim;
2213 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2214 rotatetarget=coords-victim->coords;
2215 Normalise(&rotatetarget);
2216 targetrotation=-asin(0-rotatetarget.x);
2217 targetrotation*=360/6.28;
2218 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2220 if(targetanimation!=rabbitrunninganim){
2230 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2231 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2232 OPENAL_SetVolume(channels[jumpsound], 128);
2233 OPENAL_SetPaused(channels[jumpsound], false);
2239 float damagemult=1*power;
2240 if(creature==wolftype)damagemult=2.5*power;
2241 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2242 //if(onfire)damagemult=3;
2243 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2244 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2245 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2247 if(id==0)camerashake+=.4;
2248 if(Random()%2||creature==wolftype){
2251 if(creature==wolftype)DoBloodBig(0,250);
2255 gLoc[0]=victim->coords.x;
2256 gLoc[1]=victim->coords.y;
2257 gLoc[2]=victim->coords.z;
2261 if(tutoriallevel!=1){
2262 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2263 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2264 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2265 OPENAL_SetPaused(channels[heavyimpactsound], false);
2267 if(creature==wolftype){
2268 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2269 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2270 OPENAL_SetVolume(channels[clawslicesound], 128);
2271 OPENAL_SetPaused(channels[clawslicesound], false);
2273 victim->DoBloodBig(2/victim->armorhead,175);
2277 relative=victim->coords-coords;
2279 Normalise(&relative);
2280 relative=DoRotation(relative,0,-90,0);
2281 for(i=0;i<victim->skeleton.num_joints;i++){
2282 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2284 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2287 victim->DoDamage(damagemult*100/victim->protectionhead);
2293 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2294 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2296 if(id==0)camerashake+=.4;
2297 if(Random()%2||creature==wolftype){
2299 if(creature==wolftype)DoBloodBig(0,235);
2303 gLoc[0]=victim->coords.x;
2304 gLoc[1]=victim->coords.y;
2305 gLoc[2]=victim->coords.z;
2309 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2310 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2311 OPENAL_SetVolume(channels[whooshhitsound], 512);
2312 OPENAL_SetPaused(channels[whooshhitsound], false);
2313 if(creature==wolftype){
2314 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2315 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2316 OPENAL_SetVolume(channels[clawslicesound], 128);
2317 OPENAL_SetPaused(channels[clawslicesound], false);
2319 victim->DoBloodBig(2,175);
2323 relative=victim->coords-coords;
2325 Normalise(&relative);
2327 Normalise(&relative);
2328 relative=DoRotation(relative,0,90,0);
2329 for(i=0;i<victim->skeleton.num_joints;i++){
2330 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2332 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2335 victim->DoDamage(damagemult*50/victim->protectionhead);
2339 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2340 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2342 if(id==0)camerashake+=.4;
2347 gLoc[0]=victim->coords.x;
2348 gLoc[1]=victim->coords.y;
2349 gLoc[2]=victim->coords.z;
2353 if(tutoriallevel!=1){
2354 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2355 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2356 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2357 OPENAL_SetPaused(channels[heavyimpactsound], false);
2359 if(creature==wolftype){
2360 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2361 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2362 OPENAL_SetVolume(channels[clawslicesound], 128);
2363 OPENAL_SetPaused(channels[clawslicesound], false);
2365 victim->DoBloodBig(2/victim->armorhead,175);
2371 Normalise(&relative);
2372 relative=DoRotation(relative,0,-90,0);
2373 for(i=0;i<victim->skeleton.num_joints;i++){
2374 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2376 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2379 victim->DoDamage(damagemult*150/victim->protectionhead);
2381 if(victim->damage>victim->damagetolerance)
2382 award_bonus(id, style);
2388 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2389 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2391 if(id==0)camerashake+=.4;
2396 gLoc[0]=victim->coords.x;
2397 gLoc[1]=victim->coords.y;
2398 gLoc[2]=victim->coords.z;
2402 if(tutoriallevel!=1){
2403 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2404 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2405 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2406 OPENAL_SetPaused(channels[heavyimpactsound], false);
2408 if(creature==wolftype){
2409 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2410 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2411 OPENAL_SetVolume(channels[clawslicesound], 128);
2412 OPENAL_SetPaused(channels[clawslicesound], false);
2414 victim->DoBloodBig(2/victim->armorhead,175);
2420 Normalise(&relative);
2421 relative=DoRotation(relative,0,90,0);
2422 for(i=0;i<victim->skeleton.num_joints;i++){
2423 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2425 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2428 victim->DoDamage(damagemult*150/victim->protectionhead);
2430 if(victim->damage>victim->damagetolerance)
2431 award_bonus(id, style);
2437 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2438 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2440 if(id==0)camerashake+=.4;
2447 gLoc[0]=victim->coords.x;
2448 gLoc[1]=victim->coords.y;
2449 gLoc[2]=victim->coords.z;
2453 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2454 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2455 OPENAL_SetVolume(channels[whooshhitsound], 512);
2456 OPENAL_SetPaused(channels[whooshhitsound], false);
2459 relative=victim->coords-coords;
2461 Normalise(&relative);
2462 for(i=0;i<victim->skeleton.num_joints;i++){
2463 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2465 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2468 victim->DoDamage(damagemult*50/victim->protectionhead);
2472 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2473 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2475 if(id==0)camerashake+=.2;
2478 gLoc[0]=victim->coords.x;
2479 gLoc[1]=victim->coords.y;
2480 gLoc[2]=victim->coords.z;
2484 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2485 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2486 OPENAL_SetVolume(channels[landsound2], 128);
2487 OPENAL_SetPaused(channels[landsound2], false);
2489 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2490 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2491 OPENAL_SetVolume(channels[movewhooshsound], 128);
2492 OPENAL_SetPaused(channels[movewhooshsound], false);
2494 victim->skeleton.longdead=0;
2495 victim->skeleton.free=1;
2496 victim->skeleton.broken=0;
2497 victim->skeleton.spinny=1;
2499 for(i=0;i<victim->skeleton.num_joints;i++){
2500 victim->skeleton.joints[i].velchange=0;
2501 victim->skeleton.joints[i].delay=0;
2502 victim->skeleton.joints[i].locked=0;
2503 //victim->skeleton.joints[i].velocity=0;
2509 Normalise(&relative);
2510 for(i=0;i<victim->skeleton.num_joints;i++){
2511 victim->skeleton.joints[i].velocity.y=relative.y*10;
2512 victim->skeleton.joints[i].position.y+=relative.y*.3;
2513 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2514 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2516 victim->Puff(abdomen);
2517 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2521 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2522 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2524 if(id==0)camerashake+=.4;
2533 if(tutoriallevel!=1){
2534 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2535 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2536 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2537 OPENAL_SetPaused(channels[heavyimpactsound], false);
2540 relative=victim->coords-coords;
2542 Normalise(&relative);
2543 for(i=0;i<victim->skeleton.num_joints;i++){
2544 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2546 victim->Puff(abdomen);
2547 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2551 victim->DoDamage(damagemult*500/victim->protectionhigh);
2552 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2556 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2557 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2559 if(id==0)camerashake+=.4;
2568 if(tutoriallevel!=1){
2569 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2570 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2571 OPENAL_SetVolume(channels[thudsound], 400);
2572 OPENAL_SetPaused(channels[thudsound], false);
2575 victim->skeleton.longdead=0;
2576 victim->skeleton.free=1;
2577 victim->skeleton.broken=0;
2578 victim->skeleton.spinny=1;
2580 for(i=0;i<victim->skeleton.num_joints;i++){
2581 victim->skeleton.joints[i].velchange=0;
2582 //victim->skeleton.joints[i].delay=0;
2583 victim->skeleton.joints[i].locked=0;
2586 relative=victim->coords-coords;
2587 Normalise(&relative);
2589 Normalise(&relative);
2590 for(i=0;i<victim->skeleton.num_joints;i++){
2591 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2596 victim->Puff(abdomen);
2597 victim->DoDamage(damagemult*20/victim->protectionhigh);
2598 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2600 if(!victim->dead)staggerdelay=1.2;
2606 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2607 //if(id==0)camerashake+=.4;
2618 if(!victim->skeleton.free)hasvictim=0;
2621 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2622 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2623 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2624 OPENAL_SetVolume(channels[knifesheathesound], 128);
2625 OPENAL_SetPaused(channels[knifesheathesound], false);
2628 if(victim&&hasvictim){
2629 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2631 XYZ where,startpoint,endpoint,movepoint,colpoint;
2632 float rotationpoint;
2634 if(weapons.type[weaponids[weaponactive]]==knife){
2635 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2636 where-=victim->coords;
2637 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2644 if(weapons.type[weaponids[weaponactive]]==sword){
2645 where=weapons.position[weaponids[weaponactive]];
2646 where-=victim->coords;
2647 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2649 where=weapons.tippoint[weaponids[weaponactive]];
2650 where-=victim->coords;
2651 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2654 if(weapons.type[weaponids[weaponactive]]==staff){
2655 where=weapons.position[weaponids[weaponactive]];
2656 where-=victim->coords;
2657 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2659 where=weapons.tippoint[weaponids[weaponactive]];
2660 where-=victim->coords;
2661 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2666 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2669 if(victim->dead!=2){
2670 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2672 award_bonus(id, FinishedBonus);
2674 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2676 victim->skeleton.longdead=0;
2677 victim->skeleton.free=1;
2678 victim->skeleton.broken=0;
2680 for(i=0;i<victim->skeleton.num_joints;i++){
2681 victim->skeleton.joints[i].velchange=0;
2682 victim->skeleton.joints[i].locked=0;
2683 //victim->skeleton.joints[i].velocity=0;
2685 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2686 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2687 OPENAL_SetVolume(channels[fleshstabsound], 128);
2688 OPENAL_SetPaused(channels[fleshstabsound], false);
2691 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2692 weapons.blooddrip[weaponids[weaponactive]]+=5;
2693 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2697 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2698 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2699 OPENAL_SetVolume(channels[knifesheathesound], 128);
2700 OPENAL_SetPaused(channels[knifesheathesound], false);
2706 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2707 //if(id==0)camerashake+=.4;
2717 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2718 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2719 OPENAL_SetVolume(channels[knifedrawsound], 128);
2720 OPENAL_SetPaused(channels[knifedrawsound], false);
2723 if(victim&&hasvictim){
2724 XYZ footvel,footpoint;
2726 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2727 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2728 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2729 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2732 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2734 if(weapons.type[weaponids[weaponactive]]==sword){
2735 XYZ where,startpoint,endpoint,movepoint;
2736 float rotationpoint;
2739 where=weapons.position[weaponids[weaponactive]];
2740 where-=victim->coords;
2741 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2743 where=weapons.tippoint[weaponids[weaponactive]];
2744 where-=victim->coords;
2745 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2750 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2751 footpoint+=victim->coords;
2754 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2757 if(weapons.type[weaponids[weaponactive]]==staff){
2758 XYZ where,startpoint,endpoint,movepoint;
2759 float rotationpoint;
2762 where=weapons.position[weaponids[weaponactive]];
2763 where-=victim->coords;
2764 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2766 where=weapons.tippoint[weaponids[weaponactive]];
2767 where-=victim->coords;
2768 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2773 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2774 footpoint+=victim->coords;
2777 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2780 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2782 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2783 victim->skeleton.longdead=0;
2784 victim->skeleton.free=1;
2785 victim->skeleton.broken=0;
2787 for(i=0;i<victim->skeleton.num_joints;i++){
2788 victim->skeleton.joints[i].velchange=0;
2789 victim->skeleton.joints[i].locked=0;
2790 //victim->skeleton.joints[i].velocity=0;
2796 Normalise(&relative);
2797 //victim->Puff(abdomen);
2798 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2800 if(victim->bloodloss<victim->damagetolerance){
2801 victim->bloodloss+=1000;
2805 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2809 if(!hasvictim&&onterrain){
2810 weapons.bloody[weaponids[weaponactive]]=0;
2811 weapons.blooddrip[weaponids[weaponactive]]=0;
2815 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2816 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2818 if(id==0)camerashake+=.4;
2825 gLoc[0]=victim->coords.x;
2826 gLoc[1]=victim->coords.y;
2827 gLoc[2]=victim->coords.z;
2831 if(tutoriallevel!=1){
2832 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2833 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2834 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2835 OPENAL_SetPaused(channels[heavyimpactsound], false);
2840 relative=victim->coords-coords;
2842 Normalise(&relative);
2843 for(i=0;i<victim->skeleton.num_joints;i++){
2844 victim->skeleton.joints[i].velocity=relative*30;
2846 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2848 victim->targetframe=0;
2849 victim->targetanimation=staggerbackhardanim;
2850 victim->targetrotation=targetrotation+180;
2855 victim->Puff(abdomen);
2856 victim->DoDamage(damagemult*60/victim->protectionhigh);
2863 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2864 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2866 if(id==0)camerashake+=.4;
2869 gLoc[0]=victim->coords.x;
2870 gLoc[1]=victim->coords.y;
2871 gLoc[2]=victim->coords.z;
2875 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2876 if(tutoriallevel!=1){
2877 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2878 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2879 OPENAL_SetVolume(channels[thudsound], 512);
2880 OPENAL_SetPaused(channels[thudsound], false);
2883 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2884 if(tutoriallevel!=1){
2885 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2886 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2887 OPENAL_SetVolume(channels[whooshhitsound], 512);
2888 OPENAL_SetPaused(channels[whooshhitsound], false);
2892 if(tutoriallevel!=1){
2893 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2894 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2895 OPENAL_SetVolume(channels[heavyimpactsound], 256);
2896 OPENAL_SetPaused(channels[heavyimpactsound], false);
2900 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2903 relative=victim->coords-coords;
2905 Normalise(&relative);
2907 Normalise(&relative);
2908 for(i=0;i<victim->skeleton.num_joints;i++){
2909 victim->skeleton.joints[i].velocity=relative*5;
2911 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
2913 victim->targetframe=0;
2914 victim->targetanimation=staggerbackhardanim;
2915 victim->targetrotation=targetrotation+180;
2919 victim->Puff(abdomen);
2920 victim->DoDamage(damagemult*60/victim->protectionhigh);
2926 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
2927 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2928 if(victim->id==0)camerashake+=.4;
2931 gLoc[0]=victim->coords.x;
2932 gLoc[1]=victim->coords.y;
2933 gLoc[2]=victim->coords.z;
2938 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2939 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2940 OPENAL_SetVolume(channels[landsound2], 256);
2941 OPENAL_SetPaused(channels[landsound2], false);
2947 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
2948 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2949 if(victim->id==0)camerashake+=.4;
2952 gLoc[0]=victim->coords.x;
2953 gLoc[1]=victim->coords.y;
2954 gLoc[2]=victim->coords.z;
2959 if(weaponactive!=-1){
2960 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
2961 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2962 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2964 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
2965 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
2966 OPENAL_SetVolume(channels[swordstaffsound], 512);
2967 OPENAL_SetPaused(channels[swordstaffsound], false);
2970 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
2971 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
2972 OPENAL_SetVolume(channels[metalhitsound], 512);
2973 OPENAL_SetPaused(channels[metalhitsound], false);
2981 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
2982 if(weaponactive!=-1){
2985 weapons.owner[weaponids[0]]=-1;
2986 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);
2988 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
2989 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
2991 weapons.velocity[weaponids[0]]=aim*50;
2992 weapons.tipvelocity[weaponids[0]]=aim*50;
2993 weapons.missed[weaponids[0]]=0;
2994 weapons.hitsomething[weaponids[0]]=0;
2995 weapons.freetime[weaponids[0]]=0;
2996 weapons.firstfree[weaponids[0]]=1;
2997 weapons.physics[weaponids[0]]=0;
3000 weaponids[0]=weaponids[num_weapons];
3006 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3008 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3010 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3012 award_bonus(id, Slicebonus);
3013 if(tutoriallevel!=1){
3016 gLoc[0]=victim->coords.x;
3017 gLoc[1]=victim->coords.y;
3018 gLoc[2]=victim->coords.z;
3022 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3023 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3024 OPENAL_SetVolume(channels[knifeslicesound], 512);
3025 OPENAL_SetPaused(channels[knifeslicesound], false);
3027 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3028 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3029 if(victim->id != 0 || difficulty==2){
3030 victim->targetframe=0;
3031 victim->targetanimation=staggerbackhardanim;
3032 victim->targetrotation=targetrotation+180;
3036 victim->lowreversaldelay=0;
3037 victim->highreversaldelay=0;
3038 if(aitype!=playercontrolled)weaponmissdelay=.6;
3040 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3041 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3043 XYZ footvel,footpoint;
3046 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3049 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;
3051 if(tutoriallevel!=1){
3052 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3053 footvel=DoRotation(facing,0,90,0)*.8;
3055 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3056 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3057 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3058 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3060 if(tutoriallevel==1){
3061 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3063 victim->DoDamage(damagemult*0);
3066 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3067 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3068 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3069 award_bonus(id, Slashbonus);
3071 if(tutoriallevel!=1){
3072 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3073 else victim->DoBloodBig(2/victim->armorhigh,185);
3074 victim->deathbleeding=1;
3077 gLoc[0]=victim->coords.x;
3078 gLoc[1]=victim->coords.y;
3079 gLoc[2]=victim->coords.z;
3083 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3084 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3085 OPENAL_SetVolume(channels[swordslicesound], 512);
3086 OPENAL_SetPaused(channels[swordslicesound], false);
3088 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3089 if(tutoriallevel!=1){
3090 victim->targetframe=0;
3091 victim->targetanimation=staggerbackhardanim;
3092 victim->targetrotation=targetrotation+180;
3096 if(tutoriallevel!=1){
3097 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3098 weapons.blooddrip[weaponids[weaponactive]]+=3;
3100 float bloodlossamount;
3101 bloodlossamount=200+abs((float)(Random()%40))-20;
3102 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3103 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3104 victim->DoDamage(damagemult*0);
3106 XYZ footvel,footpoint;
3109 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3112 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;
3114 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3115 footvel=DoRotation(facing,0,90,0)*.8;
3117 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3118 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3119 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3120 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3128 gLoc[0]=victim->coords.x;
3129 gLoc[1]=victim->coords.y;
3130 gLoc[2]=victim->coords.z;
3134 if(victim->weaponactive!=-1){
3135 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3136 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3137 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3139 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3140 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3141 OPENAL_SetVolume(channels[swordstaffsound], 512);
3142 OPENAL_SetPaused(channels[swordstaffsound], false);
3145 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3146 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3147 OPENAL_SetVolume(channels[metalhitsound], 512);
3148 OPENAL_SetPaused(channels[metalhitsound], false);
3154 victim->Puff(righthand);
3156 victim->targetframe=0;
3157 victim->targetanimation=staggerbackhighanim;
3158 victim->targetrotation=targetrotation+180;
3160 weapons.owner[victim->weaponids[0]]=-1;
3161 aim=DoRotation(facing,0,90,0)*21;
3163 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3164 weapons.tipvelocity[victim->weaponids[0]]=aim;
3165 weapons.missed[victim->weaponids[0]]=1;
3166 weapons.hitsomething[weaponids[0]]=0;
3167 weapons.freetime[victim->weaponids[0]]=0;
3168 weapons.firstfree[victim->weaponids[0]]=1;
3169 weapons.physics[victim->weaponids[0]]=1;
3170 victim->num_weapons--;
3171 if(victim->num_weapons){
3172 victim->weaponids[0]=victim->weaponids[num_weapons];
3173 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3175 victim->weaponactive=-1;
3176 for(i=0;i<numplayers;i++){
3177 player[i].wentforweapon=0;
3180 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3181 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3182 OPENAL_SetVolume(channels[metalhitsound], 512);
3183 OPENAL_SetPaused(channels[metalhitsound], false);*/
3189 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3190 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3191 if(tutoriallevel!=1){
3192 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3194 if(id==0)camerashake+=.4;
3195 if(Random()%2||creature==wolftype){
3200 gLoc[0]=victim->coords.x;
3201 gLoc[1]=victim->coords.y;
3202 gLoc[2]=victim->coords.z;
3206 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3207 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3208 OPENAL_SetVolume(channels[staffheadsound], 256);
3209 OPENAL_SetPaused(channels[staffheadsound], false);
3213 relative=victim->coords-coords;
3215 Normalise(&relative);
3216 relative=DoRotation(relative,0,90,0);
3218 Normalise(&relative);
3219 for(i=0;i<victim->skeleton.num_joints;i++){
3220 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3222 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3223 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3226 if(tutoriallevel!=1){
3227 victim->DoDamage(damagemult*120/victim->protectionhigh);
3229 award_bonus(id, solidhit, 30);
3234 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3235 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3236 if(tutoriallevel!=1){
3237 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3239 if(id==0)camerashake+=.4;
3240 if(Random()%2||creature==wolftype){
3245 gLoc[0]=victim->coords.x;
3246 gLoc[1]=victim->coords.y;
3247 gLoc[2]=victim->coords.z;
3251 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3252 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3253 OPENAL_SetVolume(channels[staffheadsound], 256);
3254 OPENAL_SetPaused(channels[staffheadsound], false);
3258 relative=victim->coords-coords;
3260 Normalise(&relative);
3261 relative=DoRotation(relative,0,-90,0);
3262 for(i=0;i<victim->skeleton.num_joints;i++){
3263 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3265 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3266 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3269 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3271 award_bonus(id, solidhit, 60);
3276 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3277 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3279 if(tutoriallevel!=1){
3280 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3281 if(id==0)camerashake+=.4;
3282 if(Random()%2||creature==wolftype){
3287 gLoc[0]=victim->coords.x;
3288 gLoc[1]=victim->coords.y;
3289 gLoc[2]=victim->coords.z;
3293 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3294 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3295 OPENAL_SetVolume(channels[staffbodysound], 256);
3296 OPENAL_SetPaused(channels[staffbodysound], false);
3298 victim->skeleton.longdead=0;
3299 victim->skeleton.free=1;
3300 victim->skeleton.broken=0;
3302 for(i=0;i<victim->skeleton.num_joints;i++){
3303 victim->skeleton.joints[i].velchange=0;
3304 victim->skeleton.joints[i].locked=0;
3305 //victim->skeleton.joints[i].velocity=0;
3311 /*relative=victim->coords-coords;
3313 Normalise(&relative);
3314 relative=DoRotation(relative,0,90,0);*/
3316 Normalise(&relative);
3318 for(i=0;i<victim->skeleton.num_joints;i++){
3319 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3322 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3325 for(i=0;i<victim->skeleton.num_joints;i++){
3326 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3329 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3331 victim->Puff(abdomen);
3332 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3335 award_bonus(id, solidhit, 40);
3341 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3342 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3344 if(id==0)camerashake+=.4;
3347 gLoc[0]=victim->coords.x;
3348 gLoc[1]=victim->coords.y;
3349 gLoc[2]=victim->coords.z;
3354 relative=victim->coords-coords;
3356 Normalise(&relative);
3360 if(animation[victim->targetanimation].height==lowheight){
3366 for(i=0;i<victim->skeleton.num_joints;i++){
3367 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3369 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3370 if(tutoriallevel!=1){
3371 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3372 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3373 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3374 OPENAL_SetPaused(channels[heavyimpactsound], false);
3377 victim->DoDamage(damagemult*100/victim->protectionhead);
3378 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3379 if(creature==wolftype){
3380 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3381 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3382 OPENAL_SetVolume(channels[clawslicesound], 128);
3383 OPENAL_SetPaused(channels[clawslicesound], false);
3385 victim->DoBloodBig(2/victim->armorhead,175);
3389 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3390 for(i=0;i<victim->skeleton.num_joints;i++){
3391 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3393 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3394 victim->targetframe=0;
3395 victim->targetanimation=staggerbackhighanim;
3396 victim->targetrotation=targetrotation+180;
3398 if(tutoriallevel!=1){
3399 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3400 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3401 OPENAL_SetVolume(channels[landsound2], 128);
3402 OPENAL_SetPaused(channels[landsound2], false);
3404 victim->Puff(abdomen);
3405 victim->DoDamage(damagemult*30/victim->protectionhigh);
3406 if(creature==wolftype){
3407 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3408 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3409 OPENAL_SetVolume(channels[clawslicesound], 128);
3410 OPENAL_SetPaused(channels[clawslicesound], false);
3412 victim->DoBloodBig(2/victim->armorhigh,170);
3419 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3420 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3422 if(id==0)camerashake+=.2;
3425 gLoc[0]=victim->coords.x;
3426 gLoc[1]=victim->coords.y;
3427 gLoc[2]=victim->coords.z;
3431 if(tutoriallevel!=1){
3432 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3433 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3434 OPENAL_SetVolume(channels[landsound2], 128);
3435 OPENAL_SetPaused(channels[landsound2], false);
3438 relative=victim->coords-coords;
3440 Normalise(&relative);
3442 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3445 for(i=0;i<victim->skeleton.num_joints;i++){
3446 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3448 relative=DoRotation(relative,0,-90,0);
3450 for(i=0;i<victim->skeleton.num_joints;i++){
3451 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)
3452 victim->skeleton.joints[i].velocity=relative*80;
3454 victim->Puff(rightankle);
3455 victim->Puff(leftankle);
3456 victim->DoDamage(damagemult*40/victim->protectionlow);
3459 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3460 for(i=0;i<victim->skeleton.num_joints;i++){
3461 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3463 relative=DoRotation(relative,0,-90,0);
3464 for(i=0;i<victim->skeleton.num_joints;i++){
3465 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)
3466 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3468 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3469 victim->targetframe=0;
3470 victim->targetanimation=staggerbackhighanim;
3471 victim->targetrotation=targetrotation+180;
3473 if(tutoriallevel!=1){
3474 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3475 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3476 OPENAL_SetVolume(channels[landsound2], 128);
3477 OPENAL_SetPaused(channels[landsound2], false);
3479 victim->Puff(abdomen);
3480 victim->DoDamage(damagemult*30/victim->protectionlow);
3488 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3489 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3491 if(id==0)camerashake+=.4;
3498 gLoc[0]=victim->coords.x;
3499 gLoc[1]=victim->coords.y;
3500 gLoc[2]=victim->coords.z;
3504 if(tutoriallevel!=1){
3505 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3506 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3507 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3508 OPENAL_SetPaused(channels[heavyimpactsound], false);
3510 if(creature==wolftype){
3511 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3512 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3513 OPENAL_SetVolume(channels[clawslicesound], 128);
3514 OPENAL_SetPaused(channels[clawslicesound], false);
3516 victim->DoBloodBig(2/victim->armorhigh,170);
3520 relative=victim->coords-oldcoords;
3522 Normalise(&relative);
3523 //relative=DoRotation(relative,0,-90,0);
3524 for(i=0;i<victim->skeleton.num_joints;i++){
3525 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3527 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3529 victim->Puff(abdomen);
3530 victim->DoDamage(damagemult*150/victim->protectionhigh);
3532 award_bonus(id, Reversal);
3535 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3536 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3537 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3538 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3541 weaponids[num_weapons]=weaponids[victim->weaponactive];
3544 weaponids[0]=victim->weaponids[victim->weaponactive];
3545 victim->num_weapons--;
3546 if(victim->num_weapons>0){
3547 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3548 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3550 victim->weaponactive=-1;
3555 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3557 if(id==0)camerashake+=.4;
3564 gLoc[0]=victim->coords.x;
3565 gLoc[1]=victim->coords.y;
3566 gLoc[2]=victim->coords.z;
3570 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3571 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3572 OPENAL_SetVolume(channels[whooshhitsound], 128);
3573 OPENAL_SetPaused(channels[whooshhitsound], false);
3576 relative=victim->coords-oldcoords;
3578 Normalise(&relative);
3579 //relative=DoRotation(relative,0,-90,0);
3580 for(i=0;i<victim->skeleton.num_joints;i++){
3581 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3583 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3586 victim->DoDamage(damagemult*70/victim->protectionhigh);
3589 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3591 if(id==0)camerashake+=.4;
3598 gLoc[0]=victim->coords.x;
3599 gLoc[1]=victim->coords.y;
3600 gLoc[2]=victim->coords.z;
3605 award_bonus(id, staffreversebonus);
3607 if(tutoriallevel!=1){
3608 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3609 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3610 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3611 OPENAL_SetPaused(channels[heavyimpactsound], false);
3614 award_bonus(id, staffreversebonus); // Huh, again?
3617 relative=victim->coords-oldcoords;
3619 Normalise(&relative);
3620 //relative=DoRotation(relative,0,-90,0);
3621 for(i=0;i<victim->skeleton.num_joints;i++){
3622 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3624 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3627 victim->DoDamage(damagemult*70/victim->protectionhigh);
3630 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3636 Normalise(&relative);
3639 for(i=0;i<victim->skeleton.num_joints;i++){
3640 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3642 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3643 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3644 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3645 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3646 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3647 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3648 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3649 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3651 victim->Puff(abdomen);
3652 victim->DoDamage(damagemult*90/victim->protectionhigh);
3654 award_bonus(id, Reversal);
3658 if(weaponactive!=-1||creature==wolftype)doslice=1;
3659 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3663 gLoc[0]=victim->coords.x;
3664 gLoc[1]=victim->coords.y;
3665 gLoc[2]=victim->coords.z;
3669 if(weaponactive!=-1){
3670 victim->DoBloodBig(2/victim->armorhigh,225);
3671 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3672 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3673 OPENAL_SetVolume(channels[knifeslicesound], 512);
3674 OPENAL_SetPaused(channels[knifeslicesound], false);
3675 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3676 weapons.blooddrip[weaponids[weaponactive]]+=3;
3678 if(weaponactive==-1&&creature==wolftype){
3679 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3680 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3681 OPENAL_SetVolume(channels[clawslicesound], 128);
3682 OPENAL_SetPaused(channels[clawslicesound], false);
3684 victim->DoBloodBig(2/victim->armorhigh,175);
3691 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3697 Normalise(&relative);
3700 for(i=0;i<victim->skeleton.num_joints;i++){
3701 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3703 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
3704 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
3705 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
3706 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
3707 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
3708 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
3709 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
3710 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
3712 award_bonus(id, swordreversebonus);
3715 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3717 if(id==0)camerashake+=.4;
3724 gLoc[0]=victim->coords.x;
3725 gLoc[1]=victim->coords.y;
3726 gLoc[2]=victim->coords.z;
3730 if(tutoriallevel!=1){
3731 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3732 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3733 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3734 OPENAL_SetPaused(channels[heavyimpactsound], false);
3738 relative=victim->coords-oldcoords;
3740 Normalise(&relative);
3741 relative=DoRotation(relative,0,-90,0);
3742 for(i=0;i<victim->skeleton.num_joints;i++){
3743 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3745 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3747 victim->Puff(abdomen);
3748 victim->DoDamage(damagemult*30/victim->protectionhigh);
3750 award_bonus(id, Reversal);
3753 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
3756 victim->skeleton.spinny=0;
3760 Normalise(&relative);
3761 if(victim->id==0)relative/=30;
3762 for(i=0;i<victim->skeleton.num_joints;i++){
3763 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3765 //victim->DoDamage(1000);
3766 victim->damage=victim->damagetolerance;
3767 victim->permanentdamage=victim->damagetolerance-1;
3770 if(weaponactive!=-1||creature==wolftype)doslice=1;
3771 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3775 gLoc[0]=victim->coords.x;
3776 gLoc[1]=victim->coords.y;
3777 gLoc[2]=victim->coords.z;
3781 if(weaponactive!=-1){
3782 victim->DoBloodBig(200,225);
3783 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3784 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3785 OPENAL_SetVolume(channels[knifeslicesound], 512);
3786 OPENAL_SetPaused(channels[knifeslicesound], false);
3787 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3788 weapons.blooddrip[weaponids[weaponactive]]+=5;
3791 if(creature==wolftype&&weaponactive==-1){
3792 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3793 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3794 OPENAL_SetVolume(channels[clawslicesound], 128);
3795 OPENAL_SetPaused(channels[clawslicesound], false);
3797 victim->DoBloodBig(2,175);
3800 award_bonus(id, spinecrusher);
3803 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3804 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3806 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3807 if(targetanimation==knifesneakattackanim){
3808 /*victim->DoBloodBig(200,195);
3813 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3814 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3816 XYZ footvel,footpoint;
3818 footpoint=weapons.tippoint[weaponids[0]];
3819 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3820 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3821 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3822 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3823 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3824 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3825 victim->DoBloodBig(200,195);
3826 award_bonus(id, tracheotomy);
3828 if(targetanimation==knifefollowanim){
3829 award_bonus(id, Stabbonus);
3830 XYZ footvel,footpoint;
3832 footpoint=weapons.tippoint[weaponids[0]];
3833 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3834 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3835 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3836 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3837 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3838 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3841 victim->bloodloss+=10000;
3845 gLoc[0]=victim->coords.x;
3846 gLoc[1]=victim->coords.y;
3847 gLoc[2]=victim->coords.z;
3851 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
3852 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
3853 OPENAL_SetVolume(channels[fleshstabsound], 512);
3854 OPENAL_SetPaused(channels[fleshstabsound], false);
3855 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3856 weapons.blooddrip[weaponids[weaponactive]]+=5;
3860 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
3863 for(i=0;i<victim->skeleton.num_joints;i++){
3864 victim->skeleton.joints[i].velocity=0;
3866 if(targetanimation==knifefollowanim){
3868 for(i=0;i<victim->skeleton.num_joints;i++){
3869 victim->skeleton.joints[i].velocity=0;
3872 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
3875 gLoc[0]=victim->coords.x;
3876 gLoc[1]=victim->coords.y;
3877 gLoc[2]=victim->coords.z;
3881 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
3882 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
3883 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
3884 OPENAL_SetPaused(channels[fleshstabremovesound], false);
3885 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3886 weapons.blooddrip[weaponids[weaponactive]]+=5;
3888 XYZ footvel,footpoint;
3890 footpoint=weapons.tippoint[weaponids[0]];
3891 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3892 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3893 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3894 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3895 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3896 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3900 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3901 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3902 award_bonus(id, backstab);
3906 XYZ footvel,footpoint;
3908 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
3909 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3910 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3911 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3912 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3913 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3914 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3915 victim->DoBloodBig(200,180);
3916 victim->DoBloodBig(200,215);
3917 victim->bloodloss+=10000;
3921 gLoc[0]=victim->coords.x;
3922 gLoc[1]=victim->coords.y;
3923 gLoc[2]=victim->coords.z;
3927 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
3928 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
3929 OPENAL_SetVolume(channels[fleshstabsound], 512);
3930 OPENAL_SetPaused(channels[fleshstabsound], false);
3931 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3932 weapons.blooddrip[weaponids[weaponactive]]+=5;
3936 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
3939 for(i=0;i<victim->skeleton.num_joints;i++){
3940 victim->skeleton.joints[i].velocity=0;
3942 if(weaponactive!=-1){
3945 gLoc[0]=victim->coords.x;
3946 gLoc[1]=victim->coords.y;
3947 gLoc[2]=victim->coords.z;
3951 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
3952 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
3953 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
3954 OPENAL_SetPaused(channels[fleshstabremovesound], false);
3955 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3956 weapons.blooddrip[weaponids[weaponactive]]+=5;
3958 XYZ footvel,footpoint;
3960 footpoint=weapons.tippoint[weaponids[0]];
3961 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3962 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3963 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3964 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3965 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3966 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3970 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
3972 if(id==0)camerashake+=.4;
3979 gLoc[0]=victim->coords.x;
3980 gLoc[1]=victim->coords.y;
3981 gLoc[2]=victim->coords.z;
3985 if(weaponactive==-1){
3986 if(tutoriallevel!=1){
3987 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3988 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3989 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3990 OPENAL_SetPaused(channels[heavyimpactsound], false);
3995 if(weaponactive!=-1||creature==wolftype)doslice=1;
3996 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3998 if(weaponactive!=-1){
3999 victim->DoBloodBig(2/victim->armorhead,225);
4000 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4001 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4002 OPENAL_SetVolume(channels[knifeslicesound], 512);
4003 OPENAL_SetPaused(channels[knifeslicesound], false);
4004 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4005 weapons.blooddrip[weaponids[weaponactive]]+=3;
4007 if(weaponactive==-1&&creature==wolftype){
4008 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4009 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4010 OPENAL_SetVolume(channels[clawslicesound], 128);
4011 OPENAL_SetPaused(channels[clawslicesound], false);
4013 victim->DoBloodBig(2/victim->armorhead,175);
4017 award_bonus(id, Reversal);
4022 //relative=victim->coords-oldcoords;
4025 Normalise(&relative);
4026 relative=DoRotation(relative,0,90,0);
4028 Normalise(&relative);
4029 for(i=0;i<victim->skeleton.num_joints;i++){
4030 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4032 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4033 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4034 victim->DoDamage(damagemult*100/victim->protectionhead);
4038 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4042 //relative=victim->coords-oldcoords;
4045 Normalise(&relative);
4046 relative=DoRotation(relative,0,90,0);
4048 Normalise(&relative);
4049 for(i=0;i<victim->skeleton.num_joints;i++){
4050 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4052 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4055 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4056 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4057 award_bonus(id, reverseko);
4063 if(targetframe>animation[currentanimation].numframes-1){
4066 targetanimation=getIdle();
4070 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4071 targetanimation=rollanim;
4082 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4083 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4084 OPENAL_SetVolume(channels[movewhooshsound], 128);
4085 OPENAL_SetPaused(channels[movewhooshsound], false);
4087 if(currentanimation==staggerbackhighanim){
4088 targetanimation=getIdle();
4090 if(currentanimation==staggerbackhardanim){
4091 targetanimation=getIdle();
4093 if(currentanimation==removeknifeanim){
4094 targetanimation=getIdle();
4096 if(currentanimation==crouchremoveknifeanim){
4097 targetanimation=getCrouch();
4099 if(currentanimation==backhandspringanim){
4100 targetanimation=getIdle();
4102 if(currentanimation==dodgebackanim){
4103 targetanimation=getIdle();
4105 if(currentanimation==drawleftanim){
4106 targetanimation=getIdle();
4108 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4109 targetanimation=getIdle();
4110 if(currentanimation==crouchdrawrightanim){
4111 targetanimation=getCrouch();
4113 if(weaponactive==-1)weaponactive=0;
4114 else if(weaponactive==0){
4118 buffer=weaponids[0];
4119 weaponids[0]=weaponids[1];
4120 weaponids[1]=buffer;
4124 if(weaponactive==-1){
4134 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4135 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4136 OPENAL_SetVolume(channels[knifesheathesound], 128);
4137 OPENAL_SetPaused(channels[knifesheathesound], false);
4139 if(weaponactive!=-1){
4149 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4150 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4151 OPENAL_SetVolume(channels[knifedrawsound], 128);
4152 OPENAL_SetPaused(channels[knifedrawsound], false);
4155 if(currentanimation==rollanim){
4156 targetanimation=getCrouch();
4161 if(targetanimation==walljumprightkickanim){
4164 if(targetanimation==walljumpleftkickanim){
4167 targetanimation=jumpdownanim;
4169 if(currentanimation==climbanim){
4170 targetanimation=getCrouch();
4173 if(!isnormal(coords.x))
4184 if(targetanimation==rabbitkickreversalanim){
4185 targetanimation=getCrouch();
4188 if(targetanimation==jumpreversalanim){
4189 targetanimation=getCrouch();
4192 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4193 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4195 float closestdist=-1;
4198 for(i=0;i<numplayers;i++){
4199 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4200 distance=findDistancefast(&player[i].coords,&coords);
4201 if(closestdist==-1||distance<closestdist){
4202 closestdist=distance;
4207 if(closestdist>0&&closest>=0&&closestdist<16){
4208 victim=&player[closest];
4209 targetanimation=walljumprightkickanim;
4211 XYZ rotatetarget=victim->coords-coords;
4212 Normalise(&rotatetarget);
4213 rotation=-asin(0-rotatetarget.x);
4215 if(rotatetarget.z<0)rotation=180-rotation;
4216 targettilt2=-asin(rotatetarget.y)*360/6.28;
4217 velocity=(victim->coords-coords)*4;
4222 if(targetanimation==walljumpbackanim){
4223 targetanimation=backflipanim;
4227 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4229 if(targetanimation==walljumprightanim){
4230 targetanimation=rightflipanim;
4234 velocity=DoRotation(facing,0,30,0)*-8;
4237 if(targetanimation==walljumpfrontanim){
4238 targetanimation=frontflipanim;
4240 //targetrotation-=180;
4245 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4247 if(targetanimation==walljumpleftanim){
4250 float closestdist=-1;
4253 for(i=0;i<numplayers;i++){
4254 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4255 distance=findDistancefast(&player[i].coords,&coords);
4256 if(closestdist==-1||distance<closestdist){
4257 closestdist=distance;
4262 if(closestdist>0&&closest>=0&&closestdist<16){
4263 victim=&player[closest];
4264 targetanimation=walljumpleftkickanim;
4266 XYZ rotatetarget=victim->coords-coords;
4267 Normalise(&rotatetarget);
4268 rotation=-asin(0-rotatetarget.x);
4270 if(rotatetarget.z<0)rotation=180-rotation;
4271 targettilt2=-asin(rotatetarget.y)*360/6.28;
4272 velocity=(victim->coords-coords)*4;
4277 if(targetanimation!=walljumpleftkickanim){
4278 targetanimation=leftflipanim;
4282 velocity=DoRotation(facing,0,-30,0)*-8;
4285 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4287 if(targetanimation==sneakattackanim){
4288 float ycoords=oldcoords.y;
4289 currentanimation=getCrouch();
4290 targetanimation=getCrouch();
4293 targetrotation+=180;
4298 targetheadrotation+=180;
4300 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4304 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4305 float ycoords=oldcoords.y;
4306 targetanimation=getIdle();
4308 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4312 if(currentanimation==knifefollowanim){
4313 targetanimation=getIdle();
4316 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4317 float ycoords=oldcoords.y;
4318 targetanimation=getStop();
4319 targetrotation+=180;
4324 targetheadrotation+=180;
4325 if(!isnormal(coords.x))
4327 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4328 oldcoords=coords+facing*.5;
4329 else if(currentanimation==sweepreversalanim)
4330 oldcoords=coords+facing*1.1;
4331 else if(currentanimation==upunchreversalanim){
4332 oldcoords=coords+facing*1.5;
4333 targetrotation+=180;
4335 targetheadrotation+=180;
4339 else if(currentanimation==knifeslashreversalanim){
4340 oldcoords=coords+facing*.5;
4343 targetheadrotation+=90;
4347 else if(currentanimation==staffspinhitreversalanim){
4348 targetrotation+=180;
4350 targetheadrotation+=180;
4354 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4355 else oldcoords.y=ycoords;
4356 currentoffset=coords-oldcoords;
4362 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4367 if(animation[targetanimation].attack==reversed){
4369 if(targetanimation==sweepreversedanim)targetrotation+=90;
4370 targetanimation=backhandspringanim;
4380 PlaySoundEx( landsound, samp[landsound], NULL, true);
4381 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4382 OPENAL_SetVolume(channels[landsound], 128);
4383 OPENAL_SetPaused(channels[landsound], false);
4385 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4386 targetanimation=rollanim;
4389 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4390 coords.y=oldcoords.y;
4392 if(currentanimation==knifeslashreversedanim){
4393 targetanimation=rollanim;
4398 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4399 coords.y=oldcoords.y;
4403 targetanimation=jumpdownanim;
4405 if(wasLanding())targetanimation=getIdle();
4406 if(wasLandhard())targetanimation=getIdle();
4407 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4408 targetanimation=getIdle();
4410 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4411 coords.y=oldcoords.y;
4412 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4413 targetoffset.y=coords.y;
4414 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4415 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4416 currentoffset.y-=(coords.y-targetoffset.y);
4417 coords.y=targetoffset.y;
4419 normalsupdatedelay=0;
4421 if(currentanimation==upunchanim){
4422 targetanimation=getStop();
4423 normalsupdatedelay=0;
4426 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4427 targetrotation=rotation;
4430 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4431 if(!hasstaff)DoDamage(35);
4434 rabbitkickragdoll=1;
4436 if(currentanimation==rabbitkickreversedanim){
4443 SolidHitBonus(!id); // FIXME: tricky id
4447 targetanimation=rollanim;
4449 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4453 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4459 if(currentanimation==jumpreversedanim){
4466 SolidHitBonus(!id); // FIXME: tricky id
4470 targetanimation=rollanim;
4472 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4477 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){
4478 targetanimation=getupfromfrontanim;
4481 else if(animation[currentanimation].attack==normalattack){
4482 targetanimation=getIdle();
4485 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4486 targetanimation=blockhighleftstrikeanim;
4488 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4489 targetanimation=getIdle();
4492 if(currentanimation==spinkickanim&&victim->skeleton.free){
4493 if(creature==rabbittype)targetanimation=fightidleanim;
4498 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4500 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4501 targetanimation=jumpdownanim;
4506 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4507 if(!isRun()||!wasRun()){
4508 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4509 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4510 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4511 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4513 if(isRun()&&wasRun()){
4516 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4517 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4520 else if(transspeed)target+=multiplier*transspeed*speed*2;
4522 if(!isRun()||!wasRun()){
4523 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4524 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4525 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4526 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4530 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4532 if(target>1){currentframe=targetframe; target=1;}
4534 rot=targetrot*target;
4535 rotation+=rot-oldrot;
4541 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4543 for(i=0;i<skeleton.num_joints;i++){
4544 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4547 skeleton.FindForwards();
4549 for(i=0;i<skeleton.num_muscles;i++){
4550 if(skeleton.muscles[i].visible)
4552 skeleton.FindRotationMuscle(i,targetanimation);
4555 for(i=0;i<skeleton.num_muscles;i++){
4556 if(skeleton.muscles[i].visible)
4558 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4559 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4560 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4565 for(i=0;i<skeleton.num_joints;i++){
4566 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4569 skeleton.FindForwards();
4571 for(i=0;i<skeleton.num_muscles;i++){
4572 if(skeleton.muscles[i].visible)
4574 skeleton.FindRotationMuscle(i,targetanimation);
4577 for(i=0;i<skeleton.num_muscles;i++){
4578 if(skeleton.muscles[i].visible)
4580 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4581 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4582 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4583 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4584 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4585 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4586 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4587 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4588 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4592 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4594 oldcurrentanimation=currentanimation;
4595 oldtargetanimation=targetanimation;
4596 oldtargetframe=targetframe;
4597 oldcurrentframe=currentframe;
4599 for(i=0;i<skeleton.num_joints;i++){
4600 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4601 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4603 offset=currentoffset*(1-target)+targetoffset*target;
4604 for(i=0;i<skeleton.num_muscles;i++){
4605 if(skeleton.muscles[i].visible)
4607 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4608 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4609 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4614 if(isLanding()&&landhard){
4615 if(id==0)camerashake+=.4;
4616 targetanimation=getLandhard();
4623 //skeleton.DoConstraints();
4626 void Person::DoStuff(){
4627 static XYZ terrainnormal;
4628 static XYZ flatfacing;
4629 static XYZ flatvelocity;
4630 static float flatvelspeed;
4634 static int bloodsize;
4635 static int startx,starty,endx,endy;
4636 static int texdetailint;
4637 static GLubyte color;
4638 static XYZ bloodvel;
4640 onfiredelay-=multiplier;
4641 if(onfiredelay<0&&onfire)
4649 crouchkeydowntime+=multiplier;
4650 if(!crouchkeydown)crouchkeydowntime=0;
4651 jumpkeydowntime+=multiplier;
4652 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
4654 if(hostile||damage>0||bloodloss>0)immobile=0;
4656 if(isIdle()||isRun())targetoffset=0;
4658 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
4660 if(id==0)blooddimamount-=multiplier*.3;
4661 speechdelay-=multiplier;
4662 texupdatedelay-=multiplier;
4663 interestdelay-=multiplier;
4664 flamedelay-=multiplier;
4665 parriedrecently-=multiplier;
4671 if(id==0)speed=1.1*speedmult;
4672 else speed=1.0*speedmult;
4673 if(!skeleton.free)rabbitkickragdoll=0;
4677 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
4678 if(id!=0&&creature==wolftype&&difficulty==2){
4680 if(aitype!=passivetype){
4682 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){
4686 if(scale<0.2)superruntoggle=0;
4687 if(targetanimation==wolfrunninganim&&!superruntoggle){
4688 targetanimation=getRun();
4692 if(weaponactive==-1&&num_weapons>0){
4693 if(weapons.type[weaponids[0]]==staff){
4700 /*if(aitype!=playercontrolled)*///deathbleeding=5;
4701 /*if(aitype!=playercontrolled)*/
4703 if(burnt>.6)burnt=.6;
4704 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
4706 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
4717 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4718 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
4722 while(flamedelay<0&&onfire){
4724 howmany=abs(Random()%(skeleton.num_joints));
4725 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4726 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4727 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4728 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4729 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
4732 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
4734 howmany=abs(Random()%(skeleton.num_joints));
4735 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4736 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4737 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4738 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4739 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
4743 bleeding-=multiplier*.3;
4745 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4746 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
4750 if(neckspurtamount>0){
4751 neckspurtamount-=multiplier;
4752 neckspurtdelay-=multiplier*3;
4753 neckspurtparticledelay-=multiplier*3;
4754 if(neckspurtparticledelay<0&&neckspurtdelay>2){
4758 bloodvel.z=5*neckspurtamount;
4759 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4762 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
4764 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4765 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
4766 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);
4767 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);
4768 neckspurtparticledelay=.05;
4770 if(neckspurtdelay<0){
4775 if(deathbleeding>0&&dead!=2){
4776 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
4777 else bleeddelay-=5*multiplier/4;
4778 if(bleeddelay<0&&bloodtoggle){
4783 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4784 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
4785 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
4786 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);
4789 bloodloss+=deathbleeding*multiplier*80;
4790 deathbleeding-=multiplier*1.6;
4791 //if(id==0)deathbleeding-=multiplier*.2;
4792 if(deathbleeding<0)deathbleeding=0;
4793 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
4794 if(weaponactive!=-1){
4795 weapons.owner[weaponids[0]]=-1;
4796 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4797 weapons.velocity[weaponids[0]].x+=.01;
4798 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4799 weapons.missed[weaponids[0]]=1;
4800 weapons.hitsomething[weaponids[0]]=0;
4801 weapons.freetime[weaponids[0]]=0;
4802 weapons.firstfree[weaponids[0]]=1;
4803 weapons.physics[weaponids[0]]=1;
4806 weaponids[0]=weaponids[num_weapons];
4807 if(weaponstuck==num_weapons)weaponstuck=0;
4810 for(i=0;i<numplayers;i++){
4811 player[i].wentforweapon=0;
4823 if(!dead&&creature==wolftype){
4824 award_bonus(0, Wolfbonus);
4827 if(targetanimation==knifefollowedanim&&!skeleton.free){
4828 for(i=0;i<skeleton.num_joints;i++){
4829 skeleton.joints[i].velocity=0;
4830 skeleton.joints[i].velocity.y=-2;
4833 if(id!=0&&unconscioustime>.1){
4841 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
4844 bloodsize=5-realtexdetail;
4848 texdetailint=realtexdetail;
4849 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
4850 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
4851 endx=startx+bloodsize;
4852 endy=starty+bloodsize;
4854 if(startx<0){startx=0;bleeding=0;}
4855 if(starty<0){starty=0;bleeding=0;}
4856 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
4857 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
4858 if(endx<startx)endx=startx;
4859 if(endy<starty)endy=starty;
4861 for(i=startx;i<endx;i++){
4862 for(j=starty;j<endy;j++){
4864 color=Random()%85+170;
4865 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
4866 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
4867 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
4872 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4873 DoMipmaps(0,startx,endx,starty,endy);
4877 bleedy-=4/realtexdetail;
4878 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
4879 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
4882 bleedx+=4*direction/realtexdetail;
4883 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
4884 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
4888 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
4889 righthandmorphness=targetrighthandmorphness;
4890 righthandmorphstart=righthandmorphend;
4892 else if(righthandmorphness>targetrighthandmorphness){
4893 righthandmorphness-=multiplier*4;
4895 else if(righthandmorphness<targetrighthandmorphness){
4896 righthandmorphness+=multiplier*4;
4899 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
4900 lefthandmorphness=targetlefthandmorphness;
4901 lefthandmorphstart=lefthandmorphend;
4903 else if(lefthandmorphness>targetlefthandmorphness){
4904 lefthandmorphness-=multiplier*4;
4906 else if(lefthandmorphness<targetlefthandmorphness){
4907 lefthandmorphness+=multiplier*4;
4910 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
4911 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
4912 tailmorphness=targettailmorphness;
4913 tailmorphstart=tailmorphend;
4915 else if(tailmorphness>targettailmorphness){
4916 tailmorphness-=multiplier*10;
4918 else if(tailmorphness<targettailmorphness){
4919 tailmorphness+=multiplier*10;
4923 if(creature==wolftype){
4924 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
4925 tailmorphness=targettailmorphness;
4926 tailmorphstart=tailmorphend;
4928 else if(tailmorphness>targettailmorphness){
4929 tailmorphness-=multiplier*2;
4931 else if(tailmorphness<targettailmorphness){
4932 tailmorphness+=multiplier*2;
4936 if(headmorphend==3||headmorphstart==3){
4937 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
4938 headmorphness=targetheadmorphness;
4939 headmorphstart=headmorphend;
4941 else if(headmorphness>targetheadmorphness){
4942 headmorphness-=multiplier*7;
4944 else if(headmorphness<targetheadmorphness){
4945 headmorphness+=multiplier*7;
4948 else if(headmorphend==5||headmorphstart==5){
4949 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
4950 headmorphness=targetheadmorphness;
4951 headmorphstart=headmorphend;
4953 else if(headmorphness>targetheadmorphness){
4954 headmorphness-=multiplier*10;
4956 else if(headmorphness<targetheadmorphness){
4957 headmorphness+=multiplier*10;
4961 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
4962 headmorphness=targetheadmorphness;
4963 headmorphstart=headmorphend;
4965 else if(headmorphness>targetheadmorphness){
4966 headmorphness-=multiplier*4;
4968 else if(headmorphness<targetheadmorphness){
4969 headmorphness+=multiplier*4;
4973 if(abs(chestmorphness-targetchestmorphness)<multiplier){
4974 chestmorphness=targetchestmorphness;
4975 chestmorphstart=chestmorphend;
4977 else if(chestmorphness>targetchestmorphness){
4978 chestmorphness-=multiplier;
4980 else if(chestmorphness<targetchestmorphness){
4981 chestmorphness+=multiplier;
4984 if(dead!=2&&howactive<=typesleeping){
4985 if(chestmorphstart==0&&chestmorphend==0){
4987 targetchestmorphness=1;
4990 if(chestmorphstart!=0&&chestmorphend!=0){
4992 targetchestmorphness=1;
4994 if(environment==snowyenvironment){
4997 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
4998 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
4999 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5000 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5001 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5002 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5006 if(!dead&&howactive<typesleeping){
5007 blinkdelay-=multiplier*2;
5008 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5010 targetheadmorphness=1;
5012 blinkdelay=(float)(abs(Random()%40))/5;
5014 if(headmorphstart==3&&headmorphend==3){
5016 targetheadmorphness=1;
5021 twitchdelay-=multiplier*1.5;
5022 if(targetanimation!=hurtidleanim){
5023 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5025 targetheadmorphness=1;
5027 twitchdelay=(float)(abs(Random()%40))/5;
5029 if(headmorphstart==5&&headmorphend==5){
5031 targetheadmorphness=1;
5035 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5036 twitchdelay3-=multiplier*1;
5038 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5039 righthandmorphness=0;
5040 targetrighthandmorphness=1;
5041 righthandmorphend=1;
5042 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5044 if(righthandmorphstart==1&&righthandmorphend==1){
5045 righthandmorphness=0;
5046 targetrighthandmorphness=1;
5047 righthandmorphend=0;
5051 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5052 lefthandmorphness=0;
5053 targetlefthandmorphness=1;
5055 twitchdelay3=(float)(abs(Random()%40))/5;
5057 if(lefthandmorphstart==1&&lefthandmorphend==1){
5058 lefthandmorphness=0;
5059 targetlefthandmorphness=1;
5066 if(creature==rabbittype){
5067 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5068 else twitchdelay2-=multiplier*0.5;
5069 if(howactive<=typesleeping){
5070 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5072 targettailmorphness=1;
5074 twitchdelay2=(float)(abs(Random()%40))/5;
5076 if(tailmorphstart==1&&tailmorphend==1){
5078 targettailmorphness=1;
5081 if(tailmorphstart==2&&tailmorphend==2){
5083 targettailmorphness=1;
5090 if(creature==wolftype){
5091 twitchdelay2-=multiplier*1.5;
5093 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5095 targettailmorphness=1;
5100 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5102 targettailmorphness=1;
5106 if(twitchdelay2<=0){
5107 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5109 targettailmorphness=1;
5112 if(tailmorphstart==1&&tailmorphend==1){
5114 targettailmorphness=1;
5117 if(tailmorphstart==2&&tailmorphend==2){
5119 targettailmorphness=1;
5122 if(tailmorphstart==3&&tailmorphend==3){
5124 targettailmorphness=1;
5127 if(tailmorphstart==4&&tailmorphend==4){
5129 targettailmorphness=1;
5135 if(dead!=1)unconscioustime=0;
5137 if(dead==1||howactive==typesleeping){
5138 unconscioustime+=multiplier;
5139 //If unconscious, close eyes and mouth
5140 if(righthandmorphend!=0)righthandmorphness=0;
5141 righthandmorphend=0;
5142 targetrighthandmorphness=1;
5144 if(lefthandmorphend!=0)lefthandmorphness=0;
5146 targetlefthandmorphness=1;
5148 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5150 targetheadmorphness=1;
5154 if(howactive>typesleeping){
5157 if(bloodtoggle&&!bled){
5158 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5160 if(bloodtoggle&&!bled)
5161 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5162 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5163 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5167 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5172 if(dead==2||howactive>typesleeping){
5173 //If dead, open mouth and hands
5174 if(righthandmorphend!=0)righthandmorphness=0;
5175 righthandmorphend=0;
5176 targetrighthandmorphness=1;
5178 if(lefthandmorphend!=0)lefthandmorphness=0;
5180 targetlefthandmorphness=1;
5182 if(headmorphend!=2)headmorphness=0;
5184 targetheadmorphness=1;
5187 if(stunned>0&&!dead&&headmorphend!=2){
5188 if(headmorphend!=4)headmorphness=0;
5190 targetheadmorphness=1;
5193 if(damage>damagetolerance&&!dead){
5198 if(creature==wolftype){
5199 award_bonus(0, Wolfbonus);
5204 if(weaponactive!=-1){
5205 weapons.owner[weaponids[0]]=-1;
5206 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5207 weapons.velocity[weaponids[0]].x+=.01;
5208 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5209 weapons.missed[weaponids[0]]=1;
5210 weapons.hitsomething[weaponids[0]]=0;
5211 weapons.freetime[weaponids[0]]=0;
5212 weapons.firstfree[weaponids[0]]=1;
5213 weapons.physics[weaponids[0]]=1;
5216 weaponids[0]=weaponids[num_weapons];
5217 if(weaponstuck==num_weapons)weaponstuck=0;
5220 for(i=0;i<numplayers;i++){
5221 player[i].wentforweapon=0;
5227 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5235 //if(dead)damage-=multiplier/4;
5236 if(!dead)damage-=multiplier*13;
5237 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5238 if(!dead)permanentdamage-=multiplier*4;
5239 if(isIdle()||isCrouch()){
5240 if(!dead)permanentdamage-=multiplier*4;
5241 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5243 if(damage<0)damage=0;
5244 if(permanentdamage<0)permanentdamage=0;
5245 if(superpermanentdamage<0)superpermanentdamage=0;
5246 if(permanentdamage<superpermanentdamage){
5247 permanentdamage=superpermanentdamage;
5249 if(damage<permanentdamage){
5250 damage=permanentdamage;
5252 if(dead==1&&damage<damagetolerance){
5256 for(i=0;i<skeleton.num_joints;i++){
5257 skeleton.joints[i].velocity=0;
5260 if(permanentdamage>damagetolerance&&dead!=2){
5263 if(weaponactive!=-1){
5264 weapons.owner[weaponids[0]]=-1;
5265 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5266 weapons.velocity[weaponids[0]].x+=.01;
5267 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5268 weapons.missed[weaponids[0]]=1;
5269 weapons.hitsomething[weaponids[0]]=0;
5270 weapons.freetime[weaponids[0]]=0;
5271 weapons.firstfree[weaponids[0]]=1;
5272 weapons.physics[weaponids[0]]=1;
5275 weaponids[0]=weaponids[num_weapons];
5276 if(weaponstuck==num_weapons)weaponstuck=0;
5279 for(i=0;i<numplayers;i++){
5280 player[i].wentforweapon=0;
5286 if(!dead&&creature==wolftype){
5287 award_bonus(0, Wolfbonus);
5290 if(unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance)
5291 award_bonus(id, touchofdeath);
5292 if(id!=0&&unconscioustime>.1){
5308 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5309 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5310 OPENAL_SetVolume(channels[breaksound], 512);
5311 OPENAL_SetPaused(channels[breaksound], false);
5312 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5318 if(skeleton.free==1){
5319 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5322 //If knocked over, open hands and close mouth
5323 if(righthandmorphend!=0)righthandmorphness=0;
5324 righthandmorphend=0;
5325 targetrighthandmorphness=1;
5327 if(lefthandmorphend!=0)lefthandmorphness=0;
5329 targetlefthandmorphness=1;
5331 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5332 if(headmorphend!=0)headmorphness=0;
5334 targetheadmorphness=1;
5338 skeleton.DoGravity(&scale);
5340 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5341 if(damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1))
5342 award_bonus(id, deepimpact);
5343 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5347 for(j=0;j<skeleton.num_joints;j++){
5348 average+=skeleton.joints[j].position;
5352 coords+=average*scale;
5353 for(j=0;j<skeleton.num_joints;j++){
5354 skeleton.joints[j].position-=average;
5356 average/=multiplier;
5358 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5360 for(i=0;i<skeleton.num_joints;i++){
5361 velocity+=skeleton.joints[i].velocity*scale;
5363 velocity/=skeleton.num_joints;
5365 if(!isnormal(velocity.x)&&velocity.x){
5378 if(findLength(&average)<10&&dead&&skeleton.free){
5379 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5380 if(skeleton.longdead>2000){
5381 if(skeleton.longdead>6000){
5382 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5387 if(dead==2&&bloodloss<damagetolerance){
5389 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5391 if(bloodtoggle&&!bled){
5392 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5394 if(bloodtoggle&&!bled)
5395 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5396 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5397 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5401 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5405 if(dead==2&&bloodloss>=damagetolerance){
5407 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5408 if(bleeding<=0)DoBlood(1,255);
5409 if(bloodtoggle&&!bled){
5410 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5412 if(bloodtoggle&&!bled)
5413 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5414 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5415 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5419 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5426 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5428 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5432 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5433 if(velocity.y<-30)canrecover=0;
5434 for(i=0;i<objects.numobjects;i++){
5435 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5436 colviewer=startpoint;
5438 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5446 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5447 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5448 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5449 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5451 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5452 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5453 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5455 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5456 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5457 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5459 Normalise(&terrainnormal);
5461 targetrotation=-asin(0-terrainnormal.x);
5462 targetrotation*=360/6.28;
5463 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5464 rotation=targetrotation;
5468 targetanimation=flipanim;
5469 crouchtogglekeydown=1;
5474 currentanimation=tempanim;
5477 //tilt2=targettilt2;
5479 //if(middle.y>0)targetoffset.y=middle.y+1;
5481 for(i=0;i<skeleton.num_joints;i++){
5482 tempanimation.position[i][0]=skeleton.joints[i].position;
5483 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5488 if(findLength(&average)<10&&!dead&&skeleton.free){
5489 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5490 if(skeleton.longdead>(damage+500)*1.5){
5491 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5497 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5498 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5499 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5500 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5502 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5503 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5504 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5506 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5507 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5508 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5510 Normalise(&terrainnormal);
5512 targetrotation=-asin(0-terrainnormal.x);
5513 targetrotation*=360/6.28;
5514 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5515 rotation=targetrotation;
5518 terrainnormal=terrain.getNormal(coords.x,coords.z);
5519 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5523 /*XYZ otherterrainnormal;
5524 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5525 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5526 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5527 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5530 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5534 if(skeleton.forward.y<0){
5535 targetanimation=getupfrombackanim;
5539 if(skeleton.forward.y>-.3){
5540 targetanimation=getupfromfrontanim;
5542 targetrotation+=180;
5548 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5549 targetanimation=rollanim;
5550 targetrotation=lookrotation;
5554 if(forwardkeydown)targetrotation+=45;
5555 if(backkeydown)targetrotation-=45;
5559 if(forwardkeydown)targetrotation-=45;
5560 if(backkeydown)targetrotation+=45;
5563 if ( !leftkeydown&&!rightkeydown)
5564 targetrotation+=180;
5566 targetrotation+=180;
5570 if(abs(targettilt2)>50)targettilt2=0;
5571 currentanimation=tempanim;
5576 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5578 for(i=0;i<skeleton.num_joints;i++){
5579 tempanimation.position[i][0]=skeleton.joints[i].position;
5580 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5587 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5588 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5591 tempvelocity=velocity;
5592 Normalise(&tempvelocity);
5593 targetrotation=-asin(0-tempvelocity.x);
5594 targetrotation*=360/6.28;
5595 if(velocity.z<0)targetrotation=180-targetrotation;
5596 //targetrotation+=180;
5599 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5600 targetanimation=rollanim;
5604 targetanimation=backhandspringanim;
5605 targetrotation+=180;
5618 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
5619 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
5620 OPENAL_SetVolume(channels[movewhooshsound], 128);
5621 OPENAL_SetPaused(channels[movewhooshsound], false);
5623 currentanimation=targetanimation;
5624 currentframe=targetframe-1;
5629 rotation=targetrotation;
5636 if(skeleton.freefall==0)freefall=0;
5638 if(!isnormal(velocity.x)&&velocity.x){
5643 if(aitype!=passivetype||skeleton.free==1)
5644 if(findLengthfast(&velocity)>.1)
5645 for(i=0;i<objects.numobjects;i++){
5646 if(objects.type[i]==firetype)
5647 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){
5649 if(!objects.onfire[i]){
5652 gLoc[0]=objects.position[i].x;
5653 gLoc[1]=objects.position[i].y;
5654 gLoc[2]=objects.position[i].z;
5658 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5659 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5660 OPENAL_SetVolume(channels[firestartsound], 256);
5661 OPENAL_SetPaused(channels[firestartsound], false);
5663 objects.onfire[i]=1;
5666 if(objects.onfire[i]){
5671 if(objects.type[i]==bushtype)
5672 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){
5674 if(!objects.onfire[i]){
5677 gLoc[0]=objects.position[i].x;
5678 gLoc[1]=objects.position[i].y;
5679 gLoc[2]=objects.position[i].z;
5683 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5684 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5685 OPENAL_SetVolume(channels[firestartsound], 256);
5686 OPENAL_SetPaused(channels[firestartsound], false);
5688 objects.onfire[i]=1;
5692 if(objects.onfire[i]){
5696 if(objects.messedwith[i]<=0){
5708 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5709 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5710 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5711 OPENAL_SetPaused(channels[bushrustle], false);
5714 envsound[numenvsounds]=coords;
5715 envsoundvol[numenvsounds]=4*findLength(&velocity);
5716 envsoundlife[numenvsounds]=.4;
5721 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5722 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5724 if(environment!=desertenvironment)
5725 for(j=0;j<howmany;j++){
5726 tempvel.x=float(abs(Random()%100)-50)/20;
5727 tempvel.y=float(abs(Random()%100)-50)/20;
5728 tempvel.z=float(abs(Random()%100)-50)/20;
5731 pos.x+=float(abs(Random()%100)-50)/200;
5732 pos.y+=float(abs(Random()%100)-50)/200;
5733 pos.z+=float(abs(Random()%100)-50)/200;
5734 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);
5735 Sprite::setLastSpriteSpecial(1);
5737 howmany=findLength(&velocity)*4;
5739 if(environment==snowyenvironment)
5740 for(j=0;j<howmany;j++){
5741 tempvel.x=float(abs(Random()%100)-50)/20;
5742 tempvel.y=float(abs(Random()%100)-50)/20;
5743 tempvel.z=float(abs(Random()%100)-50)/20;
5746 pos.x+=float(abs(Random()%100)-50)/200;
5747 pos.y+=float(abs(Random()%100)-50)/200;
5748 pos.z+=float(abs(Random()%100)-50)/200;
5749 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5750 Sprite::setLastSpriteSpecial(2);
5753 objects.rotx[i]+=velocity.x*multiplier*6;
5754 objects.roty[i]+=velocity.z*multiplier*6;
5755 objects.messedwith[i]=.5;
5758 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
5759 if(objects.rotation2[i]==0)tempcoord=coords;
5761 tempcoord=coords-objects.position[i];
5762 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
5763 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
5764 tempcoord+=objects.position[i];
5766 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]){
5767 if(objects.messedwith[i]<=0){
5779 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5780 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5781 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5782 OPENAL_SetPaused(channels[bushrustle], false);
5785 envsound[numenvsounds]=coords;
5786 envsoundvol[numenvsounds]=4*findLength(&velocity);
5787 envsoundlife[numenvsounds]=.4;
5792 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5793 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5795 if(environment!=desertenvironment)
5796 for(j=0;j<howmany;j++){
5797 tempvel.x=float(abs(Random()%100)-50)/20;
5798 tempvel.y=float(abs(Random()%100)-50)/20;
5799 tempvel.z=float(abs(Random()%100)-50)/20;
5803 pos.x+=float(abs(Random()%100)-50)/150;
5804 pos.y+=float(abs(Random()%100)-50)/150;
5805 pos.z+=float(abs(Random()%100)-50)/150;
5806 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);
5807 Sprite::setLastSpriteSpecial(1);
5809 howmany=findLength(&velocity)*4;
5811 if(environment==snowyenvironment)
5812 for(j=0;j<howmany;j++){
5813 tempvel.x=float(abs(Random()%100)-50)/20;
5814 tempvel.y=float(abs(Random()%100)-50)/20;
5815 tempvel.z=float(abs(Random()%100)-50)/20;
5819 pos.x+=float(abs(Random()%100)-50)/150;
5820 pos.y+=float(abs(Random()%100)-50)/150;
5821 pos.z+=float(abs(Random()%100)-50)/150;
5822 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5823 Sprite::setLastSpriteSpecial(2);
5826 objects.messedwith[i]=.5;
5834 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
5836 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
5837 if(tutoriallevel==1&&id!=0)play=0;
5838 if(play&&aitype!=playercontrolled){
5850 if(creature==rabbittype){
5851 if(i==0)whichsound=rabbitchitter;
5852 if(i==1)whichsound=rabbitchitter2;
5854 if(creature==wolftype){
5855 if(i==0)whichsound=growlsound;
5856 if(i==1)whichsound=growl2sound;
5862 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
5863 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
5864 OPENAL_SetVolume(channels[whichsound], 512);
5865 OPENAL_SetPaused(channels[whichsound], false);
5869 if(targetanimation==staggerbackhighanim)staggerdelay=1;
5870 if(targetanimation==staggerbackhardanim)staggerdelay=1;
5871 staggerdelay-=multiplier;
5872 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
5873 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
5874 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
5875 targetanimation=getIdle();
5879 weaponmissdelay-=multiplier;
5880 highreversaldelay-=multiplier;
5881 lowreversaldelay-=multiplier;
5882 lastcollide-=multiplier;
5883 skiddelay-=multiplier;
5884 if(!isnormal(velocity.x)&&velocity.x){
5887 if(!isnormal(targettilt)&&targettilt){
5890 if(!isnormal(targettilt2)&&targettilt2){
5893 if(!isnormal(targetrotation)&&targetrotation){
5897 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
5898 //open hands and close mouth
5899 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
5900 righthandmorphness=0;
5901 righthandmorphend=0;
5902 targetrighthandmorphness=1;
5905 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
5906 lefthandmorphness=0;
5908 targetlefthandmorphness=1;
5911 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
5914 targetheadmorphness=1;
5918 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){
5919 //open hands and mouth
5920 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
5921 righthandmorphness=0;
5922 righthandmorphend=0;
5923 targetrighthandmorphness=1;
5926 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
5927 lefthandmorphness=0;
5929 targetlefthandmorphness=1;
5932 if(headmorphend!=1&&headmorphness==targetheadmorphness){
5935 targetheadmorphness=1;
5939 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
5940 //close hands and mouth
5941 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
5942 righthandmorphness=0;
5943 righthandmorphend=1;
5944 targetrighthandmorphness=1;
5947 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
5948 lefthandmorphness=0;
5950 targetlefthandmorphness=1;
5953 if(headmorphend!=0&&headmorphness==targetheadmorphness){
5956 targetheadmorphness=1;
5960 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){
5961 //close hands and yell
5962 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
5963 righthandmorphness=0;
5964 righthandmorphend=1;
5965 targetrighthandmorphness=1;
5968 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
5969 lefthandmorphness=0;
5971 targetlefthandmorphness=1;
5974 if(headmorphend!=2&&headmorphness==targetheadmorphness){
5977 targetheadmorphness=1;
5981 if(speechdelay>.25){
5982 if(headmorphend!=2)headmorphness=0;
5984 targetheadmorphness=1;
5990 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
5991 behind=(normaldotproduct(facing,coords-victim->coords)>0);
5995 if(!dead&&targetanimation!=hurtidleanim)
5996 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
5997 if(headmorphend!=4||headmorphness==targetheadmorphness){
6000 targetheadmorphness=1;
6004 if(weaponactive!=-1){
6005 if(weapons.type[weaponids[weaponactive]]!=staff){
6006 righthandmorphstart=1;
6007 righthandmorphend=1;
6009 if(weapons.type[weaponids[weaponactive]]==staff){
6010 righthandmorphstart=2;
6011 righthandmorphend=2;
6013 targetrighthandmorphness=1;
6016 terrainnormal=terrain.getNormal(coords.x,coords.z);
6018 if(animation[targetanimation].attack!=reversal){
6019 if(!isnormal(coords.x))
6027 flatfacing=DoRotation(flatfacing,0,rotation,0);
6029 ReflectVector(&facing,terrainnormal);
6032 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6033 if(onterrain)targettilt2=-facing.y*20;
6037 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6038 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6039 flatvelocity=velocity;
6041 flatvelspeed=findLength(&flatvelocity);
6042 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6043 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6044 if(velocity.y<0)targettilt2*=-1;
6045 if(velocity.y<0)targettilt*=-1;
6046 if(targettilt>25)targettilt=25;
6047 if(targettilt<-25)targettilt=-25;
6050 if(targettilt2>45)targettilt2=45;
6051 if(targettilt2<-45)targettilt2=-45;
6052 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6053 else if(tilt2>targettilt2){
6054 tilt2-=multiplier*400;
6056 else if(tilt2<targettilt2){
6057 tilt2+=multiplier*400;
6059 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6060 if(tilt2>25)tilt2=25;
6061 if(tilt2<-25)tilt2=-25;
6064 if(!isnormal(targettilt)&&targettilt){
6067 if(!isnormal(targettilt2)&&targettilt2){
6072 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6073 if(targetanimation==rabbittackleanim){
6074 velocity+=facing*multiplier*speed*700*scale;
6075 velspeed=findLength(&velocity);
6076 if(velspeed>speed*65*scale){
6078 velspeed=speed*65*scale;
6081 velocity.y+=gravity*multiplier*20;
6082 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6083 velspeed=findLength(&velocity);
6084 velocity=flatfacing*velspeed;
6086 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6087 if(isRun()||targetanimation==rabbitkickanim){
6088 velocity+=facing*multiplier*speed*700*scale;
6089 velspeed=findLength(&velocity);
6090 if(velspeed>speed*45*scale){
6092 velspeed=speed*45*scale;
6095 velocity.y+=gravity*multiplier*20;
6096 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6097 velspeed=findLength(&velocity);
6098 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6099 velocity=flatfacing*velspeed;
6103 velocity+=facing*multiplier*speed*700*scale;
6104 velspeed=findLength(&velocity);
6105 if(creature==rabbittype){
6106 if(velspeed>speed*55*scale){
6108 velspeed=speed*55*scale;
6112 if(creature==wolftype){
6113 if(velspeed>speed*75*scale){
6115 velspeed=speed*75*scale;
6119 velocity.y+=gravity*multiplier*20;
6120 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6121 velspeed=findLength(&velocity);
6122 velocity=flatfacing*velspeed;
6125 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6126 velocity+=facing*multiplier*speed*700*scale;
6127 velspeed=findLength(&velocity);
6128 if(velspeed>speed*45*scale){
6130 velspeed=speed*45*scale;
6133 velocity.y+=gravity*multiplier*20;
6134 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6135 velspeed=findLength(&velocity);
6136 velocity=flatfacing*velspeed;
6140 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6141 velocity+=facing*multiplier*speed*700*scale;
6142 velspeed=findLength(&velocity);
6143 if(velspeed>speed*25*scale){
6145 velspeed=speed*25*scale;
6148 velocity.y+=gravity*multiplier*20;
6149 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6150 velspeed=findLength(&velocity);
6151 velocity=flatfacing*velspeed;
6154 if(targetanimation==sneakanim||targetanimation==walkanim){
6155 velocity+=facing*multiplier*speed*700*scale;
6156 velspeed=findLength(&velocity);
6157 if(velspeed>speed*12*scale){
6159 velspeed=speed*12*scale;
6162 velocity.y+=gravity*multiplier*20;
6163 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6164 velspeed=findLength(&velocity);
6165 velocity=flatfacing*velspeed;
6168 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6169 velocity+=facing*multiplier*speed*700*scale;
6170 velspeed=findLength(&velocity);
6171 if(velspeed>speed*2*scale){
6173 velspeed=speed*2*scale;
6176 velocity.y+=gravity*multiplier*20;
6177 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6178 velspeed=findLength(&velocity);
6179 velocity=flatfacing*velspeed;
6183 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6184 velocity-=facing*multiplier*speed*700*scale;
6185 velspeed=findLength(&velocity);
6186 if(velspeed>speed*2*scale){
6188 velspeed=speed*2*scale;
6191 velocity.y+=gravity*multiplier*20;
6192 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6193 velspeed=findLength(&velocity);
6194 velocity=flatfacing*velspeed*-1;
6197 if(targetanimation==fightsidestep){
6198 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6199 velspeed=findLength(&velocity);
6200 if(velspeed>speed*12*scale){
6202 velspeed=speed*12*scale;
6205 velocity.y+=gravity*multiplier*20;
6206 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6207 velspeed=findLength(&velocity);
6208 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6211 if(targetanimation==staggerbackhighanim){
6212 coords-=facing*multiplier*speed*16*scale;
6215 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6216 coords-=facing*multiplier*speed*20*scale;
6220 if(targetanimation==backhandspringanim){
6221 //coords-=facing*multiplier*50*scale;
6222 velocity+=facing*multiplier*speed*700*scale*-1;
6223 velspeed=findLength(&velocity);
6224 if(velspeed>speed*50*scale){
6226 velspeed=speed*50*scale;
6229 velocity.y+=gravity*multiplier*20;
6230 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6231 velspeed=findLength(&velocity);
6232 velocity=flatfacing*velspeed*-1;
6234 if(targetanimation==dodgebackanim){
6235 //coords-=facing*multiplier*50*scale;
6236 velocity+=facing*multiplier*speed*700*scale*-1;
6237 velspeed=findLength(&velocity);
6238 if(velspeed>speed*60*scale){
6240 velspeed=speed*60*scale;
6243 velocity.y+=gravity*multiplier*20;
6244 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6245 velspeed=findLength(&velocity);
6246 velocity=flatfacing*velspeed*-1;
6249 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6250 velspeed=findLength(&velocity);
6254 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6255 velocity.y+=gravity*multiplier;
6258 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6260 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6261 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6263 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6269 OPENAL_SetPaused(channels[whooshsound], true);
6270 OPENAL_SetVolume(channels[whooshsound], 0);
6273 if(targetanimation==jumpdownanim||isFlip()){
6274 if(isFlip())jumppower=-4;
6275 targetanimation=getLanding();
6284 PlaySoundEx( landsound, samp[landsound], NULL, true);
6285 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6286 OPENAL_SetVolume(channels[landsound], 128);
6287 OPENAL_SetPaused(channels[landsound], false);
6290 envsound[numenvsounds]=coords;
6291 envsoundvol[numenvsounds]=16;
6292 envsoundlife[numenvsounds]=.4;
6298 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6299 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6300 coords.y=terrain.getHeight(coords.x,coords.z);
6305 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)){
6306 velspeed=findLength(&velocity);
6308 if(velspeed<multiplier*300*scale){
6310 } else velocity-=velocity/velspeed*multiplier*300*scale;
6311 if(velspeed>5&&(isLanding()||isLandhard())){
6312 skiddingdelay+=multiplier;
6319 else skiddingdelay=0;
6323 velspeed=findLength(&velocity);
6325 if(velspeed<multiplier*600*scale){
6327 } else velocity-=velocity/velspeed*multiplier*600*scale;
6329 if(velspeed>5&&(isLanding()||isLandhard())){
6330 skiddingdelay+=multiplier;
6337 else skiddingdelay=0;
6340 if(skiddingdelay<0)skiddingdelay+=multiplier;
6341 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6351 if(!onterrain||environment==grassyenvironment){
6352 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6353 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6354 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6355 OPENAL_SetPaused(channels[skidsound], false);
6358 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6359 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6360 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6361 OPENAL_SetPaused(channels[snowskidsound], false);
6365 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6366 terrainnormal=victim->coords-coords;
6367 Normalise(&terrainnormal);
6368 targetrotation=-asin(0-terrainnormal.x);
6369 targetrotation*=360/6.28;
6370 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6371 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6374 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6375 targetrotation=victim->targetrotation;
6377 if(targetanimation==rabbittacklinganim){
6378 coords=victim->coords;
6381 skeleton.oldfree=skeleton.free;
6385 midterrain.x=terrain.size*terrain.scale/2;
6386 midterrain.z=terrain.size*terrain.scale/2;
6387 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6389 tempposit=coords-midterrain;
6391 Normalise(&tempposit);
6392 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6393 coords.x=tempposit.x+midterrain.x;
6394 coords.z=tempposit.z+midterrain.z;
6398 int Person::DrawSkeleton(){
6399 int oldplayerdetail;
6400 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6401 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6411 glAlphaFunc(GL_GREATER, 0.0001);
6413 float terrainheight;
6415 if(!isnormal(rotation))rotation=0;
6416 if(!isnormal(tilt))tilt=0;
6417 if(!isnormal(tilt2))tilt2=0;
6418 oldplayerdetail=playerdetail;
6420 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6423 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6426 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6431 if(playerdetail!=oldplayerdetail) {
6433 normalsupdatedelay=0;
6435 static float updatedelaychange;
6436 static float morphness;
6437 static float framemult;
6439 skeleton.FindForwards();
6440 if(howactive==typesittingwall){
6441 skeleton.specialforward[1]=0;
6442 skeleton.specialforward[1].z=1;
6448 static int weaponattachmuscle;
6449 static int weaponrotatemuscle,weaponrotatemuscle2;
6450 static XYZ weaponpoint;
6451 static int start,endthing;
6452 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6453 if(!isSleeping()&&!isSitting()){
6454 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6455 XYZ point,newpoint,change,change2;
6456 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6457 heightleft=terrain.getHeight(point.x,point.z)+.04;
6459 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6460 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6461 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6462 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6463 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6465 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6466 heightright=terrain.getHeight(point.x,point.z)+.04;
6467 point.y=heightright;
6468 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6469 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6470 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6471 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6472 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6473 skeleton.DoConstraints(&coords,&scale);
6475 if(creature==wolftype){
6476 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6477 heightleft=terrain.getHeight(point.x,point.z)+.04;
6479 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6480 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6481 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6482 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6483 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6485 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6486 heightright=terrain.getHeight(point.x,point.z)+.04;
6487 point.y=heightright;
6488 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6489 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6490 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6491 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6492 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6493 skeleton.DoConstraints(&coords,&scale);
6496 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6497 XYZ point,newpoint,change,change2;
6498 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6499 heightleft=terrain.getHeight(point.x,point.z)+.04;
6501 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6502 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6503 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6504 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6505 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6507 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6508 heightright=terrain.getHeight(point.x,point.z)+.04;
6509 point.y=heightright;
6510 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6511 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6512 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6513 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6514 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6515 skeleton.DoConstraints(&coords,&scale);
6517 if(creature==wolftype){
6518 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6519 heightleft=terrain.getHeight(point.x,point.z)+.04;
6521 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6522 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6523 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6524 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6525 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6527 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6528 heightright=terrain.getHeight(point.x,point.z)+.04;
6529 point.y=heightright;
6530 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6531 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6532 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6533 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6534 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6535 skeleton.DoConstraints(&coords,&scale);
6539 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6540 XYZ point,newpoint,change,change2;
6541 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6542 heightleft=terrain.getHeight(point.x,point.z)+.04;
6544 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6545 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6546 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6547 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6548 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6550 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6551 heightright=terrain.getHeight(point.x,point.z)+.04;
6552 point.y=heightright;
6553 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6554 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6555 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6556 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6557 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6558 skeleton.DoConstraints(&coords,&scale);
6560 if(creature==wolftype){
6561 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6562 heightleft=terrain.getHeight(point.x,point.z)+.04;
6564 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6565 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6566 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6567 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6568 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6570 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6571 heightright=terrain.getHeight(point.x,point.z)+.04;
6572 point.y=heightright;
6573 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6574 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6575 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6576 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6577 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6578 skeleton.DoConstraints(&coords,&scale);
6582 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()))
6585 targetheadrotation=-targetrotation;
6586 targetheadrotation2=0;
6587 if(animation[targetanimation].attack==3)targetheadrotation+=180;
6589 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6590 skeleton.drawmodel.vertex[i]=0;
6591 skeleton.drawmodel.vertex[i].y=999;
6593 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
6594 skeleton.drawmodellow.vertex[i]=0;
6595 skeleton.drawmodellow.vertex[i].y=999;
6597 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
6598 skeleton.drawmodelclothes.vertex[i]=0;
6599 skeleton.drawmodelclothes.vertex[i].y=999;
6601 for(i=0;i<skeleton.num_muscles;i++){
6602 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
6606 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
6607 morphness=righthandmorphness;
6608 start=righthandmorphstart;
6609 endthing=righthandmorphend;
6611 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
6612 morphness=lefthandmorphness;
6613 start=lefthandmorphstart;
6614 endthing=lefthandmorphend;
6616 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
6617 morphness=headmorphness;
6618 start=headmorphstart;
6619 endthing=headmorphend;
6621 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)){
6622 morphness=chestmorphness;
6623 start=chestmorphstart;
6624 endthing=chestmorphend;
6626 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)){
6627 morphness=tailmorphness;
6628 start=tailmorphstart;
6629 endthing=tailmorphend;
6631 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
6632 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6633 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6636 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6637 if(!skeleton.free)glRotatef(tilt,0,0,1);
6640 glTranslatef(mid.x,mid.y,mid.z);
6642 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6643 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6645 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6646 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6648 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6649 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6651 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
6655 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
6659 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
6663 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
6668 if(playerdetail||skeleton.free==3)
6670 for(j=0;j<skeleton.muscles[i].numvertices;j++)
6672 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
6673 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
6674 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
6675 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
6676 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
6677 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
6678 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
6679 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6681 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6682 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,
6683 (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,
6684 (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);
6685 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)
6686 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,
6687 (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,
6688 (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);
6689 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)
6690 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,
6691 (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,
6692 (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);
6693 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6694 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,
6695 (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,
6696 (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);
6697 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6698 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
6699 //if(!isnormal(scale))test=1;
6700 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
6701 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
6702 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
6707 if(!playerdetail||skeleton.free==3)
6709 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
6711 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6713 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6714 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
6715 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
6716 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
6717 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)
6718 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
6719 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
6720 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
6721 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)
6722 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
6723 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
6724 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
6725 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6726 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
6727 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
6728 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
6730 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6731 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
6732 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
6733 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
6739 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
6740 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6742 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6745 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6746 if(!skeleton.free)glRotatef(tilt,0,0,1);
6747 glTranslatef(mid.x,mid.y,mid.z);
6748 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6749 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6751 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6752 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6754 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6755 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6757 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
6758 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6760 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6761 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
6762 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
6763 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
6764 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)
6765 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
6766 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
6767 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
6768 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)
6769 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
6770 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
6771 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
6772 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6773 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
6774 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
6775 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
6776 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6777 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
6778 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
6779 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
6784 updatedelay=1+(float)(Random()%100)/1000;
6786 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
6787 normalsupdatedelay=1;
6788 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
6789 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
6790 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
6794 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
6795 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
6796 if(skeleton.clothes){
6797 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
6802 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
6803 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
6804 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
6805 if(skeleton.free==1)updatedelaychange*=6;
6806 if(id==0)updatedelaychange*=8;
6807 updatedelay+=updatedelaychange;
6809 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6811 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
6812 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
6813 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
6814 if(!skeleton.free)glRotatef(rotation,0,1,0);
6817 glColor4f(.4,1,.4,1);
6818 glDisable(GL_LIGHTING);
6819 glDisable(GL_TEXTURE_2D);
6822 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6823 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
6829 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
6830 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);
6831 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);
6832 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);
6833 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);
6834 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);
6835 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);
6841 terrainlight=terrain.getLighting(coords.x,coords.z);
6842 distance=findDistancefast(&viewer,&coords);
6843 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
6844 if(distance>1)distance=1;
6846 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
6847 if(terrainheight<1)terrainheight=1;
6848 if(terrainheight>1.7)terrainheight=1.7;
6851 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
6852 glDisable(GL_BLEND);
6853 glAlphaFunc(GL_GREATER, 0.0001);
6854 glEnable(GL_TEXTURE_2D);
6856 glDisable(GL_TEXTURE_2D);
6857 glColor4f(.7,.35,0,.5);
6859 glEnable(GL_LIGHTING);
6862 if(tutoriallevel&&id!=0){
6863 //glDisable(GL_TEXTURE_2D);
6864 glColor4f(.7,.7,.7,0.6);
6866 glEnable(GL_LIGHTING);
6868 if(canattack&&cananger)
6869 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
6870 glDisable(GL_TEXTURE_2D);
6871 glColor4f(1,0,0,0.8);
6873 glMatrixMode(GL_TEXTURE);
6875 glTranslatef(0,-smoketex,0);
6876 glTranslatef(-smoketex,0,0);
6880 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
6881 else skeleton.drawmodel.draw();
6885 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
6886 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
6889 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
6890 if(tutoriallevel&&id!=0){
6892 glMatrixMode(GL_MODELVIEW);
6893 glEnable(GL_TEXTURE_2D);
6894 glColor4f(.7,.7,.7,0.6);
6896 glEnable(GL_LIGHTING);
6898 if(canattack&&cananger)
6899 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
6900 glDisable(GL_TEXTURE_2D);
6901 glColor4f(1,0,0,0.8);
6903 glMatrixMode(GL_TEXTURE);
6905 glTranslatef(0,-smoketex*.6,0);
6906 glTranslatef(smoketex*.6,0,0);
6909 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
6910 else skeleton.drawmodel.draw();
6914 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
6915 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
6920 if(tutoriallevel&&id!=0){
6922 glMatrixMode(GL_MODELVIEW);
6923 glEnable(GL_TEXTURE_2D);
6925 if(skeleton.clothes){
6928 if(!immediate)skeleton.drawmodelclothes.draw();
6929 if(immediate)skeleton.drawmodelclothes.drawimmediate();
6936 for(k=0;k<num_weapons;k++){
6938 if(weaponactive==k){
6939 if(weapons.type[i]!=staff){
6940 for(j=0;j<skeleton.num_muscles;j++){
6941 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
6942 weaponattachmuscle=j;
6945 for(j=0;j<skeleton.num_muscles;j++){
6946 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){
6947 weaponrotatemuscle=j;
6950 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
6951 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
6953 if(weapons.type[i]==staff){
6954 for(j=0;j<skeleton.num_muscles;j++){
6955 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
6956 weaponattachmuscle=j;
6959 for(j=0;j<skeleton.num_muscles;j++){
6960 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){
6961 weaponrotatemuscle=j;
6964 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
6965 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
6966 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
6967 XYZ tempnormthing,vec1,vec2;
6968 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
6969 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
6970 CrossProduct(&vec1,&vec2,&tempnormthing);
6971 Normalise(&tempnormthing);
6972 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);
6973 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
6975 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
6976 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6977 Normalise(&weaptargnorm);
6978 weaponpoint-=weaptargnorm*2;
6982 if(weaponactive!=k&&weaponstuck!=k){
6983 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;
6984 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;
6985 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;
6986 for(j=0;j<skeleton.num_muscles;j++){
6987 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){
6988 weaponrotatemuscle=j;
6993 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
6994 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
6995 for(j=0;j<skeleton.num_muscles;j++){
6996 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){
6997 weaponrotatemuscle=j;
7002 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;
7003 weapons.bigrotation[i]=rotation;
7004 weapons.bigtilt[i]=tilt;
7005 weapons.bigtilt2[i]=tilt2;
7008 weapons.position[i]=weaponpoint*scale+coords;
7009 weapons.bigrotation[i]=0;
7010 weapons.bigtilt[i]=0;
7011 weapons.bigtilt2[i]=0;
7013 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7014 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7015 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7016 if(weaponactive==k){
7017 if(weapons.type[i]==knife){
7018 weapons.smallrotation[i]=180;
7019 weapons.smallrotation2[i]=0;
7020 if(isCrouch()||wasCrouch()){
7021 weapons.smallrotation2[i]=20;
7023 if(targetanimation==hurtidleanim){
7024 weapons.smallrotation2[i]=50;
7026 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7027 XYZ temppoint1,temppoint2,tempforward;
7030 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7031 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7032 distance=findDistance(&temppoint1,&temppoint2);
7033 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7034 weapons.rotation2[i]*=360/6.28;
7037 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7038 weapons.rotation1[i]*=360/6.28;
7039 weapons.rotation3[i]=0;
7040 weapons.smallrotation[i]=-90;
7041 weapons.smallrotation2[i]=0;
7042 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7044 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7045 XYZ temppoint1,temppoint2,tempforward;
7048 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7049 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7050 distance=findDistance(&temppoint1,&temppoint2);
7051 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7052 weapons.rotation2[i]*=360/6.28;
7055 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7056 weapons.rotation1[i]*=360/6.28;
7057 weapons.rotation3[i]=0;
7058 weapons.smallrotation[i]=90;
7059 weapons.smallrotation2[i]=0;
7060 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7062 if(targetanimation==knifethrowanim){
7063 weapons.smallrotation[i]=90;
7064 //weapons.smallrotation2[i]=-90;
7065 weapons.smallrotation2[i]=0;
7066 weapons.rotation1[i]=0;
7067 weapons.rotation2[i]=0;
7068 weapons.rotation3[i]=0;
7070 if(targetanimation==knifesneakattackanim&&targetframe<5){
7071 weapons.smallrotation[i]=-90;
7072 weapons.rotation1[i]=0;
7073 weapons.rotation2[i]=0;
7074 weapons.rotation3[i]=0;
7077 if(weapons.type[i]==sword){
7078 weapons.smallrotation[i]=0;
7079 weapons.smallrotation2[i]=0;
7080 if(targetanimation==knifethrowanim){
7081 weapons.smallrotation[i]=-90;
7082 weapons.smallrotation2[i]=0;
7083 weapons.rotation1[i]=0;
7084 weapons.rotation2[i]=0;
7085 weapons.rotation3[i]=0;
7087 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)){
7088 XYZ temppoint1,temppoint2,tempforward;
7091 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7092 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7093 distance=findDistance(&temppoint1,&temppoint2);
7094 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7095 weapons.rotation2[i]*=360/6.28;
7098 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7099 weapons.rotation1[i]*=360/6.28;
7100 weapons.rotation3[i]=0;
7101 weapons.smallrotation[i]=90;
7102 weapons.smallrotation2[i]=0;
7103 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7106 if(weapons.type[i]==staff){
7107 weapons.smallrotation[i]=100;
7108 weapons.smallrotation2[i]=0;
7109 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7110 XYZ temppoint1,temppoint2,tempforward;
7113 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7114 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7115 distance=findDistance(&temppoint1,&temppoint2);
7116 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7117 weapons.rotation2[i]*=360/6.28;
7120 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7121 weapons.rotation1[i]*=360/6.28;
7122 weapons.rotation3[i]=0;
7123 weapons.smallrotation[i]=90;
7124 weapons.smallrotation2[i]=0;
7125 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7129 if(weaponactive!=k&&weaponstuck!=k){
7130 if(weapons.type[i]==knife){
7131 weapons.smallrotation[i]=-70;
7132 weapons.smallrotation2[i]=10;
7134 if(weapons.type[i]==sword){
7135 weapons.smallrotation[i]=-100;
7136 weapons.smallrotation2[i]=-8;
7138 if(weapons.type[i]==staff){
7139 weapons.smallrotation[i]=-100;
7140 weapons.smallrotation2[i]=-8;
7144 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7145 else weapons.smallrotation[i]=0;
7146 weapons.smallrotation2[i]=10;
7153 if(skeleton.free)calcrot=1;
7154 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7155 if(currentanimation!=targetanimation)calcrot=1;
7156 //if(id==0)calcrot=1;
7157 if(skeleton.free==2)calcrot=0;
7163 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7166 static float distance;
7167 static float olddistance;
7168 static int intersecting;
7169 static int firstintersecting;
7172 static XYZ start,end;
7173 static float slopethreshold=-.4;
7175 firstintersecting=-1;
7179 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7180 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7182 for (j=0;j<model->TriangleNum;j++){
7183 if(model->facenormals[j].y<=slopethreshold){
7185 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)));
7186 if(distance<radius){
7187 point=*p1-model->facenormals[j]*distance;
7188 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;
7189 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7190 &model->vertex[model->Triangles[j].vertex[1]],
7192 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7193 &model->vertex[model->Triangles[j].vertex[2]],
7195 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7196 &model->vertex[model->Triangles[j].vertex[2]],
7199 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7203 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)){
7204 p1->y=point.y+radius;
7205 if((targetanimation==jumpdownanim||isFlip())){
7206 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7208 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7214 OPENAL_SetPaused(channels[whooshsound], true);
7215 OPENAL_SetVolume(channels[whooshsound], 0);
7218 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7219 if(isFlip())jumppower=-4;
7220 targetanimation=getLanding();
7229 PlaySoundEx( landsound, samp[landsound], NULL, true);
7230 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7231 OPENAL_SetVolume(channels[landsound], 128);
7232 OPENAL_SetPaused(channels[landsound], false);
7235 envsound[numenvsounds]=coords;
7236 envsoundvol[numenvsounds]=16;
7237 envsoundlife[numenvsounds]=.4;
7245 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7248 for (j=0;j<model->TriangleNum;j++){
7249 if(model->facenormals[j].y>slopethreshold){
7253 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)));
7254 if(distance<radius*.5){
7255 point=start-model->facenormals[j]*distance;
7256 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;
7257 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,
7258 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7259 p1->x, p1->y, p1->z, radius/2);
7260 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,
7261 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7262 p1->x, p1->y, p1->z, radius/2);
7263 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,
7264 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7265 p1->x, p1->y, p1->z, radius/2);
7267 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7268 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7270 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7271 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7273 *p1+=model->facenormals[j]*(distance-radius*.5);
7276 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7280 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7282 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7284 return firstintersecting;
7294 currentanimation = 0;
7295 targetanimation = 0;
7296 oldcurrentframe = 0;
7298 oldcurrentanimation = 0;
7299 oldtargetanimation = 0;
7303 parriedrecently = 0;
7307 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7309 currentoffset = 0,targetoffset = 0,offset = 0;
7327 unconscioustime = 0;
7345 rabbitkickenabled = 0;
7354 damagetolerance = 0;
7356 permanentdamage = 0;
7357 superpermanentdamage = 0; lastcollide = 0;
7377 headrotation = 0,headrotation2 = 0;
7378 targetheadrotation = 0,targetheadrotation2 = 0;
7389 normalsupdatedelay = 0;
7394 forwardstogglekeydown = 0;
7399 jumptogglekeydown = 0;
7401 crouchtogglekeydown = 0;
7403 drawtogglekeydown = 0;
7405 throwtogglekeydown = 0;
7411 crouchkeydowntime = 0;
7412 jumpkeydowntime = 0;
7429 whichdirectiondelay = 0;
7430 avoidsomething = 0; avoidwhere = 0;
7438 lefthandmorphness = 0;
7439 righthandmorphness = 0;
7443 targetlefthandmorphness = 0;
7444 targetrighthandmorphness = 0;
7445 targetheadmorphness = 0;
7446 targetchestmorphness = 0;
7447 targettailmorphness = 0;
7448 lefthandmorphstart = 0,lefthandmorphend = 0;
7449 righthandmorphstart = 0,righthandmorphend = 0;
7450 headmorphstart = 0,headmorphend = 0;
7451 chestmorphstart = 0,chestmorphend = 0;
7452 tailmorphstart = 0,tailmorphend = 0;
7454 weaponmissdelay = 0;
7455 highreversaldelay = 0;
7456 lowreversaldelay = 0;
7463 //Skeleton skeleton;
7482 memset(clothes, 0, sizeof(clothes));
7483 memset(clothestintr, 0, sizeof(clothestintr));
7484 memset(clothestintg, 0, sizeof(clothestintg));
7485 memset(clothestintb, 0, sizeof(clothestintb));
7491 onfiredelay = 0; burnt = 0;
7495 updatestuffdelay = 0;
7501 memset(weaponids, 0, sizeof(weaponids));
7505 weaponstuckwhere = 0;
7510 memset(waypoints, 0, sizeof(waypoints));
7511 memset(waypointtype, 0, sizeof(waypointtype));
7514 hastempwaypoint = 0;
7520 finalfinaltarget = 0;
7522 finalpathfindpoint = 0;
7523 targetpathfindpoint = 0;
7524 lastpathfindpoint = 0;
7525 lastpathfindpoint2 = 0;
7526 lastpathfindpoint3 = 0;
7527 lastpathfindpoint4 = 0;
7538 runninghowlong = 0; lastoccluded = 0;
7544 neckspurtparticledelay = 0;
7545 neckspurtamount = 0;
7548 rabbitkickragdoll = 0;
7553 //Animation tempanimation;