-- 705: Found a good map, now we can loop through every tile and add additional details
print("-");
local plotDataIsCoastal = GenerateCoastalLandDataTable();
local hillsAdded = 0;
local mountainsAdded = 0;
local mountainsFilled = 0;
for x = 0, g_iW - 1 do
for y = 0, g_iH - 1 do
local i = y * g_iW + x;
-- 705: First, clean up the rare case of a non mountain plot surrounded by mountains
if(plotTypes == g_PLOT_TYPE_LAND or plotTypes == g_PLOT_TYPE_HILLS) then
local mountainCount = 0;
for direction = 0, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
local adjacentPlot = Map.GetAdjacentPlot(x, y, direction);
if adjacentPlot ~= nil then
local newIndex = adjacentPlot:GetIndex();
if(plotTypes[newIndex] == g_PLOT_TYPE_MOUNTAIN) then
mountainCount = mountainCount + 1;
end
end
end
if(mountainCount == 6) then -- surrounded by mountains
plotTypes = g_PLOT_TYPE_MOUNTAIN;
mountainsFilled = mountainsFilled + 1;
end
end
-- 705: Detailed hills and mountains pass
-- Add extra hills in vast flatlands
-- Change hills into mountains or flat land in vast hilly areas
local rChance = 1 + TerrainBuilder.GetRandomNumber(3, "Add hills - LUA Mixed Continents");
if(plotDataIsCoastal == false) then
local hillCount = 0;
for direction = 0, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
local adjacentPlot = Map.GetAdjacentPlot(x, y, direction);
if adjacentPlot ~= nil then
local newIndex = adjacentPlot:GetIndex();
if(plotTypes[newIndex] == g_PLOT_TYPE_HILLS) then
hillCount = hillCount + 1;
end
end
end
-- Add hill to flatland areas
if(hillCount < 3 - rChance and plotTypes == g_PLOT_TYPE_LAND) then
plotTypes = g_PLOT_TYPE_HILLS;
hillsAdded = hillsAdded + 1;
end
-- Add mountain or remove hill in hilly areas
if(hillCount > 3 + rChance and mountainsAdded < world_age * 10) then
plotTypes = g_PLOT_TYPE_MOUNTAIN;
mountainsAdded = mountainsAdded + 1;
elseif(hillCount > 3 + rChance) then
plotTypes = g_PLOT_TYPE_LAND;
end
end
end
end
print("-");
print("--- Details pass");
print("- Mountain Holes Filled:", mountainsFilled);
print("- Hills added:", hillsAdded);
print("- Mountains added:", mountainsAdded);