[R&F] Grant XP based on number of promotions of governor?

Discussion in 'Mod Creation Help' started by Durkle, Jul 5, 2018.

  1. Durkle

    Durkle Chieftain

    Joined:
    Jul 29, 2017
    Messages:
    29
    Gender:
    Male
    Location:
    Jerusalem
    I'm trying to make a leader ability where units trained in cities with an established governor receive 10% more experience per promotion that governor has.

    I assumed this would be easy, since this essentially combines the Mapuche Toqui ability with Seondeok's Hwarang. Unfortunately it didn't turn out as simply as I thought. Granting units a set amount of XP, like for Toqui, is really simple. What I can't figure out is how to alter that amount of XP depending on the number of promotions.

    In the attached code below you can see that everything is set up except for the requirements at the very bottom. If anybody knows of any requirement or value I can pull up to make this work I would definitely appreciate it.

    Code:
    -----------------------------------------------
    -- Types
    -----------------------------------------------
    
    INSERT INTO    Types
            (Type,                                            Kind            )
    VALUES    ('TRAIT_LEADER_DK_TISHOMINGO_UA',                'KIND_TRAIT'    );
    
    -----------------------------------------------
    -- Traits
    -----------------------------------------------
    
    INSERT INTO    Traits
            (TraitType,                            Name,                                    Description                                        )
    VALUES    ('TRAIT_LEADER_DK_TISHOMINGO_UA',    'LOC_TRAIT_LEADER_DK_TISHOMINGO_UA_NAME',    'LOC_TRAIT_LEADER_DK_TISHOMINGO_UA_DESCRIPTION'    );
            
    -----------------------------------------------
    -- LeaderTraits
    -----------------------------------------------
    
    INSERT INTO    LeaderTraits
            (LeaderType,                TraitType                        )
    VALUES    ('LEADER_DK_TISHOMINGO',    'TRAIT_LEADER_DK_TISHOMINGO_UA'    );
    
    -----------------------------------------------
    -- TraitModifiers
    -----------------------------------------------
    
    INSERT INTO    TraitModifiers
            (TraitType,                            ModifierId                                )
    VALUES    ('TRAIT_LEADER_DK_TISHOMINGO_UA',    'MODIFIER_DK_TISHOMINGO_1_PROMOTION'    ),
            ('TRAIT_LEADER_DK_TISHOMINGO_UA',    'MODIFIER_DK_TISHOMINGO_2_PROMOTION'    ),
            ('TRAIT_LEADER_DK_TISHOMINGO_UA',    'MODIFIER_DK_TISHOMINGO_3_PROMOTION'    ),
            ('TRAIT_LEADER_DK_TISHOMINGO_UA',    'MODIFIER_DK_TISHOMINGO_4_PROMOTION'    ),
            ('TRAIT_LEADER_DK_TISHOMINGO_UA',    'MODIFIER_DK_TISHOMINGO_5_PROMOTION'    ),
            ('TRAIT_LEADER_DK_TISHOMINGO_UA',    'MODIFIER_DK_TISHOMINGO_6_PROMOTION'    );
    -----------------------------------------------
    -- Modifiers
    -----------------------------------------------
    
    INSERT INTO    Modifiers
            (ModifierId,                            ModifierType,                                    SubjectRequirementSetId        )
    VALUES    ('MODIFIER_DK_TISHOMINGO_1_PROMOTION',    'MODIFIER_CITY_TRAINED_UNITS_ADJUST_XP_BONUS',    'REQSET_DK_GOVERNOR_HAS_1_PROMOTION'    ),
            ('MODIFIER_DK_TISHOMINGO_2_PROMOTION',    'MODIFIER_CITY_TRAINED_UNITS_ADJUST_XP_BONUS',    'REQSET_DK_GOVERNOR_HAS_2_PROMOTION'    ),
            ('MODIFIER_DK_TISHOMINGO_3_PROMOTION',    'MODIFIER_CITY_TRAINED_UNITS_ADJUST_XP_BONUS',    'REQSET_DK_GOVERNOR_HAS_3_PROMOTION'    ),
            ('MODIFIER_DK_TISHOMINGO_4_PROMOTION',    'MODIFIER_CITY_TRAINED_UNITS_ADJUST_XP_BONUS',    'REQSET_DK_GOVERNOR_HAS_4_PROMOTION'    ),
            ('MODIFIER_DK_TISHOMINGO_5_PROMOTION',    'MODIFIER_CITY_TRAINED_UNITS_ADJUST_XP_BONUS',    'REQSET_DK_GOVERNOR_HAS_5_PROMOTION'    ),
            ('MODIFIER_DK_TISHOMINGO_6_PROMOTION',    'MODIFIER_CITY_TRAINED_UNITS_ADJUST_XP_BONUS',    'REQSET_DK_GOVERNOR_HAS_6_PROMOTION'    );
    -----------------------------------------------
    -- ModifierArguments
    -----------------------------------------------
    
    INSERT INTO    ModifierArguments
            (ModifierId,                            Name,        Value    )
    VALUES    ('MODIFIER_DK_TISHOMINGO_1_PROMOTION',    'Amount',    10        ),
            ('MODIFIER_DK_TISHOMINGO_2_PROMOTION',    'Amount',    20        ),
            ('MODIFIER_DK_TISHOMINGO_3_PROMOTION',    'Amount',    30        ),
            ('MODIFIER_DK_TISHOMINGO_4_PROMOTION',    'Amount',    40        ),
            ('MODIFIER_DK_TISHOMINGO_5_PROMOTION',    'Amount',    50        ),
            ('MODIFIER_DK_TISHOMINGO_6_PROMOTION',    'Amount',    60        );
    
    -----------------------------------------------
    -- RequirementSetRequirements
    -----------------------------------------------
    INSERT INTO RequirementSetRequirements
            (RequirementSetId,                        RequirementId                    )
    VALUES    ('REQSET_DK_GOVERNOR_HAS_1_PROMOTION',    'REQ_DK_GOVERNOR_1_PROMOTION'    ),
            ('REQSET_DK_GOVERNOR_HAS_2_PROMOTION',    'REQ_DK_GOVERNOR_2_PROMOTION'    ),
            ('REQSET_DK_GOVERNOR_HAS_3_PROMOTION',    'REQ_DK_GOVERNOR_3_PROMOTION'    ),
            ('REQSET_DK_GOVERNOR_HAS_3_PROMOTION',    'REQ_DK_GOVERNOR_4_PROMOTION'    ),
            ('REQSET_DK_GOVERNOR_HAS_3_PROMOTION',    'REQ_DK_GOVERNOR_5_PROMOTION'    ),
            ('REQSET_DK_GOVERNOR_HAS_3_PROMOTION',    'REQ_DK_GOVERNOR_6_PROMOTION'    );
    
    -----------------------------------------------
    -- RequirementSets
    -----------------------------------------------
    INSERT INTO RequirementSets
            (RequirementSetId,                        RequirementSetType            )
    VALUES    ('REQSET_DK_GOVERNOR_HAS_1_PROMOTION',    'REQUIREMENTSET_TEST_ALL'    ),
            ('REQSET_DK_GOVERNOR_HAS_2_PROMOTION',    'REQUIREMENTSET_TEST_ALL'    ),
            ('REQSET_DK_GOVERNOR_HAS_3_PROMOTION',    'REQUIREMENTSET_TEST_ALL'    ),
            ('REQSET_DK_GOVERNOR_HAS_4_PROMOTION',    'REQUIREMENTSET_TEST_ALL'    ),
            ('REQSET_DK_GOVERNOR_HAS_5_PROMOTION',    'REQUIREMENTSET_TEST_ALL'    ),
            ('REQSET_DK_GOVERNOR_HAS_6_PROMOTION',    'REQUIREMENTSET_TEST_ALL'    );
    
    -----------------------------------------------
    -- Requirements
    -----------------------------------------------
    INSERT INTO Requirements
            (RequirementId,                            RequirementType,    Inverse    )
    VALUES    ('REQ_DK_GOVERNOR_1_PROMOTION',            'Minimum?',            0        ),
            ('REQ_DK_GOVERNOR_1_PROMOTION',            'Maximum?',            0        ),
            ('REQ_DK_GOVERNOR_2_PROMOTION',            'Minimum?',            0        ),
            ('REQ_DK_GOVERNOR_2_PROMOTION',            'Maximum?',            0        ),
            ('REQ_DK_GOVERNOR_3_PROMOTION',            'Minimum?',            0        ),
            ('REQ_DK_GOVERNOR_3_PROMOTION',            'Maximum?',            0        ),
            ('REQ_DK_GOVERNOR_4_PROMOTION',            'Minimum?',            0        ),
            ('REQ_DK_GOVERNOR_4_PROMOTION',            'Maximum?',            0        ),
            ('REQ_DK_GOVERNOR_5_PROMOTION',            'Minimum?',            0        ),
            ('REQ_DK_GOVERNOR_5_PROMOTION',            'Maximum?',            0        ),
            ('REQ_DK_GOVERNOR_6_PROMOTION',            'Minimum?',            0        ),
            ('REQ_DK_GOVERNOR_6_PROMOTION',            'Maximum?',            0        );
     
  2. isau

    isau Deity

    Joined:
    Jan 15, 2007
    Messages:
    3,071
    I think the requirement type you're looking for is REQUIREMENT_CITY_HAS_GOVERNOR_WITH_X_TITLES.

    If you have SQLite Studio you can pull back an example of how that's used with this query:

    Code:
    select * from requirementsets
    left join modifiers on modifiers.SubjectRequirementSetId = requirementsets.RequirementSetId
    left join requirementsetrequirements using (requirementsetid)
    left join requirements using (requirementid)
    left join requirementarguments using (requirementid)
    where requirementsetid like "%CITY_HAS_3_TITLE_GOVERNOR_REQUIREMENTS%"
    
     
  3. Durkle

    Durkle Chieftain

    Joined:
    Jul 29, 2017
    Messages:
    29
    Gender:
    Male
    Location:
    Jerusalem
    Thank you, incredibly helpful. I popped into SQLite Studio and was able to figure out how this requirements works. All I had to do was add a requirement arguments section like so:
    Code:
    -----------------------------------------------
    -- RequirementArguments
    -----------------------------------------------
    INSERT INTO RequirementArguments
            (RequirementId,                            Name,            Type,                    Value    )
    VALUES    ('REQ_DK_GOVERNOR_1_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_1_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_2_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '2'        ),
            ('REQ_DK_GOVERNOR_2_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_3_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '3'        ),
            ('REQ_DK_GOVERNOR_3_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_4_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '4'        ),
            ('REQ_DK_GOVERNOR_4_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_5_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '5'        ),
            ('REQ_DK_GOVERNOR_5_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_6_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '6'        ),
            ('REQ_DK_GOVERNOR_6_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
     
  4. Durkle

    Durkle Chieftain

    Joined:
    Jul 29, 2017
    Messages:
    29
    Gender:
    Male
    Location:
    Jerusalem
    Thank you, incredibly helpful. I popped into SQLite Studio and was able to figure out how this requirements works. All I had to do was add a requirement arguments section like so:
    Code:
    -----------------------------------------------
    -- RequirementArguments
    -----------------------------------------------
    INSERT INTO RequirementArguments
            (RequirementId,                            Name,            Type,                    Value    )
    VALUES    ('REQ_DK_GOVERNOR_1_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_1_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_2_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '2'        ),
            ('REQ_DK_GOVERNOR_2_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_3_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '3'        ),
            ('REQ_DK_GOVERNOR_3_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_4_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '4'        ),
            ('REQ_DK_GOVERNOR_4_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_5_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '5'        ),
            ('REQ_DK_GOVERNOR_5_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
            ('REQ_DK_GOVERNOR_6_PROMOTION',            'Amount',        'ARGTYPE_IDENTITY',        '6'        ),
            ('REQ_DK_GOVERNOR_6_PROMOTION',            'Established',    'ARGTYPE_IDENTITY',        '1'        ),
     
  5. isau

    isau Deity

    Joined:
    Jan 15, 2007
    Messages:
    3,071

    Awesome. FYI that's the way I code most abilities in my mods. I write a SQL query to pull back a list of existing constructions similar to what I'm trying to do, and basically copy values. The up side to doing it this way is since the query is already written, it doubles as a debug and testing tool once the mod is created. For example, if you ran your mod and ran that query again it should now show your new code in the database. You can use this to make sure everything got into place correctly.

    Some really common queries I use are:


    Requirements generally:
    Code:
    select * from requirementsets
    left join requirementsetrequirements using (requirementsetid)
    left join requirements using (requirementid)
    left join requirementarguments using (requirementid)
    where requirementtype like "%UNIT%"
    
    Modifiers generally:
    Code:
    select * from MODIFIERS
    left join modifierarguments using (modifierid)
    WHERE MODIFIERtype LIKE "%MODIFIER_CITY_ADJUST_SETTLER_CONSUME_POPULATION%"
    Investigate all the modifiers attached to a civilization:
    Code:
    select * from modifiers
    left join modifierarguments using (modifierid)
    left join traitmodifiers using (modifierid)
    left join civilizationtraits using (traittype)
    where civilizationtraits.CivilizationType like "%russia%"
    
    Investigate all the modifiers attached to a leader:
    Code:
    select * from modifiers
    left join modifierarguments using (modifierid)
    left join traitmodifiers using (modifierid)
    left join leadertraits using (traittype)
    where leadertraits.leaderType like "%peter%"
    

    Policies, governors, civics, technologies, etc are all super straightforward. Just change out the table name:
    Code:
    -- policies
    select * from policymodifiers
    left join modifiers using (modifierid)
    left join modifierarguments using (modifierid)
    where modifierid like "%rogue%"
    
    
    -- governors
    
    select * from governorpromotionmodifiers
    left join modifiers using (modifierid)
    left join modifierarguments using (modifierid)
    where modifierid like "%rogue%"
    
    
    --Civics
    select * from civicmodifiers
    left join modifiers using (modifierid)
    left join modifierarguments using (modifierid)
    
    --etc
    
     

Share This Page