Would like to change house pop from 10 to 20, cant find it in the editor. Thank you!
1 Like
Not sure if it can be changed in the editor, but I think you might be able to have a “on building constructed/destroyed” function to dynamically add the extra 10 population.
1 Like
you cannot change that pop values of normal houses are giving. Only thing you can do is to turn a empty asset from campaign and assign the features of Chinese special house along with improving the house build restriction limit, so you can build less house to increase the population amount much easier.
Check my Conquest Mod thread, somewhere I had mentioned how to do it as one of tutorial while explaining it to another new modder.
1 Like
Momento’s solution is probably better, but out of curiosity I tried implementing it with a script, and came up with this:
function Mod_OnInit()
Rule_AddGlobalEvent(Mod_OnConstructionComplete, GE_ConstructionComplete)
Rule_AddGlobalEvent(Mod_OnBuildingDestroyed, GE_EntityKilled)
end
function Mod_OnConstructionComplete(context)
-- Store the player who constructed the building
local builder = Core_GetPlayersTableEntry(context.player)
if Entity_IsEBPOfType(context.pbg, "house") then
--mod.housing_pop_rate can either be set in the settings for the mode, or a static value
Player_SetMaxPopulation(builder.id, CT_Personnel, Player_GetCurrentPopulationCap(builder.id, CT_Personnel) + (10 * _mod.housing_pop_rate))
end
end
end
function Mod_OnBuildingDestroyed(context)
if context.victimOwner == nil or context.victimOwner.PlayerID == nil then
return
end
local victimOwner = get_player_by_id(context.victimOwner.PlayerID)
-- Check to see if the victim is a legitimate player, not done by a script, and they're still in the game
if victimOwner ~= nil and not victimOwner.isEliminated then
if Entity_IsEBPOfType(Entity_GetBlueprint(context.victim), "house") then
Player_SetMaxPopulation(victimOwner.id, CT_Personnel, Player_GetCurrentPopulationCap(victimOwner.id, CT_Personnel) - (10 * _mod.housing_pop_rate))
end
end
end
function get_player_by_id(id)
for i, player in pairs(PLAYERS) do
if player.id['PlayerID'] == id then
return player
end
end
end
2 Likes