Skip to content

Commit cbf8f84

Browse files
committed
gameplay: allow bots to deal explosive self dmg if non-significant
if it's more than 30% of their HP, then don't do it! but otherwise, this fixes a bug where bots would freeze and not do anything if they were too close to their target
1 parent 37186c7 commit cbf8f84

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/game/server/tf/bot/behavior/tf_bot_behavior.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1427,7 +1427,14 @@ void CTFBotMainAction::FireWeaponAtEnemy( CTFBot *me )
14271427

14281428
float hitRange = trace.fraction * 1.1f * threatRange;
14291429

1430-
if ( hitRange < TF_ROCKET_RADIUS )
1430+
// Accurate enough base damage
1431+
float flExplosiveDamage = 100.0f;
1432+
// Don't factor overheal
1433+
float flCurrentHealth = MIN( me->GetHealth(), me->GetMaxHealth() );
1434+
// Don't hit ourselves if the explosion will do a noticeable amount of our health
1435+
bool bTooMuchSelfDamage = flExplosiveDamage > 0.3f * flCurrentHealth;
1436+
1437+
if ( bTooMuchSelfDamage && hitRange < TF_ROCKET_RADIUS )
14311438
{
14321439
// shot will impact very near us
14331440
if ( !trace.m_pEnt || ( trace.m_pEnt && !trace.m_pEnt->MyCombatCharacterPointer() ) )

0 commit comments

Comments
 (0)