Requirement not re-evaluating when city lost

Amugaba

Chieftain
Joined
Nov 6, 2021
Messages
1
I'm trying to add modifiers based on the number of cities a player has. This works correctly when gaining cities (as shown in game and in FireTuner):
  • At 1 city, only the Requirement for having 1 city is marked as Met, and only the Modifier for having 1 city is applied.
  • At 2 cities, the 1-city and 2-city Requirements are met, and both of their Modifiers are applied.
However, when I test losing a city by trading it to the AI, the 2-city Requirement is still marked as met and the Modifier for 2 cities is still applied, even though I only have one city.

For the modifiers, both RunOnce and Permanent are false (confirmed by FireTuner).

Here is the requirements code:
Code:
-------------------------------------
-- Requirements
-------------------------------------
INSERT INTO Requirements (RequirementId, RequirementType) VALUES
('ZZ_REQUIRE_1_CITY', 'REQUIREMENT_PLAYER_HAS_AT_LEAST_NUMBER_CITIES'),
('ZZ_REQUIRE_2_CITY', 'REQUIREMENT_PLAYER_HAS_AT_LEAST_NUMBER_CITIES');

-------------------------------------
-- RequirementArguments
-------------------------------------
INSERT INTO RequirementArguments (RequirementId, Name, Value) VALUES
('ZZ_REQUIRE_1_CITY', 'Amount', 1),
('ZZ_REQUIRE_2_CITY', 'Amount', 2);
    
-------------------------------------
-- RequirementSets
-------------------------------------
INSERT INTO RequirementSets (RequirementSetId, RequirementSetType) VALUES
('ZZ_REQSET_1_CITY', 'REQUIREMENTSET_TEST_ALL'),
('ZZ_REQSET_2_CITY', 'REQUIREMENTSET_TEST_ALL');

-------------------------------------
-- RequirementSetRequirements
-------------------------------------
INSERT INTO RequirementSetRequirements (RequirementSetId, RequirementId) VALUES
('ZZ_REQSET_1_CITY', 'ZZ_REQUIRE_1_CITY'),
('ZZ_REQSET_2_CITY', 'ZZ_REQUIRE_2_CITY');

I believe the issue is with the Requirement still being marked as Met even when I have fewer cities. Is this just an issue with REQUIREMENT_PLAYER_HAS_AT_LEAST_NUMBER_CITIES? Like perhaps the game logic looks at the most cities you've ever had rather than your current number? If so, is there another way I can track number of cities?

Here's the Modifier code if that helps. I've tried adding the modifier two different ways (as TraitModifier or DistrictModifier), but they both behave the same.
Code:
-------------------------------------
-- Modifiers for Trait
-------------------------------------
INSERT INTO Modifiers (ModifierId, ModifierType, OwnerRequirementSetId) VALUES
('ZZ_MODIFIER_TRAIT_1_CITY_PROD', 'MODIFIER_PLAYER_CITIES_ADJUST_CITY_YIELD_MODIFIER', 'ZZ_REQSET_1_CITY'),
('ZZ_MODIFIER_TRAIT_2_CITY_PROD', 'MODIFIER_PLAYER_CITIES_ADJUST_CITY_YIELD_MODIFIER', 'ZZ_REQSET_2_CITY');
    
-------------------------------------
-- ModifierArguments
-------------------------------------
INSERT INTO ModifierArguments (ModifierId, Name, Value) VALUES
('ZZ_MODIFIER_TRAIT_1_CITY_PROD', 'YieldType', 'YIELD_PRODUCTION'),
('ZZ_MODIFIER_TRAIT_2_CITY_PROD', 'YieldType', 'YIELD_PRODUCTION');

INSERT INTO ModifierArguments (ModifierId, Name, Value) VALUES
('ZZ_MODIFIER_TRAIT_1_CITY_PROD', 'Amount', +5),
('ZZ_MODIFIER_TRAIT_2_CITY_PROD', 'Amount', +10);

-------------------------------------
-- TraitModifiers
-------------------------------------
INSERT INTO TraitModifiers (TraitType, ModifierId) VALUES
('TRAIT_LEADER_MAJOR_CIV', 'ZZ_MODIFIER_TRAIT_1_CITY_PROD'),
('TRAIT_LEADER_MAJOR_CIV', 'ZZ_MODIFIER_TRAIT_2_CITY_PROD');
 
Many Modifiers and Requirements have similar Issues to this, like some Requirements that check for the owner in "OwnerRequirementSetId" AND "SubjectRequirementSetId" (not the Subject). This is due to the Hardcoded Effects and Requirements that might have only been coded for the Purpose they are made for, so the Devs might not have checked for these kind of Issues that might arise, since it's beyond what they have intended the Effects/Requirements for.

Though, you can use lua to achieve the same Goal by using PlotProperties, you can use my Real Allies Mod as reference.
 
Top Bottom