]> git.jsancho.org Git - lugaru.git/blob - Source/Person.h
9f5e7298b898116cac45c6a42a35c282ad105e6d
[lugaru.git] / Source / Person.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3 Copyright (C) 2010-2016 - Lugaru contributors (see AUTHORS file)
4
5 This file is part of Lugaru.
6
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.
11
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.
16
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/>.
19 */
20
21 #ifndef _PERSON_H_
22 #define _PERSON_H_
23
24 /**> HEADER FILES <**/
25
26 #include "gamegl.h"
27 #include "Quaternions.h"
28 #include "Skeleton.h"
29 #include "Models.h"
30 #include "Terrain.h"
31 #include "Sprite.h"
32 #include <cmath>
33 #include <memory>
34 #include "Weapons.h"
35 #include "Animation.h"
36
37 #define passivetype 0
38 #define guardtype 1
39 #define searchtype 2
40 #define attacktype 3
41 #define attacktypecutoff 4
42 #define playercontrolled 5
43 #define gethelptype 6
44 #define getweapontype 7
45 #define pathfindtype 8
46
47 #define rabbittype 0
48 #define wolftype 1
49
50 class Person : public enable_shared_from_this<Person>
51 {
52 public:
53     static std::vector<std::shared_ptr<Person>> players;
54
55     int whichpatchx;
56     int whichpatchz;
57
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?
62     int animCurrent;
63     int animTarget;
64
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.
68     int frameCurrent;
69     int frameTarget;
70
71     int oldanimCurrent;
72     int oldanimTarget;
73     int oldframeCurrent;
74     int oldframeTarget;
75
76     int howactive;
77
78     float parriedrecently;
79
80     bool superruntoggle;
81
82     int lastattack, lastattack2, lastattack3;
83
84     XYZ currentoffset, targetoffset, offset;
85     float target;
86     float transspeed;
87
88     XYZ realoldcoords;
89     XYZ oldcoords;
90     XYZ coords;
91     XYZ originalcoords;
92     XYZ velocity;
93
94     XYZ proportionhead;
95     XYZ proportionlegs;
96     XYZ proportionarms;
97     XYZ proportionbody;
98
99     float unconscioustime;
100
101     bool immobile;
102
103     float velspeed;
104     float targetyaw;
105     float targetrot;
106     float rot;
107     float oldrot;
108     float lookyaw;
109     float lookpitch;
110     float yaw;
111     float pitch;
112     float lowyaw;
113     float tilt;
114     float targettilt;
115     float tilt2;
116     float targettilt2;
117     bool rabbitkickenabled;
118
119     float bloodloss;
120     float bleeddelay;
121     float skiddelay;
122     float skiddingdelay;
123     float deathbleeding;
124     float tempdeltav;
125
126     float damagetolerance;
127     float damage;
128     float permanentdamage;
129     float superpermanentdamage;
130     float lastcollide;
131     int dead;
132
133     float jumppower;
134     bool onground;
135     int madskills;
136
137     int wentforweapon;
138
139     bool calcrot;
140
141     bool backwardsanim;
142
143     XYZ facing;
144
145     float bleeding;
146     float bleedx, bleedy;
147     int direction;
148     float texupdatedelay;
149
150     float headyaw, headpitch;
151     float targetheadyaw, targetheadpitch;
152
153     bool onterrain;
154     bool pause;
155
156     float grabdelay;
157
158     std::shared_ptr<Person> victim;
159     bool hasvictim;
160
161     float updatedelay;
162     float normalsupdatedelay;
163
164     bool jumpstart;
165
166     bool forwardkeydown;
167     bool forwardstogglekeydown;
168     bool rightkeydown;
169     bool leftkeydown;
170     bool backkeydown;
171     bool jumpkeydown;
172     bool jumptogglekeydown;
173     bool crouchkeydown;
174     bool crouchtogglekeydown;
175     bool drawkeydown;
176     bool drawtogglekeydown;
177     bool throwkeydown;
178     bool throwtogglekeydown;
179     bool attackkeydown;
180     bool feint;
181     bool lastfeint;
182     bool headless;
183
184     float crouchkeydowntime;
185     float jumpkeydowntime;
186     bool freefall;
187
188
189     float turnspeed;
190
191     int aitype;
192     float aiupdatedelay;
193     float losupdatedelay;
194     int ally;
195     XYZ movetarget;
196     float collide;
197     float collided;
198     float avoidcollided;
199     bool loaded;
200     bool whichdirection;
201     float whichdirectiondelay;
202     bool avoidsomething;
203     XYZ avoidwhere;
204     float blooddimamount;
205
206     float staggerdelay;
207     float blinkdelay;
208     float twitchdelay;
209     float twitchdelay2;
210     float twitchdelay3;
211     float lefthandmorphness;
212     float righthandmorphness;
213     float headmorphness;
214     float chestmorphness;
215     float tailmorphness;
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;
226
227     float weaponmissdelay;
228     float highreversaldelay;
229     float lowreversaldelay;
230     float nocollidedelay;
231
232     int creature;
233
234     unsigned id;
235
236     Skeleton skeleton;
237
238     float speed;
239     float scale;
240     float power;
241     float speedmult;
242
243     float protectionhead;
244     float protectionhigh;
245     float protectionlow;
246     float armorhead;
247     float armorhigh;
248     float armorlow;
249     bool metalhead;
250     bool metalhigh;
251     bool metallow;
252
253     int numclothes;
254     char clothes[10][256];
255     float clothestintr[10];
256     float clothestintg[10];
257     float clothestintb[10];
258
259     bool landhard;
260     bool bled;
261     bool spurt;
262     bool onfire;
263     float onfiredelay;
264     float burnt;
265     float fireduration;
266
267     float flamedelay;
268     float updatestuffdelay;
269
270     int playerdetail;
271
272     int num_weapons;
273     int weaponids[4];
274     int weaponactive;
275     int weaponstuck;
276     int weaponstuckwhere;
277     int weaponwhere;
278
279     int numwaypoints;
280     XYZ waypoints[90];
281     int waypointtype[90];
282     float pausetime;
283     bool hastempwaypoint;
284     XYZ tempwaypoint;
285
286     XYZ headtarget;
287     float interestdelay;
288
289     XYZ finalfinaltarget;
290     XYZ finaltarget;
291     int finalpathfindpoint;
292     int targetpathfindpoint;
293     int lastpathfindpoint;
294     int lastpathfindpoint2;
295     int lastpathfindpoint3;
296     int lastpathfindpoint4;
297     bool onpath;
298
299     int waypoint;
300     bool jumppath;
301
302     XYZ lastseen;
303     float lastseentime;
304     float lastchecktime;
305     float stunned;
306     float surprised;
307     float runninghowlong;
308     int lastoccluded;
309     int laststanding;
310     int escapednum;
311
312     float speechdelay;
313     float neckspurtdelay;
314     float neckspurtparticledelay;
315     float neckspurtamount;
316
317     int whichskin;
318     bool rabbitkickragdoll;
319
320     XYZ averageloc;
321     XYZ oldaverageloc;
322
323     Animation tempanimation;
324
325     float occluded;
326
327     bool jumpclimb;
328
329
330
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; }
335
336
337     void CheckKick();
338     void CatchFire();
339     void DoBlood(float howmuch, int which);
340     void DoBloodBig(float howmuch, int which);
341     bool DoBloodBigWhere(float howmuch, int which, XYZ where);
342
343     bool wasIdle() { return animation_bits[animCurrent] & ab_idle; }
344     bool isIdle() { return animation_bits[animTarget] & ab_idle; }
345     int getIdle();
346
347     bool isSitting() { return animation_bits[animTarget] & ab_sit; }
348
349     bool isSleeping() { return animation_bits[animTarget] & ab_sleep; }
350
351     bool wasCrouch() { return animation_bits[animCurrent] & ab_crouch; }
352     bool isCrouch() { return animation_bits[animTarget] & ab_crouch; }
353     int getCrouch();
354
355     bool wasStop() { return animation_bits[animCurrent] & ab_stop; }
356     bool isStop() { return animation_bits[animTarget] & ab_stop; }
357     int getStop();
358
359     bool wasSneak();
360     bool isSneak();
361     int getSneak();
362
363     bool wasRun() { return animation_bits[animCurrent] & ab_run; }
364     bool isRun() { return animation_bits[animTarget] & ab_run; }
365     int getRun();
366
367     bool wasLanding() { return animation_bits[animCurrent] & ab_land; }
368     bool isLanding() { return animation_bits[animTarget] & ab_land; }
369     int getLanding();
370
371     bool wasLandhard() { return animation_bits[animCurrent] & ab_landhard; }
372     bool isLandhard() { return animation_bits[animTarget] & ab_landhard; }
373     int getLandhard();
374
375     bool wasFlip() { return animation_bits[animCurrent] & ab_flip; }
376     bool isFlip() { return animation_bits[animTarget] & ab_flip; }
377
378     bool isWallJump() { return animation_bits[animTarget] & ab_walljump; }
379     void Reverse();
380     void DoDamage(float howmuch);
381     void DoHead();
382     void DoMipmaps() {
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]);
386     }
387
388     int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
389     int DrawSkeleton();
390     void Puff(int whichlabel);
391     void FootLand(int which, float opacity);
392     void DoStuff();
393     void setAnimation(int);
394     void DoAnimations();
395     void RagDoll(bool checkcollision);
396 };
397
398 const int maxplayers = 10;
399
400 #endif