• Welcome to Zoo Tycoon Community Download Directory.
 

On Editing Terrain Graphics

Started by vondell, October 17, 2026, 04:03:17 PM

0 Members and 1 Guest are viewing this topic.

vondell

A couple of us were having a conversation on one of the discord servers and got on the subject of to what extent the game's terrain graphics can be edited.

I know I have the impression that much of the game's terrain graphics are hardcoded into the game program, and so cannot be accessed to edit them.

The only two times we are familiar with modders touching the terrain graphics are pixigger's Mud Terrain from 2003 and Fern's experimenting with the turquoise water terrain, both of which only affect the blended terrain tiles and both of which seem to only recolor the existing graphic.

My assumption is that the base textures (non-blended) are hardcoded fully, but that perhaps the blended terrain feature was a later addition in development and may have accessible files in the game folder.

I assume perhaps either the blended terrain graphics themselves or their palette files can be edited somewhere.

Has this topic been written on anywhere before? I am mostly curious to know the bounds of what is possible, however limiting the bounds may be.

fern

There is a whole topic on it somewhere either in the bowels of DD or DG from when I was experimenting.
But as far as I can remember it was not possible to change or add to them.
The turquoise water was not the only recolour I did. I changed a couple of others at the time.....just for fun.

Jay

#2
I previously experimented with new terrains. The terrain graphics are not hardcoded in the ZT program. But expectations and probably the number of terrains are hardcoded in the ZT program. The biggest problem is ZT's minimap. XPACK2\ui6.ztd contains ui/miniclr.cfg. That file says what color pixel to use in the minimap for each type of terrain and object in ZT. For example, it has:

[Asphalt]
color=83
color=70
color=48

That "Asphalt" word is in the ZT program, as are all of the other terrain names in miniclr.cfg. However, not all of the section names in miniclr.cfg are in the ZT program. For example. miniclr.cfg has a [commerceBuilding] section, but the ZT program does not have "commerceBuilding". I have not experimented with miniclr.cfg concerning new terrains. Maybe it is possible to add a new terrain section in miniclr.cfg after the [Gunnite] section and ZT will use it if its number is 1 greater than the Gunnite terrain number. Or maybe ZT will use the [Tile] section for terrain that is greater than the Gunnite terrain number. The terrain number for the Gunnite terrain is in terrain/tiletex1.cfg within XPACK2\terrain6.ztd. That has "type=17", which gives Gunnite the terrain number of 17. That file also has "texture=terrain/gunnite.tga". That says to randomly use a portion of the terrain/gunnite.tga within terrain6.ztd to display that terrain in a zoo. That terrain is used at the bottom of a tank. tiletex1.cfg also has the cost of the terrain and says it is a non-blending terrain. The other terrains are configured in terrain/tiletex.cfg within terrain.ztd. Those have terrain numbers 0 through 16, although the waterfall terrain is not used. However, the ZT program does know "Waterfall". So it might be possible to make a new terrain using that. Most of the terrains in tiletex.cfg do not have "blend=0", which means they can be blended. When the blending option in ZT says not to blend, ZT treats the blending terrain like the non-blending terrain. It uses a random portion of the ".tga" file in the terrain's "texture" setting to show in a zoo. But when the blending option in ZT is set to one of the blending choices, ZT works differently. When a tile is a blending terrain, ZT looks at all 8 of the tiles around that tile. If all 8 of those use blending terrain, I believe ZT looks in the various ztatb...ztd files to determine what graphics to show. If any of those 8 tiles is a non-blending terrain, ZT calculates how to show the blending for the tiles that are using blending.

I previously did 2 things concerning tiletex.cfg. ZT allows showing zoos that have water terrain on slopes, but by default does not allow putting water terrain on slopes. It is tiletex.cfg that prevents water terrain being put on slopes. It has "water=1" for freshwater terrain and "water=2" for salt water terrain. When the ZT program sees one of those, it does now allow that terrain to be put on slopes and it does not allow animals, objects, staff, or guests to go on the terrain unless they are configured with "cSwims=1". I created AllowFreshWaterOnSlopesHackByJay.ztd that does not have "water=1" for freshwater terrain. Then people that make maps can use that ztd to create a map that has freshwater on slopes. Other people can then use those maps without AllowFreshWaterOnSlopesHackByJay.ztd and see the freshwater on slopes, and they will behave like freshwater on flat terrain: things with "cSwims=1" can be on the freshwater on slopes; things without "cSwims=1" cannot be on the freshwater on slopes.

The other thing I did was an experiment to create a new terrain in a special case. The ZT Beta included a Swamp terrain image. Although I could have used any image, I chose to use that in the experiment. I determined that I could sometimes have ZT show the swamp terrain instead of asphalt terrain if one of the blending options was turned on in ZT. The first image shows an example. If the blending option is set to no blending, the second image is what ZT shows. Depending on how the terrain is laid out, it is also possible to have both the swamp terrain and asphalt in the same zoo. The third image shows that. The fourth image is the same as the first image but uses a ".tga" containing red instead of swamp. This image shows how ZT is calculating blending. At the time, I created notes from my experiments. The following is a copy of those notes:

It is possible to use both the asphalt and the swamp terrain at the same time, even though it is technically the same terrain number. If a swamp tile is completely surrounded by 8 pieces of terrain that either do not blend or are also swamp terrain, then the center tile uses the asphalt graphics. Otherwise the center tile uses the swamp graphics. I suspect this is because ZT looks for the graphics to use for no blending when ZT first starts and it probably does not look in the subfolders at that time. I do not know yet what ZT will do if the file is put in the main folder or if it replaces ZT's terrain.ztd. But I suspect one of those approaches would cause the swamp terrain to always be used instead of the asphalt terrain. But I like the idea of being able to use both terrains at the same time, with thought out placement, though. However, with the current approach, the swamp terrain will only appear if one of the terrain blending options is turned on inside ZT.

Just to keep as a record of what I tested, I also had another test file of swamp terrain where it almost works as a totally new terrain. It appears in the terrain menu as a separate entry and the asphalt terrain is still there. So both can be used as if they were separate. But ZT crashes when trying to scroll a zoo with swamp terrain in it or if the zoo is saved and reloaded. I don't know if ZT would work better if this version of the swamp terrain was in ZT's main folder or if it replaces ZT's terrain.ztd. It would be worth investigating though. However, it is quite possible it is overflowing an internal buffer that cannot be adjusted. So it might never work reliably as a totally new terrain.

I used the beta swamp, and the full size as well. It is interesting how ZT works. It randomly takes a tile shape of pixels out of the terrain image. Since the terrain images are larger than a tile, that randomness will usually have 2 tiles that are next to each other not to have the exact terrain texture. Without doing that, the terrain would look like paths, where the same image is repeated over and over again. Probably the larger the terrain image, the more randomness there will be. But the largest terrain images are all 256x256 pixels, so that might be the largest size allowed.

For the most part, there is no limit to how large a swamp area you can make. But you have to intersperse it here and there with some other blending terrain, such as sand, dirt, or water. Here is an example of where asphalt will appear in the center of a 3 tile by 3 tile area:
swamp or non-blending | swamp or non-blending | swamp or non-blending
swamp or non-blending | swamp becomes asphalt | swamp or non-blending
swamp or non-blending | swamp or non-blending | swamp or non-blending

But if any 1 of those 8 tiles around that center tile contains a blending terrain other than swamp, then the center stays as swamp. Here is an example where the asphalt does not appear anywhere:
swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp
swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp
swamp | swamp | -sand-- | swamp | swamp | ---dirt--- | swamp | swamp | -sand-- | swamp
swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp
swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp
swamp | ---dirt--- | swamp | swamp | -sand-- | swamp | swamp | ---dirt--- | swamp | swamp
swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp
swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp | swamp

Although this approach is confusing and only works when blending is not turned off in ZT's options menu, it allows a zoo to have both swamp and asphalt at the same time, depending on how the terrain is laid out. So, for example, you can have the above terrain pattern in one part of the zoo and the following terrain pattern in another part of the zoo, which would cause an area of asphalt surrounded by concrete:
concrete | ------------concrete------------ | -----------concrete------------ | concrete
concrete | swamp becomes asphalt | swamp becomes asphalt | concrete
concrete | swamp becomes asphalt | swamp becomes asphalt | concrete
concrete | swamp becomes asphalt | swamp becomes asphalt | concrete
concrete | swamp becomes asphalt | swamp becomes asphalt | concrete
concrete | swamp becomes asphalt | swamp becomes asphalt | concrete
concrete | swamp becomes asphalt | swamp becomes asphalt | concrete
concrete | ------------concrete------------ | -----------concrete------------ | concrete

We do not know how terrain works in either the released ZT or the ZT beta. It is also a very technical concept. But I will try to say what I suspect happens. First, the beta is different than what was released. So the terrain logic will be different. The beta had less terrains. Maps and saved zoos might also work differently. In the released ZT, there is also a difference depending on whether terrain blending is turned on or turned off. When terrain blending is turned off, ZT will use a random part of the appropriate ".tga" file in terrain.ztd. When terrain blending is turned on, ZT probably also uses a random part of the appropriate ".tga" in terrain.ztd, if all 8 tiles around the current tile are for the same terrain or are non-blending terrain (Concrete or Asphalt). But if any of the 8 tiles around the current tile contains a different terrain and it is a blending terrain, then I believe ZT uses the files inside the ztatb...ztd files. There are several reasons why I believe this. It would take time if ZT had to calculate blending every time someone moves around a zoo. It would be faster for it to have all of the calculations done in advance for every possible combination of terrains surrounding a tile. There would be a lot of combinations, and the ztatb...ztd files have lots of things in them. Second, although I do not know what the "a" stands for in "ztatb" (maybe Advanced or Alternate), the other letters could stand for "Zoo Tycoon Terrain Blending". Third, the blending terrains with their numbers are: 0 (Grass), 1 (Savannah Grass), 2 (Sand), 3 (Dirt), 4 (Rainforest Floor), 5 (Brown Stone), 6 (Gray Stone), 7 (Gravel), 8 (Snow), 9 (Fresh Water), 10 (Salt Water), 11 (Deciduous Floor), 13 (Coniferous Floor), 16 (Trampled). If those numbers are converted to hexadecimal, they would be: 00, 01, 02, 03, 04, 05, 06, 07, 08, 09, 0a, 0b, 0d, 10. As it turns out those are the exact names used: ztatb00.ztd, ztatb01.ztd, ... ztatb09.ztd, ztatb0a.ztd, ztatb0b, ztatb0d.ztd, ztatb10.ztd. So that is why I strongly suspect those are used for terrain blending. Inside those files are ".lle" files and ".pal" files. We know the format of ".pal" files, but we do not know the format of the ".lle" files. The ".lle" probably means they use Line Length Encoding. They are probably similar to the ne/nw/se/sw files, which also use line length encoding, but the formats are different. ne/nw/se/sw files have the name of the ".pal" file inside of them, but the ".lle" files do not. I never took the time to see if the ".lle" files use a subset of the ne/nw/se/sw format. It might be possible to accomplish things by overriding the ".pal" files inside the ztatb...ztd files, but no one has tried that. By changing the ".tga" files, we can make ZT do some things, but there are limits to what can be done without being able to change or make the ".lle" files. An example of what can be done by changing the ".tga" file is the Mud Terrain Hack at Zoo Admin.

I gave an example of where adding a terrain almost worked, but crashed the game when scrolling a zoo with swamp terrain. That example was using swamp terrain as a blending terrain. If the ztatb...ztd files are for blending terrain, as I suspect they are, the crash was probably because ZT could not find a ztatb...ztd file for the new terrain number. So it did not know how to blend the terrain. It would be interesting to try it as a non-blending terrain. I don't remember if I tried that.

vondell

Fascinating, this is very different than what I imagined, and has possibly more potential for working with.

My current imagined use case would be providing alternate textures for some of the current ingame terrain, replacing them visually, but keeping them otherwise exactly the same for gameplay. So this actually seems like it could be more straightforward than adding a whole new terrain would be.

I will certainly refer back to this in the future, thank you for the detailed write-up.