2 Copyright (C) 2003, 2010 - Wolfire Games
4 This file is part of Lugaru.
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 /**> HEADER FILES <**/
24 #include "openal_wrapper.h"
25 #include "Animation.h"
30 extern float multiplier;
31 extern Terrain terrain;
33 extern int environment;
35 extern FRUSTUM frustum;
37 extern float realmultiplier;
39 extern float slomodelay;
40 extern bool cellophane;
41 extern float texdetail;
42 extern float realtexdetail;
43 extern GLubyte bloodText[512*512*3];
44 extern GLubyte wolfbloodText[512*512*3];
45 extern int bloodtoggle;
46 extern Objects objects;
48 extern bool autoslomo;
49 extern float camerashake;
51 extern float terraindetail;
52 extern float viewdistance;
53 extern float blackout;
54 extern int difficulty;
56 extern float fadestart;
58 extern bool winfreeze;
59 extern float flashamount,flashr,flashg,flashb;
60 extern int flashdelay;
61 extern bool showpoints;
62 extern bool immediate;
64 extern bool tilt2weird;
65 extern bool tiltweird;
67 extern bool proportionweird;
68 extern bool vertexweird[6];
69 extern XYZ envsound[30];
70 extern float envsoundvol[30];
71 extern float envsoundlife[30];
72 extern int numenvsounds;
73 extern int tutoriallevel;
74 extern float smoketex;
75 extern int tutorialstage;
76 extern bool reversaltrain;
77 extern bool canattack;
79 extern float damagedealt;
81 extern float hostiletime;
83 extern int indialogue;
85 extern bool gamestarted;
87 Person player[maxplayers];
89 void Person::CheckKick()
92 && (targetanimation == rabbitkickanim
96 && currentanimation == rabbitkickanim)
97 && (findDistancefast(&coords,&victim->coords) < 1.2)
98 && (!victim->skeleton.free)))
101 if (animation[victim->targetanimation].height!=lowheight)
103 float damagemult = (creature == wolftype ? 2.5 : 1.) * power * power;
104 XYZ relative = velocity;
106 Normalise(&relative);
111 emit_sound_at(heavyimpactsound, victim->coords);
113 for(int i=0;i<victim->skeleton.num_joints;i++){
114 victim->skeleton.joints[i].velocity+=relative*120*damagemult;
117 victim->DoDamage(100*damagemult/victim->protectionhigh);
118 if(id==0)camerashake+=.4;
122 targetanimation=backflipanim;
128 resume_stream(whooshsound);
130 award_bonus(id, cannon);
132 else if (victim->isCrouch())
134 targetanimation=rabbitkickreversedanim;
135 currentanimation=rabbitkickreversedanim;
136 victim->currentanimation=rabbitkickreversalanim;
137 victim->targetanimation=rabbitkickreversalanim;
143 victim->oldcoords=victim->coords;
144 coords=victim->coords;
145 victim->targetrotation=targetrotation;
150 void Person::CatchFire(){
151 XYZ flatfacing,flatvelocity;
153 for(int i=0;i<10;i++){
154 howmany=abs(Random()%(skeleton.num_joints));
155 if(!skeleton.free)flatvelocity=velocity;
156 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity;
157 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
158 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
159 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, 2, 1);
164 emit_sound_at(firestartsound, coords);
166 emit_stream_at(stream_firesound, coords);
173 int Person::getIdle(){
174 if(indialogue!=-1&&howactive==typeactive&&creature==rabbittype)return talkidleanim;
175 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)){
176 if((aitype==playercontrolled&&stunned<=0&&weaponactive==-1)||pause){
177 if(creature==rabbittype)return fightidleanim;
178 if(creature==wolftype)return wolfidle;
180 if(aitype==playercontrolled&&stunned<=0&&weaponactive!=-1){
181 if(weapons.type[weaponids[weaponactive]]==knife)return knifefightidleanim;
182 if(weapons.type[weaponids[weaponactive]]==sword&&victim->weaponactive!=-1)return swordfightidlebothanim;
183 if(weapons.type[weaponids[weaponactive]]==sword)return swordfightidleanim;
184 if(weapons.type[weaponids[weaponactive]]==staff)return swordfightidleanim;
186 if(aitype!=playercontrolled&&stunned<=0&&creature!=wolftype&&!pause)return fightsidestep;
188 if((damage>permanentdamage||damage>damagetolerance*.8||deathbleeding>0)&&creature!=wolftype)return hurtidleanim;
189 if(howactive==typesitting)return sitanim;
190 if(howactive==typesittingwall)return sitwallanim;
191 if(howactive==typesleeping)return sleepanim;
192 if(howactive==typedead1)return dead1anim;
193 if(howactive==typedead2)return dead2anim;
194 if(howactive==typedead3)return dead3anim;
195 if(howactive==typedead4)return dead4anim;
196 if(creature==rabbittype)return bounceidleanim;
197 if(creature==wolftype)return wolfidle;
201 int Person::getCrouch(){
202 if(creature==rabbittype)return crouchanim;
203 if(creature==wolftype)return wolfcrouchanim;
207 int Person::getRun(){
208 if(creature==rabbittype&&(!superruntoggle||weaponactive!=-1))return runanim;
209 if(creature==wolftype&&(!superruntoggle))return wolfrunanim;
211 if(creature==rabbittype&&(superruntoggle&&weaponactive==-1))return rabbitrunninganim;
212 if(creature==wolftype&&(superruntoggle))return wolfrunninganim;
216 int Person::getStop(){
217 if(creature==rabbittype)return stopanim;
218 if(creature==wolftype)return wolfstopanim;
222 int Person::getLanding(){
223 if(creature==rabbittype)return landanim;
224 if(creature==wolftype)return wolflandanim;
228 int Person::getLandhard(){
229 if(creature==rabbittype)return landhardanim;
230 if(creature==wolftype)return wolflandhardanim;
235 SolidHitBonus(int playerid)
237 if (bonustime < 1.5 && bonus >= solidhit && bonus <= megacombo)
238 award_bonus(playerid, bonus == megacombo ? bonus : bonus + 1);
240 award_bonus(playerid, solidhit);
243 void Person::DoBlood(float howmuch,int which){
244 static int bleedxint,bleedyint;
246 //if(howmuch&&id==0)blooddimamount=1;
247 if(bloodtoggle&&tutoriallevel!=1){
248 if(bleeding<=0&&spurt){
250 for(int i=0;i<3;i++){
254 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
257 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
259 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
260 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
262 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
263 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
266 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);
267 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);
271 for(int i=0;i<3;i++){
275 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
276 bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
279 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
280 bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
284 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
286 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);
288 Sprite::setLastSpriteSpecial(3);
293 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
296 int texdetailint=realtexdetail;
297 if(creature==rabbittype)
298 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){
299 bleedxint=abs(Random()%512);
300 bleedyint=abs(Random()%512);
302 if(creature==wolftype)
303 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){
304 bleedxint=abs(Random()%512);
305 bleedyint=abs(Random()%512);
309 bleedy/=realtexdetail;
310 bleedx/=realtexdetail;
311 direction=abs(Random()%2)*2-1;
315 if(bleeding>2)bleeding=2;
318 void Person::DoBloodBig(float howmuch,int which){
319 static int bleedxint,bleedyint,i,j;
321 if(howmuch&&id==0)blooddimamount=1;
323 if(tutoriallevel!=1||id==0)
324 if(aitype!=playercontrolled&&howmuch>0){
327 if(creature==wolftype){
328 int i=abs(Random()%2);
329 if(i==0)whichsound=snarlsound;
330 if(i==1)whichsound=snarl2sound;
331 envsound[numenvsounds]=coords;
332 envsoundvol[numenvsounds]=16;
333 envsoundlife[numenvsounds]=.4;
336 if(creature==rabbittype){
337 int i=abs(Random()%2);
338 if(i==0)whichsound=rabbitpainsound;
339 if(i==1&&howmuch>=2)whichsound=rabbitpain1sound;
340 envsound[numenvsounds]=coords;
341 envsoundvol[numenvsounds]=16;
342 envsoundlife[numenvsounds]=.4;
344 //if(i==2)whichsound=rabbitpain2sound;
348 emit_sound_at(whichsound, coords);
351 if(id==0&&howmuch>0){
359 if(bloodtoggle&&decals&&tutoriallevel!=1){
360 if(bleeding<=0&&spurt){
362 for(int i=0;i<3;i++){
366 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
369 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
371 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
372 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
374 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
375 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
378 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);
379 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);
383 int offsetx=0,offsety=0;
386 offsetx=abs(Random()%60);
388 if(which==190||which==185){
390 offsetx=abs(Random()%100)-20;
400 if(which==220||which==215){
401 //offsety=Random()%20;
403 //offsetx=abs(Random()%80);
412 if(creature==rabbittype)
415 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
416 if(i<startx)startx=i;
417 if(j<starty)starty=j;
423 if(creature==wolftype)
426 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
427 if(i<startx)startx=i;
428 if(j<starty)starty=j;
440 if(startx<0)startx=0;
441 if(starty<0)starty=0;
442 if(endx>512-1)endx=512-1;
443 if(endy>512-1)endy=512-1;
444 if(endx<startx)endx=startx;
445 if(endy<starty)endy=starty;
447 startx/=realtexdetail;
448 starty/=realtexdetail;
452 int texdetailint=realtexdetail;
454 if(creature==rabbittype)
455 for(i=startx;i<endx;i++){
456 for(j=starty;j<endy;j++){
457 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){
458 color=Random()%85+170;
459 where=i*skeleton.skinsize*3+j*3;
460 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
461 skeleton.skinText[where+1]=0;
462 skeleton.skinText[where+2]=0;
466 if(creature==wolftype)
467 for(i=startx;i<endx;i++){
468 for(j=starty;j<endy;j++){
469 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){
470 color=Random()%85+170;
471 where=i*skeleton.skinsize*3+j*3;
472 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
473 skeleton.skinText[where+1]=0;
474 skeleton.skinText[where+2]=0;
478 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
483 if(creature==rabbittype)
484 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){
485 bleedxint=abs(Random()%512);
486 bleedyint=abs(Random()%512);
488 if(creature==wolftype)
489 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){
490 bleedxint=abs(Random()%512);
491 bleedyint=abs(Random()%512);
493 bleedy=bleedxint+offsetx;
494 bleedx=bleedyint+offsety;
495 bleedy/=realtexdetail;
496 bleedx/=realtexdetail;
497 if(bleedx<0)bleedx=0;
498 if(bleedy<0)bleedy=0;
499 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
500 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
501 direction=abs(Random()%2)*2-1;
504 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
505 deathbleeding+=bleeding;
506 bloodloss+=bleeding*3;
508 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
509 if(abs(Random()%2)==0){aitype=gethelptype;
512 else aitype=attacktypecutoff;
515 if(bleeding>2)bleeding=2;
518 bool Person::DoBloodBigWhere(float howmuch,int which, XYZ where){
519 static int bleedxint,bleedyint,i,j;
521 static XYZ startpoint,endpoint,colpoint,movepoint;
522 static float rotationpoint;
524 static XYZ p1,p2,p3,p0;
528 float coordsx,coordsy;
531 if(bloodtoggle&&decals&&tutoriallevel!=1){
533 if(!skeleton.free)where=DoRotation(where,0,-rotation,0);
541 whichtri=skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
544 p1=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
545 p2=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
546 p3=skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
548 CrossProduct(p2-p1,p3-p1,&N);
549 CrossProduct(p0-p1,p3-p1,&temp);
550 s = dotproduct(&temp,&N)/findLength(&N);
551 CrossProduct(p2-p1,p1-p0,&temp);
552 t = dotproduct(&temp,&N)/findLength(&N);
555 bary.x=findDistancefast(&p0,&p1);
556 bary.y=findDistancefast(&p0,&p2);
557 bary.z=findDistancefast(&p0,&p3);
559 total=bary.x+bary.y+bary.z;
568 total=bary.x+bary.y+bary.z;
574 gxx.x=skeleton.drawmodel.Triangles[whichtri].gx[0];
575 gxx.y=skeleton.drawmodel.Triangles[whichtri].gx[1];
576 gxx.z=skeleton.drawmodel.Triangles[whichtri].gx[2];
577 gyy.x=skeleton.drawmodel.Triangles[whichtri].gy[0];
578 gyy.y=skeleton.drawmodel.Triangles[whichtri].gy[1];
579 gyy.z=skeleton.drawmodel.Triangles[whichtri].gy[2];
580 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;
581 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;
583 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
584 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
586 if(bleeding<=0&&spurt){
588 for(int i=0;i<3;i++){
592 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
595 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/4,((float)(Random()%100))/4,0);
597 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
598 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
600 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
601 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position*scale+coords,bloodvel, 1,1,1, .3, 1);
604 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);
605 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);
609 int offsetx=0,offsety=0;
612 offsetx=abs(Random()%120);
614 if(which==220||which==215){
616 offsetx=abs(Random()%80);
619 offsetx=(1+coordsy)*512-291;
620 offsety=coordsx*512-437;
627 if(creature==rabbittype)
630 if(bloodText[i*512*3+j*3+0]<=which+4&&bloodText[i*512*3+j*3+0]>=which-4){
631 if(i<startx)startx=i;
632 if(j<starty)starty=j;
638 if(creature==wolftype)
641 if(wolfbloodText[i*512*3+j*3+0]<=which+4&&wolfbloodText[i*512*3+j*3+0]>=which-4){
642 if(i<startx)startx=i;
643 if(j<starty)starty=j;
654 if(startx<0)startx=0;
655 if(starty<0)starty=0;
656 if(endx>512-1)endx=512-1;
657 if(endy>512-1)endy=512-1;
658 if(endx<startx)endx=startx;
659 if(endy<starty)endy=starty;
661 startx/=realtexdetail;
662 starty/=realtexdetail;
666 int texdetailint=realtexdetail;
668 if(creature==rabbittype)
669 for(i=startx;i<endx;i++){
670 for(j=starty;j<endy;j++){
671 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){
672 color=Random()%85+170;
673 where=i*skeleton.skinsize*3+j*3;
674 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
675 skeleton.skinText[where+1]=0;
676 skeleton.skinText[where+2]=0;
678 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){
679 color=Random()%85+170;
680 where=i*skeleton.skinsize*3+j*3;
681 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
682 skeleton.skinText[where+1]=0;
683 skeleton.skinText[where+2]=0;
687 if(creature==wolftype)
688 for(i=startx;i<endx;i++){
689 for(j=starty;j<endy;j++){
690 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){
691 color=Random()%85+170;
692 where=i*skeleton.skinsize*3+j*3;
693 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
694 skeleton.skinText[where+1]=0;
695 skeleton.skinText[where+2]=0;
697 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){
698 color=Random()%85+170;
699 where=i*skeleton.skinsize*3+j*3;
700 if(skeleton.skinText[where+0]>color/2)skeleton.skinText[where+0]=color/2;
701 skeleton.skinText[where+1]=0;
702 skeleton.skinText[where+2]=0;
706 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
709 bleedy=(1+coordsy)*512;
711 bleedy/=realtexdetail;
712 bleedx/=realtexdetail;
713 if(bleedx<0)bleedx=0;
714 if(bleedy<0)bleedy=0;
715 if(bleedx>skeleton.skinsize-1)bleedx=skeleton.skinsize-1;
716 if(bleedy>skeleton.skinsize-1)bleedy=skeleton.skinsize-1;
717 direction=abs(Random()%2)*2-1;
719 if(whichtri==-1)return 0;
721 bleeding=howmuch+(float)abs(Random()%100)/200-.25;
722 deathbleeding+=bleeding;
723 bloodloss+=bleeding*3;
725 if(tutoriallevel!=1&&aitype!=playercontrolled&&bloodloss>damagetolerance*2/3&&bloodloss<damagetolerance&&creature==rabbittype){
726 if(abs(Random()%2)==0){aitype=gethelptype;
729 else aitype=attacktypecutoff;
732 if(bleeding>2)bleeding=2;
738 void Person::Reverse()
740 if (!((victim->aitype == playercontrolled
742 || staggerdelay <= 0)
743 && victim->targetanimation != jumpupanim
744 && victim->targetanimation != jumpdownanim
745 && (tutoriallevel != 1 || cananger)
749 if (normaldotproduct (victim->facing, victim->coords-coords) > 0
750 && (victim->id != 0 || difficulty >= 2)
751 && (creature != wolftype || victim->creature == wolftype))
754 if(targetanimation==sweepanim){
755 targetanimation=sweepreversedanim;
756 currentanimation=sweepreversedanim;
757 victim->currentanimation=sweepreversalanim;
758 victim->targetanimation=sweepreversalanim;
760 if(targetanimation==spinkickanim){
761 targetanimation=spinkickreversedanim;
762 currentanimation=spinkickreversedanim;
763 victim->currentanimation=spinkickreversalanim;
764 victim->targetanimation=spinkickreversalanim;
766 if(targetanimation==upunchanim||targetanimation==rabbittacklinganim){
767 if(targetanimation==rabbittacklinganim){
770 victim->currentframe=6;
771 victim->targetframe=7;
773 targetanimation=upunchreversedanim;
774 currentanimation=upunchreversedanim;
775 victim->currentanimation=upunchreversalanim;
776 victim->targetanimation=upunchreversalanim;
778 if(targetanimation==staffhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
779 if(victim->weaponactive!=-1){
780 victim->throwtogglekeydown=1;
781 weapons.owner[victim->weaponids[0]]=-1;
782 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
783 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
784 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
785 weapons.missed[victim->weaponids[0]]=1;
786 weapons.freetime[victim->weaponids[0]]=0;
787 weapons.firstfree[victim->weaponids[0]]=1;
788 weapons.physics[victim->weaponids[0]]=1;
789 victim->num_weapons--;
790 if(victim->num_weapons){
791 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
792 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
795 victim->weaponactive=-1;
796 for(int j=0;j<numplayers;j++){
797 player[j].wentforweapon=0;
801 targetanimation=staffhitreversedanim;
802 currentanimation=staffhitreversedanim;
803 victim->currentanimation=staffhitreversalanim;
804 victim->targetanimation=staffhitreversalanim;
806 if(targetanimation==staffspinhitanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%2==0)){
807 if(victim->weaponactive!=-1){
808 victim->throwtogglekeydown=1;
809 weapons.owner[victim->weaponids[0]]=-1;
810 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
811 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
812 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
813 weapons.missed[victim->weaponids[0]]=1;
814 weapons.freetime[victim->weaponids[0]]=0;
815 weapons.firstfree[victim->weaponids[0]]=1;
816 weapons.physics[victim->weaponids[0]]=1;
817 victim->num_weapons--;
818 if(victim->num_weapons){
819 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
820 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
823 victim->weaponactive=-1;
824 for(int j=0;j<numplayers;j++){
825 player[j].wentforweapon=0;
828 targetanimation=staffspinhitreversedanim;
829 currentanimation=staffspinhitreversedanim;
830 victim->currentanimation=staffspinhitreversalanim;
831 victim->targetanimation=staffspinhitreversalanim;
833 if(targetanimation==swordslashanim&&findDistancefast(&victim->coords,&coords)<2&&((victim->id==0&&victim->crouchkeydown)||Random()%4==0)){
834 if(victim->weaponactive!=-1){
835 victim->throwtogglekeydown=1;
836 weapons.owner[victim->weaponids[0]]=-1;
837 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
838 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
839 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
840 weapons.missed[victim->weaponids[0]]=1;
841 weapons.freetime[victim->weaponids[0]]=0;
842 weapons.firstfree[victim->weaponids[0]]=1;
843 weapons.physics[victim->weaponids[0]]=1;
844 victim->num_weapons--;
845 if(victim->num_weapons){
846 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
847 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
850 victim->weaponactive=-1;
851 for(int j=0;j<numplayers;j++){
852 player[j].wentforweapon=0;
855 targetanimation=swordslashreversedanim;
856 currentanimation=swordslashreversedanim;
857 victim->currentanimation=swordslashreversalanim;
858 victim->targetanimation=swordslashreversalanim;
860 if(targetanimation==knifeslashstartanim&&findDistancefast(&victim->coords,&coords)<2&&(victim->id==0||Random()%4==0)){
861 if(victim->weaponactive!=-1){
862 victim->throwtogglekeydown=1;
863 weapons.owner[victim->weaponids[0]]=-1;
864 weapons.velocity[victim->weaponids[0]]=victim->velocity*.2;
865 if(weapons.velocity[victim->weaponids[0]].x==0)weapons.velocity[victim->weaponids[0]].x=.1;
866 weapons.tipvelocity[victim->weaponids[0]]=weapons.velocity[victim->weaponids[0]];
867 weapons.missed[victim->weaponids[0]]=1;
868 weapons.freetime[victim->weaponids[0]]=0;
869 weapons.firstfree[victim->weaponids[0]]=1;
870 weapons.physics[victim->weaponids[0]]=1;
871 victim->num_weapons--;
872 if(victim->num_weapons){
873 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
874 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
877 victim->weaponactive=-1;
878 for(int j=0;j<numplayers;j++){
879 player[j].wentforweapon=0;
882 targetanimation=knifeslashreversedanim;
883 currentanimation=knifeslashreversedanim;
884 victim->currentanimation=knifeslashreversalanim;
885 victim->targetanimation=knifeslashreversalanim;
887 if(targetanimation!=knifeslashstartanim&&targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim&&targetanimation!=winduppunchanim&&targetanimation!=wolfslapanim&&targetanimation!=swordslashanim&&targetanimation!=swordslashanim){
888 victim->targettilt2=targettilt2;
889 victim->currentframe=currentframe;
890 victim->targetframe=targetframe;
891 victim->target=target;
893 victim->oldcoords=victim->coords;
894 victim->coords=coords;
895 victim->targetrotation=targetrotation;
896 victim->rotation=targetrotation;
899 if(targetanimation==winduppunchanim){
900 targetanimation=winduppunchblockedanim;
901 victim->targetanimation=blockhighleftanim;
902 victim->targetframe=1;
905 victim->targetrotation=targetrotation+180;
907 if(targetanimation==wolfslapanim){
908 targetanimation=winduppunchblockedanim;
909 victim->targetanimation=blockhighleftanim;
910 victim->targetframe=1;
913 victim->targetrotation=targetrotation+180;
915 if((targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim)&&victim->weaponactive!=-1){
916 targetanimation=swordslashparriedanim;
918 victim->parriedrecently=0;
919 victim->targetanimation=swordslashparryanim;
920 victim->targetframe=1;
923 victim->targetrotation=targetrotation+180;
925 if(abs(Random()%20)==0||weapons.type[victim->weaponids[victim->weaponactive]]==knife){
926 if(victim->weaponactive!=-1){
927 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
928 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
929 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
930 emit_sound_at(swordstaffsound, victim->coords);
933 emit_sound_at(metalhitsound, victim->coords);
937 victim->Puff(righthand);
939 victim->targetframe=0;
940 victim->targetanimation=staggerbackhighanim;
941 victim->targetrotation=targetrotation+180;
943 weapons.owner[victim->weaponids[0]]=-1;
944 aim=DoRotation(facing,0,90,0)*21;
946 weapons.velocity[victim->weaponids[0]]=aim*-.2;
947 weapons.tipvelocity[victim->weaponids[0]]=aim;
948 weapons.missed[victim->weaponids[0]]=1;
949 weapons.hitsomething[victim->weaponids[0]]=0;
950 weapons.freetime[victim->weaponids[0]]=0;
951 weapons.firstfree[victim->weaponids[0]]=1;
952 weapons.physics[victim->weaponids[0]]=1;
953 victim->num_weapons--;
954 if(victim->num_weapons){
955 victim->weaponids[0]=victim->weaponids[num_weapons];
956 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
958 victim->weaponactive=-1;
959 for(int i=0;i<numplayers;i++){
960 player[i].wentforweapon=0;
964 if(abs(Random()%20)==0){
965 if(weaponactive!=-1){
966 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
967 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
968 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
970 emit_sound_at(swordstaffsound, coords);
973 emit_sound_at(metalhitsound, coords);
981 targetanimation=staggerbackhighanim;
982 targetrotation=targetrotation+180;
984 weapons.owner[weaponids[0]]=-1;
985 aim=DoRotation(facing,0,90,0)*21;
987 weapons.velocity[weaponids[0]]=aim*-.2;
988 weapons.tipvelocity[weaponids[0]]=aim;
989 weapons.hitsomething[weaponids[0]]=0;
990 weapons.missed[weaponids[0]]=1;
991 weapons.freetime[weaponids[0]]=0;
992 weapons.firstfree[weaponids[0]]=1;
993 weapons.physics[weaponids[0]]=1;
996 weaponids[0]=weaponids[num_weapons];
997 if(weaponstuck==num_weapons)weaponstuck=0;
1000 for(int i=0;i<numplayers;i++){
1001 player[i].wentforweapon=0;
1008 if(targetanimation==knifeslashstartanim||targetanimation==swordslashanim||targetanimation==staffhitanim||targetanimation==staffspinhitanim){
1009 if((targetanimation!=staffhitanim&&targetanimation!=staffspinhitanim)||findDistancefast(&coords,&victim->coords)>.2){
1010 victim->targetanimation=dodgebackanim;
1011 victim->targetframe=0;
1015 rotatetarget=coords-victim->coords;
1016 Normalise(&rotatetarget);
1017 victim->targetrotation=-asin(0-rotatetarget.x);
1018 victim->targetrotation*=360/6.28;
1019 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1021 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1023 victim->lastattack3=victim->lastattack2;
1024 victim->lastattack2=victim->lastattack;
1025 victim->lastattack=victim->targetanimation;
1029 victim->targetanimation=sweepanim;
1030 victim->targetframe=0;
1034 rotatetarget=coords-victim->coords;
1035 Normalise(&rotatetarget);
1036 victim->targetrotation=-asin(0-rotatetarget.x);
1037 victim->targetrotation*=360/6.28;
1038 if(rotatetarget.z<0)victim->targetrotation=180-victim->targetrotation;
1040 victim->targettilt2=-asin(rotatetarget.y)*360/6.28;//*-70;
1042 victim->lastattack3=victim->lastattack2;
1043 victim->lastattack2=victim->lastattack;
1044 victim->lastattack=victim->targetanimation;
1051 if(aitype!=playercontrolled)feint=0;
1052 if(aitype!=playercontrolled&&Random()%3==0&&escapednum<2&&difficulty==2)feint=1;
1053 if(aitype!=playercontrolled&&Random()%5==0&&escapednum<2&&difficulty==1)feint=1;
1054 if(aitype!=playercontrolled&&Random()%10==0&&escapednum<2&&difficulty==0)feint=1;
1056 if(victim->id==0&&animation[victim->targetanimation].attack==reversal)numreversals++;
1059 void Person::DoDamage(float howmuch){
1060 if(tutoriallevel!=1)damage+=howmuch/power;
1061 if(id!=0)damagedealt+=howmuch/power;
1062 if(id==0)damagetaken+=howmuch/power;
1064 if(id==0&&(bonus==solidhit||bonus==twoxcombo||bonus==threexcombo||bonus==fourxcombo||bonus==megacombo))bonus=0;
1065 if(tutoriallevel!=1)permanentdamage+=howmuch/2/power;
1066 if(tutoriallevel!=1)superpermanentdamage+=howmuch/4/power;
1067 if(permanentdamage>damagetolerance/2&&permanentdamage-howmuch<damagetolerance/2&&Random()%2)DoBlood(1,255);
1068 if((permanentdamage>damagetolerance*.8&&Random()%2&&!deathbleeding)||spurt)DoBlood(1,255);
1070 if(id==0)camerashake+=howmuch/100;
1071 if(id==0&&((howmuch>50&&damage>damagetolerance/2)))blackout=damage/damagetolerance;
1072 if(blackout>1)blackout=1;
1074 if(aitype==passivetype&&damage<damagetolerance&&((tutoriallevel!=1||cananger)&&hostile))aitype=attacktypecutoff;
1075 if(tutoriallevel!=1&&aitype!=playercontrolled&&damage<damagetolerance&&damage>damagetolerance*2/3&&creature==rabbittype){
1076 if(abs(Random()%2)==0){aitype=gethelptype;
1079 else aitype=attacktypecutoff;
1083 if(howmuch>damagetolerance*50&&skeleton.free!=2){
1086 for(int i=0;i<skeleton.num_joints; i++){
1087 if(!skeleton.free)flatvelocity2=velocity;
1088 if(skeleton.free)flatvelocity2=skeleton.joints[i].velocity;
1089 if(!skeleton.free)flatfacing2=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
1090 if(skeleton.free)flatfacing2=skeleton.joints[i].position*scale+coords;
1091 flatvelocity2.x+=(float)(abs(Random()%100)-50)/10;
1092 flatvelocity2.y+=(float)(abs(Random()%100)-50)/10;
1093 flatvelocity2.z+=(float)(abs(Random()%100)-50)/10;
1094 Sprite::MakeSprite(bloodflamesprite, flatfacing2,flatvelocity2, 1,1,1, 3, 1);
1095 Sprite::MakeSprite(bloodsprite, flatfacing2,flatvelocity2, 1,1,1, .4, 1);
1096 Sprite::MakeSprite(cloudsprite, flatfacing2,flatvelocity2*0, .6,0,0, 1, .5);
1099 emit_sound_at(splattersound, coords);
1108 if(!dead&&creature==wolftype){
1109 award_bonus(0, Wolfbonus);
1115 if(tutoriallevel!=1||id==0)
1116 if(speechdelay<=0&&!dead&&aitype!=playercontrolled){
1119 if(creature==wolftype){
1120 int i=abs(Random()%2);
1121 if(i==0)whichsound=snarlsound;
1122 if(i==1)whichsound=snarl2sound;
1123 envsound[numenvsounds]=coords;
1124 envsoundvol[numenvsounds]=16;
1125 envsoundlife[numenvsounds]=.4;
1128 if(creature==rabbittype){
1129 int i=abs(Random()%2);
1130 if(i==0)whichsound=rabbitpainsound;
1131 if(i==1&&damage>damagetolerance)whichsound=rabbitpain1sound;
1132 envsound[numenvsounds]=coords;
1133 envsoundvol[numenvsounds]=16;
1134 envsoundlife[numenvsounds]=.4;
1136 //if(i==2)whichsound=rabbitpain2sound;
1140 emit_sound_at(whichsound, coords);
1145 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1146 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1149 void Person::DoHead(){
1150 static XYZ rotatearound;
1152 static float lookspeed=500;
1154 if(!freeze&&!winfreeze){
1157 targetheadrotation=(float)((int)((0-rotation-targetheadrotation+180)*100)%36000)/100;
1158 targetheadrotation2=(float)((int)(targetheadrotation2*100)%36000)/100;
1160 while(targetheadrotation>180)targetheadrotation-=360;
1161 while(targetheadrotation<-180)targetheadrotation+=360;
1163 if(targetheadrotation>160)targetheadrotation2=targetheadrotation2*-1;
1164 if(targetheadrotation<-160)targetheadrotation2=targetheadrotation2*-1;
1165 if(targetheadrotation>160)targetheadrotation=targetheadrotation-180;
1166 if(targetheadrotation<-160)targetheadrotation=targetheadrotation+180;
1168 if(targetheadrotation2>120)targetheadrotation2=120;
1169 if(targetheadrotation2<-120)targetheadrotation2=-120;
1170 if(targetheadrotation>120)targetheadrotation=120;
1171 if(targetheadrotation<-120)targetheadrotation=-120;
1173 if(!isIdle())targetheadrotation2=0;
1175 if(targetheadrotation>80)targetheadrotation=80;
1176 if(targetheadrotation<-80)targetheadrotation=-80;
1177 if(targetheadrotation2>50)targetheadrotation2=50;
1178 if(targetheadrotation2<-50)targetheadrotation2=-50;
1181 if(abs(headrotation-targetheadrotation)<multiplier*lookspeed)headrotation=targetheadrotation;
1182 else if(headrotation>targetheadrotation){
1183 headrotation-=multiplier*lookspeed;
1185 else if(headrotation<targetheadrotation){
1186 headrotation+=multiplier*lookspeed;
1189 if(abs(headrotation2-targetheadrotation2)<multiplier*lookspeed/2)headrotation2=targetheadrotation2;
1190 else if(headrotation2>targetheadrotation2){
1191 headrotation2-=multiplier*lookspeed/2;
1193 else if(headrotation2<targetheadrotation2){
1194 headrotation2+=multiplier*lookspeed/2;
1197 rotatearound=skeleton.joints[skeleton.jointlabels[neck]].position;
1198 skeleton.joints[skeleton.jointlabels[head]].position=rotatearound+DoRotation(skeleton.joints[skeleton.jointlabels[head]].position-rotatearound,headrotation2,0,0);
1202 if(targetanimation!=bounceidleanim&&targetanimation!=fightidleanim&&targetanimation!=wolfidle&&targetanimation!=knifefightidleanim&&targetanimation!=drawrightanim&&targetanimation!=drawleftanim&&targetanimation!=walkanim){
1203 facing=DoRotation(facing,headrotation2*.4,0,0);
1204 facing=DoRotation(facing,0,headrotation*.4,0);
1207 if(targetanimation==bounceidleanim||targetanimation==fightidleanim||targetanimation==wolfidle||targetanimation==knifefightidleanim||targetanimation==drawrightanim||targetanimation==drawleftanim){
1208 facing=DoRotation(facing,headrotation2*.8,0,0);
1209 facing=DoRotation(facing,0,headrotation*.8,0);
1212 if(targetanimation==walkanim){
1213 facing=DoRotation(facing,headrotation2*.6,0,0);
1214 facing=DoRotation(facing,0,headrotation*.6,0);
1217 skeleton.specialforward[0]=facing;
1218 //skeleton.specialforward[0]=DoRotation(facing,0,rotation,0);
1220 for(i=0;i<skeleton.num_muscles;i++){
1221 if(skeleton.muscles[i].visible&&(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head))
1223 skeleton.FindRotationMuscle(i,targetanimation);
1229 void Person::RagDoll(bool checkcollision){
1234 if(id==0)numfalls++;
1235 if(id==0&&isFlip())numflipfail++;
1241 facing=DoRotation(facing,0,rotation,0);
1243 skeleton.freetime=0;
1245 skeleton.longdead=0;
1251 skeleton.freefall=1;
1253 if(!isnormal(velocity.x))velocity.x=0;
1254 if(!isnormal(velocity.y))velocity.y=0;
1255 if(!isnormal(velocity.z))velocity.z=0;
1256 if(!isnormal(rotation))rotation=0;
1257 if(!isnormal(coords.x))coords=0;
1258 if(!isnormal(tilt))tilt=0;
1259 if(!isnormal(tilt2))tilt2=0;
1261 for(i=0;i<skeleton.num_joints;i++){
1262 skeleton.joints[i].delay=0;
1263 skeleton.joints[i].locked=0;
1264 skeleton.joints[i].position=DoRotation(DoRotation(DoRotation(skeleton.joints[i].position,0,0,tilt),tilt2,0,0),0,rotation,0);
1265 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=DoRotation(skeleton.joints[i].position,0,rotation,0);
1266 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=skeleton.joints[i].position;
1267 if(!isnormal(skeleton.joints[i].position.x))skeleton.joints[i].position=coords;
1268 skeleton.joints[i].position.y+=.1;
1269 skeleton.joints[i].oldposition=skeleton.joints[i].position;
1270 skeleton.joints[i].realoldposition=skeleton.joints[i].position*scale+coords;
1273 for(i=0;i<skeleton.num_joints;i++){
1274 skeleton.joints[i].velocity=0;
1275 skeleton.joints[i].velchange=0;
1277 skeleton.DoConstraints(&coords,&scale);
1278 if(animation[currentanimation].height==lowheight||animation[targetanimation].height==lowheight)
1280 skeleton.DoConstraints(&coords,&scale);
1281 skeleton.DoConstraints(&coords,&scale);
1282 skeleton.DoConstraints(&coords,&scale);
1283 skeleton.DoConstraints(&coords,&scale);
1286 speed=animation[targetanimation].speed[targetframe]*2;
1287 if(animation[currentanimation].speed[currentframe]>animation[targetanimation].speed[targetframe]){
1288 speed=animation[currentanimation].speed[currentframe]*2;
1290 if(transspeed)speed=transspeed*2;
1294 for(i=0;i<skeleton.num_joints;i++){
1295 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);
1296 else skeleton.joints[i].velocity=velocity/scale+facing*5;
1297 change.x=(float)(Random()%100)/100;
1298 change.y=(float)(Random()%100)/100;
1299 change.z=(float)(Random()%100)/100;
1300 skeleton.joints[i].velocity+=change;
1301 skeleton.joints[abs(Random()%skeleton.num_joints)].velocity-=change;
1303 change.x=(float)(Random()%100)/100;
1304 change.y=(float)(Random()%100)/100;
1305 change.z=(float)(Random()%100)/100;
1306 skeleton.joints[i].velchange+=change;
1307 skeleton.joints[abs(Random()%skeleton.num_joints)].velchange-=change;
1317 for(j=0;j<skeleton.num_joints;j++){
1318 average+=skeleton.joints[j].position;
1322 coords+=average*scale;
1323 for(j=0;j<skeleton.num_joints;j++){
1324 skeleton.joints[j].position-=average;
1327 whichpatchx=coords.x/(terrain.size/subdivision*terrain.scale*terraindetail);
1328 whichpatchz=coords.z/(terrain.size/subdivision*terrain.scale*terraindetail);
1329 if(terrain.patchobjectnum[whichpatchx][whichpatchz])
1330 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
1331 i=terrain.patchobjects[whichpatchx][whichpatchz][l];
1334 if(SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.rotation[i], &objects.model[i])!=-1){
1335 coords.x=lowpoint.x;
1336 coords.z=lowpoint.z;
1345 for(i=0;i<skeleton.num_joints;i++){
1346 velocity+=skeleton.joints[i].velocity*scale;
1348 velocity/=skeleton.num_joints;
1351 if(weaponactive!=-1&&targetanimation!=rabbitkickanim&&num_weapons>0){
1352 weapons.owner[weaponids[0]]=-1;
1353 weapons.hitsomething[weaponids[0]]=0;
1354 weapons.velocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale*-.3;
1355 weapons.velocity[weaponids[0]].x+=.01;
1356 weapons.tipvelocity[weaponids[0]]=skeleton.joints[skeleton.jointlabels[righthand]].velocity*scale;
1357 weapons.missed[weaponids[0]]=1;
1358 weapons.freetime[weaponids[0]]=0;
1359 weapons.firstfree[weaponids[0]]=1;
1360 weapons.physics[weaponids[0]]=1;
1363 weaponids[0]=weaponids[num_weapons];
1364 if(weaponstuck==num_weapons)weaponstuck=0;
1367 for(i=0;i<numplayers;i++){
1368 player[i].wentforweapon=0;
1373 targetanimation=bounceidleanim;
1374 currentanimation=bounceidleanim;
1382 void Person::FootLand(int which, float opacity){
1383 static XYZ terrainlight;
1384 static XYZ footvel,footpoint;
1385 if(opacity>=1||skiddelay<=0)
1389 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1390 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1391 //footpoint.y=coords.y;
1392 if(findDistancefast(&footpoint,&viewer))Sprite::MakeSprite(cloudsprite, footpoint,footvel, 1,1,1, .5, .2*opacity);
1394 else if(environment==snowyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1396 if(footvel.y<.8)footvel.y=.8;
1397 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1398 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1399 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1400 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1401 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, terrainlight.x,terrainlight.y,terrainlight.z, .5, .7*opacity);
1402 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,1*opacity,rotation);
1404 else if(environment==grassyenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1406 if(footvel.y<.8)footvel.y=.8;
1407 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1408 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1409 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1410 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1411 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);
1413 else if(environment==desertenvironment&&onterrain&&terrain.getOpacity(coords.x,coords.z)<.2){
1415 if(footvel.y<.8)footvel.y=.8;
1416 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1417 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1418 footpoint.y=terrain.getHeight(footpoint.x,footpoint.z);
1419 terrainlight=terrain.getLighting(footpoint.x,footpoint.z);
1420 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);
1421 if(opacity>=1||detail==2)if(detail==2)if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)terrain.MakeDecal(footprintdecal,footpoint,.2,.25*opacity,rotation);
1423 else if(isLanding()||targetanimation==jumpupanim||isLandhard())
1426 if(footvel.y<.8)footvel.y=.8;
1427 if(which==0)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
1428 if(which==1)footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
1429 //footpoint.y=coords.y;
1430 if(findDistancefast(&footpoint,&viewer)<viewdistance*viewdistance/4)Sprite::MakeSprite(cloudsprite, footpoint,footvel*.6, 1,1,1, .5, .2*opacity);
1434 void Person::Puff(int whichlabel){
1435 static XYZ footvel,footpoint;
1438 footpoint=DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position,0,rotation,0)*scale+coords;
1439 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .9, .3);
1443 void Person::DoAnimations(){
1446 static float oldtarget;
1448 if(isIdle()&¤tanimation!=getIdle())normalsupdatedelay=0;
1450 if(targetanimation==tempanim||currentanimation==tempanim){
1451 animation[tempanim]=tempanimation;
1453 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
1464 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1465 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
1467 if(((velocity.y<-15)||(crouchkeydown&&velocity.y<-8))&&abs(velocity.y)*4>fast_sqrt(velocity.x*velocity.x*velocity.z*velocity.z))landhard=1;
1468 if(!crouchkeydown&&velocity.y>=-15)landhard=0;
1470 if((currentanimation==jumpupanim||targetanimation==jumpdownanim)/*&&velocity.y<40*/&&!isFlip()&&(!isLanding()&&!isLandhard())&&((crouchkeydown&&!crouchtogglekeydown))){
1475 targfacing=DoRotation(targfacing,0,targetrotation,0);
1477 if(normaldotproduct(targfacing,velocity)>=-.3)targetanimation=flipanim;
1478 else targetanimation=backflipanim;
1479 crouchtogglekeydown=1;
1483 if(id==0)numflipped++;
1486 if(animation[targetanimation].attack!=reversed)feint=0;
1487 if(!crouchkeydown||(isLanding()||isLandhard())||(wasLanding()||wasLandhard())){
1488 crouchtogglekeydown=0;
1489 if(aitype==playercontrolled)feint=0;
1493 if(!crouchtogglekeydown&&animation[targetanimation].attack==reversed&&aitype==playercontrolled&&(escapednum<2||reversaltrain))feint=1;
1494 if(!isFlip())crouchtogglekeydown=1;
1498 if(animation[targetanimation].attack||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim){
1499 if(detail)normalsupdatedelay=0;
1503 if(targetanimation==rollanim&&targetframe==3&&onfire){
1505 emit_sound_at(fireendsound, coords);
1506 pause_sound(stream_firesound);
1510 if(targetanimation==rabbittacklinganim&&targetframe==1){
1511 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->targetanimation].attack==neutral&&victim->id!=0)Reverse();
1512 if(victim->aitype==attacktypecutoff&&victim->stunned<=0&&victim->surprised<=0&&victim->id!=0)Reverse();
1513 if(targetanimation==rabbittacklinganim&&targetframe==1&&!victim->isCrouch()&&victim->targetanimation!=backhandspringanim){
1514 if(normaldotproduct(victim->facing,facing)>0)victim->targetanimation=rabbittackledbackanim;
1515 else victim->targetanimation=rabbittackledfrontanim;
1516 victim->targetframe=2;
1518 victim->rotation=rotation;
1519 victim->targetrotation=rotation;
1520 if(victim->aitype==gethelptype)victim->DoDamage(victim->damagetolerance-victim->damage);
1521 //victim->DoDamage(30);
1522 if(creature==wolftype){
1524 emit_sound_at(clawslicesound, victim->coords);
1526 victim->DoBloodBig(1/victim->armorhead,210);
1528 award_bonus(id, TackleBonus,
1529 victim->aitype == gethelptype ? 50 : 0);
1533 if(!drawtogglekeydown&&drawkeydown&&(weaponactive==-1||num_weapons==1)&&(animation[targetanimation].label[targetframe]||(targetanimation!=currentanimation&¤tanimation==rollanim))&&num_weapons>0&&creature!=wolftype){
1534 if(weapons.type[weaponids[0]]==knife){
1535 if(weaponactive==-1)weaponactive=0;
1536 else if(weaponactive==0)weaponactive=-1;
1538 if(weaponactive==-1){
1539 emit_sound_at(knifesheathesound, coords);
1541 if(weaponactive!=-1){
1542 emit_sound_at(knifedrawsound, coords, 128);
1545 drawtogglekeydown=1;
1548 if(tutoriallevel!=1||id==0)
1549 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1552 if(terrain.getOpacity(coords.x,coords.z)<.2){
1553 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound;
1554 else whichsound=footstepsound2;
1555 if(animation[targetanimation].label[targetframe]==1)FootLand(0,1);
1556 if(animation[targetanimation].label[targetframe]==2)FootLand(1,1);
1557 if(animation[targetanimation].label[targetframe]==3&&isRun()){
1563 if(terrain.getOpacity(coords.x,coords.z)>=.2){
1564 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1565 else whichsound=footstepsound4;
1569 if(animation[targetanimation].label[targetframe]==1)whichsound=footstepsound3;
1570 else whichsound=footstepsound4;
1572 if(animation[targetanimation].label[targetframe]==4&&(weaponactive==-1||(targetanimation!=knifeslashstartanim&&targetanimation!=knifethrowanim&&targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=knifefollowanim))){
1573 if(animation[targetanimation].attack!=neutral){
1575 if(i==0)whichsound=lowwhooshsound;
1576 if(i==1)whichsound=midwhooshsound;
1577 if(i==2)whichsound=highwhooshsound;
1579 if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1581 else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1582 if(animation[targetanimation].label[targetframe]==8&&tutoriallevel!=1)whichsound=landsound2;
1584 emit_sound_at(whichsound, coords, 256.);
1587 if(whichsound==footstepsound||whichsound==footstepsound2||whichsound==footstepsound3||whichsound==footstepsound4){
1588 envsound[numenvsounds]=coords;
1589 if(targetanimation==wolfrunninganim||targetanimation==rabbitrunninganim)envsoundvol[numenvsounds]=15;
1590 else envsoundvol[numenvsounds]=6;
1591 envsoundlife[numenvsounds]=.4;
1595 if(animation[targetanimation].label[targetframe]==3){
1597 emit_sound_at(whichsound, coords, 128.);
1602 if(tutoriallevel!=1||id==0)
1604 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)
1605 if((animation[targetanimation].label[targetframe]&&(animation[targetanimation].label[targetframe]<5||animation[targetanimation].label[targetframe]==8))/*||(targetanimation==rollanim&&targetframe==animation[rollanim].numframes-1)*/){
1607 if(animation[targetanimation].label[targetframe]==4&&aitype!=playercontrolled){
1608 if(animation[targetanimation].attack!=neutral){
1610 if(creature==rabbittype){
1611 if(i==0)whichsound=rabbitattacksound;
1612 if(i==1)whichsound=rabbitattack2sound;
1613 if(i==2)whichsound=rabbitattack3sound;
1614 if(i==3)whichsound=rabbitattack4sound;
1616 if(creature==wolftype){
1617 if(i==0)whichsound=barksound;
1618 if(i==1)whichsound=bark2sound;
1619 if(i==2)whichsound=bark3sound;
1620 if(i==3)whichsound=barkgrowlsound;
1624 //if(animation[targetanimation].attack==neutral)whichsound=movewhooshsound;
1626 //else if(animation[targetanimation].label[targetframe]==4)whichsound=knifeswishsound;
1627 //if(animation[targetanimation].label[targetframe]==8)whichsound=landsound2;
1630 emit_sound_at(whichsound, coords);
1636 if((!wasLanding()&&!wasLandhard())&¤tanimation!=getIdle()&&(isLanding()||isLandhard())){
1642 currentoffset=targetoffset;
1643 targetframe=currentframe;
1644 currentanimation=targetanimation;
1647 if(targetanimation==removeknifeanim&&animation[targetanimation].label[currentframe]==5){
1648 for(i=0;i<weapons.numweapons;i++){
1649 if(/*weapons.velocity[i].x==0&&weapons.velocity[i].y==0&&weapons.velocity[i].z==0&&*/weapons.owner[i]==-1)
1650 if(findDistancefastflat(&coords,&weapons.position[i])<4&&weaponactive==-1){
1651 if(findDistancefast(&coords,&weapons.position[i])>=1){
1652 if(weapons.type[i]!=staff){
1653 emit_sound_at(knifedrawsound, coords, 128.);
1657 weapons.owner[i]=id;
1659 weaponids[num_weapons]=weaponids[0];
1668 static bool willwork;
1669 if(targetanimation==crouchremoveknifeanim&&animation[targetanimation].label[currentframe]==5){
1670 for(i=0;i<weapons.numweapons;i++){
1672 if(weapons.owner[i]!=-1)
1673 if(player[weapons.owner[i]].weaponstuck!=-1)
1674 if(player[weapons.owner[i]].weaponids[player[weapons.owner[i]].weaponstuck]==i)
1675 if(player[weapons.owner[i]].num_weapons>1)willwork=0;
1676 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))
1677 if(willwork&&findDistancefastflat(&coords,&weapons.position[i])<3&&weaponactive==-1){
1678 if(findDistancefast(&coords,&weapons.position[i])<1||hasvictim){
1680 if(weapons.owner[i]!=-1)
1681 if(victim->weaponstuck!=-1){
1682 if(victim->weaponids[victim->weaponstuck]==i){
1687 if(weapons.type[i]!=staff){
1688 emit_sound_at(knifedrawsound, coords, 128.);
1692 emit_sound_at(fleshstabremovesound, coords, 128.);
1695 if(weapons.owner[i]!=-1){
1697 victim=&player[weapons.owner[i]];
1698 if(victim->num_weapons==1)victim->num_weapons=0;
1699 else victim->num_weapons=1;
1701 //victim->weaponactive=-1;
1702 victim->skeleton.longdead=0;
1703 victim->skeleton.free=1;
1704 victim->skeleton.broken=0;
1706 for(int j=0;j<victim->skeleton.num_joints;j++){
1707 victim->skeleton.joints[j].velchange=0;
1708 victim->skeleton.joints[j].locked=0;
1714 Normalise(&relative);
1715 XYZ footvel,footpoint;
1717 footpoint=weapons.position[i];
1718 if(victim->weaponstuck!=-1){
1719 if(victim->weaponids[victim->weaponstuck]==i){
1720 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
1721 weapons.bloody[i]=2;
1722 weapons.blooddrip[i]=5;
1723 victim->weaponstuck=-1;
1726 if(victim->num_weapons>0){
1727 if(victim->weaponstuck!=0&&victim->weaponstuck!=-1)victim->weaponstuck=0;
1728 if(victim->weaponids[0]==i)
1729 victim->weaponids[0]=victim->weaponids[victim->num_weapons];
1732 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*6;
1733 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*6;
1734 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity+=relative*6;
1735 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity+=relative*6;
1737 weapons.owner[i]=id;
1739 weaponids[num_weapons]=weaponids[0];
1748 if(currentanimation==drawleftanim&&animation[targetanimation].label[currentframe]==5){
1749 if(weaponactive==-1)weaponactive=0;
1750 else if(weaponactive==0){
1754 buffer=weaponids[0];
1755 weaponids[0]=weaponids[1];
1756 weaponids[1]=buffer;
1759 if(weaponactive==-1){
1760 emit_sound_at(knifesheathesound, coords, 128.);
1762 if(weaponactive!=-1){
1763 emit_sound_at(knifedrawsound, coords, 128.);
1768 if((currentanimation==walljumprightkickanim&&targetanimation==walljumprightkickanim)||(currentanimation==walljumpleftkickanim&&targetanimation==walljumpleftkickanim)){
1769 XYZ rotatetarget=DoRotation(skeleton.forward,0,rotation,0);
1770 Normalise(&rotatetarget);
1771 targetrotation=-asin(0-rotatetarget.x);
1772 targetrotation*=360/6.28;
1773 if(rotatetarget.z<0)targetrotation=180-targetrotation;
1775 if(targetanimation==walljumprightkickanim)targetrotation+=40;
1776 if(targetanimation==walljumpleftkickanim)targetrotation-=40;
1781 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&targetframe==3&&(jumpkeydown||attackkeydown||id!=0))dojumpattack=1;
1783 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;
1785 if((targetanimation==rabbitrunninganim||targetanimation==wolfrunninganim)&&id==0){
1786 targetanimation=rabbittackleanim;
1788 emit_sound_at(jumpsound, coords);
1797 Normalise(&targetloc);
1799 for(i=0;i<numplayers;i++){
1801 if(findDistancefast(&targetloc,&player[i].coords)<closestdist||closestdist==0){
1802 closestdist=findDistancefast(&targetloc,&player[i].coords);
1807 if(closestdist<5&&!player[closestid].dead&&animation[player[closestid].targetanimation].height!=lowheight&&player[closestid].targetanimation!=backhandspringanim){
1809 victim=&player[closestid];
1810 coords=victim->coords;
1811 currentanimation=rabbittacklinganim;
1812 targetanimation=rabbittacklinganim;
1816 if(coords.z!=victim->coords.z||coords.x!=victim->coords.x){
1817 rotatetarget=coords-victim->coords;
1818 Normalise(&rotatetarget);
1819 targetrotation=-asin(0-rotatetarget.x);
1820 targetrotation*=360/6.28;
1821 if(rotatetarget.z<0)targetrotation=180-targetrotation;
1823 if(targetanimation!=rabbitrunninganim){
1824 emit_sound_at(jumpsound, coords, 128.);
1830 float damagemult=1*power;
1831 if(creature==wolftype)damagemult=2.5*power;
1832 if(hasvictim){damagemult/=victim->damagetolerance/200;}
1833 //if(onfire)damagemult=3;
1834 if((animation[targetanimation].attack==normalattack||targetanimation==walljumprightkickanim||targetanimation==walljumpleftkickanim)&&(!feint)&&(victim->skeleton.free!=2||targetanimation==killanim||targetanimation==dropkickanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==staffgroundsmashanim)){
1835 if(targetanimation==spinkickanim&&animation[targetanimation].label[currentframe]==5){
1836 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
1838 if(id==0)camerashake+=.4;
1839 if(Random()%2||creature==wolftype){
1842 if(creature==wolftype)DoBloodBig(0,250);
1844 if(tutoriallevel!=1){
1845 emit_sound_at(heavyimpactsound, victim->coords, 128.);
1847 if(creature==wolftype){
1848 emit_sound_at(clawslicesound, victim->coords, 128.);
1850 victim->DoBloodBig(2/victim->armorhead,175);
1854 relative=victim->coords-coords;
1856 Normalise(&relative);
1857 relative=DoRotation(relative,0,-90,0);
1858 for(i=0;i<victim->skeleton.num_joints;i++){
1859 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
1861 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
1864 victim->DoDamage(damagemult*100/victim->protectionhead);
1870 if(targetanimation==wolfslapanim&&animation[targetanimation].label[currentframe]==5){
1871 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&3&&animation[victim->targetanimation].height!=lowheight){
1873 if(id==0)camerashake+=.4;
1874 if(Random()%2||creature==wolftype){
1876 if(creature==wolftype)DoBloodBig(0,235);
1878 emit_sound_at(whooshhitsound, victim->coords);
1879 if(creature==wolftype){
1880 emit_sound_at(clawslicesound, victim->coords, 128.);
1882 victim->DoBloodBig(2,175);
1886 relative=victim->coords-coords;
1888 Normalise(&relative);
1890 Normalise(&relative);
1891 relative=DoRotation(relative,0,90,0);
1892 for(i=0;i<victim->skeleton.num_joints;i++){
1893 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
1895 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
1898 victim->DoDamage(damagemult*50/victim->protectionhead);
1902 if(targetanimation==walljumprightkickanim&&animation[targetanimation].label[currentframe]==5){
1903 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
1905 if(id==0)camerashake+=.4;
1908 if(tutoriallevel!=1){
1909 emit_sound_at(heavyimpactsound, victim->coords, 160.);
1911 if(creature==wolftype){
1912 emit_sound_at(clawslicesound, victim->coords, 128.);
1914 victim->DoBloodBig(2/victim->armorhead,175);
1920 Normalise(&relative);
1921 relative=DoRotation(relative,0,-90,0);
1922 for(i=0;i<victim->skeleton.num_joints;i++){
1923 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
1925 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
1928 victim->DoDamage(damagemult*150/victim->protectionhead);
1930 if(victim->damage>victim->damagetolerance)
1931 award_bonus(id, style);
1937 if(targetanimation==walljumpleftkickanim&&animation[targetanimation].label[currentframe]==5){
1938 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
1940 if(id==0)camerashake+=.4;
1943 if(tutoriallevel!=1){
1944 emit_sound_at(heavyimpactsound, victim->coords, 160.);
1946 if(creature==wolftype){
1947 emit_sound_at(clawslicesound, victim->coords, 128.);
1949 victim->DoBloodBig(2/victim->armorhead,175);
1955 Normalise(&relative);
1956 relative=DoRotation(relative,0,90,0);
1957 for(i=0;i<victim->skeleton.num_joints;i++){
1958 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
1960 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
1963 victim->DoDamage(damagemult*150/victim->protectionhead);
1965 if(victim->damage>victim->damagetolerance)
1966 award_bonus(id, style);
1972 if(targetanimation==blockhighleftstrikeanim&&animation[targetanimation].label[currentframe]==5){
1973 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=lowheight){
1975 if(id==0)camerashake+=.4;
1980 emit_sound_at(whooshhitsound, victim->coords);
1983 relative=victim->coords-coords;
1985 Normalise(&relative);
1986 for(i=0;i<victim->skeleton.num_joints;i++){
1987 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
1989 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*100;
1992 victim->DoDamage(damagemult*50/victim->protectionhead);
1996 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==8){
1997 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim->dead){
1999 if(id==0)camerashake+=.2;
2000 emit_sound_at(whooshhitsound, victim->coords, 128.);
2002 victim->skeleton.longdead=0;
2003 victim->skeleton.free=1;
2004 victim->skeleton.broken=0;
2005 victim->skeleton.spinny=1;
2007 for(i=0;i<victim->skeleton.num_joints;i++){
2008 victim->skeleton.joints[i].velchange=0;
2009 victim->skeleton.joints[i].delay=0;
2010 victim->skeleton.joints[i].locked=0;
2011 //victim->skeleton.joints[i].velocity=0;
2017 Normalise(&relative);
2018 for(i=0;i<victim->skeleton.num_joints;i++){
2019 victim->skeleton.joints[i].velocity.y=relative.y*10;
2020 victim->skeleton.joints[i].position.y+=relative.y*.3;
2021 victim->skeleton.joints[i].oldposition.y+=relative.y*.3;
2022 victim->skeleton.joints[i].realoldposition.y+=relative.y*.3;
2024 victim->Puff(abdomen);
2025 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y=relative.y*400;
2029 if(targetanimation==killanim&&animation[targetanimation].label[currentframe]==5){
2030 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->dead){
2032 if(id==0)camerashake+=.4;
2033 if(tutoriallevel!=1){
2034 emit_sound_at(heavyimpactsound, coords, 128.);
2037 relative=victim->coords-coords;
2039 Normalise(&relative);
2040 for(i=0;i<victim->skeleton.num_joints;i++){
2041 victim->skeleton.joints[i].velocity+=relative*damagemult*90;
2043 victim->Puff(abdomen);
2044 if(victim->dead!=2&&victim->permanentdamage>victim->damagetolerance-250&&autoslomo){
2048 victim->DoDamage(damagemult*500/victim->protectionhigh);
2049 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*300;
2053 if(targetanimation==dropkickanim&&animation[targetanimation].label[currentframe]==7){
2054 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*9&&victim->skeleton.free){
2056 if(id==0)camerashake+=.4;
2057 if(tutoriallevel!=1){
2058 emit_sound_at(thudsound, coords);
2061 victim->skeleton.longdead=0;
2062 victim->skeleton.free=1;
2063 victim->skeleton.broken=0;
2064 victim->skeleton.spinny=1;
2066 for(i=0;i<victim->skeleton.num_joints;i++){
2067 victim->skeleton.joints[i].velchange=0;
2068 //victim->skeleton.joints[i].delay=0;
2069 victim->skeleton.joints[i].locked=0;
2072 relative=victim->coords-coords;
2073 Normalise(&relative);
2075 Normalise(&relative);
2076 for(i=0;i<victim->skeleton.num_joints;i++){
2077 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
2082 victim->Puff(abdomen);
2083 victim->DoDamage(damagemult*20/victim->protectionhigh);
2084 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2086 if(!victim->dead)staggerdelay=1.2;
2092 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==5){
2093 //if(id==0)camerashake+=.4;
2096 if(!victim->skeleton.free)hasvictim=0;
2099 terrain.MakeDecal(blooddecalfast,(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2),.08,.6,Random()%360);
2100 emit_sound_at(knifesheathesound, coords, 128.);
2103 if(victim&&hasvictim){
2104 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2106 XYZ where,startpoint,endpoint,movepoint,colpoint;
2107 float rotationpoint;
2109 if(weapons.type[weaponids[weaponactive]]==knife){
2110 where=(weapons.tippoint[weaponids[weaponactive]]*.6+weapons.position[weaponids[weaponactive]]*.4);
2111 where-=victim->coords;
2112 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2119 if(weapons.type[weaponids[weaponactive]]==sword){
2120 where=weapons.position[weaponids[weaponactive]];
2121 where-=victim->coords;
2122 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2124 where=weapons.tippoint[weaponids[weaponactive]];
2125 where-=victim->coords;
2126 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2129 if(weapons.type[weaponids[weaponactive]]==staff){
2130 where=weapons.position[weaponids[weaponactive]];
2131 where-=victim->coords;
2132 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2134 where=weapons.tippoint[weaponids[weaponactive]];
2135 where-=victim->coords;
2136 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2141 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &colpoint, &movepoint, &rotationpoint);
2144 if(victim->dead!=2){
2145 victim->DoDamage(abs((victim->damagetolerance-victim->permanentdamage)*2));
2147 award_bonus(id, FinishedBonus);
2149 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
2151 victim->skeleton.longdead=0;
2152 victim->skeleton.free=1;
2153 victim->skeleton.broken=0;
2155 for(i=0;i<victim->skeleton.num_joints;i++){
2156 victim->skeleton.joints[i].velchange=0;
2157 victim->skeleton.joints[i].locked=0;
2158 //victim->skeleton.joints[i].velocity=0;
2160 emit_sound_at(fleshstabsound, coords, 128);
2163 if(whichtri!=-1||weapons.bloody[weaponids[weaponactive]]){
2164 weapons.blooddrip[weaponids[weaponactive]]+=5;
2165 weapons.blooddripdelay[weaponids[weaponactive]]=0;
2169 emit_sound_at(knifesheathesound, coords, 128.);
2175 if((targetanimation==crouchstabanim||targetanimation==swordgroundstabanim)&&animation[targetanimation].label[currentframe]==6){
2177 emit_sound_at(knifedrawsound, coords, 128);
2180 if(victim&&hasvictim){
2181 XYZ footvel,footpoint;
2183 emit_sound_at(fleshstabremovesound, coords, 128.);
2186 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2188 if(weapons.type[weaponids[weaponactive]]==sword){
2189 XYZ where,startpoint,endpoint,movepoint;
2190 float rotationpoint;
2193 where=weapons.position[weaponids[weaponactive]];
2194 where-=victim->coords;
2195 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2197 where=weapons.tippoint[weaponids[weaponactive]];
2198 where-=victim->coords;
2199 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2204 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2205 footpoint+=victim->coords;
2208 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2211 if(weapons.type[weaponids[weaponactive]]==staff){
2212 XYZ where,startpoint,endpoint,movepoint;
2213 float rotationpoint;
2216 where=weapons.position[weaponids[weaponactive]];
2217 where-=victim->coords;
2218 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2220 where=weapons.tippoint[weaponids[weaponactive]];
2221 where-=victim->coords;
2222 if(!victim->skeleton.free)where=DoRotation(where,0,-victim->rotation,0);
2227 whichtri=victim->skeleton.drawmodel.LineCheck(&startpoint,&endpoint, &footpoint, &movepoint, &rotationpoint);
2228 footpoint+=victim->coords;
2231 footpoint=(weapons.tippoint[weaponids[weaponactive]]*.8+weapons.position[weaponids[weaponactive]]*.2);
2234 hasvictim=victim->DoBloodBigWhere(2,220,footpoint);
2236 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2237 victim->skeleton.longdead=0;
2238 victim->skeleton.free=1;
2239 victim->skeleton.broken=0;
2241 for(i=0;i<victim->skeleton.num_joints;i++){
2242 victim->skeleton.joints[i].velchange=0;
2243 victim->skeleton.joints[i].locked=0;
2244 //victim->skeleton.joints[i].velocity=0;
2250 Normalise(&relative);
2251 //victim->Puff(abdomen);
2252 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .8, .3);
2254 if(victim->bloodloss<victim->damagetolerance){
2255 victim->bloodloss+=1000;
2259 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2263 if(!hasvictim&&onterrain){
2264 weapons.bloody[weaponids[weaponactive]]=0;
2265 weapons.blooddrip[weaponids[weaponactive]]=0;
2269 if(targetanimation==upunchanim&&animation[targetanimation].label[currentframe]==5){
2270 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3){
2272 if(id==0)camerashake+=.4;
2277 if(tutoriallevel!=1){
2278 emit_sound_at(heavyimpactsound, victim->coords, 128);
2283 relative=victim->coords-coords;
2285 Normalise(&relative);
2286 for(i=0;i<victim->skeleton.num_joints;i++){
2287 victim->skeleton.joints[i].velocity=relative*30;
2289 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*150;
2291 victim->targetframe=0;
2292 victim->targetanimation=staggerbackhardanim;
2293 victim->targetrotation=targetrotation+180;
2298 victim->Puff(abdomen);
2299 victim->DoDamage(damagemult*60/victim->protectionhigh);
2306 if(targetanimation==winduppunchanim&&animation[targetanimation].label[currentframe]==5){
2307 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*2){
2309 if(id==0)camerashake+=.4;
2310 if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height!=lowheight){
2311 if(tutoriallevel!=1){
2312 emit_sound_at(thudsound, victim->coords);
2315 else if(victim->damage<=victim->damagetolerance-60&&normaldotproduct(victim->facing,victim->coords-coords)<(scale*5)*(scale*5)*0&&animation[victim->targetanimation].height==lowheight){
2316 if(tutoriallevel!=1){
2317 emit_sound_at(whooshhitsound, victim->coords);
2321 if(tutoriallevel!=1){
2322 emit_sound_at(heavyimpactsound, victim->coords);
2326 if(victim->damage>victim->damagetolerance-60||normaldotproduct(victim->facing,victim->coords-coords)>0||animation[victim->targetanimation].height==lowheight)
2329 relative=victim->coords-coords;
2331 Normalise(&relative);
2333 Normalise(&relative);
2334 for(i=0;i<victim->skeleton.num_joints;i++){
2335 victim->skeleton.joints[i].velocity=relative*5;
2337 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*400;
2339 victim->targetframe=0;
2340 victim->targetanimation=staggerbackhardanim;
2341 victim->targetrotation=targetrotation+180;
2345 victim->Puff(abdomen);
2346 victim->DoDamage(damagemult*60/victim->protectionhigh);
2352 if(targetanimation==blockhighleftanim&&animation[targetanimation].label[currentframe]==5){
2353 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2354 if(victim->id==0)camerashake+=.4;
2355 emit_sound_at(landsound2, victim->coords);
2361 if(targetanimation==swordslashparryanim&&animation[targetanimation].label[currentframe]==5){
2362 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4){
2363 if(victim->id==0)camerashake+=.4;
2365 if(weaponactive!=-1){
2366 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
2367 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2368 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2370 emit_sound_at(swordstaffsound, victim->coords);
2373 emit_sound_at(metalhitsound, victim->coords);
2381 if(targetanimation==knifethrowanim&&animation[targetanimation].label[currentframe]==5){
2382 if(weaponactive!=-1){
2385 weapons.owner[weaponids[0]]=-1;
2386 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);
2388 /*if(victim->targetanimation==jumpupanim||victim->targetanimation==jumpdownanim){
2389 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
2391 weapons.velocity[weaponids[0]]=aim*50;
2392 weapons.tipvelocity[weaponids[0]]=aim*50;
2393 weapons.missed[weaponids[0]]=0;
2394 weapons.hitsomething[weaponids[0]]=0;
2395 weapons.freetime[weaponids[0]]=0;
2396 weapons.firstfree[weaponids[0]]=1;
2397 weapons.physics[weaponids[0]]=0;
2400 weaponids[0]=weaponids[num_weapons];
2406 if(targetanimation==knifeslashstartanim&&animation[targetanimation].label[currentframe]==5){
2408 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*4.5&&/*animation[victim->targetanimation].height!=lowheight&&*/victim->targetanimation!=dodgebackanim&&victim->targetanimation!=rollanim){
2410 if(tutoriallevel!=1)victim->DoBloodBig(1.5/victim->armorhigh,225);
2412 award_bonus(id, Slicebonus);
2413 if(tutoriallevel!=1){
2414 emit_sound_at(knifeslicesound, victim->coords);
2416 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2417 if(animation[victim->targetanimation].attack&&(victim->aitype!=playercontrolled||victim->targetanimation==knifeslashstartanim)&&(victim->creature==rabbittype||victim->deathbleeding<=0)){
2418 if(victim->id != 0 || difficulty==2){
2419 victim->targetframe=0;
2420 victim->targetanimation=staggerbackhardanim;
2421 victim->targetrotation=targetrotation+180;
2425 victim->lowreversaldelay=0;
2426 victim->highreversaldelay=0;
2427 if(aitype!=playercontrolled)weaponmissdelay=.6;
2429 if(tutoriallevel!=1)if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
2430 if(tutoriallevel!=1)weapons.blooddrip[weaponids[weaponactive]]+=3;
2432 XYZ footvel,footpoint;
2435 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
2438 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;
2440 if(tutoriallevel!=1){
2441 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .6, .3);
2442 footvel=DoRotation(facing,0,90,0)*.8;
2444 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2445 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2446 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
2447 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
2449 if(tutoriallevel==1){
2450 Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,1,1, .6, .3);
2452 victim->DoDamage(damagemult*0);
2455 if(targetanimation==swordslashanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
2456 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim){
2457 if(victim->weaponactive==-1||normaldotproduct(victim->facing,victim->coords-coords)>0||(Random()%2==0)){
2458 award_bonus(id, Slashbonus);
2460 if(tutoriallevel!=1){
2461 if(normaldotproduct(victim->facing,victim->coords-coords)<0)victim->DoBloodBig(2/victim->armorhigh,190);
2462 else victim->DoBloodBig(2/victim->armorhigh,185);
2463 victim->deathbleeding=1;
2464 emit_sound_at(swordslicesound, victim->coords);
2466 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2467 if(tutoriallevel!=1){
2468 victim->targetframe=0;
2469 victim->targetanimation=staggerbackhardanim;
2470 victim->targetrotation=targetrotation+180;
2474 if(tutoriallevel!=1){
2475 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
2476 weapons.blooddrip[weaponids[weaponactive]]+=3;
2478 float bloodlossamount;
2479 bloodlossamount=200+abs((float)(Random()%40))-20;
2480 victim->bloodloss+=bloodlossamount/victim->armorhigh;
2481 //victim->bloodloss+=100*(6.5-findDistancefast(&coords,&victim->coords));
2482 victim->DoDamage(damagemult*0);
2484 XYZ footvel,footpoint;
2487 footpoint=(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position+victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position)/2*victim->scale+victim->coords;
2490 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;
2492 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
2493 footvel=DoRotation(facing,0,90,0)*.8;
2495 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2496 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
2497 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
2498 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
2502 if(victim->weaponactive!=-1){
2503 if(weapons.type[victim->weaponids[0]]==staff||weapons.type[weaponids[0]]==staff){
2504 if(weapons.type[victim->weaponids[0]]==staff)weapons.damage[victim->weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2505 if(weapons.type[weaponids[0]]==staff)weapons.damage[weaponids[0]]+=.2+float(abs(Random()%100)-50)/250;
2507 emit_sound_at(swordstaffsound, victim->coords);
2510 emit_sound_at(metalhitsound, victim->coords);
2516 victim->Puff(righthand);
2518 victim->targetframe=0;
2519 victim->targetanimation=staggerbackhighanim;
2520 victim->targetrotation=targetrotation+180;
2522 weapons.owner[victim->weaponids[0]]=-1;
2523 aim=DoRotation(facing,0,90,0)*21;
2525 weapons.velocity[victim->weaponids[0]]=aim*-.2;
2526 weapons.tipvelocity[victim->weaponids[0]]=aim;
2527 weapons.missed[victim->weaponids[0]]=1;
2528 weapons.hitsomething[weaponids[0]]=0;
2529 weapons.freetime[victim->weaponids[0]]=0;
2530 weapons.firstfree[victim->weaponids[0]]=1;
2531 weapons.physics[victim->weaponids[0]]=1;
2532 victim->num_weapons--;
2533 if(victim->num_weapons){
2534 victim->weaponids[0]=victim->weaponids[num_weapons];
2535 if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
2537 victim->weaponactive=-1;
2538 for(i=0;i<numplayers;i++){
2539 player[i].wentforweapon=0;
2546 if(targetanimation==staffhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
2547 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
2548 if(tutoriallevel!=1){
2549 weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/250;
2551 if(id==0)camerashake+=.4;
2552 if(Random()%2||creature==wolftype){
2555 emit_sound_at(staffheadsound, victim->coords);
2559 relative=victim->coords-coords;
2561 Normalise(&relative);
2562 relative=DoRotation(relative,0,90,0);
2564 Normalise(&relative);
2565 for(i=0;i<victim->skeleton.num_joints;i++){
2566 victim->skeleton.joints[i].velocity+=relative*damagemult*60;
2568 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*230;
2569 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*230;
2572 if(tutoriallevel!=1){
2573 victim->DoDamage(damagemult*120/victim->protectionhigh);
2575 award_bonus(id, solidhit, 30);
2580 if(targetanimation==staffspinhitanim&&animation[targetanimation].label[currentframe]==5&&victim->targetanimation!=rollanim){
2581 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5&&victim->targetanimation!=dodgebackanim&&victim->targetanimation!=sweepanim){
2582 if(tutoriallevel!=1){
2583 weapons.damage[weaponids[0]]+=.6+float(abs(Random()%100)-50)/250;
2585 if(id==0)camerashake+=.4;
2586 if(Random()%2||creature==wolftype){
2589 emit_sound_at(staffheadsound, victim->coords);
2593 relative=victim->coords-coords;
2595 Normalise(&relative);
2596 relative=DoRotation(relative,0,-90,0);
2597 for(i=0;i<victim->skeleton.num_joints;i++){
2598 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2600 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*220;
2601 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity+=relative*damagemult*220;
2604 if(tutoriallevel!=1){victim->DoDamage(damagemult*350/victim->protectionhead);
2606 award_bonus(id, solidhit, 60);
2611 if(targetanimation==staffgroundsmashanim&&animation[targetanimation].label[currentframe]==5){
2612 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*6.5){
2614 if(tutoriallevel!=1){
2615 if(!victim->dead)weapons.damage[weaponids[0]]+=.4+float(abs(Random()%100)-50)/500;
2616 if(id==0)camerashake+=.4;
2617 if(Random()%2||creature==wolftype){
2620 emit_sound_at(staffbodysound, victim->coords);
2622 victim->skeleton.longdead=0;
2623 victim->skeleton.free=1;
2624 victim->skeleton.broken=0;
2626 for(i=0;i<victim->skeleton.num_joints;i++){
2627 victim->skeleton.joints[i].velchange=0;
2628 victim->skeleton.joints[i].locked=0;
2629 //victim->skeleton.joints[i].velocity=0;
2635 /*relative=victim->coords-coords;
2637 Normalise(&relative);
2638 relative=DoRotation(relative,0,90,0);*/
2640 Normalise(&relative);
2642 for(i=0;i<victim->skeleton.num_joints;i++){
2643 victim->skeleton.joints[i].velocity=relative*damagemult*40;
2646 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*40;
2649 for(i=0;i<victim->skeleton.num_joints;i++){
2650 victim->skeleton.joints[i].velocity=relative*damagemult*abs(Random()%20);
2653 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2655 victim->Puff(abdomen);
2656 if(tutoriallevel!=1){victim->DoDamage(damagemult*100/victim->protectionhigh);
2659 award_bonus(id, solidhit, 40);
2665 if(targetanimation==lowkickanim&&animation[targetanimation].label[currentframe]==5){
2666 if(findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&animation[victim->targetanimation].height!=highheight){
2668 if(id==0)camerashake+=.4;
2670 relative=victim->coords-coords;
2672 Normalise(&relative);
2676 if(animation[victim->targetanimation].height==lowheight){
2682 for(i=0;i<victim->skeleton.num_joints;i++){
2683 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2685 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
2686 if(tutoriallevel!=1){
2687 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2690 victim->DoDamage(damagemult*100/victim->protectionhead);
2691 if(victim->howactive==typesleeping)victim->DoDamage(damagemult*150/victim->protectionhead);
2692 if(creature==wolftype){
2693 emit_sound_at(clawslicesound, victim->coords, 128.);
2695 victim->DoBloodBig(2/victim->armorhead,175);
2699 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
2700 for(i=0;i<victim->skeleton.num_joints;i++){
2701 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
2703 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2704 victim->targetframe=0;
2705 victim->targetanimation=staggerbackhighanim;
2706 victim->targetrotation=targetrotation+180;
2708 if(tutoriallevel!=1){
2709 emit_sound_at(landsound2, victim->coords, 128.);
2711 victim->Puff(abdomen);
2712 victim->DoDamage(damagemult*30/victim->protectionhigh);
2713 if(creature==wolftype){
2714 emit_sound_at(clawslicesound, victim->coords, 128.);
2716 victim->DoBloodBig(2/victim->armorhigh,170);
2723 if(targetanimation==sweepanim&&animation[targetanimation].label[currentframe]==5){
2724 if(victim->targetanimation!=jumpupanim&&findDistancefast(&coords,&victim->coords)<(scale*5)*(scale*5)*3&&victim!=this){
2726 if(id==0)camerashake+=.2;
2727 if(tutoriallevel!=1){
2728 emit_sound_at(landsound2, victim->coords, 128.);
2731 relative=victim->coords-coords;
2733 Normalise(&relative);
2735 if(animation[victim->targetanimation].height==middleheight||animation[victim->currentanimation].height==middleheight||victim->damage>=victim->damagetolerance-40){
2738 for(i=0;i<victim->skeleton.num_joints;i++){
2739 victim->skeleton.joints[i].velocity+=relative*damagemult*15;
2741 relative=DoRotation(relative,0,-90,0);
2743 for(i=0;i<victim->skeleton.num_joints;i++){
2744 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)
2745 victim->skeleton.joints[i].velocity=relative*80;
2747 victim->Puff(rightankle);
2748 victim->Puff(leftankle);
2749 victim->DoDamage(damagemult*40/victim->protectionlow);
2752 if(victim->damage>=victim->damagetolerance)victim->RagDoll(0);
2753 for(i=0;i<victim->skeleton.num_joints;i++){
2754 victim->skeleton.joints[i].velocity+=relative*damagemult*10;
2756 relative=DoRotation(relative,0,-90,0);
2757 for(i=0;i<victim->skeleton.num_joints;i++){
2758 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)
2759 victim->skeleton.joints[i].velocity+=relative*damagemult*80;
2761 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2762 victim->targetframe=0;
2763 victim->targetanimation=staggerbackhighanim;
2764 victim->targetrotation=targetrotation+180;
2766 if(tutoriallevel!=1){
2767 emit_sound_at(landsound2, victim->coords, 128.);
2769 victim->Puff(abdomen);
2770 victim->DoDamage(damagemult*30/victim->protectionlow);
2778 if(animation[targetanimation].attack==reversal&&(!victim->feint||(victim->lastattack==victim->lastattack2&&victim->lastattack2==victim->lastattack3&&Random()%2)||targetanimation==knifefollowanim)){
2779 if(targetanimation==spinkickreversalanim&&animation[targetanimation].label[currentframe]==7){
2781 if(id==0)camerashake+=.4;
2786 if(tutoriallevel!=1){
2787 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2789 if(creature==wolftype){
2790 emit_sound_at(clawslicesound, victim->coords, 128);
2792 victim->DoBloodBig(2/victim->armorhigh,170);
2796 relative=victim->coords-oldcoords;
2798 Normalise(&relative);
2799 //relative=DoRotation(relative,0,-90,0);
2800 for(i=0;i<victim->skeleton.num_joints;i++){
2801 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2803 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2805 victim->Puff(abdomen);
2806 victim->DoDamage(damagemult*150/victim->protectionhigh);
2808 award_bonus(id, Reversal);
2811 if((targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim)&&animation[targetanimation].label[currentframe]==5){
2812 if(victim->weaponactive!=-1&&victim->num_weapons>0){
2813 if(weapons.owner[victim->weaponids[victim->weaponactive]]==victim->id){
2814 weapons.owner[victim->weaponids[victim->weaponactive]]=id;
2817 weaponids[num_weapons]=weaponids[victim->weaponactive];
2820 weaponids[0]=victim->weaponids[victim->weaponactive];
2821 victim->num_weapons--;
2822 if(victim->num_weapons>0){
2823 victim->weaponids[victim->weaponactive]=victim->weaponids[victim->num_weapons];
2824 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
2826 victim->weaponactive=-1;
2831 if(targetanimation==staffhitreversalanim&&animation[targetanimation].label[currentframe]==5){
2833 if(id==0)camerashake+=.4;
2838 emit_sound_at(whooshhitsound, victim->coords, 128.);
2841 relative=victim->coords-oldcoords;
2843 Normalise(&relative);
2844 //relative=DoRotation(relative,0,-90,0);
2845 for(i=0;i<victim->skeleton.num_joints;i++){
2846 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2848 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2851 victim->DoDamage(damagemult*70/victim->protectionhigh);
2854 if(targetanimation==staffspinhitreversalanim&&animation[targetanimation].label[currentframe]==7){
2856 if(id==0)camerashake+=.4;
2862 award_bonus(id, staffreversebonus);
2864 if(tutoriallevel!=1){
2865 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2868 award_bonus(id, staffreversebonus); // Huh, again?
2871 relative=victim->coords-oldcoords;
2873 Normalise(&relative);
2874 //relative=DoRotation(relative,0,-90,0);
2875 for(i=0;i<victim->skeleton.num_joints;i++){
2876 victim->skeleton.joints[i].velocity+=relative*damagemult*30;
2878 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2881 victim->DoDamage(damagemult*70/victim->protectionhigh);
2884 if(targetanimation==upunchreversalanim&&animation[targetanimation].label[currentframe]==7){
2890 Normalise(&relative);
2893 for(i=0;i<victim->skeleton.num_joints;i++){
2894 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
2896 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1;
2897 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2;
2898 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5;
2899 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7;
2900 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1;
2901 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2;
2902 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5;
2903 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7;
2905 victim->Puff(abdomen);
2906 victim->DoDamage(damagemult*90/victim->protectionhigh);
2908 award_bonus(id, Reversal);
2912 if(weaponactive!=-1||creature==wolftype)doslice=1;
2913 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
2915 if(weaponactive!=-1){
2916 victim->DoBloodBig(2/victim->armorhigh,225);
2917 emit_sound_at(knifeslicesound, victim->coords);
2918 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
2919 weapons.blooddrip[weaponids[weaponactive]]+=3;
2921 if(weaponactive==-1&&creature==wolftype){;
2922 emit_sound_at(clawslicesound, victim->coords, 128.);
2924 victim->DoBloodBig(2/victim->armorhigh,175);
2931 if(targetanimation==swordslashreversalanim&&animation[targetanimation].label[currentframe]==7){
2937 Normalise(&relative);
2940 for(i=0;i<victim->skeleton.num_joints;i++){
2941 victim->skeleton.joints[i].velocity+=relative*damagemult*70;
2943 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity*=.1-1;
2944 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity*=.2-1;
2945 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity*=.5-1;
2946 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity*=.7-1;
2947 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity*=.1-1;
2948 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity*=.2-1;
2949 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity*=.5-1;
2950 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity*=.7-1;
2952 award_bonus(id, swordreversebonus);
2955 if(hasvictim&&targetanimation==knifeslashreversalanim&&animation[targetanimation].label[currentframe]==7){
2957 if(id==0)camerashake+=.4;
2962 if(tutoriallevel!=1){
2963 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2967 relative=victim->coords-oldcoords;
2969 Normalise(&relative);
2970 relative=DoRotation(relative,0,-90,0);
2971 for(i=0;i<victim->skeleton.num_joints;i++){
2972 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2974 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2976 victim->Puff(abdomen);
2977 victim->DoDamage(damagemult*30/victim->protectionhigh);
2979 award_bonus(id, Reversal);
2982 if(hasvictim&&targetanimation==sneakattackanim&&animation[targetanimation].label[currentframe]==7){
2985 victim->skeleton.spinny=0;
2989 Normalise(&relative);
2990 if(victim->id==0)relative/=30;
2991 for(i=0;i<victim->skeleton.num_joints;i++){
2992 victim->skeleton.joints[i].velocity+=relative*damagemult*40;
2994 //victim->DoDamage(1000);
2995 victim->damage=victim->damagetolerance;
2996 victim->permanentdamage=victim->damagetolerance-1;
2999 if(weaponactive!=-1||creature==wolftype)doslice=1;
3000 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3002 if(weaponactive!=-1){
3003 victim->DoBloodBig(200,225);
3004 emit_sound_at(knifeslicesound, victim->coords);
3005 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3006 weapons.blooddrip[weaponids[weaponactive]]+=5;
3009 if(creature==wolftype&&weaponactive==-1){
3010 emit_sound_at(clawslicesound, victim->coords, 128.);
3012 victim->DoBloodBig(2,175);
3015 award_bonus(id, spinecrusher);
3018 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3019 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3021 if(targetanimation==knifefollowanim)victim->DoBloodBig(200,210);
3022 if(targetanimation==knifesneakattackanim){
3023 /*victim->DoBloodBig(200,195);
3028 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3029 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,rotation,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3031 XYZ footvel,footpoint;
3033 footpoint=weapons.tippoint[weaponids[0]];
3034 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3035 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3036 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3037 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3038 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3039 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3040 victim->DoBloodBig(200,195);
3041 award_bonus(id, tracheotomy);
3043 if(targetanimation==knifefollowanim){
3044 award_bonus(id, Stabbonus);
3045 XYZ footvel,footpoint;
3047 footpoint=weapons.tippoint[weaponids[0]];
3048 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3049 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3050 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3051 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3052 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .2, 1);
3053 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .2, 1);
3056 victim->bloodloss+=10000;
3058 emit_sound_at(fleshstabsound, victim->coords);
3059 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3060 weapons.blooddrip[weaponids[weaponactive]]+=5;
3064 if(hasvictim&&(targetanimation==knifefollowanim||targetanimation==knifesneakattackanim)&&animation[targetanimation].label[currentframe]==6){
3067 for(i=0;i<victim->skeleton.num_joints;i++){
3068 victim->skeleton.joints[i].velocity=0;
3070 if(targetanimation==knifefollowanim){
3072 for(i=0;i<victim->skeleton.num_joints;i++){
3073 victim->skeleton.joints[i].velocity=0;
3076 if(weaponactive!=-1&&animation[victim->targetanimation].attack!=reversal){
3077 emit_sound_at(fleshstabremovesound, victim->coords);
3078 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3079 weapons.blooddrip[weaponids[weaponactive]]+=5;
3081 XYZ footvel,footpoint;
3083 footpoint=weapons.tippoint[weaponids[0]];
3084 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3085 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3086 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3087 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3088 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3089 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3093 if(hasvictim&&(targetanimation==swordsneakattackanim)&&animation[targetanimation].label[currentframe]==5){
3094 if(weaponactive!=-1&&victim->bloodloss<victim->damagetolerance){
3095 award_bonus(id, backstab);
3099 XYZ footvel,footpoint;
3101 footpoint=(weapons.tippoint[weaponids[0]]+weapons.position[weaponids[0]])/2;
3102 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3103 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]]);
3104 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3105 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3106 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*5,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3107 Sprite::MakeSprite(bloodflamesprite, footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .3, 1);
3108 victim->DoBloodBig(200,180);
3109 victim->DoBloodBig(200,215);
3110 victim->bloodloss+=10000;
3112 emit_sound_at(fleshstabsound, victim->coords);
3113 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3114 weapons.blooddrip[weaponids[weaponactive]]+=5;
3118 if(hasvictim&&targetanimation==swordsneakattackanim&&animation[targetanimation].label[currentframe]==6){
3121 for(i=0;i<victim->skeleton.num_joints;i++){
3122 victim->skeleton.joints[i].velocity=0;
3124 if(weaponactive!=-1){
3125 emit_sound_at(fleshstabremovesound, victim->coords);
3126 if(bloodtoggle)weapons.bloody[weaponids[weaponactive]]=2;
3127 weapons.blooddrip[weaponids[weaponactive]]+=5;
3129 XYZ footvel,footpoint;
3131 footpoint=weapons.tippoint[weaponids[0]];
3132 if(bloodtoggle)Sprite::MakeSprite(cloudimpactsprite, footpoint,footvel, 1,0,0, .9, .3);
3133 footvel=(weapons.tippoint[weaponids[0]]-weapons.position[weaponids[0]])*-1;
3134 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*7,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3135 Sprite::MakeSprite(bloodsprite,footpoint,DoRotation(footvel*3,(float)(Random()%20),(float)(Random()%20),0), 1,1,1, .05, .9);
3136 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*5, 1,1,1, .3, 1);
3137 Sprite::MakeSprite(bloodflamesprite, footpoint,footvel*2, 1,1,1, .3, 1);
3141 if(targetanimation==sweepreversalanim&&animation[targetanimation].label[currentframe]==7){
3143 if(id==0)camerashake+=.4;
3148 if(weaponactive==-1){
3149 if(tutoriallevel!=1){
3150 emit_sound_at(heavyimpactsound, victim->coords, 128.);
3155 if(weaponactive!=-1||creature==wolftype)doslice=1;
3156 if(creature==rabbittype&&weaponactive!=-1)if(weapons.type[weaponids[0]]==staff)doslice=0;
3158 if(weaponactive!=-1){
3159 victim->DoBloodBig(2/victim->armorhead,225);
3160 emit_sound_at(knifeslicesound, victim->coords);
3161 if(bloodtoggle&&!weapons.bloody[weaponids[weaponactive]])weapons.bloody[weaponids[weaponactive]]=1;
3162 weapons.blooddrip[weaponids[weaponactive]]+=3;
3164 if(weaponactive==-1&&creature==wolftype){
3165 emit_sound_at(clawslicesound, victim->coords, 128.);
3167 victim->DoBloodBig(2/victim->armorhead,175);
3171 award_bonus(id, Reversal);
3176 //relative=victim->coords-oldcoords;
3179 Normalise(&relative);
3180 relative=DoRotation(relative,0,90,0);
3182 Normalise(&relative);
3183 for(i=0;i<victim->skeleton.num_joints;i++){
3184 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
3186 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3187 if(victim->damage<victim->damagetolerance-100)victim->velocity=relative*200;
3188 victim->DoDamage(damagemult*100/victim->protectionhead);
3192 if(targetanimation==sweepreversalanim&&((animation[targetanimation].label[currentframe]==9&&victim->damage<victim->damagetolerance)||(animation[targetanimation].label[currentframe]==7&&victim->damage>victim->damagetolerance))){
3196 //relative=victim->coords-oldcoords;
3199 Normalise(&relative);
3200 relative=DoRotation(relative,0,90,0);
3202 Normalise(&relative);
3203 for(i=0;i<victim->skeleton.num_joints;i++){
3204 victim->skeleton.joints[i].velocity+=relative*damagemult*20;
3206 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity+=relative*damagemult*200;
3209 if(hasvictim&&(targetanimation==spinkickreversalanim||targetanimation==sweepreversalanim||targetanimation==rabbitkickreversalanim||targetanimation==upunchreversalanim||targetanimation==jumpreversalanim||targetanimation==swordslashreversalanim||targetanimation==knifeslashreversalanim||targetanimation==rabbittacklereversal||targetanimation==wolftacklereversal||targetanimation==staffhitreversalanim||targetanimation==staffspinhitreversalanim))
3210 if(victim->damage>victim->damagetolerance&&bonus!=reverseko){
3211 award_bonus(id, reverseko);
3217 if(targetframe>animation[currentanimation].numframes-1){
3220 targetanimation=getIdle();
3224 if(currentanimation==rabbittackleanim||currentanimation==rabbittacklinganim){
3225 targetanimation=rollanim;
3227 emit_sound_at(movewhooshsound, coords, 128.);
3229 if(currentanimation==staggerbackhighanim){
3230 targetanimation=getIdle();
3232 if(currentanimation==staggerbackhardanim){
3233 targetanimation=getIdle();
3235 if(currentanimation==removeknifeanim){
3236 targetanimation=getIdle();
3238 if(currentanimation==crouchremoveknifeanim){
3239 targetanimation=getCrouch();
3241 if(currentanimation==backhandspringanim){
3242 targetanimation=getIdle();
3244 if(currentanimation==dodgebackanim){
3245 targetanimation=getIdle();
3247 if(currentanimation==drawleftanim){
3248 targetanimation=getIdle();
3250 if(currentanimation==drawrightanim||currentanimation==crouchdrawrightanim){
3251 targetanimation=getIdle();
3252 if(currentanimation==crouchdrawrightanim){
3253 targetanimation=getCrouch();
3255 if(weaponactive==-1)weaponactive=0;
3256 else if(weaponactive==0){
3260 buffer=weaponids[0];
3261 weaponids[0]=weaponids[1];
3262 weaponids[1]=buffer;
3266 if(weaponactive==-1){
3267 emit_sound_at(knifesheathesound, coords, 128.);
3269 if(weaponactive!=-1){
3270 emit_sound_at(knifedrawsound, coords, 128.);
3273 if(currentanimation==rollanim){
3274 targetanimation=getCrouch();
3279 if(targetanimation==walljumprightkickanim){
3282 if(targetanimation==walljumpleftkickanim){
3285 targetanimation=jumpdownanim;
3287 if(currentanimation==climbanim){
3288 targetanimation=getCrouch();
3291 if(!isnormal(coords.x))
3302 if(targetanimation==rabbitkickreversalanim){
3303 targetanimation=getCrouch();
3306 if(targetanimation==jumpreversalanim){
3307 targetanimation=getCrouch();
3310 if(targetanimation==walljumprightanim||targetanimation==walljumpbackanim||targetanimation==walljumpfrontanim){
3311 if(attackkeydown&&targetanimation!=walljumpfrontanim){
3313 float closestdist=-1;
3316 for(i=0;i<numplayers;i++){
3317 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
3318 distance=findDistancefast(&player[i].coords,&coords);
3319 if(closestdist==-1||distance<closestdist){
3320 closestdist=distance;
3325 if(closestdist>0&&closest>=0&&closestdist<16){
3326 victim=&player[closest];
3327 targetanimation=walljumprightkickanim;
3329 XYZ rotatetarget=victim->coords-coords;
3330 Normalise(&rotatetarget);
3331 rotation=-asin(0-rotatetarget.x);
3333 if(rotatetarget.z<0)rotation=180-rotation;
3334 targettilt2=-asin(rotatetarget.y)*360/6.28;
3335 velocity=(victim->coords-coords)*4;
3340 if(targetanimation==walljumpbackanim){
3341 targetanimation=backflipanim;
3346 resume_stream(whooshsound);
3348 if(targetanimation==walljumprightanim){
3349 targetanimation=rightflipanim;
3353 velocity=DoRotation(facing,0,30,0)*-8;
3356 if(targetanimation==walljumpfrontanim){
3357 targetanimation=frontflipanim;
3359 //targetrotation-=180;
3365 resume_stream(whooshsound);
3367 if(targetanimation==walljumpleftanim){
3370 float closestdist=-1;
3373 for(i=0;i<numplayers;i++){
3374 if(id!=i&&player[i].coords.y<coords.y&&!player[i].skeleton.free){
3375 distance=findDistancefast(&player[i].coords,&coords);
3376 if(closestdist==-1||distance<closestdist){
3377 closestdist=distance;
3382 if(closestdist>0&&closest>=0&&closestdist<16){
3383 victim=&player[closest];
3384 targetanimation=walljumpleftkickanim;
3386 XYZ rotatetarget=victim->coords-coords;
3387 Normalise(&rotatetarget);
3388 rotation=-asin(0-rotatetarget.x);
3390 if(rotatetarget.z<0)rotation=180-rotation;
3391 targettilt2=-asin(rotatetarget.y)*360/6.28;
3392 velocity=(victim->coords-coords)*4;
3397 if(targetanimation!=walljumpleftkickanim){
3398 targetanimation=leftflipanim;
3402 velocity=DoRotation(facing,0,-30,0)*-8;
3406 resume_stream(whooshsound);
3408 if(targetanimation==sneakattackanim){
3409 float ycoords=oldcoords.y;
3410 currentanimation=getCrouch();
3411 targetanimation=getCrouch();
3414 targetrotation+=180;
3419 targetheadrotation+=180;
3421 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
3425 if(targetanimation==knifesneakattackanim||targetanimation==swordsneakattackanim){
3426 float ycoords=oldcoords.y;
3427 targetanimation=getIdle();
3429 if(onterrain)coords.y=terrain.getHeight(coords.x,coords.z);
3433 if(currentanimation==knifefollowanim){
3434 targetanimation=getIdle();
3437 if(animation[targetanimation].attack==reversal&¤tanimation!=sneakattackanim&¤tanimation!=knifesneakattackanim&¤tanimation!=swordsneakattackanim&¤tanimation!=knifefollowanim){
3438 float ycoords=oldcoords.y;
3439 targetanimation=getStop();
3440 targetrotation+=180;
3445 targetheadrotation+=180;
3446 if(!isnormal(coords.x))
3448 if(currentanimation==spinkickreversalanim||currentanimation==swordslashreversalanim)
3449 oldcoords=coords+facing*.5;
3450 else if(currentanimation==sweepreversalanim)
3451 oldcoords=coords+facing*1.1;
3452 else if(currentanimation==upunchreversalanim){
3453 oldcoords=coords+facing*1.5;
3454 targetrotation+=180;
3456 targetheadrotation+=180;
3460 else if(currentanimation==knifeslashreversalanim){
3461 oldcoords=coords+facing*.5;
3464 targetheadrotation+=90;
3468 else if(currentanimation==staffspinhitreversalanim){
3469 targetrotation+=180;
3471 targetheadrotation+=180;
3475 if(onterrain)oldcoords.y=terrain.getHeight(oldcoords.x,oldcoords.z);
3476 else oldcoords.y=ycoords;
3477 currentoffset=coords-oldcoords;
3483 if(currentanimation==knifesneakattackedanim||currentanimation==swordsneakattackedanim){
3488 if(animation[targetanimation].attack==reversed){
3490 if(targetanimation==sweepreversedanim)targetrotation+=90;
3491 targetanimation=backhandspringanim;
3493 emit_sound_at(landsound, coords, 128);
3495 if(currentanimation==upunchreversedanim||currentanimation==swordslashreversedanim){
3496 targetanimation=rollanim;
3499 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
3500 coords.y=oldcoords.y;
3502 if(currentanimation==knifeslashreversedanim){
3503 targetanimation=rollanim;
3508 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
3509 coords.y=oldcoords.y;
3513 targetanimation=jumpdownanim;
3515 if(wasLanding())targetanimation=getIdle();
3516 if(wasLandhard())targetanimation=getIdle();
3517 if(currentanimation==spinkickanim||currentanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==lowkickanim){
3518 targetanimation=getIdle();
3520 coords+=(DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)+DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0))/2*scale;
3521 coords.y=oldcoords.y;
3522 //coords+=DoRotation(animation[currentanimation].offset,0,rotation,0)*scale;
3523 targetoffset.y=coords.y;
3524 if(onterrain)targetoffset.y=terrain.getHeight(coords.x,coords.z);
3525 currentoffset=DoRotation(animation[currentanimation].offset*-1,0,rotation,0)*scale;
3526 currentoffset.y-=(coords.y-targetoffset.y);
3527 coords.y=targetoffset.y;
3529 normalsupdatedelay=0;
3531 if(currentanimation==upunchanim){
3532 targetanimation=getStop();
3533 normalsupdatedelay=0;
3536 if(currentanimation==rabbitkickanim&&targetanimation!=backflipanim){
3537 targetrotation=rotation;
3540 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
3541 if(!hasstaff)DoDamage(35);
3544 rabbitkickragdoll=1;
3546 if(currentanimation==rabbitkickreversedanim){
3553 SolidHitBonus(!id); // FIXME: tricky id
3557 targetanimation=rollanim;
3559 if(id==0)pause_sound(whooshsound);
3563 if(currentanimation==rabbittackledbackanim||currentanimation==rabbittackledfrontanim){
3569 if(currentanimation==jumpreversedanim){
3576 SolidHitBonus(!id); // FIXME: tricky id
3580 targetanimation=rollanim;
3582 if(id==0)pause_sound(whooshsound);
3587 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){
3588 targetanimation=getupfromfrontanim;
3591 else if(animation[currentanimation].attack==normalattack){
3592 targetanimation=getIdle();
3595 if(currentanimation==blockhighleftanim&&aitype!=playercontrolled){
3596 targetanimation=blockhighleftstrikeanim;
3598 if(currentanimation==knifeslashstartanim||currentanimation==knifethrowanim||currentanimation==swordslashanim||currentanimation==staffhitanim||currentanimation==staffgroundsmashanim||currentanimation==staffspinhitanim){
3599 targetanimation=getIdle();
3602 if(currentanimation==spinkickanim&&victim->skeleton.free){
3603 if(creature==rabbittype)targetanimation=fightidleanim;
3608 if(isIdle()&&!wasIdle())normalsupdatedelay=0;
3610 if(currentanimation==jumpupanim&&velocity.y<0&&!isFlip()){
3611 targetanimation=jumpdownanim;
3616 if(!transspeed&&animation[targetanimation].attack!=2&&animation[targetanimation].attack!=3){
3617 if(!isRun()||!wasRun()){
3618 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
3619 target+=multiplier*animation[targetanimation].speed[targetframe]*speed*2;
3620 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
3621 target+=multiplier*animation[currentanimation].speed[currentframe]*speed*2;
3623 if(isRun()&&wasRun()){
3626 if(tempspeed<10*speedmult)tempspeed=10*speedmult;
3627 target+=multiplier*animation[targetanimation].speed[currentframe]*speed*1.7*tempspeed/(speed*45*scale);
3630 else if(transspeed)target+=multiplier*transspeed*speed*2;
3632 if(!isRun()||!wasRun()){
3633 if(animation[targetanimation].speed[targetframe]>animation[currentanimation].speed[currentframe])
3634 target+=multiplier*animation[targetanimation].speed[targetframe]*2;
3635 if(animation[targetanimation].speed[targetframe]<=animation[currentanimation].speed[currentframe])
3636 target+=multiplier*animation[currentanimation].speed[currentframe]*2;
3640 if(currentanimation!=targetanimation)target=(target+oldtarget)/2;
3642 if(target>1){currentframe=targetframe; target=1;}
3644 rot=targetrot*target;
3645 rotation+=rot-oldrot;
3651 if(currentanimation!=oldcurrentanimation||targetanimation!=oldtargetanimation||((currentframe!=oldcurrentframe||targetframe!=oldtargetframe)&&!calcrot)){
3653 for(i=0;i<skeleton.num_joints;i++){
3654 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe];
3657 skeleton.FindForwards();
3659 for(i=0;i<skeleton.num_muscles;i++){
3660 if(skeleton.muscles[i].visible)
3662 skeleton.FindRotationMuscle(i,targetanimation);
3665 for(i=0;i<skeleton.num_muscles;i++){
3666 if(skeleton.muscles[i].visible)
3668 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].oldrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
3669 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].oldrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
3670 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].oldrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
3675 for(i=0;i<skeleton.num_joints;i++){
3676 skeleton.joints[i].position=animation[targetanimation].position[i][targetframe];
3679 skeleton.FindForwards();
3681 for(i=0;i<skeleton.num_muscles;i++){
3682 if(skeleton.muscles[i].visible)
3684 skeleton.FindRotationMuscle(i,targetanimation);
3687 for(i=0;i<skeleton.num_muscles;i++){
3688 if(skeleton.muscles[i].visible)
3690 if(isnormal((float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100))skeleton.muscles[i].newrotate1=(float)((int)(skeleton.muscles[i].rotate1*100)%36000)/100;
3691 if(isnormal((float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100))skeleton.muscles[i].newrotate2=(float)((int)(skeleton.muscles[i].rotate2*100)%36000)/100;
3692 if(isnormal((float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100))skeleton.muscles[i].newrotate3=(float)((int)(skeleton.muscles[i].rotate3*100)%36000)/100;
3693 if(skeleton.muscles[i].newrotate3>skeleton.muscles[i].oldrotate3+180)skeleton.muscles[i].newrotate3-=360;
3694 if(skeleton.muscles[i].newrotate3<skeleton.muscles[i].oldrotate3-180)skeleton.muscles[i].newrotate3+=360;
3695 if(skeleton.muscles[i].newrotate2>skeleton.muscles[i].oldrotate2+180)skeleton.muscles[i].newrotate2-=360;
3696 if(skeleton.muscles[i].newrotate2<skeleton.muscles[i].oldrotate2-180)skeleton.muscles[i].newrotate2+=360;
3697 if(skeleton.muscles[i].newrotate1>skeleton.muscles[i].oldrotate1+180)skeleton.muscles[i].newrotate1-=360;
3698 if(skeleton.muscles[i].newrotate1<skeleton.muscles[i].oldrotate1-180)skeleton.muscles[i].newrotate1+=360;
3702 if(currentframe>=animation[currentanimation].numframes)currentframe=animation[currentanimation].numframes-1;
3704 oldcurrentanimation=currentanimation;
3705 oldtargetanimation=targetanimation;
3706 oldtargetframe=targetframe;
3707 oldcurrentframe=currentframe;
3709 for(i=0;i<skeleton.num_joints;i++){
3710 skeleton.joints[i].velocity=(animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target)-skeleton.joints[i].position)/multiplier;
3711 skeleton.joints[i].position=animation[currentanimation].position[i][currentframe]*(1-target)+animation[targetanimation].position[i][targetframe]*(target);
3713 offset=currentoffset*(1-target)+targetoffset*target;
3714 for(i=0;i<skeleton.num_muscles;i++){
3715 if(skeleton.muscles[i].visible)
3717 skeleton.muscles[i].rotate1=skeleton.muscles[i].oldrotate1*(1-target)+skeleton.muscles[i].newrotate1*(target);
3718 skeleton.muscles[i].rotate2=skeleton.muscles[i].oldrotate2*(1-target)+skeleton.muscles[i].newrotate2*(target);
3719 skeleton.muscles[i].rotate3=skeleton.muscles[i].oldrotate3*(1-target)+skeleton.muscles[i].newrotate3*(target);
3724 if(isLanding()&&landhard){
3725 if(id==0)camerashake+=.4;
3726 targetanimation=getLandhard();
3733 //skeleton.DoConstraints();
3736 void Person::DoStuff(){
3737 static XYZ terrainnormal;
3738 static XYZ flatfacing;
3739 static XYZ flatvelocity;
3740 static float flatvelspeed;
3744 static int bloodsize;
3745 static int startx,starty,endx,endy;
3746 static int texdetailint;
3747 static GLubyte color;
3748 static XYZ bloodvel;
3750 onfiredelay-=multiplier;
3751 if(onfiredelay<0&&onfire)
3759 crouchkeydowntime+=multiplier;
3760 if(!crouchkeydown)crouchkeydowntime=0;
3761 jumpkeydowntime+=multiplier;
3762 if(!jumpkeydown&&skeleton.free)jumpkeydowntime=0;
3764 if(hostile||damage>0||bloodloss>0)immobile=0;
3766 if(isIdle()||isRun())targetoffset=0;
3768 if(num_weapons==1&&weaponactive!=-1)weaponstuck=-1;
3770 if(id==0)blooddimamount-=multiplier*.3;
3771 speechdelay-=multiplier;
3772 texupdatedelay-=multiplier;
3773 interestdelay-=multiplier;
3774 flamedelay-=multiplier;
3775 parriedrecently-=multiplier;
3781 if(id==0)speed=1.1*speedmult;
3782 else speed=1.0*speedmult;
3783 if(!skeleton.free)rabbitkickragdoll=0;
3787 if(id!=0&&(creature==rabbittype||difficulty!=2))superruntoggle=0;
3788 if(id!=0&&creature==wolftype&&difficulty==2){
3790 if(aitype!=passivetype){
3792 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){
3796 if(scale<0.2)superruntoggle=0;
3797 if(targetanimation==wolfrunninganim&&!superruntoggle){
3798 targetanimation=getRun();
3802 if(weaponactive==-1&&num_weapons>0){
3803 if(weapons.type[weaponids[0]]==staff){
3810 /*if(aitype!=playercontrolled)*///deathbleeding=5;
3811 /*if(aitype!=playercontrolled)*/
3813 if(burnt>.6)burnt=.6;
3814 OPENAL_SetVolume(channels[stream_firesound], 256+256*findLength(&velocity)/3);
3816 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
3827 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
3828 OPENAL_SetVolume(channels[whooshsound], 64*findLength(&velocity)/5);
3832 while(flamedelay<0&&onfire){
3834 howmany=abs(Random()%(skeleton.num_joints));
3835 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
3836 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
3837 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
3838 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
3839 Sprite::MakeSprite(flamesprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, 1);
3842 while(flamedelay<0&&!onfire&&tutoriallevel==1&&id!=0){
3844 howmany=abs(Random()%(skeleton.num_joints));
3845 if(!skeleton.free)flatvelocity=(coords-oldcoords)/multiplier/2;//velocity/2;
3846 if(skeleton.free)flatvelocity=skeleton.joints[howmany].velocity*scale/2;
3847 if(!skeleton.free)flatfacing=DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position,0,0,tilt),tilt2,0,0),0,rotation,0)*scale+coords;
3848 if(skeleton.free)flatfacing=skeleton.joints[howmany].position*scale+coords;
3849 Sprite::MakeSprite(breathsprite, flatfacing,flatvelocity, 1,1,1, .6+(float)abs(Random()%100)/200-.25, .3);
3853 bleeding-=multiplier*.3;
3855 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
3856 if(bleeding<=0&&(detail!=2||osx))DoMipmaps();
3860 if(neckspurtamount>0){
3861 neckspurtamount-=multiplier;
3862 neckspurtdelay-=multiplier*3;
3863 neckspurtparticledelay-=multiplier*3;
3864 if(neckspurtparticledelay<0&&neckspurtdelay>2){
3868 bloodvel.z=5*neckspurtamount;
3869 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
3872 bloodvel-=DoRotation(skeleton.forward*10*scale,((float)(Random()%100))/40,((float)(Random()%100))/40,0);
3874 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity,((float)(Random()%100))/40,rotation+((float)(Random()%100))/40,0)*scale;
3875 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/40,((float)(Random()%100))/40,0)*scale;
3876 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);
3877 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);
3878 neckspurtparticledelay=.05;
3880 if(neckspurtdelay<0){
3885 if(deathbleeding>0&&dead!=2){
3886 if(deathbleeding<5)bleeddelay-=deathbleeding*multiplier/4;
3887 else bleeddelay-=5*multiplier/4;
3888 if(bleeddelay<0&&bloodtoggle){
3893 if(skeleton.free)bloodvel+=DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity,((float)(Random()%100))/4,rotation+((float)(Random()%100))/4,0)*scale;
3894 if(!skeleton.free)bloodvel+=DoRotation(velocity,((float)(Random()%100))/4,((float)(Random()%100))/4,0)*scale;
3895 if(skeleton.free)Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position*scale+coords,bloodvel, 1,1,1, .05, 1);
3896 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);
3899 bloodloss+=deathbleeding*multiplier*80;
3900 deathbleeding-=multiplier*1.6;
3901 //if(id==0)deathbleeding-=multiplier*.2;
3902 if(deathbleeding<0)deathbleeding=0;
3903 if(bloodloss>damagetolerance&&animation[targetanimation].attack==neutral){
3904 if(weaponactive!=-1){
3905 weapons.owner[weaponids[0]]=-1;
3906 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
3907 weapons.velocity[weaponids[0]].x+=.01;
3908 weapons.tipvelocity[weaponids[0]]=velocity*scale;
3909 weapons.missed[weaponids[0]]=1;
3910 weapons.hitsomething[weaponids[0]]=0;
3911 weapons.freetime[weaponids[0]]=0;
3912 weapons.firstfree[weaponids[0]]=1;
3913 weapons.physics[weaponids[0]]=1;
3916 weaponids[0]=weaponids[num_weapons];
3917 if(weaponstuck==num_weapons)weaponstuck=0;
3920 for(i=0;i<numplayers;i++){
3921 player[i].wentforweapon=0;
3933 if(!dead&&creature==wolftype){
3934 award_bonus(0, Wolfbonus);
3937 if(targetanimation==knifefollowedanim&&!skeleton.free){
3938 for(i=0;i<skeleton.num_joints;i++){
3939 skeleton.joints[i].velocity=0;
3940 skeleton.joints[i].velocity.y=-2;
3943 if(id!=0&&unconscioustime>.1){
3951 if(texupdatedelay<0&&bleeding>0&&bloodtoggle==2&&findDistancefast(&viewer,&coords)<9){
3954 bloodsize=5-realtexdetail;
3958 texdetailint=realtexdetail;
3959 startx=bleedy;//abs(Random()%(skeleton.skinsize-bloodsize-1));
3960 starty=bleedx;//abs(Random()%(skeleton.skinsize-bloodsize-1));
3961 endx=startx+bloodsize;
3962 endy=starty+bloodsize;
3964 if(startx<0){startx=0;bleeding=0;}
3965 if(starty<0){starty=0;bleeding=0;}
3966 if(endx>skeleton.skinsize-1){endx=skeleton.skinsize-1;bleeding=0;}
3967 if(endy>skeleton.skinsize-1){endy=skeleton.skinsize-1;bleeding=0;}
3968 if(endx<startx)endx=startx;
3969 if(endy<starty)endy=starty;
3971 for(i=startx;i<endx;i++){
3972 for(j=starty;j<endy;j++){
3974 color=Random()%85+170;
3975 if(skeleton.skinText[i*skeleton.skinsize*3+j*3+0]>color/2)skeleton.skinText[i*skeleton.skinsize*3+j*3+0]=color/2;
3976 skeleton.skinText[i*skeleton.skinsize*3+j*3+1]=0;
3977 skeleton.skinText[i*skeleton.skinsize*3+j*3+2]=0;
3982 glBindTexture(GL_TEXTURE_2D,skeleton.drawmodel.textureptr);
3987 bleedy-=4/realtexdetail;
3988 if(detail==2)bleedx+=(abs(Random()%3)-1)*2/realtexdetail;
3989 else bleedx+=(abs(Random()%3)-1)*4/realtexdetail;
3992 bleedx+=4*direction/realtexdetail;
3993 if(detail==2)bleedy+=(abs(Random()%3)-1)*2/realtexdetail;
3994 else bleedy+=(abs(Random()%3)-1)*4/realtexdetail;
3998 if(abs(righthandmorphness-targetrighthandmorphness)<multiplier*4){
3999 righthandmorphness=targetrighthandmorphness;
4000 righthandmorphstart=righthandmorphend;
4002 else if(righthandmorphness>targetrighthandmorphness){
4003 righthandmorphness-=multiplier*4;
4005 else if(righthandmorphness<targetrighthandmorphness){
4006 righthandmorphness+=multiplier*4;
4009 if(abs(lefthandmorphness-targetlefthandmorphness)<multiplier*4){
4010 lefthandmorphness=targetlefthandmorphness;
4011 lefthandmorphstart=lefthandmorphend;
4013 else if(lefthandmorphness>targetlefthandmorphness){
4014 lefthandmorphness-=multiplier*4;
4016 else if(lefthandmorphness<targetlefthandmorphness){
4017 lefthandmorphness+=multiplier*4;
4020 if(creature==rabbittype||targettailmorphness==5||targettailmorphness==0){
4021 if(abs(tailmorphness-targettailmorphness)<multiplier*10){
4022 tailmorphness=targettailmorphness;
4023 tailmorphstart=tailmorphend;
4025 else if(tailmorphness>targettailmorphness){
4026 tailmorphness-=multiplier*10;
4028 else if(tailmorphness<targettailmorphness){
4029 tailmorphness+=multiplier*10;
4033 if(creature==wolftype){
4034 if(abs(tailmorphness-targettailmorphness)<multiplier*4){
4035 tailmorphness=targettailmorphness;
4036 tailmorphstart=tailmorphend;
4038 else if(tailmorphness>targettailmorphness){
4039 tailmorphness-=multiplier*2;
4041 else if(tailmorphness<targettailmorphness){
4042 tailmorphness+=multiplier*2;
4046 if(headmorphend==3||headmorphstart==3){
4047 if(abs(headmorphness-targetheadmorphness)<multiplier*7){
4048 headmorphness=targetheadmorphness;
4049 headmorphstart=headmorphend;
4051 else if(headmorphness>targetheadmorphness){
4052 headmorphness-=multiplier*7;
4054 else if(headmorphness<targetheadmorphness){
4055 headmorphness+=multiplier*7;
4058 else if(headmorphend==5||headmorphstart==5){
4059 if(abs(headmorphness-targetheadmorphness)<multiplier*10){
4060 headmorphness=targetheadmorphness;
4061 headmorphstart=headmorphend;
4063 else if(headmorphness>targetheadmorphness){
4064 headmorphness-=multiplier*10;
4066 else if(headmorphness<targetheadmorphness){
4067 headmorphness+=multiplier*10;
4071 if(abs(headmorphness-targetheadmorphness)<multiplier*4){
4072 headmorphness=targetheadmorphness;
4073 headmorphstart=headmorphend;
4075 else if(headmorphness>targetheadmorphness){
4076 headmorphness-=multiplier*4;
4078 else if(headmorphness<targetheadmorphness){
4079 headmorphness+=multiplier*4;
4083 if(abs(chestmorphness-targetchestmorphness)<multiplier){
4084 chestmorphness=targetchestmorphness;
4085 chestmorphstart=chestmorphend;
4087 else if(chestmorphness>targetchestmorphness){
4088 chestmorphness-=multiplier;
4090 else if(chestmorphness<targetchestmorphness){
4091 chestmorphness+=multiplier;
4094 if(dead!=2&&howactive<=typesleeping){
4095 if(chestmorphstart==0&&chestmorphend==0){
4097 targetchestmorphness=1;
4100 if(chestmorphstart!=0&&chestmorphend!=0){
4102 targetchestmorphness=1;
4104 if(environment==snowyenvironment){
4107 if(!skeleton.free)footvel=DoRotation(skeleton.specialforward[0],0,rotation,0)*-1;
4108 if(skeleton.free)footvel=skeleton.specialforward[0]*-1;
4109 if(!skeleton.free)footpoint=DoRotation((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2,0,rotation,0)*scale+coords;
4110 if(skeleton.free)footpoint=((skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2)*scale+coords;
4111 if(targetanimation==sleepanim)footvel=DoRotation(footvel,0,90,0);
4112 Sprite::MakeSprite(breathsprite, footpoint+footvel*.2,footvel*.4, 1,1,1, .4, .3);
4116 if(!dead&&howactive<typesleeping){
4117 blinkdelay-=multiplier*2;
4118 if(headmorphstart==0&&headmorphend==0&&blinkdelay<=0){
4120 targetheadmorphness=1;
4122 blinkdelay=(float)(abs(Random()%40))/5;
4124 if(headmorphstart==3&&headmorphend==3){
4126 targetheadmorphness=1;
4131 twitchdelay-=multiplier*1.5;
4132 if(targetanimation!=hurtidleanim){
4133 if(headmorphstart==0&&headmorphend==0&&twitchdelay<=0){
4135 targetheadmorphness=1;
4137 twitchdelay=(float)(abs(Random()%40))/5;
4139 if(headmorphstart==5&&headmorphend==5){
4141 targetheadmorphness=1;
4145 if((isIdle()||isCrouch())&&targetanimation!=hurtidleanim){
4146 twitchdelay3-=multiplier*1;
4148 if(righthandmorphstart==0&&righthandmorphend==0&&twitchdelay3<=0){
4149 righthandmorphness=0;
4150 targetrighthandmorphness=1;
4151 righthandmorphend=1;
4152 if(Random()%2==0)twitchdelay3=(float)(abs(Random()%40))/5;
4154 if(righthandmorphstart==1&&righthandmorphend==1){
4155 righthandmorphness=0;
4156 targetrighthandmorphness=1;
4157 righthandmorphend=0;
4161 if(lefthandmorphstart==0&&lefthandmorphend==0&&twitchdelay3<=0){
4162 lefthandmorphness=0;
4163 targetlefthandmorphness=1;
4165 twitchdelay3=(float)(abs(Random()%40))/5;
4167 if(lefthandmorphstart==1&&lefthandmorphend==1){
4168 lefthandmorphness=0;
4169 targetlefthandmorphness=1;
4176 if(creature==rabbittype){
4177 if(howactive<typesleeping)twitchdelay2-=multiplier*1.5;
4178 else twitchdelay2-=multiplier*0.5;
4179 if(howactive<=typesleeping){
4180 if(tailmorphstart==0&&tailmorphend==0&&twitchdelay2<=0){
4182 targettailmorphness=1;
4184 twitchdelay2=(float)(abs(Random()%40))/5;
4186 if(tailmorphstart==1&&tailmorphend==1){
4188 targettailmorphness=1;
4191 if(tailmorphstart==2&&tailmorphend==2){
4193 targettailmorphness=1;
4200 if(creature==wolftype){
4201 twitchdelay2-=multiplier*1.5;
4203 if((isRun()||targetanimation==jumpupanim||targetanimation==jumpdownanim||targetanimation==backflipanim)&&!skeleton.free){
4205 targettailmorphness=1;
4210 if(targetanimation==flipanim||targetanimation==frontflipanim||targetanimation==rollanim||skeleton.free){
4212 targettailmorphness=1;
4216 if(twitchdelay2<=0){
4217 if(((tailmorphstart==0&&tailmorphend==0)||(tailmorphstart==5&&tailmorphend==5))){
4219 targettailmorphness=1;
4222 if(tailmorphstart==1&&tailmorphend==1){
4224 targettailmorphness=1;
4227 if(tailmorphstart==2&&tailmorphend==2){
4229 targettailmorphness=1;
4232 if(tailmorphstart==3&&tailmorphend==3){
4234 targettailmorphness=1;
4237 if(tailmorphstart==4&&tailmorphend==4){
4239 targettailmorphness=1;
4245 if(dead!=1)unconscioustime=0;
4247 if(dead==1||howactive==typesleeping){
4248 unconscioustime+=multiplier;
4249 //If unconscious, close eyes and mouth
4250 if(righthandmorphend!=0)righthandmorphness=0;
4251 righthandmorphend=0;
4252 targetrighthandmorphness=1;
4254 if(lefthandmorphend!=0)lefthandmorphness=0;
4256 targetlefthandmorphness=1;
4258 if(headmorphend!=3&&headmorphend!=5)headmorphness=0;
4260 targetheadmorphness=1;
4264 if(howactive>typesleeping){
4267 if(bloodtoggle&&!bled){
4268 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
4270 if(bloodtoggle&&!bled)
4271 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
4272 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
4273 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
4277 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
4282 if(dead==2||howactive>typesleeping){
4283 //If dead, open mouth and hands
4284 if(righthandmorphend!=0)righthandmorphness=0;
4285 righthandmorphend=0;
4286 targetrighthandmorphness=1;
4288 if(lefthandmorphend!=0)lefthandmorphness=0;
4290 targetlefthandmorphness=1;
4292 if(headmorphend!=2)headmorphness=0;
4294 targetheadmorphness=1;
4297 if(stunned>0&&!dead&&headmorphend!=2){
4298 if(headmorphend!=4)headmorphness=0;
4300 targetheadmorphness=1;
4303 if(damage>damagetolerance&&!dead){
4308 if(creature==wolftype){
4309 award_bonus(0, Wolfbonus);
4314 if(weaponactive!=-1){
4315 weapons.owner[weaponids[0]]=-1;
4316 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4317 weapons.velocity[weaponids[0]].x+=.01;
4318 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4319 weapons.missed[weaponids[0]]=1;
4320 weapons.hitsomething[weaponids[0]]=0;
4321 weapons.freetime[weaponids[0]]=0;
4322 weapons.firstfree[weaponids[0]]=1;
4323 weapons.physics[weaponids[0]]=1;
4326 weaponids[0]=weaponids[num_weapons];
4327 if(weaponstuck==num_weapons)weaponstuck=0;
4330 for(i=0;i<numplayers;i++){
4331 player[i].wentforweapon=0;
4337 if((id==0||findDistancefast(&coords,&viewer)<50)&&autoslomo){
4345 //if(dead)damage-=multiplier/4;
4346 if(!dead)damage-=multiplier*13;
4347 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
4348 if(!dead)permanentdamage-=multiplier*4;
4349 if(isIdle()||isCrouch()){
4350 if(!dead)permanentdamage-=multiplier*4;
4351 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
4353 if(damage<0)damage=0;
4354 if(permanentdamage<0)permanentdamage=0;
4355 if(superpermanentdamage<0)superpermanentdamage=0;
4356 if(permanentdamage<superpermanentdamage){
4357 permanentdamage=superpermanentdamage;
4359 if(damage<permanentdamage){
4360 damage=permanentdamage;
4362 if(dead==1&&damage<damagetolerance){
4366 for(i=0;i<skeleton.num_joints;i++){
4367 skeleton.joints[i].velocity=0;
4370 if(permanentdamage>damagetolerance&&dead!=2){
4373 if(weaponactive!=-1){
4374 weapons.owner[weaponids[0]]=-1;
4375 weapons.velocity[weaponids[0]]=velocity*scale*-.3;
4376 weapons.velocity[weaponids[0]].x+=.01;
4377 weapons.tipvelocity[weaponids[0]]=velocity*scale;
4378 weapons.missed[weaponids[0]]=1;
4379 weapons.hitsomething[weaponids[0]]=0;
4380 weapons.freetime[weaponids[0]]=0;
4381 weapons.firstfree[weaponids[0]]=1;
4382 weapons.physics[weaponids[0]]=1;
4385 weaponids[0]=weaponids[num_weapons];
4386 if(weaponstuck==num_weapons)weaponstuck=0;
4389 for(i=0;i<numplayers;i++){
4390 player[i].wentforweapon=0;
4396 if(!dead&&creature==wolftype){
4397 award_bonus(0, Wolfbonus);
4400 if(unconscioustime<.1&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=FinishedBonus||bonustime>1)&&bloodloss<damagetolerance)
4401 award_bonus(id, touchofdeath);
4402 if(id!=0&&unconscioustime>.1){
4410 emit_sound_at(breaksound, coords);
4413 if(skeleton.free==1){
4414 if(id==0)pause_sound(whooshsound);
4417 //If knocked over, open hands and close mouth
4418 if(righthandmorphend!=0)righthandmorphness=0;
4419 righthandmorphend=0;
4420 targetrighthandmorphness=1;
4422 if(lefthandmorphend!=0)lefthandmorphness=0;
4424 targetlefthandmorphness=1;
4426 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5){
4427 if(headmorphend!=0)headmorphness=0;
4429 targetheadmorphness=1;
4433 skeleton.DoGravity(&scale);
4435 damageamount=skeleton.DoConstraints(&coords,&scale)*5;
4436 if(damage>damagetolerance-damageamount&&!dead&&(bonus!=spinecrusher||bonustime>1)&&(bonus!=style||bonustime>1)&&(bonus!=cannon||bonustime>1))
4437 award_bonus(id, deepimpact);
4438 DoDamage(damageamount/((protectionhigh+protectionhead+protectionlow)/3));
4442 for(j=0;j<skeleton.num_joints;j++){
4443 average+=skeleton.joints[j].position;
4447 coords+=average*scale;
4448 for(j=0;j<skeleton.num_joints;j++){
4449 skeleton.joints[j].position-=average;
4451 average/=multiplier;
4453 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
4455 for(i=0;i<skeleton.num_joints;i++){
4456 velocity+=skeleton.joints[i].velocity*scale;
4458 velocity/=skeleton.num_joints;
4460 if(!isnormal(velocity.x)&&velocity.x){
4473 if(findLength(&average)<10&&dead&&skeleton.free){
4474 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
4475 if(skeleton.longdead>2000){
4476 if(skeleton.longdead>6000){
4477 if(id==0)pause_sound(whooshsound);
4482 if(dead==2&&bloodloss<damagetolerance){
4484 headpoint=(skeleton.joints[skeleton.jointlabels[head]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
4486 if(bloodtoggle&&!bled){
4487 terrain.MakeDecal(blooddecal,headpoint,.2*1.2,.5,0);
4489 if(bloodtoggle&&!bled)
4490 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
4491 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
4492 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
4496 objects.model[j].MakeDecal(blooddecal,&point,&size,&opacity,&rotation);
4500 if(dead==2&&bloodloss>=damagetolerance){
4502 headpoint=(skeleton.joints[skeleton.jointlabels[abdomen]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2*scale+coords;
4503 if(bleeding<=0)DoBlood(1,255);
4504 if(bloodtoggle&&!bled){
4505 terrain.MakeDecal(blooddecalslow,headpoint,.8,.5,0);
4507 if(bloodtoggle&&!bled)
4508 for(l=0;l<terrain.patchobjectnum[whichpatchx][whichpatchz];l++){
4509 j=terrain.patchobjects[whichpatchx][whichpatchz][l];
4510 XYZ point=DoRotation(headpoint-objects.position[j],0,-objects.rotation[j],0);
4514 objects.model[j].MakeDecal(blooddecalslow,&point,&size,&opacity,&rotation);
4521 if(!dead&&crouchkeydown&&skeleton.freetime>.5&&id==0&&skeleton.free){
4523 XYZ startpoint,endpoint,colpoint,colviewer,coltarget;
4527 if(terrain.lineTerrain(startpoint,endpoint,&colpoint)!=-1)canrecover=0;
4528 if(velocity.y<-30)canrecover=0;
4529 for(i=0;i<objects.numobjects;i++){
4530 if(objects.type[i]!=treeleavestype&&objects.type[i]!=bushtype&&objects.type[i]!=firetype){
4531 colviewer=startpoint;
4533 if(objects.model[i].LineCheck(&colviewer,&coltarget,&colpoint,&objects.position[i],&objects.rotation[i])!=-1)canrecover=0;
4541 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4542 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
4543 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4544 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4546 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4547 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4548 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4550 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4551 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4552 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
4554 Normalise(&terrainnormal);
4556 targetrotation=-asin(0-terrainnormal.x);
4557 targetrotation*=360/6.28;
4558 if(terrainnormal.z<0)targetrotation=180-targetrotation;
4559 rotation=targetrotation;
4563 targetanimation=flipanim;
4564 crouchtogglekeydown=1;
4569 currentanimation=tempanim;
4572 //tilt2=targettilt2;
4574 //if(middle.y>0)targetoffset.y=middle.y+1;
4576 for(i=0;i<skeleton.num_joints;i++){
4577 tempanimation.position[i][0]=skeleton.joints[i].position;
4578 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
4583 if(findLength(&average)<10&&!dead&&skeleton.free){
4584 skeleton.longdead+=(2000-findLength(&average))*multiplier+multiplier;
4585 if(skeleton.longdead>(damage+500)*1.5){
4586 if(id==0)pause_sound(whooshsound);
4592 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4593 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[abdomen]].locked){
4594 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[abdomen]].position;
4595 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4597 if(skeleton.joints[skeleton.jointlabels[abdomen]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4598 terrainnormal=skeleton.joints[skeleton.jointlabels[abdomen]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4599 middle=(skeleton.joints[skeleton.jointlabels[neck]].position+skeleton.joints[skeleton.jointlabels[abdomen]].position)/2;
4601 if(skeleton.joints[skeleton.jointlabels[groin]].locked&&skeleton.joints[skeleton.jointlabels[neck]].locked){
4602 terrainnormal=skeleton.joints[skeleton.jointlabels[groin]].position-skeleton.joints[skeleton.jointlabels[neck]].position;
4603 middle=(skeleton.joints[skeleton.jointlabels[groin]].position+skeleton.joints[skeleton.jointlabels[neck]].position)/2;
4605 Normalise(&terrainnormal);
4607 targetrotation=-asin(0-terrainnormal.x);
4608 targetrotation*=360/6.28;
4609 if(terrainnormal.z<0)targetrotation=180-targetrotation;
4610 rotation=targetrotation;
4613 terrainnormal=terrain.getNormal(coords.x,coords.z);
4614 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
4618 /*XYZ otherterrainnormal;
4619 otherterrainnormal=terrain.getNormal(coords.x,coords.y);
4620 otherterrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
4621 if(abs(terrainnormal.y)<abs(otherterrainnormal.y))terrainnormal.y=fast_sqrt(otherterrainnormal.x*otherterrainnormal.x+otherterrainnormal.z*otherterrainnormal.z)*-1;
4622 targettilt2=asin(otherterrainnormal.y)*180/3.14;
4625 targettilt2=asin(terrainnormal.y)*180/3.14*-1;
4629 if(skeleton.forward.y<0){
4630 targetanimation=getupfrombackanim;
4634 if(skeleton.forward.y>-.3){
4635 targetanimation=getupfromfrontanim;
4637 targetrotation+=180;
4643 if((Random()%8==0&&id!=0&&creature==rabbittype)||(Random()%2==0&&id!=0&&creature==wolftype)||(id==0&&crouchkeydown&&(forwardkeydown||backkeydown||leftkeydown||rightkeydown))){
4644 targetanimation=rollanim;
4645 targetrotation=lookrotation;
4649 if(forwardkeydown)targetrotation+=45;
4650 if(backkeydown)targetrotation-=45;
4654 if(forwardkeydown)targetrotation-=45;
4655 if(backkeydown)targetrotation+=45;
4658 if ( !leftkeydown&&!rightkeydown)
4659 targetrotation+=180;
4661 targetrotation+=180;
4665 if(abs(targettilt2)>50)targettilt2=0;
4666 currentanimation=tempanim;
4671 if(middle.y>0&&targetanimation!=rollanim)targetoffset.y=middle.y+1;
4673 for(i=0;i<skeleton.num_joints;i++){
4674 tempanimation.position[i][0]=skeleton.joints[i].position;
4675 tempanimation.position[i][0]=DoRotation(tempanimation.position[i][0],0,-rotation,0);
4682 if(num_weapons>0)if(weapons.type[0]==staff)hasstaff=1;
4683 if(!skeleton.freefall&&freefall&&((jumpkeydown&&jumpkeydowntime<.2)||(hasstaff&&rabbitkickragdoll))&&!dead){
4686 tempvelocity=velocity;
4687 Normalise(&tempvelocity);
4688 targetrotation=-asin(0-tempvelocity.x);
4689 targetrotation*=360/6.28;
4690 if(velocity.z<0)targetrotation=180-targetrotation;
4691 //targetrotation+=180;
4694 if(dotproduct(&skeleton.forward,&tempvelocity)<0){
4695 targetanimation=rollanim;
4699 targetanimation=backhandspringanim;
4700 targetrotation+=180;
4705 emit_sound_at(movewhooshsound, coords, 128.);
4707 currentanimation=targetanimation;
4708 currentframe=targetframe-1;
4713 rotation=targetrotation;
4720 if(skeleton.freefall==0)freefall=0;
4722 if(!isnormal(velocity.x)&&velocity.x){
4727 if(aitype!=passivetype||skeleton.free==1)
4728 if(findLengthfast(&velocity)>.1)
4729 for(i=0;i<objects.numobjects;i++){
4730 if(objects.type[i]==firetype)
4731 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){
4733 if(!objects.onfire[i]){
4734 emit_sound_at(firestartsound, objects.position[i]);
4736 objects.onfire[i]=1;
4739 if(objects.onfire[i]){
4744 if(objects.type[i]==bushtype)
4745 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){
4747 if(!objects.onfire[i]){
4748 emit_sound_at(firestartsound, objects.position[i]);
4750 objects.onfire[i]=1;
4754 if(objects.onfire[i]){
4758 if(objects.messedwith[i]<=0){
4762 emit_sound_at(bushrustle, coords, 40*findLength(&velocity));
4765 envsound[numenvsounds]=coords;
4766 envsoundvol[numenvsounds]=4*findLength(&velocity);
4767 envsoundlife[numenvsounds]=.4;
4772 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
4773 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
4775 if(environment!=desertenvironment)
4776 for(j=0;j<howmany;j++){
4777 tempvel.x=float(abs(Random()%100)-50)/20;
4778 tempvel.y=float(abs(Random()%100)-50)/20;
4779 tempvel.z=float(abs(Random()%100)-50)/20;
4782 pos.x+=float(abs(Random()%100)-50)/200;
4783 pos.y+=float(abs(Random()%100)-50)/200;
4784 pos.z+=float(abs(Random()%100)-50)/200;
4785 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);
4786 Sprite::setLastSpriteSpecial(1);
4788 howmany=findLength(&velocity)*4;
4790 if(environment==snowyenvironment)
4791 for(j=0;j<howmany;j++){
4792 tempvel.x=float(abs(Random()%100)-50)/20;
4793 tempvel.y=float(abs(Random()%100)-50)/20;
4794 tempvel.z=float(abs(Random()%100)-50)/20;
4797 pos.x+=float(abs(Random()%100)-50)/200;
4798 pos.y+=float(abs(Random()%100)-50)/200;
4799 pos.z+=float(abs(Random()%100)-50)/200;
4800 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
4801 Sprite::setLastSpriteSpecial(2);
4804 objects.rotx[i]+=velocity.x*multiplier*6;
4805 objects.roty[i]+=velocity.z*multiplier*6;
4806 objects.messedwith[i]=.5;
4809 if(objects.type[i]==treeleavestype&&environment!=desertenvironment){
4810 if(objects.rotation2[i]==0)tempcoord=coords;
4812 tempcoord=coords-objects.position[i];
4813 tempcoord=DoRotation(tempcoord,0,-objects.rotation[i],0);
4814 tempcoord=DoRotation(tempcoord,-objects.rotation2[i],0,0);
4815 tempcoord+=objects.position[i];
4817 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]){
4818 if(objects.messedwith[i]<=0){
4822 emit_sound_at(bushrustle, coords, 40*findLength(&velocity));
4825 envsound[numenvsounds]=coords;
4826 envsoundvol[numenvsounds]=4*findLength(&velocity);
4827 envsoundlife[numenvsounds]=.4;
4832 if(environment==grassyenvironment)howmany=findLength(&velocity)*4;
4833 if(environment==snowyenvironment)howmany=findLength(&velocity)*2;
4835 if(environment!=desertenvironment)
4836 for(j=0;j<howmany;j++){
4837 tempvel.x=float(abs(Random()%100)-50)/20;
4838 tempvel.y=float(abs(Random()%100)-50)/20;
4839 tempvel.z=float(abs(Random()%100)-50)/20;
4843 pos.x+=float(abs(Random()%100)-50)/150;
4844 pos.y+=float(abs(Random()%100)-50)/150;
4845 pos.z+=float(abs(Random()%100)-50)/150;
4846 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);
4847 Sprite::setLastSpriteSpecial(1);
4849 howmany=findLength(&velocity)*4;
4851 if(environment==snowyenvironment)
4852 for(j=0;j<howmany;j++){
4853 tempvel.x=float(abs(Random()%100)-50)/20;
4854 tempvel.y=float(abs(Random()%100)-50)/20;
4855 tempvel.z=float(abs(Random()%100)-50)/20;
4859 pos.x+=float(abs(Random()%100)-50)/150;
4860 pos.y+=float(abs(Random()%100)-50)/150;
4861 pos.z+=float(abs(Random()%100)-50)/150;
4862 Sprite::MakeSprite(splintersprite, pos,tempvel*.3+velocity*float(abs(Random()%100))/100/2, 1,1,1, .1, 1);
4863 Sprite::setLastSpriteSpecial(2);
4866 objects.messedwith[i]=.5;
4874 if((stunned>0||surprised>0)&&numplayers>2&&aitype!=passivetype)play=1;
4876 if(aitype!=passivetype&&victim->skeleton.free&&!victim->dead)play=1;
4877 if(tutoriallevel==1&&id!=0)play=0;
4878 if(play&&aitype!=playercontrolled){
4882 if(creature==rabbittype){
4883 if(i==0)whichsound=rabbitchitter;
4884 if(i==1)whichsound=rabbitchitter2;
4886 if(creature==wolftype){
4887 if(i==0)whichsound=growlsound;
4888 if(i==1)whichsound=growl2sound;
4894 emit_sound_at(whichsound, coords);
4898 if(targetanimation==staggerbackhighanim)staggerdelay=1;
4899 if(targetanimation==staggerbackhardanim)staggerdelay=1;
4900 staggerdelay-=multiplier;
4901 if(targetanimation!=crouchstabanim&&targetanimation!=swordgroundstabanim&&targetanimation!=staffgroundsmashanim)hasvictim=1;
4902 if(velocity.y<-30&&targetanimation==jumpdownanim)RagDoll(0);
4903 if(currentanimation!=getIdle()&&wasIdle()&&targetanimation!=getIdle()&&isIdle()){
4904 targetanimation=getIdle();
4908 weaponmissdelay-=multiplier;
4909 highreversaldelay-=multiplier;
4910 lowreversaldelay-=multiplier;
4911 lastcollide-=multiplier;
4912 skiddelay-=multiplier;
4913 if(!isnormal(velocity.x)&&velocity.x){
4916 if(!isnormal(targettilt)&&targettilt){
4919 if(!isnormal(targettilt2)&&targettilt2){
4922 if(!isnormal(targetrotation)&&targetrotation){
4926 if(targetanimation==bounceidleanim||targetanimation==wolfidle||targetanimation==walkanim||targetanimation==drawrightanim||targetanimation==crouchdrawrightanim||targetanimation==drawleftanim||targetanimation==fightidleanim||targetanimation==fightsidestep||targetanimation==hanganim||isCrouch()||targetanimation==backhandspringanim){
4927 //open hands and close mouth
4928 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
4929 righthandmorphness=0;
4930 righthandmorphend=0;
4931 targetrighthandmorphness=1;
4934 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
4935 lefthandmorphness=0;
4937 targetlefthandmorphness=1;
4940 if(headmorphend!=3&&headmorphend!=5&&headmorphstart!=3&&headmorphstart!=5&&headmorphend!=0&&headmorphness==targetheadmorphness){
4943 targetheadmorphness=1;
4947 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){
4948 //open hands and mouth
4949 if(righthandmorphend!=0&&righthandmorphness==targetrighthandmorphness){
4950 righthandmorphness=0;
4951 righthandmorphend=0;
4952 targetrighthandmorphness=1;
4955 if(lefthandmorphend!=0&&lefthandmorphness==targetlefthandmorphness){
4956 lefthandmorphness=0;
4958 targetlefthandmorphness=1;
4961 if(headmorphend!=1&&headmorphness==targetheadmorphness){
4964 targetheadmorphness=1;
4968 if(targetanimation==jumpupanim||targetanimation==crouchstabanim||targetanimation==swordgroundstabanim||targetanimation==swordfightidlebothanim||targetanimation==blockhighleftanim||targetanimation==blockhighleftanim){
4969 //close hands and mouth
4970 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
4971 righthandmorphness=0;
4972 righthandmorphend=1;
4973 targetrighthandmorphness=1;
4976 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
4977 lefthandmorphness=0;
4979 targetlefthandmorphness=1;
4982 if(headmorphend!=0&&headmorphness==targetheadmorphness){
4985 targetheadmorphness=1;
4989 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){
4990 //close hands and yell
4991 if(righthandmorphend!=1&&righthandmorphness==targetrighthandmorphness){
4992 righthandmorphness=0;
4993 righthandmorphend=1;
4994 targetrighthandmorphness=1;
4997 if(lefthandmorphend!=1&&lefthandmorphness==targetlefthandmorphness){
4998 lefthandmorphness=0;
5000 targetlefthandmorphness=1;
5003 if(headmorphend!=2&&headmorphness==targetheadmorphness){
5006 targetheadmorphness=1;
5010 if(speechdelay>.25){
5011 if(headmorphend!=2)headmorphness=0;
5013 targetheadmorphness=1;
5019 if(victim!=this&&!victim->dead&&victim->aitype!=passivetype&&victim->aitype!=searchtype&&aitype!=passivetype&&aitype!=searchtype&&victim->id<numplayers&&aitype!=passivetype){
5020 behind=(normaldotproduct(facing,coords-victim->coords)>0);
5024 if(!dead&&targetanimation!=hurtidleanim)
5025 if(behind||targetanimation==killanim||targetanimation==knifethrowanim||targetanimation==knifefollowanim||targetanimation==spinkickreversalanim||targetanimation==rabbitkickreversedanim||targetanimation==jumpreversedanim){
5026 if(headmorphend!=4||headmorphness==targetheadmorphness){
5029 targetheadmorphness=1;
5033 if(weaponactive!=-1){
5034 if(weapons.type[weaponids[weaponactive]]!=staff){
5035 righthandmorphstart=1;
5036 righthandmorphend=1;
5038 if(weapons.type[weaponids[weaponactive]]==staff){
5039 righthandmorphstart=2;
5040 righthandmorphend=2;
5042 targetrighthandmorphness=1;
5045 terrainnormal=terrain.getNormal(coords.x,coords.z);
5047 if(animation[targetanimation].attack!=reversal){
5048 if(!isnormal(coords.x))
5056 flatfacing=DoRotation(flatfacing,0,rotation,0);
5058 ReflectVector(&facing,terrainnormal);
5061 if(isRun()||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim){
5062 if(onterrain)targettilt2=-facing.y*20;
5066 if(!isRun()&&!animation[targetanimation].attack&&targetanimation!=getupfromfrontanim&&targetanimation!=getupfrombackanim&&targetanimation!=sneakanim)targettilt2=0;
5067 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5068 flatvelocity=velocity;
5070 flatvelspeed=findLength(&flatvelocity);
5071 targettilt=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(DoRotation(flatfacing,0,-90,0),flatvelocity);
5072 targettilt2=flatvelspeed*fast_sqrt(abs(velocity.y)*.7)*normaldotproduct(flatfacing,flatvelocity);
5073 if(velocity.y<0)targettilt2*=-1;
5074 if(velocity.y<0)targettilt*=-1;
5075 if(targettilt>25)targettilt=25;
5076 if(targettilt<-25)targettilt=-25;
5079 if(targettilt2>45)targettilt2=45;
5080 if(targettilt2<-45)targettilt2=-45;
5081 if(abs(tilt2-targettilt2)<multiplier*400)tilt2=targettilt2;
5082 else if(tilt2>targettilt2){
5083 tilt2-=multiplier*400;
5085 else if(tilt2<targettilt2){
5086 tilt2+=multiplier*400;
5088 if(!animation[targetanimation].attack&&targetanimation!=getupfrombackanim&&targetanimation!=getupfromfrontanim){
5089 if(tilt2>25)tilt2=25;
5090 if(tilt2<-25)tilt2=-25;
5093 if(!isnormal(targettilt)&&targettilt){
5096 if(!isnormal(targettilt2)&&targettilt2){
5101 //if(!creature==wolftype||targetanimation==rabbitkickanim)
5102 if(targetanimation==rabbittackleanim){
5103 velocity+=facing*multiplier*speed*700*scale;
5104 velspeed=findLength(&velocity);
5105 if(velspeed>speed*65*scale){
5107 velspeed=speed*65*scale;
5110 velocity.y+=gravity*multiplier*20;
5111 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5112 velspeed=findLength(&velocity);
5113 velocity=flatfacing*velspeed;
5115 if(targetanimation!=rabbitrunninganim&&targetanimation!=wolfrunninganim){
5116 if(isRun()||targetanimation==rabbitkickanim){
5117 velocity+=facing*multiplier*speed*700*scale;
5118 velspeed=findLength(&velocity);
5119 if(velspeed>speed*45*scale){
5121 velspeed=speed*45*scale;
5124 velocity.y+=gravity*multiplier*20;
5125 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5126 velspeed=findLength(&velocity);
5127 if(velspeed<speed*30*scale)velspeed=speed*30*scale;
5128 velocity=flatfacing*velspeed;
5132 velocity+=facing*multiplier*speed*700*scale;
5133 velspeed=findLength(&velocity);
5134 if(creature==rabbittype){
5135 if(velspeed>speed*55*scale){
5137 velspeed=speed*55*scale;
5141 if(creature==wolftype){
5142 if(velspeed>speed*75*scale){
5144 velspeed=speed*75*scale;
5148 velocity.y+=gravity*multiplier*20;
5149 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5150 velspeed=findLength(&velocity);
5151 velocity=flatfacing*velspeed;
5154 if(targetanimation==rollanim&&animation[targetanimation].label[targetframe]!=6){
5155 velocity+=facing*multiplier*speed*700*scale;
5156 velspeed=findLength(&velocity);
5157 if(velspeed>speed*45*scale){
5159 velspeed=speed*45*scale;
5162 velocity.y+=gravity*multiplier*20;
5163 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5164 velspeed=findLength(&velocity);
5165 velocity=flatfacing*velspeed;
5169 /*if(currentanimation==rollanim&&(isCrouch()||isIdle())){
5170 velocity+=facing*multiplier*speed*700*scale;
5171 velspeed=findLength(&velocity);
5172 if(velspeed>speed*25*scale){
5174 velspeed=speed*25*scale;
5177 velocity.y+=gravity*multiplier*20;
5178 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5179 velspeed=findLength(&velocity);
5180 velocity=flatfacing*velspeed;
5183 if(targetanimation==sneakanim||targetanimation==walkanim){
5184 velocity+=facing*multiplier*speed*700*scale;
5185 velspeed=findLength(&velocity);
5186 if(velspeed>speed*12*scale){
5188 velspeed=speed*12*scale;
5191 velocity.y+=gravity*multiplier*20;
5192 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5193 velspeed=findLength(&velocity);
5194 velocity=flatfacing*velspeed;
5197 if((targetanimation==fightidleanim||targetanimation==knifefightidleanim)&&(currentanimation==bounceidleanim||currentanimation==hurtidleanim)){
5198 velocity+=facing*multiplier*speed*700*scale;
5199 velspeed=findLength(&velocity);
5200 if(velspeed>speed*2*scale){
5202 velspeed=speed*2*scale;
5205 velocity.y+=gravity*multiplier*20;
5206 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5207 velspeed=findLength(&velocity);
5208 velocity=flatfacing*velspeed;
5212 if((targetanimation==bounceidleanim||currentanimation==hurtidleanim)&&(currentanimation==fightidleanim||currentanimation==knifefightidleanim)){
5213 velocity-=facing*multiplier*speed*700*scale;
5214 velspeed=findLength(&velocity);
5215 if(velspeed>speed*2*scale){
5217 velspeed=speed*2*scale;
5220 velocity.y+=gravity*multiplier*20;
5221 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5222 velspeed=findLength(&velocity);
5223 velocity=flatfacing*velspeed*-1;
5226 if(targetanimation==fightsidestep){
5227 velocity+=DoRotation(facing*multiplier*speed*700*scale,0,-90,0);
5228 velspeed=findLength(&velocity);
5229 if(velspeed>speed*12*scale){
5231 velspeed=speed*12*scale;
5234 velocity.y+=gravity*multiplier*20;
5235 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5236 velspeed=findLength(&velocity);
5237 velocity=DoRotation(flatfacing*velspeed,0,-90,0);
5240 if(targetanimation==staggerbackhighanim){
5241 coords-=facing*multiplier*speed*16*scale;
5244 if(targetanimation==staggerbackhardanim&&animation[staggerbackhardanim].label[targetframe]!=6){
5245 coords-=facing*multiplier*speed*20*scale;
5249 if(targetanimation==backhandspringanim){
5250 //coords-=facing*multiplier*50*scale;
5251 velocity+=facing*multiplier*speed*700*scale*-1;
5252 velspeed=findLength(&velocity);
5253 if(velspeed>speed*50*scale){
5255 velspeed=speed*50*scale;
5258 velocity.y+=gravity*multiplier*20;
5259 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5260 velspeed=findLength(&velocity);
5261 velocity=flatfacing*velspeed*-1;
5263 if(targetanimation==dodgebackanim){
5264 //coords-=facing*multiplier*50*scale;
5265 velocity+=facing*multiplier*speed*700*scale*-1;
5266 velspeed=findLength(&velocity);
5267 if(velspeed>speed*60*scale){
5269 velspeed=speed*60*scale;
5272 velocity.y+=gravity*multiplier*20;
5273 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5274 velspeed=findLength(&velocity);
5275 velocity=flatfacing*velspeed*-1;
5278 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5279 velspeed=findLength(&velocity);
5283 if(targetanimation==jumpupanim||targetanimation==jumpdownanim||isFlip()){
5284 velocity.y+=gravity*multiplier;
5287 if(targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords+=velocity*multiplier;
5289 if(coords.y<terrain.getHeight(coords.x,coords.z)&&(targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
5290 if(isFlip()&&animation[targetanimation].label[targetframe]==7)RagDoll(0);
5292 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
5298 pause_sound(whooshsound);
5299 OPENAL_SetVolume(channels[whooshsound], 0);
5302 if(targetanimation==jumpdownanim||isFlip()){
5303 if(isFlip())jumppower=-4;
5304 targetanimation=getLanding();
5305 emit_sound_at(landsound, coords, 128.);
5308 envsound[numenvsounds]=coords;
5309 envsoundvol[numenvsounds]=16;
5310 envsoundlife[numenvsounds]=.4;
5316 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&targetanimation!=climbanim&&targetanimation!=hanganim&&!isWallJump())coords.y+=gravity*multiplier*2;
5317 if(targetanimation!=jumpupanim&&targetanimation!=jumpdownanim&&!isFlip()&&coords.y<terrain.getHeight(coords.x,coords.z)){
5318 coords.y=terrain.getHeight(coords.x,coords.z);
5323 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)){
5324 velspeed=findLength(&velocity);
5326 if(velspeed<multiplier*300*scale){
5328 } else velocity-=velocity/velspeed*multiplier*300*scale;
5329 if(velspeed>5&&(isLanding()||isLandhard())){
5330 skiddingdelay+=multiplier;
5337 else skiddingdelay=0;
5341 velspeed=findLength(&velocity);
5343 if(velspeed<multiplier*600*scale){
5345 } else velocity-=velocity/velspeed*multiplier*600*scale;
5347 if(velspeed>5&&(isLanding()||isLandhard())){
5348 skiddingdelay+=multiplier;
5355 else skiddingdelay=0;
5358 if(skiddingdelay<0)skiddingdelay+=multiplier;
5359 if(skiddingdelay>.02&&!forwardkeydown&&!backkeydown&&!leftkeydown&&!rightkeydown&&!jumpkeydown&&isLanding()&&!landhard){
5361 if(!onterrain||environment==grassyenvironment){
5362 emit_sound_at(skidsound, coords, 128*velspeed/10);
5365 emit_sound_at(snowskidsound, coords, 128*velspeed/10);
5369 if(animation[targetanimation].attack==normalattack&&targetanimation!=rabbitkickanim&&!victim->skeleton.free){
5370 terrainnormal=victim->coords-coords;
5371 Normalise(&terrainnormal);
5372 targetrotation=-asin(0-terrainnormal.x);
5373 targetrotation*=360/6.28;
5374 if(terrainnormal.z<0)targetrotation=180-targetrotation;
5375 targettilt2=-asin(terrainnormal.y)*360/6.28;//*-70;
5378 if(animation[targetanimation].attack==reversal&&targetanimation!=rabbittacklinganim){
5379 targetrotation=victim->targetrotation;
5381 if(targetanimation==rabbittacklinganim){
5382 coords=victim->coords;
5385 skeleton.oldfree=skeleton.free;
5389 midterrain.x=terrain.size*terrain.scale/2;
5390 midterrain.z=terrain.size*terrain.scale/2;
5391 if(findDistancefastflat(&coords,&midterrain)>(terrain.size*terrain.scale/2-viewdistance)*(terrain.size*terrain.scale/2-viewdistance)){
5393 tempposit=coords-midterrain;
5395 Normalise(&tempposit);
5396 tempposit*=(terrain.size*terrain.scale/2-viewdistance);
5397 coords.x=tempposit.x+midterrain.x;
5398 coords.z=tempposit.z+midterrain.z;
5402 int Person::DrawSkeleton(){
5403 int oldplayerdetail;
5404 if((frustum.SphereInFrustum(coords.x,coords.y+scale*3,coords.z,scale*8)&&findDistancefast(&viewer,&coords)<viewdistance*viewdistance)||skeleton.free==3){
5405 if(onterrain&&(isIdle()||isCrouch()||wasIdle()||wasCrouch())&&!skeleton.free){
5415 glAlphaFunc(GL_GREATER, 0.0001);
5417 float terrainheight;
5419 if(!isnormal(rotation))rotation=0;
5420 if(!isnormal(tilt))tilt=0;
5421 if(!isnormal(tilt2))tilt2=0;
5422 oldplayerdetail=playerdetail;
5424 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/32&&detail==2){
5427 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/128&&detail==1){
5430 if(findDistancefast(&viewer,&coords)<viewdistance*viewdistance/256&&(detail!=1&&detail!=2)){
5435 if(playerdetail!=oldplayerdetail) {
5437 normalsupdatedelay=0;
5439 static float updatedelaychange;
5440 static float morphness;
5441 static float framemult;
5443 skeleton.FindForwards();
5444 if(howactive==typesittingwall){
5445 skeleton.specialforward[1]=0;
5446 skeleton.specialforward[1].z=1;
5452 static int weaponattachmuscle;
5453 static int weaponrotatemuscle,weaponrotatemuscle2;
5454 static XYZ weaponpoint;
5455 static int start,endthing;
5456 if((dead!=2||skeleton.free!=2)&&updatedelay<=0){
5457 if(!isSleeping()&&!isSitting()){
5458 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
5459 XYZ point,newpoint,change,change2;
5460 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5461 heightleft=terrain.getHeight(point.x,point.z)+.04;
5463 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5464 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5465 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5466 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5467 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5469 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5470 heightright=terrain.getHeight(point.x,point.z)+.04;
5471 point.y=heightright;
5472 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5473 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5474 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5475 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5476 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5477 skeleton.DoConstraints(&coords,&scale);
5479 if(creature==wolftype){
5480 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5481 heightleft=terrain.getHeight(point.x,point.z)+.04;
5483 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5484 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5485 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5486 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5487 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5489 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5490 heightright=terrain.getHeight(point.x,point.z)+.04;
5491 point.y=heightright;
5492 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5493 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5494 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0);
5495 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5496 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5497 skeleton.DoConstraints(&coords,&scale);
5500 if(onterrain&&((isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&!(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
5501 XYZ point,newpoint,change,change2;
5502 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5503 heightleft=terrain.getHeight(point.x,point.z)+.04;
5505 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5506 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5507 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
5508 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5509 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5511 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5512 heightright=terrain.getHeight(point.x,point.z)+.04;
5513 point.y=heightright;
5514 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5515 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5516 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
5517 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5518 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5519 skeleton.DoConstraints(&coords,&scale);
5521 if(creature==wolftype){
5522 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5523 heightleft=terrain.getHeight(point.x,point.z)+.04;
5525 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5526 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5527 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[leftfoot]].position*(1-target);
5528 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5529 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5531 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5532 heightright=terrain.getHeight(point.x,point.z)+.04;
5533 point.y=heightright;
5534 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5535 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5536 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*target+skeleton.joints[skeleton.jointlabels[rightfoot]].position*(1-target);
5537 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5538 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5539 skeleton.DoConstraints(&coords,&scale);
5543 if(onterrain&&(!(isIdle()||isCrouch()||isLanding()||isLandhard()||targetanimation==drawrightanim||targetanimation==drawleftanim||targetanimation==crouchdrawrightanim)&&(wasIdle()||wasCrouch()||wasLanding()||wasLandhard()||currentanimation==drawrightanim||currentanimation==drawleftanim||currentanimation==crouchdrawrightanim))&&!skeleton.free){
5544 XYZ point,newpoint,change,change2;
5545 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5546 heightleft=terrain.getHeight(point.x,point.z)+.04;
5548 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5549 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5550 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
5551 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5552 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5554 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5555 heightright=terrain.getHeight(point.x,point.z)+.04;
5556 point.y=heightright;
5557 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5558 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5559 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
5560 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5561 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5562 skeleton.DoConstraints(&coords,&scale);
5564 if(creature==wolftype){
5565 point=DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position,0,rotation,0)*scale+coords;
5566 heightleft=terrain.getHeight(point.x,point.z)+.04;
5568 change=skeleton.joints[skeleton.jointlabels[leftankle]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5569 change2=skeleton.joints[skeleton.jointlabels[leftknee]].position-skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5570 skeleton.joints[skeleton.jointlabels[leftfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[leftfoot]].position*target;
5571 skeleton.joints[skeleton.jointlabels[leftankle]].position=skeleton.joints[skeleton.jointlabels[leftfoot]].position+change;
5572 skeleton.joints[skeleton.jointlabels[leftknee]].position=(skeleton.joints[skeleton.jointlabels[leftfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[leftknee]].position)/2;
5574 point=DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position,0,rotation,0)*scale+coords;
5575 heightright=terrain.getHeight(point.x,point.z)+.04;
5576 point.y=heightright;
5577 change=skeleton.joints[skeleton.jointlabels[rightankle]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5578 change2=skeleton.joints[skeleton.jointlabels[rightknee]].position-skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5579 skeleton.joints[skeleton.jointlabels[rightfoot]].position=DoRotation((point-coords)/scale,0,-rotation,0)*(1-target)+skeleton.joints[skeleton.jointlabels[rightfoot]].position*target;
5580 skeleton.joints[skeleton.jointlabels[rightankle]].position=skeleton.joints[skeleton.jointlabels[rightfoot]].position+change;
5581 skeleton.joints[skeleton.jointlabels[rightknee]].position=(skeleton.joints[skeleton.jointlabels[rightfoot]].position+change2)/2+(skeleton.joints[skeleton.jointlabels[rightknee]].position)/2;
5582 skeleton.DoConstraints(&coords,&scale);
5586 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()))
5589 targetheadrotation=-targetrotation;
5590 targetheadrotation2=0;
5591 if(animation[targetanimation].attack==3)targetheadrotation+=180;
5593 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
5594 skeleton.drawmodel.vertex[i]=0;
5595 skeleton.drawmodel.vertex[i].y=999;
5597 for(i=0;i<skeleton.drawmodellow.vertexNum;i++){
5598 skeleton.drawmodellow.vertex[i]=0;
5599 skeleton.drawmodellow.vertex[i].y=999;
5601 for(i=0;i<skeleton.drawmodelclothes.vertexNum;i++){
5602 skeleton.drawmodelclothes.vertex[i]=0;
5603 skeleton.drawmodelclothes.vertex[i].y=999;
5605 for(i=0;i<skeleton.num_muscles;i++){
5606 if((skeleton.muscles[i].numvertices>0&&playerdetail)||(skeleton.muscles[i].numverticeslow>0&&!playerdetail)){
5610 if(skeleton.muscles[i].parent1->label==righthand||skeleton.muscles[i].parent2->label==righthand){
5611 morphness=righthandmorphness;
5612 start=righthandmorphstart;
5613 endthing=righthandmorphend;
5615 if(skeleton.muscles[i].parent1->label==lefthand||skeleton.muscles[i].parent2->label==lefthand){
5616 morphness=lefthandmorphness;
5617 start=lefthandmorphstart;
5618 endthing=lefthandmorphend;
5620 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head){
5621 morphness=headmorphness;
5622 start=headmorphstart;
5623 endthing=headmorphend;
5625 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)){
5626 morphness=chestmorphness;
5627 start=chestmorphstart;
5628 endthing=chestmorphend;
5630 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)){
5631 morphness=tailmorphness;
5632 start=tailmorphstart;
5633 endthing=tailmorphend;
5635 if(calcrot)skeleton.FindRotationMuscle(i,targetanimation);
5636 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
5637 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5640 if(!skeleton.free)glRotatef(tilt2,1,0,0);
5641 if(!skeleton.free)glRotatef(tilt,0,0,1);
5644 glTranslatef(mid.x,mid.y,mid.z);
5646 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
5647 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
5649 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
5650 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
5652 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
5653 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
5655 if(playerdetail||skeleton.free==3)
5657 for(j=0;j<skeleton.muscles[i].numvertices;j++)
5659 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5661 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
5662 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,
5663 (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,
5664 (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);
5665 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)
5666 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,
5667 (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,
5668 (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);
5669 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)
5670 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,
5671 (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,
5672 (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);
5673 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
5674 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,
5675 (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,
5676 (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);
5677 glGetFloatv(GL_MODELVIEW_MATRIX,M);
5678 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
5679 //if(!isnormal(scale))test=1;
5680 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x=M[12]*scale;
5681 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y=M[13]*scale;
5682 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z=M[14]*scale;
5687 if(!playerdetail||skeleton.free==3)
5689 for(j=0;j<skeleton.muscles[i].numverticeslow;j++)
5691 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5693 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
5694 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
5695 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
5696 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
5697 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)
5698 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
5699 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
5700 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
5701 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)
5702 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
5703 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
5704 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
5705 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
5706 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
5707 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
5708 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
5710 glGetFloatv(GL_MODELVIEW_MATRIX,M);
5711 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x=M[12]*scale;
5712 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y=M[13]*scale;
5713 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z=M[14]*scale;
5719 if(skeleton.clothes&&skeleton.muscles[i].numverticesclothes>0){
5720 mid=(skeleton.muscles[i].parent1->position+skeleton.muscles[i].parent2->position)/2;
5722 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5725 if(!skeleton.free)glRotatef(tilt2,1,0,0);
5726 if(!skeleton.free)glRotatef(tilt,0,0,1);
5727 glTranslatef(mid.x,mid.y,mid.z);
5728 skeleton.muscles[i].lastrotate1=skeleton.muscles[i].rotate1;
5729 glRotatef(-skeleton.muscles[i].lastrotate1+90,0,1,0);
5731 skeleton.muscles[i].lastrotate2=skeleton.muscles[i].rotate2;
5732 glRotatef(-skeleton.muscles[i].lastrotate2+90,0,0,1);
5734 skeleton.muscles[i].lastrotate3=skeleton.muscles[i].rotate3;
5735 glRotatef(-skeleton.muscles[i].lastrotate3,0,1,0);
5737 for(j=0;j<skeleton.muscles[i].numverticesclothes;j++){
5738 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5740 if(skeleton.muscles[i].parent1->label==abdomen||skeleton.muscles[i].parent2->label==abdomen)
5741 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
5742 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
5743 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
5744 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)
5745 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
5746 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
5747 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
5748 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)
5749 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
5750 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
5751 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
5752 if(skeleton.muscles[i].parent1->label==head||skeleton.muscles[i].parent2->label==head)
5753 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
5754 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
5755 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
5756 glGetFloatv(GL_MODELVIEW_MATRIX,M);
5757 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x=M[12]*scale;
5758 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y=M[13]*scale;
5759 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z=M[14]*scale;
5764 updatedelay=1+(float)(Random()%100)/1000;
5766 if(skeleton.free!=2&&(skeleton.free==1||skeleton.free==3||id==0||(normalsupdatedelay<=0)||targetanimation==getupfromfrontanim||targetanimation==getupfrombackanim||currentanimation==getupfromfrontanim||currentanimation==getupfrombackanim)){
5767 normalsupdatedelay=1;
5768 if(playerdetail||skeleton.free==3)skeleton.drawmodel.CalculateNormals(0);
5769 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.CalculateNormals(0);
5770 if(skeleton.clothes)skeleton.drawmodelclothes.CalculateNormals(0);
5774 if(playerdetail||skeleton.free==3)skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
5775 if(!playerdetail||skeleton.free==3)skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
5776 if(skeleton.clothes){
5777 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
5782 updatedelaychange=-framemult*4*(45-findDistance(&viewer,&coords)*1);
5783 if(updatedelaychange>-realmultiplier*30)updatedelaychange=-realmultiplier*30;
5784 if(updatedelaychange>-framemult*4)updatedelaychange=-framemult*4;
5785 if(skeleton.free==1)updatedelaychange*=6;
5786 if(id==0)updatedelaychange*=8;
5787 updatedelay+=updatedelaychange;
5789 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
5791 if(!skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
5792 if(skeleton.free)glTranslatef(coords.x,coords.y-.02,coords.z);
5793 if(!skeleton.free)glTranslatef(offset.x*scale,offset.y*scale,offset.z*scale);
5794 if(!skeleton.free)glRotatef(rotation,0,1,0);
5797 glColor4f(.4,1,.4,1);
5798 glDisable(GL_LIGHTING);
5799 glDisable(GL_TEXTURE_2D);
5802 for(i=0;i<skeleton.drawmodel.vertexNum;i++){
5803 glVertex3f(skeleton.drawmodel.vertex[i].x,skeleton.drawmodel.vertex[i].y,skeleton.drawmodel.vertex[i].z);
5809 for(i=0;i<skeleton.drawmodel.TriangleNum;i++){
5810 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);
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[1]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[1]].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[2]].x,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].y,skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[i].vertex[2]].z);
5815 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);
5821 terrainlight=terrain.getLighting(coords.x,coords.z);
5822 distance=findDistancefast(&viewer,&coords);
5823 distance=(viewdistance*viewdistance-(distance-(viewdistance*viewdistance*fadestart))*(1/(1-fadestart)))/viewdistance/viewdistance;
5824 if(distance>1)distance=1;
5826 terrainheight=(coords.y-terrain.getHeight(coords.x,coords.z))/3+1;
5827 if(terrainheight<1)terrainheight=1;
5828 if(terrainheight>1.7)terrainheight=1.7;
5831 glColor4f((1-(1-terrainlight.x)/terrainheight)-burnt,(1-(1-terrainlight.y)/terrainheight)-burnt,(1-(1-terrainlight.z)/terrainheight)-burnt,distance);
5832 glDisable(GL_BLEND);
5833 glAlphaFunc(GL_GREATER, 0.0001);
5834 glEnable(GL_TEXTURE_2D);
5836 glDisable(GL_TEXTURE_2D);
5837 glColor4f(.7,.35,0,.5);
5839 glEnable(GL_LIGHTING);
5842 if(tutoriallevel&&id!=0){
5843 //glDisable(GL_TEXTURE_2D);
5844 glColor4f(.7,.7,.7,0.6);
5846 glEnable(GL_LIGHTING);
5848 if(canattack&&cananger)
5849 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
5850 glDisable(GL_TEXTURE_2D);
5851 glColor4f(1,0,0,0.8);
5853 glMatrixMode(GL_TEXTURE);
5855 glTranslatef(0,-smoketex,0);
5856 glTranslatef(-smoketex,0,0);
5860 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
5861 else skeleton.drawmodel.draw();
5865 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
5866 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
5869 if(!(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed))
5870 if(tutoriallevel&&id!=0){
5872 glMatrixMode(GL_MODELVIEW);
5873 glEnable(GL_TEXTURE_2D);
5874 glColor4f(.7,.7,.7,0.6);
5876 glEnable(GL_LIGHTING);
5878 if(canattack&&cananger)
5879 if(animation[targetanimation].attack==normalattack||animation[targetanimation].attack==reversed){
5880 glDisable(GL_TEXTURE_2D);
5881 glColor4f(1,0,0,0.8);
5883 glMatrixMode(GL_TEXTURE);
5885 glTranslatef(0,-smoketex*.6,0);
5886 glTranslatef(smoketex*.6,0,0);
5889 if((tutoriallevel&&id!=0))skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
5890 else skeleton.drawmodel.draw();
5894 if((tutoriallevel&&id!=0))skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
5895 else skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
5900 if(tutoriallevel&&id!=0){
5902 glMatrixMode(GL_MODELVIEW);
5903 glEnable(GL_TEXTURE_2D);
5905 if(skeleton.clothes){
5908 if(!immediate)skeleton.drawmodelclothes.draw();
5909 if(immediate)skeleton.drawmodelclothes.drawimmediate();
5916 for(k=0;k<num_weapons;k++){
5918 if(weaponactive==k){
5919 if(weapons.type[i]!=staff){
5920 for(j=0;j<skeleton.num_muscles;j++){
5921 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
5922 weaponattachmuscle=j;
5925 for(j=0;j<skeleton.num_muscles;j++){
5926 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){
5927 weaponrotatemuscle=j;
5930 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
5931 if(creature==wolftype)weaponpoint=(skeleton.joints[skeleton.jointlabels[rightwrist]].position*.7+skeleton.joints[skeleton.jointlabels[righthand]].position*.3);
5933 if(weapons.type[i]==staff){
5934 for(j=0;j<skeleton.num_muscles;j++){
5935 if((skeleton.muscles[j].parent1->label==righthand||skeleton.muscles[j].parent2->label==righthand)&&skeleton.muscles[j].numvertices>0){
5936 weaponattachmuscle=j;
5939 for(j=0;j<skeleton.num_muscles;j++){
5940 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){
5941 weaponrotatemuscle=j;
5944 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
5945 weaponpoint=(skeleton.muscles[weaponattachmuscle].parent1->position+skeleton.muscles[weaponattachmuscle].parent2->position)/2;
5946 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
5947 XYZ tempnormthing,vec1,vec2;
5948 vec1=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
5949 vec2=(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
5950 CrossProduct(&vec1,&vec2,&tempnormthing);
5951 Normalise(&tempnormthing);
5952 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);
5955 if(weaponactive!=k&&weaponstuck!=k){
5956 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;
5957 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;
5958 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;
5959 for(j=0;j<skeleton.num_muscles;j++){
5960 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){
5961 weaponrotatemuscle=j;
5966 if(weaponstuckwhere==0)weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5-skeleton.forward*.8;
5967 else weaponpoint=skeleton.joints[skeleton.jointlabels[abdomen]].position*.5+skeleton.joints[skeleton.jointlabels[neck]].position*.5+skeleton.forward*.8;
5968 for(j=0;j<skeleton.num_muscles;j++){
5969 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){
5970 weaponrotatemuscle=j;
5975 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;
5976 weapons.bigrotation[i]=rotation;
5977 weapons.bigtilt[i]=tilt;
5978 weapons.bigtilt2[i]=tilt2;
5981 weapons.position[i]=weaponpoint*scale+coords;
5982 weapons.bigrotation[i]=0;
5983 weapons.bigtilt[i]=0;
5984 weapons.bigtilt2[i]=0;
5986 weapons.rotation1[i]=skeleton.muscles[weaponrotatemuscle].lastrotate1;
5987 weapons.rotation2[i]=skeleton.muscles[weaponrotatemuscle].lastrotate2;
5988 weapons.rotation3[i]=skeleton.muscles[weaponrotatemuscle].lastrotate3;
5989 if(weaponactive==k){
5990 if(weapons.type[i]==knife){
5991 weapons.smallrotation[i]=180;
5992 weapons.smallrotation2[i]=0;
5993 if(isCrouch()||wasCrouch()){
5994 weapons.smallrotation2[i]=20;
5996 if(targetanimation==hurtidleanim){
5997 weapons.smallrotation2[i]=50;
5999 if((currentanimation==crouchstabanim&&targetanimation==crouchstabanim)||(currentanimation==backhandspringanim&&targetanimation==backhandspringanim)){
6000 XYZ temppoint1,temppoint2,tempforward;
6003 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
6004 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6005 distance=findDistance(&temppoint1,&temppoint2);
6006 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6007 weapons.rotation2[i]*=360/6.28;
6010 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6011 weapons.rotation1[i]*=360/6.28;
6012 weapons.rotation3[i]=0;
6013 weapons.smallrotation[i]=-90;
6014 weapons.smallrotation2[i]=0;
6015 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6017 if((currentanimation==knifeslashreversalanim&&targetanimation==knifeslashreversalanim)||(currentanimation==knifeslashreversedanim&&targetanimation==knifeslashreversedanim)){
6018 XYZ temppoint1,temppoint2,tempforward;
6021 temppoint1=skeleton.joints[skeleton.jointlabels[righthand]].position;
6022 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6023 distance=findDistance(&temppoint1,&temppoint2);
6024 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6025 weapons.rotation2[i]*=360/6.28;
6028 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6029 weapons.rotation1[i]*=360/6.28;
6030 weapons.rotation3[i]=0;
6031 weapons.smallrotation[i]=90;
6032 weapons.smallrotation2[i]=0;
6033 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6035 if(targetanimation==knifethrowanim){
6036 weapons.smallrotation[i]=90;
6037 //weapons.smallrotation2[i]=-90;
6038 weapons.smallrotation2[i]=0;
6039 weapons.rotation1[i]=0;
6040 weapons.rotation2[i]=0;
6041 weapons.rotation3[i]=0;
6043 if(targetanimation==knifesneakattackanim&&targetframe<5){
6044 weapons.smallrotation[i]=-90;
6045 weapons.rotation1[i]=0;
6046 weapons.rotation2[i]=0;
6047 weapons.rotation3[i]=0;
6050 if(weapons.type[i]==sword){
6051 weapons.smallrotation[i]=0;
6052 weapons.smallrotation2[i]=0;
6053 if(targetanimation==knifethrowanim){
6054 weapons.smallrotation[i]=-90;
6055 weapons.smallrotation2[i]=0;
6056 weapons.rotation1[i]=0;
6057 weapons.rotation2[i]=0;
6058 weapons.rotation3[i]=0;
6060 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)){
6061 XYZ temppoint1,temppoint2,tempforward;
6064 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
6065 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6066 distance=findDistance(&temppoint1,&temppoint2);
6067 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6068 weapons.rotation2[i]*=360/6.28;
6071 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6072 weapons.rotation1[i]*=360/6.28;
6073 weapons.rotation3[i]=0;
6074 weapons.smallrotation[i]=90;
6075 weapons.smallrotation2[i]=0;
6076 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6079 if(weapons.type[i]==staff){
6080 weapons.smallrotation[i]=100;
6081 weapons.smallrotation2[i]=0;
6082 if((targetanimation==staffhitanim&¤tanimation==staffhitanim)||(targetanimation==staffhitreversedanim&¤tanimation==staffhitreversedanim)||(targetanimation==staffspinhitreversedanim&¤tanimation==staffspinhitreversedanim)||(targetanimation==staffgroundsmashanim&¤tanimation==staffgroundsmashanim)||(targetanimation==staffspinhitanim&¤tanimation==staffspinhitanim)){
6083 XYZ temppoint1,temppoint2,tempforward;
6086 temppoint1=animation[currentanimation].position[skeleton.jointlabels[righthand]][currentframe]*(1-target)+animation[targetanimation].position[skeleton.jointlabels[righthand]][targetframe]*(target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
6087 temppoint2=animation[currentanimation].weapontarget[currentframe]*(1-target)+animation[targetanimation].weapontarget[targetframe]*(target);
6088 distance=findDistance(&temppoint1,&temppoint2);
6089 weapons.rotation2[i]=asin((temppoint1.y-temppoint2.y)/distance);
6090 weapons.rotation2[i]*=360/6.28;
6093 weapons.rotation1[i]=acos((temppoint1.z-temppoint2.z)/findDistance(&temppoint1,&temppoint2));
6094 weapons.rotation1[i]*=360/6.28;
6095 weapons.rotation3[i]=0;
6096 weapons.smallrotation[i]=90;
6097 weapons.smallrotation2[i]=0;
6098 if(temppoint1.x>temppoint2.x)weapons.rotation1[i]=360-weapons.rotation1[i];
6102 if(weaponactive!=k&&weaponstuck!=k){
6103 if(weapons.type[i]==knife){
6104 weapons.smallrotation[i]=-70;
6105 weapons.smallrotation2[i]=10;
6107 if(weapons.type[i]==sword){
6108 weapons.smallrotation[i]=-100;
6109 weapons.smallrotation2[i]=-8;
6111 if(weapons.type[i]==staff){
6112 weapons.smallrotation[i]=-100;
6113 weapons.smallrotation2[i]=-8;
6117 if(weaponstuckwhere==0)weapons.smallrotation[i]=180;
6118 else weapons.smallrotation[i]=0;
6119 weapons.smallrotation2[i]=10;
6126 if(skeleton.free)calcrot=1;
6127 if(animation[targetanimation].attack||isRun()||targetanimation==staggerbackhardanim||isFlip()||targetanimation==climbanim||targetanimation==sneakanim||targetanimation==rollanim||targetanimation==walkanim||targetanimation==backhandspringanim||isFlip()||isWallJump())calcrot=1;
6128 if(currentanimation!=targetanimation)calcrot=1;
6129 //if(id==0)calcrot=1;
6130 if(skeleton.free==2)calcrot=0;
6136 int Person::SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
6139 static float distance;
6140 static float olddistance;
6141 static int intersecting;
6142 static int firstintersecting;
6145 static XYZ start,end;
6146 static float slopethreshold=-.4;
6148 firstintersecting=-1;
6152 if(findDistancefast(p1,&model->boundingspherecenter)>radius*radius+model->boundingsphereradius*model->boundingsphereradius)return -1;
6153 if(*rotate)*p1=DoRotation(*p1,0,-*rotate,0);
6155 for (j=0;j<model->TriangleNum;j++){
6156 if(model->facenormals[j].y<=slopethreshold){
6158 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)));
6159 if(distance<radius){
6160 point=*p1-model->facenormals[j]*distance;
6161 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;
6162 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
6163 &model->vertex[model->Triangles[j].vertex[1]],
6165 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
6166 &model->vertex[model->Triangles[j].vertex[2]],
6168 if(!intersecting)intersecting=sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
6169 &model->vertex[model->Triangles[j].vertex[2]],
6172 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
6176 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)){
6177 p1->y=point.y+radius;
6178 if((targetanimation==jumpdownanim||isFlip())){
6179 if(isFlip()&&(targetframe<5||animation[targetanimation].label[targetframe]==7||animation[targetanimation].label[targetframe]==4))RagDoll(0);
6181 if(targetanimation==jumpupanim){jumppower=-4;targetanimation=getIdle();}
6187 pause_sound(whooshsound);
6188 OPENAL_SetVolume(channels[whooshsound], 0);
6191 if((targetanimation==jumpdownanim||isFlip())&&!wasLanding()&&!wasLandhard()){
6192 if(isFlip())jumppower=-4;
6193 targetanimation=getLanding();
6194 emit_sound_at(landsound, coords, 128.);
6197 envsound[numenvsounds]=coords;
6198 envsoundvol[numenvsounds]=16;
6199 envsoundlife[numenvsounds]=.4;
6207 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
6210 for (j=0;j<model->TriangleNum;j++){
6211 if(model->facenormals[j].y>slopethreshold){
6215 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)));
6216 if(distance<radius*.5){
6217 point=start-model->facenormals[j]*distance;
6218 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;
6219 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,
6220 model->vertex[model->Triangles[j].vertex[1]].x,model->vertex[model->Triangles[j].vertex[1]].y,model->vertex[model->Triangles[j].vertex[1]].z,
6221 p1->x, p1->y, p1->z, radius/2);
6222 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,
6223 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
6224 p1->x, p1->y, p1->z, radius/2);
6225 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,
6226 model->vertex[model->Triangles[j].vertex[2]].x,model->vertex[model->Triangles[j].vertex[2]].y,model->vertex[model->Triangles[j].vertex[2]].z,
6227 p1->x, p1->y, p1->z, radius/2);
6229 if(dotproduct(&model->facenormals[j],&end)>0&&intersecting){
6230 if((targetanimation==jumpdownanim||targetanimation==jumpupanim||isFlip())){
6232 velocity-=DoRotation(model->facenormals[j],0,*rotate,0)*findLength(&velocity)*abs(normaldotproduct(velocity,DoRotation(model->facenormals[j],0,*rotate,0)));//(distance-radius*.5)/multiplier;
6233 if(findLengthfast(&start)<findLengthfast(&velocity))velocity=start;
6235 *p1+=model->facenormals[j]*(distance-radius*.5);
6238 if((distance<olddistance||firstintersecting==-1)&&intersecting){olddistance=distance; firstintersecting=j; *p=point;}
6242 if(*rotate)*p=DoRotation(*p,0,*rotate,0);
6244 if(*rotate)*p1=DoRotation(*p1,0,*rotate,0);
6246 return firstintersecting;