So why do they never all shoot you at once?
Picture a squad of five (the code's own limit: " MAX_SQUAD_MEMBERS 5") all firing whenever they see you. In our own test, with no rule, the health bar is empty in about a second.
Valve's released code gives each squad two shooting tickets and two grenade tickets ("bits_SLOT_HGRUNT_ENGAGE1", "ENGAGE2", "GRENADE1", "GRENADE2"). A soldier who sees you runs through the choice in this order: "// try to take an available ENGAGE slot", then "// throw a grenade if can and no engage slots are available", then "// hide!". When a shooter's plan changes or he dies, his ticket goes back ("VacateSlot") and the next soldier takes it. So you never face more than two guns at a time, and the waiting looks like tactics.
There's even a polite pause: if you've eluded the squad and aren't facing the soldier who finds you, the code issues "a call to the squad to waste a little time and give the player a chance to turn." And for a soldier left without a ticket: "Good place for a taunt, I guess?"
The bay, figures, damage and timings in this film are our own simplified version, built in code.
Which game's hidden trick should we cut open next?
Source: Valve's released Half-Life 1 SDK (squadmonster.h, squadmonster.cpp, hgrunt.cpp), github.com/ValveSoftware/halflife.
Unofficial. Not affiliated with or endorsed by Valve.
Sounds and music: our own, made in code.
