Skip to main content
Glama

wc3files

Warcraft III maps files reader and writer for Python

PyPI Python License wc3files MCP server

A Python library for reading and writing various Warcraft III file formats. This library allows you to work with map files, object data, regions, replays, and more.

Installation

pip install wc3files

A conda-forge package is in review and not published yet.

Python 3.10 or newer. Pure Python - no compiler, and no StormLib or game install needed. The only dependency is loguru.

Related MCP server: Warcraft 3 MCP Server

Documentation

Full documentation lives in docs/:

  • Getting started - install, then the three core workflows

  • Concepts - the rules that explain the API's shape

  • Formats - every format, its class, and how far support goes

  • API reference - every public class and method

  • Command line - the wc3files command and every subcommand

  • vJass and Zinc - compiling vJass and Zinc to JASS, as JassHelper does

  • External tools and Lua - running a map's ObjectMerger, FileImporter and other tool calls, and the Lua interpreter

  • Game data for other versions - profiles of 1.24, 1.27, 1.32... tables extracted from an install, used with --game-data

  • Lni mode - a map as a folder of text files (objects as Lni, the rest as JSON) and back, for git

  • Triggers and scripts - GUI triggers, JASS/Lua, and rebuilding editor triggers from a compiled script

  • In-game UI frames - describe a UI as data, and write the JASS, Lua, .fdf or map trigger that creates it

  • MCP server - wc3files-mcp, which lets an AI assistant such as Claude read your maps, models and replays

What changed in each release is in CHANGELOG.md.

Features

MPQ Archives

  • Read and extract MPQ archive files (Blizzard's proprietary archive format)

  • Access individual files within MPQ archives

  • Handle encryption, compression, and other MPQ-specific features

Map Files (W3X)

  • Read and write Warcraft III map files (.w3x)

  • Access map resources and components

Object Data (W3O)

  • Parse and modify object data files (.w3o)

  • Work with SLK (Symbolic Link) files

  • Handle WES (World Editor Strings) files

  • Process configuration files (CFG)

Region Data (W3R)

  • Read and write region files (.w3r)

  • Manipulate region information in maps

Replay Files (W3G)

  • Parse Warcraft III replay files (.w3g)

  • Extract game information, player data, and actions

vJass and Zinc

  • Compile vJass and Zinc to plain JASS, as JassHelper does, without the World Editor

  • Compile a single script, a set of library files, or the war3map.j of a whole map

  • wc3files vjass war3map.j -o compiled.j, or VJassCompiler().compile_file(...) from Python

In-game UI frames

  • Describe frames (backdrops, texts, buttons, their size, anchors, textures and texts) in JSON or Python

  • Write the JASS or Lua that creates them, an .fdf, or a custom-text trigger in a map: wc3files ui-build ui.json --map MyMap.w3x --out MyMap.ui.w3x

  • Read an .fdf back into a layout

MCP server

  • pip install "wc3files[mcp]", then wc3files-mcp --root D:/Maps: read-only tools for an AI assistant such as Claude (map info, members, object data, trigger text, script checks, models, replays)

  • Opens only files under the given folders, and refuses protected maps

External tools and Lua

  • Run the //! external calls and Lua //! externalblock blocks of a vJass map (ObjectMerger, FileImporter, FileExporter, ConstantMerger), as the World Editor does when saving

  • Check that Lua before opening the editor: errors name the .j line they come from

  • A Lua 5.1/5.3 interpreter in pure Python, sandboxed: wc3files lua script.lua

  • Check a Reforged war3map.lua against the game API (undefined globals, missing FourCC, wrong argument counts and types): wc3files jass war3map.lua --check

  • Run a map's script without the game (common.j stubs, blizzard.j, timers) to find its start-up errors: wc3files run-map MyMap.w3x; translate JASS to Lua with wc3files jass war3map.j --to-lua

Usage Examples

These examples are run by the test suite (tests/test_readme.py), on the checked-in sample files, so they stay correct.

Working with a map

from wc3files import W3xFile, W3iFile

# Read a map: every member it lists, by name, as bytes.
archive = W3xFile()
archive.read("MyMap.w3x")
print(sorted(archive.files))

# Parse a member, change it, and put it back, all in memory.
info = W3iFile()
info.read(archive.files["war3map.w3i"])
info.get_data()["map_name"] = "My edited map"
archive.files["war3map.w3i"] = info.to_bytes()

# Raw bytes can be changed too. Then build the map again.
script = archive.files["war3map.j"]
archive.files["war3map.j"] = script + b"// edited with wc3files\r\n"
archive.build_from_files(archive.files, "MyMap.edited.w3x")

Working with MPQ archives

from wc3files.mpq import MpqFile

mpq = MpqFile()
mpq.read("MyMap.w3x")   # .mpq, .w3x, .w3m and .w3n
mpq.read_files()
for name, data in mpq.files.items():
    print(name, len(data or b""))

Working with object data

from wc3files.w3o import ObjectFile

units = ObjectFile()
units.read("war3map.w3u")
tables = units.export_data()["w3u"]
for table in ("original", "custom"):
    for object_id, fields in tables[table].items():
        print(table, object_id, sorted(code for code in fields if code != "ID"))

Working with regions

from wc3files.w3r import RegionFile

regions = RegionFile()
regions.read("war3map.w3r")
for region in regions.get_regions().values():
    print(region.name, (region.left, region.bottom), (region.right, region.top))

Working with replays

from wc3files.w3g import ReplayFile

replay = ReplayFile()
replay.read("replay.w3g")
data = replay.get_data()
game = data["compressed_data"]
print(game["MapName"], game["GameName"], data["header"]["sub"]["version_number"])

Credits

wc3files stands on the work of the Warcraft III modding community. The projects below are either bundled with it, ported into it, or were followed or checked against while writing it. Where a module took something from one of them, its docstring says what.

Bundled data

  • Blizzard Entertainment: common.j, blizzard.j, common.ai, and the SLK and TXT game tables under w3o/gamedata/ are copies of the game's own files, used so that maps can be read without an installed game. Warcraft III and its data belong to Blizzard Entertainment.

  • War3Net by Drake53 (MIT): the bundled TriggerData.txt, itself derived from Blizzard's UI/TriggerData.txt.

  • Warcraft Image Lab by LaZz: the 13 icon borders in img/gamedata/borders/.

  • blue & nagger: the replay action and order names, generated from their w3g_actions.txt v1.01 (2006, w3g.deepnode.de).

Ported code

  • StormLib by Ladislav Zezula (MIT): the Huffman and IMA ADPCM decoders in mpq/compression.py are ports of its huff.cpp and adpcm.cpp. Its source comments were also the reference for the hash table probing and for what protected maps do to an archive.

Designs followed

These were reimplemented from their documentation and behaviour. wc3files contains none of their code.

  • w3x2lni: the Lni, Slk and Obj map modes, the optimizer passes, computed text, MDX squeezing, and the JASS dead-code removal and renaming.

  • JassHelper by Vexorian (zlib): the vJass and Zinc languages, and the names of the generated code.

  • YDWE: the ui folder format for GUI trigger definitions.

  • Grim Extension Pack by PitzerMike: the //! external tools (ObjectMerger, FileImporter, FileExporter, ConstantMerger).

Format references

The parsers were cross-checked against these, field by field, and every disagreement was settled against real map files:

Checks

  • pjass: the reference JASS syntax checker, used to validate the compiled vJass and the obfuscator output.

  • The Lua test suites (lua.org/tests): the Lua interpreter was run against the 5.1 and 5.3.4 suites. They are not checked in.

If your work should be on this list and is not, please open an issue.

License

This project is licensed under the MIT License - see the LICENSE file for details. The bundled data above keeps its own terms.

Available Tools

9 tools
check_scriptCheck a scriptA
Read-onlyIdempotent

Check a map's JASS or Lua script against the game's natives and Blizzard functions, as wc3files jass --check does: calls to unknown functions, wrong argument counts, arguments of the wrong type and similar errors. It returns the counts by severity and each finding with its line. Use it to find why a map's script may fail to load; read_member on war3map.j gives the script text itself. Only reads: it changes no file, and the same call on the same file gives the same result.

Inputs: path (required), max_chars.

list_filesList Warcraft III filesA
Read-onlyIdempotent

Find the maps (.w3x, .w3m), campaigns (.w3n), models (.mdx, .mdl) and replays (.w3g) the server may read, with their full paths and sizes in bytes. Call it first, to get the paths the other tools take. It lists at most 1000 files and sets truncated when there are more; narrow the search with folder or pattern. Only reads: it changes no file, and the same call on the same file gives the same result.

Inputs: folder, pattern.

list_membersList the files inside a mapA
Read-onlyIdempotent

List the files a map holds (war3map.j, war3map.w3u, imported models and textures, ...) with their unpacked and stored sizes, read from the archive tables without unpacking anything. Use it to see what a map contains before read_member or model_info. Fails on a protected map. Only reads: it changes no file, and the same call on the same file gives the same result.

Inputs: path (required).

map_infoMap informationA
Read-onlyIdempotent

Read a map's summary from its war3map.w3i, with the map's strings resolved: name, author, description, suggested players, width and height, script language (JASS or Lua), the game and editor versions it was saved with, players with their race and type, forces, and the number of files in the map. Use it to answer what a map is; use read_member on war3map.w3i only for every raw field. Fails on a protected map and on a map without war3map.w3i. Only reads: it changes no file, and the same call on the same file gives the same result.

Inputs: path (required).

model_infoModel informationA
Read-onlyIdempotent

Read a model's summary: name, format (MDX or MDL), version, the names of its animation sequences, the textures it uses and its number of geosets. Use it to check which animations or textures a model has, in a model file or in a model imported into a map. For a map, member is required. Only reads: it changes no file, and the same call on the same file gives the same result.

Inputs: path (required), member.

object_dataObject dataA
Read-onlyIdempotent

Read the units, items, destructables, doodads, abilities, buffs and upgrades a map adds or changes, with the game's field names (such as goldcost, spd or abilList) and the map's strings resolved. Each kind has an original table, for standard objects the map changes, and a custom table, for new objects with their template_id. Use it to answer what a unit costs or what an ability does in a map; only the fields the map changes are listed, not the game's defaults. On a large map, ask for one object_type or some ids. Only reads: it changes no file, and the same call on the same file gives the same result.

Inputs: path (required), ids, max_chars, object_type.

read_memberRead a file inside a mapA
Read-onlyIdempotent

Read one file inside a map. For a format wc3files reads (war3map.w3i, w3e, doo, w3r, wts, wtg, wct, the object files and more) it returns the parsed data, for a script or text file its text, and for any other file only its size. Prefer the focused tools when they fit: map_info for war3map.w3i, object_data for the object files, trigger_text for war3map.wtg, check_script for the script and model_info for a model. A large result such as a whole terrain is refused past max_chars. Only reads: it changes no file, and the same call on the same file gives the same result.

Inputs: path (required), member (required), max_chars.

replay_infoReplay informationA
Read-onlyIdempotent

Read a replay's summary: game name, map, host, length in milliseconds, game version and build, whether it is from Reforged, and the players with their races. When the map records W3MMD results, it adds the winners and losers. Only reads: it changes no file, and the same call on the same file gives the same result.

Inputs: path (required).

trigger_textTrigger textA
Read-onlyIdempotent

Read a map's GUI triggers as the World Editor shows them, one line per event, condition and action. Use it to explain what a map's triggers do. A large map's triggers run to hundreds of thousands of characters: start with names_only, then pass name. Triggers written as custom text are in the script; check_script or read_member on war3map.j reads them. Only reads: it changes no file, and the same call on the same file gives the same result.

Inputs: path (required), name, max_chars, names_only.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.1/5.0

    Scored across 9 tools

    Disambiguation4/5

    The tools mostly target clearly distinct WC3 artifact types: filesystem listing, map members, map summary, triggers, object data, scripts, models, and replays. The only overlap is intentional: read_member is a generic reader but its description explicitly says to prefer the focused tools when they fit.

    Naming Consistency3/5

    All names use snake_case and are readable, but they mix verb_noun patterns such as list_files, read_member, and check_script with noun_info patterns such as map_info, object_data, model_info, and replay_info. The split is somewhat predictable by tool role, but it is not a single consistent naming convention.

    Tool Count5/5

    Nine tools is well scoped for a read-only WC3 file inspection server. Each tool covers a distinct artifact or inspection task, and there is no obvious redundant tool bloating the set.

    Completeness4/5

    The server covers the main workflows for maps, map internals, object data, triggers, scripts, models, and replay summaries. Minor gaps remain, such as campaign-specific inspection despite campaigns being listed, and replay tools stop at summary-level information.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      C
      maintenance
      Answers questions about your installed Arma Reforger / Enfusion game by reading local .pak archives and resources, and can optionally drive the Workbench editor for live inspection and modifications.
      1
      MIT
    • A
      license
      C
      quality
      B
      maintenance
      Provides read-only, stdio-based MCP tools for inspecting locally captured C/C++ fault artifacts, grouping processes and sessions, querying the evidence store, and resolving explicitly supported RPC/IPC relationships. Access is restricted to a configured artifact root, with observed, static-candidate, and unresolved evidence kept strictly separate.
      24
      1
      Apache 2.0