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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#ifndef HL2MP_PLAYER_H
#define HL2MP_PLAYER_H
#pragma once
class CHL2MP_Player;
#include "basemultiplayerplayer.h"
#include "hl2_playerlocaldata.h"
#include "hl2_player.h"
#include "simtimer.h"
#include "soundenvelope.h"
#include "hl2mp_player_shared.h"
#include "hl2mp_gamerules.h"
#include "utldict.h"
//=============================================================================
// >> HL2MP_Player
//=============================================================================
class CHL2MPPlayerStateInfo
{
public:
HL2MPPlayerState m_iPlayerState;
const char *m_pStateName;
void (CHL2MP_Player::*pfnEnterState)(); // Init and deinit the state.
void (CHL2MP_Player::*pfnLeaveState)();
void (CHL2MP_Player::*pfnPreThink)(); // Do a PreThink() in this state.
};
class CHL2MP_Player : public CHL2_Player
{
public:
DECLARE_CLASS( CHL2MP_Player, CHL2_Player );
CHL2MP_Player();
~CHL2MP_Player( void );
static CHL2MP_Player *CreatePlayer( const char *className, edict_t *ed )
{
CHL2MP_Player::s_PlayerEdict = ed;
return (CHL2MP_Player*)CreateEntityByName( className );
}
DECLARE_SERVERCLASS();
DECLARE_DATADESC();
virtual void Precache( void );
virtual void Spawn( void );
virtual void PostThink( void );
virtual void PreThink( void );
virtual void PlayerDeathThink( void );
virtual void SetAnimation( PLAYER_ANIM playerAnim );
virtual bool HandleCommand_JoinTeam( int team );
virtual bool ClientCommand( const CCommand &args );
virtual void CreateViewModel( int viewmodelindex = 0 );
virtual bool BecomeRagdollOnClient( const Vector &force );
virtual void Event_Killed( const CTakeDamageInfo &info );
virtual int OnTakeDamage( const CTakeDamageInfo &inputInfo );
virtual bool WantsLagCompensationOnEntity( const CBasePlayer *pPlayer, const CUserCmd *pCmd, const CBitVec<MAX_EDICTS> *pEntityTransmitBits ) const;
virtual void FireBullets ( const FireBulletsInfo_t &info );
virtual bool Weapon_Switch( CBaseCombatWeapon *pWeapon, int viewmodelindex = 0);
virtual bool BumpWeapon( CBaseCombatWeapon *pWeapon );
virtual void ChangeTeam( int iTeam );
virtual void PickupObject ( CBaseEntity *pObject, bool bLimitMassAndSize );
virtual void PlayStepSound( Vector &vecOrigin, surfacedata_t *psurface, float fvol, bool force );
virtual void Weapon_Drop( CBaseCombatWeapon *pWeapon, const Vector *pvecTarget = NULL, const Vector *pVelocity = NULL );
virtual void UpdateOnRemove( void );
virtual void DeathSound( const CTakeDamageInfo &info );
virtual CBaseEntity* EntSelectSpawnPoint( void );
int FlashlightIsOn( void );
void FlashlightTurnOn( void );
void FlashlightTurnOff( void );
void PrecacheFootStepSounds( void );
bool ValidatePlayerModel( const char *pModel );
QAngle GetAnimEyeAngles( void ) { return m_angEyeAngles.Get(); }
Vector GetAttackSpread( CBaseCombatWeapon *pWeapon, CBaseEntity *pTarget = NULL );
void CheatImpulseCommands( int iImpulse );
void CreateRagdollEntity( void );
void GiveAllItems( void );
void GiveDefaultItems( void );
void NoteWeaponFired( void );
void ResetAnimation( void );
void SetPlayerModel( void );
void SetPlayerTeamModel( void );
Activity TranslateTeamActivity( Activity ActToTranslate );
float GetNextModelChangeTime( void ) { return m_flNextModelChangeTime; }
float GetNextTeamChangeTime( void ) { return m_flNextTeamChangeTime; }
void PickDefaultSpawnTeam( void );
void SetupPlayerSoundsByModel( const char *pModelName );
const char *GetPlayerModelSoundPrefix( void );
int GetPlayerModelType( void ) { return m_iPlayerSoundType; }
void DetonateTripmines( void );
void Reset();
bool IsReady();
void SetReady( bool bReady );
void CheckChatText( char *p, int bufsize );
void State_Transition( HL2MPPlayerState newState );
void State_Enter( HL2MPPlayerState newState );
void State_Leave();
void State_PreThink();
CHL2MPPlayerStateInfo *State_LookupInfo( HL2MPPlayerState state );
void State_Enter_ACTIVE();
void State_PreThink_ACTIVE();
void State_Enter_OBSERVER_MODE();
void State_PreThink_OBSERVER_MODE();
virtual bool StartObserverMode( int mode );
virtual void StopObserverMode( void );
Vector m_vecTotalBulletForce; //Accumulator for bullet force in a single frame
// Tracks our ragdoll entity.
CNetworkHandle( CBaseEntity, m_hRagdoll ); // networked entity handle
virtual bool CanHearAndReadChatFrom( CBasePlayer *pPlayer );
private:
CNetworkQAngle( m_angEyeAngles );
CPlayerAnimState m_PlayerAnimState;
int m_iLastWeaponFireUsercmd;
int m_iModelType;
CNetworkVar( int, m_iSpawnInterpCounter );
CNetworkVar( int, m_iPlayerSoundType );
float m_flNextModelChangeTime;
float m_flNextTeamChangeTime;
float m_flSlamProtectTime;
HL2MPPlayerState m_iPlayerState;
CHL2MPPlayerStateInfo *m_pCurStateInfo;
bool ShouldRunRateLimitedCommand( const CCommand &args );
// This lets us rate limit the commands the players can execute so they don't overflow things like reliable buffers.
CUtlDict<float,int> m_RateLimitLastCommandTimes;
bool m_bEnterObserver;
bool m_bReady;
};
inline CHL2MP_Player *ToHL2MPPlayer( CBaseEntity *pEntity )
{
if ( !pEntity || !pEntity->IsPlayer() )
return NULL;
return dynamic_cast<CHL2MP_Player*>( pEntity );
}
#endif //HL2MP_PLAYER_H
|