Skip to content

Commit

Permalink
Exponentially increase style cost based on time since filling up the …
Browse files Browse the repository at this point in the history
…style meter

This prevents players from prolonging their style charge indefinitely.
Default parameters are:
- Same cost at 60s
- Double cost every 60s

This also makes it start out at half the cost.
  • Loading branch information
TomyLobo committed Dec 18, 2019
1 parent dca4906 commit eb5a604
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions mp/src/game/client/sdk/c_sdk_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ IMPLEMENT_CLIENTCLASS_DT( C_SDKPlayer, DT_SDKPlayer, CSDKPlayer )

RecvPropInt( RECVINFO( m_flStylePoints ) ),
RecvPropFloat( RECVINFO(m_flStyleSkillCharge) ),
RecvPropFloat( RECVINFO(m_flStyleSkillActivationTime) ),

RecvPropInt( RECVINFO( m_iSlowMoType ) ),
RecvPropBool( RECVINFO( m_bHasSuperSlowMo ) ),
Expand Down Expand Up @@ -339,6 +340,7 @@ BEGIN_PREDICTION_DATA( C_SDKPlayer )
DEFINE_PRED_FIELD( m_iShotsFired, FIELD_INTEGER, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flStylePoints, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flStyleSkillCharge, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flStyleSkillActivationTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flSlowMoSeconds, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flSlowMoTime, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
DEFINE_PRED_FIELD( m_flSlowMoMultiplier, FIELD_FLOAT, FTYPEDESC_INSENDTABLE ),
Expand Down
1 change: 1 addition & 0 deletions mp/src/game/client/sdk/c_sdk_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ class C_SDKPlayer : public C_BasePlayer

float m_flStylePoints;
float m_flStyleSkillCharge;
float m_flStyleSkillActivationTime;
float m_currentAlphaVal;

class CSDKSoundEvent
Expand Down
2 changes: 2 additions & 0 deletions mp/src/game/server/sdk/sdk_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ IMPLEMENT_SERVERCLASS_ST( CSDKPlayer, DT_SDKPlayer )

SendPropInt( SENDINFO( m_flStylePoints ) ),
SendPropFloat( SENDINFO( m_flStyleSkillCharge ) ),
SendPropFloat( SENDINFO( m_flStyleSkillActivationTime ) ),

SendPropInt( SENDINFO( m_iSlowMoType ), 4, SPROP_UNSIGNED ),
SendPropBool( SENDINFO( m_bHasSuperSlowMo ) ),
Expand Down Expand Up @@ -3998,6 +3999,7 @@ bool CSDKPlayer::UseStylePoints (void)
void CSDKPlayer::FillMeter()
{
m_flStyleSkillCharge = da_stylemetertotalcharge.GetFloat();
m_flStyleSkillActivationTime = gpGlobals->curtime;
}

void CSDKPlayer::ActivateMeter()
Expand Down
1 change: 1 addition & 0 deletions mp/src/game/server/sdk/sdk_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ class CSDKPlayer : public CBaseMultiplayerPlayer
// Universal Meter
CNetworkVar(float, m_flStylePoints);
CNetworkVar(float, m_flStyleSkillCharge);
CNetworkVar(float, m_flStyleSkillActivationTime);

CSDKPlayerStateInfo *m_pCurStateInfo; // This can be NULL if no state info is defined for m_iPlayerState.
bool HandleCommand_JoinTeam( int iTeam );
Expand Down
5 changes: 5 additions & 0 deletions mp/src/game/shared/sdk/sdk_player_shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,9 @@ void CSDKPlayer::DecayStyle()
m_flStylePoints = Approach(0, m_flStylePoints, flDecayThisFrame);
}

static ConVar da_style_diminish_after("da_style_diminish_after", "60", FCVAR_REPLICATED|FCVAR_CHEAT|FCVAR_DEVELOPMENTONLY);
static ConVar da_style_diminish_every("da_style_diminish_every", "60", FCVAR_REPLICATED|FCVAR_CHEAT|FCVAR_DEVELOPMENTONLY);

void CSDKPlayer::UseStyleCharge(SkillID eSkill, float flCharge)
{
if (SDKGameRules()->GetBountyPlayer() == this)
Expand All @@ -546,6 +549,8 @@ void CSDKPlayer::UseStyleCharge(SkillID eSkill, float flCharge)
if (m_Shared.m_bSuperSkill)
flCharge *= 0.5f; // They earned it, let them keep it a while longer.

flCharge *= FastPow2((gpGlobals->curtime - m_flStyleSkillActivationTime - da_style_diminish_after.GetFloat()) / da_style_diminish_every.GetFloat());

m_flStyleSkillCharge = max(m_flStyleSkillCharge - flCharge, 0);

if (!m_flStyleSkillCharge)
Expand Down

0 comments on commit eb5a604

Please sign in to comment.