Player.h 26 KB

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