[XML] Realistic Diplomacy

Afforess

The White Wizard
Joined
Jul 31, 2007
Messages
12,239
Location
Austin, Texas
Description:
Realistic Diplomacy works to alter the way the AI remembers diplomatic events. In vanilla Civ4, the AI remembers all events forever (or close enough). This is completely unrealistic. Americans don't remember that the British razed Washington D.C to the ground in the war of 1812. Nor do the Japanese hold the two atomic explosions against us anymore. Time alters the memory of once horrific events. Now, with Realistic Diplomacy, the AI forgets minor events quickly and major ones over time.

How this is achieved:
Surprisingly, Firaxis made all diplomatic event memories editable in the LeaderHeadInfos.xml file, but decided to make some events (like War Declarations) unforgettable. Realistic Diplomacy changes this.

For example, lets look at this event:

Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_GIVE_HELP</MemoryType>
                    <iMemoryRand>200</iMemoryRand>
                </MemoryDecay>
If you gave tribute to the AI, the AI has a 39% chance of forgetting it in 100 turns. The way this is calculated is by binomial probability. Each turn, a two hundred sided die is rolled, and if it returns a 0, the AI forgets the event, otherwise, the AI remembers it. Remembering a tribute for 100 turns is like remembering something that happened a 1000 years ago.

(Note: Firaxis forgot to make memory decays scale for GameSpeed. I have reported this to the Unofficial Patch. If you are or have SDK modders, I recommend you scale it yourself, look in void CvPlayerAI::AI_doCounter() to find where the AI forgets.)

There are several memory types hidden in the SDK, never shown to XML modders, unless you know where to look. They are:
Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_DECLARED_WAR</MemoryType>
                    <iMemoryRand>45</iMemoryRand>
                </MemoryDecay>

This one modifies how long the AI remembers war declarations against them.
Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_DECLARED_WAR_ON_FRIEND</MemoryType>
                    <iMemoryRand>40</iMemoryRand>
                </MemoryDecay>

This one affects how long the AI remembers war declarations on their friends.
Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_HIRED_WAR_ALLY</MemoryType>
                    <iMemoryRand>35</iMemoryRand>
                </MemoryDecay>

This one affects how long the AI remembers you hiring war allies against them.
Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_NUKED_US</MemoryType>
                    <iMemoryRand>70</iMemoryRand>
                </MemoryDecay>

This one is pretty obvious, how long the AI remember nukes.
Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_NUKED_FRIEND</MemoryType>
                    <iMemoryRand>50</iMemoryRand>
                </MemoryDecay>

The same as above, but for the AI's friend.
Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_RAZED_CITY</MemoryType>
                    <iMemoryRand>50</iMemoryRand>
                </MemoryDecay>

How long the AI remembers that you razed one of their cities to the ground.
Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_RAZED_HOLY_CITY</MemoryType>
                    <iMemoryRand>200</iMemoryRand>
                </MemoryDecay>

Same as above, but how long the AI remembers you razing a holy city.

Code:
               <MemoryDecay>
                    <MemoryType>MEMORY_SPY_CAUGHT</MemoryType>
                    <iMemoryRand>10</iMemoryRand>
                </MemoryDecay>
How long the AI remember you having a caught spy in their territory.



Example Leader Files:
 

Attachments

Nice work, Im going to merge this into my games :)
When doing the XML, im guessing it is like this for each leader?
Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_NUKED_US</MemoryType>
                    <iMemoryRand>50</iMemoryRand>
                </MemoryDecay>
 
Nice work, Im going to merge this into my games :)
When doing the XML, im guessing it is like this for each leader?
Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_NUKED_US</MemoryType>
                    <iMemoryRand>50</iMemoryRand>
                </MemoryDecay>

Yeah. That's correct.
 
I want to merge this into Quot Capit because one leader annoyingly invaded my land when we had nothing to do with each other except for me refusing her Open Borders because she had always been "cautious".

So I see you have XML files for Realistic Diplomacy in RoM. Can I copy everything in that XML to a text document and just change the leader name, then save it for that specific leader?

Secondly, can I just copy over MemoryDecay entries only (going to be modularized of course), and NO music entries? Because I'm Deaf and I simply don't care for music?

Thanks.
 
So I see you have XML files for Realistic Diplomacy in RoM. Can I copy everything in that XML to a text document and just change the leader name, then save it for that specific leader?
Yeah. That should suffice, as long as Quot Capita uses WoC.
Secondly, can I just copy over MemoryDecay entries only (going to be modularized of course), and NO music entries? Because I'm Deaf and I simply don't care for music?

Yeah, if you don't care about the music, then go ahead. It doesn't alter gameplay...
 
Yeah. That's correct.
Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_NUKED_US</MemoryType>
                    <iMemoryRand>50</iMemoryRand>
                </MemoryDecay>

Not sure if this is working correctly in my games. They dont seem to forget that i nuked. The figure 50 means after 50 turns it will definatly be gone but it could also go before that because its 0.5% chance of forgetting that i nuked each turn. So basically a 50% chance of it forgetting before the 50th turn and on the 50th turn it will disappear anyway? :confused:
 
Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_NUKED_US</MemoryType>
                    <iMemoryRand>50</iMemoryRand>
                </MemoryDecay>
Not sure if this is working correctly in my games. They dont seem to forget that i nuked. The figure 50 means after 50 turns it will definatly be gone but it could also go before that because its 0.5% chance of forgetting that i nuked each turn. So basically a 50% chance of it forgetting before the 50th turn and on the 50th turn it will disappear anyway? :confused:

It's harder to prove that it is working with larger numbers. (There's some random variables Fraxis threw in to make things seem less... predictable, but it can through you off.)Try putting something completely unrealistic, for testing purposes, like 1 or 2. One or two turns after you nuke them, they will forget...
 
Which diplo modifiers are currently permanent (in the original version of the game)? which are not?
 
Which diplo modifiers are currently permanent (in the original version of the game)? which are not?

If you check BTS's sources, these diplomatic triggers are already predefined and can be used as memory decays, etc.

Code:
   DIPLOEVENT_CONTACT,
    DIPLOEVENT_AI_CONTACT,
    DIPLOEVENT_FAILED_CONTACT,
    DIPLOEVENT_GIVE_HELP,
    DIPLOEVENT_REFUSED_HELP,
    DIPLOEVENT_ACCEPT_DEMAND,
    DIPLOEVENT_REJECTED_DEMAND,
    DIPLOEVENT_DEMAND_WAR,
    DIPLOEVENT_CONVERT,
    DIPLOEVENT_NO_CONVERT,
    DIPLOEVENT_REVOLUTION,
    DIPLOEVENT_NO_REVOLUTION,
    DIPLOEVENT_JOIN_WAR,
    DIPLOEVENT_NO_JOIN_WAR,
    DIPLOEVENT_STOP_TRADING,
    DIPLOEVENT_NO_STOP_TRADING,
    DIPLOEVENT_ASK_HELP,
    DIPLOEVENT_MADE_DEMAND,
    DIPLOEVENT_RESEARCH_TECH,
    DIPLOEVENT_TARGET_CITY,
    DIPLOEVENT_MADE_DEMAND_VASSAL,

I add these new ones, so that modders could make the AI forget other things too.
Code:
    DIPLOEVENT_DECLARED_WAR,
    DIPLOEVENT_DECLARED_WAR_ON_FRIEND,
    DIPLOEVENT_HIRED_WAR_ALLY,
    DIPLOEVENT_NUKED_US,
    DIPLOEVENT_NUKED_FRIEND,
    DIPLOEVENT_RAZED_CITY,
    DIPLOEVENT_RAZED_HOLY_CITY,
    DIPLOEVENT_SPY_CAUGHT,
 
Hi,
can you please tell me how I can add this mod to BTS 3.19?

Yes. I'm going to assume you know how to compile the BTS source files, as this modcomp requires some rather easy SDK changes. First off, once you have a SDK you want to add this to, download my sources on the OP. There are only two files to change, and it's pretty easy. First, open up your copy of CvEnums.h, and then the one from my sources. Search for "Realistic Diplomacy" with the Control-F key. Once you find the comment that say "Afforess Realistic Diplomacy Start" copy everything in between that and the "Afforess Realistic Diplomacy End" into exactly the same spot in your own sources. Do the same thing for CvPlayer.cpp. Once that's done, recompile your sources. Use your new DLL, and place it in your mods folder. If you don't have one, create a folder in the mods directory. (There are plenty of mods here at CFC you can use as an example). There are also a few XML changes you'll need. Copy the Leaderheadinfos.xml from your BTS/Assets/XML/Civilizations to your mods folder, and open it up in your preferred text editor. Search (Control-F) for this "<MemoryDecays>" and you'll see a ton of these:
Code:
<MemoryDecays>
                <MemoryDecay>
                    <MemoryType>MEMORY_GIVE_HELP</MemoryType>
                    <iMemoryRand>30</iMemoryRand>
                </MemoryDecay>
                <MemoryDecay>
                    <MemoryType>MEMORY_REFUSED_HELP</MemoryType>
                    <iMemoryRand>20</iMemoryRand>
                </MemoryDecay>
                <MemoryDecay>
                    <MemoryType>MEMORY_ACCEPT_DEMAND</MemoryType>
                    <iMemoryRand>20</iMemoryRand>
                </MemoryDecay>
                <MemoryDecay>
                    <MemoryType>MEMORY_REJECTED_DEMAND</MemoryType>
                    <iMemoryRand>20</iMemoryRand>
                </MemoryDecay>
                <MemoryDecay>
                    <MemoryType>MEMORY_ACCEPTED_RELIGION</MemoryType>
                    <iMemoryRand>20</iMemoryRand>
                </MemoryDecay>

...

Change the values to whatever you like, they are approx the number of turns it takes that leader to to forget that particular diplomatic event. Then, at the end of the memory decays, add these new ones.

Code:
                <MemoryDecay>
                    <MemoryType>MEMORY_EVENT_BAD_TO_US</MemoryType>
                    <iMemoryRand>15</iMemoryRand>
                </MemoryDecay>
 [COLOR="Red"]               <MemoryDecay>
                    <MemoryType>MEMORY_DECLARED_WAR</MemoryType>
                    <iMemoryRand>45</iMemoryRand>
                </MemoryDecay>
                <MemoryDecay>
                    <MemoryType>MEMORY_DECLARED_WAR_ON_FRIEND</MemoryType>
                    <iMemoryRand>40</iMemoryRand>
                </MemoryDecay>
                <MemoryDecay>
                    <MemoryType>MEMORY_HIRED_WAR_ALLY</MemoryType>
                    <iMemoryRand>35</iMemoryRand>
                </MemoryDecay>
                <MemoryDecay>
                    <MemoryType>MEMORY_NUKED_US</MemoryType>
                    <iMemoryRand>70</iMemoryRand>
                </MemoryDecay>
                <MemoryDecay>
                    <MemoryType>MEMORY_NUKED_FRIEND</MemoryType>
                    <iMemoryRand>50</iMemoryRand>
                </MemoryDecay>
                <MemoryDecay>
                    <MemoryType>MEMORY_RAZED_CITY</MemoryType>
                    <iMemoryRand>50</iMemoryRand>
                </MemoryDecay>
                <MemoryDecay>
                    <MemoryType>MEMORY_RAZED_HOLY_CITY</MemoryType>
                    <iMemoryRand>200</iMemoryRand>
                </MemoryDecay>
                <MemoryDecay>
                    <MemoryType>MEMORY_SPY_CAUGHT</MemoryType>
                    <iMemoryRand>10</iMemoryRand>
                </MemoryDecay>[/COLOR]
            </MemoryDecays>

These weren't there by default, that's why you had to make SDK changes. These allow you to set values for how long the leader will remember things like nukes or war declarations.

You have to do the XML part for each leader. It sucks, I know.

Once you've done that, everything should be good to go.
 
Yes. I'm going to assume you know how to compile the BTS source files, as this modcomp requires some rather easy SDK changes.
How do I do this or is there some sort of guide available here on this?

Also in the unmodded game, when an AI asks for help in a war I don't get a diplo bonus (besides the mutual military struggle) - is there an easy way to change this?
 
The SDK is included in Beyond the Sword in Beyond the Sword/CvGameCoreDLL
 
Back
Top Bottom