[MOD] Need help: Culture per Trade Route

Kewlipo

Chieftain
Joined
Jun 27, 2015
Messages
99
Heyo, I'm trying to create a mod that changes a social policy in the aesthetics tree. When this particular social policy is taken, the player would gain extra culture and gold for each trade route. I have some idea on how to do this by using the Gateway to Africa trait, but I have no idea how to actually tie that to unlocking the social policy.

Code:
   <Trait_YieldChangesPerTradePartner>
        <Row>
            <TraitType>TRAIT_GATEWAY_AFRICA</TraitType>
            <YieldType>YIELD_GOLD</YieldType>
            <Yield>3</Yield>
        </Row>
        <Row>
            <TraitType>TRAIT_GATEWAY_AFRICA</TraitType>
            <YieldType>YIELD_CULTURE</YieldType>
            <Yield>1</Yield>
        </Row>
    </Trait_YieldChangesPerTradePartner>
    <Trait_YieldChangesIncomingTradeRoute>
        <Row>
            <TraitType>TRAIT_GATEWAY_AFRICA</TraitType>
            <YieldType>YIELD_GOLD</YieldType>
            <Yield>2</Yield>
        </Row>
    </Trait_YieldChangesIncomingTradeRoute>

Could someone provide some help? If possible, I would not want to have to edit and recompile the DLL as my C++ experience is pretty low. Thank you so much!
 
Nothing in the <Traits> Schema will be of value in the <Policies> Schema. The game is simply not constructed to graft one onto the other.

You can accomplish the effect you are after via lua, but if you are not already conversant with lua it will be a steep curve to implement the effect. Editing and compiling a custom version of the game's DLL is certainly possible but in this case not needed nor really warranted. Since there can only be one version of any DLL file active at any one time, a mod that incudes a custom DLL is automatically incompatible with any other such mod, and in some cases is incompatible with a whole host of other mods simply because the customized version of the DLL is too specific to the effect the creator wanted and therefore not universally friendly to other mods.
 
In XML, you'd need to create an unreseachable tech and a trait that gives the trade route boost dependant on that tech, then, in Lua, you'd need to detect the player adopting the policy (game event), and give the player that tech. If the policy is a tenet, you'll also need to detect when the player switches ideology and remove the tech. Far easier in XML/Lua than DLL modding!
 
Howdy guys,

Thanks for the help! I actually implemented this by adding a building into the city where the trade route is coming from (if the policy has been taken) with Lua/XML.

Also, I have another question. I am trying to replace this:

Code:
        <Row>
            <Type>POLICY_AESTHETICS</Type>
            <Description>TXT_KEY_POLICY_AESTHETICS</Description>
            <Civilopedia>TXT_KEY_POLICY_AESTHETICS_TEXT</Civilopedia>
            <Help>TXT_KEY_POLICY_BRANCH_AESTHETICS_HELP</Help>
            <GreatWriterRateModifier>25</GreatWriterRateModifier>
            <GreatArtistRateModifier>25</GreatArtistRateModifier>
            <GreatMusicianRateModifier>25</GreatMusicianRateModifier>
            <PortraitIndex>6</PortraitIndex>
            <IconAtlas>POLICY_ATLAS</IconAtlas>
            <IconAtlasAchieved>POLICY_A_ATLAS</IconAtlasAchieved>
        </Row>

with this

Code:
        <Row>
            <Type>POLICY_AESTHETICS</Type>
            <Description>TXT_KEY_POLICY_AESTHETICS</Description>
            <Civilopedia>TXT_KEY_POLICY_AESTHETICS_TEXT</Civilopedia>
            <Help>TXT_KEY_POLICY_BRANCH_AESTHETICS_HELP</Help>
<GreatPeopleRateModifier>25</GreatPeopleRateModifier>
            <PortraitIndex>6</PortraitIndex>
            <IconAtlas>POLICY_ATLAS</IconAtlas>
            <IconAtlasAchieved>POLICY_A_ATLAS</IconAtlasAchieved>
        </Row>

What I tried to do was delete the original row and then replace it. Unfortunately this caused a whole host of issues, including policy icons disappearing for the aesthetics tree and exploration tree. How do I go about inserting GreatPeopleRateModifier into the row?
 
Use either of <Replace> or <Update> instead of <Row>. To simply add "GreatPeopleRateModifier" = "25" to the existing effects of the Policy:
Code:
<GameData>
     <Policies>
          <Update>
              <Where Type="POLICY_AESTHETICS" />
              <Set GreatPeopleRateModifier="25" />
            </Update>
     </Policies>
</GameData>
To eliminate the Writer, Artist, and Musician effect and supplant these with the GreatPeopleRateModifier effect:
Code:
<GameData>
     <Policies>
          <Update>
              <Where Type="POLICY_AESTHETICS" />
              <Set GreatPeopleRateModifier="25" GreatWriterRateModifier="0"  GreatArtistRateModifier="0" GreatMusicianRateModifier="0" />
         </Update>
     </Policies>
</GameData>
To use a <Replace> syntax instead:
Code:
………
       <Replace>
            <Type>POLICY_AESTHETICS</Type>
            <Description>TXT_KEY_POLICY_AESTHETICS</Description>
            <Civilopedia>TXT_KEY_POLICY_AESTHETICS_TEXT</Civilopedia>
            <Help>TXT_KEY_POLICY_BRANCH_AESTHETICS_HELP</Help>
<GreatPeopleRateModifier>25</GreatPeopleRateModifier>
            <PortraitIndex>6</PortraitIndex>
            <IconAtlas>POLICY_ATLAS</IconAtlas>
            <IconAtlasAchieved>POLICY_A_ATLAS</IconAtlasAchieved>
        </Replace>
……
"Replace" syntax though can sometimes have unintended consequences of re-sequencing the ID #s within a Primary table, and when other parts of the game expect these rows to be in a certain order can cause issues. I tend toward "Update" wherever possible anymore when re-writing the effects of rows within Primary tables.
 
Wow, that's so strange. I originally tried your second solution before even making my post, but it threw a Database error when I did.

Now it's working like magic!

Thanks man
 
Back
Top Bottom