2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /**> HEADER FILES <**/
24 #include "openal_wrapper.h"
25 #include "Animation.h"
30 extern float multiplier;
31 extern int channels[100];
32 extern Terrain terrain;
34 extern int environment;
36 extern FRUSTUM frustum;
38 extern float realmultiplier;
40 extern float slomodelay;
41 extern bool cellophane;
42 extern float texdetail;
43 extern float realtexdetail;
44 extern GLubyte bloodText[512*512*3];
45 extern GLubyte wolfbloodText[512*512*3];
46 extern int bloodtoggle;
47 extern Objects objects;
49 extern bool autoslomo;
50 extern float camerashake;
52 extern float terraindetail;
53 extern float viewdistance;
54 extern float blackout;
55 extern int difficulty;
57 extern float fadestart;
59 extern bool winfreeze;
60 extern float flashamount,flashr,flashg,flashb;
61 extern int flashdelay;
62 extern bool showpoints;
63 extern bool immediate;
65 extern bool tilt2weird;
66 extern bool tiltweird;
68 extern bool proportionweird;
69 extern bool vertexweird[6];
70 extern GLubyte texturearray[512*512*3];
71 extern XYZ envsound[30];
72 extern float envsoundvol[30];
73 extern float envsoundlife[30];
74 extern int numenvsounds;
75 extern int tutoriallevel;
76 extern float smoketex;
77 extern int tutorialstage;
78 extern bool reversaltrain;
79 extern bool canattack;
81 extern float damagedealt;
83 extern float hostiletime;
85 extern int indialogue;
87 extern bool gamestarted;
89 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
90 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
92 void Person::CheckKick(){
96 float damagemult=1*power;
97 if(creature==wolftype)damagemult=2.5*power;
101 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
102 if(findDistancefast(&coords,&victim->coords)<1.2){
103 if(!victim->skeleton.free){
105 Normalise(&relative);
106 relative=coords+relative*1;
107 if(animation[victim->targetanimation].height!=lowheight){
112 gLoc[0]=victim->coords.x;
113 gLoc[1]=victim->coords.y;
114 gLoc[2]=victim->coords.z;
118 if(tutoriallevel!=1){
119 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
120 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
121 OPENAL_SetVolume(channels[heavyimpactsound], 128);
122 OPENAL_SetPaused(channels[heavyimpactsound], false);
127 Normalise(&relative);
128 for(i=0;i<victim->skeleton.num_joints;i++){
129 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
132 victim->DoDamage(100*damagemult/victim->protectionhigh);
133 if(id==0)camerashake+=.4;
137 targetanimation=backflipanim;
142 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
144 //if(victim->damage>victim->damagetolerance){
152 else if (victim->isCrouch()){
153 targetanimation=rabbitkickreversedanim;
154 currentanimation=rabbitkickreversedanim;
155 victim->currentanimation=rabbitkickreversalanim;
156 victim->targetanimation=rabbitkickreversalanim;
162 victim->oldcoords=victim->coords;
163 coords=victim->coords;
164 victim->targetrotation=targetrotation;
172 void Person::CatchFire(){
173 XYZ flatfacing,flatvelocity;
175 for(int i=0;i<10;i++){
176 howmany=abs(Random()%(skeleton.num_joints));
177 if(!skeleton.free)flatvelocity=velocity;
178 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
179 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
180 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
181 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
194 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
195 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
196 OPENAL_SetVolume(channels[firestartsound], 256);
197 OPENAL_SetPaused(channels[firestartsound], false);
202 //PlaySoundEx( firesound, samp[firesound], NULL, true);
203 PlayStreamEx( stream_firesound, samp[stream_firesound], NULL, true);
204 OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
205 OPENAL_SetVolume(channels[stream_firesound], 256);
206 OPENAL_SetPaused(channels[stream_firesound], false);
213 bool Person::isIdle(){
214 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;
218 bool Person::isSitting(){
219 if(targetanimation==sitanim)return 1;
220 if(targetanimation==sitwallanim)return 1;
224 bool Person::isSleeping(){
225 if(targetanimation==sleepanim)return 1;
226 if(targetanimation==dead1anim)return 1;
227 if(targetanimation==dead2anim)return 1;
228 if(targetanimation==dead3anim)return 1;
229 if(targetanimation==dead4anim)return 1;
233 bool Person::wasIdle(){
234 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;
237 int Person::getIdle(){
238 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
239 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)){
240 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
241 if(creature==rabbittype)return fightidleanim;
242 if(creature==wolftype)return wolfidle;
244 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
245 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
246 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
247 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
248 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
250 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
252 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
253 if(howactive==typesitting)return sitanim;
254 if(howactive==typesittingwall)return sitwallanim;
255 if(howactive==typesleeping)return sleepanim;
256 if(howactive==typedead1)return dead1anim;
257 if(howactive==typedead2)return dead2anim;
258 if(howactive==typedead3)return dead3anim;
259 if(howactive==typedead4)return dead4anim;
260 if(creature==rabbittype)return bounceidleanim;
261 if(creature==wolftype)return wolfidle;
265 bool Person::isCrouch(){
266 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
271 bool Person::wasCrouch(){
272 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
275 int Person::getCrouch(){
276 if(creature==rabbittype)return crouchanim;
277 if(creature==wolftype)return wolfcrouchanim;
281 bool Person::isRun(){
282 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
287 bool Person::wasRun(){
288 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
291 int Person::getRun(){
292 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
293 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
295 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
296 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
300 bool Person::isStop(){
301 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
306 bool Person::wasStop(){
307 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
310 int Person::getStop(){
311 if(creature==rabbittype)return stopanim;
312 if(creature==wolftype)return wolfstopanim;
317 bool Person::isLanding(){
318 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
323 bool Person::wasLanding(){
324 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
327 int Person::getLanding(){
328 if(creature==rabbittype)return landanim;
329 if(creature==wolftype)return wolflandanim;
334 bool Person::isLandhard(){
335 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
340 bool Person::wasLandhard(){
341 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
344 int Person::getLandhard(){
345 if(creature==rabbittype)return landhardanim;
346 if(creature==wolftype)return wolflandhardanim;
351 bool Person::isFlip(){
352 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
356 bool Person::wasFlip(){
357 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
361 bool Person::isWallJump(){
362 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
366 void SolidHitBonus();
367 void SolidHitBonus(){
368 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
373 else if(bonustime<1.5&&bonus==threexcombo){
378 else if(bonustime<1.5&&bonus==twoxcombo){
383 else if(bonustime<1.5&&bonus==solidhit){
395 void Person::DoBlood(float howmuch,int which){
396 static int bleedxint,bleedyint;
398 //if(howmuch&&id==0)blooddimamount=1;
399 if(bloodtoggle&&tutoriallevel!=1){
400 if(bleeding<=0&&spurt){
402 for(int i=0;i<3;i++){
406 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
409 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
411 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
412 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
414 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
415 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
418 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);
419 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);
423 for(int i=0;i<3;i++){
427 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
428 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
431 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
432 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
436 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
438 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);
440 Sprite::setLastSpriteSpecial(3);
445 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
448 int texdetailint=realtexdetail;
449 if(creature==rabbittype)
450 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){
451 bleedxint=abs(Random()%512);
452 bleedyint=abs(Random()%512);
454 if(creature==wolftype)
455 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){
456 bleedxint=abs(Random()%512);
457 bleedyint=abs(Random()%512);
461 bleedy/=realtexdetail;
462 bleedx/=realtexdetail;
463 direction=abs(Random()%2)*2-1;
467 if(bleeding>2)bleeding=2;
470 void Person::DoBloodBig(float howmuch,int which){
471 static int bleedxint,bleedyint,i,j;
473 if(howmuch&&id==0)blooddimamount=1;
475 if(tutoriallevel!=1||id==0)
476 if(aitype!=playercontrolled&&howmuch>0){
487 if(creature==wolftype){
488 int i=abs(Random()%2);
489 if(i==0)whichsound=snarlsound;
490 if(i==1)whichsound=snarl2sound;
491 envsound[numenvsounds]=coords;
492 envsoundvol[numenvsounds]=16;
493 envsoundlife[numenvsounds]=.4;
496 if(creature==rabbittype){
497 int i=abs(Random()%2);
498 if(i==0)whichsound=rabbitpainsound;
499 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
500 envsound[numenvsounds]=coords;
501 envsoundvol[numenvsounds]=16;
502 envsoundlife[numenvsounds]=.4;
504 //if(i==2)whichsound=rabbitpain2sound;
508 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
509 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
510 OPENAL_SetVolume(channels[whichsound], 512);
511 OPENAL_SetPaused(channels[whichsound], false);
515 if(id==0&&howmuch>0){
523 if(bloodtoggle&&decals&&tutoriallevel!=1){
524 if(bleeding<=0&&spurt){
526 for(int i=0;i<3;i++){
530 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
533 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
535 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
536 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
538 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
539 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
542 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);
543 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);
547 int offsetx=0,offsety=0;
550 offsetx=abs(Random()%60);
552 if(which==190||which==185){
554 offsetx=abs(Random()%100)-20;
564 if(which==220||which==215){
565 //offsety=Random()%20;
567 //offsetx=abs(Random()%80);
576 if(creature==rabbittype)
579 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
580 if(i<startx)startx=i;
581 if(j<starty)starty=j;
587 if(creature==wolftype)
590 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
591 if(i<startx)startx=i;
592 if(j<starty)starty=j;
604 if(startx<0)startx=0;
605 if(starty<0)starty=0;
606 if(endx>512-1)endx=512-1;
607 if(endy>512-1)endy=512-1;
608 if(endx<startx)endx=startx;
609 if(endy<starty)endy=starty;
611 startx/=realtexdetail;
612 starty/=realtexdetail;
616 int texdetailint=realtexdetail;
618 if(creature==rabbittype)
619 for(i=startx;i<endx;i++){
620 for(j=starty;j<endy;j++){
621 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){
622 color=Random()%85+170;
623 where=i*skeleton.skinsize*3+j*3;
624 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
625 skeleton.skinText[where+1]=0;
626 skeleton.skinText[where+2]=0;
630 if(creature==wolftype)
631 for(i=startx;i<endx;i++){
632 for(j=starty;j<endy;j++){
633 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){
634 color=Random()%85+170;
635 where=i*skeleton.skinsize*3+j*3;
636 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
637 skeleton.skinText[where+1]=0;
638 skeleton.skinText[where+2]=0;
642 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
643 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
644 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
648 if(creature==rabbittype)
649 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){
650 bleedxint=abs(Random()%512);
651 bleedyint=abs(Random()%512);
653 if(creature==wolftype)
654 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){
655 bleedxint=abs(Random()%512);
656 bleedyint=abs(Random()%512);
658 bleedy=bleedxint+offsetx;
659 bleedx=bleedyint+offsety;
660 bleedy/=realtexdetail;
661 bleedx/=realtexdetail;
662 if(bleedx<0)bleedx=0;
663 if(bleedy<0)bleedy=0;
664 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
665 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
666 direction=abs(Random()%2)*2-1;
669 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
670 deathbleeding+=bleeding;
671 bloodloss+=bleeding*3;
673 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
674 if(abs(Random()%2)==0){aitype=gethelptype;
677 else aitype=attacktypecutoff;
680 if(bleeding>2)bleeding=2;
683 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
684 static int bleedxint,bleedyint,i,j;
686 static XYZ startpoint,endpoint,colpoint,movepoint;
687 static float rotationpoint;
689 static XYZ p1,p2,p3,p0;
693 float coordsx,coordsy;
696 if(bloodtoggle&&decals&&tutoriallevel!=1){
698 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
706 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
709 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
710 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
711 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
713 CrossProduct(p2-p1,p3-p1,&N);
714 CrossProduct(p0-p1,p3-p1,&temp);
715 s = dotproduct(&temp,&N)/findLength(&N);
716 CrossProduct(p2-p1,p1-p0,&temp);
717 t = dotproduct(&temp,&N)/findLength(&N);
720 bary.x=findDistancefast(&p0,&p1);
721 bary.y=findDistancefast(&p0,&p2);
722 bary.z=findDistancefast(&p0,&p3);
724 total=bary.x+bary.y+bary.z;
733 total=bary.x+bary.y+bary.z;
739 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
740 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
741 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
742 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
743 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
744 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
745 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;
746 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;
748 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
749 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
751 if(bleeding<=0&&spurt){
753 for(int i=0;i<3;i++){
757 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
760 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
762 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
763 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
765 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
766 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
769 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);
770 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);
774 int offsetx=0,offsety=0;
777 offsetx=abs(Random()%120);
779 if(which==220||which==215){
781 offsetx=abs(Random()%80);
784 offsetx=(1+coordsy)*512-291;
785 offsety=coordsx*512-437;
792 if(creature==rabbittype)
795 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
796 if(i<startx)startx=i;
797 if(j<starty)starty=j;
803 if(creature==wolftype)
806 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
807 if(i<startx)startx=i;
808 if(j<starty)starty=j;
819 if(startx<0)startx=0;
820 if(starty<0)starty=0;
821 if(endx>512-1)endx=512-1;
822 if(endy>512-1)endy=512-1;
823 if(endx<startx)endx=startx;
824 if(endy<starty)endy=starty;
826 startx/=realtexdetail;
827 starty/=realtexdetail;
831 int texdetailint=realtexdetail;
833 if(creature==rabbittype)
834 for(i=startx;i<endx;i++){
835 for(j=starty;j<endy;j++){
836 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){
837 color=Random()%85+170;
838 where=i*skeleton.skinsize*3+j*3;
839 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
840 skeleton.skinText[where+1]=0;
841 skeleton.skinText[where+2]=0;
843 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){
844 color=Random()%85+170;
845 where=i*skeleton.skinsize*3+j*3;
846 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
847 skeleton.skinText[where+1]=0;
848 skeleton.skinText[where+2]=0;
852 if(creature==wolftype)
853 for(i=startx;i<endx;i++){
854 for(j=starty;j<endy;j++){
855 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){
856 color=Random()%85+170;
857 where=i*skeleton.skinsize*3+j*3;
858 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
859 skeleton.skinText[where+1]=0;
860 skeleton.skinText[where+2]=0;
862 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){
863 color=Random()%85+170;
864 where=i*skeleton.skinsize*3+j*3;
865 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
866 skeleton.skinText[where+1]=0;
867 skeleton.skinText[where+2]=0;
871 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
872 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
873 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
875 bleedy=(1+coordsy)*512;
877 bleedy/=realtexdetail;
878 bleedx/=realtexdetail;
879 if(bleedx<0)bleedx=0;
880 if(bleedy<0)bleedy=0;
881 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
882 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
883 direction=abs(Random()%2)*2-1;
885 if(whichtri==-1)return 0;
887 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
888 deathbleeding+=bleeding;
889 bloodloss+=bleeding*3;
891 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
892 if(abs(Random()%2)==0){aitype=gethelptype;
895 else aitype=attacktypecutoff;
898 if(bleeding>2)bleeding=2;
903 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
906 static int bytesPerPixel=3;
907 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
908 static int newstartx,newstarty,newendx,newendy;
909 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
911 static float sizemult;
913 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
914 texture[i]=skeleton.skinText[i];
917 if((!osx||howmanylevels)){
919 if(startx<0)startx=0;
920 if(starty<0)starty=0;
921 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
922 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
923 if((endx>startx&&endy>starty)||howmanylevels){
930 for(i=startx;i<endx;i++){
931 for(j=starty;j<endy;j++){
932 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
933 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
934 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
938 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
941 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
942 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
943 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
946 newsize=skeleton.skinsize;
949 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
951 /*for(j=1;j<=howmanylevels;j++){
952 if(j==1)texpointer=&skeleton.skinText[0];
953 else texpointer=&texture[0];
955 totalsize=int( newsize*newsize*bytesPerPixel);
956 rowsize=int( newsize*bytesPerPixel );
957 bigstep=bytesPerPixel*newsize*2;
958 smallstep=bytesPerPixel*2;
964 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
971 void Person::Reverse(){
972 if(victim->aitype==playercontrolled||hostiletime>1)
973 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
974 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
975 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
976 if(targetanimation==sweepanim){
977 targetanimation=sweepreversedanim;
978 currentanimation=sweepreversedanim;
979 victim->currentanimation=sweepreversalanim;
980 victim->targetanimation=sweepreversalanim;
982 if(targetanimation==spinkickanim){
983 targetanimation=spinkickreversedanim;
984 currentanimation=spinkickreversedanim;
985 victim->currentanimation=spinkickreversalanim;
986 victim->targetanimation=spinkickreversalanim;
988 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
989 if(targetanimation==rabbittacklinganim){
992 victim->currentframe=6;
993 victim->targetframe=7;
995 targetanimation=upunchreversedanim;
996 currentanimation=upunchreversedanim;
997 victim->currentanimation=upunchreversalanim;
998 victim->targetanimation=upunchreversalanim;
1000 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1001 if(victim->weaponactive!=-1){
1002 victim->throwtogglekeydown=1;
1003 weapons.owner[victim->weaponids[0]]=-1;
1004 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1005 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1006 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1007 weapons.missed[victim->weaponids[0]]=1;
1008 weapons.freetime[victim->weaponids[0]]=0;
1009 weapons.firstfree[victim->weaponids[0]]=1;
1010 weapons.physics[victim->weaponids[0]]=1;
1011 victim->num_weapons--;
1012 if(victim->num_weapons){
1013 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1014 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1017 victim->weaponactive=-1;
1018 for(int j=0;j<numplayers;j++){
1019 player[j].wentforweapon=0;
1023 targetanimation=staffhitreversedanim;
1024 currentanimation=staffhitreversedanim;
1025 victim->currentanimation=staffhitreversalanim;
1026 victim->targetanimation=staffhitreversalanim;
1028 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1029 if(victim->weaponactive!=-1){
1030 victim->throwtogglekeydown=1;
1031 weapons.owner[victim->weaponids[0]]=-1;
1032 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1033 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1034 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1035 weapons.missed[victim->weaponids[0]]=1;
1036 weapons.freetime[victim->weaponids[0]]=0;
1037 weapons.firstfree[victim->weaponids[0]]=1;
1038 weapons.physics[victim->weaponids[0]]=1;
1039 victim->num_weapons--;
1040 if(victim->num_weapons){
1041 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1042 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1045 victim->weaponactive=-1;
1046 for(int j=0;j<numplayers;j++){
1047 player[j].wentforweapon=0;
1050 targetanimation=staffspinhitreversedanim;
1051 currentanimation=staffspinhitreversedanim;
1052 victim->currentanimation=staffspinhitreversalanim;
1053 victim->targetanimation=staffspinhitreversalanim;
1055 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1056 if(victim->weaponactive!=-1){
1057 victim->throwtogglekeydown=1;
1058 weapons.owner[victim->weaponids[0]]=-1;
1059 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1060 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1061 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1062 weapons.missed[victim->weaponids[0]]=1;
1063 weapons.freetime[victim->weaponids[0]]=0;
1064 weapons.firstfree[victim->weaponids[0]]=1;
1065 weapons.physics[victim->weaponids[0]]=1;
1066 victim->num_weapons--;
1067 if(victim->num_weapons){
1068 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1069 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1072 victim->weaponactive=-1;
1073 for(int j=0;j<numplayers;j++){
1074 player[j].wentforweapon=0;
1077 targetanimation=swordslashreversedanim;
1078 currentanimation=swordslashreversedanim;
1079 victim->currentanimation=swordslashreversalanim;
1080 victim->targetanimation=swordslashreversalanim;
1082 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1083 if(victim->weaponactive!=-1){
1084 victim->throwtogglekeydown=1;
1085 weapons.owner[victim->weaponids[0]]=-1;
1086 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1087 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1088 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1089 weapons.missed[victim->weaponids[0]]=1;
1090 weapons.freetime[victim->weaponids[0]]=0;
1091 weapons.firstfree[victim->weaponids[0]]=1;
1092 weapons.physics[victim->weaponids[0]]=1;
1093 victim->num_weapons--;
1094 if(victim->num_weapons){
1095 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1096 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1099 victim->weaponactive=-1;
1100 for(int j=0;j<numplayers;j++){
1101 player[j].wentforweapon=0;
1104 targetanimation=knifeslashreversedanim;
1105 currentanimation=knifeslashreversedanim;
1106 victim->currentanimation=knifeslashreversalanim;
1107 victim->targetanimation=knifeslashreversalanim;
1109 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1110 victim->targettilt2=targettilt2;
1111 victim->currentframe=currentframe;
1112 victim->targetframe=targetframe;
1113 victim->target=target;
1115 victim->oldcoords=victim->coords;
1116 victim->coords=coords;
1117 victim->targetrotation=targetrotation;
1118 victim->rotation=targetrotation;
1119 victim->victim=this;
1121 if(targetanimation==winduppunchanim){
1122 targetanimation=winduppunchblockedanim;
1123 victim->targetanimation=blockhighleftanim;
1124 victim->targetframe=1;
1126 victim->victim=this;
1127 victim->targetrotation=targetrotation+180;
1129 if(targetanimation==wolfslapanim){
1130 targetanimation=winduppunchblockedanim;
1131 victim->targetanimation=blockhighleftanim;
1132 victim->targetframe=1;
1134 victim->victim=this;
1135 victim->targetrotation=targetrotation+180;
1137 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1138 targetanimation=swordslashparriedanim;
1140 victim->parriedrecently=0;
1141 victim->targetanimation=swordslashparryanim;
1142 victim->targetframe=1;
1144 victim->victim=this;
1145 victim->targetrotation=targetrotation+180;
1147 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1150 gLoc[0]=victim->coords.x;
1151 gLoc[1]=victim->coords.y;
1152 gLoc[2]=victim->coords.z;
1156 if(victim->weaponactive!=-1){
1157 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1158 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1159 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1161 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1162 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1163 OPENAL_SetVolume(channels[swordstaffsound], 512);
1164 OPENAL_SetPaused(channels[swordstaffsound], false);
1167 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1168 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1169 OPENAL_SetVolume(channels[metalhitsound], 512);
1170 OPENAL_SetPaused(channels[metalhitsound], false);
1174 victim->Puff(righthand);
1176 victim->targetframe=0;
1177 victim->targetanimation=staggerbackhighanim;
1178 victim->targetrotation=targetrotation+180;
1180 weapons.owner[victim->weaponids[0]]=-1;
1181 aim=DoRotation(facing,0,90,0)*21;
1183 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1184 weapons.tipvelocity[victim->weaponids[0]]=aim;
1185 weapons.missed[victim->weaponids[0]]=1;
1186 weapons.hitsomething[victim->weaponids[0]]=0;
1187 weapons.freetime[victim->weaponids[0]]=0;
1188 weapons.firstfree[victim->weaponids[0]]=1;
1189 weapons.physics[victim->weaponids[0]]=1;
1190 victim->num_weapons--;
1191 if(victim->num_weapons){
1192 victim->weaponids[0]=victim->weaponids[num_weapons];
1193 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1195 victim->weaponactive=-1;
1196 for(int i=0;i<numplayers;i++){
1197 player[i].wentforweapon=0;
1204 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1205 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1206 OPENAL_SetVolume(channels[metalhitsound], 512);
1207 OPENAL_SetPaused(channels[metalhitsound], false);*/
1210 if(abs(Random()%20)==0){
1219 if(weaponactive!=-1){
1220 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1221 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1222 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1224 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1225 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1226 OPENAL_SetVolume(channels[swordstaffsound], 512);
1227 OPENAL_SetPaused(channels[swordstaffsound], false);
1230 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1231 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1232 OPENAL_SetVolume(channels[metalhitsound], 512);
1233 OPENAL_SetPaused(channels[metalhitsound], false);
1241 targetanimation=staggerbackhighanim;
1242 targetrotation=targetrotation+180;
1244 weapons.owner[weaponids[0]]=-1;
1245 aim=DoRotation(facing,0,90,0)*21;
1247 weapons.velocity[weaponids[0]]=aim*-.2;
1248 weapons.tipvelocity[weaponids[0]]=aim;
1249 weapons.hitsomething[weaponids[0]]=0;
1250 weapons.missed[weaponids[0]]=1;
1251 weapons.freetime[weaponids[0]]=0;
1252 weapons.firstfree[weaponids[0]]=1;
1253 weapons.physics[weaponids[0]]=1;
1256 weaponids[0]=weaponids[num_weapons];
1257 if(weaponstuck==num_weapons)weaponstuck=0;
1260 for(int i=0;i<numplayers;i++){
1261 player[i].wentforweapon=0;
1265 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1266 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1267 OPENAL_SetVolume(channels[metalhitsound], 512);
1268 OPENAL_SetPaused(channels[metalhitsound], false);*/
1272 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1273 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1274 //victim->targetanimation=sweepanim;
1275 victim->targetanimation=dodgebackanim;
1276 victim->targetframe=0;
1278 //victim->velocity=0;
1281 rotatetarget=coords-victim->coords;
1282 Normalise(&rotatetarget);
1283 victim->targetrotation=-asin(0-rotatetarget.x);
1284 victim->targetrotation*=360/6.28;
1285 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1287 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1289 victim->lastattack3=victim->lastattack2;
1290 victim->lastattack2=victim->lastattack;
1291 victim->lastattack=victim->targetanimation;
1295 victim->targetanimation=sweepanim;
1296 victim->targetframe=0;
1300 rotatetarget=coords-victim->coords;
1301 Normalise(&rotatetarget);
1302 victim->targetrotation=-asin(0-rotatetarget.x);
1303 victim->targetrotation*=360/6.28;
1304 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1306 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1308 victim->lastattack3=victim->lastattack2;
1309 victim->lastattack2=victim->lastattack;
1310 victim->lastattack=victim->targetanimation;
1317 if(aitype!=playercontrolled)feint=0;
1318 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1319 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1320 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1322 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1326 void Person::DoDamage(float howmuch){
1327 if(tutoriallevel!=1)damage+=howmuch/power;
1328 if(id!=0)damagedealt+=howmuch/power;
1329 if(id==0)damagetaken+=howmuch/power;
1331 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1332 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1333 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1334 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1335 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1337 if(id==0)camerashake+=howmuch/100;
1338 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1339 if(blackout>1)blackout=1;
1341 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1342 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1343 if(abs(Random()%2)==0){aitype=gethelptype;
1346 else aitype=attacktypecutoff;
1350 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1353 for(int i=0;i<skeleton.num_joints; i++){
1354 if(!skeleton.free)flatvelocity2=velocity;
1355 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1356 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1357 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1358 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1359 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1360 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1361 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1362 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1363 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1374 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1375 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1376 OPENAL_SetVolume(channels[splattersound], 256);
1377 OPENAL_SetPaused(channels[splattersound], false);
1386 if(!dead&&creature==wolftype){
1395 if(tutoriallevel!=1||id==0)
1396 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1407 if(creature==wolftype){
1408 int i=abs(Random()%2);
1409 if(i==0)whichsound=snarlsound;
1410 if(i==1)whichsound=snarl2sound;
1411 envsound[numenvsounds]=coords;
1412 envsoundvol[numenvsounds]=16;
1413 envsoundlife[numenvsounds]=.4;
1416 if(creature==rabbittype){
1417 int i=abs(Random()%2);
1418 if(i==0)whichsound=rabbitpainsound;
1419 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1420 envsound[numenvsounds]=coords;
1421 envsoundvol[numenvsounds]=16;
1422 envsoundlife[numenvsounds]=.4;
1424 //if(i==2)whichsound=rabbitpain2sound;
1428 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1429 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1430 OPENAL_SetVolume(channels[whichsound], 512);
1431 OPENAL_SetPaused(channels[whichsound], false);
1436 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1437 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1440 void Person::DoHead(){
1441 static XYZ rotatearound;
1443 static float lookspeed=500;
1445 if(!freeze&&!winfreeze){
1448 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1449 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1451 while(targetheadrotation>180)targetheadrotation-=360;
1452 while(targetheadrotation<-180)targetheadrotation+=360;
1454 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1455 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1456 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1457 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1459 if(targetheadrotation2>120)targetheadrotation2=120;
1460 if(targetheadrotation2<-120)targetheadrotation2=-120;
1461 if(targetheadrotation>120)targetheadrotation=120;
1462 if(targetheadrotation<-120)targetheadrotation=-120;
1464 if(!isIdle())targetheadrotation2=0;
1466 if(targetheadrotation>80)targetheadrotation=80;
1467 if(targetheadrotation<-80)targetheadrotation=-80;
1468 if(targetheadrotation2>50)targetheadrotation2=50;
1469 if(targetheadrotation2<-50)targetheadrotation2=-50;
1472 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1473 else if(headrotation>targetheadrotation){
1474 headrotation-=multiplier*lookspeed;
1476 else if(headrotation<targetheadrotation){
1477 headrotation+=multiplier*lookspeed;
1480 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1481 else if(headrotation2>targetheadrotation2){
1482 headrotation2-=multiplier*lookspeed/2;
1484 else if(headrotation2<targetheadrotation2){
1485 headrotation2+=multiplier*lookspeed/2;
1488 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1489 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1493 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1494 facing=DoRotation(facing,headrotation2*.4,0,0);
1495 facing=DoRotation(facing,0,headrotation*.4,0);
1498 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1499 facing=DoRotation(facing,headrotation2*.8,0,0);
1500 facing=DoRotation(facing,0,headrotation*.8,0);
1503 if(targetanimation==walkanim){
1504 facing=DoRotation(facing,headrotation2*.6,0,0);
1505 facing=DoRotation(facing,0,headrotation*.6,0);
1508 skeleton.specialforward[0]=facing;
1509 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1511 for(i=0;i<skeleton.num_muscles;i++){
1512 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1514 skeleton.FindRotationMuscle(i,targetanimation);
1520 void Person::RagDoll(bool checkcollision){
1525 if(id==0)numfalls++;
1526 if(id==0&&isFlip())numflipfail++;
1532 facing=DoRotation(facing,0,rotation,0);
1534 skeleton.freetime=0;
1536 skeleton.longdead=0;
1542 skeleton.freefall=1;
1544 if(!isnormal(velocity.x))velocity.x=0;
1545 if(!isnormal(velocity.y))velocity.y=0;
1546 if(!isnormal(velocity.z))velocity.z=0;
1547 if(!isnormal(rotation))rotation=0;
1548 if(!isnormal(coords.x))coords=0;
1549 if(!isnormal(tilt))tilt=0;
1550 if(!isnormal(tilt2))tilt2=0;
1552 for(i=0;i<skeleton.num_joints;i++){
1553 skeleton.joints[i].delay=0;
1554 skeleton.joints[i].locked=0;
1555 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1556 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1557 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1558 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1559 skeleton.joints[i].position.y+=.1;
1560 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1561 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1564 for(i=0;i<skeleton.num_joints;i++){
1565 skeleton.joints[i].velocity=0;
1566 skeleton.joints[i].velchange=0;
1568 skeleton.DoConstraints(&coords,&scale);
1569 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1571 skeleton.DoConstraints(&coords,&scale);
1572 skeleton.DoConstraints(&coords,&scale);
1573 skeleton.DoConstraints(&coords,&scale);
1574 skeleton.DoConstraints(&coords,&scale);
1577 speed=animation[targetanimation].speed[targetframe]*2;
1578 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1579 speed=animation[currentanimation].speed[currentframe]*2;
1581 if(transspeed)speed=transspeed*2;
1585 for(i=0;i<skeleton.num_joints;i++){
1586 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);
1587 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1588 change.x=(float)(Random()%100)/100;
1589 change.y=(float)(Random()%100)/100;
1590 change.z=(float)(Random()%100)/100;
1591 skeleton.joints[i].velocity+=change;
1592 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1594 change.x=(float)(Random()%100)/100;
1595 change.y=(float)(Random()%100)/100;
1596 change.z=(float)(Random()%100)/100;
1597 skeleton.joints[i].velchange+=change;
1598 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1608 for(j=0;j<skeleton.num_joints;j++){
1609 average+=skeleton.joints[j].position;
1613 coords+=average*scale;
1614 for(j=0;j<skeleton.num_joints;j++){
1615 skeleton.joints[j].position-=average;
1618 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1619 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1620 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1621 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1622 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1625 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1626 coords.x=lowpoint.x;
1627 coords.z=lowpoint.z;
1636 for(i=0;i<skeleton.num_joints;i++){
1637 velocity+=skeleton.joints[i].velocity*scale;
1639 velocity/=skeleton.num_joints;
1642 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1643 weapons.owner[weaponids[0]]=-1;
1644 weapons.hitsomething[weaponids[0]]=0;
1645 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1646 weapons.velocity[weaponids[0]].x+=.01;
1647 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1648 weapons.missed[weaponids[0]]=1;
1649 weapons.freetime[weaponids[0]]=0;
1650 weapons.firstfree[weaponids[0]]=1;
1651 weapons.physics[weaponids[0]]=1;
1654 weaponids[0]=weaponids[num_weapons];
1655 if(weaponstuck==num_weapons)weaponstuck=0;
1658 for(i=0;i<numplayers;i++){
1659 player[i].wentforweapon=0;
1664 targetanimation=bounceidleanim;
1665 currentanimation=bounceidleanim;
1673 void Person::FootLand(int which, float opacity){
1674 static XYZ terrainlight;
1675 static XYZ footvel,footpoint;
1676 if(opacity>=1||skiddelay<=0)
1680 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1681 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1682 //footpoint.y=coords.y;
1683 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1685 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1687 if(footvel.y<.8)footvel.y=.8;
1688 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1689 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1690 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1691 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1692 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1693 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1695 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1697 if(footvel.y<.8)footvel.y=.8;
1698 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1699 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1700 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1701 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1702 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);
1704 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1706 if(footvel.y<.8)footvel.y=.8;
1707 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1708 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1709 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1710 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1711 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);
1712 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1714 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1717 if(footvel.y<.8)footvel.y=.8;
1718 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1719 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1720 //footpoint.y=coords.y;
1721 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1725 void Person::Puff(int whichlabel){
1726 static XYZ footvel,footpoint;
1729 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1730 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1734 void Person::DoAnimations(){
1737 static float oldtarget;
1739 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1741 if(targetanimation==tempanim||currentanimation==tempanim){
1742 animation[tempanim]=tempanimation;
1744 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1755 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1756 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1758 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1759 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1761 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1766 targfacing=DoRotation(targfacing,0,targetrotation,0);
1768 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1769 else targetanimation=backflipanim;
1770 crouchtogglekeydown=1;
1774 if(id==0)numflipped++;
1777 if(animation[targetanimation].attack!=reversed)feint=0;
1778 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1779 crouchtogglekeydown=0;
1780 if(aitype==playercontrolled)feint=0;
1784 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1785 if(!isFlip())crouchtogglekeydown=1;
1789 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1790 if(detail)normalsupdatedelay=0;
1794 if(targetanimation==rollanim&&targetframe==3&&onfire){
1804 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1805 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1806 OPENAL_SetVolume(channels[fireendsound], 256);
1807 OPENAL_SetPaused(channels[fireendsound], false);
1808 OPENAL_SetPaused(channels[stream_firesound], true);
1812 if(targetanimation==rabbittacklinganim&&targetframe==1){
1813 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1814 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1815 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1816 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1817 else victim->targetanimation=rabbittackledfrontanim;
1818 victim->targetframe=2;
1820 victim->rotation=rotation;
1821 victim->targetrotation=rotation;
1822 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1823 //victim->DoDamage(30);
1824 if(creature==wolftype){
1828 gLoc[0]=victim->coords.x;
1829 gLoc[1]=victim->coords.y;
1830 gLoc[2]=victim->coords.z;
1834 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
1835 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
1836 OPENAL_SetVolume(channels[clawslicesound], 128);
1837 OPENAL_SetPaused(channels[clawslicesound], false);
1839 victim->DoBloodBig(1/victim->armorhead,210);
1845 if(victim->aitype==gethelptype)bonusvalue=50;
1850 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1851 if(weapons.type[weaponids[0]]==knife){
1852 if(weaponactive==-1)weaponactive=0;
1853 else if(weaponactive==0)weaponactive=-1;
1855 if(weaponactive==-1){
1865 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
1866 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
1867 OPENAL_SetVolume(channels[knifesheathesound], 128);
1868 OPENAL_SetPaused(channels[knifesheathesound], false);
1870 if(weaponactive!=-1){
1880 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
1881 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
1882 OPENAL_SetVolume(channels[knifedrawsound], 128);
1883 OPENAL_SetPaused(channels[knifedrawsound], false);
1886 drawtogglekeydown=1;
1889 if(tutoriallevel!=1||id==0)
1890 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1901 if(terrain.getOpacity(coords.x,coords.z)<.2){
1902 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1903 else whichsound=footstepsound2;
1904 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1905 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1906 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1912 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1913 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1914 else whichsound=footstepsound4;
1918 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1919 else whichsound=footstepsound4;
1921 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1922 if(animation[targetanimation].attack!=neutral){
1924 if(i==0)whichsound=lowwhooshsound;
1925 if(i==1)whichsound=midwhooshsound;
1926 if(i==2)whichsound=highwhooshsound;
1928 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1930 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1931 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1933 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1934 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1935 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
1936 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
1937 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
1938 OPENAL_SetPaused(channels[whichsound], false);
1941 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1942 envsound[numenvsounds]=coords;
1943 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1944 else envsoundvol[numenvsounds]=6;
1945 envsoundlife[numenvsounds]=.4;
1949 if(animation[targetanimation].label[targetframe]==3){
1951 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1952 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1953 OPENAL_SetVolume(channels[whichsound], 128);
1954 OPENAL_SetPaused(channels[whichsound], false);
1959 if(tutoriallevel!=1||id==0)
1961 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1962 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1972 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1973 if(animation[targetanimation].attack!=neutral){
1975 if(creature==rabbittype){
1976 if(i==0)whichsound=rabbitattacksound;
1977 if(i==1)whichsound=rabbitattack2sound;
1978 if(i==2)whichsound=rabbitattack3sound;
1979 if(i==3)whichsound=rabbitattack4sound;
1981 if(creature==wolftype){
1982 if(i==0)whichsound=barksound;
1983 if(i==1)whichsound=bark2sound;
1984 if(i==2)whichsound=bark3sound;
1985 if(i==3)whichsound=barkgrowlsound;
1989 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1991 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1992 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
1995 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1996 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1997 OPENAL_SetVolume(channels[whichsound], 512);
1998 OPENAL_SetPaused(channels[whichsound], false);
2004 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
2010 currentoffset=targetoffset;
2011 targetframe=currentframe;
2012 currentanimation=targetanimation;
2015 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
2016 for(i=0;i<weapons.numweapons;i++){
2017 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
2018 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
2019 if(findDistancefast(&coords,&weapons.position[i])>=1){
2020 if(weapons.type[i]!=staff){
2029 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2030 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2031 OPENAL_SetVolume(channels[knifedrawsound], 128);
2032 OPENAL_SetPaused(channels[knifedrawsound], false);
2036 weapons.owner[i]=id;
2038 weaponids[num_weapons]=weaponids[0];
2047 static bool willwork;
2048 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2049 for(i=0;i<weapons.numweapons;i++){
2051 if(weapons.owner[i]!=-1)
2052 if(player[weapons.owner[i]].weaponstuck!=-1)
2053 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2054 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2055 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))
2056 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2057 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2067 if(weapons.owner[i]!=-1)
2068 if(victim->weaponstuck!=-1){
2069 if(victim->weaponids[victim->weaponstuck]==i){
2074 if(weapons.type[i]!=staff){
2075 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2076 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2077 OPENAL_SetVolume(channels[knifedrawsound], 128);
2078 OPENAL_SetPaused(channels[knifedrawsound], false);
2082 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2083 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2084 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2085 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2088 if(weapons.owner[i]!=-1){
2090 victim=&player[weapons.owner[i]];
2091 if(victim->num_weapons==1)victim->num_weapons=0;
2092 else victim->num_weapons=1;
2094 //victim->weaponactive=-1;
2095 victim->skeleton.longdead=0;
2096 victim->skeleton.free=1;
2097 victim->skeleton.broken=0;
2099 for(int j=0;j<victim->skeleton.num_joints;j++){
2100 victim->skeleton.joints[j].velchange=0;
2101 victim->skeleton.joints[j].locked=0;
2107 Normalise(&relative);
2108 XYZ footvel,footpoint;
2110 footpoint=weapons.position[i];
2111 if(victim->weaponstuck!=-1){
2112 if(victim->weaponids[victim->weaponstuck]==i){
2113 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2114 weapons.bloody[i]=2;
2115 weapons.blooddrip[i]=5;
2116 victim->weaponstuck=-1;
2119 if(victim->num_weapons>0){
2120 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2121 if(victim->weaponids[0]==i)
2122 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2125 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2126 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2127 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2128 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2130 weapons.owner[i]=id;
2132 weaponids[num_weapons]=weaponids[0];
2141 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2142 if(weaponactive==-1)weaponactive=0;
2143 else if(weaponactive==0){
2147 buffer=weaponids[0];
2148 weaponids[0]=weaponids[1];
2149 weaponids[1]=buffer;
2152 if(weaponactive==-1){
2162 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2163 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2164 OPENAL_SetVolume(channels[knifesheathesound], 128);
2165 OPENAL_SetPaused(channels[knifesheathesound], false);
2167 if(weaponactive!=-1){
2177 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2178 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2179 OPENAL_SetVolume(channels[knifedrawsound], 128);
2180 OPENAL_SetPaused(channels[knifedrawsound], false);
2185 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2186 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2187 Normalise(&rotatetarget);
2188 targetrotation=-asin(0-rotatetarget.x);
2189 targetrotation*=360/6.28;
2190 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2192 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2193 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2198 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2200 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;
2202 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2203 targetanimation=rabbittackleanim;
2214 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2215 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2216 OPENAL_SetVolume(channels[jumpsound], 128);
2217 OPENAL_SetPaused(channels[jumpsound], false);
2226 Normalise(&targetloc);
2228 for(i=0;i<numplayers;i++){
2230 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2231 closestdist=findDistancefast(&targetloc,&player[i].coords);
2236 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2238 victim=&player[closestid];
2239 coords=victim->coords;
2240 currentanimation=rabbittacklinganim;
2241 targetanimation=rabbittacklinganim;
2245 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2246 rotatetarget=coords-victim->coords;
2247 Normalise(&rotatetarget);
2248 targetrotation=-asin(0-rotatetarget.x);
2249 targetrotation*=360/6.28;
2250 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2252 if(targetanimation!=rabbitrunninganim){
2262 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2263 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2264 OPENAL_SetVolume(channels[jumpsound], 128);
2265 OPENAL_SetPaused(channels[jumpsound], false);
2271 float damagemult=1*power;
2272 if(creature==wolftype)damagemult=2.5*power;
2273 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2274 //if(onfire)damagemult=3;
2275 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2276 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2277 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2279 if(id==0)camerashake+=.4;
2280 if(Random()%2||creature==wolftype){
2283 if(creature==wolftype)DoBloodBig(0,250);
2287 gLoc[0]=victim->coords.x;
2288 gLoc[1]=victim->coords.y;
2289 gLoc[2]=victim->coords.z;
2293 if(tutoriallevel!=1){
2294 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2295 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2296 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2297 OPENAL_SetPaused(channels[heavyimpactsound], false);
2299 if(creature==wolftype){
2300 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2301 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2302 OPENAL_SetVolume(channels[clawslicesound], 128);
2303 OPENAL_SetPaused(channels[clawslicesound], false);
2305 victim->DoBloodBig(2/victim->armorhead,175);
2309 relative=victim->coords-coords;
2311 Normalise(&relative);
2312 relative=DoRotation(relative,0,-90,0);
2313 for(i=0;i<victim->skeleton.num_joints;i++){
2314 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2316 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2319 victim->DoDamage(damagemult*100/victim->protectionhead);
2327 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2328 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2330 if(id==0)camerashake+=.4;
2331 if(Random()%2||creature==wolftype){
2333 if(creature==wolftype)DoBloodBig(0,235);
2337 gLoc[0]=victim->coords.x;
2338 gLoc[1]=victim->coords.y;
2339 gLoc[2]=victim->coords.z;
2343 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2344 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2345 OPENAL_SetVolume(channels[whooshhitsound], 512);
2346 OPENAL_SetPaused(channels[whooshhitsound], false);
2347 if(creature==wolftype){
2348 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2349 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2350 OPENAL_SetVolume(channels[clawslicesound], 128);
2351 OPENAL_SetPaused(channels[clawslicesound], false);
2353 victim->DoBloodBig(2,175);
2357 relative=victim->coords-coords;
2359 Normalise(&relative);
2361 Normalise(&relative);
2362 relative=DoRotation(relative,0,90,0);
2363 for(i=0;i<victim->skeleton.num_joints;i++){
2364 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2366 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2369 victim->DoDamage(damagemult*50/victim->protectionhead);
2373 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2374 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2376 if(id==0)camerashake+=.4;
2381 gLoc[0]=victim->coords.x;
2382 gLoc[1]=victim->coords.y;
2383 gLoc[2]=victim->coords.z;
2387 if(tutoriallevel!=1){
2388 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2389 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2390 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2391 OPENAL_SetPaused(channels[heavyimpactsound], false);
2393 if(creature==wolftype){
2394 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2395 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2396 OPENAL_SetVolume(channels[clawslicesound], 128);
2397 OPENAL_SetPaused(channels[clawslicesound], false);
2399 victim->DoBloodBig(2/victim->armorhead,175);
2405 Normalise(&relative);
2406 relative=DoRotation(relative,0,-90,0);
2407 for(i=0;i<victim->skeleton.num_joints;i++){
2408 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2410 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2413 victim->DoDamage(damagemult*150/victim->protectionhead);
2415 if(victim->damage>victim->damagetolerance){
2428 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2429 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2431 if(id==0)camerashake+=.4;
2436 gLoc[0]=victim->coords.x;
2437 gLoc[1]=victim->coords.y;
2438 gLoc[2]=victim->coords.z;
2442 if(tutoriallevel!=1){
2443 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2444 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2445 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2446 OPENAL_SetPaused(channels[heavyimpactsound], false);
2448 if(creature==wolftype){
2449 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2450 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2451 OPENAL_SetVolume(channels[clawslicesound], 128);
2452 OPENAL_SetPaused(channels[clawslicesound], false);
2454 victim->DoBloodBig(2/victim->armorhead,175);
2460 Normalise(&relative);
2461 relative=DoRotation(relative,0,90,0);
2462 for(i=0;i<victim->skeleton.num_joints;i++){
2463 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2465 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2468 victim->DoDamage(damagemult*150/victim->protectionhead);
2470 if(victim->damage>victim->damagetolerance){
2483 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2484 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2486 if(id==0)camerashake+=.4;
2493 gLoc[0]=victim->coords.x;
2494 gLoc[1]=victim->coords.y;
2495 gLoc[2]=victim->coords.z;
2499 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2500 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2501 OPENAL_SetVolume(channels[whooshhitsound], 512);
2502 OPENAL_SetPaused(channels[whooshhitsound], false);
2505 relative=victim->coords-coords;
2507 Normalise(&relative);
2508 for(i=0;i<victim->skeleton.num_joints;i++){
2509 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2511 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2514 victim->DoDamage(damagemult*50/victim->protectionhead);
2518 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2519 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2521 if(id==0)camerashake+=.2;
2524 gLoc[0]=victim->coords.x;
2525 gLoc[1]=victim->coords.y;
2526 gLoc[2]=victim->coords.z;
2530 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2531 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2532 OPENAL_SetVolume(channels[landsound2], 128);
2533 OPENAL_SetPaused(channels[landsound2], false);
2535 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2536 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2537 OPENAL_SetVolume(channels[movewhooshsound], 128);
2538 OPENAL_SetPaused(channels[movewhooshsound], false);
2540 victim->skeleton.longdead=0;
2541 victim->skeleton.free=1;
2542 victim->skeleton.broken=0;
2543 victim->skeleton.spinny=1;
2545 for(i=0;i<victim->skeleton.num_joints;i++){
2546 victim->skeleton.joints[i].velchange=0;
2547 victim->skeleton.joints[i].delay=0;
2548 victim->skeleton.joints[i].locked=0;
2549 //victim->skeleton.joints[i].velocity=0;
2555 Normalise(&relative);
2556 for(i=0;i<victim->skeleton.num_joints;i++){
2557 victim->skeleton.joints[i].velocity.y=relative.y*10;
2558 victim->skeleton.joints[i].position.y+=relative.y*.3;
2559 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2560 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2562 victim->Puff(abdomen);
2563 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2567 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2568 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2570 if(id==0)camerashake+=.4;
2579 if(tutoriallevel!=1){
2580 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2581 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2582 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2583 OPENAL_SetPaused(channels[heavyimpactsound], false);
2586 relative=victim->coords-coords;
2588 Normalise(&relative);
2589 for(i=0;i<victim->skeleton.num_joints;i++){
2590 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2592 victim->Puff(abdomen);
2593 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2597 victim->DoDamage(damagemult*500/victim->protectionhigh);
2598 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2602 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2603 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2605 if(id==0)camerashake+=.4;
2614 if(tutoriallevel!=1){
2615 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2616 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2617 OPENAL_SetVolume(channels[thudsound], 400);
2618 OPENAL_SetPaused(channels[thudsound], false);
2621 victim->skeleton.longdead=0;
2622 victim->skeleton.free=1;
2623 victim->skeleton.broken=0;
2624 victim->skeleton.spinny=1;
2626 for(i=0;i<victim->skeleton.num_joints;i++){
2627 victim->skeleton.joints[i].velchange=0;
2628 //victim->skeleton.joints[i].delay=0;
2629 victim->skeleton.joints[i].locked=0;
2632 relative=victim->coords-coords;
2633 Normalise(&relative);
2635 Normalise(&relative);
2636 for(i=0;i<victim->skeleton.num_joints;i++){
2637 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2639 if(id==0&&!victim->dead){
2643 victim->Puff(abdomen);
2644 victim->DoDamage(damagemult*20/victim->protectionhigh);
2645 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2647 if(!victim->dead)staggerdelay=1.2;
2653 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2654 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2655 //if(id==0)camerashake+=.4;
2666 if(!victim->skeleton.free)hasvictim=0;
2669 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2670 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2671 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2672 OPENAL_SetVolume(channels[knifesheathesound], 128);
2673 OPENAL_SetPaused(channels[knifesheathesound], false);
2676 if(victim&&hasvictim){
2677 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2679 XYZ where,startpoint,endpoint,movepoint,colpoint;
2680 float rotationpoint;
2682 if(weapons.type[weaponids[weaponactive]]==knife){
2683 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2684 where-=victim->coords;
2685 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2692 if(weapons.type[weaponids[weaponactive]]==sword){
2693 where=weapons.position[weaponids[weaponactive]];
2694 where-=victim->coords;
2695 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2697 where=weapons.tippoint[weaponids[weaponactive]];
2698 where-=victim->coords;
2699 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2702 if(weapons.type[weaponids[weaponactive]]==staff){
2703 where=weapons.position[weaponids[weaponactive]];
2704 where-=victim->coords;
2705 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2707 where=weapons.tippoint[weaponids[weaponactive]];
2708 where-=victim->coords;
2709 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2714 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2717 if(victim->dead!=2){
2718 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2719 if(id==0&&!victim->dead){
2720 bonus=FinishedBonus;
2725 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2727 victim->skeleton.longdead=0;
2728 victim->skeleton.free=1;
2729 victim->skeleton.broken=0;
2731 for(i=0;i<victim->skeleton.num_joints;i++){
2732 victim->skeleton.joints[i].velchange=0;
2733 victim->skeleton.joints[i].locked=0;
2734 //victim->skeleton.joints[i].velocity=0;
2736 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2737 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2738 OPENAL_SetVolume(channels[fleshstabsound], 128);
2739 OPENAL_SetPaused(channels[fleshstabsound], false);
2742 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2743 weapons.blooddrip[weaponids[weaponactive]]+=5;
2744 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2748 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2749 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2750 OPENAL_SetVolume(channels[knifesheathesound], 128);
2751 OPENAL_SetPaused(channels[knifesheathesound], false);
2757 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2758 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2759 //if(id==0)camerashake+=.4;
2769 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2770 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2771 OPENAL_SetVolume(channels[knifedrawsound], 128);
2772 OPENAL_SetPaused(channels[knifedrawsound], false);
2775 if(victim&&hasvictim){
2776 XYZ footvel,footpoint;
2778 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2779 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2780 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2781 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2784 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2786 if(weapons.type[weaponids[weaponactive]]==sword){
2787 XYZ where,startpoint,endpoint,movepoint;
2788 float rotationpoint;
2791 where=weapons.position[weaponids[weaponactive]];
2792 where-=victim->coords;
2793 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2795 where=weapons.tippoint[weaponids[weaponactive]];
2796 where-=victim->coords;
2797 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2802 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2803 footpoint+=victim->coords;
2806 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2809 if(weapons.type[weaponids[weaponactive]]==staff){
2810 XYZ where,startpoint,endpoint,movepoint;
2811 float rotationpoint;
2814 where=weapons.position[weaponids[weaponactive]];
2815 where-=victim->coords;
2816 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2818 where=weapons.tippoint[weaponids[weaponactive]];
2819 where-=victim->coords;
2820 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2825 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2826 footpoint+=victim->coords;
2829 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2832 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2834 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2835 victim->skeleton.longdead=0;
2836 victim->skeleton.free=1;
2837 victim->skeleton.broken=0;
2839 for(i=0;i<victim->skeleton.num_joints;i++){
2840 victim->skeleton.joints[i].velchange=0;
2841 victim->skeleton.joints[i].locked=0;
2842 //victim->skeleton.joints[i].velocity=0;
2848 Normalise(&relative);
2849 //victim->Puff(abdomen);
2850 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2852 if(victim->bloodloss<victim->damagetolerance){
2853 victim->bloodloss+=1000;
2857 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2861 if(!hasvictim&&onterrain){
2862 weapons.bloody[weaponids[weaponactive]]=0;
2863 weapons.blooddrip[weaponids[weaponactive]]=0;
2867 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2868 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2870 if(id==0)camerashake+=.4;
2877 gLoc[0]=victim->coords.x;
2878 gLoc[1]=victim->coords.y;
2879 gLoc[2]=victim->coords.z;
2883 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2885 if(tutoriallevel!=1){
2886 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2887 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2888 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2889 OPENAL_SetPaused(channels[heavyimpactsound], false);
2893 if(tutoriallevel!=1){
2894 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2895 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2896 OPENAL_SetVolume(channels[landsound2], 256);
2897 OPENAL_SetPaused(channels[landsound2], false);
2901 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
2904 relative=victim->coords-coords;
2906 Normalise(&relative);
2907 for(i=0;i<victim->skeleton.num_joints;i++){
2908 victim->skeleton.joints[i].velocity=relative*30;
2910 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2912 victim->targetframe=0;
2913 victim->targetanimation=staggerbackhardanim;
2914 victim->targetrotation=targetrotation+180;
2919 victim->Puff(abdomen);
2920 victim->DoDamage(damagemult*60/victim->protectionhigh);
2929 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2930 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2932 if(id==0)camerashake+=.4;
2935 gLoc[0]=victim->coords.x;
2936 gLoc[1]=victim->coords.y;
2937 gLoc[2]=victim->coords.z;
2941 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
2942 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2943 if(tutoriallevel!=1){
2944 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2945 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2946 OPENAL_SetVolume(channels[thudsound], 512);
2947 OPENAL_SetPaused(channels[thudsound], false);
2950 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2951 if(tutoriallevel!=1){
2952 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2953 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2954 OPENAL_SetVolume(channels[whooshhitsound], 512);
2955 OPENAL_SetPaused(channels[whooshhitsound], false);
2959 if(tutoriallevel!=1){
2960 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2961 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2962 OPENAL_SetVolume(channels[heavyimpactsound], 256);
2963 OPENAL_SetPaused(channels[heavyimpactsound], false);
2967 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2970 relative=victim->coords-coords;
2972 Normalise(&relative);
2974 Normalise(&relative);
2975 for(i=0;i<victim->skeleton.num_joints;i++){
2976 victim->skeleton.joints[i].velocity=relative*5;
2978 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
2980 victim->targetframe=0;
2981 victim->targetanimation=staggerbackhardanim;
2982 victim->targetrotation=targetrotation+180;
2986 victim->Puff(abdomen);
2987 victim->DoDamage(damagemult*60/victim->protectionhigh);
2995 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
2996 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2997 if(victim->id==0)camerashake+=.4;
3000 gLoc[0]=victim->coords.x;
3001 gLoc[1]=victim->coords.y;
3002 gLoc[2]=victim->coords.z;
3007 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3008 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3009 OPENAL_SetVolume(channels[landsound2], 256);
3010 OPENAL_SetPaused(channels[landsound2], false);
3016 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
3017 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3018 if(victim->id==0)camerashake+=.4;
3021 gLoc[0]=victim->coords.x;
3022 gLoc[1]=victim->coords.y;
3023 gLoc[2]=victim->coords.z;
3028 if(weaponactive!=-1){
3029 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3030 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3031 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3033 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3034 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3035 OPENAL_SetVolume(channels[swordstaffsound], 512);
3036 OPENAL_SetPaused(channels[swordstaffsound], false);
3039 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3040 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3041 OPENAL_SetVolume(channels[metalhitsound], 512);
3042 OPENAL_SetPaused(channels[metalhitsound], false);
3050 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3051 if(weaponactive!=-1){
3054 weapons.owner[weaponids[0]]=-1;
3055 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);
3057 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3058 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3060 weapons.velocity[weaponids[0]]=aim*50;
3061 weapons.tipvelocity[weaponids[0]]=aim*50;
3062 weapons.missed[weaponids[0]]=0;
3063 weapons.hitsomething[weaponids[0]]=0;
3064 weapons.freetime[weaponids[0]]=0;
3065 weapons.firstfree[weaponids[0]]=1;
3066 weapons.physics[weaponids[0]]=0;
3069 weaponids[0]=weaponids[num_weapons];
3075 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3077 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3080 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3088 if(tutoriallevel!=1){
3091 gLoc[0]=victim->coords.x;
3092 gLoc[1]=victim->coords.y;
3093 gLoc[2]=victim->coords.z;
3097 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3098 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3099 OPENAL_SetVolume(channels[knifeslicesound], 512);
3100 OPENAL_SetPaused(channels[knifeslicesound], false);
3102 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3103 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3104 if(victim->id != 0 || difficulty==2){
3105 victim->targetframe=0;
3106 victim->targetanimation=staggerbackhardanim;
3107 victim->targetrotation=targetrotation+180;
3111 victim->lowreversaldelay=0;
3112 victim->highreversaldelay=0;
3113 if(aitype!=playercontrolled)weaponmissdelay=.6;
3115 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3116 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3118 XYZ footvel,footpoint;
3121 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3124 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;
3126 if(tutoriallevel!=1){
3127 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3128 footvel=DoRotation(facing,0,90,0)*.8;
3130 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3131 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3132 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3133 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3135 if(tutoriallevel==1){
3136 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3138 victim->DoDamage(damagemult*0);
3141 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3142 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3143 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3150 if(tutoriallevel!=1){
3151 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3152 else victim->DoBloodBig(2/victim->armorhigh,185);
3153 victim->deathbleeding=1;
3156 gLoc[0]=victim->coords.x;
3157 gLoc[1]=victim->coords.y;
3158 gLoc[2]=victim->coords.z;
3162 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3163 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3164 OPENAL_SetVolume(channels[swordslicesound], 512);
3165 OPENAL_SetPaused(channels[swordslicesound], false);
3167 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3168 //if(animation[victim->targetanimation].attack){
3169 //if(victim->creature==rabbittype){
3170 if(tutoriallevel!=1){
3171 victim->targetframe=0;
3172 victim->targetanimation=staggerbackhardanim;
3173 victim->targetrotation=targetrotation+180;
3179 if(tutoriallevel!=1){
3180 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3181 weapons.blooddrip[weaponids[weaponactive]]+=3;
3183 float bloodlossamount;
3184 bloodlossamount=200+abs((float)(Random()%40))-20;
3185 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3186 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3187 victim->DoDamage(damagemult*0);
3189 XYZ footvel,footpoint;
3192 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3195 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;
3197 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3198 footvel=DoRotation(facing,0,90,0)*.8;
3200 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3201 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3202 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3203 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3211 gLoc[0]=victim->coords.x;
3212 gLoc[1]=victim->coords.y;
3213 gLoc[2]=victim->coords.z;
3217 if(victim->weaponactive!=-1){
3218 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3219 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3220 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3222 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3223 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3224 OPENAL_SetVolume(channels[swordstaffsound], 512);
3225 OPENAL_SetPaused(channels[swordstaffsound], false);
3228 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3229 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3230 OPENAL_SetVolume(channels[metalhitsound], 512);
3231 OPENAL_SetPaused(channels[metalhitsound], false);
3237 victim->Puff(righthand);
3239 victim->targetframe=0;
3240 victim->targetanimation=staggerbackhighanim;
3241 victim->targetrotation=targetrotation+180;
3243 weapons.owner[victim->weaponids[0]]=-1;
3244 aim=DoRotation(facing,0,90,0)*21;
3246 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3247 weapons.tipvelocity[victim->weaponids[0]]=aim;
3248 weapons.missed[victim->weaponids[0]]=1;
3249 weapons.hitsomething[weaponids[0]]=0;
3250 weapons.freetime[victim->weaponids[0]]=0;
3251 weapons.firstfree[victim->weaponids[0]]=1;
3252 weapons.physics[victim->weaponids[0]]=1;
3253 victim->num_weapons--;
3254 if(victim->num_weapons){
3255 victim->weaponids[0]=victim->weaponids[num_weapons];
3256 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3258 victim->weaponactive=-1;
3259 for(i=0;i<numplayers;i++){
3260 player[i].wentforweapon=0;
3263 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3264 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3265 OPENAL_SetVolume(channels[metalhitsound], 512);
3266 OPENAL_SetPaused(channels[metalhitsound], false);*/
3272 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3273 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3274 if(tutoriallevel!=1){
3275 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3277 if(id==0)camerashake+=.4;
3278 if(Random()%2||creature==wolftype){
3283 gLoc[0]=victim->coords.x;
3284 gLoc[1]=victim->coords.y;
3285 gLoc[2]=victim->coords.z;
3289 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3290 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3291 OPENAL_SetVolume(channels[staffheadsound], 256);
3292 OPENAL_SetPaused(channels[staffheadsound], false);
3296 relative=victim->coords-coords;
3298 Normalise(&relative);
3299 relative=DoRotation(relative,0,90,0);
3301 Normalise(&relative);
3302 for(i=0;i<victim->skeleton.num_joints;i++){
3303 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3305 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3306 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3309 if(tutoriallevel!=1){
3310 victim->DoDamage(damagemult*120/victim->protectionhigh);
3321 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3322 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3323 if(tutoriallevel!=1){
3324 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3326 if(id==0)camerashake+=.4;
3327 if(Random()%2||creature==wolftype){
3332 gLoc[0]=victim->coords.x;
3333 gLoc[1]=victim->coords.y;
3334 gLoc[2]=victim->coords.z;
3338 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3339 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3340 OPENAL_SetVolume(channels[staffheadsound], 256);
3341 OPENAL_SetPaused(channels[staffheadsound], false);
3345 relative=victim->coords-coords;
3347 Normalise(&relative);
3348 relative=DoRotation(relative,0,-90,0);
3349 for(i=0;i<victim->skeleton.num_joints;i++){
3350 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3352 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3353 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3356 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3367 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3368 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3370 if(tutoriallevel!=1){
3371 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3372 if(id==0)camerashake+=.4;
3373 if(Random()%2||creature==wolftype){
3378 gLoc[0]=victim->coords.x;
3379 gLoc[1]=victim->coords.y;
3380 gLoc[2]=victim->coords.z;
3384 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3385 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3386 OPENAL_SetVolume(channels[staffbodysound], 256);
3387 OPENAL_SetPaused(channels[staffbodysound], false);
3389 victim->skeleton.longdead=0;
3390 victim->skeleton.free=1;
3391 victim->skeleton.broken=0;
3393 for(i=0;i<victim->skeleton.num_joints;i++){
3394 victim->skeleton.joints[i].velchange=0;
3395 victim->skeleton.joints[i].locked=0;
3396 //victim->skeleton.joints[i].velocity=0;
3402 /*relative=victim->coords-coords;
3404 Normalise(&relative);
3405 relative=DoRotation(relative,0,90,0);*/
3407 Normalise(&relative);
3409 for(i=0;i<victim->skeleton.num_joints;i++){
3410 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3413 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3416 for(i=0;i<victim->skeleton.num_joints;i++){
3417 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3420 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3422 victim->Puff(abdomen);
3423 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3436 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3437 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3439 if(id==0)camerashake+=.4;
3442 gLoc[0]=victim->coords.x;
3443 gLoc[1]=victim->coords.y;
3444 gLoc[2]=victim->coords.z;
3449 relative=victim->coords-coords;
3451 Normalise(&relative);
3457 if(animation[victim->targetanimation].height==lowheight){
3463 for(i=0;i<victim->skeleton.num_joints;i++){
3464 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3466 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3467 if(tutoriallevel!=1){
3468 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3469 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3470 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3471 OPENAL_SetPaused(channels[heavyimpactsound], false);
3474 victim->DoDamage(damagemult*100/victim->protectionhead);
3475 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3476 if(creature==wolftype){
3477 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3478 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3479 OPENAL_SetVolume(channels[clawslicesound], 128);
3480 OPENAL_SetPaused(channels[clawslicesound], false);
3482 victim->DoBloodBig(2/victim->armorhead,175);
3486 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3487 for(i=0;i<victim->skeleton.num_joints;i++){
3488 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3490 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3491 victim->targetframe=0;
3492 victim->targetanimation=staggerbackhighanim;
3493 victim->targetrotation=targetrotation+180;
3495 if(tutoriallevel!=1){
3496 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3497 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3498 OPENAL_SetVolume(channels[landsound2], 128);
3499 OPENAL_SetPaused(channels[landsound2], false);
3501 victim->Puff(abdomen);
3502 victim->DoDamage(damagemult*30/victim->protectionhigh);
3503 if(creature==wolftype){
3504 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3505 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3506 OPENAL_SetVolume(channels[clawslicesound], 128);
3507 OPENAL_SetPaused(channels[clawslicesound], false);
3509 victim->DoBloodBig(2/victim->armorhigh,170);
3516 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3517 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3519 if(id==0)camerashake+=.2;
3522 gLoc[0]=victim->coords.x;
3523 gLoc[1]=victim->coords.y;
3524 gLoc[2]=victim->coords.z;
3528 if(tutoriallevel!=1){
3529 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3530 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3531 OPENAL_SetVolume(channels[landsound2], 128);
3532 OPENAL_SetPaused(channels[landsound2], false);
3535 relative=victim->coords-coords;
3537 Normalise(&relative);
3539 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3542 for(i=0;i<victim->skeleton.num_joints;i++){
3543 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3545 relative=DoRotation(relative,0,-90,0);
3547 for(i=0;i<victim->skeleton.num_joints;i++){
3548 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)
3549 victim->skeleton.joints[i].velocity=relative*80;
3551 victim->Puff(rightankle);
3552 victim->Puff(leftankle);
3553 victim->DoDamage(damagemult*40/victim->protectionlow);
3556 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3557 for(i=0;i<victim->skeleton.num_joints;i++){
3558 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3560 relative=DoRotation(relative,0,-90,0);
3561 for(i=0;i<victim->skeleton.num_joints;i++){
3562 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)
3563 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3565 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3566 victim->targetframe=0;
3567 victim->targetanimation=staggerbackhighanim;
3568 victim->targetrotation=targetrotation+180;
3570 if(tutoriallevel!=1){
3571 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3572 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3573 OPENAL_SetVolume(channels[landsound2], 128);
3574 OPENAL_SetPaused(channels[landsound2], false);
3576 victim->Puff(abdomen);
3577 victim->DoDamage(damagemult*30/victim->protectionlow);
3587 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3588 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3590 if(id==0)camerashake+=.4;
3597 gLoc[0]=victim->coords.x;
3598 gLoc[1]=victim->coords.y;
3599 gLoc[2]=victim->coords.z;
3603 if(tutoriallevel!=1){
3604 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3605 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3606 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3607 OPENAL_SetPaused(channels[heavyimpactsound], false);
3609 if(creature==wolftype){
3610 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3611 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3612 OPENAL_SetVolume(channels[clawslicesound], 128);
3613 OPENAL_SetPaused(channels[clawslicesound], false);
3615 victim->DoBloodBig(2/victim->armorhigh,170);
3619 relative=victim->coords-oldcoords;
3621 Normalise(&relative);
3622 //relative=DoRotation(relative,0,-90,0);
3623 for(i=0;i<victim->skeleton.num_joints;i++){
3624 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3626 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3628 victim->Puff(abdomen);
3629 victim->DoDamage(damagemult*150/victim->protectionhigh);
3638 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3639 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3640 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3641 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3644 weaponids[num_weapons]=weaponids[victim->weaponactive];
3647 weaponids[0]=victim->weaponids[victim->weaponactive];
3648 victim->num_weapons--;
3649 if(victim->num_weapons>0){
3650 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3651 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3653 victim->weaponactive=-1;
3658 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3660 if(id==0)camerashake+=.4;
3667 gLoc[0]=victim->coords.x;
3668 gLoc[1]=victim->coords.y;
3669 gLoc[2]=victim->coords.z;
3673 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3674 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3675 OPENAL_SetVolume(channels[whooshhitsound], 128);
3676 OPENAL_SetPaused(channels[whooshhitsound], false);
3679 relative=victim->coords-oldcoords;
3681 Normalise(&relative);
3682 //relative=DoRotation(relative,0,-90,0);
3683 for(i=0;i<victim->skeleton.num_joints;i++){
3684 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3686 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3689 victim->DoDamage(damagemult*70/victim->protectionhigh);
3692 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3694 if(id==0)camerashake+=.4;
3701 gLoc[0]=victim->coords.x;
3702 gLoc[1]=victim->coords.y;
3703 gLoc[2]=victim->coords.z;
3709 bonus=staffreversebonus;
3714 if(tutoriallevel!=1){
3715 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3716 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3717 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3718 OPENAL_SetPaused(channels[heavyimpactsound], false);
3722 bonus=staffreversebonus;
3728 relative=victim->coords-oldcoords;
3730 Normalise(&relative);
3731 //relative=DoRotation(relative,0,-90,0);
3732 for(i=0;i<victim->skeleton.num_joints;i++){
3733 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3735 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3738 victim->DoDamage(damagemult*70/victim->protectionhigh);
3741 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3747 Normalise(&relative);
3750 for(i=0;i<victim->skeleton.num_joints;i++){
3751 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3753 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3754 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3755 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3756 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3757 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3758 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3759 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3760 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3762 victim->Puff(abdomen);
3763 victim->DoDamage(damagemult*90/victim->protectionhigh);
3773 if(weaponactive!=-1||creature==wolftype)doslice=1;
3774 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3778 gLoc[0]=victim->coords.x;
3779 gLoc[1]=victim->coords.y;
3780 gLoc[2]=victim->coords.z;
3784 if(weaponactive!=-1){
3785 victim->DoBloodBig(2/victim->armorhigh,225);
3786 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3787 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3788 OPENAL_SetVolume(channels[knifeslicesound], 512);
3789 OPENAL_SetPaused(channels[knifeslicesound], false);
3790 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3791 weapons.blooddrip[weaponids[weaponactive]]+=3;
3793 if(weaponactive==-1&&creature==wolftype){
3794 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3795 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3796 OPENAL_SetVolume(channels[clawslicesound], 128);
3797 OPENAL_SetPaused(channels[clawslicesound], false);
3799 victim->DoBloodBig(2/victim->armorhigh,175);
3806 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3812 Normalise(&relative);
3815 for(i=0;i<victim->skeleton.num_joints;i++){
3816 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3818 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
3819 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
3820 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
3821 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
3822 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
3823 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
3824 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
3825 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
3828 bonus=swordreversebonus;
3832 //victim->DoDamage(90);
3834 /*if(weaponactive!=-1){
3837 gLoc[0]=victim->coords.x;
3838 gLoc[1]=victim->coords.y;
3839 gLoc[2]=victim->coords.z;
3843 victim->DoBloodBig(2,225);
3844 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3845 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3846 OPENAL_SetVolume(channels[knifeslicesound], 512);
3847 OPENAL_SetPaused(channels[knifeslicesound], false);
3848 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3849 weapons.blooddrip[weaponids[weaponactive]]+=3;
3853 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
3855 if(id==0)camerashake+=.4;
3862 gLoc[0]=victim->coords.x;
3863 gLoc[1]=victim->coords.y;
3864 gLoc[2]=victim->coords.z;
3868 if(tutoriallevel!=1){
3869 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3870 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3871 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3872 OPENAL_SetPaused(channels[heavyimpactsound], false);
3876 relative=victim->coords-oldcoords;
3878 Normalise(&relative);
3879 relative=DoRotation(relative,0,-90,0);
3880 for(i=0;i<victim->skeleton.num_joints;i++){
3881 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3883 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3885 victim->Puff(abdomen);
3886 victim->DoDamage(damagemult*30/victim->protectionhigh);
3895 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
3898 victim->skeleton.spinny=0;
3902 Normalise(&relative);
3903 if(victim->id==0)relative/=30;
3904 for(i=0;i<victim->skeleton.num_joints;i++){
3905 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3907 //victim->DoDamage(1000);
3908 victim->damage=victim->damagetolerance;
3909 victim->permanentdamage=victim->damagetolerance-1;
3912 if(weaponactive!=-1||creature==wolftype)doslice=1;
3913 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3917 gLoc[0]=victim->coords.x;
3918 gLoc[1]=victim->coords.y;
3919 gLoc[2]=victim->coords.z;
3923 if(weaponactive!=-1){
3924 victim->DoBloodBig(200,225);
3925 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3926 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3927 OPENAL_SetVolume(channels[knifeslicesound], 512);
3928 OPENAL_SetPaused(channels[knifeslicesound], false);
3929 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3930 weapons.blooddrip[weaponids[weaponactive]]+=5;
3933 if(creature==wolftype&&weaponactive==-1){
3934 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3935 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3936 OPENAL_SetVolume(channels[clawslicesound], 128);
3937 OPENAL_SetPaused(channels[clawslicesound], false);
3939 victim->DoBloodBig(2,175);
3949 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3950 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3952 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3953 if(targetanimation==knifesneakattackanim){
3954 /*victim->DoBloodBig(200,195);
3959 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3960 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3962 XYZ footvel,footpoint;
3964 footpoint=weapons.tippoint[weaponids[0]];
3965 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3966 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3967 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3968 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3969 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3970 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3971 victim->DoBloodBig(200,195);
3978 //victim->neckspurtamount=5;
3980 if(targetanimation==knifefollowanim){
3986 XYZ footvel,footpoint;
3988 footpoint=weapons.tippoint[weaponids[0]];
3989 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3990 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3991 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3992 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3993 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3994 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3997 victim->bloodloss+=10000;
4001 gLoc[0]=victim->coords.x;
4002 gLoc[1]=victim->coords.y;
4003 gLoc[2]=victim->coords.z;
4007 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4008 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4009 OPENAL_SetVolume(channels[fleshstabsound], 512);
4010 OPENAL_SetPaused(channels[fleshstabsound], false);
4011 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4012 weapons.blooddrip[weaponids[weaponactive]]+=5;
4016 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
4019 for(i=0;i<victim->skeleton.num_joints;i++){
4020 victim->skeleton.joints[i].velocity=0;
4022 if(targetanimation==knifefollowanim){
4024 for(i=0;i<victim->skeleton.num_joints;i++){
4025 victim->skeleton.joints[i].velocity=0;
4028 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
4031 gLoc[0]=victim->coords.x;
4032 gLoc[1]=victim->coords.y;
4033 gLoc[2]=victim->coords.z;
4037 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4038 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4039 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4040 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4041 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4042 weapons.blooddrip[weaponids[weaponactive]]+=5;
4044 XYZ footvel,footpoint;
4046 footpoint=weapons.tippoint[weaponids[0]];
4047 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4048 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4049 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4050 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4051 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4052 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4056 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4057 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4066 XYZ footvel,footpoint;
4068 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
4069 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4070 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4071 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4072 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4073 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4074 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4075 victim->DoBloodBig(200,180);
4076 victim->DoBloodBig(200,215);
4077 victim->bloodloss+=10000;
4081 gLoc[0]=victim->coords.x;
4082 gLoc[1]=victim->coords.y;
4083 gLoc[2]=victim->coords.z;
4087 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4088 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4089 OPENAL_SetVolume(channels[fleshstabsound], 512);
4090 OPENAL_SetPaused(channels[fleshstabsound], false);
4091 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4092 weapons.blooddrip[weaponids[weaponactive]]+=5;
4096 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
4099 for(i=0;i<victim->skeleton.num_joints;i++){
4100 victim->skeleton.joints[i].velocity=0;
4102 if(weaponactive!=-1){
4105 gLoc[0]=victim->coords.x;
4106 gLoc[1]=victim->coords.y;
4107 gLoc[2]=victim->coords.z;
4111 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4112 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4113 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4114 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4115 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4116 weapons.blooddrip[weaponids[weaponactive]]+=5;
4118 XYZ footvel,footpoint;
4120 footpoint=weapons.tippoint[weaponids[0]];
4121 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4122 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4123 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4124 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4125 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4126 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4130 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4132 if(id==0)camerashake+=.4;
4139 gLoc[0]=victim->coords.x;
4140 gLoc[1]=victim->coords.y;
4141 gLoc[2]=victim->coords.z;
4145 if(weaponactive==-1){
4146 if(tutoriallevel!=1){
4147 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4148 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4149 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4150 OPENAL_SetPaused(channels[heavyimpactsound], false);
4155 if(weaponactive!=-1||creature==wolftype)doslice=1;
4156 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4158 if(weaponactive!=-1){
4159 victim->DoBloodBig(2/victim->armorhead,225);
4160 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4161 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4162 OPENAL_SetVolume(channels[knifeslicesound], 512);
4163 OPENAL_SetPaused(channels[knifeslicesound], false);
4164 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4165 weapons.blooddrip[weaponids[weaponactive]]+=3;
4167 if(weaponactive==-1&&creature==wolftype){
4168 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4169 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4170 OPENAL_SetVolume(channels[clawslicesound], 128);
4171 OPENAL_SetPaused(channels[clawslicesound], false);
4173 victim->DoBloodBig(2/victim->armorhead,175);
4186 //relative=victim->coords-oldcoords;
4189 Normalise(&relative);
4190 relative=DoRotation(relative,0,90,0);
4192 Normalise(&relative);
4193 for(i=0;i<victim->skeleton.num_joints;i++){
4194 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4196 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4197 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4198 victim->DoDamage(damagemult*100/victim->protectionhead);
4202 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4206 //relative=victim->coords-oldcoords;
4209 Normalise(&relative);
4210 relative=DoRotation(relative,0,90,0);
4212 Normalise(&relative);
4213 for(i=0;i<victim->skeleton.num_joints;i++){
4214 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4216 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4219 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4220 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4231 if(targetframe>animation[currentanimation].numframes-1){
4234 targetanimation=getIdle();
4238 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4239 targetanimation=rollanim;
4250 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4251 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4252 OPENAL_SetVolume(channels[movewhooshsound], 128);
4253 OPENAL_SetPaused(channels[movewhooshsound], false);
4255 if(currentanimation==staggerbackhighanim){
4256 targetanimation=getIdle();
4258 if(currentanimation==staggerbackhardanim){
4259 targetanimation=getIdle();
4261 if(currentanimation==removeknifeanim){
4262 targetanimation=getIdle();
4264 if(currentanimation==crouchremoveknifeanim){
4265 targetanimation=getCrouch();
4267 if(currentanimation==backhandspringanim){
4268 targetanimation=getIdle();
4270 if(currentanimation==dodgebackanim){
4271 targetanimation=getIdle();
4273 if(currentanimation==drawleftanim){
4274 targetanimation=getIdle();
4276 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4277 targetanimation=getIdle();
4278 if(currentanimation==crouchdrawrightanim){
4279 targetanimation=getCrouch();
4281 if(weaponactive==-1)weaponactive=0;
4282 else if(weaponactive==0){
4286 buffer=weaponids[0];
4287 weaponids[0]=weaponids[1];
4288 weaponids[1]=buffer;
4292 if(weaponactive==-1){
4302 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4303 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4304 OPENAL_SetVolume(channels[knifesheathesound], 128);
4305 OPENAL_SetPaused(channels[knifesheathesound], false);
4307 if(weaponactive!=-1){
4317 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4318 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4319 OPENAL_SetVolume(channels[knifedrawsound], 128);
4320 OPENAL_SetPaused(channels[knifedrawsound], false);
4323 if(currentanimation==rollanim){
4324 targetanimation=getCrouch();
4329 if(targetanimation==walljumprightkickanim){
4332 if(targetanimation==walljumpleftkickanim){
4335 targetanimation=jumpdownanim;
4337 if(currentanimation==climbanim){
4338 targetanimation=getCrouch();
4341 if(!isnormal(coords.x))
4352 if(targetanimation==rabbitkickreversalanim){
4353 targetanimation=getCrouch();
4356 if(targetanimation==jumpreversalanim){
4357 targetanimation=getCrouch();
4360 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4361 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4363 float closestdist=-1;
4366 for(i=0;i<numplayers;i++){
4367 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4368 distance=findDistancefast(&player[i].coords,&coords);
4369 if(closestdist==-1||distance<closestdist){
4370 closestdist=distance;
4375 if(closestdist>0&&closest>=0&&closestdist<16){
4376 victim=&player[closest];
4377 targetanimation=walljumprightkickanim;
4379 XYZ rotatetarget=victim->coords-coords;
4380 Normalise(&rotatetarget);
4381 rotation=-asin(0-rotatetarget.x);
4383 if(rotatetarget.z<0)rotation=180-rotation;
4384 targettilt2=-asin(rotatetarget.y)*360/6.28;
4385 velocity=(victim->coords-coords)*4;
4390 if(targetanimation==walljumpbackanim){
4391 targetanimation=backflipanim;
4395 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4397 if(targetanimation==walljumprightanim){
4398 targetanimation=rightflipanim;
4402 velocity=DoRotation(facing,0,30,0)*-8;
4405 if(targetanimation==walljumpfrontanim){
4406 targetanimation=frontflipanim;
4408 //targetrotation-=180;
4413 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4415 if(targetanimation==walljumpleftanim){
4418 float closestdist=-1;
4421 for(i=0;i<numplayers;i++){
4422 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4423 distance=findDistancefast(&player[i].coords,&coords);
4424 if(closestdist==-1||distance<closestdist){
4425 closestdist=distance;
4430 if(closestdist>0&&closest>=0&&closestdist<16){
4431 victim=&player[closest];
4432 targetanimation=walljumpleftkickanim;
4434 XYZ rotatetarget=victim->coords-coords;
4435 Normalise(&rotatetarget);
4436 rotation=-asin(0-rotatetarget.x);
4438 if(rotatetarget.z<0)rotation=180-rotation;
4439 targettilt2=-asin(rotatetarget.y)*360/6.28;
4440 velocity=(victim->coords-coords)*4;
4445 if(targetanimation!=walljumpleftkickanim){
4446 targetanimation=leftflipanim;
4450 velocity=DoRotation(facing,0,-30,0)*-8;
4453 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4455 if(targetanimation==sneakattackanim){
4456 float ycoords=oldcoords.y;
4457 currentanimation=getCrouch();
4458 targetanimation=getCrouch();
4461 targetrotation+=180;
4466 targetheadrotation+=180;
4468 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4472 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4473 float ycoords=oldcoords.y;
4474 targetanimation=getIdle();
4476 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4480 if(currentanimation==knifefollowanim){
4481 targetanimation=getIdle();
4484 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4485 float ycoords=oldcoords.y;
4486 targetanimation=getStop();
4487 targetrotation+=180;
4492 targetheadrotation+=180;
4493 if(!isnormal(coords.x))
4495 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4496 oldcoords=coords+facing*.5;
4497 else if(currentanimation==sweepreversalanim)
4498 oldcoords=coords+facing*1.1;
4499 else if(currentanimation==upunchreversalanim){
4500 oldcoords=coords+facing*1.5;
4501 targetrotation+=180;
4503 targetheadrotation+=180;
4507 else if(currentanimation==knifeslashreversalanim){
4508 oldcoords=coords+facing*.5;
4511 targetheadrotation+=90;
4515 else if(currentanimation==staffspinhitreversalanim){
4516 targetrotation+=180;
4518 targetheadrotation+=180;
4522 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4523 else oldcoords.y=ycoords;
4524 currentoffset=coords-oldcoords;
4530 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4535 if(animation[targetanimation].attack==reversed){
4537 if(targetanimation==sweepreversedanim)targetrotation+=90;
4538 targetanimation=backhandspringanim;
4548 PlaySoundEx( landsound, samp[landsound], NULL, true);
4549 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4550 OPENAL_SetVolume(channels[landsound], 128);
4551 OPENAL_SetPaused(channels[landsound], false);
4553 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4554 targetanimation=rollanim;
4557 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4558 coords.y=oldcoords.y;
4560 if(currentanimation==knifeslashreversedanim){
4561 targetanimation=rollanim;
4566 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4567 coords.y=oldcoords.y;
4571 targetanimation=jumpdownanim;
4573 if(wasLanding())targetanimation=getIdle();
4574 if(wasLandhard())targetanimation=getIdle();
4575 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4576 targetanimation=getIdle();
4578 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4579 coords.y=oldcoords.y;
4580 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4581 targetoffset.y=coords.y;
4582 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4583 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4584 currentoffset.y-=(coords.y-targetoffset.y);
4585 coords.y=targetoffset.y;
4587 normalsupdatedelay=0;
4589 if(currentanimation==upunchanim){
4590 targetanimation=getStop();
4591 normalsupdatedelay=0;
4594 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4595 targetrotation=rotation;
4598 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4599 if(!hasstaff)DoDamage(35);
4602 rabbitkickragdoll=1;
4604 if(currentanimation==rabbitkickreversedanim){
4611 if(id!=0)SolidHitBonus();
4615 targetanimation=rollanim;
4617 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4621 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4627 if(currentanimation==jumpreversedanim){
4634 if(id!=0)SolidHitBonus();
4638 targetanimation=rollanim;
4640 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4645 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){
4646 targetanimation=getupfromfrontanim;
4649 else if(animation[currentanimation].attack==normalattack){
4650 targetanimation=getIdle();
4653 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4654 targetanimation=blockhighleftstrikeanim;
4656 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4657 targetanimation=getIdle();
4660 if(currentanimation==spinkickanim&&victim->skeleton.free){
4661 if(creature==rabbittype)targetanimation=fightidleanim;
4666 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4668 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4669 targetanimation=jumpdownanim;
4674 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4675 if(!isRun()||!wasRun()){
4676 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4677 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4678 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4679 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4681 if(isRun()&&wasRun()){
4684 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4685 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4688 else if(transspeed)target+=multiplier*transspeed*speed*2;
4690 if(!isRun()||!wasRun()){
4691 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4692 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4693 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4694 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4698 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4700 if(target>1){currentframe=targetframe; target=1;}
4702 rot=targetrot*target;
4703 rotation+=rot-oldrot;
4709 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4711 for(i=0;i<skeleton.num_joints;i++){
4712 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4715 skeleton.FindForwards();
4717 for(i=0;i<skeleton.num_muscles;i++){
4718 if(skeleton.muscles[i].visible)
4720 skeleton.FindRotationMuscle(i,targetanimation);
4723 for(i=0;i<skeleton.num_muscles;i++){
4724 if(skeleton.muscles[i].visible)
4726 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4727 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4728 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4733 for(i=0;i<skeleton.num_joints;i++){
4734 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4737 skeleton.FindForwards();
4739 for(i=0;i<skeleton.num_muscles;i++){
4740 if(skeleton.muscles[i].visible)
4742 skeleton.FindRotationMuscle(i,targetanimation);
4745 for(i=0;i<skeleton.num_muscles;i++){
4746 if(skeleton.muscles[i].visible)
4748 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4749 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4750 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4751 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4752 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4753 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4754 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4755 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4756 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4760 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4762 oldcurrentanimation=currentanimation;
4763 oldtargetanimation=targetanimation;
4764 oldtargetframe=targetframe;
4765 oldcurrentframe=currentframe;
4767 for(i=0;i<skeleton.num_joints;i++){
4768 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4769 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4771 offset=currentoffset*(1-target)+targetoffset*target;
4772 for(i=0;i<skeleton.num_muscles;i++){
4773 if(skeleton.muscles[i].visible)
4775 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4776 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4777 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4782 if(isLanding()&&landhard){
4783 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4784 if(id==0)camerashake+=.4;
4785 targetanimation=getLandhard();
4793 //skeleton.DoConstraints();
4796 void Person::DoStuff(){
4797 static XYZ terrainnormal;
4798 static XYZ flatfacing;
4799 static XYZ flatvelocity;
4800 static float flatvelspeed;
4804 static int bloodsize;
4805 static int startx,starty,endx,endy;
4806 static int texdetailint;
4807 static GLubyte color;
4808 static XYZ bloodvel;
4810 onfiredelay-=multiplier;
4811 if(onfiredelay<0&&onfire)
4819 crouchkeydowntime+=multiplier;
4820 if(!crouchkeydown)crouchkeydowntime=0;
4821 jumpkeydowntime+=multiplier;
4822 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
4824 if(hostile||damage>0||bloodloss>0)immobile=0;
4826 if(isIdle()||isRun())targetoffset=0;
4828 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
4830 if(id==0)blooddimamount-=multiplier*.3;
4831 speechdelay-=multiplier;
4832 texupdatedelay-=multiplier;
4833 interestdelay-=multiplier;
4834 flamedelay-=multiplier;
4835 parriedrecently-=multiplier;
4841 if(id==0)speed=1.1*speedmult;
4842 else speed=1.0*speedmult;
4843 if(!skeleton.free)rabbitkickragdoll=0;
4847 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
4848 if(id!=0&&creature==wolftype&&difficulty==2){
4850 if(aitype!=passivetype){
4852 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){
4856 if(scale<0.2)superruntoggle=0;
4857 if(targetanimation==wolfrunninganim&&!superruntoggle){
4858 targetanimation=getRun();
4862 if(weaponactive==-1&&num_weapons>0){
4863 if(weapons.type[weaponids[0]]==staff){
4870 /*if(aitype!=playercontrolled)*///deathbleeding=5;
4871 /*if(aitype!=playercontrolled)*/
4873 if(burnt>.6)burnt=.6;
4874 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
4876 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
4887 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4888 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
4892 while(flamedelay<0&&onfire){
4894 howmany=abs(Random()%(skeleton.num_joints));
4895 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4896 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4897 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4898 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4899 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
4902 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
4904 howmany=abs(Random()%(skeleton.num_joints));
4905 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
4906 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
4907 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
4908 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
4909 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
4913 bleeding-=multiplier*.3;
4915 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
4916 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
4920 if(neckspurtamount>0){
4921 neckspurtamount-=multiplier;
4922 neckspurtdelay-=multiplier*3;
4923 neckspurtparticledelay-=multiplier*3;
4924 if(neckspurtparticledelay<0&&neckspurtdelay>2){
4928 bloodvel.z=5*neckspurtamount;
4929 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4932 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
4934 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
4935 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
4936 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);
4937 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);
4938 neckspurtparticledelay=.05;
4940 if(neckspurtdelay<0){
4945 if(deathbleeding>0&&dead!=2){
4946 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
4947 else bleeddelay-=5*multiplier/4;
4948 if(bleeddelay<0&&bloodtoggle){
4953 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4954 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
4955 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
4956 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);
4959 bloodloss+=deathbleeding*multiplier*80;
4960 deathbleeding-=multiplier*1.6;
4961 //if(id==0)deathbleeding-=multiplier*.2;
4962 if(deathbleeding<0)deathbleeding=0;
4963 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
4964 if(weaponactive!=-1){
4965 weapons.owner[weaponids[0]]=-1;
4966 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4967 weapons.velocity[weaponids[0]].x+=.01;
4968 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4969 weapons.missed[weaponids[0]]=1;
4970 weapons.hitsomething[weaponids[0]]=0;
4971 weapons.freetime[weaponids[0]]=0;
4972 weapons.firstfree[weaponids[0]]=1;
4973 weapons.physics[weaponids[0]]=1;
4976 weaponids[0]=weaponids[num_weapons];
4977 if(weaponstuck==num_weapons)weaponstuck=0;
4980 for(i=0;i<numplayers;i++){
4981 player[i].wentforweapon=0;
4993 if(!dead&&creature==wolftype){
4999 if(targetanimation==knifefollowedanim&&!skeleton.free){
5000 for(i=0;i<skeleton.num_joints;i++){
5001 skeleton.joints[i].velocity=0;
5002 skeleton.joints[i].velocity.y=-2;
5005 if(id!=0&&unconscioustime>.1){
5013 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
5016 bloodsize=5-realtexdetail;
5020 texdetailint=realtexdetail;
5021 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5022 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5023 endx=startx+bloodsize;
5024 endy=starty+bloodsize;
5026 if(startx<0){startx=0;bleeding=0;}
5027 if(starty<0){starty=0;bleeding=0;}
5028 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
5029 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
5030 if(endx<startx)endx=startx;
5031 if(endy<starty)endy=starty;
5033 for(i=startx;i<endx;i++){
5034 for(j=starty;j<endy;j++){
5036 color=Random()%85+170;
5037 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
5038 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
5039 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
5044 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5045 DoMipmaps(0,startx,endx,starty,endy);
5049 bleedy-=4/realtexdetail;
5050 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
5051 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
5054 bleedx+=4*direction/realtexdetail;
5055 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
5056 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
5060 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
5061 righthandmorphness=targetrighthandmorphness;
5062 righthandmorphstart=righthandmorphend;
5064 else if(righthandmorphness>targetrighthandmorphness){
5065 righthandmorphness-=multiplier*4;
5067 else if(righthandmorphness<targetrighthandmorphness){
5068 righthandmorphness+=multiplier*4;
5071 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
5072 lefthandmorphness=targetlefthandmorphness;
5073 lefthandmorphstart=lefthandmorphend;
5075 else if(lefthandmorphness>targetlefthandmorphness){
5076 lefthandmorphness-=multiplier*4;
5078 else if(lefthandmorphness<targetlefthandmorphness){
5079 lefthandmorphness+=multiplier*4;
5082 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
5083 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
5084 tailmorphness=targettailmorphness;
5085 tailmorphstart=tailmorphend;
5087 else if(tailmorphness>targettailmorphness){
5088 tailmorphness-=multiplier*10;
5090 else if(tailmorphness<targettailmorphness){
5091 tailmorphness+=multiplier*10;
5095 if(creature==wolftype){
5096 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
5097 tailmorphness=targettailmorphness;
5098 tailmorphstart=tailmorphend;
5100 else if(tailmorphness>targettailmorphness){
5101 tailmorphness-=multiplier*2;
5103 else if(tailmorphness<targettailmorphness){
5104 tailmorphness+=multiplier*2;
5108 if(headmorphend==3||headmorphstart==3){
5109 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
5110 headmorphness=targetheadmorphness;
5111 headmorphstart=headmorphend;
5113 else if(headmorphness>targetheadmorphness){
5114 headmorphness-=multiplier*7;
5116 else if(headmorphness<targetheadmorphness){
5117 headmorphness+=multiplier*7;
5120 else if(headmorphend==5||headmorphstart==5){
5121 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
5122 headmorphness=targetheadmorphness;
5123 headmorphstart=headmorphend;
5125 else if(headmorphness>targetheadmorphness){
5126 headmorphness-=multiplier*10;
5128 else if(headmorphness<targetheadmorphness){
5129 headmorphness+=multiplier*10;
5133 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5134 headmorphness=targetheadmorphness;
5135 headmorphstart=headmorphend;
5137 else if(headmorphness>targetheadmorphness){
5138 headmorphness-=multiplier*4;
5140 else if(headmorphness<targetheadmorphness){
5141 headmorphness+=multiplier*4;
5145 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5146 chestmorphness=targetchestmorphness;
5147 chestmorphstart=chestmorphend;
5149 else if(chestmorphness>targetchestmorphness){
5150 chestmorphness-=multiplier;
5152 else if(chestmorphness<targetchestmorphness){
5153 chestmorphness+=multiplier;
5156 if(dead!=2&&howactive<=typesleeping){
5157 if(chestmorphstart==0&&chestmorphend==0){
5159 targetchestmorphness=1;
5162 if(chestmorphstart!=0&&chestmorphend!=0){
5164 targetchestmorphness=1;
5166 if(environment==snowyenvironment){
5169 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5170 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5171 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5172 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5173 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5174 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5178 if(!dead&&howactive<typesleeping){
5179 blinkdelay-=multiplier*2;
5180 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5182 targetheadmorphness=1;
5184 blinkdelay=(float)(abs(Random()%40))/5;
5186 if(headmorphstart==3&&headmorphend==3){
5188 targetheadmorphness=1;
5193 twitchdelay-=multiplier*1.5;
5194 if(targetanimation!=hurtidleanim){
5195 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5197 targetheadmorphness=1;
5199 twitchdelay=(float)(abs(Random()%40))/5;
5201 if(headmorphstart==5&&headmorphend==5){
5203 targetheadmorphness=1;
5207 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5208 twitchdelay3-=multiplier*1;
5210 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5211 righthandmorphness=0;
5212 targetrighthandmorphness=1;
5213 righthandmorphend=1;
5214 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5216 if(righthandmorphstart==1&&righthandmorphend==1){
5217 righthandmorphness=0;
5218 targetrighthandmorphness=1;
5219 righthandmorphend=0;
5223 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5224 lefthandmorphness=0;
5225 targetlefthandmorphness=1;
5227 twitchdelay3=(float)(abs(Random()%40))/5;
5229 if(lefthandmorphstart==1&&lefthandmorphend==1){
5230 lefthandmorphness=0;
5231 targetlefthandmorphness=1;
5238 if(creature==rabbittype){
5239 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5240 else twitchdelay2-=multiplier*0.5;
5241 if(howactive<=typesleeping){
5242 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5244 targettailmorphness=1;
5246 twitchdelay2=(float)(abs(Random()%40))/5;
5248 if(tailmorphstart==1&&tailmorphend==1){
5250 targettailmorphness=1;
5253 if(tailmorphstart==2&&tailmorphend==2){
5255 targettailmorphness=1;
5262 if(creature==wolftype){
5263 twitchdelay2-=multiplier*1.5;
5265 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5267 targettailmorphness=1;
5272 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5274 targettailmorphness=1;
5278 if(twitchdelay2<=0){
5279 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5281 targettailmorphness=1;
5284 if(tailmorphstart==1&&tailmorphend==1){
5286 targettailmorphness=1;
5289 if(tailmorphstart==2&&tailmorphend==2){
5291 targettailmorphness=1;
5294 if(tailmorphstart==3&&tailmorphend==3){
5296 targettailmorphness=1;
5299 if(tailmorphstart==4&&tailmorphend==4){
5301 targettailmorphness=1;
5307 if(dead!=1)unconscioustime=0;
5309 if(dead==1||howactive==typesleeping){
5310 unconscioustime+=multiplier;
5311 //If unconscious, close eyes and mouth
5312 if(righthandmorphend!=0)righthandmorphness=0;
5313 righthandmorphend=0;
5314 targetrighthandmorphness=1;
5316 if(lefthandmorphend!=0)lefthandmorphness=0;
5318 targetlefthandmorphness=1;
5320 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
5322 targetheadmorphness=1;
5326 if(howactive>typesleeping){
5329 if(bloodtoggle&&!bled){
5330 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5332 if(bloodtoggle&&!bled)
5333 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5334 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5335 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5339 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5344 if(dead==2||howactive>typesleeping){
5345 //If dead, open mouth and hands
5346 if(righthandmorphend!=0)righthandmorphness=0;
5347 righthandmorphend=0;
5348 targetrighthandmorphness=1;
5350 if(lefthandmorphend!=0)lefthandmorphness=0;
5352 targetlefthandmorphness=1;
5354 if(headmorphend!=2)headmorphness=0;
5356 targetheadmorphness=1;
5359 if(stunned>0&&!dead&&headmorphend!=2){
5360 if(headmorphend!=4)headmorphness=0;
5362 targetheadmorphness=1;
5365 if(damage>damagetolerance&&!dead){
5370 if(creature==wolftype){
5378 if(weaponactive!=-1){
5379 weapons.owner[weaponids[0]]=-1;
5380 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5381 weapons.velocity[weaponids[0]].x+=.01;
5382 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5383 weapons.missed[weaponids[0]]=1;
5384 weapons.hitsomething[weaponids[0]]=0;
5385 weapons.freetime[weaponids[0]]=0;
5386 weapons.firstfree[weaponids[0]]=1;
5387 weapons.physics[weaponids[0]]=1;
5390 weaponids[0]=weaponids[num_weapons];
5391 if(weaponstuck==num_weapons)weaponstuck=0;
5394 for(i=0;i<numplayers;i++){
5395 player[i].wentforweapon=0;
5401 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5409 //if(dead)damage-=multiplier/4;
5410 if(!dead)damage-=multiplier*13;
5411 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5412 if(!dead)permanentdamage-=multiplier*4;
5413 if(isIdle()||isCrouch()){
5414 if(!dead)permanentdamage-=multiplier*4;
5415 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5417 if(damage<0)damage=0;
5418 if(permanentdamage<0)permanentdamage=0;
5419 if(superpermanentdamage<0)superpermanentdamage=0;
5420 if(permanentdamage<superpermanentdamage){
5421 permanentdamage=superpermanentdamage;
5423 if(damage<permanentdamage){
5424 damage=permanentdamage;
5426 if(dead==1&&damage<damagetolerance){
5430 for(i=0;i<skeleton.num_joints;i++){
5431 skeleton.joints[i].velocity=0;
5434 if(permanentdamage>damagetolerance&&dead!=2){
5437 if(weaponactive!=-1){
5438 weapons.owner[weaponids[0]]=-1;
5439 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5440 weapons.velocity[weaponids[0]].x+=.01;
5441 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5442 weapons.missed[weaponids[0]]=1;
5443 weapons.hitsomething[weaponids[0]]=0;
5444 weapons.freetime[weaponids[0]]=0;
5445 weapons.firstfree[weaponids[0]]=1;
5446 weapons.physics[weaponids[0]]=1;
5449 weaponids[0]=weaponids[num_weapons];
5450 if(weaponstuck==num_weapons)weaponstuck=0;
5453 for(i=0;i<numplayers;i++){
5454 player[i].wentforweapon=0;
5460 if(!dead&&creature==wolftype){
5466 if(id!=0&&unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance){
5471 if(id!=0&&unconscioustime>.1){
5487 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5488 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5489 OPENAL_SetVolume(channels[breaksound], 512);
5490 OPENAL_SetPaused(channels[breaksound], false);
5491 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5497 if(skeleton.free==1){
5498 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5501 //If knocked over, open hands and close mouth
5502 if(righthandmorphend!=0)righthandmorphness=0;
5503 righthandmorphend=0;
5504 targetrighthandmorphness=1;
5506 if(lefthandmorphend!=0)lefthandmorphness=0;
5508 targetlefthandmorphness=1;
5510 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5511 if(headmorphend!=0)headmorphness=0;
5513 targetheadmorphness=1;
5517 skeleton.DoGravity(&scale);
5519 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5520 if(id!=0&&damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1)){
5525 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5529 for(j=0;j<skeleton.num_joints;j++){
5530 average+=skeleton.joints[j].position;
5534 coords+=average*scale;
5535 for(j=0;j<skeleton.num_joints;j++){
5536 skeleton.joints[j].position-=average;
5538 average/=multiplier;
5540 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5542 for(i=0;i<skeleton.num_joints;i++){
5543 velocity+=skeleton.joints[i].velocity*scale;
5545 velocity/=skeleton.num_joints;
5547 if(!isnormal(velocity.x)&&velocity.x){
5560 if(findLength(&average)<10&&dead&&skeleton.free){
5561 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5562 if(skeleton.longdead>2000){
5563 if(skeleton.longdead>6000){
5564 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5569 if(dead==2&&bloodloss<damagetolerance){
5571 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5573 if(bloodtoggle&&!bled){
5574 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5576 if(bloodtoggle&&!bled)
5577 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5578 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5579 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5583 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5587 if(dead==2&&bloodloss>=damagetolerance){
5589 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5590 if(bleeding<=0)DoBlood(1,255);
5591 if(bloodtoggle&&!bled){
5592 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5594 if(bloodtoggle&&!bled)
5595 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5596 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5597 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5601 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5608 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5610 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5614 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5615 if(velocity.y<-30)canrecover=0;
5616 for(i=0;i<objects.numobjects;i++){
5617 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5618 colviewer=startpoint;
5620 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5628 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5629 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5630 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5631 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5633 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5634 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5635 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5637 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5638 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5639 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5641 Normalise(&terrainnormal);
5643 targetrotation=-asin(0-terrainnormal.x);
5644 targetrotation*=360/6.28;
5645 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5646 rotation=targetrotation;
5648 //if(skeleton.forward.y<0){
5651 //if(skeleton.forward.y>-.3){
5654 targetanimation=flipanim;
5655 crouchtogglekeydown=1;
5660 currentanimation=tempanim;
5663 //tilt2=targettilt2;
5665 //if(middle.y>0)targetoffset.y=middle.y+1;
5667 for(i=0;i<skeleton.num_joints;i++){
5668 tempanimation.position[i][0]=skeleton.joints[i].position;
5669 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5674 if(findLength(&average)<10&&!dead&&skeleton.free){
5675 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5676 if(skeleton.longdead>(damage+500)*1.5){
5677 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5683 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5684 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5685 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5686 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5688 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5689 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5690 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5692 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5693 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5694 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5696 Normalise(&terrainnormal);
5698 targetrotation=-asin(0-terrainnormal.x);
5699 targetrotation*=360/6.28;
5700 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5701 rotation=targetrotation;
5704 terrainnormal=terrain.getNormal(coords.x,coords.z);
5705 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5709 /*XYZ otherterrainnormal;
5710 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5711 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5712 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5713 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5716 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5720 if(skeleton.forward.y<0){
5721 targetanimation=getupfrombackanim;
5725 if(skeleton.forward.y>-.3){
5726 targetanimation=getupfromfrontanim;
5728 targetrotation+=180;
5734 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5735 targetanimation=rollanim;
5736 targetrotation=lookrotation;
5740 if(forwardkeydown)targetrotation+=45;
5741 if(backkeydown)targetrotation-=45;
5745 if(forwardkeydown)targetrotation-=45;
5746 if(backkeydown)targetrotation+=45;
5749 if ( !leftkeydown&&!rightkeydown)
5750 targetrotation+=180;
5752 targetrotation+=180;
5756 if(abs(targettilt2)>50)targettilt2=0;
5757 currentanimation=tempanim;
5762 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5764 for(i=0;i<skeleton.num_joints;i++){
5765 tempanimation.position[i][0]=skeleton.joints[i].position;
5766 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5773 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5774 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5777 tempvelocity=velocity;
5778 Normalise(&tempvelocity);
5779 targetrotation=-asin(0-tempvelocity.x);
5780 targetrotation*=360/6.28;
5781 if(velocity.z<0)targetrotation=180-targetrotation;
5782 //targetrotation+=180;
5785 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5786 targetanimation=rollanim;
5790 targetanimation=backhandspringanim;
5791 targetrotation+=180;
5804 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
5805 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
5806 OPENAL_SetVolume(channels[movewhooshsound], 128);
5807 OPENAL_SetPaused(channels[movewhooshsound], false);
5809 currentanimation=targetanimation;
5810 currentframe=targetframe-1;
5815 rotation=targetrotation;
5822 if(skeleton.freefall==0)freefall=0;
5824 if(!isnormal(velocity.x)&&velocity.x){
5829 if(aitype!=passivetype||skeleton.free==1)
5830 if(findLengthfast(&velocity)>.1)
5831 for(i=0;i<objects.numobjects;i++){
5832 if(objects.type[i]==firetype)
5833 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){
5835 if(!objects.onfire[i]){
5838 gLoc[0]=objects.position[i].x;
5839 gLoc[1]=objects.position[i].y;
5840 gLoc[2]=objects.position[i].z;
5844 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5845 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5846 OPENAL_SetVolume(channels[firestartsound], 256);
5847 OPENAL_SetPaused(channels[firestartsound], false);
5849 objects.onfire[i]=1;
5852 if(objects.onfire[i]){
5857 if(objects.type[i]==bushtype)
5858 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){
5860 if(!objects.onfire[i]){
5863 gLoc[0]=objects.position[i].x;
5864 gLoc[1]=objects.position[i].y;
5865 gLoc[2]=objects.position[i].z;
5869 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
5870 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
5871 OPENAL_SetVolume(channels[firestartsound], 256);
5872 OPENAL_SetPaused(channels[firestartsound], false);
5874 objects.onfire[i]=1;
5878 if(objects.onfire[i]){
5882 if(objects.messedwith[i]<=0){
5894 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5895 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5896 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5897 OPENAL_SetPaused(channels[bushrustle], false);
5900 envsound[numenvsounds]=coords;
5901 envsoundvol[numenvsounds]=4*findLength(&velocity);
5902 envsoundlife[numenvsounds]=.4;
5907 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5908 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5910 if(environment!=desertenvironment)
5911 for(j=0;j<howmany;j++){
5912 tempvel.x=float(abs(Random()%100)-50)/20;
5913 tempvel.y=float(abs(Random()%100)-50)/20;
5914 tempvel.z=float(abs(Random()%100)-50)/20;
5917 pos.x+=float(abs(Random()%100)-50)/200;
5918 pos.y+=float(abs(Random()%100)-50)/200;
5919 pos.z+=float(abs(Random()%100)-50)/200;
5920 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);
5921 Sprite::setLastSpriteSpecial(1);
5923 howmany=findLength(&velocity)*4;
5925 if(environment==snowyenvironment)
5926 for(j=0;j<howmany;j++){
5927 tempvel.x=float(abs(Random()%100)-50)/20;
5928 tempvel.y=float(abs(Random()%100)-50)/20;
5929 tempvel.z=float(abs(Random()%100)-50)/20;
5932 pos.x+=float(abs(Random()%100)-50)/200;
5933 pos.y+=float(abs(Random()%100)-50)/200;
5934 pos.z+=float(abs(Random()%100)-50)/200;
5935 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
5936 Sprite::setLastSpriteSpecial(2);
5939 objects.rotx[i]+=velocity.x*multiplier*6;
5940 objects.roty[i]+=velocity.z*multiplier*6;
5941 objects.messedwith[i]=.5;
5944 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
5945 if(objects.rotation2[i]==0)tempcoord=coords;
5947 tempcoord=coords-objects.position[i];
5948 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
5949 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
5950 tempcoord+=objects.position[i];
5952 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]){
5953 if(objects.messedwith[i]<=0){
5965 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
5966 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
5967 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
5968 OPENAL_SetPaused(channels[bushrustle], false);
5971 envsound[numenvsounds]=coords;
5972 envsoundvol[numenvsounds]=4*findLength(&velocity);
5973 envsoundlife[numenvsounds]=.4;
5978 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
5979 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
5981 if(environment!=desertenvironment)
5982 for(j=0;j<howmany;j++){
5983 tempvel.x=float(abs(Random()%100)-50)/20;
5984 tempvel.y=float(abs(Random()%100)-50)/20;
5985 tempvel.z=float(abs(Random()%100)-50)/20;
5989 pos.x+=float(abs(Random()%100)-50)/150;
5990 pos.y+=float(abs(Random()%100)-50)/150;
5991 pos.z+=float(abs(Random()%100)-50)/150;
5992 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);
5993 Sprite::setLastSpriteSpecial(1);
5995 howmany=findLength(&velocity)*4;
5997 if(environment==snowyenvironment)
5998 for(j=0;j<howmany;j++){
5999 tempvel.x=float(abs(Random()%100)-50)/20;
6000 tempvel.y=float(abs(Random()%100)-50)/20;
6001 tempvel.z=float(abs(Random()%100)-50)/20;
6005 pos.x+=float(abs(Random()%100)-50)/150;
6006 pos.y+=float(abs(Random()%100)-50)/150;
6007 pos.z+=float(abs(Random()%100)-50)/150;
6008 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6009 Sprite::setLastSpriteSpecial(2);
6012 objects.messedwith[i]=.5;
6020 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
6022 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
6023 if(tutoriallevel==1&&id!=0)play=0;
6024 if(play&&aitype!=playercontrolled){
6036 if(creature==rabbittype){
6037 if(i==0)whichsound=rabbitchitter;
6038 if(i==1)whichsound=rabbitchitter2;
6040 if(creature==wolftype){
6041 if(i==0)whichsound=growlsound;
6042 if(i==1)whichsound=growl2sound;
6048 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
6049 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
6050 OPENAL_SetVolume(channels[whichsound], 512);
6051 OPENAL_SetPaused(channels[whichsound], false);
6055 if(targetanimation==staggerbackhighanim)staggerdelay=1;
6056 if(targetanimation==staggerbackhardanim)staggerdelay=1;
6057 staggerdelay-=multiplier;
6058 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
6059 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
6060 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
6061 targetanimation=getIdle();
6065 weaponmissdelay-=multiplier;
6066 highreversaldelay-=multiplier;
6067 lowreversaldelay-=multiplier;
6068 lastcollide-=multiplier;
6069 skiddelay-=multiplier;
6070 if(!isnormal(velocity.x)&&velocity.x){
6073 if(!isnormal(targettilt)&&targettilt){
6076 if(!isnormal(targettilt2)&&targettilt2){
6079 if(!isnormal(targetrotation)&&targetrotation){
6083 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
6084 //open hands and close mouth
6085 //if(targetanimation!=wolfidle){
6086 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6087 righthandmorphness=0;
6088 righthandmorphend=0;
6089 targetrighthandmorphness=1;
6092 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6093 lefthandmorphness=0;
6095 targetlefthandmorphness=1;
6099 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
6102 targetheadmorphness=1;
6106 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){
6107 //open hands and mouth
6108 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6109 righthandmorphness=0;
6110 righthandmorphend=0;
6111 targetrighthandmorphness=1;
6114 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6115 lefthandmorphness=0;
6117 targetlefthandmorphness=1;
6120 if(headmorphend!=1&&headmorphness==targetheadmorphness){
6123 targetheadmorphness=1;
6127 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
6128 //close hands and mouth
6129 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6130 righthandmorphness=0;
6131 righthandmorphend=1;
6132 targetrighthandmorphness=1;
6135 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6136 lefthandmorphness=0;
6138 targetlefthandmorphness=1;
6141 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6144 targetheadmorphness=1;
6148 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){
6149 //close hands and yell
6150 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6151 righthandmorphness=0;
6152 righthandmorphend=1;
6153 targetrighthandmorphness=1;
6156 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6157 lefthandmorphness=0;
6159 targetlefthandmorphness=1;
6162 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6165 targetheadmorphness=1;
6169 if(speechdelay>.25){
6170 if(headmorphend!=2)headmorphness=0;
6172 targetheadmorphness=1;
6178 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6179 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6183 if(!dead&&targetanimation!=hurtidleanim)
6184 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6185 if(headmorphend!=4||headmorphness==targetheadmorphness){
6188 targetheadmorphness=1;
6192 if(weaponactive!=-1){
6193 if(weapons.type[weaponids[weaponactive]]!=staff){
6194 righthandmorphstart=1;
6195 righthandmorphend=1;
6197 if(weapons.type[weaponids[weaponactive]]==staff){
6198 righthandmorphstart=2;
6199 righthandmorphend=2;
6201 targetrighthandmorphness=1;
6204 terrainnormal=terrain.getNormal(coords.x,coords.z);
6206 if(animation[targetanimation].attack!=reversal){
6207 if(!isnormal(coords.x))
6215 flatfacing=DoRotation(flatfacing,0,rotation,0);
6217 ReflectVector(&facing,terrainnormal);
6220 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6221 if(onterrain)targettilt2=-facing.y*20;
6225 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6226 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6227 flatvelocity=velocity;
6229 flatvelspeed=findLength(&flatvelocity);
6230 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6231 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6232 if(velocity.y<0)targettilt2*=-1;
6233 if(velocity.y<0)targettilt*=-1;
6234 if(targettilt>25)targettilt=25;
6235 if(targettilt<-25)targettilt=-25;
6238 if(targettilt2>45)targettilt2=45;
6239 if(targettilt2<-45)targettilt2=-45;
6240 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6241 else if(tilt2>targettilt2){
6242 tilt2-=multiplier*400;
6244 else if(tilt2<targettilt2){
6245 tilt2+=multiplier*400;
6247 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6248 if(tilt2>25)tilt2=25;
6249 if(tilt2<-25)tilt2=-25;
6252 if(!isnormal(targettilt)&&targettilt){
6255 if(!isnormal(targettilt2)&&targettilt2){
6260 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6261 if(targetanimation==rabbittackleanim){
6262 velocity+=facing*multiplier*speed*700*scale;
6263 velspeed=findLength(&velocity);
6264 if(velspeed>speed*65*scale){
6266 velspeed=speed*65*scale;
6269 velocity.y+=gravity*multiplier*20;
6270 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6271 velspeed=findLength(&velocity);
6272 velocity=flatfacing*velspeed;
6274 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6275 if(isRun()||targetanimation==rabbitkickanim){
6276 velocity+=facing*multiplier*speed*700*scale;
6277 velspeed=findLength(&velocity);
6278 if(velspeed>speed*45*scale){
6280 velspeed=speed*45*scale;
6283 velocity.y+=gravity*multiplier*20;
6284 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6285 velspeed=findLength(&velocity);
6286 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6287 velocity=flatfacing*velspeed;
6291 velocity+=facing*multiplier*speed*700*scale;
6292 velspeed=findLength(&velocity);
6293 if(creature==rabbittype){
6294 if(velspeed>speed*55*scale){
6296 velspeed=speed*55*scale;
6300 if(creature==wolftype){
6301 if(velspeed>speed*75*scale){
6303 velspeed=speed*75*scale;
6307 velocity.y+=gravity*multiplier*20;
6308 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6309 velspeed=findLength(&velocity);
6310 velocity=flatfacing*velspeed;
6313 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6314 velocity+=facing*multiplier*speed*700*scale;
6315 velspeed=findLength(&velocity);
6316 if(velspeed>speed*45*scale){
6318 velspeed=speed*45*scale;
6321 velocity.y+=gravity*multiplier*20;
6322 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6323 velspeed=findLength(&velocity);
6324 velocity=flatfacing*velspeed;
6328 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6329 velocity+=facing*multiplier*speed*700*scale;
6330 velspeed=findLength(&velocity);
6331 if(velspeed>speed*25*scale){
6333 velspeed=speed*25*scale;
6336 velocity.y+=gravity*multiplier*20;
6337 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6338 velspeed=findLength(&velocity);
6339 velocity=flatfacing*velspeed;
6342 if(targetanimation==sneakanim||targetanimation==walkanim){
6343 velocity+=facing*multiplier*speed*700*scale;
6344 velspeed=findLength(&velocity);
6345 if(velspeed>speed*12*scale){
6347 velspeed=speed*12*scale;
6350 velocity.y+=gravity*multiplier*20;
6351 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6352 velspeed=findLength(&velocity);
6353 velocity=flatfacing*velspeed;
6356 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6357 velocity+=facing*multiplier*speed*700*scale;
6358 velspeed=findLength(&velocity);
6359 if(velspeed>speed*2*scale){
6361 velspeed=speed*2*scale;
6364 velocity.y+=gravity*multiplier*20;
6365 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6366 velspeed=findLength(&velocity);
6367 velocity=flatfacing*velspeed;
6371 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6372 velocity-=facing*multiplier*speed*700*scale;
6373 velspeed=findLength(&velocity);
6374 if(velspeed>speed*2*scale){
6376 velspeed=speed*2*scale;
6379 velocity.y+=gravity*multiplier*20;
6380 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6381 velspeed=findLength(&velocity);
6382 velocity=flatfacing*velspeed*-1;
6385 if(targetanimation==fightsidestep){
6386 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6387 velspeed=findLength(&velocity);
6388 if(velspeed>speed*12*scale){
6390 velspeed=speed*12*scale;
6393 velocity.y+=gravity*multiplier*20;
6394 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6395 velspeed=findLength(&velocity);
6396 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6399 if(targetanimation==staggerbackhighanim){
6400 coords-=facing*multiplier*speed*16*scale;
6403 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6404 coords-=facing*multiplier*speed*20*scale;
6408 if(targetanimation==backhandspringanim){
6409 //coords-=facing*multiplier*50*scale;
6410 velocity+=facing*multiplier*speed*700*scale*-1;
6411 velspeed=findLength(&velocity);
6412 if(velspeed>speed*50*scale){
6414 velspeed=speed*50*scale;
6417 velocity.y+=gravity*multiplier*20;
6418 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6419 velspeed=findLength(&velocity);
6420 velocity=flatfacing*velspeed*-1;
6422 if(targetanimation==dodgebackanim){
6423 //coords-=facing*multiplier*50*scale;
6424 velocity+=facing*multiplier*speed*700*scale*-1;
6425 velspeed=findLength(&velocity);
6426 if(velspeed>speed*60*scale){
6428 velspeed=speed*60*scale;
6431 velocity.y+=gravity*multiplier*20;
6432 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6433 velspeed=findLength(&velocity);
6434 velocity=flatfacing*velspeed*-1;
6437 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6438 velspeed=findLength(&velocity);
6442 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6443 velocity.y+=gravity*multiplier;
6446 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6448 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6449 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6451 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6457 OPENAL_SetPaused(channels[whooshsound], true);
6458 OPENAL_SetVolume(channels[whooshsound], 0);
6461 if(targetanimation==jumpdownanim||isFlip()){
6462 if(isFlip())jumppower=-4;
6463 targetanimation=getLanding();
6472 PlaySoundEx( landsound, samp[landsound], NULL, true);
6473 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6474 OPENAL_SetVolume(channels[landsound], 128);
6475 OPENAL_SetPaused(channels[landsound], false);
6478 envsound[numenvsounds]=coords;
6479 envsoundvol[numenvsounds]=16;
6480 envsoundlife[numenvsounds]=.4;
6486 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6487 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6488 coords.y=terrain.getHeight(coords.x,coords.z);
6493 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)){
6494 velspeed=findLength(&velocity);
6496 if(velspeed<multiplier*300*scale){
6498 } else velocity-=velocity/velspeed*multiplier*300*scale;
6499 if(velspeed>5&&(isLanding()||isLandhard())){
6500 skiddingdelay+=multiplier;
6507 else skiddingdelay=0;
6511 velspeed=findLength(&velocity);
6513 if(velspeed<multiplier*600*scale){
6515 } else velocity-=velocity/velspeed*multiplier*600*scale;
6517 if(velspeed>5&&(isLanding()||isLandhard())){
6518 skiddingdelay+=multiplier;
6525 else skiddingdelay=0;
6528 if(skiddingdelay<0)skiddingdelay+=multiplier;
6529 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6539 if(!onterrain||environment==grassyenvironment){
6540 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6541 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6542 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6543 OPENAL_SetPaused(channels[skidsound], false);
6546 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6547 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6548 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6549 OPENAL_SetPaused(channels[snowskidsound], false);
6553 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6554 terrainnormal=victim->coords-coords;
6555 Normalise(&terrainnormal);
6556 targetrotation=-asin(0-terrainnormal.x);
6557 targetrotation*=360/6.28;
6558 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6559 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6562 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6563 targetrotation=victim->targetrotation;
6565 if(targetanimation==rabbittacklinganim){
6566 coords=victim->coords;
6569 skeleton.oldfree=skeleton.free;
6573 midterrain.x=terrain.size*terrain.scale/2;
6574 midterrain.z=terrain.size*terrain.scale/2;
6575 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6577 tempposit=coords-midterrain;
6579 Normalise(&tempposit);
6580 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6581 coords.x=tempposit.x+midterrain.x;
6582 coords.z=tempposit.z+midterrain.z;
6586 int Person::DrawSkeleton(){
6587 int oldplayerdetail;
6588 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6589 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6599 glAlphaFunc(GL_GREATER, 0.0001);
6601 float terrainheight;
6603 if(!isnormal(rotation))rotation=0;
6604 if(!isnormal(tilt))tilt=0;
6605 if(!isnormal(tilt2))tilt2=0;
6606 oldplayerdetail=playerdetail;
6608 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6611 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6614 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6619 if(playerdetail!=oldplayerdetail) {
6621 normalsupdatedelay=0;
6623 static float updatedelaychange;
6624 static float morphness;
6625 static float framemult;
6627 skeleton.FindForwards();
6628 if(howactive==typesittingwall){
6629 skeleton.specialforward[1]=0;
6630 skeleton.specialforward[1].z=1;
6636 static int weaponattachmuscle;
6637 static int weaponrotatemuscle,weaponrotatemuscle2;
6638 static XYZ weaponpoint;
6639 static int start,endthing;
6640 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6641 if(!isSleeping()&&!isSitting()){
6642 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6643 XYZ point,newpoint,change,change2;
6644 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6645 heightleft=terrain.getHeight(point.x,point.z)+.04;
6647 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6648 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6649 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6650 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6651 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6653 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6654 heightright=terrain.getHeight(point.x,point.z)+.04;
6655 point.y=heightright;
6656 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6657 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6658 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6659 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6660 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6661 skeleton.DoConstraints(&coords,&scale);
6663 if(creature==wolftype){
6664 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6665 heightleft=terrain.getHeight(point.x,point.z)+.04;
6667 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6668 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6669 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6670 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6671 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6673 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6674 heightright=terrain.getHeight(point.x,point.z)+.04;
6675 point.y=heightright;
6676 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6677 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6678 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6679 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6680 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6681 skeleton.DoConstraints(&coords,&scale);
6684 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6685 XYZ point,newpoint,change,change2;
6686 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6687 heightleft=terrain.getHeight(point.x,point.z)+.04;
6689 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6690 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6691 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6692 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6693 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6695 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6696 heightright=terrain.getHeight(point.x,point.z)+.04;
6697 point.y=heightright;
6698 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6699 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6700 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6701 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6702 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6703 skeleton.DoConstraints(&coords,&scale);
6705 if(creature==wolftype){
6706 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6707 heightleft=terrain.getHeight(point.x,point.z)+.04;
6709 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6710 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6711 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6712 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6713 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6715 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6716 heightright=terrain.getHeight(point.x,point.z)+.04;
6717 point.y=heightright;
6718 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6719 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6720 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6721 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6722 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6723 skeleton.DoConstraints(&coords,&scale);
6727 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6728 XYZ point,newpoint,change,change2;
6729 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6730 heightleft=terrain.getHeight(point.x,point.z)+.04;
6732 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6733 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6734 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6735 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6736 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6738 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6739 heightright=terrain.getHeight(point.x,point.z)+.04;
6740 point.y=heightright;
6741 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6742 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6743 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6744 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6745 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6746 skeleton.DoConstraints(&coords,&scale);
6748 if(creature==wolftype){
6749 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6750 heightleft=terrain.getHeight(point.x,point.z)+.04;
6752 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6753 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6754 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6755 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6756 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6758 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6759 heightright=terrain.getHeight(point.x,point.z)+.04;
6760 point.y=heightright;
6761 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6762 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6763 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6764 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6765 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6766 skeleton.DoConstraints(&coords,&scale);
6770 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()))
6773 targetheadrotation=-targetrotation;
6774 targetheadrotation2=0;
6775 if(animation[targetanimation].attack==3)targetheadrotation+=180;
6777 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6778 skeleton.drawmodel.vertex[i]=0;
6779 skeleton.drawmodel.vertex[i].y=999;
6781 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
6782 skeleton.drawmodellow.vertex[i]=0;
6783 skeleton.drawmodellow.vertex[i].y=999;
6785 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
6786 skeleton.drawmodelclothes.vertex[i]=0;
6787 skeleton.drawmodelclothes.vertex[i].y=999;
6789 for(i=0;i<skeleton.num_muscles;i++){
6790 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
6794 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
6795 morphness=righthandmorphness;
6796 start=righthandmorphstart;
6797 endthing=righthandmorphend;
6799 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
6800 morphness=lefthandmorphness;
6801 start=lefthandmorphstart;
6802 endthing=lefthandmorphend;
6804 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
6805 morphness=headmorphness;
6806 start=headmorphstart;
6807 endthing=headmorphend;
6809 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)){
6810 morphness=chestmorphness;
6811 start=chestmorphstart;
6812 endthing=chestmorphend;
6814 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)){
6815 morphness=tailmorphness;
6816 start=tailmorphstart;
6817 endthing=tailmorphend;
6819 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
6820 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6821 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6824 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6825 if(!skeleton.free)glRotatef(tilt,0,0,1);
6828 glTranslatef(mid.x,mid.y,mid.z);
6830 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6831 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6833 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6834 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6836 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6837 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6839 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
6843 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
6847 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
6851 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
6856 if(playerdetail||skeleton.free==3)
6858 for(j=0;j<skeleton.muscles[i].numvertices;j++)
6860 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
6861 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
6862 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
6863 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
6864 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
6865 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
6866 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
6867 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6869 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6870 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,
6871 (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,
6872 (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);
6873 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)
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)*proportionarms.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)*proportionarms.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)*proportionarms.z);
6877 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)
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)*proportionlegs.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)*proportionlegs.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)*proportionlegs.z);
6881 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
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)*proportionhead.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)*proportionhead.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)*proportionhead.z);
6885 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6886 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
6887 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
6888 //if(!isnormal(scale))test=1;
6889 //if(isnormal(scale)){
6890 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
6891 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
6892 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
6900 if(!playerdetail||skeleton.free==3)
6902 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
6904 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
6905 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6907 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6908 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
6909 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
6910 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
6911 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)
6912 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
6913 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
6914 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
6915 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)
6916 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
6917 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
6918 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
6919 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6920 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
6921 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
6922 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
6924 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6925 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
6926 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
6927 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
6934 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
6935 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
6937 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6940 if(!skeleton.free)glRotatef(tilt2,1,0,0);
6941 if(!skeleton.free)glRotatef(tilt,0,0,1);
6942 glTranslatef(mid.x,mid.y,mid.z);
6943 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
6944 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
6946 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
6947 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
6949 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
6950 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
6952 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
6953 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6955 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
6956 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
6957 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
6958 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
6959 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)
6960 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
6961 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
6962 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
6963 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)
6964 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
6965 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
6966 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
6967 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
6968 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
6969 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
6970 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
6971 glGetFloatv(GL_MODELVIEW_MATRIX,M);
6972 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
6973 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
6974 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
6979 updatedelay=1+(float)(Random()%100)/1000;
6981 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
6982 normalsupdatedelay=1;
6983 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
6984 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
6985 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
6989 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
6990 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
6991 if(skeleton.clothes){
6992 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
6997 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
6998 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
6999 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
7000 if(skeleton.free==1)updatedelaychange*=6;
7001 if(id==0)updatedelaychange*=8;
7002 updatedelay+=updatedelaychange;
7004 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7006 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7007 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7008 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
7009 if(!skeleton.free)glRotatef(rotation,0,1,0);
7012 glColor4f(.4,1,.4,1);
7013 glDisable(GL_LIGHTING);
7014 glDisable(GL_TEXTURE_2D);
7017 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7018 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
7024 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
7025 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);
7026 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);
7027 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);
7028 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);
7029 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);
7030 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);
7036 terrainlight=terrain.getLighting(coords.x,coords.z);
7037 distance=findDistancefast(&viewer,&coords);
7038 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
7039 if(distance>1)distance=1;
7041 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
7042 if(terrainheight<1)terrainheight=1;
7043 if(terrainheight>1.7)terrainheight=1.7;
7046 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
7047 glDisable(GL_BLEND);
7048 glAlphaFunc(GL_GREATER, 0.0001);
7049 glEnable(GL_TEXTURE_2D);
7051 glDisable(GL_TEXTURE_2D);
7052 glColor4f(.7,.35,0,.5);
7054 glEnable(GL_LIGHTING);
7057 if(tutoriallevel&&id!=0){
7058 //glDisable(GL_TEXTURE_2D);
7059 glColor4f(.7,.7,.7,0.6);
7061 glEnable(GL_LIGHTING);
7063 if(canattack&&cananger)
7064 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7065 glDisable(GL_TEXTURE_2D);
7066 glColor4f(1,0,0,0.8);
7068 glMatrixMode(GL_TEXTURE);
7070 glTranslatef(0,-smoketex,0);
7071 glTranslatef(-smoketex,0,0);
7075 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7076 else skeleton.drawmodel.draw();
7080 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7081 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7084 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
7085 if(tutoriallevel&&id!=0){
7087 glMatrixMode(GL_MODELVIEW);
7088 glEnable(GL_TEXTURE_2D);
7089 glColor4f(.7,.7,.7,0.6);
7091 glEnable(GL_LIGHTING);
7093 if(canattack&&cananger)
7094 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7095 glDisable(GL_TEXTURE_2D);
7096 glColor4f(1,0,0,0.8);
7098 glMatrixMode(GL_TEXTURE);
7100 glTranslatef(0,-smoketex*.6,0);
7101 glTranslatef(smoketex*.6,0,0);
7104 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7105 else skeleton.drawmodel.draw();
7109 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7110 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7115 if(tutoriallevel&&id!=0){
7117 glMatrixMode(GL_MODELVIEW);
7118 glEnable(GL_TEXTURE_2D);
7120 if(skeleton.clothes){
7123 if(!immediate)skeleton.drawmodelclothes.draw();
7124 if(immediate)skeleton.drawmodelclothes.drawimmediate();
7131 for(k=0;k<num_weapons;k++){
7133 if(weaponactive==k){
7134 if(weapons.type[i]!=staff){
7135 for(j=0;j<skeleton.num_muscles;j++){
7136 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7137 weaponattachmuscle=j;
7140 for(j=0;j<skeleton.num_muscles;j++){
7141 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){
7142 weaponrotatemuscle=j;
7145 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7146 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7148 if(weapons.type[i]==staff){
7149 for(j=0;j<skeleton.num_muscles;j++){
7150 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7151 weaponattachmuscle=j;
7154 for(j=0;j<skeleton.num_muscles;j++){
7155 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){
7156 weaponrotatemuscle=j;
7159 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7160 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7161 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7162 XYZ tempnormthing,vec1,vec2;
7163 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7164 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7165 CrossProduct(&vec1,&vec2,&tempnormthing);
7166 Normalise(&tempnormthing);
7167 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);
7168 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7170 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7171 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7172 Normalise(&weaptargnorm);
7173 weaponpoint-=weaptargnorm*2;
7177 if(weaponactive!=k&&weaponstuck!=k){
7178 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;
7179 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;
7180 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;
7181 for(j=0;j<skeleton.num_muscles;j++){
7182 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){
7183 weaponrotatemuscle=j;
7188 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7189 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7190 for(j=0;j<skeleton.num_muscles;j++){
7191 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){
7192 weaponrotatemuscle=j;
7197 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;
7198 weapons.bigrotation[i]=rotation;
7199 weapons.bigtilt[i]=tilt;
7200 weapons.bigtilt2[i]=tilt2;
7203 weapons.position[i]=weaponpoint*scale+coords;
7204 weapons.bigrotation[i]=0;
7205 weapons.bigtilt[i]=0;
7206 weapons.bigtilt2[i]=0;
7208 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7209 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7210 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7211 if(weaponactive==k){
7212 if(weapons.type[i]==knife){
7213 weapons.smallrotation[i]=180;
7214 weapons.smallrotation2[i]=0;
7215 if(isCrouch()||wasCrouch()){
7216 weapons.smallrotation2[i]=20;
7218 if(targetanimation==hurtidleanim){
7219 weapons.smallrotation2[i]=50;
7221 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7222 XYZ temppoint1,temppoint2,tempforward;
7225 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7226 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7227 distance=findDistance(&temppoint1,&temppoint2);
7228 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7229 weapons.rotation2[i]*=360/6.28;
7232 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7233 weapons.rotation1[i]*=360/6.28;
7234 weapons.rotation3[i]=0;
7235 weapons.smallrotation[i]=-90;
7236 weapons.smallrotation2[i]=0;
7237 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7239 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7240 XYZ temppoint1,temppoint2,tempforward;
7243 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7244 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7245 distance=findDistance(&temppoint1,&temppoint2);
7246 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7247 weapons.rotation2[i]*=360/6.28;
7250 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7251 weapons.rotation1[i]*=360/6.28;
7252 weapons.rotation3[i]=0;
7253 weapons.smallrotation[i]=90;
7254 weapons.smallrotation2[i]=0;
7255 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7257 if(targetanimation==knifethrowanim){
7258 weapons.smallrotation[i]=90;
7259 //weapons.smallrotation2[i]=-90;
7260 weapons.smallrotation2[i]=0;
7261 weapons.rotation1[i]=0;
7262 weapons.rotation2[i]=0;
7263 weapons.rotation3[i]=0;
7265 if(targetanimation==knifesneakattackanim&&targetframe<5){
7266 weapons.smallrotation[i]=-90;
7267 weapons.rotation1[i]=0;
7268 weapons.rotation2[i]=0;
7269 weapons.rotation3[i]=0;
7272 if(weapons.type[i]==sword){
7273 weapons.smallrotation[i]=0;
7274 weapons.smallrotation2[i]=0;
7275 if(targetanimation==knifethrowanim){
7276 weapons.smallrotation[i]=-90;
7277 weapons.smallrotation2[i]=0;
7278 weapons.rotation1[i]=0;
7279 weapons.rotation2[i]=0;
7280 weapons.rotation3[i]=0;
7282 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)){
7283 XYZ temppoint1,temppoint2,tempforward;
7286 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7287 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7288 distance=findDistance(&temppoint1,&temppoint2);
7289 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7290 weapons.rotation2[i]*=360/6.28;
7293 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7294 weapons.rotation1[i]*=360/6.28;
7295 weapons.rotation3[i]=0;
7296 weapons.smallrotation[i]=90;
7297 weapons.smallrotation2[i]=0;
7298 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7301 if(weapons.type[i]==staff){
7302 weapons.smallrotation[i]=100;
7303 weapons.smallrotation2[i]=0;
7304 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7305 XYZ temppoint1,temppoint2,tempforward;
7308 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7309 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7310 distance=findDistance(&temppoint1,&temppoint2);
7311 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7312 weapons.rotation2[i]*=360/6.28;
7315 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7316 weapons.rotation1[i]*=360/6.28;
7317 weapons.rotation3[i]=0;
7318 weapons.smallrotation[i]=90;
7319 weapons.smallrotation2[i]=0;
7320 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7324 if(weaponactive!=k&&weaponstuck!=k){
7325 if(weapons.type[i]==knife){
7326 weapons.smallrotation[i]=-70;
7327 weapons.smallrotation2[i]=10;
7329 if(weapons.type[i]==sword){
7330 weapons.smallrotation[i]=-100;
7331 weapons.smallrotation2[i]=-8;
7333 if(weapons.type[i]==staff){
7334 weapons.smallrotation[i]=-100;
7335 weapons.smallrotation2[i]=-8;
7339 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7340 else weapons.smallrotation[i]=0;
7341 weapons.smallrotation2[i]=10;
7342 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7350 if(skeleton.free)calcrot=1;
7351 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7352 if(currentanimation!=targetanimation)calcrot=1;
7353 //if(id==0)calcrot=1;
7354 if(skeleton.free==2)calcrot=0;
7360 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7363 static float distance;
7364 static float olddistance;
7365 static int intersecting;
7366 static int firstintersecting;
7369 static XYZ start,end;
7370 static float slopethreshold=-.4;
7372 firstintersecting=-1;
7376 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7377 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7379 for (j=0;j<model->TriangleNum;j++){
7380 if(model->facenormals[j].y<=slopethreshold){
7382 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)));
7383 if(distance<radius){
7384 point=*p1-model->facenormals[j]*distance;
7385 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;
7386 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7387 &model->vertex[model->Triangles[j].vertex[1]],
7389 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7390 &model->vertex[model->Triangles[j].vertex[2]],
7392 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7393 &model->vertex[model->Triangles[j].vertex[2]],
7396 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7400 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)){
7401 p1->y=point.y+radius;
7402 if((targetanimation==jumpdownanim||isFlip())){
7403 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7405 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7411 OPENAL_SetPaused(channels[whooshsound], true);
7412 OPENAL_SetVolume(channels[whooshsound], 0);
7415 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7416 if(isFlip())jumppower=-4;
7417 targetanimation=getLanding();
7426 PlaySoundEx( landsound, samp[landsound], NULL, true);
7427 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7428 OPENAL_SetVolume(channels[landsound], 128);
7429 OPENAL_SetPaused(channels[landsound], false);
7432 envsound[numenvsounds]=coords;
7433 envsoundvol[numenvsounds]=16;
7434 envsoundlife[numenvsounds]=.4;
7442 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7445 for (j=0;j<model->TriangleNum;j++){
7446 if(model->facenormals[j].y>slopethreshold){
7450 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)));
7451 if(distance<radius*.5){
7452 point=start-model->facenormals[j]*distance;
7453 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;
7454 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,
7455 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7456 p1->x, p1->y, p1->z, radius/2);
7457 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,
7458 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7459 p1->x, p1->y, p1->z, radius/2);
7460 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,
7461 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7462 p1->x, p1->y, p1->z, radius/2);
7464 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7465 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7467 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7468 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7470 *p1+=model->facenormals[j]*(distance-radius*.5);
7473 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7477 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7479 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7481 return firstintersecting;
7491 currentanimation = 0;
7492 targetanimation = 0;
7493 oldcurrentframe = 0;
7495 oldcurrentanimation = 0;
7496 oldtargetanimation = 0;
7500 parriedrecently = 0;
7504 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7506 currentoffset = 0,targetoffset = 0,offset = 0;
7524 unconscioustime = 0;
7542 rabbitkickenabled = 0;
7551 damagetolerance = 0;
7553 permanentdamage = 0;
7554 superpermanentdamage = 0; lastcollide = 0;
7574 headrotation = 0,headrotation2 = 0;
7575 targetheadrotation = 0,targetheadrotation2 = 0;
7586 normalsupdatedelay = 0;
7591 forwardstogglekeydown = 0;
7596 jumptogglekeydown = 0;
7598 crouchtogglekeydown = 0;
7600 drawtogglekeydown = 0;
7602 throwtogglekeydown = 0;
7608 crouchkeydowntime = 0;
7609 jumpkeydowntime = 0;
7626 whichdirectiondelay = 0;
7627 avoidsomething = 0; avoidwhere = 0;
7635 lefthandmorphness = 0;
7636 righthandmorphness = 0;
7640 targetlefthandmorphness = 0;
7641 targetrighthandmorphness = 0;
7642 targetheadmorphness = 0;
7643 targetchestmorphness = 0;
7644 targettailmorphness = 0;
7645 lefthandmorphstart = 0,lefthandmorphend = 0;
7646 righthandmorphstart = 0,righthandmorphend = 0;
7647 headmorphstart = 0,headmorphend = 0;
7648 chestmorphstart = 0,chestmorphend = 0;
7649 tailmorphstart = 0,tailmorphend = 0;
7651 weaponmissdelay = 0;
7652 highreversaldelay = 0;
7653 lowreversaldelay = 0;
7660 //Skeleton skeleton;
7679 memset(clothes, 0, sizeof(clothes));
7680 memset(clothestintr, 0, sizeof(clothestintr));
7681 memset(clothestintg, 0, sizeof(clothestintg));
7682 memset(clothestintb, 0, sizeof(clothestintb));
7688 onfiredelay = 0; burnt = 0;
7692 updatestuffdelay = 0;
7698 memset(weaponids, 0, sizeof(weaponids));
7702 weaponstuckwhere = 0;
7707 memset(waypoints, 0, sizeof(waypoints));
7708 memset(waypointtype, 0, sizeof(waypointtype));
7711 hastempwaypoint = 0;
7717 finalfinaltarget = 0;
7719 finalpathfindpoint = 0;
7720 targetpathfindpoint = 0;
7721 lastpathfindpoint = 0;
7722 lastpathfindpoint2 = 0;
7723 lastpathfindpoint3 = 0;
7724 lastpathfindpoint4 = 0;
7735 runninghowlong = 0; lastoccluded = 0;
7741 neckspurtparticledelay = 0;
7742 neckspurtamount = 0;
7745 rabbitkickragdoll = 0;
7750 //Animation tempanimation;