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

Leader Trait / am I going crazy ? [sql]

Discussion in 'Mod Creation Help' started by __jack__, Nov 9, 2020.

Tags:
  1. __jack__

    __jack__ Warlord

    Joined:
    Dec 29, 2009
    Messages:
    141
    Hi,

    I wanted to create a simple trait granting a permanent +5 strength. But I can't seem to make it work.


    Code:
    INSERT OR IGNORE INTO TraitModifiers
        (TraitType , ModifierId)
        VALUES
        ('TRAIT_CIVILIZATION_MAPUCHE_TOQUI' ,'TRAIT_TOQUI_COMBAT_BONUS_UNITS_VS_GOLDEN_AGE_CIV');   
    
    INSERT OR IGNORE INTO Modifiers
        (ModifierId , ModifierType, RunOnce, Permanent, OwnerRequirementSetId, SubjectRequirementSetId)
        VALUES
        ('TRAIT_TOQUI_COMBAT_BONUS_UNITS_VS_GOLDEN_AGE_CIV' ,'MODIFIER_PLAYER_UNITS_ADJUST_COMBAT_STRENGTH', 0, 0, NULL, NULL);   
    
    INSERT OR IGNORE INTO ModifierArguments
        (ModifierId , Name, Value, Extra,     SecondExtra)
        VALUES
        ('TRAIT_TOQUI_COMBAT_BONUS_UNITS_VS_GOLDEN_AGE_CIV' ,'Amount',    5, NULL, NULL);    
    Trait Id is TRAIT_TOQUI_COMBAT_BONUS_UNITS_VS_GOLDEN_AGE_CIV different from TRAIT_TOQUI_COMBAT_BONUS_VS_GOLDEN_AGE_CIV of Mapuche.

    Original code was more complex but since I add no effect (and no database error) I tried a much simpler version first to debug it.
     
  2. maconnolly

    maconnolly Warlord Supporter

    Joined:
    Jun 3, 2019
    Messages:
    163
    Gender:
    Male
    You're not going mad, @__jack__. But I do believe there is a two-tiered approach required for the sort of bonus you're looking to apply.

    There may be a more efficient way to do it, but I believe it should work to do the following:

    1. Create two Modifiers - one that grants all of the units of the civilization a UnitAbility, the second that describes that UnitAbility's affect on Combat Strength (with no special Requirement Set).
    2. Link the Modifier that applies the UnitAbility to the TraitType.
    3. Link the Modifier that grants the Combat Strength bonus to the UnitAbility via the UnitAbilityModifiers table.

    I can provide code a little later if you don't figure out a more simplistic, direct way than this - but I know from my own previous work, this was identified as a way that worked.
     
  3. __jack__

    __jack__ Warlord

    Joined:
    Dec 29, 2009
    Messages:
    141
    That's exactly why I ended up doing. But felt more like a hack. The initial approach should have been working?

    Here is the code for those who would look to do it in the future:


    Code:
    INSERT OR IGNORE INTO Modifiers
        (ModifierId , ModifierType, Permanent)
        VALUES
        ('TRAIT_TOQUI_COMBAT_BONUS_ABILITY_VS_GOLDEN_AGE_CIV' ,'MODIFIER_PLAYER_UNITS_GRANT_ABILITY', 1);   
        
    INSERT OR IGNORE INTO Modifiers
        (ModifierId , ModifierType, SubjectRequirementSetId)
        VALUES
        ('MOD_ABILITY_MAPUCHE' ,'MODIFIER_UNIT_ADJUST_COMBAT_STRENGTH', 'OPPONENT_IS_IN_GOLDEN_AGE_REQUIREMENTS');   
        
    INSERT OR IGNORE INTO ModifierArguments
        (ModifierId , Name, Value, Extra,     SecondExtra)
        VALUES
        ('TRAIT_TOQUI_COMBAT_BONUS_ABILITY_VS_GOLDEN_AGE_CIV' ,'AbilityType',    'ABILITY_TRAIT_MAPUCHE', NULL, NULL),
        ('MOD_ABILITY_MAPUCHE' ,'Amount',    5, NULL, NULL);
    
    INSERT OR IGNORE INTO Types
        (Type , Kind)
        VALUES
        ('ABILITY_TRAIT_MAPUCHE' ,'KIND_ABILITY');   
    
    INSERT OR IGNORE INTO TypeTags
        (Type , Tag)
        VALUES
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_RECON'),
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_MELEE'),
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_RANGED'),
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_SIEGE'),
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_HEAVY_CAVALRY'),
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_RANGED_CAVALRY'),
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_LIGHT_CAVALRY'),
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_ANTI_CAVALRY'),
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_HEAVY_CHARIOT'),   
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_LIGHT_CHARIOT'),
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_NAVAL_MELEE'),
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_NAVAL_RANGED'),
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_NAVAL_RAIDER'),       
        ('ABILITY_TRAIT_MAPUCHE' ,'CLASS_AIRCRAFT');   
    
    INSERT OR IGNORE INTO UnitAbilities
        (UnitAbilityType , Name, Description)
        VALUES
        ('ABILITY_TRAIT_MAPUCHE' ,'LOC_ABILITY_TRAIT_MAPUCHE_NAME', 'LOC_ABILITY_TRAIT_MAPUCHE_DESCRIPTION');       
    
    INSERT OR IGNORE INTO UnitAbilityModifiers
        (UnitAbilityType , ModifierId)
        VALUES
        ('ABILITY_TRAIT_MAPUCHE' ,'MOD_ABILITY_MAPUCHE');
     
  4. maconnolly

    maconnolly Warlord Supporter

    Joined:
    Jun 3, 2019
    Messages:
    163
    Gender:
    Male
    I'm glad you got it working. I hear what you mean re: it feeling like a 'hack' - but, in reality, it's to do with the context under which the two parts can apply.

    Essentially, modifier that grants something the civilization cannot apply directly to the individual units. Hence, you need to apply the unit ability to a civilization's units and, then, configure how that ability directly impacts the individual unit, per unit. I believe it relates to the 'Collection' that a ModifierType applies to - the ModifierType
    MODIFIER_PLAYER_UNITS_ADJUST_COMBAT_STRENGTH cannot actually affect a single unit entity. The Combat Strength value, in particular, needs to target a specific unit entity once it exists (i.e. is trained) in-game.

    To be honest, I'm not explaining it clearly - you can probably tell that I am not quite 'set' in my mind as to why the original approach can not work. I understand why the new approach does work, but can't bridge the gap between the two well enough to explain it.

    FWIW, you can make a small efficiency gain in your code in the TypeTags table. Instead of listing each CLASS_ separately, you can use CLASS_ALL_COMBAT_UNITS (I think that's the string) which applies to any unit class that has a combat capability.
     
  5. __jack__

    __jack__ Warlord

    Joined:
    Dec 29, 2009
    Messages:
    141
    Yes. I am more of a script/lua guy. the Database seems to be full of riddles: effects only working with some particular modifiers, then unclear modifiertype etc...

    Is there any reference guide on ModifierType or Effect scopes ?
     
  6. maconnolly

    maconnolly Warlord Supporter

    Joined:
    Jun 3, 2019
    Messages:
    163
    Gender:
    Male
    The resources I have read are the following:

    Modifiers, including Effects, Collections and Arguments (chapter 2 specifically covers Effects/Collections/Arguments, chapter 1 may provide context for you)

    https://forums.civfanatics.com/reso...ter-1-creating-and-attaching-modifiers.25683/
    https://forums.civfanatics.com/reso...iers-effects-collections-and-arguments.25868/

    In addition, I would recommend wholeheartedly having a copy of LeeS Civ VI Modding Guide to hand at all times. It's a big document, but it's an extremely useful reference:

    https://forums.civfanatics.com/threads/lees-civilization-6-modding-guide.644687/
     
  7. __jack__

    __jack__ Warlord

    Joined:
    Dec 29, 2009
    Messages:
    141
    Thanks - I did read them too.
    Unfortunately not a clear list of known limitations from Effect X only working for Y but that's try and error I guess.
     
  8. maconnolly

    maconnolly Warlord Supporter

    Joined:
    Jun 3, 2019
    Messages:
    163
    Gender:
    Male
    No, indeed. So, there is also this:

    https://docs.google.com/spreadsheet...lkDACezu5-igfQkVcOxeE_KG0/edit#gid=1678767919

    It has a whole host of info in it - including lots of entries for Effects and Collections. I'll be honest, I haven't delved into this because I do not have to.

    However, in terms of understanding which Collections and Effects are configured to work together already, I think these can be derived from the dynamic modifiers that exist in-game already. Certainly, I do think it is possible to code new combinations, too - which I think the 'Builder' tab of the linked spreadsheet alludes to.

    Ultimately, I believe it's configurable if it doesn't exist - but many combinations do already exist, so they don't all need to be specified.

    I believe the list you are looking to consult is the list of existing <DynamicModifiers> that appear within the Modifiers.xml file in the base-game code. These essentially pair ModifierType elements with CollectionType and EffectType elements.
     

Share This Page