[SOLVED] Custom requirement does not trigger

'Stache

Chieftain
Joined
Jan 10, 2019
Messages
19
Hello!
I wrote this code. The game accepts it, without error messages, but it seems although the ability is functioning, the game never thinks the requirements are met.

I can't see the mistake. Granted, I am still new to modding civ.

Is there any way to check if the game is checking for the requirement?


Code:
<?xml version="1.0" encoding="utf-8"?>
<GameInfo>
   <Types>
        <Row Type="ABILITY_STACHE_MILITIA" Kind="KIND_ABILITY"/>
    </Types>
    <TypeTags>
        <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_MELEE"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_RANGED"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_RECON"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_HEAVY_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_LIGHT_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_RANGED_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_ANTI_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_NAVAL_RANGED"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_NAVAL_MELEE"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_HEAVY_CHARIOT"/>
    </TypeTags>
   <UnitAbilities>
       <Row UnitAbilityType="ABILITY_STACHE_MILITIA" Name="LOC_ABILITY_STACHE_MILITIA" Description="LOC_ABILITY_STACHE_MILITIA" Inactive="true"/>
   </UnitAbilities>
    <UnitAbilityModifiers>
        <Row>
            <UnitAbilityType>ABILITY_STACHE_MILITIA</UnitAbilityType>
            <ModifierId>STACHE_MILITIA_ADJUST_IN_TERRITORY_COMBAT</ModifierId>
        </Row>
    </UnitAbilityModifiers>
    <Modifiers>
       <Row>
           <ModifierId>STACHE_MILITIA_GRANTING</ModifierId>
           <ModifierType>MODIFIER_PLAYER_UNITS_GRANT_ABILITY</ModifierType>
           <Permanent>true</Permanent>
       </Row>
        <Row>
            <ModifierId>STACHE_MILITIA_ADJUST_IN_TERRITORY_COMBAT</ModifierId>
            <ModifierType>MODIFIER_UNIT_ADJUST_COMBAT_STRENGTH</ModifierType>
            <SubjectRequirementSetId>REQUIREMENTS_UNITS_IN_OWNER_TERRITORY</SubjectRequirementSetId>
        </Row>
    </Modifiers>
    <ModifierArguments>
        <Row>
            <ModifierId>STACHE_MILITIA_ADJUST_IN_TERRITORY_COMBAT</ModifierId>
            <Name>Amount</Name>
            <Value>10</Value>
        </Row>
       <Row>
           <ModifierId>STACHE_MILITIA_GRANTING</ModifierId>
           <Name>AbilityType</Name>
           <Value>ABILITY_STACHE_MILITIA</Value>
       </Row>
    </ModifierArguments>
    <RequirementSets>
        <Row>
            <RequirementSetId>REQUIREMENTS_UNITS_IN_OWNER_TERRITORY</RequirementSetId>
            <RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
        </Row>
    </RequirementSets>
    <RequirementSetRequirements>
        <Row>
            <RequirementSetId>REQUIREMENTS_UNITS_IN_OWNER_TERRITORY</RequirementSetId>
            <RequirementId>UNIT_IN_OWNER_TERRITORY_REQUIREMENT_STACHE_MILITIA</RequirementId>
        </Row>
    </RequirementSetRequirements>
    <Requirements>
        <Row>
            <RequirementId>UNIT_IN_OWNER_TERRITORY_REQUIREMENT_STACHE_MILITIA</RequirementId>
            <RequirementType>REQUIREMENT_UNIT_IN_OWNER_TERRITORY</RequirementType>
        </Row>
    </Requirements>
   <TraitModifiers>
       <Row TraitType="TRAIT_CIVILIZATION_STACHE_THALVARIA" ModifierId="STACHE_MILITIA_GRANTING"/>
   </TraitModifiers>
</GameInfo>
 
Last edited:
I'm kind of new to this too, so I could be wrong...
But I think you need to Add your grant ability modifier to UnitAbilityModifiers?:
<Row>
<UnitAbilityType>ABILITY_STACHE_MILITIA</UnitAbilityType>
<ModifierId>STACHE_MILITIA_GRANTING</ModifierId>
</Row>
 
Tried to insert it in different ways into <UnitAbilityModifers>, and now the game crashes in the midst of loading a game as my civ.
Strangely, there is no error in the Database.log.

Very weird.

At least it reacts now. :D
 
You should be using a SQL tool like SQLite Studio to double check your code. A query like this will reveal how all your settings made it into the database:

select * from modifiers
left join requirementsets on modifiers.SubjectRequirementSetId = requirementsets.RequirementSetId
left join requirementsetrequirements using (requirementsetid)
left join requirements using (requirementid)
left join requirementarguments using (requirementid)
where modifiers.modifierid like "%STACHE_MILITIA_GRANTING%"


You can use various variations of this query to check your settings.
 
Hi, @isau.
I can't fully get the hang of SQLite Studio just jet. Is there a tutorial of some sorts how to set it up to work with civ6?

Thanks!
 
I can't find a way to connect Databases to SQLite Studio.
Does someone know where the database files are that I need to connect to SQLite Studio, in order to check how my code makes it into the civ database?
 
Hey Guys!
After ruining and rebuilding my mod after another mistake, I finally got in running again and found my way around SQLiteStudio.
I tried to run @isau s query:

select * from modifiers
left join requirementsets on modifiers.SubjectRequirementSetId = requirementsets.RequirementSetId
left join requirementsetrequirements using (requirementsetid)
left join requirements using (requirementid)
left join requirementarguments using (requirementid)
where modifiers.modifierid like "%STACHE_MILITIA_GRANTING%"

And this is what it gave me:


ModifierId ModifierType RunOnce NewOnly Permanent
STACHE_MILITIA_GRANTING MODIFIER_PLAYER_UNITS_GRANT_ABILITY 0 0 1

After that, there are a lot of NULL in the table, which looks a bit suspicious, but I am not sure, as there are a bunch of basegame modifiers with a lot of NULL in there.


I also checked all the other components of my mod, and everything seems to have gotten into the database.
Database.log doesn't give me any errors either.

Here is my current code for reference:
Code:
<?xml version="1.0" encoding="utf-8"?>
<GameInfo>
   <Types>
        <Row Type="ABILITY_STACHE_MILITIA" Kind="KIND_ABILITY"/>
    </Types>
    <TypeTags>
        <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_MELEE"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_RANGED"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_RECON"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_HEAVY_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_LIGHT_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_RANGED_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_ANTI_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_NAVAL_RANGED"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_NAVAL_MELEE"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_HEAVY_CHARIOT"/>
    </TypeTags>
   <UnitAbilities>
       <Row UnitAbilityType="ABILITY_STACHE_MILITIA" Name="LOC_ABILITY_STACHE_MILITIA" Description="LOC_ABILITY_STACHE_MILITIA" Inactive="true"/>
   </UnitAbilities>
    <UnitAbilityModifiers>
        <Row>
            <UnitAbilityType>ABILITY_STACHE_MILITIA</UnitAbilityType>
            <ModifierId>STACHE_MILITIA_ADJUST_IN_TERRITORY_COMBAT</ModifierId>
        </Row>
    </UnitAbilityModifiers>
    <Modifiers>
       <Row>
           <ModifierId>STACHE_MILITIA_GRANTING</ModifierId>
           <ModifierType>MODIFIER_PLAYER_UNITS_GRANT_ABILITY</ModifierType>
           <Permanent>true</Permanent>
       </Row>
        <Row>
            <ModifierId>STACHE_MILITIA_ADJUST_IN_TERRITORY_COMBAT</ModifierId>
            <ModifierType>MODIFIER_CITY_ADJUST_CITY_COMBAT_BONUS</ModifierType>
        </Row>
    </Modifiers>
    <ModifierArguments>
        <Row>
            <ModifierId>STACHE_MILITIA_ADJUST_IN_TERRITORY_COMBAT</ModifierId>
            <Name>Amount</Name>
            <Value>10</Value>
        </Row>
       <Row>
           <ModifierId>STACHE_MILITIA_GRANTING</ModifierId>
           <Name>AbilityType</Name>
           <Value>ABILITY_STACHE_MILITIA</Value>
       </Row>
    </ModifierArguments>
       <TraitModifiers>
       <Row TraitType="TRAIT_CIVILIZATION_STACHE_THALVARIA" ModifierId="STACHE_MILITIA_GRANTING"/>
   </TraitModifiers>
</GameInfo>
 
Code:
<ModifierType>MODIFIER_CITY_ADJUST_CITY_COMBAT_BONUS</ModifierType>
from this modifier definition in your code
Code:
        <Row>
            <ModifierId>STACHE_MILITIA_ADJUST_IN_TERRITORY_COMBAT</ModifierId>
            <ModifierType>MODIFIER_CITY_ADJUST_CITY_COMBAT_BONUS</ModifierType>
        </Row>
 
I can't see,

Is MODIFER_CITY_ADJUST_CITY_COMBAT_BONUS the wrong modifier for this kind of action?
 
You'd be adjusting a city's combat bonus with that type of modifier, rather than a unit's combat bonus.

In earlier versions of your code you had a modifier-type for adjusting a unit's combat bonus.
 
This sure seems to be working for me
Spoiler :
Code:
<GameData>


   <Types>
        <Row Type="ABILITY_STACHE_MILITIA" Kind="KIND_ABILITY"/>
    </Types>
    <TypeTags>
        <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_MELEE"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_RANGED"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_RECON"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_HEAVY_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_LIGHT_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_RANGED_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_ANTI_CAVALRY"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_NAVAL_RANGED"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_NAVAL_MELEE"/>
       <Row Type="ABILITY_STACHE_MILITIA" Tag="CLASS_HEAVY_CHARIOT"/>
    </TypeTags>
   <UnitAbilities>
       <Row UnitAbilityType="ABILITY_STACHE_MILITIA" Name="LOC_ABILITY_STACHE_MILITIA" Description="LOC_ABILITY_STACHE_MILITIA" Inactive="true"/>
   </UnitAbilities>
    <UnitAbilityModifiers>
        <Row>
            <UnitAbilityType>ABILITY_STACHE_MILITIA</UnitAbilityType>
            <ModifierId>STACHE_MILITIA_ADJUST_IN_TERRITORY_COMBAT</ModifierId>
        </Row>
    </UnitAbilityModifiers>
    <Modifiers>
       <Row>
           <ModifierId>STACHE_MILITIA_GRANTING</ModifierId>
           <ModifierType>MODIFIER_PLAYER_UNITS_GRANT_ABILITY</ModifierType>
           <Permanent>true</Permanent>
       </Row>
        <Row>
            <ModifierId>STACHE_MILITIA_ADJUST_IN_TERRITORY_COMBAT</ModifierId>
            <ModifierType>MODIFIER_UNIT_ADJUST_COMBAT_STRENGTH</ModifierType>
            <SubjectRequirementSetId>REQUIREMENTS_UNITS_IN_OWNER_TERRITORY</SubjectRequirementSetId>
        </Row>
    </Modifiers>
    <ModifierArguments>
        <Row>
            <ModifierId>STACHE_MILITIA_ADJUST_IN_TERRITORY_COMBAT</ModifierId>
            <Name>Amount</Name>
            <Value>10</Value>
        </Row>
       <Row>
           <ModifierId>STACHE_MILITIA_GRANTING</ModifierId>
           <Name>AbilityType</Name>
           <Value>ABILITY_STACHE_MILITIA</Value>
       </Row>
    </ModifierArguments>
    <RequirementSets>
        <Row>
            <RequirementSetId>REQUIREMENTS_UNITS_IN_OWNER_TERRITORY</RequirementSetId>
            <RequirementSetType>REQUIREMENTSET_TEST_ALL</RequirementSetType>
        </Row>
    </RequirementSets>
    <RequirementSetRequirements>
        <Row>
            <RequirementSetId>REQUIREMENTS_UNITS_IN_OWNER_TERRITORY</RequirementSetId>
            <RequirementId>UNIT_IN_OWNER_TERRITORY_REQUIREMENT_STACHE_MILITIA</RequirementId>
        </Row>
    </RequirementSetRequirements>
    <Requirements>
        <Row>
            <RequirementId>UNIT_IN_OWNER_TERRITORY_REQUIREMENT_STACHE_MILITIA</RequirementId>
            <RequirementType>REQUIREMENT_UNIT_IN_OWNER_TERRITORY</RequirementType>
        </Row>
    </Requirements>
   <TraitModifiers>
       <Row TraitType="TRAJANS_COLUMN_TRAIT" ModifierId="STACHE_MILITIA_GRANTING"/>
   </TraitModifiers>




</GameData>
I used Trajan's trait to make a quick test, and I can see the difference on the pre-attack calculations for the same unit attacking one of two barb warriors with the same Roman Warrior. One Barb Warrior I placed within my territory and other outside. On the Barb inside my territory I get 10 extra combat points in the little "Sword" part of the combat-panel for my warrior. The pre-attack panel is not however showing where the extra 10 combat points is coming from like it does with the Policy for +5 combat against barbarians.

Also at least for melee units it seems to matter not where the attacking unit is standing at the moment but rather where the combat will occur. One of my warriors standing one tile outside my own territory and attacking a unit in my territory gets the bonus. Archery units may show a slightly different behavior as to when the game considers the conditions of the requirement to be met.
 
Last edited:
Oh snap!
You're right!
And it works now, what a relief.
It's a shame it doesn't get shown in the pre-attack panel.
There is probably a way. I'll look into that when I find the time.

Thank you again for your help, everyone!
 
Back
Top Bottom