summaryrefslogtreecommitdiff
path: root/game/shared/tf/tf_projectile_base.h
blob: 85d19f5eedcb563504339287ea29bab49c764aeb (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. ============//
//
// TF Base Projectile
//
//=============================================================================
#ifndef TF_BASE_PROJECTILE_H
#define TF_BASE_PROJECTILE_H
#ifdef _WIN32
#pragma once
#endif

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

// Client specific.
#ifdef CLIENT_DLL
	#include "tempent.h"
// Server specific.
#else
	#include "iscorer.h"
#endif

#ifdef CLIENT_DLL
#define CTFBaseProjectile C_TFBaseProjectile
C_LocalTempEntity *ClientsideProjectileCallback( const CEffectData &data, float flGravityBase, const char *pszParticleName = NULL );
#endif

/*
CBaseProjectile
	|-  CTFBaseProjectile
			|- CTFProjectile_Nail
			|- CTFProjectile_Dart
			|- CTFProjectile_Syringe
			|- CTFProjectile_EnergyRing
	|-  CTFBaseRocket
			|- Soldier rocket
			|- Pyro rocket
			|- CTFProjectile_Flare
			|- CTFProjectile_Arrow
	|-  CBaseGrenade
			|- CTFWeaponBaseGrenadeProj
					|- CTFGrenadePipebombProjectile
*/

//=============================================================================
//
// Generic projectile
//
class CTFBaseProjectile : public CBaseProjectile
#if !defined( CLIENT_DLL )
	, public IScorer
#endif
{
public:

	DECLARE_CLASS( CTFBaseProjectile, CBaseProjectile );
	DECLARE_NETWORKCLASS();

	CTFBaseProjectile();
	~CTFBaseProjectile();

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

	virtual int   GetWeaponID( void ) const { return m_iWeaponID; }
	void		  SetWeaponID( int iID ) { m_iWeaponID = iID; }

	bool		  IsCritical( void ) const			{ return m_bCritical; }
	virtual void  SetCritical( bool bCritical )		{ m_bCritical = bCritical; }
	
	CBaseEntity		*GetLauncher( void ) { return m_hLauncher; }

private:

	int				m_iWeaponID;
	bool			m_bCritical;

protected:

	// Networked.
	CNetworkVector( m_vInitialVelocity );

	static CTFBaseProjectile *Create( const char *pszClassname, const Vector &vecOrigin, 
		const QAngle &vecAngles, CBaseEntity *pOwner, float flVelocity, short iProjModelIndex, const char *pszDispatchEffect = NULL, CBaseEntity *pScorer = NULL, bool bCritical = false, Vector vColor1=vec3_origin, Vector vColor2=vec3_origin );

	virtual const char *GetProjectileModelName( void );
	virtual float GetGravity( void ) { return 0.001f; }

#ifdef CLIENT_DLL

public:

	virtual int		DrawModel( int flags );
	virtual void	PostDataUpdate( DataUpdateType_t type );

private:

	float	 m_flSpawnTime;
#else

public:

	DECLARE_DATADESC();

	// IScorer interface
	virtual CBasePlayer *GetScorer( void );
	virtual CBasePlayer *GetAssistant( void ) { return NULL; }

	void	SetScorer( CBaseEntity *pScorer );

	virtual void	ProjectileTouch( CBaseEntity *pOther );

	virtual int		GetProjectileType ( void )					{ return TF_PROJECTILE_NONE; }	// Default unset

	virtual float	GetDamage() { return m_flDamage; }
	virtual void	SetDamage(float flDamage) { m_flDamage = flDamage; }

	virtual Vector	GetDamageForce( void );
	virtual int		GetDamageType( void );

	virtual unsigned int PhysicsSolidMaskForEntity( void ) const OVERRIDE;

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

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

protected:

	void			FlyThink( void );

protected:
	float			m_flDamage;
	CBaseHandle		m_Scorer;

#endif // ndef CLIENT_DLL

protected:
	CNetworkHandle( CBaseEntity, m_hLauncher );
};

#endif	//TF_BASE_PROJECTILE_H