OPENAOK
A free, open-source engine for Age of Empires II: The Age of Kings, on your desktop and in your pocket.
Why
Playing Age of Empires II on a phone has been a dream of mine since I was a kid. Microsoft was never going to make that happen, so I did it myself.
OpenAoK is a new engine, written from scratch, that plays the original 1999 game from your own copy of its CD: the same units, maps, art, sounds, music, movies and campaigns, on macOS, Linux, Android phones and the Nintendo Switch.
What it is
- Written from scratch. OpenAoK contains no code or data from the original game. It is modern C++20 on SDL 2, data-oriented (EnTT), with a deterministic fixed-point simulation, and it reads the original's data files from your own copy and implements their rules.
- The original, faithfully. Every unit's numbers, every technology, civilisation and map script come from the 1999 data. The interface is drawn from the original art, laid out as the game laid it out, in its own fonts and words.
- Your copy, your data. The repository contains no game files. You copy your CD into a folder, and the build prepares everything it needs from it.
How it works
The simulation runs on 32.32 fixed point at a fixed 60 Hz, so the same orders produce the same world on every machine. Lockstep multiplayer and the self-check rely on this. Rendering, audio and the interface only read the simulation; orders reach it as commands. Units move at continuous positions; the tile grid holds buildings, terrain and path search.
At run time the engine reads the original DRS archives directly: SLP sprites, terrain, interface art, sounds, map scripts and AI scripts. The rule tables in the dat and LANGUAGE.DLL are converted to JSON once, at build time, by the tools in tools/data. The movies are decoded by the engine's own Indeo 5 decoder.
Getting the game files
OpenAoK needs your own, legally obtained copy of Age of Empires II: The Age of Kings (1999, version 1.0, the original CD). It does not work with The Conquerors expansion or the HD and Definitive editions, which use different data.
Copy the CD's files into a folder named original_game_1999 at the top of the repository. From a disc or a mounted image on macOS, for example:
cp -R /Volumes/AOE2/. original_game_1999/
The folder should then hold GAME/, SYSTEM/ and GOODIES/. That's all: the build unpacks and converts what it needs. Everything taken from your copy stays on your machine and is ignored by git. Please don't share it, or the builds you make from it: a build, the Android APK included, contains your game data. The Switch's OpenAoK.nro holds none of it; the folder made beside it does.
On the Nintendo Switch
OpenAoK runs as homebrew, from the Homebrew Menu, on a Switch that runs custom firmware. The game is one file, OpenAoK.nro, which holds none of the game's data; the data is a folder made on a computer from your own CD and copied to the SD card beside it. Nothing needs building for the Switch itself.
1. Put the game on the card. Download OpenAoK-switch-<version>.zip from the releases and unpack it onto the SD card's root. It holds switch/openaok/OpenAoK.nro and the licenses.
2. Make the game's data. Download the same release's source code (or clone the repository) and copy your CD into its original_game_1999/, as above. Preparing the data needs Python 3, cabextract, CMake and a C++ compiler, which build only a small helper that reads the game's rules:
# macOS (with the Xcode command-line tools)
brew install cmake cabextract
# Debian / Ubuntu
sudo apt install build-essential cmake python3 zlib1g-dev cabextract
Then, with the card in the computer:
python3 switch/package.py --out "/Volumes/SWITCH SD"
It prepares the game's data as build.sh does and writes switch/openaok/game/ on the card, beside the .nro: about 390 MB. Run it again after an update; only what changed is copied. Without --out it writes to build-switch/sd/, to copy to the card yourself. Some USB card readers damage what they write to large cards; Hekate's USB mass storage (Tools, USB Tools, SD Card) writes through the Switch's own card slot instead.
3. Play. Put the card back, hold R while starting any game, which opens the Homebrew Menu with all of the console's memory, and choose OpenAoK.
In handheld mode the touch screen plays as on a phone; the controller plays as a mouse and the game's hotkeys, as above. Chat and a saved game's name bring up the system keyboard. More in switch/README.md.
Building the .nro yourself
With Docker, or with devkitPro's Switch toolchain (switch-dev, switch-sdl2, switch-freetype) when DEVKITPRO is set:
switch/build.sh # writes build-switch/OpenAoK.nro
On a Mac, Docker can be brew install colima docker && colima start. Then python3 switch/package.py copies the .nro you built to the card with the data.
https://github.com/Zaydme/openaok/releases