/
tf_obj_sentrygun.h
190 lines (157 loc) · 4.89 KB
/
tf_obj_sentrygun.h
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: Defender's sentrygun
//
// $NoKeywords: $
//=============================================================================//
#ifndef TF_OBJ_SENTRYGUN_H
#define TF_OBJ_SENTRYGUN_H
#ifdef _WIN32
#pragma once
#endif
#include "tf_obj.h"
enum TFTURRET_ANIM
{
TFTURRET_ANIM_NONE = 0,
TFTURRET_ANIM_FIRE,
TFTURRET_ANIM_SPIN,
};
enum target_ranges
{
RANGE_NEAR,
RANGE_MID,
RANGE_FAR,
};
// Sentrygun damages
#define SG_MACHINEGUN_DAMAGE 5
// ------------------------------------------------------------------------ //
// The Base Sentrygun
// ------------------------------------------------------------------------ //
class CObjectSentrygun : public CBaseObject
{
DECLARE_CLASS( CObjectSentrygun, CBaseObject );
public:
DECLARE_DATADESC();
DECLARE_SERVERCLASS();
CObjectSentrygun();
static CObjectSentrygun* Create(const Vector &vOrigin, const QAngle &vAngles, int iType);
virtual void Spawn();
virtual void Precache();
virtual void SetupAttachedVersion( void );
virtual void SetupUnattachedVersion( void );
virtual void GetControlPanelInfo( int nPanelIndex, const char *&pPanelName );
virtual void FinishedBuilding( void );
virtual bool IsSentrygun( void ) { return true; };
virtual bool WantsCoverFromSentryGun() { return false; }
virtual void SetTechnology( bool bSmarter, bool bSensors );
virtual int OnTakeDamage( const CTakeDamageInfo &info );
virtual void Killed( void );
// Ammo filling
virtual bool ClientCommand( CBaseTFPlayer *pPlayer, const CCommand &args );
virtual bool TakeAmmoFrom( CBaseTFPlayer *pPlayer );
// Think functions
void SentryRotate(void);
void Attack(void);
void Sentry_Explode( void );
bool FInViewCone( CBaseEntity *pEntity );
int BloodColor( void ) { return DONT_BLEED; }
virtual void CheckShield( void );
void RestartAnimation();
void ResetOrientation();
virtual void SetSentryAnim( TFTURRET_ANIM anim );
virtual CBaseEntity *FindTarget( void );
virtual float GetPriority( CBaseEntity *pTarget );
virtual void FoundTarget();
virtual bool ValidTarget( CBaseEntity *pTarget );
virtual int Range( CBaseEntity *pTarget );
// Combat functions
virtual bool HasAmmo( void );
virtual bool Fire( void );
virtual bool WillSuppress( void ) { return true; };
virtual bool CanTakeEMPDamage( void ) { return true; }
// Turret Functions
bool MoveTurret( void );
// Object functions
void ObjectMoved( void );
// Designator interactions
void DesignateTarget( CBaseEntity *pTarget );
// Turtle mode
bool IsTurtled( void );
bool IsTurtling( void ); // Return true if we're in the process of turtling / unturtling
void ToggleTurtle( void );
void Turtle( void );
void UnTurtle( void );
private:
// Recompute sentrygun orientation...
void RecomputeOrientation();
public:
// Variables
int m_iRightBound;
int m_iLeftBound;
bool m_bTurningRight;
int m_iShardIndex;
int m_iAmmoType;
bool m_bSmarter;
bool m_bSensors;
float m_flNextLook;
// Attacking
float m_flNextAttack;
CNetworkVar( int, m_iAmmo );
int m_iMaxAmmo;
Vector m_vecFireTarget;
Vector m_vecLastKnownPosition;
bool m_bSuppressing;
float m_flStartedSuppressing;
// Movement
CNetworkVar( int, m_iBaseTurnRate );
float m_fTurnRate;
QAngle m_vecCurAngles;
QAngle m_vecGoalAngles;
Vector m_vecCurDishAngles;
// Turtling
CNetworkVar( bool, m_bTurtled );
bool m_bTurtling;
float m_flTurtlingFinishedAt;
// Data sent to clients
// Bone controllers
float m_fBoneXRotator;
float m_fBoneYRotator;
// Target data
CNetworkHandle( CBaseEntity, m_hEnemy );
EHANDLE m_hDesignatedEnemy;
CNetworkVar( int, m_nAnimationParity );
CNetworkVar( int, m_nOrientationParity );
};
//-----------------------------------------------------------------------------
// Purpose: Plasma Sentrygun
//-----------------------------------------------------------------------------
class CObjectSentrygunPlasma : public CObjectSentrygun
{
DECLARE_CLASS( CObjectSentrygunPlasma, CObjectSentrygun );
public:
DECLARE_SERVERCLASS();
virtual void Spawn();
virtual bool Fire( void );
virtual void CheckShield( void );
virtual bool HasAmmo( void );
private:
float m_flNextAmmoRecharge;
int m_nBurstCount;
};
#define SG_PLASMA_MODEL "models/sentry2.mdl"
#define PLASMA_SENTRYGUN_RECHARGE_TIME 1.25 // Time it takes to recharge 1 round of ammo
#define PLASMA_SENTRY_BURST_COUNT 4
//-----------------------------------------------------------------------------
// Purpose: Rocket launcher Sentrygun
//-----------------------------------------------------------------------------
class CObjectSentrygunRocketlauncher : public CObjectSentrygun
{
DECLARE_CLASS( CObjectSentrygunRocketlauncher, CObjectSentrygun );
public:
DECLARE_SERVERCLASS();
virtual void Spawn();
virtual bool Fire( void );
virtual void SetTechnology( bool bSmarter, bool bSensors );
};
#define SG_ROCKETLAUNCHER_MODEL "models/sentry3.mdl"
#endif // TF_OBJ_SENTRYGUN_H