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;
98 float unconscioustime;
116 bool rabbitkickenabled;
125 float damagetolerance;
127 float permanentdamage;
128 float superpermanentdamage;
130 /* Seems to be 0 = alive, 1 = unconscious, 2 = dead */
143 float bleedx, bleedy;
145 float texupdatedelay;
147 float headyaw, headpitch;
148 float targetheadyaw, targetheadpitch;
155 std::shared_ptr<Person> victim;
159 float normalsupdatedelay;
164 bool forwardstogglekeydown;
169 bool jumptogglekeydown;
171 bool crouchtogglekeydown;
173 bool drawtogglekeydown;
175 bool throwtogglekeydown;
181 float crouchkeydowntime;
182 float jumpkeydowntime;
190 float losupdatedelay;
197 float whichdirectiondelay;
200 float blooddimamount;
207 float lefthandmorphness;
208 float righthandmorphness;
210 float chestmorphness;
212 float targetlefthandmorphness;
213 float targetrighthandmorphness;
214 float targetheadmorphness;
215 float targetchestmorphness;
216 float targettailmorphness;
217 int lefthandmorphstart, lefthandmorphend;
218 int righthandmorphstart, righthandmorphend;
219 int headmorphstart, headmorphend;
220 int chestmorphstart, chestmorphend;
221 int tailmorphstart, tailmorphend;
223 float weaponmissdelay;
224 float highreversaldelay;
225 float lowreversaldelay;
238 float protectionhead;
239 float protectionhigh;
249 char clothes[10][256];
250 float clothestintr[10];
251 float clothestintg[10];
252 float clothestintb[10];
267 /* Key of weaponids which is the weapon in hand, if any. -1 otherwise.
268 * Always 0 or -1 as activeweapon is moved to position 0 when taken */
271 /* 0 or 1 to say if weapon is stuck in the front or the back */
272 int weaponstuckwhere;
276 int waypointtype[90];
282 XYZ finalfinaltarget;
284 int finalpathfindpoint;
285 int targetpathfindpoint;
286 int lastpathfindpoint;
287 int lastpathfindpoint2;
288 int lastpathfindpoint3;
289 int lastpathfindpoint4;
298 float runninghowlong;
304 float neckspurtdelay;
305 float neckspurtparticledelay;
306 float neckspurtamount;
309 bool rabbitkickragdoll;
311 Animation tempanimation;
319 // convenience functions
320 inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; }
321 inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
322 inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
327 void DoBlood(float howmuch, int which);
328 void DoBloodBig(float howmuch, int which);
329 bool DoBloodBigWhere(float howmuch, int which, XYZ where);
331 bool wasIdle() { return animation_bits[animCurrent] & ab_idle; }
332 bool isIdle() { return animation_bits[animTarget] & ab_idle; }
335 bool isSitting() { return animation_bits[animTarget] & ab_sit; }
337 bool isSleeping() { return animation_bits[animTarget] & ab_sleep; }
339 bool wasCrouch() { return animation_bits[animCurrent] & ab_crouch; }
340 bool isCrouch() { return animation_bits[animTarget] & ab_crouch; }
343 bool wasStop() { return animation_bits[animCurrent] & ab_stop; }
344 bool isStop() { return animation_bits[animTarget] & ab_stop; }
351 bool wasRun() { return animation_bits[animCurrent] & ab_run; }
352 bool isRun() { return animation_bits[animTarget] & ab_run; }
355 bool wasLanding() { return animation_bits[animCurrent] & ab_land; }
356 bool isLanding() { return animation_bits[animTarget] & ab_land; }
359 bool wasLandhard() { return animation_bits[animCurrent] & ab_landhard; }
360 bool isLandhard() { return animation_bits[animTarget] & ab_landhard; }
363 bool wasFlip() { return animation_bits[animCurrent] & ab_flip; }
364 bool isFlip() { return animation_bits[animTarget] & ab_flip; }
366 bool isWallJump() { return animation_bits[animTarget] & ab_walljump; }
368 void DoDamage(float howmuch);
371 skeleton.drawmodel.textureptr.bind();
372 glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
373 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]);
376 int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
378 void Puff(int whichlabel);
379 void FootLand(int which, float opacity);
381 void setAnimation(int);
383 void RagDoll(bool checkcollision);
385 void takeWeapon (int weaponId);
387 bool addClothes(const int& clothesId);
391 const int maxplayers = 10;