]> git.jsancho.org Git - lugaru.git/blob - Source/Person.h
employ convenience functions
[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 heightleft;
98                 float heightright;
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                 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
333                 Joint& joint(int);
334                 XYZ& jointPos(int);
335                 XYZ& jointVel(int);
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                 {
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 #endif