2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
5 This file is part of Lugaru.
7 Lugaru is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 Lugaru is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with Lugaru. If not, see <http://www.gnu.org/licenses/>.
24 /**> HEADER FILES <**/
27 #include "Quaternions.h"
35 #include "Animation.h"
41 #define attacktypecutoff 4
42 #define playercontrolled 5
44 #define getweapontype 7
45 #define pathfindtype 8
50 class Person : public enable_shared_from_this<Person>
53 static std::vector<std::shared_ptr<Person>> players;
58 // animCurrent and animTarget are used to interpolate between different animations
59 // (and for a bunch of other things).
60 // animations interpolate with one another at various speeds.
61 // animTarget seems to determine the combat state?
65 // frameCurrent and frameTarget are used to interpolate between the frames of an animation
66 // (e.g. the crouched animation has only two frames, lerped back and forth slowly).
67 // animations advance at various speeds.
78 float parriedrecently;
82 int lastattack, lastattack2, lastattack3;
84 XYZ currentoffset, targetoffset, offset;
99 float unconscioustime;
117 bool rabbitkickenabled;
126 float damagetolerance;
128 float permanentdamage;
129 float superpermanentdamage;
146 float bleedx, bleedy;
148 float texupdatedelay;
150 float headyaw, headpitch;
151 float targetheadyaw, targetheadpitch;
158 std::shared_ptr<Person> victim;
162 float normalsupdatedelay;
167 bool forwardstogglekeydown;
172 bool jumptogglekeydown;
174 bool crouchtogglekeydown;
176 bool drawtogglekeydown;
178 bool throwtogglekeydown;
184 float crouchkeydowntime;
185 float jumpkeydowntime;
193 float losupdatedelay;
201 float whichdirectiondelay;
204 float blooddimamount;
211 float lefthandmorphness;
212 float righthandmorphness;
214 float chestmorphness;
216 float targetlefthandmorphness;
217 float targetrighthandmorphness;
218 float targetheadmorphness;
219 float targetchestmorphness;
220 float targettailmorphness;
221 int lefthandmorphstart, lefthandmorphend;
222 int righthandmorphstart, righthandmorphend;
223 int headmorphstart, headmorphend;
224 int chestmorphstart, chestmorphend;
225 int tailmorphstart, tailmorphend;
227 float weaponmissdelay;
228 float highreversaldelay;
229 float lowreversaldelay;
230 float nocollidedelay;
243 float protectionhead;
244 float protectionhigh;
254 char clothes[10][256];
255 float clothestintr[10];
256 float clothestintg[10];
257 float clothestintb[10];
268 float updatestuffdelay;
276 int weaponstuckwhere;
281 int waypointtype[90];
283 bool hastempwaypoint;
289 XYZ finalfinaltarget;
291 int finalpathfindpoint;
292 int targetpathfindpoint;
293 int lastpathfindpoint;
294 int lastpathfindpoint2;
295 int lastpathfindpoint3;
296 int lastpathfindpoint4;
307 float runninghowlong;
313 float neckspurtdelay;
314 float neckspurtparticledelay;
315 float neckspurtamount;
318 bool rabbitkickragdoll;
323 Animation tempanimation;
331 // convenience functions
332 inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; }
333 inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
334 inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
339 void DoBlood(float howmuch, int which);
340 void DoBloodBig(float howmuch, int which);
341 bool DoBloodBigWhere(float howmuch, int which, XYZ where);
343 bool wasIdle() { return animation_bits[animCurrent] & ab_idle; }
344 bool isIdle() { return animation_bits[animTarget] & ab_idle; }
347 bool isSitting() { return animation_bits[animTarget] & ab_sit; }
349 bool isSleeping() { return animation_bits[animTarget] & ab_sleep; }
351 bool wasCrouch() { return animation_bits[animCurrent] & ab_crouch; }
352 bool isCrouch() { return animation_bits[animTarget] & ab_crouch; }
355 bool wasStop() { return animation_bits[animCurrent] & ab_stop; }
356 bool isStop() { return animation_bits[animTarget] & ab_stop; }
363 bool wasRun() { return animation_bits[animCurrent] & ab_run; }
364 bool isRun() { return animation_bits[animTarget] & ab_run; }
367 bool wasLanding() { return animation_bits[animCurrent] & ab_land; }
368 bool isLanding() { return animation_bits[animTarget] & ab_land; }
371 bool wasLandhard() { return animation_bits[animCurrent] & ab_landhard; }
372 bool isLandhard() { return animation_bits[animTarget] & ab_landhard; }
375 bool wasFlip() { return animation_bits[animCurrent] & ab_flip; }
376 bool isFlip() { return animation_bits[animTarget] & ab_flip; }
378 bool isWallJump() { return animation_bits[animTarget] & ab_walljump; }
380 void DoDamage(float howmuch);
383 skeleton.drawmodel.textureptr.bind();
384 glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
385 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]);
388 int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
390 void Puff(int whichlabel);
391 void FootLand(int which, float opacity);
393 void setAnimation(int);
395 void RagDoll(bool checkcollision);
397 void takeWeapon (int weaponId);
400 const int maxplayers = 10;