For I don't even remember how many years I have wanted to try this, and I finally got around to doing some
‼SCIENCE
‼ the result is in the spoiler tag below.
First Version
-- Floor Tiles
local tiles = {
FurrowedSoil
= true, StoneFloor1
= true, StoneFloor2
= true, StoneFloor3
= true, StoneFloor4
= true, GrassDarkFloor1
= true, GrassDarkFloor2
= true, GrassDarkFloor3
= true, GrassDarkFloor4
= true, SoilFloor1
= true, SoilFloor2
= true, SoilFloor3
= true, SoilFloor4
= true, SoilWetFloor1
= true, SoilWetFloor2
= true, SoilWetFloor3
= true, SoilWetFloor4
= true, GrassDryFloor1
= true, GrassDryFloor2
= true, GrassDryFloor3
= true, GrassDryFloor4
= true, GrassDeadFloor1
= true, GrassDeadFloor2
= true, GrassDeadFloor3
= true, GrassDeadFloor4
= true, GrassLightFloor1
= true, GrassLightFloor2
= true, GrassLightFloor3
= true, GrassLightFloor4
= true, StonePebbles1
= true, StonePebbles2
= true, StonePebbles3
= true, StonePebbles4
= true
}
-- Ramps Tiles
local ramps = {
GrassDryRamp
= true, GrassDeadRamp
= true, GrassLightRamp
= true, GrassDarkRamp
= true, StoneRamp
= true, SoilRamp
= true
}
local function enableFlooding()
local current = 0
local floors = 0
local slopes = 0
print( "This might take a minute, be patient.")
for k, block in ipairs(df.global.world.map.map_blocks) do
for x, row in ipairs(block.designation) do
for y, tile in ipairs(row) do
if tile.outside then
current = block.tiletype[x][y]
if (tiles[df.tiletype[current]] and math.random(100) < 10) then
block.tiletype[x][y] = 2 -- Replace with POND_TILE
floors = floors + 1
end
if (ramps[df.tiletype[current]] and math.random(100) < 30) then
block.tiletype[x][y] = 3 -- Replace with POND_RAMP
slopes = slopes + 1
end
end
end
end
end
print ("Changed ", floors, " floors and ", slopes, " ramps.")
end
enableFlooding()
Second Version
local function enableFlooding()
local current = 0
local counts = 0
local blocksize = df.global.world.map.x_count_block*df.global.world.map.y_count_block
print( "This might take a minute, be patient.")
for i = #df.global.world.map.map_blocks - 2, 0, -1 do
local block = df.global.world.map.map_blocks[i]
if( current == 0 ) then current = block.map_pos.z end
if block.map_pos.z == current or block.map_pos.z == current-3 then
for x, row in ipairs(block.designation) do
for y, tile in ipairs(row) do
if tile.outside then
if( math.random(100) < 25) then
block.tiletype[x][y] = 2 -- Replace with POND_TILE
df.global.world.map.map_blocks[i-1].tiletype[x][y] = 259 -- Replace with POND_TILE
counts = counts + 1
end
end
end
end
end
end
print ("Added ", counts, " sky tiles.")
end
enableFlooding()
Disable Flooding
local function disableFlooding()
local current = 0
local counts = 0
local blocksize = df.global.world.map.x_count_block*df.global.world.map.y_count_block
print( "This might take a minute, be patient.")
for i = #df.global.world.map.map_blocks - 2, 0, -1 do
local block = df.global.world.map.map_blocks[i]
if( current == 0 ) then current = block.map_pos.z end
if block.map_pos.z == current or block.map_pos.z == current-3 then
for x, row in ipairs(block.designation) do
for y, tile in ipairs(row) do
if tile.outside then
if( block.tiletype[x][y] == 2 ) then
block.tiletype[x][y] = 32 -- Replace with OPEN_SPACE
df.global.world.map.map_blocks[i-1].tiletype[x][y] = 32 -- Replace with OPEN_SPACE
counts = counts + 1
end
end
end
end
end
end
print ("Removed ", counts, " sky tiles.")
end
disableFlooding()
This script converts roughly 20% of Grass tiles, and 40% of Ramp tiles into POND tiles. The result is a bit ugly, but what it allows is for actual water to spawn and move around during Rain. In a real hurry you can end up with a real mess, and depending on your landscape and Fort design, may have potential for some serious
flooding FUN!
So, I am posting this to share, I'd love to hear feedback. Also I suspect some of you may be more familiar with DF Lua than I, and could probably clean the function up a bit. Making alterations based on Material Type instead of straight Tile value and what not.
Enjoy, I look forward hearing about it.
-=-=--=-=-=
Edit: Updated script in the Spoiler Tag.
@lethosor Thank you for your notes, I made modifications based on them. For the moment, I did keep the magic numbers, but thanks to your advice I know what they are so that helps alot. I chose to keep the values over text for length of the file, but I guess for clarity and modability of anyone wishing to tinker with it, text would be better.
I'll add the values below. I have the full list of ~700 Tile names, I thought I might post some place if it isn't available already, I haven't checked yet.
One thing, I did try to implement your suggested shorthand
if( tiles[current]==true and math.random(100) < 20) then
instead of the has_value( ) it didn't quite give the results I expected, and some reading suggested that the table declaration would need to change from {257,332,etc...} to {[257]=true,[332]=true,[etc]=true...}
and again, with using names over numbers, I can do it, but is it worth it? Finished, fixed this and got named indexes working.
-=-=--=-=-=
Edit: Added second Spoiler Tag.
Modified concept, rather than changing ground tiles to be scattered with pond tiles, using a qurik of SemiMoltenRock was able to scatter pond tiles across the top of the skybox, so now the surface is misty with buckets of rain!
-=-=--=-=-=
Edit: Added disable script, to change tiles back to Open_Space. Just in case you experience too much FUN.
Note: this will only repair the
Second Script.