From dca4906dcdaf7de2dd5dec021fff29b75313b8c8 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Wed, 18 Dec 2019 13:53:57 +0100 Subject: [PATCH 1/3] Remove superfluous check This is already checked inside the function. --- mp/src/game/server/sdk/sdk_player.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mp/src/game/server/sdk/sdk_player.cpp b/mp/src/game/server/sdk/sdk_player.cpp index c1ea29b28..fecc4bb5b 100644 --- a/mp/src/game/server/sdk/sdk_player.cpp +++ b/mp/src/game/server/sdk/sdk_player.cpp @@ -1875,8 +1875,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. From aea4baf3bb0f7e193fa1e0b387b2d346b38674ce Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Wed, 18 Dec 2019 16:23:45 +0100 Subject: [PATCH 2/3] Exponentially increase style cost based on time since filling up the 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. --- mp/src/game/client/sdk/c_sdk_player.cpp | 2 ++ mp/src/game/client/sdk/c_sdk_player.h | 1 + mp/src/game/server/sdk/sdk_player.cpp | 2 ++ mp/src/game/server/sdk/sdk_player.h | 1 + mp/src/game/shared/sdk/sdk_player_shared.cpp | 5 +++++ 5 files changed, 11 insertions(+) diff --git a/mp/src/game/client/sdk/c_sdk_player.cpp b/mp/src/game/client/sdk/c_sdk_player.cpp index 773c8914a..014697611 100644 --- a/mp/src/game/client/sdk/c_sdk_player.cpp +++ b/mp/src/game/client/sdk/c_sdk_player.cpp @@ -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 ) ), @@ -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 ), diff --git a/mp/src/game/client/sdk/c_sdk_player.h b/mp/src/game/client/sdk/c_sdk_player.h index 97527d892..3508639ef 100644 --- a/mp/src/game/client/sdk/c_sdk_player.h +++ b/mp/src/game/client/sdk/c_sdk_player.h @@ -350,6 +350,7 @@ class C_SDKPlayer : public C_BasePlayer float m_flStylePoints; float m_flStyleSkillCharge; + float m_flStyleSkillActivationTime; float m_currentAlphaVal; class CSDKSoundEvent diff --git a/mp/src/game/server/sdk/sdk_player.cpp b/mp/src/game/server/sdk/sdk_player.cpp index fecc4bb5b..63bf0b370 100644 --- a/mp/src/game/server/sdk/sdk_player.cpp +++ b/mp/src/game/server/sdk/sdk_player.cpp @@ -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 ) ), @@ -3998,6 +3999,7 @@ bool CSDKPlayer::UseStylePoints (void) void CSDKPlayer::FillMeter() { m_flStyleSkillCharge = da_stylemetertotalcharge.GetFloat(); + m_flStyleSkillActivationTime = gpGlobals->curtime; } void CSDKPlayer::ActivateMeter() diff --git a/mp/src/game/server/sdk/sdk_player.h b/mp/src/game/server/sdk/sdk_player.h index aea117302..ad580a008 100644 --- a/mp/src/game/server/sdk/sdk_player.h +++ b/mp/src/game/server/sdk/sdk_player.h @@ -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 ); diff --git a/mp/src/game/shared/sdk/sdk_player_shared.cpp b/mp/src/game/shared/sdk/sdk_player_shared.cpp index 3629b5892..070306a9c 100644 --- a/mp/src/game/shared/sdk/sdk_player_shared.cpp +++ b/mp/src/game/shared/sdk/sdk_player_shared.cpp @@ -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) @@ -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) From 408bd6e3a37fa4505017ad86a1ec5ae42c986313 Mon Sep 17 00:00:00 2001 From: TomyLobo Date: Fri, 20 Dec 2019 01:17:22 +0100 Subject: [PATCH 3/3] Exponentially decrease wanted healing amount based on time since becoming wanted This prevents players from prolonging the wanted indefinitely. Default parameters are: - Same cost at 60s - Double cost every 60s This also makes it start out at half the cost. --- mp/src/game/server/sdk/sdk_player.cpp | 2 +- mp/src/game/shared/sdk/sdk_gamerules.cpp | 15 ++++++++++++++- mp/src/game/shared/sdk/sdk_gamerules.h | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mp/src/game/server/sdk/sdk_player.cpp b/mp/src/game/server/sdk/sdk_player.cpp index 63bf0b370..46b63ebff 100644 --- a/mp/src/game/server/sdk/sdk_player.cpp +++ b/mp/src/game/server/sdk/sdk_player.cpp @@ -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); diff --git a/mp/src/game/shared/sdk/sdk_gamerules.cpp b/mp/src/game/shared/sdk/sdk_gamerules.cpp index 122cf8594..7f5f17fac 100644 --- a/mp/src/game/shared/sdk/sdk_gamerules.cpp +++ b/mp/src/game/shared/sdk/sdk_gamerules.cpp @@ -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 ) ), @@ -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 ) ), @@ -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()) @@ -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(); @@ -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)); diff --git a/mp/src/game/shared/sdk/sdk_gamerules.h b/mp/src/game/shared/sdk/sdk_gamerules.h index a2c99286e..e1728db5c 100644 --- a/mp/src/game/shared/sdk/sdk_gamerules.h +++ b/mp/src/game/shared/sdk/sdk_gamerules.h @@ -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 ); @@ -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;