Skip to content

Commit

Permalink
Add a timeout to SG upgrade progress
Browse files Browse the repository at this point in the history
 * Makes upgrade progress reset after 1 second of no new upgrade progress (forces the consecutive clangs to be right in a row)
  • Loading branch information
squeek502 committed May 30, 2016
1 parent e293686 commit 33caf15
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
7 changes: 7 additions & 0 deletions dlls/ff/ff_sentrygun.cpp
Expand Up @@ -240,6 +240,7 @@ void CFFSentryGun::Precache( void )
{
VPROF_BUDGET( "CFFSentryGun::Precache", VPROF_BUDGETGROUP_FF_BUILDABLE );

PrecacheScriptSound("Sentry.PartialDowngrade");
BaseClass::Precache();
}

Expand Down Expand Up @@ -396,6 +397,12 @@ void CFFSentryGun::OnObjectThink( void )
}
}

if (ShouldUpgradeProgressReset())
{
SetUpgradeProgress(0);
EmitSound( "Sentry.PartialDowngrade" );
}

// Run base class thinking
CFFBuildableObject::OnObjectThink();
}
Expand Down
6 changes: 5 additions & 1 deletion game_shared/ff/ff_buildableobjects_shared.h
Expand Up @@ -87,6 +87,7 @@
#define FF_SENTRYGUN_UNBUILD_SOUND "Sentry.unbuild"
#define FF_SENTRYGUN_EXPLODE_SOUND "Sentry.Explode"
#define FF_SENTRYGUN_UPGRADE_SWINGS 3
#define FF_SENTRYGUN_UPGRADE_TIMEOUT 1.0f

#define FF_MANCANNON_MODEL "models/items/jumppad/jumppad.mdl"
#define FF_MANCANNON_BUILD_SOUND "JumpPad.Build"
Expand Down Expand Up @@ -662,10 +663,12 @@ class CFFSentryGun : public CFFBuildableObject
bool IsUpgradeProgressComplete() { return GetUpgradeProgress() >= GetMaxUpgradeProgress(); }
int GetUpgradeProgress() { return m_iUpgradeProgress; }
int GetMaxUpgradeProgress() { return FF_SENTRYGUN_UPGRADE_SWINGS; }
void SetUpgradeProgress(int iUpgradeProgress) { m_iUpgradeProgress = iUpgradeProgress; }
void SetUpgradeProgress(int iUpgradeProgress) { m_iUpgradeProgress = iUpgradeProgress; SetLastUpgradeProgress(gpGlobals->curtime); }
void DeltaUpgradeProgress(int iDelta) { SetUpgradeProgress(GetUpgradeProgress() + iDelta); }
void SetLastUpgradeProgress(float flTime) { m_flLastUpgradeProgress = flTime; }

#ifdef GAME_DLL
bool ShouldUpgradeProgressReset() { return GetUpgradeProgress() > 0 && m_flLastUpgradeProgress > 0 && gpGlobals->curtime >= m_flLastUpgradeProgress + FF_SENTRYGUN_UPGRADE_TIMEOUT; }
void Repair( int iCells = 0 );
void AddAmmo( int iShells = 0, int iRockets = 0 );

Expand All @@ -690,6 +693,7 @@ class CFFSentryGun : public CFFBuildableObject
CNetworkVar( int, m_iMaxRockets );

CNetworkVar( int, m_iUpgradeProgress );
float m_flLastUpgradeProgress;
// <-- shared

#ifdef CLIENT_DLL
Expand Down

0 comments on commit 33caf15

Please sign in to comment.