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"
26 extern float multiplier;
27 extern Animation animation[animation_count];
28 extern OPENAL_SAMPLE *samp[100];
29 extern int channels[100];
30 extern Terrain terrain;
32 extern int environment;
34 extern FRUSTUM frustum;
36 extern float realmultiplier;
38 extern float slomodelay;
39 extern bool cellophane;
40 extern float texdetail;
41 extern float realtexdetail;
42 extern GLubyte bloodText[512*512*3];
43 extern GLubyte wolfbloodText[512*512*3];
44 extern int bloodtoggle;
45 extern Objects objects;
47 extern bool autoslomo;
48 extern float camerashake;
50 extern float terraindetail;
51 extern float viewdistance;
52 extern float blackout;
53 extern int difficulty;
54 extern Weapons weapons;
56 extern float fadestart;
57 extern Person player[maxplayers];
58 extern int numplayers;
60 extern bool winfreeze;
61 extern float flashamount,flashr,flashg,flashb;
62 extern int flashdelay;
63 extern bool showpoints;
64 extern bool immediate;
66 extern bool tilt2weird;
67 extern bool tiltweird;
69 extern bool proportionweird;
70 extern bool vertexweird[6];
71 extern GLubyte texturearray[512*512*3];
72 extern XYZ envsound[30];
73 extern float envsoundvol[30];
74 extern float envsoundlife[30];
75 extern int numenvsounds;
77 extern float bonusvalue;
78 extern float bonustotal;
79 extern float bonustime;
80 extern int tutoriallevel;
81 extern float smoketex;
82 extern int tutorialstage;
83 extern bool reversaltrain;
84 extern bool canattack;
86 extern float damagedealt;
87 extern float damagetaken;
89 extern float hostiletime;
92 extern int numflipfail;
94 extern int numswordattack;
95 extern int numknifeattack;
96 extern int numunarmedattack;
97 extern int numescaped;
98 extern int numflipped;
99 extern int numwallflipped;
100 extern int numthrowkill;
101 extern int numafterkill;
102 extern int numreversals;
103 extern int numattacks;
104 extern int maxalarmed;
105 extern int indialogue;
107 extern bool gamestarted;
109 extern OPENAL_STREAM * strm[20];
110 extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
111 extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused);
113 void Person::CheckKick(){
117 float damagemult=1*power;
118 if(creature==wolftype)damagemult=2.5*power;
122 if(targetanimation==rabbitkickanim&&victim&&victim!=this&¤tframe>=2&¤tanimation==rabbitkickanim){
123 if(findDistancefast(&coords,&victim->coords)<1.2){
124 if(!victim->skeleton.free){
126 Normalise(&relative);
127 relative=coords+relative*1;
128 if(animation[victim->targetanimation].height!=lowheight){
133 gLoc[0]=victim->coords.x;
134 gLoc[1]=victim->coords.y;
135 gLoc[2]=victim->coords.z;
139 if(tutoriallevel!=1){
140 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
141 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
142 OPENAL_SetVolume(channels[heavyimpactsound], 128);
143 OPENAL_SetPaused(channels[heavyimpactsound], false);
148 Normalise(&relative);
149 for(i=0;i<victim->skeleton.num_joints;i++){
150 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
153 victim->DoDamage(100*damagemult/victim->protectionhigh);
154 if(id==0)camerashake+=.4;
158 targetanimation=backflipanim;
163 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
165 //if(victim->damage>victim->damagetolerance){
173 else if (victim->isCrouch()){
174 targetanimation=rabbitkickreversedanim;
175 currentanimation=rabbitkickreversedanim;
176 victim->currentanimation=rabbitkickreversalanim;
177 victim->targetanimation=rabbitkickreversalanim;
183 victim->oldcoords=victim->coords;
184 coords=victim->coords;
185 victim->targetrotation=targetrotation;
193 void Person::CatchFire(){
194 XYZ flatfacing,flatvelocity;
196 for(int i=0;i<10;i++){
197 howmany=abs(Random()%(skeleton.num_joints));
198 if(!skeleton.free)flatvelocity=velocity;
199 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
200 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
201 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
202 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
215 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
216 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
217 OPENAL_SetVolume(channels[firestartsound], 256);
218 OPENAL_SetPaused(channels[firestartsound], false);
223 //PlaySoundEx( firesound, samp[firesound], NULL, true);
224 PlayStreamEx( stream_firesound, strm[stream_firesound], NULL, true);
225 OPENAL_3D_SetAttributes(channels[stream_firesound], gLoc, vel);
226 OPENAL_SetVolume(channels[stream_firesound], 256);
227 OPENAL_SetPaused(channels[stream_firesound], false);
234 bool Person::isIdle(){
235 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;
239 bool Person::isSitting(){
240 if(targetanimation==sitanim)return 1;
241 if(targetanimation==sitwallanim)return 1;
245 bool Person::isSleeping(){
246 if(targetanimation==sleepanim)return 1;
247 if(targetanimation==dead1anim)return 1;
248 if(targetanimation==dead2anim)return 1;
249 if(targetanimation==dead3anim)return 1;
250 if(targetanimation==dead4anim)return 1;
254 bool Person::wasIdle(){
255 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;
258 int Person::getIdle(){
259 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
260 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)){
261 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
262 if(creature==rabbittype)return fightidleanim;
263 if(creature==wolftype)return wolfidle;
265 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
266 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
267 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
268 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
269 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
271 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
273 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
274 if(howactive==typesitting)return sitanim;
275 if(howactive==typesittingwall)return sitwallanim;
276 if(howactive==typesleeping)return sleepanim;
277 if(howactive==typedead1)return dead1anim;
278 if(howactive==typedead2)return dead2anim;
279 if(howactive==typedead3)return dead3anim;
280 if(howactive==typedead4)return dead4anim;
281 if(creature==rabbittype)return bounceidleanim;
282 if(creature==wolftype)return wolfidle;
286 bool Person::isCrouch(){
287 if(targetanimation==crouchanim||targetanimation==wolfcrouchanim)return 1;
292 bool Person::wasCrouch(){
293 if(currentanimation==crouchanim||currentanimation==wolfcrouchanim)return 1;
296 int Person::getCrouch(){
297 if(creature==rabbittype)return crouchanim;
298 if(creature==wolftype)return wolfcrouchanim;
302 bool Person::isRun(){
303 if(targetanimation==runanim||targetanimation==wolfrunanim||targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)return 1;
308 bool Person::wasRun(){
309 if(currentanimation==runanim||currentanimation==wolfrunanim||currentanimation==wolfrunninganim||currentanimation==rabbitrunninganim)return 1;
312 int Person::getRun(){
313 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
314 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
316 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
317 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
321 bool Person::isStop(){
322 if(targetanimation==stopanim||targetanimation==wolfstopanim)return 1;
327 bool Person::wasStop(){
328 if(currentanimation==stopanim||currentanimation==wolfstopanim)return 1;
331 int Person::getStop(){
332 if(creature==rabbittype)return stopanim;
333 if(creature==wolftype)return wolfstopanim;
338 bool Person::isLanding(){
339 if(targetanimation==landanim||targetanimation==wolflandanim)return 1;
344 bool Person::wasLanding(){
345 if(currentanimation==landanim||currentanimation==wolflandanim)return 1;
348 int Person::getLanding(){
349 if(creature==rabbittype)return landanim;
350 if(creature==wolftype)return wolflandanim;
355 bool Person::isLandhard(){
356 if(targetanimation==landhardanim||targetanimation==wolflandhardanim)return 1;
361 bool Person::wasLandhard(){
362 if(currentanimation==landhardanim||currentanimation==wolflandhardanim)return 1;
365 int Person::getLandhard(){
366 if(creature==rabbittype)return landhardanim;
367 if(creature==wolftype)return wolflandhardanim;
372 bool Person::isFlip(){
373 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==backflipanim||targetanimation==rightflipanim||targetanimation==leftflipanim||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)return 1;
377 bool Person::wasFlip(){
378 if(currentanimation==flipanim||currentanimation==frontflipanim||currentanimation==backflipanim||currentanimation==rightflipanim||currentanimation==leftflipanim||currentanimation==walljumprightkickanim||currentanimation==walljumpleftkickanim)return 1;
382 bool Person::isWallJump(){
383 if(targetanimation==walljumpfrontanim||targetanimation==walljumpbackanim||targetanimation==walljumpleftanim||targetanimation==walljumprightanim)return 1;
387 void SolidHitBonus();
388 void SolidHitBonus(){
389 if(bonustime<1.5&&(bonus==fourxcombo||bonus==megacombo)){
394 else if(bonustime<1.5&&bonus==threexcombo){
399 else if(bonustime<1.5&&bonus==twoxcombo){
404 else if(bonustime<1.5&&bonus==solidhit){
416 void Person::DoBlood(float howmuch,int which){
417 static int bleedxint,bleedyint;
419 //if(howmuch&&id==0)blooddimamount=1;
420 if(bloodtoggle&&tutoriallevel!=1){
421 if(bleeding<=0&&spurt){
423 for(int i=0;i<3;i++){
427 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
430 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
432 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
433 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
435 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
436 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
439 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);
440 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);
444 for(int i=0;i<3;i++){
448 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
449 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
452 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
453 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
457 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
459 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);
461 Sprite::setLastSpriteSpecial(3);
466 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
469 int texdetailint=realtexdetail;
470 if(creature==rabbittype)
471 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){
472 bleedxint=abs(Random()%512);
473 bleedyint=abs(Random()%512);
475 if(creature==wolftype)
476 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){
477 bleedxint=abs(Random()%512);
478 bleedyint=abs(Random()%512);
482 bleedy/=realtexdetail;
483 bleedx/=realtexdetail;
484 direction=abs(Random()%2)*2-1;
488 if(bleeding>2)bleeding=2;
491 void Person::DoBloodBig(float howmuch,int which){
492 static int bleedxint,bleedyint,i,j;
494 if(howmuch&&id==0)blooddimamount=1;
496 if(tutoriallevel!=1||id==0)
497 if(aitype!=playercontrolled&&howmuch>0){
508 if(creature==wolftype){
509 int i=abs(Random()%2);
510 if(i==0)whichsound=snarlsound;
511 if(i==1)whichsound=snarl2sound;
512 envsound[numenvsounds]=coords;
513 envsoundvol[numenvsounds]=16;
514 envsoundlife[numenvsounds]=.4;
517 if(creature==rabbittype){
518 int i=abs(Random()%2);
519 if(i==0)whichsound=rabbitpainsound;
520 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
521 envsound[numenvsounds]=coords;
522 envsoundvol[numenvsounds]=16;
523 envsoundlife[numenvsounds]=.4;
525 //if(i==2)whichsound=rabbitpain2sound;
529 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
530 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
531 OPENAL_SetVolume(channels[whichsound], 512);
532 OPENAL_SetPaused(channels[whichsound], false);
536 if(id==0&&howmuch>0){
544 if(bloodtoggle&&decals&&tutoriallevel!=1){
545 if(bleeding<=0&&spurt){
547 for(int i=0;i<3;i++){
551 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
554 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
556 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
557 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
559 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
560 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
563 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);
564 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);
568 int offsetx=0,offsety=0;
571 offsetx=abs(Random()%60);
573 if(which==190||which==185){
575 offsetx=abs(Random()%100)-20;
585 if(which==220||which==215){
586 //offsety=Random()%20;
588 //offsetx=abs(Random()%80);
597 if(creature==rabbittype)
600 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
601 if(i<startx)startx=i;
602 if(j<starty)starty=j;
608 if(creature==wolftype)
611 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
612 if(i<startx)startx=i;
613 if(j<starty)starty=j;
625 if(startx<0)startx=0;
626 if(starty<0)starty=0;
627 if(endx>512-1)endx=512-1;
628 if(endy>512-1)endy=512-1;
629 if(endx<startx)endx=startx;
630 if(endy<starty)endy=starty;
632 startx/=realtexdetail;
633 starty/=realtexdetail;
637 int texdetailint=realtexdetail;
639 if(creature==rabbittype)
640 for(i=startx;i<endx;i++){
641 for(j=starty;j<endy;j++){
642 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){
643 color=Random()%85+170;
644 where=i*skeleton.skinsize*3+j*3;
645 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
646 skeleton.skinText[where+1]=0;
647 skeleton.skinText[where+2]=0;
651 if(creature==wolftype)
652 for(i=startx;i<endx;i++){
653 for(j=starty;j<endy;j++){
654 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){
655 color=Random()%85+170;
656 where=i*skeleton.skinsize*3+j*3;
657 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
658 skeleton.skinText[where+1]=0;
659 skeleton.skinText[where+2]=0;
663 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
664 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
665 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
669 if(creature==rabbittype)
670 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){
671 bleedxint=abs(Random()%512);
672 bleedyint=abs(Random()%512);
674 if(creature==wolftype)
675 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){
676 bleedxint=abs(Random()%512);
677 bleedyint=abs(Random()%512);
679 bleedy=bleedxint+offsetx;
680 bleedx=bleedyint+offsety;
681 bleedy/=realtexdetail;
682 bleedx/=realtexdetail;
683 if(bleedx<0)bleedx=0;
684 if(bleedy<0)bleedy=0;
685 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
686 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
687 direction=abs(Random()%2)*2-1;
690 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
691 deathbleeding+=bleeding;
692 bloodloss+=bleeding*3;
694 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
695 if(abs(Random()%2)==0){aitype=gethelptype;
698 else aitype=attacktypecutoff;
701 if(bleeding>2)bleeding=2;
704 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
705 static int bleedxint,bleedyint,i,j;
707 static XYZ startpoint,endpoint,colpoint,movepoint;
708 static float rotationpoint;
710 static XYZ p1,p2,p3,p0;
714 float coordsx,coordsy;
717 if(bloodtoggle&&decals&&tutoriallevel!=1){
719 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
727 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
730 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
731 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
732 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
734 CrossProduct(p2-p1,p3-p1,&N);
735 CrossProduct(p0-p1,p3-p1,&temp);
736 s = dotproduct(&temp,&N)/findLength(&N);
737 CrossProduct(p2-p1,p1-p0,&temp);
738 t = dotproduct(&temp,&N)/findLength(&N);
741 bary.x=findDistancefast(&p0,&p1);
742 bary.y=findDistancefast(&p0,&p2);
743 bary.z=findDistancefast(&p0,&p3);
745 total=bary.x+bary.y+bary.z;
754 total=bary.x+bary.y+bary.z;
760 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
761 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
762 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
763 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
764 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
765 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
766 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;
767 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;
769 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
770 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
772 if(bleeding<=0&&spurt){
774 for(int i=0;i<3;i++){
778 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
781 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
783 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
784 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
786 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
787 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
790 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);
791 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);
795 int offsetx=0,offsety=0;
798 offsetx=abs(Random()%120);
800 if(which==220||which==215){
802 offsetx=abs(Random()%80);
805 offsetx=(1+coordsy)*512-291;
806 offsety=coordsx*512-437;
813 if(creature==rabbittype)
816 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
817 if(i<startx)startx=i;
818 if(j<starty)starty=j;
824 if(creature==wolftype)
827 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
828 if(i<startx)startx=i;
829 if(j<starty)starty=j;
840 if(startx<0)startx=0;
841 if(starty<0)starty=0;
842 if(endx>512-1)endx=512-1;
843 if(endy>512-1)endy=512-1;
844 if(endx<startx)endx=startx;
845 if(endy<starty)endy=starty;
847 startx/=realtexdetail;
848 starty/=realtexdetail;
852 int texdetailint=realtexdetail;
854 if(creature==rabbittype)
855 for(i=startx;i<endx;i++){
856 for(j=starty;j<endy;j++){
857 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){
858 color=Random()%85+170;
859 where=i*skeleton.skinsize*3+j*3;
860 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
861 skeleton.skinText[where+1]=0;
862 skeleton.skinText[where+2]=0;
864 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){
865 color=Random()%85+170;
866 where=i*skeleton.skinsize*3+j*3;
867 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
868 skeleton.skinText[where+1]=0;
869 skeleton.skinText[where+2]=0;
873 if(creature==wolftype)
874 for(i=startx;i<endx;i++){
875 for(j=starty;j<endy;j++){
876 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){
877 color=Random()%85+170;
878 where=i*skeleton.skinsize*3+j*3;
879 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
880 skeleton.skinText[where+1]=0;
881 skeleton.skinText[where+2]=0;
883 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){
884 color=Random()%85+170;
885 where=i*skeleton.skinsize*3+j*3;
886 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
887 skeleton.skinText[where+1]=0;
888 skeleton.skinText[where+2]=0;
892 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
893 if(detail!=2||osx)DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
894 else DoMipmaps(0,startx/realtexdetail,endx/realtexdetail,starty/realtexdetail,endy/realtexdetail);
896 bleedy=(1+coordsy)*512;
898 bleedy/=realtexdetail;
899 bleedx/=realtexdetail;
900 if(bleedx<0)bleedx=0;
901 if(bleedy<0)bleedy=0;
902 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
903 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
904 direction=abs(Random()%2)*2-1;
906 if(whichtri==-1)return 0;
908 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
909 deathbleeding+=bleeding;
910 bloodloss+=bleeding*3;
912 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
913 if(abs(Random()%2)==0){aitype=gethelptype;
916 else aitype=attacktypecutoff;
919 if(bleeding>2)bleeding=2;
924 void Person::DoMipmaps(int howmanylevels,float startx, float endx, float starty, float endy){
927 static int bytesPerPixel=3;
928 static int newsize,totalsize,rowsize,bigstep,smallstep,sum;
929 static int newstartx,newstarty,newendx,newendy;
930 static int newnewstartx,newnewstarty,newnewendx,newnewendy;
932 static float sizemult;
934 for(i=0;i<skeleton.skinsize*skeleton.skinsize*bytesPerPixel;i++){
935 texture[i]=skeleton.skinText[i];
938 if((!osx||howmanylevels)){
940 if(startx<0)startx=0;
941 if(starty<0)starty=0;
942 if(endx>skeleton.skinsize-1)endx=skeleton.skinsize-1;
943 if(endy>skeleton.skinsize-1)endy=skeleton.skinsize-1;
944 if((endx>startx&&endy>starty)||howmanylevels){
951 for(i=startx;i<endx;i++){
952 for(j=starty;j<endy;j++){
953 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+0]=skeleton.skinText[i*skeleton.skinsize*3+j*3+0];
954 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+1]=skeleton.skinText[i*skeleton.skinsize*3+j*3+1];
955 texturearray[(i-newstartx)*(newendy-newstarty)*3+(j-newstarty)*3+2]=skeleton.skinText[i*skeleton.skinsize*3+j*3+2];
959 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
962 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_TRUE);
963 glTexSubImage2D(GL_TEXTURE_2D,0,starty,startx,endy-starty,endx-startx,GL_RGB,GL_UNSIGNED_BYTE,texturearray);
964 if(!osx)glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS,GL_FALSE);
967 newsize=skeleton.skinsize;
970 gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, skeleton.skinsize, skeleton.skinsize, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0] );
972 /*for(j=1;j<=howmanylevels;j++){
973 if(j==1)texpointer=&skeleton.skinText[0];
974 else texpointer=&texture[0];
976 totalsize=int( newsize*newsize*bytesPerPixel);
977 rowsize=int( newsize*bytesPerPixel );
978 bigstep=bytesPerPixel*newsize*2;
979 smallstep=bytesPerPixel*2;
985 glTexSubImage2D(GL_TEXTURE_2D,j,0,0,newsize/2,newsize/2,GL_RGB,GL_UNSIGNED_BYTE,texture);
992 void Person::Reverse(){
993 if(victim->aitype==playercontrolled||hostiletime>1)
994 if(victim->targetanimation!=jumpupanim&&victim->targetanimation!=jumpdownanim&&((tutoriallevel!=1||cananger)&&hostile)){
995 if(normaldotproduct(victim->facing,victim->coords-coords)>0&&!(victim->id==0&&difficulty<2)&&(creature!=wolftype||victim->creature==wolftype))return;
996 if(victim->aitype!=playercontrolled&&staggerdelay>0)return;
997 if(targetanimation==sweepanim){
998 targetanimation=sweepreversedanim;
999 currentanimation=sweepreversedanim;
1000 victim->currentanimation=sweepreversalanim;
1001 victim->targetanimation=sweepreversalanim;
1003 if(targetanimation==spinkickanim){
1004 targetanimation=spinkickreversedanim;
1005 currentanimation=spinkickreversedanim;
1006 victim->currentanimation=spinkickreversalanim;
1007 victim->targetanimation=spinkickreversalanim;
1009 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
1010 if(targetanimation==rabbittacklinganim){
1013 victim->currentframe=6;
1014 victim->targetframe=7;
1016 targetanimation=upunchreversedanim;
1017 currentanimation=upunchreversedanim;
1018 victim->currentanimation=upunchreversalanim;
1019 victim->targetanimation=upunchreversalanim;
1021 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1022 if(victim->weaponactive!=-1){
1023 victim->throwtogglekeydown=1;
1024 weapons.owner[victim->weaponids[0]]=-1;
1025 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1026 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1027 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1028 weapons.missed[victim->weaponids[0]]=1;
1029 weapons.freetime[victim->weaponids[0]]=0;
1030 weapons.firstfree[victim->weaponids[0]]=1;
1031 weapons.physics[victim->weaponids[0]]=1;
1032 victim->num_weapons--;
1033 if(victim->num_weapons){
1034 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1035 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1038 victim->weaponactive=-1;
1039 for(int j=0;j<numplayers;j++){
1040 player[j].wentforweapon=0;
1044 targetanimation=staffhitreversedanim;
1045 currentanimation=staffhitreversedanim;
1046 victim->currentanimation=staffhitreversalanim;
1047 victim->targetanimation=staffhitreversalanim;
1049 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
1050 if(victim->weaponactive!=-1){
1051 victim->throwtogglekeydown=1;
1052 weapons.owner[victim->weaponids[0]]=-1;
1053 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1054 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1055 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1056 weapons.missed[victim->weaponids[0]]=1;
1057 weapons.freetime[victim->weaponids[0]]=0;
1058 weapons.firstfree[victim->weaponids[0]]=1;
1059 weapons.physics[victim->weaponids[0]]=1;
1060 victim->num_weapons--;
1061 if(victim->num_weapons){
1062 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1063 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1066 victim->weaponactive=-1;
1067 for(int j=0;j<numplayers;j++){
1068 player[j].wentforweapon=0;
1071 targetanimation=staffspinhitreversedanim;
1072 currentanimation=staffspinhitreversedanim;
1073 victim->currentanimation=staffspinhitreversalanim;
1074 victim->targetanimation=staffspinhitreversalanim;
1076 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
1077 if(victim->weaponactive!=-1){
1078 victim->throwtogglekeydown=1;
1079 weapons.owner[victim->weaponids[0]]=-1;
1080 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1081 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1082 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1083 weapons.missed[victim->weaponids[0]]=1;
1084 weapons.freetime[victim->weaponids[0]]=0;
1085 weapons.firstfree[victim->weaponids[0]]=1;
1086 weapons.physics[victim->weaponids[0]]=1;
1087 victim->num_weapons--;
1088 if(victim->num_weapons){
1089 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1090 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1093 victim->weaponactive=-1;
1094 for(int j=0;j<numplayers;j++){
1095 player[j].wentforweapon=0;
1098 targetanimation=swordslashreversedanim;
1099 currentanimation=swordslashreversedanim;
1100 victim->currentanimation=swordslashreversalanim;
1101 victim->targetanimation=swordslashreversalanim;
1103 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
1104 if(victim->weaponactive!=-1){
1105 victim->throwtogglekeydown=1;
1106 weapons.owner[victim->weaponids[0]]=-1;
1107 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
1108 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
1109 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
1110 weapons.missed[victim->weaponids[0]]=1;
1111 weapons.freetime[victim->weaponids[0]]=0;
1112 weapons.firstfree[victim->weaponids[0]]=1;
1113 weapons.physics[victim->weaponids[0]]=1;
1114 victim->num_weapons--;
1115 if(victim->num_weapons){
1116 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1117 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1120 victim->weaponactive=-1;
1121 for(int j=0;j<numplayers;j++){
1122 player[j].wentforweapon=0;
1125 targetanimation=knifeslashreversedanim;
1126 currentanimation=knifeslashreversedanim;
1127 victim->currentanimation=knifeslashreversalanim;
1128 victim->targetanimation=knifeslashreversalanim;
1130 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
1131 victim->targettilt2=targettilt2;
1132 victim->currentframe=currentframe;
1133 victim->targetframe=targetframe;
1134 victim->target=target;
1136 victim->oldcoords=victim->coords;
1137 victim->coords=coords;
1138 victim->targetrotation=targetrotation;
1139 victim->rotation=targetrotation;
1140 victim->victim=this;
1142 if(targetanimation==winduppunchanim){
1143 targetanimation=winduppunchblockedanim;
1144 victim->targetanimation=blockhighleftanim;
1145 victim->targetframe=1;
1147 victim->victim=this;
1148 victim->targetrotation=targetrotation+180;
1150 if(targetanimation==wolfslapanim){
1151 targetanimation=winduppunchblockedanim;
1152 victim->targetanimation=blockhighleftanim;
1153 victim->targetframe=1;
1155 victim->victim=this;
1156 victim->targetrotation=targetrotation+180;
1158 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
1159 targetanimation=swordslashparriedanim;
1161 victim->parriedrecently=0;
1162 victim->targetanimation=swordslashparryanim;
1163 victim->targetframe=1;
1165 victim->victim=this;
1166 victim->targetrotation=targetrotation+180;
1168 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
1171 gLoc[0]=victim->coords.x;
1172 gLoc[1]=victim->coords.y;
1173 gLoc[2]=victim->coords.z;
1177 if(victim->weaponactive!=-1){
1178 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1179 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1180 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1182 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1183 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1184 OPENAL_SetVolume(channels[swordstaffsound], 512);
1185 OPENAL_SetPaused(channels[swordstaffsound], false);
1188 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1189 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1190 OPENAL_SetVolume(channels[metalhitsound], 512);
1191 OPENAL_SetPaused(channels[metalhitsound], false);
1195 victim->Puff(righthand);
1197 victim->targetframe=0;
1198 victim->targetanimation=staggerbackhighanim;
1199 victim->targetrotation=targetrotation+180;
1201 weapons.owner[victim->weaponids[0]]=-1;
1202 aim=DoRotation(facing,0,90,0)*21;
1204 weapons.velocity[victim->weaponids[0]]=aim*-.2;
1205 weapons.tipvelocity[victim->weaponids[0]]=aim;
1206 weapons.missed[victim->weaponids[0]]=1;
1207 weapons.hitsomething[victim->weaponids[0]]=0;
1208 weapons.freetime[victim->weaponids[0]]=0;
1209 weapons.firstfree[victim->weaponids[0]]=1;
1210 weapons.physics[victim->weaponids[0]]=1;
1211 victim->num_weapons--;
1212 if(victim->num_weapons){
1213 victim->weaponids[0]=victim->weaponids[num_weapons];
1214 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
1216 victim->weaponactive=-1;
1217 for(int i=0;i<numplayers;i++){
1218 player[i].wentforweapon=0;
1225 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1226 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1227 OPENAL_SetVolume(channels[metalhitsound], 512);
1228 OPENAL_SetPaused(channels[metalhitsound], false);*/
1231 if(abs(Random()%20)==0){
1240 if(weaponactive!=-1){
1241 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
1242 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1243 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
1245 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
1246 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
1247 OPENAL_SetVolume(channels[swordstaffsound], 512);
1248 OPENAL_SetPaused(channels[swordstaffsound], false);
1251 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1252 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1253 OPENAL_SetVolume(channels[metalhitsound], 512);
1254 OPENAL_SetPaused(channels[metalhitsound], false);
1262 targetanimation=staggerbackhighanim;
1263 targetrotation=targetrotation+180;
1265 weapons.owner[weaponids[0]]=-1;
1266 aim=DoRotation(facing,0,90,0)*21;
1268 weapons.velocity[weaponids[0]]=aim*-.2;
1269 weapons.tipvelocity[weaponids[0]]=aim;
1270 weapons.hitsomething[weaponids[0]]=0;
1271 weapons.missed[weaponids[0]]=1;
1272 weapons.freetime[weaponids[0]]=0;
1273 weapons.firstfree[weaponids[0]]=1;
1274 weapons.physics[weaponids[0]]=1;
1277 weaponids[0]=weaponids[num_weapons];
1278 if(weaponstuck==num_weapons)weaponstuck=0;
1281 for(int i=0;i<numplayers;i++){
1282 player[i].wentforweapon=0;
1286 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
1287 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
1288 OPENAL_SetVolume(channels[metalhitsound], 512);
1289 OPENAL_SetPaused(channels[metalhitsound], false);*/
1293 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1294 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1295 //victim->targetanimation=sweepanim;
1296 victim->targetanimation=dodgebackanim;
1297 victim->targetframe=0;
1299 //victim->velocity=0;
1302 rotatetarget=coords-victim->coords;
1303 Normalise(&rotatetarget);
1304 victim->targetrotation=-asin(0-rotatetarget.x);
1305 victim->targetrotation*=360/6.28;
1306 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1308 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1310 victim->lastattack3=victim->lastattack2;
1311 victim->lastattack2=victim->lastattack;
1312 victim->lastattack=victim->targetanimation;
1316 victim->targetanimation=sweepanim;
1317 victim->targetframe=0;
1321 rotatetarget=coords-victim->coords;
1322 Normalise(&rotatetarget);
1323 victim->targetrotation=-asin(0-rotatetarget.x);
1324 victim->targetrotation*=360/6.28;
1325 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1327 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1329 victim->lastattack3=victim->lastattack2;
1330 victim->lastattack2=victim->lastattack;
1331 victim->lastattack=victim->targetanimation;
1338 if(aitype!=playercontrolled)feint=0;
1339 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1340 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1341 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1343 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1347 void Person::DoDamage(float howmuch){
1348 if(tutoriallevel!=1)damage+=howmuch/power;
1349 if(id!=0)damagedealt+=howmuch/power;
1350 if(id==0)damagetaken+=howmuch/power;
1352 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1353 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1354 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1355 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1356 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1358 if(id==0)camerashake+=howmuch/100;
1359 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1360 if(blackout>1)blackout=1;
1362 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1363 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1364 if(abs(Random()%2)==0){aitype=gethelptype;
1367 else aitype=attacktypecutoff;
1371 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1374 for(int i=0;i<skeleton.num_joints; i++){
1375 if(!skeleton.free)flatvelocity2=velocity;
1376 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1377 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1378 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1379 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1380 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1381 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1382 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1383 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1384 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1395 PlaySoundEx( splattersound, samp[splattersound], NULL, true);
1396 OPENAL_3D_SetAttributes(channels[splattersound], gLoc, vel);
1397 OPENAL_SetVolume(channels[splattersound], 256);
1398 OPENAL_SetPaused(channels[splattersound], false);
1407 if(!dead&&creature==wolftype){
1416 if(tutoriallevel!=1||id==0)
1417 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1428 if(creature==wolftype){
1429 int i=abs(Random()%2);
1430 if(i==0)whichsound=snarlsound;
1431 if(i==1)whichsound=snarl2sound;
1432 envsound[numenvsounds]=coords;
1433 envsoundvol[numenvsounds]=16;
1434 envsoundlife[numenvsounds]=.4;
1437 if(creature==rabbittype){
1438 int i=abs(Random()%2);
1439 if(i==0)whichsound=rabbitpainsound;
1440 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1441 envsound[numenvsounds]=coords;
1442 envsoundvol[numenvsounds]=16;
1443 envsoundlife[numenvsounds]=.4;
1445 //if(i==2)whichsound=rabbitpain2sound;
1449 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
1450 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
1451 OPENAL_SetVolume(channels[whichsound], 512);
1452 OPENAL_SetPaused(channels[whichsound], false);
1457 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1458 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1461 void Person::DoHead(){
1462 static XYZ rotatearound;
1464 static float lookspeed=500;
1466 if(!freeze&&!winfreeze){
1469 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1470 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1472 while(targetheadrotation>180)targetheadrotation-=360;
1473 while(targetheadrotation<-180)targetheadrotation+=360;
1475 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1476 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1477 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1478 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1480 if(targetheadrotation2>120)targetheadrotation2=120;
1481 if(targetheadrotation2<-120)targetheadrotation2=-120;
1482 if(targetheadrotation>120)targetheadrotation=120;
1483 if(targetheadrotation<-120)targetheadrotation=-120;
1485 if(!isIdle())targetheadrotation2=0;
1487 if(targetheadrotation>80)targetheadrotation=80;
1488 if(targetheadrotation<-80)targetheadrotation=-80;
1489 if(targetheadrotation2>50)targetheadrotation2=50;
1490 if(targetheadrotation2<-50)targetheadrotation2=-50;
1493 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1494 else if(headrotation>targetheadrotation){
1495 headrotation-=multiplier*lookspeed;
1497 else if(headrotation<targetheadrotation){
1498 headrotation+=multiplier*lookspeed;
1501 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1502 else if(headrotation2>targetheadrotation2){
1503 headrotation2-=multiplier*lookspeed/2;
1505 else if(headrotation2<targetheadrotation2){
1506 headrotation2+=multiplier*lookspeed/2;
1509 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1510 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1514 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1515 facing=DoRotation(facing,headrotation2*.4,0,0);
1516 facing=DoRotation(facing,0,headrotation*.4,0);
1519 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1520 facing=DoRotation(facing,headrotation2*.8,0,0);
1521 facing=DoRotation(facing,0,headrotation*.8,0);
1524 if(targetanimation==walkanim){
1525 facing=DoRotation(facing,headrotation2*.6,0,0);
1526 facing=DoRotation(facing,0,headrotation*.6,0);
1529 skeleton.specialforward[0]=facing;
1530 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1532 for(i=0;i<skeleton.num_muscles;i++){
1533 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1535 skeleton.FindRotationMuscle(i,targetanimation);
1541 void Person::RagDoll(bool checkcollision){
1546 if(id==0)numfalls++;
1547 if(id==0&&isFlip())numflipfail++;
1553 facing=DoRotation(facing,0,rotation,0);
1555 skeleton.freetime=0;
1557 skeleton.longdead=0;
1563 skeleton.freefall=1;
1565 if(!isnormal(velocity.x))velocity.x=0;
1566 if(!isnormal(velocity.y))velocity.y=0;
1567 if(!isnormal(velocity.z))velocity.z=0;
1568 if(!isnormal(rotation))rotation=0;
1569 if(!isnormal(coords.x))coords=0;
1570 if(!isnormal(tilt))tilt=0;
1571 if(!isnormal(tilt2))tilt2=0;
1573 for(i=0;i<skeleton.num_joints;i++){
1574 skeleton.joints[i].delay=0;
1575 skeleton.joints[i].locked=0;
1576 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1577 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1578 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1579 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1580 skeleton.joints[i].position.y+=.1;
1581 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1582 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1585 for(i=0;i<skeleton.num_joints;i++){
1586 skeleton.joints[i].velocity=0;
1587 skeleton.joints[i].velchange=0;
1589 skeleton.DoConstraints(&coords,&scale);
1590 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1592 skeleton.DoConstraints(&coords,&scale);
1593 skeleton.DoConstraints(&coords,&scale);
1594 skeleton.DoConstraints(&coords,&scale);
1595 skeleton.DoConstraints(&coords,&scale);
1598 speed=animation[targetanimation].speed[targetframe]*2;
1599 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1600 speed=animation[currentanimation].speed[currentframe]*2;
1602 if(transspeed)speed=transspeed*2;
1606 for(i=0;i<skeleton.num_joints;i++){
1607 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);
1608 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1609 change.x=(float)(Random()%100)/100;
1610 change.y=(float)(Random()%100)/100;
1611 change.z=(float)(Random()%100)/100;
1612 skeleton.joints[i].velocity+=change;
1613 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1615 change.x=(float)(Random()%100)/100;
1616 change.y=(float)(Random()%100)/100;
1617 change.z=(float)(Random()%100)/100;
1618 skeleton.joints[i].velchange+=change;
1619 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1629 for(j=0;j<skeleton.num_joints;j++){
1630 average+=skeleton.joints[j].position;
1634 coords+=average*scale;
1635 for(j=0;j<skeleton.num_joints;j++){
1636 skeleton.joints[j].position-=average;
1639 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1640 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1641 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1642 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1643 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1646 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1647 coords.x=lowpoint.x;
1648 coords.z=lowpoint.z;
1657 for(i=0;i<skeleton.num_joints;i++){
1658 velocity+=skeleton.joints[i].velocity*scale;
1660 velocity/=skeleton.num_joints;
1663 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1664 weapons.owner[weaponids[0]]=-1;
1665 weapons.hitsomething[weaponids[0]]=0;
1666 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1667 weapons.velocity[weaponids[0]].x+=.01;
1668 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1669 weapons.missed[weaponids[0]]=1;
1670 weapons.freetime[weaponids[0]]=0;
1671 weapons.firstfree[weaponids[0]]=1;
1672 weapons.physics[weaponids[0]]=1;
1675 weaponids[0]=weaponids[num_weapons];
1676 if(weaponstuck==num_weapons)weaponstuck=0;
1679 for(i=0;i<numplayers;i++){
1680 player[i].wentforweapon=0;
1685 targetanimation=bounceidleanim;
1686 currentanimation=bounceidleanim;
1694 void Person::FootLand(int which, float opacity){
1695 static XYZ terrainlight;
1696 static XYZ footvel,footpoint;
1697 if(opacity>=1||skiddelay<=0)
1701 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1702 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1703 //footpoint.y=coords.y;
1704 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1706 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1708 if(footvel.y<.8)footvel.y=.8;
1709 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1710 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1711 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1712 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1713 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1714 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1716 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1718 if(footvel.y<.8)footvel.y=.8;
1719 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1720 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1721 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1722 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1723 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);
1725 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1727 if(footvel.y<.8)footvel.y=.8;
1728 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1729 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1730 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1731 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1732 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);
1733 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1735 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1738 if(footvel.y<.8)footvel.y=.8;
1739 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1740 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1741 //footpoint.y=coords.y;
1742 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1746 void Person::Puff(int whichlabel){
1747 static XYZ footvel,footpoint;
1750 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1751 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1756 HitStruct Person::BulletCollideWithPlayer(XYZ start, XYZ end){
1758 XYZ tempbulletloc[2];
1768 HitStruct hitstruct;
1769 hitstruct.collision=0;
1770 //Make bounding sphere
1773 for(int j=0;j<skeleton.num_joints;j++){
1774 average.x=average.x+skeleton.joints[j].position.x;
1775 average.y=average.y+skeleton.joints[j].position.y;
1776 average.z=average.z+skeleton.joints[j].position.z;
1779 average=average/howmany;
1781 for(int j=0;j<skeleton.num_joints;j++){
1782 if(findDistancefast(average,skeleton.joints[j].position)>distancemax){
1783 distancemax=findDistancefast(average,skeleton.joints[j].position);
1786 distancemax=fast_sqrt(distancemax);
1787 //Collide with player
1788 if(skeleton.free<1){
1791 if(rotation)start=DoRotation(start,0,-rotation,0);
1792 if(rotation)end=DoRotation(end,0,-rotation,0);
1794 tempbulletloc[0]=start;
1795 tempbulletloc[1]=end;
1796 if(sphere_line_intersection(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z,
1797 tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z,
1798 average.x, average.y, average.z, distancemax)){
1799 for(int j=0;j<skeleton.num_joints;j++){
1800 if(skeleton.joints[j].hasparent&&skeleton.joints[j].visible){
1801 tempbulletloc[0]=start;
1802 tempbulletloc[1]=end;
1805 glScalef(1,1/skeleton.joints[j].length,1);
1806 glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
1807 glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
1808 glTranslatef( (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
1809 (-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
1810 (-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
1811 glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
1812 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1813 tempbulletloc[0].x=M[12];
1814 tempbulletloc[0].y=M[13];
1815 tempbulletloc[0].z=M[14];
1819 glScalef(1,1/skeleton.joints[j].length,1);
1820 glRotatef(skeleton.joints[j].rotate2-90,0,0,1);
1821 glRotatef(skeleton.joints[j].rotate1-90,0,1,0);
1822 glTranslatef( (-(skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2),
1823 (-(skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2),
1824 (-(skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2));
1825 glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
1826 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1827 tempbulletloc[1].x=M[12];
1828 tempbulletloc[1].y=M[13];
1829 tempbulletloc[1].z=M[14];
1831 collide=skeletonmodels[skeleton.joints[j].modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
1836 glTranslatef( (skeleton.joints[j].position.x+skeleton.joints[j].parent->position.x)/2,
1837 (skeleton.joints[j].position.y+skeleton.joints[j].parent->position.y)/2,
1838 (skeleton.joints[j].position.z+skeleton.joints[j].parent->position.z)/2);
1839 glRotatef(-skeleton.joints[j].rotate1+90,0,1,0);
1840 glRotatef(-skeleton.joints[j].rotate2+90,0,0,1);
1841 glScalef(1,skeleton.joints[j].length,1);
1842 glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
1843 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1844 collisionpoint.x=M[12];
1845 collisionpoint.y=M[13];
1846 collisionpoint.z=M[14];
1848 hitstruct.collision=1;
1849 hitstruct.hitlocation=collisionpoint;
1850 hitstruct.joint1=&skeleton.joints[j];
1851 hitstruct.joint2=skeleton.joints[j].parent;
1855 for(int j=0;j<skeleton.num_muscles;j++){
1856 if(skeleton.muscles[j].visible){
1857 tempbulletloc[0]=start;
1858 tempbulletloc[1]=end;
1861 glScalef(1,1/skeleton.muscles[j].length,1);
1862 glRotatef(skeleton.muscles[j].rotate3,0,1,0);
1863 glRotatef(skeleton.muscles[j].rotate2-90,0,0,1);
1864 glRotatef(skeleton.muscles[j].rotate1-90,0,1,0);
1865 glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2),
1866 (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2),
1867 (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2));
1869 glTranslatef(tempbulletloc[0].x,tempbulletloc[0].y,tempbulletloc[0].z);
1870 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1871 tempbulletloc[0].x=M[12];
1872 tempbulletloc[0].y=M[13];
1873 tempbulletloc[0].z=M[14];
1877 glScalef(1,1/skeleton.muscles[j].length,1);
1878 glRotatef(skeleton.muscles[j].rotate3,0,1,0);
1879 glRotatef(skeleton.muscles[j].rotate2-90,0,0,1);
1880 glRotatef(skeleton.muscles[j].rotate1-90,0,1,0);
1882 glTranslatef( (-(skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2),
1883 (-(skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2),
1884 (-(skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2));
1885 glTranslatef(tempbulletloc[1].x,tempbulletloc[1].y,tempbulletloc[1].z);
1886 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1887 tempbulletloc[1].x=M[12];
1888 tempbulletloc[1].y=M[13];
1889 tempbulletloc[1].z=M[14];
1891 collide=skeletonmodels[skeleton.muscles[j].parent1->modelnum].LineCheck(tempbulletloc[0],tempbulletloc[1],&collisionpoint);
1896 glTranslatef( (skeleton.muscles[j].parent1->position.x+skeleton.muscles[j].parent2->position.x)/2,
1897 (skeleton.muscles[j].parent1->position.y+skeleton.muscles[j].parent2->position.y)/2,
1898 (skeleton.muscles[j].parent1->position.z+skeleton.muscles[j].parent2->position.z)/2);
1899 glRotatef(-skeleton.muscles[j].rotate1+90,0,1,0);
1900 glRotatef(-skeleton.muscles[j].rotate2+90,0,0,1);
1901 glRotatef(-skeleton.muscles[j].rotate3,0,1,0);
1902 glScalef(1,findDistance(skeleton.muscles[j].parent1->position,skeleton.muscles[j].parent2->position),1);
1903 glTranslatef(collisionpoint.x,collisionpoint.y,collisionpoint.z);
1904 glGetFloatv(GL_MODELVIEW_MATRIX,M);
1905 collisionpoint.x=M[12];
1906 collisionpoint.y=M[13];
1907 collisionpoint.z=M[14];
1909 hitstruct.collision=1;
1910 hitstruct.hitlocation=collisionpoint;
1911 hitstruct.joint1=skeleton.muscles[j].parent1;
1912 hitstruct.joint2=skeleton.muscles[j].parent2;
1917 if(skeleton.free<1){
1918 if(rotation)hitstruct.hitlocation=DoRotation(hitstruct.hitlocation,0,rotation,0);
1919 hitstruct.hitlocation=hitstruct.hitlocation+coords;
1924 void Person::DoAnimations(){
1927 static float oldtarget;
1929 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1931 if(targetanimation==tempanim||currentanimation==tempanim){
1932 animation[tempanim]=tempanimation;
1934 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1945 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1946 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1948 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1949 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1951 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1956 targfacing=DoRotation(targfacing,0,targetrotation,0);
1958 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1959 else targetanimation=backflipanim;
1960 crouchtogglekeydown=1;
1964 if(id==0)numflipped++;
1967 if(animation[targetanimation].attack!=reversed)feint=0;
1968 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1969 crouchtogglekeydown=0;
1970 if(aitype==playercontrolled)feint=0;
1974 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1975 if(!isFlip())crouchtogglekeydown=1;
1979 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1980 if(detail)normalsupdatedelay=0;
1984 if(targetanimation==rollanim&&targetframe==3&&onfire){
1994 PlaySoundEx( fireendsound, samp[fireendsound], NULL, true);
1995 OPENAL_3D_SetAttributes(channels[fireendsound], gLoc, vel);
1996 OPENAL_SetVolume(channels[fireendsound], 256);
1997 OPENAL_SetPaused(channels[fireendsound], false);
1998 OPENAL_SetPaused(channels[stream_firesound], true);
2002 if(targetanimation==rabbittacklinganim&&targetframe==1){
2003 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
2004 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
2005 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
2006 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
2007 else victim->targetanimation=rabbittackledfrontanim;
2008 victim->targetframe=2;
2010 victim->rotation=rotation;
2011 victim->targetrotation=rotation;
2012 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
2013 //victim->DoDamage(30);
2014 if(creature==wolftype){
2018 gLoc[0]=victim->coords.x;
2019 gLoc[1]=victim->coords.y;
2020 gLoc[2]=victim->coords.z;
2024 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2025 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2026 OPENAL_SetVolume(channels[clawslicesound], 128);
2027 OPENAL_SetPaused(channels[clawslicesound], false);
2029 victim->DoBloodBig(1/victim->armorhead,210);
2035 if(victim->aitype==gethelptype)bonusvalue=50;
2040 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
2041 if(weapons.type[weaponids[0]]==knife){
2042 if(weaponactive==-1)weaponactive=0;
2043 else if(weaponactive==0)weaponactive=-1;
2045 if(weaponactive==-1){
2055 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2056 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2057 OPENAL_SetVolume(channels[knifesheathesound], 128);
2058 OPENAL_SetPaused(channels[knifesheathesound], false);
2060 if(weaponactive!=-1){
2070 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2071 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2072 OPENAL_SetVolume(channels[knifedrawsound], 128);
2073 OPENAL_SetPaused(channels[knifedrawsound], false);
2076 drawtogglekeydown=1;
2079 if(tutoriallevel!=1||id==0)
2080 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
2091 if(terrain.getOpacity(coords.x,coords.z)<.2){
2092 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
2093 else whichsound=footstepsound2;
2094 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
2095 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
2096 if(animation[targetanimation].label[targetframe]==3&&isRun()){
2102 if(terrain.getOpacity(coords.x,coords.z)>=.2){
2103 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
2104 else whichsound=footstepsound4;
2108 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
2109 else whichsound=footstepsound4;
2111 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
2112 if(animation[targetanimation].attack!=neutral){
2114 if(i==0)whichsound=lowwhooshsound;
2115 if(i==1)whichsound=midwhooshsound;
2116 if(i==2)whichsound=highwhooshsound;
2118 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2120 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2121 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
2123 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2124 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2125 if(whichsound!=knifeswishsound)OPENAL_SetVolume(channels[whichsound], 128);
2126 if(whichsound!=knifeswishsound&&(targetanimation==staffhitanim||targetanimation==staffgroundsmashanim||targetanimation==staffspinhitanim))OPENAL_SetVolume(channels[whichsound], 256);
2127 if(whichsound==knifeswishsound)OPENAL_SetVolume(channels[whichsound], 512);
2128 OPENAL_SetPaused(channels[whichsound], false);
2131 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
2132 envsound[numenvsounds]=coords;
2133 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
2134 else envsoundvol[numenvsounds]=6;
2135 envsoundlife[numenvsounds]=.4;
2139 if(animation[targetanimation].label[targetframe]==3){
2141 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2142 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2143 OPENAL_SetVolume(channels[whichsound], 128);
2144 OPENAL_SetPaused(channels[whichsound], false);
2149 if(tutoriallevel!=1||id==0)
2151 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
2152 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
2162 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
2163 if(animation[targetanimation].attack!=neutral){
2165 if(creature==rabbittype){
2166 if(i==0)whichsound=rabbitattacksound;
2167 if(i==1)whichsound=rabbitattack2sound;
2168 if(i==2)whichsound=rabbitattack3sound;
2169 if(i==3)whichsound=rabbitattack4sound;
2171 if(creature==wolftype){
2172 if(i==0)whichsound=barksound;
2173 if(i==1)whichsound=bark2sound;
2174 if(i==2)whichsound=bark3sound;
2175 if(i==3)whichsound=barkgrowlsound;
2179 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
2181 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
2182 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
2185 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
2186 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
2187 OPENAL_SetVolume(channels[whichsound], 512);
2188 OPENAL_SetPaused(channels[whichsound], false);
2194 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
2200 currentoffset=targetoffset;
2201 targetframe=currentframe;
2202 currentanimation=targetanimation;
2205 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
2206 for(i=0;i<weapons.numweapons;i++){
2207 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
2208 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
2209 if(findDistancefast(&coords,&weapons.position[i])>=1){
2210 if(weapons.type[i]!=staff){
2219 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2220 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2221 OPENAL_SetVolume(channels[knifedrawsound], 128);
2222 OPENAL_SetPaused(channels[knifedrawsound], false);
2226 weapons.owner[i]=id;
2228 weaponids[num_weapons]=weaponids[0];
2237 static bool willwork;
2238 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
2239 for(i=0;i<weapons.numweapons;i++){
2241 if(weapons.owner[i]!=-1)
2242 if(player[weapons.owner[i]].weaponstuck!=-1)
2243 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
2244 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
2245 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))
2246 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
2247 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
2257 if(weapons.owner[i]!=-1)
2258 if(victim->weaponstuck!=-1){
2259 if(victim->weaponids[victim->weaponstuck]==i){
2264 if(weapons.type[i]!=staff){
2265 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2266 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2267 OPENAL_SetVolume(channels[knifedrawsound], 128);
2268 OPENAL_SetPaused(channels[knifedrawsound], false);
2272 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2273 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2274 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2275 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2278 if(weapons.owner[i]!=-1){
2280 victim=&player[weapons.owner[i]];
2281 if(victim->num_weapons==1)victim->num_weapons=0;
2282 else victim->num_weapons=1;
2284 //victim->weaponactive=-1;
2285 victim->skeleton.longdead=0;
2286 victim->skeleton.free=1;
2287 victim->skeleton.broken=0;
2289 for(int j=0;j<victim->skeleton.num_joints;j++){
2290 victim->skeleton.joints[j].velchange=0;
2291 victim->skeleton.joints[j].locked=0;
2297 Normalise(&relative);
2298 XYZ footvel,footpoint;
2300 footpoint=weapons.position[i];
2301 if(victim->weaponstuck!=-1){
2302 if(victim->weaponids[victim->weaponstuck]==i){
2303 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2304 weapons.bloody[i]=2;
2305 weapons.blooddrip[i]=5;
2306 victim->weaponstuck=-1;
2309 if(victim->num_weapons>0){
2310 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
2311 if(victim->weaponids[0]==i)
2312 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
2315 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
2316 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
2317 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
2318 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
2320 weapons.owner[i]=id;
2322 weaponids[num_weapons]=weaponids[0];
2331 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
2332 if(weaponactive==-1)weaponactive=0;
2333 else if(weaponactive==0){
2337 buffer=weaponids[0];
2338 weaponids[0]=weaponids[1];
2339 weaponids[1]=buffer;
2342 if(weaponactive==-1){
2352 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2353 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2354 OPENAL_SetVolume(channels[knifesheathesound], 128);
2355 OPENAL_SetPaused(channels[knifesheathesound], false);
2357 if(weaponactive!=-1){
2367 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2368 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2369 OPENAL_SetVolume(channels[knifedrawsound], 128);
2370 OPENAL_SetPaused(channels[knifedrawsound], false);
2375 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
2376 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
2377 Normalise(&rotatetarget);
2378 targetrotation=-asin(0-rotatetarget.x);
2379 targetrotation*=360/6.28;
2380 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2382 if(targetanimation==walljumprightkickanim)targetrotation+=40;
2383 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
2388 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
2390 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;
2392 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
2393 targetanimation=rabbittackleanim;
2404 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2405 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2406 OPENAL_SetVolume(channels[jumpsound], 128);
2407 OPENAL_SetPaused(channels[jumpsound], false);
2416 Normalise(&targetloc);
2418 for(i=0;i<numplayers;i++){
2420 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
2421 closestdist=findDistancefast(&targetloc,&player[i].coords);
2426 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
2428 victim=&player[closestid];
2429 coords=victim->coords;
2430 currentanimation=rabbittacklinganim;
2431 targetanimation=rabbittacklinganim;
2435 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
2436 rotatetarget=coords-victim->coords;
2437 Normalise(&rotatetarget);
2438 targetrotation=-asin(0-rotatetarget.x);
2439 targetrotation*=360/6.28;
2440 if(rotatetarget.z<0)targetrotation=180-targetrotation;
2442 if(targetanimation!=rabbitrunninganim){
2452 PlaySoundEx( jumpsound, samp[jumpsound], NULL, true);
2453 OPENAL_3D_SetAttributes(channels[jumpsound], gLoc, vel);
2454 OPENAL_SetVolume(channels[jumpsound], 128);
2455 OPENAL_SetPaused(channels[jumpsound], false);
2461 float damagemult=1*power;
2462 if(creature==wolftype)damagemult=2.5*power;
2463 if(hasvictim){damagemult/=victim->damagetolerance/200;}
2464 //if(onfire)damagemult=3;
2465 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
2466 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
2467 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2469 if(id==0)camerashake+=.4;
2470 if(Random()%2||creature==wolftype){
2473 if(creature==wolftype)DoBloodBig(0,250);
2477 gLoc[0]=victim->coords.x;
2478 gLoc[1]=victim->coords.y;
2479 gLoc[2]=victim->coords.z;
2483 if(tutoriallevel!=1){
2484 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2485 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2486 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2487 OPENAL_SetPaused(channels[heavyimpactsound], false);
2489 if(creature==wolftype){
2490 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2491 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2492 OPENAL_SetVolume(channels[clawslicesound], 128);
2493 OPENAL_SetPaused(channels[clawslicesound], false);
2495 victim->DoBloodBig(2/victim->armorhead,175);
2499 relative=victim->coords-coords;
2501 Normalise(&relative);
2502 relative=DoRotation(relative,0,-90,0);
2503 for(i=0;i<victim->skeleton.num_joints;i++){
2504 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2506 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2509 victim->DoDamage(damagemult*100/victim->protectionhead);
2517 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
2518 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
2520 if(id==0)camerashake+=.4;
2521 if(Random()%2||creature==wolftype){
2523 if(creature==wolftype)DoBloodBig(0,235);
2527 gLoc[0]=victim->coords.x;
2528 gLoc[1]=victim->coords.y;
2529 gLoc[2]=victim->coords.z;
2533 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2534 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2535 OPENAL_SetVolume(channels[whooshhitsound], 512);
2536 OPENAL_SetPaused(channels[whooshhitsound], false);
2537 if(creature==wolftype){
2538 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2539 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2540 OPENAL_SetVolume(channels[clawslicesound], 128);
2541 OPENAL_SetPaused(channels[clawslicesound], false);
2543 victim->DoBloodBig(2,175);
2547 relative=victim->coords-coords;
2549 Normalise(&relative);
2551 Normalise(&relative);
2552 relative=DoRotation(relative,0,90,0);
2553 for(i=0;i<victim->skeleton.num_joints;i++){
2554 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2556 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2559 victim->DoDamage(damagemult*50/victim->protectionhead);
2563 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
2564 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2566 if(id==0)camerashake+=.4;
2571 gLoc[0]=victim->coords.x;
2572 gLoc[1]=victim->coords.y;
2573 gLoc[2]=victim->coords.z;
2577 if(tutoriallevel!=1){
2578 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2579 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2580 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2581 OPENAL_SetPaused(channels[heavyimpactsound], false);
2583 if(creature==wolftype){
2584 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2585 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2586 OPENAL_SetVolume(channels[clawslicesound], 128);
2587 OPENAL_SetPaused(channels[clawslicesound], false);
2589 victim->DoBloodBig(2/victim->armorhead,175);
2595 Normalise(&relative);
2596 relative=DoRotation(relative,0,-90,0);
2597 for(i=0;i<victim->skeleton.num_joints;i++){
2598 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2600 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2603 victim->DoDamage(damagemult*150/victim->protectionhead);
2605 if(victim->damage>victim->damagetolerance){
2618 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
2619 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2621 if(id==0)camerashake+=.4;
2626 gLoc[0]=victim->coords.x;
2627 gLoc[1]=victim->coords.y;
2628 gLoc[2]=victim->coords.z;
2632 if(tutoriallevel!=1){
2633 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2634 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2635 OPENAL_SetVolume(channels[heavyimpactsound], 160);
2636 OPENAL_SetPaused(channels[heavyimpactsound], false);
2638 if(creature==wolftype){
2639 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
2640 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
2641 OPENAL_SetVolume(channels[clawslicesound], 128);
2642 OPENAL_SetPaused(channels[clawslicesound], false);
2644 victim->DoBloodBig(2/victim->armorhead,175);
2650 Normalise(&relative);
2651 relative=DoRotation(relative,0,90,0);
2652 for(i=0;i<victim->skeleton.num_joints;i++){
2653 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2655 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2658 victim->DoDamage(damagemult*150/victim->protectionhead);
2660 if(victim->damage>victim->damagetolerance){
2673 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
2674 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
2676 if(id==0)camerashake+=.4;
2683 gLoc[0]=victim->coords.x;
2684 gLoc[1]=victim->coords.y;
2685 gLoc[2]=victim->coords.z;
2689 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
2690 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
2691 OPENAL_SetVolume(channels[whooshhitsound], 512);
2692 OPENAL_SetPaused(channels[whooshhitsound], false);
2695 relative=victim->coords-coords;
2697 Normalise(&relative);
2698 for(i=0;i<victim->skeleton.num_joints;i++){
2699 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2701 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
2704 victim->DoDamage(damagemult*50/victim->protectionhead);
2708 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
2709 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
2711 if(id==0)camerashake+=.2;
2714 gLoc[0]=victim->coords.x;
2715 gLoc[1]=victim->coords.y;
2716 gLoc[2]=victim->coords.z;
2720 /*PlaySoundEx( landsound2, samp[landsound2], NULL, true);
2721 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
2722 OPENAL_SetVolume(channels[landsound2], 128);
2723 OPENAL_SetPaused(channels[landsound2], false);
2725 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
2726 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
2727 OPENAL_SetVolume(channels[movewhooshsound], 128);
2728 OPENAL_SetPaused(channels[movewhooshsound], false);
2730 victim->skeleton.longdead=0;
2731 victim->skeleton.free=1;
2732 victim->skeleton.broken=0;
2733 victim->skeleton.spinny=1;
2735 for(i=0;i<victim->skeleton.num_joints;i++){
2736 victim->skeleton.joints[i].velchange=0;
2737 victim->skeleton.joints[i].delay=0;
2738 victim->skeleton.joints[i].locked=0;
2739 //victim->skeleton.joints[i].velocity=0;
2745 Normalise(&relative);
2746 for(i=0;i<victim->skeleton.num_joints;i++){
2747 victim->skeleton.joints[i].velocity.y=relative.y*10;
2748 victim->skeleton.joints[i].position.y+=relative.y*.3;
2749 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2750 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2752 victim->Puff(abdomen);
2753 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2757 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2758 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2760 if(id==0)camerashake+=.4;
2769 if(tutoriallevel!=1){
2770 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
2771 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
2772 OPENAL_SetVolume(channels[heavyimpactsound], 128);
2773 OPENAL_SetPaused(channels[heavyimpactsound], false);
2776 relative=victim->coords-coords;
2778 Normalise(&relative);
2779 for(i=0;i<victim->skeleton.num_joints;i++){
2780 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2782 victim->Puff(abdomen);
2783 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2787 victim->DoDamage(damagemult*500/victim->protectionhigh);
2788 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2792 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2793 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2795 if(id==0)camerashake+=.4;
2804 if(tutoriallevel!=1){
2805 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
2806 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
2807 OPENAL_SetVolume(channels[thudsound], 400);
2808 OPENAL_SetPaused(channels[thudsound], false);
2811 victim->skeleton.longdead=0;
2812 victim->skeleton.free=1;
2813 victim->skeleton.broken=0;
2814 victim->skeleton.spinny=1;
2816 for(i=0;i<victim->skeleton.num_joints;i++){
2817 victim->skeleton.joints[i].velchange=0;
2818 //victim->skeleton.joints[i].delay=0;
2819 victim->skeleton.joints[i].locked=0;
2822 relative=victim->coords-coords;
2823 Normalise(&relative);
2825 Normalise(&relative);
2826 for(i=0;i<victim->skeleton.num_joints;i++){
2827 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2829 if(id==0&&!victim->dead){
2833 victim->Puff(abdomen);
2834 victim->DoDamage(damagemult*20/victim->protectionhigh);
2835 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2837 if(!victim->dead)staggerdelay=1.2;
2843 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2844 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2845 //if(id==0)camerashake+=.4;
2856 if(!victim->skeleton.free)hasvictim=0;
2859 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2860 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2861 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2862 OPENAL_SetVolume(channels[knifesheathesound], 128);
2863 OPENAL_SetPaused(channels[knifesheathesound], false);
2866 if(victim&&hasvictim){
2867 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2869 XYZ where,startpoint,endpoint,movepoint,colpoint;
2870 float rotationpoint;
2872 if(weapons.type[weaponids[weaponactive]]==knife){
2873 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2874 where-=victim->coords;
2875 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2882 if(weapons.type[weaponids[weaponactive]]==sword){
2883 where=weapons.position[weaponids[weaponactive]];
2884 where-=victim->coords;
2885 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2887 where=weapons.tippoint[weaponids[weaponactive]];
2888 where-=victim->coords;
2889 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2892 if(weapons.type[weaponids[weaponactive]]==staff){
2893 where=weapons.position[weaponids[weaponactive]];
2894 where-=victim->coords;
2895 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2897 where=weapons.tippoint[weaponids[weaponactive]];
2898 where-=victim->coords;
2899 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2904 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2907 if(victim->dead!=2){
2908 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2909 if(id==0&&!victim->dead){
2910 bonus=FinishedBonus;
2915 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2917 victim->skeleton.longdead=0;
2918 victim->skeleton.free=1;
2919 victim->skeleton.broken=0;
2921 for(i=0;i<victim->skeleton.num_joints;i++){
2922 victim->skeleton.joints[i].velchange=0;
2923 victim->skeleton.joints[i].locked=0;
2924 //victim->skeleton.joints[i].velocity=0;
2926 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
2927 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
2928 OPENAL_SetVolume(channels[fleshstabsound], 128);
2929 OPENAL_SetPaused(channels[fleshstabsound], false);
2932 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2933 weapons.blooddrip[weaponids[weaponactive]]+=5;
2934 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2938 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
2939 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
2940 OPENAL_SetVolume(channels[knifesheathesound], 128);
2941 OPENAL_SetPaused(channels[knifesheathesound], false);
2947 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2948 // if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9){
2949 //if(id==0)camerashake+=.4;
2959 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
2960 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
2961 OPENAL_SetVolume(channels[knifedrawsound], 128);
2962 OPENAL_SetPaused(channels[knifedrawsound], false);
2965 if(victim&&hasvictim){
2966 XYZ footvel,footpoint;
2968 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
2969 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
2970 OPENAL_SetVolume(channels[fleshstabremovesound], 128);
2971 OPENAL_SetPaused(channels[fleshstabremovesound], false);
2974 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2976 if(weapons.type[weaponids[weaponactive]]==sword){
2977 XYZ where,startpoint,endpoint,movepoint;
2978 float rotationpoint;
2981 where=weapons.position[weaponids[weaponactive]];
2982 where-=victim->coords;
2983 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2985 where=weapons.tippoint[weaponids[weaponactive]];
2986 where-=victim->coords;
2987 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2992 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2993 footpoint+=victim->coords;
2996 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2999 if(weapons.type[weaponids[weaponactive]]==staff){
3000 XYZ where,startpoint,endpoint,movepoint;
3001 float rotationpoint;
3004 where=weapons.position[weaponids[weaponactive]];
3005 where-=victim->coords;
3006 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
3008 where=weapons.tippoint[weaponids[weaponactive]];
3009 where-=victim->coords;
3010 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
3015 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
3016 footpoint+=victim->coords;
3019 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
3022 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
3024 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
3025 victim->skeleton.longdead=0;
3026 victim->skeleton.free=1;
3027 victim->skeleton.broken=0;
3029 for(i=0;i<victim->skeleton.num_joints;i++){
3030 victim->skeleton.joints[i].velchange=0;
3031 victim->skeleton.joints[i].locked=0;
3032 //victim->skeleton.joints[i].velocity=0;
3038 Normalise(&relative);
3039 //victim->Puff(abdomen);
3040 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
3042 if(victim->bloodloss<victim->damagetolerance){
3043 victim->bloodloss+=1000;
3047 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3051 if(!hasvictim&&onterrain){
3052 weapons.bloody[weaponids[weaponactive]]=0;
3053 weapons.blooddrip[weaponids[weaponactive]]=0;
3057 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
3058 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
3060 if(id==0)camerashake+=.4;
3067 gLoc[0]=victim->coords.x;
3068 gLoc[1]=victim->coords.y;
3069 gLoc[2]=victim->coords.z;
3073 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
3075 if(tutoriallevel!=1){
3076 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3077 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3078 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3079 OPENAL_SetPaused(channels[heavyimpactsound], false);
3083 if(tutoriallevel!=1){
3084 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3085 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3086 OPENAL_SetVolume(channels[landsound2], 256);
3087 OPENAL_SetPaused(channels[landsound2], false);
3091 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60)
3094 relative=victim->coords-coords;
3096 Normalise(&relative);
3097 for(i=0;i<victim->skeleton.num_joints;i++){
3098 victim->skeleton.joints[i].velocity=relative*30;
3100 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
3102 victim->targetframe=0;
3103 victim->targetanimation=staggerbackhardanim;
3104 victim->targetrotation=targetrotation+180;
3109 victim->Puff(abdomen);
3110 victim->DoDamage(damagemult*60/victim->protectionhigh);
3119 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
3120 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
3122 if(id==0)camerashake+=.4;
3125 gLoc[0]=victim->coords.x;
3126 gLoc[1]=victim->coords.y;
3127 gLoc[2]=victim->coords.z;
3131 //if(!victim->isIdle()||victim->damage>victim->damagetolerance-60){
3132 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
3133 if(tutoriallevel!=1){
3134 PlaySoundEx( thudsound, samp[thudsound], NULL, true);
3135 OPENAL_3D_SetAttributes(channels[thudsound], gLoc, vel);
3136 OPENAL_SetVolume(channels[thudsound], 512);
3137 OPENAL_SetPaused(channels[thudsound], false);
3140 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
3141 if(tutoriallevel!=1){
3142 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3143 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3144 OPENAL_SetVolume(channels[whooshhitsound], 512);
3145 OPENAL_SetPaused(channels[whooshhitsound], false);
3149 if(tutoriallevel!=1){
3150 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3151 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3152 OPENAL_SetVolume(channels[heavyimpactsound], 256);
3153 OPENAL_SetPaused(channels[heavyimpactsound], false);
3157 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
3160 relative=victim->coords-coords;
3162 Normalise(&relative);
3164 Normalise(&relative);
3165 for(i=0;i<victim->skeleton.num_joints;i++){
3166 victim->skeleton.joints[i].velocity=relative*5;
3168 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
3170 victim->targetframe=0;
3171 victim->targetanimation=staggerbackhardanim;
3172 victim->targetrotation=targetrotation+180;
3176 victim->Puff(abdomen);
3177 victim->DoDamage(damagemult*60/victim->protectionhigh);
3185 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
3186 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3187 if(victim->id==0)camerashake+=.4;
3190 gLoc[0]=victim->coords.x;
3191 gLoc[1]=victim->coords.y;
3192 gLoc[2]=victim->coords.z;
3197 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3198 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3199 OPENAL_SetVolume(channels[landsound2], 256);
3200 OPENAL_SetPaused(channels[landsound2], false);
3206 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
3207 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
3208 if(victim->id==0)camerashake+=.4;
3211 gLoc[0]=victim->coords.x;
3212 gLoc[1]=victim->coords.y;
3213 gLoc[2]=victim->coords.z;
3218 if(weaponactive!=-1){
3219 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3220 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3221 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3223 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3224 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3225 OPENAL_SetVolume(channels[swordstaffsound], 512);
3226 OPENAL_SetPaused(channels[swordstaffsound], false);
3229 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3230 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3231 OPENAL_SetVolume(channels[metalhitsound], 512);
3232 OPENAL_SetPaused(channels[metalhitsound], false);
3240 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
3241 if(weaponactive!=-1){
3244 weapons.owner[weaponids[0]]=-1;
3245 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);
3247 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
3248 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
3250 weapons.velocity[weaponids[0]]=aim*50;
3251 weapons.tipvelocity[weaponids[0]]=aim*50;
3252 weapons.missed[weaponids[0]]=0;
3253 weapons.hitsomething[weaponids[0]]=0;
3254 weapons.freetime[weaponids[0]]=0;
3255 weapons.firstfree[weaponids[0]]=1;
3256 weapons.physics[weaponids[0]]=0;
3259 weaponids[0]=weaponids[num_weapons];
3265 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
3267 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
3270 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
3278 if(tutoriallevel!=1){
3281 gLoc[0]=victim->coords.x;
3282 gLoc[1]=victim->coords.y;
3283 gLoc[2]=victim->coords.z;
3287 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3288 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3289 OPENAL_SetVolume(channels[knifeslicesound], 512);
3290 OPENAL_SetPaused(channels[knifeslicesound], false);
3292 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3293 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
3294 if(victim->id != 0 || difficulty==2){
3295 victim->targetframe=0;
3296 victim->targetanimation=staggerbackhardanim;
3297 victim->targetrotation=targetrotation+180;
3301 victim->lowreversaldelay=0;
3302 victim->highreversaldelay=0;
3303 if(aitype!=playercontrolled)weaponmissdelay=.6;
3305 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3306 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
3308 XYZ footvel,footpoint;
3311 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3314 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;
3316 if(tutoriallevel!=1){
3317 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
3318 footvel=DoRotation(facing,0,90,0)*.8;
3320 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3321 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3322 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3323 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3325 if(tutoriallevel==1){
3326 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
3328 victim->DoDamage(damagemult*0);
3331 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3332 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
3333 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
3340 if(tutoriallevel!=1){
3341 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
3342 else victim->DoBloodBig(2/victim->armorhigh,185);
3343 victim->deathbleeding=1;
3346 gLoc[0]=victim->coords.x;
3347 gLoc[1]=victim->coords.y;
3348 gLoc[2]=victim->coords.z;
3352 PlaySoundEx( swordslicesound, samp[swordslicesound], NULL, true);
3353 OPENAL_3D_SetAttributes(channels[swordslicesound], gLoc, vel);
3354 OPENAL_SetVolume(channels[swordslicesound], 512);
3355 OPENAL_SetPaused(channels[swordslicesound], false);
3357 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3358 //if(animation[victim->targetanimation].attack){
3359 //if(victim->creature==rabbittype){
3360 if(tutoriallevel!=1){
3361 victim->targetframe=0;
3362 victim->targetanimation=staggerbackhardanim;
3363 victim->targetrotation=targetrotation+180;
3369 if(tutoriallevel!=1){
3370 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3371 weapons.blooddrip[weaponids[weaponactive]]+=3;
3373 float bloodlossamount;
3374 bloodlossamount=200+abs((float)(Random()%40))-20;
3375 victim->bloodloss+=bloodlossamount/victim->armorhigh;
3376 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
3377 victim->DoDamage(damagemult*0);
3379 XYZ footvel,footpoint;
3382 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
3385 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;
3387 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3388 footvel=DoRotation(facing,0,90,0)*.8;
3390 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3391 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3392 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3393 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3401 gLoc[0]=victim->coords.x;
3402 gLoc[1]=victim->coords.y;
3403 gLoc[2]=victim->coords.z;
3407 if(victim->weaponactive!=-1){
3408 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
3409 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3410 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
3412 PlaySoundEx( swordstaffsound, samp[swordstaffsound], NULL, true);
3413 OPENAL_3D_SetAttributes(channels[swordstaffsound], gLoc, vel);
3414 OPENAL_SetVolume(channels[swordstaffsound], 512);
3415 OPENAL_SetPaused(channels[swordstaffsound], false);
3418 PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3419 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3420 OPENAL_SetVolume(channels[metalhitsound], 512);
3421 OPENAL_SetPaused(channels[metalhitsound], false);
3427 victim->Puff(righthand);
3429 victim->targetframe=0;
3430 victim->targetanimation=staggerbackhighanim;
3431 victim->targetrotation=targetrotation+180;
3433 weapons.owner[victim->weaponids[0]]=-1;
3434 aim=DoRotation(facing,0,90,0)*21;
3436 weapons.velocity[victim->weaponids[0]]=aim*-.2;
3437 weapons.tipvelocity[victim->weaponids[0]]=aim;
3438 weapons.missed[victim->weaponids[0]]=1;
3439 weapons.hitsomething[weaponids[0]]=0;
3440 weapons.freetime[victim->weaponids[0]]=0;
3441 weapons.firstfree[victim->weaponids[0]]=1;
3442 weapons.physics[victim->weaponids[0]]=1;
3443 victim->num_weapons--;
3444 if(victim->num_weapons){
3445 victim->weaponids[0]=victim->weaponids[num_weapons];
3446 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3448 victim->weaponactive=-1;
3449 for(i=0;i<numplayers;i++){
3450 player[i].wentforweapon=0;
3453 /*PlaySoundEx( metalhitsound, samp[metalhitsound], NULL, true);
3454 OPENAL_3D_SetAttributes(channels[metalhitsound], gLoc, vel);
3455 OPENAL_SetVolume(channels[metalhitsound], 512);
3456 OPENAL_SetPaused(channels[metalhitsound], false);*/
3462 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3463 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3464 if(tutoriallevel!=1){
3465 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
3467 if(id==0)camerashake+=.4;
3468 if(Random()%2||creature==wolftype){
3473 gLoc[0]=victim->coords.x;
3474 gLoc[1]=victim->coords.y;
3475 gLoc[2]=victim->coords.z;
3479 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3480 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3481 OPENAL_SetVolume(channels[staffheadsound], 256);
3482 OPENAL_SetPaused(channels[staffheadsound], false);
3486 relative=victim->coords-coords;
3488 Normalise(&relative);
3489 relative=DoRotation(relative,0,90,0);
3491 Normalise(&relative);
3492 for(i=0;i<victim->skeleton.num_joints;i++){
3493 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
3495 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
3496 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
3499 if(tutoriallevel!=1){
3500 victim->DoDamage(damagemult*120/victim->protectionhigh);
3511 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
3512 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
3513 if(tutoriallevel!=1){
3514 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
3516 if(id==0)camerashake+=.4;
3517 if(Random()%2||creature==wolftype){
3522 gLoc[0]=victim->coords.x;
3523 gLoc[1]=victim->coords.y;
3524 gLoc[2]=victim->coords.z;
3528 PlaySoundEx( staffheadsound, samp[staffheadsound], NULL, true);
3529 OPENAL_3D_SetAttributes(channels[staffheadsound], gLoc, vel);
3530 OPENAL_SetVolume(channels[staffheadsound], 256);
3531 OPENAL_SetPaused(channels[staffheadsound], false);
3535 relative=victim->coords-coords;
3537 Normalise(&relative);
3538 relative=DoRotation(relative,0,-90,0);
3539 for(i=0;i<victim->skeleton.num_joints;i++){
3540 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3542 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
3543 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
3546 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
3557 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
3558 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
3560 if(tutoriallevel!=1){
3561 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
3562 if(id==0)camerashake+=.4;
3563 if(Random()%2||creature==wolftype){
3568 gLoc[0]=victim->coords.x;
3569 gLoc[1]=victim->coords.y;
3570 gLoc[2]=victim->coords.z;
3574 PlaySoundEx( staffbodysound, samp[staffbodysound], NULL, true);
3575 OPENAL_3D_SetAttributes(channels[staffbodysound], gLoc, vel);
3576 OPENAL_SetVolume(channels[staffbodysound], 256);
3577 OPENAL_SetPaused(channels[staffbodysound], false);
3579 victim->skeleton.longdead=0;
3580 victim->skeleton.free=1;
3581 victim->skeleton.broken=0;
3583 for(i=0;i<victim->skeleton.num_joints;i++){
3584 victim->skeleton.joints[i].velchange=0;
3585 victim->skeleton.joints[i].locked=0;
3586 //victim->skeleton.joints[i].velocity=0;
3592 /*relative=victim->coords-coords;
3594 Normalise(&relative);
3595 relative=DoRotation(relative,0,90,0);*/
3597 Normalise(&relative);
3599 for(i=0;i<victim->skeleton.num_joints;i++){
3600 victim->skeleton.joints[i].velocity=relative*damagemult*40;
3603 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
3606 for(i=0;i<victim->skeleton.num_joints;i++){
3607 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
3610 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
3612 victim->Puff(abdomen);
3613 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
3626 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
3627 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
3629 if(id==0)camerashake+=.4;
3632 gLoc[0]=victim->coords.x;
3633 gLoc[1]=victim->coords.y;
3634 gLoc[2]=victim->coords.z;
3639 relative=victim->coords-coords;
3641 Normalise(&relative);
3647 if(animation[victim->targetanimation].height==lowheight){
3653 for(i=0;i<victim->skeleton.num_joints;i++){
3654 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3656 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3657 if(tutoriallevel!=1){
3658 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3659 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3660 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3661 OPENAL_SetPaused(channels[heavyimpactsound], false);
3664 victim->DoDamage(damagemult*100/victim->protectionhead);
3665 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
3666 if(creature==wolftype){
3667 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3668 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3669 OPENAL_SetVolume(channels[clawslicesound], 128);
3670 OPENAL_SetPaused(channels[clawslicesound], false);
3672 victim->DoBloodBig(2/victim->armorhead,175);
3676 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3677 for(i=0;i<victim->skeleton.num_joints;i++){
3678 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3680 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3681 victim->targetframe=0;
3682 victim->targetanimation=staggerbackhighanim;
3683 victim->targetrotation=targetrotation+180;
3685 if(tutoriallevel!=1){
3686 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3687 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3688 OPENAL_SetVolume(channels[landsound2], 128);
3689 OPENAL_SetPaused(channels[landsound2], false);
3691 victim->Puff(abdomen);
3692 victim->DoDamage(damagemult*30/victim->protectionhigh);
3693 if(creature==wolftype){
3694 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3695 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3696 OPENAL_SetVolume(channels[clawslicesound], 128);
3697 OPENAL_SetPaused(channels[clawslicesound], false);
3699 victim->DoBloodBig(2/victim->armorhigh,170);
3706 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
3707 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
3709 if(id==0)camerashake+=.2;
3712 gLoc[0]=victim->coords.x;
3713 gLoc[1]=victim->coords.y;
3714 gLoc[2]=victim->coords.z;
3718 if(tutoriallevel!=1){
3719 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3720 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3721 OPENAL_SetVolume(channels[landsound2], 128);
3722 OPENAL_SetPaused(channels[landsound2], false);
3725 relative=victim->coords-coords;
3727 Normalise(&relative);
3729 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
3732 for(i=0;i<victim->skeleton.num_joints;i++){
3733 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
3735 relative=DoRotation(relative,0,-90,0);
3737 for(i=0;i<victim->skeleton.num_joints;i++){
3738 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)
3739 victim->skeleton.joints[i].velocity=relative*80;
3741 victim->Puff(rightankle);
3742 victim->Puff(leftankle);
3743 victim->DoDamage(damagemult*40/victim->protectionlow);
3746 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
3747 for(i=0;i<victim->skeleton.num_joints;i++){
3748 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
3750 relative=DoRotation(relative,0,-90,0);
3751 for(i=0;i<victim->skeleton.num_joints;i++){
3752 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)
3753 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
3755 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3756 victim->targetframe=0;
3757 victim->targetanimation=staggerbackhighanim;
3758 victim->targetrotation=targetrotation+180;
3760 if(tutoriallevel!=1){
3761 PlaySoundEx( landsound2, samp[landsound2], NULL, true);
3762 OPENAL_3D_SetAttributes(channels[landsound2], gLoc, vel);
3763 OPENAL_SetVolume(channels[landsound2], 128);
3764 OPENAL_SetPaused(channels[landsound2], false);
3766 victim->Puff(abdomen);
3767 victim->DoDamage(damagemult*30/victim->protectionlow);
3777 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
3778 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
3780 if(id==0)camerashake+=.4;
3787 gLoc[0]=victim->coords.x;
3788 gLoc[1]=victim->coords.y;
3789 gLoc[2]=victim->coords.z;
3793 if(tutoriallevel!=1){
3794 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3795 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3796 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3797 OPENAL_SetPaused(channels[heavyimpactsound], false);
3799 if(creature==wolftype){
3800 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3801 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3802 OPENAL_SetVolume(channels[clawslicesound], 128);
3803 OPENAL_SetPaused(channels[clawslicesound], false);
3805 victim->DoBloodBig(2/victim->armorhigh,170);
3809 relative=victim->coords-oldcoords;
3811 Normalise(&relative);
3812 //relative=DoRotation(relative,0,-90,0);
3813 for(i=0;i<victim->skeleton.num_joints;i++){
3814 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
3816 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3818 victim->Puff(abdomen);
3819 victim->DoDamage(damagemult*150/victim->protectionhigh);
3828 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
3829 if(victim->weaponactive!=-1&&victim->num_weapons>0){
3830 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
3831 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
3834 weaponids[num_weapons]=weaponids[victim->weaponactive];
3837 weaponids[0]=victim->weaponids[victim->weaponactive];
3838 victim->num_weapons--;
3839 if(victim->num_weapons>0){
3840 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
3841 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3843 victim->weaponactive=-1;
3848 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
3850 if(id==0)camerashake+=.4;
3857 gLoc[0]=victim->coords.x;
3858 gLoc[1]=victim->coords.y;
3859 gLoc[2]=victim->coords.z;
3863 PlaySoundEx( whooshhitsound, samp[whooshhitsound], NULL, true);
3864 OPENAL_3D_SetAttributes(channels[whooshhitsound], gLoc, vel);
3865 OPENAL_SetVolume(channels[whooshhitsound], 128);
3866 OPENAL_SetPaused(channels[whooshhitsound], false);
3869 relative=victim->coords-oldcoords;
3871 Normalise(&relative);
3872 //relative=DoRotation(relative,0,-90,0);
3873 for(i=0;i<victim->skeleton.num_joints;i++){
3874 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3876 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3879 victim->DoDamage(damagemult*70/victim->protectionhigh);
3882 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
3884 if(id==0)camerashake+=.4;
3891 gLoc[0]=victim->coords.x;
3892 gLoc[1]=victim->coords.y;
3893 gLoc[2]=victim->coords.z;
3899 bonus=staffreversebonus;
3904 if(tutoriallevel!=1){
3905 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
3906 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
3907 OPENAL_SetVolume(channels[heavyimpactsound], 128);
3908 OPENAL_SetPaused(channels[heavyimpactsound], false);
3912 bonus=staffreversebonus;
3918 relative=victim->coords-oldcoords;
3920 Normalise(&relative);
3921 //relative=DoRotation(relative,0,-90,0);
3922 for(i=0;i<victim->skeleton.num_joints;i++){
3923 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
3925 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
3928 victim->DoDamage(damagemult*70/victim->protectionhigh);
3931 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
3937 Normalise(&relative);
3940 for(i=0;i<victim->skeleton.num_joints;i++){
3941 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
3943 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
3944 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
3945 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
3946 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
3947 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
3948 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
3949 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
3950 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
3952 victim->Puff(abdomen);
3953 victim->DoDamage(damagemult*90/victim->protectionhigh);
3963 if(weaponactive!=-1||creature==wolftype)doslice=1;
3964 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3968 gLoc[0]=victim->coords.x;
3969 gLoc[1]=victim->coords.y;
3970 gLoc[2]=victim->coords.z;
3974 if(weaponactive!=-1){
3975 victim->DoBloodBig(2/victim->armorhigh,225);
3976 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
3977 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
3978 OPENAL_SetVolume(channels[knifeslicesound], 512);
3979 OPENAL_SetPaused(channels[knifeslicesound], false);
3980 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3981 weapons.blooddrip[weaponids[weaponactive]]+=3;
3983 if(weaponactive==-1&&creature==wolftype){
3984 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
3985 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
3986 OPENAL_SetVolume(channels[clawslicesound], 128);
3987 OPENAL_SetPaused(channels[clawslicesound], false);
3989 victim->DoBloodBig(2/victim->armorhigh,175);
3996 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
4002 Normalise(&relative);
4005 for(i=0;i<victim->skeleton.num_joints;i++){
4006 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
4008 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
4009 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
4010 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
4011 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
4012 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
4013 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
4014 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
4015 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
4018 bonus=swordreversebonus;
4022 //victim->DoDamage(90);
4024 /*if(weaponactive!=-1){
4027 gLoc[0]=victim->coords.x;
4028 gLoc[1]=victim->coords.y;
4029 gLoc[2]=victim->coords.z;
4033 victim->DoBloodBig(2,225);
4034 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4035 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4036 OPENAL_SetVolume(channels[knifeslicesound], 512);
4037 OPENAL_SetPaused(channels[knifeslicesound], false);
4038 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4039 weapons.blooddrip[weaponids[weaponactive]]+=3;
4043 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
4045 if(id==0)camerashake+=.4;
4052 gLoc[0]=victim->coords.x;
4053 gLoc[1]=victim->coords.y;
4054 gLoc[2]=victim->coords.z;
4058 if(tutoriallevel!=1){
4059 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4060 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4061 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4062 OPENAL_SetPaused(channels[heavyimpactsound], false);
4066 relative=victim->coords-oldcoords;
4068 Normalise(&relative);
4069 relative=DoRotation(relative,0,-90,0);
4070 for(i=0;i<victim->skeleton.num_joints;i++){
4071 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
4073 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
4075 victim->Puff(abdomen);
4076 victim->DoDamage(damagemult*30/victim->protectionhigh);
4085 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
4088 victim->skeleton.spinny=0;
4092 Normalise(&relative);
4093 if(victim->id==0)relative/=30;
4094 for(i=0;i<victim->skeleton.num_joints;i++){
4095 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
4097 //victim->DoDamage(1000);
4098 victim->damage=victim->damagetolerance;
4099 victim->permanentdamage=victim->damagetolerance-1;
4102 if(weaponactive!=-1||creature==wolftype)doslice=1;
4103 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4107 gLoc[0]=victim->coords.x;
4108 gLoc[1]=victim->coords.y;
4109 gLoc[2]=victim->coords.z;
4113 if(weaponactive!=-1){
4114 victim->DoBloodBig(200,225);
4115 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4116 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4117 OPENAL_SetVolume(channels[knifeslicesound], 512);
4118 OPENAL_SetPaused(channels[knifeslicesound], false);
4119 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4120 weapons.blooddrip[weaponids[weaponactive]]+=5;
4123 if(creature==wolftype&&weaponactive==-1){
4124 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4125 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4126 OPENAL_SetVolume(channels[clawslicesound], 128);
4127 OPENAL_SetPaused(channels[clawslicesound], false);
4129 victim->DoBloodBig(2,175);
4139 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4140 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4142 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
4143 if(targetanimation==knifesneakattackanim){
4144 /*victim->DoBloodBig(200,195);
4149 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
4150 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
4152 XYZ footvel,footpoint;
4154 footpoint=weapons.tippoint[weaponids[0]];
4155 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4156 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4157 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4158 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4159 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4160 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4161 victim->DoBloodBig(200,195);
4168 //victim->neckspurtamount=5;
4170 if(targetanimation==knifefollowanim){
4176 XYZ footvel,footpoint;
4178 footpoint=weapons.tippoint[weaponids[0]];
4179 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4180 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4181 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4182 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4183 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
4184 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
4187 victim->bloodloss+=10000;
4191 gLoc[0]=victim->coords.x;
4192 gLoc[1]=victim->coords.y;
4193 gLoc[2]=victim->coords.z;
4197 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4198 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4199 OPENAL_SetVolume(channels[fleshstabsound], 512);
4200 OPENAL_SetPaused(channels[fleshstabsound], false);
4201 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4202 weapons.blooddrip[weaponids[weaponactive]]+=5;
4206 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
4209 for(i=0;i<victim->skeleton.num_joints;i++){
4210 victim->skeleton.joints[i].velocity=0;
4212 if(targetanimation==knifefollowanim){
4214 for(i=0;i<victim->skeleton.num_joints;i++){
4215 victim->skeleton.joints[i].velocity=0;
4218 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
4221 gLoc[0]=victim->coords.x;
4222 gLoc[1]=victim->coords.y;
4223 gLoc[2]=victim->coords.z;
4227 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4228 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4229 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4230 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4231 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4232 weapons.blooddrip[weaponids[weaponactive]]+=5;
4234 XYZ footvel,footpoint;
4236 footpoint=weapons.tippoint[weaponids[0]];
4237 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4238 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4239 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4240 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4241 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4242 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4246 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
4247 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
4256 XYZ footvel,footpoint;
4258 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
4259 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4260 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
4261 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4262 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4263 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4264 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
4265 victim->DoBloodBig(200,180);
4266 victim->DoBloodBig(200,215);
4267 victim->bloodloss+=10000;
4271 gLoc[0]=victim->coords.x;
4272 gLoc[1]=victim->coords.y;
4273 gLoc[2]=victim->coords.z;
4277 PlaySoundEx( fleshstabsound, samp[fleshstabsound], NULL, true);
4278 OPENAL_3D_SetAttributes(channels[fleshstabsound], gLoc, vel);
4279 OPENAL_SetVolume(channels[fleshstabsound], 512);
4280 OPENAL_SetPaused(channels[fleshstabsound], false);
4281 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4282 weapons.blooddrip[weaponids[weaponactive]]+=5;
4286 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
4289 for(i=0;i<victim->skeleton.num_joints;i++){
4290 victim->skeleton.joints[i].velocity=0;
4292 if(weaponactive!=-1){
4295 gLoc[0]=victim->coords.x;
4296 gLoc[1]=victim->coords.y;
4297 gLoc[2]=victim->coords.z;
4301 PlaySoundEx( fleshstabremovesound, samp[fleshstabremovesound], NULL, true);
4302 OPENAL_3D_SetAttributes(channels[fleshstabremovesound], gLoc, vel);
4303 OPENAL_SetVolume(channels[fleshstabremovesound], 512);
4304 OPENAL_SetPaused(channels[fleshstabremovesound], false);
4305 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
4306 weapons.blooddrip[weaponids[weaponactive]]+=5;
4308 XYZ footvel,footpoint;
4310 footpoint=weapons.tippoint[weaponids[0]];
4311 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
4312 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
4313 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4314 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
4315 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
4316 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
4320 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
4322 if(id==0)camerashake+=.4;
4329 gLoc[0]=victim->coords.x;
4330 gLoc[1]=victim->coords.y;
4331 gLoc[2]=victim->coords.z;
4335 if(weaponactive==-1){
4336 if(tutoriallevel!=1){
4337 PlaySoundEx( heavyimpactsound, samp[heavyimpactsound], NULL, true);
4338 OPENAL_3D_SetAttributes(channels[heavyimpactsound], gLoc, vel);
4339 OPENAL_SetVolume(channels[heavyimpactsound], 128);
4340 OPENAL_SetPaused(channels[heavyimpactsound], false);
4345 if(weaponactive!=-1||creature==wolftype)doslice=1;
4346 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
4348 if(weaponactive!=-1){
4349 victim->DoBloodBig(2/victim->armorhead,225);
4350 PlaySoundEx( knifeslicesound, samp[knifeslicesound], NULL, true);
4351 OPENAL_3D_SetAttributes(channels[knifeslicesound], gLoc, vel);
4352 OPENAL_SetVolume(channels[knifeslicesound], 512);
4353 OPENAL_SetPaused(channels[knifeslicesound], false);
4354 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
4355 weapons.blooddrip[weaponids[weaponactive]]+=3;
4357 if(weaponactive==-1&&creature==wolftype){
4358 PlaySoundEx( clawslicesound, samp[clawslicesound], NULL, true);
4359 OPENAL_3D_SetAttributes(channels[clawslicesound], gLoc, vel);
4360 OPENAL_SetVolume(channels[clawslicesound], 128);
4361 OPENAL_SetPaused(channels[clawslicesound], false);
4363 victim->DoBloodBig(2/victim->armorhead,175);
4376 //relative=victim->coords-oldcoords;
4379 Normalise(&relative);
4380 relative=DoRotation(relative,0,90,0);
4382 Normalise(&relative);
4383 for(i=0;i<victim->skeleton.num_joints;i++){
4384 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4386 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4387 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
4388 victim->DoDamage(damagemult*100/victim->protectionhead);
4392 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
4396 //relative=victim->coords-oldcoords;
4399 Normalise(&relative);
4400 relative=DoRotation(relative,0,90,0);
4402 Normalise(&relative);
4403 for(i=0;i<victim->skeleton.num_joints;i++){
4404 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
4406 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
4409 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
4410 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
4421 if(targetframe>animation[currentanimation].numframes-1){
4424 targetanimation=getIdle();
4428 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
4429 targetanimation=rollanim;
4440 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
4441 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
4442 OPENAL_SetVolume(channels[movewhooshsound], 128);
4443 OPENAL_SetPaused(channels[movewhooshsound], false);
4445 if(currentanimation==staggerbackhighanim){
4446 targetanimation=getIdle();
4448 if(currentanimation==staggerbackhardanim){
4449 targetanimation=getIdle();
4451 if(currentanimation==removeknifeanim){
4452 targetanimation=getIdle();
4454 if(currentanimation==crouchremoveknifeanim){
4455 targetanimation=getCrouch();
4457 if(currentanimation==backhandspringanim){
4458 targetanimation=getIdle();
4460 if(currentanimation==dodgebackanim){
4461 targetanimation=getIdle();
4463 if(currentanimation==drawleftanim){
4464 targetanimation=getIdle();
4466 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
4467 targetanimation=getIdle();
4468 if(currentanimation==crouchdrawrightanim){
4469 targetanimation=getCrouch();
4471 if(weaponactive==-1)weaponactive=0;
4472 else if(weaponactive==0){
4476 buffer=weaponids[0];
4477 weaponids[0]=weaponids[1];
4478 weaponids[1]=buffer;
4482 if(weaponactive==-1){
4492 PlaySoundEx( knifesheathesound, samp[knifesheathesound], NULL, true);
4493 OPENAL_3D_SetAttributes(channels[knifesheathesound], gLoc, vel);
4494 OPENAL_SetVolume(channels[knifesheathesound], 128);
4495 OPENAL_SetPaused(channels[knifesheathesound], false);
4497 if(weaponactive!=-1){
4507 PlaySoundEx( knifedrawsound, samp[knifedrawsound], NULL, true);
4508 OPENAL_3D_SetAttributes(channels[knifedrawsound], gLoc, vel);
4509 OPENAL_SetVolume(channels[knifedrawsound], 128);
4510 OPENAL_SetPaused(channels[knifedrawsound], false);
4513 if(currentanimation==rollanim){
4514 targetanimation=getCrouch();
4519 if(targetanimation==walljumprightkickanim){
4522 if(targetanimation==walljumpleftkickanim){
4525 targetanimation=jumpdownanim;
4527 if(currentanimation==climbanim){
4528 targetanimation=getCrouch();
4531 if(!isnormal(coords.x))
4542 if(targetanimation==rabbitkickreversalanim){
4543 targetanimation=getCrouch();
4546 if(targetanimation==jumpreversalanim){
4547 targetanimation=getCrouch();
4550 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
4551 if(attackkeydown&&targetanimation!=walljumpfrontanim){
4553 float closestdist=-1;
4556 for(i=0;i<numplayers;i++){
4557 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4558 distance=findDistancefast(&player[i].coords,&coords);
4559 if(closestdist==-1||distance<closestdist){
4560 closestdist=distance;
4565 if(closestdist>0&&closest>=0&&closestdist<16){
4566 victim=&player[closest];
4567 targetanimation=walljumprightkickanim;
4569 XYZ rotatetarget=victim->coords-coords;
4570 Normalise(&rotatetarget);
4571 rotation=-asin(0-rotatetarget.x);
4573 if(rotatetarget.z<0)rotation=180-rotation;
4574 targettilt2=-asin(rotatetarget.y)*360/6.28;
4575 velocity=(victim->coords-coords)*4;
4580 if(targetanimation==walljumpbackanim){
4581 targetanimation=backflipanim;
4585 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4587 if(targetanimation==walljumprightanim){
4588 targetanimation=rightflipanim;
4592 velocity=DoRotation(facing,0,30,0)*-8;
4595 if(targetanimation==walljumpfrontanim){
4596 targetanimation=frontflipanim;
4598 //targetrotation-=180;
4603 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4605 if(targetanimation==walljumpleftanim){
4608 float closestdist=-1;
4611 for(i=0;i<numplayers;i++){
4612 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
4613 distance=findDistancefast(&player[i].coords,&coords);
4614 if(closestdist==-1||distance<closestdist){
4615 closestdist=distance;
4620 if(closestdist>0&&closest>=0&&closestdist<16){
4621 victim=&player[closest];
4622 targetanimation=walljumpleftkickanim;
4624 XYZ rotatetarget=victim->coords-coords;
4625 Normalise(&rotatetarget);
4626 rotation=-asin(0-rotatetarget.x);
4628 if(rotatetarget.z<0)rotation=180-rotation;
4629 targettilt2=-asin(rotatetarget.y)*360/6.28;
4630 velocity=(victim->coords-coords)*4;
4635 if(targetanimation!=walljumpleftkickanim){
4636 targetanimation=leftflipanim;
4640 velocity=DoRotation(facing,0,-30,0)*-8;
4643 if(id==0)OPENAL_SetPaused(channels[whooshsound], false);
4645 if(targetanimation==sneakattackanim){
4646 float ycoords=oldcoords.y;
4647 currentanimation=getCrouch();
4648 targetanimation=getCrouch();
4651 targetrotation+=180;
4656 targetheadrotation+=180;
4658 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4662 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
4663 float ycoords=oldcoords.y;
4664 targetanimation=getIdle();
4666 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
4670 if(currentanimation==knifefollowanim){
4671 targetanimation=getIdle();
4674 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
4675 float ycoords=oldcoords.y;
4676 targetanimation=getStop();
4677 targetrotation+=180;
4682 targetheadrotation+=180;
4683 if(!isnormal(coords.x))
4685 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
4686 oldcoords=coords+facing*.5;
4687 else if(currentanimation==sweepreversalanim)
4688 oldcoords=coords+facing*1.1;
4689 else if(currentanimation==upunchreversalanim){
4690 oldcoords=coords+facing*1.5;
4691 targetrotation+=180;
4693 targetheadrotation+=180;
4697 else if(currentanimation==knifeslashreversalanim){
4698 oldcoords=coords+facing*.5;
4701 targetheadrotation+=90;
4705 else if(currentanimation==staffspinhitreversalanim){
4706 targetrotation+=180;
4708 targetheadrotation+=180;
4712 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
4713 else oldcoords.y=ycoords;
4714 currentoffset=coords-oldcoords;
4720 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
4725 if(animation[targetanimation].attack==reversed){
4727 if(targetanimation==sweepreversedanim)targetrotation+=90;
4728 targetanimation=backhandspringanim;
4738 PlaySoundEx( landsound, samp[landsound], NULL, true);
4739 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
4740 OPENAL_SetVolume(channels[landsound], 128);
4741 OPENAL_SetPaused(channels[landsound], false);
4743 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
4744 targetanimation=rollanim;
4747 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4748 coords.y=oldcoords.y;
4750 if(currentanimation==knifeslashreversedanim){
4751 targetanimation=rollanim;
4756 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4757 coords.y=oldcoords.y;
4761 targetanimation=jumpdownanim;
4763 if(wasLanding())targetanimation=getIdle();
4764 if(wasLandhard())targetanimation=getIdle();
4765 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
4766 targetanimation=getIdle();
4768 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
4769 coords.y=oldcoords.y;
4770 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
4771 targetoffset.y=coords.y;
4772 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
4773 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
4774 currentoffset.y-=(coords.y-targetoffset.y);
4775 coords.y=targetoffset.y;
4777 normalsupdatedelay=0;
4779 if(currentanimation==upunchanim){
4780 targetanimation=getStop();
4781 normalsupdatedelay=0;
4784 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
4785 targetrotation=rotation;
4788 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4789 if(!hasstaff)DoDamage(35);
4792 rabbitkickragdoll=1;
4794 if(currentanimation==rabbitkickreversedanim){
4801 if(id!=0)SolidHitBonus();
4805 targetanimation=rollanim;
4807 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4811 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
4817 if(currentanimation==jumpreversedanim){
4824 if(id!=0)SolidHitBonus();
4828 targetanimation=rollanim;
4830 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
4835 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){
4836 targetanimation=getupfromfrontanim;
4839 else if(animation[currentanimation].attack==normalattack){
4840 targetanimation=getIdle();
4843 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
4844 targetanimation=blockhighleftstrikeanim;
4846 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
4847 targetanimation=getIdle();
4850 if(currentanimation==spinkickanim&&victim->skeleton.free){
4851 if(creature==rabbittype)targetanimation=fightidleanim;
4856 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
4858 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
4859 targetanimation=jumpdownanim;
4864 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
4865 if(!isRun()||!wasRun()){
4866 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4867 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
4868 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4869 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
4871 if(isRun()&&wasRun()){
4874 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
4875 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
4878 else if(transspeed)target+=multiplier*transspeed*speed*2;
4880 if(!isRun()||!wasRun()){
4881 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
4882 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
4883 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
4884 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
4888 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
4890 if(target>1){currentframe=targetframe; target=1;}
4892 rot=targetrot*target;
4893 rotation+=rot-oldrot;
4899 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
4901 for(i=0;i<skeleton.num_joints;i++){
4902 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
4905 skeleton.FindForwards();
4907 for(i=0;i<skeleton.num_muscles;i++){
4908 if(skeleton.muscles[i].visible)
4910 skeleton.FindRotationMuscle(i,targetanimation);
4913 for(i=0;i<skeleton.num_muscles;i++){
4914 if(skeleton.muscles[i].visible)
4916 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4917 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4918 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4923 for(i=0;i<skeleton.num_joints;i++){
4924 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
4927 skeleton.FindForwards();
4929 for(i=0;i<skeleton.num_muscles;i++){
4930 if(skeleton.muscles[i].visible)
4932 skeleton.FindRotationMuscle(i,targetanimation);
4935 for(i=0;i<skeleton.num_muscles;i++){
4936 if(skeleton.muscles[i].visible)
4938 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
4939 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
4940 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
4941 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
4942 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
4943 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
4944 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
4945 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
4946 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
4950 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
4952 oldcurrentanimation=currentanimation;
4953 oldtargetanimation=targetanimation;
4954 oldtargetframe=targetframe;
4955 oldcurrentframe=currentframe;
4957 for(i=0;i<skeleton.num_joints;i++){
4958 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
4959 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
4961 offset=currentoffset*(1-target)+targetoffset*target;
4962 for(i=0;i<skeleton.num_muscles;i++){
4963 if(skeleton.muscles[i].visible)
4965 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
4966 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
4967 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
4972 if(isLanding()&&landhard){
4973 //if(abs(velocity.y)>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z)){
4974 if(id==0)camerashake+=.4;
4975 targetanimation=getLandhard();
4983 //skeleton.DoConstraints();
4986 void Person::DoStuff(){
4987 static XYZ terrainnormal;
4988 static XYZ flatfacing;
4989 static XYZ flatvelocity;
4990 static float flatvelspeed;
4994 static int bloodsize;
4995 static int startx,starty,endx,endy;
4996 static int texdetailint;
4997 static GLubyte color;
4998 static XYZ bloodvel;
5000 onfiredelay-=multiplier;
5001 if(onfiredelay<0&&onfire)
5009 crouchkeydowntime+=multiplier;
5010 if(!crouchkeydown)crouchkeydowntime=0;
5011 jumpkeydowntime+=multiplier;
5012 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
5014 if(hostile||damage>0||bloodloss>0)immobile=0;
5016 if(isIdle()||isRun())targetoffset=0;
5018 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
5020 if(id==0)blooddimamount-=multiplier*.3;
5021 speechdelay-=multiplier;
5022 texupdatedelay-=multiplier;
5023 interestdelay-=multiplier;
5024 flamedelay-=multiplier;
5025 parriedrecently-=multiplier;
5031 if(id==0)speed=1.1*speedmult;
5032 else speed=1.0*speedmult;
5033 if(!skeleton.free)rabbitkickragdoll=0;
5037 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
5038 if(id!=0&&creature==wolftype&&difficulty==2){
5040 if(aitype!=passivetype){
5042 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){
5046 if(scale<0.2)superruntoggle=0;
5047 if(targetanimation==wolfrunninganim&&!superruntoggle){
5048 targetanimation=getRun();
5052 if(weaponactive==-1&&num_weapons>0){
5053 if(weapons.type[weaponids[0]]==staff){
5060 /*if(aitype!=playercontrolled)*///deathbleeding=5;
5061 /*if(aitype!=playercontrolled)*/
5063 if(burnt>.6)burnt=.6;
5064 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
5066 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5077 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
5078 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
5082 while(flamedelay<0&&onfire){
5084 howmany=abs(Random()%(skeleton.num_joints));
5085 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
5086 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
5087 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
5088 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
5089 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
5092 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
5094 howmany=abs(Random()%(skeleton.num_joints));
5095 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
5096 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
5097 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
5098 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
5099 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
5103 bleeding-=multiplier*.3;
5105 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5106 if(bleeding<=0&&(detail!=2||osx))DoMipmaps(5,0,0,skeleton.skinsize,skeleton.skinsize);
5110 if(neckspurtamount>0){
5111 neckspurtamount-=multiplier;
5112 neckspurtdelay-=multiplier*3;
5113 neckspurtparticledelay-=multiplier*3;
5114 if(neckspurtparticledelay<0&&neckspurtdelay>2){
5118 bloodvel.z=5*neckspurtamount;
5119 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
5122 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
5124 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
5125 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
5126 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);
5127 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);
5128 neckspurtparticledelay=.05;
5130 if(neckspurtdelay<0){
5135 if(deathbleeding>0&&dead!=2){
5136 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
5137 else bleeddelay-=5*multiplier/4;
5138 if(bleeddelay<0&&bloodtoggle){
5143 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
5144 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
5145 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
5146 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);
5149 bloodloss+=deathbleeding*multiplier*80;
5150 deathbleeding-=multiplier*1.6;
5151 //if(id==0)deathbleeding-=multiplier*.2;
5152 if(deathbleeding<0)deathbleeding=0;
5153 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
5154 if(weaponactive!=-1){
5155 weapons.owner[weaponids[0]]=-1;
5156 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5157 weapons.velocity[weaponids[0]].x+=.01;
5158 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5159 weapons.missed[weaponids[0]]=1;
5160 weapons.hitsomething[weaponids[0]]=0;
5161 weapons.freetime[weaponids[0]]=0;
5162 weapons.firstfree[weaponids[0]]=1;
5163 weapons.physics[weaponids[0]]=1;
5166 weaponids[0]=weaponids[num_weapons];
5167 if(weaponstuck==num_weapons)weaponstuck=0;
5170 for(i=0;i<numplayers;i++){
5171 player[i].wentforweapon=0;
5183 if(!dead&&creature==wolftype){
5189 if(targetanimation==knifefollowedanim&&!skeleton.free){
5190 for(i=0;i<skeleton.num_joints;i++){
5191 skeleton.joints[i].velocity=0;
5192 skeleton.joints[i].velocity.y=-2;
5195 if(id!=0&&unconscioustime>.1){
5203 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
5206 bloodsize=5-realtexdetail;
5210 texdetailint=realtexdetail;
5211 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5212 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
5213 endx=startx+bloodsize;
5214 endy=starty+bloodsize;
5216 if(startx<0){startx=0;bleeding=0;}
5217 if(starty<0){starty=0;bleeding=0;}
5218 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
5219 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
5220 if(endx<startx)endx=startx;
5221 if(endy<starty)endy=starty;
5223 for(i=startx;i<endx;i++){
5224 for(j=starty;j<endy;j++){
5226 color=Random()%85+170;
5227 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
5228 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
5229 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
5234 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
5235 DoMipmaps(0,startx,endx,starty,endy);
5239 bleedy-=4/realtexdetail;
5240 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
5241 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
5244 bleedx+=4*direction/realtexdetail;
5245 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
5246 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
5250 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
5251 righthandmorphness=targetrighthandmorphness;
5252 righthandmorphstart=righthandmorphend;
5254 else if(righthandmorphness>targetrighthandmorphness){
5255 righthandmorphness-=multiplier*4;
5257 else if(righthandmorphness<targetrighthandmorphness){
5258 righthandmorphness+=multiplier*4;
5261 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
5262 lefthandmorphness=targetlefthandmorphness;
5263 lefthandmorphstart=lefthandmorphend;
5265 else if(lefthandmorphness>targetlefthandmorphness){
5266 lefthandmorphness-=multiplier*4;
5268 else if(lefthandmorphness<targetlefthandmorphness){
5269 lefthandmorphness+=multiplier*4;
5272 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
5273 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
5274 tailmorphness=targettailmorphness;
5275 tailmorphstart=tailmorphend;
5277 else if(tailmorphness>targettailmorphness){
5278 tailmorphness-=multiplier*10;
5280 else if(tailmorphness<targettailmorphness){
5281 tailmorphness+=multiplier*10;
5285 if(creature==wolftype){
5286 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
5287 tailmorphness=targettailmorphness;
5288 tailmorphstart=tailmorphend;
5290 else if(tailmorphness>targettailmorphness){
5291 tailmorphness-=multiplier*2;
5293 else if(tailmorphness<targettailmorphness){
5294 tailmorphness+=multiplier*2;
5298 if(headmorphend==3||headmorphstart==3){
5299 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
5300 headmorphness=targetheadmorphness;
5301 headmorphstart=headmorphend;
5303 else if(headmorphness>targetheadmorphness){
5304 headmorphness-=multiplier*7;
5306 else if(headmorphness<targetheadmorphness){
5307 headmorphness+=multiplier*7;
5310 else if(headmorphend==5||headmorphstart==5){
5311 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
5312 headmorphness=targetheadmorphness;
5313 headmorphstart=headmorphend;
5315 else if(headmorphness>targetheadmorphness){
5316 headmorphness-=multiplier*10;
5318 else if(headmorphness<targetheadmorphness){
5319 headmorphness+=multiplier*10;
5323 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
5324 headmorphness=targetheadmorphness;
5325 headmorphstart=headmorphend;
5327 else if(headmorphness>targetheadmorphness){
5328 headmorphness-=multiplier*4;
5330 else if(headmorphness<targetheadmorphness){
5331 headmorphness+=multiplier*4;
5335 if(abs(chestmorphness-targetchestmorphness)<multiplier){
5336 chestmorphness=targetchestmorphness;
5337 chestmorphstart=chestmorphend;
5339 else if(chestmorphness>targetchestmorphness){
5340 chestmorphness-=multiplier;
5342 else if(chestmorphness<targetchestmorphness){
5343 chestmorphness+=multiplier;
5346 if(dead!=2&&howactive<=typesleeping){
5347 if(chestmorphstart==0&&chestmorphend==0){
5349 targetchestmorphness=1;
5352 if(chestmorphstart!=0&&chestmorphend!=0){
5354 targetchestmorphness=1;
5356 if(environment==snowyenvironment){
5359 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
5360 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
5361 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
5362 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
5363 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
5364 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
5368 if(!dead&&howactive<typesleeping){
5369 blinkdelay-=multiplier*2;
5370 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
5372 targetheadmorphness=1;
5374 blinkdelay=(float)(abs(Random()%40))/5;
5376 if(headmorphstart==3&&headmorphend==3){
5378 targetheadmorphness=1;
5383 twitchdelay-=multiplier*1.5;
5384 if(targetanimation!=hurtidleanim){
5385 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
5387 targetheadmorphness=1;
5389 twitchdelay=(float)(abs(Random()%40))/5;
5391 if(headmorphstart==5&&headmorphend==5){
5393 targetheadmorphness=1;
5397 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
5398 twitchdelay3-=multiplier*1;
5400 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
5401 righthandmorphness=0;
5402 targetrighthandmorphness=1;
5403 righthandmorphend=1;
5404 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
5406 if(righthandmorphstart==1&&righthandmorphend==1){
5407 righthandmorphness=0;
5408 targetrighthandmorphness=1;
5409 righthandmorphend=0;
5413 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
5414 lefthandmorphness=0;
5415 targetlefthandmorphness=1;
5417 twitchdelay3=(float)(abs(Random()%40))/5;
5419 if(lefthandmorphstart==1&&lefthandmorphend==1){
5420 lefthandmorphness=0;
5421 targetlefthandmorphness=1;
5428 if(creature==rabbittype){
5429 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
5430 else twitchdelay2-=multiplier*0.5;
5431 if(howactive<=typesleeping){
5432 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
5434 targettailmorphness=1;
5436 twitchdelay2=(float)(abs(Random()%40))/5;
5438 if(tailmorphstart==1&&tailmorphend==1){
5440 targettailmorphness=1;
5443 if(tailmorphstart==2&&tailmorphend==2){
5445 targettailmorphness=1;
5452 if(creature==wolftype){
5453 twitchdelay2-=multiplier*1.5;
5455 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
5457 targettailmorphness=1;
5462 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
5464 targettailmorphness=1;
5468 if(twitchdelay2<=0){
5469 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
5471 targettailmorphness=1;
5474 if(tailmorphstart==1&&tailmorphend==1){
5476 targettailmorphness=1;
5479 if(tailmorphstart==2&&tailmorphend==2){
5481 targettailmorphness=1;
5484 if(tailmorphstart==3&&tailmorphend==3){
5486 targettailmorphness=1;
5489 if(tailmorphstart==4&&tailmorphend==4){
5491 targettailmorphness=1;
5497 if(dead!=1)unconscioustime=0;
5499 if(dead==1||howactive==typesleeping){
5500 unconscioustime+=multiplier;
5501 //If unconscious, close eyes and 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)headmorphness=0;
5512 targetheadmorphness=1;
5516 if(howactive>typesleeping){
5519 if(bloodtoggle&&!bled){
5520 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5522 if(bloodtoggle&&!bled)
5523 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5524 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5525 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5529 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5534 if(dead==2||howactive>typesleeping){
5535 //If dead, open mouth and hands
5536 if(righthandmorphend!=0)righthandmorphness=0;
5537 righthandmorphend=0;
5538 targetrighthandmorphness=1;
5540 if(lefthandmorphend!=0)lefthandmorphness=0;
5542 targetlefthandmorphness=1;
5544 if(headmorphend!=2)headmorphness=0;
5546 targetheadmorphness=1;
5549 if(stunned>0&&!dead&&headmorphend!=2){
5550 if(headmorphend!=4)headmorphness=0;
5552 targetheadmorphness=1;
5555 if(damage>damagetolerance&&!dead){
5560 if(creature==wolftype){
5568 if(weaponactive!=-1){
5569 weapons.owner[weaponids[0]]=-1;
5570 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5571 weapons.velocity[weaponids[0]].x+=.01;
5572 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5573 weapons.missed[weaponids[0]]=1;
5574 weapons.hitsomething[weaponids[0]]=0;
5575 weapons.freetime[weaponids[0]]=0;
5576 weapons.firstfree[weaponids[0]]=1;
5577 weapons.physics[weaponids[0]]=1;
5580 weaponids[0]=weaponids[num_weapons];
5581 if(weaponstuck==num_weapons)weaponstuck=0;
5584 for(i=0;i<numplayers;i++){
5585 player[i].wentforweapon=0;
5591 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
5599 //if(dead)damage-=multiplier/4;
5600 if(!dead)damage-=multiplier*13;
5601 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5602 if(!dead)permanentdamage-=multiplier*4;
5603 if(isIdle()||isCrouch()){
5604 if(!dead)permanentdamage-=multiplier*4;
5605 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
5607 if(damage<0)damage=0;
5608 if(permanentdamage<0)permanentdamage=0;
5609 if(superpermanentdamage<0)superpermanentdamage=0;
5610 if(permanentdamage<superpermanentdamage){
5611 permanentdamage=superpermanentdamage;
5613 if(damage<permanentdamage){
5614 damage=permanentdamage;
5616 if(dead==1&&damage<damagetolerance){
5620 for(i=0;i<skeleton.num_joints;i++){
5621 skeleton.joints[i].velocity=0;
5624 if(permanentdamage>damagetolerance&&dead!=2){
5627 if(weaponactive!=-1){
5628 weapons.owner[weaponids[0]]=-1;
5629 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
5630 weapons.velocity[weaponids[0]].x+=.01;
5631 weapons.tipvelocity[weaponids[0]]=velocity*scale;
5632 weapons.missed[weaponids[0]]=1;
5633 weapons.hitsomething[weaponids[0]]=0;
5634 weapons.freetime[weaponids[0]]=0;
5635 weapons.firstfree[weaponids[0]]=1;
5636 weapons.physics[weaponids[0]]=1;
5639 weaponids[0]=weaponids[num_weapons];
5640 if(weaponstuck==num_weapons)weaponstuck=0;
5643 for(i=0;i<numplayers;i++){
5644 player[i].wentforweapon=0;
5650 if(!dead&&creature==wolftype){
5656 if(id!=0&&unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance){
5661 if(id!=0&&unconscioustime>.1){
5677 PlaySoundEx( breaksound, samp[breaksound], NULL, true);
5678 OPENAL_3D_SetAttributes(channels[breaksound], gLoc, vel);
5679 OPENAL_SetVolume(channels[breaksound], 512);
5680 OPENAL_SetPaused(channels[breaksound], false);
5681 /*if(id==0||findDistancefast(&coords,&viewer)<50){
5687 if(skeleton.free==1){
5688 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5691 //If knocked over, open hands and close mouth
5692 if(righthandmorphend!=0)righthandmorphness=0;
5693 righthandmorphend=0;
5694 targetrighthandmorphness=1;
5696 if(lefthandmorphend!=0)lefthandmorphness=0;
5698 targetlefthandmorphness=1;
5700 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
5701 if(headmorphend!=0)headmorphness=0;
5703 targetheadmorphness=1;
5707 skeleton.DoGravity(&scale);
5709 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
5710 if(id!=0&&damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1)){
5715 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
5719 for(j=0;j<skeleton.num_joints;j++){
5720 average+=skeleton.joints[j].position;
5724 coords+=average*scale;
5725 for(j=0;j<skeleton.num_joints;j++){
5726 skeleton.joints[j].position-=average;
5728 average/=multiplier;
5730 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
5732 for(i=0;i<skeleton.num_joints;i++){
5733 velocity+=skeleton.joints[i].velocity*scale;
5735 velocity/=skeleton.num_joints;
5737 if(!isnormal(velocity.x)&&velocity.x){
5750 if(findLength(&average)<10&&dead&&skeleton.free){
5751 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5752 if(skeleton.longdead>2000){
5753 if(skeleton.longdead>6000){
5754 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5759 if(dead==2&&bloodloss<damagetolerance){
5761 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5763 if(bloodtoggle&&!bled){
5764 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
5766 if(bloodtoggle&&!bled)
5767 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5768 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5769 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5773 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
5777 if(dead==2&&bloodloss>=damagetolerance){
5779 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
5780 if(bleeding<=0)DoBlood(1,255);
5781 if(bloodtoggle&&!bled){
5782 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
5784 if(bloodtoggle&&!bled)
5785 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
5786 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
5787 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
5791 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
5798 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
5800 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
5804 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
5805 if(velocity.y<-30)canrecover=0;
5806 for(i=0;i<objects.numobjects;i++){
5807 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
5808 colviewer=startpoint;
5810 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
5818 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5819 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5820 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5821 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5823 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5824 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5825 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5827 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5828 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5829 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5831 Normalise(&terrainnormal);
5833 targetrotation=-asin(0-terrainnormal.x);
5834 targetrotation*=360/6.28;
5835 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5836 rotation=targetrotation;
5838 //if(skeleton.forward.y<0){
5841 //if(skeleton.forward.y>-.3){
5844 targetanimation=flipanim;
5845 crouchtogglekeydown=1;
5850 currentanimation=tempanim;
5853 //tilt2=targettilt2;
5855 //if(middle.y>0)targetoffset.y=middle.y+1;
5857 for(i=0;i<skeleton.num_joints;i++){
5858 tempanimation.position[i][0]=skeleton.joints[i].position;
5859 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5864 if(findLength(&average)<10&&!dead&&skeleton.free){
5865 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
5866 if(skeleton.longdead>(damage+500)*1.5){
5867 if(id==0)OPENAL_SetPaused(channels[whooshsound], true);
5873 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5874 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
5875 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
5876 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5878 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5879 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5880 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
5882 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
5883 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
5884 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
5886 Normalise(&terrainnormal);
5888 targetrotation=-asin(0-terrainnormal.x);
5889 targetrotation*=360/6.28;
5890 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5891 rotation=targetrotation;
5894 terrainnormal=terrain.getNormal(coords.x,coords.z);
5895 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5899 /*XYZ otherterrainnormal;
5900 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
5901 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5902 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
5903 targettilt2=asin(otherterrainnormal.y)*180/3.14;
5906 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
5910 if(skeleton.forward.y<0){
5911 targetanimation=getupfrombackanim;
5915 if(skeleton.forward.y>-.3){
5916 targetanimation=getupfromfrontanim;
5918 targetrotation+=180;
5924 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
5925 targetanimation=rollanim;
5926 targetrotation=lookrotation;
5930 if(forwardkeydown)targetrotation+=45;
5931 if(backkeydown)targetrotation-=45;
5935 if(forwardkeydown)targetrotation-=45;
5936 if(backkeydown)targetrotation+=45;
5939 if ( !leftkeydown&&!rightkeydown)
5940 targetrotation+=180;
5942 targetrotation+=180;
5946 if(abs(targettilt2)>50)targettilt2=0;
5947 currentanimation=tempanim;
5952 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
5954 for(i=0;i<skeleton.num_joints;i++){
5955 tempanimation.position[i][0]=skeleton.joints[i].position;
5956 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
5963 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
5964 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
5967 tempvelocity=velocity;
5968 Normalise(&tempvelocity);
5969 targetrotation=-asin(0-tempvelocity.x);
5970 targetrotation*=360/6.28;
5971 if(velocity.z<0)targetrotation=180-targetrotation;
5972 //targetrotation+=180;
5975 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
5976 targetanimation=rollanim;
5980 targetanimation=backhandspringanim;
5981 targetrotation+=180;
5994 PlaySoundEx( movewhooshsound, samp[movewhooshsound], NULL, true);
5995 OPENAL_3D_SetAttributes(channels[movewhooshsound], gLoc, vel);
5996 OPENAL_SetVolume(channels[movewhooshsound], 128);
5997 OPENAL_SetPaused(channels[movewhooshsound], false);
5999 currentanimation=targetanimation;
6000 currentframe=targetframe-1;
6005 rotation=targetrotation;
6012 if(skeleton.freefall==0)freefall=0;
6014 if(!isnormal(velocity.x)&&velocity.x){
6019 if(aitype!=passivetype||skeleton.free==1)
6020 if(findLengthfast(&velocity)>.1)
6021 for(i=0;i<objects.numobjects;i++){
6022 if(objects.type[i]==firetype)
6023 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){
6025 if(!objects.onfire[i]){
6028 gLoc[0]=objects.position[i].x;
6029 gLoc[1]=objects.position[i].y;
6030 gLoc[2]=objects.position[i].z;
6034 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
6035 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6036 OPENAL_SetVolume(channels[firestartsound], 256);
6037 OPENAL_SetPaused(channels[firestartsound], false);
6039 objects.onfire[i]=1;
6042 if(objects.onfire[i]){
6047 if(objects.type[i]==bushtype)
6048 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){
6050 if(!objects.onfire[i]){
6053 gLoc[0]=objects.position[i].x;
6054 gLoc[1]=objects.position[i].y;
6055 gLoc[2]=objects.position[i].z;
6059 PlaySoundEx( firestartsound, samp[firestartsound], NULL, true);
6060 OPENAL_3D_SetAttributes(channels[firestartsound], gLoc, vel);
6061 OPENAL_SetVolume(channels[firestartsound], 256);
6062 OPENAL_SetPaused(channels[firestartsound], false);
6064 objects.onfire[i]=1;
6068 if(objects.onfire[i]){
6072 if(objects.messedwith[i]<=0){
6084 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
6085 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
6086 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
6087 OPENAL_SetPaused(channels[bushrustle], false);
6090 envsound[numenvsounds]=coords;
6091 envsoundvol[numenvsounds]=4*findLength(&velocity);
6092 envsoundlife[numenvsounds]=.4;
6097 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6098 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6100 if(environment!=desertenvironment)
6101 for(j=0;j<howmany;j++){
6102 tempvel.x=float(abs(Random()%100)-50)/20;
6103 tempvel.y=float(abs(Random()%100)-50)/20;
6104 tempvel.z=float(abs(Random()%100)-50)/20;
6107 pos.x+=float(abs(Random()%100)-50)/200;
6108 pos.y+=float(abs(Random()%100)-50)/200;
6109 pos.z+=float(abs(Random()%100)-50)/200;
6110 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);
6111 Sprite::setLastSpriteSpecial(1);
6113 howmany=findLength(&velocity)*4;
6115 if(environment==snowyenvironment)
6116 for(j=0;j<howmany;j++){
6117 tempvel.x=float(abs(Random()%100)-50)/20;
6118 tempvel.y=float(abs(Random()%100)-50)/20;
6119 tempvel.z=float(abs(Random()%100)-50)/20;
6122 pos.x+=float(abs(Random()%100)-50)/200;
6123 pos.y+=float(abs(Random()%100)-50)/200;
6124 pos.z+=float(abs(Random()%100)-50)/200;
6125 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6126 Sprite::setLastSpriteSpecial(2);
6129 objects.rotx[i]+=velocity.x*multiplier*6;
6130 objects.roty[i]+=velocity.z*multiplier*6;
6131 objects.messedwith[i]=.5;
6134 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
6135 if(objects.rotation2[i]==0)tempcoord=coords;
6137 tempcoord=coords-objects.position[i];
6138 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
6139 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
6140 tempcoord+=objects.position[i];
6142 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]){
6143 if(objects.messedwith[i]<=0){
6155 PlaySoundEx( bushrustle, samp[bushrustle], NULL, true);
6156 OPENAL_3D_SetAttributes(channels[bushrustle], gLoc, vel);
6157 OPENAL_SetVolume(channels[bushrustle], 40*findLength(&velocity));
6158 OPENAL_SetPaused(channels[bushrustle], false);
6161 envsound[numenvsounds]=coords;
6162 envsoundvol[numenvsounds]=4*findLength(&velocity);
6163 envsoundlife[numenvsounds]=.4;
6168 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
6169 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
6171 if(environment!=desertenvironment)
6172 for(j=0;j<howmany;j++){
6173 tempvel.x=float(abs(Random()%100)-50)/20;
6174 tempvel.y=float(abs(Random()%100)-50)/20;
6175 tempvel.z=float(abs(Random()%100)-50)/20;
6179 pos.x+=float(abs(Random()%100)-50)/150;
6180 pos.y+=float(abs(Random()%100)-50)/150;
6181 pos.z+=float(abs(Random()%100)-50)/150;
6182 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);
6183 Sprite::setLastSpriteSpecial(1);
6185 howmany=findLength(&velocity)*4;
6187 if(environment==snowyenvironment)
6188 for(j=0;j<howmany;j++){
6189 tempvel.x=float(abs(Random()%100)-50)/20;
6190 tempvel.y=float(abs(Random()%100)-50)/20;
6191 tempvel.z=float(abs(Random()%100)-50)/20;
6195 pos.x+=float(abs(Random()%100)-50)/150;
6196 pos.y+=float(abs(Random()%100)-50)/150;
6197 pos.z+=float(abs(Random()%100)-50)/150;
6198 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
6199 Sprite::setLastSpriteSpecial(2);
6202 objects.messedwith[i]=.5;
6210 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
6212 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
6213 if(tutoriallevel==1&&id!=0)play=0;
6214 if(play&&aitype!=playercontrolled){
6226 if(creature==rabbittype){
6227 if(i==0)whichsound=rabbitchitter;
6228 if(i==1)whichsound=rabbitchitter2;
6230 if(creature==wolftype){
6231 if(i==0)whichsound=growlsound;
6232 if(i==1)whichsound=growl2sound;
6238 PlaySoundEx( whichsound, samp[whichsound], NULL, true);
6239 OPENAL_3D_SetAttributes(channels[whichsound], gLoc, vel);
6240 OPENAL_SetVolume(channels[whichsound], 512);
6241 OPENAL_SetPaused(channels[whichsound], false);
6245 if(targetanimation==staggerbackhighanim)staggerdelay=1;
6246 if(targetanimation==staggerbackhardanim)staggerdelay=1;
6247 staggerdelay-=multiplier;
6248 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
6249 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
6250 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
6251 targetanimation=getIdle();
6255 weaponmissdelay-=multiplier;
6256 highreversaldelay-=multiplier;
6257 lowreversaldelay-=multiplier;
6258 lastcollide-=multiplier;
6259 skiddelay-=multiplier;
6260 if(!isnormal(velocity.x)&&velocity.x){
6263 if(!isnormal(targettilt)&&targettilt){
6266 if(!isnormal(targettilt2)&&targettilt2){
6269 if(!isnormal(targetrotation)&&targetrotation){
6273 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
6274 //open hands and close mouth
6275 //if(targetanimation!=wolfidle){
6276 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6277 righthandmorphness=0;
6278 righthandmorphend=0;
6279 targetrighthandmorphness=1;
6282 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6283 lefthandmorphness=0;
6285 targetlefthandmorphness=1;
6289 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
6292 targetheadmorphness=1;
6296 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){
6297 //open hands and mouth
6298 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
6299 righthandmorphness=0;
6300 righthandmorphend=0;
6301 targetrighthandmorphness=1;
6304 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
6305 lefthandmorphness=0;
6307 targetlefthandmorphness=1;
6310 if(headmorphend!=1&&headmorphness==targetheadmorphness){
6313 targetheadmorphness=1;
6317 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
6318 //close hands and mouth
6319 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6320 righthandmorphness=0;
6321 righthandmorphend=1;
6322 targetrighthandmorphness=1;
6325 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6326 lefthandmorphness=0;
6328 targetlefthandmorphness=1;
6331 if(headmorphend!=0&&headmorphness==targetheadmorphness){
6334 targetheadmorphness=1;
6338 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){
6339 //close hands and yell
6340 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
6341 righthandmorphness=0;
6342 righthandmorphend=1;
6343 targetrighthandmorphness=1;
6346 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
6347 lefthandmorphness=0;
6349 targetlefthandmorphness=1;
6352 if(headmorphend!=2&&headmorphness==targetheadmorphness){
6355 targetheadmorphness=1;
6359 if(speechdelay>.25){
6360 if(headmorphend!=2)headmorphness=0;
6362 targetheadmorphness=1;
6368 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
6369 behind=(normaldotproduct(facing,coords-victim->coords)>0);
6373 if(!dead&&targetanimation!=hurtidleanim)
6374 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
6375 if(headmorphend!=4||headmorphness==targetheadmorphness){
6378 targetheadmorphness=1;
6382 if(weaponactive!=-1){
6383 if(weapons.type[weaponids[weaponactive]]!=staff){
6384 righthandmorphstart=1;
6385 righthandmorphend=1;
6387 if(weapons.type[weaponids[weaponactive]]==staff){
6388 righthandmorphstart=2;
6389 righthandmorphend=2;
6391 targetrighthandmorphness=1;
6394 terrainnormal=terrain.getNormal(coords.x,coords.z);
6396 if(animation[targetanimation].attack!=reversal){
6397 if(!isnormal(coords.x))
6405 flatfacing=DoRotation(flatfacing,0,rotation,0);
6407 ReflectVector(&facing,terrainnormal);
6410 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
6411 if(onterrain)targettilt2=-facing.y*20;
6415 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
6416 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6417 flatvelocity=velocity;
6419 flatvelspeed=findLength(&flatvelocity);
6420 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
6421 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
6422 if(velocity.y<0)targettilt2*=-1;
6423 if(velocity.y<0)targettilt*=-1;
6424 if(targettilt>25)targettilt=25;
6425 if(targettilt<-25)targettilt=-25;
6428 if(targettilt2>45)targettilt2=45;
6429 if(targettilt2<-45)targettilt2=-45;
6430 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
6431 else if(tilt2>targettilt2){
6432 tilt2-=multiplier*400;
6434 else if(tilt2<targettilt2){
6435 tilt2+=multiplier*400;
6437 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
6438 if(tilt2>25)tilt2=25;
6439 if(tilt2<-25)tilt2=-25;
6442 if(!isnormal(targettilt)&&targettilt){
6445 if(!isnormal(targettilt2)&&targettilt2){
6450 //if(!creature==wolftype||targetanimation==rabbitkickanim)
6451 if(targetanimation==rabbittackleanim){
6452 velocity+=facing*multiplier*speed*700*scale;
6453 velspeed=findLength(&velocity);
6454 if(velspeed>speed*65*scale){
6456 velspeed=speed*65*scale;
6459 velocity.y+=gravity*multiplier*20;
6460 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6461 velspeed=findLength(&velocity);
6462 velocity=flatfacing*velspeed;
6464 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
6465 if(isRun()||targetanimation==rabbitkickanim){
6466 velocity+=facing*multiplier*speed*700*scale;
6467 velspeed=findLength(&velocity);
6468 if(velspeed>speed*45*scale){
6470 velspeed=speed*45*scale;
6473 velocity.y+=gravity*multiplier*20;
6474 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6475 velspeed=findLength(&velocity);
6476 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
6477 velocity=flatfacing*velspeed;
6481 velocity+=facing*multiplier*speed*700*scale;
6482 velspeed=findLength(&velocity);
6483 if(creature==rabbittype){
6484 if(velspeed>speed*55*scale){
6486 velspeed=speed*55*scale;
6490 if(creature==wolftype){
6491 if(velspeed>speed*75*scale){
6493 velspeed=speed*75*scale;
6497 velocity.y+=gravity*multiplier*20;
6498 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6499 velspeed=findLength(&velocity);
6500 velocity=flatfacing*velspeed;
6503 /*if(creature==wolftype)
6505 velocity+=facing*multiplier*speed*700*scale;
6506 velspeed=findLength(&velocity);
6507 if(velspeed>speed*55*scale){
6509 velspeed=speed*55*scale;
6512 velocity.y+=gravity*multiplier*20;
6513 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6514 velspeed=findLength(&velocity);
6515 velocity=flatfacing*velspeed;
6518 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
6519 velocity+=facing*multiplier*speed*700*scale;
6520 velspeed=findLength(&velocity);
6521 if(velspeed>speed*45*scale){
6523 velspeed=speed*45*scale;
6526 velocity.y+=gravity*multiplier*20;
6527 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6528 velspeed=findLength(&velocity);
6529 velocity=flatfacing*velspeed;
6533 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
6534 velocity+=facing*multiplier*speed*700*scale;
6535 velspeed=findLength(&velocity);
6536 if(velspeed>speed*25*scale){
6538 velspeed=speed*25*scale;
6541 velocity.y+=gravity*multiplier*20;
6542 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6543 velspeed=findLength(&velocity);
6544 velocity=flatfacing*velspeed;
6547 if(targetanimation==sneakanim||targetanimation==walkanim){
6548 velocity+=facing*multiplier*speed*700*scale;
6549 velspeed=findLength(&velocity);
6550 if(velspeed>speed*12*scale){
6552 velspeed=speed*12*scale;
6555 velocity.y+=gravity*multiplier*20;
6556 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6557 velspeed=findLength(&velocity);
6558 velocity=flatfacing*velspeed;
6561 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
6562 velocity+=facing*multiplier*speed*700*scale;
6563 velspeed=findLength(&velocity);
6564 if(velspeed>speed*2*scale){
6566 velspeed=speed*2*scale;
6569 velocity.y+=gravity*multiplier*20;
6570 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6571 velspeed=findLength(&velocity);
6572 velocity=flatfacing*velspeed;
6576 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
6577 velocity-=facing*multiplier*speed*700*scale;
6578 velspeed=findLength(&velocity);
6579 if(velspeed>speed*2*scale){
6581 velspeed=speed*2*scale;
6584 velocity.y+=gravity*multiplier*20;
6585 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6586 velspeed=findLength(&velocity);
6587 velocity=flatfacing*velspeed*-1;
6590 if(targetanimation==fightsidestep){
6591 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
6592 velspeed=findLength(&velocity);
6593 if(velspeed>speed*12*scale){
6595 velspeed=speed*12*scale;
6598 velocity.y+=gravity*multiplier*20;
6599 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6600 velspeed=findLength(&velocity);
6601 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
6604 if(targetanimation==staggerbackhighanim){
6605 coords-=facing*multiplier*speed*16*scale;
6608 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
6609 coords-=facing*multiplier*speed*20*scale;
6613 if(targetanimation==backhandspringanim){
6614 //coords-=facing*multiplier*50*scale;
6615 velocity+=facing*multiplier*speed*700*scale*-1;
6616 velspeed=findLength(&velocity);
6617 if(velspeed>speed*50*scale){
6619 velspeed=speed*50*scale;
6622 velocity.y+=gravity*multiplier*20;
6623 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6624 velspeed=findLength(&velocity);
6625 velocity=flatfacing*velspeed*-1;
6627 if(targetanimation==dodgebackanim){
6628 //coords-=facing*multiplier*50*scale;
6629 velocity+=facing*multiplier*speed*700*scale*-1;
6630 velspeed=findLength(&velocity);
6631 if(velspeed>speed*60*scale){
6633 velspeed=speed*60*scale;
6636 velocity.y+=gravity*multiplier*20;
6637 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
6638 velspeed=findLength(&velocity);
6639 velocity=flatfacing*velspeed*-1;
6642 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6643 velspeed=findLength(&velocity);
6647 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
6648 velocity.y+=gravity*multiplier;
6651 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
6653 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6654 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
6656 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6662 OPENAL_SetPaused(channels[whooshsound], true);
6663 OPENAL_SetVolume(channels[whooshsound], 0);
6666 if(targetanimation==jumpdownanim||isFlip()){
6667 if(isFlip())jumppower=-4;
6668 targetanimation=getLanding();
6677 PlaySoundEx( landsound, samp[landsound], NULL, true);
6678 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
6679 OPENAL_SetVolume(channels[landsound], 128);
6680 OPENAL_SetPaused(channels[landsound], false);
6683 envsound[numenvsounds]=coords;
6684 envsoundvol[numenvsounds]=16;
6685 envsoundlife[numenvsounds]=.4;
6691 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
6692 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
6693 coords.y=terrain.getHeight(coords.x,coords.z);
6698 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)){
6699 velspeed=findLength(&velocity);
6701 if(velspeed<multiplier*300*scale){
6703 } else velocity-=velocity/velspeed*multiplier*300*scale;
6704 if(velspeed>5&&(isLanding()||isLandhard())){
6705 skiddingdelay+=multiplier;
6712 else skiddingdelay=0;
6716 velspeed=findLength(&velocity);
6718 if(velspeed<multiplier*600*scale){
6720 } else velocity-=velocity/velspeed*multiplier*600*scale;
6722 if(velspeed>5&&(isLanding()||isLandhard())){
6723 skiddingdelay+=multiplier;
6730 else skiddingdelay=0;
6733 if(skiddingdelay<0)skiddingdelay+=multiplier;
6734 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
6744 if(!onterrain||environment==grassyenvironment){
6745 PlaySoundEx( skidsound, samp[skidsound], NULL, true);
6746 OPENAL_3D_SetAttributes(channels[skidsound], gLoc, vel);
6747 OPENAL_SetVolume(channels[skidsound], 128*velspeed/10);
6748 OPENAL_SetPaused(channels[skidsound], false);
6751 PlaySoundEx( snowskidsound, samp[snowskidsound], NULL, true);
6752 OPENAL_3D_SetAttributes(channels[snowskidsound], gLoc, vel);
6753 OPENAL_SetVolume(channels[snowskidsound], 128*velspeed/10);
6754 OPENAL_SetPaused(channels[snowskidsound], false);
6758 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
6759 terrainnormal=victim->coords-coords;
6760 Normalise(&terrainnormal);
6761 targetrotation=-asin(0-terrainnormal.x);
6762 targetrotation*=360/6.28;
6763 if(terrainnormal.z<0)targetrotation=180-targetrotation;
6764 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
6767 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
6768 targetrotation=victim->targetrotation;
6770 if(targetanimation==rabbittacklinganim){
6771 coords=victim->coords;
6774 skeleton.oldfree=skeleton.free;
6778 midterrain.x=terrain.size*terrain.scale/2;
6779 midterrain.z=terrain.size*terrain.scale/2;
6780 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
6782 tempposit=coords-midterrain;
6784 Normalise(&tempposit);
6785 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
6786 coords.x=tempposit.x+midterrain.x;
6787 coords.z=tempposit.z+midterrain.z;
6791 int Person::DrawSkeleton(){
6792 int oldplayerdetail;
6793 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
6794 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
6804 glAlphaFunc(GL_GREATER, 0.0001);
6806 float terrainheight;
6808 if(!isnormal(rotation))rotation=0;
6809 if(!isnormal(tilt))tilt=0;
6810 if(!isnormal(tilt2))tilt2=0;
6811 oldplayerdetail=playerdetail;
6813 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
6816 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
6819 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
6824 if(playerdetail!=oldplayerdetail) {
6826 normalsupdatedelay=0;
6828 static float updatedelaychange;
6829 static float morphness;
6830 static float framemult;
6832 skeleton.FindForwards();
6833 if(howactive==typesittingwall){
6834 skeleton.specialforward[1]=0;
6835 skeleton.specialforward[1].z=1;
6841 static int weaponattachmuscle;
6842 static int weaponrotatemuscle,weaponrotatemuscle2;
6843 static XYZ weaponpoint;
6844 static int start,endthing;
6845 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
6846 if(!isSleeping()&&!isSitting()){
6847 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6848 XYZ point,newpoint,change,change2;
6849 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6850 heightleft=terrain.getHeight(point.x,point.z)+.04;
6852 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6853 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6854 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6855 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6856 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6858 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6859 heightright=terrain.getHeight(point.x,point.z)+.04;
6860 point.y=heightright;
6861 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6862 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6863 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6864 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6865 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6866 skeleton.DoConstraints(&coords,&scale);
6868 if(creature==wolftype){
6869 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6870 heightleft=terrain.getHeight(point.x,point.z)+.04;
6872 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6873 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6874 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6875 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6876 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6878 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6879 heightright=terrain.getHeight(point.x,point.z)+.04;
6880 point.y=heightright;
6881 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6882 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6883 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
6884 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6885 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6886 skeleton.DoConstraints(&coords,&scale);
6889 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6890 XYZ point,newpoint,change,change2;
6891 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6892 heightleft=terrain.getHeight(point.x,point.z)+.04;
6894 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6895 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6896 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6897 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6898 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6900 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6901 heightright=terrain.getHeight(point.x,point.z)+.04;
6902 point.y=heightright;
6903 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6904 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6905 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6906 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6907 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6908 skeleton.DoConstraints(&coords,&scale);
6910 if(creature==wolftype){
6911 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6912 heightleft=terrain.getHeight(point.x,point.z)+.04;
6914 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6915 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6916 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
6917 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6918 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6920 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6921 heightright=terrain.getHeight(point.x,point.z)+.04;
6922 point.y=heightright;
6923 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6924 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6925 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
6926 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6927 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6928 skeleton.DoConstraints(&coords,&scale);
6932 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
6933 XYZ point,newpoint,change,change2;
6934 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6935 heightleft=terrain.getHeight(point.x,point.z)+.04;
6937 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6938 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6939 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6940 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6941 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6943 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6944 heightright=terrain.getHeight(point.x,point.z)+.04;
6945 point.y=heightright;
6946 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6947 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6948 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6949 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6950 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6951 skeleton.DoConstraints(&coords,&scale);
6953 if(creature==wolftype){
6954 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
6955 heightleft=terrain.getHeight(point.x,point.z)+.04;
6957 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6958 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
6959 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
6960 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
6961 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
6963 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
6964 heightright=terrain.getHeight(point.x,point.z)+.04;
6965 point.y=heightright;
6966 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6967 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
6968 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
6969 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
6970 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
6971 skeleton.DoConstraints(&coords,&scale);
6975 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()))
6978 targetheadrotation=-targetrotation;
6979 targetheadrotation2=0;
6980 if(animation[targetanimation].attack==3)targetheadrotation+=180;
6982 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
6983 skeleton.drawmodel.vertex[i]=0;
6984 skeleton.drawmodel.vertex[i].y=999;
6986 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
6987 skeleton.drawmodellow.vertex[i]=0;
6988 skeleton.drawmodellow.vertex[i].y=999;
6990 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
6991 skeleton.drawmodelclothes.vertex[i]=0;
6992 skeleton.drawmodelclothes.vertex[i].y=999;
6994 for(i=0;i<skeleton.num_muscles;i++){
6995 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
6999 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
7000 morphness=righthandmorphness;
7001 start=righthandmorphstart;
7002 endthing=righthandmorphend;
7004 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
7005 morphness=lefthandmorphness;
7006 start=lefthandmorphstart;
7007 endthing=lefthandmorphend;
7009 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
7010 morphness=headmorphness;
7011 start=headmorphstart;
7012 endthing=headmorphend;
7014 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)){
7015 morphness=chestmorphness;
7016 start=chestmorphstart;
7017 endthing=chestmorphend;
7019 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)){
7020 morphness=tailmorphness;
7021 start=tailmorphstart;
7022 endthing=tailmorphend;
7024 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
7025 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
7026 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7029 if(!skeleton.free)glRotatef(tilt2,1,0,0);
7030 if(!skeleton.free)glRotatef(tilt,0,0,1);
7033 glTranslatef(mid.x,mid.y,mid.z);
7035 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
7036 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
7038 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
7039 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
7041 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
7042 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
7044 if(!isnormal(proportionbody.x)||!isnormal(proportionbody.y)||!isnormal(proportionbody.z)){
7048 if(!isnormal(proportionarms.x)||!isnormal(proportionarms.y)||!isnormal(proportionarms.z)){
7052 if(!isnormal(proportionhead.x)||!isnormal(proportionhead.y)||!isnormal(proportionhead.z)){
7056 if(!isnormal(proportionlegs.x)||!isnormal(proportionlegs.y)||!isnormal(proportionlegs.z)){
7061 if(playerdetail||skeleton.free==3)
7063 for(j=0;j<skeleton.muscles[i].numvertices;j++)
7065 /*if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[0]=1;
7066 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[1]=1;
7067 if(!isnormal(skeleton.model[start].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[2]=1;
7068 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].x))vertexweird[3]=1;
7069 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].y))vertexweird[4]=1;
7070 if(!isnormal(skeleton.model[endthing].vertex[skeleton.muscles[i].vertices[j]].z))vertexweird[5]=1;
7071 if(skeleton.muscles[i].vertices[j]<skeleton.model[start].vertexNum&&skeleton.muscles[i].vertices[j]>=0){*/
7072 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7074 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7075 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,
7076 (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,
7077 (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);
7078 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)
7079 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,
7080 (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,
7081 (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);
7082 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)
7083 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,
7084 (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,
7085 (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);
7086 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7087 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,
7088 (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,
7089 (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);
7090 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7091 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
7092 //if(isnormal(M[12])&&isnormal(M[13])&&isnormal(M[14])){
7093 //if(!isnormal(scale))test=1;
7094 //if(isnormal(scale)){
7095 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
7096 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
7097 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
7105 if(!playerdetail||skeleton.free==3)
7107 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
7109 //if(skeleton.muscles[i].verticeslow[j]<skeleton.modellow.vertexNum&&skeleton.muscles[i].verticeslow[j]>=0){
7110 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7112 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7113 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
7114 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
7115 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
7116 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)
7117 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
7118 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
7119 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
7120 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)
7121 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
7122 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
7123 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
7124 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7125 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
7126 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
7127 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
7129 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7130 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
7131 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
7132 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
7139 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
7140 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
7142 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7145 if(!skeleton.free)glRotatef(tilt2,1,0,0);
7146 if(!skeleton.free)glRotatef(tilt,0,0,1);
7147 glTranslatef(mid.x,mid.y,mid.z);
7148 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
7149 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
7151 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
7152 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
7154 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
7155 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
7157 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
7158 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7160 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
7161 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
7162 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
7163 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
7164 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)
7165 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
7166 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
7167 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
7168 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)
7169 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
7170 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
7171 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
7172 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
7173 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
7174 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
7175 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
7176 glGetFloatv(GL_MODELVIEW_MATRIX,M);
7177 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
7178 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
7179 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
7184 updatedelay=1+(float)(Random()%100)/1000;
7186 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
7187 normalsupdatedelay=1;
7188 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
7189 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
7190 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
7194 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
7195 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
7196 if(skeleton.clothes){
7197 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
7202 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
7203 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
7204 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
7205 if(skeleton.free==1)updatedelaychange*=6;
7206 if(id==0)updatedelaychange*=8;
7207 updatedelay+=updatedelaychange;
7209 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
7211 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7212 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
7213 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
7214 if(!skeleton.free)glRotatef(rotation,0,1,0);
7217 glColor4f(.4,1,.4,1);
7218 glDisable(GL_LIGHTING);
7219 glDisable(GL_TEXTURE_2D);
7222 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
7223 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
7229 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
7230 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);
7231 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);
7232 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);
7233 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);
7234 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);
7235 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);
7241 terrainlight=terrain.getLighting(coords.x,coords.z);
7242 distance=findDistancefast(&viewer,&coords);
7243 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
7244 if(distance>1)distance=1;
7246 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
7247 if(terrainheight<1)terrainheight=1;
7248 if(terrainheight>1.7)terrainheight=1.7;
7251 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
7252 glDisable(GL_BLEND);
7253 glAlphaFunc(GL_GREATER, 0.0001);
7254 glEnable(GL_TEXTURE_2D);
7256 glDisable(GL_TEXTURE_2D);
7257 glColor4f(.7,.35,0,.5);
7259 glEnable(GL_LIGHTING);
7262 if(tutoriallevel&&id!=0){
7263 //glDisable(GL_TEXTURE_2D);
7264 glColor4f(.7,.7,.7,0.6);
7266 glEnable(GL_LIGHTING);
7268 if(canattack&&cananger)
7269 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7270 glDisable(GL_TEXTURE_2D);
7271 glColor4f(1,0,0,0.8);
7273 glMatrixMode(GL_TEXTURE);
7275 glTranslatef(0,-smoketex,0);
7276 glTranslatef(-smoketex,0,0);
7280 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7281 else skeleton.drawmodel.draw();
7285 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7286 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7289 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
7290 if(tutoriallevel&&id!=0){
7292 glMatrixMode(GL_MODELVIEW);
7293 glEnable(GL_TEXTURE_2D);
7294 glColor4f(.7,.7,.7,0.6);
7296 glEnable(GL_LIGHTING);
7298 if(canattack&&cananger)
7299 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
7300 glDisable(GL_TEXTURE_2D);
7301 glColor4f(1,0,0,0.8);
7303 glMatrixMode(GL_TEXTURE);
7305 glTranslatef(0,-smoketex*.6,0);
7306 glTranslatef(smoketex*.6,0,0);
7309 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
7310 else skeleton.drawmodel.draw();
7314 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
7315 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
7320 if(tutoriallevel&&id!=0){
7322 glMatrixMode(GL_MODELVIEW);
7323 glEnable(GL_TEXTURE_2D);
7325 if(skeleton.clothes){
7328 if(!immediate)skeleton.drawmodelclothes.draw();
7329 if(immediate)skeleton.drawmodelclothes.drawimmediate();
7336 for(k=0;k<num_weapons;k++){
7338 if(weaponactive==k){
7339 if(weapons.type[i]!=staff){
7340 for(j=0;j<skeleton.num_muscles;j++){
7341 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7342 weaponattachmuscle=j;
7345 for(j=0;j<skeleton.num_muscles;j++){
7346 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){
7347 weaponrotatemuscle=j;
7350 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7351 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
7353 if(weapons.type[i]==staff){
7354 for(j=0;j<skeleton.num_muscles;j++){
7355 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
7356 weaponattachmuscle=j;
7359 for(j=0;j<skeleton.num_muscles;j++){
7360 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){
7361 weaponrotatemuscle=j;
7364 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
7365 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
7366 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7367 XYZ tempnormthing,vec1,vec2;
7368 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
7369 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
7370 CrossProduct(&vec1,&vec2,&tempnormthing);
7371 Normalise(&tempnormthing);
7372 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);
7373 /*if(targetanimation==staffhitanim||currentanimation==staffhitanim){
7375 weaptargnorm=DoRotation(weapons.tippoint[i]-weapons.position[i],0,-rotation,0);
7376 //weaptargnorm=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7377 Normalise(&weaptargnorm);
7378 weaponpoint-=weaptargnorm*2;
7382 if(weaponactive!=k&&weaponstuck!=k){
7383 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;
7384 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;
7385 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;
7386 for(j=0;j<skeleton.num_muscles;j++){
7387 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){
7388 weaponrotatemuscle=j;
7393 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
7394 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
7395 for(j=0;j<skeleton.num_muscles;j++){
7396 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){
7397 weaponrotatemuscle=j;
7402 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;
7403 weapons.bigrotation[i]=rotation;
7404 weapons.bigtilt[i]=tilt;
7405 weapons.bigtilt2[i]=tilt2;
7408 weapons.position[i]=weaponpoint*scale+coords;
7409 weapons.bigrotation[i]=0;
7410 weapons.bigtilt[i]=0;
7411 weapons.bigtilt2[i]=0;
7413 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
7414 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
7415 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
7416 if(weaponactive==k){
7417 if(weapons.type[i]==knife){
7418 weapons.smallrotation[i]=180;
7419 weapons.smallrotation2[i]=0;
7420 if(isCrouch()||wasCrouch()){
7421 weapons.smallrotation2[i]=20;
7423 if(targetanimation==hurtidleanim){
7424 weapons.smallrotation2[i]=50;
7426 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
7427 XYZ temppoint1,temppoint2,tempforward;
7430 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7431 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7432 distance=findDistance(&temppoint1,&temppoint2);
7433 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7434 weapons.rotation2[i]*=360/6.28;
7437 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7438 weapons.rotation1[i]*=360/6.28;
7439 weapons.rotation3[i]=0;
7440 weapons.smallrotation[i]=-90;
7441 weapons.smallrotation2[i]=0;
7442 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7444 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
7445 XYZ temppoint1,temppoint2,tempforward;
7448 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
7449 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7450 distance=findDistance(&temppoint1,&temppoint2);
7451 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7452 weapons.rotation2[i]*=360/6.28;
7455 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7456 weapons.rotation1[i]*=360/6.28;
7457 weapons.rotation3[i]=0;
7458 weapons.smallrotation[i]=90;
7459 weapons.smallrotation2[i]=0;
7460 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7462 if(targetanimation==knifethrowanim){
7463 weapons.smallrotation[i]=90;
7464 //weapons.smallrotation2[i]=-90;
7465 weapons.smallrotation2[i]=0;
7466 weapons.rotation1[i]=0;
7467 weapons.rotation2[i]=0;
7468 weapons.rotation3[i]=0;
7470 if(targetanimation==knifesneakattackanim&&targetframe<5){
7471 weapons.smallrotation[i]=-90;
7472 weapons.rotation1[i]=0;
7473 weapons.rotation2[i]=0;
7474 weapons.rotation3[i]=0;
7477 if(weapons.type[i]==sword){
7478 weapons.smallrotation[i]=0;
7479 weapons.smallrotation2[i]=0;
7480 if(targetanimation==knifethrowanim){
7481 weapons.smallrotation[i]=-90;
7482 weapons.smallrotation2[i]=0;
7483 weapons.rotation1[i]=0;
7484 weapons.rotation2[i]=0;
7485 weapons.rotation3[i]=0;
7487 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)){
7488 XYZ temppoint1,temppoint2,tempforward;
7491 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7492 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7493 distance=findDistance(&temppoint1,&temppoint2);
7494 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7495 weapons.rotation2[i]*=360/6.28;
7498 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7499 weapons.rotation1[i]*=360/6.28;
7500 weapons.rotation3[i]=0;
7501 weapons.smallrotation[i]=90;
7502 weapons.smallrotation2[i]=0;
7503 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7506 if(weapons.type[i]==staff){
7507 weapons.smallrotation[i]=100;
7508 weapons.smallrotation2[i]=0;
7509 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
7510 XYZ temppoint1,temppoint2,tempforward;
7513 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
7514 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
7515 distance=findDistance(&temppoint1,&temppoint2);
7516 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
7517 weapons.rotation2[i]*=360/6.28;
7520 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
7521 weapons.rotation1[i]*=360/6.28;
7522 weapons.rotation3[i]=0;
7523 weapons.smallrotation[i]=90;
7524 weapons.smallrotation2[i]=0;
7525 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
7529 if(weaponactive!=k&&weaponstuck!=k){
7530 if(weapons.type[i]==knife){
7531 weapons.smallrotation[i]=-70;
7532 weapons.smallrotation2[i]=10;
7534 if(weapons.type[i]==sword){
7535 weapons.smallrotation[i]=-100;
7536 weapons.smallrotation2[i]=-8;
7538 if(weapons.type[i]==staff){
7539 weapons.smallrotation[i]=-100;
7540 weapons.smallrotation2[i]=-8;
7544 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
7545 else weapons.smallrotation[i]=0;
7546 weapons.smallrotation2[i]=10;
7547 //if(animation[targetanimation].height==lowheight&&animation[targetanimation].attack==neutral){
7555 if(skeleton.free)calcrot=1;
7556 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
7557 if(currentanimation!=targetanimation)calcrot=1;
7558 //if(id==0)calcrot=1;
7559 if(skeleton.free==2)calcrot=0;
7565 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
7568 static float distance;
7569 static float olddistance;
7570 static int intersecting;
7571 static int firstintersecting;
7574 static XYZ start,end;
7575 static float slopethreshold=-.4;
7577 firstintersecting=-1;
7581 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
7582 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
7584 for (j=0;j<model->TriangleNum;j++){
7585 if(model->facenormals[j].y<=slopethreshold){
7587 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)));
7588 if(distance<radius){
7589 point=*p1-model->facenormals[j]*distance;
7590 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;
7591 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7592 &model->vertex[model->Triangles[j].vertex[1]],
7594 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
7595 &model->vertex[model->Triangles[j].vertex[2]],
7597 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
7598 &model->vertex[model->Triangles[j].vertex[2]],
7601 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7605 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)){
7606 p1->y=point.y+radius;
7607 if((targetanimation==jumpdownanim||isFlip())){
7608 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
7610 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
7616 OPENAL_SetPaused(channels[whooshsound], true);
7617 OPENAL_SetVolume(channels[whooshsound], 0);
7620 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
7621 if(isFlip())jumppower=-4;
7622 targetanimation=getLanding();
7631 PlaySoundEx( landsound, samp[landsound], NULL, true);
7632 OPENAL_3D_SetAttributes(channels[landsound], gLoc, vel);
7633 OPENAL_SetVolume(channels[landsound], 128);
7634 OPENAL_SetPaused(channels[landsound], false);
7637 envsound[numenvsounds]=coords;
7638 envsoundvol[numenvsounds]=16;
7639 envsoundlife[numenvsounds]=.4;
7647 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7650 for (j=0;j<model->TriangleNum;j++){
7651 if(model->facenormals[j].y>slopethreshold){
7655 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)));
7656 if(distance<radius*.5){
7657 point=start-model->facenormals[j]*distance;
7658 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;
7659 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,
7660 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
7661 p1->x, p1->y, p1->z, radius/2);
7662 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,
7663 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7664 p1->x, p1->y, p1->z, radius/2);
7665 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,
7666 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
7667 p1->x, p1->y, p1->z, radius/2);
7669 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
7670 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
7672 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
7673 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
7675 *p1+=model->facenormals[j]*(distance-radius*.5);
7678 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
7682 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
7684 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
7686 return firstintersecting;
7696 currentanimation = 0;
7697 targetanimation = 0;
7698 oldcurrentframe = 0;
7700 oldcurrentanimation = 0;
7701 oldtargetanimation = 0;
7705 parriedrecently = 0;
7709 lastattack = 0,lastattack2 = 0,lastattack3 = 0;
7711 currentoffset = 0,targetoffset = 0,offset = 0;
7729 unconscioustime = 0;
7747 rabbitkickenabled = 0;
7756 damagetolerance = 0;
7758 permanentdamage = 0;
7759 superpermanentdamage = 0; lastcollide = 0;
7779 headrotation = 0,headrotation2 = 0;
7780 targetheadrotation = 0,targetheadrotation2 = 0;
7791 normalsupdatedelay = 0;
7796 forwardstogglekeydown = 0;
7801 jumptogglekeydown = 0;
7803 crouchtogglekeydown = 0;
7805 drawtogglekeydown = 0;
7807 throwtogglekeydown = 0;
7813 crouchkeydowntime = 0;
7814 jumpkeydowntime = 0;
7831 whichdirectiondelay = 0;
7832 avoidsomething = 0; avoidwhere = 0;
7840 lefthandmorphness = 0;
7841 righthandmorphness = 0;
7845 targetlefthandmorphness = 0;
7846 targetrighthandmorphness = 0;
7847 targetheadmorphness = 0;
7848 targetchestmorphness = 0;
7849 targettailmorphness = 0;
7850 lefthandmorphstart = 0,lefthandmorphend = 0;
7851 righthandmorphstart = 0,righthandmorphend = 0;
7852 headmorphstart = 0,headmorphend = 0;
7853 chestmorphstart = 0,chestmorphend = 0;
7854 tailmorphstart = 0,tailmorphend = 0;
7856 weaponmissdelay = 0;
7857 highreversaldelay = 0;
7858 lowreversaldelay = 0;
7865 //Skeleton skeleton;
7884 memset(clothes, 0, sizeof(clothes));
7885 memset(clothestintr, 0, sizeof(clothestintr));
7886 memset(clothestintg, 0, sizeof(clothestintg));
7887 memset(clothestintb, 0, sizeof(clothestintb));
7893 onfiredelay = 0; burnt = 0;
7897 updatestuffdelay = 0;
7903 memset(weaponids, 0, sizeof(weaponids));
7907 weaponstuckwhere = 0;
7912 memset(waypoints, 0, sizeof(waypoints));
7913 memset(waypointtype, 0, sizeof(waypointtype));
7916 hastempwaypoint = 0;
7922 finalfinaltarget = 0;
7924 finalpathfindpoint = 0;
7925 targetpathfindpoint = 0;
7926 lastpathfindpoint = 0;
7927 lastpathfindpoint2 = 0;
7928 lastpathfindpoint3 = 0;
7929 lastpathfindpoint4 = 0;
7940 runninghowlong = 0; lastoccluded = 0;
7946 neckspurtparticledelay = 0;
7947 neckspurtamount = 0;
7950 rabbitkickragdoll = 0;
7955 //Animation tempanimation;