1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#ifndef C_CS_PLAYER_H
#define C_CS_PLAYER_H
#ifdef _WIN32
#pragma once
#endif
#include "cs_playeranimstate.h"
#include "c_baseplayer.h"
#include "cs_shareddefs.h"
#include "weapon_csbase.h"
#include "baseparticleentity.h"
#include "beamdraw.h"
class C_PhysicsProp;
extern ConVar cl_disablefreezecam;
class CAddonModel
{
public:
CHandle<C_BaseAnimating> m_hEnt; // The model for the addon.
int m_iAddon; // One of the ADDON_ bits telling which model this is.
int m_iAttachmentPoint; // Which attachment point on the player model this guy is on.
};
class C_CSPlayer : public C_BasePlayer, public ICSPlayerAnimStateHelpers
{
public:
DECLARE_CLASS( C_CSPlayer, C_BasePlayer );
DECLARE_CLIENTCLASS();
DECLARE_PREDICTABLE();
DECLARE_INTERPOLATION();
C_CSPlayer();
~C_CSPlayer();
virtual void Simulate();
bool HasDefuser() const;
void GiveDefuser();
void RemoveDefuser();
bool HasNightVision() const;
static C_CSPlayer* GetLocalCSPlayer();
CSPlayerState State_Get() const;
virtual float GetMinFOV() const;
// Get how much $$$ this guy has.
int GetAccount() const;
// Returns one of the CS_CLASS_ enums.
int PlayerClass() const;
bool IsInBuyZone();
bool CanShowTeamMenu() const; // Returns true if we're allowed to show the team menu right now.
// Get the amount of armor the player has.
int ArmorValue() const;
bool HasHelmet() const;
int GetCurrentAssaultSuitPrice();
virtual const QAngle& EyeAngles();
virtual const QAngle& GetRenderAngles();
virtual void CalcObserverView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
virtual void GetRenderBounds( Vector& theMins, Vector& theMaxs );
virtual void GetShadowRenderBounds( Vector &mins, Vector &maxs, ShadowType_t shadowType );
virtual bool GetShadowCastDirection( Vector *pDirection, ShadowType_t shadowType ) const;
virtual void VPhysicsUpdate( IPhysicsObject *pPhysics );
// Get the ID target entity index. The ID target is the player that is behind our crosshairs, used to
// display the player's name.
int GetIDTarget() const;
virtual void NotifyShouldTransmit( ShouldTransmitState_t state );
virtual void ClientThink();
virtual void OnDataChanged( DataUpdateType_t type );
virtual void PostDataUpdate( DataUpdateType_t updateType );
virtual bool Interpolate( float currentTime );
virtual void UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity );
virtual surfacedata_t * GetFootstepSurface( const Vector &origin, const char *surfaceName );
virtual void ValidateModelIndex( void );
virtual int GetMaxHealth() const;
bool Weapon_CanSwitchTo(C_BaseCombatWeapon *pWeapon);
virtual void UpdateClientSideAnimation();
virtual void ProcessMuzzleFlashEvent();
virtual const Vector& GetRenderOrigin( void );
bool CreateMove( float flInputSampleTime, CUserCmd *pCmd );
CUtlVector< C_BaseParticleEntity* > m_SmokeGrenades;
virtual bool ShouldDraw( void );
virtual void BuildTransformations( CStudioHdr *pStudioHdr, Vector *pos, Quaternion q[], const matrix3x4_t& cameraTransform, int boneMask, CBoneBitList &boneComputed );
virtual C_BaseAnimating * BecomeRagdollOnClient();
virtual IRagdoll* GetRepresentativeRagdoll() const;
void ImpactTrace( trace_t *pTrace, int iDamageType, const char *pCustomImpactName );
// Have this player play the sounds from his view model's reload animation.
void PlayReloadEffect();
virtual void FireEvent( const Vector& origin, const QAngle& angles, int event, const char *options );
bool HasC4( void );
virtual void CreateLightEffects( void ) {} //no dimlight effects
// Sometimes the server wants to update the client's cycle to get the two to run in sync (for proper hit detection)
virtual void SetServerIntendedCycle( float intended ) { m_serverIntendedCycle = intended; }
virtual float GetServerIntendedCycle( void ) { return m_serverIntendedCycle; }
virtual bool ShouldReceiveProjectedTextures( int flags )
{
return ( this != C_BasePlayer::GetLocalPlayer() );
}
void ClearSoundEvents()
{
m_SoundEvents.RemoveAll();
}
//=============================================================================
// HPE_BEGIN:
// [menglish] Returns whether this player is dominating or is being dominated by the specified player
//=============================================================================
bool IsPlayerDominated( int iPlayerIndex );
bool IsPlayerDominatingMe( int iPlayerIndex );
virtual void CalcFreezeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov );
virtual float GetDeathCamInterpolationTime();
//=============================================================================
// HPE_END
//=============================================================================
// Called by shared code.
public:
// ICSPlayerAnimState overrides.
virtual CWeaponCSBase* CSAnim_GetActiveWeapon();
virtual bool CSAnim_CanMove();
void DoAnimationEvent( PlayerAnimEvent_t event, int nData = 0 );
// Implemented in shared code.
public:
virtual float GetPlayerMaxSpeed();
void GetBulletTypeParameters(
int iBulletType,
float &fPenetrationPower,
float &flPenetrationDistance );
void FireBullet(
Vector vecSrc,
const QAngle &shootAngles,
float flDistance,
int iPenetration,
int iBulletType,
int iDamage,
float flRangeModifier,
CBaseEntity *pevAttacker,
bool bDoEffects,
float xSpread, float ySpread );
void KickBack(
float up_base,
float lateral_base,
float up_modifier,
float lateral_modifier,
float up_max,
float lateral_max,
int direction_change );
// Returns true if the player is allowed to move.
bool CanMove() const;
void OnJump( float fImpulse );
void OnLand( float fVelocity );
bool HasC4() const; // Is this player carrying a C4 bomb?
bool IsVIP() const; // Is this player the VIP?
virtual void SetAnimation( PLAYER_ANIM playerAnim );
public:
void UpdateIDTarget( void );
void RemoveAddonModels( void );
void UpdateMinModels( void );
void SetActivity( Activity eActivity );
Activity GetActivity( void ) const;
ICSPlayerAnimState *GetPlayerAnimState() { return m_PlayerAnimState; }
public:
ICSPlayerAnimState *m_PlayerAnimState;
// Used to control animation state.
Activity m_Activity;
// Predicted variables.
CNetworkVar( bool, m_bResumeZoom );
CNetworkVar( int , m_iLastZoom ); // after firing a shot, set the FOV to 90, and after showing the animation, bring the FOV back to last zoom level.
CNetworkVar( CSPlayerState, m_iPlayerState ); // SupraFiend: this gives the current state in the joining process, the states are listed above
CNetworkVar( bool, m_bIsDefusing ); // tracks whether this player is currently defusing a bomb
CNetworkVar( bool, m_bInBombZone );
CNetworkVar( bool, m_bInBuyZone );
CNetworkVar( int, m_iThrowGrenadeCounter ); // used to trigger grenade throw animations.
bool IsInHostageRescueZone( void );
// This is a combination of the ADDON_ flags in cs_shareddefs.h.
CNetworkVar( int, m_iAddonBits );
// Clients don't know about holstered weapons, so we need to be told about them here
CNetworkVar( int, m_iPrimaryAddon );
CNetworkVar( int, m_iSecondaryAddon );
// How long the progress bar takes to get to the end. If this is 0, then the progress bar
// should not be drawn.
CNetworkVar( int, m_iProgressBarDuration );
// When the progress bar should start.
CNetworkVar( float, m_flProgressBarStartTime );
CNetworkVar( float, m_flStamina );
CNetworkVar( int, m_iDirection ); // The current lateral kicking direction; 1 = right, 0 = left
CNetworkVar( int, m_iShotsFired ); // number of shots fired recently
CNetworkVar( bool, m_bNightVisionOn );
CNetworkVar( bool, m_bHasNightVision );
//=============================================================================
// HPE_BEGIN:
// [dwenger] Added for fun-fact support
//=============================================================================
//CNetworkVar( bool, m_bPickedUpDefuser );
//CNetworkVar( bool, m_bDefusedWithPickedUpKit );
//=============================================================================
// HPE_END
//=============================================================================
CNetworkVar( float, m_flVelocityModifier );
bool m_bDetected;
EHANDLE m_hRagdoll;
CWeaponCSBase* GetActiveCSWeapon() const;
CWeaponCSBase* GetCSWeapon( CSWeaponID id ) const;
virtual ShadowType_t ShadowCastType();
#ifdef CS_SHIELD_ENABLED
bool HasShield( void ) { return m_bHasShield; }
bool IsShieldDrawn( void ) { return m_bShieldDrawn; }
void SetShieldDrawnState( bool bState ) { m_bShieldDrawn = bState; }
#else
bool HasShield( void ) { return false; }
bool IsShieldDrawn( void ) { return false; }
void SetShieldDrawnState( bool bState ) {}
#endif
float m_flNightVisionAlpha;
float m_flFlashAlpha;
float m_flFlashBangTime;
CNetworkVar( float, m_flFlashMaxAlpha );
CNetworkVar( float, m_flFlashDuration );
// Having the RecvProxy in the player allows us to keep the var private
static void RecvProxy_CycleLatch( const CRecvProxyData *pData, void *pStruct, void *pOut );
// Bots and hostages auto-duck during jumps
bool m_duckUntilOnGround;
Vector m_lastStandingPos; // used by the gamemovement code for finding ladders
void SurpressLadderChecks( const Vector& pos, const Vector& normal );
bool CanGrabLadder( const Vector& pos, const Vector& normal );
//=============================================================================
// HPE_BEGIN:
//=============================================================================
// [tj] checks if this player has another given player on their Steam friends list.
bool HasPlayerAsFriend(C_CSPlayer* player);
private:
CountdownTimer m_ladderSurpressionTimer;
Vector m_lastLadderNormal;
Vector m_lastLadderPos;
void UpdateRadar();
void UpdateSoundEvents();
void CreateAddonModel( int i );
void UpdateAddonModels();
void PushawayThink();
int m_iAccount;
bool m_bHasHelmet;
int m_iClass;
int m_ArmorValue;
QAngle m_angEyeAngles;
bool m_bHasDefuser;
bool m_bInHostageRescueZone;
float m_fNextThinkPushAway;
bool m_bPlayingFreezeCamSound;
#ifdef CS_SHIELD_ENABLED
bool m_bHasShield;
bool m_bShieldDrawn;
#endif
Vector m_vecRagdollVelocity;
CInterpolatedVar< QAngle > m_iv_angEyeAngles;
// ID Target
int m_iIDEntIndex;
CountdownTimer m_delayTargetIDTimer;
// Show the ID target after the cursor leaves the entity
int m_iOldIDEntIndex;
CountdownTimer m_holdTargetIDTimer;
void ReleaseFlashlight( void );
Beam_t *m_pFlashlightBeam;
class CCSSoundEvent
{
public:
string_t m_SoundName;
float m_flEventTime; // Play the event when gpGlobals->curtime goes past this.
};
CUtlLinkedList<CCSSoundEvent,int> m_SoundEvents;
// This is the list of addons hanging off the guy (grenades, C4, nightvision, etc).
CUtlLinkedList<CAddonModel, int> m_AddonModels;
int m_iLastAddonBits;
int m_iLastPrimaryAddon;
int m_iLastSecondaryAddon;
int m_cycleLatch; // server periodically updates this to fix up our anims, here it is a 4 bit fixed point
float m_serverIntendedCycle; // server periodically updates this to fix up our anims, here it is the float we want, or -1 for no override
//=============================================================================
// HPE_BEGIN:
// [tj] Network variables that track who are dominating and being dominated by
//=============================================================================
CNetworkArray( bool, m_bPlayerDominated, MAX_PLAYERS+1 ); // array of state per other player whether player is dominating other players
CNetworkArray( bool, m_bPlayerDominatingMe, MAX_PLAYERS+1 ); // array of state per other player whether other players are dominating this player
//=============================================================================
// HPE_END
//=============================================================================
C_CSPlayer( const C_CSPlayer & );
};
C_CSPlayer* GetLocalOrInEyeCSPlayer( void );
inline C_CSPlayer *ToCSPlayer( CBaseEntity *pEntity )
{
if ( !pEntity || !pEntity->IsPlayer() )
return NULL;
return dynamic_cast<C_CSPlayer*>( pEntity );
}
namespace vgui
{
class IImage;
}
vgui::IImage* GetDefaultAvatarImage( C_BasePlayer *pPlayer );
#endif // C_CS_PLAYER_H
|