Skip to content

Commit 89b7ddd

Browse files
committed
Bots pause firing after inflicting team damage
1 parent 8cfdc9f commit 89b7ddd

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

src/game/server/neo/bot/neo_bot.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ void CNEOBot::PressFireButton(float duration)
469469
{
470470
// can't fire if stunned
471471
// @todo Tom Bui: Eventually, we'll probably want to check the actual weapon for supress fire
472-
if (HasAttribute(CNEOBot::SUPPRESS_FIRE))
472+
if ( GetBotPauseFiring() || HasAttribute(CNEOBot::SUPPRESS_FIRE) )
473473
{
474474
ReleaseFireButton();
475475
return;

src/game/server/neo/neo_player.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3253,9 +3253,16 @@ int CNEO_Player::OnTakeDamage_Alive(const CTakeDamageInfo& info)
32533253
attacker->m_iTeamDamageInflicted += iDamage;
32543254
}
32553255

3256-
if (info.GetDamageType() & (DMG_BULLET | DMG_SLASH | DMG_BUCKSHOT)) {
3256+
constexpr const int botDamageTypes = DMG_SLASH | DMG_BULLET | DMG_BUCKSHOT;
3257+
if (info.GetDamageType() & botDamageTypes)
3258+
{
32573259
++m_iBotDetectableBleedingInjuryEvents;
32583260
}
3261+
3262+
if (bIsTeamDmg && NEORules()->IsTeamplay() && attacker->IsBot() && (info.GetDamageType() & botDamageTypes))
3263+
{
3264+
attacker->m_botPauseFiringTimer.Start(1.0f);
3265+
}
32593266
}
32603267
}
32613268
}

src/game/server/neo/neo_player.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class CNEO_Player : public CHL2MP_Player
178178
bool GetInThermOpticCamo() const { return m_bInThermOpticCamo; }
179179
// bots can't see anything, so they need an additional timer for cloak disruption events
180180
bool GetBotCloakStateDisrupted() const { return !m_botThermOpticCamoDisruptedTimer.IsElapsed(); }
181+
bool GetBotPauseFiring() const { return !m_botPauseFiringTimer.IsElapsed(); }
181182
bool GetSpectatorTakeoverPlayerPending() const { return m_bSpectatorTakeoverPlayerPending; }
182183

183184
virtual void StartAutoSprint(void) OVERRIDE;
@@ -243,6 +244,8 @@ class CNEO_Player : public CHL2MP_Player
243244

244245
// tracks time since last cloak disruption event for bots who can't actually see
245246
CountdownTimer m_botThermOpticCamoDisruptedTimer;
247+
// cooldown after inflicting accidental team damage
248+
CountdownTimer m_botPauseFiringTimer;
246249

247250
private:
248251
float GetActiveWeaponSpeedScale() const;

0 commit comments

Comments
 (0)