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
257
258
259
260
261
262
263
264
265
266
267
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef WEAPON_RPG_H
#define WEAPON_RPG_H
#ifdef _WIN32
#pragma once
#endif
#include "weapon_hl2mpbasehlmpcombatweapon.h"
#ifdef CLIENT_DLL
#include "iviewrender_beams.h"
#endif
#ifndef CLIENT_DLL
#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:
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 );
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;
private:
float m_flGracePeriodEndsAt;
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 );
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 );
#endif
//-----------------------------------------------------------------------------
// RPG
//-----------------------------------------------------------------------------
#ifdef CLIENT_DLL
#define CWeaponRPG C_WeaponRPG
#endif
class CWeaponRPG : public CBaseHL2MPCombatWeapon
{
DECLARE_CLASS( CWeaponRPG, CBaseHL2MPCombatWeapon );
public:
CWeaponRPG();
~CWeaponRPG();
DECLARE_NETWORKCLASS();
DECLARE_PREDICTABLE();
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 );
bool CanHolster( 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; }
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 );
// 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 );
#ifdef CLIENT_DLL
// We need to render opaque and translucent pieces
virtual RenderGroup_t GetRenderGroup( void ) { return RENDER_GROUP_TWOPASS; }
virtual void NotifyShouldTransmit( ShouldTransmitState_t state );
virtual int DrawModel( int flags );
virtual void ViewModelDrawn( C_BaseViewModel *pBaseViewModel );
virtual bool IsTranslucent( void );
void InitBeam( void );
void GetWeaponAttachment( int attachmentId, Vector &outVector, Vector *dir = NULL );
void DrawEffects( void );
// void DrawLaserDot( void );
CMaterialReference m_hSpriteMaterial; // Used for the laser glint
CMaterialReference m_hBeamMaterial; // Used for the laser beam
Beam_t *m_pBeam; // Laser beam temp entity
#endif //CLIENT_DLL
CBaseEntity *GetMissile( void ) { return m_hMissile; }
#ifndef CLIENT_DLL
DECLARE_ACTTABLE();
#endif
protected:
CNetworkVar( bool, m_bInitialStateUpdate );
CNetworkVar( bool, m_bGuiding );
CNetworkVar( bool, m_bHideGuiding );
CNetworkHandle( CBaseEntity, m_hMissile );
CNetworkVar( Vector, m_vecLaserDot );
#ifndef CLIENT_DLL
CHandle<CLaserDot> m_hLaserDot;
#endif
private:
CWeaponRPG( const CWeaponRPG & );
};
#endif // WEAPON_RPG_H
|