]> icculus.org git repositories - icculus/iodoom3.git/blob - neo/d3xp/Player.h
Various Mac OS X tweaks to get this to build. Probably breaking things.
[icculus/iodoom3.git] / neo / d3xp / Player.h
1 /*
2 ===========================================================================
3
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company. 
6
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).  
8
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code.  If not, see <http://www.gnu.org/licenses/>.
21
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code.  If not, please request a copy in writing from id Software at the address below.
23
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25
26 ===========================================================================
27 */
28
29 #ifndef __GAME_PLAYER_H__
30 #define __GAME_PLAYER_H__
31
32 /*
33 ===============================================================================
34
35         Player entity.
36         
37 ===============================================================================
38 */
39
40 extern const idEventDef EV_Player_GetButtons;
41 extern const idEventDef EV_Player_GetMove;
42 extern const idEventDef EV_Player_GetViewAngles;
43 extern const idEventDef EV_Player_EnableWeapon;
44 extern const idEventDef EV_Player_DisableWeapon;
45 extern const idEventDef EV_Player_ExitTeleporter;
46 extern const idEventDef EV_Player_SelectWeapon;
47 extern const idEventDef EV_SpectatorTouch;
48
49 const float THIRD_PERSON_FOCUS_DISTANCE = 512.0f;
50 const int       LAND_DEFLECT_TIME = 150;
51 const int       LAND_RETURN_TIME = 300;
52 const int       FOCUS_TIME = 300;
53 const int       FOCUS_GUI_TIME = 500;
54
55 #ifdef _D3XP
56 const int MAX_WEAPONS = 32;
57 #else
58 const int MAX_WEAPONS = 16;
59 #endif
60
61 const int DEAD_HEARTRATE = 0;                   // fall to as you die
62 const int LOWHEALTH_HEARTRATE_ADJ = 20; // 
63 const int DYING_HEARTRATE = 30;                 // used for volumen calc when dying/dead
64 const int BASE_HEARTRATE = 70;                  // default
65 const int ZEROSTAMINA_HEARTRATE = 115;  // no stamina
66 const int MAX_HEARTRATE = 130;                  // maximum
67 const int ZERO_VOLUME = -40;                    // volume at zero
68 const int DMG_VOLUME = 5;                               // volume when taking damage
69 const int DEATH_VOLUME = 15;                    // volume at death
70
71 const int SAVING_THROW_TIME = 5000;             // maximum one "saving throw" every five seconds
72
73 const int ASYNC_PLAYER_INV_AMMO_BITS = idMath::BitsForInteger( 999 );   // 9 bits to cover the range [0, 999]
74 const int ASYNC_PLAYER_INV_CLIP_BITS = -7;                                                              // -7 bits to cover the range [-1, 60]
75
76 struct idItemInfo {
77         idStr name;
78         idStr icon;
79 };
80
81 struct idObjectiveInfo {
82         idStr title;
83         idStr text;
84         idStr screenshot;
85 };
86
87 struct idLevelTriggerInfo {
88         idStr levelName;
89         idStr triggerName;
90 };
91
92 // powerups - the "type" in item .def must match
93 enum {
94         BERSERK = 0, 
95         INVISIBILITY,
96         MEGAHEALTH,
97         ADRENALINE,
98 #ifdef _D3XP
99         INVULNERABILITY,
100         HELLTIME,
101         ENVIROSUIT,
102         //HASTE,
103         ENVIROTIME,
104 #endif
105         MAX_POWERUPS
106 };
107
108 // powerup modifiers
109 enum {
110         SPEED = 0,
111         PROJECTILE_DAMAGE,
112         MELEE_DAMAGE,
113         MELEE_DISTANCE
114 };
115
116 // influence levels
117 enum {
118         INFLUENCE_NONE = 0,                     // none
119         INFLUENCE_LEVEL1,                       // no gun or hud
120         INFLUENCE_LEVEL2,                       // no gun, hud, movement
121         INFLUENCE_LEVEL3,                       // slow player movement
122 };
123
124 #ifdef _D3XP
125 typedef struct {
126         int ammo;
127         int rechargeTime;
128         char ammoName[128];
129 } RechargeAmmo_t;
130
131 typedef struct {
132         char            name[64];
133         idList<int>     toggleList;
134 } WeaponToggle_t;
135 #endif
136
137 class idInventory {
138 public:
139         int                                             maxHealth;
140         int                                             weapons;
141         int                                             powerups;
142         int                                             armor;
143         int                                             maxarmor;
144         int                                             ammo[ AMMO_NUMTYPES ];
145         int                                             clip[ MAX_WEAPONS ];
146         int                                             powerupEndTime[ MAX_POWERUPS ];
147
148 #ifdef _D3XP
149         RechargeAmmo_t                  rechargeAmmo[ AMMO_NUMTYPES ];
150 #endif
151
152         // mp
153         int                                             ammoPredictTime;
154
155         int                                             deplete_armor;
156         float                                   deplete_rate;
157         int                                             deplete_ammount;
158         int                                             nextArmorDepleteTime;
159
160         int                                             pdasViewed[4]; // 128 bit flags for indicating if a pda has been viewed
161
162         int                                             selPDA;
163         int                                             selEMail;
164         int                                             selVideo;
165         int                                             selAudio;
166         bool                                    pdaOpened;
167         bool                                    turkeyScore;
168         idList<idDict *>                items;
169         idStrList                               pdas;
170         idStrList                               pdaSecurity;
171         idStrList                               videos;
172         idStrList                               emails;
173
174         bool                                    ammoPulse;
175         bool                                    weaponPulse;
176         bool                                    armorPulse;
177         int                                             lastGiveTime;
178
179         idList<idLevelTriggerInfo> levelTriggers;
180
181                                                         idInventory() { Clear(); }
182                                                         ~idInventory() { Clear(); }
183
184         // save games
185         void                                    Save( idSaveGame *savefile ) const;                                     // archives object for save game file
186         void                                    Restore( idRestoreGame *savefile );                                     // unarchives object from save game file
187
188         void                                    Clear( void );
189         void                                    GivePowerUp( idPlayer *player, int powerup, int msec );
190         void                                    ClearPowerUps( void );
191         void                                    GetPersistantData( idDict &dict );
192         void                                    RestoreInventory( idPlayer *owner, const idDict &dict );
193         bool                                    Give( idPlayer *owner, const idDict &spawnArgs, const char *statname, const char *value, int *idealWeapon, bool updateHud );
194         void                                    Drop( const idDict &spawnArgs, const char *weapon_classname, int weapon_index );
195         ammo_t                                  AmmoIndexForAmmoClass( const char *ammo_classname ) const;
196         int                                             MaxAmmoForAmmoClass( idPlayer *owner, const char *ammo_classname ) const;
197         int                                             WeaponIndexForAmmoClass( const idDict & spawnArgs, const char *ammo_classname ) const;
198         ammo_t                                  AmmoIndexForWeaponClass( const char *weapon_classname, int *ammoRequired );
199         const char *                    AmmoPickupNameForIndex( ammo_t ammonum ) const;
200         void                                    AddPickupName( const char *name, const char *icon, idPlayer* owner ); //_D3XP
201
202         int                                             HasAmmo( ammo_t type, int amount );
203         bool                                    UseAmmo( ammo_t type, int amount );
204         int                                             HasAmmo( const char *weapon_classname, bool includeClip = false, idPlayer* owner = NULL );                      // _D3XP
205
206 #ifdef _D3XP
207         bool                                    HasEmptyClipCannotRefill(const char *weapon_classname, idPlayer* owner);
208 #endif
209
210         void                                    UpdateArmor( void );
211
212         int                                             nextItemPickup;
213         int                                             nextItemNum;
214         int                                             onePickupTime;
215         idList<idItemInfo>              pickupItemNames;
216         idList<idObjectiveInfo> objectiveNames;
217
218 #ifdef _D3XP
219         void                                    InitRechargeAmmo(idPlayer *owner);
220         void                                    RechargeAmmo(idPlayer *owner);
221         bool                                    CanGive( idPlayer *owner, const idDict &spawnArgs, const char *statname, const char *value, int *idealWeapon );
222 #endif
223 };
224
225 typedef struct {
226         int             time;
227         idVec3  dir;            // scaled larger for running
228 } loggedAccel_t;
229
230 typedef struct {
231         int             areaNum;
232         idVec3  pos;
233 } aasLocation_t;
234
235 class idPlayer : public idActor {
236 public:
237         enum {
238                 EVENT_IMPULSE = idEntity::EVENT_MAXEVENTS,
239                 EVENT_EXIT_TELEPORTER,
240                 EVENT_ABORT_TELEPORTER,
241                 EVENT_POWERUP,
242                 EVENT_SPECTATE,
243 #ifdef _D3XP
244                 EVENT_PICKUPNAME,
245 #endif
246                 EVENT_MAXEVENTS
247         };
248
249         usercmd_t                               usercmd;
250
251         class idPlayerView              playerView;                     // handles damage kicks and effects
252
253         bool                                    noclip;
254         bool                                    godmode;
255
256         bool                                    spawnAnglesSet;         // on first usercmd, we must set deltaAngles
257         idAngles                                spawnAngles;
258         idAngles                                viewAngles;                     // player view angles
259         idAngles                                cmdAngles;                      // player cmd angles
260
261         int                                             buttonMask;
262         int                                             oldButtons;
263         int                                             oldFlags;
264
265         int                                             lastHitTime;                    // last time projectile fired by player hit target
266         int                                             lastSndHitTime;                 // MP hit sound - != lastHitTime because we throttle
267         int                                             lastSavingThrowTime;    // for the "free miss" effect
268
269         idScriptBool                    AI_FORWARD;
270         idScriptBool                    AI_BACKWARD;
271         idScriptBool                    AI_STRAFE_LEFT;
272         idScriptBool                    AI_STRAFE_RIGHT;
273         idScriptBool                    AI_ATTACK_HELD;
274         idScriptBool                    AI_WEAPON_FIRED;
275         idScriptBool                    AI_JUMP;
276         idScriptBool                    AI_CROUCH;
277         idScriptBool                    AI_ONGROUND;
278         idScriptBool                    AI_ONLADDER;
279         idScriptBool                    AI_DEAD;
280         idScriptBool                    AI_RUN;
281         idScriptBool                    AI_PAIN;
282         idScriptBool                    AI_HARDLANDING;
283         idScriptBool                    AI_SOFTLANDING;
284         idScriptBool                    AI_RELOAD;
285         idScriptBool                    AI_TELEPORT;
286         idScriptBool                    AI_TURN_LEFT;
287         idScriptBool                    AI_TURN_RIGHT;
288
289         // inventory
290         idInventory                             inventory;
291
292         idEntityPtr<idWeapon>   weapon;
293         idUserInterface *               hud;                            // MP: is NULL if not local player
294         idUserInterface *               objectiveSystem;
295         bool                                    objectiveSystemOpen;
296
297         int                                             weapon_soulcube;
298         int                                             weapon_pda;
299         int                                             weapon_fists;
300 #ifdef _D3XP
301         int                                             weapon_bloodstone;
302         int                                             weapon_bloodstone_active1;
303         int                                             weapon_bloodstone_active2;
304         int                                             weapon_bloodstone_active3;
305         bool                                    harvest_lock;
306 #endif
307
308         int                                             heartRate;
309         idInterpolate<float>    heartInfo;
310         int                                             lastHeartAdjust;
311         int                                             lastHeartBeat;
312         int                                             lastDmgTime;
313         int                                             deathClearContentsTime;
314         bool                                    doingDeathSkin;
315         int                                             lastArmorPulse;         // lastDmgTime if we had armor at time of hit
316         float                                   stamina;
317         float                                   healthPool;                     // amount of health to give over time
318         int                                             nextHealthPulse;
319         bool                                    healthPulse;
320         bool                                    healthTake;
321         int                                             nextHealthTake;
322
323
324         bool                                    hiddenWeapon;           // if the weapon is hidden ( in noWeapons maps )
325         idEntityPtr<idProjectile> soulCubeProjectile;
326
327         // mp stuff
328 #ifdef _D3XP
329         static idVec3                   colorBarTable[ 8 ];
330 #else
331         static idVec3                   colorBarTable[ 5 ];
332 #endif
333
334         int                                             spectator;
335         idVec3                                  colorBar;                       // used for scoreboard and hud display
336         int                                             colorBarIndex;
337         bool                                    scoreBoardOpen;
338         bool                                    forceScoreBoard;
339         bool                                    forceRespawn;
340         bool                                    spectating;
341         int                                             lastSpectateTeleport;
342         bool                                    lastHitToggle;
343         bool                                    forcedReady;
344         bool                                    wantSpectate;           // from userInfo
345         bool                                    weaponGone;                     // force stop firing
346         bool                                    useInitialSpawns;       // toggled by a map restart to be active for the first game spawn
347         int                                             latchedTeam;            // need to track when team gets changed
348         int                                             tourneyRank;            // for tourney cycling - the higher, the more likely to play next - server
349         int                                             tourneyLine;            // client side - our spot in the wait line. 0 means no info.
350         int                                             spawnedTime;            // when client first enters the game
351
352 #ifdef CTF    
353         bool                                    carryingFlag;           // is the player carrying the flag?
354 #endif    
355     
356         idEntityPtr<idEntity>   teleportEntity;         // while being teleported, this is set to the entity we'll use for exit
357         int                                             teleportKiller;         // entity number of an entity killing us at teleporter exit
358         bool                                    lastManOver;            // can't respawn in last man anymore (srv only)
359         bool                                    lastManPlayAgain;       // play again when end game delay is cancelled out before expiring (srv only)
360         bool                                    lastManPresent;         // true when player was in when game started (spectators can't join a running LMS)
361         bool                                    isLagged;                       // replicated from server, true if packets haven't been received from client.
362         bool                                    isChatting;                     // replicated from server, true if the player is chatting.
363
364         // timers
365         int                                             minRespawnTime;         // can respawn when time > this, force after g_forcerespawn
366         int                                             maxRespawnTime;         // force respawn after this time
367
368         // the first person view values are always calculated, even
369         // if a third person view is used
370         idVec3                                  firstPersonViewOrigin;
371         idMat3                                  firstPersonViewAxis;
372
373         idDragEntity                    dragEntity;
374
375 #ifdef _D3XP
376         idFuncMountedObject     *       mountedObject;
377         idEntityPtr<idLight>    enviroSuitLight;
378
379         bool                                    healthRecharge;
380         int                                             lastHealthRechargeTime;
381         int                                             rechargeSpeed;
382
383         float                                   new_g_damageScale;
384
385         bool                                    bloomEnabled;
386         float                                   bloomSpeed;
387         float                                   bloomIntensity;
388 #endif
389
390 public:
391         CLASS_PROTOTYPE( idPlayer );
392
393                                                         idPlayer();
394         virtual                                 ~idPlayer();
395
396         void                                    Spawn( void );
397         void                                    Think( void );
398
399         // save games
400         void                                    Save( idSaveGame *savefile ) const;                                     // archives object for save game file
401         void                                    Restore( idRestoreGame *savefile );                                     // unarchives object from save game file
402
403         virtual void                    Hide( void );
404         virtual void                    Show( void );
405
406         void                                    Init( void );
407         void                                    PrepareForRestart( void );
408         virtual void                    Restart( void );
409         void                                    LinkScriptVariables( void );
410         void                                    SetupWeaponEntity( void );
411         void                                    SelectInitialSpawnPoint( idVec3 &origin, idAngles &angles );
412         void                                    SpawnFromSpawnSpot( void );
413         void                                    SpawnToPoint( const idVec3      &spawn_origin, const idAngles &spawn_angles );
414         void                                    SetClipModel( void );   // spectator mode uses a different bbox size
415
416         void                                    SavePersistantInfo( void );
417         void                                    RestorePersistantInfo( void );
418         void                                    SetLevelTrigger( const char *levelName, const char *triggerName );
419
420         bool                                    UserInfoChanged( bool canModify );
421         idDict *                                GetUserInfo( void );
422         bool                                    BalanceTDM( void );
423
424         void                                    CacheWeapons( void );
425
426         void                                    EnterCinematic( void );
427         void                                    ExitCinematic( void );
428         bool                                    HandleESC( void );
429         bool                                    SkipCinematic( void );
430
431         void                                    UpdateConditions( void );
432         void                                    SetViewAngles( const idAngles &angles );
433
434                                                         // delta view angles to allow movers to rotate the view of the player
435         void                                    UpdateDeltaViewAngles( const idAngles &angles );
436
437         virtual bool                    Collide( const trace_t &collision, const idVec3 &velocity );
438
439         virtual void                    GetAASLocation( idAAS *aas, idVec3 &pos, int &areaNum ) const;
440         virtual void                    GetAIAimTargets( const idVec3 &lastSightPos, idVec3 &headPos, idVec3 &chestPos );
441         virtual void                    DamageFeedback( idEntity *victim, idEntity *inflictor, int &damage );
442         void                                    CalcDamagePoints(  idEntity *inflictor, idEntity *attacker, const idDict *damageDef,
443                                                            const float damageScale, const int location, int *health, int *armor );
444         virtual void                    Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
445
446                                                         // use exitEntityNum to specify a teleport with private camera view and delayed exit
447         virtual void                    Teleport( const idVec3 &origin, const idAngles &angles, idEntity *destination );
448
449         void                                    Kill( bool delayRespawn, bool nodamage );
450         virtual void                    Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
451         void                                    StartFxOnBone(const char *fx, const char *bone);
452
453         renderView_t *                  GetRenderView( void );
454         void                                    CalculateRenderView( void );    // called every tic by player code
455         void                                    CalculateFirstPersonView( void );
456
457         void                                    DrawHUD( idUserInterface *hud );
458
459         void                                    WeaponFireFeedback( const idDict *weaponDef );
460
461         float                                   DefaultFov( void ) const;
462         float                                   CalcFov( bool honorZoom );
463         void                                    CalculateViewWeaponPos( idVec3 &origin, idMat3 &axis );
464         idVec3                                  GetEyePosition( void ) const;
465         void                                    GetViewPos( idVec3 &origin, idMat3 &axis ) const;
466         void                                    OffsetThirdPersonView( float angle, float range, float height, bool clip );
467
468         bool                                    Give( const char *statname, const char *value );
469         bool                                    GiveItem( idItem *item );
470         void                                    GiveItem( const char *name );
471         void                                    GiveHealthPool( float amt );
472         
473         bool                                    GiveInventoryItem( idDict *item );
474         void                                    RemoveInventoryItem( idDict *item );
475         bool                                    GiveInventoryItem( const char *name );
476         void                                    RemoveInventoryItem( const char *name );
477         idDict *                                FindInventoryItem( const char *name );
478
479         void                                    GivePDA( const char *pdaName, idDict *item );
480         void                                    GiveVideo( const char *videoName, idDict *item );
481         void                                    GiveEmail( const char *emailName );
482         void                                    GiveSecurity( const char *security );
483         void                                    GiveObjective( const char *title, const char *text, const char *screenshot );
484         void                                    CompleteObjective( const char *title );
485
486         bool                                    GivePowerUp( int powerup, int time );
487         void                                    ClearPowerUps( void );
488         bool                                    PowerUpActive( int powerup ) const;
489         float                                   PowerUpModifier( int type );
490
491         int                                             SlotForWeapon( const char *weaponName );
492         void                                    Reload( void );
493         void                                    NextWeapon( void );
494         void                                    NextBestWeapon( void );
495         void                                    PrevWeapon( void );
496         void                                    SelectWeapon( int num, bool force );
497         void                                    DropWeapon( bool died ) ;
498         void                                    StealWeapon( idPlayer *player );
499         void                                    AddProjectilesFired( int count );
500         void                                    AddProjectileHits( int count );
501         void                                    SetLastHitTime( int time );
502         void                                    LowerWeapon( void );
503         void                                    RaiseWeapon( void );
504         void                                    WeaponLoweringCallback( void );
505         void                                    WeaponRisingCallback( void );
506         void                                    RemoveWeapon( const char *weap );
507         bool                                    CanShowWeaponViewmodel( void ) const;
508
509         void                                    AddAIKill( void );
510         void                                    SetSoulCubeProjectile( idProjectile *projectile );
511
512         void                                    AdjustHeartRate( int target, float timeInSecs, float delay, bool force );
513         void                                    SetCurrentHeartRate( void );
514         int                                             GetBaseHeartRate( void );
515         void                                    UpdateAir( void );
516
517 #ifdef _D3XP
518         void                                    UpdatePowerupHud();
519 #endif
520
521         virtual bool                    HandleSingleGuiCommand( idEntity *entityGui, idLexer *src );
522         bool                                    GuiActive( void ) { return focusGUIent != NULL; }
523
524         void                                    PerformImpulse( int impulse );
525         void                                    Spectate( bool spectate );
526         void                                    TogglePDA( void );
527         void                                    ToggleScoreboard( void );
528         void                                    RouteGuiMouse( idUserInterface *gui );
529         void                                    UpdateHud( void );
530         const idDeclPDA *               GetPDA( void ) const;
531         const idDeclVideo *             GetVideo( int index );
532         void                                    SetInfluenceFov( float fov );
533         void                                    SetInfluenceView( const char *mtr, const char *skinname, float radius, idEntity *ent );
534         void                                    SetInfluenceLevel( int level );
535         int                                             GetInfluenceLevel( void ) { return influenceActive; };
536         void                                    SetPrivateCameraView( idCamera *camView );
537         idCamera *                              GetPrivateCameraView( void ) const { return privateCameraView; }
538         void                                    StartFxFov( float duration  );
539         void                                    UpdateHudWeapon( bool flashWeapon = true );
540         void                                    UpdateHudStats( idUserInterface *hud );
541         void                                    UpdateHudAmmo( idUserInterface *hud );
542         void                                    Event_StopAudioLog( void );
543         void                                    StartAudioLog( void );
544         void                                    StopAudioLog( void );
545         void                                    ShowTip( const char *title, const char *tip, bool autoHide );
546         void                                    HideTip( void );
547         bool                                    IsTipVisible( void ) { return tipUp; };
548         void                                    ShowObjective( const char *obj );
549         void                                    HideObjective( void );
550
551         virtual void                    ClientPredictionThink( void );
552         virtual void                    WriteToSnapshot( idBitMsgDelta &msg ) const;
553         virtual void                    ReadFromSnapshot( const idBitMsgDelta &msg );
554         void                                    WritePlayerStateToSnapshot( idBitMsgDelta &msg ) const;
555         void                                    ReadPlayerStateFromSnapshot( const idBitMsgDelta &msg );
556
557         virtual bool                    ServerReceiveEvent( int event, int time, const idBitMsg &msg );
558
559         virtual bool                    GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis );
560         virtual bool                    GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
561
562         virtual bool                    ClientReceiveEvent( int event, int time, const idBitMsg &msg );
563         bool                                    IsReady( void );
564         bool                                    IsRespawning( void );
565         bool                                    IsInTeleport( void );
566
567         idEntity                                *GetInfluenceEntity( void ) { return influenceEntity; };
568         const idMaterial                *GetInfluenceMaterial( void ) { return influenceMaterial; };
569         float                                   GetInfluenceRadius( void ) { return influenceRadius; };
570
571         // server side work for in/out of spectate. takes care of spawning it into the world as well
572         void                                    ServerSpectate( bool spectate );
573         // for very specific usage. != GetPhysics()
574         idPhysics                               *GetPlayerPhysics( void );
575         void                                    TeleportDeath( int killer );
576         void                                    SetLeader( bool lead );
577         bool                                    IsLeader( void );
578
579         void                                    UpdateSkinSetup( bool restart );
580
581         bool                                    OnLadder( void ) const;
582
583         virtual void                    UpdatePlayerIcons( void );
584         virtual void                    DrawPlayerIcons( void );
585         virtual void                    HidePlayerIcons( void );
586         bool                                    NeedsIcon( void );
587
588 #ifdef _D3XP
589         void                                    StartHealthRecharge(int speed);
590         void                                    StopHealthRecharge();
591
592         idStr                                   GetCurrentWeapon();
593
594         bool                                    CanGive( const char *statname, const char *value );
595
596         void                                    StopHelltime( bool quick = true );
597         void                                    PlayHelltimeStopSound();
598 #endif
599
600 #ifdef CTF
601         void                                    DropFlag( void );       // drop CTF item
602         void                                    ReturnFlag();
603         virtual void                    FreeModelDef( void );
604 #endif
605
606         bool                                    SelfSmooth( void );
607         void                                    SetSelfSmooth( bool b );
608
609 private:
610         jointHandle_t                   hipJoint;
611         jointHandle_t                   chestJoint;
612         jointHandle_t                   headJoint;
613
614         idPhysics_Player                physicsObj;                     // player physics
615
616         idList<aasLocation_t>   aasLocation;            // for AI tracking the player
617
618         int                                             bobFoot;
619         float                                   bobFrac;
620         float                                   bobfracsin;
621         int                                             bobCycle;                       // for view bobbing and footstep generation
622         float                                   xyspeed;
623         int                                             stepUpTime;
624         float                                   stepUpDelta;
625         float                                   idealLegsYaw;
626         float                                   legsYaw;
627         bool                                    legsForward;
628         float                                   oldViewYaw;
629         idAngles                                viewBobAngles;
630         idVec3                                  viewBob;
631         int                                             landChange;
632         int                                             landTime;
633
634         int                                             currentWeapon;
635         int                                             idealWeapon;
636         int                                             previousWeapon;
637         int                                             weaponSwitchTime;
638         bool                                    weaponEnabled;
639         bool                                    showWeaponViewModel;
640
641         const idDeclSkin *              skin;
642         const idDeclSkin *              powerUpSkin;
643         idStr                                   baseSkinName;
644
645         int                                             numProjectilesFired;    // number of projectiles fired
646         int                                             numProjectileHits;              // number of hits on mobs
647
648         bool                                    airless;
649         int                                             airTics;                                // set to pm_airTics at start, drops in vacuum
650         int                                             lastAirDamage;
651
652         bool                                    gibDeath;
653         bool                                    gibsLaunched;
654         idVec3                                  gibsDir;
655
656         idInterpolate<float>    zoomFov;
657         idInterpolate<float>    centerView;
658         bool                                    fxFov;
659
660         float                                   influenceFov;
661         int                                             influenceActive;                // level of influence.. 1 == no gun or hud .. 2 == 1 + no movement
662         idEntity *                              influenceEntity;
663         const idMaterial *              influenceMaterial;
664         float                                   influenceRadius;
665         const idDeclSkin *              influenceSkin;
666
667         idCamera *                              privateCameraView;
668
669         static const int                NUM_LOGGED_VIEW_ANGLES = 64;            // for weapon turning angle offsets
670         idAngles                                loggedViewAngles[NUM_LOGGED_VIEW_ANGLES];       // [gameLocal.framenum&(LOGGED_VIEW_ANGLES-1)]
671         static const int                NUM_LOGGED_ACCELS = 16;                 // for weapon turning angle offsets
672         loggedAccel_t                   loggedAccel[NUM_LOGGED_ACCELS]; // [currentLoggedAccel & (NUM_LOGGED_ACCELS-1)]
673         int                                             currentLoggedAccel;
674
675         // if there is a focusGUIent, the attack button will be changed into mouse clicks
676         idEntity *                              focusGUIent;
677         idUserInterface *               focusUI;                                // focusGUIent->renderEntity.gui, gui2, or gui3
678         idAI *                                  focusCharacter;
679         int                                             talkCursor;                             // show the state of the focusCharacter (0 == can't talk/dead, 1 == ready to talk, 2 == busy talking)
680         int                                             focusTime;
681         idAFEntity_Vehicle *    focusVehicle;
682         idUserInterface *               cursor;
683         
684         // full screen guis track mouse movements directly
685         int                                             oldMouseX;
686         int                                             oldMouseY;
687
688         idStr                                   pdaAudio;
689         idStr                                   pdaVideo;
690         idStr                                   pdaVideoWave;
691
692         bool                                    tipUp;
693         bool                                    objectiveUp;
694
695         int                                             lastDamageDef;
696         idVec3                                  lastDamageDir;
697         int                                             lastDamageLocation;
698         int                                             smoothedFrame;
699         bool                                    smoothedOriginUpdated;
700         idVec3                                  smoothedOrigin;
701         idAngles                                smoothedAngles;
702
703 #ifdef _D3XP
704         idHashTable<WeaponToggle_t>     weaponToggles;
705
706         int                                             hudPowerup;
707         int                                             lastHudPowerup;
708         int                                             hudPowerupDuration;
709 #endif
710
711         // mp
712         bool                                    ready;                                  // from userInfo
713         bool                                    respawning;                             // set to true while in SpawnToPoint for telefrag checks
714         bool                                    leader;                                 // for sudden death situations
715         int                                             lastSpectateChange;
716         int                                             lastTeleFX;
717         unsigned int                    lastSnapshotSequence;   // track state hitches on clients
718         bool                                    weaponCatchup;                  // raise up the weapon silently ( state catchups )
719         int                                             MPAim;                                  // player num in aim
720         int                                             lastMPAim;
721         int                                             lastMPAimTime;                  // last time the aim changed
722         int                                             MPAimFadeTime;                  // for GUI fade
723         bool                                    MPAimHighlight;
724         bool                                    isTelefragged;                  // proper obituaries
725
726         idPlayerIcon                    playerIcon;
727
728         bool                                    selfSmooth;
729
730         void                                    LookAtKiller( idEntity *inflictor, idEntity *attacker );
731
732         void                                    StopFiring( void );
733         void                                    FireWeapon( void );
734         void                                    Weapon_Combat( void );
735         void                                    Weapon_NPC( void );
736         void                                    Weapon_GUI( void );
737         void                                    UpdateWeapon( void );
738         void                                    UpdateSpectating( void );
739         void                                    SpectateFreeFly( bool force );  // ignore the timeout to force when followed spec is no longer valid
740         void                                    SpectateCycle( void );
741         idAngles                                GunTurningOffset( void );
742         idVec3                                  GunAcceleratingOffset( void );
743
744         void                                    UseObjects( void );
745         void                                    CrashLand( const idVec3 &oldOrigin, const idVec3 &oldVelocity );
746         void                                    BobCycle( const idVec3 &pushVelocity );
747         void                                    UpdateViewAngles( void );
748         void                                    EvaluateControls( void );
749         void                                    AdjustSpeed( void );
750         void                                    AdjustBodyAngles( void );
751         void                                    InitAASLocation( void );
752         void                                    SetAASLocation( void );
753         void                                    Move( void );
754         void                                    UpdatePowerUps( void );
755         void                                    UpdateDeathSkin( bool state_hitch );
756         void                                    ClearPowerup( int i );
757         void                                    SetSpectateOrigin( void );
758
759         void                                    ClearFocus( void );
760         void                                    UpdateFocus( void );
761         void                                    UpdateLocation( void );
762         idUserInterface *               ActiveGui( void );
763         void                                    UpdatePDAInfo( bool updatePDASel );
764         int                                             AddGuiPDAData( const declType_t dataType, const char *listName, const idDeclPDA *src, idUserInterface *gui );
765         void                                    ExtractEmailInfo( const idStr &email, const char *scan, idStr &out );
766         void                                    UpdateObjectiveInfo( void );
767
768 #ifdef _D3XP
769         bool                                    WeaponAvailable( const char* name );
770 #endif
771
772         void                                    UseVehicle( void );
773
774         void                                    Event_GetButtons( void );
775         void                                    Event_GetMove( void );
776         void                                    Event_GetViewAngles( void );
777         void                                    Event_StopFxFov( void );
778         void                                    Event_EnableWeapon( void );
779         void                                    Event_DisableWeapon( void );
780         void                                    Event_GetCurrentWeapon( void );
781         void                                    Event_GetPreviousWeapon( void );
782         void                                    Event_SelectWeapon( const char *weaponName );
783         void                                    Event_GetWeaponEntity( void );
784         void                                    Event_OpenPDA( void );
785         void                                    Event_PDAAvailable( void );
786         void                                    Event_InPDA( void );
787         void                                    Event_ExitTeleporter( void );
788         void                                    Event_HideTip( void );
789         void                                    Event_LevelTrigger( void );
790         void                                    Event_Gibbed( void );
791
792 #ifdef _D3XP //BSM: Event to remove inventory items. Useful with powercells.
793         void                                    Event_GiveInventoryItem( const char* name );
794         void                                    Event_RemoveInventoryItem( const char* name );
795
796         void                                    Event_GetIdealWeapon( void );
797         void                                    Event_WeaponAvailable( const char* name );
798         void                                    Event_SetPowerupTime( int powerup, int time );
799         void                                    Event_IsPowerupActive( int powerup );
800         void                                    Event_StartWarp();
801         void                                    Event_StopHelltime( int mode );
802         void                                    Event_ToggleBloom( int on );
803         void                                    Event_SetBloomParms( float speed, float intensity );
804 #endif
805 };
806
807 ID_INLINE bool idPlayer::IsReady( void ) {
808         return ready || forcedReady;
809 }
810
811 ID_INLINE bool idPlayer::IsRespawning( void ) {
812         return respawning;
813 }
814
815 ID_INLINE idPhysics* idPlayer::GetPlayerPhysics( void ) {
816         return &physicsObj;
817 }
818
819 ID_INLINE bool idPlayer::IsInTeleport( void ) {
820         return ( teleportEntity.GetEntity() != NULL );
821 }
822
823 ID_INLINE void idPlayer::SetLeader( bool lead ) {
824         leader = lead;
825 }
826
827 ID_INLINE bool idPlayer::IsLeader( void ) {
828         return leader;
829 }
830
831 ID_INLINE bool idPlayer::SelfSmooth( void ) {
832         return selfSmooth;
833 }
834
835 ID_INLINE void idPlayer::SetSelfSmooth( bool b ) {
836         selfSmooth = b;
837 }
838
839 #endif /* !__GAME_PLAYER_H__ */
840