Player.h 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093
  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. void SetAmmo( ammo_t type, int amount );
  168. #ifdef _D3XP
  169. bool HasEmptyClipCannotRefill(const char *weapon_classname, idPlayer* owner);
  170. #endif
  171. void UpdateArmor( void );
  172. int nextItemPickup;
  173. int nextItemNum;
  174. int onePickupTime;
  175. idList<idItemInfo> pickupItemNames;
  176. idList<idObjectiveInfo> objectiveNames;
  177. #ifdef _D3XP
  178. void InitRechargeAmmo(idPlayer *owner);
  179. void RechargeAmmo(idPlayer *owner);
  180. bool CanGive( idPlayer *owner, const idDict &spawnArgs, const char *statname, const char *value, int *idealWeapon );
  181. #endif
  182. };
  183. typedef struct {
  184. int time;
  185. idVec3 dir; // scaled larger for running
  186. } loggedAccel_t;
  187. typedef struct {
  188. int areaNum;
  189. idVec3 pos;
  190. } aasLocation_t;
  191. class idPlayer : public idActor {
  192. public:
  193. enum {
  194. EVENT_IMPULSE = idEntity::EVENT_MAXEVENTS,
  195. EVENT_EXIT_TELEPORTER,
  196. EVENT_ABORT_TELEPORTER,
  197. EVENT_POWERUP,
  198. EVENT_SPECTATE,
  199. #ifdef _D3XP
  200. EVENT_PICKUPNAME,
  201. #endif
  202. EVENT_MAXEVENTS
  203. };
  204. usercmd_t usercmd;
  205. class idPlayerView playerView; // handles damage kicks and effects
  206. bool noclip;
  207. bool godmode;
  208. bool spawnAnglesSet; // on first usercmd, we must set deltaAngles
  209. idAngles spawnAngles;
  210. idAngles viewAngles; // player view angles
  211. idAngles cmdAngles; // player cmd angles
  212. int buttonMask;
  213. int oldButtons;
  214. int oldFlags;
  215. int lastHitTime; // last time projectile fired by player hit target
  216. int lastSndHitTime; // MP hit sound - != lastHitTime because we throttle
  217. int lastSavingThrowTime; // for the "free miss" effect
  218. idScriptBool AI_FORWARD;
  219. idScriptBool AI_BACKWARD;
  220. idScriptBool AI_STRAFE_LEFT;
  221. idScriptBool AI_STRAFE_RIGHT;
  222. idScriptBool AI_ATTACK_HELD;
  223. idScriptBool AI_WEAPON_FIRED;
  224. idScriptBool AI_JUMP;
  225. idScriptBool AI_CROUCH;
  226. idScriptBool AI_ONGROUND;
  227. idScriptBool AI_ONLADDER;
  228. idScriptBool AI_DEAD;
  229. idScriptBool AI_RUN;
  230. idScriptBool AI_PAIN;
  231. idScriptBool AI_HARDLANDING;
  232. idScriptBool AI_SOFTLANDING;
  233. idScriptBool AI_RELOAD;
  234. idScriptBool AI_TELEPORT;
  235. idScriptBool AI_TURN_LEFT;
  236. idScriptBool AI_TURN_RIGHT;
  237. idScriptBool AI_CLAMBER;
  238. // inventory
  239. idInventory inventory;
  240. idEntityPtr<idWeapon> weapon;
  241. idUserInterface * hud; // MP: is NULL if not local player
  242. idUserInterface * objectiveSystem;
  243. bool objectiveSystemOpen;
  244. int weapon_soulcube;
  245. int weapon_pda;
  246. int weapon_fists;
  247. #ifdef _D3XP
  248. int weapon_bloodstone;
  249. int weapon_bloodstone_active1;
  250. int weapon_bloodstone_active2;
  251. int weapon_bloodstone_active3;
  252. bool harvest_lock;
  253. #endif
  254. int heartRate;
  255. idInterpolate<float> heartInfo;
  256. int lastHeartAdjust;
  257. int lastHeartBeat;
  258. int lastDmgTime;
  259. int deathClearContentsTime;
  260. bool doingDeathSkin;
  261. int lastArmorPulse; // lastDmgTime if we had armor at time of hit
  262. float stamina;
  263. float healthPool; // amount of health to give over time
  264. int nextHealthPulse;
  265. bool healthPulse;
  266. bool healthTake;
  267. int nextHealthTake;
  268. bool hiddenWeapon; // if the weapon is hidden ( in noWeapons maps )
  269. idEntityPtr<idProjectile> soulCubeProjectile;
  270. // mp stuff
  271. #ifdef _D3XP
  272. static idVec3 colorBarTable[ 8 ];
  273. #else
  274. static idVec3 colorBarTable[ 5 ];
  275. #endif
  276. int spectator;
  277. idVec3 colorBar; // used for scoreboard and hud display
  278. int colorBarIndex;
  279. bool scoreBoardOpen;
  280. bool forceScoreBoard;
  281. bool forceRespawn;
  282. bool spectating;
  283. int lastSpectateTeleport;
  284. bool lastHitToggle;
  285. bool forcedReady;
  286. bool wantSpectate; // from userInfo
  287. bool weaponGone; // force stop firing
  288. bool useInitialSpawns; // toggled by a map restart to be active for the first game spawn
  289. int latchedTeam; // need to track when team gets changed
  290. int tourneyRank; // for tourney cycling - the higher, the more likely to play next - server
  291. int tourneyLine; // client side - our spot in the wait line. 0 means no info.
  292. int spawnedTime; // when client first enters the game
  293. #ifdef CTF
  294. bool carryingFlag; // is the player carrying the flag?
  295. #endif
  296. idEntityPtr<idEntity> teleportEntity; // while being teleported, this is set to the entity we'll use for exit
  297. int teleportKiller; // entity number of an entity killing us at teleporter exit
  298. bool lastManOver; // can't respawn in last man anymore (srv only)
  299. bool lastManPlayAgain; // play again when end game delay is cancelled out before expiring (srv only)
  300. bool lastManPresent; // true when player was in when game started (spectators can't join a running LMS)
  301. bool isLagged; // replicated from server, true if packets haven't been received from client.
  302. bool isChatting; // replicated from server, true if the player is chatting.
  303. // timers
  304. int minRespawnTime; // can respawn when time > this, force after g_forcerespawn
  305. int maxRespawnTime; // force respawn after this time
  306. // the first person view values are always calculated, even
  307. // if a third person view is used
  308. idVec3 firstPersonViewOrigin;
  309. idMat3 firstPersonViewAxis;
  310. idDragEntity dragEntity;
  311. #ifdef _D3XP
  312. idFuncMountedObject * mountedObject;
  313. idEntityPtr<idLight> enviroSuitLight;
  314. bool healthRecharge;
  315. int lastHealthRechargeTime;
  316. int rechargeSpeed;
  317. float new_g_damageScale;
  318. bool bloomEnabled;
  319. float bloomSpeed;
  320. float bloomIntensity;
  321. //int hazeStartTime;
  322. //int hazeEndTime;
  323. //bool hazeActive;
  324. #endif
  325. public:
  326. CLASS_PROTOTYPE( idPlayer );
  327. idPlayer();
  328. virtual ~idPlayer();
  329. void Spawn( void );
  330. void Think( void );
  331. // save games
  332. void Save( idSaveGame *savefile ) const; // archives object for save game file
  333. void Restore( idRestoreGame *savefile ); // unarchives object from save game file
  334. virtual void Hide( void );
  335. virtual void Show( void );
  336. void Init( void );
  337. void PrepareForRestart( void );
  338. virtual void Restart( void );
  339. void LinkScriptVariables( void );
  340. void SetupWeaponEntity( void );
  341. void SelectInitialSpawnPoint( idVec3 &origin, idAngles &angles );
  342. void SpawnFromSpawnSpot( void );
  343. void SpawnToPoint( const idVec3 &spawn_origin, const idAngles &spawn_angles );
  344. void SetClipModel( void ); // spectator mode uses a different bbox size
  345. void SavePersistantInfo( void );
  346. void RestorePersistantInfo( void );
  347. void SetLevelTrigger( const char *levelName, const char *triggerName );
  348. bool UserInfoChanged( bool canModify );
  349. idDict * GetUserInfo( void );
  350. bool BalanceTDM( void );
  351. void CacheWeapons( void );
  352. void EnterCinematic( void );
  353. void ExitCinematic( void );
  354. bool HandleESC( void );
  355. bool SkipCinematic( void );
  356. void UpdateConditions( void );
  357. void SetViewAngles( const idAngles &angles );
  358. void Event_lerpviewangle( const idVec3 &pos, int movetime );
  359. // delta view angles to allow movers to rotate the view of the player
  360. void UpdateDeltaViewAngles( const idAngles &angles );
  361. virtual bool Collide( const trace_t &collision, const idVec3 &velocity );
  362. virtual void GetAASLocation( idAAS *aas, idVec3 &pos, int &areaNum ) const;
  363. virtual void GetAIAimTargets( const idVec3 &lastSightPos, idVec3 &headPos, idVec3 &chestPos );
  364. virtual void DamageFeedback( idEntity *victim, idEntity *inflictor, int &damage );
  365. void CalcDamagePoints( idEntity *inflictor, idEntity *attacker, const idDict *damageDef,
  366. const float damageScale, const int location, int *health, int *armor );
  367. virtual void Damage( idEntity *inflictor, idEntity *attacker, const idVec3 &dir, const char *damageDefName, const float damageScale, const int location );
  368. // use exitEntityNum to specify a teleport with private camera view and delayed exit
  369. virtual void Teleport( const idVec3 &origin, const idAngles &angles, idEntity *destination );
  370. void Kill( bool delayRespawn, bool nodamage );
  371. virtual void Killed( idEntity *inflictor, idEntity *attacker, int damage, const idVec3 &dir, int location );
  372. void StartFxOnBone(const char *fx, const char *bone);
  373. renderView_t * GetRenderView( void );
  374. void CalculateRenderView( void ); // called every tic by player code
  375. void CalculateFirstPersonView( void );
  376. void DrawHUD( idUserInterface *hud );
  377. void WeaponFireFeedback( const idDict *weaponDef );
  378. float DefaultFov( void ) const;
  379. float CalcFov( bool honorZoom );
  380. void CalculateViewWeaponPos( idVec3 &origin, idMat3 &axis );
  381. idVec3 GetEyePosition( void ) const;
  382. void GetViewPos( idVec3 &origin, idMat3 &axis ) const;
  383. void OffsetThirdPersonView( float angle, float range, float height, bool clip );
  384. bool Give( const char *statname, const char *value );
  385. bool GiveItem( idItem *item );
  386. void GiveItem( const char *name );
  387. void GiveHealthPool( float amt );
  388. //bc PUBLIC
  389. bool RemoveWeaponItem( const char *name );
  390. int GetWeaponByIndex( const char *name );
  391. void UseDeck( idEntity *target, idEntity *master );
  392. idUserInterface * deckGui;
  393. idEntityPtr<idEntity> deckEnt;
  394. idEntityPtr<idEntity> deckMaster;
  395. idListGUI * deckList;
  396. idEntityPtr<idEntity> deckScript;
  397. bool inDeck;
  398. void DebugMessage( const char *text );
  399. void StopClamber( void );
  400. int pickerState;
  401. idPicker pickerWeapon;
  402. idStr text_objective;
  403. int text_alarms;
  404. float text_missionclock;
  405. idEntityPtr<idEntity> launcherEnt;
  406. int attackTimer;
  407. bool attackHeld;
  408. idVec3 lastTracePos;
  409. bool DoFrob( idEntity *frobbee );
  410. idVec3 popcornPosition;
  411. int lastMoveTime; //for the demo time-out.
  412. idEntity * focusFrobEnt;
  413. void Event_setviewangle(idVec3 const &ang);
  414. void Event_viewlook( idVec3 const &org, float time, int backwards, int stayLocked );
  415. void Event_pressEnter( void );
  416. void Event_setFrozen( int value );
  417. void Event_ToggleBloom( int on );
  418. void Event_SetBloomParms( float speed, float intensity );
  419. void Event_ToggleHaze(int time, float value);
  420. bool isCasing;
  421. bool IsTourist();
  422. idUserInterface * commentaryScreen;
  423. bool toggleCommentary( int value, idStr text );
  424. bool commentaryActive;
  425. int nextCommentaryTime;
  426. bool commentaryMode;
  427. idListGUI * topfriendnameList;
  428. idListGUI * topfriendtimeList;
  429. float deckCurLerp;
  430. int deckLookLerp;
  431. float GetLookLerp(float value, float movetime);
  432. idAngles deckInitialViewAngles;
  433. idAngles deckFinalViewAngles;
  434. idVec3 deckInitialPosition;
  435. float viewlookMoveTime;
  436. float viewlookLerp;
  437. float viewlookCurLerp;
  438. idVec3 viewlookInitialPosition;
  439. idVec3 viewlookFinalPosition;
  440. bool viewlookActive;
  441. bool viewlookLocked;
  442. idAngles lerpviewInitialPosition;
  443. idAngles lerpviewFinalPosition;
  444. bool lerpviewActive;
  445. int lerpviewStarttime;
  446. int lerpviewEndtime;
  447. bool UnstickPlayer( void );
  448. void ExitDeck( bool forced );
  449. bool stickynotePending;
  450. //bc end public.
  451. bool GiveInventoryItem( idDict *item );
  452. void RemoveInventoryItem( idDict *item );
  453. bool GiveInventoryItem( const char *name );
  454. void RemoveInventoryItem( const char *name );
  455. idDict * FindInventoryItem( const char *name );
  456. void GivePDA( const char *pdaName, idDict *item );
  457. void GiveVideo( const char *videoName, idDict *item );
  458. void GiveEmail( const char *emailName );
  459. void GiveSecurity( const char *security );
  460. void GiveObjective( const char *title, const char *text, const char *screenshot );
  461. void CompleteObjective( const char *title );
  462. bool GivePowerUp( int powerup, int time );
  463. void ClearPowerUps( void );
  464. bool PowerUpActive( int powerup ) const;
  465. float PowerUpModifier( int type );
  466. int SlotForWeapon( const char *weaponName );
  467. void Reload( void );
  468. void NextWeapon( void );
  469. void NextBestWeapon( void );
  470. void PrevWeapon( void );
  471. void SelectWeapon( int num, bool force );
  472. void DropWeapon( bool died ) ;
  473. void StealWeapon( idPlayer *player );
  474. void AddProjectilesFired( int count );
  475. void AddProjectileHits( int count );
  476. void SetLastHitTime( int time );
  477. void LowerWeapon( void );
  478. void RaiseWeapon( void );
  479. void WeaponLoweringCallback( void );
  480. void WeaponRisingCallback( void );
  481. void RemoveWeapon( const char *weap );
  482. bool CanShowWeaponViewmodel( void ) const;
  483. void AddAIKill( void );
  484. void SetSoulCubeProjectile( idProjectile *projectile );
  485. void AdjustHeartRate( int target, float timeInSecs, float delay, bool force );
  486. void SetCurrentHeartRate( void );
  487. int GetBaseHeartRate( void );
  488. void UpdateAir( void );
  489. #ifdef _D3XP
  490. void UpdatePowerupHud();
  491. #endif
  492. virtual bool HandleSingleGuiCommand( idEntity *entityGui, idLexer *src );
  493. bool GuiActive( void ) { return focusGUIent != NULL; }
  494. void PerformImpulse( int impulse );
  495. void Spectate( bool spectate );
  496. void TogglePDA( void );
  497. void ToggleScoreboard( void );
  498. void RouteGuiMouse( idUserInterface *gui );
  499. void UpdateHud( void );
  500. const idDeclPDA * GetPDA( void ) const;
  501. const idDeclVideo * GetVideo( int index );
  502. void SetInfluenceFov( float fov );
  503. void SetInfluenceView( const char *mtr, const char *skinname, float radius, idEntity *ent );
  504. void SetInfluenceLevel( int level );
  505. int GetInfluenceLevel( void ) { return influenceActive; };
  506. void SetPrivateCameraView( idCamera *camView );
  507. idCamera * GetPrivateCameraView( void ) const { return privateCameraView; }
  508. void StartFxFov( float duration );
  509. void UpdateHudWeapon( bool flashWeapon = true );
  510. void UpdateHudStats( idUserInterface *hud );
  511. void UpdateHudAmmo( idUserInterface *hud );
  512. void Event_StopAudioLog( void );
  513. void StartAudioLog( void );
  514. void StopAudioLog( void );
  515. void ShowTip( const char *title, const char *tip, bool autoHide );
  516. void HideTip( void );
  517. bool IsTipVisible( void ) { return tipUp; };
  518. void ShowObjective( const char *obj );
  519. void HideObjective( void );
  520. virtual void ClientPredictionThink( void );
  521. virtual void WriteToSnapshot( idBitMsgDelta &msg ) const;
  522. virtual void ReadFromSnapshot( const idBitMsgDelta &msg );
  523. void WritePlayerStateToSnapshot( idBitMsgDelta &msg ) const;
  524. void ReadPlayerStateFromSnapshot( const idBitMsgDelta &msg );
  525. virtual bool ServerReceiveEvent( int event, int time, const idBitMsg &msg );
  526. virtual bool GetPhysicsToVisualTransform( idVec3 &origin, idMat3 &axis );
  527. virtual bool GetPhysicsToSoundTransform( idVec3 &origin, idMat3 &axis );
  528. virtual bool ClientReceiveEvent( int event, int time, const idBitMsg &msg );
  529. bool IsReady( void );
  530. bool IsRespawning( void );
  531. bool IsInTeleport( void );
  532. idEntity *GetInfluenceEntity( void ) { return influenceEntity; };
  533. const idMaterial *GetInfluenceMaterial( void ) { return influenceMaterial; };
  534. float GetInfluenceRadius( void ) { return influenceRadius; };
  535. // server side work for in/out of spectate. takes care of spawning it into the world as well
  536. void ServerSpectate( bool spectate );
  537. // for very specific usage. != GetPhysics()
  538. idPhysics *GetPlayerPhysics( void );
  539. void TeleportDeath( int killer );
  540. void SetLeader( bool lead );
  541. bool IsLeader( void );
  542. void UpdateSkinSetup( bool restart );
  543. bool OnLadder( void ) const;
  544. virtual void UpdatePlayerIcons( void );
  545. virtual void DrawPlayerIcons( void );
  546. virtual void HidePlayerIcons( void );
  547. bool NeedsIcon( void );
  548. #ifdef _D3XP
  549. void StartHealthRecharge(int speed);
  550. void StopHealthRecharge();
  551. idStr GetCurrentWeapon();
  552. bool CanGive( const char *statname, const char *value );
  553. void StopHelltime( bool quick = true );
  554. void PlayHelltimeStopSound();
  555. #endif
  556. #ifdef CTF
  557. void DropFlag( void ); // drop CTF item
  558. void ReturnFlag();
  559. virtual void FreeModelDef( void );
  560. #endif
  561. bool SelfSmooth( void );
  562. void SetSelfSmooth( bool b );
  563. //bc public.
  564. bool UseFrob( idEntity *entity, const char *scriptname );
  565. void Event_hudMessage( const char *message );
  566. void Event_usePicker( idEntity *ent );
  567. bool Event_isHolding( idEntity *ent );
  568. int Event_getAmmo( const char *ammoname );
  569. bool Event_useAmmo( const char *ammoname, int value );
  570. void Event_setAmmo( const char *ammoname, int value );
  571. void Event_writesticky( int value );
  572. void Event_setcasing( int value );
  573. void Event_setplayerskin( const char *skinname );
  574. bool Event_hasWeapon( const char* name );
  575. void ClearPowerup( int i );
  576. bool pickerHeld;
  577. idPhysics_Player physicsObj; // player physics
  578. void Event_setgodmode( int value );
  579. void Event_sethipclock( int value );
  580. bool Event_isInFOV( idVec3 const &position );
  581. void Event_killDeckthreads( void );
  582. void Event_forcestand( void );
  583. void Event_forcegui( const char *flag, int value );
  584. void Event_setCanFrob(int value);
  585. private:
  586. jointHandle_t hipJoint;
  587. jointHandle_t chestJoint;
  588. jointHandle_t headJoint;
  589. idList<aasLocation_t> aasLocation; // for AI tracking the player
  590. int bobFoot;
  591. float bobFrac;
  592. float bobfracsin;
  593. int bobCycle; // for view bobbing and footstep generation
  594. float xyspeed;
  595. int stepUpTime;
  596. float stepUpDelta;
  597. float idealLegsYaw;
  598. float legsYaw;
  599. bool legsForward;
  600. float oldViewYaw;
  601. idAngles viewBobAngles;
  602. idVec3 viewBob;
  603. int landChange;
  604. int landTime;
  605. int currentWeapon;
  606. int idealWeapon;
  607. int previousWeapon;
  608. int weaponSwitchTime;
  609. bool weaponEnabled;
  610. bool showWeaponViewModel;
  611. const idDeclSkin * skin;
  612. const idDeclSkin * powerUpSkin;
  613. idStr baseSkinName;
  614. const idDeclSkin * customskin;
  615. int numProjectilesFired; // number of projectiles fired
  616. int numProjectileHits; // number of hits on mobs
  617. bool airless;
  618. int airTics; // set to pm_airTics at start, drops in vacuum
  619. int lastAirDamage;
  620. bool gibDeath;
  621. bool gibsLaunched;
  622. idVec3 gibsDir;
  623. idInterpolate<float> zoomFov;
  624. idInterpolate<float> centerView;
  625. bool fxFov;
  626. float influenceFov;
  627. int influenceActive; // level of influence.. 1 == no gun or hud .. 2 == 1 + no movement
  628. idEntity * influenceEntity;
  629. const idMaterial * influenceMaterial;
  630. float influenceRadius;
  631. const idDeclSkin * influenceSkin;
  632. idCamera * privateCameraView;
  633. static const int NUM_LOGGED_VIEW_ANGLES = 64; // for weapon turning angle offsets
  634. idAngles loggedViewAngles[NUM_LOGGED_VIEW_ANGLES]; // [gameLocal.framenum&(LOGGED_VIEW_ANGLES-1)]
  635. static const int NUM_LOGGED_ACCELS = 16; // for weapon turning angle offsets
  636. loggedAccel_t loggedAccel[NUM_LOGGED_ACCELS]; // [currentLoggedAccel & (NUM_LOGGED_ACCELS-1)]
  637. int currentLoggedAccel;
  638. // if there is a focusGUIent, the attack button will be changed into mouse clicks
  639. idEntity * focusGUIent;
  640. idUserInterface * focusUI; // focusGUIent->renderEntity.gui, gui2, or gui3
  641. idAI * focusCharacter;
  642. int talkCursor; // show the state of the focusCharacter (0 == can't talk/dead, 1 == ready to talk, 2 == busy talking)
  643. int focusTime;
  644. idAFEntity_Vehicle * focusVehicle;
  645. idUserInterface * cursor;
  646. //bc private.
  647. int placerAngleIndex;
  648. idStr launcherName;
  649. void launcherAssign( void );
  650. bool wasOnLadder;
  651. bool pressedRemoteButton;
  652. int zoomCurrentFOV;
  653. int lastPopcornTime;
  654. void RevivePlayer();
  655. idAngles lastViewAngles; //for the demo time-out.
  656. idUserInterface * stickygui;
  657. // full screen guis track mouse movements directly
  658. int oldMouseX;
  659. int oldMouseY;
  660. idStr pdaAudio;
  661. idStr pdaVideo;
  662. idStr pdaVideoWave;
  663. int photosTaken;
  664. int photosMax;
  665. void snapPhoto( void );
  666. int getBestCameraPoint( void );
  667. void UpdatePhotoStatus( void );
  668. idAnimatedEntity * hipclock;
  669. int nextPlayerDeathlookTime;
  670. bool hipclockActive;
  671. int GetWeaponsAvailable( void );
  672. bool showingMap;
  673. bool writingStickynote;
  674. bool canFrob;
  675. int nextStickynoteTime;
  676. bool tipUp;
  677. bool objectiveUp;
  678. int lastDamageDef;
  679. idVec3 lastDamageDir;
  680. int lastDamageLocation;
  681. int smoothedFrame;
  682. bool smoothedOriginUpdated;
  683. idVec3 smoothedOrigin;
  684. idAngles smoothedAngles;
  685. #ifdef _D3XP
  686. idHashTable<WeaponToggle_t> weaponToggles;
  687. int hudPowerup;
  688. int lastHudPowerup;
  689. int hudPowerupDuration;
  690. #endif
  691. // mp
  692. bool ready; // from userInfo
  693. bool respawning; // set to true while in SpawnToPoint for telefrag checks
  694. bool leader; // for sudden death situations
  695. int lastSpectateChange;
  696. int lastTeleFX;
  697. unsigned int lastSnapshotSequence; // track state hitches on clients
  698. bool weaponCatchup; // raise up the weapon silently ( state catchups )
  699. int MPAim; // player num in aim
  700. int lastMPAim;
  701. int lastMPAimTime; // last time the aim changed
  702. int MPAimFadeTime; // for GUI fade
  703. bool MPAimHighlight;
  704. bool isTelefragged; // proper obituaries
  705. idPlayerIcon playerIcon;
  706. bool selfSmooth;
  707. void LookAtKiller( idEntity *inflictor, idEntity *attacker );
  708. void StopFiring( void );
  709. void FireWeapon( void );
  710. void Weapon_Combat( void );
  711. void Weapon_NPC( void );
  712. void Weapon_GUI( void );
  713. void UpdateWeapon( void );
  714. void UpdateSpectating( void );
  715. void SpectateFreeFly( bool force ); // ignore the timeout to force when followed spec is no longer valid
  716. void SpectateCycle( void );
  717. idAngles GunTurningOffset( void );
  718. idVec3 GunAcceleratingOffset( void );
  719. //bc private
  720. void UpdateFrob( void );
  721. void UpdatePlacer( void );
  722. void UpdatePlacerGround( void );
  723. void UpdatePlacerSticky( void );
  724. bool MakeStickymap( void );
  725. void UpdateCaserCamera( void );
  726. void UpdateHipclock( void );
  727. bool UpdateStickyRemoval( void );
  728. idEntity *placerEnt;
  729. idEntity *placerGhost;
  730. bool placerClearance;
  731. idVec3 placerFloatPos;
  732. bool CheckPlacerBoundCheck(idVec3 endPos);
  733. void UseObjects( void );
  734. void CrashLand( const idVec3 &oldOrigin, const idVec3 &oldVelocity );
  735. void BobCycle( const idVec3 &pushVelocity );
  736. void UpdateViewAngles( void );
  737. void EvaluateControls( void );
  738. void AdjustSpeed( void );
  739. void AdjustBodyAngles( void );
  740. void InitAASLocation( void );
  741. void SetAASLocation( void );
  742. void Move( void );
  743. void UpdatePowerUps( void );
  744. void UpdateDeathSkin( bool state_hitch );
  745. void SetSpectateOrigin( void );
  746. void ClearFocus( void );
  747. void UpdateFocus( void );
  748. void UpdateLocation( void );
  749. idUserInterface * ActiveGui( void );
  750. void UpdatePDAInfo( bool updatePDASel );
  751. int AddGuiPDAData( const declType_t dataType, const char *listName, const idDeclPDA *src, idUserInterface *gui );
  752. void ExtractEmailInfo( const idStr &email, const char *scan, idStr &out );
  753. void UpdateObjectiveInfo( void );
  754. #ifdef _D3XP
  755. bool WeaponAvailable( const char* name );
  756. #endif
  757. void UseVehicle( void );
  758. void Event_GetButtons( void );
  759. void Event_GetMove( void );
  760. void Event_GetViewAngles( void );
  761. void Event_StopFxFov( void );
  762. void Event_EnableWeapon( void );
  763. void Event_DisableWeapon( void );
  764. void Event_GetCurrentWeapon( void );
  765. void Event_GetPreviousWeapon( void );
  766. void Event_SelectWeapon( const char *weaponName, int flash );
  767. void Event_GetWeaponEntity( void );
  768. void Event_OpenPDA( void );
  769. void Event_PDAAvailable( void );
  770. void Event_InPDA( void );
  771. void Event_ExitTeleporter( void );
  772. void Event_HideTip( void );
  773. void Event_LevelTrigger( void );
  774. void Event_Gibbed( void );
  775. //bc
  776. void Event_settext_missionclock( float amount );
  777. void Event_settext_alarms( int amount );
  778. void Event_settext_obj( const char* text );
  779. void Event_getPickerState( void );
  780. void Event_stopPicker( void );
  781. void Event_useVehicle( idEntity *target, int value );
  782. void Event_setDeckScript( idEntity *ent );
  783. void Event_removeWeaponItem( const char* name );
  784. void Event_useDeck( idEntity *target, idEntity *master );
  785. void Event_getEyePos( void );
  786. void Event_getPlacerAngle( void );
  787. void Event_getPlacerAngleRaw( void );
  788. void Event_getPlacerPos( void );
  789. void Event_getPlacerFloatPos( void );
  790. void Event_setPlacerAngle( int value );
  791. void Event_getPlacerValid( void );
  792. void Event_debugMessage( const char *message );
  793. void Event_setNoclip( int value );
  794. void Event_getNoclip( void );
  795. idVec3 getPlacerAngle( void );
  796. void Event_inDeck( void );
  797. void Event_clamberScripted( const idVec3 &targetPos, float intensity, float movetime );
  798. int isFrozen;
  799. int hudmessageNextNum;
  800. #ifdef _D3XP //BSM: Event to remove inventory items. Useful with powercells.
  801. void Event_GiveInventoryItem( const char* name );
  802. void Event_RemoveInventoryItem( const char* name );
  803. void Event_GetIdealWeapon( void );
  804. void Event_WeaponAvailable( const char* name );
  805. void Event_SetPowerupTime( int powerup, int time );
  806. void Event_IsPowerupActive( int powerup );
  807. void Event_StartWarp();
  808. void Event_StopHelltime( int mode );
  809. #endif
  810. };
  811. ID_INLINE bool idPlayer::IsReady( void ) {
  812. return ready || forcedReady;
  813. }
  814. ID_INLINE bool idPlayer::IsRespawning( void ) {
  815. return respawning;
  816. }
  817. ID_INLINE idPhysics* idPlayer::GetPlayerPhysics( void ) {
  818. return &physicsObj;
  819. }
  820. ID_INLINE bool idPlayer::IsInTeleport( void ) {
  821. return ( teleportEntity.GetEntity() != NULL );
  822. }
  823. ID_INLINE void idPlayer::SetLeader( bool lead ) {
  824. leader = lead;
  825. }
  826. ID_INLINE bool idPlayer::IsLeader( void ) {
  827. return leader;
  828. }
  829. ID_INLINE bool idPlayer::SelfSmooth( void ) {
  830. return selfSmooth;
  831. }
  832. ID_INLINE void idPlayer::SetSelfSmooth( bool b ) {
  833. selfSmooth = b;
  834. }
  835. #endif /* !__GAME_PLAYER_H__ */