dlls/smoke_trail.cpp
565758596061
DEFINE_KEYFIELD( m_SpawnRadius, FIELD_FLOAT, "spawnradius" ),
DEFINE_FIELD( m_bEmit, FIELD_BOOLEAN ),
DEFINE_FIELD( m_nAttachment, FIELD_INTEGER ),
END_DATADESC()
56575859606162
DEFINE_KEYFIELD( m_SpawnRadius, FIELD_FLOAT, "spawnradius" ),
DEFINE_FIELD( m_bEmit, FIELD_BOOLEAN ),
DEFINE_FIELD( m_nAttachment, FIELD_INTEGER ),
DEFINE_THINKFUNC( Think ),
END_DATADESC()
166167168169170171172173174175
m_nAttachment = 0;
}
BaseClass::FollowEntity( pEntity );
}
//==================================================
// RocketTrail
//==================================================
167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
m_nAttachment = 0;
}
SetThink( &SmokeTrail::Think );
SetNextThink( gpGlobals->curtime );
BaseClass::FollowEntity( pEntity );
}
//-----------------------------------------------------------------------------
// Purpose: Kill the trail if in water and do bubbles
//-----------------------------------------------------------------------------
void SmokeTrail::Think( void )
{
// A smoke trail dies when the object
// it is attached to goes into water
if( GetFollowedEntity() )
{
if( GetFollowedEntity()->GetWaterLevel() != 0 )
{
if( m_bEmit )
SetEmit( false );
// If we're going slow enough, don't do bubbles anymore
// Also make sure we're still underwater and haven't bounced out
if( ( GetFollowedEntity()->GetAbsVelocity() != vec3_origin ) && ( UTIL_PointContents( GetFollowedEntity()->GetAbsOrigin() ) & MASK_WATER ) )
{
// Do bubbles!
UTIL_Bubbles( GetFollowedEntity()->GetAbsOrigin() - Vector( 16, 16, 16 ), GetFollowedEntity()->GetAbsOrigin() + Vector( 16, 16, 16 ), random->RandomInt( 3, 8 ) );
}
// Think slower underwater
SetNextThink( gpGlobals->curtime + random->RandomFloat( 0.1f, 0.4f ) );
}
else
{
// Set next time to think. Not underwater
// yet so keep spamming the think function
SetNextThink( gpGlobals->curtime );
}
}
}
//==================================================
// RocketTrail
//==================================================
212213214215216217
DEFINE_FIELD( m_nAttachment, FIELD_INTEGER ),
DEFINE_FIELD( m_bDamaged, FIELD_BOOLEAN ),
DEFINE_FIELD( m_flFlareScale, FIELD_FLOAT ),
END_DATADESC()
250251252253254255256
DEFINE_FIELD( m_nAttachment, FIELD_INTEGER ),
DEFINE_FIELD( m_bDamaged, FIELD_BOOLEAN ),
DEFINE_FIELD( m_flFlareScale, FIELD_FLOAT ),
DEFINE_THINKFUNC( Think ),
END_DATADESC()
290291292293294295296297298
m_nAttachment = 0;
}
BaseClass::FollowEntity( pEntity );
}
//==================================================
// SporeTrail
//==================================================
329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
m_nAttachment = 0;
}
SetThink( &RocketTrail::Think );
SetNextThink( gpGlobals->curtime );
BaseClass::FollowEntity( pEntity );
}
//-----------------------------------------------------------------------------
// Purpose: Kill the trail if in water and do bubbles
//-----------------------------------------------------------------------------
void RocketTrail::Think( void )
{
// A rocket trail dies when the object
// it is attached to goes into water but
// will restart if that object comes out
// of water
if( GetFollowedEntity() )
{
if( GetFollowedEntity()->GetWaterLevel() != 0 )
{
if( m_bEmit )
SetEmit( false );
// Make sure we're still under water... since we
// think slower we might have left the water and
// are now airborn (so therefore we don't want
// bubbles being made!)
if( UTIL_PointContents( GetFollowedEntity()->GetAbsOrigin() ) & MASK_WATER )
{
// Do bubbles!
UTIL_Bubbles( GetFollowedEntity()->GetAbsOrigin() - Vector( 16, 16, 16 ), GetFollowedEntity()->GetAbsOrigin() + Vector( 16, 16, 16 ), random->RandomInt( 3, 8 ) );
}
// Think slower underwater
SetNextThink( gpGlobals->curtime + random->RandomFloat( 0.1f, 0.4f ) );
}
else
{
// Turn on the trail, we're leaving water
if( !m_bEmit )
SetEmit( true );
// Set next time to think
SetNextThink( gpGlobals->curtime );
}
}
else
{
// If we're not following an entity, remove self
// See if this helps the rogue rocket trails at all
SetThink(&RocketTrail::SUB_Remove);
SetNextThink(gpGlobals->curtime);
}
}
//==================================================
// SporeTrail
//==================================================