summaryrefslogtreecommitdiff
path: root/game/server/tf/raid/tf_raid_logic.h
blob: 973f0faf3eb65bb081e64f09ae850f25a181461c (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
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
//========= Copyright Valve Corporation, All rights reserved. ============//
// tf_raid_logic.h
// Raid game mode singleton manager
// Michael Booth, November 2009

#ifndef TF_RAID_LOGIC_H
#define TF_RAID_LOGIC_H

#ifdef TF_RAID_MODE

#include "tf_gamerules.h"
#include "player_vs_environment/tf_population_manager.h"

class CBaseDoor;


//-----------------------------------------------------------------------
class CRaidLogic : public CPointEntity, public CGameEventListener
{
	DECLARE_CLASS( CRaidLogic, CPointEntity );
public:
	DECLARE_DATADESC();

	CRaidLogic();
	virtual ~CRaidLogic();

	virtual void Spawn( void );
	void Reset( void );
	void Update( void );

	virtual void FireGameEvent( IGameEvent *event );

	void DrawDebugDisplay( float deltaT );

	CTeamControlPoint *GetContestedPoint( void ) const;					// return the next control point that can be captured

	bool IsWaitingForRaidersToLeaveSafeRoom( void ) const;				// returns true if all raiders have not yet left the spawn room for the first time
	bool IsMobSpawning( void ) const;									// return true if a mob is trying to spawn right now
	bool IsSentryGunArea( CTFNavArea *area ) const;						// return true if this area should contain an enemy sentry gun

	int GetWandererCount( void ) const;									// how many wanderers exist at the moment?

	CTFPlayer *GetFarthestAlongRaider( void ) const;					// return raider who is farthest through the map

	float GetMaximumRaiderIncursionDistance( void ) const;				// return incursion distance of farthest along raider
	float GetIncursionDistanceAtEnd( void ) const;						// return maximum incursion distance at end of route

	CTFNavArea *GetEscapeRouteStart( void ) const;
	CTFNavArea *GetEscapeRouteEnd( void ) const;

	CTFNavArea *FindSniperSpawn( void );
	CTFNavArea *FindSentryArea( void );

	CTFNavArea *FindSpawnAreaAhead( void );
	CTFNavArea *FindSpawnAreaBehind( void );

	CTFNavArea *SelectRaidSentryArea( void ) const;						// choose unpopulated sentry area nearest the invaders

	CTFPlayer *SelectRaiderToAttack( void );							// pick a member of the raiding (blue) team for a red defender to attack

	virtual int UpdateTransmitState()
	{
		return SetTransmitState( FL_EDICT_ALWAYS );
	}

	CBaseEntity *GetRescueRespawn( void ) const;						// return entity positioned within next valid rescue closet area for to respawn players in

private:
	bool LoadPopulationFromFile( void );

	int m_priorRaiderAliveCount;

	int m_wandererCount;
	int m_engineerCount;
	int m_demomanCount;
	int m_heavyCount;
	int m_soldierCount;
	int m_pyroCount;
	int m_spyCount;
	int m_sniperCount;
	int m_squadCount;

	void OnRoundStart( void );
	bool Unspawn( CTFPlayer *who );
	void CullObsoleteEnemies( float minIncursion, float maxIncursion );

//	void SpawnMobs( CUtlVector< CTFNavArea * > *spawnAreaVector );
	CountdownTimer m_mobSpawnTimer;
	CountdownTimer m_mobLifetimeTimer;
	CTFNavArea *m_mobArea;
	int m_mobCountRemaining;
	int m_mobClass;

//	void SpawnEngineers( void );
	CountdownTimer m_engineerSpawnTimer;

//	void SpawnSpecials( CUtlVector< CTFNavArea * > *spawnAheadVector, CUtlVector< CTFNavArea * > *spawnAnywhereVector );
	CountdownTimer m_specialSpawnTimer;

	CTFNavArea *SelectMobSpawn( CUtlVector< CTFNavArea * > *spawnAreaVector, RelativePositionType where );
//	bool SpawnSquad( CTFNavArea *spawnArea );
	void StartMobTimer( float duration );

	bool m_isWaitingForRaidersToLeaveSpawnRoom;
	bool m_wasCapturingPoint;
	bool m_didFailLastTime;

	CHandle< CTFPlayer > m_farthestAlongRaider;							// raider with highest incursion distance
	float m_incursionDistanceAtEnd;

	void BuildEscapeRoute( void );
	CUtlVector< CTFNavArea * > m_escapeRouteVector;						// a vector of areas in order along the escape route
	CTFNavArea *m_farthestAlongEscapeRouteArea;
	CTFNavArea *FindEarliestVisibleEscapeRouteAreaNearTeam( CTFNavArea *viewArea ) const;	// given a viewing area, return the earliest escape route area near the team that is visible

	CUtlVector< CTFNavArea * > m_sniperSpotVector;						// a vector of good sniping areas
	CUtlVector< CTFNavArea * > m_sentrySpotVector;						// a vector of good sentry areas
	CUtlVector< CTFNavArea * > m_actualSentrySpotVector;				// a vector of areas to actually place sentry guns

	CUtlVector< CTFNavArea * > m_rescueClosetVector;					// a vector of areas to respawn raiders

	CUtlVector< CTFNavArea * > m_miniBossHomeVector;
	int m_miniBossIndex;

	CUtlVector< CBaseDoor * > m_gateVector;								// vector of gates that open when point is captured
};

inline bool CRaidLogic::IsSentryGunArea( CTFNavArea *area ) const
{
	return m_actualSentrySpotVector.HasElement( area );
}

inline int CRaidLogic::GetWandererCount( void ) const
{
	return m_wandererCount;
}

inline CTFNavArea *CRaidLogic::GetEscapeRouteStart( void ) const
{
	return m_escapeRouteVector.Count() ? m_escapeRouteVector[0] : NULL;
}

inline CTFNavArea *CRaidLogic::GetEscapeRouteEnd( void ) const
{
	return m_escapeRouteVector.Count() ? m_escapeRouteVector[ m_escapeRouteVector.Count()-1 ] : NULL;
}

inline CTFPlayer *CRaidLogic::GetFarthestAlongRaider( void ) const
{
	return m_farthestAlongRaider;
}


inline bool CRaidLogic::IsWaitingForRaidersToLeaveSafeRoom( void ) const
{
	return m_isWaitingForRaidersToLeaveSpawnRoom;
}

inline bool CRaidLogic::IsMobSpawning( void ) const
{
	return m_mobLifetimeTimer.HasStarted() && !m_mobLifetimeTimer.IsElapsed();
}

inline float CRaidLogic::GetIncursionDistanceAtEnd( void ) const
{
	return m_incursionDistanceAtEnd;
}

extern CRaidLogic *g_pRaidLogic;

#endif // TF_RAID_MODE


#endif // TF_RAID_LOGIC_H