Skip to content
Roasted-CodesPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StatsBorg — Halo 2 Post-Game Stats Reader

Cross-platform Python tool that reads Halo 2 multiplayer post-game statistics from Xbox/Xemu via XBDM or QMP. Linux-compatible alternative to Windows-only HaloCaster.

Stats captured: Kills, deaths, assists, suicides, K/D ratio, accuracy (shots/hits/headshots), medals, placement, team data, and gametype-specific stats across all game modes (Slayer, CTF, Oddball, KOTH, Juggernaut, Territories, Assault).

Project Status

main is the production branch. It includes relocatable xemu/QMP reads for the active game-variant name, map metadata fallbacks, and the shared agent/master snapshot schema. Experimental memory research belongs under research/ or on a feature branch and should not replace main without passing the regression suite.

Requirements

  • Python 3.7+ (no pip dependencies for core tool)
  • One of:
    • Xbox with XBDM enabled (debug kit or modded console with CerbiosDebug)
    • Xemu with QMP enabled (launch with -qmp tcp:0.0.0.0:4444,server,nowait)

Quick Start

1. Capture Stats

Run watch mode in the background during your session. It auto-detects game completions and saves stats after each match:

QMP (Xemu) — primary method:

python halo2_stats.py --host <XEMU_IP> --qmp 4444 --watch

Requires Xemu launched with -qmp tcp:0.0.0.0:4444,server,nowait.

XBDM (Xbox/Xemu with CerbiosDebug):

# Polling (checks every 3 seconds)
python halo2_stats.py --host <XBOX_IP> --watch

# Instant detection via breakpoint (no polling delay)
python halo2_stats.py --host <XBOX_IP> --watch --breakpoint

Each completed game is automatically deduplicated and saved as JSON to the history/ directory.

2. View Your Stats

Start the built-in web viewer to browse your game history:

python pgcr_server.py

Open http://localhost:8080 in your browser. The viewer reads all saved games from history/ and displays them with scores, placements, and per-player breakdowns.

To use a different port: python pgcr_server.py 9090

Where Stats Are Stored

All game data is saved to the history/ directory as JSON files, one per game:

history/
  2026-02-18_22-31-58_cf561ec1.json
  2026-02-18_21-59-26_bc2c035c.json
  ...

Each file is named <date>_<time>_<fingerprint>.json and contains the full scoreboard: every player's stats, team data, and gametype. These files are consumed by the web viewer and the export scripts.

Output Formats

# Default: rich scoreboard with accuracy, medals, gametype stats
python halo2_stats.py --host <IP> --save

# Simple K/D/A summary
python halo2_stats.py --host <IP> --simple

# PGCR tabular format (matches in-game screenshot layout)
python halo2_stats.py --host <IP> --pgcr

# JSON output (to stdout)
python halo2_stats.py --host <IP> --json

# JSON output to a specific file
python halo2_stats.py --host <IP> --json --output stats.json

Additional Flags

Flag Description
--port N XBDM port (default: 731)
--poll N Poll every N seconds without watch mode (0 = single read)
--watch-interval N Seconds between watch-mode polls (default: 3)
--breakpoint, -b Use XBDM breakpoint for instant game-end detection instead of polling
--history-dir DIR Directory for auto-saved games (default: history/)
--pgcr-display Also read killed-by data from PGCR display (post-game screen only)
--timeout N Connection timeout in seconds (default: 5)
--slow 200ms read delay instead of 50ms (XBDM only, safer for unstable connections)
--save-ram Save full 64MB RAM snapshot at game end (QMP only, large files)
--verbose Debug logging

Testing Your Connection

# Test XBDM
python xbdm_client.py <XBOX_IP>

# Test QMP
python qmp_client.py <XEMU_IP> 4444

Export (Optional)

Export scripts require additional dependencies:

pip install -r exports/requirements.txt
# PostgreSQL
python exports/db_export.py --init-schema
python exports/db_export.py --import-history

# Excel
python exports/xlsx_export.py --history-dir history/ -o halo2_stats.xlsx

# Per-game Excel sheets (Bungie-style)
python exports/xlsx_export.py --per-game --style bungie -o exports/bungie/

Shared Master Server (Optional)

StatsBorg can also run as a central ingest server backed by PostgreSQL. This is for collecting matches from multiple game boxes into one shared database while letting contributors build different frontends from the same source.

cp .env.example .env  # or set POSTGRES_PASSWORD and MASTER_TOKEN another way
docker compose -f docker-compose.master.yml up -d --build
curl http://127.0.0.1:8080/healthz

The master service binds to 127.0.0.1:8080 by default. Put a TLS reverse proxy in front of it before exposing it publicly, because agents send MASTER_TOKEN as a bearer token.

Agent ingest endpoint:

POST http://127.0.0.1:8080/api/v1/matches
Authorization: Bearer <MASTER_TOKEN>

Read APIs include /api/games, /api/players, /api/leaderboard/<stat>, /api/pvp?player=<name>, and /api/v1/servers.

Project Structure

halo2_stats.py        Main CLI tool
xbdm_client.py        XBDM protocol client
qmp_client.py         QMP protocol client
halo2_structs.py      Data structures and struct parsing
addresses.json        Memory address reference
pgcr_server.py        Web viewer server
pgcr_viewer.html      Browser-based game history viewer
history/              Saved game data (JSON, one file per game)
exports/              PostgreSQL and Excel export scripts

Tests

Run the dependency-free regression suite before deploying:

python3 -m unittest discover -s tests -v

GitHub Actions also validates addresses.json and compiles every tracked, non-archived Python module.

Credits

  • Memory structures from OpenSauce (Networking/Statistics.hpp)
  • Research informed by HaloCaster and Yelo Carnage

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages