1. We have added the ability to collapse/expand forum categories and widgets on forum home.
    Dismiss Notice
  2. All Civ avatars are brought back and available for selection in the Avatar Gallery! There are 945 avatars total.
    Dismiss Notice
  3. To make the site more secure, we have installed SSL certificates and enabled HTTPS for both the main site and forums.
    Dismiss Notice
  4. Civ6 is released! Order now! (Amazon US | Amazon UK | Amazon CA | Amazon DE | Amazon FR)
    Dismiss Notice
  5. Dismiss Notice
  6. Forum account upgrades are available for ad-free browsing.
    Dismiss Notice

[Vanilla] Granting a specific tech boost on game start

Discussion in 'Mod Creation Help' started by RayOfSpeed, Feb 24, 2018.

  1. RayOfSpeed

    RayOfSpeed Chieftain

    Joined:
    Feb 24, 2018
    Messages:
    8
    EDIT: changed my mind about how I wanted to ask this question since every time I think I've figured something out, I dead end. I think I can handle the other two components of the mod (a building that replaces the University and a unit that replaces the Warrior Monk). What I'm having trouble with is the leader trait:

    Originally, my intent was to have them start with Archery, and have ranged units get +50% ranged strength while in a city or fort.

    It seems like you can't just start with a tech in this game. I was initially looking at ADJUST_TECH_BOOST before I realised that just adds a % to all tech boost effectiveness, and it seems like MODIFIER_PLAYER_GRANT_SPECIFIC_TECH_BOOST only works with the pre-defined boostable techs (GREATPERSON_ROCKETRYTECHBOOST, GREATPERSON_PRINTINGTECHBOOST etc.). Is this even a possible thing to do or should I go back to the drawing board and find a new trait?
     
    Last edited: Feb 25, 2018
  2. Imnimo

    Imnimo Chieftain

    Joined:
    Dec 3, 2017
    Messages:
    33
    Gender:
    Male
    You can define your own modifier of the MODIFIER_PLAYER_GRANT_SPECIFIC_TECH_BOOST type to boost any tech you want. Let's look at how GREATPERSON_MATHTECHBOOST works, as an example.

    If we look in GreatPeople_Scientists.xml, we can see the xml for defining the math boost:

    Code:
    <Modifiers>
    ...
            <Row>
                <ModifierId>GREATPERSON_MATHTECHBOOST</ModifierId>
                <ModifierType>MODIFIER_PLAYER_GRANT_SPECIFIC_TECH_BOOST</ModifierType>
                <RunOnce>true</RunOnce>
                <Permanent>true</Permanent>
            </Row>
    ...
    </Modifiers>
    
    Here we're making a new modifier called GREATPERSON_MATHTECHBOOST. It has the type MODIFIER_PLAYER_GRANT_SPECIFIC_TECH_BOOST (the other tech boosts also have this type). RunOnce and Permanent are other properties of the modifier that are necessary for this sort of single-shot effect.

    Code:
    <ModifierArguments>
    ...
            <Row>
                <ModifierId>GREATPERSON_MATHTECHBOOST</ModifierId>
                <Name>TechType</Name>
                <Value>TECH_MATHEMATICS</Value>
            </Row>
    ...
    </ModifierArguments>
    
    Here we've got the arguments to our modifier. The MODIFIER_PLAYER_GRANT_SPECIFIC_TECH_BOOST type takes one argument, named TechType, which defines which tech boost the modifier will grant. The Value of that argument, in this case, TECH_MATHEMATICS, is where we can specify which tech we want.

    By adding your own entries to modifiers table and the modifierarguments table, you can make a new modifier that grants a boost to archery.
     
    RayOfSpeed likes this.
  3. RayOfSpeed

    RayOfSpeed Chieftain

    Joined:
    Feb 24, 2018
    Messages:
    8
    Augh, I missed the TechType argument. Thanks a lot. Just need to figure out how to get it to run on game start...
     
  4. raen

    raen Coat of Arms

    Joined:
    May 12, 2003
    Messages:
    1,695
    Location:
    Portugal
  5. RayOfSpeed

    RayOfSpeed Chieftain

    Joined:
    Feb 24, 2018
    Messages:
    8
    Will that work for making a mod for distribution or is it only for your personal copy of the game?
     
  6. raen

    raen Coat of Arms

    Joined:
    May 12, 2003
    Messages:
    1,695
    Location:
    Portugal
  7. LeeS

    LeeS Imperator

    Joined:
    Jul 23, 2013
    Messages:
    5,414
    Location:
    Illinois, USA
    This lua code ought to do it. You just need to alter "CIVILIZATION_X" to the correct name of the civilzation as you have it in your XML or SQL code.
    Code:
    local iFreeTech = GameInfo.Technologies["TECH_ARCHERY"].Index
    local sRequiredCiv = "CIVILIZATION_X"
    
    for iLoopPlayer = 0, 62 do
    	local pLoopPlayer = Players[iLoopPlayer]
    	if pLoopPlayer:WasEverAlive() and pLoopPlayer:IsAlive() then
    		if (PlayerConfigurations[iLoopPlayer]:GetCivilizationTypeName() == sRequiredCiv) then
    			local pPlayerTechs = pLoopPlayer:GetTechs()
    			if (pPlayerTechs:HasTech(iFreeTech) == false) then
    				pPlayerTechs:SetTech(iFreeTech, true)
    			end
    		end
    	end
    end
    It needs to be placed in a file with extension ".lua" and the file needs to be set-up in the modinfo like as this
    Code:
      <InGameActions>
        <AddGameplayScripts id="FreeArcheryLua">
          <File>SomeFileName.lua</File>
        </AddGameplayScripts>
      </InGameActions>
      <Files>
        <File>SomeFileName.lua</File>
      </Files>
    In Modbuddy, "AddGameplayScripts" is one of the options in the dropdown for the type of action. You have to change from "UpdateDatabase" via the dropdown after you create the new InGame Action.
     
    racha, RayOfSpeed and raen like this.
  8. RayOfSpeed

    RayOfSpeed Chieftain

    Joined:
    Feb 24, 2018
    Messages:
    8
    Oh, wow, I didn't even know you could do that. That makes running things on startup way easier, thanks a lot.
     
  9. isau

    isau Warlord

    Joined:
    Jan 15, 2007
    Messages:
    2,701
    Partial answer to your question. If you want to give them a burst of Science to start where they can choose any tech to finish in 1 turn, you can do it like this (from a special ability given to China in my Combined Tweaks mod):


    Code:
    INSERT INTO Requirements
        (RequirementId,         RequirementType,     Likeliness,    Inverse,     Triggered)
    VALUES    ('QUO_REQ_CHINA_CITY_HAS_PALACE',         'REQUIREMENT_CITY_HAS_BUILDING',    0,0,0) ;
    
    
    INSERT INTO RequirementArguments
        (RequirementId,            Name,             Type,             Value,                 Extra,     SecondExtra)
    VALUES     ('QUO_REQ_CHINA_CITY_HAS_PALACE',    'BuildingType',        'ARGTYPE_IDENTITY',    'BUILDING_PALACE',    NULL,    NULL     )  ;
    
    
    INSERT INTO RequirementSets
        (RequirementSetId,         RequirementSetType)
    VALUES     ('QUO_REQSET_CHINA_FREE_SCIENCE_UNLOCK',     'REQUIREMENTSET_TEST_ALL') ;
    
    
    INSERT INTO RequirementSetRequirements
        (RequirementSetId,    RequirementId)
    VALUES     ('QUO_REQSET_CHINA_FREE_SCIENCE_UNLOCK',     'QUO_REQ_CHINA_CITY_HAS_PALACE')  ;
    
    
    
    INSERT INTO Modifiers
        (ModifierId, ModifierType, RunOnce, Permanent, OwnerRequirementSetId, SubjectRequirementSetId)
    VALUES    ('QUO_CHINA_FREE_STARTING_SCIENCE', 'MODIFIER_PLAYER_GRANT_YIELD', 1, 1, NULL, NULL) ,
            ('QUO_CHINA_FREE_STARTING_SCIENCE_PLAYER', 'MODIFIER_PLAYER_CITIES_ATTACH_MODIFIER', 0, 0, NULL,     'QUO_REQSET_CHINA_FREE_SCIENCE_UNLOCK') ;
    
    
    INSERT INTO ModifierArguments
        (ModifierId,             Name,             Type,             Value,         Extra,     SecondExtra)
    VALUES    ('QUO_CHINA_FREE_STARTING_SCIENCE',     'Amount',     'ScaleByGameSpeed',     '25',        NULL,     NULL),
            ('QUO_CHINA_FREE_STARTING_SCIENCE',     'YieldType',     'ARGTYPE_IDENTITY',     'YIELD_SCIENCE',    NULL,     NULL)  ,
            ('QUO_CHINA_FREE_STARTING_SCIENCE_PLAYER',     'ModifierId',     'ARGTYPE_IDENTITY',     'QUO_CHINA_FREE_STARTING_SCIENCE',    NULL,     NULL)  ;
     
    
    
    INSERT INTO TraitModifiers
        (TraitType,             ModifierID)
    VALUES    ('TRAIT_CIVILIZATION_DYNASTIC_CYCLE',    'QUO_CHINA_FREE_STARTING_SCIENCE_PLAYER')  ;


    What this code does is attach a Modifier that is "broadcast" to all of the player's cities (QUO_CHINA_FREE_STARTING_SCIENCE_PLAYER broadcasts QUO_CHINA_FREE_STARTING_SCIENCE). Each time the player founds or captures a city the Modifier is applied. But the Modifier contains a RequirementSet check to see if this city is the capital.

    In practice, the effect is to supply 25 science the moment the player founds the capital.

    The reason to delay a science burst like this is to make sure the player actually gets it. A burst of this kind on Turn 1 with no cities present can result in strange behavior.

    If you find directly awarding a tech doesn't work you can try the "look for a city with a Palace" method above.
     
    Last edited: Feb 28, 2018
    RayOfSpeed likes this.
  10. RayOfSpeed

    RayOfSpeed Chieftain

    Joined:
    Feb 24, 2018
    Messages:
    8
    Oh, that's really neat. I'll have to give that a shot too.
     

Share This Page