• We are currently performing site maintenance, parts of civfanatics are currently offline, but will come back online in the coming days. For more updates please see here.

[Basics] Problem about requirement sets

sunny19879394

Chieftain
Joined
Dec 11, 2019
Messages
29
Basically I think I may have conceptual problem for how requirement sets works..

I am basically making the mod base on Keniisu's template so all things for requirements are copied from his mod, but strangely if I define the requirement SetID, Requirement Set type, and Requirement ID, it never works.

Below is an example:

Code:
-- RequirementSets

-- This is where you define your Requirement Set
-----------------------------------------------

INSERT INTO RequirementSets
        (RequirementSetId,                        RequirementSetType            )
VALUES    ('REQSET_SUNNY_HONGKONG_UA_CITY_HAS_X_POPULATION',    'REQUIREMENTSET_SUNNY_HONGKONG_UA_CITY_HAS_X_POPULATION'    ); -- Defines the ReqSet.

        -----------------------------------------------
-- RequirementSetRequirements

-- This is where you link your RequirementSet to your actual RequirementIDs
-----------------------------------------------

INSERT INTO RequirementSetRequirements
        (RequirementSetId,                        RequirementId                        )
VALUES    ('REQSET_SUNNY_HONGKONG_UA_CITY_HAS_X_POPULATION',    'REQ_SUNNY_HONGKONG_UA_CITY_HAS_X_POPULATION'    ); -- Defines the ReqSet by linking it to a RequirmentID

-----------------------------------------------
-- Requirements

-- This is where you define your Requirements
-----------------------------------------------

INSERT INTO Requirements
        (RequirementId,                            RequirementType,    Likeliness,   Inverse,   Triggered)
VALUES    ('REQ_SUNNY_HONGKONG_UA_CITY_HAS_X_POPULATION',    'REQUIREMENT_CITY_HAS_X_POPULATION',    0,  0,  0        ); -- Defines the Requirement as whenever your on the pop

-------------------------------------
-- RequirementArguments
-------------------------------------
INSERT INTO RequirementArguments
        (RequirementId,                                         Name,                        Value)
VALUES    ('REQ_SUNNY_HONGKONG_UA_CITY_HAS_X_POPULATION',                 'Amount',                5);

It just does not have effect. Similar, when I try to make a requirement for sth happen after a civic is reached, it does not work.

However, if I use the existing ID, like this time, i use "REQUIRES_PLAYER_HAS_WRITING", it works:

Code:
        -----------------------------------------------
-- RequirementSets

-- This is where you define your Requirement Set
-----------------------------------------------

INSERT INTO RequirementSets
        (RequirementSetId,                        RequirementSetType            )
VALUES    ('REQESET_SUNNY_HONGKONG_UA_HASWRT',    'REQUIREMENTSET_TEST_ALL'    ); -- Defines the ReqSet.

-----------------------------------------------
-- RequirementSetRequirements

-- This is where you link your RequirementSet to your actual RequirementIDs
-----------------------------------------------

INSERT INTO RequirementSetRequirements
        (RequirementSetId,                        RequirementId                        )
VALUES    ('REQESET_SUNNY_HONGKONG_UA_HASWRT',    'REQUIRES_PLAYER_HAS_WRITING'    ); -- Defines the ReqSet by linking it to a RequirmentID

So I wonder is it is some kind of conceptual problem......And this time, when I define a reqSet and use an existing ID 'UNIT_IN_ENEMY_TERRITORY_REQUIREMENT' , it does not work again (Sorry the code has a lot of other effects...but the one in concern is 'MODTYPE_SUNNY_HONGKONG_UA_CANNOTATTACK'. It works when I did not add any requirements.)

Code:
----------------------------------------------
-- Types
-----------------------------------------------

INSERT INTO    Types
        (Type,                                            Kind            )
VALUES    ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',            'KIND_TRAIT'    ),
        ('MODTYPE_SUNNY_HONGKONG_UA_EXTRA POPULATION',    'KIND_MODIFIER'    ),
        ('MODTYPE_SUNNY_HONGKONG_UA_BAN_SETTLER',    'KIND_MODIFIER'    ),
        ('MODTYPE_SUNNY_HONGKONG_UA_FAITHBYWAR',    'KIND_MODIFIER'    ),
        ('MODTYPE_SUNNY_HONGKONG_UA_EXTRAROUTE',    'KIND_MODIFIER'    ),
        ('MODTYPE_SUNNY_HONGKONG_UA_EXTRAFAVOR',    'KIND_MODIFIER'    ),
        ('MODTYPE_SUNNY_HONGKONG_UA_CANNOTATTACK',    'KIND_MODIFIER'    );

-----------------------------------------------
-- Traits
-----------------------------------------------

INSERT INTO    Traits
        (TraitType,                                Name,                                            Description                                            )
VALUES    ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'LOC_TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA_NAME',    'LOC_TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA_DESCRIPTION'    );
      
-----------------------------------------------
-- CivilizationTraits
-----------------------------------------------

INSERT INTO    CivilizationTraits
        (CivilizationType,                TraitType                            )
VALUES    ('CIVILIZATION_SUNNY_HONGKONG',    'TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA'    );

-----------------------------------------------
-- TraitModifiers
-----------------------------------------------

INSERT INTO    TraitModifiers   
        (TraitType,                                ModifierId                                        )
VALUES    ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_TRADE_GOLD'    ),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_TRADE_PRODUCTION'    ),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_TRADE_FOOD'    ),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_GAIN_GOLD'    ),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_GAIN_SC'    ),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_GAIN_CL'    ),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_OTHERGOLD'    ),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_POPULATION_PRESETTLEMENT'),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_BAN_SETTLER'),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_FAITHBYWAR'    ),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_EXTRAROUTE'    ),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_EXTRAFAVOR'    ),
        ('TRAIT_CIVILIZATION_SUNNY_HONGKONG_UA',    'MODIFIER_SUNNY_HONGKONG_UA_CANNOTATTACK'    );

----------------------------------------------
-- DynamicModifiers
-----------------------------------------------

INSERT INTO    DynamicModifiers
        (ModifierType,                                    CollectionType,                    EffectType                                        )
VALUES    ('MODTYPE_SUNNY_HONGKONG_UA_EXTRA POPULATION',    'COLLECTION_PLAYER_CITIES',        'EFFECT_ADJUST_CITY_POPULATION'            ),
        ('MODTYPE_SUNNY_HONGKONG_UA_BAN_SETTLER',    'COLLECTION_OWNER_PLAYER',        'EFFECT_ADJUST_PLAYER_UNIT_BUILD_DISABLED'            ),
        ('MODTYPE_SUNNY_HONGKONG_UA_FAITHBYWAR',    'COLLECTION_PLAYER_COMBAT',        'EFFECT_ADJUST_UNIT_POST_COMBAT_YIELD'            ),
        ('MODTYPE_SUNNY_HONGKONG_UA_EXTRAROUTE',    'COLLECTION_OWNER',        'EFFECT_ADJUST_TRADE_ROUTE_CAPACITY'            ),
        ('MODTYPE_SUNNY_HONGKONG_UA_EXTRAFAVOR',    'COLLECTION_OWNER_PLAYER',        'EFFECT_ADJUST_PLAYER_EXTRA_FAVOR_PER_TURN'            ),
        ('MODTYPE_SUNNY_HONGKONG_UA_CANNOTATTACK',    'COLLECTION_PLAYER_UNITS',        'EFFECT_ADJUST_UNIT_CANNOT_ATTACK');

----------------------------------------------
-- Modifiers
-----------------------------------------------

INSERT INTO    Modifiers
        (ModifierId,                                        ModifierType,                                    OwnerRequirementSetId,                SubjectRequirementSetId,            RunOnce,    Permanent    )
VALUES       ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_GOLD',                'MODIFIER_PLAYER_ADJUST_TRADE_ROUTE_YIELD_FOR_INTERNATIONAL',    NULL,        NULL,                                0,            1   ),
             ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_PRODUCTION',                'MODIFIER_PLAYER_ADJUST_TRADE_ROUTE_YIELD_FOR_INTERNATIONAL',    NULL,        NULL,                                0,            1   ),
             ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_FOOD',                'MODIFIER_PLAYER_ADJUST_TRADE_ROUTE_YIELD_FOR_INTERNATIONAL',    NULL,        NULL,                                0,            1   ),
             ('MODIFIER_SUNNY_HONGKONG_UA_GAIN_GOLD',                'MODIFIER_PLAYER_CITIES_ADJUST_TRADE_ROUTE_YIELD_FROM_OTHERS',    NULL,        NULL,                                0,            1   ),
             ('MODIFIER_SUNNY_HONGKONG_UA_GAIN_SC',                'MODIFIER_PLAYER_CITIES_ADJUST_TRADE_ROUTE_YIELD_FROM_OTHERS',    NULL,        NULL,                                0,            1   ),
             ('MODIFIER_SUNNY_HONGKONG_UA_GAIN_CL',                'MODIFIER_PLAYER_CITIES_ADJUST_TRADE_ROUTE_YIELD_FROM_OTHERS',    NULL,        NULL,                                0,            1   ),
             ('MODIFIER_SUNNY_HONGKONG_UA_OTHERGOLD',                'MODIFIER_PLAYER_CITIES_ADJUST_TRADE_ROUTE_YIELD_TO_OTHERS',    NULL,        NULL,                                0,            1   ),
             ('MODIFIER_SUNNY_HONGKONG_UA_POPULATION_PRESETTLEMENT',        'MODTYPE_SUNNY_HONGKONG_UA_EXTRA POPULATION',    NULL,        NULL,                                0,            1            ),
             ('MODIFIER_SUNNY_HONGKONG_UA_BAN_SETTLER',        'MODTYPE_SUNNY_HONGKONG_UA_BAN_SETTLER',    NULL,        NULL,                                0,            1            ),
             ('MODIFIER_SUNNY_HONGKONG_UA_FAITHBYWAR',        'MODTYPE_SUNNY_HONGKONG_UA_FAITHBYWAR',    NULL,        NULL,                                0,            1    ),
             ('MODIFIER_SUNNY_HONGKONG_UA_EXTRAROUTE',        'MODTYPE_SUNNY_HONGKONG_UA_EXTRAROUTE',    NULL,        NULL,                                0,            1            ),
             ('MODIFIER_SUNNY_HONGKONG_UA_EXTRAFAVOR',        'MODTYPE_SUNNY_HONGKONG_UA_EXTRAFAVOR',    NULL,        NULL,                                0,            1    ),
             ('MODIFIER_SUNNY_HONGKONG_UA_CANNOTATTACK',        'MODTYPE_SUNNY_HONGKONG_UA_CANNOTATTACK',    NULL,        'REQSET_SUNNY_HONGKONG_ENEMYLAND',                                0,            0    );


    -----------------------------------------------
-- ModifierArguments
-----------------------------------------------

INSERT INTO    ModifierArguments
        (ModifierId,                                            Name,                            Value                                    )
VALUES     ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_GOLD',            'Amount',                        2                          ),
        ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_GOLD',            'YieldType',                    'YIELD_GOLD'                        ),
        ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_GOLD',            'Intercontinental',                   0                      ),
---------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_PRODUCTION',            'Amount',                        2                           ),
        ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_PRODUCTION',            'YieldType',                    'YIELD_PRODUCTION'                        ),
        ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_PRODUCTION',            'Intercontinental',                   0                      ),
---------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_FOOD',            'Amount',                        2                           ),
        ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_FOOD',            'YieldType',                    'YIELD_FOOD'                        ),
        ('MODIFIER_SUNNY_HONGKONG_UA_TRADE_FOOD',            'Intercontinental',                   0                      ),
---------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_GAIN_GOLD',            'Amount',                        2                           ),
        ('MODIFIER_SUNNY_HONGKONG_UA_GAIN_GOLD',            'YieldType',                    'YIELD_GOLD'                        ),
---------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_GAIN_SC',            'Amount',                        1                           ),
        ('MODIFIER_SUNNY_HONGKONG_UA_GAIN_SC',            'YieldType',                    'YIELD_SCIENCE'                        ),
---------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_GAIN_CL',            'Amount',                        1                           ),
        ('MODIFIER_SUNNY_HONGKONG_UA_GAIN_CL',            'YieldType',                    'YIELD_CULTURE'                        ),
---------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_OTHERGOLD',            'Amount',                        4                           ),
        ('MODIFIER_SUNNY_HONGKONG_UA_OTHERGOLD',            'YieldType',                    'YIELD_GOLD'                        ),
---------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_POPULATION_PRESETTLEMENT',            'Amount',                        2                                    ),
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_BAN_SETTLER',            'UnitType',                        'UNIT_SETTLER'                                ),
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_EXTRAROUTE',            'Amount',                        20                            ),
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_FAITHBYWAR',            'YieldType',                        'YIELD_FAITH'                                ),
        ('MODIFIER_SUNNY_HONGKONG_UA_FAITHBYWAR',            'PercentDefeatedStrength',                        100                            ),
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_EXTRAFAVOR',            'Amount',                        1                            ),
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
        ('MODIFIER_SUNNY_HONGKONG_UA_CANNOTATTACK',            'Disable',                        1                            );

        -----------------------------------------------
-- RequirementSets

-- This is where you define your Requirement Set
-----------------------------------------------

INSERT INTO RequirementSets
        (RequirementSetId,                        RequirementSetType            )
VALUES    ('REQSET_SUNNY_HONGKONG_ENEMYLAND',    'REQUIREMENTSET_TEST_ANY'    ); -- Defines the ReqSet.

-----------------------------------------------
-- RequirementSetRequirements

-- This is where you link your RequirementSet to your actual RequirementIDs
-----------------------------------------------

INSERT INTO RequirementSetRequirements
        (RequirementSetId,                        RequirementId                        )
VALUES    ('REQSET_SUNNY_HONGKONG_ENEMYLAND',    'UNIT_IN_ENEMY_TERRITORY_REQUIREMENT'    ); -- Defines the ReqSet by linking it to a RequirmentID

Gameeffects.log is also posted. Also is there any tutorial about requirements set to read?
 

Attachments

So I wonder is it is some kind of conceptual problem......And this time, when I define a reqSet and use an existing ID 'UNIT_IN_ENEMY_TERRITORY_REQUIREMENT' , it does not work again (Sorry the code has a lot of other effects...but the one in concern is 'MODTYPE_SUNNY_HONGKONG_UA_CANNOTATTACK'. It works when I did not add any requirements.)
Yes. The effect-type is not expecting any requirements, or requirement arguments. It is an inherent "ability" attached permanently to the unit:
Code:
DynamicModifiers
ModifierType					CollectionType		EffectType
MODIFIER_PLAYER_UNIT_ADJUST_CANNOT_ATTACK	COLLECTION_OWNER	EFFECT_ADJUST_UNIT_CANNOT_ATTACK

Modifiers
ModifierId	ModifierType					RunOnce		NewOnly	Permanent	OwnerRequirementSetId	SubjectRequirementSetId	OwnerStackLimit	SubjectStackLimit
CANNOT_ATTACK	MODIFIER_PLAYER_UNIT_ADJUST_CANNOT_ATTACK	0		0		0				

UnitAbilityModifiers
UnitAbilityType				ModifierId
ABILITY_RELIGIOUS_CANNOT_ATTACK		CANNOT_ATTACK

UnitAbilities
UnitAbilityType				Name						Description						Inactive	ShowFloatTextWhenEarned
ABILITY_RELIGIOUS_CANNOT_ATTACK		LOC_ABILITY_RELIGIOUS_CANNOT_ATTACK_NAME	LOC_ABILITY_RELIGIOUS_CANNOT_ATTACK_DESCRIPTION		0			0

TypeTags
Type					Tag
ABILITY_RELIGIOUS_CANNOT_ATTACK		CLASS_MISSIONARY
UNIT_MISSIONARY				CLASS_MISSIONARY
UNIT_GURU				CLASS_MISSIONARY
ABILITY_MARTYR				CLASS_MISSIONARY
You cannot make up your own RequirementSetType:
Code:
INSERT INTO RequirementSets
        (RequirementSetId,                        RequirementSetType            )
VALUES    ('REQSET_SUNNY_HONGKONG_UA_CITY_HAS_X_POPULATION',    'REQUIREMENTSET_SUNNY_HONGKONG_UA_CITY_HAS_X_POPULATION'    ); -- Defines the ReqSet.
You can only use the ones provided by Firaxis for the "test" method:
Code:
GameEffects:
Type				CommonName	Description
REQUIREMENTSET_TEST_ALL		Test All	This requirement set is met if *all* of the inner requirements are met.
REQUIREMENTSET_TEST_ANY		Test Any	This requirement set is met if *any* of the inner requirements are met.
 
Last edited:
IC. So

1. If the effect-type is not expecting any requirements, or requirement arguments in the original game, I basically cannot impose any requirements? Is it that I need to find out how the original game uses the effect to check? Is there any tricks to do so if I want the effect type but to impose any requirements?

2.Is that any ways to link up requirement and effect that have different collections? for example, To do like "when populatiion reaches 10" -> "get one more favor points" as the requirement "when population reaches 10" is with collection "city" and "get one more favor points" is with collection "player".

3. ->.You cannot make up your own RequirementSetType:...Will try to correct and see, thank you very much.
 
Thank you very much, I successfully made extra trade route after getting tech_pottery.

What I wonder is still if it is possible to link up effect and requirements with different collections.
 
You can make your own DynamicModifier and use CollectionType and EdffectType combinations that Firaxis did not use, but when you do so you have to be prepared for the EffectType to not work properly with the CollectionType you specify, or that it might ignore anything you establish as RequirementSets in the Modifier. If you only see that Firaxis ever used a specific EffectType in a certain way its a fair bet that it will not work in any other. The EFFECT_ADJUST_UNIT_CANNOT_ATTACK is a good example of where you can experiment with adding RequirementSets but you must be ready for it not to pay any attention to them, since the original use of the EffectType by Firaxis was a one-use-only deal and in that case the Effect was permanent to the unit rather than something that was dynamically being added or removed as Requirements were met or not met.

As far as #2 goes, the result of what you do must at least make logical sense. In many cases the key is to use a series of linked modifiers. In other words Modifier_A can grant Modifier_B, and the requirements of Modifier_A to grant Modifier_B can be of a completely different sort of thing than the EffectTye and Requirements that Modifier_B has.
 
Back
Top Bottom