----------------------------------------------------------------------------------------------------------------------------------|
-- THIS NEEDS TO GO IN GetMapScriptInfo(). Change GetCustomOption(<index>) to suit your needs.
-- For GetWaterPercent() Custom method: Land Scaling by Number of Cities per Players and City-States
-- Use in your own script, just please remember to credit ColBashar and I. Thanks!
----------------------------------------------------------------------------------------------------------------------------------|
{-- Override Land Scale
Name = "Land Scale Target:", -- overrideLandScale = Map.GetCustomOption(6) -- based on target 25 tiles per city
Values = { -- Val PlotsPerCiv
"3 Cities/Civilization", -- 1 75
"4 Cities/Civilization", -- 2 100
"5 Cities/Civilization", -- 3 125 <-Default
"6 Cities/Civilization", -- 4 150
"7 Cities/Civilization", -- 5 175
"TXT_KEY_MAP_OPTION_RANDOM" -- 6 ???
},
DefaultValue = 3,
SortPriority = 1
},
----------------------------------------------------------------------------------------------------------------------------------|
----------------------------------------------------------------------------------------------------------------------------------|
-- GetWaterPercent() Custom method: Land Scaling by Number of Cities per Players and City-States
-- Code based on Tyson Guttwein's (ColBashar) variation of my Land Scale by Player Count concept.
-- Use in your own script, just please remember to credit ColBashar and I. Thanks!
----------------------------------------------------------------------------------------------------------------------------------|
function GetWaterPercent()
print("S>-----------------------------------------------------------------------------------|");
print("S>-----Get Water Percentage: START!");
print("S>--------------------------------------------------------------------5.0");
--Declare and initialise variables and constants
local X, Y = Map.GetGridSize();
local major_civ_count = 0;
local minor_civ_count = 0;
local tiles_per_city = 19; -- Constant: This is based on calculation of Firaxis default... I may be off... TODO: Make this user selectable????
local tiles_per_state = 35; -- Constant
local extra_land = 3;
local water_percent = 0;
print("S>-----Land Tiles per Target City/Civ:", tiles_per_city);
print("S>-----Land Tiles City State:", tiles_per_state);
--Collect custom options
local land_scale = Map.GetCustomOption(6); -- YOU WILL NEED THIS CUSTOM OPTION SETUP
local sea_level = Map.GetCustomOption(4); -- sea_level core option
print("S>-----Land Scaling override:", land_scale);
print("S>-----Sea Level override:", sea_level);
--Do randomising and perform other evaluations.
--Cities per Civilization override selection
if land_scale == 6 then -- user chose Random
land_scale = 3 + Map.Rand(5, "S>-----Rolling Land Scale Option:");
print("S>-----Rolled Cities per Civ:", land_scale);
else
land_scale = (land_scale + 2); -- need to bump it up by two, as option values represent 3 to 7 Cities per Civilization
print("S>-----User Cities per Civ:", land_scale);
end
tiles_per_city = math.ceil(tiles_per_city * land_scale); -- tiles per city * option value
--Sea Level override selection
if sea_level == 4 then
sea_level = 1 + Map.Rand(3, "S>-----Random Sea Level");
end
--This is for WorldBuilder compatability --
--Simulate random Civ values coming in from Map Size...
if worldSize == nil then -- if map size is nil, then we are in WB
major_civ_count, minor_civ_count = 2, 4;
local sim_map_size_roll = 1 + Map.Rand(6, "S>-----Roll Map Size Sim");
major_civ_count = major_civ_count * sim_map_size_roll;
minor_civ_count = minor_civ_count * sim_map_size_roll;
end
-- DEBUG
-- major_civ_count, minor_civ_count = 2, 4; -- override random for testing in WB
-- DEBUG
print("S>-----Map Grid Size:", X, "x", Y);
print("S>-----Total Number of Map Plots:", X * Y);
print("S>-----Civs and States:", major_civ_count, minor_civ_count);
print("S>-----Major Civ Land Plots: ", major_civ_count * tiles_per_city);
print("S>-----Minor Civ Land Plots: ", minor_civ_count * tiles_per_state);
--Set the number of land tiles by tiles_per_city by major_civ_count and minor_civ_count
local land_total = math.abs((major_civ_count * tiles_per_city) + (minor_civ_count * tiles_per_state));
print("S>-----Pure Total Land Plots:", land_total);
--Adjust extra_land according to selected Sea Level
if sea_level == 2 then -- Normal: 4-6%
extra_land = 4 + Map.Rand(3, "S>-----Random Normal Extra Land %");
print("S>-----Land increased by: ", extra_land, "%");
elseif sea_level == 1 then -- Low: 7-9%
extra_land = 7 + Map.Rand(3, "S>-----Random More Extra Land %");
print("S>-----Land increased by: ", extra_land, "%");
else -- High: 1-3%
extra_land = 1 + Map.Rand(3, "S>-----Random Less Extra Land %");
print("S>-----Land increased by: ", extra_land, "%");
end
--Increase land total by extra land percentage
extra_land = math.abs((extra_land / 100) + 1.00)
land_total = math.ceil(land_total * extra_land);
print("S>-----Adjusted Total Land Area: ", land_total);
local total_map_plots = (X * Y);
--Collect water percentage for map size.
water_percent = math.abs((total_map_plots - land_total) / total_map_plots * 100);
water_percent = math.floor(water_percent + 0.5)
water_percent = math.clamp(water_percent, 5, 95);
print("S>-----Ocean Percentage for Player Count: ", water_percent);
return water_percent;
end
----------------------------------------------------------------------------------------------------------------------------------|
If you use it, please remember to credit ColBashar and I. Thanks!