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 viewdistance;
52 extern float blackout;
53 extern int difficulty;
55 extern float fadestart;
57 extern bool winfreeze;
58 extern float flashamount, flashr, flashg, flashb;
59 extern int flashdelay;
60 extern bool showpoints;
61 extern bool immediate;
63 extern bool tilt2weird;
64 extern bool tiltweird;
66 extern bool proportionweird;
67 extern bool vertexweird[6];
68 extern XYZ envsound[30];
69 extern float envsoundvol[30];
70 extern float envsoundlife[30];
71 extern int numenvsounds;
72 extern int tutoriallevel;
73 extern float smoketex;
74 extern int tutorialstage;
75 extern bool reversaltrain;
76 extern bool canattack;
78 extern float damagedealt;
80 extern float hostiletime;
82 extern int indialogue;
84 extern bool gamestarted;
86 Person player[maxplayers];
88 void Person::CheckKick()
91 && (animTarget == rabbitkickanim
95 && animCurrent == rabbitkickanim)
96 && (distsq(&coords, &victim->coords) < 1.2)
97 && (!victim->skeleton.free)))
100 if (animation[victim->animTarget].height != lowheight) {
101 float damagemult = (creature == wolftype ? 2.5 : 1.) * power * power;
102 XYZ relative = velocity;
104 Normalise(&relative);
108 if (tutoriallevel != 1)
109 emit_sound_at(heavyimpactsound, victim->coords);
111 for (int i = 0; i < victim->skeleton.num_joints; i++) {
112 victim->skeleton.joints[i].velocity += relative * 120 * damagemult;
115 victim->DoDamage(100 * damagemult / victim->protectionhigh);
121 animTarget = backflipanim;
123 velocity = facing * -10;
127 resume_stream(whooshsound);
129 award_bonus(id, cannon);
130 } else if (victim->isCrouch()) {
131 animTarget = rabbitkickreversedanim;
132 animCurrent = rabbitkickreversedanim;
133 victim->animCurrent = rabbitkickreversalanim;
134 victim->animTarget = rabbitkickreversalanim;
140 victim->oldcoords = victim->coords;
141 coords = victim->coords;
142 victim->targetyaw = targetyaw;
143 victim->victim = this;
147 void Person::CatchFire()
149 XYZ flatfacing, flatvelocity;
151 for (int i = 0; i < 10; i++) {
152 howmany = abs(Random() % (skeleton.num_joints));
154 flatvelocity = velocity;
156 flatvelocity = skeleton.joints[howmany].velocity;
158 flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
160 flatfacing = skeleton.joints[howmany].position * scale + coords;
161 Sprite::MakeSprite(flamesprite, flatfacing, flatvelocity, 1, 1, 1, 2, 1);
166 emit_sound_at(firestartsound, coords);
168 emit_stream_at(stream_firesound, coords);
175 int Person::getIdle()
177 if (indialogue != -1 && howactive == typeactive && creature == rabbittype)
179 if (hasvictim && victim != this/*||(id==0&&attackkeydown)*/)
180 if (/*(id==0&&attackkeydown)||*/(!victim->dead && victim->aitype != passivetype && victim->aitype != searchtype && aitype != passivetype && aitype != searchtype && victim->id < numplayers)) {
181 if ((aitype == playercontrolled && stunned <= 0 && weaponactive == -1) || pause) {
182 if (creature == rabbittype)
183 return fightidleanim;
184 if (creature == wolftype)
187 if (aitype == playercontrolled && stunned <= 0 && weaponactive != -1) {
188 if (weapons[weaponids[weaponactive]].getType() == knife)
189 return knifefightidleanim;
190 if (weapons[weaponids[weaponactive]].getType() == sword && victim->weaponactive != -1)
191 return swordfightidlebothanim;
192 if (weapons[weaponids[weaponactive]].getType() == sword)
193 return swordfightidleanim;
194 if (weapons[weaponids[weaponactive]].getType() == staff)
195 return swordfightidleanim;
197 if (aitype != playercontrolled && stunned <= 0 && creature != wolftype && !pause)
198 return fightsidestep;
200 if ((damage > permanentdamage || damage > damagetolerance * .8 || deathbleeding > 0) && creature != wolftype)
202 if (howactive == typesitting) return sitanim;
203 if (howactive == typesittingwall) return sitwallanim;
204 if (howactive == typesleeping) return sleepanim;
205 if (howactive == typedead1) return dead1anim;
206 if (howactive == typedead2) return dead2anim;
207 if (howactive == typedead3) return dead3anim;
208 if (howactive == typedead4) return dead4anim;
209 if (creature == rabbittype) return bounceidleanim;
210 if (creature == wolftype) return wolfidle;
214 int Person::getCrouch()
216 if (creature == rabbittype)
218 if (creature == wolftype)
219 return wolfcrouchanim;
225 if (creature == rabbittype && (!superruntoggle || weaponactive != -1))
227 if (creature == wolftype && (!superruntoggle))
230 if (creature == rabbittype && (superruntoggle && weaponactive == -1))
231 return rabbitrunninganim;
232 if (creature == wolftype && (superruntoggle))
233 return wolfrunninganim;
237 int Person::getStop()
239 if (creature == rabbittype)
241 if (creature == wolftype)
246 int Person::getLanding()
248 if (creature == rabbittype)
250 if (creature == wolftype)
255 int Person::getLandhard()
257 if (creature == rabbittype)
259 if (creature == wolftype)
260 return wolflandhardanim;
265 SolidHitBonus(int playerid)
267 if (bonustime < 1.5 && bonus >= solidhit && bonus <= megacombo)
268 award_bonus(playerid, bonus == megacombo ? bonus : bonus + 1);
270 award_bonus(playerid, solidhit);
273 void Person::DoBlood(float howmuch, int which)
275 static int bleedxint, bleedyint;
277 //if(howmuch&&id==0)blooddimamount=1;
278 if (bloodtoggle && tutoriallevel != 1) {
279 if (bleeding <= 0 && spurt) {
281 for (int i = 0; i < 3; i++) {
283 if (!skeleton.free) {
285 bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
288 bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0);
291 bloodvel += DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
293 bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
295 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position * scale + coords, bloodvel, 1, 1, 1, .05, 1);
296 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position * scale + coords, bloodvel, 1, 1, 1, .3, 1);
298 if (!skeleton.free) {
299 Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
300 Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1);
303 if (Random() % 2 == 0)
304 for (int i = 0; i < 3; i++) {
305 if (Random() % 2 != 0) {
308 bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0);
309 bloodvel += DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
312 bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
313 bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
317 Sprite::MakeSprite(splintersprite, skeleton.joints[skeleton.jointlabels[head]].position * scale + coords, bloodvel, 1, 1, 1, .05, 1);
319 Sprite::MakeSprite(splintersprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
321 Sprite::setLastSpriteSpecial(3);
326 bleeding = howmuch + (float)abs(Random() % 100) / 200 - .25;
329 if (creature == rabbittype)
330 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) {
331 bleedxint = abs(Random() % 512);
332 bleedyint = abs(Random() % 512);
334 if (creature == wolftype)
335 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) {
336 bleedxint = abs(Random() % 512);
337 bleedyint = abs(Random() % 512);
341 bleedy /= realtexdetail;
342 bleedx /= realtexdetail;
343 direction = abs(Random() % 2) * 2 - 1;
351 void Person::DoBloodBig(float howmuch, int which)
353 static int bleedxint, bleedyint, i, j;
355 if (howmuch && id == 0)
358 if (tutoriallevel != 1 || id == 0)
359 if (aitype != playercontrolled && howmuch > 0) {
362 if (creature == wolftype) {
363 int i = abs(Random() % 2);
365 whichsound = snarlsound;
367 whichsound = snarl2sound;
368 envsound[numenvsounds] = coords;
369 envsoundvol[numenvsounds] = 16;
370 envsoundlife[numenvsounds] = .4;
373 if (creature == rabbittype) {
374 int i = abs(Random() % 2);
376 whichsound = rabbitpainsound;
377 if (i == 1 && howmuch >= 2)
378 whichsound = rabbitpain1sound;
379 envsound[numenvsounds] = coords;
380 envsoundvol[numenvsounds] = 16;
381 envsoundlife[numenvsounds] = .4;
383 //if(i==2)whichsound=rabbitpain2sound;
386 if (whichsound != -1)
387 emit_sound_at(whichsound, coords);
390 if (id == 0 && howmuch > 0) {
398 if (bloodtoggle && decals && tutoriallevel != 1) {
399 if (bleeding <= 0 && spurt) {
401 for (int i = 0; i < 3; i++) {
403 if (!skeleton.free) {
405 bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
408 bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0);
411 bloodvel += DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
413 bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
415 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position * scale + coords, bloodvel, 1, 1, 1, .05, 1);
416 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position * scale + coords, bloodvel, 1, 1, 1, .3, 1);
418 if (!skeleton.free) {
419 Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
420 Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1);
424 int offsetx = 0, offsety = 0;
426 offsety = Random() % 40;
427 offsetx = abs(Random() % 60);
429 if (which == 190 || which == 185) {
430 offsety = Random() % 40;
431 offsetx = abs(Random() % 100) - 20;
434 offsety = Random() % 10;
435 offsetx = Random() % 10;
438 offsety = Random() % 20;
439 offsetx = Random() % 20;
441 if (which == 220 || which == 215) {
451 if (creature == rabbittype)
452 for (i = 0; i < 512; i++) {
453 for (j = 0; j < 512; j++) {
454 if (bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
455 if (i < startx) startx = i;
456 if (j < starty) starty = j;
457 if (i > endx) endx = i;
458 if (j > endy) endy = j;
462 if (creature == wolftype)
463 for (i = 0; i < 512; i++) {
464 for (j = 0; j < 512; j++) {
465 if (wolfbloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && wolfbloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
466 if (i < startx) startx = i;
467 if (j < starty) starty = j;
468 if (i > endx) endx = i;
469 if (j > endy) endy = j;
479 if (startx < 0) startx = 0;
480 if (starty < 0) starty = 0;
481 if (endx > 512 - 1) endx = 512 - 1;
482 if (endy > 512 - 1) endy = 512 - 1;
483 if (endx < startx) endx = startx;
484 if (endy < starty) endy = starty;
486 startx /= realtexdetail;
487 starty /= realtexdetail;
488 endx /= realtexdetail;
489 endy /= realtexdetail;
491 int texdetailint = realtexdetail;
493 if (creature == rabbittype)
494 for (i = startx; i < endx; i++) {
495 for (j = starty; j < endy; j++) {
496 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) {
497 color = Random() % 85 + 170;
498 where = i * skeleton.skinsize * 3 + j * 3;
499 if (skeleton.skinText[where + 0] > color / 2)
500 skeleton.skinText[where + 0] = color / 2;
501 skeleton.skinText[where + 1] = 0;
502 skeleton.skinText[where + 2] = 0;
506 if (creature == wolftype)
507 for (i = startx; i < endx; i++) {
508 for (j = starty; j < endy; j++) {
509 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) {
510 color = Random() % 85 + 170;
511 where = i * skeleton.skinsize * 3 + j * 3;
512 if (skeleton.skinText[where + 0] > color / 2)
513 skeleton.skinText[where + 0] = color / 2;
514 skeleton.skinText[where + 1] = 0;
515 skeleton.skinText[where + 2] = 0;
519 skeleton.drawmodel.textureptr.bind();
524 if (creature == rabbittype)
525 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) {
526 bleedxint = abs(Random() % 512);
527 bleedyint = abs(Random() % 512);
529 if (creature == wolftype)
530 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) {
531 bleedxint = abs(Random() % 512);
532 bleedyint = abs(Random() % 512);
534 bleedy = bleedxint + offsetx;
535 bleedx = bleedyint + offsety;
536 bleedy /= realtexdetail;
537 bleedx /= realtexdetail;
542 if (bleedx > skeleton.skinsize - 1)
543 bleedx = skeleton.skinsize - 1;
544 if (bleedy > skeleton.skinsize - 1)
545 bleedy = skeleton.skinsize - 1;
546 direction = abs(Random() % 2) * 2 - 1;
549 bleeding = howmuch + (float)abs(Random() % 100) / 200 - .25;
550 deathbleeding += bleeding;
551 bloodloss += bleeding * 3;
553 if (tutoriallevel != 1 && aitype != playercontrolled && bloodloss > damagetolerance * 2 / 3 && bloodloss < damagetolerance && creature == rabbittype) {
554 if (abs(Random() % 2) == 0) {
555 aitype = gethelptype;
558 aitype = attacktypecutoff;
565 bool Person::DoBloodBigWhere(float howmuch, int which, XYZ where)
569 static XYZ startpoint, endpoint, colpoint, movepoint;
570 static float rotationpoint;
572 static XYZ p1, p2, p3, p0;
576 float coordsx, coordsy;
579 if (bloodtoggle && decals && tutoriallevel != 1) {
582 where = DoRotation(where, 0, -yaw, 0);
590 whichtri = skeleton.drawmodel.LineCheck(&startpoint, &endpoint, &colpoint, &movepoint, &rotationpoint);
591 if (whichtri != -1) {
593 p1 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[0]];
594 p2 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[1]];
595 p3 = skeleton.drawmodel.vertex[skeleton.drawmodel.Triangles[whichtri].vertex[2]];
597 CrossProduct(p2-p1,p3-p1,&N);
598 CrossProduct(p0-p1,p3-p1,&temp);
599 s = dotproduct(&temp,&N)/findLength(&N);
600 CrossProduct(p2-p1,p1-p0,&temp);
601 t = dotproduct(&temp,&N)/findLength(&N);
604 bary.x = distsq(&p0, &p1);
605 bary.y = distsq(&p0, &p2);
606 bary.z = distsq(&p0, &p3);
608 total = bary.x + bary.y + bary.z;
617 total = bary.x + bary.y + bary.z;
623 gxx.x = skeleton.drawmodel.Triangles[whichtri].gx[0];
624 gxx.y = skeleton.drawmodel.Triangles[whichtri].gx[1];
625 gxx.z = skeleton.drawmodel.Triangles[whichtri].gx[2];
626 gyy.x = skeleton.drawmodel.Triangles[whichtri].gy[0];
627 gyy.y = skeleton.drawmodel.Triangles[whichtri].gy[1];
628 gyy.z = skeleton.drawmodel.Triangles[whichtri].gy[2];
629 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;
630 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;
632 //coordsx=skeleton.drawmodel.Triangles[whichtri].gx[1];
633 //coordsy=skeleton.drawmodel.Triangles[whichtri].gy[1];
635 if (bleeding <= 0 && spurt) {
637 for (int i = 0; i < 3; i++) {
639 if (!skeleton.free) {
641 bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
644 bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0);
647 bloodvel += DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
649 bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
651 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[head]].position * scale + coords, bloodvel, 1, 1, 1, .05, 1);
652 Sprite::MakeSprite(bloodflamesprite, skeleton.joints[skeleton.jointlabels[head]].position * scale + coords, bloodvel, 1, 1, 1, .3, 1);
654 if (!skeleton.free) {
655 Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
656 Sprite::MakeSprite(bloodflamesprite, DoRotation((skeleton.joints[skeleton.jointlabels[head]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .3, 1);
660 int offsetx = 0, offsety = 0;
663 offsetx=abs(Random()%120);
665 if(which==220||which==215){
667 offsetx=abs(Random()%80);
670 offsetx = (1 + coordsy) * 512 - 291;
671 offsety = coordsx * 512 - 437;
678 if (creature == rabbittype)
679 for (i = 0; i < 512; i++) {
680 for (j = 0; j < 512; j++) {
681 if (bloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && bloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
682 if (i < startx) startx = i;
683 if (j < starty) starty = j;
684 if (i > endx) endx = i;
685 if (j > endy) endy = j;
689 if (creature == wolftype)
690 for (i = 0; i < 512; i++) {
691 for (j = 0; j < 512; j++) {
692 if (wolfbloodText[i * 512 * 3 + j * 3 + 0] <= which + 4 && wolfbloodText[i * 512 * 3 + j * 3 + 0] >= which - 4) {
693 if (i < startx) startx = i;
694 if (j < starty) starty = j;
695 if (i > endx) endx = i;
696 if (j > endy) endy = j;
705 if (startx < 0) startx = 0;
706 if (starty < 0) starty = 0;
707 if (endx > 512 - 1) endx = 512 - 1;
708 if (endy > 512 - 1) endy = 512 - 1;
709 if (endx < startx) endx = startx;
710 if (endy < starty) endy = starty;
712 startx /= realtexdetail;
713 starty /= realtexdetail;
714 endx /= realtexdetail;
715 endy /= realtexdetail;
717 int texdetailint = realtexdetail;
719 if (creature == rabbittype)
720 for (i = startx; i < endx; i++) {
721 for (j = starty; j < endy; j++) {
722 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) {
723 color = Random() % 85 + 170;
724 where = i * skeleton.skinsize * 3 + j * 3;
725 if (skeleton.skinText[where + 0] > color / 2)
726 skeleton.skinText[where + 0] = color / 2;
727 skeleton.skinText[where + 1] = 0;
728 skeleton.skinText[where + 2] = 0;
729 } 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) {
730 color = Random() % 85 + 170;
731 where = i * skeleton.skinsize * 3 + j * 3;
732 if (skeleton.skinText[where + 0] > color / 2)
733 skeleton.skinText[where + 0] = color / 2;
734 skeleton.skinText[where + 1] = 0;
735 skeleton.skinText[where + 2] = 0;
739 if (creature == wolftype)
740 for (i = startx; i < endx; i++) {
741 for (j = starty; j < endy; j++) {
742 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) {
743 color = Random() % 85 + 170;
744 where = i * skeleton.skinsize * 3 + j * 3;
745 if (skeleton.skinText[where + 0] > color / 2)
746 skeleton.skinText[where + 0] = color / 2;
747 skeleton.skinText[where + 1] = 0;
748 skeleton.skinText[where + 2] = 0;
749 } 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) {
750 color = Random() % 85 + 170;
751 where = i * skeleton.skinsize * 3 + j * 3;
752 if (skeleton.skinText[where + 0] > color / 2)
753 skeleton.skinText[where + 0] = color / 2;
754 skeleton.skinText[where + 1] = 0;
755 skeleton.skinText[where + 2] = 0;
759 skeleton.drawmodel.textureptr.bind();
762 bleedy = (1 + coordsy) * 512;
763 bleedx = coordsx * 512;
764 bleedy /= realtexdetail;
765 bleedx /= realtexdetail;
770 if (bleedx > skeleton.skinsize - 1)
771 bleedx = skeleton.skinsize - 1;
772 if (bleedy > skeleton.skinsize - 1)
773 bleedy = skeleton.skinsize - 1;
774 direction = abs(Random() % 2) * 2 - 1;
779 bleeding = howmuch + (float)abs(Random() % 100) / 200 - .25;
780 deathbleeding += bleeding;
781 bloodloss += bleeding * 3;
783 if (tutoriallevel != 1 && aitype != playercontrolled && bloodloss > damagetolerance * 2 / 3 && bloodloss < damagetolerance && creature == rabbittype) {
784 if (abs(Random() % 2) == 0) {
785 aitype = gethelptype;
788 aitype = attacktypecutoff;
798 void Person::Reverse()
800 if (!((victim->aitype == playercontrolled
802 || staggerdelay <= 0)
803 && victim->animTarget != jumpupanim
804 && victim->animTarget != jumpdownanim
805 && (tutoriallevel != 1 || cananger)
809 if (normaldotproduct (victim->facing, victim->coords - coords) > 0
810 && (victim->id != 0 || difficulty >= 2)
811 && (creature != wolftype || victim->creature == wolftype))
814 if (animTarget == sweepanim) {
815 animTarget = sweepreversedanim;
816 animCurrent = sweepreversedanim;
817 victim->animCurrent = sweepreversalanim;
818 victim->animTarget = sweepreversalanim;
820 if (animTarget == spinkickanim) {
821 animTarget = spinkickreversedanim;
822 animCurrent = spinkickreversedanim;
823 victim->animCurrent = spinkickreversalanim;
824 victim->animTarget = spinkickreversalanim;
826 if (animTarget == upunchanim || animTarget == rabbittacklinganim) {
827 if (animTarget == rabbittacklinganim) {
830 victim->frameCurrent = 6;
831 victim->frameTarget = 7;
833 animTarget = upunchreversedanim;
834 animCurrent = upunchreversedanim;
835 victim->animCurrent = upunchreversalanim;
836 victim->animTarget = upunchreversalanim;
838 if (animTarget == staffhitanim && distsq(&victim->coords, &coords) < 2 && ((victim->id == 0 && victim->crouchkeydown) || Random() % 4 == 0)) {
839 if (victim->weaponactive != -1) {
840 victim->throwtogglekeydown = 1;
841 weapons[victim->weaponids[0]].owner = -1;
842 weapons[victim->weaponids[0]].velocity = victim->velocity * .2;
843 if (weapons[victim->weaponids[0]].velocity.x == 0)
844 weapons[victim->weaponids[0]].velocity.x = .1;
845 weapons[victim->weaponids[0]].tipvelocity = weapons[victim->weaponids[0]].velocity;
846 weapons[victim->weaponids[0]].missed = 1;
847 weapons[victim->weaponids[0]].freetime = 0;
848 weapons[victim->weaponids[0]].firstfree = 1;
849 weapons[victim->weaponids[0]].physics = 1;
850 victim->num_weapons--;
851 if (victim->num_weapons) {
852 victim->weaponids[0] = victim->weaponids[victim->num_weapons];
853 if (victim->weaponstuck == victim->num_weapons)
854 victim->weaponstuck = 0;
857 victim->weaponactive = -1;
858 for (int j = 0; j < numplayers; j++) {
859 player[j].wentforweapon = 0;
863 animTarget = staffhitreversedanim;
864 animCurrent = staffhitreversedanim;
865 victim->animCurrent = staffhitreversalanim;
866 victim->animTarget = staffhitreversalanim;
868 if (animTarget == staffspinhitanim && distsq(&victim->coords, &coords) < 2 && ((victim->id == 0 && victim->crouchkeydown) || Random() % 2 == 0)) {
869 if (victim->weaponactive != -1) {
870 victim->throwtogglekeydown = 1;
871 weapons[victim->weaponids[0]].owner = -1;
872 weapons[victim->weaponids[0]].velocity = victim->velocity * .2;
873 if (weapons[victim->weaponids[0]].velocity.x == 0)
874 weapons[victim->weaponids[0]].velocity.x = .1;
875 weapons[victim->weaponids[0]].tipvelocity = weapons[victim->weaponids[0]].velocity;
876 weapons[victim->weaponids[0]].missed = 1;
877 weapons[victim->weaponids[0]].freetime = 0;
878 weapons[victim->weaponids[0]].firstfree = 1;
879 weapons[victim->weaponids[0]].physics = 1;
880 victim->num_weapons--;
881 if (victim->num_weapons) {
882 victim->weaponids[0] = victim->weaponids[victim->num_weapons];
883 if (victim->weaponstuck == victim->num_weapons)
884 victim->weaponstuck = 0;
887 victim->weaponactive = -1;
888 for (int j = 0; j < numplayers; j++) {
889 player[j].wentforweapon = 0;
892 animTarget = staffspinhitreversedanim;
893 animCurrent = staffspinhitreversedanim;
894 victim->animCurrent = staffspinhitreversalanim;
895 victim->animTarget = staffspinhitreversalanim;
897 if (animTarget == swordslashanim && distsq(&victim->coords, &coords) < 2 && ((victim->id == 0 && victim->crouchkeydown) || Random() % 4 == 0)) {
898 if (victim->weaponactive != -1) {
899 victim->throwtogglekeydown = 1;
900 weapons[victim->weaponids[0]].owner = -1;
901 weapons[victim->weaponids[0]].velocity = victim->velocity * .2;
902 if (weapons[victim->weaponids[0]].velocity.x == 0)
903 weapons[victim->weaponids[0]].velocity.x = .1;
904 weapons[victim->weaponids[0]].tipvelocity = weapons[victim->weaponids[0]].velocity;
905 weapons[victim->weaponids[0]].missed = 1;
906 weapons[victim->weaponids[0]].freetime = 0;
907 weapons[victim->weaponids[0]].firstfree = 1;
908 weapons[victim->weaponids[0]].physics = 1;
909 victim->num_weapons--;
910 if (victim->num_weapons) {
911 victim->weaponids[0] = victim->weaponids[victim->num_weapons];
912 if (victim->weaponstuck == victim->num_weapons)
913 victim->weaponstuck = 0;
916 victim->weaponactive = -1;
917 for (int j = 0; j < numplayers; j++) {
918 player[j].wentforweapon = 0;
921 animTarget = swordslashreversedanim;
922 animCurrent = swordslashreversedanim;
923 victim->animCurrent = swordslashreversalanim;
924 victim->animTarget = swordslashreversalanim;
926 if (animTarget == knifeslashstartanim && distsq(&victim->coords, &coords) < 2 && (victim->id == 0 || Random() % 4 == 0)) {
927 if (victim->weaponactive != -1) {
928 victim->throwtogglekeydown = 1;
929 weapons[victim->weaponids[0]].owner = -1;
930 weapons[victim->weaponids[0]].velocity = victim->velocity * .2;
931 if (weapons[victim->weaponids[0]].velocity.x == 0)
932 weapons[victim->weaponids[0]].velocity.x = .1;
933 weapons[victim->weaponids[0]].tipvelocity = weapons[victim->weaponids[0]].velocity;
934 weapons[victim->weaponids[0]].missed = 1;
935 weapons[victim->weaponids[0]].freetime = 0;
936 weapons[victim->weaponids[0]].firstfree = 1;
937 weapons[victim->weaponids[0]].physics = 1;
938 victim->num_weapons--;
939 if (victim->num_weapons) {
940 victim->weaponids[0] = victim->weaponids[victim->num_weapons];
941 if (victim->weaponstuck == victim->num_weapons)
942 victim->weaponstuck = 0;
945 victim->weaponactive = -1;
946 for (int j = 0; j < numplayers; j++) {
947 player[j].wentforweapon = 0;
950 animTarget = knifeslashreversedanim;
951 animCurrent = knifeslashreversedanim;
952 victim->animCurrent = knifeslashreversalanim;
953 victim->animTarget = knifeslashreversalanim;
955 if (animTarget != knifeslashstartanim && animTarget != staffhitanim && animTarget != staffspinhitanim && animTarget != winduppunchanim && animTarget != wolfslapanim && animTarget != swordslashanim && animTarget != swordslashanim) {
956 victim->targettilt2 = targettilt2;
957 victim->frameCurrent = frameCurrent;
958 victim->frameTarget = frameTarget;
959 victim->target = target;
960 victim->velocity = 0;
961 victim->oldcoords = victim->coords;
962 victim->coords = coords;
963 victim->targetyaw = targetyaw;
964 victim->yaw = targetyaw;
965 victim->victim = this;
967 if (animTarget == winduppunchanim) {
968 animTarget = winduppunchblockedanim;
969 victim->animTarget = blockhighleftanim;
970 victim->frameTarget = 1;
972 victim->victim = this;
973 victim->targetyaw = targetyaw + 180;
975 if (animTarget == wolfslapanim) {
976 animTarget = winduppunchblockedanim;
977 victim->animTarget = blockhighleftanim;
978 victim->frameTarget = 1;
980 victim->victim = this;
981 victim->targetyaw = targetyaw + 180;
983 if ((animTarget == swordslashanim || animTarget == staffhitanim || animTarget == staffspinhitanim) && victim->weaponactive != -1) {
984 animTarget = swordslashparriedanim;
985 parriedrecently = .4;
986 victim->parriedrecently = 0;
987 victim->animTarget = swordslashparryanim;
988 victim->frameTarget = 1;
990 victim->victim = this;
991 victim->targetyaw = targetyaw + 180;
993 if (abs(Random() % 20) == 0 || weapons[victim->weaponids[victim->weaponactive]].getType() == knife) {
994 if (victim->weaponactive != -1) {
995 if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
996 if (weapons[victim->weaponids[0]].getType() == staff)
997 weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
998 if (weapons[weaponids[0]].getType() == staff)
999 weapons[weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
1000 emit_sound_at(swordstaffsound, victim->coords);
1002 emit_sound_at(metalhitsound, victim->coords);
1006 victim->Puff(righthand);
1008 victim->frameTarget = 0;
1009 victim->animTarget = staggerbackhighanim;
1010 victim->targetyaw = targetyaw + 180;
1012 weapons[victim->weaponids[0]].owner = -1;
1013 aim = DoRotation(facing, 0, 90, 0) * 21;
1015 weapons[victim->weaponids[0]].velocity = aim * -.2;
1016 weapons[victim->weaponids[0]].tipvelocity = aim;
1017 weapons[victim->weaponids[0]].missed = 1;
1018 weapons[victim->weaponids[0]].hitsomething = 0;
1019 weapons[victim->weaponids[0]].freetime = 0;
1020 weapons[victim->weaponids[0]].firstfree = 1;
1021 weapons[victim->weaponids[0]].physics = 1;
1022 victim->num_weapons--;
1023 if (victim->num_weapons) {
1024 victim->weaponids[0] = victim->weaponids[num_weapons];
1025 if (victim->weaponstuck == victim->num_weapons)
1026 victim->weaponstuck = 0;
1028 victim->weaponactive = -1;
1029 for (int i = 0; i < numplayers; i++) {
1030 player[i].wentforweapon = 0;
1034 if (abs(Random() % 20) == 0) {
1035 if (weaponactive != -1) {
1036 if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
1037 if (weapons[victim->weaponids[0]].getType() == staff)
1038 weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
1039 if (weapons[weaponids[0]].getType() == staff)
1040 weapons[weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
1042 emit_sound_at(swordstaffsound, coords);
1044 emit_sound_at(metalhitsound, coords);
1052 animTarget = staggerbackhighanim;
1053 targetyaw = targetyaw + 180;
1055 weapons[weaponids[0]].owner = -1;
1056 aim = DoRotation(facing, 0, 90, 0) * 21;
1058 weapons[weaponids[0]].velocity = aim * -.2;
1059 weapons[weaponids[0]].tipvelocity = aim;
1060 weapons[weaponids[0]].hitsomething = 0;
1061 weapons[weaponids[0]].missed = 1;
1062 weapons[weaponids[0]].freetime = 0;
1063 weapons[weaponids[0]].firstfree = 1;
1064 weapons[weaponids[0]].physics = 1;
1067 weaponids[0] = weaponids[num_weapons];
1068 if (weaponstuck == num_weapons)
1072 for (int i = 0; i < numplayers; i++) {
1073 player[i].wentforweapon = 0;
1080 if (animTarget == knifeslashstartanim || animTarget == swordslashanim || animTarget == staffhitanim || animTarget == staffspinhitanim) {
1081 if ((animTarget != staffhitanim && animTarget != staffspinhitanim) || distsq(&coords, &victim->coords) > .2) {
1082 victim->animTarget = dodgebackanim;
1083 victim->frameTarget = 0;
1087 rotatetarget = coords - victim->coords;
1088 Normalise(&rotatetarget);
1089 victim->targetyaw = -asin(0 - rotatetarget.x);
1090 victim->targetyaw *= 360 / 6.28;
1091 if (rotatetarget.z < 0)
1092 victim->targetyaw = 180 - victim->targetyaw;
1094 victim->targettilt2 = -asin(rotatetarget.y) * 360 / 6.28; //*-70;
1096 victim->lastattack3 = victim->lastattack2;
1097 victim->lastattack2 = victim->lastattack;
1098 victim->lastattack = victim->animTarget;
1100 victim->animTarget = sweepanim;
1101 victim->frameTarget = 0;
1105 rotatetarget = coords - victim->coords;
1106 Normalise(&rotatetarget);
1107 victim->targetyaw = -asin(0 - rotatetarget.x);
1108 victim->targetyaw *= 360 / 6.28;
1109 if (rotatetarget.z < 0)
1110 victim->targetyaw = 180 - victim->targetyaw;
1112 victim->targettilt2 = -asin(rotatetarget.y) * 360 / 6.28; //*-70;
1114 victim->lastattack3 = victim->lastattack2;
1115 victim->lastattack2 = victim->lastattack;
1116 victim->lastattack = victim->animTarget;
1121 victim->velocity = 0;
1123 if (aitype != playercontrolled)
1125 if (aitype != playercontrolled && Random() % 3 == 0 && escapednum < 2 && difficulty == 2)
1127 if (aitype != playercontrolled && Random() % 5 == 0 && escapednum < 2 && difficulty == 1)
1129 if (aitype != playercontrolled && Random() % 10 == 0 && escapednum < 2 && difficulty == 0)
1132 if (victim->id == 0 && animation[victim->animTarget].attack == reversal)
1136 void Person::DoDamage(float howmuch)
1138 if (tutoriallevel != 1)
1139 damage += howmuch / power;
1141 damagedealt += howmuch / power;
1143 damagetaken += howmuch / power;
1145 if (id == 0 && (bonus == solidhit || bonus == twoxcombo || bonus == threexcombo || bonus == fourxcombo || bonus == megacombo))
1147 if (tutoriallevel != 1)
1148 permanentdamage += howmuch / 2 / power;
1149 if (tutoriallevel != 1)
1150 superpermanentdamage += howmuch / 4 / power;
1151 if (permanentdamage > damagetolerance / 2 && permanentdamage - howmuch < damagetolerance / 2 && Random() % 2)
1153 if ((permanentdamage > damagetolerance * .8 && Random() % 2 && !deathbleeding) || spurt)
1157 camerashake += howmuch / 100;
1158 if (id == 0 && ((howmuch > 50 && damage > damagetolerance / 2)))
1159 blackout = damage / damagetolerance;
1163 if (aitype == passivetype && damage < damagetolerance && ((tutoriallevel != 1 || cananger) && hostile))
1164 aitype = attacktypecutoff;
1165 if (tutoriallevel != 1 && aitype != playercontrolled && damage < damagetolerance && damage > damagetolerance * 2 / 3 && creature == rabbittype) {
1166 if (abs(Random() % 2) == 0) {
1167 aitype = gethelptype;
1170 aitype = attacktypecutoff;
1174 if (howmuch > damagetolerance * 50 && skeleton.free != 2) {
1177 for (int i = 0; i < skeleton.num_joints; i++) {
1179 flatvelocity2 = velocity;
1181 flatvelocity2 = skeleton.joints[i].velocity;
1183 flatfacing2 = DoRotation(DoRotation(DoRotation(skeleton.joints[i].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
1185 flatfacing2 = skeleton.joints[i].position * scale + coords;
1186 flatvelocity2.x += (float)(abs(Random() % 100) - 50) / 10;
1187 flatvelocity2.y += (float)(abs(Random() % 100) - 50) / 10;
1188 flatvelocity2.z += (float)(abs(Random() % 100) - 50) / 10;
1189 Sprite::MakeSprite(bloodflamesprite, flatfacing2, flatvelocity2, 1, 1, 1, 3, 1);
1190 Sprite::MakeSprite(bloodsprite, flatfacing2, flatvelocity2, 1, 1, 1, .4, 1);
1191 Sprite::MakeSprite(cloudsprite, flatfacing2, flatvelocity2 * 0, .6, 0, 0, 1, .5);
1194 emit_sound_at(splattersound, coords);
1203 if (!dead && creature == wolftype) {
1204 award_bonus(0, Wolfbonus);
1210 if (tutoriallevel != 1 || id == 0)
1211 if (speechdelay <= 0 && !dead && aitype != playercontrolled) {
1212 int whichsound = -1;
1214 if (creature == wolftype) {
1215 int i = abs(Random() % 2);
1217 whichsound = snarlsound;
1219 whichsound = snarl2sound;
1220 envsound[numenvsounds] = coords;
1221 envsoundvol[numenvsounds] = 16;
1222 envsoundlife[numenvsounds] = .4;
1225 if (creature == rabbittype) {
1226 int i = abs(Random() % 2);
1228 whichsound = rabbitpainsound;
1229 if (i == 1 && damage > damagetolerance)
1230 whichsound = rabbitpain1sound;
1231 envsound[numenvsounds] = coords;
1232 envsoundvol[numenvsounds] = 16;
1233 envsoundlife[numenvsounds] = .4;
1235 //if(i==2)whichsound=rabbitpain2sound;
1238 if (whichsound != -1) {
1239 emit_sound_at(whichsound, coords);
1244 //if(permanentdamage>=damagetolerance&&howmuch<50)permanentdamage=damagetolerance-1;
1245 //if(damage>=damagetolerance&&howmuch<30&&!dead)damage=damagetolerance-1;
1248 void Person::DoHead()
1250 static XYZ rotatearound;
1252 static float lookspeed = 500;
1254 if (!freeze && !winfreeze) {
1257 targetheadyaw = (float)((int)((0 - yaw - targetheadyaw + 180) * 100) % 36000) / 100;
1258 targetheadpitch = (float)((int)(targetheadpitch * 100) % 36000) / 100;
1260 while (targetheadyaw > 180)targetheadyaw -= 360;
1261 while (targetheadyaw < -180)targetheadyaw += 360;
1263 if (targetheadyaw > 160)
1264 targetheadpitch = targetheadpitch * -1;
1265 if (targetheadyaw < -160)
1266 targetheadpitch = targetheadpitch * -1;
1267 if (targetheadyaw > 160)
1268 targetheadyaw = targetheadyaw - 180;
1269 if (targetheadyaw < -160)
1270 targetheadyaw = targetheadyaw + 180;
1272 if (targetheadpitch > 120)
1273 targetheadpitch = 120;
1274 if (targetheadpitch < -120)
1275 targetheadpitch = -120;
1276 if (targetheadyaw > 120)
1277 targetheadyaw = 120;
1278 if (targetheadyaw < -120)
1279 targetheadyaw = -120;
1282 targetheadpitch = 0;
1284 if (targetheadyaw > 80)
1286 if (targetheadyaw < -80)
1287 targetheadyaw = -80;
1288 if (targetheadpitch > 50)
1289 targetheadpitch = 50;
1290 if (targetheadpitch < -50)
1291 targetheadpitch = -50;
1294 if (abs(headyaw - targetheadyaw) < multiplier * lookspeed)
1295 headyaw = targetheadyaw;
1296 else if (headyaw > targetheadyaw) {
1297 headyaw -= multiplier * lookspeed;
1298 } else if (headyaw < targetheadyaw) {
1299 headyaw += multiplier * lookspeed;
1302 if (abs(headpitch - targetheadpitch) < multiplier * lookspeed / 2)
1303 headpitch = targetheadpitch;
1304 else if (headpitch > targetheadpitch) {
1305 headpitch -= multiplier * lookspeed / 2;
1306 } else if (headpitch < targetheadpitch) {
1307 headpitch += multiplier * lookspeed / 2;
1310 rotatearound = skeleton.joints[skeleton.jointlabels[neck]].position;
1311 skeleton.joints[skeleton.jointlabels[head]].position = rotatearound + DoRotation(skeleton.joints[skeleton.jointlabels[head]].position - rotatearound, headpitch, 0, 0);
1315 if (animTarget != bounceidleanim && animTarget != fightidleanim && animTarget != wolfidle && animTarget != knifefightidleanim && animTarget != drawrightanim && animTarget != drawleftanim && animTarget != walkanim) {
1316 facing = DoRotation(facing, headpitch * .4, 0, 0);
1317 facing = DoRotation(facing, 0, headyaw * .4, 0);
1320 if (animTarget == bounceidleanim || animTarget == fightidleanim || animTarget == wolfidle || animTarget == knifefightidleanim || animTarget == drawrightanim || animTarget == drawleftanim) {
1321 facing = DoRotation(facing, headpitch * .8, 0, 0);
1322 facing = DoRotation(facing, 0, headyaw * .8, 0);
1325 if (animTarget == walkanim) {
1326 facing = DoRotation(facing, headpitch * .6, 0, 0);
1327 facing = DoRotation(facing, 0, headyaw * .6, 0);
1330 skeleton.specialforward[0] = facing;
1331 //skeleton.specialforward[0]=DoRotation(facing,0,yaw,0);
1333 for (i = 0; i < skeleton.num_muscles; i++) {
1334 if (skeleton.muscles[i].visible && (skeleton.muscles[i].parent1->label == head || skeleton.muscles[i].parent2->label == head)) {
1335 skeleton.FindRotationMuscle(i, animTarget);
1341 void Person::RagDoll(bool checkcollision)
1346 if (!skeleton.free) {
1349 if (id == 0 && isFlip())
1356 facing = DoRotation(facing, 0, yaw, 0);
1358 skeleton.freetime = 0;
1360 skeleton.longdead = 0;
1363 skeleton.broken = 0;
1364 skeleton.spinny = 1;
1366 skeleton.freefall = 1;
1368 if (!isnormal(velocity.x)) velocity.x = 0;
1369 if (!isnormal(velocity.y)) velocity.y = 0;
1370 if (!isnormal(velocity.z)) velocity.z = 0;
1371 if (!isnormal(yaw)) yaw = 0;
1372 if (!isnormal(coords.x)) coords = 0;
1373 if (!isnormal(tilt)) tilt = 0;
1374 if (!isnormal(tilt2)) tilt2 = 0;
1376 for (i = 0; i < skeleton.num_joints; i++) {
1377 skeleton.joints[i].delay = 0;
1378 skeleton.joints[i].locked = 0;
1379 skeleton.joints[i].position = DoRotation(DoRotation(DoRotation(skeleton.joints[i].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
1380 if (!isnormal(skeleton.joints[i].position.x)) skeleton.joints[i].position = DoRotation(skeleton.joints[i].position, 0, yaw, 0);
1381 if (!isnormal(skeleton.joints[i].position.x)) skeleton.joints[i].position = skeleton.joints[i].position;
1382 if (!isnormal(skeleton.joints[i].position.x)) skeleton.joints[i].position = coords;
1383 skeleton.joints[i].position.y += .1;
1384 skeleton.joints[i].oldposition = skeleton.joints[i].position;
1385 skeleton.joints[i].realoldposition = skeleton.joints[i].position * scale + coords;
1388 for (i = 0; i < skeleton.num_joints; i++) {
1389 skeleton.joints[i].velocity = 0;
1390 skeleton.joints[i].velchange = 0;
1392 skeleton.DoConstraints(&coords, &scale);
1393 if (animation[animCurrent].height == lowheight || animation[animTarget].height == lowheight) {
1394 skeleton.DoConstraints(&coords, &scale);
1395 skeleton.DoConstraints(&coords, &scale);
1396 skeleton.DoConstraints(&coords, &scale);
1397 skeleton.DoConstraints(&coords, &scale);
1400 speed = animation[animTarget].speed[frameTarget] * 2;
1401 if (animation[animCurrent].speed[frameCurrent] > animation[animTarget].speed[frameTarget]) {
1402 speed = animation[animCurrent].speed[frameCurrent] * 2;
1405 speed = transspeed * 2;
1409 for (i = 0; i < skeleton.num_joints; i++) {
1410 if ((animation[animCurrent].attack != reversed || animCurrent == swordslashreversedanim) && animCurrent != rabbitkickanim && !isLanding() && !wasLanding() && animation[animCurrent].height == animation[animTarget].height)
1411 skeleton.joints[i].velocity = velocity / scale + facing * 5 + DoRotation(DoRotation(DoRotation((animation[animTarget].position[i][frameTarget] - animation[animCurrent].position[i][frameCurrent]) * speed, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0);
1413 skeleton.joints[i].velocity = velocity / scale + facing * 5;
1414 change.x = (float)(Random() % 100) / 100;
1415 change.y = (float)(Random() % 100) / 100;
1416 change.z = (float)(Random() % 100) / 100;
1417 skeleton.joints[i].velocity += change;
1418 skeleton.joints[abs(Random() % skeleton.num_joints)].velocity -= change;
1420 change.x = (float)(Random() % 100) / 100;
1421 change.y = (float)(Random() % 100) / 100;
1422 change.z = (float)(Random() % 100) / 100;
1423 skeleton.joints[i].velchange += change;
1424 skeleton.joints[abs(Random() % skeleton.num_joints)].velchange -= change;
1427 if (checkcollision) {
1434 for (j = 0; j < skeleton.num_joints; j++) {
1435 average += skeleton.joints[j].position;
1439 coords += average * scale;
1440 for (j = 0; j < skeleton.num_joints; j++) {
1441 skeleton.joints[j].position -= average;
1444 whichpatchx = coords.x / (terrain.size / subdivision * terrain.scale);
1445 whichpatchz = coords.z / (terrain.size / subdivision * terrain.scale);
1446 if (terrain.patchobjectnum[whichpatchx][whichpatchz])
1447 for (l = 0; l < terrain.patchobjectnum[whichpatchx][whichpatchz]; l++) {
1448 i = terrain.patchobjects[whichpatchx][whichpatchz][l];
1451 if (SphereCheck(&lowpoint, 3, &colpoint, &objects.position[i], &objects.yaw[i], &objects.model[i]) != -1) {
1452 coords.x = lowpoint.x;
1453 coords.z = lowpoint.z;
1462 for (i = 0; i < skeleton.num_joints; i++) {
1463 velocity += skeleton.joints[i].velocity * scale;
1465 velocity /= skeleton.num_joints;
1467 if (Random() % 2 == 0) {
1468 if (weaponactive != -1 && animTarget != rabbitkickanim && num_weapons > 0) {
1469 weapons[weaponids[0]].owner = -1;
1470 weapons[weaponids[0]].hitsomething = 0;
1471 weapons[weaponids[0]].velocity = skeleton.joints[skeleton.jointlabels[righthand]].velocity * scale * -.3;
1472 weapons[weaponids[0]].velocity.x += .01;
1473 weapons[weaponids[0]].tipvelocity = skeleton.joints[skeleton.jointlabels[righthand]].velocity * scale;
1474 weapons[weaponids[0]].missed = 1;
1475 weapons[weaponids[0]].freetime = 0;
1476 weapons[weaponids[0]].firstfree = 1;
1477 weapons[weaponids[0]].physics = 1;
1480 weaponids[0] = weaponids[num_weapons];
1481 if (weaponstuck == num_weapons)
1485 for (i = 0; i < numplayers; i++) {
1486 player[i].wentforweapon = 0;
1491 animTarget = bounceidleanim;
1492 animCurrent = bounceidleanim;
1500 void Person::FootLand(int which, float opacity)
1502 static XYZ terrainlight;
1503 static XYZ footvel, footpoint;
1504 if (opacity >= 1 || skiddelay <= 0)
1508 footpoint = DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) * scale + coords;
1510 footpoint = DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0) * scale + coords;
1511 //footpoint.y=coords.y;
1512 if (distsq(&footpoint, &viewer))
1513 Sprite::MakeSprite(cloudsprite, footpoint, footvel, 1, 1, 1, .5, .2 * opacity);
1514 } else if (environment == snowyenvironment && onterrain && terrain.getOpacity(coords.x, coords.z) < .2) {
1515 footvel = velocity / 5;
1519 footpoint = DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) * scale + coords;
1521 footpoint = DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0) * scale + coords;
1522 footpoint.y = terrain.getHeight(footpoint.x, footpoint.z);
1523 terrainlight = terrain.getLighting(footpoint.x, footpoint.z);
1524 if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
1525 Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, terrainlight.x, terrainlight.y, terrainlight.z, .5, .7 * opacity);
1526 if (opacity >= 1 || detail == 2)
1528 if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
1529 terrain.MakeDecal(footprintdecal, footpoint, .2, 1 * opacity, yaw);
1530 } else if (environment == grassyenvironment && onterrain && terrain.getOpacity(coords.x, coords.z) < .2) {
1531 footvel = velocity / 5;
1535 footpoint = DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) * scale + coords;
1537 footpoint = DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0) * scale + coords;
1538 footpoint.y = terrain.getHeight(footpoint.x, footpoint.z);
1539 terrainlight = terrain.getLighting(footpoint.x, footpoint.z);
1540 if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
1541 Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, terrainlight.x * 90 / 255, terrainlight.y * 70 / 255, terrainlight.z * 8 / 255, .5, .5 * opacity);
1542 } else if (environment == desertenvironment && onterrain && terrain.getOpacity(coords.x, coords.z) < .2) {
1543 footvel = velocity / 5;
1547 footpoint = DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) * scale + coords;
1549 footpoint = DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0) * scale + coords;
1550 footpoint.y = terrain.getHeight(footpoint.x, footpoint.z);
1551 terrainlight = terrain.getLighting(footpoint.x, footpoint.z);
1552 if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
1553 Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, terrainlight.x * 190 / 255, terrainlight.y * 170 / 255, terrainlight.z * 108 / 255, .5, .7 * opacity);
1554 if (opacity >= 1 || detail == 2)
1556 if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
1557 terrain.MakeDecal(footprintdecal, footpoint, .2, .25 * opacity, yaw);
1558 } else if (isLanding() || animTarget == jumpupanim || isLandhard()) {
1559 footvel = velocity / 5;
1563 footpoint = DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) * scale + coords;
1565 footpoint = DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0) * scale + coords;
1566 //footpoint.y=coords.y;
1567 if (distsq(&footpoint, &viewer) < viewdistance * viewdistance / 4)
1568 Sprite::MakeSprite(cloudsprite, footpoint, footvel * .6, 1, 1, 1, .5, .2 * opacity);
1572 void Person::Puff(int whichlabel)
1574 static XYZ footvel, footpoint;
1577 footpoint = DoRotation(skeleton.joints[skeleton.jointlabels[whichlabel]].position, 0, yaw, 0) * scale + coords;
1578 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 1, 1, .9, .3);
1581 Joint& Person::getJointFor(int bodypart)
1583 return skeleton.joints[skeleton.jointlabels[bodypart]];
1586 void Person::setAnimation(int animation)
1588 animTarget = animation;
1593 void Person::DoAnimations()
1595 if (!skeleton.free) {
1597 static float oldtarget;
1599 if (isIdle() && animCurrent != getIdle())
1600 normalsupdatedelay = 0;
1602 if (animTarget == tempanim || animCurrent == tempanim) {
1603 animation[tempanim] = tempanimation;
1605 if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) {
1611 vel[0] = velocity.x;
1612 vel[1] = velocity.y;
1613 vel[2] = velocity.z;
1616 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
1617 OPENAL_SetVolume(channels[whooshsound], 64 * findLength(&velocity) / 5);
1619 if (((velocity.y < -15) || (crouchkeydown && velocity.y < -8)) && abs(velocity.y) * 4 > fast_sqrt(velocity.x * velocity.x * velocity.z * velocity.z))
1621 if (!crouchkeydown && velocity.y >= -15)
1624 if ((animCurrent == jumpupanim || animTarget == jumpdownanim)/*&&velocity.y<40*/ && !isFlip() && (!isLanding() && !isLandhard()) && ((crouchkeydown && !crouchtogglekeydown))) {
1629 targfacing = DoRotation(targfacing, 0, targetyaw, 0);
1631 if (normaldotproduct(targfacing, velocity) >= -.3)
1632 animTarget = flipanim;
1634 animTarget = backflipanim;
1635 crouchtogglekeydown = 1;
1643 if (animation[animTarget].attack != reversed)
1645 if (!crouchkeydown || (isLanding() || isLandhard()) || (wasLanding() || wasLandhard())) {
1646 crouchtogglekeydown = 0;
1647 if (aitype == playercontrolled)
1650 if (!crouchtogglekeydown && animation[animTarget].attack == reversed && aitype == playercontrolled && (escapednum < 2 || reversaltrain))
1653 crouchtogglekeydown = 1;
1657 if (animation[animTarget].attack || animCurrent == getupfrombackanim || animCurrent == getupfromfrontanim) {
1659 normalsupdatedelay = 0;
1663 if (animTarget == rollanim && frameTarget == 3 && onfire) {
1665 emit_sound_at(fireendsound, coords);
1666 pause_sound(stream_firesound);
1670 if (animTarget == rabbittacklinganim && frameTarget == 1) {
1671 //if(victim->aitype==attacktypecutoff&&Random()%2==0&&victim->stunned<=0&&animation[victim->animTarget].attack==neutral&&victim->id!=0)Reverse();
1672 if (victim->aitype == attacktypecutoff && victim->stunned <= 0 && victim->surprised <= 0 && victim->id != 0)
1674 if (animTarget == rabbittacklinganim && frameTarget == 1 && !victim->isCrouch() && victim->animTarget != backhandspringanim) {
1675 if (normaldotproduct(victim->facing, facing) > 0)
1676 victim->animTarget = rabbittackledbackanim;
1678 victim->animTarget = rabbittackledfrontanim;
1679 victim->frameTarget = 2;
1682 victim->targetyaw = yaw;
1683 if (victim->aitype == gethelptype)
1684 victim->DoDamage(victim->damagetolerance - victim->damage);
1685 //victim->DoDamage(30);
1686 if (creature == wolftype) {
1688 emit_sound_at(clawslicesound, victim->coords);
1690 victim->DoBloodBig(1 / victim->armorhead, 210);
1692 award_bonus(id, TackleBonus,
1693 victim->aitype == gethelptype ? 50 : 0);
1697 if (!drawtogglekeydown && drawkeydown && (weaponactive == -1 || num_weapons == 1) && (animation[animTarget].label[frameTarget] || (animTarget != animCurrent && animCurrent == rollanim)) && num_weapons > 0 && creature != wolftype) {
1698 if (weapons[weaponids[0]].getType() == knife) {
1699 if (weaponactive == -1)
1701 else if (weaponactive == 0)
1704 if (weaponactive == -1) {
1705 emit_sound_at(knifesheathesound, coords);
1707 if (weaponactive != -1) {
1708 emit_sound_at(knifedrawsound, coords, 128);
1711 drawtogglekeydown = 1;
1714 if (tutoriallevel != 1 || id == 0)
1715 if ((animation[animTarget].label[frameTarget] && (animation[animTarget].label[frameTarget] < 5 || animation[animTarget].label[frameTarget] == 8))/*||(animTarget==rollanim&&frameTarget==animation[rollanim].numframes-1)*/) {
1718 if (terrain.getOpacity(coords.x, coords.z) < .2) {
1719 if (animation[animTarget].label[frameTarget] == 1)
1720 whichsound = footstepsound;
1722 whichsound = footstepsound2;
1723 if (animation[animTarget].label[frameTarget] == 1)
1725 if (animation[animTarget].label[frameTarget] == 2)
1727 if (animation[animTarget].label[frameTarget] == 3 && isRun()) {
1733 if (terrain.getOpacity(coords.x, coords.z) >= .2) {
1734 if (animation[animTarget].label[frameTarget] == 1)
1735 whichsound = footstepsound3;
1737 whichsound = footstepsound4;
1741 if (animation[animTarget].label[frameTarget] == 1)
1742 whichsound = footstepsound3;
1744 whichsound = footstepsound4;
1746 if (animation[animTarget].label[frameTarget] == 4 && (weaponactive == -1 || (animTarget != knifeslashstartanim && animTarget != knifethrowanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != knifefollowanim))) {
1747 if (animation[animTarget].attack != neutral) {
1748 i = abs(Random() % 3);
1750 whichsound = lowwhooshsound;
1752 whichsound = midwhooshsound;
1754 whichsound = highwhooshsound;
1756 if (animation[animTarget].attack == neutral)
1757 whichsound = movewhooshsound;
1758 } else if (animation[animTarget].label[frameTarget] == 4)
1759 whichsound = knifeswishsound;
1760 if (animation[animTarget].label[frameTarget] == 8 && tutoriallevel != 1)
1761 whichsound = landsound2;
1763 emit_sound_at(whichsound, coords, 256.);
1766 if (whichsound == footstepsound || whichsound == footstepsound2 || whichsound == footstepsound3 || whichsound == footstepsound4) {
1767 envsound[numenvsounds] = coords;
1768 if (animTarget == wolfrunninganim || animTarget == rabbitrunninganim)
1769 envsoundvol[numenvsounds] = 15;
1771 envsoundvol[numenvsounds] = 6;
1772 envsoundlife[numenvsounds] = .4;
1776 if (animation[animTarget].label[frameTarget] == 3) {
1778 emit_sound_at(whichsound, coords, 128.);
1783 if (tutoriallevel != 1 || id == 0)
1784 if (speechdelay <= 0)
1785 if (animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != staffgroundsmashanim)
1786 if ((animation[animTarget].label[frameTarget] && (animation[animTarget].label[frameTarget] < 5 || animation[animTarget].label[frameTarget] == 8))/*||(animTarget==rollanim&&frameTarget==animation[rollanim].numframes-1)*/) {
1787 int whichsound = -1;
1788 if (animation[animTarget].label[frameTarget] == 4 && aitype != playercontrolled) {
1789 if (animation[animTarget].attack != neutral) {
1790 i = abs(Random() % 4);
1791 if (creature == rabbittype) {
1792 if (i == 0) whichsound = rabbitattacksound;
1793 if (i == 1) whichsound = rabbitattack2sound;
1794 if (i == 2) whichsound = rabbitattack3sound;
1795 if (i == 3) whichsound = rabbitattack4sound;
1797 if (creature == wolftype) {
1798 if (i == 0) whichsound = barksound;
1799 if (i == 1) whichsound = bark2sound;
1800 if (i == 2) whichsound = bark3sound;
1801 if (i == 3) whichsound = barkgrowlsound;
1805 //if(animation[animTarget].attack==neutral)whichsound=movewhooshsound;
1807 //else if(animation[animTarget].label[frameTarget]==4)whichsound=knifeswishsound;
1808 //if(animation[animTarget].label[frameTarget]==8)whichsound=landsound2;
1810 if (whichsound != -1) {
1811 emit_sound_at(whichsound, coords);
1817 if ((!wasLanding() && !wasLandhard()) && animCurrent != getIdle() && (isLanding() || isLandhard())) {
1823 currentoffset = targetoffset;
1824 frameTarget = frameCurrent;
1825 animCurrent = animTarget;
1828 if (animTarget == removeknifeanim && animation[animTarget].label[frameCurrent] == 5) {
1829 for (i = 0; i < weapons.size(); i++) {
1830 if (weapons[i].owner == -1)
1831 if (distsqflat(&coords, &weapons[i].position) < 4 && weaponactive == -1) {
1832 if (distsq(&coords, &weapons[i].position) >= 1) {
1833 if (weapons[i].getType() != staff) {
1834 emit_sound_at(knifedrawsound, coords, 128.);
1838 weapons[i].owner = id;
1839 if (num_weapons > 0) {
1840 weaponids[num_weapons] = weaponids[0];
1849 if (animTarget == crouchremoveknifeanim && animation[animTarget].label[frameCurrent] == 5) {
1850 for (i = 0; i < weapons.size(); i++) {
1851 bool willwork = true;
1852 if (weapons[i].owner != -1)
1853 if (player[weapons[i].owner].weaponstuck != -1)
1854 if (player[weapons[i].owner].weaponids[player[weapons[i].owner].weaponstuck] == i)
1855 if (player[weapons[i].owner].num_weapons > 1)
1857 if ((weapons[i].owner == -1) || (hasvictim && weapons[i].owner == victim->id && victim->skeleton.free))
1858 if (willwork && distsqflat(&coords, &weapons[i].position) < 3 && weaponactive == -1) {
1859 if (distsq(&coords, &weapons[i].position) < 1 || hasvictim) {
1860 bool fleshstuck = false;
1861 if (weapons[i].owner != -1)
1862 if (victim->weaponstuck != -1) {
1863 if (victim->weaponids[victim->weaponstuck] == i) {
1868 emit_sound_at(fleshstabremovesound, coords, 128.);
1870 if (weapons[i].getType() != staff) {
1871 emit_sound_at(knifedrawsound, coords, 128.);
1875 if (weapons[i].owner != -1) {
1877 victim = &player[weapons[i].owner];
1878 if (victim->num_weapons == 1)
1879 victim->num_weapons = 0;
1881 victim->num_weapons = 1;
1883 //victim->weaponactive=-1;
1884 victim->skeleton.longdead = 0;
1885 victim->skeleton.free = 1;
1886 victim->skeleton.broken = 0;
1888 for (int j = 0; j < victim->skeleton.num_joints; j++) {
1889 victim->skeleton.joints[j].velchange = 0;
1890 victim->skeleton.joints[j].locked = 0;
1896 Normalise(&relative);
1897 XYZ footvel, footpoint;
1899 footpoint = weapons[i].position;
1900 if (victim->weaponstuck != -1) {
1901 if (victim->weaponids[victim->weaponstuck] == i) {
1903 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3);
1904 weapons[i].bloody = 2;
1905 weapons[i].blooddrip = 5;
1906 victim->weaponstuck = -1;
1909 if (victim->num_weapons > 0) {
1910 if (victim->weaponstuck != 0 && victim->weaponstuck != -1)
1911 victim->weaponstuck = 0;
1912 if (victim->weaponids[0] == i)
1913 victim->weaponids[0] = victim->weaponids[victim->num_weapons];
1916 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * 6;
1917 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity += relative * 6;
1918 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity += relative * 6;
1919 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity += relative * 6;
1921 weapons[i].owner = id;
1922 if (num_weapons > 0) {
1923 weaponids[num_weapons] = weaponids[0];
1932 if (animCurrent == drawleftanim && animation[animTarget].label[frameCurrent] == 5) {
1933 if (weaponactive == -1)
1935 else if (weaponactive == 0) {
1937 if (num_weapons == 2) {
1939 buffer = weaponids[0];
1940 weaponids[0] = weaponids[1];
1941 weaponids[1] = buffer;
1944 if (weaponactive == -1) {
1945 emit_sound_at(knifesheathesound, coords, 128.);
1947 if (weaponactive != -1) {
1948 emit_sound_at(knifedrawsound, coords, 128.);
1953 if ((animCurrent == walljumprightkickanim && animTarget == walljumprightkickanim) || (animCurrent == walljumpleftkickanim && animTarget == walljumpleftkickanim)) {
1954 XYZ rotatetarget = DoRotation(skeleton.forward, 0, yaw, 0);
1955 Normalise(&rotatetarget);
1956 targetyaw = -asin(0 - rotatetarget.x);
1957 targetyaw *= 360 / 6.28;
1958 if (rotatetarget.z < 0)
1959 targetyaw = 180 - targetyaw;
1961 if (animTarget == walljumprightkickanim)
1963 if (animTarget == walljumpleftkickanim)
1969 if ((animTarget == rabbitrunninganim || animTarget == wolfrunninganim) && frameTarget == 3 && (jumpkeydown || attackkeydown || id != 0))
1972 if (distsq(&victim->coords, &/*player[i].*/coords) < 5 && victim->aitype == gethelptype && (attackkeydown) && !victim->skeleton.free && victim->isRun() && victim->runninghowlong >= 1)
1977 if ((animTarget == rabbitrunninganim || animTarget == wolfrunninganim) && id == 0) {
1978 animTarget = rabbittackleanim;
1980 emit_sound_at(jumpsound, coords);
1988 targetloc = velocity;
1989 Normalise(&targetloc);
1990 targetloc += coords;
1991 for (i = 0; i < numplayers; i++) {
1993 if (distsq(&targetloc, &player[i].coords) < closestdist || closestdist == 0) {
1994 closestdist = distsq(&targetloc, &player[i].coords);
1998 if (closestid != -1)
1999 if (closestdist < 5 && !player[closestid].dead && animation[player[closestid].animTarget].height != lowheight && player[closestid].animTarget != backhandspringanim) {
2001 victim = &player[closestid];
2002 coords = victim->coords;
2003 animCurrent = rabbittacklinganim;
2004 animTarget = rabbittacklinganim;
2008 if (coords.z != victim->coords.z || coords.x != victim->coords.x) {
2009 rotatetarget = coords - victim->coords;
2010 Normalise(&rotatetarget);
2011 targetyaw = -asin(0 - rotatetarget.x);
2012 targetyaw *= 360 / 6.28;
2013 if (rotatetarget.z < 0)
2014 targetyaw = 180 - targetyaw;
2016 if (animTarget != rabbitrunninganim) {
2017 emit_sound_at(jumpsound, coords, 128.);
2023 float damagemult = 1 * power;
2024 if (creature == wolftype)
2025 damagemult = 2.5 * power;
2027 damagemult /= victim->damagetolerance / 200;
2029 //if(onfire)damagemult=3;
2030 if ((animation[animTarget].attack == normalattack || animTarget == walljumprightkickanim || animTarget == walljumpleftkickanim) && (!feint) && (victim->skeleton.free != 2 || animTarget == killanim || animTarget == dropkickanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || animTarget == staffgroundsmashanim)) {
2031 if (animTarget == spinkickanim && animation[animTarget].label[frameCurrent] == 5) {
2032 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && 3 && animation[victim->animTarget].height != lowheight) {
2036 if (Random() % 2 || creature == wolftype) {
2039 if (creature == wolftype)
2042 if (tutoriallevel != 1) {
2043 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2045 if (creature == wolftype) {
2046 emit_sound_at(clawslicesound, victim->coords, 128.);
2048 victim->DoBloodBig(2 / victim->armorhead, 175);
2052 relative = victim->coords - coords;
2054 Normalise(&relative);
2055 relative = DoRotation(relative, 0, -90, 0);
2056 for (i = 0; i < victim->skeleton.num_joints; i++) {
2057 victim->skeleton.joints[i].velocity += relative * damagemult * 40;
2059 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
2062 victim->DoDamage(damagemult * 100 / victim->protectionhead);
2068 if (animTarget == wolfslapanim && animation[animTarget].label[frameCurrent] == 5) {
2069 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && 3 && animation[victim->animTarget].height != lowheight) {
2073 if (Random() % 2 || creature == wolftype) {
2075 if (creature == wolftype)
2078 emit_sound_at(whooshhitsound, victim->coords);
2079 if (creature == wolftype) {
2080 emit_sound_at(clawslicesound, victim->coords, 128.);
2082 victim->DoBloodBig(2, 175);
2086 relative = victim->coords - coords;
2088 Normalise(&relative);
2090 Normalise(&relative);
2091 relative = DoRotation(relative, 0, 90, 0);
2092 for (i = 0; i < victim->skeleton.num_joints; i++) {
2093 victim->skeleton.joints[i].velocity += relative * damagemult * 20;
2095 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 100;
2098 victim->DoDamage(damagemult * 50 / victim->protectionhead);
2102 if (animTarget == walljumprightkickanim && animation[animTarget].label[frameCurrent] == 5) {
2103 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != lowheight) {
2109 if (tutoriallevel != 1) {
2110 emit_sound_at(heavyimpactsound, victim->coords, 160.);
2112 if (creature == wolftype) {
2113 emit_sound_at(clawslicesound, victim->coords, 128.);
2115 victim->DoBloodBig(2 / victim->armorhead, 175);
2121 Normalise(&relative);
2122 relative = DoRotation(relative, 0, -90, 0);
2123 for (i = 0; i < victim->skeleton.num_joints; i++) {
2124 victim->skeleton.joints[i].velocity += relative * damagemult * 40;
2126 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
2129 victim->DoDamage(damagemult * 150 / victim->protectionhead);
2131 if (victim->damage > victim->damagetolerance)
2132 award_bonus(id, style);
2138 if (animTarget == walljumpleftkickanim && animation[animTarget].label[frameCurrent] == 5) {
2139 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != lowheight) {
2145 if (tutoriallevel != 1) {
2146 emit_sound_at(heavyimpactsound, victim->coords, 160.);
2148 if (creature == wolftype) {
2149 emit_sound_at(clawslicesound, victim->coords, 128.);
2151 victim->DoBloodBig(2 / victim->armorhead, 175);
2157 Normalise(&relative);
2158 relative = DoRotation(relative, 0, 90, 0);
2159 for (i = 0; i < victim->skeleton.num_joints; i++) {
2160 victim->skeleton.joints[i].velocity += relative * damagemult * 40;
2162 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
2165 victim->DoDamage(damagemult * 150 / victim->protectionhead);
2167 if (victim->damage > victim->damagetolerance)
2168 award_bonus(id, style);
2174 if (animTarget == blockhighleftstrikeanim && animation[animTarget].label[frameCurrent] == 5) {
2175 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != lowheight) {
2183 emit_sound_at(whooshhitsound, victim->coords);
2186 relative = victim->coords - coords;
2188 Normalise(&relative);
2189 for (i = 0; i < victim->skeleton.num_joints; i++) {
2190 victim->skeleton.joints[i].velocity += relative * damagemult * 30;
2192 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 100;
2195 victim->DoDamage(damagemult * 50 / victim->protectionhead);
2199 if (animTarget == killanim && animation[animTarget].label[frameCurrent] == 8) {
2200 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && victim->dead) {
2204 emit_sound_at(whooshhitsound, victim->coords, 128.);
2206 victim->skeleton.longdead = 0;
2207 victim->skeleton.free = 1;
2208 victim->skeleton.broken = 0;
2209 victim->skeleton.spinny = 1;
2211 for (i = 0; i < victim->skeleton.num_joints; i++) {
2212 victim->skeleton.joints[i].velchange = 0;
2213 victim->skeleton.joints[i].delay = 0;
2214 victim->skeleton.joints[i].locked = 0;
2215 //victim->skeleton.joints[i].velocity=0;
2221 Normalise(&relative);
2222 for (i = 0; i < victim->skeleton.num_joints; i++) {
2223 victim->skeleton.joints[i].velocity.y = relative.y * 10;
2224 victim->skeleton.joints[i].position.y += relative.y * .3;
2225 victim->skeleton.joints[i].oldposition.y += relative.y * .3;
2226 victim->skeleton.joints[i].realoldposition.y += relative.y * .3;
2228 victim->Puff(abdomen);
2229 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity.y = relative.y * 400;
2233 if (animTarget == killanim && animation[animTarget].label[frameCurrent] == 5) {
2234 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 9 && victim->dead) {
2238 if (tutoriallevel != 1) {
2239 emit_sound_at(heavyimpactsound, coords, 128.);
2242 relative = victim->coords - coords;
2244 Normalise(&relative);
2245 for (i = 0; i < victim->skeleton.num_joints; i++) {
2246 victim->skeleton.joints[i].velocity += relative * damagemult * 90;
2248 victim->Puff(abdomen);
2249 if (victim->dead != 2 && victim->permanentdamage > victim->damagetolerance - 250 && autoslomo) {
2253 victim->DoDamage(damagemult * 500 / victim->protectionhigh);
2254 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 300;
2258 if (animTarget == dropkickanim && animation[animTarget].label[frameCurrent] == 7) {
2259 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 9 && victim->skeleton.free) {
2263 if (tutoriallevel != 1) {
2264 emit_sound_at(thudsound, coords);
2267 victim->skeleton.longdead = 0;
2268 victim->skeleton.free = 1;
2269 victim->skeleton.broken = 0;
2270 victim->skeleton.spinny = 1;
2272 for (i = 0; i < victim->skeleton.num_joints; i++) {
2273 victim->skeleton.joints[i].velchange = 0;
2274 //victim->skeleton.joints[i].delay=0;
2275 victim->skeleton.joints[i].locked = 0;
2278 relative = victim->coords - coords;
2279 Normalise(&relative);
2281 Normalise(&relative);
2282 for (i = 0; i < victim->skeleton.num_joints; i++) {
2283 victim->skeleton.joints[i].velocity += relative * damagemult * 20;
2288 victim->Puff(abdomen);
2289 victim->DoDamage(damagemult * 20 / victim->protectionhigh);
2290 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
2299 if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && animation[animTarget].label[frameCurrent] == 5) {
2300 //if(id==0)camerashake+=.4;
2303 if (!victim->skeleton.free)
2307 terrain.MakeDecal(blooddecalfast, (weapons[weaponids[weaponactive]].tippoint * .8 + weapons[weaponids[weaponactive]].position * .2), .08, .6, Random() % 360);
2308 emit_sound_at(knifesheathesound, coords, 128.);
2311 if (victim && hasvictim) {
2312 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) {
2314 XYZ where, startpoint, endpoint, movepoint, colpoint;
2315 float rotationpoint;
2317 if (weapons[weaponids[weaponactive]].getType() == knife) {
2318 where = (weapons[weaponids[weaponactive]].tippoint * .6 + weapons[weaponids[weaponactive]].position * .4);
2319 where -= victim->coords;
2320 if (!victim->skeleton.free)
2321 where = DoRotation(where, 0, -victim->yaw, 0);
2324 startpoint.y += 100;
2328 if (weapons[weaponids[weaponactive]].getType() == sword) {
2329 where = weapons[weaponids[weaponactive]].position;
2330 where -= victim->coords;
2331 if (!victim->skeleton.free)
2332 where = DoRotation(where, 0, -victim->yaw, 0);
2334 where = weapons[weaponids[weaponactive]].tippoint;
2335 where -= victim->coords;
2336 if (!victim->skeleton.free)
2337 where = DoRotation(where, 0, -victim->yaw, 0);
2340 if (weapons[weaponids[weaponactive]].getType() == staff) {
2341 where = weapons[weaponids[weaponactive]].position;
2342 where -= victim->coords;
2343 if (!victim->skeleton.free)
2344 where = DoRotation(where, 0, -victim->yaw, 0);
2346 where = weapons[weaponids[weaponactive]].tippoint;
2347 where -= victim->coords;
2348 if (!victim->skeleton.free)
2349 where = DoRotation(where, 0, -victim->yaw, 0);
2354 whichtri = victim->skeleton.drawmodel.LineCheck(&startpoint, &endpoint, &colpoint, &movepoint, &rotationpoint);
2356 if (whichtri != -1) {
2357 if (victim->dead != 2) {
2358 victim->DoDamage(abs((victim->damagetolerance - victim->permanentdamage) * 2));
2360 award_bonus(id, FinishedBonus);
2363 weapons[weaponids[weaponactive]].bloody = 2;
2365 victim->skeleton.longdead = 0;
2366 victim->skeleton.free = 1;
2367 victim->skeleton.broken = 0;
2369 for (i = 0; i < victim->skeleton.num_joints; i++) {
2370 victim->skeleton.joints[i].velchange = 0;
2371 victim->skeleton.joints[i].locked = 0;
2372 //victim->skeleton.joints[i].velocity=0;
2374 emit_sound_at(fleshstabsound, coords, 128);
2377 if (whichtri != -1 || weapons[weaponids[weaponactive]].bloody) {
2378 weapons[weaponids[weaponactive]].blooddrip += 5;
2379 weapons[weaponids[weaponactive]].blooddripdelay = 0;
2381 if (whichtri == -1) {
2383 emit_sound_at(knifesheathesound, coords, 128.);
2389 if ((animTarget == crouchstabanim || animTarget == swordgroundstabanim) && animation[animTarget].label[frameCurrent] == 6) {
2391 emit_sound_at(knifedrawsound, coords, 128);
2394 if (victim && hasvictim) {
2395 XYZ footvel, footpoint;
2397 emit_sound_at(fleshstabremovesound, coords, 128.);
2400 footpoint = (weapons[weaponids[weaponactive]].tippoint * .8 + weapons[weaponids[weaponactive]].position * .2);
2402 if (weapons[weaponids[weaponactive]].getType() == sword) {
2403 XYZ where, startpoint, endpoint, movepoint;
2404 float rotationpoint;
2407 where = weapons[weaponids[weaponactive]].position;
2408 where -= victim->coords;
2409 if (!victim->skeleton.free)
2410 where = DoRotation(where, 0, -victim->yaw, 0);
2412 where = weapons[weaponids[weaponactive]].tippoint;
2413 where -= victim->coords;
2414 if (!victim->skeleton.free)
2415 where = DoRotation(where, 0, -victim->yaw, 0);
2420 whichtri = victim->skeleton.drawmodel.LineCheck(&startpoint, &endpoint, &footpoint, &movepoint, &rotationpoint);
2421 footpoint += victim->coords;
2423 if (whichtri == -1) {
2424 footpoint = (weapons[weaponids[weaponactive]].tippoint * .8 + weapons[weaponids[weaponactive]].position * .2);
2427 if (weapons[weaponids[weaponactive]].getType() == staff) {
2428 XYZ where, startpoint, endpoint, movepoint;
2429 float rotationpoint;
2432 where = weapons[weaponids[weaponactive]].position;
2433 where -= victim->coords;
2434 if (!victim->skeleton.free)
2435 where = DoRotation(where, 0, -victim->yaw, 0);
2437 where = weapons[weaponids[weaponactive]].tippoint;
2438 where -= victim->coords;
2439 if (!victim->skeleton.free)
2440 where = DoRotation(where, 0, -victim->yaw, 0);
2445 whichtri = victim->skeleton.drawmodel.LineCheck(&startpoint, &endpoint, &footpoint, &movepoint, &rotationpoint);
2446 footpoint += victim->coords;
2448 if (whichtri == -1) {
2449 footpoint = (weapons[weaponids[weaponactive]].tippoint * .8 + weapons[weaponids[weaponactive]].position * .2);
2452 hasvictim = victim->DoBloodBigWhere(2, 220, footpoint);
2454 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) {
2455 victim->skeleton.longdead = 0;
2456 victim->skeleton.free = 1;
2457 victim->skeleton.broken = 0;
2459 for (i = 0; i < victim->skeleton.num_joints; i++) {
2460 victim->skeleton.joints[i].velchange = 0;
2461 victim->skeleton.joints[i].locked = 0;
2462 //victim->skeleton.joints[i].velocity=0;
2468 Normalise(&relative);
2469 //victim->Puff(abdomen);
2471 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .8, .3);
2473 if (victim->bloodloss < victim->damagetolerance) {
2474 victim->bloodloss += 1000;
2478 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 20;
2482 if (!hasvictim && onterrain) {
2483 weapons[weaponids[weaponactive]].bloody = 0;
2484 weapons[weaponids[weaponactive]].blooddrip = 0;
2488 if (animTarget == upunchanim && animation[animTarget].label[frameCurrent] == 5) {
2489 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3) {
2497 if (tutoriallevel != 1) {
2498 emit_sound_at(heavyimpactsound, victim->coords, 128);
2503 relative = victim->coords - coords;
2505 Normalise(&relative);
2506 for (i = 0; i < victim->skeleton.num_joints; i++) {
2507 victim->skeleton.joints[i].velocity = relative * 30;
2509 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 150;
2511 victim->frameTarget = 0;
2512 victim->animTarget = staggerbackhardanim;
2513 victim->targetyaw = targetyaw + 180;
2515 victim->stunned = 1;
2518 victim->Puff(abdomen);
2519 victim->DoDamage(damagemult * 60 / victim->protectionhigh);
2526 if (animTarget == winduppunchanim && animation[animTarget].label[frameCurrent] == 5) {
2527 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 2) {
2531 if (victim->damage <= victim->damagetolerance - 60 && normaldotproduct(victim->facing, victim->coords - coords) < (scale * 5) * (scale * 5) * 0 && animation[victim->animTarget].height != lowheight) {
2532 if (tutoriallevel != 1) {
2533 emit_sound_at(thudsound, victim->coords);
2535 } else if (victim->damage <= victim->damagetolerance - 60 && normaldotproduct(victim->facing, victim->coords - coords) < (scale * 5) * (scale * 5) * 0 && animation[victim->animTarget].height == lowheight) {
2536 if (tutoriallevel != 1) {
2537 emit_sound_at(whooshhitsound, victim->coords);
2540 if (tutoriallevel != 1) {
2541 emit_sound_at(heavyimpactsound, victim->coords);
2545 if (victim->damage > victim->damagetolerance - 60 || normaldotproduct(victim->facing, victim->coords - coords) > 0 || animation[victim->animTarget].height == lowheight)
2548 relative = victim->coords - coords;
2550 Normalise(&relative);
2552 Normalise(&relative);
2553 for (i = 0; i < victim->skeleton.num_joints; i++) {
2554 victim->skeleton.joints[i].velocity = relative * 5;
2556 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 400;
2558 victim->frameTarget = 0;
2559 victim->animTarget = staggerbackhardanim;
2560 victim->targetyaw = targetyaw + 180;
2562 victim->stunned = 1;
2564 victim->Puff(abdomen);
2565 victim->DoDamage(damagemult * 60 / victim->protectionhigh);
2571 if (animTarget == blockhighleftanim && animation[animTarget].label[frameCurrent] == 5) {
2572 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4) {
2573 if (victim->id == 0)
2575 emit_sound_at(landsound2, victim->coords);
2581 if (animTarget == swordslashparryanim && animation[animTarget].label[frameCurrent] == 5) {
2582 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4) {
2583 if (victim->id == 0)
2586 if (weaponactive != -1) {
2587 if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
2588 if (weapons[victim->weaponids[0]].getType() == staff)
2589 weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
2590 if (weapons[weaponids[0]].getType() == staff)
2591 weapons[weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
2593 emit_sound_at(swordstaffsound, victim->coords);
2595 emit_sound_at(metalhitsound, victim->coords);
2603 if (animTarget == knifethrowanim && animation[animTarget].label[frameCurrent] == 5) {
2604 if (weaponactive != -1) {
2607 weapons[weaponids[0]].owner = -1;
2608 aim = victim->coords + DoRotation(victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position, 0, victim->yaw, 0) * victim->scale + victim->velocity * findDistance(&victim->coords, &coords) / 50 - (coords + DoRotation(skeleton.joints[skeleton.jointlabels[righthand]].position, 0, yaw, 0) * scale);
2610 /*if(victim->animTarget==jumpupanim||victim->animTarget==jumpdownanim){
2611 aim=DoRotation(aim,(float)abs(Random()%15)-7,(float)abs(Random()%15)-7,0);
2613 weapons[weaponids[0]].velocity = aim * 50;
2614 weapons[weaponids[0]].tipvelocity = aim * 50;
2615 weapons[weaponids[0]].missed = 0;
2616 weapons[weaponids[0]].hitsomething = 0;
2617 weapons[weaponids[0]].freetime = 0;
2618 weapons[weaponids[0]].firstfree = 1;
2619 weapons[weaponids[0]].physics = 0;
2622 weaponids[0] = weaponids[num_weapons];
2628 if (animTarget == knifeslashstartanim && animation[animTarget].label[frameCurrent] == 5) {
2630 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 4.5 &&/*animation[victim->animTarget].height!=lowheight&&*/victim->animTarget != dodgebackanim && victim->animTarget != rollanim) {
2632 if (tutoriallevel != 1)
2633 victim->DoBloodBig(1.5 / victim->armorhigh, 225);
2635 award_bonus(id, Slicebonus);
2636 if (tutoriallevel != 1) {
2637 emit_sound_at(knifeslicesound, victim->coords);
2639 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2640 if (animation[victim->animTarget].attack && (victim->aitype != playercontrolled || victim->animTarget == knifeslashstartanim) && (victim->creature == rabbittype || victim->deathbleeding <= 0)) {
2641 if (victim->id != 0 || difficulty == 2) {
2642 victim->frameTarget = 0;
2643 victim->animTarget = staggerbackhardanim;
2644 victim->targetyaw = targetyaw + 180;
2648 victim->lowreversaldelay = 0;
2649 victim->highreversaldelay = 0;
2650 if (aitype != playercontrolled)
2651 weaponmissdelay = .6;
2653 if (tutoriallevel != 1)
2654 if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody)
2655 weapons[weaponids[weaponactive]].bloody = 1;
2656 if (tutoriallevel != 1)
2657 weapons[weaponids[weaponactive]].blooddrip += 3;
2659 XYZ footvel, footpoint;
2661 if (skeleton.free) {
2662 footpoint = (victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position + victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position) / 2 * victim->scale + victim->coords;
2664 if (!skeleton.free) {
2665 footpoint = DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position + victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position) / 2, 0, victim->yaw, 0) * victim->scale + victim->coords;
2667 if (tutoriallevel != 1) {
2669 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .6, .3);
2670 footvel = DoRotation(facing, 0, 90, 0) * .8;
2672 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
2673 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
2674 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .2, 1);
2675 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .2, 1);
2677 if (tutoriallevel == 1) {
2678 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 1, 1, .6, .3);
2680 victim->DoDamage(damagemult * 0);
2683 if (animTarget == swordslashanim && animation[animTarget].label[frameCurrent] == 5 && victim->animTarget != rollanim) {
2684 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim) {
2685 if (victim->weaponactive == -1 || normaldotproduct(victim->facing, victim->coords - coords) > 0 || (Random() % 2 == 0)) {
2686 award_bonus(id, Slashbonus);
2688 if (tutoriallevel != 1) {
2689 if (normaldotproduct(victim->facing, victim->coords - coords) < 0)
2690 victim->DoBloodBig(2 / victim->armorhigh, 190);
2692 victim->DoBloodBig(2 / victim->armorhigh, 185);
2693 victim->deathbleeding = 1;
2694 emit_sound_at(swordslicesound, victim->coords);
2696 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*200;
2697 if (tutoriallevel != 1) {
2698 victim->frameTarget = 0;
2699 victim->animTarget = staggerbackhardanim;
2700 victim->targetyaw = targetyaw + 180;
2704 if (tutoriallevel != 1) {
2705 if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody)
2706 weapons[weaponids[weaponactive]].bloody = 1;
2707 weapons[weaponids[weaponactive]].blooddrip += 3;
2709 float bloodlossamount;
2710 bloodlossamount = 200 + abs((float)(Random() % 40)) - 20;
2711 victim->bloodloss += bloodlossamount / victim->armorhigh;
2712 //victim->bloodloss+=100*(6.5-distsq(&coords,&victim->coords));
2713 victim->DoDamage(damagemult * 0);
2715 XYZ footvel, footpoint;
2717 if (skeleton.free) {
2718 footpoint = (victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position + victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position) / 2 * victim->scale + victim->coords;
2720 if (!skeleton.free) {
2721 footpoint = DoRotation((victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].position + victim->skeleton.joints[victim->skeleton.jointlabels[neck]].position) / 2, 0, victim->yaw, 0) * victim->scale + victim->coords;
2724 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
2725 footvel = DoRotation(facing, 0, 90, 0) * .8;
2727 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
2728 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
2729 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .3, 1);
2730 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .3, 1);
2733 if (victim->weaponactive != -1) {
2734 if (weapons[victim->weaponids[0]].getType() == staff || weapons[weaponids[0]].getType() == staff) {
2735 if (weapons[victim->weaponids[0]].getType() == staff)
2736 weapons[victim->weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
2737 if (weapons[weaponids[0]].getType() == staff)
2738 weapons[weaponids[0]].damage += .2 + float(abs(Random() % 100) - 50) / 250;
2740 emit_sound_at(swordstaffsound, victim->coords);
2742 emit_sound_at(metalhitsound, victim->coords);
2748 victim->Puff(righthand);
2750 victim->frameTarget = 0;
2751 victim->animTarget = staggerbackhighanim;
2752 victim->targetyaw = targetyaw + 180;
2754 weapons[victim->weaponids[0]].owner = -1;
2755 aim = DoRotation(facing, 0, 90, 0) * 21;
2757 weapons[victim->weaponids[0]].velocity = aim * -.2;
2758 weapons[victim->weaponids[0]].tipvelocity = aim;
2759 weapons[victim->weaponids[0]].missed = 1;
2760 weapons[weaponids[0]].hitsomething = 0;
2761 weapons[victim->weaponids[0]].freetime = 0;
2762 weapons[victim->weaponids[0]].firstfree = 1;
2763 weapons[victim->weaponids[0]].physics = 1;
2764 victim->num_weapons--;
2765 if (victim->num_weapons) {
2766 victim->weaponids[0] = victim->weaponids[num_weapons];
2767 if (victim->weaponstuck == victim->num_weapons)
2768 victim->weaponstuck = 0;
2770 victim->weaponactive = -1;
2771 for (i = 0; i < numplayers; i++) {
2772 player[i].wentforweapon = 0;
2779 if (animTarget == staffhitanim && animation[animTarget].label[frameCurrent] == 5 && victim->animTarget != rollanim) {
2780 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim && victim->animTarget != sweepanim) {
2781 if (tutoriallevel != 1) {
2782 weapons[weaponids[0]].damage += .4 + float(abs(Random() % 100) - 50) / 250;
2786 if (Random() % 2 || creature == wolftype) {
2789 emit_sound_at(staffheadsound, victim->coords);
2793 relative = victim->coords - coords;
2795 Normalise(&relative);
2796 relative = DoRotation(relative, 0, 90, 0);
2798 Normalise(&relative);
2799 for (i = 0; i < victim->skeleton.num_joints; i++) {
2800 victim->skeleton.joints[i].velocity += relative * damagemult * 60;
2802 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 230;
2803 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity += relative * damagemult * 230;
2806 if (tutoriallevel != 1) {
2807 victim->DoDamage(damagemult * 120 / victim->protectionhigh);
2809 award_bonus(id, solidhit, 30);
2814 if (animTarget == staffspinhitanim && animation[animTarget].label[frameCurrent] == 5 && victim->animTarget != rollanim) {
2815 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5 && victim->animTarget != dodgebackanim && victim->animTarget != sweepanim) {
2816 if (tutoriallevel != 1) {
2817 weapons[weaponids[0]].damage += .6 + float(abs(Random() % 100) - 50) / 250;
2821 if (Random() % 2 || creature == wolftype) {
2824 emit_sound_at(staffheadsound, victim->coords);
2828 relative = victim->coords - coords;
2830 Normalise(&relative);
2831 relative = DoRotation(relative, 0, -90, 0);
2832 for (i = 0; i < victim->skeleton.num_joints; i++) {
2833 victim->skeleton.joints[i].velocity += relative * damagemult * 40;
2835 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 220;
2836 victim->skeleton.joints[victim->skeleton.jointlabels[neck]].velocity += relative * damagemult * 220;
2839 if (tutoriallevel != 1) {
2840 victim->DoDamage(damagemult * 350 / victim->protectionhead);
2842 award_bonus(id, solidhit, 60);
2847 if (animTarget == staffgroundsmashanim && animation[animTarget].label[frameCurrent] == 5) {
2848 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 6.5) {
2850 if (tutoriallevel != 1) {
2852 weapons[weaponids[0]].damage += .4 + float(abs(Random() % 100) - 50) / 500;
2855 if (Random() % 2 || creature == wolftype) {
2858 emit_sound_at(staffbodysound, victim->coords);
2860 victim->skeleton.longdead = 0;
2861 victim->skeleton.free = 1;
2862 victim->skeleton.broken = 0;
2864 for (i = 0; i < victim->skeleton.num_joints; i++) {
2865 victim->skeleton.joints[i].velchange = 0;
2866 victim->skeleton.joints[i].locked = 0;
2867 //victim->skeleton.joints[i].velocity=0;
2873 /*relative=victim->coords-coords;
2875 Normalise(&relative);
2876 relative=DoRotation(relative,0,90,0);*/
2878 Normalise(&relative);
2879 if (!victim->dead) {
2880 for (i = 0; i < victim->skeleton.num_joints; i++) {
2881 victim->skeleton.joints[i].velocity = relative * damagemult * 40;
2884 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 40;
2887 for (i = 0; i < victim->skeleton.num_joints; i++) {
2888 victim->skeleton.joints[i].velocity = relative * damagemult * abs(Random() % 20);
2891 //victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity+=relative*damagemult*20;
2893 victim->Puff(abdomen);
2894 if (tutoriallevel != 1) {
2895 victim->DoDamage(damagemult * 100 / victim->protectionhigh);
2897 if (!victim->dead) {
2898 award_bonus(id, solidhit, 40);
2904 if (animTarget == lowkickanim && animation[animTarget].label[frameCurrent] == 5) {
2905 if (distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && animation[victim->animTarget].height != highheight) {
2910 relative = victim->coords - coords;
2912 Normalise(&relative);
2916 if (animation[victim->animTarget].height == lowheight) {
2922 for (i = 0; i < victim->skeleton.num_joints; i++) {
2923 victim->skeleton.joints[i].velocity += relative * damagemult * 40;
2925 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
2926 if (tutoriallevel != 1) {
2927 emit_sound_at(heavyimpactsound, victim->coords, 128.);
2930 victim->DoDamage(damagemult * 100 / victim->protectionhead);
2931 if (victim->howactive == typesleeping)
2932 victim->DoDamage(damagemult * 150 / victim->protectionhead);
2933 if (creature == wolftype) {
2934 emit_sound_at(clawslicesound, victim->coords, 128.);
2936 victim->DoBloodBig(2 / victim->armorhead, 175);
2939 if (victim->damage >= victim->damagetolerance)
2941 for (i = 0; i < victim->skeleton.num_joints; i++) {
2942 victim->skeleton.joints[i].velocity += relative * damagemult * 10;
2944 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
2945 victim->frameTarget = 0;
2946 victim->animTarget = staggerbackhighanim;
2947 victim->targetyaw = targetyaw + 180;
2949 if (tutoriallevel != 1) {
2950 emit_sound_at(landsound2, victim->coords, 128.);
2952 victim->Puff(abdomen);
2953 victim->DoDamage(damagemult * 30 / victim->protectionhigh);
2954 if (creature == wolftype) {
2955 emit_sound_at(clawslicesound, victim->coords, 128.);
2957 victim->DoBloodBig(2 / victim->armorhigh, 170);
2964 if (animTarget == sweepanim && animation[animTarget].label[frameCurrent] == 5) {
2965 if (victim->animTarget != jumpupanim && distsq(&coords, &victim->coords) < (scale * 5) * (scale * 5) * 3 && victim != this) {
2969 if (tutoriallevel != 1) {
2970 emit_sound_at(landsound2, victim->coords, 128.);
2973 relative = victim->coords - coords;
2975 Normalise(&relative);
2977 if (animation[victim->animTarget].height == middleheight || animation[victim->animCurrent].height == middleheight || victim->damage >= victim->damagetolerance - 40) {
2980 for (i = 0; i < victim->skeleton.num_joints; i++) {
2981 victim->skeleton.joints[i].velocity += relative * damagemult * 15;
2983 relative = DoRotation(relative, 0, -90, 0);
2985 for (i = 0; i < victim->skeleton.num_joints; i++) {
2986 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)
2987 victim->skeleton.joints[i].velocity = relative * 80;
2989 victim->Puff(rightankle);
2990 victim->Puff(leftankle);
2991 victim->DoDamage(damagemult * 40 / victim->protectionlow);
2993 if (victim->damage >= victim->damagetolerance)
2995 for (i = 0; i < victim->skeleton.num_joints; i++) {
2996 victim->skeleton.joints[i].velocity += relative * damagemult * 10;
2998 relative = DoRotation(relative, 0, -90, 0);
2999 for (i = 0; i < victim->skeleton.num_joints; i++) {
3000 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)
3001 victim->skeleton.joints[i].velocity += relative * damagemult * 80;
3003 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
3004 victim->frameTarget = 0;
3005 victim->animTarget = staggerbackhighanim;
3006 victim->targetyaw = targetyaw + 180;
3008 if (tutoriallevel != 1) {
3009 emit_sound_at(landsound2, victim->coords, 128.);
3011 victim->Puff(abdomen);
3012 victim->DoDamage(damagemult * 30 / victim->protectionlow);
3020 if (animation[animTarget].attack == reversal && (!victim->feint || (victim->lastattack == victim->lastattack2 && victim->lastattack2 == victim->lastattack3 && Random() % 2) || animTarget == knifefollowanim)) {
3021 if (animTarget == spinkickreversalanim && animation[animTarget].label[frameCurrent] == 7) {
3029 if (tutoriallevel != 1) {
3030 emit_sound_at(heavyimpactsound, victim->coords, 128.);
3032 if (creature == wolftype) {
3033 emit_sound_at(clawslicesound, victim->coords, 128);
3035 victim->DoBloodBig(2 / victim->armorhigh, 170);
3039 relative = victim->coords - oldcoords;
3041 Normalise(&relative);
3042 //relative=DoRotation(relative,0,-90,0);
3043 for (i = 0; i < victim->skeleton.num_joints; i++) {
3044 victim->skeleton.joints[i].velocity += relative * damagemult * 40;
3046 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
3048 victim->Puff(abdomen);
3049 victim->DoDamage(damagemult * 150 / victim->protectionhigh);
3051 award_bonus(id, Reversal);
3054 if ((animTarget == swordslashreversalanim || animTarget == knifeslashreversalanim || animTarget == staffhitreversalanim || animTarget == staffspinhitreversalanim) && animation[animTarget].label[frameCurrent] == 5) {
3055 if (victim->weaponactive != -1 && victim->num_weapons > 0) {
3056 if (weapons[victim->weaponids[victim->weaponactive]].owner == victim->id) {
3057 weapons[victim->weaponids[victim->weaponactive]].owner = id;
3059 if (num_weapons > 0) {
3060 weaponids[num_weapons] = weaponids[victim->weaponactive];
3063 weaponids[0] = victim->weaponids[victim->weaponactive];
3064 victim->num_weapons--;
3065 if (victim->num_weapons > 0) {
3066 victim->weaponids[victim->weaponactive] = victim->weaponids[victim->num_weapons];
3067 //if(victim->weaponstuck==victim->num_weapons)victim->weaponstuck=0;
3069 victim->weaponactive = -1;
3074 if (animTarget == staffhitreversalanim && animation[animTarget].label[frameCurrent] == 5) {
3082 emit_sound_at(whooshhitsound, victim->coords, 128.);
3085 relative = victim->coords - oldcoords;
3087 Normalise(&relative);
3088 //relative=DoRotation(relative,0,-90,0);
3089 for (i = 0; i < victim->skeleton.num_joints; i++) {
3090 victim->skeleton.joints[i].velocity += relative * damagemult * 30;
3092 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
3095 victim->DoDamage(damagemult * 70 / victim->protectionhigh);
3098 if (animTarget == staffspinhitreversalanim && animation[animTarget].label[frameCurrent] == 7) {
3107 award_bonus(id, staffreversebonus);
3109 if (tutoriallevel != 1) {
3110 emit_sound_at(heavyimpactsound, victim->coords, 128.);
3113 award_bonus(id, staffreversebonus); // Huh, again?
3116 relative = victim->coords - oldcoords;
3118 Normalise(&relative);
3119 //relative=DoRotation(relative,0,-90,0);
3120 for (i = 0; i < victim->skeleton.num_joints; i++) {
3121 victim->skeleton.joints[i].velocity += relative * damagemult * 30;
3123 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
3126 victim->DoDamage(damagemult * 70 / victim->protectionhigh);
3129 if (animTarget == upunchreversalanim && animation[animTarget].label[frameCurrent] == 7) {
3135 Normalise(&relative);
3138 for (i = 0; i < victim->skeleton.num_joints; i++) {
3139 victim->skeleton.joints[i].velocity += relative * damagemult * 70;
3141 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity *= .1;
3142 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity *= .2;
3143 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity *= .5;
3144 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity *= .7;
3145 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity *= .1;
3146 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity *= .2;
3147 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity *= .5;
3148 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity *= .7;
3150 victim->Puff(abdomen);
3151 victim->DoDamage(damagemult * 90 / victim->protectionhigh);
3153 award_bonus(id, Reversal);
3157 if (weaponactive != -1 || creature == wolftype)
3159 if (creature == rabbittype && weaponactive != -1)
3160 if (weapons[weaponids[0]].getType() == staff)
3163 if (weaponactive != -1) {
3164 victim->DoBloodBig(2 / victim->armorhigh, 225);
3165 emit_sound_at(knifeslicesound, victim->coords);
3166 if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody)
3167 weapons[weaponids[weaponactive]].bloody = 1;
3168 weapons[weaponids[weaponactive]].blooddrip += 3;
3170 if (weaponactive == -1 && creature == wolftype) {
3172 emit_sound_at(clawslicesound, victim->coords, 128.);
3174 victim->DoBloodBig(2 / victim->armorhigh, 175);
3181 if (animTarget == swordslashreversalanim && animation[animTarget].label[frameCurrent] == 7) {
3187 Normalise(&relative);
3190 for (i = 0; i < victim->skeleton.num_joints; i++) {
3191 victim->skeleton.joints[i].velocity += relative * damagemult * 70;
3193 victim->skeleton.joints[victim->skeleton.jointlabels[lefthand]].velocity *= .1 - 1;
3194 victim->skeleton.joints[victim->skeleton.jointlabels[leftwrist]].velocity *= .2 - 1;
3195 victim->skeleton.joints[victim->skeleton.jointlabels[leftelbow]].velocity *= .5 - 1;
3196 victim->skeleton.joints[victim->skeleton.jointlabels[leftshoulder]].velocity *= .7 - 1;
3197 victim->skeleton.joints[victim->skeleton.jointlabels[righthand]].velocity *= .1 - 1;
3198 victim->skeleton.joints[victim->skeleton.jointlabels[rightwrist]].velocity *= .2 - 1;
3199 victim->skeleton.joints[victim->skeleton.jointlabels[rightelbow]].velocity *= .5 - 1;
3200 victim->skeleton.joints[victim->skeleton.jointlabels[rightshoulder]].velocity *= .7 - 1;
3202 award_bonus(id, swordreversebonus);
3205 if (hasvictim && animTarget == knifeslashreversalanim && animation[animTarget].label[frameCurrent] == 7) {
3213 if (tutoriallevel != 1) {
3214 emit_sound_at(heavyimpactsound, victim->coords, 128.);
3218 relative = victim->coords - oldcoords;
3220 Normalise(&relative);
3221 relative = DoRotation(relative, 0, -90, 0);
3222 for (i = 0; i < victim->skeleton.num_joints; i++) {
3223 victim->skeleton.joints[i].velocity += relative * damagemult * 40;
3225 victim->skeleton.joints[victim->skeleton.jointlabels[abdomen]].velocity += relative * damagemult * 200;
3227 victim->Puff(abdomen);
3228 victim->DoDamage(damagemult * 30 / victim->protectionhigh);
3230 award_bonus(id, Reversal);
3233 if (hasvictim && animTarget == sneakattackanim && animation[animTarget].label[frameCurrent] == 7) {
3236 victim->skeleton.spinny = 0;
3238 relative = facing * -1;
3240 Normalise(&relative);
3241 if (victim->id == 0)
3243 for (i = 0; i < victim->skeleton.num_joints; i++) {
3244 victim->skeleton.joints[i].velocity += relative * damagemult * 40;
3246 //victim->DoDamage(1000);
3247 victim->damage = victim->damagetolerance;
3248 victim->permanentdamage = victim->damagetolerance - 1;
3251 if (weaponactive != -1 || creature == wolftype)
3253 if (creature == rabbittype && weaponactive != -1)
3254 if (weapons[weaponids[0]].getType() == staff)
3257 if (weaponactive != -1) {
3258 victim->DoBloodBig(200, 225);
3259 emit_sound_at(knifeslicesound, victim->coords);
3261 weapons[weaponids[weaponactive]].bloody = 2;
3262 weapons[weaponids[weaponactive]].blooddrip += 5;
3265 if (creature == wolftype && weaponactive == -1) {
3266 emit_sound_at(clawslicesound, victim->coords, 128.);
3268 victim->DoBloodBig(2, 175);
3271 award_bonus(id, spinecrusher);
3274 if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && animation[animTarget].label[frameCurrent] == 5) {
3275 if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
3277 if (animTarget == knifefollowanim)
3278 victim->DoBloodBig(200, 210);
3279 if (animTarget == knifesneakattackanim) {
3280 /*victim->DoBloodBig(200,195);
3285 bloodvel=DoRotation(bloodvel,((float)(Random()%100))/4,yaw+((float)(Random()%100))/4,0)*scale;
3286 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position,0,yaw,0)*scale+coords,bloodvel, 1,1,1, .05, 1);
3288 XYZ footvel, footpoint;
3290 footpoint = weapons[weaponids[0]].tippoint;
3292 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
3293 footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position);
3294 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
3295 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
3296 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .3, 1);
3297 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .3, 1);
3298 victim->DoBloodBig(200, 195);
3299 award_bonus(id, tracheotomy);
3301 if (animTarget == knifefollowanim) {
3302 award_bonus(id, Stabbonus);
3303 XYZ footvel, footpoint;
3305 footpoint = weapons[weaponids[0]].tippoint;
3307 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
3308 footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position) * -1;
3309 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
3310 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
3311 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .2, 1);
3312 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .2, 1);
3315 victim->bloodloss += 10000;
3316 victim->velocity = 0;
3317 emit_sound_at(fleshstabsound, victim->coords);
3319 weapons[weaponids[weaponactive]].bloody = 2;
3320 weapons[weaponids[weaponactive]].blooddrip += 5;
3324 if (hasvictim && (animTarget == knifefollowanim || animTarget == knifesneakattackanim) && animation[animTarget].label[frameCurrent] == 6) {
3326 victim->velocity = 0;
3327 for (i = 0; i < victim->skeleton.num_joints; i++) {
3328 victim->skeleton.joints[i].velocity = 0;
3330 if (animTarget == knifefollowanim) {
3332 for (i = 0; i < victim->skeleton.num_joints; i++) {
3333 victim->skeleton.joints[i].velocity = 0;
3336 if (weaponactive != -1 && animation[victim->animTarget].attack != reversal) {
3337 emit_sound_at(fleshstabremovesound, victim->coords);
3339 weapons[weaponids[weaponactive]].bloody = 2;
3340 weapons[weaponids[weaponactive]].blooddrip += 5;
3342 XYZ footvel, footpoint;
3344 footpoint = weapons[weaponids[0]].tippoint;
3346 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
3347 footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position) * -1;
3348 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
3349 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
3350 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .3, 1);
3351 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .3, 1);
3355 if (hasvictim && (animTarget == swordsneakattackanim) && animation[animTarget].label[frameCurrent] == 5) {
3356 if (weaponactive != -1 && victim->bloodloss < victim->damagetolerance) {
3357 award_bonus(id, backstab);
3361 XYZ footvel, footpoint;
3363 footpoint = (weapons[weaponids[0]].tippoint + weapons[weaponids[0]].position) / 2;
3365 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
3366 footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position);
3367 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
3368 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
3369 Sprite::MakeSprite(bloodflamesprite, footpoint, DoRotation(footvel * 5, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .3, 1);
3370 Sprite::MakeSprite(bloodflamesprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .3, 1);
3371 victim->DoBloodBig(200, 180);
3372 victim->DoBloodBig(200, 215);
3373 victim->bloodloss += 10000;
3374 victim->velocity = 0;
3375 emit_sound_at(fleshstabsound, victim->coords);
3377 weapons[weaponids[weaponactive]].bloody = 2;
3378 weapons[weaponids[weaponactive]].blooddrip += 5;
3382 if (hasvictim && animTarget == swordsneakattackanim && animation[animTarget].label[frameCurrent] == 6) {
3384 victim->velocity = 0;
3385 for (i = 0; i < victim->skeleton.num_joints; i++) {
3386 victim->skeleton.joints[i].velocity = 0;
3388 if (weaponactive != -1) {
3389 emit_sound_at(fleshstabremovesound, victim->coords);
3391 weapons[weaponids[weaponactive]].bloody = 2;
3392 weapons[weaponids[weaponactive]].blooddrip += 5;
3394 XYZ footvel, footpoint;
3396 footpoint = weapons[weaponids[0]].tippoint;
3398 Sprite::MakeSprite(cloudimpactsprite, footpoint, footvel, 1, 0, 0, .9, .3);
3399 footvel = (weapons[weaponids[0]].tippoint - weapons[weaponids[0]].position) * -1;
3400 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 7, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
3401 Sprite::MakeSprite(bloodsprite, footpoint, DoRotation(footvel * 3, (float)(Random() % 20), (float)(Random() % 20), 0), 1, 1, 1, .05, .9);
3402 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 5, 1, 1, 1, .3, 1);
3403 Sprite::MakeSprite(bloodflamesprite, footpoint, footvel * 2, 1, 1, 1, .3, 1);
3407 if (animTarget == sweepreversalanim && animation[animTarget].label[frameCurrent] == 7) {
3415 if (weaponactive == -1) {
3416 if (tutoriallevel != 1) {
3417 emit_sound_at(heavyimpactsound, victim->coords, 128.);
3422 if (weaponactive != -1 || creature == wolftype)
3424 if (creature == rabbittype && weaponactive != -1)
3425 if (weapons[weaponids[0]].getType() == staff)
3428 if (weaponactive != -1) {
3429 victim->DoBloodBig(2 / victim->armorhead, 225);
3430 emit_sound_at(knifeslicesound, victim->coords);
3431 if (bloodtoggle && !weapons[weaponids[weaponactive]].bloody)
3432 weapons[weaponids[weaponactive]].bloody = 1;
3433 weapons[weaponids[weaponactive]].blooddrip += 3;
3435 if (weaponactive == -1 && creature == wolftype) {
3436 emit_sound_at(clawslicesound, victim->coords, 128.);
3438 victim->DoBloodBig(2 / victim->armorhead, 175);
3442 award_bonus(id, Reversal);
3447 //relative=victim->coords-oldcoords;
3448 relative = facing * -1;
3450 Normalise(&relative);
3451 relative = DoRotation(relative, 0, 90, 0);
3453 Normalise(&relative);
3454 for (i = 0; i < victim->skeleton.num_joints; i++) {
3455 victim->skeleton.joints[i].velocity += relative * damagemult * 20;
3457 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
3458 if (victim->damage < victim->damagetolerance - 100)
3459 victim->velocity = relative * 200;
3460 victim->DoDamage(damagemult * 100 / victim->protectionhead);
3461 victim->velocity = 0;
3464 if (animTarget == sweepreversalanim && ((animation[animTarget].label[frameCurrent] == 9 && victim->damage < victim->damagetolerance) || (animation[animTarget].label[frameCurrent] == 7 && victim->damage > victim->damagetolerance))) {
3468 //relative=victim->coords-oldcoords;
3469 relative = facing * -1;
3471 Normalise(&relative);
3472 relative = DoRotation(relative, 0, 90, 0);
3474 Normalise(&relative);
3475 for (i = 0; i < victim->skeleton.num_joints; i++) {
3476 victim->skeleton.joints[i].velocity += relative * damagemult * 20;
3478 victim->skeleton.joints[victim->skeleton.jointlabels[head]].velocity += relative * damagemult * 200;
3481 if (hasvictim && (animTarget == spinkickreversalanim || animTarget == sweepreversalanim || animTarget == rabbitkickreversalanim || animTarget == upunchreversalanim || animTarget == jumpreversalanim || animTarget == swordslashreversalanim || animTarget == knifeslashreversalanim || animTarget == rabbittacklereversal || animTarget == wolftacklereversal || animTarget == staffhitreversalanim || animTarget == staffspinhitreversalanim))
3482 if (victim->damage > victim->damagetolerance && bonus != reverseko) {
3483 award_bonus(id, reverseko);
3489 if (frameTarget > animation[animCurrent].numframes - 1) {
3492 animTarget = getIdle();
3496 if (animCurrent == rabbittackleanim || animCurrent == rabbittacklinganim) {
3497 animTarget = rollanim;
3499 emit_sound_at(movewhooshsound, coords, 128.);
3501 if (animCurrent == staggerbackhighanim) {
3502 animTarget = getIdle();
3504 if (animCurrent == staggerbackhardanim) {
3505 animTarget = getIdle();
3507 if (animCurrent == removeknifeanim) {
3508 animTarget = getIdle();
3510 if (animCurrent == crouchremoveknifeanim) {
3511 animTarget = getCrouch();
3513 if (animCurrent == backhandspringanim) {
3514 animTarget = getIdle();
3516 if (animCurrent == dodgebackanim) {
3517 animTarget = getIdle();
3519 if (animCurrent == drawleftanim) {
3520 animTarget = getIdle();
3522 if (animCurrent == drawrightanim || animCurrent == crouchdrawrightanim) {
3523 animTarget = getIdle();
3524 if (animCurrent == crouchdrawrightanim) {
3525 animTarget = getCrouch();
3527 if (weaponactive == -1)
3529 else if (weaponactive == 0) {
3531 if (num_weapons == 2) {
3533 buffer = weaponids[0];
3534 weaponids[0] = weaponids[1];
3535 weaponids[1] = buffer;
3539 if (weaponactive == -1) {
3540 emit_sound_at(knifesheathesound, coords, 128.);
3542 if (weaponactive != -1) {
3543 emit_sound_at(knifedrawsound, coords, 128.);
3546 if (animCurrent == rollanim) {
3547 animTarget = getCrouch();
3552 if (animTarget == walljumprightkickanim) {
3555 if (animTarget == walljumpleftkickanim) {
3558 animTarget = jumpdownanim;
3560 if (animCurrent == climbanim) {
3561 animTarget = getCrouch();
3563 coords += facing * .1;
3564 if (!isnormal(coords.x))
3575 if (animTarget == rabbitkickreversalanim) {
3576 animTarget = getCrouch();
3579 if (animTarget == jumpreversalanim) {
3580 animTarget = getCrouch();
3583 if (animTarget == walljumprightanim || animTarget == walljumpbackanim || animTarget == walljumpfrontanim) {
3584 if (attackkeydown && animTarget != walljumpfrontanim) {
3586 float closestdist = -1;
3589 for (i = 0; i < numplayers; i++) {
3590 if (id != i && player[i].coords.y < coords.y && !player[i].skeleton.free) {
3591 distance = distsq(&player[i].coords, &coords);
3592 if (closestdist == -1 || distance < closestdist) {
3593 closestdist = distance;
3598 if (closestdist > 0 && closest >= 0 && closestdist < 16) {
3599 victim = &player[closest];
3600 animTarget = walljumprightkickanim;
3602 XYZ rotatetarget = victim->coords - coords;
3603 Normalise(&rotatetarget);
3604 yaw = -asin(0 - rotatetarget.x);
3606 if (rotatetarget.z < 0)
3608 targettilt2 = -asin(rotatetarget.y) * 360 / 6.28;
3609 velocity = (victim->coords - coords) * 4;
3614 if (animTarget == walljumpbackanim) {
3615 animTarget = backflipanim;
3617 velocity = facing * -8;
3620 resume_stream(whooshsound);
3622 if (animTarget == walljumprightanim) {
3623 animTarget = rightflipanim;
3627 velocity = DoRotation(facing, 0, 30, 0) * -8;
3630 if (animTarget == walljumpfrontanim) {
3631 animTarget = frontflipanim;
3635 velocity = facing * 8;
3639 resume_stream(whooshsound);
3641 if (animTarget == walljumpleftanim) {
3642 if (attackkeydown) {
3644 float closestdist = -1;
3647 for (i = 0; i < numplayers; i++) {
3648 if (id != i && player[i].coords.y < coords.y && !player[i].skeleton.free) {
3649 distance = distsq(&player[i].coords, &coords);
3650 if (closestdist == -1 || distance < closestdist) {
3651 closestdist = distance;
3656 if (closestdist > 0 && closest >= 0 && closestdist < 16) {
3657 victim = &player[closest];
3658 animTarget = walljumpleftkickanim;
3660 XYZ rotatetarget = victim->coords - coords;
3661 Normalise(&rotatetarget);
3662 yaw = -asin(0 - rotatetarget.x);
3664 if (rotatetarget.z < 0)
3666 targettilt2 = -asin(rotatetarget.y) * 360 / 6.28;
3667 velocity = (victim->coords - coords) * 4;
3672 if (animTarget != walljumpleftkickanim) {
3673 animTarget = leftflipanim;
3677 velocity = DoRotation(facing, 0, -30, 0) * -8;
3681 resume_stream(whooshsound);
3683 if (animTarget == sneakattackanim) {
3684 animCurrent = getCrouch();
3685 animTarget = getCrouch();
3692 transspeed = 1000000;
3693 targetheadyaw += 180;
3694 coords -= facing * .7;
3696 coords.y = terrain.getHeight(coords.x, coords.z);
3700 if (animTarget == knifesneakattackanim || animTarget == swordsneakattackanim) {
3701 animTarget = getIdle();
3704 coords.y = terrain.getHeight(coords.x, coords.z);
3708 if (animCurrent == knifefollowanim) {
3709 animTarget = getIdle();
3712 if (animation[animTarget].attack == reversal && animCurrent != sneakattackanim && animCurrent != knifesneakattackanim && animCurrent != swordsneakattackanim && animCurrent != knifefollowanim) {
3713 float ycoords = oldcoords.y;
3714 animTarget = getStop();
3719 transspeed = 1000000;
3720 targetheadyaw += 180;
3721 if (!isnormal(coords.x))
3723 if (animCurrent == spinkickreversalanim || animCurrent == swordslashreversalanim)
3724 oldcoords = coords + facing * .5;
3725 else if (animCurrent == sweepreversalanim)
3726 oldcoords = coords + facing * 1.1;
3727 else if (animCurrent == upunchreversalanim) {
3728 oldcoords = coords + facing * 1.5;
3731 targetheadyaw += 180;
3734 } else if (animCurrent == knifeslashreversalanim) {
3735 oldcoords = coords + facing * .5;
3738 targetheadyaw += 90;
3741 } else if (animCurrent == staffspinhitreversalanim) {
3744 targetheadyaw += 180;
3749 oldcoords.y = terrain.getHeight(oldcoords.x, oldcoords.z);
3751 oldcoords.y = ycoords;
3752 currentoffset = coords - oldcoords;
3758 if (animCurrent == knifesneakattackedanim || animCurrent == swordsneakattackedanim) {
3763 if (animation[animTarget].attack == reversed) {
3765 if (animTarget == sweepreversedanim)
3767 animTarget = backhandspringanim;
3769 emit_sound_at(landsound, coords, 128);
3771 if (animCurrent == upunchreversedanim || animCurrent == swordslashreversedanim) {
3772 animTarget = rollanim;
3775 coords += (DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) + DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0)) / 2 * scale;
3776 coords.y = oldcoords.y;
3778 if (animCurrent == knifeslashreversedanim) {
3779 animTarget = rollanim;
3784 coords += (DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) + DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0)) / 2 * scale;
3785 coords.y = oldcoords.y;
3789 animTarget = jumpdownanim;
3792 animTarget = getIdle();
3794 animTarget = getIdle();
3795 if (animCurrent == spinkickanim || animCurrent == getupfrombackanim || animCurrent == getupfromfrontanim || animCurrent == lowkickanim) {
3796 animTarget = getIdle();
3798 coords += (DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) + DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0)) / 2 * scale;
3799 coords.y = oldcoords.y;
3800 //coords+=DoRotation(animation[animCurrent].offset,0,yaw,0)*scale;
3801 targetoffset.y = coords.y;
3803 targetoffset.y = terrain.getHeight(coords.x, coords.z);
3804 currentoffset = DoRotation(animation[animCurrent].offset * -1, 0, yaw, 0) * scale;
3805 currentoffset.y -= (coords.y - targetoffset.y);
3806 coords.y = targetoffset.y;
3808 normalsupdatedelay = 0;
3810 if (animCurrent == upunchanim) {
3811 animTarget = getStop();
3812 normalsupdatedelay = 0;
3815 if (animCurrent == rabbitkickanim && animTarget != backflipanim) {
3819 if (num_weapons > 0)
3820 if (weapons[0].getType() == staff)
3826 rabbitkickragdoll = 1;
3828 if (animCurrent == rabbitkickreversedanim) {
3834 skeleton.spinny = 0;
3835 SolidHitBonus(!id); // FIXME: tricky id
3839 animTarget = rollanim;
3842 pause_sound(whooshsound);
3846 if (animCurrent == rabbittackledbackanim || animCurrent == rabbittackledfrontanim) {
3850 skeleton.spinny = 0;
3852 if (animCurrent == jumpreversedanim) {
3858 skeleton.spinny = 0;
3859 SolidHitBonus(!id); // FIXME: tricky id
3863 animTarget = rollanim;
3864 coords += facing * 2;
3866 pause_sound(whooshsound);
3871 if (animation[animCurrent].attack == normalattack && !victim->skeleton.free && victim->animTarget != staggerbackhighanim && victim->animTarget != staggerbackhardanim && animTarget != winduppunchblockedanim && animTarget != blockhighleftanim && animTarget != swordslashparryanim && animTarget != swordslashparriedanim && animTarget != crouchstabanim && animTarget != swordgroundstabanim) {
3872 animTarget = getupfromfrontanim;
3874 } else if (animation[animCurrent].attack == normalattack) {
3875 animTarget = getIdle();
3878 if (animCurrent == blockhighleftanim && aitype != playercontrolled) {
3879 animTarget = blockhighleftstrikeanim;
3881 if (animCurrent == knifeslashstartanim || animCurrent == knifethrowanim || animCurrent == swordslashanim || animCurrent == staffhitanim || animCurrent == staffgroundsmashanim || animCurrent == staffspinhitanim) {
3882 animTarget = getIdle();
3885 if (animCurrent == spinkickanim && victim->skeleton.free) {
3886 if (creature == rabbittype)
3887 animTarget = fightidleanim;
3892 if (isIdle() && !wasIdle())
3893 normalsupdatedelay = 0;
3895 if (animCurrent == jumpupanim && velocity.y < 0 && !isFlip()) {
3896 animTarget = jumpdownanim;
3899 if (!skeleton.free) {
3901 if (!transspeed && animation[animTarget].attack != 2 && animation[animTarget].attack != 3) {
3902 if (!isRun() || !wasRun()) {
3903 if (animation[animTarget].speed[frameTarget] > animation[animCurrent].speed[frameCurrent])
3904 target += multiplier * animation[animTarget].speed[frameTarget] * speed * 2;
3905 if (animation[animTarget].speed[frameTarget] <= animation[animCurrent].speed[frameCurrent])
3906 target += multiplier * animation[animCurrent].speed[frameCurrent] * speed * 2;
3908 if (isRun() && wasRun()) {
3910 tempspeed = velspeed;
3911 if (tempspeed < 10 * speedmult)
3912 tempspeed = 10 * speedmult;
3913 target += multiplier * animation[animTarget].speed[frameCurrent] * speed * 1.7 * tempspeed / (speed * 45 * scale);
3915 } else if (transspeed)
3916 target += multiplier * transspeed * speed * 2;
3918 if (!isRun() || !wasRun()) {
3919 if (animation[animTarget].speed[frameTarget] > animation[animCurrent].speed[frameCurrent])
3920 target += multiplier * animation[animTarget].speed[frameTarget] * 2;
3921 if (animation[animTarget].speed[frameTarget] <= animation[animCurrent].speed[frameCurrent])
3922 target += multiplier * animation[animCurrent].speed[frameCurrent] * 2;
3926 if (animCurrent != animTarget)
3927 target = (target + oldtarget) / 2;
3930 frameCurrent = frameTarget;
3934 rot = targetrot * target;
3935 yaw += rot - oldrot;
3941 if (animCurrent != oldanimCurrent || animTarget != oldanimTarget || ((frameCurrent != oldframeCurrent || frameTarget != oldframeTarget) && !calcrot)) {
3943 for (i = 0; i < skeleton.num_joints; i++) {
3944 skeleton.joints[i].position = animation[animCurrent].position[i][frameCurrent];
3947 skeleton.FindForwards();
3949 for (i = 0; i < skeleton.num_muscles; i++) {
3950 if (skeleton.muscles[i].visible) {
3951 skeleton.FindRotationMuscle(i, animTarget);
3954 for (i = 0; i < skeleton.num_muscles; i++) {
3955 if (skeleton.muscles[i].visible) {
3956 if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
3957 skeleton.muscles[i].oldrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
3958 if (isnormal((float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100))
3959 skeleton.muscles[i].oldrotate2 = (float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100;
3960 if (isnormal((float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100))
3961 skeleton.muscles[i].oldrotate3 = (float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100;
3966 for (i = 0; i < skeleton.num_joints; i++) {
3967 skeleton.joints[i].position = animation[animTarget].position[i][frameTarget];
3970 skeleton.FindForwards();
3972 for (i = 0; i < skeleton.num_muscles; i++) {
3973 if (skeleton.muscles[i].visible) {
3974 skeleton.FindRotationMuscle(i, animTarget);
3977 for (i = 0; i < skeleton.num_muscles; i++) {
3978 if (skeleton.muscles[i].visible) {
3979 if (isnormal((float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100))
3980 skeleton.muscles[i].newrotate1 = (float)((int)(skeleton.muscles[i].rotate1 * 100) % 36000) / 100;
3981 if (isnormal((float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100))
3982 skeleton.muscles[i].newrotate2 = (float)((int)(skeleton.muscles[i].rotate2 * 100) % 36000) / 100;
3983 if (isnormal((float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100))
3984 skeleton.muscles[i].newrotate3 = (float)((int)(skeleton.muscles[i].rotate3 * 100) % 36000) / 100;
3985 if (skeleton.muscles[i].newrotate3 > skeleton.muscles[i].oldrotate3 + 180) skeleton.muscles[i].newrotate3 -= 360;
3986 if (skeleton.muscles[i].newrotate3 < skeleton.muscles[i].oldrotate3 - 180) skeleton.muscles[i].newrotate3 += 360;
3987 if (skeleton.muscles[i].newrotate2 > skeleton.muscles[i].oldrotate2 + 180) skeleton.muscles[i].newrotate2 -= 360;
3988 if (skeleton.muscles[i].newrotate2 < skeleton.muscles[i].oldrotate2 - 180) skeleton.muscles[i].newrotate2 += 360;
3989 if (skeleton.muscles[i].newrotate1 > skeleton.muscles[i].oldrotate1 + 180) skeleton.muscles[i].newrotate1 -= 360;
3990 if (skeleton.muscles[i].newrotate1 < skeleton.muscles[i].oldrotate1 - 180) skeleton.muscles[i].newrotate1 += 360;
3994 if (frameCurrent >= animation[animCurrent].numframes)
3995 frameCurrent = animation[animCurrent].numframes - 1;
3997 oldanimCurrent = animCurrent;
3998 oldanimTarget = animTarget;
3999 oldframeTarget = frameTarget;
4000 oldframeCurrent = frameCurrent;
4002 for (i = 0; i < skeleton.num_joints; i++) {
4003 skeleton.joints[i].velocity = (animation[animCurrent].position[i][frameCurrent] * (1 - target) + animation[animTarget].position[i][frameTarget] * (target) - skeleton.joints[i].position) / multiplier;
4004 skeleton.joints[i].position = animation[animCurrent].position[i][frameCurrent] * (1 - target) + animation[animTarget].position[i][frameTarget] * (target);
4006 offset = currentoffset * (1 - target) + targetoffset * target;
4007 for (i = 0; i < skeleton.num_muscles; i++) {
4008 if (skeleton.muscles[i].visible) {
4009 skeleton.muscles[i].rotate1 = skeleton.muscles[i].oldrotate1 * (1 - target) + skeleton.muscles[i].newrotate1 * (target);
4010 skeleton.muscles[i].rotate2 = skeleton.muscles[i].oldrotate2 * (1 - target) + skeleton.muscles[i].newrotate2 * (target);
4011 skeleton.muscles[i].rotate3 = skeleton.muscles[i].oldrotate3 * (1 - target) + skeleton.muscles[i].newrotate3 * (target);
4016 if (isLanding() && landhard) {
4019 animTarget = getLandhard();
4026 //skeleton.DoConstraints();
4029 void Person::DoStuff()
4031 static XYZ terrainnormal;
4032 static XYZ flatfacing;
4033 static XYZ flatvelocity;
4034 static float flatvelspeed;
4038 static int bloodsize;
4039 static int startx, starty, endx, endy;
4040 static GLubyte color;
4041 static XYZ bloodvel;
4043 onfiredelay -= multiplier;
4044 if (onfiredelay < 0 && onfire) {
4045 if (Random() % 2 == 0) {
4051 crouchkeydowntime += multiplier;
4053 crouchkeydowntime = 0;
4054 jumpkeydowntime += multiplier;
4055 if (!jumpkeydown && skeleton.free)
4056 jumpkeydowntime = 0;
4058 if (hostile || damage > 0 || bloodloss > 0)
4061 if (isIdle() || isRun())
4064 if (num_weapons == 1 && weaponactive != -1)
4068 blooddimamount -= multiplier * .3;
4069 speechdelay -= multiplier;
4070 texupdatedelay -= multiplier;
4071 interestdelay -= multiplier;
4072 flamedelay -= multiplier;
4073 parriedrecently -= multiplier;
4080 speed = 1.1 * speedmult;
4082 speed = 1.0 * speedmult;
4084 rabbitkickragdoll = 0;
4088 if (id != 0 && (creature == rabbittype || difficulty != 2))
4090 if (id != 0 && creature == wolftype && difficulty == 2) {
4092 if (aitype != passivetype) {
4094 if (aitype == attacktypecutoff && (player[0].isIdle() || player[0].isCrouch() || player[0].skeleton.free || player[0].animTarget == getupfrombackanim || player[0].animTarget == getupfromfrontanim || player[0].animTarget == sneakanim) && distsq(&coords, &player[0].coords) < 16) {
4100 if (animTarget == wolfrunninganim && !superruntoggle) {
4101 animTarget = getRun();
4105 if (weaponactive == -1 && num_weapons > 0) {
4106 if (weapons[weaponids[0]].getType() == staff) {
4112 burnt += multiplier;
4113 /*if(aitype!=playercontrolled)*///deathbleeding=5;
4114 /*if(aitype!=playercontrolled)*/
4118 OPENAL_SetVolume(channels[stream_firesound], 256 + 256 * findLength(&velocity) / 3);
4120 if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) {
4126 vel[0] = velocity.x;
4127 vel[1] = velocity.y;
4128 vel[2] = velocity.z;
4131 OPENAL_3D_SetAttributes(channels[whooshsound], gLoc, vel);
4132 OPENAL_SetVolume(channels[whooshsound], 64 * findLength(&velocity) / 5);
4136 while (flamedelay < 0 && onfire) {
4138 howmany = abs(Random() % (skeleton.num_joints));
4140 flatvelocity = (coords - oldcoords) / multiplier / 2; //velocity/2;
4142 flatvelocity = skeleton.joints[howmany].velocity * scale / 2;
4144 flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
4146 flatfacing = skeleton.joints[howmany].position * scale + coords;
4147 Sprite::MakeSprite(flamesprite, flatfacing, flatvelocity, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, 1);
4150 while (flamedelay < 0 && !onfire && tutoriallevel == 1 && id != 0) {
4152 howmany = abs(Random() % (skeleton.num_joints));
4154 flatvelocity = (coords - oldcoords) / multiplier / 2; //velocity/2;
4156 flatvelocity = skeleton.joints[howmany].velocity * scale / 2;
4158 flatfacing = DoRotation(DoRotation(DoRotation(skeleton.joints[howmany].position, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords;
4160 flatfacing = skeleton.joints[howmany].position * scale + coords;
4161 Sprite::MakeSprite(breathsprite, flatfacing, flatvelocity, 1, 1, 1, .6 + (float)abs(Random() % 100) / 200 - .25, .3);
4165 bleeding -= multiplier * .3;
4166 if (bloodtoggle == 2) {
4167 skeleton.drawmodel.textureptr.bind();
4168 if (bleeding <= 0 && (detail != 2 || osx))
4173 if (neckspurtamount > 0) {
4174 neckspurtamount -= multiplier;
4175 neckspurtdelay -= multiplier * 3;
4176 neckspurtparticledelay -= multiplier * 3;
4177 if (neckspurtparticledelay < 0 && neckspurtdelay > 2) {
4180 if (!skeleton.free) {
4181 bloodvel.z = 5 * neckspurtamount;
4182 bloodvel = DoRotation(bloodvel, ((float)(Random() % 100)) / 40, yaw + ((float)(Random() % 100)) / 40, 0) * scale;
4184 if (skeleton.free) {
4185 bloodvel -= DoRotation(skeleton.forward * 10 * scale, ((float)(Random() % 100)) / 40, ((float)(Random() % 100)) / 40, 0);
4188 bloodvel += DoRotation(skeleton.joints[skeleton.jointlabels[head]].velocity, ((float)(Random() % 100)) / 40, yaw + ((float)(Random() % 100)) / 40, 0) * scale;
4190 bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 40, ((float)(Random() % 100)) / 40, 0) * scale;
4192 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);
4194 Sprite::MakeSprite(bloodsprite, DoRotation(skeleton.joints[skeleton.jointlabels[neck]].position + (skeleton.joints[skeleton.jointlabels[neck]].position - skeleton.joints[skeleton.jointlabels[head]].position) / 5, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, .9);
4195 neckspurtparticledelay = .05;
4197 if (neckspurtdelay < 0) {
4202 if (deathbleeding > 0 && dead != 2) {
4203 if (deathbleeding < 5)
4204 bleeddelay -= deathbleeding * multiplier / 4;
4206 bleeddelay -= 5 * multiplier / 4;
4207 if (bleeddelay < 0 && bloodtoggle) {
4213 bloodvel += DoRotation(skeleton.joints[skeleton.jointlabels[abdomen]].velocity, ((float)(Random() % 100)) / 4, yaw + ((float)(Random() % 100)) / 4, 0) * scale;
4215 bloodvel += DoRotation(velocity, ((float)(Random() % 100)) / 4, ((float)(Random() % 100)) / 4, 0) * scale;
4217 Sprite::MakeSprite(bloodsprite, skeleton.joints[skeleton.jointlabels[abdomen]].position * scale + coords, bloodvel, 1, 1, 1, .05, 1);
4219 Sprite::MakeSprite(bloodsprite, DoRotation((skeleton.joints[skeleton.jointlabels[abdomen]].position + skeleton.joints[skeleton.jointlabels[abdomen]].position) / 2, 0, yaw, 0)*scale + coords, bloodvel, 1, 1, 1, .05, 1);
4222 bloodloss += deathbleeding * multiplier * 80;
4223 deathbleeding -= multiplier * 1.6;
4224 //if(id==0)deathbleeding-=multiplier*.2;
4225 if (deathbleeding < 0)
4227 if (bloodloss > damagetolerance && animation[animTarget].attack == neutral) {
4228 if (weaponactive != -1) {
4229 weapons[weaponids[0]].owner = -1;
4230 weapons[weaponids[0]].velocity = velocity * scale * -.3;
4231 weapons[weaponids[0]].velocity.x += .01;
4232 weapons[weaponids[0]].tipvelocity = velocity * scale;
4233 weapons[weaponids[0]].missed = 1;
4234 weapons[weaponids[0]].hitsomething = 0;
4235 weapons[weaponids[0]].freetime = 0;
4236 weapons[weaponids[0]].firstfree = 1;
4237 weapons[weaponids[0]].physics = 1;
4240 weaponids[0] = weaponids[num_weapons];
4241 if (weaponstuck == num_weapons)
4245 for (i = 0; i < numplayers; i++) {
4246 player[i].wentforweapon = 0;
4258 if (!dead && creature == wolftype) {
4259 award_bonus(0, Wolfbonus);
4262 if (animTarget == knifefollowedanim && !skeleton.free) {
4263 for (i = 0; i < skeleton.num_joints; i++) {
4264 skeleton.joints[i].velocity = 0;
4265 skeleton.joints[i].velocity.y = -2;
4268 if (id != 0 && unconscioustime > .1) {
4276 if (texupdatedelay < 0 && bleeding > 0 && bloodtoggle == 2 && distsq(&viewer, &coords) < 9) {
4277 texupdatedelay = .12;
4279 bloodsize = 5 - realtexdetail;
4283 startx = bleedy; //abs(Random()%(skeleton.skinsize-bloodsize-1));
4284 starty = bleedx; //abs(Random()%(skeleton.skinsize-bloodsize-1));
4285 endx = startx + bloodsize;
4286 endy = starty + bloodsize;
4296 if (endx > skeleton.skinsize - 1) {
4297 endx = skeleton.skinsize - 1;
4300 if (endy > skeleton.skinsize - 1) {
4301 endy = skeleton.skinsize - 1;
4309 for (i = startx; i < endx; i++) {
4310 for (j = starty; j < endy; j++) {
4311 if (Random() % 2 == 0) {
4312 color = Random() % 85 + 170;
4313 if (skeleton.skinText[i * skeleton.skinsize * 3 + j * 3 + 0] > color / 2)
4314 skeleton.skinText[i * skeleton.skinsize * 3 + j * 3 + 0] = color / 2;
4315 skeleton.skinText[i * skeleton.skinsize * 3 + j * 3 + 1] = 0;
4316 skeleton.skinText[i * skeleton.skinsize * 3 + j * 3 + 2] = 0;
4320 if (!osx && detail > 1) {
4321 skeleton.drawmodel.textureptr.bind();
4325 if (!skeleton.free) {
4326 bleedy -= 4 / realtexdetail;
4328 bleedx += (abs(Random() % 3) - 1) * 2 / realtexdetail;
4330 bleedx += (abs(Random() % 3) - 1) * 4 / realtexdetail;
4332 if (skeleton.free) {
4333 bleedx += 4 * direction / realtexdetail;
4335 bleedy += (abs(Random() % 3) - 1) * 2 / realtexdetail;
4337 bleedy += (abs(Random() % 3) - 1) * 4 / realtexdetail;
4341 if (abs(righthandmorphness - targetrighthandmorphness) < multiplier * 4) {
4342 righthandmorphness = targetrighthandmorphness;
4343 righthandmorphstart = righthandmorphend;
4344 } else if (righthandmorphness > targetrighthandmorphness) {
4345 righthandmorphness -= multiplier * 4;
4346 } else if (righthandmorphness < targetrighthandmorphness) {
4347 righthandmorphness += multiplier * 4;
4350 if (abs(lefthandmorphness - targetlefthandmorphness) < multiplier * 4) {
4351 lefthandmorphness = targetlefthandmorphness;
4352 lefthandmorphstart = lefthandmorphend;
4353 } else if (lefthandmorphness > targetlefthandmorphness) {
4354 lefthandmorphness -= multiplier * 4;
4355 } else if (lefthandmorphness < targetlefthandmorphness) {
4356 lefthandmorphness += multiplier * 4;
4359 if (creature == rabbittype || targettailmorphness == 5 || targettailmorphness == 0) {
4360 if (abs(tailmorphness - targettailmorphness) < multiplier * 10) {
4361 tailmorphness = targettailmorphness;
4362 tailmorphstart = tailmorphend;
4363 } else if (tailmorphness > targettailmorphness) {
4364 tailmorphness -= multiplier * 10;
4365 } else if (tailmorphness < targettailmorphness) {
4366 tailmorphness += multiplier * 10;
4370 if (creature == wolftype) {
4371 if (abs(tailmorphness - targettailmorphness) < multiplier * 4) {
4372 tailmorphness = targettailmorphness;
4373 tailmorphstart = tailmorphend;
4374 } else if (tailmorphness > targettailmorphness) {
4375 tailmorphness -= multiplier * 2;
4376 } else if (tailmorphness < targettailmorphness) {
4377 tailmorphness += multiplier * 2;
4381 if (headmorphend == 3 || headmorphstart == 3) {
4382 if (abs(headmorphness - targetheadmorphness) < multiplier * 7) {
4383 headmorphness = targetheadmorphness;
4384 headmorphstart = headmorphend;
4385 } else if (headmorphness > targetheadmorphness) {
4386 headmorphness -= multiplier * 7;
4387 } else if (headmorphness < targetheadmorphness) {
4388 headmorphness += multiplier * 7;
4390 } else if (headmorphend == 5 || headmorphstart == 5) {
4391 if (abs(headmorphness - targetheadmorphness) < multiplier * 10) {
4392 headmorphness = targetheadmorphness;
4393 headmorphstart = headmorphend;
4394 } else if (headmorphness > targetheadmorphness) {
4395 headmorphness -= multiplier * 10;
4396 } else if (headmorphness < targetheadmorphness) {
4397 headmorphness += multiplier * 10;
4400 if (abs(headmorphness - targetheadmorphness) < multiplier * 4) {
4401 headmorphness = targetheadmorphness;
4402 headmorphstart = headmorphend;
4403 } else if (headmorphness > targetheadmorphness) {
4404 headmorphness -= multiplier * 4;
4405 } else if (headmorphness < targetheadmorphness) {
4406 headmorphness += multiplier * 4;
4410 if (abs(chestmorphness - targetchestmorphness) < multiplier) {
4411 chestmorphness = targetchestmorphness;
4412 chestmorphstart = chestmorphend;
4413 } else if (chestmorphness > targetchestmorphness) {
4414 chestmorphness -= multiplier;
4415 } else if (chestmorphness < targetchestmorphness) {
4416 chestmorphness += multiplier;
4419 if (dead != 2 && howactive <= typesleeping) {
4420 if (chestmorphstart == 0 && chestmorphend == 0) {
4422 targetchestmorphness = 1;
4425 if (chestmorphstart != 0 && chestmorphend != 0) {
4427 targetchestmorphness = 1;
4429 if (environment == snowyenvironment) {
4433 footvel = DoRotation(skeleton.specialforward[0], 0, yaw, 0) * -1;
4435 footvel = skeleton.specialforward[0] * -1;
4437 footpoint = DoRotation((skeleton.joints[skeleton.jointlabels[head]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2, 0, yaw, 0) * scale + coords;
4439 footpoint = ((skeleton.joints[skeleton.jointlabels[head]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2) * scale + coords;
4440 if (animTarget == sleepanim)
4441 footvel = DoRotation(footvel, 0, 90, 0);
4442 Sprite::MakeSprite(breathsprite, footpoint + footvel * .2, footvel * .4, 1, 1, 1, .4, .3);
4446 if (!dead && howactive < typesleeping) {
4447 blinkdelay -= multiplier * 2;
4448 if (headmorphstart == 0 && headmorphend == 0 && blinkdelay <= 0) {
4450 targetheadmorphness = 1;
4452 blinkdelay = (float)(abs(Random() % 40)) / 5;
4454 if (headmorphstart == 3 && headmorphend == 3) {
4456 targetheadmorphness = 1;
4461 twitchdelay -= multiplier * 1.5;
4462 if (animTarget != hurtidleanim) {
4463 if (headmorphstart == 0 && headmorphend == 0 && twitchdelay <= 0) {
4465 targetheadmorphness = 1;
4467 twitchdelay = (float)(abs(Random() % 40)) / 5;
4469 if (headmorphstart == 5 && headmorphend == 5) {
4471 targetheadmorphness = 1;
4475 if ((isIdle() || isCrouch()) && animTarget != hurtidleanim) {
4476 twitchdelay3 -= multiplier * 1;
4477 if (Random() % 2 == 0) {
4478 if (righthandmorphstart == 0 && righthandmorphend == 0 && twitchdelay3 <= 0) {
4479 righthandmorphness = 0;
4480 targetrighthandmorphness = 1;
4481 righthandmorphend = 1;
4482 if (Random() % 2 == 0)twitchdelay3 = (float)(abs(Random() % 40)) / 5;
4484 if (righthandmorphstart == 1 && righthandmorphend == 1) {
4485 righthandmorphness = 0;
4486 targetrighthandmorphness = 1;
4487 righthandmorphend = 0;
4490 if (Random() % 2 == 0) {
4491 if (lefthandmorphstart == 0 && lefthandmorphend == 0 && twitchdelay3 <= 0) {
4492 lefthandmorphness = 0;
4493 targetlefthandmorphness = 1;
4494 lefthandmorphend = 1;
4495 twitchdelay3 = (float)(abs(Random() % 40)) / 5;
4497 if (lefthandmorphstart == 1 && lefthandmorphend == 1) {
4498 lefthandmorphness = 0;
4499 targetlefthandmorphness = 1;
4500 lefthandmorphend = 0;
4506 if (creature == rabbittype) {
4507 if (howactive < typesleeping)
4508 twitchdelay2 -= multiplier * 1.5;
4510 twitchdelay2 -= multiplier * 0.5;
4511 if (howactive <= typesleeping) {
4512 if (tailmorphstart == 0 && tailmorphend == 0 && twitchdelay2 <= 0) {
4514 targettailmorphness = 1;
4516 twitchdelay2 = (float)(abs(Random() % 40)) / 5;
4518 if (tailmorphstart == 1 && tailmorphend == 1) {
4520 targettailmorphness = 1;
4523 if (tailmorphstart == 2 && tailmorphend == 2) {
4525 targettailmorphness = 1;
4532 if (creature == wolftype) {
4533 twitchdelay2 -= multiplier * 1.5;
4534 if (tailmorphend != 0)
4535 if ((isRun() || animTarget == jumpupanim || animTarget == jumpdownanim || animTarget == backflipanim) && !skeleton.free) {
4537 targettailmorphness = 1;
4541 if (tailmorphend != 5)
4542 if (animTarget == flipanim || animTarget == frontflipanim || animTarget == rollanim || skeleton.free) {
4544 targettailmorphness = 1;
4548 if (twitchdelay2 <= 0) {
4549 if (((tailmorphstart == 0 && tailmorphend == 0) || (tailmorphstart == 5 && tailmorphend == 5))) {
4551 targettailmorphness = 1;
4554 if (tailmorphstart == 1 && tailmorphend == 1) {
4556 targettailmorphness = 1;
4559 if (tailmorphstart == 2 && tailmorphend == 2) {
4561 targettailmorphness = 1;
4564 if (tailmorphstart == 3 && tailmorphend == 3) {
4566 targettailmorphness = 1;
4569 if (tailmorphstart == 4 && tailmorphend == 4) {
4571 targettailmorphness = 1;
4578 unconscioustime = 0;
4580 if (dead == 1 || howactive == typesleeping) {
4581 unconscioustime += multiplier;
4582 //If unconscious, close eyes and mouth
4583 if (righthandmorphend != 0)
4584 righthandmorphness = 0;
4585 righthandmorphend = 0;
4586 targetrighthandmorphness = 1;
4588 if (lefthandmorphend != 0)
4589 lefthandmorphness = 0;
4590 lefthandmorphend = 0;
4591 targetlefthandmorphness = 1;
4593 if (headmorphend != 3 && headmorphend != 5)
4596 targetheadmorphness = 1;
4600 if (howactive > typesleeping) {
4603 if (bloodtoggle && !bled) {
4604 terrain.MakeDecal(blooddecalslow, headpoint, .8, .5, 0);
4606 if (bloodtoggle && !bled)
4607 for (l = 0; l < terrain.patchobjectnum[whichpatchx][whichpatchz]; l++) {
4608 j = terrain.patchobjects[whichpatchx][whichpatchz][l];
4609 XYZ point = DoRotation(headpoint - objects.position[j], 0, -objects.yaw[j], 0);
4613 objects.model[j].MakeDecal(blooddecalslow, &point, &size, &opacity, &yaw);
4618 if (dead == 2 || howactive > typesleeping) {
4619 //If dead, open mouth and hands
4620 if (righthandmorphend != 0)
4621 righthandmorphness = 0;
4622 righthandmorphend = 0;
4623 targetrighthandmorphness = 1;
4625 if (lefthandmorphend != 0)
4626 lefthandmorphness = 0;
4627 lefthandmorphend = 0;
4628 targetlefthandmorphness = 1;
4630 if (headmorphend != 2)
4633 targetheadmorphness = 1;
4636 if (stunned > 0 && !dead && headmorphend != 2) {
4637 if (headmorphend != 4)
4640 targetheadmorphness = 1;
4643 if (damage > damagetolerance && !dead) {
4646 unconscioustime = 0;
4648 if (creature == wolftype) {
4649 award_bonus(0, Wolfbonus);
4654 if (weaponactive != -1) {
4655 weapons[weaponids[0]].owner = -1;
4656 weapons[weaponids[0]].velocity = velocity * scale * -.3;
4657 weapons[weaponids[0]].velocity.x += .01;
4658 weapons[weaponids[0]].tipvelocity = velocity * scale;
4659 weapons[weaponids[0]].missed = 1;
4660 weapons[weaponids[0]].hitsomething = 0;
4661 weapons[weaponids[0]].freetime = 0;
4662 weapons[weaponids[0]].firstfree = 1;
4663 weapons[weaponids[0]].physics = 1;
4666 weaponids[0] = weaponids[num_weapons];
4667 if (weaponstuck == num_weapons)
4671 for (i = 0; i < numplayers; i++) {
4672 player[i].wentforweapon = 0;
4678 if ((id == 0 || distsq(&coords, &viewer) < 50) && autoslomo) {
4686 //if(dead)damage-=multiplier/4;
4688 damage -= multiplier * 13;
4689 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
4691 permanentdamage -= multiplier * 4;
4692 if (isIdle() || isCrouch()) {
4694 permanentdamage -= multiplier * 4;
4695 //if(!dead&&deathbleeding<=0&&id==0)bloodloss-=multiplier*4;
4699 if (permanentdamage < 0)
4700 permanentdamage = 0;
4701 if (superpermanentdamage < 0)
4702 superpermanentdamage = 0;
4703 if (permanentdamage < superpermanentdamage) {
4704 permanentdamage = superpermanentdamage;
4706 if (damage < permanentdamage) {
4707 damage = permanentdamage;
4709 if (dead == 1 && damage < damagetolerance) {
4713 for (i = 0; i < skeleton.num_joints; i++) {
4714 skeleton.joints[i].velocity = 0;
4717 if (permanentdamage > damagetolerance && dead != 2) {
4720 if (weaponactive != -1) {
4721 weapons[weaponids[0]].owner = -1;
4722 weapons[weaponids[0]].velocity = velocity * scale * -.3;
4723 weapons[weaponids[0]].velocity.x += .01;
4724 weapons[weaponids[0]].tipvelocity = velocity * scale;
4725 weapons[weaponids[0]].missed = 1;
4726 weapons[weaponids[0]].hitsomething = 0;
4727 weapons[weaponids[0]].freetime = 0;
4728 weapons[weaponids[0]].firstfree = 1;
4729 weapons[weaponids[0]].physics = 1;
4732 weaponids[0] = weaponids[num_weapons];
4733 if (weaponstuck == num_weapons)
4737 for (i = 0; i < numplayers; i++) {
4738 player[i].wentforweapon = 0;
4744 if (!dead && creature == wolftype) {
4745 award_bonus(0, Wolfbonus);
4748 if (unconscioustime < .1 && (bonus != spinecrusher || bonustime > 1) && (bonus != FinishedBonus || bonustime > 1) && bloodloss < damagetolerance)
4749 award_bonus(id, touchofdeath);
4750 if (id != 0 && unconscioustime > .1) {
4758 emit_sound_at(breaksound, coords);
4761 if (skeleton.free == 1) {
4763 pause_sound(whooshsound);
4766 //If knocked over, open hands and close mouth
4767 if (righthandmorphend != 0)
4768 righthandmorphness = 0;
4769 righthandmorphend = 0;
4770 targetrighthandmorphness = 1;
4772 if (lefthandmorphend != 0)
4773 lefthandmorphness = 0;
4774 lefthandmorphend = 0;
4775 targetlefthandmorphness = 1;
4777 if (headmorphend != 3 && headmorphend != 5 && headmorphstart != 3 && headmorphstart != 5) {
4778 if (headmorphend != 0)
4781 targetheadmorphness = 1;
4785 skeleton.DoGravity(&scale);
4787 damageamount = skeleton.DoConstraints(&coords, &scale) * 5;
4788 if (damage > damagetolerance - damageamount && !dead && (bonus != spinecrusher || bonustime > 1) && (bonus != style || bonustime > 1) && (bonus != cannon || bonustime > 1))
4789 award_bonus(id, deepimpact);
4790 DoDamage(damageamount / ((protectionhigh + protectionhead + protectionlow) / 3));
4794 for (j = 0; j < skeleton.num_joints; j++) {
4795 average += skeleton.joints[j].position;
4799 coords += average * scale;
4800 for (j = 0; j < skeleton.num_joints; j++) {
4801 skeleton.joints[j].position -= average;
4803 average /= multiplier;
4805 //velocity=skeleton.joints[skeleton.jointlabels[groin]].velocity*scale;
4807 for (i = 0; i < skeleton.num_joints; i++) {
4808 velocity += skeleton.joints[i].velocity * scale;
4810 velocity /= skeleton.num_joints;
4812 if (!isnormal(velocity.x) && velocity.x) {
4816 if (findLength(&average) < 10 && dead && skeleton.free) {
4817 skeleton.longdead += (2000 - findLength(&average)) * multiplier + multiplier;
4818 if (skeleton.longdead > 2000) {
4819 if (skeleton.longdead > 6000) {
4821 pause_sound(whooshsound);
4826 if (dead == 2 && bloodloss < damagetolerance) {
4828 headpoint = (skeleton.joints[skeleton.jointlabels[head]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2 * scale + coords;
4830 if (bloodtoggle && !bled) {
4831 terrain.MakeDecal(blooddecal, headpoint, .2 * 1.2, .5, 0);
4833 if (bloodtoggle && !bled)
4834 for (l = 0; l < terrain.patchobjectnum[whichpatchx][whichpatchz]; l++) {
4835 j = terrain.patchobjects[whichpatchx][whichpatchz][l];
4836 XYZ point = DoRotation(headpoint - objects.position[j], 0, -objects.yaw[j], 0);
4837 float size = .2 * 1.2;
4840 objects.model[j].MakeDecal(blooddecal, &point, &size, &opacity, &yaw);
4844 if (dead == 2 && bloodloss >= damagetolerance) {
4846 headpoint = (skeleton.joints[skeleton.jointlabels[abdomen]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2 * scale + coords;
4849 if (bloodtoggle && !bled) {
4850 terrain.MakeDecal(blooddecalslow, headpoint, .8, .5, 0);
4852 if (bloodtoggle && !bled)
4853 for (l = 0; l < terrain.patchobjectnum[whichpatchx][whichpatchz]; l++) {
4854 j = terrain.patchobjects[whichpatchx][whichpatchz][l];
4855 XYZ point = DoRotation(headpoint - objects.position[j], 0, -objects.yaw[j], 0);
4859 objects.model[j].MakeDecal(blooddecalslow, &point, &size, &opacity, &yaw);
4866 if (!dead && crouchkeydown && skeleton.freetime > .5 && id == 0 && skeleton.free) {
4867 bool canrecover = 1;
4868 XYZ startpoint, endpoint, colpoint, colviewer, coltarget;
4869 startpoint = coords;
4872 if (terrain.lineTerrain(startpoint, endpoint, &colpoint) != -1)
4874 if (velocity.y < -30)
4876 for (i = 0; i < objects.numobjects; i++) {
4877 if (objects.type[i] != treeleavestype && objects.type[i] != bushtype && objects.type[i] != firetype) {
4878 colviewer = startpoint;
4879 coltarget = endpoint;
4880 if (objects.model[i].LineCheck(&colviewer, &coltarget, &colpoint, &objects.position[i], &objects.yaw[i]) != -1)
4889 terrainnormal = skeleton.joints[skeleton.jointlabels[groin]].position - skeleton.joints[skeleton.jointlabels[abdomen]].position;
4890 if (skeleton.joints[skeleton.jointlabels[groin]].locked && skeleton.joints[skeleton.jointlabels[abdomen]].locked) {
4891 terrainnormal = skeleton.joints[skeleton.jointlabels[groin]].position - skeleton.joints[skeleton.jointlabels[abdomen]].position;
4892 middle = (skeleton.joints[skeleton.jointlabels[groin]].position + skeleton.joints[skeleton.jointlabels[abdomen]].position) / 2;
4894 if (skeleton.joints[skeleton.jointlabels[abdomen]].locked && skeleton.joints[skeleton.jointlabels[neck]].locked) {
4895 terrainnormal = skeleton.joints[skeleton.jointlabels[abdomen]].position - skeleton.joints[skeleton.jointlabels[neck]].position;
4896 middle = (skeleton.joints[skeleton.jointlabels[neck]].position + skeleton.joints[skeleton.jointlabels[abdomen]].position) / 2;
4898 if (skeleton.joints[skeleton.jointlabels[groin]].locked && skeleton.joints[skeleton.jointlabels[neck]].locked) {
4899 terrainnormal = skeleton.joints[skeleton.jointlabels[groin]].position - skeleton.joints[skeleton.jointlabels[neck]].position;
4900 middle = (skeleton.joints[skeleton.jointlabels[groin]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2;
4902 Normalise(&terrainnormal);
4904 targetyaw = -asin(0 - terrainnormal.x);
4905 targetyaw *= 360 / 6.28;
4906 if (terrainnormal.z < 0)
4907 targetyaw = 180 - targetyaw;
4912 animTarget = flipanim;
4913 crouchtogglekeydown = 1;
4918 animCurrent = tempanim;
4921 //tilt2=targettilt2;
4923 //if(middle.y>0)targetoffset.y=middle.y+1;
4925 for (i = 0; i < skeleton.num_joints; i++) {
4926 tempanimation.position[i][0] = skeleton.joints[i].position;
4927 tempanimation.position[i][0] = DoRotation(tempanimation.position[i][0], 0, -yaw, 0);
4932 if (findLength(&average) < 10 && !dead && skeleton.free) {
4933 skeleton.longdead += (2000 - findLength(&average)) * multiplier + multiplier;
4934 if (skeleton.longdead > (damage + 500) * 1.5) {
4936 pause_sound(whooshsound);
4942 terrainnormal = skeleton.joints[skeleton.jointlabels[groin]].position - skeleton.joints[skeleton.jointlabels[abdomen]].position;
4943 if (skeleton.joints[skeleton.jointlabels[groin]].locked && skeleton.joints[skeleton.jointlabels[abdomen]].locked) {
4944 terrainnormal = skeleton.joints[skeleton.jointlabels[groin]].position - skeleton.joints[skeleton.jointlabels[abdomen]].position;
4945 middle = (skeleton.joints[skeleton.jointlabels[groin]].position + skeleton.joints[skeleton.jointlabels[abdomen]].position) / 2;
4947 if (skeleton.joints[skeleton.jointlabels[abdomen]].locked && skeleton.joints[skeleton.jointlabels[neck]].locked) {
4948 terrainnormal = skeleton.joints[skeleton.jointlabels[abdomen]].position - skeleton.joints[skeleton.jointlabels[neck]].position;
4949 middle = (skeleton.joints[skeleton.jointlabels[neck]].position + skeleton.joints[skeleton.jointlabels[abdomen]].position) / 2;
4951 if (skeleton.joints[skeleton.jointlabels[groin]].locked && skeleton.joints[skeleton.jointlabels[neck]].locked) {
4952 terrainnormal = skeleton.joints[skeleton.jointlabels[groin]].position - skeleton.joints[skeleton.jointlabels[neck]].position;
4953 middle = (skeleton.joints[skeleton.jointlabels[groin]].position + skeleton.joints[skeleton.jointlabels[neck]].position) / 2;
4955 Normalise(&terrainnormal);
4957 targetyaw = -asin(0 - terrainnormal.x);
4958 targetyaw *= 360 / 6.28;
4959 if (terrainnormal.z < 0)
4960 targetyaw = 180 - targetyaw;
4963 targettilt2 = asin(terrainnormal.y) * 180 / 3.14 * -1;
4966 if (skeleton.forward.y < 0) {
4967 animTarget = getupfrombackanim;
4971 if (skeleton.forward.y > -.3) {
4972 animTarget = getupfromfrontanim;
4980 if ((Random() % 8 == 0 && id != 0 && creature == rabbittype) || (Random() % 2 == 0 && id != 0 && creature == wolftype) || (id == 0 && crouchkeydown && (forwardkeydown || backkeydown || leftkeydown || rightkeydown))) {
4981 animTarget = rollanim;
4982 targetyaw = lookyaw;
4999 if ( !leftkeydown && !rightkeydown)
5006 if (abs(targettilt2) > 50)
5008 animCurrent = tempanim;
5011 tilt2 = targettilt2;
5013 if (middle.y > 0 && animTarget != rollanim)
5014 targetoffset.y = middle.y + 1;
5016 for (i = 0; i < skeleton.num_joints; i++) {
5017 tempanimation.position[i][0] = skeleton.joints[i].position;
5018 tempanimation.position[i][0] = DoRotation(tempanimation.position[i][0], 0, -yaw, 0);
5025 if (num_weapons > 0)
5026 if (weapons[0].getType() == staff)
5028 if (!skeleton.freefall && freefall && ((jumpkeydown && jumpkeydowntime < .2) || (hasstaff && rabbitkickragdoll)) && !dead) {
5029 if (velocity.y > -30) {
5031 tempvelocity = velocity;
5032 Normalise(&tempvelocity);
5033 targetyaw = -asin(0 - tempvelocity.x);
5034 targetyaw *= 360 / 6.28;
5036 targetyaw = 180 - targetyaw;
5040 if (dotproduct(&skeleton.forward, &tempvelocity) < 0) {
5041 animTarget = rollanim;
5044 animTarget = backhandspringanim;
5050 emit_sound_at(movewhooshsound, coords, 128.);
5052 animCurrent = animTarget;
5053 frameCurrent = frameTarget - 1;
5065 if (skeleton.freefall == 0)
5070 if (aitype != passivetype || skeleton.free == 1)
5071 if (findLengthfast(&velocity) > .1)
5072 for (i = 0; i < objects.numobjects; i++) {
5073 if (objects.type[i] == firetype)
5074 if (distsqflat(&coords, &objects.position[i]) < objects.scale[i]*objects.scale[i] * 12 && distsq(&coords, &objects.position[i]) < objects.scale[i]*objects.scale[i] * 49) {
5076 if (!objects.onfire[i]) {
5077 emit_sound_at(firestartsound, objects.position[i]);
5079 objects.onfire[i] = 1;
5082 if (objects.onfire[i]) {
5087 if (objects.type[i] == bushtype)
5088 if (distsqflat(&coords, &objects.position[i]) < objects.scale[i]*objects.scale[i] * 12 && distsq(&coords, &objects.position[i]) < objects.scale[i]*objects.scale[i] * 49) {
5090 if (!objects.onfire[i]) {
5091 emit_sound_at(firestartsound, objects.position[i]);
5093 objects.onfire[i] = 1;
5097 if (objects.onfire[i]) {
5101 if (objects.messedwith[i] <= 0) {
5105 emit_sound_at(bushrustle, coords, 40 * findLength(&velocity));
5108 envsound[numenvsounds] = coords;
5109 envsoundvol[numenvsounds] = 4 * findLength(&velocity);
5110 envsoundlife[numenvsounds] = .4;
5115 if (environment == grassyenvironment)
5116 howmany = findLength(&velocity) * 4;
5117 if (environment == snowyenvironment)
5118 howmany = findLength(&velocity) * 2;
5120 if (environment != desertenvironment)
5121 for (j = 0; j < howmany; j++) {
5122 tempvel.x = float(abs(Random() % 100) - 50) / 20;
5123 tempvel.y = float(abs(Random() % 100) - 50) / 20;
5124 tempvel.z = float(abs(Random() % 100) - 50) / 20;
5127 pos.x += float(abs(Random() % 100) - 50) / 200;
5128 pos.y += float(abs(Random() % 100) - 50) / 200;
5129 pos.z += float(abs(Random() % 100) - 50) / 200;
5130 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);
5131 Sprite::setLastSpriteSpecial(1);
5133 howmany = findLength(&velocity) * 4;
5135 if (environment == snowyenvironment)
5136 for (j = 0; j < howmany; j++) {
5137 tempvel.x = float(abs(Random() % 100) - 50) / 20;
5138 tempvel.y = float(abs(Random() % 100) - 50) / 20;
5139 tempvel.z = float(abs(Random() % 100) - 50) / 20;
5142 pos.x += float(abs(Random() % 100) - 50) / 200;
5143 pos.y += float(abs(Random() % 100) - 50) / 200;
5144 pos.z += float(abs(Random() % 100) - 50) / 200;
5145 Sprite::MakeSprite(splintersprite, pos, tempvel * .3 + velocity * float(abs(Random() % 100)) / 100 / 2, 1, 1, 1, .1, 1);
5146 Sprite::setLastSpriteSpecial(2);
5149 objects.rotx[i] += velocity.x * multiplier * 6;
5150 objects.roty[i] += velocity.z * multiplier * 6;
5151 objects.messedwith[i] = .5;
5154 if (objects.type[i] == treeleavestype && environment != desertenvironment) {
5155 if (objects.pitch[i] == 0)
5158 tempcoord = coords - objects.position[i];
5159 tempcoord = DoRotation(tempcoord, 0, -objects.yaw[i], 0);
5160 tempcoord = DoRotation(tempcoord, -objects.pitch[i], 0, 0);
5161 tempcoord += objects.position[i];
5163 if (distsqflat(&tempcoord, &objects.position[i]) < objects.scale[i]*objects.scale[i] * 8 && distsq(&tempcoord, &objects.position[i]) < objects.scale[i]*objects.scale[i] * 300 && tempcoord.y > objects.position[i].y + 3 * objects.scale[i]) {
5164 if (objects.messedwith[i] <= 0) {
5168 emit_sound_at(bushrustle, coords, 40 * findLength(&velocity));
5171 envsound[numenvsounds] = coords;
5172 envsoundvol[numenvsounds] = 4 * findLength(&velocity);
5173 envsoundlife[numenvsounds] = .4;
5178 if (environment == grassyenvironment)
5179 howmany = findLength(&velocity) * 4;
5180 if (environment == snowyenvironment)
5181 howmany = findLength(&velocity) * 2;
5183 if (environment != desertenvironment)
5184 for (j = 0; j < howmany; j++) {
5185 tempvel.x = float(abs(Random() % 100) - 50) / 20;
5186 tempvel.y = float(abs(Random() % 100) - 50) / 20;
5187 tempvel.z = float(abs(Random() % 100) - 50) / 20;
5189 pos += velocity * .1;
5191 pos.x += float(abs(Random() % 100) - 50) / 150;
5192 pos.y += float(abs(Random() % 100) - 50) / 150;
5193 pos.z += float(abs(Random() % 100) - 50) / 150;
5194 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);
5195 Sprite::setLastSpriteSpecial(1);
5197 howmany = findLength(&velocity) * 4;
5199 if (environment == snowyenvironment)
5200 for (j = 0; j < howmany; j++) {
5201 tempvel.x = float(abs(Random() % 100) - 50) / 20;
5202 tempvel.y = float(abs(Random() % 100) - 50) / 20;
5203 tempvel.z = float(abs(Random() % 100) - 50) / 20;
5205 pos += velocity * .1;
5207 pos.x += float(abs(Random() % 100) - 50) / 150;
5208 pos.y += float(abs(Random() % 100) - 50) / 150;
5209 pos.z += float(abs(Random() % 100) - 50) / 150;
5210 Sprite::MakeSprite(splintersprite, pos, tempvel * .3 + velocity * float(abs(Random() % 100)) / 100 / 2, 1, 1, 1, .1, 1);
5211 Sprite::setLastSpriteSpecial(2);
5214 objects.messedwith[i] = .5;
5219 if (!skeleton.free) {
5222 if ((stunned > 0 || surprised > 0) && numplayers > 2 && aitype != passivetype)
5225 if (aitype != passivetype && victim->skeleton.free && !victim->dead)
5227 if (tutoriallevel == 1 && id != 0)
5229 if (play && aitype != playercontrolled) {
5230 int whichsound = -1;
5231 i = abs(Random() % 4);
5232 if (speechdelay <= 0) {
5233 if (creature == rabbittype) {
5235 whichsound = rabbitchitter;
5237 whichsound = rabbitchitter2;
5239 if (creature == wolftype) {
5241 whichsound = growlsound;
5243 whichsound = growl2sound;
5248 if (whichsound != -1) {
5249 emit_sound_at(whichsound, coords);
5253 if (animTarget == staggerbackhighanim)
5255 if (animTarget == staggerbackhardanim)
5257 staggerdelay -= multiplier;
5258 if (animTarget != crouchstabanim && animTarget != swordgroundstabanim && animTarget != staffgroundsmashanim)
5260 if (velocity.y < -30 && animTarget == jumpdownanim)
5262 if (animCurrent != getIdle() && wasIdle() && animTarget != getIdle() && isIdle()) {
5263 animTarget = getIdle();
5267 weaponmissdelay -= multiplier;
5268 highreversaldelay -= multiplier;
5269 lowreversaldelay -= multiplier;
5270 lastcollide -= multiplier;
5271 skiddelay -= multiplier;
5272 if (!isnormal(velocity.x) && velocity.x) {
5275 if (!isnormal(targettilt) && targettilt) {
5278 if (!isnormal(targettilt2) && targettilt2) {
5281 if (!isnormal(targetyaw) && targetyaw) {
5285 if (animTarget == bounceidleanim || animTarget == wolfidle || animTarget == walkanim || animTarget == drawrightanim || animTarget == crouchdrawrightanim || animTarget == drawleftanim || animTarget == fightidleanim || animTarget == fightsidestep || animTarget == hanganim || isCrouch() || animTarget == backhandspringanim) {
5286 //open hands and close mouth
5287 if (righthandmorphend != 0 && righthandmorphness == targetrighthandmorphness) {
5288 righthandmorphness = 0;
5289 righthandmorphend = 0;
5290 targetrighthandmorphness = 1;
5293 if (lefthandmorphend != 0 && lefthandmorphness == targetlefthandmorphness) {
5294 lefthandmorphness = 0;
5295 lefthandmorphend = 0;
5296 targetlefthandmorphness = 1;
5299 if (headmorphend != 3 && headmorphend != 5 && headmorphstart != 3 && headmorphstart != 5 && headmorphend != 0 && headmorphness == targetheadmorphness) {
5302 targetheadmorphness = 1;
5306 if (animTarget == rollanim || animTarget == dodgebackanim || animTarget == removeknifeanim || animTarget == knifefightidleanim || animTarget == swordfightidleanim || animTarget == blockhighleftstrikeanim || animTarget == crouchremoveknifeanim || animTarget == sneakanim || animTarget == sweepanim || animTarget == spinkickreversedanim || animTarget == jumpdownanim || isWallJump() || isFlip() || animTarget == climbanim || isRun() || animTarget == getupfrombackanim || animTarget == getupfromfrontanim) {
5307 //open hands and mouth
5308 if (righthandmorphend != 0 && righthandmorphness == targetrighthandmorphness) {
5309 righthandmorphness = 0;
5310 righthandmorphend = 0;
5311 targetrighthandmorphness = 1;
5314 if (lefthandmorphend != 0 && lefthandmorphness == targetlefthandmorphness) {
5315 lefthandmorphness = 0;
5316 lefthandmorphend = 0;
5317 targetlefthandmorphness = 1;
5320 if (headmorphend != 1 && headmorphness == targetheadmorphness) {
5323 targetheadmorphness = 1;
5327 if (animTarget == jumpupanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || animTarget == swordfightidlebothanim || animTarget == blockhighleftanim || animTarget == blockhighleftanim) {
5328 //close hands and mouth
5329 if (righthandmorphend != 1 && righthandmorphness == targetrighthandmorphness) {
5330 righthandmorphness = 0;
5331 righthandmorphend = 1;
5332 targetrighthandmorphness = 1;
5335 if (lefthandmorphend != 1 && lefthandmorphness == targetlefthandmorphness) {
5336 lefthandmorphness = 0;
5337 lefthandmorphend = 1;
5338 targetlefthandmorphness = 1;
5341 if (headmorphend != 0 && headmorphness == targetheadmorphness) {
5344 targetheadmorphness = 1;
5348 if (animTarget == spinkickanim || animTarget == staffspinhitreversalanim || animTarget == staffspinhitreversedanim || animTarget == staffhitreversalanim || animTarget == staffhitreversedanim || animTarget == hurtidleanim || animTarget == winduppunchanim || animTarget == swordslashreversalanim || animTarget == swordslashreversedanim || animTarget == knifeslashreversalanim || animTarget == knifeslashreversedanim || animTarget == knifethrowanim || animTarget == knifefollowanim || animTarget == knifefollowedanim || animTarget == killanim || animTarget == dropkickanim || animTarget == upunchanim || animTarget == knifeslashstartanim || animTarget == swordslashanim || animTarget == staffhitanim || animTarget == staffspinhitanim || animTarget == staffgroundsmashanim || animTarget == spinkickreversalanim || animTarget == sweepreversalanim || animTarget == lowkickanim || animTarget == sweepreversedanim || animTarget == rabbitkickreversalanim || animTarget == rabbitkickreversedanim || animTarget == jumpreversalanim || animTarget == jumpreversedanim) {
5349 //close hands and yell
5350 if (righthandmorphend != 1 && righthandmorphness == targetrighthandmorphness) {
5351 righthandmorphness = 0;
5352 righthandmorphend = 1;
5353 targetrighthandmorphness = 1;
5356 if (lefthandmorphend != 1 && lefthandmorphness == targetlefthandmorphness) {
5357 lefthandmorphness = 0;
5358 lefthandmorphend = 1;
5359 targetlefthandmorphness = 1;
5362 if (headmorphend != 2 && headmorphness == targetheadmorphness) {
5365 targetheadmorphness = 1;
5372 if (victim != this && !victim->dead && victim->aitype != passivetype && victim->aitype != searchtype && aitype != passivetype && aitype != searchtype && victim->id < numplayers && aitype != passivetype) {
5373 behind = (normaldotproduct(facing, coords - victim->coords) > 0);
5377 if (!dead && animTarget != hurtidleanim)
5378 if (behind || animTarget == killanim || animTarget == knifethrowanim || animTarget == knifefollowanim || animTarget == spinkickreversalanim || animTarget == rabbitkickreversedanim || animTarget == jumpreversedanim) {
5379 if (headmorphend != 4 || headmorphness == targetheadmorphness) {
5382 targetheadmorphness = 1;
5386 if (weaponactive != -1) {
5387 if (weapons[weaponids[weaponactive]].getType() != staff) {
5388 righthandmorphstart = 1;
5389 righthandmorphend = 1;
5391 if (weapons[weaponids[weaponactive]].getType() == staff) {
5392 righthandmorphstart = 2;
5393 righthandmorphend = 2;
5395 targetrighthandmorphness = 1;
5398 terrainnormal = terrain.getNormal(coords.x, coords.z);
5400 if (animation[animTarget].attack != reversal) {
5401 if (!isnormal(coords.x))
5409 flatfacing = DoRotation(flatfacing, 0, yaw, 0);
5410 facing = flatfacing;
5411 ReflectVector(&facing, terrainnormal);
5414 if (isRun() || animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim) {
5416 targettilt2 = -facing.y * 20;
5421 if (!isRun() && !animation[animTarget].attack && animTarget != getupfromfrontanim && animTarget != getupfrombackanim && animTarget != sneakanim)
5423 if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) {
5424 flatvelocity = velocity;
5426 flatvelspeed = findLength(&flatvelocity);
5427 targettilt = flatvelspeed * fast_sqrt(abs(velocity.y) * .7) * normaldotproduct(DoRotation(flatfacing, 0, -90, 0), flatvelocity);
5428 targettilt2 = flatvelspeed * fast_sqrt(abs(velocity.y) * .7) * normaldotproduct(flatfacing, flatvelocity);
5433 if (targettilt > 25)
5435 if (targettilt < -25)
5439 if (targettilt2 > 45)
5441 if (targettilt2 < -45)
5443 if (abs(tilt2 - targettilt2) < multiplier * 400)
5444 tilt2 = targettilt2;
5445 else if (tilt2 > targettilt2) {
5446 tilt2 -= multiplier * 400;
5447 } else if (tilt2 < targettilt2) {
5448 tilt2 += multiplier * 400;
5450 if (!animation[animTarget].attack && animTarget != getupfrombackanim && animTarget != getupfromfrontanim) {
5457 if (!isnormal(targettilt) && targettilt) {
5460 if (!isnormal(targettilt2) && targettilt2) {
5465 //if(!creature==wolftype||animTarget==rabbitkickanim)
5466 if (animTarget == rabbittackleanim) {
5467 velocity += facing * multiplier * speed * 700 * scale;
5468 velspeed = findLength(&velocity);
5469 if (velspeed > speed * 65 * scale) {
5470 velocity /= velspeed;
5471 velspeed = speed * 65 * scale;
5472 velocity *= velspeed;
5474 velocity.y += gravity * multiplier * 20;
5475 ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
5476 velspeed = findLength(&velocity);
5477 velocity = flatfacing * velspeed;
5479 if (animTarget != rabbitrunninganim && animTarget != wolfrunninganim) {
5480 if (isRun() || animTarget == rabbitkickanim) {
5481 velocity += facing * multiplier * speed * 700 * scale;
5482 velspeed = findLength(&velocity);
5483 if (velspeed > speed * 45 * scale) {
5484 velocity /= velspeed;
5485 velspeed = speed * 45 * scale;
5486 velocity *= velspeed;
5488 velocity.y += gravity * multiplier * 20;
5489 ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
5490 velspeed = findLength(&velocity);
5491 if (velspeed < speed * 30 * scale)
5492 velspeed = speed * 30 * scale;
5493 velocity = flatfacing * velspeed;
5495 } else if (isRun()) {
5496 velocity += facing * multiplier * speed * 700 * scale;
5497 velspeed = findLength(&velocity);
5498 if (creature == rabbittype) {
5499 if (velspeed > speed * 55 * scale) {
5500 velocity /= velspeed;
5501 velspeed = speed * 55 * scale;
5502 velocity *= velspeed;
5505 if (creature == wolftype) {
5506 if (velspeed > speed * 75 * scale) {
5507 velocity /= velspeed;
5508 velspeed = speed * 75 * scale;
5509 velocity *= velspeed;
5512 velocity.y += gravity * multiplier * 20;
5513 ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
5514 velspeed = findLength(&velocity);
5515 velocity = flatfacing * velspeed;
5518 if (animTarget == rollanim && animation[animTarget].label[frameTarget] != 6) {
5519 velocity += facing * multiplier * speed * 700 * scale;
5520 velspeed = findLength(&velocity);
5521 if (velspeed > speed * 45 * scale) {
5522 velocity /= velspeed;
5523 velspeed = speed * 45 * scale;
5524 velocity *= velspeed;
5526 velocity.y += gravity * multiplier * 20;
5527 ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
5528 velspeed = findLength(&velocity);
5529 velocity = flatfacing * velspeed;
5533 /*if(animCurrent==rollanim&&(isCrouch()||isIdle())){
5534 velocity+=facing*multiplier*speed*700*scale;
5535 velspeed=findLength(&velocity);
5536 if(velspeed>speed*25*scale){
5538 velspeed=speed*25*scale;
5541 velocity.y+=gravity*multiplier*20;
5542 ReflectVector(&velocity,terrain.getNormal(coords.x,coords.z));
5543 velspeed=findLength(&velocity);
5544 velocity=flatfacing*velspeed;
5547 if (animTarget == sneakanim || animTarget == walkanim) {
5548 velocity += facing * multiplier * speed * 700 * scale;
5549 velspeed = findLength(&velocity);
5550 if (velspeed > speed * 12 * scale) {
5551 velocity /= velspeed;
5552 velspeed = speed * 12 * scale;
5553 velocity *= velspeed;
5555 velocity.y += gravity * multiplier * 20;
5556 ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
5557 velspeed = findLength(&velocity);
5558 velocity = flatfacing * velspeed;
5561 if ((animTarget == fightidleanim || animTarget == knifefightidleanim) && (animCurrent == bounceidleanim || animCurrent == hurtidleanim)) {
5562 velocity += facing * multiplier * speed * 700 * scale;
5563 velspeed = findLength(&velocity);
5564 if (velspeed > speed * 2 * scale) {
5565 velocity /= velspeed;
5566 velspeed = speed * 2 * scale;
5567 velocity *= velspeed;
5569 velocity.y += gravity * multiplier * 20;
5570 ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
5571 velspeed = findLength(&velocity);
5572 velocity = flatfacing * velspeed;
5576 if ((animTarget == bounceidleanim || animCurrent == hurtidleanim) && (animCurrent == fightidleanim || animCurrent == knifefightidleanim)) {
5577 velocity -= facing * multiplier * speed * 700 * scale;
5578 velspeed = findLength(&velocity);
5579 if (velspeed > speed * 2 * scale) {
5580 velocity /= velspeed;
5581 velspeed = speed * 2 * scale;
5582 velocity *= velspeed;
5584 velocity.y += gravity * multiplier * 20;
5585 ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
5586 velspeed = findLength(&velocity);
5587 velocity = flatfacing * velspeed * -1;
5590 if (animTarget == fightsidestep) {
5591 velocity += DoRotation(facing * multiplier * speed * 700 * scale, 0, -90, 0);
5592 velspeed = findLength(&velocity);
5593 if (velspeed > speed * 12 * scale) {
5594 velocity /= velspeed;
5595 velspeed = speed * 12 * scale;
5596 velocity *= velspeed;
5598 velocity.y += gravity * multiplier * 20;
5599 ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
5600 velspeed = findLength(&velocity);
5601 velocity = DoRotation(flatfacing * velspeed, 0, -90, 0);
5604 if (animTarget == staggerbackhighanim) {
5605 coords -= facing * multiplier * speed * 16 * scale;
5608 if (animTarget == staggerbackhardanim && animation[staggerbackhardanim].label[frameTarget] != 6) {
5609 coords -= facing * multiplier * speed * 20 * scale;
5613 if (animTarget == backhandspringanim) {
5614 //coords-=facing*multiplier*50*scale;
5615 velocity += facing * multiplier * speed * 700 * scale * -1;
5616 velspeed = findLength(&velocity);
5617 if (velspeed > speed * 50 * scale) {
5618 velocity /= velspeed;
5619 velspeed = speed * 50 * scale;
5620 velocity *= velspeed;
5622 velocity.y += gravity * multiplier * 20;
5623 ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
5624 velspeed = findLength(&velocity);
5625 velocity = flatfacing * velspeed * -1;
5627 if (animTarget == dodgebackanim) {
5628 //coords-=facing*multiplier*50*scale;
5629 velocity += facing * multiplier * speed * 700 * scale * -1;
5630 velspeed = findLength(&velocity);
5631 if (velspeed > speed * 60 * scale) {
5632 velocity /= velspeed;
5633 velspeed = speed * 60 * scale;
5634 velocity *= velspeed;
5636 velocity.y += gravity * multiplier * 20;
5637 ReflectVector(&velocity, terrain.getNormal(coords.x, coords.z));
5638 velspeed = findLength(&velocity);
5639 velocity = flatfacing * velspeed * -1;
5642 if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) {
5643 velspeed = findLength(&velocity);
5647 if (animTarget == jumpupanim || animTarget == jumpdownanim || isFlip()) {
5648 velocity.y += gravity * multiplier;
5651 if (animTarget != climbanim && animTarget != hanganim && !isWallJump())
5652 coords += velocity * multiplier;
5654 if (coords.y < terrain.getHeight(coords.x, coords.z) && (animTarget == jumpdownanim || animTarget == jumpupanim || isFlip())) {
5655 if (isFlip() && animation[animTarget].label[frameTarget] == 7)
5658 if (animTarget == jumpupanim) {
5660 animTarget = getIdle();
5667 pause_sound(whooshsound);
5668 OPENAL_SetVolume(channels[whooshsound], 0);
5671 if (animTarget == jumpdownanim || isFlip()) {
5672 if (isFlip())jumppower = -4;
5673 animTarget = getLanding();
5674 emit_sound_at(landsound, coords, 128.);
5677 envsound[numenvsounds] = coords;
5678 envsoundvol[numenvsounds] = 16;
5679 envsoundlife[numenvsounds] = .4;
5685 if (animTarget != jumpupanim && animTarget != jumpdownanim && !isFlip() && animTarget != climbanim && animTarget != hanganim && !isWallJump())
5686 coords.y += gravity * multiplier * 2;
5687 if (animTarget != jumpupanim && animTarget != jumpdownanim && !isFlip() && coords.y < terrain.getHeight(coords.x, coords.z)) {
5688 coords.y = terrain.getHeight(coords.x, coords.z);
5693 if (isIdle() || animTarget == drawrightanim || animTarget == drawleftanim || animTarget == crouchdrawrightanim || animTarget == crouchstabanim || animTarget == swordgroundstabanim || isStop() || animTarget == removeknifeanim || animTarget == crouchremoveknifeanim || isLanding() || isCrouch() || animation[animTarget].attack || (animTarget == rollanim && animation[animTarget].label[frameTarget] == 6)) {
5694 velspeed = findLength(&velocity);
5696 if (velspeed < multiplier * 300 * scale) {
5699 velocity -= velocity / velspeed * multiplier * 300 * scale;
5700 if (velspeed > 5 && (isLanding() || isLandhard())) {
5701 skiddingdelay += multiplier;
5702 if (skiddelay <= 0) {
5712 velspeed = findLength(&velocity);
5714 if (velspeed < multiplier * 600 * scale) {
5717 velocity -= velocity / velspeed * multiplier * 600 * scale;
5719 if (velspeed > 5 && (isLanding() || isLandhard())) {
5720 skiddingdelay += multiplier;
5721 if (skiddelay <= 0) {
5730 if (skiddingdelay < 0)
5731 skiddingdelay += multiplier;
5732 if (skiddingdelay > .02 && !forwardkeydown && !backkeydown && !leftkeydown && !rightkeydown && !jumpkeydown && isLanding() && !landhard) {
5734 if (!onterrain || environment == grassyenvironment) {
5735 emit_sound_at(skidsound, coords, 128 * velspeed / 10);
5737 emit_sound_at(snowskidsound, coords, 128 * velspeed / 10);
5741 if (animation[animTarget].attack == normalattack && animTarget != rabbitkickanim && !victim->skeleton.free) {
5742 terrainnormal = victim->coords - coords;
5743 Normalise(&terrainnormal);
5744 targetyaw = -asin(0 - terrainnormal.x);
5745 targetyaw *= 360 / 6.28;
5746 if (terrainnormal.z < 0)
5747 targetyaw = 180 - targetyaw;
5748 targettilt2 = -asin(terrainnormal.y) * 360 / 6.28; //*-70;
5751 if (animation[animTarget].attack == reversal && animTarget != rabbittacklinganim) {
5752 targetyaw = victim->targetyaw;
5754 if (animTarget == rabbittacklinganim) {
5755 coords = victim->coords;
5758 skeleton.oldfree = skeleton.free;
5762 midterrain.x = terrain.size * terrain.scale / 2;
5763 midterrain.z = terrain.size * terrain.scale / 2;
5764 if (distsqflat(&coords, &midterrain) > (terrain.size * terrain.scale / 2 - viewdistance) * (terrain.size * terrain.scale / 2 - viewdistance)) {
5766 tempposit = coords - midterrain;
5768 Normalise(&tempposit);
5769 tempposit *= (terrain.size * terrain.scale / 2 - viewdistance);
5770 coords.x = tempposit.x + midterrain.x;
5771 coords.z = tempposit.z + midterrain.z;
5775 int Person::DrawSkeleton()
5777 int oldplayerdetail;
5778 if ((frustum.SphereInFrustum(coords.x, coords.y + scale * 3, coords.z, scale * 8) && distsq(&viewer, &coords) < viewdistance * viewdistance) || skeleton.free == 3) {
5779 if (onterrain && (isIdle() || isCrouch() || wasIdle() || wasCrouch()) && !skeleton.free) {
5789 glAlphaFunc(GL_GREATER, 0.0001);
5791 float terrainheight;
5795 if (!isnormal(tilt))
5797 if (!isnormal(tilt2))
5799 oldplayerdetail = playerdetail;
5801 if (distsq(&viewer, &coords) < viewdistance * viewdistance / 32 && detail == 2) {
5804 if (distsq(&viewer, &coords) < viewdistance * viewdistance / 128 && detail == 1) {
5807 if (distsq(&viewer, &coords) < viewdistance * viewdistance / 256 && (detail != 1 && detail != 2)) {
5812 if (playerdetail != oldplayerdetail) {
5814 normalsupdatedelay = 0;
5816 static float updatedelaychange;
5817 static float morphness;
5818 static float framemult;
5820 skeleton.FindForwards();
5821 if (howactive == typesittingwall) {
5822 skeleton.specialforward[1] = 0;
5823 skeleton.specialforward[1].z = 1;
5829 static int weaponattachmuscle;
5830 static int weaponrotatemuscle;
5831 static XYZ weaponpoint;
5832 static int start, endthing;
5833 if ((dead != 2 || skeleton.free != 2) && updatedelay <= 0) {
5834 if (!isSleeping() && !isSitting()) {
5835 if (onterrain && ((isIdle() || isCrouch() || isLanding() || isLandhard() || animTarget == drawrightanim || animTarget == drawleftanim || animTarget == crouchdrawrightanim) && (wasIdle() || wasCrouch() || wasLanding() || wasLandhard() || animCurrent == drawrightanim || animCurrent == drawleftanim || animCurrent == crouchdrawrightanim)) && !skeleton.free) {
5836 XYZ point, newpoint, change, change2;
5837 point = DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) * scale + coords;
5838 heightleft = terrain.getHeight(point.x, point.z) + .04;
5839 point.y = heightleft;
5840 change = skeleton.joints[skeleton.jointlabels[leftankle]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5841 change2 = skeleton.joints[skeleton.jointlabels[leftknee]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5842 skeleton.joints[skeleton.jointlabels[leftfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0);
5843 skeleton.joints[skeleton.jointlabels[leftankle]].position = skeleton.joints[skeleton.jointlabels[leftfoot]].position + change;
5844 skeleton.joints[skeleton.jointlabels[leftknee]].position = (skeleton.joints[skeleton.jointlabels[leftfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[leftknee]].position) / 2;
5846 point = DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0) * scale + coords;
5847 heightright = terrain.getHeight(point.x, point.z) + .04;
5848 point.y = heightright;
5849 change = skeleton.joints[skeleton.jointlabels[rightankle]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5850 change2 = skeleton.joints[skeleton.jointlabels[rightknee]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5851 skeleton.joints[skeleton.jointlabels[rightfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0);
5852 skeleton.joints[skeleton.jointlabels[rightankle]].position = skeleton.joints[skeleton.jointlabels[rightfoot]].position + change;
5853 skeleton.joints[skeleton.jointlabels[rightknee]].position = (skeleton.joints[skeleton.jointlabels[rightfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[rightknee]].position) / 2;
5854 skeleton.DoConstraints(&coords, &scale);
5856 if (creature == wolftype) {
5857 point = DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) * scale + coords;
5858 heightleft = terrain.getHeight(point.x, point.z) + .04;
5859 point.y = heightleft;
5860 change = skeleton.joints[skeleton.jointlabels[leftankle]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5861 change2 = skeleton.joints[skeleton.jointlabels[leftknee]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5862 skeleton.joints[skeleton.jointlabels[leftfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0);
5863 skeleton.joints[skeleton.jointlabels[leftankle]].position = skeleton.joints[skeleton.jointlabels[leftfoot]].position + change;
5864 skeleton.joints[skeleton.jointlabels[leftknee]].position = (skeleton.joints[skeleton.jointlabels[leftfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[leftknee]].position) / 2;
5866 point = DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0) * scale + coords;
5867 heightright = terrain.getHeight(point.x, point.z) + .04;
5868 point.y = heightright;
5869 change = skeleton.joints[skeleton.jointlabels[rightankle]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5870 change2 = skeleton.joints[skeleton.jointlabels[rightknee]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5871 skeleton.joints[skeleton.jointlabels[rightfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0);
5872 skeleton.joints[skeleton.jointlabels[rightankle]].position = skeleton.joints[skeleton.jointlabels[rightfoot]].position + change;
5873 skeleton.joints[skeleton.jointlabels[rightknee]].position = (skeleton.joints[skeleton.jointlabels[rightfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[rightknee]].position) / 2;
5874 skeleton.DoConstraints(&coords, &scale);
5877 if (onterrain && ((isIdle() || isCrouch() || isLanding() || isLandhard() || animTarget == drawrightanim || animTarget == drawleftanim || animTarget == crouchdrawrightanim) && !(wasIdle() || wasCrouch() || wasLanding() || wasLandhard() || animCurrent == drawrightanim || animCurrent == drawleftanim || animCurrent == crouchdrawrightanim)) && !skeleton.free) {
5878 XYZ point, newpoint, change, change2;
5879 point = DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) * scale + coords;
5880 heightleft = terrain.getHeight(point.x, point.z) + .04;
5881 point.y = heightleft;
5882 change = skeleton.joints[skeleton.jointlabels[leftankle]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5883 change2 = skeleton.joints[skeleton.jointlabels[leftknee]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5884 skeleton.joints[skeleton.jointlabels[leftfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0) * target + skeleton.joints[skeleton.jointlabels[leftfoot]].position * (1 - target);
5885 skeleton.joints[skeleton.jointlabels[leftankle]].position = skeleton.joints[skeleton.jointlabels[leftfoot]].position + change;
5886 skeleton.joints[skeleton.jointlabels[leftknee]].position = (skeleton.joints[skeleton.jointlabels[leftfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[leftknee]].position) / 2;
5888 point = DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0) * scale + coords;
5889 heightright = terrain.getHeight(point.x, point.z) + .04;
5890 point.y = heightright;
5891 change = skeleton.joints[skeleton.jointlabels[rightankle]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5892 change2 = skeleton.joints[skeleton.jointlabels[rightknee]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5893 skeleton.joints[skeleton.jointlabels[rightfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0) * target + skeleton.joints[skeleton.jointlabels[rightfoot]].position * (1 - target);
5894 skeleton.joints[skeleton.jointlabels[rightankle]].position = skeleton.joints[skeleton.jointlabels[rightfoot]].position + change;
5895 skeleton.joints[skeleton.jointlabels[rightknee]].position = (skeleton.joints[skeleton.jointlabels[rightfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[rightknee]].position) / 2;
5896 skeleton.DoConstraints(&coords, &scale);
5898 if (creature == wolftype) {
5899 point = DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) * scale + coords;
5900 heightleft = terrain.getHeight(point.x, point.z) + .04;
5901 point.y = heightleft;
5902 change = skeleton.joints[skeleton.jointlabels[leftankle]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5903 change2 = skeleton.joints[skeleton.jointlabels[leftknee]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5904 skeleton.joints[skeleton.jointlabels[leftfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0) * target + skeleton.joints[skeleton.jointlabels[leftfoot]].position * (1 - target);
5905 skeleton.joints[skeleton.jointlabels[leftankle]].position = skeleton.joints[skeleton.jointlabels[leftfoot]].position + change;
5906 skeleton.joints[skeleton.jointlabels[leftknee]].position = (skeleton.joints[skeleton.jointlabels[leftfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[leftknee]].position) / 2;
5908 point = DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0) * scale + coords;
5909 heightright = terrain.getHeight(point.x, point.z) + .04;
5910 point.y = heightright;
5911 change = skeleton.joints[skeleton.jointlabels[rightankle]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5912 change2 = skeleton.joints[skeleton.jointlabels[rightknee]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5913 skeleton.joints[skeleton.jointlabels[rightfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0) * target + skeleton.joints[skeleton.jointlabels[rightfoot]].position * (1 - target);
5914 skeleton.joints[skeleton.jointlabels[rightankle]].position = skeleton.joints[skeleton.jointlabels[rightfoot]].position + change;
5915 skeleton.joints[skeleton.jointlabels[rightknee]].position = (skeleton.joints[skeleton.jointlabels[rightfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[rightknee]].position) / 2;
5916 skeleton.DoConstraints(&coords, &scale);
5920 if (onterrain && (!(isIdle() || isCrouch() || isLanding() || isLandhard() || animTarget == drawrightanim || animTarget == drawleftanim || animTarget == crouchdrawrightanim) && (wasIdle() || wasCrouch() || wasLanding() || wasLandhard() || animCurrent == drawrightanim || animCurrent == drawleftanim || animCurrent == crouchdrawrightanim)) && !skeleton.free) {
5921 XYZ point, newpoint, change, change2;
5922 point = DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) * scale + coords;
5923 heightleft = terrain.getHeight(point.x, point.z) + .04;
5924 point.y = heightleft;
5925 change = skeleton.joints[skeleton.jointlabels[leftankle]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5926 change2 = skeleton.joints[skeleton.jointlabels[leftknee]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5927 skeleton.joints[skeleton.jointlabels[leftfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0) * (1 - target) + skeleton.joints[skeleton.jointlabels[leftfoot]].position * target;
5928 skeleton.joints[skeleton.jointlabels[leftankle]].position = skeleton.joints[skeleton.jointlabels[leftfoot]].position + change;
5929 skeleton.joints[skeleton.jointlabels[leftknee]].position = (skeleton.joints[skeleton.jointlabels[leftfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[leftknee]].position) / 2;
5931 point = DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0) * scale + coords;
5932 heightright = terrain.getHeight(point.x, point.z) + .04;
5933 point.y = heightright;
5934 change = skeleton.joints[skeleton.jointlabels[rightankle]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5935 change2 = skeleton.joints[skeleton.jointlabels[rightknee]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5936 skeleton.joints[skeleton.jointlabels[rightfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0) * (1 - target) + skeleton.joints[skeleton.jointlabels[rightfoot]].position * target;
5937 skeleton.joints[skeleton.jointlabels[rightankle]].position = skeleton.joints[skeleton.jointlabels[rightfoot]].position + change;
5938 skeleton.joints[skeleton.jointlabels[rightknee]].position = (skeleton.joints[skeleton.jointlabels[rightfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[rightknee]].position) / 2;
5939 skeleton.DoConstraints(&coords, &scale);
5941 if (creature == wolftype) {
5942 point = DoRotation(skeleton.joints[skeleton.jointlabels[leftfoot]].position, 0, yaw, 0) * scale + coords;
5943 heightleft = terrain.getHeight(point.x, point.z) + .04;
5944 point.y = heightleft;
5945 change = skeleton.joints[skeleton.jointlabels[leftankle]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5946 change2 = skeleton.joints[skeleton.jointlabels[leftknee]].position - skeleton.joints[skeleton.jointlabels[leftfoot]].position;
5947 skeleton.joints[skeleton.jointlabels[leftfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0) * (1 - target) + skeleton.joints[skeleton.jointlabels[leftfoot]].position * target;
5948 skeleton.joints[skeleton.jointlabels[leftankle]].position = skeleton.joints[skeleton.jointlabels[leftfoot]].position + change;
5949 skeleton.joints[skeleton.jointlabels[leftknee]].position = (skeleton.joints[skeleton.jointlabels[leftfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[leftknee]].position) / 2;
5951 point = DoRotation(skeleton.joints[skeleton.jointlabels[rightfoot]].position, 0, yaw, 0) * scale + coords;
5952 heightright = terrain.getHeight(point.x, point.z) + .04;
5953 point.y = heightright;
5954 change = skeleton.joints[skeleton.jointlabels[rightankle]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5955 change2 = skeleton.joints[skeleton.jointlabels[rightknee]].position - skeleton.joints[skeleton.jointlabels[rightfoot]].position;
5956 skeleton.joints[skeleton.jointlabels[rightfoot]].position = DoRotation((point - coords) / scale, 0, -yaw, 0) * (1 - target) + skeleton.joints[skeleton.jointlabels[rightfoot]].position * target;
5957 skeleton.joints[skeleton.jointlabels[rightankle]].position = skeleton.joints[skeleton.jointlabels[rightfoot]].position + change;
5958 skeleton.joints[skeleton.jointlabels[rightknee]].position = (skeleton.joints[skeleton.jointlabels[rightfoot]].position + change2) / 2 + (skeleton.joints[skeleton.jointlabels[rightknee]].position) / 2;
5959 skeleton.DoConstraints(&coords, &scale);
5963 if (!skeleton.free && (!animation[animTarget].attack && animTarget != getupfrombackanim && ((animTarget != rollanim && !isFlip()) || animation[animTarget].label[frameTarget] == 6) && animTarget != getupfromfrontanim && animTarget != wolfrunninganim && animTarget != rabbitrunninganim && animTarget != backhandspringanim && animTarget != walljumpfrontanim && animTarget != hurtidleanim && !isLandhard() && !isSleeping()))
5966 targetheadyaw = -targetyaw;
5967 targetheadpitch = 0;
5968 if (animation[animTarget].attack == 3)
5969 targetheadyaw += 180;
5971 for (i = 0; i < skeleton.drawmodel.vertexNum; i++) {
5972 skeleton.drawmodel.vertex[i] = 0;
5973 skeleton.drawmodel.vertex[i].y = 999;
5975 for (i = 0; i < skeleton.drawmodellow.vertexNum; i++) {
5976 skeleton.drawmodellow.vertex[i] = 0;
5977 skeleton.drawmodellow.vertex[i].y = 999;
5979 for (i = 0; i < skeleton.drawmodelclothes.vertexNum; i++) {
5980 skeleton.drawmodelclothes.vertex[i] = 0;
5981 skeleton.drawmodelclothes.vertex[i].y = 999;
5983 for (i = 0; i < skeleton.num_muscles; i++) {
5984 if ((skeleton.muscles[i].numvertices > 0 && playerdetail) || (skeleton.muscles[i].numverticeslow > 0 && !playerdetail)) {
5988 if (skeleton.muscles[i].parent1->label == righthand || skeleton.muscles[i].parent2->label == righthand) {
5989 morphness = righthandmorphness;
5990 start = righthandmorphstart;
5991 endthing = righthandmorphend;
5993 if (skeleton.muscles[i].parent1->label == lefthand || skeleton.muscles[i].parent2->label == lefthand) {
5994 morphness = lefthandmorphness;
5995 start = lefthandmorphstart;
5996 endthing = lefthandmorphend;
5998 if (skeleton.muscles[i].parent1->label == head || skeleton.muscles[i].parent2->label == head) {
5999 morphness = headmorphness;
6000 start = headmorphstart;
6001 endthing = headmorphend;
6003 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)) {
6004 morphness = chestmorphness;
6005 start = chestmorphstart;
6006 endthing = chestmorphend;
6008 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)) {
6009 morphness = tailmorphness;
6010 start = tailmorphstart;
6011 endthing = tailmorphend;
6014 skeleton.FindRotationMuscle(i, animTarget);
6015 mid = (skeleton.muscles[i].parent1->position + skeleton.muscles[i].parent2->position) / 2;
6016 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6020 glRotatef(tilt2, 1, 0, 0);
6022 glRotatef(tilt, 0, 0, 1);
6025 glTranslatef(mid.x, mid.y, mid.z);
6027 skeleton.muscles[i].lastrotate1 = skeleton.muscles[i].rotate1;
6028 glRotatef(-skeleton.muscles[i].lastrotate1 + 90, 0, 1, 0);
6030 skeleton.muscles[i].lastrotate2 = skeleton.muscles[i].rotate2;
6031 glRotatef(-skeleton.muscles[i].lastrotate2 + 90, 0, 0, 1);
6033 skeleton.muscles[i].lastrotate3 = skeleton.muscles[i].rotate3;
6034 glRotatef(-skeleton.muscles[i].lastrotate3, 0, 1, 0);
6036 if (playerdetail || skeleton.free == 3) {
6037 for (j = 0; j < skeleton.muscles[i].numvertices; j++) {
6038 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6040 if (skeleton.muscles[i].parent1->label == abdomen || skeleton.muscles[i].parent2->label == abdomen)
6041 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,
6042 (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,
6043 (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);
6044 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)
6045 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,
6046 (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,
6047 (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);
6048 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)
6049 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,
6050 (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,
6051 (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);
6052 if (skeleton.muscles[i].parent1->label == head || skeleton.muscles[i].parent2->label == head)
6053 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,
6054 (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,
6055 (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);
6056 glGetFloatv(GL_MODELVIEW_MATRIX, M);
6057 //if(!isnormal(M[12])||!isnormal(M[13])||!isnormal(M[14]))test=0;
6058 //if(!isnormal(scale))test=1;
6059 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].x = M[12] * scale;
6060 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].y = M[13] * scale;
6061 skeleton.drawmodel.vertex[skeleton.muscles[i].vertices[j]].z = M[14] * scale;
6066 if (!playerdetail || skeleton.free == 3) {
6067 for (j = 0; j < skeleton.muscles[i].numverticeslow; j++) {
6068 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6070 if (skeleton.muscles[i].parent1->label == abdomen || skeleton.muscles[i].parent2->label == abdomen)
6071 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionbody.x,
6072 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionbody.y,
6073 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionbody.z);
6074 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)
6075 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionarms.x,
6076 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionarms.y,
6077 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionarms.z);
6078 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)
6079 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionlegs.x,
6080 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionlegs.y,
6081 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionlegs.z);
6082 if (skeleton.muscles[i].parent1->label == head || skeleton.muscles[i].parent2->label == head)
6083 glTranslatef((skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].x)*proportionhead.x,
6084 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].y)*proportionhead.y,
6085 (skeleton.modellow.vertex[skeleton.muscles[i].verticeslow[j]].z)*proportionhead.z);
6087 glGetFloatv(GL_MODELVIEW_MATRIX, M);
6088 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].x = M[12] * scale;
6089 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].y = M[13] * scale;
6090 skeleton.drawmodellow.vertex[skeleton.muscles[i].verticeslow[j]].z = M[14] * scale;
6096 if (skeleton.clothes && skeleton.muscles[i].numverticesclothes > 0) {
6097 mid = (skeleton.muscles[i].parent1->position + skeleton.muscles[i].parent2->position) / 2;
6099 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6103 glRotatef(tilt2, 1, 0, 0);
6105 glRotatef(tilt, 0, 0, 1);
6106 glTranslatef(mid.x, mid.y, mid.z);
6107 skeleton.muscles[i].lastrotate1 = skeleton.muscles[i].rotate1;
6108 glRotatef(-skeleton.muscles[i].lastrotate1 + 90, 0, 1, 0);
6110 skeleton.muscles[i].lastrotate2 = skeleton.muscles[i].rotate2;
6111 glRotatef(-skeleton.muscles[i].lastrotate2 + 90, 0, 0, 1);
6113 skeleton.muscles[i].lastrotate3 = skeleton.muscles[i].rotate3;
6114 glRotatef(-skeleton.muscles[i].lastrotate3, 0, 1, 0);
6116 for (j = 0; j < skeleton.muscles[i].numverticesclothes; j++) {
6117 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6119 if (skeleton.muscles[i].parent1->label == abdomen || skeleton.muscles[i].parent2->label == abdomen)
6120 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionbody.x,
6121 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionbody.y,
6122 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionbody.z);
6123 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)
6124 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionarms.x,
6125 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionarms.y,
6126 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionarms.z);
6127 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)
6128 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionlegs.x,
6129 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionlegs.y,
6130 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionlegs.z);
6131 if (skeleton.muscles[i].parent1->label == head || skeleton.muscles[i].parent2->label == head)
6132 glTranslatef((skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x)*proportionhead.x,
6133 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y)*proportionhead.y,
6134 (skeleton.modelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z)*proportionhead.z);
6135 glGetFloatv(GL_MODELVIEW_MATRIX, M);
6136 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].x = M[12] * scale;
6137 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].y = M[13] * scale;
6138 skeleton.drawmodelclothes.vertex[skeleton.muscles[i].verticesclothes[j]].z = M[14] * scale;
6143 updatedelay = 1 + (float)(Random() % 100) / 1000;
6145 if (skeleton.free != 2 && (skeleton.free == 1 || skeleton.free == 3 || id == 0 || (normalsupdatedelay <= 0) || animTarget == getupfromfrontanim || animTarget == getupfrombackanim || animCurrent == getupfromfrontanim || animCurrent == getupfrombackanim)) {
6146 normalsupdatedelay = 1;
6147 if (playerdetail || skeleton.free == 3)
6148 skeleton.drawmodel.CalculateNormals(0);
6149 if (!playerdetail || skeleton.free == 3)
6150 skeleton.drawmodellow.CalculateNormals(0);
6151 if (skeleton.clothes)
6152 skeleton.drawmodelclothes.CalculateNormals(0);
6154 if (playerdetail || skeleton.free == 3)
6155 skeleton.drawmodel.UpdateVertexArrayNoTexNoNorm();
6156 if (!playerdetail || skeleton.free == 3)
6157 skeleton.drawmodellow.UpdateVertexArrayNoTexNoNorm();
6158 if (skeleton.clothes) {
6159 skeleton.drawmodelclothes.UpdateVertexArrayNoTexNoNorm();
6164 updatedelaychange = -framemult * 4 * (45 - findDistance(&viewer, &coords) * 1);
6165 if (updatedelaychange > -realmultiplier * 30)
6166 updatedelaychange = -realmultiplier * 30;
6167 if (updatedelaychange > -framemult * 4)
6168 updatedelaychange = -framemult * 4;
6169 if (skeleton.free == 1)
6170 updatedelaychange *= 6;
6172 updatedelaychange *= 8;
6173 updatedelay += updatedelaychange;
6175 glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
6178 glTranslatef(coords.x, coords.y - .02, coords.z);
6180 glTranslatef(coords.x, coords.y - .02, coords.z);
6182 glTranslatef(offset.x * scale, offset.y * scale, offset.z * scale);
6184 glRotatef(yaw, 0, 1, 0);
6187 glColor4f(.4, 1, .4, 1);
6188 glDisable(GL_LIGHTING);
6189 glDisable(GL_TEXTURE_2D);
6192 for (i = 0; i < skeleton.drawmodel.vertexNum; i++) {
6193 glVertex3f(skeleton.drawmodel.vertex[i].x, skeleton.drawmodel.vertex[i].y, skeleton.drawmodel.vertex[i].z);
6199 for (i = 0; i < skeleton.drawmodel.TriangleNum; i++) {
6200 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);
6201 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);
6202 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);
6203 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);
6204 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);
6205 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);
6211 terrainlight = terrain.getLighting(coords.x, coords.z);
6212 distance = distsq(&viewer, &coords);
6213 distance = (viewdistance * viewdistance - (distance - (viewdistance * viewdistance * fadestart)) * (1 / (1 - fadestart))) / viewdistance / viewdistance;
6217 terrainheight = (coords.y - terrain.getHeight(coords.x, coords.z)) / 3 + 1;
6218 if (terrainheight < 1)
6220 if (terrainheight > 1.7)
6221 terrainheight = 1.7;
6224 glColor4f((1 - (1 - terrainlight.x) / terrainheight) - burnt, (1 - (1 - terrainlight.y) / terrainheight) - burnt, (1 - (1 - terrainlight.z) / terrainheight) - burnt, distance);
6225 glDisable(GL_BLEND);
6226 glAlphaFunc(GL_GREATER, 0.0001);
6227 glEnable(GL_TEXTURE_2D);
6229 glDisable(GL_TEXTURE_2D);
6230 glColor4f(.7, .35, 0, .5);
6232 glEnable(GL_LIGHTING);
6235 if (tutoriallevel && id != 0) {
6236 //glDisable(GL_TEXTURE_2D);
6237 glColor4f(.7, .7, .7, 0.6);
6239 glEnable(GL_LIGHTING);
6241 if (canattack && cananger)
6242 if (animation[animTarget].attack == normalattack || animation[animTarget].attack == reversed) {
6243 glDisable(GL_TEXTURE_2D);
6244 glColor4f(1, 0, 0, 0.8);
6246 glMatrixMode(GL_TEXTURE);
6248 glTranslatef(0, -smoketex, 0);
6249 glTranslatef(-smoketex, 0, 0);
6253 if ((tutoriallevel && id != 0))
6254 skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
6256 skeleton.drawmodel.draw();
6259 if (!playerdetail) {
6260 if ((tutoriallevel && id != 0))
6261 skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
6263 skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
6266 if (!(animation[animTarget].attack == normalattack || animation[animTarget].attack == reversed))
6267 if (tutoriallevel && id != 0) {
6269 glMatrixMode(GL_MODELVIEW);
6270 glEnable(GL_TEXTURE_2D);
6271 glColor4f(.7, .7, .7, 0.6);
6273 glEnable(GL_LIGHTING);
6275 if (canattack && cananger)
6276 if (animation[animTarget].attack == normalattack || animation[animTarget].attack == reversed) {
6277 glDisable(GL_TEXTURE_2D);
6278 glColor4f(1, 0, 0, 0.8);
6280 glMatrixMode(GL_TEXTURE);
6282 glTranslatef(0, -smoketex * .6, 0);
6283 glTranslatef(smoketex * .6, 0, 0);
6286 if ((tutoriallevel && id != 0))
6287 skeleton.drawmodel.drawdifftex(Sprite::cloudimpacttexture);
6289 skeleton.drawmodel.draw();
6292 if (!playerdetail) {
6293 if ((tutoriallevel && id != 0))
6294 skeleton.drawmodellow.drawdifftex(Sprite::cloudimpacttexture);
6296 skeleton.drawmodellow.drawdifftex(skeleton.drawmodel.textureptr);
6301 if (tutoriallevel && id != 0) {
6303 glMatrixMode(GL_MODELVIEW);
6304 glEnable(GL_TEXTURE_2D);
6306 if (skeleton.clothes) {
6310 skeleton.drawmodelclothes.draw();
6312 skeleton.drawmodelclothes.drawimmediate();
6318 if (num_weapons > 0) {
6319 for (k = 0; k < num_weapons; k++) {
6321 if (weaponactive == k) {
6322 if (weapons[i].getType() != staff) {
6323 for (j = 0; j < skeleton.num_muscles; j++) {
6324 if ((skeleton.muscles[j].parent1->label == righthand || skeleton.muscles[j].parent2->label == righthand) && skeleton.muscles[j].numvertices > 0) {
6325 weaponattachmuscle = j;
6328 for (j = 0; j < skeleton.num_muscles; j++) {
6329 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) {
6330 weaponrotatemuscle = j;
6333 weaponpoint = (skeleton.muscles[weaponattachmuscle].parent1->position + skeleton.muscles[weaponattachmuscle].parent2->position) / 2;
6334 if (creature == wolftype)
6335 weaponpoint = (skeleton.joints[skeleton.jointlabels[rightwrist]].position * .7 + skeleton.joints[skeleton.jointlabels[righthand]].position * .3);
6337 if (weapons[i].getType() == staff) {
6338 for (j = 0; j < skeleton.num_muscles; j++) {
6339 if ((skeleton.muscles[j].parent1->label == righthand || skeleton.muscles[j].parent2->label == righthand) && skeleton.muscles[j].numvertices > 0) {
6340 weaponattachmuscle = j;
6343 for (j = 0; j < skeleton.num_muscles; j++) {
6344 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) {
6345 weaponrotatemuscle = j;
6348 //weaponpoint=skeleton.joints[skeleton.jointlabels[rightwrist]].position;
6349 weaponpoint = (skeleton.muscles[weaponattachmuscle].parent1->position + skeleton.muscles[weaponattachmuscle].parent2->position) / 2;
6350 //weaponpoint+=skeleton.specialforward[1]*.1+(skeleton.joints[skeleton.jointlabels[rightwrist]].position-skeleton.joints[skeleton.jointlabels[rightelbow]].position);
6351 XYZ tempnormthing, vec1, vec2;
6352 vec1 = (skeleton.joints[skeleton.jointlabels[rightwrist]].position - skeleton.joints[skeleton.jointlabels[rightelbow]].position);
6353 vec2 = (skeleton.joints[skeleton.jointlabels[rightwrist]].position - skeleton.joints[skeleton.jointlabels[rightshoulder]].position);
6354 CrossProduct(&vec1, &vec2, &tempnormthing);
6355 Normalise(&tempnormthing);
6356 if (animTarget != staffhitanim && animCurrent != staffhitanim && animTarget != staffgroundsmashanim && animCurrent != staffgroundsmashanim && animTarget != staffspinhitanim && animCurrent != staffspinhitanim)
6357 weaponpoint += tempnormthing * .1 - skeleton.specialforward[1] * .3 + (skeleton.joints[skeleton.jointlabels[rightwrist]].position - skeleton.joints[skeleton.jointlabels[rightelbow]].position);
6360 if (weaponactive != k && weaponstuck != k) {
6361 if (weapons[i].getType() == knife)
6362 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;
6363 if (weapons[i].getType() == sword)
6364 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;
6365 if (weapons[i].getType() == staff)
6366 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;
6367 for (j = 0; j < skeleton.num_muscles; j++) {
6368 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) {
6369 weaponrotatemuscle = j;
6373 if (weaponstuck == k) {
6374 if (weaponstuckwhere == 0)
6375 weaponpoint = skeleton.joints[skeleton.jointlabels[abdomen]].position * .5 + skeleton.joints[skeleton.jointlabels[neck]].position * .5 - skeleton.forward * .8;
6377 weaponpoint = skeleton.joints[skeleton.jointlabels[abdomen]].position * .5 + skeleton.joints[skeleton.jointlabels[neck]].position * .5 + skeleton.forward * .8;
6378 for (j = 0; j < skeleton.num_muscles; j++) {
6379 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) {
6380 weaponrotatemuscle = j;
6384 if (skeleton.free) {
6385 weapons[i].position = weaponpoint * scale + coords;
6386 weapons[i].bigrotation = 0;
6387 weapons[i].bigtilt = 0;
6388 weapons[i].bigtilt2 = 0;
6390 weapons[i].position = DoRotation(DoRotation(DoRotation(weaponpoint, 0, 0, tilt), tilt2, 0, 0), 0, yaw, 0) * scale + coords + currentoffset * (1 - target) * scale + targetoffset * target * scale;
6391 weapons[i].bigrotation = yaw;
6392 weapons[i].bigtilt = tilt;
6393 weapons[i].bigtilt2 = tilt2;
6395 weapons[i].rotation1 = skeleton.muscles[weaponrotatemuscle].lastrotate1;
6396 weapons[i].rotation2 = skeleton.muscles[weaponrotatemuscle].lastrotate2;
6397 weapons[i].rotation3 = skeleton.muscles[weaponrotatemuscle].lastrotate3;
6398 if (weaponactive == k) {
6399 if (weapons[i].getType() == knife) {
6400 weapons[i].smallrotation = 180;
6401 weapons[i].smallrotation2 = 0;
6402 if (isCrouch() || wasCrouch()) {
6403 weapons[i].smallrotation2 = 20;
6405 if (animTarget == hurtidleanim) {
6406 weapons[i].smallrotation2 = 50;
6408 if ((animCurrent == crouchstabanim && animTarget == crouchstabanim) || (animCurrent == backhandspringanim && animTarget == backhandspringanim)) {
6409 XYZ temppoint1, temppoint2, tempforward;
6412 temppoint1 = skeleton.joints[skeleton.jointlabels[righthand]].position;
6413 temppoint2 = animation[animCurrent].weapontarget[frameCurrent] * (1 - target) + animation[animTarget].weapontarget[frameTarget] * (target);
6414 distance = findDistance(&temppoint1, &temppoint2);
6415 weapons[i].rotation2 = asin((temppoint1.y - temppoint2.y) / distance);
6416 weapons[i].rotation2 *= 360 / 6.28;
6419 weapons[i].rotation1 = acos((temppoint1.z - temppoint2.z) / findDistance(&temppoint1, &temppoint2));
6420 weapons[i].rotation1 *= 360 / 6.28;
6421 weapons[i].rotation3 = 0;
6422 weapons[i].smallrotation = -90;
6423 weapons[i].smallrotation2 = 0;
6424 if (temppoint1.x > temppoint2.x)
6425 weapons[i].rotation1 = 360 - weapons[i].rotation1;
6427 if ((animCurrent == knifeslashreversalanim && animTarget == knifeslashreversalanim) || (animCurrent == knifeslashreversedanim && animTarget == knifeslashreversedanim)) {
6428 XYZ temppoint1, temppoint2, tempforward;
6431 temppoint1 = skeleton.joints[skeleton.jointlabels[righthand]].position;
6432 temppoint2 = animation[animCurrent].weapontarget[frameCurrent] * (1 - target) + animation[animTarget].weapontarget[frameTarget] * (target);
6433 distance = findDistance(&temppoint1, &temppoint2);
6434 weapons[i].rotation2 = asin((temppoint1.y - temppoint2.y) / distance);
6435 weapons[i].rotation2 *= 360 / 6.28;
6438 weapons[i].rotation1 = acos((temppoint1.z - temppoint2.z) / findDistance(&temppoint1, &temppoint2));
6439 weapons[i].rotation1 *= 360 / 6.28;
6440 weapons[i].rotation3 = 0;
6441 weapons[i].smallrotation = 90;
6442 weapons[i].smallrotation2 = 0;
6443 if (temppoint1.x > temppoint2.x)
6444 weapons[i].rotation1 = 360 - weapons[i].rotation1;
6446 if (animTarget == knifethrowanim) {
6447 weapons[i].smallrotation = 90;
6448 //weapons[i].smallrotation2=-90;
6449 weapons[i].smallrotation2 = 0;
6450 weapons[i].rotation1 = 0;
6451 weapons[i].rotation2 = 0;
6452 weapons[i].rotation3 = 0;
6454 if (animTarget == knifesneakattackanim && frameTarget < 5) {
6455 weapons[i].smallrotation = -90;
6456 weapons[i].rotation1 = 0;
6457 weapons[i].rotation2 = 0;
6458 weapons[i].rotation3 = 0;
6461 if (weapons[i].getType() == sword) {
6462 weapons[i].smallrotation = 0;
6463 weapons[i].smallrotation2 = 0;
6464 if (animTarget == knifethrowanim) {
6465 weapons[i].smallrotation = -90;
6466 weapons[i].smallrotation2 = 0;
6467 weapons[i].rotation1 = 0;
6468 weapons[i].rotation2 = 0;
6469 weapons[i].rotation3 = 0;
6471 if ((animTarget == swordgroundstabanim && animCurrent == swordgroundstabanim) || (animTarget == swordsneakattackanim && animCurrent == swordsneakattackanim) || (animTarget == swordslashparryanim && animCurrent == swordslashparryanim) || (animTarget == swordslashparriedanim && animCurrent == swordslashparriedanim) || (animTarget == swordslashreversalanim && animCurrent == swordslashreversalanim) || (animTarget == swordslashreversedanim && animCurrent == swordslashreversedanim) || (animTarget == knifeslashreversalanim && animCurrent == knifeslashreversalanim) || (animTarget == knifeslashreversedanim && animCurrent == knifeslashreversedanim) || (animTarget == swordslashanim && animCurrent == swordslashanim) || (animTarget == drawleftanim && animCurrent == drawleftanim) || (animCurrent == backhandspringanim && animTarget == backhandspringanim)) {
6472 XYZ temppoint1, temppoint2, tempforward;
6475 temppoint1 = animation[animCurrent].position[skeleton.jointlabels[righthand]][frameCurrent] * (1 - target) + animation[animTarget].position[skeleton.jointlabels[righthand]][frameTarget] * (target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
6476 temppoint2 = animation[animCurrent].weapontarget[frameCurrent] * (1 - target) + animation[animTarget].weapontarget[frameTarget] * (target);
6477 distance = findDistance(&temppoint1, &temppoint2);
6478 weapons[i].rotation2 = asin((temppoint1.y - temppoint2.y) / distance);
6479 weapons[i].rotation2 *= 360 / 6.28;
6482 weapons[i].rotation1 = acos((temppoint1.z - temppoint2.z) / findDistance(&temppoint1, &temppoint2));
6483 weapons[i].rotation1 *= 360 / 6.28;
6484 weapons[i].rotation3 = 0;
6485 weapons[i].smallrotation = 90;
6486 weapons[i].smallrotation2 = 0;
6487 if (temppoint1.x > temppoint2.x)
6488 weapons[i].rotation1 = 360 - weapons[i].rotation1;
6491 if (weapons[i].getType() == staff) {
6492 weapons[i].smallrotation = 100;
6493 weapons[i].smallrotation2 = 0;
6494 if ((animTarget == staffhitanim && animCurrent == staffhitanim) || (animTarget == staffhitreversedanim && animCurrent == staffhitreversedanim) || (animTarget == staffspinhitreversedanim && animCurrent == staffspinhitreversedanim) || (animTarget == staffgroundsmashanim && animCurrent == staffgroundsmashanim) || (animTarget == staffspinhitanim && animCurrent == staffspinhitanim)) {
6495 XYZ temppoint1, temppoint2, tempforward;
6498 temppoint1 = animation[animCurrent].position[skeleton.jointlabels[righthand]][frameCurrent] * (1 - target) + animation[animTarget].position[skeleton.jointlabels[righthand]][frameTarget] * (target); //skeleton.joints[skeleton.jointlabels[righthand]].position;
6499 temppoint2 = animation[animCurrent].weapontarget[frameCurrent] * (1 - target) + animation[animTarget].weapontarget[frameTarget] * (target);
6500 distance = findDistance(&temppoint1, &temppoint2);
6501 weapons[i].rotation2 = asin((temppoint1.y - temppoint2.y) / distance);
6502 weapons[i].rotation2 *= 360 / 6.28;
6505 weapons[i].rotation1 = acos((temppoint1.z - temppoint2.z) / findDistance(&temppoint1, &temppoint2));
6506 weapons[i].rotation1 *= 360 / 6.28;
6507 weapons[i].rotation3 = 0;
6508 weapons[i].smallrotation = 90;
6509 weapons[i].smallrotation2 = 0;
6510 if (temppoint1.x > temppoint2.x)
6511 weapons[i].rotation1 = 360 - weapons[i].rotation1;
6515 if (weaponactive != k && weaponstuck != k) {
6516 if (weapons[i].getType() == knife) {
6517 weapons[i].smallrotation = -70;
6518 weapons[i].smallrotation2 = 10;
6520 if (weapons[i].getType() == sword) {
6521 weapons[i].smallrotation = -100;
6522 weapons[i].smallrotation2 = -8;
6524 if (weapons[i].getType() == staff) {
6525 weapons[i].smallrotation = -100;
6526 weapons[i].smallrotation2 = -8;
6529 if (weaponstuck == k) {
6530 if (weaponstuckwhere == 0)
6531 weapons[i].smallrotation = 180;
6533 weapons[i].smallrotation = 0;
6534 weapons[i].smallrotation2 = 10;
6543 if (animation[animTarget].attack || isRun() || animTarget == staggerbackhardanim || isFlip() || animTarget == climbanim || animTarget == sneakanim || animTarget == rollanim || animTarget == walkanim || animTarget == backhandspringanim || isFlip() || isWallJump())
6545 if (animCurrent != animTarget)
6547 //if(id==0)calcrot=1;
6548 if (skeleton.free == 2)
6555 int Person::SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model)
6558 static float distance;
6559 static float olddistance;
6560 static int intersecting;
6561 static int firstintersecting;
6564 static XYZ start, end;
6565 static float slopethreshold = -.4;
6567 firstintersecting = -1;
6571 if (distsq(p1, &model->boundingspherecenter) > radius * radius + model->boundingsphereradius * model->boundingsphereradius)
6574 *p1 = DoRotation(*p1, 0, -*rotate, 0);
6575 for (i = 0; i < 4; i++) {
6576 for (j = 0; j < model->TriangleNum; j++) {
6577 if (model->facenormals[j].y <= slopethreshold) {
6579 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)));
6580 if (distance < radius) {
6581 point = *p1 - model->facenormals[j] * distance;
6582 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]]))
6585 intersecting = sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
6586 &model->vertex[model->Triangles[j].vertex[1]],
6589 intersecting = sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[1]],
6590 &model->vertex[model->Triangles[j].vertex[2]],
6593 intersecting = sphere_line_intersection(&model->vertex[model->Triangles[j].vertex[0]],
6594 &model->vertex[model->Triangles[j].vertex[2]],
6597 if (dotproduct(&model->facenormals[j], &end) > 0 && intersecting) {
6601 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)) {
6602 p1->y = point.y + radius;
6603 if ((animTarget == jumpdownanim || isFlip())) {
6604 if (isFlip() && (frameTarget < 5 || animation[animTarget].label[frameTarget] == 7 || animation[animTarget].label[frameTarget] == 4))
6607 if (animTarget == jumpupanim) {
6609 animTarget = getIdle();
6616 pause_sound(whooshsound);
6617 OPENAL_SetVolume(channels[whooshsound], 0);
6620 if ((animTarget == jumpdownanim || isFlip()) && !wasLanding() && !wasLandhard()) {
6623 animTarget = getLanding();
6624 emit_sound_at(landsound, coords, 128.);
6627 envsound[numenvsounds] = coords;
6628 envsoundvol[numenvsounds] = 16;
6629 envsoundlife[numenvsounds] = .4;
6637 if ((distance < olddistance || firstintersecting == -1) && intersecting) {
6638 olddistance = distance;
6639 firstintersecting = j;
6644 for (j = 0; j < model->TriangleNum; j++) {
6645 if (model->facenormals[j].y > slopethreshold) {
6648 start.y -= radius / 4;
6649 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)));
6650 if (distance < radius * .5) {
6651 point = start - model->facenormals[j] * distance;
6652 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]]))
6655 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,
6656 model->vertex[model->Triangles[j].vertex[1]].x, model->vertex[model->Triangles[j].vertex[1]].y, model->vertex[model->Triangles[j].vertex[1]].z,
6657 p1->x, p1->y, p1->z, radius / 2);
6659 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,
6660 model->vertex[model->Triangles[j].vertex[2]].x, model->vertex[model->Triangles[j].vertex[2]].y, model->vertex[model->Triangles[j].vertex[2]].z,
6661 p1->x, p1->y, p1->z, radius / 2);
6663 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,
6664 model->vertex[model->Triangles[j].vertex[2]].x, model->vertex[model->Triangles[j].vertex[2]].y, model->vertex[model->Triangles[j].vertex[2]].z,
6665 p1->x, p1->y, p1->z, radius / 2);
6667 if (dotproduct(&model->facenormals[j], &end) > 0 && intersecting) {
6668 if ((animTarget == jumpdownanim || animTarget == jumpupanim || isFlip())) {
6670 velocity -= DoRotation(model->facenormals[j], 0, *rotate, 0) * findLength(&velocity) * abs(normaldotproduct(velocity, DoRotation(model->facenormals[j], 0, *rotate, 0))); //(distance-radius*.5)/multiplier;
6671 if (findLengthfast(&start) < findLengthfast(&velocity))
6674 *p1 += model->facenormals[j] * (distance - radius * .5);
6677 if ((distance < olddistance || firstintersecting == -1) && intersecting) {
6678 olddistance = distance;
6679 firstintersecting = j;
6686 *p = DoRotation(*p, 0, *rotate, 0);
6689 *p1 = DoRotation(*p1, 0, *rotate, 0);
6691 return firstintersecting;