I expanded my script for map conversion a bit and tweaked it a bit for the better or worse. As Ched pointed out the tombstones, mounts and path tiles with green grass looked a bit out of place on the otherwise brown map. I converted the paths to sand tiles. Furthermore, 10% of the original grass tiles are not converted to dirt so that tombstones and mounts might fit better into the scenery - same goes for tiles with grass undertiles, which cannot be changed by script afaik.
Additional changes are the the addition of blood and moss onto walls, etc.
Code: Select all
-- Apocalyptic script by LordMortiferus 2014/07/21
-- Existing maps can be turned into a waste land
-- enter the maplevel within the function name
function load_map_054(lvl, load_on_the_fly)
local tile_groups = {
[11]="grass",[12]="grass",[46]="grass",[13]="grass",[14]="grass",[214]="grass",
[128]="water",[129]="water",[130]="water",[131]="water",[132]="water",
[133]="water",[134]="water",[135]="water",[136]="water",[137]="water",
[138]="water",[139]="water",[140]="water",[141]="water",[142]="water",
[143]="water",[197]="water",[198]="water",[126]="water",[249]="water",
[031]="long_grass", [116]="rocks",[44]="scrub",[199]="foothill",[200]="foothill",
[255]="column",[167]="column",[169]="column",[111]="column",
[254]="floor",[166]="floor",[168]="floor",[95]="floor",[151]="floor",
[152]="floor",[153]="floor",[154]="floor",[155]="floor",[229]="floor",
[23]="floor",[92]="floor",[22]="floor",[19]="floor",[20]="floor",
[213]="floor",[222]="floor",[54]="floor",[40]="floor",[16]="floor",[15]="floor",
[37]="black_wall",[58]="black_door",
[124]="grey_wall",[177]="grey_door",
[119]="brown_wall",[179]="brown_door",
[64]="forest",[115]="tree",[226]="tree",
[76]="path",[77]="path",[80]="path",[112]="path",[121]="path",[41]="path",[175]="path"
}
local moss_blood_support = {
[101]="mb",[219]="mb",[91]="mb",[93]="mb",
[146]="mb",[178]="mb",[148]="mb",[147]="mb",
[35]="mb",[180]="mb",[123]="mb",[125]="mb",
[124]="mb",[177]="mb",[145]="mb",[144]="mb",
[170]="mb",[127]="mb",[174]="mb",[172]="mb",
[37]="mb",[58]="mb",[59]="mb",[257]="mb",
[119]="mb",[179]="mb",[171]="mb",[216]="mb",[262]="mb",
[78]="mb",[96]="mb",[228]="mb",[30]="mb",
[113]="mb",[181]="mb",[28]="mb",[29]="mb",
[150]="mb",[217]="mb", -- grey stone wall
[149]="mb",[218]="mb", -- brown stone wall
[17]="mb",[260]="mb", -- black stone wall
[110]="mb",[109]="mb", -- doors
[262]="mb", -- tombstone
[267]="mb",[264]="mb",[108]="mb",[122]="mb",[99]="mb",[118]="mb",[98]="mb", -- signs
[75]="mb",[194]="mb",[227]="mb",[231]="mb",[232]="mb",[250]="mb",[253]="mb", -- signs
[165]="mb",[71]="mb",[193]="mb",[72]="mb",[81]="mb" -- furnitures (drawers, bookcase, cupboard)
}
local random_dirt = {42,33,36,176,39} -- 032 is separate
map=get_map_ptr(lvl)
-- iteration over all tiles in the map:
for yy = 0, map:get_max_y()-1 do
for xx = 0, map:get_max_x()-1 do
local t = map:get_tile(xx,yy)
-- grass tiles are switched to various dirt tiles at random
if (tile_groups[t] == "grass" and int_rand(10) ~= 1)
or (tile_groups[t] == "floor" and int_rand(5) == 1) then
if int_rand(5) == 1 then
map:set_tile(xx,yy,get_random_element(random_dirt))
else
map:set_tile(xx,yy,32) -- dirt
end
-- water into lava
elseif tile_groups[t] == "water" then
map:set_tile(xx,yy,220) -- lave
-- long grass into dirt with grass
elseif tile_groups[t] == "long_grass" and int_rand(10) ~= 1 then
map:set_tile(xx,yy,39) -- long grass with dirt
-- some rocks with grass into some rocks with dirt
elseif tile_groups[t] == "rocks" and int_rand(10) ~= 1 then
map:set_tile(xx,yy,114) -- rocks with dirt
-- scrub into swamp
elseif tile_groups[t] == "scrub" and int_rand(10) ~= 1 then
map:set_tile(xx,yy,43) -- swamp
-- foothills with grass into plain foothills
elseif tile_groups[t] == "foothill" then
map:set_tile(xx,yy,47) -- foothill
-- columms into some rocks with dirt at random
elseif tile_groups[t] == "column" and int_rand(5) == 1 then
map:set_tile(xx,yy,114) -- rocks with dirt
-- black stone walls into black rock walls, at random
elseif tile_groups[t] == "black_wall" and int_rand(5) == 1 then
map:set_tile(xx,yy,17)
-- black stone walls with secret door into black rock walls with secret door, at random
elseif tile_groups[t] == "black_door" and int_rand(5) == 1 then
map:set_tile(xx,yy,260)
-- grey stone walls into grey rock walls, at random
elseif tile_groups[t] == "grey_wall" and int_rand(5) == 1 then
map:set_tile(xx,yy,150)
-- grey stone walls with secret door into grey rock walls with secret door, at random
elseif tile_groups[t] == "grey_door" and int_rand(5) == 1 then
map:set_tile(xx,yy,217)
-- brown stone walls into brown rock walls, at random
elseif tile_groups[t] == "brown_wall" and int_rand(5) == 1 then
map:set_tile(xx,yy,149)
-- brown stone walls with secret door into brown rock walls with secret door, at random
elseif tile_groups[t] == "brown_door" and int_rand(5) == 1 then
map:set_tile(xx,yy,218)
-- forest into forest with snow
--elseif tile_groups[map:get_tile(xx,yy)] == "forest" then
--map:set_tile(xx,yy,238) -- forest with snow
-- change a single tree into a dead tree, unless the tree is completly surrounded
-- by trees or is at the edge of the map, then it the tile is converted
-- into endless darkness and snc-fea is placed over it. This allows for
-- reduced line of sight (atmosphere)
elseif tile_groups[t] == "tree" or t == 53 then
local tree_density = 0
for yyy = yy-1, yy+1 do
for xxx = xx-1, xx+1 do
if map:get_tile(xxx,yyy) == 115 -- tree
or map:get_tile(xxx,yyy) == 226 -- tree
or map:get_tile(xxx,yyy) == 53 -- dead tree
or map:get_tile(xxx,yyy) == 221 -- endless darkness
or xxx < 0 or xxx > map:get_max_x()
or yyy < 0 or yyy > map:get_max_y() then
tree_density = tree_density + 1
end
end
end
if tree_density == 9 then
map:set_tile(xx,yy,221) -- endless darkness
map:del_feat(xx,yy)
map:add_feat(xx,yy,12) -- snc-fea
else
map:set_tile(xx,yy,53) -- dead tree
end
-- paths into sand tiles
elseif tile_groups[t] == "path" then
map:set_tile(xx,yy,45) -- sand tile
end
-- exchange waterfalls with lava falls and add trp-fea
local i = map:get_item_code(xx,yy)
if i == Item(0x0000012e) then
map:destroy_pile(xx,yy)
map:add_item(xx,yy,1,Item(0x00000459)) -- lavafall
map:del_feat(xx,yy-1) -- just in case
map:add_feat(xx,yy-1,15,0,xx,yy+1) --trd-fea
map:set_feat_text(xx,yy-1,"F-A-L-L-S!!!")
map:set_as_furniture(xx,yy)
-- change 50% of lighted braziers to unlit braziers
elseif i == Item(0x0000010e) and int_rand(2) == 1 then
map:set_item_code(xx,yy,Item(0x0000051e)) -- unlit brazier
map:set_as_furniture(xx,yy)
end
-- adds moss and blood on walls that are visible
if moss_blood_support[t] == "mb" and map:get_item_qty(xx,yy) == 0 then
local wall_density = 0
for yyy = yy-1, yy+1 do
for xxx = xx-1, xx+1 do
if moss_blood_support[map:get_tile(xxx,yyy)] == "mb"
or xxx < 0 or xxx > map:get_max_x()
or yyy < 0 or yyy > map:get_max_y() then
wall_density = wall_density + 1
end
end
end
if wall_density ~= 9 and int_rand(3) == 1 then
if int_rand(3) == 1 then -- add more moss than blood
map:add_item(xx,yy,1,Item(0x5d0)) -- blood
map:set_as_furniture(xx,yy)
else
map:add_item(xx,yy,1,Item(0x5d1)) -- moss
map:set_as_furniture(xx,yy)
end
end
end
end
end
end
EDIT: Had to fix an argument in the if statement to place blood and moss items. And thanks for all the positive feedback!