Level hacking

Ideas, technology and contributions to Z modifications

Moderator: Brad

User avatar
lil' T
Lieutenant
Lieutenant
Posts: 77
Joined: 2007-03-07, 20:40
Location: Germany
Contact:

Level hacking

Postby lil' T » 2010-02-05, 12:18

EDIT: Level editing application is ready, quick download link and instructions

Did you ever want to finish Level 01 with a Heavy? Well, I always wanted to... :shake:

I was inspired by this topic, where it is shown how to modify unit stats: viewtopic.php?f=4&t=289 . I thought it must be possible to edit the levels, more precisely the building types, empty vehicles and more. As I know now, it is possible. This is what I mostly found out by trial and error or by looking at the files of already existing levels.

Obviously, the files of interest are the LEVELxx folders found on the CD (DOS) or in the installed game directory (Z95). The xx stands for the respective level, obviously too. I have investigated BUILDxx.DAT and OBJECTxx.DAT, which contain the buildings and objects of level xx, again that was obvious. You will also need a hex editor to edit those files. The values below are in hexadecimal format if not specified otherwise. Note: byte #1 means the first byte of a building.

BUILDxx.DAT
Buildings are crammed into 50h bytes (or 80 decimal bytes), starting from the very first byte of this file. I have listed only the interesting bytes that have a visible effect. Also, forts don't seem to be in those files.

Code: Select all

byte# effect
1	x-coordinate in territory
2	x-coordinate sector
3	y-coordinate in territory
4	y-coordinate sector
5	building type:
	00	repair facility
	01	vehicle factory
	04	robot factory
	08	radar facility
	09+	crash (don't use)
	FF	disabled
14	star rating:
	add 4h for each star this factory shall have
	should have at least one star if building type is a factory
	radars and repair facilities have the value 01, unknown
	what it does to them
	03	one-star
	07	two-star
	0B	three-star
	0F	four-star
	13	five-star
OBJECTxx.DAT
Objects are stored in ah bytes (10 decimal bytes), also starting from the very first byte of this dat. There are a lot of object types, most of which I did not list because they are landscape objects, e.g. rocks.

Code: Select all

byte# effect
1	x-coordinate in territory
2	x-coordinate sector
3	y-coordinate in territory
4	y-coordinate sector
5	object type:
	05	Gun
	08	Medium
	0A	grenades
	15	Missile
	16	Gattling
	17	Howitzer
	18	Mobile Missile
	1A	Heavy
	1D	Light
	1F	APC
	21	Jeep
	23	Crane
6	FF for objects other than empty vehicles and guns
	this byte contains the attributes of the vehicle/gun
	if not set appropriately, this will produce weird results
	i.e. a vehicle with speed, power, rof etc. of another vehicle
	00	Gun
	01	Medium
	05	Heavy
	06	Mobile Missile
	08	Light
	09	Missile
	0A	APC
	0B	Gattling
	0C	Howitzer
	0D	Jeep
	0F	Crane
This should enable you to open any level and a text editor and easily modify what is already there. Can you add buildings or objects this way? Indeedio you can, just search for a free spot filled entirely with FFs in those files where another entity can fit. Note that buildings and object have trailing FFs. The first byte of a building is always a multiple of 50h whereas it is 10h for an object. It is best to copy an already existing entity into a free spot and change the bytes to your likes, don't forget to change the coordinates! :wink:

I nearly forgot to add: if you are using Z DOS (most likely with DOSBox), you will need to extract the entire ISO image you are using to install and start the game. Then, you can edit the files to your likes. Once finished, you need to pack the extracted files back into an ISO file and use it to start Z. There are several packing tools that can do this for you, e.g. Linux has the very simple command line application named 'genisoimage'.

Additionally, I am seeking to edit the starting units and the levels of the forts. If anyone knows about this or something related, add it here.

Cheers, lil' T :cheers:
Last edited by lil' T on 2010-02-06, 20:20, edited 2 times in total.
User avatar
FreakNigh
General
General
Posts: 254
Joined: 2009-12-23, 22:41
Are you a spam bot?: No
Location: Philadelphia, USA
Contact:

Re: Level hacking

Postby FreakNigh » 2010-02-05, 18:38

Do you know of a way we could switch teams for all the original levels? because that would be cool to play as the blue team throughout the original levels. Thanks :D
Image Image
User avatar
lil' T
Lieutenant
Lieutenant
Posts: 77
Joined: 2007-03-07, 20:40
Location: Germany
Contact:

Re: Level hacking

Postby lil' T » 2010-02-06, 19:07

Playing as the blue team has been tried a while ago, however I think it has been established that it is not easily possible to make red and blue change roles. This could severly break game play even crashing the game at worst. Now, for swapping starting positions, that might actually be possible as well as changing the team's colors. Problem is I don't know where to look for this and experimenting on my own would probably take ages. However, if you give me a good indication where to look for, I will try my best.

As for the hacking application, there is a first usable version. You can get it here: http://code.google.com/p/zhacker/downloads/list (EDIT: moved to googlecode repository)

It is a Java application, meaning you can run it on any plattform that Java is ported to. Get Java from here http://java.com and install it if you haven't already. If you want to get the hacker's source code, contact me anytime.


Instructions for using ZHacker

If you have the DOS version, I presume you have extracted the Z .iso image. This is not necessary for Z95. Make a backup of all files you are going to edit first!

1. Start the application by double-clicking the .jar or by issuing via command-line:

Code: Select all

java -jar ZHacker.jar
2. Open the "File" menu and select either "Open BUILDxx.DAT" or "Open OBJECTxx.DAT". Navigate to a LEVELxx directory and open the respective file that is shown. The xx stands for the respecting level number. All level entities are then loaded into the editor.

Image

3. Depending on which file you opened, the application will jump to the respective editing interface. The upper panel lets you select an entity. There are two combo boxes to do so: the left one let's you choose the entity by id as it appears in the .DAT file, while the second shows the entity type if known, allowing for a more meaningful selection.

3.1. Once selected, the fields of the value editor change according to the selected entity. You can now change those values to you likes using the spinner elements (recommended) or by using the keyboard (only decimal values between 0 - 255 are accepted). Some spinners have a combo box next to them, their use is recommended over the spinners.
Here is an explaination to each field:
  • X Position - X coordinate for position in sector
  • X Territory - X coordinate for territory
  • Y Position - Y coordinate for position in sector
  • Y Territory - Y coordinate for territory
  • Building Type - The type of a building, e.g. factories, radar and repair shed.
  • Star Rating - The "rating" of a building, only makes sense for factories.
  • Object Type - The type of an object, currently only empty vehicles, guns and grenades. The attributes of the vehicle/gun are automatically set so you don't need to worry about that.
Note: the coordinates are still very inaccurate. That is because I don't know yet where the coordinates emanate from. If you can give me a more precise description, I'd be glad to reflect those changes in this application. For now, it is best to look at already existing coordinates to get a feeling where the entities reside.

3.2. To create "new" entities, look for an entity with all values set to "255" and change them to more sane values. Make sure that the coordinates are approximately inside the map. Again look at already existing entities. I will make this easier in a later version.

4. If you are done editing, choose "Save BUILDxx.DAT" or "Save OBJECTxx.DAT" depending on which you edited and select the file you opened earlier. A dialog will confirm that you saved your changes.

4.1. DOSBox users will have to repackage the .iso file. See the first post in this topic.

5. Start Z and load the level whose files you have edited. Enjoy the changes you have done! :cheers:

If you have suggestions, feature requests or problems concerning ZHacker, feel free to contact me.


Greetz, lil' T
Meeky
Captain
Captain
Posts: 137
Joined: 2009-02-05, 11:18
Location: Russia

Re: Level hacking

Postby Meeky » 2010-02-13, 21:15

lil' T
I, along with Ballwin, have spent considerable amount of time studying Z files structure.
So you don't need to waste your time following our way, just ask us :wink:
WinZMod - mod for playing Z with high screen resolution
ZEdMod - ZEditor mod allowing to edit single player levels
ZGFX - Utility for extracting Z graphic
ZStats - Small utility for fine-tuning unit statistics
Z-Remake - XNA project on 2D IceCream Engine
User avatar
lil' T
Lieutenant
Lieutenant
Posts: 77
Joined: 2007-03-07, 20:40
Location: Germany
Contact:

Re: Level hacking

Postby lil' T » 2010-02-14, 00:21

@Meeky
Thanks for your help! After digging through robots.dat, I will definitely appreciate any help. Basically, I would most like to know about the following subjects:
  • Where do you set the 'star-rating' of the forts?
  • I know how to edit the CPU player's starting units. Is it also possible to edit the starting units for the human player?
  • Since you modded the Z Level Editor, can you explain how the coordinates, i.e. in BUILDxx.DAT, exactly work? Currently, I only have rough estimates, such as X,Y for territory and X,Y for position in that territory.
By the way: some interesting things I have noticed:
  • You can change the team of the units, the CPU starts with. Green units and blue will attack each other. Unfortunately, the game registers only blue robots, meaning if there are no more blue robots, the game is over.
  • The maximum number of robots in a group is 21. Although it will take some real minutes to produce them, robot armys are hilariously funny to play with. This will definitely be editable by ZHacker.
  • Just for fun, I gave Grunts full energy (value: 100). Surprisingly, vehicles - with Grunts inside - were far, far less likely to have their driver shot out. This leads me to believe that the chance of shooting a driver out of the vehicle depends on the driver's energy.
  • You can change the default factory build task, default: Grunts/Jeep.
  • Obviously, besides the well-known Fire Truck, there was supposed to be another Truck, which function or looks is completely unknown.
Also, version 0.2 of ZHacker is up, which has preliminary robots.dat/exp editing support. It has not been thoroughly tested but you can if you like. :wink:

Greetz, lil' T
User avatar
FreakNigh
General
General
Posts: 254
Joined: 2009-12-23, 22:41
Are you a spam bot?: No
Location: Philadelphia, USA
Contact:

Re: Level hacking

Postby FreakNigh » 2010-02-14, 02:27

Dang we're going to have this whole game at our mercy soon enough.
Image Image

Who is online

Users browsing this forum: No registered users and 2 guests