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