A mod loader for Mafia: The City of Lost Heaven (2002; Steam/GOG 1.2 and the original 1.0), made for AI agents. An agent connects over MCP and works with the live game: starts it, plays it, changes it, writes mods for it and reloads them while it runs.
The host and SDK target both game builds. Download the player runtime. Individual validation results and open defects are recorded in current status. The November update notes explain the cumulative changes since the October 31 GitHub main. A locally installed build is not evidence that its source has been published.
- Run the game. Start it straight into any chapter of the story, a new game or any freeride, skipping the logos. Close it. Take screenshots, even with the window in the background.
- Control the character. Walk, run, turn, jump, shoot, drive, use things: the game's own controls, injected. Click and type in the game's menus.
- Spawn and remove anything. Cars and people of any model, seated in cars, armed, moved anywhere. Any model as a prop: in the world or attached to a bone, a car or another prop.
- Read and change the game's state. The player, cars, people and their skeletons, money, health, weapons, ammo, lights and sun, weather, particles. Events for shots, hits, deaths, explosions, cars entered and left.
- Run the game's own scripts. Every command the missions use.
- Take over input. Keys, the game's actions, hotkeys. Keep a key or an action from the game, lock the player, replace a car's physics.
- Add interaction. Zones, use-points in the game's own Action menu, timers on the mission's clock.
- Change the interface. Text, shapes and pictures on screen in the game's fonts. Lines in the game's console and help line. Markers on the screen, on the radar and as the compass' target. New items and whole pages in the game's own menus, built from its real controls.
- Draw in 3D. Draw into the world with the game's Direct3D device. Replace the shaders of the game's own objects (HLSL, Shader Model 3, through the d3d8to9 wrapper), with the game's lights near each one and a shadow map from the sun. Direct3D 11 passes over the frame with its colour, depth, camera and the sun's shadow map (a god rays example). Hide the game's meshes and draw your own instead.
- Use more cameras. Move the game camera or drive it from a mod. Render the scene again from other cameras (mirrors, reflections, stereo views) into textures.
- Play sound. The game's sounds or your own, 2D or 3D, with live volume and pitch. Music.
- Replace and add files. Textures, models, sounds and tables from a mod's folder, loaded by the game by name. The game's folder stays untouched.
- Query the world. Rays, sphere sweeps, the ground under a point, actors nearby, collision shapes.
- Develop fast. Hot-reload mods while the game runs. A crashing mod is switched off, the game goes on. Per-mod settings changed live (also on a page in the game's Options > Mods, made from the mod's manifest), per-frame cost per mod, watch any function or memory field, read crash dumps with names, a knowledge base of the game's code. Mods in C, C++, Rust or anything with a C ABI.
| Part | What it is |
|---|---|
host/ |
MafiaModLoader.asi: the loader inside the game (loaded by Ultimate ASI Loader) |
sdk/ |
mml.h: the one C header every mod is written against |
mcp/ |
the MCP server (Rust): the agent's tools |
mods/ |
core (the game's live state) and small examples, all off by default |
knowledge/ |
what is known about the game's code: functions, names, calls, notes |
Needs Windows, Visual Studio 2022 (C++ x86), CMake 3.24+, Rust, Python 3.10+ and the game (1.2 or 1.0).
python tools/deps.py :: pinned downloads (hash-checked)
copy mml.config.example.json mml.config.json :: set game_dir to your game's folder
cmake --preset x86
cmake --build --preset x86-release :: the loader and the mods
cargo build --release --manifest-path mcp/Cargo.toml :: the MCP server
python tests/run_tests.py :: offline tests
python tools/lab.py mode loader :: install into the game
python tools/kb_strings.py :: the knowledge base's strings, from your own game.mcp.json registers the server as mafia for Claude Code and clients supporting that configuration format.
For Codex, see agent client setup; it uses config.toml. The agent starts with
AGENTS.md, read in full (it exceeds Codex's default instruction size limit).
Mafia Ragdolls uses the loader's human poses, collision queries and game camera to give characters physical reactions to bullets, vehicle impacts and explosions. It supports Mafia 1.0 and 1.2. Source and installation · Download.
With the x86 and x64 release outputs available, python tools/player_release.py builds the
base, the full player runtime, and the FFmpeg video add-on under build/dist/. The base
contains the ASI bootstrap, the regular host with its game fixes, and the stock core mod.
The existing-ASI package puts the host in scripts/ and keeps a modpack's proxy DLLs.
The full runtime adds dxwrapper, FFmpeg and the 64-bit sidecar. An individual mod can ship
separately in its own mml/mods/<id>/ directory. Player installation.
Documentation index · Current status and update cautions · November patch notes
AGENTS.md (for agents) · MODDING.md (writing a mod) · PROTOCOL.md (every bridge method) · SCRIPTS.md (the game's scripts) · ARCHITECTURE.md · VERSIONS.md · ROADMAP.md · knowledge/
MIT (LICENSE). Third-party libraries keep their own licenses: MinHook and nlohmann/json (vendored),
Ultimate ASI Loader and Jolt Physics (downloaded by tools/deps.py).
Unofficial fan project, not affiliated with 2K, Take-Two Interactive or Illusion Softworks. Mafia: The City of Lost Heaven is a trademark of Take-Two Interactive Software, Inc. You need your own copy of the game; no game files are in this repository.