2012-08-29 09:20:38 -06:00
|
|
|
-- Communicates current population to mountainhomes to avoid cap overshooting.
|
|
|
|
|
2015-10-23 08:37:39 -06:00
|
|
|
--[[=begin
|
2012-08-29 09:20:38 -06:00
|
|
|
|
2015-10-23 08:37:39 -06:00
|
|
|
fix/population-cap
|
|
|
|
==================
|
|
|
|
Run this after every migrant wave to ensure your population cap is not exceeded.
|
|
|
|
|
|
|
|
The reason for population cap problems is that the population value it
|
|
|
|
is compared against comes from the last dwarven caravan that successfully
|
|
|
|
left for mountainhomes. This script instantly updates it.
|
|
|
|
Note that a migration wave can still overshoot the limit by 1-2 dwarves because
|
|
|
|
of the last migrant bringing his family. Likewise, king arrival ignores cap.
|
|
|
|
|
|
|
|
=end]]
|
2012-08-29 09:20:38 -06:00
|
|
|
local args = {...}
|
|
|
|
|
|
|
|
local ui = df.global.ui
|
|
|
|
local ui_stats = ui.tasks
|
|
|
|
local civ = df.historical_entity.find(ui.civ_id)
|
|
|
|
|
|
|
|
if not civ then
|
|
|
|
qerror('No active fortress.')
|
|
|
|
end
|
|
|
|
|
|
|
|
local civ_stats = civ.activity_stats
|
|
|
|
|
|
|
|
if not civ_stats then
|
|
|
|
if args[1] ~= 'force' then
|
|
|
|
qerror('No caravan report object; use "fix/population-cap force" to create one')
|
|
|
|
end
|
|
|
|
print('Creating an empty statistics structure...')
|
|
|
|
civ.activity_stats = {
|
|
|
|
new = true,
|
|
|
|
created_weapons = { resize = #ui_stats.created_weapons },
|
2014-04-14 11:30:34 -06:00
|
|
|
discovered_creature_foods = { resize = #ui_stats.discovered_creature_foods },
|
|
|
|
discovered_creatures = { resize = #ui_stats.discovered_creatures },
|
|
|
|
discovered_plant_foods = { resize = #ui_stats.discovered_plant_foods },
|
|
|
|
discovered_plants = { resize = #ui_stats.discovered_plants },
|
2012-08-29 09:20:38 -06:00
|
|
|
}
|
|
|
|
civ_stats = civ.activity_stats
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Use max to keep at least some of the original caravan communication idea
|
|
|
|
civ_stats.population = math.max(civ_stats.population, ui_stats.population)
|
|
|
|
|
|
|
|
print('Home civ notified about current population.')
|