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