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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "cbase.h"
#include "basegrenade_shared.h"
#include "engine/IEngineSound.h"
#include "grenade_base_empable.h"
#include "IEffects.h"
#if !defined( CLIENT_DLL )
// Global Savedata
BEGIN_DATADESC( CBaseEMPableGrenade )
// Function Pointers
DEFINE_THINKFUNC( FizzleThink ),
END_DATADESC()
#endif
IMPLEMENT_NETWORKCLASS_ALIASED( BaseEMPableGrenade, DT_BaseEMPableGrenade )
BEGIN_NETWORK_TABLE( CBaseEMPableGrenade, DT_BaseEMPableGrenade )
#if !defined( CLIENT_DLL )
SendPropFloat( SENDINFO( m_flFizzleDuration ), 10, SPROP_ROUNDDOWN, 0.0, 256.0f ),
#else
RecvPropFloat( RECVINFO( m_flFizzleDuration ) ),
#endif
END_NETWORK_TABLE()
LINK_ENTITY_TO_CLASS( base_empable_grenade, CBaseEMPableGrenade );
BEGIN_PREDICTION_DATA( CBaseEMPableGrenade )
DEFINE_PRED_FIELD( m_flFizzleDuration, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
END_PREDICTION_DATA()
#define GRENADE_FIZZLE_DURATION 0.5
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CBaseEMPableGrenade::CBaseEMPableGrenade( void )
{
m_flFizzleDuration = 0;
}
//-----------------------------------------------------------------------------
// Purpose: Apply EMP damage to class
//-----------------------------------------------------------------------------
bool CBaseEMPableGrenade::TakeEMPDamage( float duration )
{
// If we're fizzling already, ignore extra EMP damage
if ( m_flFizzleDuration )
return true;
// Fizzle away in a couple of seconds
m_flFizzleDuration = gpGlobals->curtime + MIN( duration, GRENADE_FIZZLE_DURATION );
SetThink( FizzleThink );
SetNextThink( gpGlobals->curtime + 0.1f );
return true;
}
//-----------------------------------------------------------------------------
// Purpose: Fizzle out and remove self from the world.
//-----------------------------------------------------------------------------
void CBaseEMPableGrenade::FizzleThink( void )
{
float flDeltaTime = m_flFizzleDuration - gpGlobals->curtime;
// Keep fizzling until it's time to go
if ( flDeltaTime > 0.0f )
{
// Emit a fizzle sound
EmitSound( "BaseEMPableGrenade.Fizzle" );
// Smoke & Spark
g_pEffects->Sparks( GetAbsOrigin() );
UTIL_Smoke( GetAbsOrigin(), random->RandomInt( 4, 7), 10 );
}
else
{
Remove( );
return;
}
SetNextThink( gpGlobals->curtime + 0.1f );
}
|