summaryrefslogtreecommitdiff
path: root/game/server/tf/player_vs_environment/tf_boss_battle_logic.cpp
blob: 6e0a66d4d0ac11d121f28f112e52339d92186384 (plain) (blame)
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
//========= Copyright Valve Corporation, All rights reserved. ============//
// tf_boss_battle_logic.cpp
// Boss battle game mode singleton manager
// Michael Booth, April 2011

#include "cbase.h"

#ifdef TF_RAID_MODE

#include "tf_team.h"
#include "bot/map_entities/tf_bot_generator.h"
#include "player_vs_environment/tf_boss_battle_logic.h"

CBossBattleLogic *g_pBossBattleLogic = NULL;


//-------------------------------------------------------------------------
//-------------------------------------------------------------------------
BEGIN_DATADESC( CBossBattleLogic )
	DEFINE_THINKFUNC( Update ),
END_DATADESC()

LINK_ENTITY_TO_CLASS( tf_logic_boss_battle, CBossBattleLogic );


ConVar tf_bot_npc_minion_wave_launch_count( "tf_bot_npc_minion_wave_launch_count", "0"/*, FCVAR_CHEAT*/ );
ConVar tf_bot_npc_minion_wave_initial_launch_interval( "tf_bot_npc_minion_wave_initial_launch_interval", "15"/*, FCVAR_CHEAT*/ );
ConVar tf_bot_npc_minion_wave_launch_interval( "tf_bot_npc_minion_wave_launch_interval", "30"/*, FCVAR_CHEAT*/ );

ConVar tf_bot_npc_grunt_wave_launch_count( "tf_bot_npc_grunt_wave_launch_count", "2"/*, FCVAR_CHEAT*/ );
ConVar tf_bot_npc_grunt_wave_initial_launch_interval( "tf_bot_grunt_wave_initial_launch_interval", "25"/*, FCVAR_CHEAT*/ );
ConVar tf_bot_npc_grunt_wave_launch_interval( "tf_bot_npc_grunt_wave_launch_interval", "30"/*, FCVAR_CHEAT*/ );


//-------------------------------------------------------------------------
CBossBattleLogic::CBossBattleLogic()
{
	ListenForGameEvent( "teamplay_round_win" );
	ListenForGameEvent( "teamplay_round_start" );
}


//-------------------------------------------------------------------------
CBossBattleLogic::~CBossBattleLogic()
{
	g_pBossBattleLogic = NULL;
}


//-------------------------------------------------------------------------
void CBossBattleLogic::Spawn( void )
{
	BaseClass::Spawn();

	Reset();

	SetThink( &CBossBattleLogic::Update );
	SetNextThink( gpGlobals->curtime );

	g_pBossBattleLogic = this;
}


//-------------------------------------------------------------------------
void CBossBattleLogic::Reset( void )
{
	// unspawn entire red team
	CTeam *defendingTeam = GetGlobalTeam( TF_TEAM_RED );
	int i;
	for( i=0; i<defendingTeam->GetNumPlayers(); ++i )
	{
		engine->ServerCommand( UTIL_VarArgs( "kickid %d\n", defendingTeam->GetPlayer(i)->GetUserID() ) );
	}

	// remove all minions
	CBaseEntity *minion = NULL;
	while( ( minion = gEntList.FindEntityByClassname( minion, "bot_npc_minion" ) ) != NULL )
	{
		UTIL_Remove( minion );
	}
}


//-------------------------------------------------------------------------
void CBossBattleLogic::OnRoundStart( void )
{
	if ( !TFGameRules() || !TFGameRules()->IsBossBattleMode() )
		return;

	Reset();
}


//--------------------------------------------------------------------------------------------------------
void CBossBattleLogic::FireGameEvent( IGameEvent *event )
{
	const char *eventName = event->GetName();

	if ( !Q_strcmp( eventName, "teamplay_round_win" ) )
	{
		if ( event->GetInt( "team" ) == TF_TEAM_RED )
		{
		}
	}
	else if ( !Q_strcmp( eventName, "teamplay_round_start" ) )
	{
		OnRoundStart();
	}
}


//--------------------------------------------------------------------------------------------------------
void CBossBattleLogic::Update( void )
{
	VPROF_BUDGET( "CBossBattleLogic::Update", "Game" );

	const float deltaT = 0.33f;
	SetNextThink( gpGlobals->curtime + deltaT );

	if ( !TFGameRules()->IsBossBattleMode() )
		return;
}


#endif // TF_RAID_MODE