Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions bots/promod_ai.gsc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,13 @@ on_round_end()
{
level waittill("game_ended");
setdvar("bot_ai_ready", 0);
players = getentarray("player", "classname");
for (i = 0; i < players.size; i++)
if (players[i].isbot)
{
players[i] notify("bot_use");
players[i] BotBuiltinBotAction("-activate");
}
}

attach()
Expand All @@ -148,6 +155,7 @@ attach()
self.promod_ai_core_spawned = undefined;
self maps\mp\bots\_bot_internal::added();
self thread difficulty_control();
self thread objective_spawns();
self maps\mp\bots\_bot_internal::connected();
self thread model_ready();
self thread weapon_selection();
Expand Down Expand Up @@ -337,3 +345,17 @@ bot_trace(message)
if (getdvarint("bot_debug"))
logprint(message + "\n");
}

// Start only after the existing combat core announces each native spawn.
objective_spawns()
{
self endon("disconnect");
self endon("promod_ai_reset");
level endon("game_ended");
for (;;)
{
self thread maps\mp\bots\sd_objectives::start();
self waittill("bot_spawned");
wait 0.05;
}
}
94 changes: 94 additions & 0 deletions bots/sd_objectives.gsc
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
// Promod-specific glue for the derived Bot Warfare S&D routines.
// Mod asset terms and attribution: docs/third-party-bots.md.

start()
{
self endon("disconnect");
self endon("death");
self endon("promod_ai_reset");
level endon("game_ended");
self waittill("bot_spawned");
if (!getdvarint("bot_sd_objectives") || !self.isbot)
return;
if (getdvarint("bot_debug")) logprint("PMBOT SD_START slot=" + self getentitynumber() + "\n");
self.bot_lock_goal = false;
self thread cleanup_on_death();
self thread cleanup_on_reset();
self thread bot_sd_attackers();
self thread bot_sd_defenders();
}

cleanup_on_death()
{
self endon("disconnect");
self endon("promod_ai_reset");
level endon("game_ended");
self waittill("death");
self notify("bot_use");
self BotBuiltinBotAction("-activate");
}

cleanup_on_reset()
{
self endon("disconnect");
self endon("death");
level endon("game_ended");
self waittill("promod_ai_reset");
self notify("bot_use");
self notify("new_goal");
self BotBuiltinBotAction("-activate");
}

carries_bomb()
{
return isdefined(level.sdbomb) && isdefined(self.carryobject) &&
self.carryobject == level.sdbomb;
}

objective_goal(origin, radius)
{
if (getdvarint("bot_debug")) logprint("PMBOT SD_GOAL slot=" + self getentitynumber() + " origin=" + origin + "\n");
self SetScriptGoal(origin, radius);
self thread goal_deadline(level.bombplanted);
}

goal_deadline(planted)
{
self endon("disconnect");
self endon("death");
self endon("promod_ai_reset");
self endon("new_goal");
self endon("goal");
self endon("bad_path");
level endon("game_ended");
deadline = gettime() + 45000;
while (gettime() < deadline && getdvarint("bot_sd_objectives") &&
!level.gameended && planted == level.bombplanted)
wait 0.1;
self notify("bad_path");
}

wait_stop_move()
{
deadline = gettime() + 2000;
while (gettime() < deadline && (!self isonground() || lengthsquared(self getvelocity()) > 1))
wait 0.05;
}

hold_objective_use(duration)
{
if (getdvarint("bot_debug")) logprint("PMBOT SD_USE slot=" + self getentitynumber() + "\n");
planted = level.bombplanted;
deadline = gettime() + int(duration * 1000);
while (gettime() < deadline && getdvarint("bot_sd_objectives") &&
!level.gameended && planted == level.bombplanted &&
!level.bombdefused && !level.bombexploded && !self HasThreat())
{
// Short renewable native input leases: interruption cannot leave use held.
// The native game object validates contact, team and ownership every tick.
self thread BotPressUse(0.1);
wait 0.05;
}
self notify("bot_use");
self BotBuiltinBotAction("-activate");
}
145 changes: 145 additions & 0 deletions docs/promod-military-sd.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Final feature candidate: military names and native S&D

Status: candidate implementation, **not gameplay certified**. Feature freeze
resumes after this focused delivery; no unrelated development is authorized.
No production/homologation runtime, deployment policy or RCON bridge is changed.
Owner approval is required for merges and a separate supervised homologation.

## Ownership and behavior

Engine population management consumes Bot Warfare's existing root
`scriptdata/botnames.txt` convention when `bot_use_names=1`. Configuration owns
the 15-name military pool; the workspace copies it and includes its content in
the configuration fingerprint. Assignment happens only in `BotAddOne`, before
`SV_AddBotClient`. Existing bots and humans are never renamed. Round restarts
retain native client userinfo. Subsequent admissions rotate through the unused names using a process cursor (reset on process restart),
including collision checks against humans after native name cleaning, ignoring
case. Missing, invalid, oversized or exhausted pools use unique numbered Promod
fallbacks. Name input is bounded to 8192 bytes and 31 ASCII display bytes per
line; overlong and unsafe lines are rejected rather than truncated. Blank lines
are ignored; allowed characters are letters, numbers, spaces, dots and hyphens.
Zombies uses its existing naming path. Changing the pool affects new bots only.

`bot_sd_objectives=1` starts the pinned Bot Warfare S&D routines after the
existing combat core's `bot_spawned` event. Enabling it midround takes effect
on the next spawn. Disabling cancels held input and outstanding navigation
within the 100ms goal watchdog; controllers remain idle/retry until the next
spawn. `bots_play_obj` stays zero because the stock all-gametype initializer and
its callback replacements are not installed.

Preparation extracts only S&D routines and their helpers. It removes the stock
preplant defender lookup of the dropped bomb, and reactions to remote enemy
plant/defuse activity. Navigation uses public sites and the announced planted
bomb; teammate carrier ownership remains normal. Bad paths have bounded waits
and the attacker retries another site. Promod exposes its existing defuse object
through a reference; native creation, callbacks, timers and outcomes are intact.
Carrier tests use authoritative `carryObject`, not Bot Warfare's absent flag.
Use input passes through the existing Bot Warfare adapter and native player
button path. Native Promod validates ownership, team, contact, health and the
full hold timer. Short renewable input leases release on interruption; death
and round end explicitly clear use. No production code teleports, grants bombs,
invokes plant/defuse callbacks, sets bomb outcomes or reads enemy carrier data.

Pinned inputs are unchanged: Bot Warfare v2.2.0 at
`7b52b462e40fa68287b9e54602e52da83b17766c`, Promod LIVE V2.20 EU and all
eight header hashes in `bots/dependencies.json`. Licensed extracted/generated
scripts stay private. Source terms and credits: [third-party-bots.md](third-party-bots.md).
The preserved PoC remains read-only. Objective qualification build 1291 SHA-256:
`e5278dd552ad3fd486fbc3d295ed680804a272327185f4848ab2915893c20584`.
Final reviewed preparation manifest SHA-256:
`bf0ff97b01490d20316f1bc2c563f0bd837fff69b389dbe3b1b5ee3946ca2d63`.
Its private `inputs.json` binds both S&D overlay identities and pinned assets.

## Evidence and remaining gates

Local engine build passes. Existing and focused parser/overlay Python tests,
native population policy, rotation and voting harnesses pass. Workspace packaging
and operation mocks are run without SSH or service changes. Hosted mandatory CI
must pass on final PR heads; existing workflows are retained without changes.

`tests/run_sd_native.py` creates a new loopback process and verifies pinned
Promod/header identities. Its native fixture uses **test-only positioning** to
exercise legitimate pickup, interrupted plant/defuse and real native completion.
Accepted Crash evidence: `/tmp/cod4x-sd-native-qakidgli/results.json` shows plant
5150ms, defuse 7100ms, both interruptions, carrier death/drop/recovery, death during defuse, native
round reset, pure=1 and all 12 requested names retained across the round. Strike
(`/tmp/cod4x-sd-native-tuz9t_ot`), Winter Crash (`4hrkqryt`) and Backlot
(`v4up0t8v`, with the same `/tmp/cod4x-sd-native-` prefix) also passed. It does not prove autonomous navigation or real-client gameplay.
Rejected runs are retained privately and are not qualification evidence.

The final-source no-positioning navigation fixture passed on Crash at
`/tmp/cod4x-sd-native-8b_azzwk/results.json`: Soap picked up and navigated to a
site, held use at 0:56, native `P_P` occurred at 1:01; Thompson held use at 1:05,
native `P_D` at 1:12. Combat fire and enemy perception are suppressed only in
this disposable fixture. This demonstrates autonomous navigation and native
objective interactions, not behavior under combat or real-client certification.
Earlier polling observers missed a real defuse before round end; those runs
remain rejected, and the runner now observes the native `bomb_defused` event.

Native interaction/lifecycle fixtures passed on all 21 configured S&D maps
(first site on each, using fixture positioning). The private matrix is
`/tmp/cod4-final-map-matrix.json`; it contains 16 passes plus an initial Bog
fixture grounding rejection. Bog's traced grounded placement then passed in
`/tmp/cod4x-sd-native-4avuq1fj`; Crash/Strike/Winter Crash/Backlot are the four
separate passes listed above. This is not a 21-map autonomous route/combat test.

`/tmp/cod4x-sd-native-vm05fp72/results.json` passed duplicate/unsafe name-pool
rejection, exhausted-pool numbered fallback, case-insensitive collision handling,
round preservation, and a synthetic human retaining Capt. Price while native
`bot_kick 3`/`bot_add 3` removed/recreated the other bots. Twelve unique names
remained, with one human and eleven bots. Human priority/Ready Up/authentication
remain covered by existing regressions; synthetic peers do not replace clients.

Local totals: 83 engine Python tests (one existing optional skip), two catalog
tests, 53 workspace tests, native population policy/rotation/voting and the
workspace operations mocks pass. Existing hosted Configuration/Operations and
engine Linux/Windows CI passed on the initial draft heads; required checks must
also pass on the final heads. No workflow or protection was changed.

Independent Principal source architecture/security review approved draft review
on 2026-10-27. Objective source review is bound to engine `a4e6c5f`; independent review also
approved the final name-cursor delta committed as `2cfc558`. Coordinated catalog
`ca71c9d` and workspace `6d92b98` retain independent source approval. Final naming
qualification build 1293 SHA-256 is
`84294d91a62c3dbfeab7ec3eb86cd1a2b39d8be529877fb0a68c9bcea5dae64c`.
`/tmp/cod4x-sd-native-csvkxixf` passes full native lifecycle, names across rounds
and rotation through all fifteen names across replacement admissions;
`/tmp/cod4x-sd-native-kc8psw70` repeats duplicate/unsafe/overflow/human-collision
and administration qualification with that same binary. Full qualification approval remains pending.
Supervised real-client combat, both sites/routes across supported maps, human
bomb ownership/HUD, full matches, and exact-artifact homologation/rollback must
be qualified before promotion. Zombies regression must not be silently certified: two build-1291 runs
(`/tmp/btd-five-allies-vja6233l` and `n_tk7kgw` with the same prefix) passed 51/52,
failing only `five_allies_native_engagement`. The unchanged fixture using the
previously qualified binary `2aac8c013b234a4dee8272bcb8e3fc09f5df3e35a7f8f936ccf0bb464e607b70`
passed 52/52 at `/tmp/btd-five-allies-8q8wczc9`. Purity, headers, native hits,
lifecycle, human priority, administration and script-error checks passed in the
51/52 runs. A prior wrong-baseline run without the existing Killhouse repair was
rejected separately. Thresholds and Zombies source are unchanged; preserve all
candidate/control evidence and keep the gameplay gate open. The final build-1293
run passed all 52 checks at `/tmp/btd-five-allies-e8pcoy76/results.json`.
The independent Principal reviewer accepted that local regression pass while
retaining the earlier engagement failures as a supervised-gameplay concern.
Operator gameplay and balance flags remain false.

Build 1293 was compiled with the reviewed naming-cursor working-tree delta before
its `2cfc558` commit. Its embedded/base evidence revision is `8c6084f`; it must
not be described as a clean build of that revision. The exact binary SHA above,
reviewed cursor delta and preserved fixture outputs bind this precommit local
run. A fresh exact-revision artifact and supervised qualification are required
after approved merges.

## Rollback and freeze

Revert the focused engine, catalog and workspace changes together and rebuild
the prior reviewed artifact. Preserve the previous immutable artifact and config
hash for operational rollback. There is no data migration. Setting
`bot_sd_objectives=0`/`bot_use_names=0` stops new objective/name activation but
is not an approved replacement for exact-artifact rollback. No merges,
deployments, bridge activation or production promotion are performed here.
After approved merges, prepare one pinned homologation candidate, obtain owner
deployment approval, supervise real-client gameplay and exact-artifact rollback,
then request qualification approval before proposing production promotion.

Development is frozen across the three repositories outside focused qualification
and remediation of this final candidate. No additional features are authorized.
79 changes: 76 additions & 3 deletions src/sv_bot_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
#include "qcommon.h"
#include "qcommon_io.h"
#include "sv_bot_policy.h"
#include "sv_bot_names.h"
#include "g_sv_shared.h"
#include "filesystem.h"

static cvar_t *bot_enable, *bot_ai_ready, *bot_fill_limit, *bot_skill;
static cvar_t *btd_allies_enable, *btd_allies_limit;
static cvar_t *btd_allies_enable, *btd_allies_limit, *bot_use_names;
static bot_fill_state_t fill_state = BOT_FILL_ACTIVE;
static int next_fill;
static unsigned int next_name_index;

static int BotCount(void)
{
Expand Down Expand Up @@ -51,10 +53,79 @@ static qboolean BotQueueWaiting(void)
return qfalse;
}

/* Names are assigned once, never by renaming an existing player. Include humans
* in collision checks without modifying their names. Re-read the small local
* pool on admission so editing it affects only newly created Promod bots. */
static qboolean BotNameUsed(const char *name)
{
int i;
for (i = 0; i < sv_maxclients->integer; ++i) {
char clean[BOT_NAME_BYTES];
client_t *cl = &svs.clients[i];
if (cl->state < CS_CONNECTED) continue;
ClientCleanName(Info_ValueForKey(cl->userinfo, "name"), clean, sizeof(clean), qfalse);
if (!Q_stricmp(clean, name)) return qtrue;
}
return qfalse;
}

static qboolean BotPoolName(char name[BOT_NAME_BYTES])
{
fileHandle_t file;
char data[BOT_NAMES_BYTES], candidate[BOT_NAME_BYTES], fallback[BOT_NAME_BYTES];
unsigned int count = 0, index = 0, start, fallback_index = 0;
qboolean have_fallback = qfalse;
const char *cursor = data;
int length = FS_SV_FOpenFileRead("scriptdata/botnames.txt", &file);
if (!file) return qfalse;
if (length <= 0 || length > sizeof(data)) {
FS_FCloseFile(file);
return qfalse;
}
if (FS_Read(data, length, file) != length) {
FS_FCloseFile(file);
return qfalse;
}
FS_FCloseFile(file);
while (BotName_Next(&cursor, data + length, candidate)) ++count;
if (!count) return qfalse;
start = next_name_index % count;
cursor = data;
while (BotName_Next(&cursor, data + length, candidate)) {
ClientCleanName(candidate, name, BOT_NAME_BYTES, qfalse);
if (!BotNameUsed(name)) {
if (index >= start) {
next_name_index = index + 1;
return qtrue;
}
if (!have_fallback) {
Q_strncpyz(fallback, name, sizeof(fallback));
fallback_index = index;
have_fallback = qtrue;
}
}
++index;
}
if (have_fallback) {
Q_strncpyz(name, fallback, BOT_NAME_BYTES);
next_name_index = fallback_index + 1;
}
return have_fallback;
}

static qboolean BotAddOne(void)
{
char name[32];
Com_sprintf(name, sizeof(name), "[BOT] %s %02d", BotAlliedMode() ? "Ally" : "Promod", BotCount() + 1);
char name[BOT_NAME_BYTES];
int number;
if (BotAlliedMode()) {
Com_sprintf(name, sizeof(name), "[BOT] Ally %02d", BotCount() + 1);
} else if (!bot_use_names->boolean || !BotPoolName(name)) {
/* Pigeonhole bound: with N slots at most N names can be occupied. */
for (number = 1; number <= sv_maxclients->integer + 1; ++number) {
Com_sprintf(name, sizeof(name), "[BOT] Promod %02d", number);
if (!BotNameUsed(name)) break;
}
}
return SV_AddBotClient(name) != NULL;
}

Expand Down Expand Up @@ -197,6 +268,8 @@ void SV_BotManagerInit(void)
bot_skill = Cvar_RegisterInt("bot_skill", -1, -1, 7, 0, "Bot skill: -1 original fixed profile, 0 mixed, 1..7 Bot Warfare tiers");
btd_allies_enable = Cvar_RegisterBool("btd_allies_enable", qtrue, 0, "Enable the isolated BTD allied controller");
btd_allies_limit = Cvar_RegisterInt("btd_allies_limit", 5, 0, 12, 0, "Maximum allied BTD bots");
bot_use_names = Cvar_RegisterBool("bot_use_names", qfalse, 0, "Use Bot Warfare scriptdata/botnames.txt for new Promod bots");
Cvar_RegisterBool("bot_sd_objectives", qfalse, 0, "Enable native Promod S&D objective navigation and use input");
Cvar_RegisterBool("bot_debug", qfalse, 0, "Write bot gameplay evidence to the game log");
Cmd_AddPCommand("bot_kickall", BotKickAll, 80);
Cmd_AddPCommand("bot_killall", BotKillAll, 80);
Expand Down
Loading
Loading