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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef WEAPON_RPG_H
#define WEAPON_RPG_H
#ifdef _WIN32
#pragma once
#endif
#include "basehlcombatweapon.h"
#include "Sprite.h"
#include "npcevent.h"
#include "beam_shared.h"
class CWeaponRPG;
class CLaserDot;
class RocketTrail;
//###########################################################################
// >> CMissile (missile launcher class is below this one!)
//###########################################################################
class CMissile : public CBaseCombatCharacter
{
DECLARE_CLASS( CMissile, CBaseCombatCharacter );
public:
static const int EXPLOSION_RADIUS = 200;
CMissile();
~CMissile();
#ifdef HL1_DLL
Class_T Classify( void ) { return CLASS_NONE; }
#else
Class_T Classify( void ) { return CLASS_MISSILE; }
#endif
void Spawn( void );
void Precache( void );
void MissileTouch( CBaseEntity *pOther );
void Explode( void );
void ShotDown( void );
void AccelerateThink( void );
void AugerThink( void );
void IgniteThink( void );
void SeekThink( void );
void DumbFire( void );
void SetGracePeriod( float flGracePeriod );
int OnTakeDamage_Alive( const CTakeDamageInfo &info );
void Event_Killed( const CTakeDamageInfo &info );
virtual float GetDamage() { return m_flDamage; }
virtual void SetDamage(float flDamage) { m_flDamage = flDamage; }
unsigned int PhysicsSolidMaskForEntity( void ) const;
CHandle<CWeaponRPG> m_hOwner;
static CMissile *Create( const Vector &vecOrigin, const QAngle &vecAngles, edict_t *pentOwner );
void CreateDangerSounds( bool bState ){ m_bCreateDangerSounds = bState; }
static void AddCustomDetonator( CBaseEntity *pEntity, float radius, float height = -1 );
static void RemoveCustomDetonator( CBaseEntity *pEntity );
protected:
virtual void DoExplosion();
virtual void ComputeActualDotPosition( CLaserDot *pLaserDot, Vector *pActualDotPosition, float *pHomingSpeed );
virtual int AugerHealth() { return m_iMaxHealth - 20; }
// Creates the smoke trail
void CreateSmokeTrail( void );
// Gets the shooting position
void GetShootPosition( CLaserDot *pLaserDot, Vector *pShootPosition );
CHandle<RocketTrail> m_hRocketTrail;
float m_flAugerTime; // Amount of time to auger before blowing up anyway
float m_flMarkDeadTime;
float m_flDamage;
struct CustomDetonator_t
{
EHANDLE hEntity;
float radiusSq;
float halfHeight;
};
static CUtlVector<CustomDetonator_t> gm_CustomDetonators;
private:
float m_flGracePeriodEndsAt;
bool m_bCreateDangerSounds;
DECLARE_DATADESC();
};
//-----------------------------------------------------------------------------
// Laser dot control
//-----------------------------------------------------------------------------
CBaseEntity *CreateLaserDot( const Vector &origin, CBaseEntity *pOwner, bool bVisibleDot );
void SetLaserDotTarget( CBaseEntity *pLaserDot, CBaseEntity *pTarget );
void EnableLaserDot( CBaseEntity *pLaserDot, bool bEnable );
//-----------------------------------------------------------------------------
// Specialized mizzizzile
//-----------------------------------------------------------------------------
class CAPCMissile : public CMissile
{
DECLARE_CLASS( CMissile, CMissile );
DECLARE_DATADESC();
public:
static CAPCMissile *Create( const Vector &vecOrigin, const QAngle &vecAngles, const Vector &vecVelocity, CBaseEntity *pOwner );
CAPCMissile();
~CAPCMissile();
void IgniteDelay( void );
void AugerDelay( float flDelayTime );
void ExplodeDelay( float flDelayTime );
void DisableGuiding();
#if defined( HL2_DLL )
virtual Class_T Classify ( void ) { return CLASS_COMBINE; }
#endif
void AimAtSpecificTarget( CBaseEntity *pTarget );
void SetGuidanceHint( const char *pHintName );
void APCSeekThink( void );
CAPCMissile *m_pNext;
protected:
virtual void DoExplosion();
virtual void ComputeActualDotPosition( CLaserDot *pLaserDot, Vector *pActualDotPosition, float *pHomingSpeed );
virtual int AugerHealth();
private:
void Init();
void ComputeLeadingPosition( const Vector &vecShootPosition, CBaseEntity *pTarget, Vector *pLeadPosition );
void BeginSeekThink();
void AugerStartThink();
void ExplodeThink();
void APCMissileTouch( CBaseEntity *pOther );
float m_flReachedTargetTime;
float m_flIgnitionTime;
bool m_bGuidingDisabled;
float m_flLastHomingSpeed;
EHANDLE m_hSpecificTarget;
string_t m_strHint;
};
//-----------------------------------------------------------------------------
// Finds apc missiles in cone
//-----------------------------------------------------------------------------
CAPCMissile *FindAPCMissileInCone( const Vector &vecOrigin, const Vector &vecDirection, float flAngle );
//-----------------------------------------------------------------------------
// RPG
//-----------------------------------------------------------------------------
class CWeaponRPG : public CBaseHLCombatWeapon
{
DECLARE_CLASS( CWeaponRPG, CBaseHLCombatWeapon );
public:
CWeaponRPG();
~CWeaponRPG();
DECLARE_SERVERCLASS();
void Precache( void );
void PrimaryAttack( void );
virtual float GetFireRate( void ) { return 1; };
void ItemPostFrame( void );
void Activate( void );
void DecrementAmmo( CBaseCombatCharacter *pOwner );
bool Deploy( void );
bool Holster( CBaseCombatWeapon *pSwitchingTo = NULL );
bool Reload( void );
bool WeaponShouldBeLowered( void );
bool Lower( void );
virtual void Drop( const Vector &vecVelocity );
int GetMinBurst() { return 1; }
int GetMaxBurst() { return 1; }
float GetMinRestTime() { return 4.0; }
float GetMaxRestTime() { return 4.0; }
bool WeaponLOSCondition( const Vector &ownerPos, const Vector &targetPos, bool bSetConditions );
int WeaponRangeAttack1Condition( float flDot, float flDist );
void Operator_HandleAnimEvent( animevent_t *pEvent, CBaseCombatCharacter *pOperator );
void StartGuiding( void );
void StopGuiding( void );
void ToggleGuiding( void );
bool IsGuiding( void );
void NotifyRocketDied( void );
bool HasAnyAmmo( void );
void SuppressGuiding( bool state = true );
void CreateLaserPointer( void );
void UpdateLaserPosition( Vector vecMuzzlePos = vec3_origin, Vector vecEndPos = vec3_origin );
Vector GetLaserPosition( void );
void StartLaserEffects( void );
void StopLaserEffects( void );
void UpdateLaserEffects( void );
// NPC RPG users cheat and directly set the laser pointer's origin
void UpdateNPCLaserPosition( const Vector &vecTarget );
void SetNPCLaserPosition( const Vector &vecTarget );
const Vector &GetNPCLaserPosition( void );
int CapabilitiesGet( void ) { return bits_CAP_WEAPON_RANGE_ATTACK1; }
virtual const Vector& GetBulletSpread( void )
{
static Vector cone = VECTOR_CONE_3DEGREES;
return cone;
}
CBaseEntity *GetMissile( void ) { return m_hMissile; }
DECLARE_ACTTABLE();
DECLARE_DATADESC();
protected:
bool m_bInitialStateUpdate;
bool m_bGuiding;
bool m_bHideGuiding; //User to override the player's wish to guide under certain circumstances
Vector m_vecNPCLaserDot;
CHandle<CLaserDot> m_hLaserDot;
CHandle<CMissile> m_hMissile;
CHandle<CSprite> m_hLaserMuzzleSprite;
CHandle<CBeam> m_hLaserBeam;
};
#endif // WEAPON_RPG_H
|