summaryrefslogtreecommitdiff
path: root/game/shared/tf2/tf_gamerules.h
blob: 9c4ce4fe480dd2b87140a1823089a5b673fc1316 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: The TF Game rules object
//
// $Workfile:     $
// $Date:         $
// $NoKeywords: $
//=============================================================================//

#ifndef TF_GAMERULES_H
#define TF_GAMERULES_H

#ifdef _WIN32
#pragma once
#endif


#include "Teamplay_GameRules.h"
#include "takedamageinfo.h"


#ifdef CLIENT_DLL

	#define CTeamFortress C_TeamFortress

#endif


class CTeamFortress : public CTeamplayRules
{
public:
	DECLARE_CLASS( CTeamFortress, CTeamplayRules );

	int DefaultFOV( void ) { return 90; }

	// Shared implementation between client and server.
	void WeaponTraceLine( const Vector& src, const Vector& end, unsigned int mask, CBaseEntity *pShooter, int damageType, trace_t* pTrace );
	
	virtual bool ShouldCollide( int collisionGroup0, int collisionGroup1 );
	
	virtual void FireBullets( const CTakeDamageInfo &info, int cShots, const Vector &vecSrc, const Vector &vecDirShooting, 
		const Vector &vecSpread, float flDistance, int iBulletType, int iTracerFreq, int firingEntID, 
		int attachmentID, const char *sCustomTracer = NULL );


#ifdef CLIENT_DLL


#else

	CTeamFortress();
	virtual ~CTeamFortress();

	CBaseEntity *GetPlayerSpawnSpot( CBasePlayer *pPlayer );

	virtual void Think( void );
	virtual void LevelInitPostEntity( void );

	virtual void CreateStandardEntities();

	// Called when game rules are destroyed by CWorld
	virtual void LevelShutdown( void );

	virtual void ClientDisconnected( edict_t *pClient );
	virtual bool ClientCommand( CBaseEntity *pEdict, const CCommand &args );
	virtual void PlayerSpawn( CBasePlayer *pPlayer );

	virtual bool PlayTextureSounds( void ) { return true; }
	virtual bool PlayFootstepSounds( CBasePlayer *pl );
	virtual float FlPlayerFallDamage( CBasePlayer *pPlayer );
	virtual void  RadiusDamage( const CTakeDamageInfo &info, const Vector &vecSrcIn, float flRadius, int iClassIgnore );
	// Let the game rules specify if fall death should fade screen to black
	virtual bool  FlPlayerFallDeathDoesScreenFade( CBasePlayer *pl ) { return FALSE; }

	bool	IsTraceBlockedByWorldOrShield( const Vector& src, const Vector& end, CBaseEntity *pShooter, int damageType, trace_t* pTrace );

	virtual float WeaponTraceEntity( CBaseEntity *pEntity, const Vector &vecStart, const Vector &vecEnd, unsigned int mask, trace_t *ptr );

	virtual void UpdateClientData( CBasePlayer *pl );
	
	// Death notices
	virtual void		DeathNotice( CBasePlayer *pVictim, const CTakeDamageInfo &info );
	virtual const char  *GetDamageCustomString( const CTakeDamageInfo &info );
	CBasePlayer			*GetDeathAssistant( CBaseEntity *pKiller, CBaseEntity *pInflictor );

	virtual bool PlayerCanHearChat( CBasePlayer *pListener, CBasePlayer *pSpeaker );
	virtual void			InitDefaultAIRelationships( void );

	virtual const char *GetGameDescription( void ) { return "TeamFortress 2"; }  // this is the game name that gets seen in the server browser
	virtual const char *AIClassText(int classType);

	virtual bool FShouldSwitchWeapon( CBasePlayer *pPlayer, CBaseCombatWeapon *pWeapon );

	virtual const char *SetDefaultPlayerTeam( CBasePlayer *pPlayer );

	// Is the ray blocked by enemy shields?
	bool IsBlockedByEnemyShields( const Vector& src, const Vector& end, int nFriendlyTeam );

public:

	virtual void	SetAllowWeaponSwitch( bool allow );
	virtual bool	GetAllowWeaponSwitch( void );
private:

	// Don't allow switching weapons while gaining new technologies
	bool			m_bAllowWeaponSwitch;

#endif

};

//-----------------------------------------------------------------------------
// Gets us at the team fortress game rules
//-----------------------------------------------------------------------------

inline CTeamFortress* TFGameRules()
{
	#ifdef _DEBUG
		Assert( dynamic_cast< CTeamFortress* >( g_pGameRules ) );
	#endif

	return static_cast<CTeamFortress*>(g_pGameRules);
}

// Send the appropriate weapon impact.
void WeaponImpact( trace_t *tr, Vector vecDir, bool bHurt, CBaseEntity *pEntity, int iDamageType );


#ifdef CLIENT_DLL

#else

	//-----------------------------------------------------------------------------
	// Purpose: Useful utility functions
	//-----------------------------------------------------------------------------
	class CTFTeam;
	CTFTeam *GetOpposingTeam( CTeam *pTeam );
	bool EntityPlacementTest( CBaseEntity *pMainEnt, const Vector &vOrigin, Vector &outPos, bool bDropToGround );

#endif

#endif // TF_GAMERULES_H