wc: mapgen: move total_tiles to scenario_data

This commit is contained in:
gfgtdf 2023-03-25 05:08:51 +01:00
parent c75fa8b4cb
commit 9804935cad
6 changed files with 10 additions and 11 deletions

View file

@ -8,7 +8,7 @@ local function world_conquest_tek_map_repaint_2b()
))
-- base amount in map surface
local r = mathx.random_choice(tostring(total_tiles // 675) .. ".." .. tostring(total_tiles // 330))
local r = mathx.random_choice(tostring(scenario_data.total_tiles // 675) .. ".." .. tostring(scenario_data.total_tiles // 330))
wct_storm(terrain_to_change, r)
end
wct_expand_snow()
@ -143,7 +143,7 @@ local function world_conquest_tek_map_repaint_2b()
-- chance of diferent forest based in map temperature
local terrain_to_change = map:find(f.terrain("A*^*,Ha*^*,Ms^*"))
local chance = 2000 * #terrain_to_change // total_tiles
local chance = 2000 * #terrain_to_change // scenario_data.total_tiles
if mathx.random(0, 99 ) > chance then
set_terrain { "*^Ftd",
f.terrain("*^Ft"),
@ -231,7 +231,7 @@ function world_conquest_tek_map_constructor_lakes()
fraction_rand = "11..13",
}
local r = mathx.random_choice(tostring(total_tiles // 675) .. ".." .. tostring(total_tiles // 285))
local r = mathx.random_choice(tostring(scenario_data.total_tiles // 675) .. ".." .. tostring(scenario_data.total_tiles // 285))
set_terrain { "Hh^Tf",
f.all(

View file

@ -143,7 +143,7 @@ function world_conquest_tek_map_decoration_2c()
))
mathx.shuffle(terrain_to_change)
-- base amount in map surface
local r1 = mathx.random_choice(tostring(total_tiles // 285) .. ".." .. tostring(total_tiles // 150))
local r1 = mathx.random_choice(tostring(scenario_data.total_tiles // 285) .. ".." .. tostring(scenario_data.total_tiles // 150))
for i = 1, math.min(r1, #terrain_to_change) do
map[terrain_to_change[i]] = "Ai"
end
@ -153,7 +153,7 @@ function world_conquest_tek_map_decoration_2c()
f.adjacent(f.terrain("!,Wo,Ai"), nil, 0)
))
mathx.shuffle(icepack_candiates)
local r2 = mathx.random_choice(tostring(total_tiles // 250) .. ".." .. tostring(total_tiles // 150))
local r2 = mathx.random_choice(tostring(scenario_data.total_tiles // 250) .. ".." .. tostring(scenario_data.total_tiles // 150))
for i = 1, math.min(r2, #icepack_candiates) do
local loc = icepack_candiates[i]

View file

@ -278,7 +278,7 @@ function world_conquest_tek_map_repaint_4b()
-- mushrooms, base amount in map surface
local terrain_to_change3 = map:find(f.terrain("Hhd,Hhd^F^*"))
mathx.shuffle(terrain_to_change3)
local r1 = mathx.random_choice(tostring(total_tiles // 600) .. ".." .. tostring(total_tiles // 300))
local r1 = mathx.random_choice(tostring(scenario_data.total_tiles // 600) .. ".." .. tostring(scenario_data.total_tiles // 300))
for mush_i = 1, math.min(r1, #terrain_to_change3) do
map[terrain_to_change3[mush_i]] = "Hhd^Tf"

View file

@ -175,7 +175,7 @@ local function world_conquest_tek_map_decoration_6a()
))
))
local rand_choice1 = mathx.random_choice(tostring(total_tiles // 930) .. ".." .. tostring(total_tiles // 210))
local rand_choice1 = mathx.random_choice(tostring(scenario_data.total_tiles // 930) .. ".." .. tostring(scenario_data.total_tiles // 210))
wct_storm(terrain_to_change1, rand_choice1 + 2)
wct_expand_snow()

View file

@ -47,7 +47,7 @@ function world_conquest_tek_map_rebuild(cave, reef)
-- replace hills for mushrooms
-- base amount in map surface
local r = mathx.random_choice(tostring(total_tiles // 500) .. ".." .. tostring(total_tiles // 250))
local r = mathx.random_choice(tostring(scenario_data.total_tiles // 500) .. ".." .. tostring(scenario_data.total_tiles // 250))
-- just to be sure.
r = tonumber(r)
set_terrain { "Hh^Tf",

View file

@ -39,13 +39,13 @@ local function run_postgeneration(map_data, id, scenario_content, nplayers, nhum
wesnoth.dofile("./postgeneration_utils/noise.lua")
local postgenfile = postgenerators[id] or id .. "./lua"
--local postgenfile = postgenerators["2f"] or id .. "./lua"
_G.map = wesnoth.map.create(map_data)
_G.scenario_data = {
nplayers = nplayers,
nhumanplayers = nhumanplayer,
scenario = scenario_content,
total_tiles = _G.map.width * _G.map.height,
}
_G.map = wesnoth.map.create(map_data)
_G.total_tiles = _G.map.width * _G.map.height
_G.prestart_event = scenario_content.event[1]
_G.print_time = function(msg)
wesnoth.log("info", msg .. " time: " .. (wesnoth.ms_since_init() - postgen_starttime))
@ -58,7 +58,6 @@ local function run_postgeneration(map_data, id, scenario_content, nplayers, nhum
wct_fix_impassible_item_spawn(_G.map)
local map = _G.map.data
_G.map = nil
_G.total_tiles = nil
_G.prestart_event = nil
_G.scenario_data = nil
return map