Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void CEnvExplosion::InputExplode( inputdata_t &inputdata )
- {
- trace_t tr;
- SetModelName( NULL_STRING );//invisible
- SetSolid( SOLID_NONE );// intangible
- Vector vecSpot = GetAbsOrigin() + Vector( 0 , 0 , 8 );
- UTIL_TraceLine( vecSpot, vecSpot + Vector( 0, 0, -40 ), (MASK_SOLID_BRUSHONLY | MASK_WATER), this, COLLISION_GROUP_NONE, &tr );
- // Pull out of the wall a bit. We used to move the explosion origin itself, but that seems unnecessary, not to mention a
- // little weird when you consider that it might be in hierarchy. Instead we just calculate a new virtual position at
- // which to place the explosion. We don't use that new position to calculate radius damage because according to Steve's
- // comment, that adversely affects the force vector imparted on explosion victims when they ragdoll.
- Vector vecExplodeOrigin = GetAbsOrigin();
- if ( tr.fraction != 1.0 )
- {
- vecExplodeOrigin = tr.endpos + (tr.plane.normal * 24 );
- }
- // draw decal
- if (! ( m_spawnflags & SF_ENVEXPLOSION_NODECAL ))
- {
- if ( ! ( m_spawnflags & SF_ENVEXPLOSION_ICE ))
- UTIL_DecalTrace( &tr, "Scorch" );
- else
- UTIL_DecalTrace( &tr, "Ice_Explosion_Decal" );
- }
- // It's stupid that this entity's spawnflags and the flags for the
- // explosion temp ent don't match up. But because they don't, we
- // have to reinterpret some of the spawnflags to determine which
- // flags to pass to the temp ent.
- int nFlags = TE_EXPLFLAG_NONE;
- if( m_spawnflags & SF_ENVEXPLOSION_NOFIREBALL )
- {
- nFlags |= TE_EXPLFLAG_NOFIREBALL;
- }
- if( m_spawnflags & SF_ENVEXPLOSION_NOSOUND )
- {
- nFlags |= TE_EXPLFLAG_NOSOUND;
- }
- if ( m_spawnflags & SF_ENVEXPLOSION_RND_ORIENT )
- {
- nFlags |= TE_EXPLFLAG_ROTATE;
- }
- if ( m_nRenderMode == kRenderTransAlpha )
- {
- nFlags |= TE_EXPLFLAG_DRAWALPHA;
- }
- else if ( m_nRenderMode != kRenderTransAdd )
- {
- nFlags |= TE_EXPLFLAG_NOADDITIVE;
- }
- if( m_spawnflags & SF_ENVEXPLOSION_NOPARTICLES )
- {
- nFlags |= TE_EXPLFLAG_NOPARTICLES;
- }
- if( !(m_spawnflags & SF_ENVEXPLOSION_NODLIGHTS) )
- {
- nFlags |= TE_EXPLFLAG_DLIGHT;
- }
- if ( m_spawnflags & SF_ENVEXPLOSION_NOFIREBALLSMOKE )
- {
- nFlags |= TE_EXPLFLAG_NOFIREBALLSMOKE;
- }
- if ( m_spawnflags & SF_ENVEXPLOSION_ICE )
- {
- nFlags |= TE_EXPLFLAG_ICE;
- }
- //Get the damage override if specified
- int iRadius = ( m_iRadiusOverride > 0 ) ? m_iRadiusOverride : ( m_iMagnitude * 2.5f );
- CPASFilter filter( vecExplodeOrigin );
- te->Explosion( filter, 0.0,
- &vecExplodeOrigin,
- ( m_sFireballSprite < 1 ) ? g_sModelIndexFireball : m_sFireballSprite,
- !( m_spawnflags & SF_ENVEXPLOSION_NOFIREBALL ) ? ( m_spriteScale / 10.0 ) : 0.0,
- 15,
- nFlags,
- iRadius,
- m_iMagnitude );
- // do damage
- if ( !( m_spawnflags & SF_ENVEXPLOSION_NODAMAGE ) )
- {
- CBaseEntity *pAttacker = GetOwnerEntity() ? GetOwnerEntity() : this;
- // Only calculate damage type if we didn't get a custom one passed in
- int iDamageType = m_iCustomDamageType;
- if ( iDamageType == -1 )
- {
- iDamageType = HasSpawnFlags( SF_ENVEXPLOSION_GENERIC_DAMAGE ) ? DMG_GENERIC : DMG_BLAST;
- }
- CTakeDamageInfo info( m_hInflictor ? m_hInflictor : this, pAttacker, m_iMagnitude, iDamageType );
- if( HasSpawnFlags( SF_ENVEXPLOSION_SURFACEONLY ) )
- {
- info.AddDamageType( DMG_BLAST_SURFACE );
- }
- if ( m_flDamageForce )
- {
- // Not the right direction, but it'll be fixed up by RadiusDamage.
- info.SetDamagePosition( GetAbsOrigin() );
- info.SetDamageForce( Vector( m_flDamageForce, 0, 0 ) );
- }
- RadiusDamage( info, GetAbsOrigin(), iRadius, m_iClassIgnore, m_hEntityIgnore.Get() );
- }
- SetThink( &CEnvExplosion::Smoke );
- SetNextThink( gpGlobals->curtime + 0.3 );
- // Only do these effects if we're not submerged
- if ( UTIL_PointContents( GetAbsOrigin(), MASK_WATER ) & CONTENTS_WATER )
- {
- // draw sparks
- if ( !( m_spawnflags & SF_ENVEXPLOSION_NOSPARKS ) )
- {
- int sparkCount = random->RandomInt(0,3);
- for ( int i = 0; i < sparkCount; i++ )
- {
- QAngle angles;
- VectorAngles( tr.plane.normal, angles );
- Create( "spark_shower", vecExplodeOrigin, angles, NULL );
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement