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 struct InvalidPersonException : public exception {
51 const char * what () const throw () {
52 return "Invalid weapon number";
56 class Person : public enable_shared_from_this<Person>
59 static std::vector<std::shared_ptr<Person>> players;
64 // animCurrent and animTarget are used to interpolate between different animations
65 // (and for a bunch of other things).
66 // animations interpolate with one another at various speeds.
67 // animTarget seems to determine the combat state?
71 // frameCurrent and frameTarget are used to interpolate between the frames of an animation
72 // (e.g. the crouched animation has only two frames, lerped back and forth slowly).
73 // animations advance at various speeds.
84 float parriedrecently;
88 int lastattack, lastattack2, lastattack3;
90 XYZ currentoffset, targetoffset, offset;
104 float unconscioustime;
122 bool rabbitkickenabled;
131 float damagetolerance;
133 float permanentdamage;
134 float superpermanentdamage;
136 /* Seems to be 0 = alive, 1 = unconscious, 2 = dead */
149 float bleedx, bleedy;
151 float texupdatedelay;
153 float headyaw, headpitch;
154 float targetheadyaw, targetheadpitch;
161 std::shared_ptr<Person> victim;
165 float normalsupdatedelay;
170 bool forwardstogglekeydown;
175 bool jumptogglekeydown;
177 bool crouchtogglekeydown;
179 bool drawtogglekeydown;
181 bool throwtogglekeydown;
187 float crouchkeydowntime;
188 float jumpkeydowntime;
196 float losupdatedelay;
203 float whichdirectiondelay;
206 float blooddimamount;
213 float lefthandmorphness;
214 float righthandmorphness;
216 float chestmorphness;
218 float targetlefthandmorphness;
219 float targetrighthandmorphness;
220 float targetheadmorphness;
221 float targetchestmorphness;
222 float targettailmorphness;
223 int lefthandmorphstart, lefthandmorphend;
224 int righthandmorphstart, righthandmorphend;
225 int headmorphstart, headmorphend;
226 int chestmorphstart, chestmorphend;
227 int tailmorphstart, tailmorphend;
229 float weaponmissdelay;
230 float highreversaldelay;
231 float lowreversaldelay;
244 float protectionhead;
245 float protectionhigh;
255 char clothes[10][256];
256 float clothestintr[10];
257 float clothestintg[10];
258 float clothestintb[10];
273 /* Key of weaponids which is the weapon in hand, if any. -1 otherwise.
274 * Always 0 or -1 as activeweapon is moved to position 0 when taken */
277 /* 0 or 1 to say if weapon is stuck in the front or the back */
278 int weaponstuckwhere;
282 int waypointtype[90];
288 XYZ finalfinaltarget;
290 int finalpathfindpoint;
291 int targetpathfindpoint;
292 int lastpathfindpoint;
293 int lastpathfindpoint2;
294 int lastpathfindpoint3;
295 int lastpathfindpoint4;
304 float runninghowlong;
311 float neckspurtdelay;
312 float neckspurtparticledelay;
313 float neckspurtamount;
316 bool rabbitkickragdoll;
318 Animation tempanimation;
323 Person(FILE*, int, unsigned);
325 // convenience functions
326 inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; }
327 inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
328 inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
333 void DoBlood(float howmuch, int which);
334 void DoBloodBig(float howmuch, int which);
335 bool DoBloodBigWhere(float howmuch, int which, XYZ where);
337 bool wasIdle() { return animation_bits[animCurrent] & ab_idle; }
338 bool isIdle() { return animation_bits[animTarget] & ab_idle; }
341 bool isSitting() { return animation_bits[animTarget] & ab_sit; }
343 bool isSleeping() { return animation_bits[animTarget] & ab_sleep; }
345 bool wasCrouch() { return animation_bits[animCurrent] & ab_crouch; }
346 bool isCrouch() { return animation_bits[animTarget] & ab_crouch; }
349 bool wasStop() { return animation_bits[animCurrent] & ab_stop; }
350 bool isStop() { return animation_bits[animTarget] & ab_stop; }
357 bool wasRun() { return animation_bits[animCurrent] & ab_run; }
358 bool isRun() { return animation_bits[animTarget] & ab_run; }
361 bool wasLanding() { return animation_bits[animCurrent] & ab_land; }
362 bool isLanding() { return animation_bits[animTarget] & ab_land; }
365 bool wasLandhard() { return animation_bits[animCurrent] & ab_landhard; }
366 bool isLandhard() { return animation_bits[animTarget] & ab_landhard; }
369 bool wasFlip() { return animation_bits[animCurrent] & ab_flip; }
370 bool isFlip() { return animation_bits[animTarget] & ab_flip; }
372 bool isWallJump() { return animation_bits[animTarget] & ab_walljump; }
374 void DoDamage(float howmuch);
377 skeleton.drawmodel.textureptr.bind();
378 glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
379 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]);
382 int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
384 void Puff(int whichlabel);
385 void FootLand(bodyparts whichfoot, float opacity);
387 void setAnimation(int);
389 void RagDoll(bool checkcollision);
391 void takeWeapon (int weaponId);
393 bool addClothes(const int& clothesId);
397 const int maxplayers = 10;