2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /**> HEADER FILES <**/
24 #include "openal_wrapper.h"
25 #include "Animation.h"
30 extern float multiplier;
31 extern int channels[100];
32 extern Terrain terrain;
34 extern int environment;
36 extern FRUSTUM frustum;
38 extern float realmultiplier;
40 extern float slomodelay;
41 extern bool cellophane;
42 extern float texdetail;
43 extern float realtexdetail;
44 extern GLubyte bloodText[512*512*3];
45 extern GLubyte wolfbloodText[512*512*3];
46 extern int bloodtoggle;
47 extern Objects objects;
49 extern bool autoslomo;
50 extern float camerashake;
52 extern float terraindetail;
53 extern float viewdistance;
54 extern float blackout;
55 extern int difficulty;
57 extern float fadestart;
59 extern bool winfreeze;
60 extern float flashamount,flashr,flashg,flashb;
61 extern int flashdelay;
62 extern bool showpoints;
63 extern bool immediate;
65 extern bool tilt2weird;
66 extern bool tiltweird;
68 extern bool proportionweird;
69 extern bool vertexweird[6];
70 extern XYZ envsound[30];
71 extern float envsoundvol[30];
72 extern float envsoundlife[30];
73 extern int numenvsounds;
74 extern int tutoriallevel;
75 extern float smoketex;
76 extern int tutorialstage;
77 extern bool reversaltrain;
78 extern bool canattack;
80 extern float damagedealt;
82 extern float hostiletime;
84 extern int indialogue;
86 extern bool gamestarted;
88 void Person::CheckKick()
91 && (targetanimation == rabbitkickanim
95 && currentanimation == rabbitkickanim)
96 && (findDistancefast(&coords,&victim->coords) < 1.2)
97 && (!victim->skeleton.free)))
100 if (animation[victim->targetanimation].height!=lowheight)
102 float damagemult = (creature == wolftype ? 2.5 : 1.) * power * power;
103 XYZ relative = velocity;
105 Normalise(&relative);
110 emit_sound_at(heavyimpactsound, victim->coords);
112 for(int i=0;i<victim->skeleton.num_joints;i++){
113 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
116 victim->DoDamage(100*damagemult/victim->protectionhigh);
117 if(id==0)camerashake+=.4;
121 targetanimation=backflipanim;
127 resume_stream(whooshsound);
129 award_bonus(id, cannon);
131 else if (victim->isCrouch())
133 targetanimation=rabbitkickreversedanim;
134 currentanimation=rabbitkickreversedanim;
135 victim->currentanimation=rabbitkickreversalanim;
136 victim->targetanimation=rabbitkickreversalanim;
142 victim->oldcoords=victim->coords;
143 coords=victim->coords;
144 victim->targetrotation=targetrotation;
149 void Person::CatchFire(){
150 XYZ flatfacing,flatvelocity;
152 for(int i=0;i<10;i++){
153 howmany=abs(Random()%(skeleton.num_joints));
154 if(!skeleton.free)flatvelocity=velocity;
155 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
156 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
157 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
158 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
163 emit_sound_at(firestartsound, coords);
165 emit_stream_at(stream_firesound, coords);
172 int Person::getIdle(){
173 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
174 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)){
175 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
176 if(creature==rabbittype)return fightidleanim;
177 if(creature==wolftype)return wolfidle;
179 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
180 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
181 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
182 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
183 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
185 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
187 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
188 if(howactive==typesitting)return sitanim;
189 if(howactive==typesittingwall)return sitwallanim;
190 if(howactive==typesleeping)return sleepanim;
191 if(howactive==typedead1)return dead1anim;
192 if(howactive==typedead2)return dead2anim;
193 if(howactive==typedead3)return dead3anim;
194 if(howactive==typedead4)return dead4anim;
195 if(creature==rabbittype)return bounceidleanim;
196 if(creature==wolftype)return wolfidle;
200 int Person::getCrouch(){
201 if(creature==rabbittype)return crouchanim;
202 if(creature==wolftype)return wolfcrouchanim;
206 int Person::getRun(){
207 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
208 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
210 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
211 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
215 int Person::getStop(){
216 if(creature==rabbittype)return stopanim;
217 if(creature==wolftype)return wolfstopanim;
221 int Person::getLanding(){
222 if(creature==rabbittype)return landanim;
223 if(creature==wolftype)return wolflandanim;
227 int Person::getLandhard(){
228 if(creature==rabbittype)return landhardanim;
229 if(creature==wolftype)return wolflandhardanim;
234 SolidHitBonus(int playerid)
236 if (bonustime < 1.5 && bonus >= solidhit && bonus <= megacombo)
237 award_bonus(playerid, bonus == megacombo ? bonus : bonus + 1);
239 award_bonus(playerid, solidhit);
242 void Person::DoBlood(float howmuch,int which){
243 static int bleedxint,bleedyint;
245 //if(howmuch&&id==0)blooddimamount=1;
246 if(bloodtoggle&&tutoriallevel!=1){
247 if(bleeding<=0&&spurt){
249 for(int i=0;i<3;i++){
253 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
256 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
258 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
259 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
261 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
262 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
265 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);
266 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);
270 for(int i=0;i<3;i++){
274 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
275 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
278 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
279 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
283 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
285 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);
287 Sprite::setLastSpriteSpecial(3);
292 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
295 int texdetailint=realtexdetail;
296 if(creature==rabbittype)
297 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){
298 bleedxint=abs(Random()%512);
299 bleedyint=abs(Random()%512);
301 if(creature==wolftype)
302 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){
303 bleedxint=abs(Random()%512);
304 bleedyint=abs(Random()%512);
308 bleedy/=realtexdetail;
309 bleedx/=realtexdetail;
310 direction=abs(Random()%2)*2-1;
314 if(bleeding>2)bleeding=2;
317 void Person::DoBloodBig(float howmuch,int which){
318 static int bleedxint,bleedyint,i,j;
320 if(howmuch&&id==0)blooddimamount=1;
322 if(tutoriallevel!=1||id==0)
323 if(aitype!=playercontrolled&&howmuch>0){
326 if(creature==wolftype){
327 int i=abs(Random()%2);
328 if(i==0)whichsound=snarlsound;
329 if(i==1)whichsound=snarl2sound;
330 envsound[numenvsounds]=coords;
331 envsoundvol[numenvsounds]=16;
332 envsoundlife[numenvsounds]=.4;
335 if(creature==rabbittype){
336 int i=abs(Random()%2);
337 if(i==0)whichsound=rabbitpainsound;
338 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
339 envsound[numenvsounds]=coords;
340 envsoundvol[numenvsounds]=16;
341 envsoundlife[numenvsounds]=.4;
343 //if(i==2)whichsound=rabbitpain2sound;
347 emit_sound_at(whichsound, coords);
350 if(id==0&&howmuch>0){
358 if(bloodtoggle&&decals&&tutoriallevel!=1){
359 if(bleeding<=0&&spurt){
361 for(int i=0;i<3;i++){
365 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
368 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
370 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
371 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
373 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
374 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
377 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);
378 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);
382 int offsetx=0,offsety=0;
385 offsetx=abs(Random()%60);
387 if(which==190||which==185){
389 offsetx=abs(Random()%100)-20;
399 if(which==220||which==215){
400 //offsety=Random()%20;
402 //offsetx=abs(Random()%80);
411 if(creature==rabbittype)
414 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
415 if(i<startx)startx=i;
416 if(j<starty)starty=j;
422 if(creature==wolftype)
425 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
426 if(i<startx)startx=i;
427 if(j<starty)starty=j;
439 if(startx<0)startx=0;
440 if(starty<0)starty=0;
441 if(endx>512-1)endx=512-1;
442 if(endy>512-1)endy=512-1;
443 if(endx<startx)endx=startx;
444 if(endy<starty)endy=starty;
446 startx/=realtexdetail;
447 starty/=realtexdetail;
451 int texdetailint=realtexdetail;
453 if(creature==rabbittype)
454 for(i=startx;i<endx;i++){
455 for(j=starty;j<endy;j++){
456 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){
457 color=Random()%85+170;
458 where=i*skeleton.skinsize*3+j*3;
459 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
460 skeleton.skinText[where+1]=0;
461 skeleton.skinText[where+2]=0;
465 if(creature==wolftype)
466 for(i=startx;i<endx;i++){
467 for(j=starty;j<endy;j++){
468 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){
469 color=Random()%85+170;
470 where=i*skeleton.skinsize*3+j*3;
471 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
472 skeleton.skinText[where+1]=0;
473 skeleton.skinText[where+2]=0;
477 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
482 if(creature==rabbittype)
483 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){
484 bleedxint=abs(Random()%512);
485 bleedyint=abs(Random()%512);
487 if(creature==wolftype)
488 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){
489 bleedxint=abs(Random()%512);
490 bleedyint=abs(Random()%512);
492 bleedy=bleedxint+offsetx;
493 bleedx=bleedyint+offsety;
494 bleedy/=realtexdetail;
495 bleedx/=realtexdetail;
496 if(bleedx<0)bleedx=0;
497 if(bleedy<0)bleedy=0;
498 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
499 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
500 direction=abs(Random()%2)*2-1;
503 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
504 deathbleeding+=bleeding;
505 bloodloss+=bleeding*3;
507 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
508 if(abs(Random()%2)==0){aitype=gethelptype;
511 else aitype=attacktypecutoff;
514 if(bleeding>2)bleeding=2;
517 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
518 static int bleedxint,bleedyint,i,j;
520 static XYZ startpoint,endpoint,colpoint,movepoint;
521 static float rotationpoint;
523 static XYZ p1,p2,p3,p0;
527 float coordsx,coordsy;
530 if(bloodtoggle&&decals&&tutoriallevel!=1){
532 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
540 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
543 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
544 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
545 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
547 CrossProduct(p2-p1,p3-p1,&N);
548 CrossProduct(p0-p1,p3-p1,&temp);
549 s = dotproduct(&temp,&N)/findLength(&N);
550 CrossProduct(p2-p1,p1-p0,&temp);
551 t = dotproduct(&temp,&N)/findLength(&N);
554 bary.x=findDistancefast(&p0,&p1);
555 bary.y=findDistancefast(&p0,&p2);
556 bary.z=findDistancefast(&p0,&p3);
558 total=bary.x+bary.y+bary.z;
567 total=bary.x+bary.y+bary.z;
573 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
574 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
575 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
576 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
577 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
578 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
579 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;
580 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;
582 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
583 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
585 if(bleeding<=0&&spurt){
587 for(int i=0;i<3;i++){
591 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
594 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
596 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
597 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
599 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
600 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
603 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);
604 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);
608 int offsetx=0,offsety=0;
611 offsetx=abs(Random()%120);
613 if(which==220||which==215){
615 offsetx=abs(Random()%80);
618 offsetx=(1+coordsy)*512-291;
619 offsety=coordsx*512-437;
626 if(creature==rabbittype)
629 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
630 if(i<startx)startx=i;
631 if(j<starty)starty=j;
637 if(creature==wolftype)
640 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
641 if(i<startx)startx=i;
642 if(j<starty)starty=j;
653 if(startx<0)startx=0;
654 if(starty<0)starty=0;
655 if(endx>512-1)endx=512-1;
656 if(endy>512-1)endy=512-1;
657 if(endx<startx)endx=startx;
658 if(endy<starty)endy=starty;
660 startx/=realtexdetail;
661 starty/=realtexdetail;
665 int texdetailint=realtexdetail;
667 if(creature==rabbittype)
668 for(i=startx;i<endx;i++){
669 for(j=starty;j<endy;j++){
670 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){
671 color=Random()%85+170;
672 where=i*skeleton.skinsize*3+j*3;
673 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
674 skeleton.skinText[where+1]=0;
675 skeleton.skinText[where+2]=0;
677 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){
678 color=Random()%85+170;
679 where=i*skeleton.skinsize*3+j*3;
680 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
681 skeleton.skinText[where+1]=0;
682 skeleton.skinText[where+2]=0;
686 if(creature==wolftype)
687 for(i=startx;i<endx;i++){
688 for(j=starty;j<endy;j++){
689 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){
690 color=Random()%85+170;
691 where=i*skeleton.skinsize*3+j*3;
692 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
693 skeleton.skinText[where+1]=0;
694 skeleton.skinText[where+2]=0;
696 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){
697 color=Random()%85+170;
698 where=i*skeleton.skinsize*3+j*3;
699 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
700 skeleton.skinText[where+1]=0;
701 skeleton.skinText[where+2]=0;
705 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
708 bleedy=(1+coordsy)*512;
710 bleedy/=realtexdetail;
711 bleedx/=realtexdetail;
712 if(bleedx<0)bleedx=0;
713 if(bleedy<0)bleedy=0;
714 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
715 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
716 direction=abs(Random()%2)*2-1;
718 if(whichtri==-1)return 0;
720 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
721 deathbleeding+=bleeding;
722 bloodloss+=bleeding*3;
724 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
725 if(abs(Random()%2)==0){aitype=gethelptype;
728 else aitype=attacktypecutoff;
731 if(bleeding>2)bleeding=2;
737 void Person::Reverse()
739 if (!((victim->aitype == playercontrolled
741 || staggerdelay <= 0)
742 && victim->targetanimation != jumpupanim
743 && victim->targetanimation != jumpdownanim
744 && (tutoriallevel != 1 || cananger)
748 if (normaldotproduct (victim->facing, victim->coords-coords) > 0
749 && (victim->id != 0 || difficulty >= 2)
750 && (creature != wolftype || victim->creature == wolftype))
753 if(targetanimation==sweepanim){
754 targetanimation=sweepreversedanim;
755 currentanimation=sweepreversedanim;
756 victim->currentanimation=sweepreversalanim;
757 victim->targetanimation=sweepreversalanim;
759 if(targetanimation==spinkickanim){
760 targetanimation=spinkickreversedanim;
761 currentanimation=spinkickreversedanim;
762 victim->currentanimation=spinkickreversalanim;
763 victim->targetanimation=spinkickreversalanim;
765 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
766 if(targetanimation==rabbittacklinganim){
769 victim->currentframe=6;
770 victim->targetframe=7;
772 targetanimation=upunchreversedanim;
773 currentanimation=upunchreversedanim;
774 victim->currentanimation=upunchreversalanim;
775 victim->targetanimation=upunchreversalanim;
777 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
778 if(victim->weaponactive!=-1){
779 victim->throwtogglekeydown=1;
780 weapons.owner[victim->weaponids[0]]=-1;
781 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
782 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
783 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
784 weapons.missed[victim->weaponids[0]]=1;
785 weapons.freetime[victim->weaponids[0]]=0;
786 weapons.firstfree[victim->weaponids[0]]=1;
787 weapons.physics[victim->weaponids[0]]=1;
788 victim->num_weapons--;
789 if(victim->num_weapons){
790 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
791 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
794 victim->weaponactive=-1;
795 for(int j=0;j<numplayers;j++){
796 player[j].wentforweapon=0;
800 targetanimation=staffhitreversedanim;
801 currentanimation=staffhitreversedanim;
802 victim->currentanimation=staffhitreversalanim;
803 victim->targetanimation=staffhitreversalanim;
805 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
806 if(victim->weaponactive!=-1){
807 victim->throwtogglekeydown=1;
808 weapons.owner[victim->weaponids[0]]=-1;
809 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
810 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
811 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
812 weapons.missed[victim->weaponids[0]]=1;
813 weapons.freetime[victim->weaponids[0]]=0;
814 weapons.firstfree[victim->weaponids[0]]=1;
815 weapons.physics[victim->weaponids[0]]=1;
816 victim->num_weapons--;
817 if(victim->num_weapons){
818 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
819 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
822 victim->weaponactive=-1;
823 for(int j=0;j<numplayers;j++){
824 player[j].wentforweapon=0;
827 targetanimation=staffspinhitreversedanim;
828 currentanimation=staffspinhitreversedanim;
829 victim->currentanimation=staffspinhitreversalanim;
830 victim->targetanimation=staffspinhitreversalanim;
832 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
833 if(victim->weaponactive!=-1){
834 victim->throwtogglekeydown=1;
835 weapons.owner[victim->weaponids[0]]=-1;
836 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
837 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
838 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
839 weapons.missed[victim->weaponids[0]]=1;
840 weapons.freetime[victim->weaponids[0]]=0;
841 weapons.firstfree[victim->weaponids[0]]=1;
842 weapons.physics[victim->weaponids[0]]=1;
843 victim->num_weapons--;
844 if(victim->num_weapons){
845 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
846 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
849 victim->weaponactive=-1;
850 for(int j=0;j<numplayers;j++){
851 player[j].wentforweapon=0;
854 targetanimation=swordslashreversedanim;
855 currentanimation=swordslashreversedanim;
856 victim->currentanimation=swordslashreversalanim;
857 victim->targetanimation=swordslashreversalanim;
859 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
860 if(victim->weaponactive!=-1){
861 victim->throwtogglekeydown=1;
862 weapons.owner[victim->weaponids[0]]=-1;
863 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
864 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
865 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
866 weapons.missed[victim->weaponids[0]]=1;
867 weapons.freetime[victim->weaponids[0]]=0;
868 weapons.firstfree[victim->weaponids[0]]=1;
869 weapons.physics[victim->weaponids[0]]=1;
870 victim->num_weapons--;
871 if(victim->num_weapons){
872 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
873 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
876 victim->weaponactive=-1;
877 for(int j=0;j<numplayers;j++){
878 player[j].wentforweapon=0;
881 targetanimation=knifeslashreversedanim;
882 currentanimation=knifeslashreversedanim;
883 victim->currentanimation=knifeslashreversalanim;
884 victim->targetanimation=knifeslashreversalanim;
886 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
887 victim->targettilt2=targettilt2;
888 victim->currentframe=currentframe;
889 victim->targetframe=targetframe;
890 victim->target=target;
892 victim->oldcoords=victim->coords;
893 victim->coords=coords;
894 victim->targetrotation=targetrotation;
895 victim->rotation=targetrotation;
898 if(targetanimation==winduppunchanim){
899 targetanimation=winduppunchblockedanim;
900 victim->targetanimation=blockhighleftanim;
901 victim->targetframe=1;
904 victim->targetrotation=targetrotation+180;
906 if(targetanimation==wolfslapanim){
907 targetanimation=winduppunchblockedanim;
908 victim->targetanimation=blockhighleftanim;
909 victim->targetframe=1;
912 victim->targetrotation=targetrotation+180;
914 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
915 targetanimation=swordslashparriedanim;
917 victim->parriedrecently=0;
918 victim->targetanimation=swordslashparryanim;
919 victim->targetframe=1;
922 victim->targetrotation=targetrotation+180;
924 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
925 if(victim->weaponactive!=-1){
926 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
927 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
928 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
929 emit_sound_at(swordstaffsound, victim->coords);
932 emit_sound_at(metalhitsound, victim->coords);
936 victim->Puff(righthand);
938 victim->targetframe=0;
939 victim->targetanimation=staggerbackhighanim;
940 victim->targetrotation=targetrotation+180;
942 weapons.owner[victim->weaponids[0]]=-1;
943 aim=DoRotation(facing,0,90,0)*21;
945 weapons.velocity[victim->weaponids[0]]=aim*-.2;
946 weapons.tipvelocity[victim->weaponids[0]]=aim;
947 weapons.missed[victim->weaponids[0]]=1;
948 weapons.hitsomething[victim->weaponids[0]]=0;
949 weapons.freetime[victim->weaponids[0]]=0;
950 weapons.firstfree[victim->weaponids[0]]=1;
951 weapons.physics[victim->weaponids[0]]=1;
952 victim->num_weapons--;
953 if(victim->num_weapons){
954 victim->weaponids[0]=victim->weaponids[num_weapons];
955 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
957 victim->weaponactive=-1;
958 for(int i=0;i<numplayers;i++){
959 player[i].wentforweapon=0;
963 if(abs(Random()%20)==0){
964 if(weaponactive!=-1){
965 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
966 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
967 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
969 emit_sound_at(swordstaffsound, coords);
972 emit_sound_at(metalhitsound, coords);
980 targetanimation=staggerbackhighanim;
981 targetrotation=targetrotation+180;
983 weapons.owner[weaponids[0]]=-1;
984 aim=DoRotation(facing,0,90,0)*21;
986 weapons.velocity[weaponids[0]]=aim*-.2;
987 weapons.tipvelocity[weaponids[0]]=aim;
988 weapons.hitsomething[weaponids[0]]=0;
989 weapons.missed[weaponids[0]]=1;
990 weapons.freetime[weaponids[0]]=0;
991 weapons.firstfree[weaponids[0]]=1;
992 weapons.physics[weaponids[0]]=1;
995 weaponids[0]=weaponids[num_weapons];
996 if(weaponstuck==num_weapons)weaponstuck=0;
999 for(int i=0;i<numplayers;i++){
1000 player[i].wentforweapon=0;
1007 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1008 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1009 victim->targetanimation=dodgebackanim;
1010 victim->targetframe=0;
1014 rotatetarget=coords-victim->coords;
1015 Normalise(&rotatetarget);
1016 victim->targetrotation=-asin(0-rotatetarget.x);
1017 victim->targetrotation*=360/6.28;
1018 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1020 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1022 victim->lastattack3=victim->lastattack2;
1023 victim->lastattack2=victim->lastattack;
1024 victim->lastattack=victim->targetanimation;
1028 victim->targetanimation=sweepanim;
1029 victim->targetframe=0;
1033 rotatetarget=coords-victim->coords;
1034 Normalise(&rotatetarget);
1035 victim->targetrotation=-asin(0-rotatetarget.x);
1036 victim->targetrotation*=360/6.28;
1037 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1039 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1041 victim->lastattack3=victim->lastattack2;
1042 victim->lastattack2=victim->lastattack;
1043 victim->lastattack=victim->targetanimation;
1050 if(aitype!=playercontrolled)feint=0;
1051 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1052 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1053 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1055 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1058 void Person::DoDamage(float howmuch){
1059 if(tutoriallevel!=1)damage+=howmuch/power;
1060 if(id!=0)damagedealt+=howmuch/power;
1061 if(id==0)damagetaken+=howmuch/power;
1063 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1064 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1065 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1066 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1067 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1069 if(id==0)camerashake+=howmuch/100;
1070 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1071 if(blackout>1)blackout=1;
1073 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1074 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1075 if(abs(Random()%2)==0){aitype=gethelptype;
1078 else aitype=attacktypecutoff;
1082 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1085 for(int i=0;i<skeleton.num_joints; i++){
1086 if(!skeleton.free)flatvelocity2=velocity;
1087 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1088 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1089 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1090 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1091 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1092 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1093 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1094 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1095 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1098 emit_sound_at(splattersound, coords);
1107 if(!dead&&creature==wolftype){
1108 award_bonus(0, Wolfbonus);
1114 if(tutoriallevel!=1||id==0)
1115 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1118 if(creature==wolftype){
1119 int i=abs(Random()%2);
1120 if(i==0)whichsound=snarlsound;
1121 if(i==1)whichsound=snarl2sound;
1122 envsound[numenvsounds]=coords;
1123 envsoundvol[numenvsounds]=16;
1124 envsoundlife[numenvsounds]=.4;
1127 if(creature==rabbittype){
1128 int i=abs(Random()%2);
1129 if(i==0)whichsound=rabbitpainsound;
1130 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1131 envsound[numenvsounds]=coords;
1132 envsoundvol[numenvsounds]=16;
1133 envsoundlife[numenvsounds]=.4;
1135 //if(i==2)whichsound=rabbitpain2sound;
1139 emit_sound_at(whichsound, coords);
1144 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1145 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1148 void Person::DoHead(){
1149 static XYZ rotatearound;
1151 static float lookspeed=500;
1153 if(!freeze&&!winfreeze){
1156 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1157 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1159 while(targetheadrotation>180)targetheadrotation-=360;
1160 while(targetheadrotation<-180)targetheadrotation+=360;
1162 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1163 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1164 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1165 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1167 if(targetheadrotation2>120)targetheadrotation2=120;
1168 if(targetheadrotation2<-120)targetheadrotation2=-120;
1169 if(targetheadrotation>120)targetheadrotation=120;
1170 if(targetheadrotation<-120)targetheadrotation=-120;
1172 if(!isIdle())targetheadrotation2=0;
1174 if(targetheadrotation>80)targetheadrotation=80;
1175 if(targetheadrotation<-80)targetheadrotation=-80;
1176 if(targetheadrotation2>50)targetheadrotation2=50;
1177 if(targetheadrotation2<-50)targetheadrotation2=-50;
1180 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1181 else if(headrotation>targetheadrotation){
1182 headrotation-=multiplier*lookspeed;
1184 else if(headrotation<targetheadrotation){
1185 headrotation+=multiplier*lookspeed;
1188 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1189 else if(headrotation2>targetheadrotation2){
1190 headrotation2-=multiplier*lookspeed/2;
1192 else if(headrotation2<targetheadrotation2){
1193 headrotation2+=multiplier*lookspeed/2;
1196 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1197 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1201 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1202 facing=DoRotation(facing,headrotation2*.4,0,0);
1203 facing=DoRotation(facing,0,headrotation*.4,0);
1206 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1207 facing=DoRotation(facing,headrotation2*.8,0,0);
1208 facing=DoRotation(facing,0,headrotation*.8,0);
1211 if(targetanimation==walkanim){
1212 facing=DoRotation(facing,headrotation2*.6,0,0);
1213 facing=DoRotation(facing,0,headrotation*.6,0);
1216 skeleton.specialforward[0]=facing;
1217 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1219 for(i=0;i<skeleton.num_muscles;i++){
1220 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1222 skeleton.FindRotationMuscle(i,targetanimation);
1228 void Person::RagDoll(bool checkcollision){
1233 if(id==0)numfalls++;
1234 if(id==0&&isFlip())numflipfail++;
1240 facing=DoRotation(facing,0,rotation,0);
1242 skeleton.freetime=0;
1244 skeleton.longdead=0;
1250 skeleton.freefall=1;
1252 if(!isnormal(velocity.x))velocity.x=0;
1253 if(!isnormal(velocity.y))velocity.y=0;
1254 if(!isnormal(velocity.z))velocity.z=0;
1255 if(!isnormal(rotation))rotation=0;
1256 if(!isnormal(coords.x))coords=0;
1257 if(!isnormal(tilt))tilt=0;
1258 if(!isnormal(tilt2))tilt2=0;
1260 for(i=0;i<skeleton.num_joints;i++){
1261 skeleton.joints[i].delay=0;
1262 skeleton.joints[i].locked=0;
1263 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1264 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1265 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1266 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1267 skeleton.joints[i].position.y+=.1;
1268 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1269 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1272 for(i=0;i<skeleton.num_joints;i++){
1273 skeleton.joints[i].velocity=0;
1274 skeleton.joints[i].velchange=0;
1276 skeleton.DoConstraints(&coords,&scale);
1277 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1279 skeleton.DoConstraints(&coords,&scale);
1280 skeleton.DoConstraints(&coords,&scale);
1281 skeleton.DoConstraints(&coords,&scale);
1282 skeleton.DoConstraints(&coords,&scale);
1285 speed=animation[targetanimation].speed[targetframe]*2;
1286 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1287 speed=animation[currentanimation].speed[currentframe]*2;
1289 if(transspeed)speed=transspeed*2;
1293 for(i=0;i<skeleton.num_joints;i++){
1294 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);
1295 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1296 change.x=(float)(Random()%100)/100;
1297 change.y=(float)(Random()%100)/100;
1298 change.z=(float)(Random()%100)/100;
1299 skeleton.joints[i].velocity+=change;
1300 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1302 change.x=(float)(Random()%100)/100;
1303 change.y=(float)(Random()%100)/100;
1304 change.z=(float)(Random()%100)/100;
1305 skeleton.joints[i].velchange+=change;
1306 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1316 for(j=0;j<skeleton.num_joints;j++){
1317 average+=skeleton.joints[j].position;
1321 coords+=average*scale;
1322 for(j=0;j<skeleton.num_joints;j++){
1323 skeleton.joints[j].position-=average;
1326 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1327 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1328 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1329 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1330 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1333 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1334 coords.x=lowpoint.x;
1335 coords.z=lowpoint.z;
1344 for(i=0;i<skeleton.num_joints;i++){
1345 velocity+=skeleton.joints[i].velocity*scale;
1347 velocity/=skeleton.num_joints;
1350 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1351 weapons.owner[weaponids[0]]=-1;
1352 weapons.hitsomething[weaponids[0]]=0;
1353 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1354 weapons.velocity[weaponids[0]].x+=.01;
1355 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1356 weapons.missed[weaponids[0]]=1;
1357 weapons.freetime[weaponids[0]]=0;
1358 weapons.firstfree[weaponids[0]]=1;
1359 weapons.physics[weaponids[0]]=1;
1362 weaponids[0]=weaponids[num_weapons];
1363 if(weaponstuck==num_weapons)weaponstuck=0;
1366 for(i=0;i<numplayers;i++){
1367 player[i].wentforweapon=0;
1372 targetanimation=bounceidleanim;
1373 currentanimation=bounceidleanim;
1381 void Person::FootLand(int which, float opacity){
1382 static XYZ terrainlight;
1383 static XYZ footvel,footpoint;
1384 if(opacity>=1||skiddelay<=0)
1388 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1389 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1390 //footpoint.y=coords.y;
1391 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1393 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1395 if(footvel.y<.8)footvel.y=.8;
1396 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1397 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1398 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1399 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1400 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1401 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1403 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1405 if(footvel.y<.8)footvel.y=.8;
1406 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1407 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1408 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1409 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1410 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);
1412 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1414 if(footvel.y<.8)footvel.y=.8;
1415 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1416 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1417 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1418 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1419 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);
1420 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1422 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1425 if(footvel.y<.8)footvel.y=.8;
1426 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1427 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1428 //footpoint.y=coords.y;
1429 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1433 void Person::Puff(int whichlabel){
1434 static XYZ footvel,footpoint;
1437 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1438 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1442 void Person::DoAnimations(){
1445 static float oldtarget;
1447 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1449 if(targetanimation==tempanim||currentanimation==tempanim){
1450 animation[tempanim]=tempanimation;
1452 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1463 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1464 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1466 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1467 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1469 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1474 targfacing=DoRotation(targfacing,0,targetrotation,0);
1476 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1477 else targetanimation=backflipanim;
1478 crouchtogglekeydown=1;
1482 if(id==0)numflipped++;
1485 if(animation[targetanimation].attack!=reversed)feint=0;
1486 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1487 crouchtogglekeydown=0;
1488 if(aitype==playercontrolled)feint=0;
1492 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1493 if(!isFlip())crouchtogglekeydown=1;
1497 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1498 if(detail)normalsupdatedelay=0;
1502 if(targetanimation==rollanim&&targetframe==3&&onfire){
1504 emit_sound_at(fireendsound, coords);
1505 pause_sound(stream_firesound);
1509 if(targetanimation==rabbittacklinganim&&targetframe==1){
1510 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1511 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1512 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1513 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1514 else victim->targetanimation=rabbittackledfrontanim;
1515 victim->targetframe=2;
1517 victim->rotation=rotation;
1518 victim->targetrotation=rotation;
1519 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1520 //victim->DoDamage(30);
1521 if(creature==wolftype){
1523 emit_sound_at(clawslicesound, victim->coords);
1525 victim->DoBloodBig(1/victim->armorhead,210);
1527 award_bonus(id, TackleBonus,
1528 victim->aitype == gethelptype ? 50 : 0);
1532 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1533 if(weapons.type[weaponids[0]]==knife){
1534 if(weaponactive==-1)weaponactive=0;
1535 else if(weaponactive==0)weaponactive=-1;
1537 if(weaponactive==-1){
1538 emit_sound_at(knifesheathesound, coords);
1540 if(weaponactive!=-1){
1541 emit_sound_at(knifedrawsound, coords, 128);
1544 drawtogglekeydown=1;
1547 if(tutoriallevel!=1||id==0)
1548 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1551 if(terrain.getOpacity(coords.x,coords.z)<.2){
1552 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1553 else whichsound=footstepsound2;
1554 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1555 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1556 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1562 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1563 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1564 else whichsound=footstepsound4;
1568 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1569 else whichsound=footstepsound4;
1571 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1572 if(animation[targetanimation].attack!=neutral){
1574 if(i==0)whichsound=lowwhooshsound;
1575 if(i==1)whichsound=midwhooshsound;
1576 if(i==2)whichsound=highwhooshsound;
1578 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1580 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1581 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1583 emit_sound_at(whichsound, coords, 256.);
1586 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1587 envsound[numenvsounds]=coords;
1588 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1589 else envsoundvol[numenvsounds]=6;
1590 envsoundlife[numenvsounds]=.4;
1594 if(animation[targetanimation].label[targetframe]==3){
1596 emit_sound_at(whichsound, coords, 128.);
1601 if(tutoriallevel!=1||id==0)
1603 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1604 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1606 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1607 if(animation[targetanimation].attack!=neutral){
1609 if(creature==rabbittype){
1610 if(i==0)whichsound=rabbitattacksound;
1611 if(i==1)whichsound=rabbitattack2sound;
1612 if(i==2)whichsound=rabbitattack3sound;
1613 if(i==3)whichsound=rabbitattack4sound;
1615 if(creature==wolftype){
1616 if(i==0)whichsound=barksound;
1617 if(i==1)whichsound=bark2sound;
1618 if(i==2)whichsound=bark3sound;
1619 if(i==3)whichsound=barkgrowlsound;
1623 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1625 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1626 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
1629 emit_sound_at(whichsound, coords);
1635 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
1641 currentoffset=targetoffset;
1642 targetframe=currentframe;
1643 currentanimation=targetanimation;
1646 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
1647 for(i=0;i<weapons.numweapons;i++){
1648 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
1649 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
1650 if(findDistancefast(&coords,&weapons.position[i])>=1){
1651 if(weapons.type[i]!=staff){
1652 emit_sound_at(knifedrawsound, coords, 128.);
1656 weapons.owner[i]=id;
1658 weaponids[num_weapons]=weaponids[0];
1667 static bool willwork;
1668 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
1669 for(i=0;i<weapons.numweapons;i++){
1671 if(weapons.owner[i]!=-1)
1672 if(player[weapons.owner[i]].weaponstuck!=-1)
1673 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
1674 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
1675 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))
1676 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
1677 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
1679 if(weapons.owner[i]!=-1)
1680 if(victim->weaponstuck!=-1){
1681 if(victim->weaponids[victim->weaponstuck]==i){
1686 if(weapons.type[i]!=staff){
1687 emit_sound_at(knifedrawsound, coords, 128.);
1691 emit_sound_at(fleshstabremovesound, coords, 128.);
1694 if(weapons.owner[i]!=-1){
1696 victim=&player[weapons.owner[i]];
1697 if(victim->num_weapons==1)victim->num_weapons=0;
1698 else victim->num_weapons=1;
1700 //victim->weaponactive=-1;
1701 victim->skeleton.longdead=0;
1702 victim->skeleton.free=1;
1703 victim->skeleton.broken=0;
1705 for(int j=0;j<victim->skeleton.num_joints;j++){
1706 victim->skeleton.joints[j].velchange=0;
1707 victim->skeleton.joints[j].locked=0;
1713 Normalise(&relative);
1714 XYZ footvel,footpoint;
1716 footpoint=weapons.position[i];
1717 if(victim->weaponstuck!=-1){
1718 if(victim->weaponids[victim->weaponstuck]==i){
1719 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
1720 weapons.bloody[i]=2;
1721 weapons.blooddrip[i]=5;
1722 victim->weaponstuck=-1;
1725 if(victim->num_weapons>0){
1726 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
1727 if(victim->weaponids[0]==i)
1728 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1731 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
1732 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
1733 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
1734 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
1736 weapons.owner[i]=id;
1738 weaponids[num_weapons]=weaponids[0];
1747 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
1748 if(weaponactive==-1)weaponactive=0;
1749 else if(weaponactive==0){
1753 buffer=weaponids[0];
1754 weaponids[0]=weaponids[1];
1755 weaponids[1]=buffer;
1758 if(weaponactive==-1){
1759 emit_sound_at(knifesheathesound, coords, 128.);
1761 if(weaponactive!=-1){
1762 emit_sound_at(knifedrawsound, coords, 128.);
1767 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
1768 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
1769 Normalise(&rotatetarget);
1770 targetrotation=-asin(0-rotatetarget.x);
1771 targetrotation*=360/6.28;
1772 if(rotatetarget.z<0)targetrotation=180-targetrotation;
1774 if(targetanimation==walljumprightkickanim)targetrotation+=40;
1775 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
1780 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
1782 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;
1784 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
1785 targetanimation=rabbittackleanim;
1787 emit_sound_at(jumpsound, coords);
1796 Normalise(&targetloc);
1798 for(i=0;i<numplayers;i++){
1800 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
1801 closestdist=findDistancefast(&targetloc,&player[i].coords);
1806 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
1808 victim=&player[closestid];
1809 coords=victim->coords;
1810 currentanimation=rabbittacklinganim;
1811 targetanimation=rabbittacklinganim;
1815 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
1816 rotatetarget=coords-victim->coords;
1817 Normalise(&rotatetarget);
1818 targetrotation=-asin(0-rotatetarget.x);
1819 targetrotation*=360/6.28;
1820 if(rotatetarget.z<0)targetrotation=180-targetrotation;
1822 if(targetanimation!=rabbitrunninganim){
1823 emit_sound_at(jumpsound, coords, 128.);
1829 float damagemult=1*power;
1830 if(creature==wolftype)damagemult=2.5*power;
1831 if(hasvictim){damagemult/=victim->damagetolerance/200;}
1832 //if(onfire)damagemult=3;
1833 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
1834 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
1835 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
1837 if(id==0)camerashake+=.4;
1838 if(Random()%2||creature==wolftype){
1841 if(creature==wolftype)DoBloodBig(0,250);
1843 if(tutoriallevel!=1){
1844 emit_sound_at(heavyimpactsound, victim->coords, 128.);
1846 if(creature==wolftype){
1847 emit_sound_at(clawslicesound, victim->coords, 128.);
1849 victim->DoBloodBig(2/victim->armorhead,175);
1853 relative=victim->coords-coords;
1855 Normalise(&relative);
1856 relative=DoRotation(relative,0,-90,0);
1857 for(i=0;i<victim->skeleton.num_joints;i++){
1858 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
1860 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
1863 victim->DoDamage(damagemult*100/victim->protectionhead);
1869 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
1870 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
1872 if(id==0)camerashake+=.4;
1873 if(Random()%2||creature==wolftype){
1875 if(creature==wolftype)DoBloodBig(0,235);
1877 emit_sound_at(whooshhitsound, victim->coords);
1878 if(creature==wolftype){
1879 emit_sound_at(clawslicesound, victim->coords, 128.);
1881 victim->DoBloodBig(2,175);
1885 relative=victim->coords-coords;
1887 Normalise(&relative);
1889 Normalise(&relative);
1890 relative=DoRotation(relative,0,90,0);
1891 for(i=0;i<victim->skeleton.num_joints;i++){
1892 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
1894 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
1897 victim->DoDamage(damagemult*50/victim->protectionhead);
1901 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
1902 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
1904 if(id==0)camerashake+=.4;
1907 if(tutoriallevel!=1){
1908 emit_sound_at(heavyimpactsound, victim->coords, 160.);
1910 if(creature==wolftype){
1911 emit_sound_at(clawslicesound, victim->coords, 128.);
1913 victim->DoBloodBig(2/victim->armorhead,175);
1919 Normalise(&relative);
1920 relative=DoRotation(relative,0,-90,0);
1921 for(i=0;i<victim->skeleton.num_joints;i++){
1922 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
1924 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
1927 victim->DoDamage(damagemult*150/victim->protectionhead);
1929 if(victim->damage>victim->damagetolerance)
1930 award_bonus(id, style);
1936 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
1937 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
1939 if(id==0)camerashake+=.4;
1942 if(tutoriallevel!=1){
1943 emit_sound_at(heavyimpactsound, victim->coords, 160.);
1945 if(creature==wolftype){
1946 emit_sound_at(clawslicesound, victim->coords, 128.);
1948 victim->DoBloodBig(2/victim->armorhead,175);
1954 Normalise(&relative);
1955 relative=DoRotation(relative,0,90,0);
1956 for(i=0;i<victim->skeleton.num_joints;i++){
1957 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
1959 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
1962 victim->DoDamage(damagemult*150/victim->protectionhead);
1964 if(victim->damage>victim->damagetolerance)
1965 award_bonus(id, style);
1971 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
1972 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
1974 if(id==0)camerashake+=.4;
1979 emit_sound_at(whooshhitsound, victim->coords);
1982 relative=victim->coords-coords;
1984 Normalise(&relative);
1985 for(i=0;i<victim->skeleton.num_joints;i++){
1986 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
1988 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
1991 victim->DoDamage(damagemult*50/victim->protectionhead);
1995 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
1996 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
1998 if(id==0)camerashake+=.2;
1999 emit_sound_at(whooshhitsound, victim->coords, 128.);
2001 victim->skeleton.longdead=0;
2002 victim->skeleton.free=1;
2003 victim->skeleton.broken=0;
2004 victim->skeleton.spinny=1;
2006 for(i=0;i<victim->skeleton.num_joints;i++){
2007 victim->skeleton.joints[i].velchange=0;
2008 victim->skeleton.joints[i].delay=0;
2009 victim->skeleton.joints[i].locked=0;
2010 //victim->skeleton.joints[i].velocity=0;
2016 Normalise(&relative);
2017 for(i=0;i<victim->skeleton.num_joints;i++){
2018 victim->skeleton.joints[i].velocity.y=relative.y*10;
2019 victim->skeleton.joints[i].position.y+=relative.y*.3;
2020 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2021 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2023 victim->Puff(abdomen);
2024 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2028 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2029 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2031 if(id==0)camerashake+=.4;
2032 if(tutoriallevel!=1){
2033 emit_sound_at(heavyimpactsound, coords, 128.);
2036 relative=victim->coords-coords;
2038 Normalise(&relative);
2039 for(i=0;i<victim->skeleton.num_joints;i++){
2040 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2042 victim->Puff(abdomen);
2043 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2047 victim->DoDamage(damagemult*500/victim->protectionhigh);
2048 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2052 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2053 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2055 if(id==0)camerashake+=.4;
2056 if(tutoriallevel!=1){
2057 emit_sound_at(thudsound, coords);
2060 victim->skeleton.longdead=0;
2061 victim->skeleton.free=1;
2062 victim->skeleton.broken=0;
2063 victim->skeleton.spinny=1;
2065 for(i=0;i<victim->skeleton.num_joints;i++){
2066 victim->skeleton.joints[i].velchange=0;
2067 //victim->skeleton.joints[i].delay=0;
2068 victim->skeleton.joints[i].locked=0;
2071 relative=victim->coords-coords;
2072 Normalise(&relative);
2074 Normalise(&relative);
2075 for(i=0;i<victim->skeleton.num_joints;i++){
2076 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2081 victim->Puff(abdomen);
2082 victim->DoDamage(damagemult*20/victim->protectionhigh);
2083 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2085 if(!victim->dead)staggerdelay=1.2;
2091 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2092 //if(id==0)camerashake+=.4;
2095 if(!victim->skeleton.free)hasvictim=0;
2098 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2099 emit_sound_at(knifesheathesound, coords, 128.);
2102 if(victim&&hasvictim){
2103 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2105 XYZ where,startpoint,endpoint,movepoint,colpoint;
2106 float rotationpoint;
2108 if(weapons.type[weaponids[weaponactive]]==knife){
2109 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2110 where-=victim->coords;
2111 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2118 if(weapons.type[weaponids[weaponactive]]==sword){
2119 where=weapons.position[weaponids[weaponactive]];
2120 where-=victim->coords;
2121 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2123 where=weapons.tippoint[weaponids[weaponactive]];
2124 where-=victim->coords;
2125 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2128 if(weapons.type[weaponids[weaponactive]]==staff){
2129 where=weapons.position[weaponids[weaponactive]];
2130 where-=victim->coords;
2131 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2133 where=weapons.tippoint[weaponids[weaponactive]];
2134 where-=victim->coords;
2135 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2140 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2143 if(victim->dead!=2){
2144 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2146 award_bonus(id, FinishedBonus);
2148 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2150 victim->skeleton.longdead=0;
2151 victim->skeleton.free=1;
2152 victim->skeleton.broken=0;
2154 for(i=0;i<victim->skeleton.num_joints;i++){
2155 victim->skeleton.joints[i].velchange=0;
2156 victim->skeleton.joints[i].locked=0;
2157 //victim->skeleton.joints[i].velocity=0;
2159 emit_sound_at(fleshstabsound, coords, 128);
2162 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2163 weapons.blooddrip[weaponids[weaponactive]]+=5;
2164 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2168 emit_sound_at(knifesheathesound, coords, 128.);
2174 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2176 emit_sound_at(knifedrawsound, coords, 128);
2179 if(victim&&hasvictim){
2180 XYZ footvel,footpoint;
2182 emit_sound_at(fleshstabremovesound, coords, 128.);
2185 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2187 if(weapons.type[weaponids[weaponactive]]==sword){
2188 XYZ where,startpoint,endpoint,movepoint;
2189 float rotationpoint;
2192 where=weapons.position[weaponids[weaponactive]];
2193 where-=victim->coords;
2194 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2196 where=weapons.tippoint[weaponids[weaponactive]];
2197 where-=victim->coords;
2198 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2203 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2204 footpoint+=victim->coords;
2207 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2210 if(weapons.type[weaponids[weaponactive]]==staff){
2211 XYZ where,startpoint,endpoint,movepoint;
2212 float rotationpoint;
2215 where=weapons.position[weaponids[weaponactive]];
2216 where-=victim->coords;
2217 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2219 where=weapons.tippoint[weaponids[weaponactive]];
2220 where-=victim->coords;
2221 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2226 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2227 footpoint+=victim->coords;
2230 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2233 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2235 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2236 victim->skeleton.longdead=0;
2237 victim->skeleton.free=1;
2238 victim->skeleton.broken=0;
2240 for(i=0;i<victim->skeleton.num_joints;i++){
2241 victim->skeleton.joints[i].velchange=0;
2242 victim->skeleton.joints[i].locked=0;
2243 //victim->skeleton.joints[i].velocity=0;
2249 Normalise(&relative);
2250 //victim->Puff(abdomen);
2251 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2253 if(victim->bloodloss<victim->damagetolerance){
2254 victim->bloodloss+=1000;
2258 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2262 if(!hasvictim&&onterrain){
2263 weapons.bloody[weaponids[weaponactive]]=0;
2264 weapons.blooddrip[weaponids[weaponactive]]=0;
2268 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2269 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2271 if(id==0)camerashake+=.4;
2276 if(tutoriallevel!=1){
2277 emit_sound_at(heavyimpactsound, victim->coords, 128);
2282 relative=victim->coords-coords;
2284 Normalise(&relative);
2285 for(i=0;i<victim->skeleton.num_joints;i++){
2286 victim->skeleton.joints[i].velocity=relative*30;
2288 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2290 victim->targetframe=0;
2291 victim->targetanimation=staggerbackhardanim;
2292 victim->targetrotation=targetrotation+180;
2297 victim->Puff(abdomen);
2298 victim->DoDamage(damagemult*60/victim->protectionhigh);
2305 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2306 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2308 if(id==0)camerashake+=.4;
2309 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2310 if(tutoriallevel!=1){
2311 emit_sound_at(thudsound, victim->coords);
2314 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2315 if(tutoriallevel!=1){
2316 emit_sound_at(whooshhitsound, victim->coords);
2320 if(tutoriallevel!=1){
2321 emit_sound_at(heavyimpactsound, victim->coords);
2325 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2328 relative=victim->coords-coords;
2330 Normalise(&relative);
2332 Normalise(&relative);
2333 for(i=0;i<victim->skeleton.num_joints;i++){
2334 victim->skeleton.joints[i].velocity=relative*5;
2336 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
2338 victim->targetframe=0;
2339 victim->targetanimation=staggerbackhardanim;
2340 victim->targetrotation=targetrotation+180;
2344 victim->Puff(abdomen);
2345 victim->DoDamage(damagemult*60/victim->protectionhigh);
2351 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
2352 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2353 if(victim->id==0)camerashake+=.4;
2354 emit_sound_at(landsound2, victim->coords);
2360 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
2361 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2362 if(victim->id==0)camerashake+=.4;
2364 if(weaponactive!=-1){
2365 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
2366 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2367 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2369 emit_sound_at(swordstaffsound, victim->coords);
2372 emit_sound_at(metalhitsound, victim->coords);
2380 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
2381 if(weaponactive!=-1){
2384 weapons.owner[weaponids[0]]=-1;
2385 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);
2387 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
2388 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
2390 weapons.velocity[weaponids[0]]=aim*50;
2391 weapons.tipvelocity[weaponids[0]]=aim*50;
2392 weapons.missed[weaponids[0]]=0;
2393 weapons.hitsomething[weaponids[0]]=0;
2394 weapons.freetime[weaponids[0]]=0;
2395 weapons.firstfree[weaponids[0]]=1;
2396 weapons.physics[weaponids[0]]=0;
2399 weaponids[0]=weaponids[num_weapons];
2405 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
2407 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
2409 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
2411 award_bonus(id, Slicebonus);
2412 if(tutoriallevel!=1){
2413 emit_sound_at(knifeslicesound, victim->coords);
2415 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2416 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
2417 if(victim->id != 0 || difficulty==2){
2418 victim->targetframe=0;
2419 victim->targetanimation=staggerbackhardanim;
2420 victim->targetrotation=targetrotation+180;
2424 victim->lowreversaldelay=0;
2425 victim->highreversaldelay=0;
2426 if(aitype!=playercontrolled)weaponmissdelay=.6;
2428 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
2429 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
2431 XYZ footvel,footpoint;
2434 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
2437 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;
2439 if(tutoriallevel!=1){
2440 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
2441 footvel=DoRotation(facing,0,90,0)*.8;
2443 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2444 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2445 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
2446 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
2448 if(tutoriallevel==1){
2449 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
2451 victim->DoDamage(damagemult*0);
2454 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
2455 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
2456 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
2457 award_bonus(id, Slashbonus);
2459 if(tutoriallevel!=1){
2460 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
2461 else victim->DoBloodBig(2/victim->armorhigh,185);
2462 victim->deathbleeding=1;
2463 emit_sound_at(swordslicesound, victim->coords);
2465 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2466 if(tutoriallevel!=1){
2467 victim->targetframe=0;
2468 victim->targetanimation=staggerbackhardanim;
2469 victim->targetrotation=targetrotation+180;
2473 if(tutoriallevel!=1){
2474 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
2475 weapons.blooddrip[weaponids[weaponactive]]+=3;
2477 float bloodlossamount;
2478 bloodlossamount=200+abs((float)(Random()%40))-20;
2479 victim->bloodloss+=bloodlossamount/victim->armorhigh;
2480 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
2481 victim->DoDamage(damagemult*0);
2483 XYZ footvel,footpoint;
2486 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
2489 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;
2491 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
2492 footvel=DoRotation(facing,0,90,0)*.8;
2494 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2495 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2496 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
2497 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
2501 if(victim->weaponactive!=-1){
2502 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
2503 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2504 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2506 emit_sound_at(swordstaffsound, victim->coords);
2509 emit_sound_at(metalhitsound, victim->coords);
2515 victim->Puff(righthand);
2517 victim->targetframe=0;
2518 victim->targetanimation=staggerbackhighanim;
2519 victim->targetrotation=targetrotation+180;
2521 weapons.owner[victim->weaponids[0]]=-1;
2522 aim=DoRotation(facing,0,90,0)*21;
2524 weapons.velocity[victim->weaponids[0]]=aim*-.2;
2525 weapons.tipvelocity[victim->weaponids[0]]=aim;
2526 weapons.missed[victim->weaponids[0]]=1;
2527 weapons.hitsomething[weaponids[0]]=0;
2528 weapons.freetime[victim->weaponids[0]]=0;
2529 weapons.firstfree[victim->weaponids[0]]=1;
2530 weapons.physics[victim->weaponids[0]]=1;
2531 victim->num_weapons--;
2532 if(victim->num_weapons){
2533 victim->weaponids[0]=victim->weaponids[num_weapons];
2534 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
2536 victim->weaponactive=-1;
2537 for(i=0;i<numplayers;i++){
2538 player[i].wentforweapon=0;
2545 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
2546 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
2547 if(tutoriallevel!=1){
2548 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
2550 if(id==0)camerashake+=.4;
2551 if(Random()%2||creature==wolftype){
2554 emit_sound_at(staffheadsound, victim->coords);
2558 relative=victim->coords-coords;
2560 Normalise(&relative);
2561 relative=DoRotation(relative,0,90,0);
2563 Normalise(&relative);
2564 for(i=0;i<victim->skeleton.num_joints;i++){
2565 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
2567 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
2568 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
2571 if(tutoriallevel!=1){
2572 victim->DoDamage(damagemult*120/victim->protectionhigh);
2574 award_bonus(id, solidhit, 30);
2579 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
2580 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
2581 if(tutoriallevel!=1){
2582 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
2584 if(id==0)camerashake+=.4;
2585 if(Random()%2||creature==wolftype){
2588 emit_sound_at(staffheadsound, victim->coords);
2592 relative=victim->coords-coords;
2594 Normalise(&relative);
2595 relative=DoRotation(relative,0,-90,0);
2596 for(i=0;i<victim->skeleton.num_joints;i++){
2597 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2599 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
2600 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
2603 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
2605 award_bonus(id, solidhit, 60);
2610 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
2611 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
2613 if(tutoriallevel!=1){
2614 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
2615 if(id==0)camerashake+=.4;
2616 if(Random()%2||creature==wolftype){
2619 emit_sound_at(staffbodysound, victim->coords);
2621 victim->skeleton.longdead=0;
2622 victim->skeleton.free=1;
2623 victim->skeleton.broken=0;
2625 for(i=0;i<victim->skeleton.num_joints;i++){
2626 victim->skeleton.joints[i].velchange=0;
2627 victim->skeleton.joints[i].locked=0;
2628 //victim->skeleton.joints[i].velocity=0;
2634 /*relative=victim->coords-coords;
2636 Normalise(&relative);
2637 relative=DoRotation(relative,0,90,0);*/
2639 Normalise(&relative);
2641 for(i=0;i<victim->skeleton.num_joints;i++){
2642 victim->skeleton.joints[i].velocity=relative*damagemult*40;
2645 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
2648 for(i=0;i<victim->skeleton.num_joints;i++){
2649 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
2652 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2654 victim->Puff(abdomen);
2655 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
2658 award_bonus(id, solidhit, 40);
2664 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
2665 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
2667 if(id==0)camerashake+=.4;
2669 relative=victim->coords-coords;
2671 Normalise(&relative);
2675 if(animation[victim->targetanimation].height==lowheight){
2681 for(i=0;i<victim->skeleton.num_joints;i++){
2682 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2684 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2685 if(tutoriallevel!=1){
2686 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2689 victim->DoDamage(damagemult*100/victim->protectionhead);
2690 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
2691 if(creature==wolftype){
2692 emit_sound_at(clawslicesound, victim->coords, 128.);
2694 victim->DoBloodBig(2/victim->armorhead,175);
2698 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
2699 for(i=0;i<victim->skeleton.num_joints;i++){
2700 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
2702 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2703 victim->targetframe=0;
2704 victim->targetanimation=staggerbackhighanim;
2705 victim->targetrotation=targetrotation+180;
2707 if(tutoriallevel!=1){
2708 emit_sound_at(landsound2, victim->coords, 128.);
2710 victim->Puff(abdomen);
2711 victim->DoDamage(damagemult*30/victim->protectionhigh);
2712 if(creature==wolftype){
2713 emit_sound_at(clawslicesound, victim->coords, 128.);
2715 victim->DoBloodBig(2/victim->armorhigh,170);
2722 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
2723 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
2725 if(id==0)camerashake+=.2;
2726 if(tutoriallevel!=1){
2727 emit_sound_at(landsound2, victim->coords, 128.);
2730 relative=victim->coords-coords;
2732 Normalise(&relative);
2734 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
2737 for(i=0;i<victim->skeleton.num_joints;i++){
2738 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
2740 relative=DoRotation(relative,0,-90,0);
2742 for(i=0;i<victim->skeleton.num_joints;i++){
2743 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)
2744 victim->skeleton.joints[i].velocity=relative*80;
2746 victim->Puff(rightankle);
2747 victim->Puff(leftankle);
2748 victim->DoDamage(damagemult*40/victim->protectionlow);
2751 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
2752 for(i=0;i<victim->skeleton.num_joints;i++){
2753 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
2755 relative=DoRotation(relative,0,-90,0);
2756 for(i=0;i<victim->skeleton.num_joints;i++){
2757 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)
2758 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
2760 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2761 victim->targetframe=0;
2762 victim->targetanimation=staggerbackhighanim;
2763 victim->targetrotation=targetrotation+180;
2765 if(tutoriallevel!=1){
2766 emit_sound_at(landsound2, victim->coords, 128.);
2768 victim->Puff(abdomen);
2769 victim->DoDamage(damagemult*30/victim->protectionlow);
2777 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
2778 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
2780 if(id==0)camerashake+=.4;
2785 if(tutoriallevel!=1){
2786 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2788 if(creature==wolftype){
2789 emit_sound_at(clawslicesound, victim->coords, 128);
2791 victim->DoBloodBig(2/victim->armorhigh,170);
2795 relative=victim->coords-oldcoords;
2797 Normalise(&relative);
2798 //relative=DoRotation(relative,0,-90,0);
2799 for(i=0;i<victim->skeleton.num_joints;i++){
2800 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2802 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2804 victim->Puff(abdomen);
2805 victim->DoDamage(damagemult*150/victim->protectionhigh);
2807 award_bonus(id, Reversal);
2810 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
2811 if(victim->weaponactive!=-1&&victim->num_weapons>0){
2812 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
2813 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
2816 weaponids[num_weapons]=weaponids[victim->weaponactive];
2819 weaponids[0]=victim->weaponids[victim->weaponactive];
2820 victim->num_weapons--;
2821 if(victim->num_weapons>0){
2822 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
2823 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
2825 victim->weaponactive=-1;
2830 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
2832 if(id==0)camerashake+=.4;
2837 emit_sound_at(whooshhitsound, victim->coords, 128.);
2840 relative=victim->coords-oldcoords;
2842 Normalise(&relative);
2843 //relative=DoRotation(relative,0,-90,0);
2844 for(i=0;i<victim->skeleton.num_joints;i++){
2845 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2847 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2850 victim->DoDamage(damagemult*70/victim->protectionhigh);
2853 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
2855 if(id==0)camerashake+=.4;
2861 award_bonus(id, staffreversebonus);
2863 if(tutoriallevel!=1){
2864 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2867 award_bonus(id, staffreversebonus); // Huh, again?
2870 relative=victim->coords-oldcoords;
2872 Normalise(&relative);
2873 //relative=DoRotation(relative,0,-90,0);
2874 for(i=0;i<victim->skeleton.num_joints;i++){
2875 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2877 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2880 victim->DoDamage(damagemult*70/victim->protectionhigh);
2883 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
2889 Normalise(&relative);
2892 for(i=0;i<victim->skeleton.num_joints;i++){
2893 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
2895 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
2896 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
2897 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
2898 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
2899 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
2900 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
2901 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
2902 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
2904 victim->Puff(abdomen);
2905 victim->DoDamage(damagemult*90/victim->protectionhigh);
2907 award_bonus(id, Reversal);
2911 if(weaponactive!=-1||creature==wolftype)doslice=1;
2912 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
2914 if(weaponactive!=-1){
2915 victim->DoBloodBig(2/victim->armorhigh,225);
2916 emit_sound_at(knifeslicesound, victim->coords);
2917 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
2918 weapons.blooddrip[weaponids[weaponactive]]+=3;
2920 if(weaponactive==-1&&creature==wolftype){;
2921 emit_sound_at(clawslicesound, victim->coords, 128.);
2923 victim->DoBloodBig(2/victim->armorhigh,175);
2930 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
2936 Normalise(&relative);
2939 for(i=0;i<victim->skeleton.num_joints;i++){
2940 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
2942 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
2943 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
2944 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
2945 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
2946 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
2947 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
2948 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
2949 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
2951 award_bonus(id, swordreversebonus);
2954 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
2956 if(id==0)camerashake+=.4;
2961 if(tutoriallevel!=1){
2962 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2966 relative=victim->coords-oldcoords;
2968 Normalise(&relative);
2969 relative=DoRotation(relative,0,-90,0);
2970 for(i=0;i<victim->skeleton.num_joints;i++){
2971 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2973 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2975 victim->Puff(abdomen);
2976 victim->DoDamage(damagemult*30/victim->protectionhigh);
2978 award_bonus(id, Reversal);
2981 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
2984 victim->skeleton.spinny=0;
2988 Normalise(&relative);
2989 if(victim->id==0)relative/=30;
2990 for(i=0;i<victim->skeleton.num_joints;i++){
2991 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2993 //victim->DoDamage(1000);
2994 victim->damage=victim->damagetolerance;
2995 victim->permanentdamage=victim->damagetolerance-1;
2998 if(weaponactive!=-1||creature==wolftype)doslice=1;
2999 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3001 if(weaponactive!=-1){
3002 victim->DoBloodBig(200,225);
3003 emit_sound_at(knifeslicesound, victim->coords);
3004 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3005 weapons.blooddrip[weaponids[weaponactive]]+=5;
3008 if(creature==wolftype&&weaponactive==-1){
3009 emit_sound_at(clawslicesound, victim->coords, 128.);
3011 victim->DoBloodBig(2,175);
3014 award_bonus(id, spinecrusher);
3017 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3018 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3020 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3021 if(targetanimation==knifesneakattackanim){
3022 /*victim->DoBloodBig(200,195);
3027 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3028 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3030 XYZ footvel,footpoint;
3032 footpoint=weapons.tippoint[weaponids[0]];
3033 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3034 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3035 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3036 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3037 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3038 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3039 victim->DoBloodBig(200,195);
3040 award_bonus(id, tracheotomy);
3042 if(targetanimation==knifefollowanim){
3043 award_bonus(id, Stabbonus);
3044 XYZ footvel,footpoint;
3046 footpoint=weapons.tippoint[weaponids[0]];
3047 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3048 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3049 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3050 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3051 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3052 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3055 victim->bloodloss+=10000;
3057 emit_sound_at(fleshstabsound, victim->coords);
3058 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3059 weapons.blooddrip[weaponids[weaponactive]]+=5;
3063 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
3066 for(i=0;i<victim->skeleton.num_joints;i++){
3067 victim->skeleton.joints[i].velocity=0;
3069 if(targetanimation==knifefollowanim){
3071 for(i=0;i<victim->skeleton.num_joints;i++){
3072 victim->skeleton.joints[i].velocity=0;
3075 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
3076 emit_sound_at(fleshstabremovesound, victim->coords);
3077 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3078 weapons.blooddrip[weaponids[weaponactive]]+=5;
3080 XYZ footvel,footpoint;
3082 footpoint=weapons.tippoint[weaponids[0]];
3083 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3084 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3085 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3086 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3087 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3088 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3092 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3093 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3094 award_bonus(id, backstab);
3098 XYZ footvel,footpoint;
3100 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
3101 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3102 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3103 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3104 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3105 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3106 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3107 victim->DoBloodBig(200,180);
3108 victim->DoBloodBig(200,215);
3109 victim->bloodloss+=10000;
3111 emit_sound_at(fleshstabsound, victim->coords);
3112 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3113 weapons.blooddrip[weaponids[weaponactive]]+=5;
3117 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
3120 for(i=0;i<victim->skeleton.num_joints;i++){
3121 victim->skeleton.joints[i].velocity=0;
3123 if(weaponactive!=-1){
3124 emit_sound_at(fleshstabremovesound, victim->coords);
3125 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3126 weapons.blooddrip[weaponids[weaponactive]]+=5;
3128 XYZ footvel,footpoint;
3130 footpoint=weapons.tippoint[weaponids[0]];
3131 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3132 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3133 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3134 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3135 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3136 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3140 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
3142 if(id==0)camerashake+=.4;
3147 if(weaponactive==-1){
3148 if(tutoriallevel!=1){
3149 emit_sound_at(heavyimpactsound, victim->coords, 128.);
3154 if(weaponactive!=-1||creature==wolftype)doslice=1;
3155 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3157 if(weaponactive!=-1){
3158 victim->DoBloodBig(2/victim->armorhead,225);
3159 emit_sound_at(knifeslicesound, victim->coords);
3160 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3161 weapons.blooddrip[weaponids[weaponactive]]+=3;
3163 if(weaponactive==-1&&creature==wolftype){
3164 emit_sound_at(clawslicesound, victim->coords, 128.);
3166 victim->DoBloodBig(2/victim->armorhead,175);
3170 award_bonus(id, Reversal);
3175 //relative=victim->coords-oldcoords;
3178 Normalise(&relative);
3179 relative=DoRotation(relative,0,90,0);
3181 Normalise(&relative);
3182 for(i=0;i<victim->skeleton.num_joints;i++){
3183 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
3185 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3186 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
3187 victim->DoDamage(damagemult*100/victim->protectionhead);
3191 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
3195 //relative=victim->coords-oldcoords;
3198 Normalise(&relative);
3199 relative=DoRotation(relative,0,90,0);
3201 Normalise(&relative);
3202 for(i=0;i<victim->skeleton.num_joints;i++){
3203 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
3205 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3208 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
3209 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
3210 award_bonus(id, reverseko);
3216 if(targetframe>animation[currentanimation].numframes-1){
3219 targetanimation=getIdle();
3223 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
3224 targetanimation=rollanim;
3226 emit_sound_at(movewhooshsound, coords, 128.);
3228 if(currentanimation==staggerbackhighanim){
3229 targetanimation=getIdle();
3231 if(currentanimation==staggerbackhardanim){
3232 targetanimation=getIdle();
3234 if(currentanimation==removeknifeanim){
3235 targetanimation=getIdle();
3237 if(currentanimation==crouchremoveknifeanim){
3238 targetanimation=getCrouch();
3240 if(currentanimation==backhandspringanim){
3241 targetanimation=getIdle();
3243 if(currentanimation==dodgebackanim){
3244 targetanimation=getIdle();
3246 if(currentanimation==drawleftanim){
3247 targetanimation=getIdle();
3249 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
3250 targetanimation=getIdle();
3251 if(currentanimation==crouchdrawrightanim){
3252 targetanimation=getCrouch();
3254 if(weaponactive==-1)weaponactive=0;
3255 else if(weaponactive==0){
3259 buffer=weaponids[0];
3260 weaponids[0]=weaponids[1];
3261 weaponids[1]=buffer;
3265 if(weaponactive==-1){
3266 emit_sound_at(knifesheathesound, coords, 128.);
3268 if(weaponactive!=-1){
3269 emit_sound_at(knifedrawsound, coords, 128.);
3272 if(currentanimation==rollanim){
3273 targetanimation=getCrouch();
3278 if(targetanimation==walljumprightkickanim){
3281 if(targetanimation==walljumpleftkickanim){
3284 targetanimation=jumpdownanim;
3286 if(currentanimation==climbanim){
3287 targetanimation=getCrouch();
3290 if(!isnormal(coords.x))
3301 if(targetanimation==rabbitkickreversalanim){
3302 targetanimation=getCrouch();
3305 if(targetanimation==jumpreversalanim){
3306 targetanimation=getCrouch();
3309 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
3310 if(attackkeydown&&targetanimation!=walljumpfrontanim){
3312 float closestdist=-1;
3315 for(i=0;i<numplayers;i++){
3316 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
3317 distance=findDistancefast(&player[i].coords,&coords);
3318 if(closestdist==-1||distance<closestdist){
3319 closestdist=distance;
3324 if(closestdist>0&&closest>=0&&closestdist<16){
3325 victim=&player[closest];
3326 targetanimation=walljumprightkickanim;
3328 XYZ rotatetarget=victim->coords-coords;
3329 Normalise(&rotatetarget);
3330 rotation=-asin(0-rotatetarget.x);
3332 if(rotatetarget.z<0)rotation=180-rotation;
3333 targettilt2=-asin(rotatetarget.y)*360/6.28;
3334 velocity=(victim->coords-coords)*4;
3339 if(targetanimation==walljumpbackanim){
3340 targetanimation=backflipanim;
3345 resume_stream(whooshsound);
3347 if(targetanimation==walljumprightanim){
3348 targetanimation=rightflipanim;
3352 velocity=DoRotation(facing,0,30,0)*-8;
3355 if(targetanimation==walljumpfrontanim){
3356 targetanimation=frontflipanim;
3358 //targetrotation-=180;
3364 resume_stream(whooshsound);
3366 if(targetanimation==walljumpleftanim){
3369 float closestdist=-1;
3372 for(i=0;i<numplayers;i++){
3373 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
3374 distance=findDistancefast(&player[i].coords,&coords);
3375 if(closestdist==-1||distance<closestdist){
3376 closestdist=distance;
3381 if(closestdist>0&&closest>=0&&closestdist<16){
3382 victim=&player[closest];
3383 targetanimation=walljumpleftkickanim;
3385 XYZ rotatetarget=victim->coords-coords;
3386 Normalise(&rotatetarget);
3387 rotation=-asin(0-rotatetarget.x);
3389 if(rotatetarget.z<0)rotation=180-rotation;
3390 targettilt2=-asin(rotatetarget.y)*360/6.28;
3391 velocity=(victim->coords-coords)*4;
3396 if(targetanimation!=walljumpleftkickanim){
3397 targetanimation=leftflipanim;
3401 velocity=DoRotation(facing,0,-30,0)*-8;
3405 resume_stream(whooshsound);
3407 if(targetanimation==sneakattackanim){
3408 float ycoords=oldcoords.y;
3409 currentanimation=getCrouch();
3410 targetanimation=getCrouch();
3413 targetrotation+=180;
3418 targetheadrotation+=180;
3420 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
3424 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
3425 float ycoords=oldcoords.y;
3426 targetanimation=getIdle();
3428 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
3432 if(currentanimation==knifefollowanim){
3433 targetanimation=getIdle();
3436 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
3437 float ycoords=oldcoords.y;
3438 targetanimation=getStop();
3439 targetrotation+=180;
3444 targetheadrotation+=180;
3445 if(!isnormal(coords.x))
3447 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
3448 oldcoords=coords+facing*.5;
3449 else if(currentanimation==sweepreversalanim)
3450 oldcoords=coords+facing*1.1;
3451 else if(currentanimation==upunchreversalanim){
3452 oldcoords=coords+facing*1.5;
3453 targetrotation+=180;
3455 targetheadrotation+=180;
3459 else if(currentanimation==knifeslashreversalanim){
3460 oldcoords=coords+facing*.5;
3463 targetheadrotation+=90;
3467 else if(currentanimation==staffspinhitreversalanim){
3468 targetrotation+=180;
3470 targetheadrotation+=180;
3474 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
3475 else oldcoords.y=ycoords;
3476 currentoffset=coords-oldcoords;
3482 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
3487 if(animation[targetanimation].attack==reversed){
3489 if(targetanimation==sweepreversedanim)targetrotation+=90;
3490 targetanimation=backhandspringanim;
3492 emit_sound_at(landsound, coords, 128);
3494 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
3495 targetanimation=rollanim;
3498 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
3499 coords.y=oldcoords.y;
3501 if(currentanimation==knifeslashreversedanim){
3502 targetanimation=rollanim;
3507 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
3508 coords.y=oldcoords.y;
3512 targetanimation=jumpdownanim;
3514 if(wasLanding())targetanimation=getIdle();
3515 if(wasLandhard())targetanimation=getIdle();
3516 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
3517 targetanimation=getIdle();
3519 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
3520 coords.y=oldcoords.y;
3521 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
3522 targetoffset.y=coords.y;
3523 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
3524 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
3525 currentoffset.y-=(coords.y-targetoffset.y);
3526 coords.y=targetoffset.y;
3528 normalsupdatedelay=0;
3530 if(currentanimation==upunchanim){
3531 targetanimation=getStop();
3532 normalsupdatedelay=0;
3535 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
3536 targetrotation=rotation;
3539 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
3540 if(!hasstaff)DoDamage(35);
3543 rabbitkickragdoll=1;
3545 if(currentanimation==rabbitkickreversedanim){
3552 SolidHitBonus(!id); // FIXME: tricky id
3556 targetanimation=rollanim;
3558 if(id==0)pause_sound(whooshsound);
3562 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
3568 if(currentanimation==jumpreversedanim){
3575 SolidHitBonus(!id); // FIXME: tricky id
3579 targetanimation=rollanim;
3581 if(id==0)pause_sound(whooshsound);
3586 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){
3587 targetanimation=getupfromfrontanim;
3590 else if(animation[currentanimation].attack==normalattack){
3591 targetanimation=getIdle();
3594 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
3595 targetanimation=blockhighleftstrikeanim;
3597 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
3598 targetanimation=getIdle();
3601 if(currentanimation==spinkickanim&&victim->skeleton.free){
3602 if(creature==rabbittype)targetanimation=fightidleanim;
3607 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
3609 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
3610 targetanimation=jumpdownanim;
3615 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
3616 if(!isRun()||!wasRun()){
3617 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
3618 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
3619 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
3620 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
3622 if(isRun()&&wasRun()){
3625 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
3626 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
3629 else if(transspeed)target+=multiplier*transspeed*speed*2;
3631 if(!isRun()||!wasRun()){
3632 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
3633 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
3634 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
3635 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
3639 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
3641 if(target>1){currentframe=targetframe; target=1;}
3643 rot=targetrot*target;
3644 rotation+=rot-oldrot;
3650 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
3652 for(i=0;i<skeleton.num_joints;i++){
3653 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
3656 skeleton.FindForwards();
3658 for(i=0;i<skeleton.num_muscles;i++){
3659 if(skeleton.muscles[i].visible)
3661 skeleton.FindRotationMuscle(i,targetanimation);
3664 for(i=0;i<skeleton.num_muscles;i++){
3665 if(skeleton.muscles[i].visible)
3667 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
3668 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
3669 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
3674 for(i=0;i<skeleton.num_joints;i++){
3675 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
3678 skeleton.FindForwards();
3680 for(i=0;i<skeleton.num_muscles;i++){
3681 if(skeleton.muscles[i].visible)
3683 skeleton.FindRotationMuscle(i,targetanimation);
3686 for(i=0;i<skeleton.num_muscles;i++){
3687 if(skeleton.muscles[i].visible)
3689 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
3690 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
3691 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
3692 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
3693 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
3694 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
3695 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
3696 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
3697 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
3701 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
3703 oldcurrentanimation=currentanimation;
3704 oldtargetanimation=targetanimation;
3705 oldtargetframe=targetframe;
3706 oldcurrentframe=currentframe;
3708 for(i=0;i<skeleton.num_joints;i++){
3709 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
3710 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
3712 offset=currentoffset*(1-target)+targetoffset*target;
3713 for(i=0;i<skeleton.num_muscles;i++){
3714 if(skeleton.muscles[i].visible)
3716 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
3717 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
3718 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
3723 if(isLanding()&&landhard){
3724 if(id==0)camerashake+=.4;
3725 targetanimation=getLandhard();
3732 //skeleton.DoConstraints();
3735 void Person::DoStuff(){
3736 static XYZ terrainnormal;
3737 static XYZ flatfacing;
3738 static XYZ flatvelocity;
3739 static float flatvelspeed;
3743 static int bloodsize;
3744 static int startx,starty,endx,endy;
3745 static int texdetailint;
3746 static GLubyte color;
3747 static XYZ bloodvel;
3749 onfiredelay-=multiplier;
3750 if(onfiredelay<0&&onfire)
3758 crouchkeydowntime+=multiplier;
3759 if(!crouchkeydown)crouchkeydowntime=0;
3760 jumpkeydowntime+=multiplier;
3761 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
3763 if(hostile||damage>0||bloodloss>0)immobile=0;
3765 if(isIdle()||isRun())targetoffset=0;
3767 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
3769 if(id==0)blooddimamount-=multiplier*.3;
3770 speechdelay-=multiplier;
3771 texupdatedelay-=multiplier;
3772 interestdelay-=multiplier;
3773 flamedelay-=multiplier;
3774 parriedrecently-=multiplier;
3780 if(id==0)speed=1.1*speedmult;
3781 else speed=1.0*speedmult;
3782 if(!skeleton.free)rabbitkickragdoll=0;
3786 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
3787 if(id!=0&&creature==wolftype&&difficulty==2){
3789 if(aitype!=passivetype){
3791 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){
3795 if(scale<0.2)superruntoggle=0;
3796 if(targetanimation==wolfrunninganim&&!superruntoggle){
3797 targetanimation=getRun();
3801 if(weaponactive==-1&&num_weapons>0){
3802 if(weapons.type[weaponids[0]]==staff){
3809 /*if(aitype!=playercontrolled)*///deathbleeding=5;
3810 /*if(aitype!=playercontrolled)*/
3812 if(burnt>.6)burnt=.6;
3813 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
3815 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
3826 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
3827 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
3831 while(flamedelay<0&&onfire){
3833 howmany=abs(Random()%(skeleton.num_joints));
3834 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
3835 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
3836 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
3837 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
3838 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
3841 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
3843 howmany=abs(Random()%(skeleton.num_joints));
3844 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
3845 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
3846 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
3847 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
3848 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
3852 bleeding-=multiplier*.3;
3854 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
3855 if(bleeding<=0&&(detail!=2||osx))DoMipmaps();
3859 if(neckspurtamount>0){
3860 neckspurtamount-=multiplier;
3861 neckspurtdelay-=multiplier*3;
3862 neckspurtparticledelay-=multiplier*3;
3863 if(neckspurtparticledelay<0&&neckspurtdelay>2){
3867 bloodvel.z=5*neckspurtamount;
3868 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
3871 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
3873 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
3874 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
3875 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);
3876 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);
3877 neckspurtparticledelay=.05;
3879 if(neckspurtdelay<0){
3884 if(deathbleeding>0&&dead!=2){
3885 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
3886 else bleeddelay-=5*multiplier/4;
3887 if(bleeddelay<0&&bloodtoggle){
3892 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3893 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
3894 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
3895 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);
3898 bloodloss+=deathbleeding*multiplier*80;
3899 deathbleeding-=multiplier*1.6;
3900 //if(id==0)deathbleeding-=multiplier*.2;
3901 if(deathbleeding<0)deathbleeding=0;
3902 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
3903 if(weaponactive!=-1){
3904 weapons.owner[weaponids[0]]=-1;
3905 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
3906 weapons.velocity[weaponids[0]].x+=.01;
3907 weapons.tipvelocity[weaponids[0]]=velocity*scale;
3908 weapons.missed[weaponids[0]]=1;
3909 weapons.hitsomething[weaponids[0]]=0;
3910 weapons.freetime[weaponids[0]]=0;
3911 weapons.firstfree[weaponids[0]]=1;
3912 weapons.physics[weaponids[0]]=1;
3915 weaponids[0]=weaponids[num_weapons];
3916 if(weaponstuck==num_weapons)weaponstuck=0;
3919 for(i=0;i<numplayers;i++){
3920 player[i].wentforweapon=0;
3932 if(!dead&&creature==wolftype){
3933 award_bonus(0, Wolfbonus);
3936 if(targetanimation==knifefollowedanim&&!skeleton.free){
3937 for(i=0;i<skeleton.num_joints;i++){
3938 skeleton.joints[i].velocity=0;
3939 skeleton.joints[i].velocity.y=-2;
3942 if(id!=0&&unconscioustime>.1){
3950 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
3953 bloodsize=5-realtexdetail;
3957 texdetailint=realtexdetail;
3958 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
3959 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
3960 endx=startx+bloodsize;
3961 endy=starty+bloodsize;
3963 if(startx<0){startx=0;bleeding=0;}
3964 if(starty<0){starty=0;bleeding=0;}
3965 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
3966 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
3967 if(endx<startx)endx=startx;
3968 if(endy<starty)endy=starty;
3970 for(i=startx;i<endx;i++){
3971 for(j=starty;j<endy;j++){
3973 color=Random()%85+170;
3974 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
3975 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
3976 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
3981 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
3986 bleedy-=4/realtexdetail;
3987 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
3988 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
3991 bleedx+=4*direction/realtexdetail;
3992 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
3993 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
3997 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
3998 righthandmorphness=targetrighthandmorphness;
3999 righthandmorphstart=righthandmorphend;
4001 else if(righthandmorphness>targetrighthandmorphness){
4002 righthandmorphness-=multiplier*4;
4004 else if(righthandmorphness<targetrighthandmorphness){
4005 righthandmorphness+=multiplier*4;
4008 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
4009 lefthandmorphness=targetlefthandmorphness;
4010 lefthandmorphstart=lefthandmorphend;
4012 else if(lefthandmorphness>targetlefthandmorphness){
4013 lefthandmorphness-=multiplier*4;
4015 else if(lefthandmorphness<targetlefthandmorphness){
4016 lefthandmorphness+=multiplier*4;
4019 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
4020 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
4021 tailmorphness=targettailmorphness;
4022 tailmorphstart=tailmorphend;
4024 else if(tailmorphness>targettailmorphness){
4025 tailmorphness-=multiplier*10;
4027 else if(tailmorphness<targettailmorphness){
4028 tailmorphness+=multiplier*10;
4032 if(creature==wolftype){
4033 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
4034 tailmorphness=targettailmorphness;
4035 tailmorphstart=tailmorphend;
4037 else if(tailmorphness>targettailmorphness){
4038 tailmorphness-=multiplier*2;
4040 else if(tailmorphness<targettailmorphness){
4041 tailmorphness+=multiplier*2;
4045 if(headmorphend==3||headmorphstart==3){
4046 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
4047 headmorphness=targetheadmorphness;
4048 headmorphstart=headmorphend;
4050 else if(headmorphness>targetheadmorphness){
4051 headmorphness-=multiplier*7;
4053 else if(headmorphness<targetheadmorphness){
4054 headmorphness+=multiplier*7;
4057 else if(headmorphend==5||headmorphstart==5){
4058 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
4059 headmorphness=targetheadmorphness;
4060 headmorphstart=headmorphend;
4062 else if(headmorphness>targetheadmorphness){
4063 headmorphness-=multiplier*10;
4065 else if(headmorphness<targetheadmorphness){
4066 headmorphness+=multiplier*10;
4070 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
4071 headmorphness=targetheadmorphness;
4072 headmorphstart=headmorphend;
4074 else if(headmorphness>targetheadmorphness){
4075 headmorphness-=multiplier*4;
4077 else if(headmorphness<targetheadmorphness){
4078 headmorphness+=multiplier*4;
4082 if(abs(chestmorphness-targetchestmorphness)<multiplier){
4083 chestmorphness=targetchestmorphness;
4084 chestmorphstart=chestmorphend;
4086 else if(chestmorphness>targetchestmorphness){
4087 chestmorphness-=multiplier;
4089 else if(chestmorphness<targetchestmorphness){
4090 chestmorphness+=multiplier;
4093 if(dead!=2&&howactive<=typesleeping){
4094 if(chestmorphstart==0&&chestmorphend==0){
4096 targetchestmorphness=1;
4099 if(chestmorphstart!=0&&chestmorphend!=0){
4101 targetchestmorphness=1;
4103 if(environment==snowyenvironment){
4106 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
4107 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
4108 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
4109 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
4110 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
4111 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
4115 if(!dead&&howactive<typesleeping){
4116 blinkdelay-=multiplier*2;
4117 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
4119 targetheadmorphness=1;
4121 blinkdelay=(float)(abs(Random()%40))/5;
4123 if(headmorphstart==3&&headmorphend==3){
4125 targetheadmorphness=1;
4130 twitchdelay-=multiplier*1.5;
4131 if(targetanimation!=hurtidleanim){
4132 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
4134 targetheadmorphness=1;
4136 twitchdelay=(float)(abs(Random()%40))/5;
4138 if(headmorphstart==5&&headmorphend==5){
4140 targetheadmorphness=1;
4144 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
4145 twitchdelay3-=multiplier*1;
4147 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
4148 righthandmorphness=0;
4149 targetrighthandmorphness=1;
4150 righthandmorphend=1;
4151 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
4153 if(righthandmorphstart==1&&righthandmorphend==1){
4154 righthandmorphness=0;
4155 targetrighthandmorphness=1;
4156 righthandmorphend=0;
4160 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
4161 lefthandmorphness=0;
4162 targetlefthandmorphness=1;
4164 twitchdelay3=(float)(abs(Random()%40))/5;
4166 if(lefthandmorphstart==1&&lefthandmorphend==1){
4167 lefthandmorphness=0;
4168 targetlefthandmorphness=1;
4175 if(creature==rabbittype){
4176 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
4177 else twitchdelay2-=multiplier*0.5;
4178 if(howactive<=typesleeping){
4179 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
4181 targettailmorphness=1;
4183 twitchdelay2=(float)(abs(Random()%40))/5;
4185 if(tailmorphstart==1&&tailmorphend==1){
4187 targettailmorphness=1;
4190 if(tailmorphstart==2&&tailmorphend==2){
4192 targettailmorphness=1;
4199 if(creature==wolftype){
4200 twitchdelay2-=multiplier*1.5;
4202 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
4204 targettailmorphness=1;
4209 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
4211 targettailmorphness=1;
4215 if(twitchdelay2<=0){
4216 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
4218 targettailmorphness=1;
4221 if(tailmorphstart==1&&tailmorphend==1){
4223 targettailmorphness=1;
4226 if(tailmorphstart==2&&tailmorphend==2){
4228 targettailmorphness=1;
4231 if(tailmorphstart==3&&tailmorphend==3){
4233 targettailmorphness=1;
4236 if(tailmorphstart==4&&tailmorphend==4){
4238 targettailmorphness=1;
4244 if(dead!=1)unconscioustime=0;
4246 if(dead==1||howactive==typesleeping){
4247 unconscioustime+=multiplier;
4248 //If unconscious, close eyes and mouth
4249 if(righthandmorphend!=0)righthandmorphness=0;
4250 righthandmorphend=0;
4251 targetrighthandmorphness=1;
4253 if(lefthandmorphend!=0)lefthandmorphness=0;
4255 targetlefthandmorphness=1;
4257 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
4259 targetheadmorphness=1;
4263 if(howactive>typesleeping){
4266 if(bloodtoggle&&!bled){
4267 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
4269 if(bloodtoggle&&!bled)
4270 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
4271 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
4272 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
4276 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
4281 if(dead==2||howactive>typesleeping){
4282 //If dead, open mouth and hands
4283 if(righthandmorphend!=0)righthandmorphness=0;
4284 righthandmorphend=0;
4285 targetrighthandmorphness=1;
4287 if(lefthandmorphend!=0)lefthandmorphness=0;
4289 targetlefthandmorphness=1;
4291 if(headmorphend!=2)headmorphness=0;
4293 targetheadmorphness=1;
4296 if(stunned>0&&!dead&&headmorphend!=2){
4297 if(headmorphend!=4)headmorphness=0;
4299 targetheadmorphness=1;
4302 if(damage>damagetolerance&&!dead){
4307 if(creature==wolftype){
4308 award_bonus(0, Wolfbonus);
4313 if(weaponactive!=-1){
4314 weapons.owner[weaponids[0]]=-1;
4315 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4316 weapons.velocity[weaponids[0]].x+=.01;
4317 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4318 weapons.missed[weaponids[0]]=1;
4319 weapons.hitsomething[weaponids[0]]=0;
4320 weapons.freetime[weaponids[0]]=0;
4321 weapons.firstfree[weaponids[0]]=1;
4322 weapons.physics[weaponids[0]]=1;
4325 weaponids[0]=weaponids[num_weapons];
4326 if(weaponstuck==num_weapons)weaponstuck=0;
4329 for(i=0;i<numplayers;i++){
4330 player[i].wentforweapon=0;
4336 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
4344 //if(dead)damage-=multiplier/4;
4345 if(!dead)damage-=multiplier*13;
4346 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
4347 if(!dead)permanentdamage-=multiplier*4;
4348 if(isIdle()||isCrouch()){
4349 if(!dead)permanentdamage-=multiplier*4;
4350 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
4352 if(damage<0)damage=0;
4353 if(permanentdamage<0)permanentdamage=0;
4354 if(superpermanentdamage<0)superpermanentdamage=0;
4355 if(permanentdamage<superpermanentdamage){
4356 permanentdamage=superpermanentdamage;
4358 if(damage<permanentdamage){
4359 damage=permanentdamage;
4361 if(dead==1&&damage<damagetolerance){
4365 for(i=0;i<skeleton.num_joints;i++){
4366 skeleton.joints[i].velocity=0;
4369 if(permanentdamage>damagetolerance&&dead!=2){
4372 if(weaponactive!=-1){
4373 weapons.owner[weaponids[0]]=-1;
4374 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4375 weapons.velocity[weaponids[0]].x+=.01;
4376 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4377 weapons.missed[weaponids[0]]=1;
4378 weapons.hitsomething[weaponids[0]]=0;
4379 weapons.freetime[weaponids[0]]=0;
4380 weapons.firstfree[weaponids[0]]=1;
4381 weapons.physics[weaponids[0]]=1;
4384 weaponids[0]=weaponids[num_weapons];
4385 if(weaponstuck==num_weapons)weaponstuck=0;
4388 for(i=0;i<numplayers;i++){
4389 player[i].wentforweapon=0;
4395 if(!dead&&creature==wolftype){
4396 award_bonus(0, Wolfbonus);
4399 if(unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance)
4400 award_bonus(id, touchofdeath);
4401 if(id!=0&&unconscioustime>.1){
4409 emit_sound_at(breaksound, coords);
4412 if(skeleton.free==1){
4413 if(id==0)pause_sound(whooshsound);
4416 //If knocked over, open hands and close mouth
4417 if(righthandmorphend!=0)righthandmorphness=0;
4418 righthandmorphend=0;
4419 targetrighthandmorphness=1;
4421 if(lefthandmorphend!=0)lefthandmorphness=0;
4423 targetlefthandmorphness=1;
4425 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
4426 if(headmorphend!=0)headmorphness=0;
4428 targetheadmorphness=1;
4432 skeleton.DoGravity(&scale);
4434 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
4435 if(damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1))
4436 award_bonus(id, deepimpact);
4437 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
4441 for(j=0;j<skeleton.num_joints;j++){
4442 average+=skeleton.joints[j].position;
4446 coords+=average*scale;
4447 for(j=0;j<skeleton.num_joints;j++){
4448 skeleton.joints[j].position-=average;
4450 average/=multiplier;
4452 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
4454 for(i=0;i<skeleton.num_joints;i++){
4455 velocity+=skeleton.joints[i].velocity*scale;
4457 velocity/=skeleton.num_joints;
4459 if(!isnormal(velocity.x)&&velocity.x){
4472 if(findLength(&average)<10&&dead&&skeleton.free){
4473 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
4474 if(skeleton.longdead>2000){
4475 if(skeleton.longdead>6000){
4476 if(id==0)pause_sound(whooshsound);
4481 if(dead==2&&bloodloss<damagetolerance){
4483 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
4485 if(bloodtoggle&&!bled){
4486 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
4488 if(bloodtoggle&&!bled)
4489 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
4490 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
4491 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
4495 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
4499 if(dead==2&&bloodloss>=damagetolerance){
4501 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
4502 if(bleeding<=0)DoBlood(1,255);
4503 if(bloodtoggle&&!bled){
4504 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
4506 if(bloodtoggle&&!bled)
4507 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
4508 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
4509 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
4513 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
4520 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
4522 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
4526 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
4527 if(velocity.y<-30)canrecover=0;
4528 for(i=0;i<objects.numobjects;i++){
4529 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
4530 colviewer=startpoint;
4532 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
4540 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4541 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
4542 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4543 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4545 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4546 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4547 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4549 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4550 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4551 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
4553 Normalise(&terrainnormal);
4555 targetrotation=-asin(0-terrainnormal.x);
4556 targetrotation*=360/6.28;
4557 if(terrainnormal.z<0)targetrotation=180-targetrotation;
4558 rotation=targetrotation;
4562 targetanimation=flipanim;
4563 crouchtogglekeydown=1;
4568 currentanimation=tempanim;
4571 //tilt2=targettilt2;
4573 //if(middle.y>0)targetoffset.y=middle.y+1;
4575 for(i=0;i<skeleton.num_joints;i++){
4576 tempanimation.position[i][0]=skeleton.joints[i].position;
4577 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
4582 if(findLength(&average)<10&&!dead&&skeleton.free){
4583 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
4584 if(skeleton.longdead>(damage+500)*1.5){
4585 if(id==0)pause_sound(whooshsound);
4591 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4592 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
4593 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4594 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4596 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4597 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4598 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4600 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4601 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4602 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
4604 Normalise(&terrainnormal);
4606 targetrotation=-asin(0-terrainnormal.x);
4607 targetrotation*=360/6.28;
4608 if(terrainnormal.z<0)targetrotation=180-targetrotation;
4609 rotation=targetrotation;
4612 terrainnormal=terrain.getNormal(coords.x,coords.z);
4613 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
4617 /*XYZ otherterrainnormal;
4618 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
4619 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
4620 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
4621 targettilt2=asin(otherterrainnormal.y)*180/3.14;
4624 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
4628 if(skeleton.forward.y<0){
4629 targetanimation=getupfrombackanim;
4633 if(skeleton.forward.y>-.3){
4634 targetanimation=getupfromfrontanim;
4636 targetrotation+=180;
4642 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
4643 targetanimation=rollanim;
4644 targetrotation=lookrotation;
4648 if(forwardkeydown)targetrotation+=45;
4649 if(backkeydown)targetrotation-=45;
4653 if(forwardkeydown)targetrotation-=45;
4654 if(backkeydown)targetrotation+=45;
4657 if ( !leftkeydown&&!rightkeydown)
4658 targetrotation+=180;
4660 targetrotation+=180;
4664 if(abs(targettilt2)>50)targettilt2=0;
4665 currentanimation=tempanim;
4670 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
4672 for(i=0;i<skeleton.num_joints;i++){
4673 tempanimation.position[i][0]=skeleton.joints[i].position;
4674 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
4681 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4682 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
4685 tempvelocity=velocity;
4686 Normalise(&tempvelocity);
4687 targetrotation=-asin(0-tempvelocity.x);
4688 targetrotation*=360/6.28;
4689 if(velocity.z<0)targetrotation=180-targetrotation;
4690 //targetrotation+=180;
4693 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
4694 targetanimation=rollanim;
4698 targetanimation=backhandspringanim;
4699 targetrotation+=180;
4704 emit_sound_at(movewhooshsound, coords, 128.);
4706 currentanimation=targetanimation;
4707 currentframe=targetframe-1;
4712 rotation=targetrotation;
4719 if(skeleton.freefall==0)freefall=0;
4721 if(!isnormal(velocity.x)&&velocity.x){
4726 if(aitype!=passivetype||skeleton.free==1)
4727 if(findLengthfast(&velocity)>.1)
4728 for(i=0;i<objects.numobjects;i++){
4729 if(objects.type[i]==firetype)
4730 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){
4732 if(!objects.onfire[i]){
4733 emit_sound_at(firestartsound, objects.position[i]);
4735 objects.onfire[i]=1;
4738 if(objects.onfire[i]){
4743 if(objects.type[i]==bushtype)
4744 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){
4746 if(!objects.onfire[i]){
4747 emit_sound_at(firestartsound, objects.position[i]);
4749 objects.onfire[i]=1;
4753 if(objects.onfire[i]){
4757 if(objects.messedwith[i]<=0){
4761 emit_sound_at(bushrustle, coords, 40*findLength(&velocity));
4764 envsound[numenvsounds]=coords;
4765 envsoundvol[numenvsounds]=4*findLength(&velocity);
4766 envsoundlife[numenvsounds]=.4;
4771 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
4772 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
4774 if(environment!=desertenvironment)
4775 for(j=0;j<howmany;j++){
4776 tempvel.x=float(abs(Random()%100)-50)/20;
4777 tempvel.y=float(abs(Random()%100)-50)/20;
4778 tempvel.z=float(abs(Random()%100)-50)/20;
4781 pos.x+=float(abs(Random()%100)-50)/200;
4782 pos.y+=float(abs(Random()%100)-50)/200;
4783 pos.z+=float(abs(Random()%100)-50)/200;
4784 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);
4785 Sprite::setLastSpriteSpecial(1);
4787 howmany=findLength(&velocity)*4;
4789 if(environment==snowyenvironment)
4790 for(j=0;j<howmany;j++){
4791 tempvel.x=float(abs(Random()%100)-50)/20;
4792 tempvel.y=float(abs(Random()%100)-50)/20;
4793 tempvel.z=float(abs(Random()%100)-50)/20;
4796 pos.x+=float(abs(Random()%100)-50)/200;
4797 pos.y+=float(abs(Random()%100)-50)/200;
4798 pos.z+=float(abs(Random()%100)-50)/200;
4799 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
4800 Sprite::setLastSpriteSpecial(2);
4803 objects.rotx[i]+=velocity.x*multiplier*6;
4804 objects.roty[i]+=velocity.z*multiplier*6;
4805 objects.messedwith[i]=.5;
4808 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
4809 if(objects.rotation2[i]==0)tempcoord=coords;
4811 tempcoord=coords-objects.position[i];
4812 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
4813 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
4814 tempcoord+=objects.position[i];
4816 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]){
4817 if(objects.messedwith[i]<=0){
4821 emit_sound_at(bushrustle, coords, 40*findLength(&velocity));
4824 envsound[numenvsounds]=coords;
4825 envsoundvol[numenvsounds]=4*findLength(&velocity);
4826 envsoundlife[numenvsounds]=.4;
4831 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
4832 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
4834 if(environment!=desertenvironment)
4835 for(j=0;j<howmany;j++){
4836 tempvel.x=float(abs(Random()%100)-50)/20;
4837 tempvel.y=float(abs(Random()%100)-50)/20;
4838 tempvel.z=float(abs(Random()%100)-50)/20;
4842 pos.x+=float(abs(Random()%100)-50)/150;
4843 pos.y+=float(abs(Random()%100)-50)/150;
4844 pos.z+=float(abs(Random()%100)-50)/150;
4845 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);
4846 Sprite::setLastSpriteSpecial(1);
4848 howmany=findLength(&velocity)*4;
4850 if(environment==snowyenvironment)
4851 for(j=0;j<howmany;j++){
4852 tempvel.x=float(abs(Random()%100)-50)/20;
4853 tempvel.y=float(abs(Random()%100)-50)/20;
4854 tempvel.z=float(abs(Random()%100)-50)/20;
4858 pos.x+=float(abs(Random()%100)-50)/150;
4859 pos.y+=float(abs(Random()%100)-50)/150;
4860 pos.z+=float(abs(Random()%100)-50)/150;
4861 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
4862 Sprite::setLastSpriteSpecial(2);
4865 objects.messedwith[i]=.5;
4873 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
4875 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
4876 if(tutoriallevel==1&&id!=0)play=0;
4877 if(play&&aitype!=playercontrolled){
4881 if(creature==rabbittype){
4882 if(i==0)whichsound=rabbitchitter;
4883 if(i==1)whichsound=rabbitchitter2;
4885 if(creature==wolftype){
4886 if(i==0)whichsound=growlsound;
4887 if(i==1)whichsound=growl2sound;
4893 emit_sound_at(whichsound, coords);
4897 if(targetanimation==staggerbackhighanim)staggerdelay=1;
4898 if(targetanimation==staggerbackhardanim)staggerdelay=1;
4899 staggerdelay-=multiplier;
4900 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
4901 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
4902 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
4903 targetanimation=getIdle();
4907 weaponmissdelay-=multiplier;
4908 highreversaldelay-=multiplier;
4909 lowreversaldelay-=multiplier;
4910 lastcollide-=multiplier;
4911 skiddelay-=multiplier;
4912 if(!isnormal(velocity.x)&&velocity.x){
4915 if(!isnormal(targettilt)&&targettilt){
4918 if(!isnormal(targettilt2)&&targettilt2){
4921 if(!isnormal(targetrotation)&&targetrotation){
4925 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
4926 //open hands and close mouth
4927 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
4928 righthandmorphness=0;
4929 righthandmorphend=0;
4930 targetrighthandmorphness=1;
4933 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
4934 lefthandmorphness=0;
4936 targetlefthandmorphness=1;
4939 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
4942 targetheadmorphness=1;
4946 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){
4947 //open hands and mouth
4948 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
4949 righthandmorphness=0;
4950 righthandmorphend=0;
4951 targetrighthandmorphness=1;
4954 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
4955 lefthandmorphness=0;
4957 targetlefthandmorphness=1;
4960 if(headmorphend!=1&&headmorphness==targetheadmorphness){
4963 targetheadmorphness=1;
4967 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
4968 //close hands and mouth
4969 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
4970 righthandmorphness=0;
4971 righthandmorphend=1;
4972 targetrighthandmorphness=1;
4975 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
4976 lefthandmorphness=0;
4978 targetlefthandmorphness=1;
4981 if(headmorphend!=0&&headmorphness==targetheadmorphness){
4984 targetheadmorphness=1;
4988 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){
4989 //close hands and yell
4990 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
4991 righthandmorphness=0;
4992 righthandmorphend=1;
4993 targetrighthandmorphness=1;
4996 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
4997 lefthandmorphness=0;
4999 targetlefthandmorphness=1;
5002 if(headmorphend!=2&&headmorphness==targetheadmorphness){
5005 targetheadmorphness=1;
5009 if(speechdelay>.25){
5010 if(headmorphend!=2)headmorphness=0;
5012 targetheadmorphness=1;
5018 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
5019 behind=(normaldotproduct(facing,coords-victim->coords)>0);
5023 if(!dead&&targetanimation!=hurtidleanim)
5024 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
5025 if(headmorphend!=4||headmorphness==targetheadmorphness){
5028 targetheadmorphness=1;
5032 if(weaponactive!=-1){
5033 if(weapons.type[weaponids[weaponactive]]!=staff){
5034 righthandmorphstart=1;
5035 righthandmorphend=1;
5037 if(weapons.type[weaponids[weaponactive]]==staff){
5038 righthandmorphstart=2;
5039 righthandmorphend=2;
5041 targetrighthandmorphness=1;
5044 terrainnormal=terrain.getNormal(coords.x,coords.z);
5046 if(animation[targetanimation].attack!=reversal){
5047 if(!isnormal(coords.x))
5055 flatfacing=DoRotation(flatfacing,0,rotation,0);
5057 ReflectVector(&facing,terrainnormal);
5060 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
5061 if(onterrain)targettilt2=-facing.y*20;
5065 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
5066 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5067 flatvelocity=velocity;
5069 flatvelspeed=findLength(&flatvelocity);
5070 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
5071 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
5072 if(velocity.y<0)targettilt2*=-1;
5073 if(velocity.y<0)targettilt*=-1;
5074 if(targettilt>25)targettilt=25;
5075 if(targettilt<-25)targettilt=-25;
5078 if(targettilt2>45)targettilt2=45;
5079 if(targettilt2<-45)targettilt2=-45;
5080 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
5081 else if(tilt2>targettilt2){
5082 tilt2-=multiplier*400;
5084 else if(tilt2<targettilt2){
5085 tilt2+=multiplier*400;
5087 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
5088 if(tilt2>25)tilt2=25;
5089 if(tilt2<-25)tilt2=-25;
5092 if(!isnormal(targettilt)&&targettilt){
5095 if(!isnormal(targettilt2)&&targettilt2){
5100 //if(!creature==wolftype||targetanimation==rabbitkickanim)
5101 if(targetanimation==rabbittackleanim){
5102 velocity+=facing*multiplier*speed*700*scale;
5103 velspeed=findLength(&velocity);
5104 if(velspeed>speed*65*scale){
5106 velspeed=speed*65*scale;
5109 velocity.y+=gravity*multiplier*20;
5110 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5111 velspeed=findLength(&velocity);
5112 velocity=flatfacing*velspeed;
5114 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
5115 if(isRun()||targetanimation==rabbitkickanim){
5116 velocity+=facing*multiplier*speed*700*scale;
5117 velspeed=findLength(&velocity);
5118 if(velspeed>speed*45*scale){
5120 velspeed=speed*45*scale;
5123 velocity.y+=gravity*multiplier*20;
5124 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5125 velspeed=findLength(&velocity);
5126 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
5127 velocity=flatfacing*velspeed;
5131 velocity+=facing*multiplier*speed*700*scale;
5132 velspeed=findLength(&velocity);
5133 if(creature==rabbittype){
5134 if(velspeed>speed*55*scale){
5136 velspeed=speed*55*scale;
5140 if(creature==wolftype){
5141 if(velspeed>speed*75*scale){
5143 velspeed=speed*75*scale;
5147 velocity.y+=gravity*multiplier*20;
5148 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5149 velspeed=findLength(&velocity);
5150 velocity=flatfacing*velspeed;
5153 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
5154 velocity+=facing*multiplier*speed*700*scale;
5155 velspeed=findLength(&velocity);
5156 if(velspeed>speed*45*scale){
5158 velspeed=speed*45*scale;
5161 velocity.y+=gravity*multiplier*20;
5162 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5163 velspeed=findLength(&velocity);
5164 velocity=flatfacing*velspeed;
5168 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
5169 velocity+=facing*multiplier*speed*700*scale;
5170 velspeed=findLength(&velocity);
5171 if(velspeed>speed*25*scale){
5173 velspeed=speed*25*scale;
5176 velocity.y+=gravity*multiplier*20;
5177 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5178 velspeed=findLength(&velocity);
5179 velocity=flatfacing*velspeed;
5182 if(targetanimation==sneakanim||targetanimation==walkanim){
5183 velocity+=facing*multiplier*speed*700*scale;
5184 velspeed=findLength(&velocity);
5185 if(velspeed>speed*12*scale){
5187 velspeed=speed*12*scale;
5190 velocity.y+=gravity*multiplier*20;
5191 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5192 velspeed=findLength(&velocity);
5193 velocity=flatfacing*velspeed;
5196 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
5197 velocity+=facing*multiplier*speed*700*scale;
5198 velspeed=findLength(&velocity);
5199 if(velspeed>speed*2*scale){
5201 velspeed=speed*2*scale;
5204 velocity.y+=gravity*multiplier*20;
5205 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5206 velspeed=findLength(&velocity);
5207 velocity=flatfacing*velspeed;
5211 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
5212 velocity-=facing*multiplier*speed*700*scale;
5213 velspeed=findLength(&velocity);
5214 if(velspeed>speed*2*scale){
5216 velspeed=speed*2*scale;
5219 velocity.y+=gravity*multiplier*20;
5220 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5221 velspeed=findLength(&velocity);
5222 velocity=flatfacing*velspeed*-1;
5225 if(targetanimation==fightsidestep){
5226 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
5227 velspeed=findLength(&velocity);
5228 if(velspeed>speed*12*scale){
5230 velspeed=speed*12*scale;
5233 velocity.y+=gravity*multiplier*20;
5234 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5235 velspeed=findLength(&velocity);
5236 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
5239 if(targetanimation==staggerbackhighanim){
5240 coords-=facing*multiplier*speed*16*scale;
5243 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
5244 coords-=facing*multiplier*speed*20*scale;
5248 if(targetanimation==backhandspringanim){
5249 //coords-=facing*multiplier*50*scale;
5250 velocity+=facing*multiplier*speed*700*scale*-1;
5251 velspeed=findLength(&velocity);
5252 if(velspeed>speed*50*scale){
5254 velspeed=speed*50*scale;
5257 velocity.y+=gravity*multiplier*20;
5258 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5259 velspeed=findLength(&velocity);
5260 velocity=flatfacing*velspeed*-1;
5262 if(targetanimation==dodgebackanim){
5263 //coords-=facing*multiplier*50*scale;
5264 velocity+=facing*multiplier*speed*700*scale*-1;
5265 velspeed=findLength(&velocity);
5266 if(velspeed>speed*60*scale){
5268 velspeed=speed*60*scale;
5271 velocity.y+=gravity*multiplier*20;
5272 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5273 velspeed=findLength(&velocity);
5274 velocity=flatfacing*velspeed*-1;
5277 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5278 velspeed=findLength(&velocity);
5282 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5283 velocity.y+=gravity*multiplier;
5286 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
5288 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
5289 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
5291 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
5297 pause_sound(whooshsound);
5298 OPENAL_SetVolume(channels[whooshsound], 0);
5301 if(targetanimation==jumpdownanim||isFlip()){
5302 if(isFlip())jumppower=-4;
5303 targetanimation=getLanding();
5304 emit_sound_at(landsound, coords, 128.);
5307 envsound[numenvsounds]=coords;
5308 envsoundvol[numenvsounds]=16;
5309 envsoundlife[numenvsounds]=.4;
5315 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
5316 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
5317 coords.y=terrain.getHeight(coords.x,coords.z);
5322 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)){
5323 velspeed=findLength(&velocity);
5325 if(velspeed<multiplier*300*scale){
5327 } else velocity-=velocity/velspeed*multiplier*300*scale;
5328 if(velspeed>5&&(isLanding()||isLandhard())){
5329 skiddingdelay+=multiplier;
5336 else skiddingdelay=0;
5340 velspeed=findLength(&velocity);
5342 if(velspeed<multiplier*600*scale){
5344 } else velocity-=velocity/velspeed*multiplier*600*scale;
5346 if(velspeed>5&&(isLanding()||isLandhard())){
5347 skiddingdelay+=multiplier;
5354 else skiddingdelay=0;
5357 if(skiddingdelay<0)skiddingdelay+=multiplier;
5358 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
5360 if(!onterrain||environment==grassyenvironment){
5361 emit_sound_at(skidsound, coords, 128*velspeed/10);
5364 emit_sound_at(snowskidsound, coords, 128*velspeed/10);
5368 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
5369 terrainnormal=victim->coords-coords;
5370 Normalise(&terrainnormal);
5371 targetrotation=-asin(0-terrainnormal.x);
5372 targetrotation*=360/6.28;
5373 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5374 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
5377 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
5378 targetrotation=victim->targetrotation;
5380 if(targetanimation==rabbittacklinganim){
5381 coords=victim->coords;
5384 skeleton.oldfree=skeleton.free;
5388 midterrain.x=terrain.size*terrain.scale/2;
5389 midterrain.z=terrain.size*terrain.scale/2;
5390 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
5392 tempposit=coords-midterrain;
5394 Normalise(&tempposit);
5395 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
5396 coords.x=tempposit.x+midterrain.x;
5397 coords.z=tempposit.z+midterrain.z;
5401 int Person::DrawSkeleton(){
5402 int oldplayerdetail;
5403 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
5404 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
5414 glAlphaFunc(GL_GREATER, 0.0001);
5416 float terrainheight;
5418 if(!isnormal(rotation))rotation=0;
5419 if(!isnormal(tilt))tilt=0;
5420 if(!isnormal(tilt2))tilt2=0;
5421 oldplayerdetail=playerdetail;
5423 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
5426 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
5429 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
5434 if(playerdetail!=oldplayerdetail) {
5436 normalsupdatedelay=0;
5438 static float updatedelaychange;
5439 static float morphness;
5440 static float framemult;
5442 skeleton.FindForwards();
5443 if(howactive==typesittingwall){
5444 skeleton.specialforward[1]=0;
5445 skeleton.specialforward[1].z=1;
5451 static int weaponattachmuscle;
5452 static int weaponrotatemuscle,weaponrotatemuscle2;
5453 static XYZ weaponpoint;
5454 static int start,endthing;
5455 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
5456 if(!isSleeping()&&!isSitting()){
5457 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
5458 XYZ point,newpoint,change,change2;
5459 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5460 heightleft=terrain.getHeight(point.x,point.z)+.04;
5462 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5463 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5464 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5465 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5466 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5468 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5469 heightright=terrain.getHeight(point.x,point.z)+.04;
5470 point.y=heightright;
5471 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5472 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5473 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5474 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5475 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5476 skeleton.DoConstraints(&coords,&scale);
5478 if(creature==wolftype){
5479 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5480 heightleft=terrain.getHeight(point.x,point.z)+.04;
5482 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5483 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5484 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5485 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5486 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5488 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5489 heightright=terrain.getHeight(point.x,point.z)+.04;
5490 point.y=heightright;
5491 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5492 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5493 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5494 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5495 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5496 skeleton.DoConstraints(&coords,&scale);
5499 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
5500 XYZ point,newpoint,change,change2;
5501 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5502 heightleft=terrain.getHeight(point.x,point.z)+.04;
5504 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5505 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5506 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
5507 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5508 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5510 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5511 heightright=terrain.getHeight(point.x,point.z)+.04;
5512 point.y=heightright;
5513 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5514 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5515 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
5516 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5517 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5518 skeleton.DoConstraints(&coords,&scale);
5520 if(creature==wolftype){
5521 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5522 heightleft=terrain.getHeight(point.x,point.z)+.04;
5524 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5525 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5526 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
5527 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5528 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5530 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5531 heightright=terrain.getHeight(point.x,point.z)+.04;
5532 point.y=heightright;
5533 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5534 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5535 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
5536 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5537 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5538 skeleton.DoConstraints(&coords,&scale);
5542 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
5543 XYZ point,newpoint,change,change2;
5544 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5545 heightleft=terrain.getHeight(point.x,point.z)+.04;
5547 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5548 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5549 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
5550 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5551 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5553 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5554 heightright=terrain.getHeight(point.x,point.z)+.04;
5555 point.y=heightright;
5556 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5557 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5558 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
5559 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5560 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5561 skeleton.DoConstraints(&coords,&scale);
5563 if(creature==wolftype){
5564 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5565 heightleft=terrain.getHeight(point.x,point.z)+.04;
5567 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5568 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5569 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
5570 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5571 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5573 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5574 heightright=terrain.getHeight(point.x,point.z)+.04;
5575 point.y=heightright;
5576 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5577 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5578 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
5579 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5580 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5581 skeleton.DoConstraints(&coords,&scale);
5585 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()))
5588 targetheadrotation=-targetrotation;
5589 targetheadrotation2=0;
5590 if(animation[targetanimation].attack==3)targetheadrotation+=180;
5592 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
5593 skeleton.drawmodel.vertex[i]=0;
5594 skeleton.drawmodel.vertex[i].y=999;
5596 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
5597 skeleton.drawmodellow.vertex[i]=0;
5598 skeleton.drawmodellow.vertex[i].y=999;
5600 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
5601 skeleton.drawmodelclothes.vertex[i]=0;
5602 skeleton.drawmodelclothes.vertex[i].y=999;
5604 for(i=0;i<skeleton.num_muscles;i++){
5605 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
5609 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
5610 morphness=righthandmorphness;
5611 start=righthandmorphstart;
5612 endthing=righthandmorphend;
5614 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
5615 morphness=lefthandmorphness;
5616 start=lefthandmorphstart;
5617 endthing=lefthandmorphend;
5619 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
5620 morphness=headmorphness;
5621 start=headmorphstart;
5622 endthing=headmorphend;
5624 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)){
5625 morphness=chestmorphness;
5626 start=chestmorphstart;
5627 endthing=chestmorphend;
5629 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)){
5630 morphness=tailmorphness;
5631 start=tailmorphstart;
5632 endthing=tailmorphend;
5634 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
5635 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
5636 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5639 if(!skeleton.free)glRotatef(tilt2,1,0,0);
5640 if(!skeleton.free)glRotatef(tilt,0,0,1);
5643 glTranslatef(mid.x,mid.y,mid.z);
5645 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
5646 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
5648 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
5649 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
5651 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
5652 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
5654 if(playerdetail||skeleton.free==3)
5656 for(j=0;j<skeleton.muscles[i].numvertices;j++)
5658 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5660 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
5661 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,
5662 (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,
5663 (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);
5664 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)
5665 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,
5666 (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,
5667 (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);
5668 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)
5669 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,
5670 (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,
5671 (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);
5672 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
5673 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,
5674 (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,
5675 (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);
5676 glGetFloatv(GL_MODELVIEW_MATRIX,M);
5677 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
5678 //if(!isnormal(scale))test=1;
5679 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
5680 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
5681 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
5686 if(!playerdetail||skeleton.free==3)
5688 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
5690 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5692 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
5693 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
5694 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
5695 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
5696 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)
5697 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
5698 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
5699 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
5700 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)
5701 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
5702 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
5703 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
5704 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
5705 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
5706 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
5707 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
5709 glGetFloatv(GL_MODELVIEW_MATRIX,M);
5710 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
5711 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
5712 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
5718 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
5719 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
5721 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5724 if(!skeleton.free)glRotatef(tilt2,1,0,0);
5725 if(!skeleton.free)glRotatef(tilt,0,0,1);
5726 glTranslatef(mid.x,mid.y,mid.z);
5727 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
5728 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
5730 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
5731 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
5733 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
5734 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
5736 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
5737 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5739 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
5740 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
5741 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
5742 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
5743 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)
5744 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
5745 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
5746 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
5747 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)
5748 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
5749 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
5750 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
5751 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
5752 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
5753 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
5754 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
5755 glGetFloatv(GL_MODELVIEW_MATRIX,M);
5756 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
5757 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
5758 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
5763 updatedelay=1+(float)(Random()%100)/1000;
5765 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
5766 normalsupdatedelay=1;
5767 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
5768 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
5769 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
5773 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
5774 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
5775 if(skeleton.clothes){
5776 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
5781 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
5782 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
5783 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
5784 if(skeleton.free==1)updatedelaychange*=6;
5785 if(id==0)updatedelaychange*=8;
5786 updatedelay+=updatedelaychange;
5788 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5790 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
5791 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
5792 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
5793 if(!skeleton.free)glRotatef(rotation,0,1,0);
5796 glColor4f(.4,1,.4,1);
5797 glDisable(GL_LIGHTING);
5798 glDisable(GL_TEXTURE_2D);
5801 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
5802 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
5808 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
5809 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);
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[1]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].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[2]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].z);
5814 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);
5820 terrainlight=terrain.getLighting(coords.x,coords.z);
5821 distance=findDistancefast(&viewer,&coords);
5822 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
5823 if(distance>1)distance=1;
5825 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
5826 if(terrainheight<1)terrainheight=1;
5827 if(terrainheight>1.7)terrainheight=1.7;
5830 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
5831 glDisable(GL_BLEND);
5832 glAlphaFunc(GL_GREATER, 0.0001);
5833 glEnable(GL_TEXTURE_2D);
5835 glDisable(GL_TEXTURE_2D);
5836 glColor4f(.7,.35,0,.5);
5838 glEnable(GL_LIGHTING);
5841 if(tutoriallevel&&id!=0){
5842 //glDisable(GL_TEXTURE_2D);
5843 glColor4f(.7,.7,.7,0.6);
5845 glEnable(GL_LIGHTING);
5847 if(canattack&&cananger)
5848 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
5849 glDisable(GL_TEXTURE_2D);
5850 glColor4f(1,0,0,0.8);
5852 glMatrixMode(GL_TEXTURE);
5854 glTranslatef(0,-smoketex,0);
5855 glTranslatef(-smoketex,0,0);
5859 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
5860 else skeleton.drawmodel.draw();
5864 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
5865 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
5868 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
5869 if(tutoriallevel&&id!=0){
5871 glMatrixMode(GL_MODELVIEW);
5872 glEnable(GL_TEXTURE_2D);
5873 glColor4f(.7,.7,.7,0.6);
5875 glEnable(GL_LIGHTING);
5877 if(canattack&&cananger)
5878 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
5879 glDisable(GL_TEXTURE_2D);
5880 glColor4f(1,0,0,0.8);
5882 glMatrixMode(GL_TEXTURE);
5884 glTranslatef(0,-smoketex*.6,0);
5885 glTranslatef(smoketex*.6,0,0);
5888 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
5889 else skeleton.drawmodel.draw();
5893 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
5894 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
5899 if(tutoriallevel&&id!=0){
5901 glMatrixMode(GL_MODELVIEW);
5902 glEnable(GL_TEXTURE_2D);
5904 if(skeleton.clothes){
5907 if(!immediate)skeleton.drawmodelclothes.draw();
5908 if(immediate)skeleton.drawmodelclothes.drawimmediate();
5915 for(k=0;k<num_weapons;k++){
5917 if(weaponactive==k){
5918 if(weapons.type[i]!=staff){
5919 for(j=0;j<skeleton.num_muscles;j++){
5920 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
5921 weaponattachmuscle=j;
5924 for(j=0;j<skeleton.num_muscles;j++){
5925 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){
5926 weaponrotatemuscle=j;
5929 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
5930 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
5932 if(weapons.type[i]==staff){
5933 for(j=0;j<skeleton.num_muscles;j++){
5934 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
5935 weaponattachmuscle=j;
5938 for(j=0;j<skeleton.num_muscles;j++){
5939 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){
5940 weaponrotatemuscle=j;
5943 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
5944 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
5945 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
5946 XYZ tempnormthing,vec1,vec2;
5947 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
5948 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
5949 CrossProduct(&vec1,&vec2,&tempnormthing);
5950 Normalise(&tempnormthing);
5951 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);
5954 if(weaponactive!=k&&weaponstuck!=k){
5955 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;
5956 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;
5957 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;
5958 for(j=0;j<skeleton.num_muscles;j++){
5959 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){
5960 weaponrotatemuscle=j;
5965 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
5966 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
5967 for(j=0;j<skeleton.num_muscles;j++){
5968 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){
5969 weaponrotatemuscle=j;
5974 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;
5975 weapons.bigrotation[i]=rotation;
5976 weapons.bigtilt[i]=tilt;
5977 weapons.bigtilt2[i]=tilt2;
5980 weapons.position[i]=weaponpoint*scale+coords;
5981 weapons.bigrotation[i]=0;
5982 weapons.bigtilt[i]=0;
5983 weapons.bigtilt2[i]=0;
5985 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
5986 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
5987 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
5988 if(weaponactive==k){
5989 if(weapons.type[i]==knife){
5990 weapons.smallrotation[i]=180;
5991 weapons.smallrotation2[i]=0;
5992 if(isCrouch()||wasCrouch()){
5993 weapons.smallrotation2[i]=20;
5995 if(targetanimation==hurtidleanim){
5996 weapons.smallrotation2[i]=50;
5998 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
5999 XYZ temppoint1,temppoint2,tempforward;
6002 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
6003 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6004 distance=findDistance(&temppoint1,&temppoint2);
6005 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6006 weapons.rotation2[i]*=360/6.28;
6009 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6010 weapons.rotation1[i]*=360/6.28;
6011 weapons.rotation3[i]=0;
6012 weapons.smallrotation[i]=-90;
6013 weapons.smallrotation2[i]=0;
6014 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6016 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
6017 XYZ temppoint1,temppoint2,tempforward;
6020 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
6021 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6022 distance=findDistance(&temppoint1,&temppoint2);
6023 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6024 weapons.rotation2[i]*=360/6.28;
6027 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6028 weapons.rotation1[i]*=360/6.28;
6029 weapons.rotation3[i]=0;
6030 weapons.smallrotation[i]=90;
6031 weapons.smallrotation2[i]=0;
6032 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6034 if(targetanimation==knifethrowanim){
6035 weapons.smallrotation[i]=90;
6036 //weapons.smallrotation2[i]=-90;
6037 weapons.smallrotation2[i]=0;
6038 weapons.rotation1[i]=0;
6039 weapons.rotation2[i]=0;
6040 weapons.rotation3[i]=0;
6042 if(targetanimation==knifesneakattackanim&&targetframe<5){
6043 weapons.smallrotation[i]=-90;
6044 weapons.rotation1[i]=0;
6045 weapons.rotation2[i]=0;
6046 weapons.rotation3[i]=0;
6049 if(weapons.type[i]==sword){
6050 weapons.smallrotation[i]=0;
6051 weapons.smallrotation2[i]=0;
6052 if(targetanimation==knifethrowanim){
6053 weapons.smallrotation[i]=-90;
6054 weapons.smallrotation2[i]=0;
6055 weapons.rotation1[i]=0;
6056 weapons.rotation2[i]=0;
6057 weapons.rotation3[i]=0;
6059 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)){
6060 XYZ temppoint1,temppoint2,tempforward;
6063 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
6064 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6065 distance=findDistance(&temppoint1,&temppoint2);
6066 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6067 weapons.rotation2[i]*=360/6.28;
6070 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6071 weapons.rotation1[i]*=360/6.28;
6072 weapons.rotation3[i]=0;
6073 weapons.smallrotation[i]=90;
6074 weapons.smallrotation2[i]=0;
6075 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6078 if(weapons.type[i]==staff){
6079 weapons.smallrotation[i]=100;
6080 weapons.smallrotation2[i]=0;
6081 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
6082 XYZ temppoint1,temppoint2,tempforward;
6085 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
6086 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6087 distance=findDistance(&temppoint1,&temppoint2);
6088 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6089 weapons.rotation2[i]*=360/6.28;
6092 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6093 weapons.rotation1[i]*=360/6.28;
6094 weapons.rotation3[i]=0;
6095 weapons.smallrotation[i]=90;
6096 weapons.smallrotation2[i]=0;
6097 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6101 if(weaponactive!=k&&weaponstuck!=k){
6102 if(weapons.type[i]==knife){
6103 weapons.smallrotation[i]=-70;
6104 weapons.smallrotation2[i]=10;
6106 if(weapons.type[i]==sword){
6107 weapons.smallrotation[i]=-100;
6108 weapons.smallrotation2[i]=-8;
6110 if(weapons.type[i]==staff){
6111 weapons.smallrotation[i]=-100;
6112 weapons.smallrotation2[i]=-8;
6116 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
6117 else weapons.smallrotation[i]=0;
6118 weapons.smallrotation2[i]=10;
6125 if(skeleton.free)calcrot=1;
6126 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
6127 if(currentanimation!=targetanimation)calcrot=1;
6128 //if(id==0)calcrot=1;
6129 if(skeleton.free==2)calcrot=0;
6135 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
6138 static float distance;
6139 static float olddistance;
6140 static int intersecting;
6141 static int firstintersecting;
6144 static XYZ start,end;
6145 static float slopethreshold=-.4;
6147 firstintersecting=-1;
6151 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
6152 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
6154 for (j=0;j<model->TriangleNum;j++){
6155 if(model->facenormals[j].y<=slopethreshold){
6157 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)));
6158 if(distance<radius){
6159 point=*p1-model->facenormals[j]*distance;
6160 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;
6161 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
6162 &model->vertex[model->Triangles[j].vertex[1]],
6164 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
6165 &model->vertex[model->Triangles[j].vertex[2]],
6167 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
6168 &model->vertex[model->Triangles[j].vertex[2]],
6171 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
6175 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)){
6176 p1->y=point.y+radius;
6177 if((targetanimation==jumpdownanim||isFlip())){
6178 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
6180 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6186 pause_sound(whooshsound);
6187 OPENAL_SetVolume(channels[whooshsound], 0);
6190 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
6191 if(isFlip())jumppower=-4;
6192 targetanimation=getLanding();
6193 emit_sound_at(landsound, coords, 128.);
6196 envsound[numenvsounds]=coords;
6197 envsoundvol[numenvsounds]=16;
6198 envsoundlife[numenvsounds]=.4;
6206 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
6209 for (j=0;j<model->TriangleNum;j++){
6210 if(model->facenormals[j].y>slopethreshold){
6214 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)));
6215 if(distance<radius*.5){
6216 point=start-model->facenormals[j]*distance;
6217 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;
6218 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,
6219 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
6220 p1->x, p1->y, p1->z, radius/2);
6221 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,
6222 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
6223 p1->x, p1->y, p1->z, radius/2);
6224 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,
6225 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
6226 p1->x, p1->y, p1->z, radius/2);
6228 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
6229 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6231 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
6232 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
6234 *p1+=model->facenormals[j]*(distance-radius*.5);
6237 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
6241 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
6243 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
6245 return firstintersecting;