Skip to content

Commit 1a3d8b3

Browse files
committed
gameplay: consider overheal penalties when calculating pct hp charge rate
1 parent ad61025 commit 1a3d8b3

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

src/game/shared/tf/tf_player_shared.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2181,13 +2181,45 @@ void CTFPlayerShared::OnConditionRemoved( ETFCond eCond )
21812181
}
21822182
}
21832183

2184+
// FIXME: copied from tf_weapon_medigun... move to a common place
2185+
float GetOverhealBonus( float flOverheal, float flMod )
2186+
{
2187+
// Handle bonuses as additive, penalties as percentage...
2188+
float flOverhealBonus = flOverheal - 1.0f;
2189+
if ( flMod >= 1.0f )
2190+
{
2191+
flOverhealBonus += flMod;
2192+
}
2193+
else if ( flMod < 1.0f && flOverhealBonus > 0.0f )
2194+
{
2195+
flOverhealBonus *= flMod;
2196+
flOverhealBonus += 1.0f;
2197+
}
2198+
2199+
// Safety net
2200+
if ( flOverhealBonus <= 1.0f )
2201+
{
2202+
flOverhealBonus = 1.0f;
2203+
}
2204+
2205+
return flOverhealBonus;
2206+
}
2207+
21842208
//-----------------------------------------------------------------------------
21852209
// Purpose: Returns the overheal bonus the specified healer is capable of buffing to
21862210
//-----------------------------------------------------------------------------
21872211
int CTFPlayerShared::GetMaxBuffedHealth( bool bIgnoreAttributes /*= false*/, bool bIgnoreHealthOverMax /*= false*/ )
21882212
{
2213+
float flPatientOverheal = 1.0f;
2214+
if ( !bIgnoreAttributes )
2215+
{
2216+
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( m_pOuter, flPatientOverheal, mult_patient_overheal_penalty );
2217+
// TODO: active
2218+
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( m_pOuter, flPatientOverheal, mult_patient_overheal_penalty_active );
2219+
}
2220+
21892221
// Find the healer we have who's providing the most overheal
2190-
float flBoostMax = m_pOuter->GetMaxHealthForBuffing() * tf_max_health_boost.GetFloat();
2222+
float flBoostMax = m_pOuter->GetMaxHealthForBuffing() * GetOverhealBonus( tf_max_health_boost.GetFloat(), flPatientOverheal );
21912223
#ifdef GAME_DLL
21922224
if ( !bIgnoreAttributes )
21932225
{

src/game/shared/tf/tf_weapon_medigun.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,6 +1219,14 @@ bool CWeaponMedigun::FindAndHealTargets( void )
12191219
{
12201220
#ifdef GAME_DLL
12211221
int iBoostMax = floor( pTFPlayer->m_Shared.GetMaxBuffedHealth() * 0.95);
1222+
1223+
// Make sure the boost is at least the max health (if < max health, we aren't fully healed)
1224+
int iMaxHealth = pTFPlayer->GetMaxHealthForBuffing();
1225+
if ( iBoostMax < iMaxHealth )
1226+
{
1227+
iBoostMax = iMaxHealth;
1228+
}
1229+
12221230
float flChargeModifier = 1.f;
12231231

12241232
// Reduced charge for healing fully healed guys

0 commit comments

Comments
 (0)