diff options
| author | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
|---|---|---|
| committer | FluorescentCIAAfricanAmerican <[email protected]> | 2020-04-22 12:56:21 -0400 |
| commit | 3bf9df6b2785fa6d951086978a3e66f49427166a (patch) | |
| tree | 2c0f1f0c63c4832882bc93814ebd2c2b1c6224e5 /game/server/hl1/hl1_basegrenade.cpp | |
| download | archived-source-engine-2018-hl2-src-master.tar.xz archived-source-engine-2018-hl2-src-master.zip | |
Diffstat (limited to 'game/server/hl1/hl1_basegrenade.cpp')
| -rw-r--r-- | game/server/hl1/hl1_basegrenade.cpp | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/game/server/hl1/hl1_basegrenade.cpp b/game/server/hl1/hl1_basegrenade.cpp new file mode 100644 index 0000000..8762ae4 --- /dev/null +++ b/game/server/hl1/hl1_basegrenade.cpp @@ -0,0 +1,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 ); + } +} |