hoschi@gfuzz:~$

Hacking X-COM: Terror From The Deep (Demo, 1996)

Hmm?

It must have been around 1996 when I first heard about X-COM: TERROR FROM THE DEEP. It is the sequel to the round-based strategy game classic UFO: ENEMY UNKOWN, where you have to defeat an alien invasion with your pixel soldier squad. This time the mean alien bastards came back (actually, they never left) and continue with their plan to get in control of planet earth while doing nasty experiments on the human residents - and I am not talking about the typical analysis of the human butt.

The Damn Demo

Until the middle of 2001 I did not have internet access at home (how un-nerdy!) so I may have received the copy of the demo version on a CD-ROM by a paper magazine about PC games. However, today you can download the ZIP file from many mirrors on the internet and fire it up quickly with DosBOX on many platforms. The demo version is limited to a single underwater mission where you start right off by re-arranging the equipment for your squad (weapons, ammunition, grenades and health packs).

You start right off with 1 tank (Coelacanth) and 6 soldiers:

00 Coelacanth/Gauss Cannon
01 Edward Smillie
02 Otto Zander
03 Orski Pavlov
04 Rudi Mederow
05 Gerhard Hafner
06 Marcel Cuvelier

Your enemy has 7 Tasoth aliens, all of them have identical unit stats:

07 Tasoth  Soldier
08 Tasoth  Soldier
09 Tasoth  Soldier
10 Tasoth  Soldier
11 Tasoth  Navigator
12 Tasoth  Soldier
13 Tasoth  Soldier

Here lies the actual challenge of the demo, the Tasoth Units are pretty strong and typicall look like this:

Accuracy   : Shot accuracy multiplier
Health     : 0 means dead
Energy     : Movement and shooting consumes energy and time units,
             a unit that carries a lot consumes more energy
Reaction   : Chance for an automated counter attack, higher means better
PSI        : Ability to use mean mind tricks
armor stats: front/left/... body armor stats
Accuracy   : 027 ######
Health     : 125 ##########################
Energy     : 090 ###################
Reaction   : 060 #############
Time untis : 056 ############
PSI        : 002 #
armor stats: 010/010/010/010/005

The player units vary a bit from each other but not that much:

Accuracy   : 057 ############
Health     : 041 #########
Energy     : 043 #########
Reaction   : 039 ########
Time untis : 054 ###########
PSI        : 000 
armor stats: 012/008/008/005/002

The player has a bit higher accuracy and some units have pretty good armor stats compared to their alien opponents.

On the other hand, the Tasoth soldiers have 3 times the health, a damn good reaction and PSI force. PSI force allows to trigger a panic to the enemy unit which causes them to drop their weapon, run away and remain unusable for at least 1 round. This attack even works through walls and drives you nuts once you enter the labyrinth of alien space ship.

Furthermore the alien Sonic Blasta is also a pretty strong weapon compared to the mixed players weapons, the damage multiplier is about double the size.

My list of complaints is long:

  • All alien units absorb about 3 times more hits than the player
  • Enemy weapon damage multiplier is much higher
  • All aliens have PSI ability which cannot be defended by the player
  • Player has the role of the attacker while the enemy can camp in their spaceship, the high alien reaction multiplier is another disadvantage in this case
  • The demo has limited rounds so the human player has to hurry up before the match abruptly ends, again an advantage for alien camper units

Hurt me plenty

When you play the game for the first time you realize pretty fast how hard it is even without knowing the stats above. Since it really bugged me I tried it again and again. I watched some youtube play throughs and read articles about the right strategy and so on but either I was killed by the last surviving Tasoth or I ran out of rounds and the demo exited.

So I wanted to find out how the demo mission looks like exactly, how many units you have to fight and what stats they have.

The internet has it all

The open source project UFOpaedia has all you need to know about the X-COM games (including Terror From The Deep). This is where I found the right information how the games stores the mission infos I am looking for. Basically we are interested in only two files:

MISSDAT/UNIREF.DAT   1848 bytes
MISSDAT/UNIREF2.DAT 10560 bytes

Both files contain the same information but are used in a different way. UNIREF.DAT stores all units within a savegame or mission data, UNIREF2.DAT is normaly created after the mission ends and compared to UNIREF.DAT to determine who survived, who got killed, what items have been collected, etc.

A single unit is stored within a fixed slot of size 132 bytes.

Since we have 14 units in our demo UNIREF.DAT has 14 * 132 = 1848 bytes.

The game can handle up to 80 units within a mission so UNIREF2.DAT has size 80 * 132 = 10560 bytes. The rest of the 66 units are indicated as empty unit slots here.

The structure of such an unit slot has already been reverse engineered and is very well documented in UFOpaedia. We are interested in the stats which have the following decimal offset:

-------------------------------------
Offset  Type
-------------------------------------
86-110: Units name
23    : Accuracy
25    : Time units
26    : Health
27    : Energy
28    : Reactions
37    : PSI
29-33 : Body armor
-------------------------------------

You could have done this with the hex editor of your choice but since I wanted to not only read but also modify the values I decided to write a little helper in C.

You cheating scumbag!

A good friend of mine called the program a ‘Game mod’, from that perspective my approach looks less sneaky. By using the C function FGETC(3) you can read byte after byte from a file input stream, modify it at the desired offsets and put it back using the function FPUTC(3).

https://gogs.gfuzz.de/oliver.peter/xcom-demo-hack

The program works pretty simple, it reads from UNIREF.DAT and UNIREF2.DAT, modifies both player and opponent unit stats and writes new files called UNIREF_NEW.DAT and UNIREF2_NEW.DAT. Just overwrite the original files in the MISSDAT directory, start the game and kick some alien bastard arses.

No need to be ashamed, we only balanced the game a bit to our needs:

  • The player has more health than the enemy
  • Player and aliens have the same reaction multiplier
  • Aliens are not able to use PSI anymore T he challenge remains, the time units are untouched and the player is still in a hurry of attacking while the aliens are lame base campers with strong weapons and good reactions.

Lessons learned

  • The difficulty in the demo is way too high, Microprose probably wanted the player to focus on the demo until the she finally decides to buy the full version of the game.
  • C is great
  • UFOpaedia is great
  • Game balancing is hard, while the original demo was too hard (on purpose) it may be now too easy for an experienced player. To find the right tuning is it’s own topic. If you ever managed to finish the demo without any hacks please let me know!

If you want to buy the original DOS game: It’s available on Steam.