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;
131 /* Seems to be 0 = alive, 1 = unconscious, 2 = dead */
147 float bleedx, bleedy;
149 float texupdatedelay;
151 float headyaw, headpitch;
152 float targetheadyaw, targetheadpitch;
159 std::shared_ptr<Person> victim;
163 float normalsupdatedelay;
168 bool forwardstogglekeydown;
173 bool jumptogglekeydown;
175 bool crouchtogglekeydown;
177 bool drawtogglekeydown;
179 bool throwtogglekeydown;
185 float crouchkeydowntime;
186 float jumpkeydowntime;
194 float losupdatedelay;
202 float whichdirectiondelay;
205 float blooddimamount;
212 float lefthandmorphness;
213 float righthandmorphness;
215 float chestmorphness;
217 float targetlefthandmorphness;
218 float targetrighthandmorphness;
219 float targetheadmorphness;
220 float targetchestmorphness;
221 float targettailmorphness;
222 int lefthandmorphstart, lefthandmorphend;
223 int righthandmorphstart, righthandmorphend;
224 int headmorphstart, headmorphend;
225 int chestmorphstart, chestmorphend;
226 int tailmorphstart, tailmorphend;
228 float weaponmissdelay;
229 float highreversaldelay;
230 float lowreversaldelay;
231 float nocollidedelay;
244 float protectionhead;
245 float protectionhigh;
255 char clothes[10][256];
256 float clothestintr[10];
257 float clothestintg[10];
258 float clothestintb[10];
269 float updatestuffdelay;
275 /* Key of weaponids which is the weapon in hand, if any. -1 otherwise.
276 * Always 0 or -1 as activeweapon is moved to position 0 when taken */
279 /* 0 or 1 to say if weapon is stuck in the front or the back */
280 int weaponstuckwhere;
284 int waypointtype[90];
286 bool hastempwaypoint;
292 XYZ finalfinaltarget;
294 int finalpathfindpoint;
295 int targetpathfindpoint;
296 int lastpathfindpoint;
297 int lastpathfindpoint2;
298 int lastpathfindpoint3;
299 int lastpathfindpoint4;
310 float runninghowlong;
316 float neckspurtdelay;
317 float neckspurtparticledelay;
318 float neckspurtamount;
321 bool rabbitkickragdoll;
326 Animation tempanimation;
334 // convenience functions
335 inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; }
336 inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
337 inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
342 void DoBlood(float howmuch, int which);
343 void DoBloodBig(float howmuch, int which);
344 bool DoBloodBigWhere(float howmuch, int which, XYZ where);
346 bool wasIdle() { return animation_bits[animCurrent] & ab_idle; }
347 bool isIdle() { return animation_bits[animTarget] & ab_idle; }
350 bool isSitting() { return animation_bits[animTarget] & ab_sit; }
352 bool isSleeping() { return animation_bits[animTarget] & ab_sleep; }
354 bool wasCrouch() { return animation_bits[animCurrent] & ab_crouch; }
355 bool isCrouch() { return animation_bits[animTarget] & ab_crouch; }
358 bool wasStop() { return animation_bits[animCurrent] & ab_stop; }
359 bool isStop() { return animation_bits[animTarget] & ab_stop; }
366 bool wasRun() { return animation_bits[animCurrent] & ab_run; }
367 bool isRun() { return animation_bits[animTarget] & ab_run; }
370 bool wasLanding() { return animation_bits[animCurrent] & ab_land; }
371 bool isLanding() { return animation_bits[animTarget] & ab_land; }
374 bool wasLandhard() { return animation_bits[animCurrent] & ab_landhard; }
375 bool isLandhard() { return animation_bits[animTarget] & ab_landhard; }
378 bool wasFlip() { return animation_bits[animCurrent] & ab_flip; }
379 bool isFlip() { return animation_bits[animTarget] & ab_flip; }
381 bool isWallJump() { return animation_bits[animTarget] & ab_walljump; }
383 void DoDamage(float howmuch);
386 skeleton.drawmodel.textureptr.bind();
387 glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
388 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]);
391 int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
393 void Puff(int whichlabel);
394 void FootLand(int which, float opacity);
396 void setAnimation(int);
398 void RagDoll(bool checkcollision);
400 void takeWeapon (int weaponId);
402 bool addClothes(const int& clothesId);
406 const int maxplayers = 10;