How to detect certain civs/leaders via requirements system?

luei333

Warlord
Joined
May 25, 2014
Messages
185
For context, I'm trying to recreate the Papal Primacy belief's effects as a Leader Ability for a custom civ/leader. Papal Primacy is implemented very differently than most beliefs, instead having its modifiers and requirements in Leaders.xml, same spot that the normal modifiers go for type and suzerain bonuses for city states. The modifiers are attached to all city states of a given type, and they attach another modifier to any players who meet the prereqs (has the right number of envoys, has the belief, not at war, etc), and THAT modifier grants extra yields either to the capital or to all of the player's districts of a given type. Since I can't attach either of those modifiers to the leader's trait, I need a way to detect a specific civ/leader to attach as a requirement to one of those modifiers.

I'm pretty sure there's no requirement type that lets you specify a specific leader or civ or check for an attached modifier, so there's no easy way to do this. My first thought it perhaps making a dummy tech, granting it to the desired leader via a few lines of lua, and checking for that as the requirement I need.

What might be the easiest/most efficient way to do this? Danke!
 
I'm pretty sure there's no requirement type that lets you specify a specific leader or civ
I'm not so sure you're correct. There's REQUIREMENT_CIV_TYPE_MATCHES. It isn't used by any of the code we have access to, but it may be functional.
 
sadly it is not functional, or at least not the way you would think it is ( i tried arguments like CivType and CivilizationType, didnt work)
but, good news i found a way to do something like it, may not be the most elegant or simple way and may have some bugs but is seems to work so far:

you can create a building that is unobtainable for everyone( by setting Mustpurchase="1" and not setting a PurchaseYield and excluding it from the civilopedia)
then give the civ or leader a trait that grants that building in every city
and as a requirement for the ability you want to have use one that checks if all your cities have that building.

there might be some problems related to capturing cities an such, since the building might stay in the city, bu i think if you require ALL cities to have the building it should work(cant confirm)
 
i tried arguments like CivType and CivilizationType
I presume you mean the value of the argument not the name of the argument.

I would hope something like the following to work:

Code:
<Requirements>
        <Row>
            <RequirementId>REQUIRES_EGYPT</RequirementId>
            <RequirementType>REQUIREMENT_CIV_TYPE_MATCHES</RequirementType>
        </Row>
</Requirements>
<RequirementArguments>
        <Row>
            <RequirementId>REQUIRES_EGYPT</RequirementId>
            <Name>CivilizationType</Name>
            <Value>CIVILIZATION_EGYPT</Value>
        </Row>
</RequirementArguments>

but if it doesn't it doesn't.
 
REQUIREMENT_CIV_TYPE_MATCHES simply does not work, unfortunately. I previously suggested it someone, but this was done without testing it, so, my apologies. I've since tested this Requirement in various combinations, with no success. I've also queried its process through Lua and there is absolutely no clarity. I suspect that it may refer to the primary civ's counterpart in the transaction, like, for example.REQUIREMENT_PLAYER_IS_SUZERAIN refers back to the city state to confirm that the major civ is the suzerain of the city state that's conferring the benefit.

Of course, I'll continue testing and will let you know if I have any success.

However, in most cases, the solution is to structure the code through a Civ Trait. That way, you have a direct link and confirmation that the object (Civ) receiving the benefit/subject to the modifier is the object (Civ) that is intended to be the beneficiary.

As I am now seeing, most of the problems with using the Modifier system (such as as for the OP) come from the way the Modifier Type is set up. If, for example, COLLECTION_OWNER is used, it makes it very inflexible and you often need to create a new Modifier Type.

@luei333 If you give me a more thorough explanation of what you are trying to achieve, I might be able to help. The first thing I would look at, in your situation, is the way your preferred Modifier Type is set up. You may be able to restate it and solve a lot of your problems.
 
Hi @Gleb Bazov (and everyone else), thanks for taking the time to answer. Broadly, I'm trying to recreate the effects of the Papal Primacy belief, but as part of a Leader Ability for a new leader I'm making instead of a belief. Papal Primacy reads: 'Type bonuses from city-states following your Religion are 50% more powerful.' This means that the bonuses you get from sending envoys (+2 science in the capital, +2 science in all campus districts, etc) are half again as effective (total of +3 science in the capital, and +3 science in all campus districts, etc).

More thoroughly, Papal Primacy's effects aren't implemented in the same manner as most other beliefs. In particular, instead of having attached modifiers in the BeliefModifiers table, it has its related modifiers in the TraitModifiers table for the City State leaders. Here is the relevant code, only for scientific CSes, to save space (from Leaders.xml):
Code:
   <TraitModifiers>
       <Row TraitType="MINOR_CIV_SCIENTIFIC_TRAIT" ModifierId="MINOR_CIV_SCIENTIFIC_SMALL_INFLUENCE_BONUS_PAPAL_PRIMACY"/>
       <Row TraitType="MINOR_CIV_SCIENTIFIC_TRAIT" ModifierId="MINOR_CIV_SCIENTIFIC_MEDIUM_INFLUENCE_BONUS_PAPAL_PRIMACY"/>
       <Row TraitType="MINOR_CIV_SCIENTIFIC_TRAIT" ModifierId="MINOR_CIV_SCIENTIFIC_LARGE_INFLUENCE_BONUS_PAPAL_PRIMACY"/>
   </TraitModifiers>

   <Modifiers>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_SMALL_INFLUENCE_BONUS_PAPAL_PRIMACY</ModifierId>
           <ModifierType>MODIFIER_ALL_PLAYERS_ATTACH_MODIFIER</ModifierType>
           <SubjectRequirementSetId>PLAYER_HAS_SMALL_INFLUENCE_AND_PAPAL_PRIMACY</SubjectRequirementSetId>
       </Row>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_MEDIUM_INFLUENCE_BONUS_PAPAL_PRIMACY</ModifierId>
           <ModifierType>MODIFIER_ALL_PLAYERS_ATTACH_MODIFIER</ModifierType>
           <SubjectRequirementSetId>PLAYER_HAS_MEDIUM_INFLUENCE_AND_PAPAL_PRIMACY</SubjectRequirementSetId>
       </Row>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_LARGE_INFLUENCE_BONUS_PAPAL_PRIMACY</ModifierId>
           <ModifierType>MODIFIER_ALL_PLAYERS_ATTACH_MODIFIER</ModifierType>
           <SubjectRequirementSetId>PLAYER_HAS_LARGE_INFLUENCE_AND_PAPAL_PRIMACY</SubjectRequirementSetId>
       </Row>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_YIELD_FOR_CAPITAL_PAPAL_PRIMACY</ModifierId>
           <ModifierType>MODIFIER_PLAYER_CAPITAL_CITY_ADJUST_CITY_YIELD_CHANGE</ModifierType>
       </Row>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_YIELD_FOR_CAMPUS_PAPAL_PRIMACY</ModifierId>
           <ModifierType>MODIFIER_PLAYER_DISTRICTS_ADJUST_YIELD_CHANGE</ModifierType>
           <SubjectRequirementSetId>DISTRICT_IS_CAMPUS</SubjectRequirementSetId>
       </Row>
   </Modifiers>

   <ModifierArguments>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_SMALL_INFLUENCE_BONUS_PAPAL_PRIMACY</ModifierId>
           <Name>ModifierId</Name>
           <Value>MINOR_CIV_SCIENTIFIC_YIELD_FOR_CAPITAL_PAPAL_PRIMACY</Value>
       </Row>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_MEDIUM_INFLUENCE_BONUS_PAPAL_PRIMACY</ModifierId>
           <Name>ModifierId</Name>
           <Value>MINOR_CIV_SCIENTIFIC_YIELD_FOR_CAMPUS_PAPAL_PRIMACY</Value>
       </Row>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_LARGE_INFLUENCE_BONUS_PAPAL_PRIMACY</ModifierId>
           <Name>ModifierId</Name>
           <Value>MINOR_CIV_SCIENTIFIC_YIELD_FOR_CAMPUS_PAPAL_PRIMACY</Value>
       </Row>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_YIELD_FOR_CAPITAL_PAPAL_PRIMACY</ModifierId>
           <Name>YieldType</Name>
           <Value>YIELD_SCIENCE</Value>
       </Row>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_YIELD_FOR_CAPITAL_PAPAL_PRIMACY</ModifierId>
           <Name>Amount</Name>
           <Value>1</Value>
       </Row>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_YIELD_FOR_CAMPUS_PAPAL_PRIMACY</ModifierId>
           <Name>YieldType</Name>
           <Value>YIELD_SCIENCE</Value>
       </Row>
       <Row>
           <ModifierId>MINOR_CIV_SCIENTIFIC_YIELD_FOR_CAMPUS_PAPAL_PRIMACY</ModifierId>
           <Name>Amount</Name>
           <Value>1</Value>
       </Row>
   </ModifierArguments>

   <RequirementSets>
       <Row>
           <RequirementSetId>PLAYER_HAS_SMALL_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_MEDIUM_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_LARGE_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
       </Row>
   </RequirementSets>

   <RequirementSetRequirements>
       <Row>
           <RequirementSetId>PLAYER_HAS_SMALL_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_HAS_SMALL_INFLUENCE</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_SMALL_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_AT_PEACE</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_SMALL_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_FOUNDED_OUR_RELIGION</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_SMALL_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_HAS_PAPAL_PRIMACY</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_MEDIUM_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_HAS_MEDIUM_INFLUENCE</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_MEDIUM_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_AT_PEACE</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_MEDIUM_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_FOUNDED_OUR_RELIGION</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_MEDIUM_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_HAS_PAPAL_PRIMACY</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_LARGE_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_HAS_LARGE_INFLUENCE</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_LARGE_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_AT_PEACE</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_LARGE_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_FOUNDED_OUR_RELIGION</RequirementId>
       </Row>
       <Row>
           <RequirementSetId>PLAYER_HAS_LARGE_INFLUENCE_AND_PAPAL_PRIMACY</RequirementSetId>
           <RequirementId>REQUIRES_PLAYER_HAS_PAPAL_PRIMACY</RequirementId>
       </Row>
   </RequirementSetRequirements>

So, there are 3 modifiers attached to the City States' leaders' traits, one for the 1 envoy bonus, one for the 3 envoy bonus, and one for the 6 envoy bonus. These modifiers' collection is ALL players, but per the requirements they only affect players who have the requisite number of envoys, are at peace with the city state, and who have founded the religion that the CS has, as long as said religion has the Papal Primacy belief. Once the requirements are met, the modifiers attach a new modifier to the PLAYER entity, which grants the proper yield either to their capital or their cities (as long as the city has the requisite district). The modifier types are very simple, but it's the requirements that I need more than anything.

In its simplest form, my idea would be essentially to copy the code above, but replace the requirements PLAYER_FOUNDED_OUR_RELIGION and PLAYER_HAS_PAPAL_PRIMACY with whatever requirements would allow me to identify a single leader type (or even civilization type at this point, I'm not that picky). This seems impossible to do simply, but there might be some workarounds.

If I created a dummy tech or civic and granted it to the player (perhaps via lua?), then I can make a requirement to check for that. Though, I'd likely have to use lua to grant the tech, and I'd have to make sure that there's no way other players can get it, potentially through a later starting era or some AI trickery.
If I created a dummy building and granted it to every city that the leader owns, I could make a requirement to check for that (though on the modifers that get attached to the Player instead). Though, I'd have to make sure that it can only exist in the player's cities, and, for example, doesn't stay when the city is captured by another player; perhaps by making it a leader trait building and not setting an entry in the BuildingReplaces table.

Beyond one of those, I can't really see any way, outside of maybe just doing 90% of it in lua, to achieve the effect. The 2 requirements I need from the code above are PLAYER_HAS_X_INFLUENCE and PLAYER_AT_PEACE, and those I believe have to come from a modifier attached to the City State to function correctly, or at all.
 
I had attempted to solve this by creating "dummy" Resources, and then providing specific civs with Resource Visibility for that resource. Sadly it still doesn't work. It almost feels like Firaxis deliberately closed a lot of doors that would lead to a solution (of course they didn't really, but it's frustrating how close a number of systems are to solving major issues, but miss the mark due to a detail of the programming like the fact that you cant create unresearachable Techs or Civics, can't access Projects from Lua,etc.)
 
Back
Top Bottom