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