]> git.jsancho.org Git - lugaru.git/blob - Source/Person.h
31bb43197913bf034ec1aff45254686c8afef994
[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;
122         float lastcollide;
123                 int dead;
124                 
125                 float jumppower;
126                 bool onground;
127                 int madskills;
128                 
129                 int wentforweapon;
130                 
131                 bool calcrot;
132                 
133                 bool backwardsanim;
134                 
135                 XYZ facing;
136                 
137                 float bleeding;
138                 float bleedx,bleedy;
139                 int direction;
140                 float texupdatedelay;
141                 
142                 float headyaw,headpitch;
143                 float targetheadyaw,targetheadpitch;
144                 
145                 bool onterrain;
146                 bool pause;
147                 
148                 float grabdelay;
149                 
150                 Person *victim;
151                 bool hasvictim;
152                 
153                 float updatedelay;
154                 float normalsupdatedelay;
155                 
156                 bool jumpstart;
157                 
158                 bool forwardkeydown;
159                 bool forwardstogglekeydown;
160                 bool rightkeydown;
161                 bool leftkeydown;
162                 bool backkeydown;
163                 bool jumpkeydown;
164                 bool jumptogglekeydown;
165                 bool crouchkeydown;
166                 bool crouchtogglekeydown;
167                 bool drawkeydown;
168                 bool drawtogglekeydown;
169                 bool throwkeydown;
170                 bool throwtogglekeydown;
171                 bool attackkeydown;
172                 bool feint;
173                 bool lastfeint;
174                 bool headless;
175                 
176                 float crouchkeydowntime;
177                 float jumpkeydowntime;
178                 bool freefall;
179                 
180                 
181                 float turnspeed;
182                 
183                 int aitype;
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;
195         XYZ avoidwhere;         
196                 float blooddimamount;
197                 
198                 float staggerdelay;
199                 float blinkdelay;
200                 float twitchdelay;
201                 float twitchdelay2;
202                 float twitchdelay3;
203                 float lefthandmorphness;
204                 float righthandmorphness;
205                 float headmorphness;
206                 float chestmorphness;
207                 float tailmorphness;
208                 float targetlefthandmorphness;
209                 float targetrighthandmorphness;
210                 float targetheadmorphness;
211                 float targetchestmorphness;
212                 float targettailmorphness;
213                 int lefthandmorphstart,lefthandmorphend;
214                 int righthandmorphstart,righthandmorphend;
215                 int headmorphstart,headmorphend;
216                 int chestmorphstart,chestmorphend;
217                 int tailmorphstart,tailmorphend;
218                 
219                 float weaponmissdelay;
220                 float highreversaldelay;
221                 float lowreversaldelay;
222                 float nocollidedelay;
223                 
224                 int creature;
225                 
226                 int id;
227                 
228                 Skeleton skeleton;
229                 
230                 float speed;
231                 float scale;
232                 float power;
233                 float speedmult;
234                 
235                 float protectionhead;
236                 float protectionhigh;
237                 float protectionlow;
238                 float armorhead;
239                 float armorhigh;
240                 float armorlow;
241                 bool metalhead;
242                 bool metalhigh;
243                 bool metallow;
244                 
245                 int numclothes;
246                 char clothes[10][256];
247                 float clothestintr[10];
248                 float clothestintg[10];
249                 float clothestintb[10];
250                 
251                 bool landhard;
252                 bool bled;
253                 bool spurt;
254                 bool onfire;
255                 float onfiredelay;
256         float burnt;
257                 float fireduration;
258                 
259                 float flamedelay;
260                 float updatestuffdelay;
261                 
262                 int playerdetail;
263                 
264                 int num_weapons;
265                 int weaponids[4];
266                 int weaponactive;
267                 int weaponstuck;
268                 int weaponstuckwhere;
269                 int weaponwhere;
270                 
271                 int numwaypoints;
272                 XYZ waypoints[90];
273                 int waypointtype[90];
274                 float pausetime;
275                 bool hastempwaypoint;
276                 XYZ tempwaypoint;
277                 
278                 XYZ headtarget;
279                 float interestdelay;
280                 
281                 XYZ finalfinaltarget;
282                 XYZ finaltarget;
283                 int finalpathfindpoint;
284                 int targetpathfindpoint;
285                 int lastpathfindpoint;
286                 int lastpathfindpoint2;
287                 int lastpathfindpoint3;
288                 int lastpathfindpoint4;
289                 bool onpath;
290                 
291                 int waypoint;
292                 bool jumppath;
293                 
294                 XYZ lastseen;
295                 float lastseentime;
296                 float lastchecktime;
297                 float stunned;
298                 float surprised;
299                 float runninghowlong;
300         int lastoccluded;
301                 int laststanding;
302                 int escapednum;
303                 
304                 float speechdelay;
305                 float neckspurtdelay;
306                 float neckspurtparticledelay;
307                 float neckspurtamount;
308                 
309                 int whichskin;
310                 bool rabbitkickragdoll;
311                 
312                 XYZ averageloc;
313                 XYZ oldaverageloc;
314                 
315                 Animation tempanimation;
316                 
317                 float occluded;
318                 
319                 bool jumpclimb;
320
321
322
323                 void CheckKick();
324                 void CatchFire();
325                 void DoBlood(float howmuch, int which);
326                 void DoBloodBig(float howmuch, int which);
327                 bool DoBloodBigWhere(float howmuch, int which, XYZ where);
328                 
329                 bool wasIdle() { return animation_bits[currentanimation] & ab_idle; }
330                 bool isIdle() { return animation_bits[targetanimation] & ab_idle; }
331                 int getIdle();
332                 
333                 bool isSitting() { return animation_bits[targetanimation] & ab_sit; }
334
335                 bool isSleeping() { return animation_bits[targetanimation] & ab_sleep; }
336
337                 bool wasCrouch() { return animation_bits[currentanimation] & ab_crouch; }
338                 bool isCrouch() { return animation_bits[targetanimation] & ab_crouch; }
339                 int getCrouch();
340                 
341                 bool wasStop() { return animation_bits[currentanimation] & ab_stop; }
342                 bool isStop() { return animation_bits[targetanimation] & ab_stop; }
343                 int getStop();
344                 
345                 bool wasSneak();
346                 bool isSneak();
347                 int getSneak();
348                 
349                 bool wasRun() { return animation_bits[currentanimation] & ab_run; }
350                 bool isRun() { return animation_bits[targetanimation] & ab_run; }
351                 int getRun();
352
353                 bool wasLanding() { return animation_bits[currentanimation] & ab_land; }
354                 bool isLanding() { return animation_bits[targetanimation] & ab_land; }
355                 int getLanding();
356
357                 bool wasLandhard() { return animation_bits[currentanimation] & ab_landhard; }
358                 bool isLandhard() { return animation_bits[targetanimation] & ab_landhard; }
359                 int getLandhard();
360
361                 bool wasFlip() { return animation_bits[currentanimation] & ab_flip; }
362                 bool isFlip() { return animation_bits[targetanimation] & ab_flip; }
363
364                 bool isWallJump() { return animation_bits[targetanimation] & ab_walljump; }
365                 void Reverse();
366                 void DoDamage(float howmuch);
367                 void DoHead();
368                 void DoMipmaps()
369                 {
370                   skeleton.drawmodel.textureptr.bind();
371           glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);
372                   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, skeleton.skinsize, skeleton.skinsize, 0, GL_RGB, GL_UNSIGNED_BYTE, &skeleton.skinText[0]);
373                 }
374
375                 int SphereCheck(XYZ *p1,float radius, XYZ *p, XYZ *move, float *rotate, Model *model);
376                 int DrawSkeleton();
377                 void Puff(int whichlabel);
378                 void FootLand(int which, float opacity);
379                 void DoStuff();
380                 Joint& getJointFor(int);
381                 void setAnimation(int);
382                 void DoAnimations();
383                 void RagDoll(bool checkcollision);
384 };
385
386 const int maxplayers = 10;
387 extern Person player[maxplayers];
388 #endif