Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1800 lines
65 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose: Player for HL1.
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef CS_PLAYER_H
  8. #define CS_PLAYER_H
  9. #pragma once
  10. #include "basemultiplayerplayer.h"
  11. #include "server_class.h"
  12. #include "cs_gamerules.h"
  13. #include "cs_playeranimstate.h"
  14. #include "cs_shareddefs.h"
  15. #include "cs_autobuy.h"
  16. #include "utldict.h"
  17. #include "usermessages.h"
  18. #include "cstrike15_item_inventory.h"
  19. class CWeaponCSBase;
  20. class CMenu;
  21. class CHintMessageQueue;
  22. class CNavArea;
  23. class CCSBot;
  24. class CEconPersonaDataPublic;
  25. class CCSUsrMsg_PlayerDecalDigitalSignature;
  26. #include "matchmaking/cstrike15/imatchext_cstrike15.h"
  27. #include "matchmaking/iplayerrankingdata.h"
  28. #include "cs_player_rank_shared.h"
  29. #include "cs_player_shared.h"
  30. #include "csgo_playeranimstate.h"
  31. #define MENU_STRING_BUFFER_SIZE 1024
  32. #define MENU_MSG_TEXTCHUNK_SIZE 50
  33. #define CS_FORCE_TEAM_THINK_CONTEXT "CSForceTeamThink"
  34. enum
  35. {
  36. MIN_NAME_CHANGE_INTERVAL = 0, // minimum number of seconds between name changes
  37. NAME_CHANGE_HISTORY_SIZE = 5, // number of times a player can change names in NAME_CHANGE_HISTORY_INTERVAL
  38. NAME_CHANGE_HISTORY_INTERVAL = 600, // no more than NAME_CHANGE_HISTORY_SIZE name changes can be made in this many seconds
  39. };
  40. extern ConVar bot_mimic;
  41. // Function table for each player state.
  42. class CCSPlayerStateInfo
  43. {
  44. public:
  45. CSPlayerState m_iPlayerState;
  46. const char *m_pStateName;
  47. void (CCSPlayer::*pfnEnterState)(); // Init and deinit the state.
  48. void (CCSPlayer::*pfnLeaveState)();
  49. void (CCSPlayer::*pfnPreThink)(); // Do a PreThink() in this state.
  50. };
  51. //=======================================
  52. //Record of either damage taken or given.
  53. //Contains the player name that we hurt or that hurt us,
  54. //and the total damage
  55. //=======================================
  56. class CDamageRecord
  57. {
  58. public:
  59. CDamageRecord( CCSPlayer * pPlayerDamager, CCSPlayer * pPlayerRecipient, int iDamage, int iCounter, int iActualHealthRemoved );
  60. void AddDamage( int iDamage, int iCounter, int iActualHealthRemoved = 0 )
  61. {
  62. m_iDamage += iDamage;
  63. m_iActualHealthRemoved += iActualHealthRemoved;
  64. if ( m_iLastBulletUpdate != iCounter || GetPlayerDamagerPtr() == NULL )
  65. m_iNumHits++;
  66. m_iLastBulletUpdate = iCounter;
  67. }
  68. bool IsDamageRecordStillValidForDamagerAndRecipient( CCSPlayer * pPlayerDamager, CCSPlayer * pPlayerRecipient );
  69. bool IsDamageRecordValidPlayerToPlayer(void) { return ( this && m_PlayerDamager && m_PlayerRecipient) ? true : false; }
  70. CCSPlayer* GetPlayerDamagerPtr( void ) { return m_PlayerDamager; }
  71. CCSPlayer* GetPlayerRecipientPtr( void ) { return m_PlayerRecipient; }
  72. char *GetPlayerDamagerName( void ) { return m_szPlayerDamagerName; }
  73. char *GetPlayerRecipientName( void ) { return m_szPlayerRecipientName; }
  74. int GetDamage( void ) { return m_iDamage; }
  75. int GetActualHealthRemoved( void ) { return m_iActualHealthRemoved; }
  76. int GetNumHits( void ) { return m_iNumHits; }
  77. CCSPlayer* GetPlayerDamagerControlledBotPtr( void ) { return m_PlayerDamagerControlledBot; }
  78. CCSPlayer* GetPlayerRecipientControlledBotPtr( void ) { return m_PlayerRecipientControlledBot; }
  79. private:
  80. CHandle<CCSPlayer> m_PlayerDamager;
  81. CHandle<CCSPlayer> m_PlayerRecipient;
  82. char m_szPlayerDamagerName[MAX_PLAYER_NAME_LENGTH];
  83. char m_szPlayerRecipientName[MAX_PLAYER_NAME_LENGTH];
  84. int m_iDamage; //how much damage was delivered
  85. int m_iActualHealthRemoved; //how much damage was actually applied
  86. int m_iNumHits; //how many hits
  87. int m_iLastBulletUpdate; // update counter
  88. CHandle<CCSPlayer> m_PlayerDamagerControlledBot;
  89. CHandle<CCSPlayer> m_PlayerRecipientControlledBot;
  90. };
  91. // Message display history (CCSPlayer::m_iDisplayHistoryBits)
  92. // These bits are set when hint messages are displayed, and cleared at
  93. // different times, according to the DHM_xxx bitmasks that follow
  94. #define DHF_ROUND_STARTED ( 1 << 1 )
  95. #define DHF_HOSTAGE_SEEN_FAR ( 1 << 2 )
  96. #define DHF_HOSTAGE_SEEN_NEAR ( 1 << 3 )
  97. #define DHF_HOSTAGE_USED ( 1 << 4 )
  98. #define DHF_HOSTAGE_INJURED ( 1 << 5 )
  99. #define DHF_HOSTAGE_KILLED ( 1 << 6 )
  100. #define DHF_FRIEND_SEEN ( 1 << 7 )
  101. #define DHF_ENEMY_SEEN ( 1 << 8 )
  102. #define DHF_FRIEND_INJURED ( 1 << 9 )
  103. #define DHF_FRIEND_KILLED ( 1 << 10 )
  104. #define DHF_ENEMY_KILLED ( 1 << 11 )
  105. #define DHF_BOMB_RETRIEVED ( 1 << 12 )
  106. #define DHF_AMMO_EXHAUSTED ( 1 << 15 )
  107. #define DHF_IN_TARGET_ZONE ( 1 << 16 )
  108. #define DHF_IN_RESCUE_ZONE ( 1 << 17 )
  109. #define DHF_IN_ESCAPE_ZONE ( 1 << 18 ) // unimplemented
  110. #define DHF_IN_VIPSAFETY_ZONE ( 1 << 19 ) // unimplemented
  111. #define DHF_NIGHTVISION ( 1 << 20 )
  112. #define DHF_HOSTAGE_CTMOVE ( 1 << 21 )
  113. #define DHF_SPEC_DUCK ( 1 << 22 )
  114. // DHF_xxx bits to clear when the round restarts
  115. #define DHM_ROUND_CLEAR ( \
  116. DHF_ROUND_STARTED | \
  117. DHF_HOSTAGE_KILLED | \
  118. DHF_FRIEND_KILLED | \
  119. DHF_BOMB_RETRIEVED )
  120. // DHF_xxx bits to clear when the player is restored
  121. #define DHM_CONNECT_CLEAR ( \
  122. DHF_HOSTAGE_SEEN_FAR | \
  123. DHF_HOSTAGE_SEEN_NEAR | \
  124. DHF_HOSTAGE_USED | \
  125. DHF_HOSTAGE_INJURED | \
  126. DHF_FRIEND_SEEN | \
  127. DHF_ENEMY_SEEN | \
  128. DHF_FRIEND_INJURED | \
  129. DHF_ENEMY_KILLED | \
  130. DHF_AMMO_EXHAUSTED | \
  131. DHF_IN_TARGET_ZONE | \
  132. DHF_IN_RESCUE_ZONE | \
  133. DHF_IN_ESCAPE_ZONE | \
  134. DHF_IN_VIPSAFETY_ZONE | \
  135. DHF_HOSTAGE_CTMOVE | \
  136. DHF_SPEC_DUCK )
  137. // radio messages (these must be kept in sync with actual radio) -------------------------------------
  138. enum RadioType
  139. {
  140. RADIO_INVALID = 0,
  141. RADIO_START_1, ///< radio messages between this and RADIO_START_2 and part of Radio1()
  142. RADIO_GO_GO_GO,
  143. RADIO_TEAM_FALL_BACK,
  144. RADIO_STICK_TOGETHER_TEAM,
  145. RADIO_HOLD_THIS_POSITION,
  146. RADIO_FOLLOW_ME,
  147. RADIO_START_2, ///< radio messages between this and RADIO_START_3 are part of Radio2()
  148. RADIO_AFFIRMATIVE,
  149. RADIO_NEGATIVE,
  150. RADIO_CHEER,
  151. RADIO_COMPLIMENT,
  152. RADIO_THANKS,
  153. RADIO_START_3, ///< radio messages above this are part of Radio3()
  154. RADIO_ENEMY_SPOTTED,
  155. RADIO_NEED_BACKUP,
  156. RADIO_YOU_TAKE_THE_POINT,
  157. RADIO_SECTOR_CLEAR,
  158. RADIO_IN_POSITION,
  159. // not used
  160. ///////////////////////////////////
  161. RADIO_COVER_ME,
  162. RADIO_REGROUP_TEAM,
  163. RADIO_TAKING_FIRE,
  164. RADIO_REPORT_IN_TEAM,
  165. RADIO_REPORTING_IN,
  166. RADIO_GET_OUT_OF_THERE,
  167. RADIO_ENEMY_DOWN,
  168. RADIO_STORM_THE_FRONT,
  169. RADIO_END,
  170. RADIO_NUM_EVENTS
  171. };
  172. extern const char *RadioEventName[ RADIO_NUM_EVENTS+1 ];
  173. /**
  174. * Convert name to RadioType
  175. */
  176. extern RadioType NameToRadioEvent( const char *name );
  177. enum BuyResult_e
  178. {
  179. BUY_BOUGHT,
  180. BUY_ALREADY_HAVE,
  181. BUY_CANT_AFFORD,
  182. BUY_PLAYER_CANT_BUY, // not in the buy zone, is the VIP, is past the timelimit, etc
  183. BUY_NOT_ALLOWED, // weapon is restricted by VIP mode, team, etc
  184. BUY_INVALID_ITEM,
  185. };
  186. // [tj] The phases for the "Goose Chase" achievement
  187. enum GooseChaseAchievementStep
  188. {
  189. GC_NONE,
  190. GC_SHOT_DURING_DEFUSE,
  191. GC_STOPPED_AFTER_GETTING_SHOT
  192. };
  193. // [tj] The phases for the "Defuse Defense" achievement
  194. enum DefuseDefenseAchivementStep
  195. {
  196. DD_NONE,
  197. DD_STARTED_DEFUSE,
  198. DD_KILLED_TERRORIST
  199. };
  200. struct quest_data_t
  201. {
  202. public:
  203. const char * m_szQuestCalcExpression;
  204. const char * m_szQuestBonusCalcExpression;
  205. int m_nQuestID;
  206. int m_nQuestNormalPoints;
  207. int m_nQuestBonusPoints;
  208. };
  209. //=============================================================================
  210. // >> CounterStrike player
  211. //=============================================================================
  212. class CCSPlayer : public CBaseMultiplayerPlayer, public ICSPlayerAnimStateHelpers
  213. #if !defined( NO_STEAM ) && !defined( NO_STEAM_GAMECOORDINATOR )
  214. , public IHasAttributes, public IInventoryUpdateListener
  215. #endif
  216. {
  217. public:
  218. DECLARE_CLASS( CCSPlayer, CBaseMultiplayerPlayer );
  219. DECLARE_SERVERCLASS();
  220. DECLARE_PREDICTABLE();
  221. DECLARE_DATADESC();
  222. CCSPlayer();
  223. ~CCSPlayer();
  224. static CCSPlayer *CreatePlayer( const char *className, edict_t *ed );
  225. static CCSPlayer* Instance( int iEnt );
  226. virtual void Precache();
  227. virtual void Spawn();
  228. virtual void InitialSpawn( void );
  229. virtual void UpdateOnRemove( void );
  230. virtual void PostSpawnPointSelection( void );
  231. void SetCSSpawnLocation( Vector position, QAngle angle );
  232. virtual void ImpulseCommands() OVERRIDE;
  233. virtual void CheatImpulseCommands( int iImpulse );
  234. virtual void PlayerRunCommand( CUserCmd *ucmd, IMoveHelper *moveHelper );
  235. virtual void PostThink();
  236. void SprayPaint( CCSUsrMsg_PlayerDecalDigitalSignature const &msg );
  237. class ITakeDamageListener
  238. {
  239. public:
  240. ITakeDamageListener();
  241. ~ITakeDamageListener();
  242. virtual void OnTakeDamageListenerCallback( CCSPlayer *pVictim, CTakeDamageInfo &infoTweakable ) = 0;
  243. };
  244. virtual int OnTakeDamage( const CTakeDamageInfo &inputInfo );
  245. virtual int OnTakeDamage_Alive( const CTakeDamageInfo &info );
  246. virtual void Event_Killed( const CTakeDamageInfo &info );
  247. virtual void Event_KilledOther( CBaseEntity *pVictim, const CTakeDamageInfo &info );
  248. virtual void TraceAttack( const CTakeDamageInfo &inputInfo, const Vector &vecDir, trace_t *ptr );
  249. void FindMatchingWeaponsForTeamLoadout( const char *pchName, int nTeam, bool bMustBeTeamSpecific, CUtlVector< CEconItemView* > &matchingWeapons );
  250. virtual CBaseEntity *GiveNamedItem( const char *pchName, int iSubType = 0, CEconItemView *pScriptItem = NULL, bool bForce = false ) OVERRIDE;
  251. virtual bool IsBeingGivenItem() const { return m_bIsBeingGivenItem; }
  252. virtual CBaseEntity *FindUseEntity( void );
  253. virtual bool IsUseableEntity( CBaseEntity *pEntity, unsigned int requiredCaps );
  254. virtual void CreateViewModel( int viewmodelindex = 0 );
  255. virtual void ShowViewPortPanel( const char * name, bool bShow = true, KeyValues *data = NULL );
  256. void HandleOutOfAmmoKnifeKills( CCSPlayer* pAttackerPlayer, CWeaponCSBase* pAttackerWeapon );
  257. // This passes the event to the client's and server's CPlayerAnimState.
  258. void DoAnimationEvent( PlayerAnimEvent_t event, int nData = 0 );
  259. // from CBasePlayer
  260. virtual void SetupVisibility( CBaseEntity *pViewEntity, unsigned char *pvs, int pvssize );
  261. virtual bool ShouldCheckOcclusion( CBasePlayer *pOtherPlayer ) OVERRIDE;
  262. virtual bool ShouldCollide( int collisionGroup, int contentsMask ) const;
  263. // from CBasePlayer
  264. virtual bool IsValidObserverTarget(CBaseEntity * target);
  265. virtual CBaseEntity* FindNextObserverTarget( bool bReverse );
  266. virtual int GetNextObserverSearchStartPoint( bool bReverse );
  267. virtual bool UpdateDispatchLayer( CAnimationLayer *pLayer, CStudioHdr *pWeaponStudioHdr, int iSequence ) OVERRIDE;
  268. // In shared code.
  269. public:
  270. // ICSPlayerAnimState overrides.
  271. virtual CWeaponCSBase* CSAnim_GetActiveWeapon();
  272. virtual bool CSAnim_CanMove();
  273. virtual float GetPlayerMaxSpeed();
  274. void CheckForWeaponFiredAchievement();
  275. void FireBullet(
  276. Vector vecSrc,
  277. const QAngle &shootAngles,
  278. float flDistance,
  279. float flPenetration,
  280. int nPenetrationCount,
  281. int iBulletType,
  282. int iDamage,
  283. float flRangeModifier,
  284. CBaseEntity *pevAttacker,
  285. bool bDoEffects,
  286. float xSpread, float ySpread );
  287. bool HandleBulletPenetration(
  288. float &flPenetration,
  289. int &iEnterMaterial,
  290. bool &hitGrate,
  291. trace_t &tr,
  292. Vector &vecDir,
  293. surfacedata_t *pSurfaceData,
  294. float flPenetrationModifier,
  295. float flDamageModifier,
  296. bool bDoEffects,
  297. int iDamageType,
  298. float flPenetrationPower,
  299. int &nPenetrationCount,
  300. Vector &vecSrc,
  301. float flDistance,
  302. float flCurrentDistance,
  303. float &fCurrentDamage );
  304. virtual QAngle GetAimPunchAngle( void );
  305. QAngle GetRawAimPunchAngle( void ) const;
  306. void KickBack(
  307. float fAngle,
  308. float fMagnitude );
  309. void GetBulletTypeParameters(
  310. int iBulletType,
  311. float &fPenetrationPower,
  312. float &flPenetrationDistance );
  313. int GetDefaultCrouchedFOV( void ) const;
  314. void DisplayPenetrationDebug( Vector vecEnter, Vector vecExit, float flDistance, float flInitialDamage, float flDamageLostImpact, float flTotalLostDamage, short nEnterSurf, short nExitSurf );
  315. // Returns true if the player is allowed to move.
  316. bool CanMove() const;
  317. // Returns the player mask which includes the solid mask plus the team mask.
  318. virtual unsigned int PhysicsSolidMaskForEntity( void ) const;
  319. void OnJump( float fImpulse );
  320. void OnLand( float fVelocity );
  321. bool HasC4() const; // Is this player carrying a C4 bomb?
  322. bool IsVIP() const;
  323. bool IsCloseToActiveBomb();
  324. bool IsCloseToHostage();
  325. bool IsObjectiveKill( CCSPlayer* pCSVictim );
  326. int GetClass( void ) const;
  327. void MakeVIP( bool isVIP );
  328. virtual void SetAnimation( PLAYER_ANIM playerAnim );
  329. void DoAnimStateEvent( PlayerAnimEvent_t evt );
  330. virtual bool StartReplayMode( float fDelay, float fDuration, int iEntity ) OVERRIDE;
  331. virtual void StopReplayMode() OVERRIDE;
  332. virtual void PlayUseDenySound() OVERRIDE;
  333. bool IsOtherSameTeam( int nTeam );
  334. bool IsOtherEnemy( CCSPlayer *pPlayer );
  335. bool IsOtherEnemy( int nEntIndex );
  336. bool IsOtherEnemyAndPlaying( int nEntIndex ); // Doesn't consider observer to be an enemy
  337. public:
  338. // Simulates a single frame of movement for a player
  339. void RunPlayerMove( const QAngle& viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, float frametime );
  340. virtual void HandleAnimEvent( animevent_t *pEvent );
  341. virtual void UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity );
  342. virtual void PlayStepSound( Vector &vecOrigin, surfacedata_t *psurface, float fvol, bool force );
  343. // from cbasecombatcharacter
  344. void InitVCollision( const Vector &vecAbsOrigin, const Vector &vecAbsVelocity );
  345. void VPhysicsShadowUpdate( IPhysicsObject *pPhysics );
  346. bool HasWeaponOfType( int nWeaponID ) const;
  347. bool IsPrimaryOrSecondaryWeapon( CSWeaponType nType );
  348. virtual bool IsTaunting( void ) const { return m_bIsTaunting; }
  349. virtual bool IsThirdPersonTaunt( void ) const { return m_bIsThirdPersonTaunt; }
  350. virtual float GetTauntYaw( void ) const { return m_flTauntYaw; }
  351. virtual void StopTaunting( void ) { m_bIsTaunting = false; }
  352. virtual bool IsLookingAtWeapon( void ) const { return m_bIsLookingAtWeapon; }
  353. virtual bool IsHoldingLookAtWeapon( void ) const { return m_bIsHoldingLookAtWeapon; }
  354. virtual void StopLookingAtWeapon( void ) { m_bIsLookingAtWeapon = false; m_bIsHoldingLookAtWeapon = false; }
  355. void ModifyTauntDuration( float flTimingChange );
  356. CBaseEntity *GetUsableHighPriorityEntity( void );
  357. bool GetUseConfigurationForHighPriorityUseEntity( CBaseEntity *pEntity, CConfigurationForHighPriorityUseEntity_t &cfg );
  358. bool HasShield() const;
  359. bool IsShieldDrawn() const;
  360. void GiveShield( void );
  361. void RemoveShield( void );
  362. bool IsProtectedByShield( void ) const; // returns true if player has a shield and is currently hidden behind it
  363. bool HasPrimaryWeapon( void );
  364. bool HasSecondaryWeapon( void );
  365. bool IsReloading( void ) const; // returns true if current weapon is reloading
  366. void GiveDefaultItems();
  367. void GiveDefaultWearables();
  368. void GiveWearableFromSlot( loadout_positions_t position );
  369. void RemoveAllItems( bool removeSuit ); //overridden to remove the defuser
  370. void ValidateWearables( void );
  371. // Reset account, get rid of shield, etc..
  372. void Reset( bool resetScore );
  373. void RoundRespawn( void );
  374. void ObserverRoundRespawn( void );
  375. void CheckTKPunishment( void );
  376. virtual void ObserverUse( bool bIsPressed ); // observer pressed use
  377. // Add money to this player's account.
  378. void ResetAccount();
  379. void InitializeAccount( int amount = -1 );
  380. void AddAccount( int amount, bool bTrackChange = true, bool bItemBought = false, const char *pItemName = NULL );
  381. bool AreAccountAwardsEnabled( PlayerCashAward::Type reason ) const;
  382. void AddAccountAward( PlayerCashAward::Type reason );
  383. void AddAccountAward( PlayerCashAward::Type reason, int amount, const CWeaponCSBase *pWeapon = NULL );
  384. void AddAccountFromTeam( int amount, bool bTrackChange, TeamCashAward::Type reason );
  385. int AddDeathmatchKillScore( int nScore, CSWeaponID wepID, int iSlot, bool bIsAssist = false, const char* szVictim = NULL );
  386. void HintMessage( const char *pMessage, bool bDisplayIfDead, bool bOverrideClientSettings = false ); // Displays a hint message to the player
  387. CHintMessageQueue *m_pHintMessageQueue;
  388. unsigned int m_iDisplayHistoryBits;
  389. bool m_bShowHints;
  390. float m_flLastAttackedTeammate;
  391. float m_flNextMouseoverUpdate;
  392. void UpdateMouseoverHints();
  393. float m_flDominateEffectDelayTime;
  394. EHANDLE m_hDominateEffectPlayer;
  395. // mark this player as not receiving money at the start of the next round.
  396. void ProcessSuicideAsKillReward();
  397. void MarkAsNotReceivingMoneyNextRound( bool bAllowMoneyNextRound = false );
  398. bool DoesPlayerGetRoundStartMoney(); // self-explanitory :)
  399. virtual bool ShouldPickupItemSilently( CBaseCombatCharacter *pNewOwner );
  400. void DropC4(); // Get rid of the C4 bomb.
  401. CNetworkHandle( CBaseEntity, m_hCarriedHostage ); // networked entity handle
  402. //EHANDLE GetCarriedHostage() const;
  403. void GiveCarriedHostage( EHANDLE hHostage );
  404. void RefreshCarriedHostage( bool bForceCreate );
  405. void RemoveCarriedHostage();
  406. CNetworkHandle( CBaseEntity, m_hCarriedHostageProp ); // networked entity handle
  407. EHANDLE m_hHostageViewModel;
  408. bool HasDefuser(); // Is this player carrying a bomb defuser?
  409. void GiveDefuser( bool bPickedUp = false ); // give the player a defuser
  410. void RemoveDefuser(); // remove defuser from the player and remove the model attachment
  411. bool PickedUpDefuser() { return m_bPickedUpDefuser; }
  412. void SetDefusedWithPickedUpKit(bool bDefusedWithPickedUpKit) { m_bDefusedWithPickedUpKit = bDefusedWithPickedUpKit; }
  413. bool GetDefusedWithPickedUpKit() { return m_bDefusedWithPickedUpKit; }
  414. bool AttemptedToDefuseBomb() { return m_bAttemptedDefusal; }
  415. void SetDefusedBombWithThisTimeRemaining( float flTimeRemaining ) { m_flDefusedBombWithThisTimeRemaining = flTimeRemaining; }
  416. float GetDefusedBombWithThisTimeRemaining() { return m_flDefusedBombWithThisTimeRemaining; }
  417. bool IsBlindForAchievement(); // more stringent than IsBlind; more accurately represents when the player can see again
  418. // [jpaquin] auto refill ammo
  419. float m_flNextAutoBuyAmmoTime;
  420. void AutoBuyAmmo( bool bForce = false );
  421. void GuardianForceFillAmmo( void );
  422. bool IsBlind( void ) const; // return true if this player is blind (from a flashbang)
  423. virtual void Blind( float holdTime, float fadeTime, float startingAlpha = 255 ); // player blinded by a flashbang
  424. void Unblind( void ); // removes the blind effect from the player
  425. float m_blindUntilTime;
  426. float m_blindStartTime;
  427. void Deafen( float flDistance ); //make the player deaf / apply dsp preset to muffle sound
  428. void ApplyDeafnessEffect(); // apply the deafness effect for a nearby explosion.
  429. bool IsAutoFollowAllowed( void ) const; // return true if this player will allow bots to auto follow
  430. void InhibitAutoFollow( float duration ); // prevent bots from auto-following for given duration
  431. void AllowAutoFollow( void ); // allow bots to auto-follow immediately
  432. float m_allowAutoFollowTime; // bots can auto-follow after this time
  433. // Have this guy speak a message into his radio.
  434. void Radio( const char *szRadioSound, const char *szRadioText = NULL , bool bTriggeredAutomatically = false );
  435. void ConstructRadioFilter( CRecipientFilter& filter );
  436. float m_flGotHostageTalkTimer;
  437. float m_flDefusingTalkTimer;
  438. float m_flC4PlantTalkTimer;
  439. virtual bool CanHearAndReadChatFrom( CBasePlayer *pPlayer );
  440. void EmitPrivateSound( const char *soundName ); ///< emit given sound that only we can hear
  441. bool Weapon_Switch( CBaseCombatWeapon *pWeapon, int viewmodelindex = 0 );
  442. CWeaponCSBase* GetActiveCSWeapon() const;
  443. int GetNumTriggerPulls() { return m_triggerPulls; }
  444. void LogTriggerPulls();
  445. void PreThink();
  446. // This is the think function for the player when they first join the server and have to select a team
  447. void JoiningThink();
  448. virtual bool ClientCommand( const CCommand &args );
  449. bool AllowTaunts( void );
  450. void Taunt( void );
  451. void LookAtHeldWeapon( void );
  452. void SendJoinTeamFailedMessage( int reason, bool raiseTeamScreen );
  453. bool HandleCommand_JoinClass( void );
  454. bool HandleCommand_JoinTeam( int iTeam, bool bQueue = false, int iCoachTeam = 0 ); // if bQueue is true then the team move will not occur until round restart
  455. BuyResult_e HandleCommand_Buy( const char *item, int nPos = -1, bool bAddToRebuy = true );
  456. BuyResult_e HandleCommand_Buy_Internal( const char * item, int nPos = -1, bool bAddToRebuy = true );
  457. CNetworkVar( bool, m_bIsBuyMenuOpen );
  458. bool IsBuyMenuOpen( void ) { return m_bIsBuyMenuOpen; }
  459. void SetBuyMenuOpen( bool bOpen );
  460. AcquireResult::Type CanAcquire( CSWeaponID weaponId, AcquireMethod::Type acquireMethod, CEconItemView *pItem = NULL );
  461. int GetCarryLimit( CSWeaponID weaponId );
  462. int GetWeaponPrice( CSWeaponID weaponId, const CEconItemView *pWepView = NULL ) const;
  463. CWeaponCSBase* CSWeapon_OwnsThisType( CEconItemView *pItem ) const;
  464. void HandleMenu_Radio1( int slot );
  465. void HandleMenu_Radio2( int slot );
  466. void HandleMenu_Radio3( int slot );
  467. float m_flRadioTime;
  468. int m_iRadioMessages;
  469. int iRadioMenu;
  470. void ListPlayers();
  471. bool m_bIgnoreRadio;
  472. // Returns one of the CS_CLASS_ enums.
  473. int PlayerClass() const;
  474. void MoveToNextIntroCamera();
  475. // Used to be GETINTOGAME state.
  476. void GetIntoGame();
  477. CBaseEntity* EntSelectSpawnPoint();
  478. void SetProgressBarTime( int barTime );
  479. virtual void PlayerDeathThink();
  480. virtual void PlayerForceTeamThink();
  481. virtual void ResetForceTeamThink();
  482. virtual bool StartObserverMode( int mode ) OVERRIDE;
  483. virtual bool SetObserverTarget( CBaseEntity *target );
  484. virtual void ValidateCurrentObserverTarget( void );
  485. virtual void CheckObserverSettings( void );
  486. void Weapon_Equip( CBaseCombatWeapon *pWeapon );
  487. virtual bool BumpWeapon( CBaseCombatWeapon *pWeapon );
  488. virtual bool Weapon_CanUse( CBaseCombatWeapon *pWeapon );
  489. void ClearFlashbangScreenFade ( void );
  490. bool ShouldDoLargeFlinch( const CTakeDamageInfo& info, int nHitGroup );
  491. void ResetStamina( void );
  492. bool IsArmored( int nHitGroup );
  493. void Pain( CCSPlayer* attacker, bool HasArmour, int nDmgTypeBits = 0 );
  494. void DeathSound( const CTakeDamageInfo &info );
  495. bool Weapon_CanSwitchTo( CBaseCombatWeapon *pWeapon );
  496. virtual void OnSwitchWeapons( CBaseCombatWeapon* pWeapon );
  497. void ChangeTeam( int iTeamNum );
  498. void SwitchTeam( int iTeamNum ); // Changes teams without penalty - used for auto team balancing
  499. virtual void ModifyOrAppendCriteria( AI_CriteriaSet& set );
  500. void ModifyOrAppendPlayerCriteria( AI_CriteriaSet& set );
  501. virtual void OnDamagedByExplosion( const CTakeDamageInfo &info );
  502. virtual bool CanKickFromTeam( int kickTeam );
  503. // Called whenever this player fires a shot.
  504. void NoteWeaponFired();
  505. virtual bool WantsLagCompensationOnEntity( const CBaseEntity *pPlayer, const CUserCmd *pCmd, const CBitVec<MAX_EDICTS> *pEntityTransmitBits ) const;
  506. // training map - used to set hud element visibility via script
  507. void SetMiniScoreHidden( bool bHidden ) { m_bHud_MiniScoreHidden = bHidden; }
  508. bool IsMiniScoreHidden( void ) { return m_bHud_MiniScoreHidden; }
  509. void SetRadarHidden( bool bHidden ) { m_bHud_RadarHidden = bHidden; }
  510. bool IsRadarHidden( void ) { return m_bHud_RadarHidden; }
  511. void SetLastKillerIndex( int nLastKillerIndex ) { m_nLastKillerIndex = nLastKillerIndex; }
  512. int GetLastKillerIndex( void ) { return m_nLastKillerIndex; }
  513. void SetLastConcurrentKilled( int nLastConcurrentKilled ) { m_nLastConcurrentKilled = nLastConcurrentKilled; }
  514. int GetLastConcurrentKilled( void ) { return m_nLastConcurrentKilled; }
  515. void SetDeathCamMusicIndex( int nDeathCamMusicIndex ) { m_nDeathCamMusic = nDeathCamMusicIndex; }
  516. int GetDeathCamMusicIndex( void ) { return m_nDeathCamMusic; }
  517. void UpdateEquippedCoinFromInventory();
  518. void SetRank( MedalCategory_t category, MedalRank_t rank );
  519. MedalRank_t GetRank( MedalCategory_t category ) { return m_rank.Get( category ); }
  520. void UpdateRankFromKV( KeyValues *pKV );
  521. void UpdateEquippedMusicFromInventory();
  522. void SetMusicID( uint16 unMusicID );
  523. uint32 GetMusicID( ) { return m_unMusicID.Get(); }
  524. void UpdateEquippedPlayerSprayFromInventory();
  525. void UpdatePersonaDataFromInventory();
  526. CEconPersonaDataPublic const * GetPersonaDataPublic() const;
  527. virtual void AwardAchievement( int iAchievement, int iCount = 1 );
  528. // ------------------------------------------------------------------------------------------------ //
  529. // Player state management.
  530. // ------------------------------------------------------------------------------------------------ //
  531. public:
  532. void State_Transition( CSPlayerState newState ); // Cleanup the previous state and enter a new state.
  533. CSPlayerState State_Get() const; // Get the current state.
  534. private:
  535. void State_Enter( CSPlayerState newState ); // Initialize the new state.
  536. void State_Leave(); // Cleanup the previous state.
  537. void State_PreThink(); // Update the current state.
  538. // Find the state info for the specified state.
  539. static CCSPlayerStateInfo* State_LookupInfo( CSPlayerState state );
  540. // This tells us which state the player is currently in (joining, observer, dying, etc).
  541. // Each state has a well-defined set of parameters that go with it (ie: observer is movetype_noclip, nonsolid,
  542. // invisible, etc).
  543. CNetworkVar( CSPlayerState, m_iPlayerState );
  544. CCSPlayerStateInfo *m_pCurStateInfo; // This can be NULL if no state info is defined for m_iPlayerState.
  545. // tells us whether or not this player gets money at the start of the next round.
  546. bool m_receivesMoneyNextRound;
  547. // Specific state handler functions.
  548. void State_Enter_WELCOME();
  549. void State_PreThink_WELCOME();
  550. void State_Enter_PICKINGTEAM();
  551. void State_Enter_PICKINGCLASS();
  552. void State_Enter_ACTIVE();
  553. void State_PreThink_ACTIVE();
  554. void State_Enter_OBSERVER_MODE();
  555. void State_Leave_OBSERVER_MODE();
  556. void State_PreThink_OBSERVER_MODE();
  557. void State_Enter_GUNGAME_RESPAWN();
  558. void State_PreThink_GUNGAME_RESPAWN();
  559. void TryGungameRespawn();
  560. void State_Enter_DEATH_WAIT_FOR_KEY();
  561. void State_PreThink_DEATH_WAIT_FOR_KEY();
  562. void State_Enter_DEATH_ANIM();
  563. void State_PreThink_DEATH_ANIM();
  564. int FlashlightIsOn( void );
  565. virtual bool FlashlightTurnOn( bool playSound = false );
  566. virtual void FlashlightTurnOff( bool playSound = false );
  567. void UpdateAddonBits();
  568. void ProcessSpottedEntityUpdate();
  569. void AppendSpottedEntityUpdateMessage( int entindex, bool bSpotted,
  570. CCSUsrMsg_ProcessSpottedEntityUpdate::SpottedEntityUpdate *pMsg );
  571. //void UpdateTeamMoney();
  572. int GetAccountForScoreboard();
  573. public:
  574. bool StartHltvReplayEvent( const ClientReplayEventParams_t &params );
  575. int GetHealth() const { return m_iHealth; }
  576. virtual void SetHealth( int amt );
  577. void SetDeathPose( const int &iDeathPose ) { m_iDeathPose = iDeathPose; }
  578. void SetDeathPoseFrame( const int &iDeathPoseFrame ) { m_iDeathFrame = iDeathPoseFrame; }
  579. void SetDeathPoseYaw( const float &flDeathPoseYaw ) { m_flDeathYaw = flDeathPoseYaw; }
  580. void SelectDeathPose( const CTakeDamageInfo &info );
  581. bool MadeFinalGunGameProgressiveKill( void ) { return m_bMadeFinalGunGameProgressiveKill; }
  582. bool JustLeftSpawnImmunity(){return m_fJustLeftImmunityTime > 0.0f;}
  583. virtual void IncrementFragCount( int nCount, int nHeadshots = 0 );
  584. virtual void IncrementAssistsCount( int nCount );
  585. virtual void IncrementDeathCount( int nCount );
  586. void IncrementTeamKillsCount( int nCount );
  587. void IncrementHostageKillsCount( int nCount );
  588. void IncrementTeamDamagePoints( int numDamagePoints );
  589. void SetLastKillTime( float time );
  590. float GetLastKillTime();
  591. void IncrementKillStreak( int nCount );
  592. void ResetKillStreak();
  593. int GetKillStreak();
  594. void ResetNumRoundKills() { m_iNumRoundKills = 0; m_iNumRoundKillsHeadshots = 0; }
  595. int GetNumConcurrentDominations( void );
  596. void GiveWeaponFromID ( int nWeaponID );
  597. private:
  598. int m_iKillStreak;
  599. float m_flLastKillTime;
  600. int m_iDeathPose;
  601. int m_iDeathFrame;
  602. float m_flDeathYaw;
  603. bool m_bAbortFreezeCam;
  604. bool m_bJustBecameSpectator;
  605. bool m_bRespawning;
  606. int m_iNumGunGameTRBombTotalPoints;
  607. bool m_bShouldProgressGunGameTRBombModeWeapon;
  608. bool m_switchTeamsOnNextRoundReset;
  609. float m_fJustLeftImmunityTime;
  610. float m_lowHealthGoalTime;
  611. CNetworkArray( MedalRank_t, m_rank, MEDAL_CATEGORY_COUNT );
  612. bool m_bNeedToUpdateCoinFromInventory;
  613. CNetworkVar( uint16, m_unMusicID );
  614. bool m_bNeedToUpdateMusicFromInventory;
  615. uint16 m_unEquippedPlayerSprayIDs[ /*LOADOUT_POSITION_SPRAY3*/ LOADOUT_POSITION_SPRAY0 + 1 - LOADOUT_POSITION_SPRAY0 ];
  616. bool m_bNeedToUpdatePlayerSprayFromInventory;
  617. CEconPersonaDataPublic *m_pPersonaDataPublic;
  618. bool m_bNeedToUpdatePersonaDataPublicFromInventory;
  619. protected:
  620. void AttemptToExitFreezeCam( void );
  621. void GiveCurrentProgressiveGunGameWeapon( void );
  622. void GiveNextProgressiveGunGameWeapon( void );
  623. void SubtractProgressiveWeaponIndex( void );
  624. void SendGunGameWeaponUpgradeAlert( void );
  625. public:
  626. CNetworkVar( bool, m_bIsScoped );
  627. CNetworkVar( bool, m_bIsWalking );
  628. // Predicted variables.
  629. CNetworkVar( bool, m_bResumeZoom );
  630. CNetworkVar( bool, m_bIsDefusing ); // tracks whether this player is currently defusing a bomb
  631. bool IsDefusing( void ) { return m_bIsDefusing; }
  632. CNetworkVar( bool, m_bIsGrabbingHostage ); // tracks whether this player is currently grabbing a hostage
  633. CNetworkVar( float, m_fImmuneToGunGameDamageTime ); // When gun game spawn damage immunity will expire
  634. CNetworkVar( bool, m_bGunGameImmunity ); // tracks whether this player is currently immune in gun game
  635. CNetworkVar( bool, m_bMadeFinalGunGameProgressiveKill );
  636. CNetworkVar( int, m_iGunGameProgressiveWeaponIndex ); // index of current gun game weapon
  637. CNetworkVar( int, m_iNumGunGameTRKillPoints ); // number of kill points accumulated so far in TR Gun Game mode (resets to 0 when weapon is upgraded)
  638. CNetworkVar( int, m_iNumGunGameKillsWithCurrentWeapon );
  639. CNetworkVar( int, m_iNumRoundKills ); // number of kills a player has in a single round
  640. CNetworkVar( int, m_iNumRoundKillsHeadshots ); // number of kills a player got this round with headshots
  641. int m_iNumRoundTKs; // number of teammate kills a player has in a single round
  642. CNetworkVar( float, m_fMolotovUseTime ); // Molotov can be used if current time is after this time
  643. CNetworkVar( float, m_fMolotovDamageTime ); // Last time when this player was burnt by Molotov damage
  644. CNetworkVar( bool, m_bHasMovedSinceSpawn ); // Whether player has moved from spawn position
  645. CNetworkVar( bool, m_bCanMoveDuringFreezePeriod );
  646. CNetworkVar( bool, m_isCurrentGunGameLeader );
  647. CNetworkVar( bool, m_isCurrentGunGameTeamLeader );
  648. CNetworkVar( float, m_flGuardianTooFarDistFrac );
  649. float m_flNextGuardianTooFarHurtTime;
  650. CNetworkVar( float, m_flDetectedByEnemySensorTime );
  651. void GiveHealthAndArmorForGuardianMode( bool bAdditive );
  652. int GetPlayerGunGameWeaponIndex( void ) { return m_iGunGameProgressiveWeaponIndex; }
  653. int GetNumGunGameTRKillPoints( void ) { return m_iNumGunGameTRKillPoints; }
  654. int GetNumRoundKills( void ) { return m_iNumRoundKills; }
  655. int GetNumRoundKillsHeadshots( void ) { return m_iNumRoundKillsHeadshots; }
  656. int GetNumGunGameKillsWithCurrentWeapon( void ) { return m_iNumGunGameKillsWithCurrentWeapon; }
  657. //--------------------------------------------------------------------------------------------------------
  658. void OnHealthshotUsed( void );
  659. bool UpdateTeamLeaderPlaySound( int nTeam );
  660. void UpdateLeader( void );
  661. void IncrementGunGameProgressiveWeapon( int nNumLevelsToIncrease );
  662. // [tj] overriding the base suicides to trash CS specific stuff
  663. virtual void CommitSuicide( bool bExplode = false, bool bForce = false );
  664. virtual void CommitSuicide( const Vector &vecForce, bool bExplode = false, bool bForce = false );
  665. void WieldingKnifeAndKilledByGun( bool bState ) { m_bWieldingKnifeAndKilledByGun = bState; }
  666. bool WasWieldingKnifeAndKilledByGun() { return m_bWieldingKnifeAndKilledByGun; }
  667. void RecordRebuyStructLastRound();
  668. void HandleEndOfRound();
  669. bool WasKilledThisRound(){return m_wasKilledThisRound;}
  670. void SetWasKilledThisRound(bool wasKilled);
  671. int GetMaxNumRoundsSurvived() {return m_maxNumRoundsSurvived;}
  672. int GetCurNumRoundsSurvived() {return m_numRoundsSurvived;}
  673. // [dwenger] adding tracking for weapon used fun fact
  674. void PlayerUsedFirearm( CBaseCombatWeapon* pBaseWeapon );
  675. void PlayerEmptiedAmmoForFirearm( CBaseCombatWeapon* pBaseWeapon );
  676. void PlayerOutOfAmmoForFirearm( CBaseCombatWeapon* pBaseWeapon );
  677. void PlayerHeldFirearm( CBaseCombatWeapon* pBaseWeapon );
  678. void AddBurnDamageDelt( int entityIndex);
  679. int GetNumPlayersDamagedWithFire();
  680. int GetNumFirearmsHeld() { return m_WeaponTypesHeld.Count(); }
  681. int GetNumFirearmsUsed() { return m_WeaponTypesUsed.Count(); }
  682. int GetNumFirearmsRanOutOfAmmo() { return m_WeaponTypesRunningOutOfAmmo.Count(); }
  683. bool DidPlayerEmptyAmmoForWeapon( CBaseCombatWeapon* pBaseWeapon );
  684. void SetLastWeaponBeforeAutoSwitchToC4( CBaseCombatWeapon * weapon ){m_lastWeaponBeforeC4AutoSwitch = weapon;}
  685. CBaseCombatWeapon* GetLastWeaponBeforeAutoSwitchToC4( void ){return m_lastWeaponBeforeC4AutoSwitch;}
  686. void RestoreWeaponOnC4Abort();
  687. void PlayerUsedGrenade( int nWeaponID );
  688. void PlayerUsedKnife( void );
  689. void ImpactTrace( trace_t *pTrace, int iDamageType, char *pCustomImpactName );
  690. bool HasHeavyArmor() const {return m_bHasHeavyArmor;}
  691. CNetworkVar( bool, m_bHasHelmet ); // Does the player have helmet armor
  692. CNetworkVar( bool, m_bHasHeavyArmor ); // Does the player have heavy armor?
  693. bool m_bEscaped; // Has this terrorist escaped yet?
  694. // Other variables.
  695. bool m_bIsVIP; // Are we the VIP?
  696. int m_iNumSpawns; // Number of times player has spawned this round
  697. int m_iOldTeam; // Keep what team they were last on so we can allow joining spec and switching back to their real team
  698. bool m_bTeamChanged; // Just allow one team change per round
  699. int m_iShouldHaveCash;
  700. bool m_bHasSeenJoinGame; // Since creation, have we seen a joingame command for this player?
  701. int m_iLastTeam; // Last team on which this player was a member
  702. bool m_bJustKilledTeammate;
  703. bool m_bPunishedForTK;
  704. bool m_bInvalidSteamLogonDelayed;
  705. int m_iTeamKills;
  706. float m_flLastAction;
  707. int m_iNextTimeCheck; // Next time the player can execute a "timeleft" command
  708. float m_flNameChangeHistory[NAME_CHANGE_HISTORY_SIZE]; // index 0 = most recent change
  709. bool CanChangeName( void ); // Checks if the player can change his name
  710. void ChangeName( const char *pszNewName );
  711. void SetClanTag( const char *pTag );
  712. const char *GetClanTag( void ) const;
  713. void SetClanName( const char *pName );
  714. const char *GetClanName( void ) const;
  715. void InitTeammatePreferredColor();
  716. void SetTeammatePreferredColor( int nColor );
  717. int GetTeammatePreferredColor( void ) const;
  718. //RecvPropEHandle( RECVINFO(m_hCarriedHostage) ),
  719. CNetworkVar( bool, m_bHasDefuser ); // Does this player have a defuser kit?
  720. float m_fLastGivenDefuserTime; // the last time this player received the defuser
  721. float m_fLastGivenBombTime; // the last time this player received the bomb
  722. CNetworkVar( bool, m_bHasNightVision ); // Does this player have night vision?
  723. CNetworkVar( bool, m_bNightVisionOn ); // Is the NightVision turned on ?
  724. float m_fNextRadarUpdateTime;
  725. float m_flLastMoneyUpdateTime;
  726. // Backup copy of the menu text so the player can change this and the menu knows when to update.
  727. char m_MenuStringBuffer[MENU_STRING_BUFFER_SIZE];
  728. // When the player joins, it cycles their view between trigger_camera entities.
  729. // This is the current camera, and the time that we'll switch to the next one.
  730. EHANDLE m_pIntroCamera;
  731. float m_fIntroCamTime;
  732. // Set to true each frame while in a bomb zone.
  733. // Reset after prediction (in PostThink).
  734. CNetworkVar( bool, m_bInBombZone );
  735. CNetworkVar( bool, m_bInBuyZone );
  736. // See if we need to prevent player from being able to diffuse bomb.
  737. CNetworkVar( bool, m_bInNoDefuseArea );
  738. CNetworkVar( bool, m_bKilledByTaser );
  739. CNetworkVar( int, m_iMoveState ); // Is the player trying to run? Used for state transitioning after a player lands from a jump etc.
  740. CNetworkString( m_szArmsModel, MAX_MODEL_STRING_SIZE ); // Which arms we're using for the view model.
  741. // Match Stats data
  742. CNetworkArray( int, m_iMatchStats_Kills, MAX_MATCH_STATS_ROUNDS ); //kills, per round
  743. CNetworkArray( int, m_iMatchStats_Damage, MAX_MATCH_STATS_ROUNDS ); //damage, per round
  744. CNetworkArray( int, m_iMatchStats_EquipmentValue, MAX_MATCH_STATS_ROUNDS ); //Equipment value, per round
  745. CNetworkArray( int, m_iMatchStats_MoneySaved, MAX_MATCH_STATS_ROUNDS ); //Saved money, per round
  746. CNetworkArray( int, m_iMatchStats_KillReward, MAX_MATCH_STATS_ROUNDS ); //Money earned from kills, per round
  747. CNetworkArray( int, m_iMatchStats_LiveTime, MAX_MATCH_STATS_ROUNDS ); //Time spent alive, per round
  748. CNetworkArray( int, m_iMatchStats_Deaths, MAX_MATCH_STATS_ROUNDS ); //Deaths
  749. CNetworkArray( int, m_iMatchStats_Assists, MAX_MATCH_STATS_ROUNDS ); //Assists
  750. CNetworkArray( int, m_iMatchStats_HeadShotKills, MAX_MATCH_STATS_ROUNDS ); // Head shot kills
  751. CNetworkArray( int, m_iMatchStats_Objective, MAX_MATCH_STATS_ROUNDS ); // successful objectives ( bomb plants, defuses, hostage rescues )
  752. CNetworkArray( int, m_iMatchStats_CashEarned, MAX_MATCH_STATS_ROUNDS ); // Cash awards
  753. CNetworkArray( int, m_iMatchStats_UtilityDamage, MAX_MATCH_STATS_ROUNDS ); // Grenade etc damage
  754. CNetworkArray( int, m_iMatchStats_EnemiesFlashed, MAX_MATCH_STATS_ROUNDS ); // Enemies flashed
  755. bool m_bUseNewAnimstate;
  756. virtual void SetModel( const char *szModelName );
  757. virtual Vector Weapon_ShootPosition();
  758. int m_iBombSiteIndex;
  759. // keep track of when we enter and exit a bombzone
  760. bool m_bInBombZoneTrigger;
  761. bool m_bWasInBombZoneTrigger;
  762. bool m_bWasInHostageRescueZone;
  763. // keep track of when we enter and exit a buyzone
  764. bool m_bWasInBuyZone;
  765. bool IsInBuyZone();
  766. bool IsInBuyPeriod();
  767. bool CanBuyDuringImmunity();
  768. bool CanPlayerBuy( bool display );
  769. CNetworkVar( bool, m_bInHostageRescueZone );
  770. void RescueZoneTouch( inputdata_t &inputdata );
  771. CNetworkVar( float, m_flStamina );
  772. CNetworkVar( int, m_iDirection ); // The current lateral kicking direction; 1 = right, 0 = left
  773. CNetworkVar( int, m_iShotsFired ); // number of shots fired recently (seems inconsistent, based on specific weapons incrementing this value)
  774. CNetworkVar( int, m_nNumFastDucks ); // UNUSED. Kept for backwards demo compatibility. $$$REI TODO: Investigate safely removing variables
  775. CNetworkVar( bool, m_bDuckOverride ); // force the player to duck regardless of if they're holding crouch
  776. // Make sure to register changes for armor.
  777. IMPLEMENT_NETWORK_VAR_FOR_DERIVED( m_ArmorValue );
  778. float m_flFlinchStack; // we add to this stack everytime we take damage that would "tag" us - decays constantly
  779. CNetworkVar( float, m_flVelocityModifier );
  780. void SetFlinchVelocityModifier( float fVelocityModifier )
  781. {
  782. // this function only allows more flinch (smaller values) to be applied, not less
  783. m_flVelocityModifier = Min(m_flVelocityModifier.Get(), fVelocityModifier);
  784. }
  785. CNetworkVar( float, m_flGroundAccelLinearFracLastTime );
  786. int m_iHostagesKilled;
  787. int m_bulletsFiredSinceLastSpawn;
  788. void SetShieldDrawnState( bool bState );
  789. void DropShield( void );
  790. char m_szNewName [MAX_PLAYER_NAME_LENGTH]; // not empty if player requested a namechange
  791. char m_szClanTag[MAX_CLAN_TAG_LENGTH];
  792. char m_szClanName[MAX_TEAM_NAME_LENGTH];
  793. Vector m_vecTotalBulletForce; //Accumulator for bullet force in a single frame
  794. // preferred teammate color that user has set for themselves
  795. int m_iTeammatePreferredColor;
  796. CNetworkVar( float, m_flFlashDuration );
  797. CNetworkVar( float, m_flFlashMaxAlpha );
  798. CNetworkVar( float, m_flProgressBarStartTime );
  799. CNetworkVar( int, m_iProgressBarDuration );
  800. CNetworkVar( int, m_iThrowGrenadeCounter ); // used to trigger grenade throw animations.
  801. CNetworkVar( bool, m_bWaitForNoAttack ); // flag to indicate player cannot attack until the attack button is released
  802. CNetworkVar( bool, m_bIsRespawningForDMBonus ); // flag to indicate player wants to spawn with the deathmatch bonus weapons
  803. CNetworkVar( float, m_flLowerBodyYawTarget );
  804. CNetworkVar( bool, m_bStrafing );
  805. // Tracks our ragdoll entity.
  806. CNetworkHandle( CBaseEntity, m_hRagdoll ); // networked entity handle
  807. // Bots and hostages auto-duck during jumps
  808. bool m_duckUntilOnGround;
  809. Vector m_lastStandingPos; // used by the gamemovement code for finding ladders
  810. void SurpressLadderChecks( const Vector& pos, const Vector& normal );
  811. bool CanGrabLadder( const Vector& pos, const Vector& normal );
  812. void ClearGunGameImmunity( void );
  813. void ClearGunGameProgressiveWeaponIndex( void ) { m_iGunGameProgressiveWeaponIndex = 0; }
  814. void ResetTRBombModeWeaponProgressFlag( void ) { m_bShouldProgressGunGameTRBombModeWeapon = false; }
  815. void ResetTRBombModeKillPoints( void ) { m_iNumGunGameTRKillPoints = 0; }
  816. void SwitchTeamsAtRoundReset( void ) { m_switchTeamsOnNextRoundReset = true; }
  817. bool WillSwitchTeamsAtRoundReset( void ) { return m_switchTeamsOnNextRoundReset; }
  818. void ResetTRBombModeData( void );
  819. void SetPickedUpWeaponThisRound( bool pickedUp ){m_bPickedUpWeapon = pickedUp;}
  820. bool GetPickedUpWeaponThisRound( void ){return m_bPickedUpWeapon;}
  821. bool CanUseGrenade( CSWeaponID );
  822. bool CSWeaponDrop( CBaseCombatWeapon *pWeapon, bool bDropShield = true, bool bThrow = false );
  823. bool CSWeaponDrop( CBaseCombatWeapon *pWeapon, Vector targetPos, bool bDropShield = true );
  824. bool HandleDropWeapon( CBaseCombatWeapon *pWeapon = NULL, bool bSwapping = false );
  825. void SetViewModelArms( const char *armsModel );
  826. void ReportCustomClothingModels( void );
  827. void DestroyWeapon( CBaseCombatWeapon *pWeapon );
  828. void DestroyWeapons( bool bDropC4 = true );
  829. bool IsPlayerSpawning( void ) { return m_bIsSpawning; }
  830. void SetPlayerSpawning( bool bIsSpawning ) { m_bIsSpawning = bIsSpawning; }
  831. private:
  832. CountdownTimer m_ladderSurpressionTimer;
  833. Vector m_lastLadderNormal;
  834. Vector m_lastLadderPos;
  835. protected:
  836. void CreateRagdollEntity();
  837. bool IsHittingShield( const Vector &vecDirection, trace_t *ptr );
  838. void PhysObjectSleep();
  839. void PhysObjectWake();
  840. bool RunMimicCommand( CUserCmd& cmd );
  841. bool SelectSpawnSpot( const char *pEntClassName, CBaseEntity* &pSpot );
  842. void SetModelFromClass( void );
  843. CNetworkVar( int, m_iClass ); // One of the CS_CLASS_ enums.
  844. void TransferInventory( CCSPlayer* pTargetPlayer );
  845. bool DropWeaponSlot( int nSlot, bool fromDeath = false );
  846. void DropWeapons( bool fromDeath, bool killedByEnemy );
  847. virtual int SpawnArmorValue( void ) const { return ArmorValue(); }
  848. bool BAttemptToBuyCheckSufficientBalance( int nCostOfPurchaseToCheck, bool bClientPrint = true );
  849. BuyResult_e AttemptToBuyAmmo( int iAmmoType );
  850. BuyResult_e AttemptToBuyAmmoSingle( int iAmmoType );
  851. BuyResult_e AttemptToBuyVest( void );
  852. BuyResult_e AttemptToBuyAssaultSuit( void );
  853. BuyResult_e AttemptToBuyHeavyAssaultSuit( void );
  854. BuyResult_e AttemptToBuyDefuser( void );
  855. BuyResult_e AttemptToBuyNightVision( void );
  856. BuyResult_e BuyAmmo( int nSlot, bool bBlinkMoney );
  857. BuyResult_e BuyGunAmmo( CBaseCombatWeapon *pWeapon, bool bBlinkMoney );
  858. void InternalAutoBuyAmmo( int slot );
  859. void PushawayThink();
  860. private:
  861. IPlayerAnimState *m_PlayerAnimState;
  862. CCSGOPlayerAnimState *m_PlayerAnimStateCSGO;
  863. // Aiming heuristics code
  864. float m_flIdleTime; //Amount of time we've been motionless
  865. float m_flMoveTime; //Amount of time we've been in motion
  866. float m_flLastDamageTime; //Last time we took damage
  867. float m_flTargetFindTime;
  868. int m_lastDamageHealth; // Last damage given to our health
  869. int m_lastDamageArmor; // Last damage given to our armor
  870. bool m_bPickedUpWeapon;
  871. bool m_bPickedUpDefuser; // Did player pick up the defuser kit as opposed to buying it?
  872. bool m_bDefusedWithPickedUpKit; // Did player defuse the bomb with a picked-up defuse kit?
  873. bool m_bAttemptedDefusal;
  874. int m_nPreferredGrenadeDrop;
  875. float m_flDefusedBombWithThisTimeRemaining;
  876. // Last usercmd we shot a bullet on.
  877. int m_iLastWeaponFireUsercmd;
  878. // Copyed from EyeAngles() so we can send it to the client.
  879. CNetworkVectorXYZ( m_angEyeAngles );
  880. bool m_bVCollisionInitted;
  881. Vector m_storedSpawnPosition;
  882. QAngle m_storedSpawnAngle;
  883. bool m_bIsSpawning;
  884. public:
  885. CNetworkVar( float, m_flThirdpersonRecoil );
  886. // AutoBuy functions.
  887. public:
  888. void AutoBuy( const char *autobuyString ); // this should take into account what the player can afford and should buy the best equipment for them.
  889. bool IsInAutoBuy( void ) { return m_bIsInAutoBuy; }
  890. bool IsInReBuy( void ) { return m_bIsInRebuy; }
  891. int GetAccountBalance( );
  892. private:
  893. bool ShouldExecuteAutoBuyCommand(const AutoBuyInfoStruct *commandInfo, bool boughtPrimary, bool boughtSecondary);
  894. void PostAutoBuyCommandProcessing(const AutoBuyInfoStruct *commandInfo, bool &boughtPrimary, bool &boughtSecondary);
  895. void ParseAutoBuyString(const char *string, bool &boughtPrimary, bool &boughtSecondary);
  896. AutoBuyInfoStruct *GetAutoBuyCommandInfo(const char *command);
  897. void PrioritizeAutoBuyString(char *autobuyString, const char *priorityString); // reorders the tokens in autobuyString based on the order of tokens in the priorityString.
  898. BuyResult_e CombineBuyResults( BuyResult_e prevResult, BuyResult_e newResult );
  899. bool m_bIsInAutoBuy;
  900. bool m_bAutoReload;
  901. //ReBuy functions
  902. public:
  903. void Rebuy( const char *rebuyString );
  904. bool AttemptToBuyDMBonusWeapon( void );
  905. private:
  906. void AddToRebuy( CSWeaponID weaponId, int nPos );
  907. void AddToGrenadeRebuy( CSWeaponID weaponId );
  908. BuyResult_e RebuyPrimaryWeapon();
  909. BuyResult_e RebuySecondaryWeapon();
  910. BuyResult_e RebuyTaser();
  911. BuyResult_e RebuyGrenade( CSWeaponID weaponId );
  912. BuyResult_e RebuyDefuser();
  913. BuyResult_e RebuyNightVision();
  914. BuyResult_e RebuyArmor();
  915. bool m_bIsInRebuy;
  916. RebuyStruct m_rebuyStruct;
  917. RebuyStruct m_rebuyStructLastRound;
  918. bool m_bUsingDefaultPistol;
  919. bool m_bIsBeingGivenItem;
  920. //BuyRandom functions
  921. public:
  922. void BuyRandom();
  923. #ifdef CS_SHIELD_ENABLED
  924. CNetworkVar( bool, m_bHasShield );
  925. CNetworkVar( bool, m_bShieldDrawn );
  926. #endif
  927. CNetworkVar( bool, m_bHud_MiniScoreHidden );
  928. CNetworkVar( bool, m_bHud_RadarHidden );
  929. CNetworkVar( int, m_nLastKillerIndex );
  930. CNetworkVar( int, m_nLastConcurrentKilled );
  931. CNetworkVar( int, m_nDeathCamMusic ); // this players deathcam music index
  932. // This is a combination of the ADDON_ flags in cs_shareddefs.h.
  933. CNetworkVar( int, m_iAddonBits );
  934. // Clients don't know about holstered weapons, so we need to tell them the weapon type here
  935. CNetworkVar( int, m_iPrimaryAddon );
  936. CNetworkVar( int, m_iSecondaryAddon );
  937. CNetworkVar( int, m_iAccount ); // How much cash this player has.
  938. int m_iAccountMoneyEarnedForNextRound; // How much of this player's cash cannot be used during this round (kill rewards, suicide rewards, etc.)
  939. CNetworkVar( int, m_iStartAccount ); // How much cash this player started the round with
  940. CNetworkVar( int, m_totalHitsOnServer ); // used to compare against client's hit counts to see how 'wrong' the client was.
  941. //Damage record functions
  942. public:
  943. static void StartNewBulletGroup(); // global function
  944. static uint32 GetBulletGroup(); // global function
  945. static void ResetBulletGroup(); // global function, called at the beginning of every match
  946. void RecordDamage( CCSPlayer* damageDealer, CCSPlayer* damageTaker, int iDamageDealt, int iActualHealthRemoved );
  947. void ResetDamageCounters(); //Reset all lists
  948. void RemoveSelfFromOthersDamageCounters(); // Additional cleanup to damage counters when not in a round respawn mode.
  949. void OutputDamageTaken( void );
  950. void OutputDamageGiven( void );
  951. void SendLastKillerDamageToClient( CCSPlayer *pLastKiller );
  952. void StockPlayerAmmo( CBaseCombatWeapon *pNewWeapon = NULL );
  953. CUtlLinkedList< CDamageRecord *, int >& GetDamageList() {return m_DamageList;}
  954. int GetNumAttackersFromDamageList( void );
  955. int GetMostNumHitsDamageRecordFrom( CCSPlayer *pAttacker );
  956. int m_nTeamDamageGivenForMatch;
  957. bool m_bTDGaveProtectionWarning;
  958. bool m_bTDGaveProtectionWarningThisRound;
  959. private:
  960. //A unified list of recorded damage that includes giver and taker in each entry
  961. CUtlLinkedList< CDamageRecord *, int > m_DamageList;
  962. protected:
  963. float m_flLastTHWarningTime;
  964. float m_applyDeafnessTime;
  965. int m_currentDeafnessFilter;
  966. bool m_isVIP;
  967. // Command rate limiting.
  968. private:
  969. bool ShouldRunRateLimitedCommand( const CCommand &args );
  970. // This lets us rate limit the commands the players can execute so they don't overflow things like reliable buffers.
  971. CUtlDict<float,int> m_RateLimitLastCommandTimes;
  972. CNetworkVar(int, m_cycleLatch); // Every so often, we are going to transmit our cycle to the client to correct divergence caused by PVS changes
  973. CountdownTimer m_cycleLatchTimer;
  974. public:
  975. void ResetRoundBasedAchievementVariables();
  976. void OnRoundEnd(int winningTeam, int reason);
  977. void OnPreResetRound();
  978. void DecrementProgressiveWeaponFromSuicide( void );
  979. int GetNumEnemyDamagers();
  980. int GetNumEnemiesDamaged();
  981. int GetTotalActualHealthRemovedFromEnemies();
  982. CBaseEntity* GetNearestSurfaceBelow(float maxTrace);
  983. // Returns the % of the enemies this player killed in the round
  984. int GetPercentageOfEnemyTeamKilled();
  985. //List of times of recent kills to check for sprees
  986. CUtlVector<float> m_killTimes;
  987. //List of all players killed this round
  988. CUtlVector<CHandle<CCSPlayer> > m_enemyPlayersKilledThisRound;
  989. //List of weapons we have used to kill players with this round
  990. CUtlVector<int> m_killWeapons;
  991. //List of weapons we have used to kill players with this match
  992. CUtlVector<int> m_uniqueKillWeaponsMatch;
  993. bool m_bLastKillUsedUniqueWeaponMatch;
  994. int m_NumEnemiesKilledThisSpawn;
  995. int m_maxNumEnemiesKillStreak;
  996. int m_NumEnemiesKilledThisRound;
  997. int m_NumEnemiesAtRoundStart;
  998. int m_KillingSpreeStartTime;
  999. int m_NumChickensKilledThisSpawn;
  1000. bool m_bLastKillUsedUniqueWeapon;
  1001. int m_iRoundsWon;
  1002. float m_firstKillBlindStartTime; //This is the start time of the blind effect during which we got our most recent kill.
  1003. int m_killsWhileBlind;
  1004. int m_bombCarrierkills;
  1005. CNetworkVar( bool, m_bIsRescuing ); // tracks whether a player is currently rescuing a hostage :: Networked to provide access at OGS RoundData recording time
  1006. //bool m_bIsRescuing; // tracks whether this player is currently rescuing a hostage
  1007. bool m_bInjuredAHostage; // tracks whether this player injured a hostage
  1008. int m_iNumFollowers; // Number of hostages following this player
  1009. bool m_bSurvivedHeadshotDueToHelmet;
  1010. bool m_knifeKillBombPlacer;
  1011. bool m_attemptedBombPlace;
  1012. int m_knifeKillsWhenOutOfAmmo;
  1013. bool m_triggerPulled;
  1014. int m_triggerPulls;
  1015. bool m_bHasUsedDMBonusRespawn;
  1016. // mainly fun-fact/achievement related values below
  1017. int GetKnifeKillsWhenOutOfAmmo() { return m_knifeKillsWhenOutOfAmmo; }
  1018. void IncrKnifeKillsWhenOutOfAmmo() { m_knifeKillsWhenOutOfAmmo++; }
  1019. bool HasAttemptedBombPlace(){ return m_attemptedBombPlace; }
  1020. void SetAttemptedBombPlace(){ m_attemptedBombPlace = true; }
  1021. int GetNumBombCarrierKills( void ) { return m_bombCarrierkills; }
  1022. void IncrementNumFollowers() { m_iNumFollowers++; }
  1023. void DecrementNumFollowers() { m_iNumFollowers--; if (m_iNumFollowers < 0) m_iNumFollowers = 0; }
  1024. int GetNumFollowers() { return m_iNumFollowers; }
  1025. void SetIsRescuing(bool in_bRescuing) { m_bIsRescuing = in_bRescuing; }
  1026. bool IsRescuing() { return m_bIsRescuing; }
  1027. void SetInjuredAHostage(bool in_bInjured) { m_bInjuredAHostage = in_bInjured; }
  1028. bool InjuredAHostage() { return m_bInjuredAHostage; }
  1029. bool PlacedBombThisRound() { return (GetBombPlacedTime() >= 0.0f); }
  1030. float GetBombPickuptime() { return m_bombPickupTime; }
  1031. float GetBombPlacedTime() {return m_bombPlacedTime; }
  1032. float GetBombDroppedTime() {return m_bombDroppedTime; }
  1033. void SetBombPickupTime(float time) { m_bombPickupTime = time; }
  1034. void SetBombPlacedTime( float time) { m_bombPlacedTime = time; }
  1035. void SetBombDroppedTime( float time) { m_bombDroppedTime = time; }
  1036. void SetKnifeLevelKilledBombPlacer( void ) { m_knifeKillBombPlacer = true; }
  1037. bool GetKnifeLevelKilledBombPlacer() {return m_knifeKillBombPlacer; }
  1038. CCSPlayer* GetLastFlashbangAttacker() { return m_lastFlashBangAttacker; }
  1039. void SetLastFlashbangAttacker(CCSPlayer* attacker) { m_lastFlashBangAttacker = attacker; }
  1040. float GetKilledTime( void ) { return m_killedTime; }
  1041. void SetKilledTime( float time );
  1042. static const CCSWeaponInfo* GetWeaponInfoFromDamageInfo( const CTakeDamageInfo &info );
  1043. static void ProcessPlayerDeathAchievements( CCSPlayer *pAttacker, CCSPlayer *pVictim, const CTakeDamageInfo &info );
  1044. float GetLongestSurvivalTime( void ) { return m_longestLife; }
  1045. void OnCanceledDefuse();
  1046. void OnStartedDefuse();
  1047. GooseChaseAchievementStep m_gooseChaseStep;
  1048. DefuseDefenseAchivementStep m_defuseDefenseStep;
  1049. CHandle<CCSPlayer> m_pGooseChaseDistractingPlayer;
  1050. int m_lastRoundResult; //save the reason for the last round ending.
  1051. bool m_bMadeFootstepNoise;
  1052. float m_bombPickupTime;
  1053. float m_bombPlacedTime;
  1054. float m_bombDroppedTime;
  1055. float m_killedTime;
  1056. float m_spawnedTime;
  1057. float m_longestLife;
  1058. bool m_bMadePurchseThisRound;
  1059. int m_roundsWonWithoutPurchase;
  1060. bool m_bKilledDefuser;
  1061. bool m_bKilledRescuer;
  1062. int m_maxGrenadeKills;
  1063. int m_grenadeDamageTakenThisRound;
  1064. int m_firstShotKills;
  1065. bool m_hasReloaded;
  1066. void SetHasReloaded(){m_hasReloaded = true;}
  1067. bool HasReloaded(){return m_hasReloaded;}
  1068. void IncrementFirstShotKills(int amount){m_firstShotKills += amount;}
  1069. void ResetFirstShotKills(){m_firstShotKills = 0;}
  1070. int GetFirstShotKills(){return m_firstShotKills;}
  1071. bool GetKilledDefuser() { return m_bKilledDefuser; }
  1072. bool GetKilledRescuer() { return m_bKilledRescuer; }
  1073. int GetMaxGrenadeKills() { return m_maxGrenadeKills; }
  1074. void CheckMaxGrenadeKills(int grenadeKills);
  1075. CHandle<CCSPlayer> m_lastFlashBangAttacker;
  1076. void SetPlayerDominated( CCSPlayer *pPlayer, bool bDominated );
  1077. void SetPlayerDominatingMe( CCSPlayer *pPlayer, bool bDominated );
  1078. bool IsPlayerDominated( int iPlayerIndex );
  1079. bool IsPlayerDominatingMe( int iPlayerIndex );
  1080. bool m_wasNotKilledNaturally; //Set if the player is dead from a kill command or late login
  1081. bool WasNotKilledNaturally() { return m_wasNotKilledNaturally; }
  1082. void SetNumMVPs( int iNumMVP );
  1083. void IncrementNumMVPs( CSMvpReason_t mvpReason );
  1084. int GetNumMVPs();
  1085. void SetEnemyKillTrackInfo( int iEnemyKills, int iEnemyKillHeadshots, int iEnemy3Ks, int iEnemy4Ks, int iEnemy5Ks, int iEnemyKillsAgg ) { m_iEnemyKills = iEnemyKills; m_iEnemyKillHeadshots = iEnemyKillHeadshots; m_iEnemy3Ks = iEnemy3Ks; m_iEnemy4Ks = iEnemy4Ks; m_iEnemy5Ks = iEnemy5Ks; m_iEnemyKillsAgg = iEnemyKillsAgg; }
  1086. void GetEnemyKillTrackInfo( int &iEnemyKills, int &iEnemyKillHeadshots, int &iEnemy3Ks, int &iEnemy4Ks, int &iEnemy5Ks, int &iEnemyKillsAgg ) { iEnemyKills = m_iEnemyKills; iEnemyKillHeadshots = m_iEnemyKillHeadshots; iEnemy3Ks = m_iEnemy3Ks; iEnemy4Ks = m_iEnemy4Ks; iEnemy5Ks = m_iEnemy5Ks; iEnemyKillsAgg = m_iEnemyKillsAgg; }
  1087. void SetEnemyFirstKills( int numFirstKills, int numClutchKills ) { m_numFirstKills = numFirstKills; m_numClutchKills = numClutchKills; }
  1088. void GetEnemyFirstKills( int &numFirstKills, int &numClutchKills ) { numFirstKills = m_numFirstKills; numClutchKills = m_numClutchKills; }
  1089. void SetEnemyWeaponKills( int numPistolKills, int numSniperKills ) { m_numPistolKills = numPistolKills; m_numSniperKills = numSniperKills; }
  1090. void GetEnemyWeaponKills( int &numPistolKills, int &numSniperKills ) { numPistolKills = m_numPistolKills; numSniperKills = m_numSniperKills; }
  1091. void ClearRoundContributionScore( void ) { m_iRoundContributionScore = 0; }
  1092. void AddRoundContributionScore( int iPoints );
  1093. int GetRoundContributionScore( void ) { return m_iRoundContributionScore; }
  1094. void ClearRoundProximityScore( void ){ m_iRoundProximityScore = 0; }
  1095. void AddRoundProximityScore( int iPoints );
  1096. int GetRoundProximityScore( void ) { return m_iRoundProximityScore ; }
  1097. void ClearScore( void );
  1098. void AddScore( int iPoints );
  1099. #define USE_OLD_SCORE_SYSTEM 0
  1100. #if ( USE_OLD_SCORE_SYSTEM )
  1101. int GetScore() const { return m_iScore; }
  1102. #else
  1103. int GetScore() const { return m_iContributionScore; }
  1104. #endif
  1105. int GetContributionScore( void ) { return m_iContributionScore; }
  1106. void ClearContributionScore( void ){ m_iContributionScore = 0; pl.score = 0; }
  1107. void AddContributionScore( int iPoints );
  1108. uint32 GetHumanPlayerAccountID() const { return m_uiAccountId; }
  1109. void SetHumanPlayerAccountID( uint32 uiAccountId );
  1110. void RemoveNemesisRelationships();
  1111. void SetDeathFlags( int iDeathFlags ) { m_iDeathFlags = iDeathFlags; }
  1112. int GetDeathFlags() { return m_iDeathFlags; }
  1113. int GetNumBotsControlled( void ) { return m_botsControlled; }
  1114. int GetNumFootsteps( void ) { return m_iFootsteps; }
  1115. int GetMediumHealthKills( void ) { return m_iMediumHealthKills; }
  1116. int GetTotalCashSpent( void ) { return m_iTotalCashSpent; }
  1117. int GetCashSpentThisRound( void ) { return m_iCashSpentThisRound; }
  1118. int GetEndMatchNextMapVote( void ) { return m_nEndMatchNextMapVote; }
  1119. void ClearTRModeHEGrenade( void ) { m_bGunGameTRModeHasHEGrenade = false; }
  1120. void ClearTRModeFlashbang( void ) { m_bGunGameTRModeHasFlashbang = false; }
  1121. void ClearTRModeMolotov( void ) { m_bGunGameTRModeHasMolotov = false; }
  1122. void ClearTRModeIncendiary( void ) { m_bGunGameTRModeHasIncendiary = false; }
  1123. private:
  1124. CNetworkArray( bool, m_bPlayerDominated, MAX_PLAYERS+1 ); // array of state per other player whether player is dominating other players
  1125. CNetworkArray( bool, m_bPlayerDominatingMe, MAX_PLAYERS+1 ); // array of state per other player whether other players are dominating this player
  1126. CNetworkArray( int, m_iWeaponPurchasesThisRound, MAX_WEAPONS ); // number of times weapons purchased this round; used to limit repurchases
  1127. CNetworkVar( bool, m_bIsTaunting );
  1128. CNetworkVar( bool, m_bIsThirdPersonTaunt );
  1129. CNetworkVar( bool, m_bIsHoldingTaunt );
  1130. CNetworkVar( float, m_flTauntYaw );
  1131. CNetworkVar( bool, m_bIsLookingAtWeapon );
  1132. CNetworkVar( bool, m_bIsHoldingLookAtWeapon );
  1133. float m_flTauntEndTime;
  1134. float m_flLookWeaponEndTime;
  1135. bool m_bMustNotMoveDuringTaunt;
  1136. // [menglish] number of rounds this player has caused to be won for their team
  1137. int m_iMVPs;
  1138. uint32 m_uiAccountId;
  1139. // Competitive scorecard tracking information
  1140. int m_iEnemyKills;
  1141. int m_iEnemyKillHeadshots;
  1142. int m_iEnemy3Ks;
  1143. int m_iEnemy4Ks;
  1144. int m_iEnemy5Ks;
  1145. int m_iEnemyKillsAgg;
  1146. int m_numFirstKills;
  1147. int m_numClutchKills;
  1148. int m_numPistolKills;
  1149. int m_numSniperKills;
  1150. // [pfreese] new contribution score system
  1151. int m_iScore;
  1152. int m_iRoundProximityScore;
  1153. int m_iRoundContributionScore;
  1154. int m_iContributionScore;
  1155. // [dwenger] adding tracking for fun fact
  1156. bool m_bWieldingKnifeAndKilledByGun;
  1157. int m_botsControlled;
  1158. int m_iFootsteps;
  1159. int m_iMediumHealthKills;
  1160. // tracking Money spent to calculate Cash Per Kill
  1161. int m_iTotalCashSpent;
  1162. // tracking just the cash spent in this round
  1163. int m_iCashSpentThisRound;
  1164. // this players vote for the next map in the mapgroup at the end of the match
  1165. int m_nEndMatchNextMapVote;
  1166. // [dkorus] achievement tracking
  1167. bool m_wasKilledThisRound;
  1168. int m_numRoundsSurvived;
  1169. int m_maxNumRoundsSurvived;
  1170. // [dwenger] adding tracking for which weapons this player has used in a round
  1171. CUtlVector<CSWeaponID> m_WeaponTypesUsed;
  1172. CUtlVector<CSWeaponID> m_WeaponTypesHeld;
  1173. CUtlVector<CSWeaponID> m_WeaponTypesRunningOutOfAmmo;
  1174. CUtlVector<int> m_BurnDamageDeltVec;
  1175. CBaseCombatWeapon* m_lastWeaponBeforeC4AutoSwitch;
  1176. int m_iDeathFlags; // Flags holding revenge and domination info about a death
  1177. // Track last damage type
  1178. int m_LastDamageType;
  1179. // Used to track whether or not a player in TR gun game mode has earned grenades
  1180. bool m_bGunGameTRModeHasHEGrenade;
  1181. bool m_bGunGameTRModeHasFlashbang;
  1182. bool m_bGunGameTRModeHasMolotov;
  1183. bool m_bGunGameTRModeHasIncendiary;
  1184. public:
  1185. bool IsAbleToInstantRespawn( void );
  1186. bool IsAssassinationTarget( void ) const;
  1187. char const * IsAbleToApplySpray( trace_t *ptr, Vector *pvecForward, Vector *pvecRight );
  1188. uint32 GetActiveQuestID( void ) const;
  1189. QuestProgress::Reason GetQuestProgressReason( void ) const;
  1190. private:
  1191. CNetworkVar( bool, m_bIsAssassinationTarget ); // This player is an assassination target for an active mission
  1192. #if CS_CONTROLLABLE_BOTS_ENABLED
  1193. public:
  1194. bool CanControlBot( CCSBot *pBot ,bool bSkipTeamCheck = false );
  1195. bool TakeControlOfBot( CCSBot *pBot, bool bSkipTeamCheck = false );
  1196. void ReleaseControlOfBot( void );
  1197. CCSBot* FindNearestControllableBot( bool bMustBeValidObserverTarget );
  1198. bool IsControllingBot( void ) const { return m_bIsControllingBot; }
  1199. bool HasControlledBot( void ) const { return m_hControlledBot.Get() != NULL; }
  1200. CCSPlayer* GetControlledBot( void ) const { return static_cast<CCSPlayer*>(m_hControlledBot.Get()); }
  1201. void SetControlledBot( CCSPlayer* pOther ) { m_hControlledBot = pOther; }
  1202. bool HasControlledByPlayer( void ) const { return m_hControlledByPlayer.Get() != NULL; }
  1203. CCSPlayer* GetControlledByPlayer( void ) const { return static_cast<CCSPlayer*>(m_hControlledByPlayer.Get()); }
  1204. void SetControlledByPlayer( CCSPlayer* pOther ) { m_hControlledByPlayer = pOther; }
  1205. bool HasBeenControlledThisRound( void ) { return m_bHasBeenControlledByPlayerThisRound; }
  1206. bool HasControlledBotThisRound( void ) {return m_bHasControlledBotThisRound;}
  1207. private:
  1208. CNetworkVar( bool, m_bIsControllingBot ); // Are we controlling a bot?
  1209. // Note that this can be TRUE even if GetControlledPlayer() returns NULL,
  1210. // IFF we started controlling a bot and then the bot was deleted for some reason.
  1211. CNetworkVar( bool, m_bCanControlObservedBot ); // set to true if we can take control of the bot we are observing, for client UI feedback.
  1212. CNetworkVar( int, m_iControlledBotEntIndex); // Are we controlling a bot?
  1213. CHandle<CCSPlayer> m_hControlledBot; // The is the OTHER player that THIS player is controlling
  1214. CHandle<CCSPlayer> m_hControlledByPlayer; // This is the OTHER player that is controlling THIS player
  1215. bool m_bHasBeenControlledByPlayerThisRound;
  1216. CNetworkVar( bool, m_bHasControlledBotThisRound );
  1217. // Various values from this character before they took control or were controlled
  1218. struct PreControlData
  1219. {
  1220. int m_iClass; // CS class (such as CS_CLASS_PHOENIX_CONNNECTION or CS_CLASS_SEAL_TEAM_6)
  1221. int m_iAccount; // money
  1222. int m_iAccountMoneyEarnedForNextRound; // money earned this round
  1223. int m_iFrags; // kills / score
  1224. int m_iAssists;
  1225. int m_iDeaths;
  1226. };
  1227. void SavePreControlData();
  1228. PreControlData m_PreControlData;
  1229. public:
  1230. PreControlData GetBotPreControlData( void ) { return m_PreControlData; }
  1231. #endif // #if CS_CONTROLLABLE_BOTS_ENABLED
  1232. #if !defined( NO_STEAM ) && !defined( NO_STEAM_GAMECOORDINATOR )
  1233. public:
  1234. // IHasAttributes
  1235. CAttributeManager *GetAttributeManager( void ) {
  1236. #if defined( USE_PLAYER_ATTRIBUTE_MANAGER )
  1237. return &m_AttributeManager;
  1238. #else
  1239. return NULL;
  1240. #endif
  1241. }
  1242. CAttributeContainer *GetAttributeContainer( void ) { return NULL; }
  1243. CBaseEntity *GetAttributeOwner( void ) { return NULL; }
  1244. CAttributeList *GetAttributeList( void ) {
  1245. #if defined( USE_PLAYER_ATTRIBUTE_MANAGER )
  1246. return &m_AttributeList;
  1247. #else
  1248. return NULL;
  1249. #endif
  1250. }
  1251. virtual void ReapplyProvision( void ) { return; }
  1252. #if defined( USE_PLAYER_ATTRIBUTE_MANAGER )
  1253. protected:
  1254. CNetworkVarEmbedded( CAttributeContainerPlayer, m_AttributeManager );
  1255. #endif
  1256. //----------------------------
  1257. // ECONOMY INVENTORY MANAGEMENT
  1258. public:
  1259. // IInventoryUpdateListener
  1260. virtual void InventoryUpdated( CPlayerInventory *pInventory );
  1261. virtual void SOCacheUnsubscribed( const CSteamID & steamIDOwner ) { /*m_Shared.SetLoadoutUnavailable( true );*/ }
  1262. void VerifySOCache();
  1263. #endif //!defined( NO_STEAM ) && !defined( NO_STEAM_GAMECOORDINATOR )
  1264. void UpdateInventory( bool bInit );
  1265. // Inventory access
  1266. CCSPlayerInventory *Inventory( void ) { return &m_Inventory; }
  1267. const CCSPlayerInventory *Inventory( void ) const { return &m_Inventory; }
  1268. CEconItemView *GetEquippedItemInLoadoutSlot( int iLoadoutSlot ) { return Inventory()->GetInventoryItemByItemID( m_EquippedLoadoutItemIndices[iLoadoutSlot] ); }
  1269. CEconItemView *GetEquippedItemInLoadoutSlotOrBaseItem( int iLoadoutSlot );
  1270. uint32 RecalculateCurrentEquipmentValue( void );
  1271. void UpdateFreezetimeEndEquipmentValue( void );
  1272. //void UpdateAppearanceIndex( void );
  1273. private:
  1274. CCSPlayerInventory m_Inventory;
  1275. // Items that have been equipped on this player instance (the inventory loadout may have changed)
  1276. itemid_t m_EquippedLoadoutItemIndices[LOADOUT_POSITION_COUNT];
  1277. //uint16 m_unAppearanceIndex;
  1278. CNetworkVar( uint16, m_unCurrentEquipmentValue );
  1279. CNetworkVar( uint16, m_unRoundStartEquipmentValue );
  1280. CNetworkVar( uint16, m_unFreezetimeEndEquipmentValue );
  1281. private:
  1282. // override for weapon driving animations
  1283. bool UpdateLayerWeaponDispatch( CAnimationLayer *pLayer, int iSequence );
  1284. public:
  1285. virtual float GetLayerSequenceCycleRate( CAnimationLayer *pLayer, int iSequence );
  1286. bool GetBulletHitLocalBoneOffset( const trace_t &tr, int &boneIndexOut, Vector &vecPositionOut, QAngle &angAngleOut );
  1287. // Quest state
  1288. private:
  1289. // Can we make progress in our current quest? If not, why not?
  1290. CNetworkVar( QuestProgress::Reason, m_nQuestProgressReason );
  1291. };
  1292. inline CSPlayerState CCSPlayer::State_Get() const
  1293. {
  1294. return m_iPlayerState;
  1295. }
  1296. inline CCSPlayer *ToCSPlayer( CBaseEntity *pEntity )
  1297. {
  1298. if ( !pEntity || !pEntity->IsPlayer() )
  1299. return NULL;
  1300. return dynamic_cast<CCSPlayer*>( pEntity );
  1301. }
  1302. inline bool CCSPlayer::IsReloading( void ) const
  1303. {
  1304. CBaseCombatWeapon *gun = GetActiveWeapon();
  1305. if (gun == NULL)
  1306. return false;
  1307. return gun->m_bInReload;
  1308. }
  1309. inline bool CCSPlayer::IsProtectedByShield( void ) const
  1310. {
  1311. return HasShield() && IsShieldDrawn();
  1312. }
  1313. inline bool CCSPlayer::IsBlind( void ) const
  1314. {
  1315. return gpGlobals->curtime < m_blindUntilTime;
  1316. }
  1317. inline bool CCSPlayer::IsBlindForAchievement()
  1318. {
  1319. return (m_blindStartTime + m_flFlashDuration) > gpGlobals->curtime;
  1320. }
  1321. inline bool CCSPlayer::IsAutoFollowAllowed( void ) const
  1322. {
  1323. return (gpGlobals->curtime > m_allowAutoFollowTime);
  1324. }
  1325. inline void CCSPlayer::InhibitAutoFollow( float duration )
  1326. {
  1327. m_allowAutoFollowTime = gpGlobals->curtime + duration;
  1328. }
  1329. inline void CCSPlayer::AllowAutoFollow( void )
  1330. {
  1331. m_allowAutoFollowTime = 0.0f;
  1332. }
  1333. inline int CCSPlayer::GetClass( void ) const
  1334. {
  1335. return m_iClass;
  1336. }
  1337. inline int CCSPlayer::GetTeammatePreferredColor( void ) const
  1338. {
  1339. return m_iTeammatePreferredColor;
  1340. }
  1341. inline const char *CCSPlayer::GetClanTag( void ) const
  1342. {
  1343. return m_szClanTag;
  1344. }
  1345. inline const char *CCSPlayer::GetClanName( void ) const
  1346. {
  1347. return m_szClanName;
  1348. }
  1349. #endif //CS_PLAYER_H