Skip to content

Add mp_hostage_fear cvar to control improved hostage AI fear reactions#1167

Open
belomaxorka wants to merge 1 commit into
rehlds:masterfrom
belomaxorka:feat/hostage-fear-cvar
Open

Add mp_hostage_fear cvar to control improved hostage AI fear reactions#1167
belomaxorka wants to merge 1 commit into
rehlds:masterfrom
belomaxorka:feat/hostage-fear-cvar

Conversation

@belomaxorka

Copy link
Copy Markdown

Addresses the hostage panic/scatter part of #1125.

What

New cvar mp_hostage_fear (default 1 - vanilla behavior) that controls whether hostages driven by the improved AI (hostage_ai_enable 1) get scared of gunfire, explosions and nearby deaths. With mp_hostage_fear 0 hostages stay calm: they don't panic, don't scatter and don't refuse to follow after nearby shooting - CS 1.6-like hostage temperament while keeping the rest of the improved AI (navigation, chatter, animations).

Why

With hostage_ai_enable 1 on CS 1.6 hostage maps, any nearby enemy gunfire frightens the hostages (CHostageImprov::OnGameEvent -> Frighten(SCARED/TERRIFIED)). Scared hostages scatter, crouch and refuse to follow the rescuer, which #1125 reports as disruptive on 1.6 servers, where the original hostages ignore gunfire completely. Server operators currently have no way to keep the improved AI but disable the fear reactions.

How it works

All fear-driven behavior (fleeing in HostageIdleState, refusing to follow, scared/afraid animations) is gated by CHostageImprov::IsScared(), which is true only while m_scaredTimer is running - and that timer is started exclusively in CHostageImprov::Frighten(). So a single early return in Frighten() when mp_hostage_fear is 0 keeps hostages calm everywhere. The cvar is evaluated on every call, so it can be flipped at runtime without a map change or server restart.

Edge cases

  • Direct damage to a hostage still makes it flee (OnInjury -> m_mustFlee in the idle state). That path is deliberately not gated: fleeing from an actual injury is self-preservation, distinct from panicking at noise.
  • Classic 1.6 hostage AI (hostage_ai_enable 0) is unaffected - it has no fear logic at all.
  • Default value 1 keeps vanilla behavior; vanilla builds are unaffected (the check is under #ifdef REGAMEDLL_ADD).

Tested

Windows build (MSVC), verified on a ReHLDS server with hostage_ai_enable 1:

  • mp_hostage_fear 1 (default): hostages panic, scatter and refuse to follow when a Terrorist fires nearby - unchanged behavior.
  • mp_hostage_fear 0 (set at runtime, no restart): hostages stay calm under fire and keep following normally.

When improved hostage AI (hostage_ai_enable 1) is used in CS 1.6,
hostages panic and scatter in response to gunfire, explosions and
nearby deaths. Setting mp_hostage_fear 0 keeps them calm, restoring
1.6-like hostage behavior while retaining the rest of the improved AI.

Related to rehlds#1125

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@belomaxorka belomaxorka changed the title Add mp_hostage_fear cvar to control improved hostage AI fear reactions Add mp_hostage_fear cvar to control improved hostage AI fear reactions Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant