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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
//=============================================================================
#ifndef BASEMULTIPLAYERPLAYER_H
#define BASEMULTIPLAYERPLAYER_H
#pragma once
#include "player.h"
#include "ai_speech.h"
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
class CBaseMultiplayerPlayer : public CAI_ExpresserHost<CBasePlayer>
{
DECLARE_CLASS( CBaseMultiplayerPlayer, CAI_ExpresserHost<CBasePlayer> );
public:
CBaseMultiplayerPlayer();
~CBaseMultiplayerPlayer();
virtual void Spawn( void );
virtual void PostConstructor( const char *szClassname );
virtual void ModifyOrAppendCriteria( AI_CriteriaSet& criteriaSet );
virtual bool SpeakIfAllowed( AIConcept_t concept, const char *modifiers = NULL, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL );
virtual IResponseSystem *GetResponseSystem();
bool SpeakConcept( AI_Response& response, int iConcept );
virtual bool SpeakConceptIfAllowed( int iConcept, const char *modifiers = NULL, char *pszOutResponseChosen = NULL, size_t bufsize = 0, IRecipientFilter *filter = NULL );
virtual bool CanHearAndReadChatFrom( CBasePlayer *pPlayer );
virtual bool CanSpeak( void ) { return true; }
virtual bool CanBeAutobalanced() { return true; }
virtual void Precache( void )
{
PrecacheParticleSystem( "achieved" );
BaseClass::Precache();
}
virtual bool ClientCommand( const CCommand &args );
virtual bool CanSpeakVoiceCommand( void ) { return true; }
virtual bool ShouldShowVoiceSubtitleToEnemy( void );
virtual void NoteSpokeVoiceCommand( const char *pszScenePlayed ) {}
virtual void OnAchievementEarned( int iAchievement ) {}
enum
{
CHAT_IGNORE_NONE = 0,
CHAT_IGNORE_ALL,
CHAT_IGNORE_TEAM,
};
int m_iIgnoreGlobalChat;
//---------------------------------
// Speech support
virtual CAI_Expresser *GetExpresser() { return m_pExpresser; }
virtual CMultiplayer_Expresser *GetMultiplayerExpresser() { return m_pExpresser; }
void SetLastForcedChangeTeamTimeToNow( void ) { m_flLastForcedChangeTeamTime = gpGlobals->curtime; }
float GetLastForcedChangeTeamTime( void ) { return m_flLastForcedChangeTeamTime; }
void SetTeamBalanceScore( int iScore ) { m_iBalanceScore = iScore; }
int GetTeamBalanceScore( void ) { return m_iBalanceScore; }
virtual int CalculateTeamBalanceScore( void );
void AwardAchievement( int iAchievement, int iCount = 1 );
int GetPerLifeCounterKV( const char *name );
void SetPerLifeCounterKV( const char *name, int value );
void ResetPerLifeCounters( void );
KeyValues *GetPerLifeCounterKeys( void ) { return m_pAchievementKV; }
void EscortScoringThink( void );
void StartScoringEscortPoints( float flRate );
void StopScoringEscortPoints( void );
float m_flAreaCaptureScoreAccumulator;
float m_flCapPointScoreRate;
float GetConnectionTime( void ) { return m_flConnectionTime; }
// Command rate limiting.
bool ShouldRunRateLimitedCommand( const CCommand &args );
bool ShouldRunRateLimitedCommand( const char *pszCommand );
protected:
virtual CAI_Expresser *CreateExpresser( void );
int m_iCurrentConcept;
private:
//---------------------------------
CMultiplayer_Expresser *m_pExpresser;
float m_flConnectionTime;
float m_flLastForcedChangeTeamTime;
int m_iBalanceScore; // a score used to determine which players are switched to balance the teams
KeyValues *m_pAchievementKV;
// 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;
};
//-----------------------------------------------------------------------------
// Inline methods
//-----------------------------------------------------------------------------
inline CBaseMultiplayerPlayer *ToBaseMultiplayerPlayer( CBaseEntity *pEntity )
{
if ( !pEntity || !pEntity->IsPlayer() )
return NULL;
#if _DEBUG
return dynamic_cast<CBaseMultiplayerPlayer *>( pEntity );
#else
return static_cast<CBaseMultiplayerPlayer *>( pEntity );
#endif
}
#endif // BASEMULTIPLAYERPLAYER_H
|