[eWIP] Diplomacy Changes

Ok: my first, super-simple mod is a change in the way research treaties and trade treaties work.

Instead of each trade or research treaty giving each person involved a 1.1 multiplier, these treaties will now give a bonus equal to .1 of the other parties income or research.

I was very lucky in making this, because the very first change I made achieved my goal. The new problem, however, is that I cannot get the modified treaties to change the old treaties. I would be very grateful if someone helped me with this.

Here is the current code. Right now, since the old treaties currently replace my new ones, to actually try them you will need to give each treaty a new internal name or display name, or both (I haven't tested that out). For testing, it also speeds things up to remove the prerequisites.

Code: xml
  1. <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
  2. <Treaties>
  3.     <DataChecksum NoParse="1">
  4.         <Ignore>DisplayName,Description</Ignore>
  5.         <Translate>DisplayName,Description</Translate>
  6.     </DataChecksum>
  7. <Treaty InternalName = "TradeTreaty" Type = "Trade">
  8.         <DisplayName>Trade Treaty</DisplayName>
  9.     <Image>Action_Treaty.png</Image>
  10.         <Description>Both parties get a bonus to their per-turn income equal to 10% of the other party's income.</Description>
  11.         <TreatyValueDescription><![CDATA[[Player_1] will receive an additional [TreatyValue1WithUnits] and [Player_2] will receive an additional [TreatyValue2WithUnits]]]></TreatyValueDescription>
  12.         <Units>gp/turn</Units>
  13.         <Duration>-1</Duration>
  14.         <BasePerceivedValue>10000</BasePerceivedValue>
  15.         <MinimumRelations><![CDATA[[RELATIONS_NEUTRAL]]]></MinimumRelations>
  16.         <Calculate InternalName = "IncomeBonus" ValueOwner="Player_2">
  17.             <Expression><![CDATA[0.1*[Income]]]></Expression>
  18.         </Calculate>
  19.         <!-- Any one of these prereqs can be fulfilled to unlock this treaty -->
  20.         <Prereq>
  21.             <Type>Tech</Type>
  22.             <Attribute>Treaties_Amarian</Attribute>
  23.             <Value>0</Value>
  24.         </Prereq>
  25.         <Prereq>
  26.             <Type>Tech</Type>
  27.             <Attribute>Treaties_Trogs</Attribute>
  28.             <Value>0</Value>
  29.         </Prereq>
  30.     </Treaty>
  31.         <Treaty InternalName = "TechTreaty" Type = "Trade">
  32.         <DisplayName>Technology Treaty</DisplayName>
  33.         <Description>Both parties get a bonus to their tech research equal to 10% of the other party's tech research.</Description>
  34.         <TreatyValueDescription><![CDATA[[Player_1] will receive an additional [TreatyValue1WithUnits] and [Player_2] will receive an additional [TreatyValue2WithUnits]]]></TreatyValueDescription>
  35.         <Duration>-1</Duration>
  36.     <Image>Action_Treaty.png</Image>
  37.     <Units>Tech Knowledge per turn</Units>
  38.     <OneUnit>Tech Knowledge per turn</OneUnit>
  39.     <BasePerceivedValue>10000</BasePerceivedValue>
  40.     <MinimumRelations><![CDATA[[RELATIONS_NEUTRAL]]]></MinimumRelations>
  41.     <Calculate InternalName = "ResearchPointsBonus" ValueOwner="Player_2">
  42.       <Expression><![CDATA[[ResearchPoints]*0.1]]></Expression>
  43.     </Calculate>
  44.     <!-- Any one of these prereqs can be fulfilled to unlock this treaty -->
  45.     <Prereq>
  46.       <Type>Tech</Type>
  47.       <Attribute>Treaties_Amarian</Attribute>
  48.       <Value>0</Value>
  49.     </Prereq>
  50.     <Prereq>
  51.       <Type>Tech</Type>
  52.       <Attribute>Treaties_Trogs</Attribute>
  53.       <Value>0</Value>
  54.     </Prereq>
  55.   </Treaty>
  56. </Treaties>

To get the treaties to work differently, all I had to do was change "ValueOwner" from "Player_1" to "Player_2"!

 

Also, if anyone knows where the other diplomatic option files are located (if xml files exist), like for trading or marriage, I would be grateful for the information.

7,141 views 3 replies
Reply #1 Top

Onionfighter, here is a fairly simple solution to your treaty issue.

Code: xml
  1. <?xml version="1.0" encoding="iso-8859-1" standalone="yes"?>
  2. <Treaties>
  3.     <Treaty InternalName = "TradeTreaty" Type = "Trade">
  4.         <Calculate InternalName = "IncomeBonus" ValueOwner="Player_2">
  5.             <Expression><![CDATA[0.1*[Income]]]></Expression>
  6.         </Calculate>
  7.     </Treaty>
  8. </Treaties>

This code does everything that your code does, and overrides the current treaty. Ok so I know this doesn't look anything like what you are doing here but I will try to explain it a bit. One of the big things about the way elemental handles mods is the way it handles named references. If you want to modify only one part of a reference, you only need to "call" the reference then specify the exact change you want to make. So above, all we are doing is referencing the treaty, and telling the system that this is the calculation we want for this treaty. Now the sake of example, say you wanted to give these modded treaties a duration. All you would do is a single line for the modified duration and the system will use the modified version instead of the regular version. This tends to work for most of the xml files, though game modifiers do not follow this logic as they are loaded immediately and usually require a counter modifier to get rid of the bonus.

Edit: sorry about the odd link there, the forums make 1 *  into 1*

+1 Loading…
Reply #2 Top

Thanks for the help. It is good to know that I don't have to rebuild everything in the file. What I still cannot understand is why your change would be successful in replacing the option while mine is not.

Reply #3 Top

Honestly I have no clue why it works when you replace a little but not when you replace a lot. I would bet there is some kind of check in place that looks at the entry and uses some heuristic to determine if it is the same or different. This check probably doesn't kick in when you don't specify certain fields, like the display name or description. Though honestly, the method I have shown above is a good modding practice so that you are not attempting to override every value of an entry with a duplicate value and future modders can clearly see what changes you are adding.