Skip to content

Commit 4fd0a57

Browse files
committed
gameplay: consider overheal penalties when calculating pct hp charge rate
this was fixed for the Razorback, but the Fists of Steel can be used to build uber just as fast since even at max overheal, the Heavy will not hit the reduced charge rate health amount. I'm not sure how the Fists of Steel was implemented, but I tried to provide an example of how this bug could be fixed.
1 parent e5647b3 commit 4fd0a57

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

src/game/shared/tf/tf_player_shared.cpp

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2181,13 +2181,48 @@ 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+
CTFWeaponBase* pActiveWeapon = m_pOuter->GetActiveTFWeapon();
2218+
if ( pActiveWeapon )
2219+
{
2220+
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( pActiveWeapon, flPatientOverheal, mult_patient_overheal_penalty_active );
2221+
}
2222+
}
2223+
21892224
// Find the healer we have who's providing the most overheal
2190-
float flBoostMax = m_pOuter->GetMaxHealthForBuffing() * tf_max_health_boost.GetFloat();
2225+
float flBoostMax = m_pOuter->GetMaxHealthForBuffing() * GetOverhealBonus( tf_max_health_boost.GetFloat(), flPatientOverheal );
21912226
#ifdef GAME_DLL
21922227
if ( !bIgnoreAttributes )
21932228
{

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)