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
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
//=============================================================================//
#include "cbase.h"
#include "decals.h"
#include "basecombatcharacter.h"
#include "shake.h"
#include "engine/IEngineSound.h"
#include "soundent.h"
#include "entitylist.h"
#include "hl1_basegrenade.h"
extern short g_sModelIndexFireball; // (in combatweapon.cpp) holds the index for the fireball
extern short g_sModelIndexWExplosion; // (in combatweapon.cpp) holds the index for the underwater explosion
unsigned int CHL1BaseGrenade::PhysicsSolidMaskForEntity( void ) const
{
return BaseClass::PhysicsSolidMaskForEntity() | CONTENTS_HITBOX;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CHL1BaseGrenade::Precache()
{
BaseClass::Precache();
PrecacheScriptSound( "BaseGrenade.Explode" );
}
void CHL1BaseGrenade::Explode( trace_t *pTrace, int bitsDamageType )
{
float flRndSound;// sound randomizer
SetModelName( NULL_STRING );//invisible
AddSolidFlags( FSOLID_NOT_SOLID );
m_takedamage = DAMAGE_NO;
// Pull out of the wall a bit
if ( pTrace->fraction != 1.0 )
{
SetLocalOrigin( pTrace->endpos + (pTrace->plane.normal * 0.6) );
}
Vector vecAbsOrigin = GetAbsOrigin();
int contents = UTIL_PointContents ( vecAbsOrigin );
if ( pTrace->fraction != 1.0 )
{
Vector vecNormal = pTrace->plane.normal;
const surfacedata_t *pdata = physprops->GetSurfaceData( pTrace->surface.surfaceProps );
CPASFilter filter( vecAbsOrigin );
te->Explosion( filter, 0.0,
&vecAbsOrigin,
!( contents & MASK_WATER ) ? g_sModelIndexFireball : g_sModelIndexWExplosion,
m_DmgRadius * .03,
25,
TE_EXPLFLAG_NONE,
m_DmgRadius,
m_flDamage,
&vecNormal,
(char) pdata->game.material );
}
else
{
CPASFilter filter( vecAbsOrigin );
te->Explosion( filter, 0.0,
&vecAbsOrigin,
!( contents & MASK_WATER ) ? g_sModelIndexFireball : g_sModelIndexWExplosion,
m_DmgRadius * .03,
25,
TE_EXPLFLAG_NONE,
m_DmgRadius,
m_flDamage );
}
CSoundEnt::InsertSound ( SOUND_COMBAT, GetAbsOrigin(), BASEGRENADE_EXPLOSION_VOLUME, 3.0 );
// Use the owner's position as the reported position
Vector vecReported = GetThrower() ? GetThrower()->GetAbsOrigin() : vec3_origin;
CTakeDamageInfo info( this, GetThrower(), GetBlastForce(), GetAbsOrigin(), m_flDamage, bitsDamageType, 0, &vecReported );
RadiusDamage( info, GetAbsOrigin(), m_DmgRadius, CLASS_NONE, NULL );
UTIL_DecalTrace( pTrace, "Scorch" );
flRndSound = random->RandomFloat( 0 , 1 );
EmitSound( "BaseGrenade.Explode" );
SetTouch( NULL );
AddEffects( EF_NODRAW );
SetAbsVelocity( vec3_origin );
SetThink( &CBaseGrenade::Smoke );
SetNextThink( gpGlobals->curtime + 0.3);
if ( GetWaterLevel() == 0 )
{
int sparkCount = random->RandomInt( 0,3 );
QAngle angles;
VectorAngles( pTrace->plane.normal, angles );
for ( int i = 0; i < sparkCount; i++ )
Create( "spark_shower", GetAbsOrigin(), angles, NULL );
}
}
|