[SOLVED] Limiting cities to X popultion

Joined
Mar 12, 2019
Messages
100
I'm trying to create a mod which limits the population in the players cities to a set amount, lets just say 4. I've thought a bit about how to implement this and I believe that one solution is to set the city growth rate to -500% or so when the city hits four population. However, I would only like this penalty to apply to the human's cities not the AIs.

Doing some research I have found the following modifier which looks promising:

MODIFIER_ALL_CITIES_ADJUST_CITY_GROWTH
MODIFIER_PLAYER_CITIES_ADJUST_CITY_GROWTH

I assume that the PLAYER is the human and will not be applied to the AI? Is that correct? How can I put a hook into the code for it to apply with cities that have 4 or more population? Is there another mod that already does this? Thanks!
 
PLAYER in the names of modifiers refers to any player taking part in the game -- human, AI major civ, city states, the free cities "civilization", and barbarians.

Your ModifierId in table Modifiers would need a RequirementSet (a SubjectSetRequirmentId most likely in this case) which contains the logic for when the effects of the modifier are to be applied. RequirementSets are made up of individual Requirements. There is already an individual requirement available that specifies a modifier is only to be applied to a Human player -- REQUIREMENT_PLAYER_IS_HUMAN. But you would need additional requirements attached to the Set of Requirements that specifies the effect should only be applied to cities with at least four population. REQUIREMENT_CITY_HAS_X_POPULATION is already available for this -- you would need to supply the population amount needed as a RequirementArgument.

In order to implement this you will need to learn more about how Modifiers, RequirementSets, and Requirements work. Everybody who mods Civ6 had to learn this at one point or another, so it isn't actually like saying you need to learn how to read ancient chinese as written in sandskrit. It only seems that way at first.
 
Thanks for the feedback! Here is the current version of the code that doesn't work and I am not sure why. Does it have something to do with me playing with all of the expansions or are there some errors in the code? I currently have the load order set to 999.

Code:
INSERT INTO RequirementSets (RequirementSetId, RequirementSetType)
    VALUES
        ('PLAYER_IS_HUMAN_GROWTH_CHANGE', 'REQUIREMENTSET_TEST_ALL');

INSERT INTO RequirementSetRequirements (RequirementSetId, RequirementId)
    VALUES
        ('PLAYER_IS_HUMAN_GROWTH_CHANGE', 'REQUIRES_PLAYER_IS_HUMAN');

INSERT INTO RequirementArguments (RequirementSetId, Name, Value)
    VALUES
        ('PLAYER_IS_HUMAN_GROWTH_CHANGE', 'REQUIREMENT_CITY_HAS_X_POPULATION', 2);

INSERT INTO DynamicModifiers (ModifierType, CollectionType, EffectType)
    VALUES
        ('DYN_HUMAN_GROWTH_CHANGE', 'COLLECTION_PLAYER_CITIES', 'EFFECT_ADJUST_CITY_GROWTH');

INSERT INTO Modifiers (ModifierId, ModifierType, SubjectStackLimit, OwnerStackLimit, RunOnce, Permanent, SubjectRequirementSetId)
    VALUES
        ('PLAYER_IS_HUMAN_GROWTH_CHANGE', 'DYN_HUMAN_GROWTH_CHANGE',  0,0,0,0,NULL);

INSERT INTO ModifierArguments (ModifierId, Name, Value)
    VALUES
        ('PLAYER_IS_HUMAN_GROWTH_CHANGE', 'Amount', -100);
 
I've made some progress! Now I am just having issues for the mod to work with cities greater than or equal to two population. I am not able to get: REQUIREMENT_CITY_HAS_X_POPULATION to work. Here is the current code with the offending section commented out.


Code:
INSERT INTO RequirementSets (RequirementSetId, RequirementSetType)
    VALUES
        ('PLAYER_IS_HUMAN_GROWTH_CHANGE', 'REQUIREMENTSET_TEST_ALL');

INSERT INTO RequirementSetRequirements (RequirementSetId, RequirementId)
    VALUES
        ('PLAYER_IS_HUMAN_GROWTH_CHANGE', 'REQUIRES_PLAYER_IS_HUMAN');

---INSERT INTO RequirementArguments (RequirementSetId, Name, Value)
---    VALUES
---        ('PLAYER_IS_HUMAN_GROWTH_CHANGE', 'REQUIREMENT_CITY_HAS_X_POPULATION', '2');

INSERT INTO TraitModifiers (TraitType, ModifierId)
    VALUES
        ('TRAIT_LEADER_MAJOR_CIV', 'TRAIT_NERF_HUMAN_GROWTH');

INSERT INTO Modifiers (ModifierId, ModifierType, OwnerRequirementSetId)
    VALUES
        ('TRAIT_NERF_HUMAN_GROWTH', 'MODIFIER_PLAYER_CITIES_ADJUST_CITY_GROWTH', 'PLAYER_IS_HUMAN_GROWTH_CHANGE');


INSERT INTO ModifierArguments (ModifierId, Name, Value)
    VALUES
        ('TRAIT_NERF_HUMAN_GROWTH', 'Amount', '50');

Any help would be appreciated!
 
Last edited:
I got it to work! I basically ended up looking at how the rationalism policy is implemented in the Expansion1_Policies.xml file since it has two requirements for the card to work. Here is the working code, I'll release the mod on steam in a few days and it'll probably be called 4 max pop or something probably better.

I also changed a lot of the ModifierId's to make sure that they don't conflict with anything, even though I don't know if that matters. But if you want to write a mod that needs two (or more) requirements this should help you out!

Code:
INSERT INTO TraitModifiers (TraitType, ModifierId)
    VALUES
        ('TRAIT_LEADER_MAJOR_CIV', 'OTTER_NERF_HUMAN_GROWTH');


INSERT INTO Modifiers (ModifierId, ModifierType, SubjectRequirementSetId)
    VALUES
        ('OTTER_NERF_HUMAN_GROWTH', 'MODIFIER_PLAYER_CITIES_ADJUST_CITY_GROWTH', 'OTTER_PLAYER_IS_HUMAN_GROWTH_CHANGE');


INSERT INTO RequirementSets (RequirementSetId, RequirementSetType)
    VALUES
        ('OTTER_PLAYER_IS_HUMAN_GROWTH_CHANGE', 'REQUIREMENTSET_TEST_ALL');


INSERT INTO RequirementSetRequirements (RequirementSetId, RequirementId)
    VALUES
        ('OTTER_PLAYER_IS_HUMAN_GROWTH_CHANGE', 'REQUIRES_PLAYER_IS_HUMAN'),
        ('OTTER_PLAYER_IS_HUMAN_GROWTH_CHANGE', 'OTTER_REQUIRES_CITY_HAS_HIGH_POPULATION');


INSERT INTO Requirements (RequirementId, RequirementType)
    VALUES
        ('OTTER_REQUIRES_CITY_HAS_HIGH_POPULATION', 'REQUIREMENT_CITY_HAS_X_POPULATION');


INSERT INTO RequirementArguments(RequirementId, Name, Value)
    VALUES
        ('OTTER_REQUIRES_CITY_HAS_HIGH_POPULATION', 'Amount', '4');


INSERT INTO ModifierArguments (ModifierId, Name, Value)
    VALUES
        ('OTTER_NERF_HUMAN_GROWTH', 'Amount', '-100');
 
Back
Top Bottom