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 modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 Lugaru 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. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
23 /**> HEADER FILES <**/
26 #include "Quaternions.h"
34 #include "Animation.h"
40 #define attacktypecutoff 4
41 #define playercontrolled 5
43 #define getweapontype 7
44 #define pathfindtype 8
49 class Person : public enable_shared_from_this<Person>
52 static std::vector<std::shared_ptr<Person>> players;
57 // animCurrent and animTarget are used to interpolate between different animations
58 // (and for a bunch of other things).
59 // animations interpolate with one another at various speeds.
60 // animTarget seems to determine the combat state?
64 // frameCurrent and frameTarget are used to interpolate between the frames of an animation
65 // (e.g. the crouched animation has only two frames, lerped back and forth slowly).
66 // animations advance at various speeds.
77 float parriedrecently;
81 int lastattack, lastattack2, lastattack3;
83 XYZ currentoffset, targetoffset, offset;
98 float unconscioustime;
116 bool rabbitkickenabled;
125 float damagetolerance;
127 float permanentdamage;
128 float superpermanentdamage;
145 float bleedx, bleedy;
147 float texupdatedelay;
149 float headyaw, headpitch;
150 float targetheadyaw, targetheadpitch;
157 std::shared_ptr<Person> victim;
161 float normalsupdatedelay;
166 bool forwardstogglekeydown;
171 bool jumptogglekeydown;
173 bool crouchtogglekeydown;
175 bool drawtogglekeydown;
177 bool throwtogglekeydown;
183 float crouchkeydowntime;
184 float jumpkeydowntime;
192 float losupdatedelay;
200 float whichdirectiondelay;
203 float blooddimamount;
210 float lefthandmorphness;
211 float righthandmorphness;
213 float chestmorphness;
215 float targetlefthandmorphness;
216 float targetrighthandmorphness;
217 float targetheadmorphness;
218 float targetchestmorphness;
219 float targettailmorphness;
220 int lefthandmorphstart, lefthandmorphend;
221 int righthandmorphstart, righthandmorphend;
222 int headmorphstart, headmorphend;
223 int chestmorphstart, chestmorphend;
224 int tailmorphstart, tailmorphend;
226 float weaponmissdelay;
227 float highreversaldelay;
228 float lowreversaldelay;
229 float nocollidedelay;
242 float protectionhead;
243 float protectionhigh;
253 char clothes[10][256];
254 float clothestintr[10];
255 float clothestintg[10];
256 float clothestintb[10];
267 float updatestuffdelay;
275 int weaponstuckwhere;
280 int waypointtype[90];
282 bool hastempwaypoint;
288 XYZ finalfinaltarget;
290 int finalpathfindpoint;
291 int targetpathfindpoint;
292 int lastpathfindpoint;
293 int lastpathfindpoint2;
294 int lastpathfindpoint3;
295 int lastpathfindpoint4;
306 float runninghowlong;
312 float neckspurtdelay;
313 float neckspurtparticledelay;
314 float neckspurtamount;
317 bool rabbitkickragdoll;
322 Animation tempanimation;
330 // convenience functions
331 inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; }
332 inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
333 inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
338 void DoBlood(float howmuch, int which);
339 void DoBloodBig(float howmuch, int which);
340 bool DoBloodBigWhere(float howmuch, int which, XYZ where);
342 bool wasIdle() { return animation_bits[animCurrent] & ab_idle; }
343 bool isIdle() { return animation_bits[animTarget] & ab_idle; }
346 bool isSitting() { return animation_bits[animTarget] & ab_sit; }
348 bool isSleeping() { return animation_bits[animTarget] & ab_sleep; }
350 bool wasCrouch() { return animation_bits[animCurrent] & ab_crouch; }
351 bool isCrouch() { return animation_bits[animTarget] & ab_crouch; }
354 bool wasStop() { return animation_bits[animCurrent] & ab_stop; }
355 bool isStop() { return animation_bits[animTarget] & ab_stop; }
362 bool wasRun() { return animation_bits[animCurrent] & ab_run; }
363 bool isRun() { return animation_bits[animTarget] & ab_run; }
366 bool wasLanding() { return animation_bits[animCurrent] & ab_land; }
367 bool isLanding() { return animation_bits[animTarget] & ab_land; }
370 bool wasLandhard() { return animation_bits[animCurrent] & ab_landhard; }
371 bool isLandhard() { return animation_bits[animTarget] & ab_landhard; }
374 bool wasFlip() { return animation_bits[animCurrent] & ab_flip; }
375 bool isFlip() { return animation_bits[animTarget] & ab_flip; }
377 bool isWallJump() { return animation_bits[animTarget] & ab_walljump; }
379 void DoDamage(float howmuch);
382 skeleton.drawmodel.textureptr.bind();
383 glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
384 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]);
387 int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
389 void Puff(int whichlabel);
390 void FootLand(int which, float opacity);
392 void setAnimation(int);
394 void RagDoll(bool checkcollision);
397 const int maxplayers = 10;