While waiting for Japa to finish the minor side projects of Armok Vision and raising a family
A script to flatten the embark region prior to embark
function flattenregion ()
if not dfhack.isWorldLoaded () then
dfhack.color (COLOR_RED)
dfhack.print("Error: This script requires a world to be loaded.")
dfhack.color(COLOR_RESET)
dfhack.println()
return
end
if dfhack.isMapLoaded() then
dfhack.color (COLOR_RED)
dfhack.print("Error: This script requires a world to be loaded, but not a map.")
dfhack.color(COLOR_RESET)
dfhack.println()
return
end
local cursor_x = df.global.world.world_data.region_details [0].pos.x
local cursor_y = df.global.world.world_data.region_details [0].pos.y
local biome = df.global.world.world_data.region_map [cursor_x]:_displace(cursor_y)
dfhack.println (biome.elevation)
for y, Y in ipairs (df.global.world.world_data.region_details [0].elevation) do
for x, X in ipairs (df.global.world.world_data.region_details [0].elevation [y]) do
df.global.world.world_data.region_details [0].elevation [y] [x] = biome.elevation
end
end
end
flattenregion ()
The embark region is generated from an unknown seed every time you move the embark cursor into the world tile, so the effects of the script are lost if you move the cursor away from the region (but not within it). Similarly, embarking again in the same region (i.e. close to a previous fortress) will again have the region map generated afresh with the original elevation. The previous fortress will retain the geography in force when it was generated, though, so reclaiming won't have the ground buckle under it...
The script sets the elevation to that of the biome associated with the region's world tile (while ignoring the elevation of the surrounding world tiles, even if their biomes appear in the embark).
I've tried the script by flattening the area around a volcano, resulting in an embark with a volcano hole in the flat ground, with magma a few levels down.
Hacking things yourself is fairly easy through "gui/gm-editor df.global.world.world_data.region_details[0].elevation" which gets you to a 17*17 matrix covering the 16*16 region tiles (I don't know what the last index, 16, is used for). Again, moving out of the region resets the edits.
Using manual hacking I've flattened the terrain around the volcano above (in a copy of the save) while raising the volcano itself to the maximum height. It resulted in a silly spire surrounded by flat ground (with the embark team clinging to the sides of the spire, and the wagon (but not goods) lost).
Edit: I tried a couple of variations on this theme, with interesting results. First I lowered the terrain of some the tiles a stream was passing through, in the hope of creating a waterfall. Instead, I ended up with an "aqueduct", where the stream was flowing high over the landscape in the lowered parts of the terrain, with no waterfall, and it seems the aqueduct walls were straight. I then reversed it to raise the terrain around a stream, and ended up with a vertical gash 10 levels deep (I'd raise the terrain 10 levels).
I guess both a gash and an aqueduct can be of interested to some people.
Edit 2: You can create waterfalls by manipulating region details data, but you have to do it to rivers_vertical and rivers_horizontal, respectively. In addition to that, DF refuses to have a river flowing upwards, so lowering a river in the wrong direction is ignored. I tried lowering a river's middle section of a 3 tile embark, and ended up with a waterfall at one of the embark tile boundaries and the rest of the river taking the lower level. It seems river_vertical/horizontal.active takes a value of 0 if no river is present, and -1 or 1 depending on the flow direction, with 1 = N->S / W->E, and -1 = S->N / E->W. Lowering/elevating rivers have the same effects as doing the opposite action on the elevation, by the way, i.e. creating canyons/aqueducts. It should also be possible to manipulate a river's width through x_min/x_max and y_min/y_max respectively in river_horizontal/vertical, and that ought to allow you to control their course (where they exit the tile, based on the flow direction).