Skip to content

feat: spawn menus - vehicles, weapons and AI in front of any player (Halo CE, 2, 3, ODST), a menu per player on the D-pad - #46

Merged
megabitt01 merged 12 commits into
megabitt01:master-chieffrom
kirklandsig:upstream/08-spawn
Nov 20, 2026
Merged

megabitt01 merged 12 commits into
megabitt01:master-chieffrom
kirklandsig:upstream/08-spawn

Conversation

@kirklandsig

Copy link
Copy Markdown

Spawn menus, PR 8 of the series: spawn vehicles, weapons, equipment and AI characters in front of any player in Halo CE, 2, 3 and ODST campaigns. Each player drives their own menu with the D-pad in their own view, and there's a Spawn window in the debug overlay for the keyboard-and-mouse player.

What players get

  • A spawn menu per player. In a campaign mission, each player presses D-pad Down on their own controller to open a menu in their own view, while their Spartan holds still. The controls:
    • LB / RB: page (vehicles, weapons, equipment, characters, their HUD);
    • up / down: choose; A: spawn in front of them; Y: refresh; B: close;
    • on characters: left / right picks the side (own, ally or enemy), and LT / RT the weapon.
  • The button is spawn_menu_controller in alpha_ring_menu.cfg: a button or combo (DPAD_DOWN by default), or NONE to turn the menus off. It's only read, so the default file MenuConfig writes is unchanged.
  • A Spawn window in the debug overlay's menu bar, beside Splitscreen and HUD: player, page, search, side and weapon.
  • The HUD page edits the same per-player settings as feat: per-player HUD in Halo CE, 2, 3, ODST and Reach; Halo 2 ultrawide HUD option, Halo 4 HUD fit for every split view #43's HUD window (area, size, colour, reset). Like those, they last until MCC closes.
  • Nothing is written. The window doesn't keep its place in imgui.ini. My fork's menu also had SPLIT, ANNIV 3-4P and SPECIES rows; they're left out because they save to files (the first two are in Dev Tools).
  • Where there's nothing to offer, there's no menu. Halo 4 has no spawning, and the HUD page isn't offered there, so the menu doesn't open. On an MCC build missing one of a game's offsets, that game offers no spawning.
  • Halo CE Anniversary with three players: with feat: Anniversary graphics with 3-4 players in Halo CE and Halo 2; Halo 2 Anniversary 2P views fill their halves #44's quad mode, the menus sit in each player's quarter.

How it works

  • Commands on the game's thread. Spawning calls into the game, so it runs on the game's thread through two fixed verbs registered in code, spawn_list and spawn. Only AlphaRing's menus post them; there's no free-form command channel.
    • Halo 3 and ODST run them on their World tick (one registration line in each world.cpp).
    • Halo CE and Halo 2 get them through MCC's execute_command (HS: @ar ...) at their console-script compiler, which is hooked (entry/halo1/console.cpp, halo2/console.cpp). Text starting with @ar goes to the registered handlers, and anything else goes to the game unchanged.
    • A command is dropped once another map has loaded (CGameManager::load_generation, counted from MCC's Loading state). A handler's temporary edits to game data are put back if the game faults in one of its calls.
  • Objects use each engine's object_placement_data_new and object_new.
  • Characters:
    • In Halo CE, a character is a unit armed by actor_customize_unit and given a free actor (ai_attach_free).
    • Halo 2, 3 and ODST point the nearest starting location of an empty mission squad at the player for one ai_place, armed from the scenario's weapon palette, then put the squad back. In Halo 3 / ODST the squad is put back 61 ticks later by a tick counter (Command::ScheduleAfter / Tick), and it isn't lent again before that.
  • Controllers:
    • With split screen on, get_key_state hands the menu the pad it just read for that player (the dashboard's assignment) and zeroes it for the game while the menu has it.
    • With one player, the menu reads the dashboard's player 1 controller and player 1 gets no game input while it's open.
    • Inputs held as a menu closes (triggers included) stay out of the game until released, so closing with B while holding RT doesn't fire.
    • The debug overlay and the dashboard close any open menu, and no menu opens while either is up.
  • Which player: each backend finds a local user's player through the game's own mapping (Halo 3 / ODST's input user -> player getter, CE's players globals, Halo 2's per-user handle), not by slot order. A network co-op guest or a refilled slot therefore spawns in front of the right player.
  • Drawing: while a menu is open and the overlays are hidden, ImGui still runs a frame, with no cursor and no input fed to it. RenderPlayerMenus draws on the foreground list, with the dashboard's bundled Segoe UI at 34 px.
  • Offsets: 40 new, all DefOffset with byte patterns: Halo CE 11, Halo 2 14, Halo 3 5, ODST 10 (the last two each include the new input user -> player getter). Halo 2's ai_living_count is a 13-byte thunk no pattern can find again, so the offset is the function it jumps to. Each game's spawning is a Feature of every offset it uses, plus the hook that runs its commands. Halo CE's and Halo 2's console hooks require that feature, so they only go in with all of it. check_gates.py gets the spawn files' features and passes.

Known limits

  • In Halo 3's pillarboxed 2-player views, a menu starts in the black bar.
  • The first time a menu opens there's a short hitch.

Testing (MCC 1.3528, Steam under Proton on Batocera, with virtual pads; not on Windows)

Depends on #45 (the build fix): this branch is on top of it. After #45 merges, only this PR's own commits remain in the diff.

🤖 Generated with Claude Code

kirklandsig and others added 12 commits November 19, 2026 14:07
…01#43

Merging master-chief into megabitt01#43 (after megabitt01#44) resolved the conflicts in the
Halo CE and Halo 2 offset headers by keeping megabitt01#44's side only, so the
per-player HUD's offsets and byte patterns there were dropped while the
code using them stayed: master-chief stopped compiling (C2065
'OFFSET_HALO2_PF_HUD_ASPECT_LOCK' in CModule.cpp, and the HUD files).

Both blocks are kept now, as the two PRs had them:
- offset_halo1.h / patterns_halo1.inc: hud_calculate_point, the HUD
  viewport bounds and the drawing player (3);
- offset_halo2.h / patterns_halo2.inc: the "HUD anchor: Centered" je and
  global, the drawing player, the HUD view bounds and the offset unit
  scale (5).
Only lines are added; the values and patterns are megabitt01#43's.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The addresses the spawn menus use, as DefOffsets with their byte
patterns (gen_patterns.py; values and patterns as in the kirklandsig
fork, same 1.3528 build):
- Halo CE (11): the console-script compiler the commands come in
  through, the players array, tag iteration and lookup, object placement,
  creation, origin and lookup, actor_customize_unit and ai_attach_free;
- Halo 2 (14): the console-script compiler, the tag table and names, the
  map's and the shared map's tag bases, the object headers and memory,
  object placement, creation and origin, ai_place and the living count;
- Halo 3 (4): the tag base, the scenario, ai_place and the loaded-tag
  test (its tags header and object functions were already here);
- ODST (9): the same as Halo 3's.

Halo 2's ai_living_count (0x619B10) is a 13-byte thunk no pattern can
find again, so the fork left it to the known build. The offset is now
the function it jumps to (0x6198E0), which the spawn code calls with the
thunk's own arguments (0, null, null).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
Vehicles, weapons, equipment and AI characters (their own side, ally or
enemy, with a chosen weapon) in front of any player, ported from the
kirklandsig fork (src/mcc/spawn):
- Command: spawning calls into the game, so it runs on the game's thread
  through two fixed verbs registered in code, spawn_list and spawn,
  posted only by AlphaRing's menus. Halo 3 and ODST run them on their
  World tick (the task queue in module/entry/halo3/world.cpp and
  halo3odst/world.cpp, which only get a registration; one task a tick, as
  before). Halo CE and Halo 2 get them through MCC's execute_command
  ("HS: @ar ...") at their console-script compiler, which is hooked
  (module/entry/halo1/console.cpp, halo2/console.cpp): text starting with
  "@ar " goes to the registered handlers, anything else to the game
  unchanged. A task is dropped once another map has loaded
  (CGameManager::load_generation, counted from MCC's Loading state), and
  a handler's temporary edits to game data are put back if the game
  faults in one of its calls.
- Backends: objects with each engine's object_placement_data_new and
  object_new. Halo CE characters are a unit armed by
  actor_customize_unit and given a free actor (ai_attach_free); Halo 2,
  3 and ODST place a character by pointing the nearest starting location
  of an empty mission squad at the player for one ai_place, armed from
  the scenario's weapon palette, then putting it back.
- The Spawn window, in the debug overlay's menu bar beside Splitscreen
  and HUD: player, page, search, side and weapon. It writes no file, its
  place in imgui.ini included (ImGuiWindowFlags_NoSavedSettings).

Each game's spawning is an AlphaRing::Feature of every offset it uses,
with the hook that runs its commands: the World hook's offset for Halo 3
and ODST; for Halo CE and Halo 2 the console hook is an EntryFeature
that requires the spawning feature, so it goes in only with all of it.
On an MCC build missing one of them the game offers no spawning. Halo
2's characters also need ai_place and the living count; without them
objects still spawn. check_gates.py reviews gen3.cpp's features, which
are built from each game's table of offsets, as in the fork.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
In a campaign mission each player presses D-pad Down on their own
controller and drives a menu in their own view while their Spartan
holds still: LB / RB for the page (vehicles, weapons, equipment,
characters, their HUD), up / down to choose, A to spawn in front of
them, Y to refresh, B to close; on characters left / right picks the
side and LT / RT the weapon. Ported from the kirklandsig fork
(PlayerMenu.cpp), with what this tree needs:
- Controllers: with AlphaRing's split screen on, get_key_state hands the
  menu the pad it has just read for that player (get_controller, the
  dashboard's assignment) and zeroes it while the menu has it, the press
  that opened it and the buttons held as it closes included. With one
  player MCC reads the pads itself, so player 1's menu reads the
  dashboard's player 1 controller (GetXInputGetState) and the game gets
  no input from player 1 while it's open. The keyboard-and-mouse player
  has no menu (the Spawn window is theirs). No menu opens while the
  debug overlay or the dashboard is up.
- The button is spawn_menu_controller in alpha_ring_menu.cfg (a button
  or combo, NONE turns the menus off; DPAD_DOWN by default). It's only
  read: the default file MenuConfig writes is unchanged.
- Drawing: ImGui also runs a frame while a menu is open and the overlays
  are hidden, with no cursor and no input fed to it (Window.cpp is
  unchanged), and RenderPlayerMenus draws on the foreground list. The
  menus use the dashboard's bundled Segoe UI at 34 px.
- The HUD page (area, size, colour, reset) edits the player's settings
  through Hud::Settings / SetSettings, so like the HUD window's edits
  they last until MCC closes. Hud gets Supported() and kAreaNames. The
  fork's page also had SPLIT, ANNIV 3-4P and SPECIES rows; they're left
  out, as they save to alpha_ring_splitscreen.cfg or to the player's
  profile (the first two are in Dev Tools). Where the HUD page has no
  rows (Halo 4, or a build without the HUD's offsets) it isn't offered,
  and with no spawning either (Halo 4) the menu doesn't open.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
…uarters

With Anniversary graphics for 3-4 players, Halo CE draws three players
in quarters, the fourth left black, where the menus were laid out for
the Classic three-player layout (player 1 on the top half). The menus
now follow what CE draws: Splitscreen::AnniversaryQuartersShown asks the
CE module whether its quad mode drew at the last sync (QuadShown, false
once the module unloads). Halo 2's mode keeps its own grid, player 1 on
the top half, so its menus stay where they are. As in the kirklandsig
fork's v2.0.1.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
Halo 3 and ODST put a squad lent to a character spawn back 60 ticks
later, as the engine reads its spawn point again while it finishes
placing the actor. A second spawn in that time could pick the same
squad - it still counts as empty while its actor is being placed, or
when the placement failed - and save the first spawn's changes as the
squad's own: the first restore put the original back, then the second
put the changes back over it, and the mission's own squad kept the
player's position, character, team and no objective for the rest of
the map. A squad isn't lent again until its restore has run (the list
starts over with each map, whose pending restores are dropped).

The kirklandsig fork has the same gap; Halo 2 puts its squad back right
after ai_place, so it doesn't.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
A squad lent to a character spawn was put back by a task that queued
itself 60 times. The kirklandsig fork's World queue ran every task due
on a tick, so that was 61 ticks; this tree's queue runs one task a tick,
so each restore step waited behind every other queued task: four spawns
in a row kept each squad lent for about 244 ticks, and any other command
stretched it further - the squad's borrowed definition stayed live to
the mission's AI, and lent squads stayed out of later spawns, for that
long.

Command gets ScheduleAfter(game, ticks, task) and Tick(game): the World
hooks call Tick at the start of each tick (one line each in
module/entry/halo3/world.cpp and halo3odst/world.cpp), which counts
ticks and runs every task due, beside the queue, which still runs one
ordinary task a tick. A task is dropped if another map loads first, as
queued ones are. The restore now runs on the 61st tick after the
spawn's, as in the fork, however many commands are queued.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
As a menu closed, the pad stayed with it while any of its buttons was
held, and the triggers weren't counted: hold RT choosing a character's
weapon, close with B, let go of B with RT still down, and RT reached the
game at once (a shot; LT a grenade). It also held back every input,
movement included, while any button at all was down, even one pressed
after the menu closed.

Now the menu records what's held as it closes, the triggers past
XInput's threshold included, and takes each of those out of the pad the
game gets until that input is released; everything else goes through.
HandlePlayerInput edits the pad in place for that. With one player MCC
reads the pad itself, so player 1 gets no input while anything is held
back, as before but for the kept inputs only.

The kirklandsig fork has the same trigger leak (its gate checks
wButtons only).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
A spawn menu couldn't open while the debug overlay or the dashboard was
up, but one already open stayed open when either came up: with the
dashboard, the menu kept taking that player's controller, so navigating
the dashboard also moved through the menu and could spawn from it; with
the debug overlay (which stops the game's input poll), the menu kept
acting on the last pad it had seen, a held direction scrolling on.

Now either overlay closes every open menu, on the input thread
(HandlePlayerInput) and before the menus act in a frame
(RenderPlayerMenus), whichever sees it first. What's held then stays
out of the game until released, as with B. A menu opened again starts
from the pad as it is: its press, a held direction and a held trigger
aren't actions until released (the weapon turn's edge is set as the
list's already was).

The kirklandsig fork has the debug overlay half of this (an open menu
acts on its last pad while the overlay is up); it has no dashboard.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
A closing menu recorded what was held from the last pad it had seen:
the previous poll's when an overlay closed it on the input thread, and
on the render thread one poll old or more - a whole debug overlay's
worth, as the overlay stops the game's input polls. A trigger first
pulled in between wasn't recorded, so holding it through the close
fired, or threw a grenade, with no new press.

Closing now only marks the menu, and the first pad polled after it
(HandlePlayerInput) gives what's held: no input has reached the game
since the close, so that's everything held as it closed, plus at most
what was pressed in the same poll. Each is kept from the game until
released, as before.

The kirklandsig fork doesn't record inputs at a close (its gate holds
the whole pad while any button is down, and leaks triggers: the
previous fix).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
The catalog was dropped when a new map loaded only once a menu asked
for a refresh, and the Spawn window asked at the end of its frame,
after reading the catalog and posting a pick. Its first frame after
another map of the same game had loaded (with the window hidden
meanwhile) could still list the last map's items and spawn one: the
reads checked the game, not the map, and the command, posted in the new
map, passed the scheduler's map check - a tag or palette index of the
last map's, so another object or character, or a tag the engine can't
take. Halo CE and Halo 2 had no map check on their commands at all.

- The catalog keeps the map load it was listed in, and Read, Size, Get
  and Spawn only use it in that map (Fresh).
- Catalog::Spawn takes the item's index and looks the item and the
  weapon up under one lock, then posts the catalog's map with the
  command; CmdSpawn drops a command from another map ("Not spawned: the
  map changed"), in every game.
- The Spawn window and the players' menus refresh before they read or
  pick anything in a frame.

The kirklandsig fork has this in its Spawn window (its players' menus
refresh before picking), and no map check on Halo CE and Halo 2
commands.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
A spawn menu belongs to a local user - the controller slot MCC polls -
and every backend used that slot as an index into the players array,
which only holds while the game hands out players in slot order. With
any other mapping (a network co-op guest, a slot freed and refilled) a
spawn went in front of another player, or found no player at all. Each
backend now asks the game:
- Halo 3 and ODST: their player mapping, through its input user ->
  player getter (OFFSET_HALO3_PF_PLAYER_OF_INPUT_USER 0xEE0D4,
  OFFSET_HALO3ODST_PF_PLAYER_OF_INPUT_USER 0x108EA8, new, with
  patterns). The mapping lives behind thread-local slot +0x110 (ODST
  +0x108): input user -> player int[4] at +0x4, player -> input user at
  +0x74, set together at 0xEDF70 (0x108D44), output users (views) from
  +0xB4 - the count the split-screen player count reads.
- Halo CE: the same mapping, kept in its players globals
  (OFFSET_HALO1_PV_LOCAL_PLAYERS, already patterned): input user ->
  player at +0x4, set at 0xAE43FC with the unit at +0x14.
- Halo 2: its handle per local player (Players::Handle, players globals
  +0xC, written by user index at 0x69E53A), OFFSET_HALO2_PV_RESPAWN
  joining the spawning feature.
A user without a player spawns nothing, and each new offset is in the
feature that gates its game's spawning, so a build without it offers
none rather than falling back to the slot.

The kirklandsig fork has the same assumption in all four games.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPJBucDk2kQ8oms9Kf7NLs
@megabitt01
megabitt01 merged commit cea8227 into megabitt01:master-chief Nov 20, 2026
1 check passed
@kirklandsig
kirklandsig deleted the upstream/08-spawn branch November 20, 2026 16:25
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.

2 participants