Duke 1 Savegame Format

From ModdingWiki
Jump to navigation Jump to search

There are two types of save games in Duke Nukum : the files called SAVEDx.DN# (where x is a number between 1 and 9), which can be saved manually when Duke reaches the intermission hallway and SAVEDT.DN#, which is an automatic save created by the game.

A save game is always made of 22 short unsigned integers and a final string of undetermined size terminated by a soft return carriage character (0x0A).

The file saves Duke’s score, health, firepower, inventory (gloves, robohand and boots), if a hint needs to be triggered or not when encountering a specific item and of course, the level Duke is at.

File format

Data type Content
UINT16 iCamX Camera position (X axis) - in half-tile units (8 pixels per unit)
UINT16 iCamY Camera position (Y axis) - row offset for map data (multiples of 128)
UINT16 iDukeX Duke's position on screen (X axis) -- relative to camera position, in half-tile units (8 pixels)
UINT16 iDukeY Duke's position on screen (Y axis) -- relative to camera position, in pixels
UINT16 iLevel Current level (0 to 21). Note that the intermission counts for one, so the first hallway is level 1, the second is level 3, the third is level 5...
UINT16 iFirepower Amount of rays (1 to 4). You can set any other number, but you'll get strange results (not being able to fire at all or graphical glitches)
UINT16 iBoots Jumping Boots (0 or 1). Set to 1 to have the jumping boots, other values have strange results.
UINT16 iHook Hook (0 or 1). Set to 1 to have the hook.
UINT16 iHealth Hit points (1 to 9). Note that when the game displays no life bar, you still have one hit point.
UINT16 iGlove Robohand (0 or 1). Set to 1 to have the Robohand.
UINT16 iHint1 Secret tip 1 (0 or 1). "Find the key that goes here and press the UP ARROW."
UINT16 iHint2 Secret tip 2 (0 or 1). "Press the up arrow to read the notes."
UINT16 iHint3 Secret tip 3 (0 or 1). "Drink soda to increase your health!"
UINT16 iHint4 Secret tip 4 (0 or 1). "Eat turkey to increase your health!"
UINT16 iHint5 Secret tip 5 (0 or 1). "The nuclear molecule increases your health to maximum!"
UINT16 iHint6 Secret tip 6 (0 or 1). "Press the up arrow to open the door"
UINT16 iHint7 Secret tip 7 (0 or 1). "Press the up arrow to activate the elevators."
UINT16 iHint8 Secret tip 8 (0 or 1). "Press the up arrow to activate the transporter."
UINT16 iHint9 Secret tip 9 (0 or 1). "Press the up arrow here after you have found the Robohand"
UINT16 iHint10 Secret tip 10 (0 or 1). "Find the access card and press the up arrow here"
UINT16 iHint11 Secret tip 11 (0 or 1).
UINT16 iHint12 Secret tip 12 (0 or 1).
CHAR cScore Score, this string is terminated with a soft carriage return

Coordinates

The camera coordinates stored in the savegame files are ignored when the game is loaded! Since the player coordinates are stored as screen coordinates and not as level coordinates, the player might be stuck in a wall when a modified savegame is being loaded and the current level has not enough free space around the player's starting position.

Safe checks

If you plan to write a save game hacker, don't worry for the output file as Duke will blindly trust any file called SAVED# to be a genuine save game. However, it's harder to make sure the input file is a save game without any kind of signature, here's what you might want to check: The file MUST be between 46 and 51 bytes long. 46 is the size of 22 UINT16 plus two CHAR ("0" + "0x0A"). 51 is 22 UINT16 plus nine CHARS (the default score displayed in Duke is 8-digits + "0x0A"). iHint1 through 10, iBoots, iHook, iGlove MUST be either 0 or 1. iHealth MUST be a value between 1 and 9. iFirePower must be a value between 1 and 4. Characters from byte 44 must be "1234567890". The file MUST end with a soft carriage return character.