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