# Ordoor

Ordoor is an **unofficial** [game engine recreation](https://en.wikipedia.org/wiki/Game_engine_recreation)
of the classic game from 1998, [Warhammer 40,000: Chaos Gate](https://en.wikipedia.org/wiki/Warhammer_40,000:_Chaos_Gate)

**You must have a copy of the original game data to use this project**. GOG is
the current publisher of this game; [you can purchase it here](https://www.gog.com/game/warhammer_40000_chaos_gate).

"Warhammer 40,000" is a trademark of Games Workshop, and the game data used by
Ordoor contains Games Workshop intellectual property. I am confident that this
project uses all those things in accordance with the
[Intellectual Property Policy](https://www.games-workshop.com/en-GB/Intellectual-Property-Policy)
and the license granted when purchasing a copy of the game in question. Do let
me know if you see or suspect any violation, and I'll address it immediately.

Ordoor is a portmanteau of Order Door, which is, of course, the opposite of a
Chaos Gate.

## Current status

Some of the original file formats are either partially or fully decoded. Maps,
menus, and most visual data can be rendered pixel-perfect. Sound can be played
(with a preprocessing step). Some UI tookit work is done. No game mechanics are
implemented yet.

I keep a GIF showcasing interesting progress here:

![](https://ur.gs/img/ordoor-main-menu.gif)

I've just been informed that another game from 1998, [Soldiers At War](https://en.wikipedia.org/wiki/Soldiers_at_War),
seems to use the same engine. Maybe at some point Ordoor will be able to play
both. Will that need a rename? Hmm. Watch this space.

## Building from source

I'm writing code in Go at the moment, so you'll need to have a Go runtime
installed on your system:

```
$ go version
go version go1.14 linux/amd64
```

In addition, you'll also need the following packages installed, at least in
Debian:

```
# apt install libx11-dev libxcursor-dev mesa-common-dev libxrandr-dev \
  libxinerama-dev libgl1-mesa-dev libxi-dev libasound2-dev mpv ffmpeg
```

You can then run `make all` in the source tree to get the binaries that are
present at the moment.

Place your WH40K: Chaos Gate installation in `./orig` to benefit from automatic
path defaults. Otherwise, point to it with `-game-path`

The `view-map` binary attempts to render a map, and is the current focus of
effort. Once I can render a whole map, including pre-placed characters (cultist
scum), things can start to get more interesting.

Current status: almost pixel-perfect map rendering. Static objects (four per map
coordinate: floor, centre, left, and right) are rendered fine, and each Z level
looks good. There are a few minor artifacts here and there.

Characters and animations aren't touched at all yet. Rendering performance is
poor. No gameplay, no campaign logic. Interaction with the play area is minimal
and limited to pan, zoom, and click for basic console output.

Still, I'm proud of myself.

To run:

```
$ make view-map
$ ./view-map -map Chapter01
```

Looks like this:

![](doc/formats/img/chapter01_rendered_2018-09-08.png)

Use the arrow keys to scroll around the map, the mouse wheel to zoom, and the
`1` - `7` keys to change Z level.

Dependency management uses `go mod`, so ensure you have at least Go 1.11.

There is the **start** of the menu / campaign flow in a `ordoor` binary:

```
$ cp config.toml.example config.toml
$ make ordoor
$ ./ordoor
```

This plays the introductory videos so far, and nothing else.

Menus are in the process of being rendered; you can use the `view-menu` binary
to inspect them:

```
make view-menu
./view-menu -menu ./orig/Menu/Main.mnu
```

This menu *displays* OK, including 

## Sound

Sound is in the very early stages. Chaos Gate uses ADPCM WAV files, which are a
pain to play in Go, so for now, a preprocessing step that converts them to .ogg
is used instead. To create ./orig/Wav/*.wav.ogg, run:

```
# apt install ffmpeg
$ ./scripts/convert-wav ./orig/Wav
```

As with video playback, the ambition is to *eventually* remove this dependency
and operate on the unmodified files instead.

## Miscellany

"Mission Setup" includes information about available squad types

From EquipDef.cpp Dumo: CEquipment we learn the following object types:

0. DELETED
1. WEAPON
2. GRENADE
3. MEDIPACK
4. SCANNER
5. GENESEED
6. CLIP
7. DOOR KEY
8. DOOR KEY
9. DOOR KEY
10. DOOR KEY

And we learn they can be "on"....

0. CHARACTER
1. VEHICLE
2. CANISTER

I'm starting to see some parallels with [this](https://github.com/shlainn/game-file-formats/wiki/)
in the data formats, and the timeline (1997) seems about right. Worth keeping an
eye on!
