Player.h 24 KB

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