summaryrefslogtreecommitdiff
path: root/game/shared/tf/tf_weaponbase_rocket.h
blob: b90ec1b015f3716c1c98b13df2a8c19cad261ce4 (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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: TF Base Rockets.
//
//=============================================================================//
#ifndef TF_WEAPONBASE_ROCKET_H
#define TF_WEAPONBASE_ROCKET_H
#ifdef _WIN32
#pragma once
#endif

#include "cbase.h"
#include "tf_shareddefs.h"
#include "baseprojectile.h"

// Server specific.
#ifdef GAME_DLL
#include "smoke_trail.h"
#endif

#ifdef CLIENT_DLL
#define CTFBaseRocket C_TFBaseRocket
#endif

#define TF_ROCKET_RADIUS_FOR_RJS	(110.0f * 1.1f)	// radius * TF scale up factor (121) - Used when applying damage to attacker.
#define TF_ROCKET_RADIUS			(146)			// Radius used when applying damage to others
#define TF_FLARE_DET_RADIUS			(110)			// Special version of the flare that can be detonated by the player
#define TF_FLARE_RADIUS_FOR_FJS		(100.0f)
#define TF_ROCKET_DESTROYABLE_TIMER	(0.25)


//=============================================================================
//
// TF Base Rocket.
//
class CTFBaseRocket : public CBaseProjectile
{

//=============================================================================
//
// Shared (client/server).
//
public:

	DECLARE_CLASS( CTFBaseRocket, CBaseProjectile );
	DECLARE_NETWORKCLASS();

			CTFBaseRocket();
			~CTFBaseRocket();

	void	Precache( void );
	void	Spawn( void );

	virtual int		GetWeaponID( void ) const { return TF_WEAPON_ROCKETLAUNCHER; }
	virtual int		GetCustomDamageType() const { return TF_DMG_CUSTOM_NONE; }
	virtual void	IncrementDeflected( void ) { m_iDeflected++; }
	void			ResetDeflected( void ) { m_iDeflected = 0; }
	int				GetDeflected( void ) { return m_iDeflected; }

protected:

	// Networked.
	CNetworkVector( m_vInitialVelocity );
	CNetworkVar( int, m_iDeflected );

//=============================================================================
//
// Client specific.
//
#ifdef CLIENT_DLL

public:

	virtual int		DrawModel( int flags );
	virtual void	PostDataUpdate( DataUpdateType_t type );
	virtual void	OnDataChanged(DataUpdateType_t updateType);
	virtual void	CreateTrails( void ) { }
	CBaseEntity		*GetLauncher( void ) { return m_hLauncher; }

protected:

	float	 m_flSpawnTime;
	int		m_iCachedDeflect;
	CNetworkHandle( CBaseEntity, m_hLauncher );

//=============================================================================
//
// Server specific.
//
#else

public:

	DECLARE_DATADESC();

	static CTFBaseRocket *Create( CBaseEntity *pLauncher, const char *szClassname, const Vector &vecOrigin, const QAngle &vecAngles, CBaseEntity *pOwner = NULL );	

	virtual void	RocketTouch( CBaseEntity *pOther );
	virtual void	Explode( trace_t *pTrace, CBaseEntity *pOther );
	void			CheckForStunOnImpact( CTFPlayer* pTarget );
	int				GetStunLevel( void );

	virtual bool	ShouldNotDetonate( void );
	virtual void	Destroy( bool bBlinkOut = true, bool bBreakRocket = false ) OVERRIDE;

	virtual float	GetDamage() { return m_flDamage; }
	virtual int		GetDamageType() { return g_aWeaponDamageTypes[ GetWeaponID() ]; }
	virtual int		GetDamageCustom() { return TF_DMG_CUSTOM_NONE; }
	virtual void	SetDamage(float flDamage) { m_flDamage = flDamage; }
#ifdef STAGING_ONLY
	void			DrawRadius( float flRadius );
#endif
	virtual float	GetRadius();

	virtual void	SetDamageForceScale( float flScale ) {  m_flDamageForceScale = flScale; }
	virtual float	GetDamageForceScale() { return m_flDamageForceScale; }

	unsigned int	PhysicsSolidMaskForEntity( void ) const;

	void			SetupInitialTransmittedGrenadeVelocity( const Vector &velocity )	{ m_vInitialVelocity = velocity; }

	virtual CBaseEntity		*GetEnemy( void )			{ return m_hEnemy; }

	void			SetHomingTarget( CBaseEntity *pHomingTarget );

	virtual void	SetLauncher( CBaseEntity *pLauncher ) OVERRIDE { m_hLauncher = pLauncher; BaseClass::SetLauncher( pLauncher ); }
	CBaseEntity		*GetLauncher( void ) { return m_hLauncher; }

	virtual bool	IsDestroyable( void ){ return gpGlobals->curtime > m_flDestroyableTime; }

	CBaseEntity		*GetOwnerPlayer( void ) const;

protected:

	// Not networked.
	float					m_flDamage;

	CNetworkHandle( CBaseEntity, m_hLauncher );

	float					m_flDestroyableTime;
	bool					m_bCritical;
	bool					m_bStunOnImpact;

	float					m_flDamageForceScale;

	CHandle<CBaseEntity>	m_hEnemy;

#endif
};


#endif // TF_WEAPONBASE_ROCKET_H