rendered paste bodyvoid CGrenadeAR2::Spawn( void )
{
Precache( );
SetSolid( SOLID_BBOX );
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
// Hits everything but debris
SetCollisionGroup( COLLISION_GROUP_PROJECTILE );
SetModel( "models/Weapons/ar2_grenade.mdl");
UTIL_SetSize(this, Vector(-3, -3, -3), Vector(3, 3, 3));
// UTIL_SetSize(this, Vector(0, 0, 0), Vector(0, 0, 0));
SetUse( &CGrenadeAR2::DetonateUse );
SetTouch( &CGrenadeAR2::GrenadeAR2Touch );
SetThink( &CGrenadeAR2::GrenadeAR2Think );
SetNextThink( gpGlobals->curtime + 0.1f );
if( GetOwnerEntity() && GetOwnerEntity()->IsPlayer() )
{
m_flDamage = sk_plr_dmg_smg1_grenade.GetFloat();
}
else
{
m_flDamage = sk_npc_dmg_smg1_grenade.GetFloat();
}
m_DmgRadius = sk_smg1_grenade_radius.GetFloat();
m_takedamage = DAMAGE_YES;
m_bIsLive = true;
m_iHealth = 1;
SetGravity( UTIL_ScaleForGravity( 400 ) ); // use a lower gravity for grenades to make them easier to see
SetFriction( 0.8 );
SetSequence( 0 );
m_fDangerRadius = 100;
m_fSpawnTime = gpGlobals->curtime;
// -------------
// Smoke trail.
// -------------
m_hSmokeTrail = SmokeTrail::CreateSmokeTrail();
if( m_hSmokeTrail )
{
m_hSmokeTrail->m_SpawnRate = 4800;
m_hSmokeTrail->m_ParticleLifetime = 10;
m_hSmokeTrail->m_StartColor.Init(0.9, 0.1, 0.1);
m_hSmokeTrail->m_EndColor.Init(1,1,1);
m_hSmokeTrail->m_StartSize = 12;
m_hSmokeTrail->m_EndSize = m_hSmokeTrail->m_StartSize * 4;
m_hSmokeTrail->m_SpawnRadius = 4;
m_hSmokeTrail->m_MinSpeed = 4;
m_hSmokeTrail->m_MaxSpeed = 24;
m_hSmokeTrail->m_Opacity = 0.9f;
m_hSmokeTrail->SetLifetime(100.0f);
m_hSmokeTrail->FollowEntity(this);
}
}
void CGrenadeAR2::GrenadeAR2Touch( CBaseEntity *pOther )
{
Assert( pOther );
if ( !pOther->IsSolid() )
return;
// If I'm live go ahead and blow up
if (m_bIsLive)
{
DevMsg("BOOM");
}
else
{
// If I'm not live, only blow up if I'm hitting an chacter that
// is not the owner of the weapon
CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pOther );
if (pBCC && GetThrower() != pBCC)
{
m_bIsLive = true;
Detonate();
}
}
}
void CGrenadeAR2::Detonate(void)
{
if (!m_bIsLive)
{
return;
}
m_bIsLive = false;
m_takedamage = DAMAGE_NO;
UTIL_Remove( this );
}
void CGrenadeAR2::Detonate(void)
{
if (!m_bIsLive)
{
return;
}
m_bIsLive = false;
m_takedamage = DAMAGE_NO;
UTIL_Remove( this );
}