1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Quick Modding Questions Thread

Discussion in 'Mod Creation Help' started by Leyrann, Oct 28, 2018.

  1. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,454
    Location:
    Illinois, USA
    Individaul Ubnits are assigned to Ability Classes in table "TypeTags"
    Code:
    	<TypeTags>
    		<Row Type="UNIT_EGYPTIAN_CHARIOT_ARCHER" Tag="CLASS_LIGHT_CHARIOT"/>
    		<Row Type="UNIT_SUMERIAN_WAR_CART" Tag="CLASS_HEAVY_CHARIOT"/>
    		<Row Type="UNIT_HEAVY_CHARIOT" Tag="CLASS_HEAVY_CHARIOT"/>
    		<Row Type="UNIT_TANK" Tag="CLASS_HEAVY_CHARIOT"/>
    		<Row Type="UNIT_MODERN_ARMOR" Tag="CLASS_HEAVY_CHARIOT"/>
    	</TypeTags>
    
    Any unit assigned to an individual Ability Class will share in the effect of a UnitAbility that is assigned to be effective for that class of unit:
    Code:
    	<TypeTags>
    		<Row Type="ABILITY_HEAVY_CHARIOT" Tag="CLASS_HEAVY_CHARIOT"/>
    		<Row Type="ABILITY_LIGHT_CHARIOT" Tag="CLASS_LIGHT_CHARIOT"/>
    	</TypeTags>
    An individual unit can be assigned to multiple different Ability-Classes, and will share in the UnitAbility effects of any Unit Ability which is thus made valid for that Class of "Ability"

    UnitAbilities (and their modifiers) are not directly tied to individual units -- they are tied to Ability-Classes, which in turn have individual units assigned to them. The Ability-Class (ie, "ABILITY_CLASS" in the "Tags" table) is used as a convenient catch-all for multiple units when desired without needing to individually code an Ability as being valid for a specific unit or combination of units anywhere else in the database.

    Individual units can and often are by Firaxis assigned to their own special Ability-Class. So far as I know (at least in the Vanilla expansion) the only unit that was assigned to the "CLASS_LIGHT_CHARIOT" was the Egyptian unique chariot-archer unit. In this way unique or special units can have their own "private" set of abilities without needing to add a bunch of extra single-case Boolean type stuff as was so often done in Civ5 with Promotions and the like.

    [edit] Without directly looking at which modifiers are attached to a given UnitAbility, and what those individual modifiers actually do, there's no quick and easy answer as to what the difference between two discreet Ability-Classes are.

    The Light Chariot Ability is an extra 2 movement when starting a turn on "clear" terrain as I recall, but I don't remember what the Heavy Chariot ability is off the top of my head.

    [edit edit] A quick check of the UnitAbilities.xml file shows that the Heavy Chariot ability is to only give +1 movement on "clear" terrain, so essentially the difference in the two Abilities / Modifiers gives the Egyptian Chariot-Archer an extra extra move in the proper conditions.
     
    Last edited: Dec 4, 2019
  2. Knasp

    Knasp Warlord

    Joined:
    Sep 10, 2011
    Messages:
    262
    I've looked through the Guides & References section but I haven't found a more in-depth explanation of various attributes in the game's XML code.

    I have now tinkered a lot with MODIFIERS and REQUIREMENTS but still find it difficult to execute intuitively easy changes and conditions for them.

    Is there an explanation anywhere for MODIFIER attributes like:
    Permanent, RunOnce, NewOnly, and stack limits?

    Or for REQUIREMENTS attributes like:
    Reverse, Persistent, etc?

    And why does some modifiers only work with some requirements?
    For e.g. the Conquistadors requirements of having a religious unit on the same plot seems to work for the modifier increasing combat strength, but not for the modifier increasing the unit's attack range.
     
  3. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,427
    Gender:
    Male
    Location:
    Warsaw
  4. Laurana Kanan

    Laurana Kanan Don’t underestimate who I am.

    Joined:
    Apr 10, 2014
    Messages:
    1,935
    Gender:
    Female
    Location:
    Near the Greatest Snow on Earth
  5. criZp

    criZp Emperor

    Joined:
    Jul 19, 2013
    Messages:
    1,393
    Location:
    Nidaros, Norway
    Don't know much about these parameters as I haven't had to deal with them in my mods, except RunOnce and Permanent. And I don't know these 2 perfectly either, except that they are used with modifiers from great people and the like, where the game runs a script that attaches a modifier to a district or something, these modifiers are RunOnce=true and Permanent=true. Modifiers are RunOnce=false by default, which means that the modifier will update every turn and see if conditions has changed. Permanent=true works with modifiers of the type "attach modifier to target", which great people modifiers are. Modifiers that are connected to a district or whatever by using "attach modifier to target", I think they go away after every turn. Normally they are refreshed because the modifier is RunOnce=false and will run at the start of every turn. But in the case of great people modifiers that's not possible because the great people disappear when activated.

    Edit: and stack limit parameter I will guess refers to how many times a modifier can be applied to the same target, for example if you have a policy with a modifier that give +5 strength to all units, and a government building with the same modifier giving +5 strength to all units, I would think that setting stacklimit to 1 prevents both sources from applying, so that total strength increases by +5 rather than +10.

    I also think the conquistador requirement should work with other modifiertypes like the increase range one. What code did you use?
     
    Last edited: Dec 5, 2019
    Knasp likes this.
  6. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    6,454
    Location:
    Illinois, USA
    Just ignore everything in the current version of the guide relating to how to Download the SDK and Assets packages from Steam.

    Because the latest (and really quite organizationally and visually dreadful) version of the Steam Interface has completely invalidated it.
     
  7. criZp

    criZp Emperor

    Joined:
    Jul 19, 2013
    Messages:
    1,393
    Location:
    Nidaros, Norway
    Now steam just puts the sdk and assets into "uncategorized" in the library tab along with the games, so you don't really need a guide to find it anymore
     
  8. Knasp

    Knasp Warlord

    Joined:
    Sep 10, 2011
    Messages:
    262
    Thanks for replies! I think I understand RunOnce and Permanent better now.

    So a modifier by default will stick around every turn that its owner exists and the effect will only apply if the requirements are met during each turn.

    By setting RunOnce = true, the modifier will not stick around for any subsequent turns, once it has been run.

    By setting Permanent = true, the modifier's effect will remain for any following turn(s), once the modifier has run. But if RunOnce isn't true, does the modifier accumulate new effects every turn? Or is the old effect removed every turn anyway?

    Still curious about the other attributes, especially regarding Requirements.
     
  9. criZp

    criZp Emperor

    Joined:
    Jul 19, 2013
    Messages:
    1,393
    Location:
    Nidaros, Norway
    I do believe this is the case, but I haven't tested too much with these parameters, so can't say for sure.
     
  10. Infixo

    Infixo Deity

    Joined:
    Jan 9, 2016
    Messages:
    3,427
    Gender:
    Male
    Location:
    Warsaw
    All modifiers are internally attached to their owners all the time, until conditions (e.g. requirements) change and then they are detached.
    Usual way is that modifier is attached and its effects are active, then it is detached and its effects are gone. You can change this using those extra features.
    RunOnce - simple, it is executed once. It could be attached later again, but it will not be executed. There is no stacking or accumulating of effects, never.
    Permanent - the effect of the modifier is permanent; I don't remember now, but I think it just cannot be detached, even if conditions are no longer met.
     
    cvb and Knasp like this.
  11. SocialMechanic

    SocialMechanic Chieftain

    Joined:
    May 11, 2019
    Messages:
    77
    I was wondering if the following is possible:
    I'm trying to get a Governor promotion to award the player an envoy when they complete the construction of a district in the city.
    It seems that the effect is specific and I'm scrolling through the available effects and requirements and not really finding anything that would allow it to work.
    Any ideas?

    EDIT: I suppose my main question is how do you get an effect to occur upon the completion of something? I know there are effects that are specific (like faith upon building completion), but I suppose I'm trying to find out if there is a requirement type for the completion of a building or district of whatever...
     
    Last edited: Dec 6, 2019
  12. criZp

    criZp Emperor

    Joined:
    Jul 19, 2013
    Messages:
    1,393
    Location:
    Nidaros, Norway
    Acropolis given an envoy when completed. It used the modifiertype MODIFIER_PLAYER_GRANT_INFLUENCE_TOKEN. You can try to attach that to other districts, but put as requirement "city has governor X promotion"
     
  13. SocialMechanic

    SocialMechanic Chieftain

    Joined:
    May 11, 2019
    Messages:
    77
    I did the following and it didn't work:
    Code:
    <DistrictModifiers>
            <Row DistrictType="DISTRICT_CAMPUS" ModifierId="CIVIC_AWARD_ONE_INFLUENCE_TOKEN" SubjectRequirementSetId="SM_CITY_HAS_GOVERNOR_PROMOTION_WATER_WORKS"/>
            <Row DistrictType="DISTRICT_COMMERCIAL_HUB" ModifierId="CIVIC_AWARD_ONE_INFLUENCE_TOKEN" SubjectRequirementSetId="SM_CITY_HAS_GOVERNOR_PROMOTION_WATER_WORKS"/>
            <Row DistrictType="DISTRICT_HARBOR" ModifierId="CIVIC_AWARD_ONE_INFLUENCE_TOKEN" SubjectRequirementSetId="SM_CITY_HAS_GOVERNOR_PROMOTION_WATER_WORKS"/>
            <Row DistrictType="DISTRICT_HOLY_SITE" ModifierId="CIVIC_AWARD_ONE_INFLUENCE_TOKEN" SubjectRequirementSetId="SM_CITY_HAS_GOVERNOR_PROMOTION_WATER_WORKS"/>
            <Row DistrictType="DISTRICT_THEATER" ModifierId="CIVIC_AWARD_ONE_INFLUENCE_TOKEN" SubjectRequirementSetId="SM_CITY_HAS_GOVERNOR_PROMOTION_WATER_WORKS"/>
            <Row DistrictType="DISTRICT_INDUSTRIAL_ZONE" ModifierId="CIVIC_AWARD_ONE_INFLUENCE_TOKEN" SubjectRequirementSetId="SM_CITY_HAS_GOVERNOR_PROMOTION_WATER_WORKS"/>
        </DistrictModifiers>
        <RequirementSets>
            <Row RequirementSetId="SM_CITY_HAS_GOVERNOR_PROMOTION_WATER_WORKS" RequirementSetType="REQUIREMENTSET_TEST_ALL"/>
        </RequirementSets>
        <RequirementSetRequirements>
            <Row RequirementSetId="SM_CITY_HAS_GOVERNOR_PROMOTION_WATER_WORKS" RequirementId="SM_WATER_WORKS_PROMO_RID"/>
        </RequirementSetRequirements>
        <Requirements>
            <Row RequirementId="SM_WATER_WORKS_PROMO_RID" RequirementType="REQUIREMENT_CITY_HAS_SPECIFIC_GOVERNOR_PROMOTION_TYPE"/>
        </Requirements>
        <RequirementArguments>
            <Row RequirementId="SM_WATER_WORKS_PROMO_RID" Name="Established" Value="true"/>
            <Row RequirementId="SM_WATER_WORKS_PROMO_RID" Name="GovernorPromotionType" Value="GOVERNOR_PROMOTION_WATER_WORKS"/>
        </RequirementArguments>
    Did I do something wrong?
     
  14. criZp

    criZp Emperor

    Joined:
    Jul 19, 2013
    Messages:
    1,393
    Location:
    Nidaros, Norway
    What does the database.log say? No error?
     
  15. SocialMechanic

    SocialMechanic Chieftain

    Joined:
    May 11, 2019
    Messages:
    77
    Oh. Apparently the DistrictModifiers table has no space for SubjectRequirements:
    Code:
    [3766498.097] [Gameplay] ERROR: table DistrictModifiers has no column named SubjectRequirementSetId
    [3766498.097] [Gameplay]: In Query - insert into DistrictModifiers('DistrictType', 'ModifierId', 'SubjectRequirementSetId') values (?, ?, ?);
    [3766498.097] [Gameplay]: In XMLSerializer while updating table DistrictModifiers from file Gameplay.xml.
    [3766499.541] [Gameplay]: Validating Foreign Key Constraints...
    [3766499.580] [Gameplay]: Passed Validation.
    Is there any other way to attach a prereq to it?
     
  16. Laurana Kanan

    Laurana Kanan Don’t underestimate who I am.

    Joined:
    Apr 10, 2014
    Messages:
    1,935
    Gender:
    Female
    Location:
    Near the Greatest Snow on Earth
    Create your own modifier instead of using an existing one and then you can add your own SubjectRequirementSet.
     
  17. criZp

    criZp Emperor

    Joined:
    Jul 19, 2013
    Messages:
    1,393
    Location:
    Nidaros, Norway
    The subject requirement set goes into the modifiers table, not into the district modifiers table
     
  18. SocialMechanic

    SocialMechanic Chieftain

    Joined:
    May 11, 2019
    Messages:
    77
    I don't know if I'm understanding correctly, but let me check,
    So, I should just create a Modifier ID within in the modifier table with the correct Modifier Type (which I'm going to assume is "MODIFIER_PLAYER_GRANT_INFLUENCE_TOKEN" since the "Districts.xml" doesn't say what it is) and then create a Subject Requirement Set ID that includes two Requirement IDs (one for the required governor promo and one for the appropriate district type, which will be the hardest part for me because I haven't been able to find a requirement based on district completion)?

    EDIT: OMG Or do you just mean making another row in the District Modifier table and add another Modifier ID to an existing District :lol: ?
    Okay, I think I feel ya. I'll test it and see what happens.
     
    Last edited: Dec 7, 2019
  19. SocialMechanic

    SocialMechanic Chieftain

    Joined:
    May 11, 2019
    Messages:
    77
    Okay, so I got another question xD
    I'm trying to get a governor promotion to produce a Loyalty Bomb (Loyalty Attack) when a Wonder is completed.
    Code:
        <Types>
            <Row Type="SM_WONDER_LOYALTY_BOMB" Kind="KIND_MODIFIER"/>
        </Types>
        <DynamicModifiers>
            <Row ModifierType="SM_WONDER_LOYALTY_BOMB" CollectionType="COLLECTION_OWNER" EffectType="EFFECT_ADJUST_CITY_IDENTITY_PRESSURE"/>
        </DynamicModifiers>
        <GovernorPromotionModifiers>
            <Delete GovernorPromotionType="GOVERNOR_PROMOTION_RESOURCE_MANAGER_INDUSTRIALIST"/>
            <Row GovernorPromotionType="GOVERNOR_PROMOTION_RESOURCE_MANAGER_INDUSTRIALIST" ModifierId="SM_WONDER_LOYALTY_BOMB_ID"/>
        </GovernorPromotionModifiers>
        <Modifiers>
            <Row ModifierId="SM_WONDER_LOYALTY_BOMB_ID" ModifierType="SM_WONDER_LOYALTY_BOMB" RunOnce="true" Permanent="true" SubjectRequirementSetId="SM_CITY_BUILDS_WONDER"/>
        </Modifiers>
        <ModifierArguments>
            <Row ModifierId="SM_WONDER_LOYALTY_BOMB_ID" Name="Amount" Value="100"/>
        </ModifierArguments>
        <RequirementSets>
            <Row RequirementSetId="SM_CITY_BUILDS_WONDER" RequirementSetType="REQUIREMENTSET_TEST_ALL"/>
        </RequirementSets>
        <RequirementSetRequirements>
            <Row RequirementSetId="SM_CITY_BUILDS_WONDER" RequirementId="SM_CITY_BUILDS_WONDER_ID"/>
        </RequirementSetRequirements>
        <Requirements>
            <Row RequirementId="SM_CITY_BUILDS_WONDER_ID" RequirementType="REQUIREMENT_PLAYER_BUILT_NEW_WONDER"/>
        </Requirements>
    I've also tried the "EFFECT_GRANT_CITY_LOYALTY" effect type but that doesn't work either.
    Any ideas?
     
  20. Knasp

    Knasp Warlord

    Joined:
    Sep 10, 2011
    Messages:
    262
    I figured out how the Requirements were working thanks to your suggestions above.

    The problem was that "REQUIREMENT_PLOT_UNIT_TYPE_MATCHES" only works if the unit owning the modifier moves onto the required unit's plot, not the other way around. And also the requirement didn't work if the support unit was being escorted and they moved together. It did however trigger by locking and then unlocking a escort-formation. I incorrectly assumed that the requirement would be met simply whenever the unit type would be present on the same plot, but that wasn't the case. I also tried adding Persistent = true and aslo tried with Triggered = true to see if that changed anything, but I couldn't see any difference.

    On the other hand it was possible to get: "REQUIREMENT_PLOT_NEARBY_UNIT_TAG_MATCHES" to work, but only if using the modifier: "MODIFIER_PLAYER_UNITS_GRANT_ABILITY". The requirement couldn't be used directly with the modifier affecting attack range or combat strength.
     
    Last edited: Dec 9, 2019

Share This Page