Skip to content

Commit

Permalink
Merge pull request #155 from BSVino/stylebar-diminishing-returns
Browse files Browse the repository at this point in the history
WIP: Balance bonuses by diminishing returns after a while
  • Loading branch information
BSVino authored Dec 24, 2019
2 parents e405177 + 408bd6e commit e48a0ef
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 4 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
7 changes: 4 additions & 3 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 ), 32, SPROP_NOSCALE ),

SendPropInt( SENDINFO( m_iSlowMoType ), 4, SPROP_UNSIGNED ),
SendPropBool( SENDINFO( m_bHasSuperSlowMo ) ),
Expand Down Expand Up @@ -1875,8 +1876,7 @@ void CSDKPlayer::Event_Killed( const CTakeDamageInfo &info )
CreateRagdollEntity();

// Turn off slow motion.
if (m_flSlowMoTime)
DeactivateSlowMo();
DeactivateSlowMo();

State_Transition( STATE_DEATH_ANIM ); // Transition into the dying state.

Expand Down Expand Up @@ -3909,7 +3909,7 @@ CBaseEntity *CSDKPlayer::GiveNamedItem( const char *pszName, int iSubType )
void CSDKPlayer::AddStylePoints(float points, style_sound_t eStyle, announcement_t eAnnouncement, style_point_t ePointStyle)
{
if (SDKGameRules()->GetBountyPlayer() == this)
TakeHealth(points, 0);
SDKGameRules()->HealWanted(points);

points *= GetDKRatio(0.7, 2, true);

Expand Down Expand Up @@ -3999,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
15 changes: 14 additions & 1 deletion mp/src/game/shared/sdk/sdk_gamerules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ REGISTER_GAMERULES_CLASS( CSDKGameRules );

BEGIN_NETWORK_TABLE_NOBASE( CSDKGameRules, DT_SDKGameRules )
#if defined ( CLIENT_DLL )
RecvPropFloat( RECVINFO( m_flCurrentMiniObjectiveStartTime )),
RecvPropInt( RECVINFO( m_eCurrentMiniObjective ), 0, RECVCALLBACKPROXY(RecvProxy_Int32ToInt32, RecvCallback_UpdateRichPresence) ),
RecvPropFloat( RECVINFO( m_flGameStartTime ) ),
RecvPropBool( RECVINFO( m_bIsTeamplay ) ),
Expand All @@ -107,6 +108,7 @@ BEGIN_NETWORK_TABLE_NOBASE( CSDKGameRules, DT_SDKGameRules )
RecvPropEHandle( RECVINFO( m_hRaceWaypoint2 ) ),
RecvPropEHandle( RECVINFO( m_hRaceWaypoint3 ) ),
#else
SendPropFloat( SENDINFO( m_flCurrentMiniObjectiveStartTime ), 32, SPROP_NOSCALE ),
SendPropInt( SENDINFO( m_eCurrentMiniObjective ) ),
SendPropFloat( SENDINFO( m_flGameStartTime ), 32, SPROP_NOSCALE ),
SendPropBool( SENDINFO( m_bIsTeamplay ) ),
Expand Down Expand Up @@ -1836,6 +1838,16 @@ const char *CSDKGameRules::GetKillingWeaponName( const CTakeDamageInfo &info, CS
return killer_weapon_name;
}

static ConVar da_wanted_heal_diminish_after("da_wanted_heal_diminish_after", "60", FCVAR_REPLICATED|FCVAR_CHEAT|FCVAR_DEVELOPMENTONLY);
static ConVar da_wanted_heal_diminish_every("da_wanted_heal_diminish_every", "60", FCVAR_REPLICATED|FCVAR_CHEAT|FCVAR_DEVELOPMENTONLY);

void CSDKGameRules::HealWanted(float flHealAmount)
{
flHealAmount /= FastPow2((gpGlobals->curtime - m_flCurrentMiniObjectiveStartTime - da_wanted_heal_diminish_after.GetFloat()) / da_wanted_heal_diminish_every.GetFloat());
GetBountyPlayer()->TakeHealth(flHealAmount, 0);
}


void CSDKGameRules::PlayerKilled( CBasePlayer *pVictim, const CTakeDamageInfo &info )
{
if (pVictim && pVictim == GetBountyPlayer())
Expand Down Expand Up @@ -1863,7 +1875,7 @@ void CSDKGameRules::PlayerKilled( CBasePlayer *pVictim, const CTakeDamageInfo &i
}
else if (GetBountyPlayer() && GetBountyPlayer() == ToSDKPlayer(info.GetAttacker()))
{
GetBountyPlayer()->TakeHealth(25, 0);
HealWanted(25);
}

CSDKPlayer* pLeader = GetLeader();
Expand Down Expand Up @@ -2214,6 +2226,7 @@ void CSDKGameRules::StartMiniObjective(const char* pszObjective)
return;

m_eCurrentMiniObjective = m_ePreviousMiniObjective = eObjective;
m_flCurrentMiniObjectiveStartTime = gpGlobals->curtime;

CSDKPlayer::SendBroadcastNotice(GetNoticeForMiniObjective(m_eCurrentMiniObjective));

Expand Down
2 changes: 2 additions & 0 deletions mp/src/game/shared/sdk/sdk_gamerules.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class CSDKGameRules : public CTeamplayRules
void RadiusDamage( const CTakeDamageInfo &info, const Vector &vecSrcIn, float flRadius, int iClassIgnore, CBaseEntity *pEntityIgnore );

public:
void HealWanted( float flHealAmount );
void PlayerKilled( CBasePlayer *pVictim, const CTakeDamageInfo &info );
virtual void DeathNotice( CBasePlayer *pVictim, const CTakeDamageInfo &info );
const char *GetKillingWeaponName( const CTakeDamageInfo &info, CSDKPlayer *pVictim, int *iWeaponID );
Expand All @@ -234,6 +235,7 @@ class CSDKGameRules : public CTeamplayRules

private:
float m_flNextMiniObjectiveStartTime;
CNetworkVar( float, m_flCurrentMiniObjectiveStartTime);
CNetworkVar( miniobjective_t, m_eCurrentMiniObjective );
miniobjective_t m_ePreviousMiniObjective;

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_cost_increase_after("da_style_cost_increase_after", "60", FCVAR_REPLICATED|FCVAR_CHEAT|FCVAR_DEVELOPMENTONLY);
static ConVar da_style_cost_increase_every("da_style_cost_increase_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_cost_increase_after.GetFloat()) / da_style_cost_increase_every.GetFloat());

m_flStyleSkillCharge = max(m_flStyleSkillCharge - flCharge, 0);

if (!m_flStyleSkillCharge)
Expand Down

0 comments on commit e48a0ef

Please sign in to comment.