Skip to content

Improved prop_thumper #416

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions sp/src/game/client/hl2/c_thumper_dust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,6 @@ class ThumperDustEmitter : public CSimpleEmitter

void FX_ThumperDust( const CEffectData &data )
{
Vector vecDustColor;
vecDustColor.x = 0.85f;
vecDustColor.y = 0.75f;
vecDustColor.z = 0.52f;

CSmartPtr<ThumperDustEmitter> pSimple = ThumperDustEmitter::Create( "thumperdust" );

Expand Down Expand Up @@ -117,7 +113,7 @@ void FX_ThumperDust( const CEffectData &data )

// Setup the color for these particles
engine->ComputeLighting( data.m_vOrigin, NULL, true, vecColor );
VectorLerp( vecColor, vecDustColor, 0.5, vecColor );
VectorLerp( vecColor, data.m_CustomColors.m_vecColor1, 0.5, vecColor );
vecColor *= 255;

for ( i = 0; i < numPuffs; i++ )
Expand Down
38 changes: 35 additions & 3 deletions sp/src/game/server/hl2/prop_thumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
#define THUMPER_RADIUS 1000
#endif

#define SF_NO_DUST 1
#define SF_NO_SHAKE 2
#define SF_DISABLED 4

#define STATE_CHANGE_MODIFIER 0.02f
#define THUMPER_SOUND_DURATION 1.5f
Expand Down Expand Up @@ -58,6 +61,10 @@ class CPropThumper : public CBaseAnimating
EHANDLE m_hRepellantEnt;
int m_iDustScale;


// I would have used color24 instead of color32, but there is no FIELD_COLOR32
color32 m_DustColor;

COutputEvent m_OnThumped; // Fired when thumper goes off

#if HL2_EPISODIC
Expand All @@ -84,6 +91,9 @@ BEGIN_DATADESC( CPropThumper )
DEFINE_INPUTFUNC( FIELD_VOID, "Enable", InputEnable ),

DEFINE_OUTPUT( m_OnThumped, "OnThumped" ),

DEFINE_KEYFIELD( m_DustColor, FIELD_COLOR32, "DustColor" ),

END_DATADESC()

void CPropThumper::Spawn( void )
Expand All @@ -104,7 +114,10 @@ void CPropThumper::Spawn( void )

BaseClass::Spawn();

m_bEnabled = true;
if (HasSpawnFlags(SF_DISABLED))
m_bEnabled = false;
else
m_bEnabled = true;

SetThink( &CPropThumper::Think );
SetNextThink( gpGlobals->curtime + 1.0f );
Expand Down Expand Up @@ -141,6 +154,15 @@ void CPropThumper::Spawn( void )
m_iEffectRadius = 1000;
#endif

//This isn't very clever, but there needs to be a fallback for maps that dont have a color specified.
//Mappers can use 1 1 1 instead of 0 0 0, as it looks the same.
if ((m_DustColor.r == 0 && m_DustColor.g == 0 && m_DustColor.b == 0) && !HasSpawnFlags(SF_NO_DUST))
{
m_DustColor.r = 0.85 * 255;
m_DustColor.g = 0.75 * 255;
m_DustColor.b = 0.52 * 255;
}

}

void CPropThumper::Precache( void )
Expand Down Expand Up @@ -205,8 +227,18 @@ void CPropThumper::Thump ( void )
data.m_nEntIndex = entindex();
data.m_vOrigin = vOrigin;
data.m_flScale = m_iDustScale * m_flPlaybackRate;
DispatchEffect( "ThumperDust", data );
UTIL_ScreenShake( vOrigin, 10.0 * m_flPlaybackRate, m_flPlaybackRate, m_flPlaybackRate / 2, THUMPER_RADIUS * m_flPlaybackRate, SHAKE_START, false );

data.m_bCustomColors = true;
data.m_CustomColors.m_vecColor1.x = (float)m_DustColor.r / 255;
data.m_CustomColors.m_vecColor1.y = (float)m_DustColor.g / 255;
data.m_CustomColors.m_vecColor1.z = (float)m_DustColor.b / 255;

if (!HasSpawnFlags(SF_NO_DUST))
DispatchEffect("ThumperDust", data);

if (!HasSpawnFlags(SF_NO_SHAKE))
UTIL_ScreenShake(vOrigin, 10.0 * m_flPlaybackRate, m_flPlaybackRate, m_flPlaybackRate / 2, THUMPER_RADIUS * m_flPlaybackRate, SHAKE_START, false);

}

EmitSound( "coast.thumper_dust" );
Expand Down