1. Firaxis celebrates the "Asian American and Pacific Islander Heritage Month", and offers a give-away of a Civ6 anthology copy (5 in total)! For all the details, please check the thread here. .
    Dismiss Notice
  2. We have selected the winners of the Old World random draw and competition. For the winning entries, please check this thread.
    Dismiss Notice
  3. Old World has finally been released on GOG and Steam, besides also being available in the Epic store . Come to our Old World forum and discuss with us!
    Dismiss Notice

[GS] Support Unit Combat Modifiers

Discussion in 'Mod Creation Help' started by Viciousbunny, Apr 19, 2021.

  1. Viciousbunny

    Viciousbunny Chieftain

    Joined:
    Apr 19, 2021
    Messages:
    2
    Gender:
    Male
    TL;DR: I'm trying to add appropriate combat bonuses to anti-air guns and mobile SAMs. Having trouble with diplomatic visibility combat bonus, terrain defensive modifiers, and Victor governor's Garrison Commander promotion.

    I'm very new to the modding community and happy to be here! Last year (about 6 months ago) I opened a support ticket to 2K explaining that anti air units did not properly receive combat bonuses from most sources. Since I play this game in multiplayer regularly, this resulted in bombers being able to take down anti air units with ease, giving no effective counter to air units. 2K confirmed this is a bug, and needs to be fixed. After waiting this long for a fix and not seeing one, I decided to try and learn how to mod so I can just fix it myself. I've spend hours now pouring through the SQL and XML, and I've been able to fix a number of these combat bonuses.

    One such example was for Hojo Tokimune's bonus to units on the coast:
    INSERT INTO TypeTags (Type, Tag)
    VALUES ('ABILITY_HOJO_TOKIMUNE_COASTAL_COMBAT_BONUS', 'CLASS_SUPPORT');

    It seems easy enough to fix for each buff listed in the table TypeTags, where I can just add support units to the list of units that receive the buff. However, I'm having trouble with the bonuses listed below:

    Terrain Defensive Modifiers: In the "Terrains" table/file, there's a column for DefensiveModifier, but I can't find where that modifier is applied to a unit.
    Diplomatic Visibility Combat Bonus: This one is elusive, I started by looking at leaders like Catherine de Medici and civilizations like Mongolia to get a sense of what their traits were doing with diplomatic visibility. Catherine increases an attribute called "Source" by 1, and Mongolia gets an additional +3 combat strength for visibility, but I also cannot seem to find where this is applied to units.
    Garrison Commander Promotion: I tracked this bonus from Expansion1_Governors.xml to Expansion1_Modifiers.xml to a dead end here
    <Row>
    <ModifierType>MODIFIER_CITY_ADJUST_CITY_COMBAT_BONUS</ModifierType>
    <CollectionType>COLLECTION_OWNER</CollectionType>
    <EffectType>EFFECT_ADJUST_CITY_COMBAT_BONUS</EffectType>
    </Row>
    where it appears to apply to a collection.

    While I believe adding CLASS_SUPPORT is a viable option for fixing most of these issues, I've found what I believe to be the source of the problem in my search. That is this in Units.xml:

    <!-- IMPLICIT TAGS: filtered by criteria, do not need to be individually assigned to the UNIT -->
    <Row Tag="CLASS_ALL_UNITS" Vocabulary="ABILITY_CLASS"/>
    <Row Tag="CLASS_ALL_COMBAT_UNITS" Vocabulary="ABILITY_CLASS"/>
    <!-- STANDARD TAGS -->
    ....

    CLASS_ALL_COMBAT_UNITS does not include CLASS_SUPPORT, so every effect that applies to combat units will not apply to anti air guns and mobile SAMs. I'm not positive yet that this is intentional for any particular effects, but I'd be curious to know if there was a way that I could just add CLASS_SUPPORT to CLASS_ALL_COMBAT_UNITS somehow. If not, I think I'm missing a link.
     
  2. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    7,241
    Location:
    Illinois, USA
    DefenseModifier in table Terrains is an inherent effect of the map plot itself when that plot is of the particular terrain. This does not attach a modifier in the usual sense in which we refer to Modifiers -- it is just applied for an additional combat defense to any unit that happens to be standing on that type of terrain when attacked. It is done internally by the game engine -- there is no other code elsewhere in the game' XML files related to this. Since support units do not have inherent Combat power and are not FORMATION_CLASS_LAND_COMBAT nor FORMATION_CLASS_NAVAL the effect does not apply to them for inherent terrain combat bonuses (ie, DefenseModifier).

    DynamicModifiers all define a ModifierType, a CollectionType, and an EffectType. The CollectionType is the collection of "things" to which the EffectType is applied. In the case of COLLECTION_OWNER the effect is applied to the thing that "owns" the modifier. In the case of Victor's Promotion Modifier, the thing that "owns" the modifier is seen by the game as being the city to which Victor is currently assigned. So COLLECTION_OWNER in this case means applied only to the city where Victor is assigned.

    Other CollectionTypes (to pick an example or two) are COLLECTION_PLAYER_UNITS which would apply the effect to all units owned by the player who is assigned the modifier, or COLLECTION_PLAYER_CITIES which would be applied to all cities owned by the player who is assigned the modifier, or COLLECTION_CITY_PLOT_YIELDS which would apply the effect to all the yields in all the plots owned by a given city that is assigned the modifier.

    The reason that the Modifier used for Victor's promotion seems to terminate in a dead end is that the specific manner in which each individual EffectType is implemented is determined entirely within the inaccessible source code of the game. Firaxis defines these EffectTypes and codes how they work and what the actual effect is -- modders cannot change this in any way. So EFFECT_ADJUST_CITY_COMBAT_BONUS does what it does because Firaxis made it behave that way in the internal inaccessible source code. Usually they are pretty consistent in naming conventions of EffectTypes so that it is obvious that Effect_X will do X but every once in a while they add a new EffectType which logic would say based on the name of the EffectType ought to do X when in fact it actually does "C+A".

    Diplomatic Visibility Combat Bonuses I have never looked into so cannot say whether they are actually implemented by Modifiers or by internal code-magic within the game's sourcecode.
     
  3. Viciousbunny

    Viciousbunny Chieftain

    Joined:
    Apr 19, 2021
    Messages:
    2
    Gender:
    Male
    This is very helpful, thank you. Perhaps for now I'll apply what I can to support units using TypeTags and then hold out for an official fix. Much appreciated!
     

Share This Page