Skip to content

Commit

Permalink
Add custom smoke sprite for env_explosion
Browse files Browse the repository at this point in the history
  • Loading branch information
FreeSlave committed Sep 25, 2023
1 parent 3745197 commit 68000b1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion dlls/explode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ class CEnvExplosion : public CBaseEntity
int m_iMagnitude;// how large is the fireball? how much damage?
int m_spriteScale; // what's the exact fireball sprite scale?
int m_iRadius;
string_t m_smokeSprite;

int m_iFireball;
int m_iSmoke;
};

TYPEDESCRIPTION CEnvExplosion::m_SaveData[] =
Expand All @@ -124,6 +126,11 @@ void CEnvExplosion::KeyValue( KeyValueData *pkvd )
m_iRadius = atoi( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else if( FStrEq(pkvd->szKeyName, "smokesprite") )
{
m_smokeSprite = ALLOC_STRING( pkvd->szValue );
pkvd->fHandled = TRUE;
}
else
CBaseEntity::KeyValue( pkvd );
}
Expand All @@ -132,6 +139,8 @@ void CEnvExplosion::Precache()
{
if (!FStringNull(pev->model))
m_iFireball = PRECACHE_MODEL(STRING(pev->model));
if (!FStringNull(m_smokeSprite))
m_iSmoke = PRECACHE_MODEL(STRING(m_smokeSprite));
}

void CEnvExplosion::Spawn( void )
Expand Down Expand Up @@ -290,7 +299,7 @@ void CEnvExplosion::Smoke( void )
WRITE_COORD( pev->origin.x );
WRITE_COORD( pev->origin.y );
WRITE_COORD( pev->origin.z );
WRITE_SHORT( g_sModelIndexSmoke );
WRITE_SHORT( m_iSmoke ? m_iSmoke : g_sModelIndexSmoke );
WRITE_BYTE( (BYTE)m_spriteScale ); // scale * 10
WRITE_BYTE( 12 ); // framerate
MESSAGE_END();
Expand Down
3 changes: 2 additions & 1 deletion fgd/halflife.fgd
Original file line number Diff line number Diff line change
Expand Up @@ -1527,7 +1527,8 @@
64: "No Sound" : 0
128: "Activator is attacker" : 0
]
model(sprite) : "Fireball Sprite"
model(sprite) : "Custom Fireball Sprite"
smokesprite(sprite) : "Custom Smoke Sprite"
scale(string) : "Custom sprite scale"
]

Expand Down

0 comments on commit 68000b1

Please sign in to comment.