Skip to content

Commit

Permalink
Exponentially decrease wanted healing amount based on time since beco…
Browse files Browse the repository at this point in the history
…ming 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.
  • Loading branch information
TomyLobo committed Dec 20, 2019
1 parent aea4baf commit 408bd6e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mp/src/game/server/sdk/sdk_player.cpp
Original file line number Diff line number Diff line change
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
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

0 comments on commit 408bd6e

Please sign in to comment.