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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//
//=============================================================================//
#include "cbase.h"
#include "hltvdirector.h"
class CDODHLTVDirector : public CHLTVDirector
{
public:
DECLARE_CLASS( CDODHLTVDirector, CHLTVDirector );
const char** GetModEvents();
void SetHLTVServer( IHLTVServer *hltv );
void CreateShotFromEvent( CHLTVGameEvent *event );
};
void CDODHLTVDirector::SetHLTVServer( IHLTVServer *hltv )
{
BaseClass::SetHLTVServer( hltv );
if ( m_pHLTVServer )
{
// mod specific events the director uses to find interesting shots
ListenForGameEvent( "dod_point_captured" );
ListenForGameEvent( "dod_capture_blocked" );
}
}
void CDODHLTVDirector::CreateShotFromEvent( CHLTVGameEvent *event )
{
// show event at least for 2 more seconds after it occured
const char *name = event->m_Event->GetName();
IGameEvent *shot = NULL;
if ( !Q_strcmp( "dod_point_captured", name ) ||
!Q_strcmp( "dod_capture_blocked", name ) )
{
// try to find a capper or blocker
const char *text = event->m_Event->GetString("blocker");
int playerIndex = text[0];
if ( playerIndex < 1 )
{
// maybe its a capper ?
text = event->m_Event->GetString("cappers");
playerIndex = text[0];
}
// if we found one, show him
if ( playerIndex > 0 )
{
// shot player as primary, hostage as secondary target
shot = gameeventmanager->CreateEvent( "hltv_chase", true );
shot->SetInt( "target1", playerIndex );
shot->SetInt( "target2", 0 );
shot->SetFloat( "distance", 96.0f );
shot->SetInt( "theta", 0 );
shot->SetInt( "phi", 20 );
// shot 2 seconds after event
m_nNextShotTick = MIN( m_nNextShotTick, (event->m_Tick+TIME_TO_TICKS(2.0)) );
m_iPVSEntity = playerIndex;
}
}
else
{
// let baseclass create a shot
BaseClass::CreateShotFromEvent( event );
return;
}
if ( shot )
{
m_pHLTVServer->BroadcastEvent( shot );
gameeventmanager->FreeEvent( shot );
DevMsg("DrcCmd: %s\n", name );
}
}
const char** CDODHLTVDirector::GetModEvents()
{
// game events relayed to spectator clients
static const char *s_modevents[] =
{
"hltv_status",
"hltv_chat",
"player_connect",
"player_disconnect",
"player_team",
"player_info",
"server_cvar",
"player_death",
"player_chat",
"round_start",
"round_end",
// additional DoD:S events:
"player_changeclass",
"dod_warmup_begins",
"dod_warmup_ends",
"dod_round_start",
"dod_restart_round",
"dod_ready_restart",
"dod_allies_ready",
"dod_axis_ready",
"dod_round_restart_seconds",
"dod_team_scores",
"dod_round_win",
"dod_tick_points",
"dod_game_over",
"dod_broadcast_audio",
"dod_point_captured",
"dod_capture_blocked",
"dod_top_cappers",
"dod_timer_flash",
"dod_bomb_planted",
NULL
};
return s_modevents;
}
static CDODHLTVDirector s_HLTVDirector; // singleton
EXPOSE_SINGLE_INTERFACE_GLOBALVAR(CHLTVDirector, IHLTVDirector, INTERFACEVERSION_HLTVDIRECTOR, s_HLTVDirector );
CHLTVDirector* HLTVDirector()
{
return &s_HLTVDirector;
}
IGameSystem* HLTVDirectorSystem()
{
return &s_HLTVDirector;
}
|