Skip to content

CSR Bot & Navigation

CSR Bot — single integrated bot

CSRetro ships one runtime bot: the CSR Bot (CCSRBot / CCSRBotManager) in the ReGameDLL (dlls/csr_cstrike_*.so). There is no separate Metamod bot plugin; yb_* CVars and a csr_yapb_* plugin are not part of the supported product surface.

YaPB was migrated into CSR; client/3rdparty/yapb/ no longer exists.

Overview

Topic Summary
Control Server CVars bot_*, native menu csr_botmenu
Nav mesh (Valve) bot_nav_*, .nav
CSR graph csr_*, .csrnav, embedding in .nav
Converter nav2csrnav (tools/csrnav/)
Sidecar files maps/<map>.csrprac, maps/<map>.csrvis

What the CSR Bot does (implemented)

The following applies only to the CSR Bot (CCSRBot), not the generic ReGameDLL bot base — so server admins and mappers know what to expect.

Target selection with multiple enemies

  • Where: csr_bot_target.cpp, hooked from cs_bot_vision.cpp (only when IsCSRBot()).
  • Behaviour: Among several visible threats, one target is chosen by score: distance as baseline, plus weighted bonuses for C4 carrier (CT view, defuse), low enemy HP, CT with defuse kit (T view, bomb planted). Shield is penalised; a small stickiness to the current target reduces flicker.
  • Tuning: bot_csr_target_* (see below); finer values via console.

Combat, aiming, melee

  • Difficulty: Table values g_csrDifficulty[] in csr_bot_combat.cpp / API in csr_bot_combat.h — reaction time, headshot / fire-through probabilities, aim error (CsrApplyAimError etc. in csr_bot.cpp Upkeep).
  • Knife / melee: Extra scaling of aim error via CsrGetMeleeAimErrorScaletighter aim in knife range (distance bands).

Attack state and “under pressure”

  • Attack: states/csr_bot_attack.cpp — includes retreat logic when the bot stays “pinned” in a firefight (m_pinnedDownTimestamp). For CSR, that window scales with bot_difficulty (0–3): higher skill → shorter patience before considering retreat.
  • Pathfinding: csr_bot_pathfind.cpp — A* on the CSR graph; edge costs increase for nodes with crouch / ladder (×1.5), double jump (×1.25), narrow (×1.1). Safe mode adds practice / danger damage (g_csrPractice) to edge cost.
  • Path smoothing: cantSkipNode etc. — no shortcuts across tight corridors (CSR_NODE_NARROW), large Z gaps, jump edges too long/short, marked jump links (details in source).
  • Movement: csr_bot_movement.cpp — applies graph semantics (e.g. ladder, camp, crouch when approaching nodes).

Practice & visibility

  • Practice / danger: csr_bot_practice.cpp — persistent danger data (e.g. .csrprac); feeds into safe path costs. Visibility: csr_bot_vistable.cpp for visibility-based path decisions where used.

Buying (economy)

  • Defuse scenario: In states/csr_bot_buy.cpp, CSR bots increase defuse kit purchase probability over the base logic by an amount proportional to GetSkill() (classic CS: stronger bots buy kits more reliably).

Native menu (no AMXX)

  • csr_botmenu: Bot count, difficulty, team, weapon restrictions, navigation (mesh + CSR graph), server/debug including a third page for CSR target weights (bot_csr_target_*) — see Native menu.

Offline parameters (workshop)

Project rule: menu vs. console

  • Menu (csr_botmenu): Quick access to common bot_nav_* and csr_node_* actions plus server/debug pages — no typing.
  • Console: Commands that need arguments (e.g. bot_nav_use_place <name>, bot_nav_check_consistency <file>) stay console-only in documentation; the GoldSrc menu has no text field.

Missing menu entries would be UI gaps, not evidence of a second bot system.

Server CVars (bot_*)

Bots are controlled via ReGameDLL bot_* CVars. There is no supported yb_* configuration.

CVar Typical Description
bot_quota 032 Number of bots in the game
bot_difficulty 03 Difficulty
bot_join_team any / T / CT Preferred team

CSR target selection (bot_csr_target_*)

CSR Bot only, when several enemies are visible: weighting beyond pure distance (console).

CVar Default Description
bot_csr_target_c4 1 Weight: C4 carrier (CT vs. T with bomb, defuse scenario). 0 = off.
bot_csr_target_weak 0.5 Weight: low enemy HP. 0 = off.
bot_csr_target_defuser 0.8 Weight: CT with defuse kit when bomb is planted (T view). 0 = off.

More bot_* and game rules: Server CVARs, Server administrators.

Native menu csr_botmenu

In-game: console csr_botmenu (often bound to p).

Main menu: Add/remove bots, difficulty, team, weapon mode, navigation, server/debug.

Navigation → Nav mesh (multiple pages, 1/4–4/4): classic Valve/ReGame nav editor — e.g. bot_nav_edit, mark, areas, connect, save/load, analyse, split/merge, places, consistency checks (where argument-free makes sense).

Navigation → CSR graph: CSR nodes (csr_node_add, csr_node_remove, csr_node_save), connections (mark/complete/abort), csr_practice_reset.

Server / Debug: e.g. cyclic quota modes, bot_nav_zdraw, and on the third subpage CSR target weights (bot_csr_target_*) — see source csr_bot_menu.cpp.

Implementation: client/3rdparty/ReGameDLL_CS/regamedll/dlls/bot/csr_bot_menu.cpp (replaces an older AMXX csr_botmenu plugin).

Two layers, both for CSR — no competing bots:

  1. Nav mesh (bot_nav_*): Area mesh, classic editor, analysis, places.
  2. CSR graph (csr_*): Nodes, edges, practice — .csrnav format or embedding.

File formats

  • .nav: Valve/ReGame mesh; may end with an embedded CSR graph (magic CSRRETRO + payload).
  • .csrnav: Standalone CSR graph; optional alongside maps/<mapname>.nav until embedding is written.
  • nav2csrnav: Helper under tools/csrnav/ (output e.g. under game-test/bin/csrnav/), builds .csrnav from mesh .nav when no graph exists yet.

Per-map sidecar files

File Contents
maps/<mapname>.csrprac Persistent danger / practice data
maps/<mapname>.csrvis Precomputed visibility between nodes

Prefix quick reference

Prefix Role
bot_nav_* Nav mesh editor and mesh analysis (Valve/ReGame)
csr_* CSR graph (csr_node_*, csr_practice_*, …)
csr_bot_* / internal CSR bot implementation (csr_bot_*.cpp) — not a separate product plugin

Useful commands (not exhaustive): bot_nav_save, bot_nav_load, bot_nav_analyze, csr_node_save, csr_practice_reset, bot_goto_mark (menu).

Historical migration (YaPB / ReGame → CSR)

Origin In CSR
A* pathfinding (YaPB planner) csr_bot_pathfind.cpp
Nav nodes / .pwf era csr_bot_nav.cpp, .csrnav
BotPractice (danger) csr_bot_practice.cpp
Graph vistable csr_bot_vistable.cpp
Difficulty / weapon error csr_bot_combat.h
Movement along path csr_bot_movement.cpp
ReGame states, chatter, manager csr_bot_*, CCSRBotManager

Historical YaPB docs (e.g. yb g … on yapb.readthedocs.io) are a workflow reference, not a 1:1 command mapping.

Optional: local mirror docs/_upstream_mirror/mirror/yapb-rtd/ (gitignored).

Design references (ideas only, not dependencies)

External bots do not ship code in CSRetro; they may inspire target selection, economy, or tools:

Project Link Note
CS-E-BOT github.com/EfeDursun125/CS-EBOT SyPB/YaPB line; ZP/Escape focus — not required for classic CS.
RealBot github.com/APGRoboCop/RealBot CS 1.6 Metamod; node/BSP tooling as concept.
jk_botti github.com/APGRoboCop/jk_botti HL1 DM — different rules; GA/NN at most as offline tuning idea.

Offline tuning (optional)

  • No machine learning in the live DLL; parameters live in g_csrDifficulty[] (csr_bot_combat.cpp).
  • Helper script to print a table template: tools/csr_bot_tune_sweep.py — merge values manually only after testing.

Manual verification (smoke test)

Five- to ten-minute checks on a game-test install (listen or dedicated):

  1. Open the console (~). Run csr_botmenu (default bind p) and confirm the native CSR Bot menu opens.
  2. Navigate Server / DebugMoreCSR target weights — toggle bot_csr_target_c4, cycle bot_csr_target_weak / bot_csr_target_defuser (or set the same CVars in the console).
  3. Load a defuse map, set bot_quota 4, bot_difficulty 2. With multiple enemies visible, changes to bot_csr_* are subtle — compare bot_csr_target_weak 0 vs. 0.8 over several engagements.
  4. Optional: bot_show_danger 1 / bot_debug 1 (Server/Debug menu) when validating practice/danger-related path behaviour on maps with a CSR graph.

Baseline bot_* / bot_csr_* values for new installs live in the repository data/cstrike/server.cfg (see Server administrators).

Upstream & regression

  • ReGameDLL upstream: Revision in VENDOR.md; if unsure, compare git -C client/3rdparty/ReGameDLL_CS log to origin/master.
  • Often not a “CSRetro bug”: Bots stuck on edges/stairs; missing waypoints on community maps without .nav/graph; differences between official and custom maps.
  • Reports: Map name, bot count/difficulty, repro, optional pinned ReGameDLL revision.

Older “YAPB-in-tree” notes: Bot Nav Reference defers here.

See also