Population Cap
Maximum population capacity
Changing maximum population capacity can be done through both script and tuning packs.
Always check the for full related functionality.
Here are some examples of the more relevant functions:Player_SetPopCapOverride(World_GetPlayerAt(1), 250)
Player_SetMaxPopulation(World_GetPlayerAt(1), CT_Personnel, 250)
To change the maximum population using a tuning pack load a tuning pack mod and navigate to army attribute editor. You will have to clone every separate civ file you want to modify.
In cloned files, go to army_bag/race_population_cap_table and army_bag/resource_max_cap. Some of the values you'll see there might be left over from previous Essence Engine games, however we will modify them anyway. Adjust base_vehicle_cap, max_personnel_cap, max_vehicle_cap and popcap values. Now you can proceed to test your mod.
Modifying house-granted popcap
Unfortunately there is no currently known way to modify house-granted popcap through tuning packs. This is because state model fields and attribute groups are not modifiable. However, it is possible to achieve the desired effect through script.
Here is an example implementation which increases default house-granted population by 15. Note that Mod_OnGameSetup is a default function that you might already be using in your mod!
local houseModifiers = {}
function HouseDestroyedListener(context)
local modifier = houseModifiers[#houseModifiers]
if modifier then
Modifier_Remove(modifier)
houseModifiers[#houseModifiers] = nil
end
end
function ConstructionCompleteListener(context)
if Entity_IsOfType(context.entity, "house") then
houseModifiers[#houseModifiers + 1] = Modify_PlayerPopCap(context.player, 15, MUT_Addition)
Rule_AddEntityEvent(HouseDestroyedListener, context.entity, GE_EntityKilled)
end
end
-- Called during load as part of the game setup sequence
function Mod_OnGameSetup()
for i=1,World_GetPlayerCount() do
local p = World_GetPlayerAt(i)
Rule_RemovePlayerEvent(ConstructionCompleteListener, p)
Rule_AddPlayerEvent(ConstructionCompleteListener, p, GE_ConstructionComplete)
end
end