Headless tool for patching StarCraft 2 maps to mimic balance updates when the SC2 Linux binary is frozen at an older API version.
The SC2 Linux binary (used by AI Arena and bot competitions) is frozen at version 4.10.0. Balance patches (5.0.x) are not applied to the API. To run bots on current balance, map files are modified to include updated game data — the map overrides the binary's default data when loaded.
This tool automates that process on Linux. No Windows, no SC2 Editor, no Ladik's MPQ Editor required.
SC2 map files (.SC2Map) are MPQ archives containing:
- 109 GameData XML files — unit stats, weapons, abilities, effects, upgrades, behaviors, tech tree
- Localized string files — GameStrings.txt, ObjectStrings.txt, TriggerStrings.txt, GameHotkeys.txt
- Assets — 3D models, textures, sounds for new/changed visual elements
- Map structure — terrain, triggers, minimap, map script
The patcher:
- Extracts the original map's MPQ archive
- Replaces GameData XMLs and localized strings with the target patch version
- Adds any new assets from the patch
- Repackages into a new
.SC2Mapwith 16MB sector size for optimal compression
- Python 3.10+
- StormLib (C library for MPQ read/write)
- sc2reader (Python, for MPQ reading)
- mpyq (Python, comes with sc2reader)
git clone https://github.com/ladislav-zezula/StormLib.git
cd StormLib
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON .
make -j$(nproc)
sudo make install
sudo ldconfigpip install sc2readerpython3 patch_aie_map.py <input_map.SC2Map> <patch_dir> <output_map.SC2Map>Example:
python3 patch_aie_map.py PylonLE.SC2Map ./patches/5.0.14.94137 PylonAIE_v4.SC2MapPatch data files are sourced from the aiarena/sc2patch repository, which covers versions 5.0.3 through 5.0.14.
Pre-patched reference maps are available in Cryptyc/Sc2-AIE-Maps.
To patch all maps in a folder:
for map in maps/*.SC2Map; do
name=$(basename "$map" .SC2Map)
python3 patch_aie_map.py "$map" patches/5.0.14.94137 "patched/${name}_5.0.14.SC2Map"
doneAfter patching, verify that balance data matches a known-good reference map:
import ctypes
lib = ctypes.cdll.LoadLibrary('/usr/local/lib/libstorm.so')
# Read UnitData.xml from both maps and compare bytes
# If they match, the patch was applied correctly| File | Contains |
|---|---|
| UnitData.xml | Unit HP, shields, supply cost, speed, sight, attributes, build times |
| WeaponData.xml | Weapon range, damage period, arc, scan range |
| AbilData.xml | Ability costs, cooldowns, cast ranges, button layouts |
| EffectData.xml | Damage amounts, healing, shields, applied behaviors |
| UpgradeData.xml | Research costs, build times, unlock tree |
| BehaviorData.xml | Buffs/debuffs, durations, modifiers |
| RequirementData.xml | Tech tree requirements |
| stableid.json | Internal ID mappings |
The patcher uses 16MB MPQ sector size to achieve compression ratios comparable to the SC2 Editor's output (~5x on typical maps). Using smaller sector sizes (e.g., 64KB) results in nearly uncompressed archives because StormLib compresses per-sector, not per-file.
- AI Arena — original patch data and methodology
- Cryptyc — pre-patched AIE maps and patch repo
- Scarlett — original AIE map patching tutorial
MIT