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;
76 extern float bonusvalue;
77 extern float bonustotal;
78 extern float bonustime;
79 extern int tutoriallevel;
80 extern float smoketex;
81 extern int tutorialstage;
82 extern bool reversaltrain;
83 extern bool canattack;
85 extern float damagedealt;
87 extern float hostiletime;
89 extern int indialogue;
91 extern bool gamestarted;
93 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
94 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
96 void Person::CheckKick(){
100 float damagemult=1*power;
101 if(creature==wolftype)damagemult=2.5*power;
105 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
106 if(findDistancefast(&coords,&victim->coords)<1.2){
107 if(!victim->skeleton.free){
109 Normalise(&relative);
110 relative=coords+relative*1;
111 if(animation[victim->targetanimation].height!=lowheight){
116 gLoc[0]=victim->coords.x;
117 gLoc[1]=victim->coords.y;
118 gLoc[2]=victim->coords.z;
122 if(tutoriallevel!=1){
123 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
124 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
125 OPENAL_SetVolume(channels[heavyimpactsound], 128);
126 OPENAL_SetPaused(channels[heavyimpactsound], false);
131 Normalise(&relative);
132 for(i=0;i<victim->skeleton.num_joints;i++){
133 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
136 victim->DoDamage(100*damagemult/victim->protectionhigh);
137 if(id==0)camerashake+=.4;
141 targetanimation=backflipanim;
146 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
148 //if(victim->damage>victim->damagetolerance){
156 else if (victim->isCrouch()){
157 targetanimation=rabbitkickreversedanim;
158 currentanimation=rabbitkickreversedanim;
159 victim->currentanimation=rabbitkickreversalanim;
160 victim->targetanimation=rabbitkickreversalanim;
166 victim->oldcoords=victim->coords;
167 coords=victim->coords;
168 victim->targetrotation=targetrotation;
176 void Person::CatchFire(){
177 XYZ flatfacing,flatvelocity;
179 for(int i=0;i<10;i++){
180 howmany=abs(Random()%(skeleton.num_joints));
181 if(!skeleton.free)flatvelocity=velocity;
182 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
183 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
184 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
185 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
198 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
199 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
200 OPENAL_SetVolume(channels[firestartsound], 256);
201 OPENAL_SetPaused(channels[firestartsound], false);
206 //PlaySoundEx( firesound, samp[firesound], NULL, true);
207 PlayStreamEx( stream_firesound, samp[stream_firesound], NULL, true);
208 OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
209 OPENAL_SetVolume(channels[stream_firesound], 256);
210 OPENAL_SetPaused(channels[stream_firesound], false);
217 bool Person::isIdle(){
218 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;
222 bool Person::isSitting(){
223 if(targetanimation==sitanim)return 1;
224 if(targetanimation==sitwallanim)return 1;
228 bool Person::isSleeping(){
229 if(targetanimation==sleepanim)return 1;
230 if(targetanimation==dead1anim)return 1;
231 if(targetanimation==dead2anim)return 1;
232 if(targetanimation==dead3anim)return 1;
233 if(targetanimation==dead4anim)return 1;
237 bool Person::wasIdle(){
238 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;
241 int Person::getIdle(){
242 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
243 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)){
244 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
245 if(creature==rabbittype)return fightidleanim;
246 if(creature==wolftype)return wolfidle;
248 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
249 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
250 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
251 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
252 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
254 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
256 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
257 if(howactive==typesitting)return sitanim;
258 if(howactive==typesittingwall)return sitwallanim;
259 if(howactive==typesleeping)return sleepanim;
260 if(howactive==typedead1)return dead1anim;
261 if(howactive==typedead2)return dead2anim;
262 if(howactive==typedead3)return dead3anim;
263 if(howactive==typedead4)return dead4anim;
264 if(creature==rabbittype)return bounceidleanim;
265 if(creature==wolftype)return wolfidle;
269 bool Person::isCrouch(){
270 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
275 bool Person::wasCrouch(){
276 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
279 int Person::getCrouch(){
280 if(creature==rabbittype)return crouchanim;
281 if(creature==wolftype)return wolfcrouchanim;
285 bool Person::isRun(){
286 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
291 bool Person::wasRun(){
292 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
295 int Person::getRun(){
296 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
297 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
299 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
300 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
304 bool Person::isStop(){
305 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
310 bool Person::wasStop(){
311 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
314 int Person::getStop(){
315 if(creature==rabbittype)return stopanim;
316 if(creature==wolftype)return wolfstopanim;
321 bool Person::isLanding(){
322 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
327 bool Person::wasLanding(){
328 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
331 int Person::getLanding(){
332 if(creature==rabbittype)return landanim;
333 if(creature==wolftype)return wolflandanim;
338 bool Person::isLandhard(){
339 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
344 bool Person::wasLandhard(){
345 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
348 int Person::getLandhard(){
349 if(creature==rabbittype)return landhardanim;
350 if(creature==wolftype)return wolflandhardanim;
355 bool Person::isFlip(){
356 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
360 bool Person::wasFlip(){
361 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
365 bool Person::isWallJump(){
366 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
370 void SolidHitBonus();
371 void SolidHitBonus(){
372 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
377 else if(bonustime<1.5&&bonus==threexcombo){
382 else if(bonustime<1.5&&bonus==twoxcombo){
387 else if(bonustime<1.5&&bonus==solidhit){
399 void Person::DoBlood(float howmuch,int which){
400 static int bleedxint,bleedyint;
402 //if(howmuch&&id==0)blooddimamount=1;
403 if(bloodtoggle&&tutoriallevel!=1){
404 if(bleeding<=0&&spurt){
406 for(int i=0;i<3;i++){
410 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
413 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
415 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
416 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
418 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
419 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
422 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);
423 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);
427 for(int i=0;i<3;i++){
431 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
432 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
435 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
436 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
440 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
442 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);
444 Sprite::setLastSpriteSpecial(3);
449 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
452 int texdetailint=realtexdetail;
453 if(creature==rabbittype)
454 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){
455 bleedxint=abs(Random()%512);
456 bleedyint=abs(Random()%512);
458 if(creature==wolftype)
459 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){
460 bleedxint=abs(Random()%512);
461 bleedyint=abs(Random()%512);
465 bleedy/=realtexdetail;
466 bleedx/=realtexdetail;
467 direction=abs(Random()%2)*2-1;
471 if(bleeding>2)bleeding=2;
474 void Person::DoBloodBig(float howmuch,int which){
475 static int bleedxint,bleedyint,i,j;
477 if(howmuch&&id==0)blooddimamount=1;
479 if(tutoriallevel!=1||id==0)
480 if(aitype!=playercontrolled&&howmuch>0){
491 if(creature==wolftype){
492 int i=abs(Random()%2);
493 if(i==0)whichsound=snarlsound;
494 if(i==1)whichsound=snarl2sound;
495 envsound[numenvsounds]=coords;
496 envsoundvol[numenvsounds]=16;
497 envsoundlife[numenvsounds]=.4;
500 if(creature==rabbittype){
501 int i=abs(Random()%2);
502 if(i==0)whichsound=rabbitpainsound;
503 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
504 envsound[numenvsounds]=coords;
505 envsoundvol[numenvsounds]=16;
506 envsoundlife[numenvsounds]=.4;
508 //if(i==2)whichsound=rabbitpain2sound;
512 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
513 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
514 OPENAL_SetVolume(channels[whichsound], 512);
515 OPENAL_SetPaused(channels[whichsound], false);
519 if(id==0&&howmuch>0){
527 if(bloodtoggle&&decals&&tutoriallevel!=1){
528 if(bleeding<=0&&spurt){
530 for(int i=0;i<3;i++){
534 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
537 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
539 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
540 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
542 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
543 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
546 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);
547 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);
551 int offsetx=0,offsety=0;
554 offsetx=abs(Random()%60);
556 if(which==190||which==185){
558 offsetx=abs(Random()%100)-20;
568 if(which==220||which==215){
569 //offsety=Random()%20;
571 //offsetx=abs(Random()%80);
580 if(creature==rabbittype)
583 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
584 if(i<startx)startx=i;
585 if(j<starty)starty=j;
591 if(creature==wolftype)
594 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
595 if(i<startx)startx=i;
596 if(j<starty)starty=j;
608 if(startx<0)startx=0;
609 if(starty<0)starty=0;
610 if(endx>512-1)endx=512-1;
611 if(endy>512-1)endy=512-1;
612 if(endx<startx)endx=startx;
613 if(endy<starty)endy=starty;
615 startx/=realtexdetail;
616 starty/=realtexdetail;
620 int texdetailint=realtexdetail;
622 if(creature==rabbittype)
623 for(i=startx;i<endx;i++){
624 for(j=starty;j<endy;j++){
625 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){
626 color=Random()%85+170;
627 where=i*skeleton.skinsize*3+j*3;
628 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
629 skeleton.skinText[where+1]=0;
630 skeleton.skinText[where+2]=0;
634 if(creature==wolftype)
635 for(i=startx;i<endx;i++){
636 for(j=starty;j<endy;j++){
637 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){
638 color=Random()%85+170;
639 where=i*skeleton.skinsize*3+j*3;
640 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
641 skeleton.skinText[where+1]=0;
642 skeleton.skinText[where+2]=0;
646 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
647 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
648 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
652 if(creature==rabbittype)
653 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){
654 bleedxint=abs(Random()%512);
655 bleedyint=abs(Random()%512);
657 if(creature==wolftype)
658 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){
659 bleedxint=abs(Random()%512);
660 bleedyint=abs(Random()%512);
662 bleedy=bleedxint+offsetx;
663 bleedx=bleedyint+offsety;
664 bleedy/=realtexdetail;
665 bleedx/=realtexdetail;
666 if(bleedx<0)bleedx=0;
667 if(bleedy<0)bleedy=0;
668 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
669 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
670 direction=abs(Random()%2)*2-1;
673 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
674 deathbleeding+=bleeding;
675 bloodloss+=bleeding*3;
677 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
678 if(abs(Random()%2)==0){aitype=gethelptype;
681 else aitype=attacktypecutoff;
684 if(bleeding>2)bleeding=2;
687 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
688 static int bleedxint,bleedyint,i,j;
690 static XYZ startpoint,endpoint,colpoint,movepoint;
691 static float rotationpoint;
693 static XYZ p1,p2,p3,p0;
697 float coordsx,coordsy;
700 if(bloodtoggle&&decals&&tutoriallevel!=1){
702 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
710 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
713 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
714 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
715 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
717 CrossProduct(p2-p1,p3-p1,&N);
718 CrossProduct(p0-p1,p3-p1,&temp);
719 s = dotproduct(&temp,&N)/findLength(&N);
720 CrossProduct(p2-p1,p1-p0,&temp);
721 t = dotproduct(&temp,&N)/findLength(&N);
724 bary.x=findDistancefast(&p0,&p1);
725 bary.y=findDistancefast(&p0,&p2);
726 bary.z=findDistancefast(&p0,&p3);
728 total=bary.x+bary.y+bary.z;
737 total=bary.x+bary.y+bary.z;
743 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
744 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
745 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
746 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
747 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
748 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
749 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;
750 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;
752 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
753 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
755 if(bleeding<=0&&spurt){
757 for(int i=0;i<3;i++){
761 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
764 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
766 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
767 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
769 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
770 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
773 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);
774 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);
778 int offsetx=0,offsety=0;
781 offsetx=abs(Random()%120);
783 if(which==220||which==215){
785 offsetx=abs(Random()%80);
788 offsetx=(1+coordsy)*512-291;
789 offsety=coordsx*512-437;
796 if(creature==rabbittype)
799 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
800 if(i<startx)startx=i;
801 if(j<starty)starty=j;
807 if(creature==wolftype)
810 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
811 if(i<startx)startx=i;
812 if(j<starty)starty=j;
823 if(startx<0)startx=0;
824 if(starty<0)starty=0;
825 if(endx>512-1)endx=512-1;
826 if(endy>512-1)endy=512-1;
827 if(endx<startx)endx=startx;
828 if(endy<starty)endy=starty;
830 startx/=realtexdetail;
831 starty/=realtexdetail;
835 int texdetailint=realtexdetail;
837 if(creature==rabbittype)
838 for(i=startx;i<endx;i++){
839 for(j=starty;j<endy;j++){
840 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){
841 color=Random()%85+170;
842 where=i*skeleton.skinsize*3+j*3;
843 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
844 skeleton.skinText[where+1]=0;
845 skeleton.skinText[where+2]=0;
847 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){
848 color=Random()%85+170;
849 where=i*skeleton.skinsize*3+j*3;
850 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
851 skeleton.skinText[where+1]=0;
852 skeleton.skinText[where+2]=0;
856 if(creature==wolftype)
857 for(i=startx;i<endx;i++){
858 for(j=starty;j<endy;j++){
859 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){
860 color=Random()%85+170;
861 where=i*skeleton.skinsize*3+j*3;
862 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
863 skeleton.skinText[where+1]=0;
864 skeleton.skinText[where+2]=0;
866 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){
867 color=Random()%85+170;
868 where=i*skeleton.skinsize*3+j*3;
869 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
870 skeleton.skinText[where+1]=0;
871 skeleton.skinText[where+2]=0;
875 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
876 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
877 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
879 bleedy=(1+coordsy)*512;
881 bleedy/=realtexdetail;
882 bleedx/=realtexdetail;
883 if(bleedx<0)bleedx=0;
884 if(bleedy<0)bleedy=0;
885 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
886 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
887 direction=abs(Random()%2)*2-1;
889 if(whichtri==-1)return 0;
891 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
892 deathbleeding+=bleeding;
893 bloodloss+=bleeding*3;
895 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
896 if(abs(Random()%2)==0){aitype=gethelptype;
899 else aitype=attacktypecutoff;
902 if(bleeding>2)bleeding=2;
907 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
910 static int bytesPerPixel=3;
911 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
912 static int newstartx,newstarty,newendx,newendy;
913 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
915 static float sizemult;
917 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
918 texture[i]=skeleton.skinText[i];
921 if((!osx||howmanylevels)){
923 if(startx<0)startx=0;
924 if(starty<0)starty=0;
925 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
926 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
927 if((endx>startx&&endy>starty)||howmanylevels){
934 for(i=startx;i<endx;i++){
935 for(j=starty;j<endy;j++){
936 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
937 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
938 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
942 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
945 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
946 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
947 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
950 newsize=skeleton.skinsize;
953 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
955 /*for(j=1;j<=howmanylevels;j++){
956 if(j==1)texpointer=&skeleton.skinText[0];
957 else texpointer=&texture[0];
959 totalsize=int( newsize*newsize*bytesPerPixel);
960 rowsize=int( newsize*bytesPerPixel );
961 bigstep=bytesPerPixel*newsize*2;
962 smallstep=bytesPerPixel*2;
968 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
975 void Person::Reverse(){
976 if(victim->aitype==playercontrolled||hostiletime>1)
977 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
978 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
979 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
980 if(targetanimation==sweepanim){
981 targetanimation=sweepreversedanim;
982 currentanimation=sweepreversedanim;
983 victim->currentanimation=sweepreversalanim;
984 victim->targetanimation=sweepreversalanim;
986 if(targetanimation==spinkickanim){
987 targetanimation=spinkickreversedanim;
988 currentanimation=spinkickreversedanim;
989 victim->currentanimation=spinkickreversalanim;
990 victim->targetanimation=spinkickreversalanim;
992 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
993 if(targetanimation==rabbittacklinganim){
996 victim->currentframe=6;
997 victim->targetframe=7;
999 targetanimation=upunchreversedanim;
1000 currentanimation=upunchreversedanim;
1001 victim->currentanimation=upunchreversalanim;
1002 victim->targetanimation=upunchreversalanim;
1004 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1005 if(victim->weaponactive!=-1){
1006 victim->throwtogglekeydown=1;
1007 weapons.owner[victim->weaponids[0]]=-1;
1008 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1009 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1010 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1011 weapons.missed[victim->weaponids[0]]=1;
1012 weapons.freetime[victim->weaponids[0]]=0;
1013 weapons.firstfree[victim->weaponids[0]]=1;
1014 weapons.physics[victim->weaponids[0]]=1;
1015 victim->num_weapons--;
1016 if(victim->num_weapons){
1017 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1018 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1021 victim->weaponactive=-1;
1022 for(int j=0;j<numplayers;j++){
1023 player[j].wentforweapon=0;
1027 targetanimation=staffhitreversedanim;
1028 currentanimation=staffhitreversedanim;
1029 victim->currentanimation=staffhitreversalanim;
1030 victim->targetanimation=staffhitreversalanim;
1032 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1033 if(victim->weaponactive!=-1){
1034 victim->throwtogglekeydown=1;
1035 weapons.owner[victim->weaponids[0]]=-1;
1036 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1037 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1038 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1039 weapons.missed[victim->weaponids[0]]=1;
1040 weapons.freetime[victim->weaponids[0]]=0;
1041 weapons.firstfree[victim->weaponids[0]]=1;
1042 weapons.physics[victim->weaponids[0]]=1;
1043 victim->num_weapons--;
1044 if(victim->num_weapons){
1045 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1046 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1049 victim->weaponactive=-1;
1050 for(int j=0;j<numplayers;j++){
1051 player[j].wentforweapon=0;
1054 targetanimation=staffspinhitreversedanim;
1055 currentanimation=staffspinhitreversedanim;
1056 victim->currentanimation=staffspinhitreversalanim;
1057 victim->targetanimation=staffspinhitreversalanim;
1059 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1060 if(victim->weaponactive!=-1){
1061 victim->throwtogglekeydown=1;
1062 weapons.owner[victim->weaponids[0]]=-1;
1063 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1064 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1065 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1066 weapons.missed[victim->weaponids[0]]=1;
1067 weapons.freetime[victim->weaponids[0]]=0;
1068 weapons.firstfree[victim->weaponids[0]]=1;
1069 weapons.physics[victim->weaponids[0]]=1;
1070 victim->num_weapons--;
1071 if(victim->num_weapons){
1072 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1073 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1076 victim->weaponactive=-1;
1077 for(int j=0;j<numplayers;j++){
1078 player[j].wentforweapon=0;
1081 targetanimation=swordslashreversedanim;
1082 currentanimation=swordslashreversedanim;
1083 victim->currentanimation=swordslashreversalanim;
1084 victim->targetanimation=swordslashreversalanim;
1086 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1087 if(victim->weaponactive!=-1){
1088 victim->throwtogglekeydown=1;
1089 weapons.owner[victim->weaponids[0]]=-1;
1090 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1091 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1092 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1093 weapons.missed[victim->weaponids[0]]=1;
1094 weapons.freetime[victim->weaponids[0]]=0;
1095 weapons.firstfree[victim->weaponids[0]]=1;
1096 weapons.physics[victim->weaponids[0]]=1;
1097 victim->num_weapons--;
1098 if(victim->num_weapons){
1099 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1100 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1103 victim->weaponactive=-1;
1104 for(int j=0;j<numplayers;j++){
1105 player[j].wentforweapon=0;
1108 targetanimation=knifeslashreversedanim;
1109 currentanimation=knifeslashreversedanim;
1110 victim->currentanimation=knifeslashreversalanim;
1111 victim->targetanimation=knifeslashreversalanim;
1113 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1114 victim->targettilt2=targettilt2;
1115 victim->currentframe=currentframe;
1116 victim->targetframe=targetframe;
1117 victim->target=target;
1119 victim->oldcoords=victim->coords;
1120 victim->coords=coords;
1121 victim->targetrotation=targetrotation;
1122 victim->rotation=targetrotation;
1123 victim->victim=this;
1125 if(targetanimation==winduppunchanim){
1126 targetanimation=winduppunchblockedanim;
1127 victim->targetanimation=blockhighleftanim;
1128 victim->targetframe=1;
1130 victim->victim=this;
1131 victim->targetrotation=targetrotation+180;
1133 if(targetanimation==wolfslapanim){
1134 targetanimation=winduppunchblockedanim;
1135 victim->targetanimation=blockhighleftanim;
1136 victim->targetframe=1;
1138 victim->victim=this;
1139 victim->targetrotation=targetrotation+180;
1141 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1142 targetanimation=swordslashparriedanim;
1144 victim->parriedrecently=0;
1145 victim->targetanimation=swordslashparryanim;
1146 victim->targetframe=1;
1148 victim->victim=this;
1149 victim->targetrotation=targetrotation+180;
1151 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1154 gLoc[0]=victim->coords.x;
1155 gLoc[1]=victim->coords.y;
1156 gLoc[2]=victim->coords.z;
1160 if(victim->weaponactive!=-1){
1161 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1162 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1163 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1165 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1166 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1167 OPENAL_SetVolume(channels[swordstaffsound], 512);
1168 OPENAL_SetPaused(channels[swordstaffsound], false);
1171 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1172 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1173 OPENAL_SetVolume(channels[metalhitsound], 512);
1174 OPENAL_SetPaused(channels[metalhitsound], false);
1178 victim->Puff(righthand);
1180 victim->targetframe=0;
1181 victim->targetanimation=staggerbackhighanim;
1182 victim->targetrotation=targetrotation+180;
1184 weapons.owner[victim->weaponids[0]]=-1;
1185 aim=DoRotation(facing,0,90,0)*21;
1187 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1188 weapons.tipvelocity[victim->weaponids[0]]=aim;
1189 weapons.missed[victim->weaponids[0]]=1;
1190 weapons.hitsomething[victim->weaponids[0]]=0;
1191 weapons.freetime[victim->weaponids[0]]=0;
1192 weapons.firstfree[victim->weaponids[0]]=1;
1193 weapons.physics[victim->weaponids[0]]=1;
1194 victim->num_weapons--;
1195 if(victim->num_weapons){
1196 victim->weaponids[0]=victim->weaponids[num_weapons];
1197 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1199 victim->weaponactive=-1;
1200 for(int i=0;i<numplayers;i++){
1201 player[i].wentforweapon=0;
1208 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1209 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1210 OPENAL_SetVolume(channels[metalhitsound], 512);
1211 OPENAL_SetPaused(channels[metalhitsound], false);*/
1214 if(abs(Random()%20)==0){
1223 if(weaponactive!=-1){
1224 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1225 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1226 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1228 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1229 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1230 OPENAL_SetVolume(channels[swordstaffsound], 512);
1231 OPENAL_SetPaused(channels[swordstaffsound], false);
1234 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1235 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1236 OPENAL_SetVolume(channels[metalhitsound], 512);
1237 OPENAL_SetPaused(channels[metalhitsound], false);
1245 targetanimation=staggerbackhighanim;
1246 targetrotation=targetrotation+180;
1248 weapons.owner[weaponids[0]]=-1;
1249 aim=DoRotation(facing,0,90,0)*21;
1251 weapons.velocity[weaponids[0]]=aim*-.2;
1252 weapons.tipvelocity[weaponids[0]]=aim;
1253 weapons.hitsomething[weaponids[0]]=0;
1254 weapons.missed[weaponids[0]]=1;
1255 weapons.freetime[weaponids[0]]=0;
1256 weapons.firstfree[weaponids[0]]=1;
1257 weapons.physics[weaponids[0]]=1;
1260 weaponids[0]=weaponids[num_weapons];
1261 if(weaponstuck==num_weapons)weaponstuck=0;
1264 for(int i=0;i<numplayers;i++){
1265 player[i].wentforweapon=0;
1269 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1270 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1271 OPENAL_SetVolume(channels[metalhitsound], 512);
1272 OPENAL_SetPaused(channels[metalhitsound], false);*/
1276 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1277 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1278 //victim->targetanimation=sweepanim;
1279 victim->targetanimation=dodgebackanim;
1280 victim->targetframe=0;
1282 //victim->velocity=0;
1285 rotatetarget=coords-victim->coords;
1286 Normalise(&rotatetarget);
1287 victim->targetrotation=-asin(0-rotatetarget.x);
1288 victim->targetrotation*=360/6.28;
1289 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1291 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1293 victim->lastattack3=victim->lastattack2;
1294 victim->lastattack2=victim->lastattack;
1295 victim->lastattack=victim->targetanimation;
1299 victim->targetanimation=sweepanim;
1300 victim->targetframe=0;
1304 rotatetarget=coords-victim->coords;
1305 Normalise(&rotatetarget);
1306 victim->targetrotation=-asin(0-rotatetarget.x);
1307 victim->targetrotation*=360/6.28;
1308 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1310 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1312 victim->lastattack3=victim->lastattack2;
1313 victim->lastattack2=victim->lastattack;
1314 victim->lastattack=victim->targetanimation;
1321 if(aitype!=playercontrolled)feint=0;
1322 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1323 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1324 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1326 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1330 void Person::DoDamage(float howmuch){
1331 if(tutoriallevel!=1)damage+=howmuch/power;
1332 if(id!=0)damagedealt+=howmuch/power;
1333 if(id==0)damagetaken+=howmuch/power;
1335 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1336 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1337 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1338 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1339 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1341 if(id==0)camerashake+=howmuch/100;
1342 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1343 if(blackout>1)blackout=1;
1345 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1346 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1347 if(abs(Random()%2)==0){aitype=gethelptype;
1350 else aitype=attacktypecutoff;
1354 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1357 for(int i=0;i<skeleton.num_joints; i++){
1358 if(!skeleton.free)flatvelocity2=velocity;
1359 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1360 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1361 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1362 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1363 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1364 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1365 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1366 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1367 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1378 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1379 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1380 OPENAL_SetVolume(channels[splattersound], 256);
1381 OPENAL_SetPaused(channels[splattersound], false);
1390 if(!dead&&creature==wolftype){
1399 if(tutoriallevel!=1||id==0)
1400 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1411 if(creature==wolftype){
1412 int i=abs(Random()%2);
1413 if(i==0)whichsound=snarlsound;
1414 if(i==1)whichsound=snarl2sound;
1415 envsound[numenvsounds]=coords;
1416 envsoundvol[numenvsounds]=16;
1417 envsoundlife[numenvsounds]=.4;
1420 if(creature==rabbittype){
1421 int i=abs(Random()%2);
1422 if(i==0)whichsound=rabbitpainsound;
1423 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1424 envsound[numenvsounds]=coords;
1425 envsoundvol[numenvsounds]=16;
1426 envsoundlife[numenvsounds]=.4;
1428 //if(i==2)whichsound=rabbitpain2sound;
1432 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1433 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1434 OPENAL_SetVolume(channels[whichsound], 512);
1435 OPENAL_SetPaused(channels[whichsound], false);
1440 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1441 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1444 void Person::DoHead(){
1445 static XYZ rotatearound;
1447 static float lookspeed=500;
1449 if(!freeze&&!winfreeze){
1452 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1453 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1455 while(targetheadrotation>180)targetheadrotation-=360;
1456 while(targetheadrotation<-180)targetheadrotation+=360;
1458 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1459 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1460 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1461 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1463 if(targetheadrotation2>120)targetheadrotation2=120;
1464 if(targetheadrotation2<-120)targetheadrotation2=-120;
1465 if(targetheadrotation>120)targetheadrotation=120;
1466 if(targetheadrotation<-120)targetheadrotation=-120;
1468 if(!isIdle())targetheadrotation2=0;
1470 if(targetheadrotation>80)targetheadrotation=80;
1471 if(targetheadrotation<-80)targetheadrotation=-80;
1472 if(targetheadrotation2>50)targetheadrotation2=50;
1473 if(targetheadrotation2<-50)targetheadrotation2=-50;
1476 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1477 else if(headrotation>targetheadrotation){
1478 headrotation-=multiplier*lookspeed;
1480 else if(headrotation<targetheadrotation){
1481 headrotation+=multiplier*lookspeed;
1484 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1485 else if(headrotation2>targetheadrotation2){
1486 headrotation2-=multiplier*lookspeed/2;
1488 else if(headrotation2<targetheadrotation2){
1489 headrotation2+=multiplier*lookspeed/2;
1492 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1493 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1497 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1498 facing=DoRotation(facing,headrotation2*.4,0,0);
1499 facing=DoRotation(facing,0,headrotation*.4,0);
1502 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1503 facing=DoRotation(facing,headrotation2*.8,0,0);
1504 facing=DoRotation(facing,0,headrotation*.8,0);
1507 if(targetanimation==walkanim){
1508 facing=DoRotation(facing,headrotation2*.6,0,0);
1509 facing=DoRotation(facing,0,headrotation*.6,0);
1512 skeleton.specialforward[0]=facing;
1513 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1515 for(i=0;i<skeleton.num_muscles;i++){
1516 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1518 skeleton.FindRotationMuscle(i,targetanimation);
1524 void Person::RagDoll(bool checkcollision){
1529 if(id==0)numfalls++;
1530 if(id==0&&isFlip())numflipfail++;
1536 facing=DoRotation(facing,0,rotation,0);
1538 skeleton.freetime=0;
1540 skeleton.longdead=0;
1546 skeleton.freefall=1;
1548 if(!isnormal(velocity.x))velocity.x=0;
1549 if(!isnormal(velocity.y))velocity.y=0;
1550 if(!isnormal(velocity.z))velocity.z=0;
1551 if(!isnormal(rotation))rotation=0;
1552 if(!isnormal(coords.x))coords=0;
1553 if(!isnormal(tilt))tilt=0;
1554 if(!isnormal(tilt2))tilt2=0;
1556 for(i=0;i<skeleton.num_joints;i++){
1557 skeleton.joints[i].delay=0;
1558 skeleton.joints[i].locked=0;
1559 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1560 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1561 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1562 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1563 skeleton.joints[i].position.y+=.1;
1564 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1565 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1568 for(i=0;i<skeleton.num_joints;i++){
1569 skeleton.joints[i].velocity=0;
1570 skeleton.joints[i].velchange=0;
1572 skeleton.DoConstraints(&coords,&scale);
1573 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1575 skeleton.DoConstraints(&coords,&scale);
1576 skeleton.DoConstraints(&coords,&scale);
1577 skeleton.DoConstraints(&coords,&scale);
1578 skeleton.DoConstraints(&coords,&scale);
1581 speed=animation[targetanimation].speed[targetframe]*2;
1582 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1583 speed=animation[currentanimation].speed[currentframe]*2;
1585 if(transspeed)speed=transspeed*2;
1589 for(i=0;i<skeleton.num_joints;i++){
1590 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);
1591 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1592 change.x=(float)(Random()%100)/100;
1593 change.y=(float)(Random()%100)/100;
1594 change.z=(float)(Random()%100)/100;
1595 skeleton.joints[i].velocity+=change;
1596 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1598 change.x=(float)(Random()%100)/100;
1599 change.y=(float)(Random()%100)/100;
1600 change.z=(float)(Random()%100)/100;
1601 skeleton.joints[i].velchange+=change;
1602 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1612 for(j=0;j<skeleton.num_joints;j++){
1613 average+=skeleton.joints[j].position;
1617 coords+=average*scale;
1618 for(j=0;j<skeleton.num_joints;j++){
1619 skeleton.joints[j].position-=average;
1622 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1623 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1624 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1625 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1626 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1629 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1630 coords.x=lowpoint.x;
1631 coords.z=lowpoint.z;
1640 for(i=0;i<skeleton.num_joints;i++){
1641 velocity+=skeleton.joints[i].velocity*scale;
1643 velocity/=skeleton.num_joints;
1646 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1647 weapons.owner[weaponids[0]]=-1;
1648 weapons.hitsomething[weaponids[0]]=0;
1649 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1650 weapons.velocity[weaponids[0]].x+=.01;
1651 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1652 weapons.missed[weaponids[0]]=1;
1653 weapons.freetime[weaponids[0]]=0;
1654 weapons.firstfree[weaponids[0]]=1;
1655 weapons.physics[weaponids[0]]=1;
1658 weaponids[0]=weaponids[num_weapons];
1659 if(weaponstuck==num_weapons)weaponstuck=0;
1662 for(i=0;i<numplayers;i++){
1663 player[i].wentforweapon=0;
1668 targetanimation=bounceidleanim;
1669 currentanimation=bounceidleanim;
1677 void Person::FootLand(int which, float opacity){
1678 static XYZ terrainlight;
1679 static XYZ footvel,footpoint;
1680 if(opacity>=1||skiddelay<=0)
1684 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1685 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1686 //footpoint.y=coords.y;
1687 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1689 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1691 if(footvel.y<.8)footvel.y=.8;
1692 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1693 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1694 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1695 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1696 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1697 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1699 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1701 if(footvel.y<.8)footvel.y=.8;
1702 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1703 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1704 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1705 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1706 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);
1708 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1710 if(footvel.y<.8)footvel.y=.8;
1711 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1712 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1713 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1714 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1715 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);
1716 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1718 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1721 if(footvel.y<.8)footvel.y=.8;
1722 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1723 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1724 //footpoint.y=coords.y;
1725 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1729 void Person::Puff(int whichlabel){
1730 static XYZ footvel,footpoint;
1733 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1734 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1738 void Person::DoAnimations(){
1741 static float oldtarget;
1743 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1745 if(targetanimation==tempanim||currentanimation==tempanim){
1746 animation[tempanim]=tempanimation;
1748 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1759 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1760 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1762 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1763 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1765 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1770 targfacing=DoRotation(targfacing,0,targetrotation,0);
1772 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1773 else targetanimation=backflipanim;
1774 crouchtogglekeydown=1;
1778 if(id==0)numflipped++;
1781 if(animation[targetanimation].attack!=reversed)feint=0;
1782 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1783 crouchtogglekeydown=0;
1784 if(aitype==playercontrolled)feint=0;
1788 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1789 if(!isFlip())crouchtogglekeydown=1;
1793 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1794 if(detail)normalsupdatedelay=0;
1798 if(targetanimation==rollanim&&targetframe==3&&onfire){
1808 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1809 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1810 OPENAL_SetVolume(channels[fireendsound], 256);
1811 OPENAL_SetPaused(channels[fireendsound], false);
1812 OPENAL_SetPaused(channels[stream_firesound], true);
1816 if(targetanimation==rabbittacklinganim&&targetframe==1){
1817 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1818 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1819 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1820 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1821 else victim->targetanimation=rabbittackledfrontanim;
1822 victim->targetframe=2;
1824 victim->rotation=rotation;
1825 victim->targetrotation=rotation;
1826 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1827 //victim->DoDamage(30);
1828 if(creature==wolftype){
1832 gLoc[0]=victim->coords.x;
1833 gLoc[1]=victim->coords.y;
1834 gLoc[2]=victim->coords.z;
1838 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
1839 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
1840 OPENAL_SetVolume(channels[clawslicesound], 128);
1841 OPENAL_SetPaused(channels[clawslicesound], false);
1843 victim->DoBloodBig(1/victim->armorhead,210);
1849 if(victim->aitype==gethelptype)bonusvalue=50;
1854 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1855 if(weapons.type[weaponids[0]]==knife){
1856 if(weaponactive==-1)weaponactive=0;
1857 else if(weaponactive==0)weaponactive=-1;
1859 if(weaponactive==-1){
1869 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
1870 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
1871 OPENAL_SetVolume(channels[knifesheathesound], 128);
1872 OPENAL_SetPaused(channels[knifesheathesound], false);
1874 if(weaponactive!=-1){
1884 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1885 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1886 OPENAL_SetVolume(channels[knifedrawsound], 128);
1887 OPENAL_SetPaused(channels[knifedrawsound], false);
1890 drawtogglekeydown=1;
1893 if(tutoriallevel!=1||id==0)
1894 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1905 if(terrain.getOpacity(coords.x,coords.z)<.2){
1906 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1907 else whichsound=footstepsound2;
1908 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1909 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1910 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1916 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1917 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1918 else whichsound=footstepsound4;
1922 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1923 else whichsound=footstepsound4;
1925 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1926 if(animation[targetanimation].attack!=neutral){
1928 if(i==0)whichsound=lowwhooshsound;
1929 if(i==1)whichsound=midwhooshsound;
1930 if(i==2)whichsound=highwhooshsound;
1932 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1934 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1935 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1937 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1938 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1939 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
1940 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
1941 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
1942 OPENAL_SetPaused(channels[whichsound], false);
1945 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1946 envsound[numenvsounds]=coords;
1947 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1948 else envsoundvol[numenvsounds]=6;
1949 envsoundlife[numenvsounds]=.4;
1953 if(animation[targetanimation].label[targetframe]==3){
1955 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1956 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1957 OPENAL_SetVolume(channels[whichsound], 128);
1958 OPENAL_SetPaused(channels[whichsound], false);
1963 if(tutoriallevel!=1||id==0)
1965 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1966 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1976 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1977 if(animation[targetanimation].attack!=neutral){
1979 if(creature==rabbittype){
1980 if(i==0)whichsound=rabbitattacksound;
1981 if(i==1)whichsound=rabbitattack2sound;
1982 if(i==2)whichsound=rabbitattack3sound;
1983 if(i==3)whichsound=rabbitattack4sound;
1985 if(creature==wolftype){
1986 if(i==0)whichsound=barksound;
1987 if(i==1)whichsound=bark2sound;
1988 if(i==2)whichsound=bark3sound;
1989 if(i==3)whichsound=barkgrowlsound;
1993 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1995 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1996 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
1999 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2000 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2001 OPENAL_SetVolume(channels[whichsound], 512);
2002 OPENAL_SetPaused(channels[whichsound], false);
2008 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
2014 currentoffset=targetoffset;
2015 targetframe=currentframe;
2016 currentanimation=targetanimation;
2019 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
2020 for(i=0;i<weapons.numweapons;i++){
2021 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
2022 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
2023 if(findDistancefast(&coords,&weapons.position[i])>=1){
2024 if(weapons.type[i]!=staff){
2033 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2034 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2035 OPENAL_SetVolume(channels[knifedrawsound], 128);
2036 OPENAL_SetPaused(channels[knifedrawsound], false);
2040 weapons.owner[i]=id;
2042 weaponids[num_weapons]=weaponids[0];
2051 static bool willwork;
2052 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2053 for(i=0;i<weapons.numweapons;i++){
2055 if(weapons.owner[i]!=-1)
2056 if(player[weapons.owner[i]].weaponstuck!=-1)
2057 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2058 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2059 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))
2060 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2061 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2071 if(weapons.owner[i]!=-1)
2072 if(victim->weaponstuck!=-1){
2073 if(victim->weaponids[victim->weaponstuck]==i){
2078 if(weapons.type[i]!=staff){
2079 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2080 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2081 OPENAL_SetVolume(channels[knifedrawsound], 128);
2082 OPENAL_SetPaused(channels[knifedrawsound], false);
2086 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2087 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2088 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2089 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2092 if(weapons.owner[i]!=-1){
2094 victim=&player[weapons.owner[i]];
2095 if(victim->num_weapons==1)victim->num_weapons=0;
2096 else victim->num_weapons=1;
2098 //victim->weaponactive=-1;
2099 victim->skeleton.longdead=0;
2100 victim->skeleton.free=1;
2101 victim->skeleton.broken=0;
2103 for(int j=0;j<victim->skeleton.num_joints;j++){
2104 victim->skeleton.joints[j].velchange=0;
2105 victim->skeleton.joints[j].locked=0;
2111 Normalise(&relative);
2112 XYZ footvel,footpoint;
2114 footpoint=weapons.position[i];
2115 if(victim->weaponstuck!=-1){
2116 if(victim->weaponids[victim->weaponstuck]==i){
2117 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2118 weapons.bloody[i]=2;
2119 weapons.blooddrip[i]=5;
2120 victim->weaponstuck=-1;
2123 if(victim->num_weapons>0){
2124 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2125 if(victim->weaponids[0]==i)
2126 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2129 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2130 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2131 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2132 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2134 weapons.owner[i]=id;
2136 weaponids[num_weapons]=weaponids[0];
2145 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2146 if(weaponactive==-1)weaponactive=0;
2147 else if(weaponactive==0){
2151 buffer=weaponids[0];
2152 weaponids[0]=weaponids[1];
2153 weaponids[1]=buffer;
2156 if(weaponactive==-1){
2166 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2167 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2168 OPENAL_SetVolume(channels[knifesheathesound], 128);
2169 OPENAL_SetPaused(channels[knifesheathesound], false);
2171 if(weaponactive!=-1){
2181 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2182 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2183 OPENAL_SetVolume(channels[knifedrawsound], 128);
2184 OPENAL_SetPaused(channels[knifedrawsound], false);
2189 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2190 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2191 Normalise(&rotatetarget);
2192 targetrotation=-asin(0-rotatetarget.x);
2193 targetrotation*=360/6.28;
2194 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2196 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2197 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2202 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2204 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;
2206 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2207 targetanimation=rabbittackleanim;
2218 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2219 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2220 OPENAL_SetVolume(channels[jumpsound], 128);
2221 OPENAL_SetPaused(channels[jumpsound], false);
2230 Normalise(&targetloc);
2232 for(i=0;i<numplayers;i++){
2234 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2235 closestdist=findDistancefast(&targetloc,&player[i].coords);
2240 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2242 victim=&player[closestid];
2243 coords=victim->coords;
2244 currentanimation=rabbittacklinganim;
2245 targetanimation=rabbittacklinganim;
2249 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2250 rotatetarget=coords-victim->coords;
2251 Normalise(&rotatetarget);
2252 targetrotation=-asin(0-rotatetarget.x);
2253 targetrotation*=360/6.28;
2254 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2256 if(targetanimation!=rabbitrunninganim){
2266 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2267 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2268 OPENAL_SetVolume(channels[jumpsound], 128);
2269 OPENAL_SetPaused(channels[jumpsound], false);
2275 float damagemult=1*power;
2276 if(creature==wolftype)damagemult=2.5*power;
2277 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2278 //if(onfire)damagemult=3;
2279 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2280 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2281 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2283 if(id==0)camerashake+=.4;
2284 if(Random()%2||creature==wolftype){
2287 if(creature==wolftype)DoBloodBig(0,250);
2291 gLoc[0]=victim->coords.x;
2292 gLoc[1]=victim->coords.y;
2293 gLoc[2]=victim->coords.z;
2297 if(tutoriallevel!=1){
2298 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2299 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2300 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2301 OPENAL_SetPaused(channels[heavyimpactsound], false);
2303 if(creature==wolftype){
2304 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2305 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2306 OPENAL_SetVolume(channels[clawslicesound], 128);
2307 OPENAL_SetPaused(channels[clawslicesound], false);
2309 victim->DoBloodBig(2/victim->armorhead,175);
2313 relative=victim->coords-coords;
2315 Normalise(&relative);
2316 relative=DoRotation(relative,0,-90,0);
2317 for(i=0;i<victim->skeleton.num_joints;i++){
2318 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2320 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2323 victim->DoDamage(damagemult*100/victim->protectionhead);
2331 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2332 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2334 if(id==0)camerashake+=.4;
2335 if(Random()%2||creature==wolftype){
2337 if(creature==wolftype)DoBloodBig(0,235);
2341 gLoc[0]=victim->coords.x;
2342 gLoc[1]=victim->coords.y;
2343 gLoc[2]=victim->coords.z;
2347 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2348 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2349 OPENAL_SetVolume(channels[whooshhitsound], 512);
2350 OPENAL_SetPaused(channels[whooshhitsound], false);
2351 if(creature==wolftype){
2352 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2353 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2354 OPENAL_SetVolume(channels[clawslicesound], 128);
2355 OPENAL_SetPaused(channels[clawslicesound], false);
2357 victim->DoBloodBig(2,175);
2361 relative=victim->coords-coords;
2363 Normalise(&relative);
2365 Normalise(&relative);
2366 relative=DoRotation(relative,0,90,0);
2367 for(i=0;i<victim->skeleton.num_joints;i++){
2368 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2370 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2373 victim->DoDamage(damagemult*50/victim->protectionhead);
2377 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2378 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2380 if(id==0)camerashake+=.4;
2385 gLoc[0]=victim->coords.x;
2386 gLoc[1]=victim->coords.y;
2387 gLoc[2]=victim->coords.z;
2391 if(tutoriallevel!=1){
2392 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2393 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2394 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2395 OPENAL_SetPaused(channels[heavyimpactsound], false);
2397 if(creature==wolftype){
2398 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2399 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2400 OPENAL_SetVolume(channels[clawslicesound], 128);
2401 OPENAL_SetPaused(channels[clawslicesound], false);
2403 victim->DoBloodBig(2/victim->armorhead,175);
2409 Normalise(&relative);
2410 relative=DoRotation(relative,0,-90,0);
2411 for(i=0;i<victim->skeleton.num_joints;i++){
2412 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2414 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2417 victim->DoDamage(damagemult*150/victim->protectionhead);
2419 if(victim->damage>victim->damagetolerance){
2432 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2433 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2435 if(id==0)camerashake+=.4;
2440 gLoc[0]=victim->coords.x;
2441 gLoc[1]=victim->coords.y;
2442 gLoc[2]=victim->coords.z;
2446 if(tutoriallevel!=1){
2447 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2448 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2449 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2450 OPENAL_SetPaused(channels[heavyimpactsound], false);
2452 if(creature==wolftype){
2453 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2454 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2455 OPENAL_SetVolume(channels[clawslicesound], 128);
2456 OPENAL_SetPaused(channels[clawslicesound], false);
2458 victim->DoBloodBig(2/victim->armorhead,175);
2464 Normalise(&relative);
2465 relative=DoRotation(relative,0,90,0);
2466 for(i=0;i<victim->skeleton.num_joints;i++){
2467 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2469 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2472 victim->DoDamage(damagemult*150/victim->protectionhead);
2474 if(victim->damage>victim->damagetolerance){
2487 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2488 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2490 if(id==0)camerashake+=.4;
2497 gLoc[0]=victim->coords.x;
2498 gLoc[1]=victim->coords.y;
2499 gLoc[2]=victim->coords.z;
2503 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2504 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2505 OPENAL_SetVolume(channels[whooshhitsound], 512);
2506 OPENAL_SetPaused(channels[whooshhitsound], false);
2509 relative=victim->coords-coords;
2511 Normalise(&relative);
2512 for(i=0;i<victim->skeleton.num_joints;i++){
2513 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2515 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2518 victim->DoDamage(damagemult*50/victim->protectionhead);
2522 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2523 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2525 if(id==0)camerashake+=.2;
2528 gLoc[0]=victim->coords.x;
2529 gLoc[1]=victim->coords.y;
2530 gLoc[2]=victim->coords.z;
2534 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2535 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2536 OPENAL_SetVolume(channels[landsound2], 128);
2537 OPENAL_SetPaused(channels[landsound2], false);
2539 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2540 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2541 OPENAL_SetVolume(channels[movewhooshsound], 128);
2542 OPENAL_SetPaused(channels[movewhooshsound], false);
2544 victim->skeleton.longdead=0;
2545 victim->skeleton.free=1;
2546 victim->skeleton.broken=0;
2547 victim->skeleton.spinny=1;
2549 for(i=0;i<victim->skeleton.num_joints;i++){
2550 victim->skeleton.joints[i].velchange=0;
2551 victim->skeleton.joints[i].delay=0;
2552 victim->skeleton.joints[i].locked=0;
2553 //victim->skeleton.joints[i].velocity=0;
2559 Normalise(&relative);
2560 for(i=0;i<victim->skeleton.num_joints;i++){
2561 victim->skeleton.joints[i].velocity.y=relative.y*10;
2562 victim->skeleton.joints[i].position.y+=relative.y*.3;
2563 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2564 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2566 victim->Puff(abdomen);
2567 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2571 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2572 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2574 if(id==0)camerashake+=.4;
2583 if(tutoriallevel!=1){
2584 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2585 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2586 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2587 OPENAL_SetPaused(channels[heavyimpactsound], false);
2590 relative=victim->coords-coords;
2592 Normalise(&relative);
2593 for(i=0;i<victim->skeleton.num_joints;i++){
2594 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2596 victim->Puff(abdomen);
2597 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2601 victim->DoDamage(damagemult*500/victim->protectionhigh);
2602 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2606 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2607 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2609 if(id==0)camerashake+=.4;
2618 if(tutoriallevel!=1){
2619 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2620 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2621 OPENAL_SetVolume(channels[thudsound], 400);
2622 OPENAL_SetPaused(channels[thudsound], false);
2625 victim->skeleton.longdead=0;
2626 victim->skeleton.free=1;
2627 victim->skeleton.broken=0;
2628 victim->skeleton.spinny=1;
2630 for(i=0;i<victim->skeleton.num_joints;i++){
2631 victim->skeleton.joints[i].velchange=0;
2632 //victim->skeleton.joints[i].delay=0;
2633 victim->skeleton.joints[i].locked=0;
2636 relative=victim->coords-coords;
2637 Normalise(&relative);
2639 Normalise(&relative);
2640 for(i=0;i<victim->skeleton.num_joints;i++){
2641 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2643 if(id==0&&!victim->dead){
2647 victim->Puff(abdomen);
2648 victim->DoDamage(damagemult*20/victim->protectionhigh);
2649 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2651 if(!victim->dead)staggerdelay=1.2;
2657 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2658 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2659 //if(id==0)camerashake+=.4;
2670 if(!victim->skeleton.free)hasvictim=0;
2673 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2674 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2675 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2676 OPENAL_SetVolume(channels[knifesheathesound], 128);
2677 OPENAL_SetPaused(channels[knifesheathesound], false);
2680 if(victim&&hasvictim){
2681 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2683 XYZ where,startpoint,endpoint,movepoint,colpoint;
2684 float rotationpoint;
2686 if(weapons.type[weaponids[weaponactive]]==knife){
2687 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2688 where-=victim->coords;
2689 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2696 if(weapons.type[weaponids[weaponactive]]==sword){
2697 where=weapons.position[weaponids[weaponactive]];
2698 where-=victim->coords;
2699 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2701 where=weapons.tippoint[weaponids[weaponactive]];
2702 where-=victim->coords;
2703 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2706 if(weapons.type[weaponids[weaponactive]]==staff){
2707 where=weapons.position[weaponids[weaponactive]];
2708 where-=victim->coords;
2709 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2711 where=weapons.tippoint[weaponids[weaponactive]];
2712 where-=victim->coords;
2713 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2718 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2721 if(victim->dead!=2){
2722 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2723 if(id==0&&!victim->dead){
2724 bonus=FinishedBonus;
2729 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2731 victim->skeleton.longdead=0;
2732 victim->skeleton.free=1;
2733 victim->skeleton.broken=0;
2735 for(i=0;i<victim->skeleton.num_joints;i++){
2736 victim->skeleton.joints[i].velchange=0;
2737 victim->skeleton.joints[i].locked=0;
2738 //victim->skeleton.joints[i].velocity=0;
2740 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2741 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2742 OPENAL_SetVolume(channels[fleshstabsound], 128);
2743 OPENAL_SetPaused(channels[fleshstabsound], false);
2746 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2747 weapons.blooddrip[weaponids[weaponactive]]+=5;
2748 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2752 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2753 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2754 OPENAL_SetVolume(channels[knifesheathesound], 128);
2755 OPENAL_SetPaused(channels[knifesheathesound], false);
2761 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2762 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2763 //if(id==0)camerashake+=.4;
2773 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2774 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2775 OPENAL_SetVolume(channels[knifedrawsound], 128);
2776 OPENAL_SetPaused(channels[knifedrawsound], false);
2779 if(victim&&hasvictim){
2780 XYZ footvel,footpoint;
2782 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2783 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2784 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2785 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2788 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2790 if(weapons.type[weaponids[weaponactive]]==sword){
2791 XYZ where,startpoint,endpoint,movepoint;
2792 float rotationpoint;
2795 where=weapons.position[weaponids[weaponactive]];
2796 where-=victim->coords;
2797 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2799 where=weapons.tippoint[weaponids[weaponactive]];
2800 where-=victim->coords;
2801 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2806 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2807 footpoint+=victim->coords;
2810 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2813 if(weapons.type[weaponids[weaponactive]]==staff){
2814 XYZ where,startpoint,endpoint,movepoint;
2815 float rotationpoint;
2818 where=weapons.position[weaponids[weaponactive]];
2819 where-=victim->coords;
2820 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2822 where=weapons.tippoint[weaponids[weaponactive]];
2823 where-=victim->coords;
2824 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2829 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2830 footpoint+=victim->coords;
2833 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2836 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2838 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2839 victim->skeleton.longdead=0;
2840 victim->skeleton.free=1;
2841 victim->skeleton.broken=0;
2843 for(i=0;i<victim->skeleton.num_joints;i++){
2844 victim->skeleton.joints[i].velchange=0;
2845 victim->skeleton.joints[i].locked=0;
2846 //victim->skeleton.joints[i].velocity=0;
2852 Normalise(&relative);
2853 //victim->Puff(abdomen);
2854 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2856 if(victim->bloodloss<victim->damagetolerance){
2857 victim->bloodloss+=1000;
2861 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2865 if(!hasvictim&&onterrain){
2866 weapons.bloody[weaponids[weaponactive]]=0;
2867 weapons.blooddrip[weaponids[weaponactive]]=0;
2871 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2872 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2874 if(id==0)camerashake+=.4;
2881 gLoc[0]=victim->coords.x;
2882 gLoc[1]=victim->coords.y;
2883 gLoc[2]=victim->coords.z;
2887 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2889 if(tutoriallevel!=1){
2890 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2891 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2892 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2893 OPENAL_SetPaused(channels[heavyimpactsound], false);
2897 if(tutoriallevel!=1){
2898 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2899 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2900 OPENAL_SetVolume(channels[landsound2], 256);
2901 OPENAL_SetPaused(channels[landsound2], false);
2905 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
2908 relative=victim->coords-coords;
2910 Normalise(&relative);
2911 for(i=0;i<victim->skeleton.num_joints;i++){
2912 victim->skeleton.joints[i].velocity=relative*30;
2914 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2916 victim->targetframe=0;
2917 victim->targetanimation=staggerbackhardanim;
2918 victim->targetrotation=targetrotation+180;
2923 victim->Puff(abdomen);
2924 victim->DoDamage(damagemult*60/victim->protectionhigh);
2933 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2934 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2936 if(id==0)camerashake+=.4;
2939 gLoc[0]=victim->coords.x;
2940 gLoc[1]=victim->coords.y;
2941 gLoc[2]=victim->coords.z;
2945 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2946 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2947 if(tutoriallevel!=1){
2948 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2949 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2950 OPENAL_SetVolume(channels[thudsound], 512);
2951 OPENAL_SetPaused(channels[thudsound], false);
2954 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2955 if(tutoriallevel!=1){
2956 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2957 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2958 OPENAL_SetVolume(channels[whooshhitsound], 512);
2959 OPENAL_SetPaused(channels[whooshhitsound], false);
2963 if(tutoriallevel!=1){
2964 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2965 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2966 OPENAL_SetVolume(channels[heavyimpactsound], 256);
2967 OPENAL_SetPaused(channels[heavyimpactsound], false);
2971 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2974 relative=victim->coords-coords;
2976 Normalise(&relative);
2978 Normalise(&relative);
2979 for(i=0;i<victim->skeleton.num_joints;i++){
2980 victim->skeleton.joints[i].velocity=relative*5;
2982 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
2984 victim->targetframe=0;
2985 victim->targetanimation=staggerbackhardanim;
2986 victim->targetrotation=targetrotation+180;
2990 victim->Puff(abdomen);
2991 victim->DoDamage(damagemult*60/victim->protectionhigh);
2999 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
3000 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3001 if(victim->id==0)camerashake+=.4;
3004 gLoc[0]=victim->coords.x;
3005 gLoc[1]=victim->coords.y;
3006 gLoc[2]=victim->coords.z;
3011 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3012 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3013 OPENAL_SetVolume(channels[landsound2], 256);
3014 OPENAL_SetPaused(channels[landsound2], false);
3020 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
3021 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3022 if(victim->id==0)camerashake+=.4;
3025 gLoc[0]=victim->coords.x;
3026 gLoc[1]=victim->coords.y;
3027 gLoc[2]=victim->coords.z;
3032 if(weaponactive!=-1){
3033 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3034 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3035 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3037 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3038 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3039 OPENAL_SetVolume(channels[swordstaffsound], 512);
3040 OPENAL_SetPaused(channels[swordstaffsound], false);
3043 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3044 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3045 OPENAL_SetVolume(channels[metalhitsound], 512);
3046 OPENAL_SetPaused(channels[metalhitsound], false);
3054 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3055 if(weaponactive!=-1){
3058 weapons.owner[weaponids[0]]=-1;
3059 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);
3061 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3062 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3064 weapons.velocity[weaponids[0]]=aim*50;
3065 weapons.tipvelocity[weaponids[0]]=aim*50;
3066 weapons.missed[weaponids[0]]=0;
3067 weapons.hitsomething[weaponids[0]]=0;
3068 weapons.freetime[weaponids[0]]=0;
3069 weapons.firstfree[weaponids[0]]=1;
3070 weapons.physics[weaponids[0]]=0;
3073 weaponids[0]=weaponids[num_weapons];
3079 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3081 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3084 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3092 if(tutoriallevel!=1){
3095 gLoc[0]=victim->coords.x;
3096 gLoc[1]=victim->coords.y;
3097 gLoc[2]=victim->coords.z;
3101 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3102 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3103 OPENAL_SetVolume(channels[knifeslicesound], 512);
3104 OPENAL_SetPaused(channels[knifeslicesound], false);
3106 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3107 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3108 if(victim->id != 0 || difficulty==2){
3109 victim->targetframe=0;
3110 victim->targetanimation=staggerbackhardanim;
3111 victim->targetrotation=targetrotation+180;
3115 victim->lowreversaldelay=0;
3116 victim->highreversaldelay=0;
3117 if(aitype!=playercontrolled)weaponmissdelay=.6;
3119 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3120 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3122 XYZ footvel,footpoint;
3125 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3128 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;
3130 if(tutoriallevel!=1){
3131 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3132 footvel=DoRotation(facing,0,90,0)*.8;
3134 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3135 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3136 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3137 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3139 if(tutoriallevel==1){
3140 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3142 victim->DoDamage(damagemult*0);
3145 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3146 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3147 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3154 if(tutoriallevel!=1){
3155 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3156 else victim->DoBloodBig(2/victim->armorhigh,185);
3157 victim->deathbleeding=1;
3160 gLoc[0]=victim->coords.x;
3161 gLoc[1]=victim->coords.y;
3162 gLoc[2]=victim->coords.z;
3166 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3167 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3168 OPENAL_SetVolume(channels[swordslicesound], 512);
3169 OPENAL_SetPaused(channels[swordslicesound], false);
3171 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3172 //if(animation[victim->targetanimation].attack){
3173 //if(victim->creature==rabbittype){
3174 if(tutoriallevel!=1){
3175 victim->targetframe=0;
3176 victim->targetanimation=staggerbackhardanim;
3177 victim->targetrotation=targetrotation+180;
3183 if(tutoriallevel!=1){
3184 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3185 weapons.blooddrip[weaponids[weaponactive]]+=3;
3187 float bloodlossamount;
3188 bloodlossamount=200+abs((float)(Random()%40))-20;
3189 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3190 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3191 victim->DoDamage(damagemult*0);
3193 XYZ footvel,footpoint;
3196 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3199 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;
3201 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3202 footvel=DoRotation(facing,0,90,0)*.8;
3204 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3205 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3206 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3207 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3215 gLoc[0]=victim->coords.x;
3216 gLoc[1]=victim->coords.y;
3217 gLoc[2]=victim->coords.z;
3221 if(victim->weaponactive!=-1){
3222 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3223 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3224 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3226 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3227 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3228 OPENAL_SetVolume(channels[swordstaffsound], 512);
3229 OPENAL_SetPaused(channels[swordstaffsound], false);
3232 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3233 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3234 OPENAL_SetVolume(channels[metalhitsound], 512);
3235 OPENAL_SetPaused(channels[metalhitsound], false);
3241 victim->Puff(righthand);
3243 victim->targetframe=0;
3244 victim->targetanimation=staggerbackhighanim;
3245 victim->targetrotation=targetrotation+180;
3247 weapons.owner[victim->weaponids[0]]=-1;
3248 aim=DoRotation(facing,0,90,0)*21;
3250 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3251 weapons.tipvelocity[victim->weaponids[0]]=aim;
3252 weapons.missed[victim->weaponids[0]]=1;
3253 weapons.hitsomething[weaponids[0]]=0;
3254 weapons.freetime[victim->weaponids[0]]=0;
3255 weapons.firstfree[victim->weaponids[0]]=1;
3256 weapons.physics[victim->weaponids[0]]=1;
3257 victim->num_weapons--;
3258 if(victim->num_weapons){
3259 victim->weaponids[0]=victim->weaponids[num_weapons];
3260 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3262 victim->weaponactive=-1;
3263 for(i=0;i<numplayers;i++){
3264 player[i].wentforweapon=0;
3267 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3268 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3269 OPENAL_SetVolume(channels[metalhitsound], 512);
3270 OPENAL_SetPaused(channels[metalhitsound], false);*/
3276 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3277 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3278 if(tutoriallevel!=1){
3279 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
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( staffheadsound, samp[staffheadsound], NULL, true);
3294 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3295 OPENAL_SetVolume(channels[staffheadsound], 256);
3296 OPENAL_SetPaused(channels[staffheadsound], false);
3300 relative=victim->coords-coords;
3302 Normalise(&relative);
3303 relative=DoRotation(relative,0,90,0);
3305 Normalise(&relative);
3306 for(i=0;i<victim->skeleton.num_joints;i++){
3307 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3309 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3310 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3313 if(tutoriallevel!=1){
3314 victim->DoDamage(damagemult*120/victim->protectionhigh);
3325 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3326 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3327 if(tutoriallevel!=1){
3328 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3330 if(id==0)camerashake+=.4;
3331 if(Random()%2||creature==wolftype){
3336 gLoc[0]=victim->coords.x;
3337 gLoc[1]=victim->coords.y;
3338 gLoc[2]=victim->coords.z;
3342 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3343 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3344 OPENAL_SetVolume(channels[staffheadsound], 256);
3345 OPENAL_SetPaused(channels[staffheadsound], false);
3349 relative=victim->coords-coords;
3351 Normalise(&relative);
3352 relative=DoRotation(relative,0,-90,0);
3353 for(i=0;i<victim->skeleton.num_joints;i++){
3354 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3356 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3357 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3360 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3371 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3372 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3374 if(tutoriallevel!=1){
3375 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3376 if(id==0)camerashake+=.4;
3377 if(Random()%2||creature==wolftype){
3382 gLoc[0]=victim->coords.x;
3383 gLoc[1]=victim->coords.y;
3384 gLoc[2]=victim->coords.z;
3388 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3389 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3390 OPENAL_SetVolume(channels[staffbodysound], 256);
3391 OPENAL_SetPaused(channels[staffbodysound], false);
3393 victim->skeleton.longdead=0;
3394 victim->skeleton.free=1;
3395 victim->skeleton.broken=0;
3397 for(i=0;i<victim->skeleton.num_joints;i++){
3398 victim->skeleton.joints[i].velchange=0;
3399 victim->skeleton.joints[i].locked=0;
3400 //victim->skeleton.joints[i].velocity=0;
3406 /*relative=victim->coords-coords;
3408 Normalise(&relative);
3409 relative=DoRotation(relative,0,90,0);*/
3411 Normalise(&relative);
3413 for(i=0;i<victim->skeleton.num_joints;i++){
3414 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3417 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3420 for(i=0;i<victim->skeleton.num_joints;i++){
3421 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3424 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3426 victim->Puff(abdomen);
3427 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3440 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3441 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3443 if(id==0)camerashake+=.4;
3446 gLoc[0]=victim->coords.x;
3447 gLoc[1]=victim->coords.y;
3448 gLoc[2]=victim->coords.z;
3453 relative=victim->coords-coords;
3455 Normalise(&relative);
3461 if(animation[victim->targetanimation].height==lowheight){
3467 for(i=0;i<victim->skeleton.num_joints;i++){
3468 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3470 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3471 if(tutoriallevel!=1){
3472 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3473 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3474 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3475 OPENAL_SetPaused(channels[heavyimpactsound], false);
3478 victim->DoDamage(damagemult*100/victim->protectionhead);
3479 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3480 if(creature==wolftype){
3481 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3482 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3483 OPENAL_SetVolume(channels[clawslicesound], 128);
3484 OPENAL_SetPaused(channels[clawslicesound], false);
3486 victim->DoBloodBig(2/victim->armorhead,175);
3490 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3491 for(i=0;i<victim->skeleton.num_joints;i++){
3492 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3494 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3495 victim->targetframe=0;
3496 victim->targetanimation=staggerbackhighanim;
3497 victim->targetrotation=targetrotation+180;
3499 if(tutoriallevel!=1){
3500 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3501 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3502 OPENAL_SetVolume(channels[landsound2], 128);
3503 OPENAL_SetPaused(channels[landsound2], false);
3505 victim->Puff(abdomen);
3506 victim->DoDamage(damagemult*30/victim->protectionhigh);
3507 if(creature==wolftype){
3508 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3509 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3510 OPENAL_SetVolume(channels[clawslicesound], 128);
3511 OPENAL_SetPaused(channels[clawslicesound], false);
3513 victim->DoBloodBig(2/victim->armorhigh,170);
3520 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3521 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3523 if(id==0)camerashake+=.2;
3526 gLoc[0]=victim->coords.x;
3527 gLoc[1]=victim->coords.y;
3528 gLoc[2]=victim->coords.z;
3532 if(tutoriallevel!=1){
3533 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3534 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3535 OPENAL_SetVolume(channels[landsound2], 128);
3536 OPENAL_SetPaused(channels[landsound2], false);
3539 relative=victim->coords-coords;
3541 Normalise(&relative);
3543 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3546 for(i=0;i<victim->skeleton.num_joints;i++){
3547 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3549 relative=DoRotation(relative,0,-90,0);
3551 for(i=0;i<victim->skeleton.num_joints;i++){
3552 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)
3553 victim->skeleton.joints[i].velocity=relative*80;
3555 victim->Puff(rightankle);
3556 victim->Puff(leftankle);
3557 victim->DoDamage(damagemult*40/victim->protectionlow);
3560 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3561 for(i=0;i<victim->skeleton.num_joints;i++){
3562 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3564 relative=DoRotation(relative,0,-90,0);
3565 for(i=0;i<victim->skeleton.num_joints;i++){
3566 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)
3567 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3569 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3570 victim->targetframe=0;
3571 victim->targetanimation=staggerbackhighanim;
3572 victim->targetrotation=targetrotation+180;
3574 if(tutoriallevel!=1){
3575 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3576 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3577 OPENAL_SetVolume(channels[landsound2], 128);
3578 OPENAL_SetPaused(channels[landsound2], false);
3580 victim->Puff(abdomen);
3581 victim->DoDamage(damagemult*30/victim->protectionlow);
3591 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3592 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3594 if(id==0)camerashake+=.4;
3601 gLoc[0]=victim->coords.x;
3602 gLoc[1]=victim->coords.y;
3603 gLoc[2]=victim->coords.z;
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);
3613 if(creature==wolftype){
3614 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3615 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3616 OPENAL_SetVolume(channels[clawslicesound], 128);
3617 OPENAL_SetPaused(channels[clawslicesound], false);
3619 victim->DoBloodBig(2/victim->armorhigh,170);
3623 relative=victim->coords-oldcoords;
3625 Normalise(&relative);
3626 //relative=DoRotation(relative,0,-90,0);
3627 for(i=0;i<victim->skeleton.num_joints;i++){
3628 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3630 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3632 victim->Puff(abdomen);
3633 victim->DoDamage(damagemult*150/victim->protectionhigh);
3642 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3643 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3644 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3645 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3648 weaponids[num_weapons]=weaponids[victim->weaponactive];
3651 weaponids[0]=victim->weaponids[victim->weaponactive];
3652 victim->num_weapons--;
3653 if(victim->num_weapons>0){
3654 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3655 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3657 victim->weaponactive=-1;
3662 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3664 if(id==0)camerashake+=.4;
3671 gLoc[0]=victim->coords.x;
3672 gLoc[1]=victim->coords.y;
3673 gLoc[2]=victim->coords.z;
3677 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3678 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3679 OPENAL_SetVolume(channels[whooshhitsound], 128);
3680 OPENAL_SetPaused(channels[whooshhitsound], false);
3683 relative=victim->coords-oldcoords;
3685 Normalise(&relative);
3686 //relative=DoRotation(relative,0,-90,0);
3687 for(i=0;i<victim->skeleton.num_joints;i++){
3688 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3690 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3693 victim->DoDamage(damagemult*70/victim->protectionhigh);
3696 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3698 if(id==0)camerashake+=.4;
3705 gLoc[0]=victim->coords.x;
3706 gLoc[1]=victim->coords.y;
3707 gLoc[2]=victim->coords.z;
3713 bonus=staffreversebonus;
3718 if(tutoriallevel!=1){
3719 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3720 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3721 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3722 OPENAL_SetPaused(channels[heavyimpactsound], false);
3726 bonus=staffreversebonus;
3732 relative=victim->coords-oldcoords;
3734 Normalise(&relative);
3735 //relative=DoRotation(relative,0,-90,0);
3736 for(i=0;i<victim->skeleton.num_joints;i++){
3737 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3739 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3742 victim->DoDamage(damagemult*70/victim->protectionhigh);
3745 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3751 Normalise(&relative);
3754 for(i=0;i<victim->skeleton.num_joints;i++){
3755 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3757 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3758 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3759 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3760 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3761 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3762 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3763 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3764 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3766 victim->Puff(abdomen);
3767 victim->DoDamage(damagemult*90/victim->protectionhigh);
3777 if(weaponactive!=-1||creature==wolftype)doslice=1;
3778 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3782 gLoc[0]=victim->coords.x;
3783 gLoc[1]=victim->coords.y;
3784 gLoc[2]=victim->coords.z;
3788 if(weaponactive!=-1){
3789 victim->DoBloodBig(2/victim->armorhigh,225);
3790 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3791 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3792 OPENAL_SetVolume(channels[knifeslicesound], 512);
3793 OPENAL_SetPaused(channels[knifeslicesound], false);
3794 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3795 weapons.blooddrip[weaponids[weaponactive]]+=3;
3797 if(weaponactive==-1&&creature==wolftype){
3798 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3799 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3800 OPENAL_SetVolume(channels[clawslicesound], 128);
3801 OPENAL_SetPaused(channels[clawslicesound], false);
3803 victim->DoBloodBig(2/victim->armorhigh,175);
3810 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3816 Normalise(&relative);
3819 for(i=0;i<victim->skeleton.num_joints;i++){
3820 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3822 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
3823 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
3824 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
3825 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
3826 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
3827 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
3828 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
3829 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
3832 bonus=swordreversebonus;
3836 //victim->DoDamage(90);
3838 /*if(weaponactive!=-1){
3841 gLoc[0]=victim->coords.x;
3842 gLoc[1]=victim->coords.y;
3843 gLoc[2]=victim->coords.z;
3847 victim->DoBloodBig(2,225);
3848 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3849 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3850 OPENAL_SetVolume(channels[knifeslicesound], 512);
3851 OPENAL_SetPaused(channels[knifeslicesound], false);
3852 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3853 weapons.blooddrip[weaponids[weaponactive]]+=3;
3857 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3859 if(id==0)camerashake+=.4;
3866 gLoc[0]=victim->coords.x;
3867 gLoc[1]=victim->coords.y;
3868 gLoc[2]=victim->coords.z;
3872 if(tutoriallevel!=1){
3873 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3874 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3875 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3876 OPENAL_SetPaused(channels[heavyimpactsound], false);
3880 relative=victim->coords-oldcoords;
3882 Normalise(&relative);
3883 relative=DoRotation(relative,0,-90,0);
3884 for(i=0;i<victim->skeleton.num_joints;i++){
3885 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3887 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3889 victim->Puff(abdomen);
3890 victim->DoDamage(damagemult*30/victim->protectionhigh);
3899 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
3902 victim->skeleton.spinny=0;
3906 Normalise(&relative);
3907 if(victim->id==0)relative/=30;
3908 for(i=0;i<victim->skeleton.num_joints;i++){
3909 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3911 //victim->DoDamage(1000);
3912 victim->damage=victim->damagetolerance;
3913 victim->permanentdamage=victim->damagetolerance-1;
3916 if(weaponactive!=-1||creature==wolftype)doslice=1;
3917 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3921 gLoc[0]=victim->coords.x;
3922 gLoc[1]=victim->coords.y;
3923 gLoc[2]=victim->coords.z;
3927 if(weaponactive!=-1){
3928 victim->DoBloodBig(200,225);
3929 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3930 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3931 OPENAL_SetVolume(channels[knifeslicesound], 512);
3932 OPENAL_SetPaused(channels[knifeslicesound], false);
3933 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3934 weapons.blooddrip[weaponids[weaponactive]]+=5;
3937 if(creature==wolftype&&weaponactive==-1){
3938 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3939 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3940 OPENAL_SetVolume(channels[clawslicesound], 128);
3941 OPENAL_SetPaused(channels[clawslicesound], false);
3943 victim->DoBloodBig(2,175);
3953 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3954 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3956 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3957 if(targetanimation==knifesneakattackanim){
3958 /*victim->DoBloodBig(200,195);
3963 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3964 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3966 XYZ footvel,footpoint;
3968 footpoint=weapons.tippoint[weaponids[0]];
3969 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3970 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3971 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3972 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3973 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3974 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3975 victim->DoBloodBig(200,195);
3982 //victim->neckspurtamount=5;
3984 if(targetanimation==knifefollowanim){
3990 XYZ footvel,footpoint;
3992 footpoint=weapons.tippoint[weaponids[0]];
3993 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3994 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3995 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3996 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3997 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3998 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
4001 victim->bloodloss+=10000;
4005 gLoc[0]=victim->coords.x;
4006 gLoc[1]=victim->coords.y;
4007 gLoc[2]=victim->coords.z;
4011 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4012 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4013 OPENAL_SetVolume(channels[fleshstabsound], 512);
4014 OPENAL_SetPaused(channels[fleshstabsound], false);
4015 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4016 weapons.blooddrip[weaponids[weaponactive]]+=5;
4020 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
4023 for(i=0;i<victim->skeleton.num_joints;i++){
4024 victim->skeleton.joints[i].velocity=0;
4026 if(targetanimation==knifefollowanim){
4028 for(i=0;i<victim->skeleton.num_joints;i++){
4029 victim->skeleton.joints[i].velocity=0;
4032 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
4035 gLoc[0]=victim->coords.x;
4036 gLoc[1]=victim->coords.y;
4037 gLoc[2]=victim->coords.z;
4041 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4042 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4043 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4044 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4045 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4046 weapons.blooddrip[weaponids[weaponactive]]+=5;
4048 XYZ footvel,footpoint;
4050 footpoint=weapons.tippoint[weaponids[0]];
4051 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4052 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4053 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4054 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4055 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4056 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4060 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4061 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4070 XYZ footvel,footpoint;
4072 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
4073 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4074 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4075 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4076 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4077 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4078 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4079 victim->DoBloodBig(200,180);
4080 victim->DoBloodBig(200,215);
4081 victim->bloodloss+=10000;
4085 gLoc[0]=victim->coords.x;
4086 gLoc[1]=victim->coords.y;
4087 gLoc[2]=victim->coords.z;
4091 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4092 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4093 OPENAL_SetVolume(channels[fleshstabsound], 512);
4094 OPENAL_SetPaused(channels[fleshstabsound], false);
4095 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4096 weapons.blooddrip[weaponids[weaponactive]]+=5;
4100 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
4103 for(i=0;i<victim->skeleton.num_joints;i++){
4104 victim->skeleton.joints[i].velocity=0;
4106 if(weaponactive!=-1){
4109 gLoc[0]=victim->coords.x;
4110 gLoc[1]=victim->coords.y;
4111 gLoc[2]=victim->coords.z;
4115 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4116 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4117 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4118 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4119 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4120 weapons.blooddrip[weaponids[weaponactive]]+=5;
4122 XYZ footvel,footpoint;
4124 footpoint=weapons.tippoint[weaponids[0]];
4125 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4126 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4127 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4128 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4129 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4130 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4134 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4136 if(id==0)camerashake+=.4;
4143 gLoc[0]=victim->coords.x;
4144 gLoc[1]=victim->coords.y;
4145 gLoc[2]=victim->coords.z;
4149 if(weaponactive==-1){
4150 if(tutoriallevel!=1){
4151 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4152 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4153 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4154 OPENAL_SetPaused(channels[heavyimpactsound], false);
4159 if(weaponactive!=-1||creature==wolftype)doslice=1;
4160 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4162 if(weaponactive!=-1){
4163 victim->DoBloodBig(2/victim->armorhead,225);
4164 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4165 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4166 OPENAL_SetVolume(channels[knifeslicesound], 512);
4167 OPENAL_SetPaused(channels[knifeslicesound], false);
4168 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4169 weapons.blooddrip[weaponids[weaponactive]]+=3;
4171 if(weaponactive==-1&&creature==wolftype){
4172 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4173 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4174 OPENAL_SetVolume(channels[clawslicesound], 128);
4175 OPENAL_SetPaused(channels[clawslicesound], false);
4177 victim->DoBloodBig(2/victim->armorhead,175);
4190 //relative=victim->coords-oldcoords;
4193 Normalise(&relative);
4194 relative=DoRotation(relative,0,90,0);
4196 Normalise(&relative);
4197 for(i=0;i<victim->skeleton.num_joints;i++){
4198 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4200 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4201 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4202 victim->DoDamage(damagemult*100/victim->protectionhead);
4206 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4210 //relative=victim->coords-oldcoords;
4213 Normalise(&relative);
4214 relative=DoRotation(relative,0,90,0);
4216 Normalise(&relative);
4217 for(i=0;i<victim->skeleton.num_joints;i++){
4218 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4220 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4223 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4224 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4235 if(targetframe>animation[currentanimation].numframes-1){
4238 targetanimation=getIdle();
4242 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4243 targetanimation=rollanim;
4254 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4255 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4256 OPENAL_SetVolume(channels[movewhooshsound], 128);
4257 OPENAL_SetPaused(channels[movewhooshsound], false);
4259 if(currentanimation==staggerbackhighanim){
4260 targetanimation=getIdle();
4262 if(currentanimation==staggerbackhardanim){
4263 targetanimation=getIdle();
4265 if(currentanimation==removeknifeanim){
4266 targetanimation=getIdle();
4268 if(currentanimation==crouchremoveknifeanim){
4269 targetanimation=getCrouch();
4271 if(currentanimation==backhandspringanim){
4272 targetanimation=getIdle();
4274 if(currentanimation==dodgebackanim){
4275 targetanimation=getIdle();
4277 if(currentanimation==drawleftanim){
4278 targetanimation=getIdle();
4280 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4281 targetanimation=getIdle();
4282 if(currentanimation==crouchdrawrightanim){
4283 targetanimation=getCrouch();
4285 if(weaponactive==-1)weaponactive=0;
4286 else if(weaponactive==0){
4290 buffer=weaponids[0];
4291 weaponids[0]=weaponids[1];
4292 weaponids[1]=buffer;
4296 if(weaponactive==-1){
4306 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4307 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4308 OPENAL_SetVolume(channels[knifesheathesound], 128);
4309 OPENAL_SetPaused(channels[knifesheathesound], false);
4311 if(weaponactive!=-1){
4321 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4322 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4323 OPENAL_SetVolume(channels[knifedrawsound], 128);
4324 OPENAL_SetPaused(channels[knifedrawsound], false);
4327 if(currentanimation==rollanim){
4328 targetanimation=getCrouch();
4333 if(targetanimation==walljumprightkickanim){
4336 if(targetanimation==walljumpleftkickanim){
4339 targetanimation=jumpdownanim;
4341 if(currentanimation==climbanim){
4342 targetanimation=getCrouch();
4345 if(!isnormal(coords.x))
4356 if(targetanimation==rabbitkickreversalanim){
4357 targetanimation=getCrouch();
4360 if(targetanimation==jumpreversalanim){
4361 targetanimation=getCrouch();
4364 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4365 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4367 float closestdist=-1;
4370 for(i=0;i<numplayers;i++){
4371 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4372 distance=findDistancefast(&player[i].coords,&coords);
4373 if(closestdist==-1||distance<closestdist){
4374 closestdist=distance;
4379 if(closestdist>0&&closest>=0&&closestdist<16){
4380 victim=&player[closest];
4381 targetanimation=walljumprightkickanim;
4383 XYZ rotatetarget=victim->coords-coords;
4384 Normalise(&rotatetarget);
4385 rotation=-asin(0-rotatetarget.x);
4387 if(rotatetarget.z<0)rotation=180-rotation;
4388 targettilt2=-asin(rotatetarget.y)*360/6.28;
4389 velocity=(victim->coords-coords)*4;
4394 if(targetanimation==walljumpbackanim){
4395 targetanimation=backflipanim;
4399 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4401 if(targetanimation==walljumprightanim){
4402 targetanimation=rightflipanim;
4406 velocity=DoRotation(facing,0,30,0)*-8;
4409 if(targetanimation==walljumpfrontanim){
4410 targetanimation=frontflipanim;
4412 //targetrotation-=180;
4417 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4419 if(targetanimation==walljumpleftanim){
4422 float closestdist=-1;
4425 for(i=0;i<numplayers;i++){
4426 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4427 distance=findDistancefast(&player[i].coords,&coords);
4428 if(closestdist==-1||distance<closestdist){
4429 closestdist=distance;
4434 if(closestdist>0&&closest>=0&&closestdist<16){
4435 victim=&player[closest];
4436 targetanimation=walljumpleftkickanim;
4438 XYZ rotatetarget=victim->coords-coords;
4439 Normalise(&rotatetarget);
4440 rotation=-asin(0-rotatetarget.x);
4442 if(rotatetarget.z<0)rotation=180-rotation;
4443 targettilt2=-asin(rotatetarget.y)*360/6.28;
4444 velocity=(victim->coords-coords)*4;
4449 if(targetanimation!=walljumpleftkickanim){
4450 targetanimation=leftflipanim;
4454 velocity=DoRotation(facing,0,-30,0)*-8;
4457 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4459 if(targetanimation==sneakattackanim){
4460 float ycoords=oldcoords.y;
4461 currentanimation=getCrouch();
4462 targetanimation=getCrouch();
4465 targetrotation+=180;
4470 targetheadrotation+=180;
4472 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4476 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4477 float ycoords=oldcoords.y;
4478 targetanimation=getIdle();
4480 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4484 if(currentanimation==knifefollowanim){
4485 targetanimation=getIdle();
4488 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4489 float ycoords=oldcoords.y;
4490 targetanimation=getStop();
4491 targetrotation+=180;
4496 targetheadrotation+=180;
4497 if(!isnormal(coords.x))
4499 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4500 oldcoords=coords+facing*.5;
4501 else if(currentanimation==sweepreversalanim)
4502 oldcoords=coords+facing*1.1;
4503 else if(currentanimation==upunchreversalanim){
4504 oldcoords=coords+facing*1.5;
4505 targetrotation+=180;
4507 targetheadrotation+=180;
4511 else if(currentanimation==knifeslashreversalanim){
4512 oldcoords=coords+facing*.5;
4515 targetheadrotation+=90;
4519 else if(currentanimation==staffspinhitreversalanim){
4520 targetrotation+=180;
4522 targetheadrotation+=180;
4526 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4527 else oldcoords.y=ycoords;
4528 currentoffset=coords-oldcoords;
4534 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4539 if(animation[targetanimation].attack==reversed){
4541 if(targetanimation==sweepreversedanim)targetrotation+=90;
4542 targetanimation=backhandspringanim;
4552 PlaySoundEx( landsound, samp[landsound], NULL, true);
4553 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4554 OPENAL_SetVolume(channels[landsound], 128);
4555 OPENAL_SetPaused(channels[landsound], false);
4557 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4558 targetanimation=rollanim;
4561 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4562 coords.y=oldcoords.y;
4564 if(currentanimation==knifeslashreversedanim){
4565 targetanimation=rollanim;
4570 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4571 coords.y=oldcoords.y;
4575 targetanimation=jumpdownanim;
4577 if(wasLanding())targetanimation=getIdle();
4578 if(wasLandhard())targetanimation=getIdle();
4579 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4580 targetanimation=getIdle();
4582 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4583 coords.y=oldcoords.y;
4584 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4585 targetoffset.y=coords.y;
4586 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4587 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4588 currentoffset.y-=(coords.y-targetoffset.y);
4589 coords.y=targetoffset.y;
4591 normalsupdatedelay=0;
4593 if(currentanimation==upunchanim){
4594 targetanimation=getStop();
4595 normalsupdatedelay=0;
4598 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4599 targetrotation=rotation;
4602 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4603 if(!hasstaff)DoDamage(35);
4606 rabbitkickragdoll=1;
4608 if(currentanimation==rabbitkickreversedanim){
4615 if(id!=0)SolidHitBonus();
4619 targetanimation=rollanim;
4621 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4625 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4631 if(currentanimation==jumpreversedanim){
4638 if(id!=0)SolidHitBonus();
4642 targetanimation=rollanim;
4644 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4649 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){
4650 targetanimation=getupfromfrontanim;
4653 else if(animation[currentanimation].attack==normalattack){
4654 targetanimation=getIdle();
4657 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4658 targetanimation=blockhighleftstrikeanim;
4660 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4661 targetanimation=getIdle();
4664 if(currentanimation==spinkickanim&&victim->skeleton.free){
4665 if(creature==rabbittype)targetanimation=fightidleanim;
4670 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4672 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4673 targetanimation=jumpdownanim;
4678 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4679 if(!isRun()||!wasRun()){
4680 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4681 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4682 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4683 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4685 if(isRun()&&wasRun()){
4688 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4689 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4692 else if(transspeed)target+=multiplier*transspeed*speed*2;
4694 if(!isRun()||!wasRun()){
4695 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4696 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4697 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4698 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4702 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4704 if(target>1){currentframe=targetframe; target=1;}
4706 rot=targetrot*target;
4707 rotation+=rot-oldrot;
4713 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4715 for(i=0;i<skeleton.num_joints;i++){
4716 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4719 skeleton.FindForwards();
4721 for(i=0;i<skeleton.num_muscles;i++){
4722 if(skeleton.muscles[i].visible)
4724 skeleton.FindRotationMuscle(i,targetanimation);
4727 for(i=0;i<skeleton.num_muscles;i++){
4728 if(skeleton.muscles[i].visible)
4730 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4731 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4732 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4737 for(i=0;i<skeleton.num_joints;i++){
4738 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4741 skeleton.FindForwards();
4743 for(i=0;i<skeleton.num_muscles;i++){
4744 if(skeleton.muscles[i].visible)
4746 skeleton.FindRotationMuscle(i,targetanimation);
4749 for(i=0;i<skeleton.num_muscles;i++){
4750 if(skeleton.muscles[i].visible)
4752 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4753 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4754 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4755 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4756 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4757 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4758 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4759 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4760 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4764 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4766 oldcurrentanimation=currentanimation;
4767 oldtargetanimation=targetanimation;
4768 oldtargetframe=targetframe;
4769 oldcurrentframe=currentframe;
4771 for(i=0;i<skeleton.num_joints;i++){
4772 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4773 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4775 offset=currentoffset*(1-target)+targetoffset*target;
4776 for(i=0;i<skeleton.num_muscles;i++){
4777 if(skeleton.muscles[i].visible)
4779 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4780 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4781 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4786 if(isLanding()&&landhard){
4787 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4788 if(id==0)camerashake+=.4;
4789 targetanimation=getLandhard();
4797 //skeleton.DoConstraints();
4800 void Person::DoStuff(){
4801 static XYZ terrainnormal;
4802 static XYZ flatfacing;
4803 static XYZ flatvelocity;
4804 static float flatvelspeed;
4808 static int bloodsize;
4809 static int startx,starty,endx,endy;
4810 static int texdetailint;
4811 static GLubyte color;
4812 static XYZ bloodvel;
4814 onfiredelay-=multiplier;
4815 if(onfiredelay<0&&onfire)
4823 crouchkeydowntime+=multiplier;
4824 if(!crouchkeydown)crouchkeydowntime=0;
4825 jumpkeydowntime+=multiplier;
4826 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
4828 if(hostile||damage>0||bloodloss>0)immobile=0;
4830 if(isIdle()||isRun())targetoffset=0;
4832 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
4834 if(id==0)blooddimamount-=multiplier*.3;
4835 speechdelay-=multiplier;
4836 texupdatedelay-=multiplier;
4837 interestdelay-=multiplier;
4838 flamedelay-=multiplier;
4839 parriedrecently-=multiplier;
4845 if(id==0)speed=1.1*speedmult;
4846 else speed=1.0*speedmult;
4847 if(!skeleton.free)rabbitkickragdoll=0;
4851 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
4852 if(id!=0&&creature==wolftype&&difficulty==2){
4854 if(aitype!=passivetype){
4856 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){
4860 if(scale<0.2)superruntoggle=0;
4861 if(targetanimation==wolfrunninganim&&!superruntoggle){
4862 targetanimation=getRun();
4866 if(weaponactive==-1&&num_weapons>0){
4867 if(weapons.type[weaponids[0]]==staff){
4874 /*if(aitype!=playercontrolled)*///deathbleeding=5;
4875 /*if(aitype!=playercontrolled)*/
4877 if(burnt>.6)burnt=.6;
4878 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
4880 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
4891 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4892 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
4896 while(flamedelay<0&&onfire){
4898 howmany=abs(Random()%(skeleton.num_joints));
4899 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4900 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4901 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4902 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4903 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
4906 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
4908 howmany=abs(Random()%(skeleton.num_joints));
4909 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4910 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4911 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4912 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4913 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
4917 bleeding-=multiplier*.3;
4919 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4920 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
4924 if(neckspurtamount>0){
4925 neckspurtamount-=multiplier;
4926 neckspurtdelay-=multiplier*3;
4927 neckspurtparticledelay-=multiplier*3;
4928 if(neckspurtparticledelay<0&&neckspurtdelay>2){
4932 bloodvel.z=5*neckspurtamount;
4933 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4936 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
4938 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4939 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
4940 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);
4941 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);
4942 neckspurtparticledelay=.05;
4944 if(neckspurtdelay<0){
4949 if(deathbleeding>0&&dead!=2){
4950 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
4951 else bleeddelay-=5*multiplier/4;
4952 if(bleeddelay<0&&bloodtoggle){
4957 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4958 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
4959 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
4960 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);
4963 bloodloss+=deathbleeding*multiplier*80;
4964 deathbleeding-=multiplier*1.6;
4965 //if(id==0)deathbleeding-=multiplier*.2;
4966 if(deathbleeding<0)deathbleeding=0;
4967 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
4968 if(weaponactive!=-1){
4969 weapons.owner[weaponids[0]]=-1;
4970 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4971 weapons.velocity[weaponids[0]].x+=.01;
4972 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4973 weapons.missed[weaponids[0]]=1;
4974 weapons.hitsomething[weaponids[0]]=0;
4975 weapons.freetime[weaponids[0]]=0;
4976 weapons.firstfree[weaponids[0]]=1;
4977 weapons.physics[weaponids[0]]=1;
4980 weaponids[0]=weaponids[num_weapons];
4981 if(weaponstuck==num_weapons)weaponstuck=0;
4984 for(i=0;i<numplayers;i++){
4985 player[i].wentforweapon=0;
4997 if(!dead&&creature==wolftype){
5003 if(targetanimation==knifefollowedanim&&!skeleton.free){
5004 for(i=0;i<skeleton.num_joints;i++){
5005 skeleton.joints[i].velocity=0;
5006 skeleton.joints[i].velocity.y=-2;
5009 if(id!=0&&unconscioustime>.1){
5017 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
5020 bloodsize=5-realtexdetail;
5024 texdetailint=realtexdetail;
5025 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5026 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5027 endx=startx+bloodsize;
5028 endy=starty+bloodsize;
5030 if(startx<0){startx=0;bleeding=0;}
5031 if(starty<0){starty=0;bleeding=0;}
5032 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
5033 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
5034 if(endx<startx)endx=startx;
5035 if(endy<starty)endy=starty;
5037 for(i=startx;i<endx;i++){
5038 for(j=starty;j<endy;j++){
5040 color=Random()%85+170;
5041 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
5042 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
5043 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
5048 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5049 DoMipmaps(0,startx,endx,starty,endy);
5053 bleedy-=4/realtexdetail;
5054 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
5055 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
5058 bleedx+=4*direction/realtexdetail;
5059 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
5060 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
5064 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
5065 righthandmorphness=targetrighthandmorphness;
5066 righthandmorphstart=righthandmorphend;
5068 else if(righthandmorphness>targetrighthandmorphness){
5069 righthandmorphness-=multiplier*4;
5071 else if(righthandmorphness<targetrighthandmorphness){
5072 righthandmorphness+=multiplier*4;
5075 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
5076 lefthandmorphness=targetlefthandmorphness;
5077 lefthandmorphstart=lefthandmorphend;
5079 else if(lefthandmorphness>targetlefthandmorphness){
5080 lefthandmorphness-=multiplier*4;
5082 else if(lefthandmorphness<targetlefthandmorphness){
5083 lefthandmorphness+=multiplier*4;
5086 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
5087 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
5088 tailmorphness=targettailmorphness;
5089 tailmorphstart=tailmorphend;
5091 else if(tailmorphness>targettailmorphness){
5092 tailmorphness-=multiplier*10;
5094 else if(tailmorphness<targettailmorphness){
5095 tailmorphness+=multiplier*10;
5099 if(creature==wolftype){
5100 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
5101 tailmorphness=targettailmorphness;
5102 tailmorphstart=tailmorphend;
5104 else if(tailmorphness>targettailmorphness){
5105 tailmorphness-=multiplier*2;
5107 else if(tailmorphness<targettailmorphness){
5108 tailmorphness+=multiplier*2;
5112 if(headmorphend==3||headmorphstart==3){
5113 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
5114 headmorphness=targetheadmorphness;
5115 headmorphstart=headmorphend;
5117 else if(headmorphness>targetheadmorphness){
5118 headmorphness-=multiplier*7;
5120 else if(headmorphness<targetheadmorphness){
5121 headmorphness+=multiplier*7;
5124 else if(headmorphend==5||headmorphstart==5){
5125 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
5126 headmorphness=targetheadmorphness;
5127 headmorphstart=headmorphend;
5129 else if(headmorphness>targetheadmorphness){
5130 headmorphness-=multiplier*10;
5132 else if(headmorphness<targetheadmorphness){
5133 headmorphness+=multiplier*10;
5137 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5138 headmorphness=targetheadmorphness;
5139 headmorphstart=headmorphend;
5141 else if(headmorphness>targetheadmorphness){
5142 headmorphness-=multiplier*4;
5144 else if(headmorphness<targetheadmorphness){
5145 headmorphness+=multiplier*4;
5149 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5150 chestmorphness=targetchestmorphness;
5151 chestmorphstart=chestmorphend;
5153 else if(chestmorphness>targetchestmorphness){
5154 chestmorphness-=multiplier;
5156 else if(chestmorphness<targetchestmorphness){
5157 chestmorphness+=multiplier;
5160 if(dead!=2&&howactive<=typesleeping){
5161 if(chestmorphstart==0&&chestmorphend==0){
5163 targetchestmorphness=1;
5166 if(chestmorphstart!=0&&chestmorphend!=0){
5168 targetchestmorphness=1;
5170 if(environment==snowyenvironment){
5173 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5174 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5175 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5176 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5177 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5178 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5182 if(!dead&&howactive<typesleeping){
5183 blinkdelay-=multiplier*2;
5184 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5186 targetheadmorphness=1;
5188 blinkdelay=(float)(abs(Random()%40))/5;
5190 if(headmorphstart==3&&headmorphend==3){
5192 targetheadmorphness=1;
5197 twitchdelay-=multiplier*1.5;
5198 if(targetanimation!=hurtidleanim){
5199 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5201 targetheadmorphness=1;
5203 twitchdelay=(float)(abs(Random()%40))/5;
5205 if(headmorphstart==5&&headmorphend==5){
5207 targetheadmorphness=1;
5211 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5212 twitchdelay3-=multiplier*1;
5214 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5215 righthandmorphness=0;
5216 targetrighthandmorphness=1;
5217 righthandmorphend=1;
5218 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5220 if(righthandmorphstart==1&&righthandmorphend==1){
5221 righthandmorphness=0;
5222 targetrighthandmorphness=1;
5223 righthandmorphend=0;
5227 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5228 lefthandmorphness=0;
5229 targetlefthandmorphness=1;
5231 twitchdelay3=(float)(abs(Random()%40))/5;
5233 if(lefthandmorphstart==1&&lefthandmorphend==1){
5234 lefthandmorphness=0;
5235 targetlefthandmorphness=1;
5242 if(creature==rabbittype){
5243 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5244 else twitchdelay2-=multiplier*0.5;
5245 if(howactive<=typesleeping){
5246 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5248 targettailmorphness=1;
5250 twitchdelay2=(float)(abs(Random()%40))/5;
5252 if(tailmorphstart==1&&tailmorphend==1){
5254 targettailmorphness=1;
5257 if(tailmorphstart==2&&tailmorphend==2){
5259 targettailmorphness=1;
5266 if(creature==wolftype){
5267 twitchdelay2-=multiplier*1.5;
5269 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5271 targettailmorphness=1;
5276 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5278 targettailmorphness=1;
5282 if(twitchdelay2<=0){
5283 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5285 targettailmorphness=1;
5288 if(tailmorphstart==1&&tailmorphend==1){
5290 targettailmorphness=1;
5293 if(tailmorphstart==2&&tailmorphend==2){
5295 targettailmorphness=1;
5298 if(tailmorphstart==3&&tailmorphend==3){
5300 targettailmorphness=1;
5303 if(tailmorphstart==4&&tailmorphend==4){
5305 targettailmorphness=1;
5311 if(dead!=1)unconscioustime=0;
5313 if(dead==1||howactive==typesleeping){
5314 unconscioustime+=multiplier;
5315 //If unconscious, close eyes and mouth
5316 if(righthandmorphend!=0)righthandmorphness=0;
5317 righthandmorphend=0;
5318 targetrighthandmorphness=1;
5320 if(lefthandmorphend!=0)lefthandmorphness=0;
5322 targetlefthandmorphness=1;
5324 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5326 targetheadmorphness=1;
5330 if(howactive>typesleeping){
5333 if(bloodtoggle&&!bled){
5334 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5336 if(bloodtoggle&&!bled)
5337 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5338 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5339 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5343 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5348 if(dead==2||howactive>typesleeping){
5349 //If dead, open mouth and hands
5350 if(righthandmorphend!=0)righthandmorphness=0;
5351 righthandmorphend=0;
5352 targetrighthandmorphness=1;
5354 if(lefthandmorphend!=0)lefthandmorphness=0;
5356 targetlefthandmorphness=1;
5358 if(headmorphend!=2)headmorphness=0;
5360 targetheadmorphness=1;
5363 if(stunned>0&&!dead&&headmorphend!=2){
5364 if(headmorphend!=4)headmorphness=0;
5366 targetheadmorphness=1;
5369 if(damage>damagetolerance&&!dead){
5374 if(creature==wolftype){
5382 if(weaponactive!=-1){
5383 weapons.owner[weaponids[0]]=-1;
5384 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5385 weapons.velocity[weaponids[0]].x+=.01;
5386 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5387 weapons.missed[weaponids[0]]=1;
5388 weapons.hitsomething[weaponids[0]]=0;
5389 weapons.freetime[weaponids[0]]=0;
5390 weapons.firstfree[weaponids[0]]=1;
5391 weapons.physics[weaponids[0]]=1;
5394 weaponids[0]=weaponids[num_weapons];
5395 if(weaponstuck==num_weapons)weaponstuck=0;
5398 for(i=0;i<numplayers;i++){
5399 player[i].wentforweapon=0;
5405 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5413 //if(dead)damage-=multiplier/4;
5414 if(!dead)damage-=multiplier*13;
5415 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5416 if(!dead)permanentdamage-=multiplier*4;
5417 if(isIdle()||isCrouch()){
5418 if(!dead)permanentdamage-=multiplier*4;
5419 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5421 if(damage<0)damage=0;
5422 if(permanentdamage<0)permanentdamage=0;
5423 if(superpermanentdamage<0)superpermanentdamage=0;
5424 if(permanentdamage<superpermanentdamage){
5425 permanentdamage=superpermanentdamage;
5427 if(damage<permanentdamage){
5428 damage=permanentdamage;
5430 if(dead==1&&damage<damagetolerance){
5434 for(i=0;i<skeleton.num_joints;i++){
5435 skeleton.joints[i].velocity=0;
5438 if(permanentdamage>damagetolerance&&dead!=2){
5441 if(weaponactive!=-1){
5442 weapons.owner[weaponids[0]]=-1;
5443 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5444 weapons.velocity[weaponids[0]].x+=.01;
5445 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5446 weapons.missed[weaponids[0]]=1;
5447 weapons.hitsomething[weaponids[0]]=0;
5448 weapons.freetime[weaponids[0]]=0;
5449 weapons.firstfree[weaponids[0]]=1;
5450 weapons.physics[weaponids[0]]=1;
5453 weaponids[0]=weaponids[num_weapons];
5454 if(weaponstuck==num_weapons)weaponstuck=0;
5457 for(i=0;i<numplayers;i++){
5458 player[i].wentforweapon=0;
5464 if(!dead&&creature==wolftype){
5470 if(id!=0&&unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance){
5475 if(id!=0&&unconscioustime>.1){
5491 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5492 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5493 OPENAL_SetVolume(channels[breaksound], 512);
5494 OPENAL_SetPaused(channels[breaksound], false);
5495 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5501 if(skeleton.free==1){
5502 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5505 //If knocked over, open hands and close mouth
5506 if(righthandmorphend!=0)righthandmorphness=0;
5507 righthandmorphend=0;
5508 targetrighthandmorphness=1;
5510 if(lefthandmorphend!=0)lefthandmorphness=0;
5512 targetlefthandmorphness=1;
5514 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5515 if(headmorphend!=0)headmorphness=0;
5517 targetheadmorphness=1;
5521 skeleton.DoGravity(&scale);
5523 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5524 if(id!=0&&damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1)){
5529 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5533 for(j=0;j<skeleton.num_joints;j++){
5534 average+=skeleton.joints[j].position;
5538 coords+=average*scale;
5539 for(j=0;j<skeleton.num_joints;j++){
5540 skeleton.joints[j].position-=average;
5542 average/=multiplier;
5544 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5546 for(i=0;i<skeleton.num_joints;i++){
5547 velocity+=skeleton.joints[i].velocity*scale;
5549 velocity/=skeleton.num_joints;
5551 if(!isnormal(velocity.x)&&velocity.x){
5564 if(findLength(&average)<10&&dead&&skeleton.free){
5565 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5566 if(skeleton.longdead>2000){
5567 if(skeleton.longdead>6000){
5568 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5573 if(dead==2&&bloodloss<damagetolerance){
5575 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5577 if(bloodtoggle&&!bled){
5578 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5580 if(bloodtoggle&&!bled)
5581 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5582 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5583 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5587 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5591 if(dead==2&&bloodloss>=damagetolerance){
5593 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5594 if(bleeding<=0)DoBlood(1,255);
5595 if(bloodtoggle&&!bled){
5596 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5598 if(bloodtoggle&&!bled)
5599 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5600 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5601 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5605 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5612 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5614 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5618 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5619 if(velocity.y<-30)canrecover=0;
5620 for(i=0;i<objects.numobjects;i++){
5621 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5622 colviewer=startpoint;
5624 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5632 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5633 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5634 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5635 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5637 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5638 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5639 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5641 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5642 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5643 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5645 Normalise(&terrainnormal);
5647 targetrotation=-asin(0-terrainnormal.x);
5648 targetrotation*=360/6.28;
5649 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5650 rotation=targetrotation;
5652 //if(skeleton.forward.y<0){
5655 //if(skeleton.forward.y>-.3){
5658 targetanimation=flipanim;
5659 crouchtogglekeydown=1;
5664 currentanimation=tempanim;
5667 //tilt2=targettilt2;
5669 //if(middle.y>0)targetoffset.y=middle.y+1;
5671 for(i=0;i<skeleton.num_joints;i++){
5672 tempanimation.position[i][0]=skeleton.joints[i].position;
5673 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5678 if(findLength(&average)<10&&!dead&&skeleton.free){
5679 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5680 if(skeleton.longdead>(damage+500)*1.5){
5681 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5687 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5688 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5689 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5690 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5692 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5693 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5694 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5696 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5697 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5698 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5700 Normalise(&terrainnormal);
5702 targetrotation=-asin(0-terrainnormal.x);
5703 targetrotation*=360/6.28;
5704 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5705 rotation=targetrotation;
5708 terrainnormal=terrain.getNormal(coords.x,coords.z);
5709 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5713 /*XYZ otherterrainnormal;
5714 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5715 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5716 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5717 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5720 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5724 if(skeleton.forward.y<0){
5725 targetanimation=getupfrombackanim;
5729 if(skeleton.forward.y>-.3){
5730 targetanimation=getupfromfrontanim;
5732 targetrotation+=180;
5738 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5739 targetanimation=rollanim;
5740 targetrotation=lookrotation;
5744 if(forwardkeydown)targetrotation+=45;
5745 if(backkeydown)targetrotation-=45;
5749 if(forwardkeydown)targetrotation-=45;
5750 if(backkeydown)targetrotation+=45;
5753 if ( !leftkeydown&&!rightkeydown)
5754 targetrotation+=180;
5756 targetrotation+=180;
5760 if(abs(targettilt2)>50)targettilt2=0;
5761 currentanimation=tempanim;
5766 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5768 for(i=0;i<skeleton.num_joints;i++){
5769 tempanimation.position[i][0]=skeleton.joints[i].position;
5770 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5777 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5778 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5781 tempvelocity=velocity;
5782 Normalise(&tempvelocity);
5783 targetrotation=-asin(0-tempvelocity.x);
5784 targetrotation*=360/6.28;
5785 if(velocity.z<0)targetrotation=180-targetrotation;
5786 //targetrotation+=180;
5789 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5790 targetanimation=rollanim;
5794 targetanimation=backhandspringanim;
5795 targetrotation+=180;
5808 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
5809 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
5810 OPENAL_SetVolume(channels[movewhooshsound], 128);
5811 OPENAL_SetPaused(channels[movewhooshsound], false);
5813 currentanimation=targetanimation;
5814 currentframe=targetframe-1;
5819 rotation=targetrotation;
5826 if(skeleton.freefall==0)freefall=0;
5828 if(!isnormal(velocity.x)&&velocity.x){
5833 if(aitype!=passivetype||skeleton.free==1)
5834 if(findLengthfast(&velocity)>.1)
5835 for(i=0;i<objects.numobjects;i++){
5836 if(objects.type[i]==firetype)
5837 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){
5839 if(!objects.onfire[i]){
5842 gLoc[0]=objects.position[i].x;
5843 gLoc[1]=objects.position[i].y;
5844 gLoc[2]=objects.position[i].z;
5848 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5849 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5850 OPENAL_SetVolume(channels[firestartsound], 256);
5851 OPENAL_SetPaused(channels[firestartsound], false);
5853 objects.onfire[i]=1;
5856 if(objects.onfire[i]){
5861 if(objects.type[i]==bushtype)
5862 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){
5864 if(!objects.onfire[i]){
5867 gLoc[0]=objects.position[i].x;
5868 gLoc[1]=objects.position[i].y;
5869 gLoc[2]=objects.position[i].z;
5873 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5874 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5875 OPENAL_SetVolume(channels[firestartsound], 256);
5876 OPENAL_SetPaused(channels[firestartsound], false);
5878 objects.onfire[i]=1;
5882 if(objects.onfire[i]){
5886 if(objects.messedwith[i]<=0){
5898 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5899 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5900 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5901 OPENAL_SetPaused(channels[bushrustle], false);
5904 envsound[numenvsounds]=coords;
5905 envsoundvol[numenvsounds]=4*findLength(&velocity);
5906 envsoundlife[numenvsounds]=.4;
5911 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5912 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5914 if(environment!=desertenvironment)
5915 for(j=0;j<howmany;j++){
5916 tempvel.x=float(abs(Random()%100)-50)/20;
5917 tempvel.y=float(abs(Random()%100)-50)/20;
5918 tempvel.z=float(abs(Random()%100)-50)/20;
5921 pos.x+=float(abs(Random()%100)-50)/200;
5922 pos.y+=float(abs(Random()%100)-50)/200;
5923 pos.z+=float(abs(Random()%100)-50)/200;
5924 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);
5925 Sprite::setLastSpriteSpecial(1);
5927 howmany=findLength(&velocity)*4;
5929 if(environment==snowyenvironment)
5930 for(j=0;j<howmany;j++){
5931 tempvel.x=float(abs(Random()%100)-50)/20;
5932 tempvel.y=float(abs(Random()%100)-50)/20;
5933 tempvel.z=float(abs(Random()%100)-50)/20;
5936 pos.x+=float(abs(Random()%100)-50)/200;
5937 pos.y+=float(abs(Random()%100)-50)/200;
5938 pos.z+=float(abs(Random()%100)-50)/200;
5939 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5940 Sprite::setLastSpriteSpecial(2);
5943 objects.rotx[i]+=velocity.x*multiplier*6;
5944 objects.roty[i]+=velocity.z*multiplier*6;
5945 objects.messedwith[i]=.5;
5948 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
5949 if(objects.rotation2[i]==0)tempcoord=coords;
5951 tempcoord=coords-objects.position[i];
5952 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
5953 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
5954 tempcoord+=objects.position[i];
5956 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]){
5957 if(objects.messedwith[i]<=0){
5969 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5970 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5971 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5972 OPENAL_SetPaused(channels[bushrustle], false);
5975 envsound[numenvsounds]=coords;
5976 envsoundvol[numenvsounds]=4*findLength(&velocity);
5977 envsoundlife[numenvsounds]=.4;
5982 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5983 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5985 if(environment!=desertenvironment)
5986 for(j=0;j<howmany;j++){
5987 tempvel.x=float(abs(Random()%100)-50)/20;
5988 tempvel.y=float(abs(Random()%100)-50)/20;
5989 tempvel.z=float(abs(Random()%100)-50)/20;
5993 pos.x+=float(abs(Random()%100)-50)/150;
5994 pos.y+=float(abs(Random()%100)-50)/150;
5995 pos.z+=float(abs(Random()%100)-50)/150;
5996 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);
5997 Sprite::setLastSpriteSpecial(1);
5999 howmany=findLength(&velocity)*4;
6001 if(environment==snowyenvironment)
6002 for(j=0;j<howmany;j++){
6003 tempvel.x=float(abs(Random()%100)-50)/20;
6004 tempvel.y=float(abs(Random()%100)-50)/20;
6005 tempvel.z=float(abs(Random()%100)-50)/20;
6009 pos.x+=float(abs(Random()%100)-50)/150;
6010 pos.y+=float(abs(Random()%100)-50)/150;
6011 pos.z+=float(abs(Random()%100)-50)/150;
6012 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6013 Sprite::setLastSpriteSpecial(2);
6016 objects.messedwith[i]=.5;
6024 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
6026 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
6027 if(tutoriallevel==1&&id!=0)play=0;
6028 if(play&&aitype!=playercontrolled){
6040 if(creature==rabbittype){
6041 if(i==0)whichsound=rabbitchitter;
6042 if(i==1)whichsound=rabbitchitter2;
6044 if(creature==wolftype){
6045 if(i==0)whichsound=growlsound;
6046 if(i==1)whichsound=growl2sound;
6052 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
6053 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
6054 OPENAL_SetVolume(channels[whichsound], 512);
6055 OPENAL_SetPaused(channels[whichsound], false);
6059 if(targetanimation==staggerbackhighanim)staggerdelay=1;
6060 if(targetanimation==staggerbackhardanim)staggerdelay=1;
6061 staggerdelay-=multiplier;
6062 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
6063 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
6064 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
6065 targetanimation=getIdle();
6069 weaponmissdelay-=multiplier;
6070 highreversaldelay-=multiplier;
6071 lowreversaldelay-=multiplier;
6072 lastcollide-=multiplier;
6073 skiddelay-=multiplier;
6074 if(!isnormal(velocity.x)&&velocity.x){
6077 if(!isnormal(targettilt)&&targettilt){
6080 if(!isnormal(targettilt2)&&targettilt2){
6083 if(!isnormal(targetrotation)&&targetrotation){
6087 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
6088 //open hands and close mouth
6089 //if(targetanimation!=wolfidle){
6090 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6091 righthandmorphness=0;
6092 righthandmorphend=0;
6093 targetrighthandmorphness=1;
6096 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6097 lefthandmorphness=0;
6099 targetlefthandmorphness=1;
6103 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
6106 targetheadmorphness=1;
6110 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){
6111 //open hands and mouth
6112 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6113 righthandmorphness=0;
6114 righthandmorphend=0;
6115 targetrighthandmorphness=1;
6118 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6119 lefthandmorphness=0;
6121 targetlefthandmorphness=1;
6124 if(headmorphend!=1&&headmorphness==targetheadmorphness){
6127 targetheadmorphness=1;
6131 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
6132 //close hands and mouth
6133 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6134 righthandmorphness=0;
6135 righthandmorphend=1;
6136 targetrighthandmorphness=1;
6139 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6140 lefthandmorphness=0;
6142 targetlefthandmorphness=1;
6145 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6148 targetheadmorphness=1;
6152 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){
6153 //close hands and yell
6154 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6155 righthandmorphness=0;
6156 righthandmorphend=1;
6157 targetrighthandmorphness=1;
6160 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6161 lefthandmorphness=0;
6163 targetlefthandmorphness=1;
6166 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6169 targetheadmorphness=1;
6173 if(speechdelay>.25){
6174 if(headmorphend!=2)headmorphness=0;
6176 targetheadmorphness=1;
6182 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6183 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6187 if(!dead&&targetanimation!=hurtidleanim)
6188 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6189 if(headmorphend!=4||headmorphness==targetheadmorphness){
6192 targetheadmorphness=1;
6196 if(weaponactive!=-1){
6197 if(weapons.type[weaponids[weaponactive]]!=staff){
6198 righthandmorphstart=1;
6199 righthandmorphend=1;
6201 if(weapons.type[weaponids[weaponactive]]==staff){
6202 righthandmorphstart=2;
6203 righthandmorphend=2;
6205 targetrighthandmorphness=1;
6208 terrainnormal=terrain.getNormal(coords.x,coords.z);
6210 if(animation[targetanimation].attack!=reversal){
6211 if(!isnormal(coords.x))
6219 flatfacing=DoRotation(flatfacing,0,rotation,0);
6221 ReflectVector(&facing,terrainnormal);
6224 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6225 if(onterrain)targettilt2=-facing.y*20;
6229 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6230 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6231 flatvelocity=velocity;
6233 flatvelspeed=findLength(&flatvelocity);
6234 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6235 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6236 if(velocity.y<0)targettilt2*=-1;
6237 if(velocity.y<0)targettilt*=-1;
6238 if(targettilt>25)targettilt=25;
6239 if(targettilt<-25)targettilt=-25;
6242 if(targettilt2>45)targettilt2=45;
6243 if(targettilt2<-45)targettilt2=-45;
6244 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6245 else if(tilt2>targettilt2){
6246 tilt2-=multiplier*400;
6248 else if(tilt2<targettilt2){
6249 tilt2+=multiplier*400;
6251 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6252 if(tilt2>25)tilt2=25;
6253 if(tilt2<-25)tilt2=-25;
6256 if(!isnormal(targettilt)&&targettilt){
6259 if(!isnormal(targettilt2)&&targettilt2){
6264 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6265 if(targetanimation==rabbittackleanim){
6266 velocity+=facing*multiplier*speed*700*scale;
6267 velspeed=findLength(&velocity);
6268 if(velspeed>speed*65*scale){
6270 velspeed=speed*65*scale;
6273 velocity.y+=gravity*multiplier*20;
6274 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6275 velspeed=findLength(&velocity);
6276 velocity=flatfacing*velspeed;
6278 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6279 if(isRun()||targetanimation==rabbitkickanim){
6280 velocity+=facing*multiplier*speed*700*scale;
6281 velspeed=findLength(&velocity);
6282 if(velspeed>speed*45*scale){
6284 velspeed=speed*45*scale;
6287 velocity.y+=gravity*multiplier*20;
6288 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6289 velspeed=findLength(&velocity);
6290 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6291 velocity=flatfacing*velspeed;
6295 velocity+=facing*multiplier*speed*700*scale;
6296 velspeed=findLength(&velocity);
6297 if(creature==rabbittype){
6298 if(velspeed>speed*55*scale){
6300 velspeed=speed*55*scale;
6304 if(creature==wolftype){
6305 if(velspeed>speed*75*scale){
6307 velspeed=speed*75*scale;
6311 velocity.y+=gravity*multiplier*20;
6312 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6313 velspeed=findLength(&velocity);
6314 velocity=flatfacing*velspeed;
6317 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6318 velocity+=facing*multiplier*speed*700*scale;
6319 velspeed=findLength(&velocity);
6320 if(velspeed>speed*45*scale){
6322 velspeed=speed*45*scale;
6325 velocity.y+=gravity*multiplier*20;
6326 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6327 velspeed=findLength(&velocity);
6328 velocity=flatfacing*velspeed;
6332 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6333 velocity+=facing*multiplier*speed*700*scale;
6334 velspeed=findLength(&velocity);
6335 if(velspeed>speed*25*scale){
6337 velspeed=speed*25*scale;
6340 velocity.y+=gravity*multiplier*20;
6341 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6342 velspeed=findLength(&velocity);
6343 velocity=flatfacing*velspeed;
6346 if(targetanimation==sneakanim||targetanimation==walkanim){
6347 velocity+=facing*multiplier*speed*700*scale;
6348 velspeed=findLength(&velocity);
6349 if(velspeed>speed*12*scale){
6351 velspeed=speed*12*scale;
6354 velocity.y+=gravity*multiplier*20;
6355 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6356 velspeed=findLength(&velocity);
6357 velocity=flatfacing*velspeed;
6360 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6361 velocity+=facing*multiplier*speed*700*scale;
6362 velspeed=findLength(&velocity);
6363 if(velspeed>speed*2*scale){
6365 velspeed=speed*2*scale;
6368 velocity.y+=gravity*multiplier*20;
6369 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6370 velspeed=findLength(&velocity);
6371 velocity=flatfacing*velspeed;
6375 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6376 velocity-=facing*multiplier*speed*700*scale;
6377 velspeed=findLength(&velocity);
6378 if(velspeed>speed*2*scale){
6380 velspeed=speed*2*scale;
6383 velocity.y+=gravity*multiplier*20;
6384 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6385 velspeed=findLength(&velocity);
6386 velocity=flatfacing*velspeed*-1;
6389 if(targetanimation==fightsidestep){
6390 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6391 velspeed=findLength(&velocity);
6392 if(velspeed>speed*12*scale){
6394 velspeed=speed*12*scale;
6397 velocity.y+=gravity*multiplier*20;
6398 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6399 velspeed=findLength(&velocity);
6400 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6403 if(targetanimation==staggerbackhighanim){
6404 coords-=facing*multiplier*speed*16*scale;
6407 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6408 coords-=facing*multiplier*speed*20*scale;
6412 if(targetanimation==backhandspringanim){
6413 //coords-=facing*multiplier*50*scale;
6414 velocity+=facing*multiplier*speed*700*scale*-1;
6415 velspeed=findLength(&velocity);
6416 if(velspeed>speed*50*scale){
6418 velspeed=speed*50*scale;
6421 velocity.y+=gravity*multiplier*20;
6422 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6423 velspeed=findLength(&velocity);
6424 velocity=flatfacing*velspeed*-1;
6426 if(targetanimation==dodgebackanim){
6427 //coords-=facing*multiplier*50*scale;
6428 velocity+=facing*multiplier*speed*700*scale*-1;
6429 velspeed=findLength(&velocity);
6430 if(velspeed>speed*60*scale){
6432 velspeed=speed*60*scale;
6435 velocity.y+=gravity*multiplier*20;
6436 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6437 velspeed=findLength(&velocity);
6438 velocity=flatfacing*velspeed*-1;
6441 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6442 velspeed=findLength(&velocity);
6446 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6447 velocity.y+=gravity*multiplier;
6450 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6452 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6453 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6455 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6461 OPENAL_SetPaused(channels[whooshsound], true);
6462 OPENAL_SetVolume(channels[whooshsound], 0);
6465 if(targetanimation==jumpdownanim||isFlip()){
6466 if(isFlip())jumppower=-4;
6467 targetanimation=getLanding();
6476 PlaySoundEx( landsound, samp[landsound], NULL, true);
6477 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6478 OPENAL_SetVolume(channels[landsound], 128);
6479 OPENAL_SetPaused(channels[landsound], false);
6482 envsound[numenvsounds]=coords;
6483 envsoundvol[numenvsounds]=16;
6484 envsoundlife[numenvsounds]=.4;
6490 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6491 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6492 coords.y=terrain.getHeight(coords.x,coords.z);
6497 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)){
6498 velspeed=findLength(&velocity);
6500 if(velspeed<multiplier*300*scale){
6502 } else velocity-=velocity/velspeed*multiplier*300*scale;
6503 if(velspeed>5&&(isLanding()||isLandhard())){
6504 skiddingdelay+=multiplier;
6511 else skiddingdelay=0;
6515 velspeed=findLength(&velocity);
6517 if(velspeed<multiplier*600*scale){
6519 } else velocity-=velocity/velspeed*multiplier*600*scale;
6521 if(velspeed>5&&(isLanding()||isLandhard())){
6522 skiddingdelay+=multiplier;
6529 else skiddingdelay=0;
6532 if(skiddingdelay<0)skiddingdelay+=multiplier;
6533 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6543 if(!onterrain||environment==grassyenvironment){
6544 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6545 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6546 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6547 OPENAL_SetPaused(channels[skidsound], false);
6550 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6551 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6552 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6553 OPENAL_SetPaused(channels[snowskidsound], false);
6557 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6558 terrainnormal=victim->coords-coords;
6559 Normalise(&terrainnormal);
6560 targetrotation=-asin(0-terrainnormal.x);
6561 targetrotation*=360/6.28;
6562 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6563 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6566 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6567 targetrotation=victim->targetrotation;
6569 if(targetanimation==rabbittacklinganim){
6570 coords=victim->coords;
6573 skeleton.oldfree=skeleton.free;
6577 midterrain.x=terrain.size*terrain.scale/2;
6578 midterrain.z=terrain.size*terrain.scale/2;
6579 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6581 tempposit=coords-midterrain;
6583 Normalise(&tempposit);
6584 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6585 coords.x=tempposit.x+midterrain.x;
6586 coords.z=tempposit.z+midterrain.z;
6590 int Person::DrawSkeleton(){
6591 int oldplayerdetail;
6592 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6593 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6603 glAlphaFunc(GL_GREATER, 0.0001);
6605 float terrainheight;
6607 if(!isnormal(rotation))rotation=0;
6608 if(!isnormal(tilt))tilt=0;
6609 if(!isnormal(tilt2))tilt2=0;
6610 oldplayerdetail=playerdetail;
6612 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6615 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6618 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6623 if(playerdetail!=oldplayerdetail) {
6625 normalsupdatedelay=0;
6627 static float updatedelaychange;
6628 static float morphness;
6629 static float framemult;
6631 skeleton.FindForwards();
6632 if(howactive==typesittingwall){
6633 skeleton.specialforward[1]=0;
6634 skeleton.specialforward[1].z=1;
6640 static int weaponattachmuscle;
6641 static int weaponrotatemuscle,weaponrotatemuscle2;
6642 static XYZ weaponpoint;
6643 static int start,endthing;
6644 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6645 if(!isSleeping()&&!isSitting()){
6646 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6647 XYZ point,newpoint,change,change2;
6648 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6649 heightleft=terrain.getHeight(point.x,point.z)+.04;
6651 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6652 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6653 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6654 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6655 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6657 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6658 heightright=terrain.getHeight(point.x,point.z)+.04;
6659 point.y=heightright;
6660 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6661 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6662 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6663 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6664 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6665 skeleton.DoConstraints(&coords,&scale);
6667 if(creature==wolftype){
6668 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6669 heightleft=terrain.getHeight(point.x,point.z)+.04;
6671 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6672 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6673 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6674 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6675 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6677 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6678 heightright=terrain.getHeight(point.x,point.z)+.04;
6679 point.y=heightright;
6680 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6681 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6682 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6683 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6684 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6685 skeleton.DoConstraints(&coords,&scale);
6688 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6689 XYZ point,newpoint,change,change2;
6690 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6691 heightleft=terrain.getHeight(point.x,point.z)+.04;
6693 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6694 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6695 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6696 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6697 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6699 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6700 heightright=terrain.getHeight(point.x,point.z)+.04;
6701 point.y=heightright;
6702 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6703 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6704 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6705 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6706 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6707 skeleton.DoConstraints(&coords,&scale);
6709 if(creature==wolftype){
6710 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6711 heightleft=terrain.getHeight(point.x,point.z)+.04;
6713 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6714 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6715 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6716 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6717 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6719 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6720 heightright=terrain.getHeight(point.x,point.z)+.04;
6721 point.y=heightright;
6722 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6723 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6724 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6725 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6726 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6727 skeleton.DoConstraints(&coords,&scale);
6731 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6732 XYZ point,newpoint,change,change2;
6733 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6734 heightleft=terrain.getHeight(point.x,point.z)+.04;
6736 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6737 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6738 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6739 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6740 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6742 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6743 heightright=terrain.getHeight(point.x,point.z)+.04;
6744 point.y=heightright;
6745 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6746 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6747 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6748 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6749 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6750 skeleton.DoConstraints(&coords,&scale);
6752 if(creature==wolftype){
6753 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6754 heightleft=terrain.getHeight(point.x,point.z)+.04;
6756 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6757 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6758 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6759 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6760 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6762 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6763 heightright=terrain.getHeight(point.x,point.z)+.04;
6764 point.y=heightright;
6765 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6766 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6767 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6768 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6769 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6770 skeleton.DoConstraints(&coords,&scale);
6774 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()))
6777 targetheadrotation=-targetrotation;
6778 targetheadrotation2=0;
6779 if(animation[targetanimation].attack==3)targetheadrotation+=180;
6781 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6782 skeleton.drawmodel.vertex[i]=0;
6783 skeleton.drawmodel.vertex[i].y=999;
6785 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
6786 skeleton.drawmodellow.vertex[i]=0;
6787 skeleton.drawmodellow.vertex[i].y=999;
6789 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
6790 skeleton.drawmodelclothes.vertex[i]=0;
6791 skeleton.drawmodelclothes.vertex[i].y=999;
6793 for(i=0;i<skeleton.num_muscles;i++){
6794 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
6798 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
6799 morphness=righthandmorphness;
6800 start=righthandmorphstart;
6801 endthing=righthandmorphend;
6803 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
6804 morphness=lefthandmorphness;
6805 start=lefthandmorphstart;
6806 endthing=lefthandmorphend;
6808 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
6809 morphness=headmorphness;
6810 start=headmorphstart;
6811 endthing=headmorphend;
6813 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)){
6814 morphness=chestmorphness;
6815 start=chestmorphstart;
6816 endthing=chestmorphend;
6818 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)){
6819 morphness=tailmorphness;
6820 start=tailmorphstart;
6821 endthing=tailmorphend;
6823 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
6824 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6825 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6828 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6829 if(!skeleton.free)glRotatef(tilt,0,0,1);
6832 glTranslatef(mid.x,mid.y,mid.z);
6834 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6835 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6837 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6838 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6840 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6841 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6843 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
6847 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
6851 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
6855 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
6860 if(playerdetail||skeleton.free==3)
6862 for(j=0;j<skeleton.muscles[i].numvertices;j++)
6864 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
6865 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
6866 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
6867 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
6868 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
6869 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
6870 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
6871 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6873 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6874 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,
6875 (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,
6876 (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);
6877 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)
6878 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,
6879 (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,
6880 (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);
6881 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)
6882 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,
6883 (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,
6884 (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);
6885 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6886 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,
6887 (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,
6888 (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);
6889 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6890 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
6891 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
6892 //if(!isnormal(scale))test=1;
6893 //if(isnormal(scale)){
6894 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
6895 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
6896 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
6904 if(!playerdetail||skeleton.free==3)
6906 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
6908 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
6909 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6911 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6912 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
6913 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
6914 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
6915 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)
6916 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
6917 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
6918 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
6919 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)
6920 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
6921 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
6922 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
6923 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6924 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
6925 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
6926 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
6928 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6929 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
6930 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
6931 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
6938 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
6939 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6941 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6944 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6945 if(!skeleton.free)glRotatef(tilt,0,0,1);
6946 glTranslatef(mid.x,mid.y,mid.z);
6947 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6948 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6950 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6951 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6953 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6954 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6956 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
6957 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6959 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6960 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
6961 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
6962 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
6963 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)
6964 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
6965 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
6966 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
6967 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)
6968 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
6969 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
6970 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
6971 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6972 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
6973 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
6974 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
6975 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6976 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
6977 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
6978 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
6983 updatedelay=1+(float)(Random()%100)/1000;
6985 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
6986 normalsupdatedelay=1;
6987 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
6988 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
6989 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
6993 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
6994 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
6995 if(skeleton.clothes){
6996 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
7001 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
7002 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
7003 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
7004 if(skeleton.free==1)updatedelaychange*=6;
7005 if(id==0)updatedelaychange*=8;
7006 updatedelay+=updatedelaychange;
7008 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7010 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7011 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7012 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
7013 if(!skeleton.free)glRotatef(rotation,0,1,0);
7016 glColor4f(.4,1,.4,1);
7017 glDisable(GL_LIGHTING);
7018 glDisable(GL_TEXTURE_2D);
7021 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7022 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
7028 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
7029 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);
7030 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);
7031 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);
7032 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);
7033 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);
7034 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);
7040 terrainlight=terrain.getLighting(coords.x,coords.z);
7041 distance=findDistancefast(&viewer,&coords);
7042 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
7043 if(distance>1)distance=1;
7045 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
7046 if(terrainheight<1)terrainheight=1;
7047 if(terrainheight>1.7)terrainheight=1.7;
7050 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
7051 glDisable(GL_BLEND);
7052 glAlphaFunc(GL_GREATER, 0.0001);
7053 glEnable(GL_TEXTURE_2D);
7055 glDisable(GL_TEXTURE_2D);
7056 glColor4f(.7,.35,0,.5);
7058 glEnable(GL_LIGHTING);
7061 if(tutoriallevel&&id!=0){
7062 //glDisable(GL_TEXTURE_2D);
7063 glColor4f(.7,.7,.7,0.6);
7065 glEnable(GL_LIGHTING);
7067 if(canattack&&cananger)
7068 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7069 glDisable(GL_TEXTURE_2D);
7070 glColor4f(1,0,0,0.8);
7072 glMatrixMode(GL_TEXTURE);
7074 glTranslatef(0,-smoketex,0);
7075 glTranslatef(-smoketex,0,0);
7079 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7080 else skeleton.drawmodel.draw();
7084 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7085 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7088 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
7089 if(tutoriallevel&&id!=0){
7091 glMatrixMode(GL_MODELVIEW);
7092 glEnable(GL_TEXTURE_2D);
7093 glColor4f(.7,.7,.7,0.6);
7095 glEnable(GL_LIGHTING);
7097 if(canattack&&cananger)
7098 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7099 glDisable(GL_TEXTURE_2D);
7100 glColor4f(1,0,0,0.8);
7102 glMatrixMode(GL_TEXTURE);
7104 glTranslatef(0,-smoketex*.6,0);
7105 glTranslatef(smoketex*.6,0,0);
7108 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7109 else skeleton.drawmodel.draw();
7113 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7114 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7119 if(tutoriallevel&&id!=0){
7121 glMatrixMode(GL_MODELVIEW);
7122 glEnable(GL_TEXTURE_2D);
7124 if(skeleton.clothes){
7127 if(!immediate)skeleton.drawmodelclothes.draw();
7128 if(immediate)skeleton.drawmodelclothes.drawimmediate();
7135 for(k=0;k<num_weapons;k++){
7137 if(weaponactive==k){
7138 if(weapons.type[i]!=staff){
7139 for(j=0;j<skeleton.num_muscles;j++){
7140 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7141 weaponattachmuscle=j;
7144 for(j=0;j<skeleton.num_muscles;j++){
7145 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){
7146 weaponrotatemuscle=j;
7149 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7150 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7152 if(weapons.type[i]==staff){
7153 for(j=0;j<skeleton.num_muscles;j++){
7154 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7155 weaponattachmuscle=j;
7158 for(j=0;j<skeleton.num_muscles;j++){
7159 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){
7160 weaponrotatemuscle=j;
7163 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7164 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7165 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7166 XYZ tempnormthing,vec1,vec2;
7167 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7168 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7169 CrossProduct(&vec1,&vec2,&tempnormthing);
7170 Normalise(&tempnormthing);
7171 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);
7172 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7174 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7175 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7176 Normalise(&weaptargnorm);
7177 weaponpoint-=weaptargnorm*2;
7181 if(weaponactive!=k&&weaponstuck!=k){
7182 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;
7183 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;
7184 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;
7185 for(j=0;j<skeleton.num_muscles;j++){
7186 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){
7187 weaponrotatemuscle=j;
7192 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7193 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7194 for(j=0;j<skeleton.num_muscles;j++){
7195 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){
7196 weaponrotatemuscle=j;
7201 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;
7202 weapons.bigrotation[i]=rotation;
7203 weapons.bigtilt[i]=tilt;
7204 weapons.bigtilt2[i]=tilt2;
7207 weapons.position[i]=weaponpoint*scale+coords;
7208 weapons.bigrotation[i]=0;
7209 weapons.bigtilt[i]=0;
7210 weapons.bigtilt2[i]=0;
7212 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7213 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7214 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7215 if(weaponactive==k){
7216 if(weapons.type[i]==knife){
7217 weapons.smallrotation[i]=180;
7218 weapons.smallrotation2[i]=0;
7219 if(isCrouch()||wasCrouch()){
7220 weapons.smallrotation2[i]=20;
7222 if(targetanimation==hurtidleanim){
7223 weapons.smallrotation2[i]=50;
7225 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7226 XYZ temppoint1,temppoint2,tempforward;
7229 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7230 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7231 distance=findDistance(&temppoint1,&temppoint2);
7232 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7233 weapons.rotation2[i]*=360/6.28;
7236 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7237 weapons.rotation1[i]*=360/6.28;
7238 weapons.rotation3[i]=0;
7239 weapons.smallrotation[i]=-90;
7240 weapons.smallrotation2[i]=0;
7241 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7243 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7244 XYZ temppoint1,temppoint2,tempforward;
7247 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7248 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7249 distance=findDistance(&temppoint1,&temppoint2);
7250 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7251 weapons.rotation2[i]*=360/6.28;
7254 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7255 weapons.rotation1[i]*=360/6.28;
7256 weapons.rotation3[i]=0;
7257 weapons.smallrotation[i]=90;
7258 weapons.smallrotation2[i]=0;
7259 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7261 if(targetanimation==knifethrowanim){
7262 weapons.smallrotation[i]=90;
7263 //weapons.smallrotation2[i]=-90;
7264 weapons.smallrotation2[i]=0;
7265 weapons.rotation1[i]=0;
7266 weapons.rotation2[i]=0;
7267 weapons.rotation3[i]=0;
7269 if(targetanimation==knifesneakattackanim&&targetframe<5){
7270 weapons.smallrotation[i]=-90;
7271 weapons.rotation1[i]=0;
7272 weapons.rotation2[i]=0;
7273 weapons.rotation3[i]=0;
7276 if(weapons.type[i]==sword){
7277 weapons.smallrotation[i]=0;
7278 weapons.smallrotation2[i]=0;
7279 if(targetanimation==knifethrowanim){
7280 weapons.smallrotation[i]=-90;
7281 weapons.smallrotation2[i]=0;
7282 weapons.rotation1[i]=0;
7283 weapons.rotation2[i]=0;
7284 weapons.rotation3[i]=0;
7286 if((targetanimation==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)){
7287 XYZ temppoint1,temppoint2,tempforward;
7290 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7291 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7292 distance=findDistance(&temppoint1,&temppoint2);
7293 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7294 weapons.rotation2[i]*=360/6.28;
7297 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7298 weapons.rotation1[i]*=360/6.28;
7299 weapons.rotation3[i]=0;
7300 weapons.smallrotation[i]=90;
7301 weapons.smallrotation2[i]=0;
7302 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7305 if(weapons.type[i]==staff){
7306 weapons.smallrotation[i]=100;
7307 weapons.smallrotation2[i]=0;
7308 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7309 XYZ temppoint1,temppoint2,tempforward;
7312 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7313 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7314 distance=findDistance(&temppoint1,&temppoint2);
7315 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7316 weapons.rotation2[i]*=360/6.28;
7319 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7320 weapons.rotation1[i]*=360/6.28;
7321 weapons.rotation3[i]=0;
7322 weapons.smallrotation[i]=90;
7323 weapons.smallrotation2[i]=0;
7324 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7328 if(weaponactive!=k&&weaponstuck!=k){
7329 if(weapons.type[i]==knife){
7330 weapons.smallrotation[i]=-70;
7331 weapons.smallrotation2[i]=10;
7333 if(weapons.type[i]==sword){
7334 weapons.smallrotation[i]=-100;
7335 weapons.smallrotation2[i]=-8;
7337 if(weapons.type[i]==staff){
7338 weapons.smallrotation[i]=-100;
7339 weapons.smallrotation2[i]=-8;
7343 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7344 else weapons.smallrotation[i]=0;
7345 weapons.smallrotation2[i]=10;
7346 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7354 if(skeleton.free)calcrot=1;
7355 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7356 if(currentanimation!=targetanimation)calcrot=1;
7357 //if(id==0)calcrot=1;
7358 if(skeleton.free==2)calcrot=0;
7364 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7367 static float distance;
7368 static float olddistance;
7369 static int intersecting;
7370 static int firstintersecting;
7373 static XYZ start,end;
7374 static float slopethreshold=-.4;
7376 firstintersecting=-1;
7380 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7381 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7383 for (j=0;j<model->TriangleNum;j++){
7384 if(model->facenormals[j].y<=slopethreshold){
7386 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)));
7387 if(distance<radius){
7388 point=*p1-model->facenormals[j]*distance;
7389 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;
7390 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7391 &model->vertex[model->Triangles[j].vertex[1]],
7393 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7394 &model->vertex[model->Triangles[j].vertex[2]],
7396 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7397 &model->vertex[model->Triangles[j].vertex[2]],
7400 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7404 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)){
7405 p1->y=point.y+radius;
7406 if((targetanimation==jumpdownanim||isFlip())){
7407 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7409 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7415 OPENAL_SetPaused(channels[whooshsound], true);
7416 OPENAL_SetVolume(channels[whooshsound], 0);
7419 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7420 if(isFlip())jumppower=-4;
7421 targetanimation=getLanding();
7430 PlaySoundEx( landsound, samp[landsound], NULL, true);
7431 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7432 OPENAL_SetVolume(channels[landsound], 128);
7433 OPENAL_SetPaused(channels[landsound], false);
7436 envsound[numenvsounds]=coords;
7437 envsoundvol[numenvsounds]=16;
7438 envsoundlife[numenvsounds]=.4;
7446 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7449 for (j=0;j<model->TriangleNum;j++){
7450 if(model->facenormals[j].y>slopethreshold){
7454 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)));
7455 if(distance<radius*.5){
7456 point=start-model->facenormals[j]*distance;
7457 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;
7458 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,
7459 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7460 p1->x, p1->y, p1->z, radius/2);
7461 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,
7462 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7463 p1->x, p1->y, p1->z, radius/2);
7464 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,
7465 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7466 p1->x, p1->y, p1->z, radius/2);
7468 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7469 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7471 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7472 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7474 *p1+=model->facenormals[j]*(distance-radius*.5);
7477 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7481 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7483 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7485 return firstintersecting;
7495 currentanimation = 0;
7496 targetanimation = 0;
7497 oldcurrentframe = 0;
7499 oldcurrentanimation = 0;
7500 oldtargetanimation = 0;
7504 parriedrecently = 0;
7508 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7510 currentoffset = 0,targetoffset = 0,offset = 0;
7528 unconscioustime = 0;
7546 rabbitkickenabled = 0;
7555 damagetolerance = 0;
7557 permanentdamage = 0;
7558 superpermanentdamage = 0; lastcollide = 0;
7578 headrotation = 0,headrotation2 = 0;
7579 targetheadrotation = 0,targetheadrotation2 = 0;
7590 normalsupdatedelay = 0;
7595 forwardstogglekeydown = 0;
7600 jumptogglekeydown = 0;
7602 crouchtogglekeydown = 0;
7604 drawtogglekeydown = 0;
7606 throwtogglekeydown = 0;
7612 crouchkeydowntime = 0;
7613 jumpkeydowntime = 0;
7630 whichdirectiondelay = 0;
7631 avoidsomething = 0; avoidwhere = 0;
7639 lefthandmorphness = 0;
7640 righthandmorphness = 0;
7644 targetlefthandmorphness = 0;
7645 targetrighthandmorphness = 0;
7646 targetheadmorphness = 0;
7647 targetchestmorphness = 0;
7648 targettailmorphness = 0;
7649 lefthandmorphstart = 0,lefthandmorphend = 0;
7650 righthandmorphstart = 0,righthandmorphend = 0;
7651 headmorphstart = 0,headmorphend = 0;
7652 chestmorphstart = 0,chestmorphend = 0;
7653 tailmorphstart = 0,tailmorphend = 0;
7655 weaponmissdelay = 0;
7656 highreversaldelay = 0;
7657 lowreversaldelay = 0;
7664 //Skeleton skeleton;
7683 memset(clothes, 0, sizeof(clothes));
7684 memset(clothestintr, 0, sizeof(clothestintr));
7685 memset(clothestintg, 0, sizeof(clothestintg));
7686 memset(clothestintb, 0, sizeof(clothestintb));
7692 onfiredelay = 0; burnt = 0;
7696 updatestuffdelay = 0;
7702 memset(weaponids, 0, sizeof(weaponids));
7706 weaponstuckwhere = 0;
7711 memset(waypoints, 0, sizeof(waypoints));
7712 memset(waypointtype, 0, sizeof(waypointtype));
7715 hastempwaypoint = 0;
7721 finalfinaltarget = 0;
7723 finalpathfindpoint = 0;
7724 targetpathfindpoint = 0;
7725 lastpathfindpoint = 0;
7726 lastpathfindpoint2 = 0;
7727 lastpathfindpoint3 = 0;
7728 lastpathfindpoint4 = 0;
7739 runninghowlong = 0; lastoccluded = 0;
7745 neckspurtparticledelay = 0;
7746 neckspurtamount = 0;
7749 rabbitkickragdoll = 0;
7754 //Animation tempanimation;