]> git.jsancho.org Git - lugaru.git/blob - Source/Person.h
1eb92efe33d6e5a42e2f8db5b9b9a1384370a771
[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 "Constants.h"
32 #include "Terrain.h"
33 #include "Sprite.h"
34 #include <cmath>
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 struct Person
52 {
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 targetrotation;
97                 float targetrot;
98                 float rot;
99                 float oldrot;
100                 float lookrotation;
101                 float lookrotation2;
102                 float rotation;
103                 float rotation2;
104                 float lowrotation;
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 headrotation,headrotation2;
142                 float targetheadrotation,targetheadrotation2;
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                 int aitarget;
184                 float aiupdatedelay;
185                 float losupdatedelay;
186                 int ally;
187                 XYZ movetarget;
188                 float collide;
189                 float collided;
190                 float avoidcollided;
191                 bool loaded;
192                 bool whichdirection;
193                 float whichdirectiondelay;
194                 bool avoidsomething;            XYZ avoidwhere;         
195                 float blooddimamount;
196                 
197                 float staggerdelay;
198                 float blinkdelay;
199                 float twitchdelay;
200                 float twitchdelay2;
201                 float twitchdelay3;
202                 float lefthandmorphness;
203                 float righthandmorphness;
204                 float headmorphness;
205                 float chestmorphness;
206                 float tailmorphness;
207                 float targetlefthandmorphness;
208                 float targetrighthandmorphness;
209                 float targetheadmorphness;
210                 float targetchestmorphness;
211                 float targettailmorphness;
212                 int lefthandmorphstart,lefthandmorphend;
213                 int righthandmorphstart,righthandmorphend;
214                 int headmorphstart,headmorphend;
215                 int chestmorphstart,chestmorphend;
216                 int tailmorphstart,tailmorphend;
217                 
218                 float weaponmissdelay;
219                 float highreversaldelay;
220                 float lowreversaldelay;
221                 float nocollidedelay;
222                 
223                 int creature;
224                 
225                 int id;
226                 
227                 Skeleton skeleton;
228                 
229                 float speed;
230                 float scale;
231                 float power;
232                 float speedmult;
233                 
234                 float protectionhead;
235                 float protectionhigh;
236                 float protectionlow;
237                 float armorhead;
238                 float armorhigh;
239                 float armorlow;
240                 bool metalhead;
241                 bool metalhigh;
242                 bool metallow;
243                 
244                 int numclothes;
245                 char clothes[10][256];
246                 float clothestintr[10];
247                 float clothestintg[10];
248                 float clothestintb[10];
249                 
250                 bool landhard;
251                 bool bled;
252                 bool spurt;
253                 bool onfire;
254                 float onfiredelay;              float burnt;
255                 float fireduration;
256                 
257                 float flamedelay;
258                 float updatestuffdelay;
259                 
260                 int playerdetail;
261                 
262                 int num_weapons;
263                 int weaponids[4];
264                 int weaponactive;
265                 int weaponstuck;
266                 int weaponstuckwhere;
267                 int weaponwhere;
268                 
269                 int numwaypoints;
270                 XYZ waypoints[90];
271                 int waypointtype[90];
272                 float pausetime;
273                 bool hastempwaypoint;
274                 XYZ tempwaypoint;
275                 
276                 XYZ headtarget;
277                 float interestdelay;
278                 
279                 XYZ finalfinaltarget;
280                 XYZ finaltarget;
281                 int finalpathfindpoint;
282                 int targetpathfindpoint;
283                 int lastpathfindpoint;
284                 int lastpathfindpoint2;
285                 int lastpathfindpoint3;
286                 int lastpathfindpoint4;
287                 bool onpath;
288                 
289                 int waypoint;
290                 bool jumppath;
291                 
292                 XYZ lastseen;
293                 float lastseentime;
294                 float lastchecktime;
295                 float stunned;
296                 float surprised;
297                 float runninghowlong;           int lastoccluded;
298                 int laststanding;
299                 int escapednum;
300                 
301                 float speechdelay;
302                 float neckspurtdelay;
303                 float neckspurtparticledelay;
304                 float neckspurtamount;
305                 
306                 int whichskin;
307                 bool rabbitkickragdoll;
308                 
309                 XYZ averageloc;
310                 XYZ oldaverageloc;
311                 
312                 Animation tempanimation;
313                 
314                 float occluded;
315                 
316                 void CheckKick();
317                 void CatchFire();
318                 void DoBlood(float howmuch, int which);
319                 void DoBloodBig(float howmuch, int which);
320                 bool DoBloodBigWhere(float howmuch, int which, XYZ where);
321                 
322                 bool wasIdle()
323                 {
324                   return animation_bits[currentanimation] & ab_idle;
325                 }
326                 bool isIdle()
327                 {
328                   return animation_bits[targetanimation] & ab_idle;
329                 }
330                 int getIdle();
331                 
332                 bool isSitting()
333                 {
334                   return animation_bits[targetanimation] & ab_sit;
335                 }
336
337                 bool isSleeping()
338                 {
339                   return animation_bits[targetanimation] & ab_sleep;
340                 }
341
342                 bool wasCrouch()
343                 {
344                   return animation_bits[currentanimation] & ab_crouch;
345                 }
346                 bool isCrouch()
347                 {
348                   return animation_bits[targetanimation] & ab_crouch;
349                 }
350                 int getCrouch();
351                 
352                 bool wasStop()
353                 {
354                   return animation_bits[currentanimation] & ab_stop;
355                 }
356                 bool isStop()
357                 {
358                   return animation_bits[targetanimation] & ab_stop;
359                 }
360                 int getStop();
361                 
362                 bool wasSneak();
363                 bool isSneak();
364                 int getSneak();
365                 
366                 bool wasRun()
367                 {
368                   return animation_bits[currentanimation] & ab_run;
369                 }
370                 bool isRun()
371                 {
372                   return animation_bits[targetanimation] & ab_run;
373                 }
374                 int getRun();
375
376                 bool wasLanding()
377                 {
378                   return animation_bits[currentanimation] & ab_land;
379                 }
380                 bool isLanding()
381                 {
382                   return animation_bits[targetanimation] & ab_land;
383                 }
384                 int getLanding();
385
386                 bool wasLandhard()
387                 {
388                   return animation_bits[currentanimation] & ab_landhard;
389                 }
390                 bool isLandhard()
391                 {
392                   return animation_bits[targetanimation] & ab_landhard;
393                 }
394                 int getLandhard();
395
396                 bool wasFlip()
397                 {
398                   return animation_bits[currentanimation] & ab_flip;
399                 }
400                 bool isFlip()
401                 {
402                   return animation_bits[targetanimation] & ab_flip;
403                 }
404
405                 bool jumpclimb;
406
407                 bool isWallJump()
408                 {
409                   return animation_bits[targetanimation] & ab_walljump;
410                 }
411                 void Reverse();
412                 void DoDamage(float howmuch);
413                 void DoHead();
414                 void DoMipmaps()
415                 {
416                   glBindTexture(GL_TEXTURE_2D, skeleton.drawmodel.textureptr);
417                   gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB,
418                                     skeleton.skinsize,
419                                     skeleton.skinsize,
420                                     GL_RGB, GL_UNSIGNED_BYTE,
421                                     &skeleton.skinText[0]);
422                 }
423
424                 int SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
425                 int DrawSkeleton();
426                 void Puff(int whichlabel);
427                 void FootLand(int which, float opacity);
428                 void DoStuff();
429                 void DoAnimations();
430                 void RagDoll(bool checkcollision);
431 };
432
433 const int maxplayers = 10;
434 extern Person player[maxplayers];
435 #endif