2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /**> HEADER FILES <**/
24 #include "openal_wrapper.h"
25 #include "Animation.h"
30 extern float multiplier;
31 extern Terrain terrain;
33 extern int environment;
35 extern FRUSTUM frustum;
37 extern float realmultiplier;
39 extern float slomodelay;
40 extern bool cellophane;
41 extern float texdetail;
42 extern float realtexdetail;
43 extern GLubyte bloodText[512*512*3];
44 extern GLubyte wolfbloodText[512*512*3];
45 extern int bloodtoggle;
46 extern Objects objects;
48 extern bool autoslomo;
49 extern float camerashake;
51 extern float terraindetail;
52 extern float viewdistance;
53 extern float blackout;
54 extern int difficulty;
56 extern float fadestart;
58 extern bool winfreeze;
59 extern float flashamount,flashr,flashg,flashb;
60 extern int flashdelay;
61 extern bool showpoints;
62 extern bool immediate;
64 extern bool tilt2weird;
65 extern bool tiltweird;
67 extern bool proportionweird;
68 extern bool vertexweird[6];
69 extern XYZ envsound[30];
70 extern float envsoundvol[30];
71 extern float envsoundlife[30];
72 extern int numenvsounds;
73 extern int tutoriallevel;
74 extern float smoketex;
75 extern int tutorialstage;
76 extern bool reversaltrain;
77 extern bool canattack;
79 extern float damagedealt;
81 extern float hostiletime;
83 extern int indialogue;
85 extern bool gamestarted;
87 void Person::CheckKick()
90 && (targetanimation == rabbitkickanim
94 && currentanimation == rabbitkickanim)
95 && (findDistancefast(&coords,&victim->coords) < 1.2)
96 && (!victim->skeleton.free)))
99 if (animation[victim->targetanimation].height!=lowheight)
101 float damagemult = (creature == wolftype ? 2.5 : 1.) * power * power;
102 XYZ relative = velocity;
104 Normalise(&relative);
109 emit_sound_at(heavyimpactsound, victim->coords);
111 for(int i=0;i<victim->skeleton.num_joints;i++){
112 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
115 victim->DoDamage(100*damagemult/victim->protectionhigh);
116 if(id==0)camerashake+=.4;
120 targetanimation=backflipanim;
126 resume_stream(whooshsound);
128 award_bonus(id, cannon);
130 else if (victim->isCrouch())
132 targetanimation=rabbitkickreversedanim;
133 currentanimation=rabbitkickreversedanim;
134 victim->currentanimation=rabbitkickreversalanim;
135 victim->targetanimation=rabbitkickreversalanim;
141 victim->oldcoords=victim->coords;
142 coords=victim->coords;
143 victim->targetrotation=targetrotation;
148 void Person::CatchFire(){
149 XYZ flatfacing,flatvelocity;
151 for(int i=0;i<10;i++){
152 howmany=abs(Random()%(skeleton.num_joints));
153 if(!skeleton.free)flatvelocity=velocity;
154 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
155 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
156 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
157 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
162 emit_sound_at(firestartsound, coords);
164 emit_stream_at(stream_firesound, coords);
171 int Person::getIdle(){
172 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
173 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)){
174 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
175 if(creature==rabbittype)return fightidleanim;
176 if(creature==wolftype)return wolfidle;
178 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
179 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
180 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
181 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
182 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
184 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
186 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
187 if(howactive==typesitting)return sitanim;
188 if(howactive==typesittingwall)return sitwallanim;
189 if(howactive==typesleeping)return sleepanim;
190 if(howactive==typedead1)return dead1anim;
191 if(howactive==typedead2)return dead2anim;
192 if(howactive==typedead3)return dead3anim;
193 if(howactive==typedead4)return dead4anim;
194 if(creature==rabbittype)return bounceidleanim;
195 if(creature==wolftype)return wolfidle;
199 int Person::getCrouch(){
200 if(creature==rabbittype)return crouchanim;
201 if(creature==wolftype)return wolfcrouchanim;
205 int Person::getRun(){
206 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
207 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
209 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
210 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
214 int Person::getStop(){
215 if(creature==rabbittype)return stopanim;
216 if(creature==wolftype)return wolfstopanim;
220 int Person::getLanding(){
221 if(creature==rabbittype)return landanim;
222 if(creature==wolftype)return wolflandanim;
226 int Person::getLandhard(){
227 if(creature==rabbittype)return landhardanim;
228 if(creature==wolftype)return wolflandhardanim;
233 SolidHitBonus(int playerid)
235 if (bonustime < 1.5 && bonus >= solidhit && bonus <= megacombo)
236 award_bonus(playerid, bonus == megacombo ? bonus : bonus + 1);
238 award_bonus(playerid, solidhit);
241 void Person::DoBlood(float howmuch,int which){
242 static int bleedxint,bleedyint;
244 //if(howmuch&&id==0)blooddimamount=1;
245 if(bloodtoggle&&tutoriallevel!=1){
246 if(bleeding<=0&&spurt){
248 for(int i=0;i<3;i++){
252 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
255 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
257 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
258 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
260 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
261 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
264 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);
265 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);
269 for(int i=0;i<3;i++){
273 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
274 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
277 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
278 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
282 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
284 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);
286 Sprite::setLastSpriteSpecial(3);
291 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
294 int texdetailint=realtexdetail;
295 if(creature==rabbittype)
296 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){
297 bleedxint=abs(Random()%512);
298 bleedyint=abs(Random()%512);
300 if(creature==wolftype)
301 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){
302 bleedxint=abs(Random()%512);
303 bleedyint=abs(Random()%512);
307 bleedy/=realtexdetail;
308 bleedx/=realtexdetail;
309 direction=abs(Random()%2)*2-1;
313 if(bleeding>2)bleeding=2;
316 void Person::DoBloodBig(float howmuch,int which){
317 static int bleedxint,bleedyint,i,j;
319 if(howmuch&&id==0)blooddimamount=1;
321 if(tutoriallevel!=1||id==0)
322 if(aitype!=playercontrolled&&howmuch>0){
325 if(creature==wolftype){
326 int i=abs(Random()%2);
327 if(i==0)whichsound=snarlsound;
328 if(i==1)whichsound=snarl2sound;
329 envsound[numenvsounds]=coords;
330 envsoundvol[numenvsounds]=16;
331 envsoundlife[numenvsounds]=.4;
334 if(creature==rabbittype){
335 int i=abs(Random()%2);
336 if(i==0)whichsound=rabbitpainsound;
337 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
338 envsound[numenvsounds]=coords;
339 envsoundvol[numenvsounds]=16;
340 envsoundlife[numenvsounds]=.4;
342 //if(i==2)whichsound=rabbitpain2sound;
346 emit_sound_at(whichsound, coords);
349 if(id==0&&howmuch>0){
357 if(bloodtoggle&&decals&&tutoriallevel!=1){
358 if(bleeding<=0&&spurt){
360 for(int i=0;i<3;i++){
364 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
367 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
369 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
370 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
372 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
373 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
376 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);
377 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);
381 int offsetx=0,offsety=0;
384 offsetx=abs(Random()%60);
386 if(which==190||which==185){
388 offsetx=abs(Random()%100)-20;
398 if(which==220||which==215){
399 //offsety=Random()%20;
401 //offsetx=abs(Random()%80);
410 if(creature==rabbittype)
413 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
414 if(i<startx)startx=i;
415 if(j<starty)starty=j;
421 if(creature==wolftype)
424 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
425 if(i<startx)startx=i;
426 if(j<starty)starty=j;
438 if(startx<0)startx=0;
439 if(starty<0)starty=0;
440 if(endx>512-1)endx=512-1;
441 if(endy>512-1)endy=512-1;
442 if(endx<startx)endx=startx;
443 if(endy<starty)endy=starty;
445 startx/=realtexdetail;
446 starty/=realtexdetail;
450 int texdetailint=realtexdetail;
452 if(creature==rabbittype)
453 for(i=startx;i<endx;i++){
454 for(j=starty;j<endy;j++){
455 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){
456 color=Random()%85+170;
457 where=i*skeleton.skinsize*3+j*3;
458 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
459 skeleton.skinText[where+1]=0;
460 skeleton.skinText[where+2]=0;
464 if(creature==wolftype)
465 for(i=startx;i<endx;i++){
466 for(j=starty;j<endy;j++){
467 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){
468 color=Random()%85+170;
469 where=i*skeleton.skinsize*3+j*3;
470 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
471 skeleton.skinText[where+1]=0;
472 skeleton.skinText[where+2]=0;
476 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
481 if(creature==rabbittype)
482 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){
483 bleedxint=abs(Random()%512);
484 bleedyint=abs(Random()%512);
486 if(creature==wolftype)
487 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){
488 bleedxint=abs(Random()%512);
489 bleedyint=abs(Random()%512);
491 bleedy=bleedxint+offsetx;
492 bleedx=bleedyint+offsety;
493 bleedy/=realtexdetail;
494 bleedx/=realtexdetail;
495 if(bleedx<0)bleedx=0;
496 if(bleedy<0)bleedy=0;
497 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
498 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
499 direction=abs(Random()%2)*2-1;
502 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
503 deathbleeding+=bleeding;
504 bloodloss+=bleeding*3;
506 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
507 if(abs(Random()%2)==0){aitype=gethelptype;
510 else aitype=attacktypecutoff;
513 if(bleeding>2)bleeding=2;
516 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
517 static int bleedxint,bleedyint,i,j;
519 static XYZ startpoint,endpoint,colpoint,movepoint;
520 static float rotationpoint;
522 static XYZ p1,p2,p3,p0;
526 float coordsx,coordsy;
529 if(bloodtoggle&&decals&&tutoriallevel!=1){
531 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
539 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
542 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
543 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
544 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
546 CrossProduct(p2-p1,p3-p1,&N);
547 CrossProduct(p0-p1,p3-p1,&temp);
548 s = dotproduct(&temp,&N)/findLength(&N);
549 CrossProduct(p2-p1,p1-p0,&temp);
550 t = dotproduct(&temp,&N)/findLength(&N);
553 bary.x=findDistancefast(&p0,&p1);
554 bary.y=findDistancefast(&p0,&p2);
555 bary.z=findDistancefast(&p0,&p3);
557 total=bary.x+bary.y+bary.z;
566 total=bary.x+bary.y+bary.z;
572 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
573 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
574 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
575 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
576 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
577 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
578 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;
579 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;
581 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
582 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
584 if(bleeding<=0&&spurt){
586 for(int i=0;i<3;i++){
590 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
593 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
595 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
596 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
598 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
599 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
602 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);
603 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);
607 int offsetx=0,offsety=0;
610 offsetx=abs(Random()%120);
612 if(which==220||which==215){
614 offsetx=abs(Random()%80);
617 offsetx=(1+coordsy)*512-291;
618 offsety=coordsx*512-437;
625 if(creature==rabbittype)
628 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
629 if(i<startx)startx=i;
630 if(j<starty)starty=j;
636 if(creature==wolftype)
639 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
640 if(i<startx)startx=i;
641 if(j<starty)starty=j;
652 if(startx<0)startx=0;
653 if(starty<0)starty=0;
654 if(endx>512-1)endx=512-1;
655 if(endy>512-1)endy=512-1;
656 if(endx<startx)endx=startx;
657 if(endy<starty)endy=starty;
659 startx/=realtexdetail;
660 starty/=realtexdetail;
664 int texdetailint=realtexdetail;
666 if(creature==rabbittype)
667 for(i=startx;i<endx;i++){
668 for(j=starty;j<endy;j++){
669 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){
670 color=Random()%85+170;
671 where=i*skeleton.skinsize*3+j*3;
672 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
673 skeleton.skinText[where+1]=0;
674 skeleton.skinText[where+2]=0;
676 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){
677 color=Random()%85+170;
678 where=i*skeleton.skinsize*3+j*3;
679 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
680 skeleton.skinText[where+1]=0;
681 skeleton.skinText[where+2]=0;
685 if(creature==wolftype)
686 for(i=startx;i<endx;i++){
687 for(j=starty;j<endy;j++){
688 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){
689 color=Random()%85+170;
690 where=i*skeleton.skinsize*3+j*3;
691 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
692 skeleton.skinText[where+1]=0;
693 skeleton.skinText[where+2]=0;
695 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){
696 color=Random()%85+170;
697 where=i*skeleton.skinsize*3+j*3;
698 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
699 skeleton.skinText[where+1]=0;
700 skeleton.skinText[where+2]=0;
704 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
707 bleedy=(1+coordsy)*512;
709 bleedy/=realtexdetail;
710 bleedx/=realtexdetail;
711 if(bleedx<0)bleedx=0;
712 if(bleedy<0)bleedy=0;
713 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
714 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
715 direction=abs(Random()%2)*2-1;
717 if(whichtri==-1)return 0;
719 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
720 deathbleeding+=bleeding;
721 bloodloss+=bleeding*3;
723 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
724 if(abs(Random()%2)==0){aitype=gethelptype;
727 else aitype=attacktypecutoff;
730 if(bleeding>2)bleeding=2;
736 void Person::Reverse()
738 if (!((victim->aitype == playercontrolled
740 || staggerdelay <= 0)
741 && victim->targetanimation != jumpupanim
742 && victim->targetanimation != jumpdownanim
743 && (tutoriallevel != 1 || cananger)
747 if (normaldotproduct (victim->facing, victim->coords-coords) > 0
748 && (victim->id != 0 || difficulty >= 2)
749 && (creature != wolftype || victim->creature == wolftype))
752 if(targetanimation==sweepanim){
753 targetanimation=sweepreversedanim;
754 currentanimation=sweepreversedanim;
755 victim->currentanimation=sweepreversalanim;
756 victim->targetanimation=sweepreversalanim;
758 if(targetanimation==spinkickanim){
759 targetanimation=spinkickreversedanim;
760 currentanimation=spinkickreversedanim;
761 victim->currentanimation=spinkickreversalanim;
762 victim->targetanimation=spinkickreversalanim;
764 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
765 if(targetanimation==rabbittacklinganim){
768 victim->currentframe=6;
769 victim->targetframe=7;
771 targetanimation=upunchreversedanim;
772 currentanimation=upunchreversedanim;
773 victim->currentanimation=upunchreversalanim;
774 victim->targetanimation=upunchreversalanim;
776 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
777 if(victim->weaponactive!=-1){
778 victim->throwtogglekeydown=1;
779 weapons.owner[victim->weaponids[0]]=-1;
780 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
781 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
782 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
783 weapons.missed[victim->weaponids[0]]=1;
784 weapons.freetime[victim->weaponids[0]]=0;
785 weapons.firstfree[victim->weaponids[0]]=1;
786 weapons.physics[victim->weaponids[0]]=1;
787 victim->num_weapons--;
788 if(victim->num_weapons){
789 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
790 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
793 victim->weaponactive=-1;
794 for(int j=0;j<numplayers;j++){
795 player[j].wentforweapon=0;
799 targetanimation=staffhitreversedanim;
800 currentanimation=staffhitreversedanim;
801 victim->currentanimation=staffhitreversalanim;
802 victim->targetanimation=staffhitreversalanim;
804 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
805 if(victim->weaponactive!=-1){
806 victim->throwtogglekeydown=1;
807 weapons.owner[victim->weaponids[0]]=-1;
808 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
809 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
810 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
811 weapons.missed[victim->weaponids[0]]=1;
812 weapons.freetime[victim->weaponids[0]]=0;
813 weapons.firstfree[victim->weaponids[0]]=1;
814 weapons.physics[victim->weaponids[0]]=1;
815 victim->num_weapons--;
816 if(victim->num_weapons){
817 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
818 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
821 victim->weaponactive=-1;
822 for(int j=0;j<numplayers;j++){
823 player[j].wentforweapon=0;
826 targetanimation=staffspinhitreversedanim;
827 currentanimation=staffspinhitreversedanim;
828 victim->currentanimation=staffspinhitreversalanim;
829 victim->targetanimation=staffspinhitreversalanim;
831 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
832 if(victim->weaponactive!=-1){
833 victim->throwtogglekeydown=1;
834 weapons.owner[victim->weaponids[0]]=-1;
835 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
836 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
837 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
838 weapons.missed[victim->weaponids[0]]=1;
839 weapons.freetime[victim->weaponids[0]]=0;
840 weapons.firstfree[victim->weaponids[0]]=1;
841 weapons.physics[victim->weaponids[0]]=1;
842 victim->num_weapons--;
843 if(victim->num_weapons){
844 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
845 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
848 victim->weaponactive=-1;
849 for(int j=0;j<numplayers;j++){
850 player[j].wentforweapon=0;
853 targetanimation=swordslashreversedanim;
854 currentanimation=swordslashreversedanim;
855 victim->currentanimation=swordslashreversalanim;
856 victim->targetanimation=swordslashreversalanim;
858 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
859 if(victim->weaponactive!=-1){
860 victim->throwtogglekeydown=1;
861 weapons.owner[victim->weaponids[0]]=-1;
862 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
863 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
864 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
865 weapons.missed[victim->weaponids[0]]=1;
866 weapons.freetime[victim->weaponids[0]]=0;
867 weapons.firstfree[victim->weaponids[0]]=1;
868 weapons.physics[victim->weaponids[0]]=1;
869 victim->num_weapons--;
870 if(victim->num_weapons){
871 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
872 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
875 victim->weaponactive=-1;
876 for(int j=0;j<numplayers;j++){
877 player[j].wentforweapon=0;
880 targetanimation=knifeslashreversedanim;
881 currentanimation=knifeslashreversedanim;
882 victim->currentanimation=knifeslashreversalanim;
883 victim->targetanimation=knifeslashreversalanim;
885 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
886 victim->targettilt2=targettilt2;
887 victim->currentframe=currentframe;
888 victim->targetframe=targetframe;
889 victim->target=target;
891 victim->oldcoords=victim->coords;
892 victim->coords=coords;
893 victim->targetrotation=targetrotation;
894 victim->rotation=targetrotation;
897 if(targetanimation==winduppunchanim){
898 targetanimation=winduppunchblockedanim;
899 victim->targetanimation=blockhighleftanim;
900 victim->targetframe=1;
903 victim->targetrotation=targetrotation+180;
905 if(targetanimation==wolfslapanim){
906 targetanimation=winduppunchblockedanim;
907 victim->targetanimation=blockhighleftanim;
908 victim->targetframe=1;
911 victim->targetrotation=targetrotation+180;
913 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
914 targetanimation=swordslashparriedanim;
916 victim->parriedrecently=0;
917 victim->targetanimation=swordslashparryanim;
918 victim->targetframe=1;
921 victim->targetrotation=targetrotation+180;
923 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
924 if(victim->weaponactive!=-1){
925 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
926 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
927 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
928 emit_sound_at(swordstaffsound, victim->coords);
931 emit_sound_at(metalhitsound, victim->coords);
935 victim->Puff(righthand);
937 victim->targetframe=0;
938 victim->targetanimation=staggerbackhighanim;
939 victim->targetrotation=targetrotation+180;
941 weapons.owner[victim->weaponids[0]]=-1;
942 aim=DoRotation(facing,0,90,0)*21;
944 weapons.velocity[victim->weaponids[0]]=aim*-.2;
945 weapons.tipvelocity[victim->weaponids[0]]=aim;
946 weapons.missed[victim->weaponids[0]]=1;
947 weapons.hitsomething[victim->weaponids[0]]=0;
948 weapons.freetime[victim->weaponids[0]]=0;
949 weapons.firstfree[victim->weaponids[0]]=1;
950 weapons.physics[victim->weaponids[0]]=1;
951 victim->num_weapons--;
952 if(victim->num_weapons){
953 victim->weaponids[0]=victim->weaponids[num_weapons];
954 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
956 victim->weaponactive=-1;
957 for(int i=0;i<numplayers;i++){
958 player[i].wentforweapon=0;
962 if(abs(Random()%20)==0){
963 if(weaponactive!=-1){
964 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
965 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
966 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
968 emit_sound_at(swordstaffsound, coords);
971 emit_sound_at(metalhitsound, coords);
979 targetanimation=staggerbackhighanim;
980 targetrotation=targetrotation+180;
982 weapons.owner[weaponids[0]]=-1;
983 aim=DoRotation(facing,0,90,0)*21;
985 weapons.velocity[weaponids[0]]=aim*-.2;
986 weapons.tipvelocity[weaponids[0]]=aim;
987 weapons.hitsomething[weaponids[0]]=0;
988 weapons.missed[weaponids[0]]=1;
989 weapons.freetime[weaponids[0]]=0;
990 weapons.firstfree[weaponids[0]]=1;
991 weapons.physics[weaponids[0]]=1;
994 weaponids[0]=weaponids[num_weapons];
995 if(weaponstuck==num_weapons)weaponstuck=0;
998 for(int i=0;i<numplayers;i++){
999 player[i].wentforweapon=0;
1006 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1007 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1008 victim->targetanimation=dodgebackanim;
1009 victim->targetframe=0;
1013 rotatetarget=coords-victim->coords;
1014 Normalise(&rotatetarget);
1015 victim->targetrotation=-asin(0-rotatetarget.x);
1016 victim->targetrotation*=360/6.28;
1017 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1019 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1021 victim->lastattack3=victim->lastattack2;
1022 victim->lastattack2=victim->lastattack;
1023 victim->lastattack=victim->targetanimation;
1027 victim->targetanimation=sweepanim;
1028 victim->targetframe=0;
1032 rotatetarget=coords-victim->coords;
1033 Normalise(&rotatetarget);
1034 victim->targetrotation=-asin(0-rotatetarget.x);
1035 victim->targetrotation*=360/6.28;
1036 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1038 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1040 victim->lastattack3=victim->lastattack2;
1041 victim->lastattack2=victim->lastattack;
1042 victim->lastattack=victim->targetanimation;
1049 if(aitype!=playercontrolled)feint=0;
1050 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1051 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1052 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1054 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1057 void Person::DoDamage(float howmuch){
1058 if(tutoriallevel!=1)damage+=howmuch/power;
1059 if(id!=0)damagedealt+=howmuch/power;
1060 if(id==0)damagetaken+=howmuch/power;
1062 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1063 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1064 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1065 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1066 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1068 if(id==0)camerashake+=howmuch/100;
1069 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1070 if(blackout>1)blackout=1;
1072 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1073 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1074 if(abs(Random()%2)==0){aitype=gethelptype;
1077 else aitype=attacktypecutoff;
1081 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1084 for(int i=0;i<skeleton.num_joints; i++){
1085 if(!skeleton.free)flatvelocity2=velocity;
1086 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1087 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1088 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1089 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1090 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1091 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1092 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1093 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1094 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1097 emit_sound_at(splattersound, coords);
1106 if(!dead&&creature==wolftype){
1107 award_bonus(0, Wolfbonus);
1113 if(tutoriallevel!=1||id==0)
1114 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1117 if(creature==wolftype){
1118 int i=abs(Random()%2);
1119 if(i==0)whichsound=snarlsound;
1120 if(i==1)whichsound=snarl2sound;
1121 envsound[numenvsounds]=coords;
1122 envsoundvol[numenvsounds]=16;
1123 envsoundlife[numenvsounds]=.4;
1126 if(creature==rabbittype){
1127 int i=abs(Random()%2);
1128 if(i==0)whichsound=rabbitpainsound;
1129 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1130 envsound[numenvsounds]=coords;
1131 envsoundvol[numenvsounds]=16;
1132 envsoundlife[numenvsounds]=.4;
1134 //if(i==2)whichsound=rabbitpain2sound;
1138 emit_sound_at(whichsound, coords);
1143 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1144 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1147 void Person::DoHead(){
1148 static XYZ rotatearound;
1150 static float lookspeed=500;
1152 if(!freeze&&!winfreeze){
1155 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1156 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1158 while(targetheadrotation>180)targetheadrotation-=360;
1159 while(targetheadrotation<-180)targetheadrotation+=360;
1161 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1162 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1163 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1164 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1166 if(targetheadrotation2>120)targetheadrotation2=120;
1167 if(targetheadrotation2<-120)targetheadrotation2=-120;
1168 if(targetheadrotation>120)targetheadrotation=120;
1169 if(targetheadrotation<-120)targetheadrotation=-120;
1171 if(!isIdle())targetheadrotation2=0;
1173 if(targetheadrotation>80)targetheadrotation=80;
1174 if(targetheadrotation<-80)targetheadrotation=-80;
1175 if(targetheadrotation2>50)targetheadrotation2=50;
1176 if(targetheadrotation2<-50)targetheadrotation2=-50;
1179 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1180 else if(headrotation>targetheadrotation){
1181 headrotation-=multiplier*lookspeed;
1183 else if(headrotation<targetheadrotation){
1184 headrotation+=multiplier*lookspeed;
1187 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1188 else if(headrotation2>targetheadrotation2){
1189 headrotation2-=multiplier*lookspeed/2;
1191 else if(headrotation2<targetheadrotation2){
1192 headrotation2+=multiplier*lookspeed/2;
1195 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1196 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1200 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1201 facing=DoRotation(facing,headrotation2*.4,0,0);
1202 facing=DoRotation(facing,0,headrotation*.4,0);
1205 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1206 facing=DoRotation(facing,headrotation2*.8,0,0);
1207 facing=DoRotation(facing,0,headrotation*.8,0);
1210 if(targetanimation==walkanim){
1211 facing=DoRotation(facing,headrotation2*.6,0,0);
1212 facing=DoRotation(facing,0,headrotation*.6,0);
1215 skeleton.specialforward[0]=facing;
1216 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1218 for(i=0;i<skeleton.num_muscles;i++){
1219 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1221 skeleton.FindRotationMuscle(i,targetanimation);
1227 void Person::RagDoll(bool checkcollision){
1232 if(id==0)numfalls++;
1233 if(id==0&&isFlip())numflipfail++;
1239 facing=DoRotation(facing,0,rotation,0);
1241 skeleton.freetime=0;
1243 skeleton.longdead=0;
1249 skeleton.freefall=1;
1251 if(!isnormal(velocity.x))velocity.x=0;
1252 if(!isnormal(velocity.y))velocity.y=0;
1253 if(!isnormal(velocity.z))velocity.z=0;
1254 if(!isnormal(rotation))rotation=0;
1255 if(!isnormal(coords.x))coords=0;
1256 if(!isnormal(tilt))tilt=0;
1257 if(!isnormal(tilt2))tilt2=0;
1259 for(i=0;i<skeleton.num_joints;i++){
1260 skeleton.joints[i].delay=0;
1261 skeleton.joints[i].locked=0;
1262 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1263 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1264 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1265 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1266 skeleton.joints[i].position.y+=.1;
1267 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1268 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1271 for(i=0;i<skeleton.num_joints;i++){
1272 skeleton.joints[i].velocity=0;
1273 skeleton.joints[i].velchange=0;
1275 skeleton.DoConstraints(&coords,&scale);
1276 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1278 skeleton.DoConstraints(&coords,&scale);
1279 skeleton.DoConstraints(&coords,&scale);
1280 skeleton.DoConstraints(&coords,&scale);
1281 skeleton.DoConstraints(&coords,&scale);
1284 speed=animation[targetanimation].speed[targetframe]*2;
1285 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1286 speed=animation[currentanimation].speed[currentframe]*2;
1288 if(transspeed)speed=transspeed*2;
1292 for(i=0;i<skeleton.num_joints;i++){
1293 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);
1294 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1295 change.x=(float)(Random()%100)/100;
1296 change.y=(float)(Random()%100)/100;
1297 change.z=(float)(Random()%100)/100;
1298 skeleton.joints[i].velocity+=change;
1299 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1301 change.x=(float)(Random()%100)/100;
1302 change.y=(float)(Random()%100)/100;
1303 change.z=(float)(Random()%100)/100;
1304 skeleton.joints[i].velchange+=change;
1305 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1315 for(j=0;j<skeleton.num_joints;j++){
1316 average+=skeleton.joints[j].position;
1320 coords+=average*scale;
1321 for(j=0;j<skeleton.num_joints;j++){
1322 skeleton.joints[j].position-=average;
1325 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1326 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1327 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1328 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1329 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1332 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1333 coords.x=lowpoint.x;
1334 coords.z=lowpoint.z;
1343 for(i=0;i<skeleton.num_joints;i++){
1344 velocity+=skeleton.joints[i].velocity*scale;
1346 velocity/=skeleton.num_joints;
1349 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1350 weapons.owner[weaponids[0]]=-1;
1351 weapons.hitsomething[weaponids[0]]=0;
1352 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1353 weapons.velocity[weaponids[0]].x+=.01;
1354 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1355 weapons.missed[weaponids[0]]=1;
1356 weapons.freetime[weaponids[0]]=0;
1357 weapons.firstfree[weaponids[0]]=1;
1358 weapons.physics[weaponids[0]]=1;
1361 weaponids[0]=weaponids[num_weapons];
1362 if(weaponstuck==num_weapons)weaponstuck=0;
1365 for(i=0;i<numplayers;i++){
1366 player[i].wentforweapon=0;
1371 targetanimation=bounceidleanim;
1372 currentanimation=bounceidleanim;
1380 void Person::FootLand(int which, float opacity){
1381 static XYZ terrainlight;
1382 static XYZ footvel,footpoint;
1383 if(opacity>=1||skiddelay<=0)
1387 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1388 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1389 //footpoint.y=coords.y;
1390 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1392 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1394 if(footvel.y<.8)footvel.y=.8;
1395 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1396 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1397 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1398 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1399 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1400 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1402 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1404 if(footvel.y<.8)footvel.y=.8;
1405 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1406 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1407 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1408 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1409 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);
1411 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1413 if(footvel.y<.8)footvel.y=.8;
1414 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1415 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1416 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1417 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1418 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);
1419 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1421 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1424 if(footvel.y<.8)footvel.y=.8;
1425 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1426 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1427 //footpoint.y=coords.y;
1428 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1432 void Person::Puff(int whichlabel){
1433 static XYZ footvel,footpoint;
1436 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1437 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1441 void Person::DoAnimations(){
1444 static float oldtarget;
1446 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1448 if(targetanimation==tempanim||currentanimation==tempanim){
1449 animation[tempanim]=tempanimation;
1451 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1462 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1463 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1465 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1466 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1468 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1473 targfacing=DoRotation(targfacing,0,targetrotation,0);
1475 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1476 else targetanimation=backflipanim;
1477 crouchtogglekeydown=1;
1481 if(id==0)numflipped++;
1484 if(animation[targetanimation].attack!=reversed)feint=0;
1485 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1486 crouchtogglekeydown=0;
1487 if(aitype==playercontrolled)feint=0;
1491 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1492 if(!isFlip())crouchtogglekeydown=1;
1496 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1497 if(detail)normalsupdatedelay=0;
1501 if(targetanimation==rollanim&&targetframe==3&&onfire){
1503 emit_sound_at(fireendsound, coords);
1504 pause_sound(stream_firesound);
1508 if(targetanimation==rabbittacklinganim&&targetframe==1){
1509 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1510 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1511 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1512 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1513 else victim->targetanimation=rabbittackledfrontanim;
1514 victim->targetframe=2;
1516 victim->rotation=rotation;
1517 victim->targetrotation=rotation;
1518 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1519 //victim->DoDamage(30);
1520 if(creature==wolftype){
1522 emit_sound_at(clawslicesound, victim->coords);
1524 victim->DoBloodBig(1/victim->armorhead,210);
1526 award_bonus(id, TackleBonus,
1527 victim->aitype == gethelptype ? 50 : 0);
1531 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1532 if(weapons.type[weaponids[0]]==knife){
1533 if(weaponactive==-1)weaponactive=0;
1534 else if(weaponactive==0)weaponactive=-1;
1536 if(weaponactive==-1){
1537 emit_sound_at(knifesheathesound, coords);
1539 if(weaponactive!=-1){
1540 emit_sound_at(knifedrawsound, coords, 128);
1543 drawtogglekeydown=1;
1546 if(tutoriallevel!=1||id==0)
1547 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1550 if(terrain.getOpacity(coords.x,coords.z)<.2){
1551 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1552 else whichsound=footstepsound2;
1553 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1554 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1555 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1561 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1562 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1563 else whichsound=footstepsound4;
1567 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1568 else whichsound=footstepsound4;
1570 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1571 if(animation[targetanimation].attack!=neutral){
1573 if(i==0)whichsound=lowwhooshsound;
1574 if(i==1)whichsound=midwhooshsound;
1575 if(i==2)whichsound=highwhooshsound;
1577 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1579 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1580 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1582 emit_sound_at(whichsound, coords, 256.);
1585 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1586 envsound[numenvsounds]=coords;
1587 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1588 else envsoundvol[numenvsounds]=6;
1589 envsoundlife[numenvsounds]=.4;
1593 if(animation[targetanimation].label[targetframe]==3){
1595 emit_sound_at(whichsound, coords, 128.);
1600 if(tutoriallevel!=1||id==0)
1602 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1603 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1605 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1606 if(animation[targetanimation].attack!=neutral){
1608 if(creature==rabbittype){
1609 if(i==0)whichsound=rabbitattacksound;
1610 if(i==1)whichsound=rabbitattack2sound;
1611 if(i==2)whichsound=rabbitattack3sound;
1612 if(i==3)whichsound=rabbitattack4sound;
1614 if(creature==wolftype){
1615 if(i==0)whichsound=barksound;
1616 if(i==1)whichsound=bark2sound;
1617 if(i==2)whichsound=bark3sound;
1618 if(i==3)whichsound=barkgrowlsound;
1622 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1624 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1625 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
1628 emit_sound_at(whichsound, coords);
1634 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
1640 currentoffset=targetoffset;
1641 targetframe=currentframe;
1642 currentanimation=targetanimation;
1645 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
1646 for(i=0;i<weapons.numweapons;i++){
1647 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
1648 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
1649 if(findDistancefast(&coords,&weapons.position[i])>=1){
1650 if(weapons.type[i]!=staff){
1651 emit_sound_at(knifedrawsound, coords, 128.);
1655 weapons.owner[i]=id;
1657 weaponids[num_weapons]=weaponids[0];
1666 static bool willwork;
1667 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
1668 for(i=0;i<weapons.numweapons;i++){
1670 if(weapons.owner[i]!=-1)
1671 if(player[weapons.owner[i]].weaponstuck!=-1)
1672 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
1673 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
1674 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))
1675 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
1676 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
1678 if(weapons.owner[i]!=-1)
1679 if(victim->weaponstuck!=-1){
1680 if(victim->weaponids[victim->weaponstuck]==i){
1685 if(weapons.type[i]!=staff){
1686 emit_sound_at(knifedrawsound, coords, 128.);
1690 emit_sound_at(fleshstabremovesound, coords, 128.);
1693 if(weapons.owner[i]!=-1){
1695 victim=&player[weapons.owner[i]];
1696 if(victim->num_weapons==1)victim->num_weapons=0;
1697 else victim->num_weapons=1;
1699 //victim->weaponactive=-1;
1700 victim->skeleton.longdead=0;
1701 victim->skeleton.free=1;
1702 victim->skeleton.broken=0;
1704 for(int j=0;j<victim->skeleton.num_joints;j++){
1705 victim->skeleton.joints[j].velchange=0;
1706 victim->skeleton.joints[j].locked=0;
1712 Normalise(&relative);
1713 XYZ footvel,footpoint;
1715 footpoint=weapons.position[i];
1716 if(victim->weaponstuck!=-1){
1717 if(victim->weaponids[victim->weaponstuck]==i){
1718 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
1719 weapons.bloody[i]=2;
1720 weapons.blooddrip[i]=5;
1721 victim->weaponstuck=-1;
1724 if(victim->num_weapons>0){
1725 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
1726 if(victim->weaponids[0]==i)
1727 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1730 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
1731 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
1732 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
1733 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
1735 weapons.owner[i]=id;
1737 weaponids[num_weapons]=weaponids[0];
1746 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
1747 if(weaponactive==-1)weaponactive=0;
1748 else if(weaponactive==0){
1752 buffer=weaponids[0];
1753 weaponids[0]=weaponids[1];
1754 weaponids[1]=buffer;
1757 if(weaponactive==-1){
1758 emit_sound_at(knifesheathesound, coords, 128.);
1760 if(weaponactive!=-1){
1761 emit_sound_at(knifedrawsound, coords, 128.);
1766 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
1767 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
1768 Normalise(&rotatetarget);
1769 targetrotation=-asin(0-rotatetarget.x);
1770 targetrotation*=360/6.28;
1771 if(rotatetarget.z<0)targetrotation=180-targetrotation;
1773 if(targetanimation==walljumprightkickanim)targetrotation+=40;
1774 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
1779 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
1781 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;
1783 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
1784 targetanimation=rabbittackleanim;
1786 emit_sound_at(jumpsound, coords);
1795 Normalise(&targetloc);
1797 for(i=0;i<numplayers;i++){
1799 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
1800 closestdist=findDistancefast(&targetloc,&player[i].coords);
1805 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
1807 victim=&player[closestid];
1808 coords=victim->coords;
1809 currentanimation=rabbittacklinganim;
1810 targetanimation=rabbittacklinganim;
1814 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
1815 rotatetarget=coords-victim->coords;
1816 Normalise(&rotatetarget);
1817 targetrotation=-asin(0-rotatetarget.x);
1818 targetrotation*=360/6.28;
1819 if(rotatetarget.z<0)targetrotation=180-targetrotation;
1821 if(targetanimation!=rabbitrunninganim){
1822 emit_sound_at(jumpsound, coords, 128.);
1828 float damagemult=1*power;
1829 if(creature==wolftype)damagemult=2.5*power;
1830 if(hasvictim){damagemult/=victim->damagetolerance/200;}
1831 //if(onfire)damagemult=3;
1832 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
1833 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
1834 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
1836 if(id==0)camerashake+=.4;
1837 if(Random()%2||creature==wolftype){
1840 if(creature==wolftype)DoBloodBig(0,250);
1842 if(tutoriallevel!=1){
1843 emit_sound_at(heavyimpactsound, victim->coords, 128.);
1845 if(creature==wolftype){
1846 emit_sound_at(clawslicesound, victim->coords, 128.);
1848 victim->DoBloodBig(2/victim->armorhead,175);
1852 relative=victim->coords-coords;
1854 Normalise(&relative);
1855 relative=DoRotation(relative,0,-90,0);
1856 for(i=0;i<victim->skeleton.num_joints;i++){
1857 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
1859 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
1862 victim->DoDamage(damagemult*100/victim->protectionhead);
1868 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
1869 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
1871 if(id==0)camerashake+=.4;
1872 if(Random()%2||creature==wolftype){
1874 if(creature==wolftype)DoBloodBig(0,235);
1876 emit_sound_at(whooshhitsound, victim->coords);
1877 if(creature==wolftype){
1878 emit_sound_at(clawslicesound, victim->coords, 128.);
1880 victim->DoBloodBig(2,175);
1884 relative=victim->coords-coords;
1886 Normalise(&relative);
1888 Normalise(&relative);
1889 relative=DoRotation(relative,0,90,0);
1890 for(i=0;i<victim->skeleton.num_joints;i++){
1891 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
1893 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
1896 victim->DoDamage(damagemult*50/victim->protectionhead);
1900 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
1901 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
1903 if(id==0)camerashake+=.4;
1906 if(tutoriallevel!=1){
1907 emit_sound_at(heavyimpactsound, victim->coords, 160.);
1909 if(creature==wolftype){
1910 emit_sound_at(clawslicesound, victim->coords, 128.);
1912 victim->DoBloodBig(2/victim->armorhead,175);
1918 Normalise(&relative);
1919 relative=DoRotation(relative,0,-90,0);
1920 for(i=0;i<victim->skeleton.num_joints;i++){
1921 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
1923 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
1926 victim->DoDamage(damagemult*150/victim->protectionhead);
1928 if(victim->damage>victim->damagetolerance)
1929 award_bonus(id, style);
1935 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
1936 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
1938 if(id==0)camerashake+=.4;
1941 if(tutoriallevel!=1){
1942 emit_sound_at(heavyimpactsound, victim->coords, 160.);
1944 if(creature==wolftype){
1945 emit_sound_at(clawslicesound, victim->coords, 128.);
1947 victim->DoBloodBig(2/victim->armorhead,175);
1953 Normalise(&relative);
1954 relative=DoRotation(relative,0,90,0);
1955 for(i=0;i<victim->skeleton.num_joints;i++){
1956 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
1958 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
1961 victim->DoDamage(damagemult*150/victim->protectionhead);
1963 if(victim->damage>victim->damagetolerance)
1964 award_bonus(id, style);
1970 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
1971 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
1973 if(id==0)camerashake+=.4;
1978 emit_sound_at(whooshhitsound, victim->coords);
1981 relative=victim->coords-coords;
1983 Normalise(&relative);
1984 for(i=0;i<victim->skeleton.num_joints;i++){
1985 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
1987 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
1990 victim->DoDamage(damagemult*50/victim->protectionhead);
1994 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
1995 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
1997 if(id==0)camerashake+=.2;
1998 emit_sound_at(whooshhitsound, victim->coords, 128.);
2000 victim->skeleton.longdead=0;
2001 victim->skeleton.free=1;
2002 victim->skeleton.broken=0;
2003 victim->skeleton.spinny=1;
2005 for(i=0;i<victim->skeleton.num_joints;i++){
2006 victim->skeleton.joints[i].velchange=0;
2007 victim->skeleton.joints[i].delay=0;
2008 victim->skeleton.joints[i].locked=0;
2009 //victim->skeleton.joints[i].velocity=0;
2015 Normalise(&relative);
2016 for(i=0;i<victim->skeleton.num_joints;i++){
2017 victim->skeleton.joints[i].velocity.y=relative.y*10;
2018 victim->skeleton.joints[i].position.y+=relative.y*.3;
2019 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2020 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2022 victim->Puff(abdomen);
2023 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2027 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2028 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2030 if(id==0)camerashake+=.4;
2031 if(tutoriallevel!=1){
2032 emit_sound_at(heavyimpactsound, coords, 128.);
2035 relative=victim->coords-coords;
2037 Normalise(&relative);
2038 for(i=0;i<victim->skeleton.num_joints;i++){
2039 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2041 victim->Puff(abdomen);
2042 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2046 victim->DoDamage(damagemult*500/victim->protectionhigh);
2047 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2051 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2052 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2054 if(id==0)camerashake+=.4;
2055 if(tutoriallevel!=1){
2056 emit_sound_at(thudsound, coords);
2059 victim->skeleton.longdead=0;
2060 victim->skeleton.free=1;
2061 victim->skeleton.broken=0;
2062 victim->skeleton.spinny=1;
2064 for(i=0;i<victim->skeleton.num_joints;i++){
2065 victim->skeleton.joints[i].velchange=0;
2066 //victim->skeleton.joints[i].delay=0;
2067 victim->skeleton.joints[i].locked=0;
2070 relative=victim->coords-coords;
2071 Normalise(&relative);
2073 Normalise(&relative);
2074 for(i=0;i<victim->skeleton.num_joints;i++){
2075 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2080 victim->Puff(abdomen);
2081 victim->DoDamage(damagemult*20/victim->protectionhigh);
2082 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2084 if(!victim->dead)staggerdelay=1.2;
2090 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2091 //if(id==0)camerashake+=.4;
2094 if(!victim->skeleton.free)hasvictim=0;
2097 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2098 emit_sound_at(knifesheathesound, coords, 128.);
2101 if(victim&&hasvictim){
2102 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2104 XYZ where,startpoint,endpoint,movepoint,colpoint;
2105 float rotationpoint;
2107 if(weapons.type[weaponids[weaponactive]]==knife){
2108 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2109 where-=victim->coords;
2110 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2117 if(weapons.type[weaponids[weaponactive]]==sword){
2118 where=weapons.position[weaponids[weaponactive]];
2119 where-=victim->coords;
2120 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2122 where=weapons.tippoint[weaponids[weaponactive]];
2123 where-=victim->coords;
2124 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2127 if(weapons.type[weaponids[weaponactive]]==staff){
2128 where=weapons.position[weaponids[weaponactive]];
2129 where-=victim->coords;
2130 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2132 where=weapons.tippoint[weaponids[weaponactive]];
2133 where-=victim->coords;
2134 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2139 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2142 if(victim->dead!=2){
2143 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2145 award_bonus(id, FinishedBonus);
2147 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2149 victim->skeleton.longdead=0;
2150 victim->skeleton.free=1;
2151 victim->skeleton.broken=0;
2153 for(i=0;i<victim->skeleton.num_joints;i++){
2154 victim->skeleton.joints[i].velchange=0;
2155 victim->skeleton.joints[i].locked=0;
2156 //victim->skeleton.joints[i].velocity=0;
2158 emit_sound_at(fleshstabsound, coords, 128);
2161 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2162 weapons.blooddrip[weaponids[weaponactive]]+=5;
2163 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2167 emit_sound_at(knifesheathesound, coords, 128.);
2173 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2175 emit_sound_at(knifedrawsound, coords, 128);
2178 if(victim&&hasvictim){
2179 XYZ footvel,footpoint;
2181 emit_sound_at(fleshstabremovesound, coords, 128.);
2184 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2186 if(weapons.type[weaponids[weaponactive]]==sword){
2187 XYZ where,startpoint,endpoint,movepoint;
2188 float rotationpoint;
2191 where=weapons.position[weaponids[weaponactive]];
2192 where-=victim->coords;
2193 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2195 where=weapons.tippoint[weaponids[weaponactive]];
2196 where-=victim->coords;
2197 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2202 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2203 footpoint+=victim->coords;
2206 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2209 if(weapons.type[weaponids[weaponactive]]==staff){
2210 XYZ where,startpoint,endpoint,movepoint;
2211 float rotationpoint;
2214 where=weapons.position[weaponids[weaponactive]];
2215 where-=victim->coords;
2216 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2218 where=weapons.tippoint[weaponids[weaponactive]];
2219 where-=victim->coords;
2220 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2225 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2226 footpoint+=victim->coords;
2229 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2232 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2234 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2235 victim->skeleton.longdead=0;
2236 victim->skeleton.free=1;
2237 victim->skeleton.broken=0;
2239 for(i=0;i<victim->skeleton.num_joints;i++){
2240 victim->skeleton.joints[i].velchange=0;
2241 victim->skeleton.joints[i].locked=0;
2242 //victim->skeleton.joints[i].velocity=0;
2248 Normalise(&relative);
2249 //victim->Puff(abdomen);
2250 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2252 if(victim->bloodloss<victim->damagetolerance){
2253 victim->bloodloss+=1000;
2257 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2261 if(!hasvictim&&onterrain){
2262 weapons.bloody[weaponids[weaponactive]]=0;
2263 weapons.blooddrip[weaponids[weaponactive]]=0;
2267 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2268 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2270 if(id==0)camerashake+=.4;
2275 if(tutoriallevel!=1){
2276 emit_sound_at(heavyimpactsound, victim->coords, 128);
2281 relative=victim->coords-coords;
2283 Normalise(&relative);
2284 for(i=0;i<victim->skeleton.num_joints;i++){
2285 victim->skeleton.joints[i].velocity=relative*30;
2287 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2289 victim->targetframe=0;
2290 victim->targetanimation=staggerbackhardanim;
2291 victim->targetrotation=targetrotation+180;
2296 victim->Puff(abdomen);
2297 victim->DoDamage(damagemult*60/victim->protectionhigh);
2304 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2305 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2307 if(id==0)camerashake+=.4;
2308 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2309 if(tutoriallevel!=1){
2310 emit_sound_at(thudsound, victim->coords);
2313 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2314 if(tutoriallevel!=1){
2315 emit_sound_at(whooshhitsound, victim->coords);
2319 if(tutoriallevel!=1){
2320 emit_sound_at(heavyimpactsound, victim->coords);
2324 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2327 relative=victim->coords-coords;
2329 Normalise(&relative);
2331 Normalise(&relative);
2332 for(i=0;i<victim->skeleton.num_joints;i++){
2333 victim->skeleton.joints[i].velocity=relative*5;
2335 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
2337 victim->targetframe=0;
2338 victim->targetanimation=staggerbackhardanim;
2339 victim->targetrotation=targetrotation+180;
2343 victim->Puff(abdomen);
2344 victim->DoDamage(damagemult*60/victim->protectionhigh);
2350 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
2351 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2352 if(victim->id==0)camerashake+=.4;
2353 emit_sound_at(landsound2, victim->coords);
2359 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
2360 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2361 if(victim->id==0)camerashake+=.4;
2363 if(weaponactive!=-1){
2364 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
2365 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2366 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2368 emit_sound_at(swordstaffsound, victim->coords);
2371 emit_sound_at(metalhitsound, victim->coords);
2379 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
2380 if(weaponactive!=-1){
2383 weapons.owner[weaponids[0]]=-1;
2384 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);
2386 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
2387 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
2389 weapons.velocity[weaponids[0]]=aim*50;
2390 weapons.tipvelocity[weaponids[0]]=aim*50;
2391 weapons.missed[weaponids[0]]=0;
2392 weapons.hitsomething[weaponids[0]]=0;
2393 weapons.freetime[weaponids[0]]=0;
2394 weapons.firstfree[weaponids[0]]=1;
2395 weapons.physics[weaponids[0]]=0;
2398 weaponids[0]=weaponids[num_weapons];
2404 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
2406 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
2408 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
2410 award_bonus(id, Slicebonus);
2411 if(tutoriallevel!=1){
2412 emit_sound_at(knifeslicesound, victim->coords);
2414 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2415 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
2416 if(victim->id != 0 || difficulty==2){
2417 victim->targetframe=0;
2418 victim->targetanimation=staggerbackhardanim;
2419 victim->targetrotation=targetrotation+180;
2423 victim->lowreversaldelay=0;
2424 victim->highreversaldelay=0;
2425 if(aitype!=playercontrolled)weaponmissdelay=.6;
2427 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
2428 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
2430 XYZ footvel,footpoint;
2433 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
2436 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;
2438 if(tutoriallevel!=1){
2439 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
2440 footvel=DoRotation(facing,0,90,0)*.8;
2442 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2443 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2444 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
2445 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
2447 if(tutoriallevel==1){
2448 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
2450 victim->DoDamage(damagemult*0);
2453 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
2454 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
2455 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
2456 award_bonus(id, Slashbonus);
2458 if(tutoriallevel!=1){
2459 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
2460 else victim->DoBloodBig(2/victim->armorhigh,185);
2461 victim->deathbleeding=1;
2462 emit_sound_at(swordslicesound, victim->coords);
2464 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2465 if(tutoriallevel!=1){
2466 victim->targetframe=0;
2467 victim->targetanimation=staggerbackhardanim;
2468 victim->targetrotation=targetrotation+180;
2472 if(tutoriallevel!=1){
2473 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
2474 weapons.blooddrip[weaponids[weaponactive]]+=3;
2476 float bloodlossamount;
2477 bloodlossamount=200+abs((float)(Random()%40))-20;
2478 victim->bloodloss+=bloodlossamount/victim->armorhigh;
2479 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
2480 victim->DoDamage(damagemult*0);
2482 XYZ footvel,footpoint;
2485 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
2488 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;
2490 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
2491 footvel=DoRotation(facing,0,90,0)*.8;
2493 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2494 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2495 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
2496 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
2500 if(victim->weaponactive!=-1){
2501 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
2502 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2503 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2505 emit_sound_at(swordstaffsound, victim->coords);
2508 emit_sound_at(metalhitsound, victim->coords);
2514 victim->Puff(righthand);
2516 victim->targetframe=0;
2517 victim->targetanimation=staggerbackhighanim;
2518 victim->targetrotation=targetrotation+180;
2520 weapons.owner[victim->weaponids[0]]=-1;
2521 aim=DoRotation(facing,0,90,0)*21;
2523 weapons.velocity[victim->weaponids[0]]=aim*-.2;
2524 weapons.tipvelocity[victim->weaponids[0]]=aim;
2525 weapons.missed[victim->weaponids[0]]=1;
2526 weapons.hitsomething[weaponids[0]]=0;
2527 weapons.freetime[victim->weaponids[0]]=0;
2528 weapons.firstfree[victim->weaponids[0]]=1;
2529 weapons.physics[victim->weaponids[0]]=1;
2530 victim->num_weapons--;
2531 if(victim->num_weapons){
2532 victim->weaponids[0]=victim->weaponids[num_weapons];
2533 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
2535 victim->weaponactive=-1;
2536 for(i=0;i<numplayers;i++){
2537 player[i].wentforweapon=0;
2544 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
2545 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
2546 if(tutoriallevel!=1){
2547 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
2549 if(id==0)camerashake+=.4;
2550 if(Random()%2||creature==wolftype){
2553 emit_sound_at(staffheadsound, victim->coords);
2557 relative=victim->coords-coords;
2559 Normalise(&relative);
2560 relative=DoRotation(relative,0,90,0);
2562 Normalise(&relative);
2563 for(i=0;i<victim->skeleton.num_joints;i++){
2564 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
2566 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
2567 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
2570 if(tutoriallevel!=1){
2571 victim->DoDamage(damagemult*120/victim->protectionhigh);
2573 award_bonus(id, solidhit, 30);
2578 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
2579 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
2580 if(tutoriallevel!=1){
2581 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
2583 if(id==0)camerashake+=.4;
2584 if(Random()%2||creature==wolftype){
2587 emit_sound_at(staffheadsound, victim->coords);
2591 relative=victim->coords-coords;
2593 Normalise(&relative);
2594 relative=DoRotation(relative,0,-90,0);
2595 for(i=0;i<victim->skeleton.num_joints;i++){
2596 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2598 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
2599 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
2602 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
2604 award_bonus(id, solidhit, 60);
2609 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
2610 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
2612 if(tutoriallevel!=1){
2613 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
2614 if(id==0)camerashake+=.4;
2615 if(Random()%2||creature==wolftype){
2618 emit_sound_at(staffbodysound, victim->coords);
2620 victim->skeleton.longdead=0;
2621 victim->skeleton.free=1;
2622 victim->skeleton.broken=0;
2624 for(i=0;i<victim->skeleton.num_joints;i++){
2625 victim->skeleton.joints[i].velchange=0;
2626 victim->skeleton.joints[i].locked=0;
2627 //victim->skeleton.joints[i].velocity=0;
2633 /*relative=victim->coords-coords;
2635 Normalise(&relative);
2636 relative=DoRotation(relative,0,90,0);*/
2638 Normalise(&relative);
2640 for(i=0;i<victim->skeleton.num_joints;i++){
2641 victim->skeleton.joints[i].velocity=relative*damagemult*40;
2644 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
2647 for(i=0;i<victim->skeleton.num_joints;i++){
2648 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
2651 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2653 victim->Puff(abdomen);
2654 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
2657 award_bonus(id, solidhit, 40);
2663 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
2664 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
2666 if(id==0)camerashake+=.4;
2668 relative=victim->coords-coords;
2670 Normalise(&relative);
2674 if(animation[victim->targetanimation].height==lowheight){
2680 for(i=0;i<victim->skeleton.num_joints;i++){
2681 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2683 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2684 if(tutoriallevel!=1){
2685 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2688 victim->DoDamage(damagemult*100/victim->protectionhead);
2689 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
2690 if(creature==wolftype){
2691 emit_sound_at(clawslicesound, victim->coords, 128.);
2693 victim->DoBloodBig(2/victim->armorhead,175);
2697 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
2698 for(i=0;i<victim->skeleton.num_joints;i++){
2699 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
2701 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2702 victim->targetframe=0;
2703 victim->targetanimation=staggerbackhighanim;
2704 victim->targetrotation=targetrotation+180;
2706 if(tutoriallevel!=1){
2707 emit_sound_at(landsound2, victim->coords, 128.);
2709 victim->Puff(abdomen);
2710 victim->DoDamage(damagemult*30/victim->protectionhigh);
2711 if(creature==wolftype){
2712 emit_sound_at(clawslicesound, victim->coords, 128.);
2714 victim->DoBloodBig(2/victim->armorhigh,170);
2721 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
2722 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
2724 if(id==0)camerashake+=.2;
2725 if(tutoriallevel!=1){
2726 emit_sound_at(landsound2, victim->coords, 128.);
2729 relative=victim->coords-coords;
2731 Normalise(&relative);
2733 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
2736 for(i=0;i<victim->skeleton.num_joints;i++){
2737 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
2739 relative=DoRotation(relative,0,-90,0);
2741 for(i=0;i<victim->skeleton.num_joints;i++){
2742 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)
2743 victim->skeleton.joints[i].velocity=relative*80;
2745 victim->Puff(rightankle);
2746 victim->Puff(leftankle);
2747 victim->DoDamage(damagemult*40/victim->protectionlow);
2750 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
2751 for(i=0;i<victim->skeleton.num_joints;i++){
2752 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
2754 relative=DoRotation(relative,0,-90,0);
2755 for(i=0;i<victim->skeleton.num_joints;i++){
2756 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)
2757 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
2759 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2760 victim->targetframe=0;
2761 victim->targetanimation=staggerbackhighanim;
2762 victim->targetrotation=targetrotation+180;
2764 if(tutoriallevel!=1){
2765 emit_sound_at(landsound2, victim->coords, 128.);
2767 victim->Puff(abdomen);
2768 victim->DoDamage(damagemult*30/victim->protectionlow);
2776 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
2777 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
2779 if(id==0)camerashake+=.4;
2784 if(tutoriallevel!=1){
2785 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2787 if(creature==wolftype){
2788 emit_sound_at(clawslicesound, victim->coords, 128);
2790 victim->DoBloodBig(2/victim->armorhigh,170);
2794 relative=victim->coords-oldcoords;
2796 Normalise(&relative);
2797 //relative=DoRotation(relative,0,-90,0);
2798 for(i=0;i<victim->skeleton.num_joints;i++){
2799 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2801 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2803 victim->Puff(abdomen);
2804 victim->DoDamage(damagemult*150/victim->protectionhigh);
2806 award_bonus(id, Reversal);
2809 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
2810 if(victim->weaponactive!=-1&&victim->num_weapons>0){
2811 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
2812 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
2815 weaponids[num_weapons]=weaponids[victim->weaponactive];
2818 weaponids[0]=victim->weaponids[victim->weaponactive];
2819 victim->num_weapons--;
2820 if(victim->num_weapons>0){
2821 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
2822 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
2824 victim->weaponactive=-1;
2829 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
2831 if(id==0)camerashake+=.4;
2836 emit_sound_at(whooshhitsound, victim->coords, 128.);
2839 relative=victim->coords-oldcoords;
2841 Normalise(&relative);
2842 //relative=DoRotation(relative,0,-90,0);
2843 for(i=0;i<victim->skeleton.num_joints;i++){
2844 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2846 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2849 victim->DoDamage(damagemult*70/victim->protectionhigh);
2852 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
2854 if(id==0)camerashake+=.4;
2860 award_bonus(id, staffreversebonus);
2862 if(tutoriallevel!=1){
2863 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2866 award_bonus(id, staffreversebonus); // Huh, again?
2869 relative=victim->coords-oldcoords;
2871 Normalise(&relative);
2872 //relative=DoRotation(relative,0,-90,0);
2873 for(i=0;i<victim->skeleton.num_joints;i++){
2874 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2876 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2879 victim->DoDamage(damagemult*70/victim->protectionhigh);
2882 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
2888 Normalise(&relative);
2891 for(i=0;i<victim->skeleton.num_joints;i++){
2892 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
2894 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
2895 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
2896 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
2897 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
2898 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
2899 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
2900 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
2901 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
2903 victim->Puff(abdomen);
2904 victim->DoDamage(damagemult*90/victim->protectionhigh);
2906 award_bonus(id, Reversal);
2910 if(weaponactive!=-1||creature==wolftype)doslice=1;
2911 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
2913 if(weaponactive!=-1){
2914 victim->DoBloodBig(2/victim->armorhigh,225);
2915 emit_sound_at(knifeslicesound, victim->coords);
2916 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
2917 weapons.blooddrip[weaponids[weaponactive]]+=3;
2919 if(weaponactive==-1&&creature==wolftype){;
2920 emit_sound_at(clawslicesound, victim->coords, 128.);
2922 victim->DoBloodBig(2/victim->armorhigh,175);
2929 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
2935 Normalise(&relative);
2938 for(i=0;i<victim->skeleton.num_joints;i++){
2939 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
2941 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
2942 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
2943 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
2944 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
2945 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
2946 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
2947 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
2948 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
2950 award_bonus(id, swordreversebonus);
2953 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
2955 if(id==0)camerashake+=.4;
2960 if(tutoriallevel!=1){
2961 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2965 relative=victim->coords-oldcoords;
2967 Normalise(&relative);
2968 relative=DoRotation(relative,0,-90,0);
2969 for(i=0;i<victim->skeleton.num_joints;i++){
2970 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2972 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2974 victim->Puff(abdomen);
2975 victim->DoDamage(damagemult*30/victim->protectionhigh);
2977 award_bonus(id, Reversal);
2980 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
2983 victim->skeleton.spinny=0;
2987 Normalise(&relative);
2988 if(victim->id==0)relative/=30;
2989 for(i=0;i<victim->skeleton.num_joints;i++){
2990 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2992 //victim->DoDamage(1000);
2993 victim->damage=victim->damagetolerance;
2994 victim->permanentdamage=victim->damagetolerance-1;
2997 if(weaponactive!=-1||creature==wolftype)doslice=1;
2998 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3000 if(weaponactive!=-1){
3001 victim->DoBloodBig(200,225);
3002 emit_sound_at(knifeslicesound, victim->coords);
3003 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3004 weapons.blooddrip[weaponids[weaponactive]]+=5;
3007 if(creature==wolftype&&weaponactive==-1){
3008 emit_sound_at(clawslicesound, victim->coords, 128.);
3010 victim->DoBloodBig(2,175);
3013 award_bonus(id, spinecrusher);
3016 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3017 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3019 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3020 if(targetanimation==knifesneakattackanim){
3021 /*victim->DoBloodBig(200,195);
3026 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3027 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3029 XYZ footvel,footpoint;
3031 footpoint=weapons.tippoint[weaponids[0]];
3032 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3033 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3034 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3035 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3036 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3037 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3038 victim->DoBloodBig(200,195);
3039 award_bonus(id, tracheotomy);
3041 if(targetanimation==knifefollowanim){
3042 award_bonus(id, Stabbonus);
3043 XYZ footvel,footpoint;
3045 footpoint=weapons.tippoint[weaponids[0]];
3046 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3047 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3048 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3049 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3050 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3051 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3054 victim->bloodloss+=10000;
3056 emit_sound_at(fleshstabsound, victim->coords);
3057 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3058 weapons.blooddrip[weaponids[weaponactive]]+=5;
3062 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
3065 for(i=0;i<victim->skeleton.num_joints;i++){
3066 victim->skeleton.joints[i].velocity=0;
3068 if(targetanimation==knifefollowanim){
3070 for(i=0;i<victim->skeleton.num_joints;i++){
3071 victim->skeleton.joints[i].velocity=0;
3074 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
3075 emit_sound_at(fleshstabremovesound, victim->coords);
3076 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3077 weapons.blooddrip[weaponids[weaponactive]]+=5;
3079 XYZ footvel,footpoint;
3081 footpoint=weapons.tippoint[weaponids[0]];
3082 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3083 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3084 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3085 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3086 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3087 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3091 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3092 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3093 award_bonus(id, backstab);
3097 XYZ footvel,footpoint;
3099 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
3100 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3101 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3102 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3103 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3104 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3105 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3106 victim->DoBloodBig(200,180);
3107 victim->DoBloodBig(200,215);
3108 victim->bloodloss+=10000;
3110 emit_sound_at(fleshstabsound, victim->coords);
3111 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3112 weapons.blooddrip[weaponids[weaponactive]]+=5;
3116 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
3119 for(i=0;i<victim->skeleton.num_joints;i++){
3120 victim->skeleton.joints[i].velocity=0;
3122 if(weaponactive!=-1){
3123 emit_sound_at(fleshstabremovesound, victim->coords);
3124 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3125 weapons.blooddrip[weaponids[weaponactive]]+=5;
3127 XYZ footvel,footpoint;
3129 footpoint=weapons.tippoint[weaponids[0]];
3130 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3131 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3132 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3133 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3134 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3135 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3139 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
3141 if(id==0)camerashake+=.4;
3146 if(weaponactive==-1){
3147 if(tutoriallevel!=1){
3148 emit_sound_at(heavyimpactsound, victim->coords, 128.);
3153 if(weaponactive!=-1||creature==wolftype)doslice=1;
3154 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3156 if(weaponactive!=-1){
3157 victim->DoBloodBig(2/victim->armorhead,225);
3158 emit_sound_at(knifeslicesound, victim->coords);
3159 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3160 weapons.blooddrip[weaponids[weaponactive]]+=3;
3162 if(weaponactive==-1&&creature==wolftype){
3163 emit_sound_at(clawslicesound, victim->coords, 128.);
3165 victim->DoBloodBig(2/victim->armorhead,175);
3169 award_bonus(id, Reversal);
3174 //relative=victim->coords-oldcoords;
3177 Normalise(&relative);
3178 relative=DoRotation(relative,0,90,0);
3180 Normalise(&relative);
3181 for(i=0;i<victim->skeleton.num_joints;i++){
3182 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
3184 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3185 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
3186 victim->DoDamage(damagemult*100/victim->protectionhead);
3190 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
3194 //relative=victim->coords-oldcoords;
3197 Normalise(&relative);
3198 relative=DoRotation(relative,0,90,0);
3200 Normalise(&relative);
3201 for(i=0;i<victim->skeleton.num_joints;i++){
3202 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
3204 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3207 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
3208 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
3209 award_bonus(id, reverseko);
3215 if(targetframe>animation[currentanimation].numframes-1){
3218 targetanimation=getIdle();
3222 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
3223 targetanimation=rollanim;
3225 emit_sound_at(movewhooshsound, coords, 128.);
3227 if(currentanimation==staggerbackhighanim){
3228 targetanimation=getIdle();
3230 if(currentanimation==staggerbackhardanim){
3231 targetanimation=getIdle();
3233 if(currentanimation==removeknifeanim){
3234 targetanimation=getIdle();
3236 if(currentanimation==crouchremoveknifeanim){
3237 targetanimation=getCrouch();
3239 if(currentanimation==backhandspringanim){
3240 targetanimation=getIdle();
3242 if(currentanimation==dodgebackanim){
3243 targetanimation=getIdle();
3245 if(currentanimation==drawleftanim){
3246 targetanimation=getIdle();
3248 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
3249 targetanimation=getIdle();
3250 if(currentanimation==crouchdrawrightanim){
3251 targetanimation=getCrouch();
3253 if(weaponactive==-1)weaponactive=0;
3254 else if(weaponactive==0){
3258 buffer=weaponids[0];
3259 weaponids[0]=weaponids[1];
3260 weaponids[1]=buffer;
3264 if(weaponactive==-1){
3265 emit_sound_at(knifesheathesound, coords, 128.);
3267 if(weaponactive!=-1){
3268 emit_sound_at(knifedrawsound, coords, 128.);
3271 if(currentanimation==rollanim){
3272 targetanimation=getCrouch();
3277 if(targetanimation==walljumprightkickanim){
3280 if(targetanimation==walljumpleftkickanim){
3283 targetanimation=jumpdownanim;
3285 if(currentanimation==climbanim){
3286 targetanimation=getCrouch();
3289 if(!isnormal(coords.x))
3300 if(targetanimation==rabbitkickreversalanim){
3301 targetanimation=getCrouch();
3304 if(targetanimation==jumpreversalanim){
3305 targetanimation=getCrouch();
3308 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
3309 if(attackkeydown&&targetanimation!=walljumpfrontanim){
3311 float closestdist=-1;
3314 for(i=0;i<numplayers;i++){
3315 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
3316 distance=findDistancefast(&player[i].coords,&coords);
3317 if(closestdist==-1||distance<closestdist){
3318 closestdist=distance;
3323 if(closestdist>0&&closest>=0&&closestdist<16){
3324 victim=&player[closest];
3325 targetanimation=walljumprightkickanim;
3327 XYZ rotatetarget=victim->coords-coords;
3328 Normalise(&rotatetarget);
3329 rotation=-asin(0-rotatetarget.x);
3331 if(rotatetarget.z<0)rotation=180-rotation;
3332 targettilt2=-asin(rotatetarget.y)*360/6.28;
3333 velocity=(victim->coords-coords)*4;
3338 if(targetanimation==walljumpbackanim){
3339 targetanimation=backflipanim;
3344 resume_stream(whooshsound);
3346 if(targetanimation==walljumprightanim){
3347 targetanimation=rightflipanim;
3351 velocity=DoRotation(facing,0,30,0)*-8;
3354 if(targetanimation==walljumpfrontanim){
3355 targetanimation=frontflipanim;
3357 //targetrotation-=180;
3363 resume_stream(whooshsound);
3365 if(targetanimation==walljumpleftanim){
3368 float closestdist=-1;
3371 for(i=0;i<numplayers;i++){
3372 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
3373 distance=findDistancefast(&player[i].coords,&coords);
3374 if(closestdist==-1||distance<closestdist){
3375 closestdist=distance;
3380 if(closestdist>0&&closest>=0&&closestdist<16){
3381 victim=&player[closest];
3382 targetanimation=walljumpleftkickanim;
3384 XYZ rotatetarget=victim->coords-coords;
3385 Normalise(&rotatetarget);
3386 rotation=-asin(0-rotatetarget.x);
3388 if(rotatetarget.z<0)rotation=180-rotation;
3389 targettilt2=-asin(rotatetarget.y)*360/6.28;
3390 velocity=(victim->coords-coords)*4;
3395 if(targetanimation!=walljumpleftkickanim){
3396 targetanimation=leftflipanim;
3400 velocity=DoRotation(facing,0,-30,0)*-8;
3404 resume_stream(whooshsound);
3406 if(targetanimation==sneakattackanim){
3407 float ycoords=oldcoords.y;
3408 currentanimation=getCrouch();
3409 targetanimation=getCrouch();
3412 targetrotation+=180;
3417 targetheadrotation+=180;
3419 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
3423 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
3424 float ycoords=oldcoords.y;
3425 targetanimation=getIdle();
3427 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
3431 if(currentanimation==knifefollowanim){
3432 targetanimation=getIdle();
3435 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
3436 float ycoords=oldcoords.y;
3437 targetanimation=getStop();
3438 targetrotation+=180;
3443 targetheadrotation+=180;
3444 if(!isnormal(coords.x))
3446 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
3447 oldcoords=coords+facing*.5;
3448 else if(currentanimation==sweepreversalanim)
3449 oldcoords=coords+facing*1.1;
3450 else if(currentanimation==upunchreversalanim){
3451 oldcoords=coords+facing*1.5;
3452 targetrotation+=180;
3454 targetheadrotation+=180;
3458 else if(currentanimation==knifeslashreversalanim){
3459 oldcoords=coords+facing*.5;
3462 targetheadrotation+=90;
3466 else if(currentanimation==staffspinhitreversalanim){
3467 targetrotation+=180;
3469 targetheadrotation+=180;
3473 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
3474 else oldcoords.y=ycoords;
3475 currentoffset=coords-oldcoords;
3481 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
3486 if(animation[targetanimation].attack==reversed){
3488 if(targetanimation==sweepreversedanim)targetrotation+=90;
3489 targetanimation=backhandspringanim;
3491 emit_sound_at(landsound, coords, 128);
3493 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
3494 targetanimation=rollanim;
3497 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
3498 coords.y=oldcoords.y;
3500 if(currentanimation==knifeslashreversedanim){
3501 targetanimation=rollanim;
3506 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
3507 coords.y=oldcoords.y;
3511 targetanimation=jumpdownanim;
3513 if(wasLanding())targetanimation=getIdle();
3514 if(wasLandhard())targetanimation=getIdle();
3515 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
3516 targetanimation=getIdle();
3518 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
3519 coords.y=oldcoords.y;
3520 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
3521 targetoffset.y=coords.y;
3522 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
3523 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
3524 currentoffset.y-=(coords.y-targetoffset.y);
3525 coords.y=targetoffset.y;
3527 normalsupdatedelay=0;
3529 if(currentanimation==upunchanim){
3530 targetanimation=getStop();
3531 normalsupdatedelay=0;
3534 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
3535 targetrotation=rotation;
3538 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
3539 if(!hasstaff)DoDamage(35);
3542 rabbitkickragdoll=1;
3544 if(currentanimation==rabbitkickreversedanim){
3551 SolidHitBonus(!id); // FIXME: tricky id
3555 targetanimation=rollanim;
3557 if(id==0)pause_sound(whooshsound);
3561 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
3567 if(currentanimation==jumpreversedanim){
3574 SolidHitBonus(!id); // FIXME: tricky id
3578 targetanimation=rollanim;
3580 if(id==0)pause_sound(whooshsound);
3585 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){
3586 targetanimation=getupfromfrontanim;
3589 else if(animation[currentanimation].attack==normalattack){
3590 targetanimation=getIdle();
3593 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
3594 targetanimation=blockhighleftstrikeanim;
3596 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
3597 targetanimation=getIdle();
3600 if(currentanimation==spinkickanim&&victim->skeleton.free){
3601 if(creature==rabbittype)targetanimation=fightidleanim;
3606 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
3608 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
3609 targetanimation=jumpdownanim;
3614 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
3615 if(!isRun()||!wasRun()){
3616 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
3617 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
3618 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
3619 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
3621 if(isRun()&&wasRun()){
3624 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
3625 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
3628 else if(transspeed)target+=multiplier*transspeed*speed*2;
3630 if(!isRun()||!wasRun()){
3631 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
3632 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
3633 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
3634 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
3638 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
3640 if(target>1){currentframe=targetframe; target=1;}
3642 rot=targetrot*target;
3643 rotation+=rot-oldrot;
3649 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
3651 for(i=0;i<skeleton.num_joints;i++){
3652 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
3655 skeleton.FindForwards();
3657 for(i=0;i<skeleton.num_muscles;i++){
3658 if(skeleton.muscles[i].visible)
3660 skeleton.FindRotationMuscle(i,targetanimation);
3663 for(i=0;i<skeleton.num_muscles;i++){
3664 if(skeleton.muscles[i].visible)
3666 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
3667 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
3668 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
3673 for(i=0;i<skeleton.num_joints;i++){
3674 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
3677 skeleton.FindForwards();
3679 for(i=0;i<skeleton.num_muscles;i++){
3680 if(skeleton.muscles[i].visible)
3682 skeleton.FindRotationMuscle(i,targetanimation);
3685 for(i=0;i<skeleton.num_muscles;i++){
3686 if(skeleton.muscles[i].visible)
3688 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
3689 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
3690 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
3691 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
3692 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
3693 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
3694 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
3695 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
3696 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
3700 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
3702 oldcurrentanimation=currentanimation;
3703 oldtargetanimation=targetanimation;
3704 oldtargetframe=targetframe;
3705 oldcurrentframe=currentframe;
3707 for(i=0;i<skeleton.num_joints;i++){
3708 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
3709 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
3711 offset=currentoffset*(1-target)+targetoffset*target;
3712 for(i=0;i<skeleton.num_muscles;i++){
3713 if(skeleton.muscles[i].visible)
3715 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
3716 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
3717 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
3722 if(isLanding()&&landhard){
3723 if(id==0)camerashake+=.4;
3724 targetanimation=getLandhard();
3731 //skeleton.DoConstraints();
3734 void Person::DoStuff(){
3735 static XYZ terrainnormal;
3736 static XYZ flatfacing;
3737 static XYZ flatvelocity;
3738 static float flatvelspeed;
3742 static int bloodsize;
3743 static int startx,starty,endx,endy;
3744 static int texdetailint;
3745 static GLubyte color;
3746 static XYZ bloodvel;
3748 onfiredelay-=multiplier;
3749 if(onfiredelay<0&&onfire)
3757 crouchkeydowntime+=multiplier;
3758 if(!crouchkeydown)crouchkeydowntime=0;
3759 jumpkeydowntime+=multiplier;
3760 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
3762 if(hostile||damage>0||bloodloss>0)immobile=0;
3764 if(isIdle()||isRun())targetoffset=0;
3766 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
3768 if(id==0)blooddimamount-=multiplier*.3;
3769 speechdelay-=multiplier;
3770 texupdatedelay-=multiplier;
3771 interestdelay-=multiplier;
3772 flamedelay-=multiplier;
3773 parriedrecently-=multiplier;
3779 if(id==0)speed=1.1*speedmult;
3780 else speed=1.0*speedmult;
3781 if(!skeleton.free)rabbitkickragdoll=0;
3785 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
3786 if(id!=0&&creature==wolftype&&difficulty==2){
3788 if(aitype!=passivetype){
3790 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){
3794 if(scale<0.2)superruntoggle=0;
3795 if(targetanimation==wolfrunninganim&&!superruntoggle){
3796 targetanimation=getRun();
3800 if(weaponactive==-1&&num_weapons>0){
3801 if(weapons.type[weaponids[0]]==staff){
3808 /*if(aitype!=playercontrolled)*///deathbleeding=5;
3809 /*if(aitype!=playercontrolled)*/
3811 if(burnt>.6)burnt=.6;
3812 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
3814 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
3825 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
3826 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
3830 while(flamedelay<0&&onfire){
3832 howmany=abs(Random()%(skeleton.num_joints));
3833 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
3834 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
3835 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
3836 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
3837 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
3840 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
3842 howmany=abs(Random()%(skeleton.num_joints));
3843 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
3844 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
3845 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
3846 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
3847 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
3851 bleeding-=multiplier*.3;
3853 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
3854 if(bleeding<=0&&(detail!=2||osx))DoMipmaps();
3858 if(neckspurtamount>0){
3859 neckspurtamount-=multiplier;
3860 neckspurtdelay-=multiplier*3;
3861 neckspurtparticledelay-=multiplier*3;
3862 if(neckspurtparticledelay<0&&neckspurtdelay>2){
3866 bloodvel.z=5*neckspurtamount;
3867 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
3870 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
3872 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
3873 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
3874 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);
3875 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);
3876 neckspurtparticledelay=.05;
3878 if(neckspurtdelay<0){
3883 if(deathbleeding>0&&dead!=2){
3884 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
3885 else bleeddelay-=5*multiplier/4;
3886 if(bleeddelay<0&&bloodtoggle){
3891 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3892 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
3893 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
3894 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);
3897 bloodloss+=deathbleeding*multiplier*80;
3898 deathbleeding-=multiplier*1.6;
3899 //if(id==0)deathbleeding-=multiplier*.2;
3900 if(deathbleeding<0)deathbleeding=0;
3901 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
3902 if(weaponactive!=-1){
3903 weapons.owner[weaponids[0]]=-1;
3904 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
3905 weapons.velocity[weaponids[0]].x+=.01;
3906 weapons.tipvelocity[weaponids[0]]=velocity*scale;
3907 weapons.missed[weaponids[0]]=1;
3908 weapons.hitsomething[weaponids[0]]=0;
3909 weapons.freetime[weaponids[0]]=0;
3910 weapons.firstfree[weaponids[0]]=1;
3911 weapons.physics[weaponids[0]]=1;
3914 weaponids[0]=weaponids[num_weapons];
3915 if(weaponstuck==num_weapons)weaponstuck=0;
3918 for(i=0;i<numplayers;i++){
3919 player[i].wentforweapon=0;
3931 if(!dead&&creature==wolftype){
3932 award_bonus(0, Wolfbonus);
3935 if(targetanimation==knifefollowedanim&&!skeleton.free){
3936 for(i=0;i<skeleton.num_joints;i++){
3937 skeleton.joints[i].velocity=0;
3938 skeleton.joints[i].velocity.y=-2;
3941 if(id!=0&&unconscioustime>.1){
3949 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
3952 bloodsize=5-realtexdetail;
3956 texdetailint=realtexdetail;
3957 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
3958 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
3959 endx=startx+bloodsize;
3960 endy=starty+bloodsize;
3962 if(startx<0){startx=0;bleeding=0;}
3963 if(starty<0){starty=0;bleeding=0;}
3964 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
3965 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
3966 if(endx<startx)endx=startx;
3967 if(endy<starty)endy=starty;
3969 for(i=startx;i<endx;i++){
3970 for(j=starty;j<endy;j++){
3972 color=Random()%85+170;
3973 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
3974 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
3975 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
3980 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
3985 bleedy-=4/realtexdetail;
3986 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
3987 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
3990 bleedx+=4*direction/realtexdetail;
3991 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
3992 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
3996 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
3997 righthandmorphness=targetrighthandmorphness;
3998 righthandmorphstart=righthandmorphend;
4000 else if(righthandmorphness>targetrighthandmorphness){
4001 righthandmorphness-=multiplier*4;
4003 else if(righthandmorphness<targetrighthandmorphness){
4004 righthandmorphness+=multiplier*4;
4007 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
4008 lefthandmorphness=targetlefthandmorphness;
4009 lefthandmorphstart=lefthandmorphend;
4011 else if(lefthandmorphness>targetlefthandmorphness){
4012 lefthandmorphness-=multiplier*4;
4014 else if(lefthandmorphness<targetlefthandmorphness){
4015 lefthandmorphness+=multiplier*4;
4018 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
4019 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
4020 tailmorphness=targettailmorphness;
4021 tailmorphstart=tailmorphend;
4023 else if(tailmorphness>targettailmorphness){
4024 tailmorphness-=multiplier*10;
4026 else if(tailmorphness<targettailmorphness){
4027 tailmorphness+=multiplier*10;
4031 if(creature==wolftype){
4032 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
4033 tailmorphness=targettailmorphness;
4034 tailmorphstart=tailmorphend;
4036 else if(tailmorphness>targettailmorphness){
4037 tailmorphness-=multiplier*2;
4039 else if(tailmorphness<targettailmorphness){
4040 tailmorphness+=multiplier*2;
4044 if(headmorphend==3||headmorphstart==3){
4045 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
4046 headmorphness=targetheadmorphness;
4047 headmorphstart=headmorphend;
4049 else if(headmorphness>targetheadmorphness){
4050 headmorphness-=multiplier*7;
4052 else if(headmorphness<targetheadmorphness){
4053 headmorphness+=multiplier*7;
4056 else if(headmorphend==5||headmorphstart==5){
4057 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
4058 headmorphness=targetheadmorphness;
4059 headmorphstart=headmorphend;
4061 else if(headmorphness>targetheadmorphness){
4062 headmorphness-=multiplier*10;
4064 else if(headmorphness<targetheadmorphness){
4065 headmorphness+=multiplier*10;
4069 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
4070 headmorphness=targetheadmorphness;
4071 headmorphstart=headmorphend;
4073 else if(headmorphness>targetheadmorphness){
4074 headmorphness-=multiplier*4;
4076 else if(headmorphness<targetheadmorphness){
4077 headmorphness+=multiplier*4;
4081 if(abs(chestmorphness-targetchestmorphness)<multiplier){
4082 chestmorphness=targetchestmorphness;
4083 chestmorphstart=chestmorphend;
4085 else if(chestmorphness>targetchestmorphness){
4086 chestmorphness-=multiplier;
4088 else if(chestmorphness<targetchestmorphness){
4089 chestmorphness+=multiplier;
4092 if(dead!=2&&howactive<=typesleeping){
4093 if(chestmorphstart==0&&chestmorphend==0){
4095 targetchestmorphness=1;
4098 if(chestmorphstart!=0&&chestmorphend!=0){
4100 targetchestmorphness=1;
4102 if(environment==snowyenvironment){
4105 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
4106 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
4107 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
4108 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
4109 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
4110 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
4114 if(!dead&&howactive<typesleeping){
4115 blinkdelay-=multiplier*2;
4116 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
4118 targetheadmorphness=1;
4120 blinkdelay=(float)(abs(Random()%40))/5;
4122 if(headmorphstart==3&&headmorphend==3){
4124 targetheadmorphness=1;
4129 twitchdelay-=multiplier*1.5;
4130 if(targetanimation!=hurtidleanim){
4131 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
4133 targetheadmorphness=1;
4135 twitchdelay=(float)(abs(Random()%40))/5;
4137 if(headmorphstart==5&&headmorphend==5){
4139 targetheadmorphness=1;
4143 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
4144 twitchdelay3-=multiplier*1;
4146 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
4147 righthandmorphness=0;
4148 targetrighthandmorphness=1;
4149 righthandmorphend=1;
4150 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
4152 if(righthandmorphstart==1&&righthandmorphend==1){
4153 righthandmorphness=0;
4154 targetrighthandmorphness=1;
4155 righthandmorphend=0;
4159 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
4160 lefthandmorphness=0;
4161 targetlefthandmorphness=1;
4163 twitchdelay3=(float)(abs(Random()%40))/5;
4165 if(lefthandmorphstart==1&&lefthandmorphend==1){
4166 lefthandmorphness=0;
4167 targetlefthandmorphness=1;
4174 if(creature==rabbittype){
4175 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
4176 else twitchdelay2-=multiplier*0.5;
4177 if(howactive<=typesleeping){
4178 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
4180 targettailmorphness=1;
4182 twitchdelay2=(float)(abs(Random()%40))/5;
4184 if(tailmorphstart==1&&tailmorphend==1){
4186 targettailmorphness=1;
4189 if(tailmorphstart==2&&tailmorphend==2){
4191 targettailmorphness=1;
4198 if(creature==wolftype){
4199 twitchdelay2-=multiplier*1.5;
4201 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
4203 targettailmorphness=1;
4208 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
4210 targettailmorphness=1;
4214 if(twitchdelay2<=0){
4215 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
4217 targettailmorphness=1;
4220 if(tailmorphstart==1&&tailmorphend==1){
4222 targettailmorphness=1;
4225 if(tailmorphstart==2&&tailmorphend==2){
4227 targettailmorphness=1;
4230 if(tailmorphstart==3&&tailmorphend==3){
4232 targettailmorphness=1;
4235 if(tailmorphstart==4&&tailmorphend==4){
4237 targettailmorphness=1;
4243 if(dead!=1)unconscioustime=0;
4245 if(dead==1||howactive==typesleeping){
4246 unconscioustime+=multiplier;
4247 //If unconscious, close eyes and mouth
4248 if(righthandmorphend!=0)righthandmorphness=0;
4249 righthandmorphend=0;
4250 targetrighthandmorphness=1;
4252 if(lefthandmorphend!=0)lefthandmorphness=0;
4254 targetlefthandmorphness=1;
4256 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
4258 targetheadmorphness=1;
4262 if(howactive>typesleeping){
4265 if(bloodtoggle&&!bled){
4266 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
4268 if(bloodtoggle&&!bled)
4269 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
4270 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
4271 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
4275 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
4280 if(dead==2||howactive>typesleeping){
4281 //If dead, open mouth and hands
4282 if(righthandmorphend!=0)righthandmorphness=0;
4283 righthandmorphend=0;
4284 targetrighthandmorphness=1;
4286 if(lefthandmorphend!=0)lefthandmorphness=0;
4288 targetlefthandmorphness=1;
4290 if(headmorphend!=2)headmorphness=0;
4292 targetheadmorphness=1;
4295 if(stunned>0&&!dead&&headmorphend!=2){
4296 if(headmorphend!=4)headmorphness=0;
4298 targetheadmorphness=1;
4301 if(damage>damagetolerance&&!dead){
4306 if(creature==wolftype){
4307 award_bonus(0, Wolfbonus);
4312 if(weaponactive!=-1){
4313 weapons.owner[weaponids[0]]=-1;
4314 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4315 weapons.velocity[weaponids[0]].x+=.01;
4316 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4317 weapons.missed[weaponids[0]]=1;
4318 weapons.hitsomething[weaponids[0]]=0;
4319 weapons.freetime[weaponids[0]]=0;
4320 weapons.firstfree[weaponids[0]]=1;
4321 weapons.physics[weaponids[0]]=1;
4324 weaponids[0]=weaponids[num_weapons];
4325 if(weaponstuck==num_weapons)weaponstuck=0;
4328 for(i=0;i<numplayers;i++){
4329 player[i].wentforweapon=0;
4335 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
4343 //if(dead)damage-=multiplier/4;
4344 if(!dead)damage-=multiplier*13;
4345 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
4346 if(!dead)permanentdamage-=multiplier*4;
4347 if(isIdle()||isCrouch()){
4348 if(!dead)permanentdamage-=multiplier*4;
4349 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
4351 if(damage<0)damage=0;
4352 if(permanentdamage<0)permanentdamage=0;
4353 if(superpermanentdamage<0)superpermanentdamage=0;
4354 if(permanentdamage<superpermanentdamage){
4355 permanentdamage=superpermanentdamage;
4357 if(damage<permanentdamage){
4358 damage=permanentdamage;
4360 if(dead==1&&damage<damagetolerance){
4364 for(i=0;i<skeleton.num_joints;i++){
4365 skeleton.joints[i].velocity=0;
4368 if(permanentdamage>damagetolerance&&dead!=2){
4371 if(weaponactive!=-1){
4372 weapons.owner[weaponids[0]]=-1;
4373 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4374 weapons.velocity[weaponids[0]].x+=.01;
4375 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4376 weapons.missed[weaponids[0]]=1;
4377 weapons.hitsomething[weaponids[0]]=0;
4378 weapons.freetime[weaponids[0]]=0;
4379 weapons.firstfree[weaponids[0]]=1;
4380 weapons.physics[weaponids[0]]=1;
4383 weaponids[0]=weaponids[num_weapons];
4384 if(weaponstuck==num_weapons)weaponstuck=0;
4387 for(i=0;i<numplayers;i++){
4388 player[i].wentforweapon=0;
4394 if(!dead&&creature==wolftype){
4395 award_bonus(0, Wolfbonus);
4398 if(unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance)
4399 award_bonus(id, touchofdeath);
4400 if(id!=0&&unconscioustime>.1){
4408 emit_sound_at(breaksound, coords);
4411 if(skeleton.free==1){
4412 if(id==0)pause_sound(whooshsound);
4415 //If knocked over, open hands and close mouth
4416 if(righthandmorphend!=0)righthandmorphness=0;
4417 righthandmorphend=0;
4418 targetrighthandmorphness=1;
4420 if(lefthandmorphend!=0)lefthandmorphness=0;
4422 targetlefthandmorphness=1;
4424 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
4425 if(headmorphend!=0)headmorphness=0;
4427 targetheadmorphness=1;
4431 skeleton.DoGravity(&scale);
4433 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
4434 if(damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1))
4435 award_bonus(id, deepimpact);
4436 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
4440 for(j=0;j<skeleton.num_joints;j++){
4441 average+=skeleton.joints[j].position;
4445 coords+=average*scale;
4446 for(j=0;j<skeleton.num_joints;j++){
4447 skeleton.joints[j].position-=average;
4449 average/=multiplier;
4451 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
4453 for(i=0;i<skeleton.num_joints;i++){
4454 velocity+=skeleton.joints[i].velocity*scale;
4456 velocity/=skeleton.num_joints;
4458 if(!isnormal(velocity.x)&&velocity.x){
4471 if(findLength(&average)<10&&dead&&skeleton.free){
4472 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
4473 if(skeleton.longdead>2000){
4474 if(skeleton.longdead>6000){
4475 if(id==0)pause_sound(whooshsound);
4480 if(dead==2&&bloodloss<damagetolerance){
4482 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
4484 if(bloodtoggle&&!bled){
4485 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
4487 if(bloodtoggle&&!bled)
4488 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
4489 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
4490 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
4494 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
4498 if(dead==2&&bloodloss>=damagetolerance){
4500 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
4501 if(bleeding<=0)DoBlood(1,255);
4502 if(bloodtoggle&&!bled){
4503 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
4505 if(bloodtoggle&&!bled)
4506 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
4507 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
4508 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
4512 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
4519 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
4521 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
4525 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
4526 if(velocity.y<-30)canrecover=0;
4527 for(i=0;i<objects.numobjects;i++){
4528 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
4529 colviewer=startpoint;
4531 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
4539 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4540 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
4541 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4542 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4544 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4545 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4546 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4548 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4549 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4550 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
4552 Normalise(&terrainnormal);
4554 targetrotation=-asin(0-terrainnormal.x);
4555 targetrotation*=360/6.28;
4556 if(terrainnormal.z<0)targetrotation=180-targetrotation;
4557 rotation=targetrotation;
4561 targetanimation=flipanim;
4562 crouchtogglekeydown=1;
4567 currentanimation=tempanim;
4570 //tilt2=targettilt2;
4572 //if(middle.y>0)targetoffset.y=middle.y+1;
4574 for(i=0;i<skeleton.num_joints;i++){
4575 tempanimation.position[i][0]=skeleton.joints[i].position;
4576 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
4581 if(findLength(&average)<10&&!dead&&skeleton.free){
4582 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
4583 if(skeleton.longdead>(damage+500)*1.5){
4584 if(id==0)pause_sound(whooshsound);
4590 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4591 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
4592 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4593 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4595 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4596 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4597 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4599 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4600 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4601 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
4603 Normalise(&terrainnormal);
4605 targetrotation=-asin(0-terrainnormal.x);
4606 targetrotation*=360/6.28;
4607 if(terrainnormal.z<0)targetrotation=180-targetrotation;
4608 rotation=targetrotation;
4611 terrainnormal=terrain.getNormal(coords.x,coords.z);
4612 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
4616 /*XYZ otherterrainnormal;
4617 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
4618 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
4619 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
4620 targettilt2=asin(otherterrainnormal.y)*180/3.14;
4623 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
4627 if(skeleton.forward.y<0){
4628 targetanimation=getupfrombackanim;
4632 if(skeleton.forward.y>-.3){
4633 targetanimation=getupfromfrontanim;
4635 targetrotation+=180;
4641 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
4642 targetanimation=rollanim;
4643 targetrotation=lookrotation;
4647 if(forwardkeydown)targetrotation+=45;
4648 if(backkeydown)targetrotation-=45;
4652 if(forwardkeydown)targetrotation-=45;
4653 if(backkeydown)targetrotation+=45;
4656 if ( !leftkeydown&&!rightkeydown)
4657 targetrotation+=180;
4659 targetrotation+=180;
4663 if(abs(targettilt2)>50)targettilt2=0;
4664 currentanimation=tempanim;
4669 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
4671 for(i=0;i<skeleton.num_joints;i++){
4672 tempanimation.position[i][0]=skeleton.joints[i].position;
4673 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
4680 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4681 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
4684 tempvelocity=velocity;
4685 Normalise(&tempvelocity);
4686 targetrotation=-asin(0-tempvelocity.x);
4687 targetrotation*=360/6.28;
4688 if(velocity.z<0)targetrotation=180-targetrotation;
4689 //targetrotation+=180;
4692 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
4693 targetanimation=rollanim;
4697 targetanimation=backhandspringanim;
4698 targetrotation+=180;
4703 emit_sound_at(movewhooshsound, coords, 128.);
4705 currentanimation=targetanimation;
4706 currentframe=targetframe-1;
4711 rotation=targetrotation;
4718 if(skeleton.freefall==0)freefall=0;
4720 if(!isnormal(velocity.x)&&velocity.x){
4725 if(aitype!=passivetype||skeleton.free==1)
4726 if(findLengthfast(&velocity)>.1)
4727 for(i=0;i<objects.numobjects;i++){
4728 if(objects.type[i]==firetype)
4729 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){
4731 if(!objects.onfire[i]){
4732 emit_sound_at(firestartsound, objects.position[i]);
4734 objects.onfire[i]=1;
4737 if(objects.onfire[i]){
4742 if(objects.type[i]==bushtype)
4743 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){
4745 if(!objects.onfire[i]){
4746 emit_sound_at(firestartsound, objects.position[i]);
4748 objects.onfire[i]=1;
4752 if(objects.onfire[i]){
4756 if(objects.messedwith[i]<=0){
4760 emit_sound_at(bushrustle, coords, 40*findLength(&velocity));
4763 envsound[numenvsounds]=coords;
4764 envsoundvol[numenvsounds]=4*findLength(&velocity);
4765 envsoundlife[numenvsounds]=.4;
4770 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
4771 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
4773 if(environment!=desertenvironment)
4774 for(j=0;j<howmany;j++){
4775 tempvel.x=float(abs(Random()%100)-50)/20;
4776 tempvel.y=float(abs(Random()%100)-50)/20;
4777 tempvel.z=float(abs(Random()%100)-50)/20;
4780 pos.x+=float(abs(Random()%100)-50)/200;
4781 pos.y+=float(abs(Random()%100)-50)/200;
4782 pos.z+=float(abs(Random()%100)-50)/200;
4783 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);
4784 Sprite::setLastSpriteSpecial(1);
4786 howmany=findLength(&velocity)*4;
4788 if(environment==snowyenvironment)
4789 for(j=0;j<howmany;j++){
4790 tempvel.x=float(abs(Random()%100)-50)/20;
4791 tempvel.y=float(abs(Random()%100)-50)/20;
4792 tempvel.z=float(abs(Random()%100)-50)/20;
4795 pos.x+=float(abs(Random()%100)-50)/200;
4796 pos.y+=float(abs(Random()%100)-50)/200;
4797 pos.z+=float(abs(Random()%100)-50)/200;
4798 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
4799 Sprite::setLastSpriteSpecial(2);
4802 objects.rotx[i]+=velocity.x*multiplier*6;
4803 objects.roty[i]+=velocity.z*multiplier*6;
4804 objects.messedwith[i]=.5;
4807 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
4808 if(objects.rotation2[i]==0)tempcoord=coords;
4810 tempcoord=coords-objects.position[i];
4811 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
4812 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
4813 tempcoord+=objects.position[i];
4815 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]){
4816 if(objects.messedwith[i]<=0){
4820 emit_sound_at(bushrustle, coords, 40*findLength(&velocity));
4823 envsound[numenvsounds]=coords;
4824 envsoundvol[numenvsounds]=4*findLength(&velocity);
4825 envsoundlife[numenvsounds]=.4;
4830 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
4831 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
4833 if(environment!=desertenvironment)
4834 for(j=0;j<howmany;j++){
4835 tempvel.x=float(abs(Random()%100)-50)/20;
4836 tempvel.y=float(abs(Random()%100)-50)/20;
4837 tempvel.z=float(abs(Random()%100)-50)/20;
4841 pos.x+=float(abs(Random()%100)-50)/150;
4842 pos.y+=float(abs(Random()%100)-50)/150;
4843 pos.z+=float(abs(Random()%100)-50)/150;
4844 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);
4845 Sprite::setLastSpriteSpecial(1);
4847 howmany=findLength(&velocity)*4;
4849 if(environment==snowyenvironment)
4850 for(j=0;j<howmany;j++){
4851 tempvel.x=float(abs(Random()%100)-50)/20;
4852 tempvel.y=float(abs(Random()%100)-50)/20;
4853 tempvel.z=float(abs(Random()%100)-50)/20;
4857 pos.x+=float(abs(Random()%100)-50)/150;
4858 pos.y+=float(abs(Random()%100)-50)/150;
4859 pos.z+=float(abs(Random()%100)-50)/150;
4860 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
4861 Sprite::setLastSpriteSpecial(2);
4864 objects.messedwith[i]=.5;
4872 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
4874 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
4875 if(tutoriallevel==1&&id!=0)play=0;
4876 if(play&&aitype!=playercontrolled){
4880 if(creature==rabbittype){
4881 if(i==0)whichsound=rabbitchitter;
4882 if(i==1)whichsound=rabbitchitter2;
4884 if(creature==wolftype){
4885 if(i==0)whichsound=growlsound;
4886 if(i==1)whichsound=growl2sound;
4892 emit_sound_at(whichsound, coords);
4896 if(targetanimation==staggerbackhighanim)staggerdelay=1;
4897 if(targetanimation==staggerbackhardanim)staggerdelay=1;
4898 staggerdelay-=multiplier;
4899 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
4900 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
4901 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
4902 targetanimation=getIdle();
4906 weaponmissdelay-=multiplier;
4907 highreversaldelay-=multiplier;
4908 lowreversaldelay-=multiplier;
4909 lastcollide-=multiplier;
4910 skiddelay-=multiplier;
4911 if(!isnormal(velocity.x)&&velocity.x){
4914 if(!isnormal(targettilt)&&targettilt){
4917 if(!isnormal(targettilt2)&&targettilt2){
4920 if(!isnormal(targetrotation)&&targetrotation){
4924 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
4925 //open hands and close mouth
4926 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
4927 righthandmorphness=0;
4928 righthandmorphend=0;
4929 targetrighthandmorphness=1;
4932 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
4933 lefthandmorphness=0;
4935 targetlefthandmorphness=1;
4938 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
4941 targetheadmorphness=1;
4945 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){
4946 //open hands and mouth
4947 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
4948 righthandmorphness=0;
4949 righthandmorphend=0;
4950 targetrighthandmorphness=1;
4953 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
4954 lefthandmorphness=0;
4956 targetlefthandmorphness=1;
4959 if(headmorphend!=1&&headmorphness==targetheadmorphness){
4962 targetheadmorphness=1;
4966 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
4967 //close hands and mouth
4968 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
4969 righthandmorphness=0;
4970 righthandmorphend=1;
4971 targetrighthandmorphness=1;
4974 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
4975 lefthandmorphness=0;
4977 targetlefthandmorphness=1;
4980 if(headmorphend!=0&&headmorphness==targetheadmorphness){
4983 targetheadmorphness=1;
4987 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){
4988 //close hands and yell
4989 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
4990 righthandmorphness=0;
4991 righthandmorphend=1;
4992 targetrighthandmorphness=1;
4995 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
4996 lefthandmorphness=0;
4998 targetlefthandmorphness=1;
5001 if(headmorphend!=2&&headmorphness==targetheadmorphness){
5004 targetheadmorphness=1;
5008 if(speechdelay>.25){
5009 if(headmorphend!=2)headmorphness=0;
5011 targetheadmorphness=1;
5017 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
5018 behind=(normaldotproduct(facing,coords-victim->coords)>0);
5022 if(!dead&&targetanimation!=hurtidleanim)
5023 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
5024 if(headmorphend!=4||headmorphness==targetheadmorphness){
5027 targetheadmorphness=1;
5031 if(weaponactive!=-1){
5032 if(weapons.type[weaponids[weaponactive]]!=staff){
5033 righthandmorphstart=1;
5034 righthandmorphend=1;
5036 if(weapons.type[weaponids[weaponactive]]==staff){
5037 righthandmorphstart=2;
5038 righthandmorphend=2;
5040 targetrighthandmorphness=1;
5043 terrainnormal=terrain.getNormal(coords.x,coords.z);
5045 if(animation[targetanimation].attack!=reversal){
5046 if(!isnormal(coords.x))
5054 flatfacing=DoRotation(flatfacing,0,rotation,0);
5056 ReflectVector(&facing,terrainnormal);
5059 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
5060 if(onterrain)targettilt2=-facing.y*20;
5064 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
5065 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5066 flatvelocity=velocity;
5068 flatvelspeed=findLength(&flatvelocity);
5069 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
5070 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
5071 if(velocity.y<0)targettilt2*=-1;
5072 if(velocity.y<0)targettilt*=-1;
5073 if(targettilt>25)targettilt=25;
5074 if(targettilt<-25)targettilt=-25;
5077 if(targettilt2>45)targettilt2=45;
5078 if(targettilt2<-45)targettilt2=-45;
5079 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
5080 else if(tilt2>targettilt2){
5081 tilt2-=multiplier*400;
5083 else if(tilt2<targettilt2){
5084 tilt2+=multiplier*400;
5086 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
5087 if(tilt2>25)tilt2=25;
5088 if(tilt2<-25)tilt2=-25;
5091 if(!isnormal(targettilt)&&targettilt){
5094 if(!isnormal(targettilt2)&&targettilt2){
5099 //if(!creature==wolftype||targetanimation==rabbitkickanim)
5100 if(targetanimation==rabbittackleanim){
5101 velocity+=facing*multiplier*speed*700*scale;
5102 velspeed=findLength(&velocity);
5103 if(velspeed>speed*65*scale){
5105 velspeed=speed*65*scale;
5108 velocity.y+=gravity*multiplier*20;
5109 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5110 velspeed=findLength(&velocity);
5111 velocity=flatfacing*velspeed;
5113 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
5114 if(isRun()||targetanimation==rabbitkickanim){
5115 velocity+=facing*multiplier*speed*700*scale;
5116 velspeed=findLength(&velocity);
5117 if(velspeed>speed*45*scale){
5119 velspeed=speed*45*scale;
5122 velocity.y+=gravity*multiplier*20;
5123 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5124 velspeed=findLength(&velocity);
5125 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
5126 velocity=flatfacing*velspeed;
5130 velocity+=facing*multiplier*speed*700*scale;
5131 velspeed=findLength(&velocity);
5132 if(creature==rabbittype){
5133 if(velspeed>speed*55*scale){
5135 velspeed=speed*55*scale;
5139 if(creature==wolftype){
5140 if(velspeed>speed*75*scale){
5142 velspeed=speed*75*scale;
5146 velocity.y+=gravity*multiplier*20;
5147 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5148 velspeed=findLength(&velocity);
5149 velocity=flatfacing*velspeed;
5152 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
5153 velocity+=facing*multiplier*speed*700*scale;
5154 velspeed=findLength(&velocity);
5155 if(velspeed>speed*45*scale){
5157 velspeed=speed*45*scale;
5160 velocity.y+=gravity*multiplier*20;
5161 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5162 velspeed=findLength(&velocity);
5163 velocity=flatfacing*velspeed;
5167 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
5168 velocity+=facing*multiplier*speed*700*scale;
5169 velspeed=findLength(&velocity);
5170 if(velspeed>speed*25*scale){
5172 velspeed=speed*25*scale;
5175 velocity.y+=gravity*multiplier*20;
5176 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5177 velspeed=findLength(&velocity);
5178 velocity=flatfacing*velspeed;
5181 if(targetanimation==sneakanim||targetanimation==walkanim){
5182 velocity+=facing*multiplier*speed*700*scale;
5183 velspeed=findLength(&velocity);
5184 if(velspeed>speed*12*scale){
5186 velspeed=speed*12*scale;
5189 velocity.y+=gravity*multiplier*20;
5190 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5191 velspeed=findLength(&velocity);
5192 velocity=flatfacing*velspeed;
5195 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
5196 velocity+=facing*multiplier*speed*700*scale;
5197 velspeed=findLength(&velocity);
5198 if(velspeed>speed*2*scale){
5200 velspeed=speed*2*scale;
5203 velocity.y+=gravity*multiplier*20;
5204 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5205 velspeed=findLength(&velocity);
5206 velocity=flatfacing*velspeed;
5210 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
5211 velocity-=facing*multiplier*speed*700*scale;
5212 velspeed=findLength(&velocity);
5213 if(velspeed>speed*2*scale){
5215 velspeed=speed*2*scale;
5218 velocity.y+=gravity*multiplier*20;
5219 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5220 velspeed=findLength(&velocity);
5221 velocity=flatfacing*velspeed*-1;
5224 if(targetanimation==fightsidestep){
5225 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
5226 velspeed=findLength(&velocity);
5227 if(velspeed>speed*12*scale){
5229 velspeed=speed*12*scale;
5232 velocity.y+=gravity*multiplier*20;
5233 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5234 velspeed=findLength(&velocity);
5235 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
5238 if(targetanimation==staggerbackhighanim){
5239 coords-=facing*multiplier*speed*16*scale;
5242 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
5243 coords-=facing*multiplier*speed*20*scale;
5247 if(targetanimation==backhandspringanim){
5248 //coords-=facing*multiplier*50*scale;
5249 velocity+=facing*multiplier*speed*700*scale*-1;
5250 velspeed=findLength(&velocity);
5251 if(velspeed>speed*50*scale){
5253 velspeed=speed*50*scale;
5256 velocity.y+=gravity*multiplier*20;
5257 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5258 velspeed=findLength(&velocity);
5259 velocity=flatfacing*velspeed*-1;
5261 if(targetanimation==dodgebackanim){
5262 //coords-=facing*multiplier*50*scale;
5263 velocity+=facing*multiplier*speed*700*scale*-1;
5264 velspeed=findLength(&velocity);
5265 if(velspeed>speed*60*scale){
5267 velspeed=speed*60*scale;
5270 velocity.y+=gravity*multiplier*20;
5271 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5272 velspeed=findLength(&velocity);
5273 velocity=flatfacing*velspeed*-1;
5276 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5277 velspeed=findLength(&velocity);
5281 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5282 velocity.y+=gravity*multiplier;
5285 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
5287 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
5288 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
5290 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
5296 pause_sound(whooshsound);
5297 OPENAL_SetVolume(channels[whooshsound], 0);
5300 if(targetanimation==jumpdownanim||isFlip()){
5301 if(isFlip())jumppower=-4;
5302 targetanimation=getLanding();
5303 emit_sound_at(landsound, coords, 128.);
5306 envsound[numenvsounds]=coords;
5307 envsoundvol[numenvsounds]=16;
5308 envsoundlife[numenvsounds]=.4;
5314 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
5315 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
5316 coords.y=terrain.getHeight(coords.x,coords.z);
5321 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)){
5322 velspeed=findLength(&velocity);
5324 if(velspeed<multiplier*300*scale){
5326 } else velocity-=velocity/velspeed*multiplier*300*scale;
5327 if(velspeed>5&&(isLanding()||isLandhard())){
5328 skiddingdelay+=multiplier;
5335 else skiddingdelay=0;
5339 velspeed=findLength(&velocity);
5341 if(velspeed<multiplier*600*scale){
5343 } else velocity-=velocity/velspeed*multiplier*600*scale;
5345 if(velspeed>5&&(isLanding()||isLandhard())){
5346 skiddingdelay+=multiplier;
5353 else skiddingdelay=0;
5356 if(skiddingdelay<0)skiddingdelay+=multiplier;
5357 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
5359 if(!onterrain||environment==grassyenvironment){
5360 emit_sound_at(skidsound, coords, 128*velspeed/10);
5363 emit_sound_at(snowskidsound, coords, 128*velspeed/10);
5367 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
5368 terrainnormal=victim->coords-coords;
5369 Normalise(&terrainnormal);
5370 targetrotation=-asin(0-terrainnormal.x);
5371 targetrotation*=360/6.28;
5372 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5373 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
5376 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
5377 targetrotation=victim->targetrotation;
5379 if(targetanimation==rabbittacklinganim){
5380 coords=victim->coords;
5383 skeleton.oldfree=skeleton.free;
5387 midterrain.x=terrain.size*terrain.scale/2;
5388 midterrain.z=terrain.size*terrain.scale/2;
5389 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
5391 tempposit=coords-midterrain;
5393 Normalise(&tempposit);
5394 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
5395 coords.x=tempposit.x+midterrain.x;
5396 coords.z=tempposit.z+midterrain.z;
5400 int Person::DrawSkeleton(){
5401 int oldplayerdetail;
5402 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
5403 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
5413 glAlphaFunc(GL_GREATER, 0.0001);
5415 float terrainheight;
5417 if(!isnormal(rotation))rotation=0;
5418 if(!isnormal(tilt))tilt=0;
5419 if(!isnormal(tilt2))tilt2=0;
5420 oldplayerdetail=playerdetail;
5422 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
5425 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
5428 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
5433 if(playerdetail!=oldplayerdetail) {
5435 normalsupdatedelay=0;
5437 static float updatedelaychange;
5438 static float morphness;
5439 static float framemult;
5441 skeleton.FindForwards();
5442 if(howactive==typesittingwall){
5443 skeleton.specialforward[1]=0;
5444 skeleton.specialforward[1].z=1;
5450 static int weaponattachmuscle;
5451 static int weaponrotatemuscle,weaponrotatemuscle2;
5452 static XYZ weaponpoint;
5453 static int start,endthing;
5454 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
5455 if(!isSleeping()&&!isSitting()){
5456 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
5457 XYZ point,newpoint,change,change2;
5458 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5459 heightleft=terrain.getHeight(point.x,point.z)+.04;
5461 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5462 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5463 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5464 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5465 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5467 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5468 heightright=terrain.getHeight(point.x,point.z)+.04;
5469 point.y=heightright;
5470 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5471 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5472 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5473 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5474 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5475 skeleton.DoConstraints(&coords,&scale);
5477 if(creature==wolftype){
5478 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5479 heightleft=terrain.getHeight(point.x,point.z)+.04;
5481 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5482 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5483 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5484 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5485 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5487 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5488 heightright=terrain.getHeight(point.x,point.z)+.04;
5489 point.y=heightright;
5490 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5491 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5492 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5493 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5494 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5495 skeleton.DoConstraints(&coords,&scale);
5498 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
5499 XYZ point,newpoint,change,change2;
5500 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5501 heightleft=terrain.getHeight(point.x,point.z)+.04;
5503 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5504 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5505 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
5506 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5507 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5509 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5510 heightright=terrain.getHeight(point.x,point.z)+.04;
5511 point.y=heightright;
5512 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5513 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5514 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
5515 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5516 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5517 skeleton.DoConstraints(&coords,&scale);
5519 if(creature==wolftype){
5520 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5521 heightleft=terrain.getHeight(point.x,point.z)+.04;
5523 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5524 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5525 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
5526 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5527 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5529 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5530 heightright=terrain.getHeight(point.x,point.z)+.04;
5531 point.y=heightright;
5532 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5533 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5534 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
5535 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5536 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5537 skeleton.DoConstraints(&coords,&scale);
5541 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
5542 XYZ point,newpoint,change,change2;
5543 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5544 heightleft=terrain.getHeight(point.x,point.z)+.04;
5546 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5547 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5548 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
5549 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5550 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5552 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5553 heightright=terrain.getHeight(point.x,point.z)+.04;
5554 point.y=heightright;
5555 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5556 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5557 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
5558 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5559 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5560 skeleton.DoConstraints(&coords,&scale);
5562 if(creature==wolftype){
5563 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5564 heightleft=terrain.getHeight(point.x,point.z)+.04;
5566 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5567 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5568 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
5569 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5570 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5572 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5573 heightright=terrain.getHeight(point.x,point.z)+.04;
5574 point.y=heightright;
5575 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5576 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5577 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
5578 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5579 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5580 skeleton.DoConstraints(&coords,&scale);
5584 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()))
5587 targetheadrotation=-targetrotation;
5588 targetheadrotation2=0;
5589 if(animation[targetanimation].attack==3)targetheadrotation+=180;
5591 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
5592 skeleton.drawmodel.vertex[i]=0;
5593 skeleton.drawmodel.vertex[i].y=999;
5595 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
5596 skeleton.drawmodellow.vertex[i]=0;
5597 skeleton.drawmodellow.vertex[i].y=999;
5599 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
5600 skeleton.drawmodelclothes.vertex[i]=0;
5601 skeleton.drawmodelclothes.vertex[i].y=999;
5603 for(i=0;i<skeleton.num_muscles;i++){
5604 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
5608 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
5609 morphness=righthandmorphness;
5610 start=righthandmorphstart;
5611 endthing=righthandmorphend;
5613 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
5614 morphness=lefthandmorphness;
5615 start=lefthandmorphstart;
5616 endthing=lefthandmorphend;
5618 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
5619 morphness=headmorphness;
5620 start=headmorphstart;
5621 endthing=headmorphend;
5623 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)){
5624 morphness=chestmorphness;
5625 start=chestmorphstart;
5626 endthing=chestmorphend;
5628 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)){
5629 morphness=tailmorphness;
5630 start=tailmorphstart;
5631 endthing=tailmorphend;
5633 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
5634 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
5635 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5638 if(!skeleton.free)glRotatef(tilt2,1,0,0);
5639 if(!skeleton.free)glRotatef(tilt,0,0,1);
5642 glTranslatef(mid.x,mid.y,mid.z);
5644 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
5645 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
5647 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
5648 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
5650 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
5651 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
5653 if(playerdetail||skeleton.free==3)
5655 for(j=0;j<skeleton.muscles[i].numvertices;j++)
5657 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5659 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
5660 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,
5661 (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,
5662 (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);
5663 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)
5664 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,
5665 (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,
5666 (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);
5667 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)
5668 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,
5669 (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,
5670 (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);
5671 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
5672 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,
5673 (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,
5674 (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);
5675 glGetFloatv(GL_MODELVIEW_MATRIX,M);
5676 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
5677 //if(!isnormal(scale))test=1;
5678 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
5679 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
5680 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
5685 if(!playerdetail||skeleton.free==3)
5687 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
5689 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5691 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
5692 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
5693 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
5694 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
5695 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)
5696 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
5697 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
5698 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
5699 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)
5700 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
5701 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
5702 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
5703 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
5704 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
5705 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
5706 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
5708 glGetFloatv(GL_MODELVIEW_MATRIX,M);
5709 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
5710 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
5711 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
5717 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
5718 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
5720 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5723 if(!skeleton.free)glRotatef(tilt2,1,0,0);
5724 if(!skeleton.free)glRotatef(tilt,0,0,1);
5725 glTranslatef(mid.x,mid.y,mid.z);
5726 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
5727 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
5729 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
5730 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
5732 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
5733 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
5735 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
5736 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5738 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
5739 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
5740 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
5741 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
5742 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)
5743 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
5744 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
5745 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
5746 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)
5747 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
5748 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
5749 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
5750 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
5751 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
5752 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
5753 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
5754 glGetFloatv(GL_MODELVIEW_MATRIX,M);
5755 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
5756 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
5757 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
5762 updatedelay=1+(float)(Random()%100)/1000;
5764 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
5765 normalsupdatedelay=1;
5766 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
5767 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
5768 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
5772 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
5773 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
5774 if(skeleton.clothes){
5775 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
5780 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
5781 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
5782 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
5783 if(skeleton.free==1)updatedelaychange*=6;
5784 if(id==0)updatedelaychange*=8;
5785 updatedelay+=updatedelaychange;
5787 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5789 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
5790 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
5791 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
5792 if(!skeleton.free)glRotatef(rotation,0,1,0);
5795 glColor4f(.4,1,.4,1);
5796 glDisable(GL_LIGHTING);
5797 glDisable(GL_TEXTURE_2D);
5800 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
5801 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
5807 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
5808 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);
5809 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);
5810 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);
5811 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);
5812 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);
5813 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);
5819 terrainlight=terrain.getLighting(coords.x,coords.z);
5820 distance=findDistancefast(&viewer,&coords);
5821 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
5822 if(distance>1)distance=1;
5824 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
5825 if(terrainheight<1)terrainheight=1;
5826 if(terrainheight>1.7)terrainheight=1.7;
5829 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
5830 glDisable(GL_BLEND);
5831 glAlphaFunc(GL_GREATER, 0.0001);
5832 glEnable(GL_TEXTURE_2D);
5834 glDisable(GL_TEXTURE_2D);
5835 glColor4f(.7,.35,0,.5);
5837 glEnable(GL_LIGHTING);
5840 if(tutoriallevel&&id!=0){
5841 //glDisable(GL_TEXTURE_2D);
5842 glColor4f(.7,.7,.7,0.6);
5844 glEnable(GL_LIGHTING);
5846 if(canattack&&cananger)
5847 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
5848 glDisable(GL_TEXTURE_2D);
5849 glColor4f(1,0,0,0.8);
5851 glMatrixMode(GL_TEXTURE);
5853 glTranslatef(0,-smoketex,0);
5854 glTranslatef(-smoketex,0,0);
5858 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
5859 else skeleton.drawmodel.draw();
5863 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
5864 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
5867 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
5868 if(tutoriallevel&&id!=0){
5870 glMatrixMode(GL_MODELVIEW);
5871 glEnable(GL_TEXTURE_2D);
5872 glColor4f(.7,.7,.7,0.6);
5874 glEnable(GL_LIGHTING);
5876 if(canattack&&cananger)
5877 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
5878 glDisable(GL_TEXTURE_2D);
5879 glColor4f(1,0,0,0.8);
5881 glMatrixMode(GL_TEXTURE);
5883 glTranslatef(0,-smoketex*.6,0);
5884 glTranslatef(smoketex*.6,0,0);
5887 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
5888 else skeleton.drawmodel.draw();
5892 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
5893 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
5898 if(tutoriallevel&&id!=0){
5900 glMatrixMode(GL_MODELVIEW);
5901 glEnable(GL_TEXTURE_2D);
5903 if(skeleton.clothes){
5906 if(!immediate)skeleton.drawmodelclothes.draw();
5907 if(immediate)skeleton.drawmodelclothes.drawimmediate();
5914 for(k=0;k<num_weapons;k++){
5916 if(weaponactive==k){
5917 if(weapons.type[i]!=staff){
5918 for(j=0;j<skeleton.num_muscles;j++){
5919 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
5920 weaponattachmuscle=j;
5923 for(j=0;j<skeleton.num_muscles;j++){
5924 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){
5925 weaponrotatemuscle=j;
5928 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
5929 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
5931 if(weapons.type[i]==staff){
5932 for(j=0;j<skeleton.num_muscles;j++){
5933 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
5934 weaponattachmuscle=j;
5937 for(j=0;j<skeleton.num_muscles;j++){
5938 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){
5939 weaponrotatemuscle=j;
5942 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
5943 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
5944 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
5945 XYZ tempnormthing,vec1,vec2;
5946 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
5947 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
5948 CrossProduct(&vec1,&vec2,&tempnormthing);
5949 Normalise(&tempnormthing);
5950 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);
5953 if(weaponactive!=k&&weaponstuck!=k){
5954 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;
5955 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;
5956 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;
5957 for(j=0;j<skeleton.num_muscles;j++){
5958 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){
5959 weaponrotatemuscle=j;
5964 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
5965 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
5966 for(j=0;j<skeleton.num_muscles;j++){
5967 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){
5968 weaponrotatemuscle=j;
5973 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;
5974 weapons.bigrotation[i]=rotation;
5975 weapons.bigtilt[i]=tilt;
5976 weapons.bigtilt2[i]=tilt2;
5979 weapons.position[i]=weaponpoint*scale+coords;
5980 weapons.bigrotation[i]=0;
5981 weapons.bigtilt[i]=0;
5982 weapons.bigtilt2[i]=0;
5984 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
5985 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
5986 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
5987 if(weaponactive==k){
5988 if(weapons.type[i]==knife){
5989 weapons.smallrotation[i]=180;
5990 weapons.smallrotation2[i]=0;
5991 if(isCrouch()||wasCrouch()){
5992 weapons.smallrotation2[i]=20;
5994 if(targetanimation==hurtidleanim){
5995 weapons.smallrotation2[i]=50;
5997 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
5998 XYZ temppoint1,temppoint2,tempforward;
6001 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
6002 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6003 distance=findDistance(&temppoint1,&temppoint2);
6004 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6005 weapons.rotation2[i]*=360/6.28;
6008 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6009 weapons.rotation1[i]*=360/6.28;
6010 weapons.rotation3[i]=0;
6011 weapons.smallrotation[i]=-90;
6012 weapons.smallrotation2[i]=0;
6013 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6015 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
6016 XYZ temppoint1,temppoint2,tempforward;
6019 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
6020 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6021 distance=findDistance(&temppoint1,&temppoint2);
6022 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6023 weapons.rotation2[i]*=360/6.28;
6026 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6027 weapons.rotation1[i]*=360/6.28;
6028 weapons.rotation3[i]=0;
6029 weapons.smallrotation[i]=90;
6030 weapons.smallrotation2[i]=0;
6031 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6033 if(targetanimation==knifethrowanim){
6034 weapons.smallrotation[i]=90;
6035 //weapons.smallrotation2[i]=-90;
6036 weapons.smallrotation2[i]=0;
6037 weapons.rotation1[i]=0;
6038 weapons.rotation2[i]=0;
6039 weapons.rotation3[i]=0;
6041 if(targetanimation==knifesneakattackanim&&targetframe<5){
6042 weapons.smallrotation[i]=-90;
6043 weapons.rotation1[i]=0;
6044 weapons.rotation2[i]=0;
6045 weapons.rotation3[i]=0;
6048 if(weapons.type[i]==sword){
6049 weapons.smallrotation[i]=0;
6050 weapons.smallrotation2[i]=0;
6051 if(targetanimation==knifethrowanim){
6052 weapons.smallrotation[i]=-90;
6053 weapons.smallrotation2[i]=0;
6054 weapons.rotation1[i]=0;
6055 weapons.rotation2[i]=0;
6056 weapons.rotation3[i]=0;
6058 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)){
6059 XYZ temppoint1,temppoint2,tempforward;
6062 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
6063 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6064 distance=findDistance(&temppoint1,&temppoint2);
6065 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6066 weapons.rotation2[i]*=360/6.28;
6069 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6070 weapons.rotation1[i]*=360/6.28;
6071 weapons.rotation3[i]=0;
6072 weapons.smallrotation[i]=90;
6073 weapons.smallrotation2[i]=0;
6074 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6077 if(weapons.type[i]==staff){
6078 weapons.smallrotation[i]=100;
6079 weapons.smallrotation2[i]=0;
6080 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
6081 XYZ temppoint1,temppoint2,tempforward;
6084 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
6085 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6086 distance=findDistance(&temppoint1,&temppoint2);
6087 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6088 weapons.rotation2[i]*=360/6.28;
6091 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6092 weapons.rotation1[i]*=360/6.28;
6093 weapons.rotation3[i]=0;
6094 weapons.smallrotation[i]=90;
6095 weapons.smallrotation2[i]=0;
6096 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6100 if(weaponactive!=k&&weaponstuck!=k){
6101 if(weapons.type[i]==knife){
6102 weapons.smallrotation[i]=-70;
6103 weapons.smallrotation2[i]=10;
6105 if(weapons.type[i]==sword){
6106 weapons.smallrotation[i]=-100;
6107 weapons.smallrotation2[i]=-8;
6109 if(weapons.type[i]==staff){
6110 weapons.smallrotation[i]=-100;
6111 weapons.smallrotation2[i]=-8;
6115 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
6116 else weapons.smallrotation[i]=0;
6117 weapons.smallrotation2[i]=10;
6124 if(skeleton.free)calcrot=1;
6125 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
6126 if(currentanimation!=targetanimation)calcrot=1;
6127 //if(id==0)calcrot=1;
6128 if(skeleton.free==2)calcrot=0;
6134 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
6137 static float distance;
6138 static float olddistance;
6139 static int intersecting;
6140 static int firstintersecting;
6143 static XYZ start,end;
6144 static float slopethreshold=-.4;
6146 firstintersecting=-1;
6150 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
6151 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
6153 for (j=0;j<model->TriangleNum;j++){
6154 if(model->facenormals[j].y<=slopethreshold){
6156 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)));
6157 if(distance<radius){
6158 point=*p1-model->facenormals[j]*distance;
6159 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;
6160 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
6161 &model->vertex[model->Triangles[j].vertex[1]],
6163 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
6164 &model->vertex[model->Triangles[j].vertex[2]],
6166 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
6167 &model->vertex[model->Triangles[j].vertex[2]],
6170 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
6174 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)){
6175 p1->y=point.y+radius;
6176 if((targetanimation==jumpdownanim||isFlip())){
6177 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
6179 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6185 pause_sound(whooshsound);
6186 OPENAL_SetVolume(channels[whooshsound], 0);
6189 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
6190 if(isFlip())jumppower=-4;
6191 targetanimation=getLanding();
6192 emit_sound_at(landsound, coords, 128.);
6195 envsound[numenvsounds]=coords;
6196 envsoundvol[numenvsounds]=16;
6197 envsoundlife[numenvsounds]=.4;
6205 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
6208 for (j=0;j<model->TriangleNum;j++){
6209 if(model->facenormals[j].y>slopethreshold){
6213 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)));
6214 if(distance<radius*.5){
6215 point=start-model->facenormals[j]*distance;
6216 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;
6217 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,
6218 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
6219 p1->x, p1->y, p1->z, radius/2);
6220 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,
6221 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
6222 p1->x, p1->y, p1->z, radius/2);
6223 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,
6224 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
6225 p1->x, p1->y, p1->z, radius/2);
6227 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
6228 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6230 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
6231 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
6233 *p1+=model->facenormals[j]*(distance-radius*.5);
6236 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
6240 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
6242 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
6244 return firstintersecting;