Thief The Dark Project and Thief 2 The Metal Age - Flying - God Mode - Invisibility

This blog is focused on how to enable cheats for Flying - God Mode - Invisibility in Thief The Dark Project and Thief 2 The Metal Age

PRE-REQUISITES ]

First off, you will need to get Cheat Engine from this location: 

CheatEngine75.zip (2.59 mb)

I'm currently using Cheat Engine 6.3. Although not accustomed with, you may find good uses for it in other games as well.

Next up, fetch the hotlinked archive: 

DarkHook.zip (11.81 kb)
It contains two tables: one for T1, TG, T2 v1.21 - and - one for DromEd v1.21. The reason why there are two tables is simple: DromEd contains way too much functions than the game executable, so for the game release I had to "improvise" and rebuild missing functions or properties. Such as: physics, ai_aware_of_player, ai_sleep_all, ai_wake_all - and probably future more.


MECHANICS ]

To use the table, follow the steps below:
- open the game;
- open Cheat Engine;
- in CE, choose File > Open Process - OR - click the first top icon (a computer with a magnifying glass);
- once the Process List is up, find 'thief.exe', 'thief2.exe' OR 'DROMED.exe' in there;
- once found, double-click it - OR - click Open;

Top part of CE should look like this now: (note that the process ID will be different on your end - e.g.: 00000F88)

Based on your preference: T1, G, T2 - OR - DromEd, open the corresponding table from the provided archive via File > Open File - OR - Ctrl+O - OR - clicking the second icon in CE's top part. Choose 'DarkHook.CT' and hit Open. Once that is done, the table data should appear in CE's bottom window:

To proceed, click [Enable]. If an issue occurs then try restarting the cheat engine.

For future reference, when you see the checkbox, everything is OK.

[Enable] is a script - you can open it selecting the line, then hitting Enter key, if curious what it contains - that uses patterns to identify locations in game's code for later use or just simple hooking. Once active, it will allow access to sub-sections:

[Coordinates] - here you will find Garrett's in-game coordinates (you have to be in a map);
[Scripts] - here you will find DarkHook script;

To activate DarkHook, tick [Scripts], then tick DarkHook. Everything should look like this now:

FEATURES ]

Get back in-game and use the following hotkeys for their effects:

F2: Will display the menu.

NUMPAD1: PlayersOnly.

The name of the option is taken from UnrealEngine's command, where, once activated, it would freeze entire world but the player. In DarkEngine, you may know it as the combo ai_sleep_all/ai_wake_all. I found that the aforementioned engine functions are a bit buggy - if you knock-out or kill an AI, then use ai_wake_all, they'll be back on their feet, although inactive. This might be a bit strange when you play the game, to find AIs that were taken care of staring at you  ai_sleep_all sets the AIs state to 0 (Asleep), without storing previous state. ai_wake_all sets state to 3 (Normal), only for the Asleep AIs (state 0). This is where I intend to make some changes of logic: get each AI state through GetProperty, store it and when setting state through SetProperty, check stored AI states and restore their original ones instead of forcing them all to Normal for the Asleep ones.

-- UPDATE --

PlayersOnly works perfectly now! When activated, AI IDs and states are backed-up, then Asleep state (0) is set for all of them. When deactivated, AI states are restored based on the backed-up values. You should now be able to blackjack an AI, "pause" game while he begins to fall, then "unpause" to see him touch the ground.

Toggleable ON/OFF with the press of the key.

NUMPAD2: Fly.

This option makes use of two functions: PhysSetGravity and PhysSetBaseFriction. When active, it will 0 the gravity and set friction to 320.0f. When inactive, will restore original state, setting gravity to 1 and friction to 0.

Toggleable ON/OFF with the press of the key.

NUMPAD3: Ghost.

Option name taken from UE again. What it actually uses from DarkEngine is physics, setting it to 0 or 1. When active, you will notice the message "Collisions: OFF" (meaning you can walk through doors, walls, or if you jump, fall through the map). I suggest you use Fly with it. When inactive, message will be "Collisions: ON". The physics BOOL is checked in two locations: one which is generic, taking care of all objects AND one which only works for trees, doors, AIs but not walls, floors. If need be, I can adjust this to work to the player's advantage, thus allowing you to play normally without Fly, but without the ability to walk through walls.

In the game release, the checks were removed, so I had to find the spots, hook them and "plant" the missing code 

Toggleable ON/OFF with the press of the key.

NUMPAD4: Super Speed.

Option will mimic the effects of the Speed Potion.

Toggleable ON/OFF with the press of the key.

NUMPAD5: God Mode.

This option makes use of a hook location (where your health is decremented) and two adjacent functions: ObjGetMaxHitPoints and ObjSetHitPoints. What they do is to acquire the max health points your character (Garrett) can have and set them accordingly. Option works like healing as well: say you got 2 bars left and want to just heal yourself - what you do is hit the key twice (hitting it once will enable God, but at the same time heal you to your maximum health; hitting the key again will disable God).

Toggleable ON/OFF with the press of the key.

NUMPAD6: Activate/Deactivate LockCheat Script

This feature should only be used in Thief or Thief Gold. Read below, in the LockCheat section!

NUMPAD7: LockCheat.

You may know this cheat. To work with it, one would have to open up user.cfg and type it in there on a line, save file, load game, and all locks would be open. Well, now you can do this without having to type it in the .cfg file. Option works via two functions: hash_set and hash_delete. Their purpose is to fetch strings and hash them to values. Based on these values, corresponding options are activated/deactivated - such as these cheats.

Toggleable ON/OFF with the press of the key.

-- UPDATE --

In Thief or Thief Gold, LockCheat is not available. I've managed to get a workaround ready, so follow below steps:

- load up T1 or TG and target it in CE;
- activate [Enable] script, then activate Scripts > DarkHook;
- back in-game, hit NUMPAD6 to activate LockCheat Script script - you'll see it becoming active in CE's list and bOldThief address is set to 1 <- DO NOT TOUCH IT! (as in, change its value - it's done on NUMPAD6 key press);
- use NUMPAD7 as before to activate/deactivate the option;

Inside technical:

- when you enable LockCheat Script in T1/TG, you will see the message "LockCheat Script is enabled." in-game - so you know it'on;
- a secondary BOOL is used - bOldThief - that becomes 0 or 1, depending on LockCheat Script's state (active or disabled);
- bOldThief is checked for in DarkHook, so: when it's 0, normal LockCheat is executed (for T2); when it's 1, the T1/TG version is executed;
- how do you know which one is active when you hit NUMPAD7? For T2, message is "LockCheat: ON" or "OFF"; for T1/TG, message will be "LockCheat: Active" or "Inactive";
- furthermore, since array pattern won't be found, you won't be able to activate it in T2 (it won't get enabled/ticked)

In T2, the check happens in gen.osm. In T1/TG, most missions have their own .osm files. Therefore, you will have to do it like this:

- play a mission - hit NUMPAD6, to activate script, then NUMPAD7 to activate option;
- if you finish mission OR reload map, .osm gets reloaded - hit NUMPAD6 to deactivate script, and one more time to activate it (you will see status on screen), then use NUMPAD7 as you wish;

NUMPAD8: Infinite Item Timeout.

This feature can also be set in the .cfg files, but I've managed to go without it. Simple as is, once enabled you'll see: "Inventory Item Timeout: OFF", meaning all inventory items will remain on your screen indefinitely. Turning it off will show "Inventory Item Timeout: ON", restoring the timeout.

Toggleable ON/OFF with the press of the key.

NUMPAD9: AI Awareness.

Option will mimic the DromEd BOOL. This variable was used to check whether AI Sight and Listening casts would involve the player as well. It was removed in the game release, so I had to hook the 2 or 3 locations where this BOOL was used. Simply put - when enabled, you will see: "AI Awareness: OFF" - AIs will ignore you on sight or sound. Turning it off will show "AI Awareness: ON" - you'll be 'visible' again

Toggleable ON/OFF with the press of the key.