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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "dod_smokegrenade.h"
#include "particle_parse.h"
LINK_ENTITY_TO_CLASS( grenade_smoke, CDODSmokeGrenade );
PRECACHE_WEAPON_REGISTER( grenade_smoke );
BEGIN_DATADESC( CDODSmokeGrenade )
DEFINE_THINKFUNC( Think_Emit ),
DEFINE_THINKFUNC( Think_Fade ),
DEFINE_THINKFUNC( Think_Remove )
END_DATADESC()
IMPLEMENT_SERVERCLASS_ST( CDODSmokeGrenade, DT_DODSmokeGrenade )
SendPropTime(SENDINFO(m_flSmokeSpawnTime) ),
END_SEND_TABLE()
void CDODSmokeGrenade::Spawn()
{
BaseClass::Spawn();
SetThink( &CDODSmokeGrenade::Think_Emit );
SetNextThink( gpGlobals->curtime + 0.5 );
m_bInitialSmoke = false;
m_flRemoveTime = -1;
m_flSmokeSpawnTime = 0;
}
void CDODSmokeGrenade::Precache()
{
PrecacheScriptSound( "SmokeGrenade.Bounce" );
PrecacheParticleSystem( "smokegrenade" );
PrecacheParticleSystem( "smokegrenade_jet" );
BaseClass::Precache();
}
void CDODSmokeGrenade::BounceSound( void )
{
EmitSound( "SmokeGrenade.Bounce" );
}
void CDODSmokeGrenade::Think_Emit( void )
{
// if we're stationary and have not yet created smoke, do so now
Vector vel;
AngularImpulse a;
VPhysicsGetObject()->GetVelocity( &vel, &a );
if ( vel.Length() < 15.0 && !m_bInitialSmoke )
{
VPhysicsGetObject()->EnableMotion( false );
// Smoke Cloud
DispatchParticleEffect( "smokegrenade", GetAbsOrigin(), vec3_angle );
// Smoke Jet
DispatchParticleEffect( "smokegrenade_jet", PATTACH_POINT, this, "jet" );
EmitSound( "BaseSmokeEffect.Sound" );
m_flRemoveTime = gpGlobals->curtime + 10;
m_bInitialSmoke = true;
m_flSmokeSpawnTime = gpGlobals->curtime;
}
// if its past our bedtime, fade out
if ( m_flRemoveTime > 0 && gpGlobals->curtime > m_flRemoveTime )
{
m_nRenderMode = kRenderTransColor;
SetThink( &CDODSmokeGrenade::Think_Fade );
}
SetNextThink( gpGlobals->curtime + 0.1 );
}
// Fade the projectile out over time before making it disappear
void CDODSmokeGrenade::Think_Fade()
{
m_bFading = true;
SetNextThink( gpGlobals->curtime );
color32 c = GetRenderColor();
c.a -= 1;
SetRenderColor( c.r, c.b, c.g, c.a );
if ( !c.a )
{
SetModelName( NULL_STRING );//invisible
SetNextThink( gpGlobals->curtime + 10 );
SetThink( &CDODSmokeGrenade::Think_Remove ); // Spit out smoke for 10 seconds.
SetSolid( SOLID_NONE );
}
}
void CDODSmokeGrenade::Think_Remove()
{
// stop all effects
StopParticleEffects( this );
SetModelName( NULL_STRING );//invisible
SetSolid( SOLID_NONE );
SetMoveType( MOVETYPE_NONE );
UTIL_Remove( this );
}
void CDODSmokeGrenade::Detonate( void )
{
// Intentionally blank - our detonate does nothing
}
|