]> git.jsancho.org Git - lugaru.git/blob - Source/Person.h
License: Update GPLv2+ header to match current FSF recommendation
[lugaru.git] / Source / Person.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3
4 This file is part of Lugaru.
5
6 Lugaru is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 Lugaru is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _PERSON_H_
21 #define _PERSON_H_
22
23 /**> HEADER FILES <**/
24
25 #include "gamegl.h"
26 #include "Quaternions.h"
27 #include "Skeleton.h"
28 #include "Models.h"
29 #include "Terrain.h"
30 #include "Sprite.h"
31 #include <cmath>
32 #include <memory>
33 #include "Weapons.h"
34 #include "Animation.h"
35
36 #define passivetype 0
37 #define guardtype 1
38 #define searchtype 2
39 #define attacktype 3
40 #define attacktypecutoff 4
41 #define playercontrolled 5
42 #define gethelptype 6
43 #define getweapontype 7
44 #define pathfindtype 8
45
46 #define rabbittype 0
47 #define wolftype 1
48
49 class Person : public enable_shared_from_this<Person>
50 {
51 public:
52     static std::vector<std::shared_ptr<Person>> players;
53
54     int whichpatchx;
55     int whichpatchz;
56
57     // animCurrent and animTarget are used to interpolate between different animations
58     // (and for a bunch of other things).
59     // animations interpolate with one another at various speeds.
60     // animTarget seems to determine the combat state?
61     int animCurrent;
62     int animTarget;
63
64     // frameCurrent and frameTarget are used to interpolate between the frames of an animation
65     // (e.g. the crouched animation has only two frames, lerped back and forth slowly).
66     // animations advance at various speeds.
67     int frameCurrent;
68     int frameTarget;
69
70     int oldanimCurrent;
71     int oldanimTarget;
72     int oldframeCurrent;
73     int oldframeTarget;
74
75     int howactive;
76
77     float parriedrecently;
78
79     bool superruntoggle;
80
81     int lastattack, lastattack2, lastattack3;
82
83     XYZ currentoffset, targetoffset, offset;
84     float target;
85     float transspeed;
86
87     XYZ realoldcoords;
88     XYZ oldcoords;
89     XYZ coords;
90     XYZ originalcoords;
91     XYZ velocity;
92
93     XYZ proportionhead;
94     XYZ proportionlegs;
95     XYZ proportionarms;
96     XYZ proportionbody;
97
98     float unconscioustime;
99
100     bool immobile;
101
102     float velspeed;
103     float targetyaw;
104     float targetrot;
105     float rot;
106     float oldrot;
107     float lookyaw;
108     float lookpitch;
109     float yaw;
110     float pitch;
111     float lowyaw;
112     float tilt;
113     float targettilt;
114     float tilt2;
115     float targettilt2;
116     bool rabbitkickenabled;
117
118     float bloodloss;
119     float bleeddelay;
120     float skiddelay;
121     float skiddingdelay;
122     float deathbleeding;
123     float tempdeltav;
124
125     float damagetolerance;
126     float damage;
127     float permanentdamage;
128     float superpermanentdamage;
129     float lastcollide;
130     int dead;
131
132     float jumppower;
133     bool onground;
134     int madskills;
135
136     int wentforweapon;
137
138     bool calcrot;
139
140     bool backwardsanim;
141
142     XYZ facing;
143
144     float bleeding;
145     float bleedx, bleedy;
146     int direction;
147     float texupdatedelay;
148
149     float headyaw, headpitch;
150     float targetheadyaw, targetheadpitch;
151
152     bool onterrain;
153     bool pause;
154
155     float grabdelay;
156
157     std::shared_ptr<Person> victim;
158     bool hasvictim;
159
160     float updatedelay;
161     float normalsupdatedelay;
162
163     bool jumpstart;
164
165     bool forwardkeydown;
166     bool forwardstogglekeydown;
167     bool rightkeydown;
168     bool leftkeydown;
169     bool backkeydown;
170     bool jumpkeydown;
171     bool jumptogglekeydown;
172     bool crouchkeydown;
173     bool crouchtogglekeydown;
174     bool drawkeydown;
175     bool drawtogglekeydown;
176     bool throwkeydown;
177     bool throwtogglekeydown;
178     bool attackkeydown;
179     bool feint;
180     bool lastfeint;
181     bool headless;
182
183     float crouchkeydowntime;
184     float jumpkeydowntime;
185     bool freefall;
186
187
188     float turnspeed;
189
190     int aitype;
191     float aiupdatedelay;
192     float losupdatedelay;
193     int ally;
194     XYZ movetarget;
195     float collide;
196     float collided;
197     float avoidcollided;
198     bool loaded;
199     bool whichdirection;
200     float whichdirectiondelay;
201     bool avoidsomething;
202     XYZ avoidwhere;
203     float blooddimamount;
204
205     float staggerdelay;
206     float blinkdelay;
207     float twitchdelay;
208     float twitchdelay2;
209     float twitchdelay3;
210     float lefthandmorphness;
211     float righthandmorphness;
212     float headmorphness;
213     float chestmorphness;
214     float tailmorphness;
215     float targetlefthandmorphness;
216     float targetrighthandmorphness;
217     float targetheadmorphness;
218     float targetchestmorphness;
219     float targettailmorphness;
220     int lefthandmorphstart, lefthandmorphend;
221     int righthandmorphstart, righthandmorphend;
222     int headmorphstart, headmorphend;
223     int chestmorphstart, chestmorphend;
224     int tailmorphstart, tailmorphend;
225
226     float weaponmissdelay;
227     float highreversaldelay;
228     float lowreversaldelay;
229     float nocollidedelay;
230
231     int creature;
232
233     unsigned id;
234
235     Skeleton skeleton;
236
237     float speed;
238     float scale;
239     float power;
240     float speedmult;
241
242     float protectionhead;
243     float protectionhigh;
244     float protectionlow;
245     float armorhead;
246     float armorhigh;
247     float armorlow;
248     bool metalhead;
249     bool metalhigh;
250     bool metallow;
251
252     int numclothes;
253     char clothes[10][256];
254     float clothestintr[10];
255     float clothestintg[10];
256     float clothestintb[10];
257
258     bool landhard;
259     bool bled;
260     bool spurt;
261     bool onfire;
262     float onfiredelay;
263     float burnt;
264     float fireduration;
265
266     float flamedelay;
267     float updatestuffdelay;
268
269     int playerdetail;
270
271     int num_weapons;
272     int weaponids[4];
273     int weaponactive;
274     int weaponstuck;
275     int weaponstuckwhere;
276     int weaponwhere;
277
278     int numwaypoints;
279     XYZ waypoints[90];
280     int waypointtype[90];
281     float pausetime;
282     bool hastempwaypoint;
283     XYZ tempwaypoint;
284
285     XYZ headtarget;
286     float interestdelay;
287
288     XYZ finalfinaltarget;
289     XYZ finaltarget;
290     int finalpathfindpoint;
291     int targetpathfindpoint;
292     int lastpathfindpoint;
293     int lastpathfindpoint2;
294     int lastpathfindpoint3;
295     int lastpathfindpoint4;
296     bool onpath;
297
298     int waypoint;
299     bool jumppath;
300
301     XYZ lastseen;
302     float lastseentime;
303     float lastchecktime;
304     float stunned;
305     float surprised;
306     float runninghowlong;
307     int lastoccluded;
308     int laststanding;
309     int escapednum;
310
311     float speechdelay;
312     float neckspurtdelay;
313     float neckspurtparticledelay;
314     float neckspurtamount;
315
316     int whichskin;
317     bool rabbitkickragdoll;
318
319     XYZ averageloc;
320     XYZ oldaverageloc;
321
322     Animation tempanimation;
323
324     float occluded;
325
326     bool jumpclimb;
327
328
329
330     // convenience functions
331     inline Joint& joint(int bodypart) { return skeleton.joints[skeleton.jointlabels[bodypart]]; }
332     inline XYZ& jointPos(int bodypart) { return joint(bodypart).position; }
333     inline XYZ& jointVel(int bodypart) { return joint(bodypart).velocity; }
334
335
336     void CheckKick();
337     void CatchFire();
338     void DoBlood(float howmuch, int which);
339     void DoBloodBig(float howmuch, int which);
340     bool DoBloodBigWhere(float howmuch, int which, XYZ where);
341
342     bool wasIdle() { return animation_bits[animCurrent] & ab_idle; }
343     bool isIdle() { return animation_bits[animTarget] & ab_idle; }
344     int getIdle();
345
346     bool isSitting() { return animation_bits[animTarget] & ab_sit; }
347
348     bool isSleeping() { return animation_bits[animTarget] & ab_sleep; }
349
350     bool wasCrouch() { return animation_bits[animCurrent] & ab_crouch; }
351     bool isCrouch() { return animation_bits[animTarget] & ab_crouch; }
352     int getCrouch();
353
354     bool wasStop() { return animation_bits[animCurrent] & ab_stop; }
355     bool isStop() { return animation_bits[animTarget] & ab_stop; }
356     int getStop();
357
358     bool wasSneak();
359     bool isSneak();
360     int getSneak();
361
362     bool wasRun() { return animation_bits[animCurrent] & ab_run; }
363     bool isRun() { return animation_bits[animTarget] & ab_run; }
364     int getRun();
365
366     bool wasLanding() { return animation_bits[animCurrent] & ab_land; }
367     bool isLanding() { return animation_bits[animTarget] & ab_land; }
368     int getLanding();
369
370     bool wasLandhard() { return animation_bits[animCurrent] & ab_landhard; }
371     bool isLandhard() { return animation_bits[animTarget] & ab_landhard; }
372     int getLandhard();
373
374     bool wasFlip() { return animation_bits[animCurrent] & ab_flip; }
375     bool isFlip() { return animation_bits[animTarget] & ab_flip; }
376
377     bool isWallJump() { return animation_bits[animTarget] & ab_walljump; }
378     void Reverse();
379     void DoDamage(float howmuch);
380     void DoHead();
381     void DoMipmaps() {
382         skeleton.drawmodel.textureptr.bind();
383         glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
384         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]);
385     }
386
387     int SphereCheck(XYZ *p1, float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
388     int DrawSkeleton();
389     void Puff(int whichlabel);
390     void FootLand(int which, float opacity);
391     void DoStuff();
392     void setAnimation(int);
393     void DoAnimations();
394     void RagDoll(bool checkcollision);
395 };
396
397 const int maxplayers = 10;
398
399 #endif