Commit 87e5af69 authored by Max Maton's avatar Max Maton

Version 3

- Water tiles are no longer considered when finding a building to remove.
- Removal is now random instead of deterministic.
- Added option to bias building removal to spherical towns. (makes towns smaller instead of ghost towns)
- Fixed bug that would make the script ignore towns without industry when finding a building to remove.
parent 780438d3
Pipeline #93798916 passed with stage
in 1 minute and 25 seconds
import("pathfinder.road", "RoadPathFinder", 4);
class EconomyManager {
constructor(queueFunc, _gridSize, _minPopularity, _populationMultiplier) {
constructor(queueFunc, _gridSize, _minPopularity, _populationMultiplier, _radialTownShrinking) {
enqueueAction = queueFunc;
gridSize = _gridSize;
minPopularity = _minPopularity;
populationMultiplier = _populationMultiplier;
radialTownShrinking = _radialTownShrinking;
}
enqueueAction = false;
......@@ -19,6 +20,7 @@ class EconomyManager {
minPopularity = 3000;
populationMultiplier = 10;
reservePopulation = 0;
radialTownShrinking = false;
function Initialize() {
if (isInitialized)
......@@ -157,9 +159,6 @@ class EconomyManager {
gridTowns[grid] <- [];
gridTowns[grid].append(townId);
if (productivity == 0)
continue;
if (!gridPopularity.rawin(grid))
gridPopularity[grid] <- 0;
gridPopularity[grid] += productivity;
......@@ -287,6 +286,17 @@ class EconomyManager {
tiles.KeepValue(0);
tiles.Valuate(_isIndustry);
tiles.KeepValue(0);
tiles.Valuate(GSTile.IsWaterTile);
tiles.KeepValue(0);
if (radialTownShrinking) {
local valuator = function (t, townPos) {
return GSBase.RandRange(100) * GSTile.GetDistanceSquareToTile(t, townPos);
};
tiles.Valuate(valuator, townPos);
} else {
tiles.Valuate(GSBase.RandRangeItem, 100);
}
tiles.Sort(GSList.SORT_BY_VALUE, GSList.SORT_DESCENDING);
foreach(tileId, _ in tiles) {
local result = GSTile.DemolishTile(tileId);
......
......@@ -3,7 +3,7 @@ class MigrationScriptInfo extends GSInfo {
function GetName() { return "Migrations"; }
function GetShortName() { return "MIGR"; }
function GetDescription() { return "Town migrations"; }
function GetVersion() { return 2; }
function GetVersion() { return 3; }
function MinVersionToLoad() { return 1; }
function GetDate() { return "2018-09-13"; }
function UseAsRandomAI() { return true; }
......@@ -17,6 +17,8 @@ class MigrationScriptInfo extends GSInfo {
AddSetting({name = "city_creation_floor", description = "How hard it is for a new town to start.", easy_value = 3000, medium_value = 5000, hard_value = 7000, custom_value = 3000, flags = 0, min_value = 100, max_value = 10000});
AddSetting({name = "population_modifier", description = "How quickly a town grows once created.", easy_value = 10, medium_value = 8, hard_value = 5, custom_value = 10, flags = 0, min_value = 1, max_value = 100});
AddSetting({name = "grid_size", description = "Size of industry regions. (higher is faster but results in fewer towns)", easy_value = 32, medium_value = 32, hard_value = 32, custom_value = 32, flags = 0, min_value = 16, max_value = 256});
AddSetting({name = "radial_town_shrinking", description = "Reduce towns from edges out?", easy_value = 0, medium_value = 0, hard_value = 0, custom_value = 0, flags = 0, min_value = 0, max_value = 1});
AddLabels("radial_town_shrinking", {_0 = "0: Off (produces ghost towns)", _1 = "1: On (produces round, smaller towns)"});
}
}
......
......@@ -8,7 +8,8 @@ class MigrationScript extends GSController {
local _gridSize = MigrationScript.GetSetting("grid_size");
local _minPopularity = MigrationScript.GetSetting("city_creation_floor");
local _populationMultiplier = MigrationScript.GetSetting("population_modifier");
economyManager = EconomyManager(this.QueueAction.bindenv(this), _gridSize, _minPopularity, _populationMultiplier);
local _radialTownShrinking = MigrationScript.GetSetting("radial_town_shrinking");
economyManager = EconomyManager(this.QueueAction.bindenv(this), _gridSize, _minPopularity, _populationMultiplier, _radialTownShrinking);
}
function Start();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment