• Civilization 7 has been announced. For more info please check the forum here .

Some notes about diplomacy.


Jun 25, 2011
Some notes about diplomacy. Can be a bit spoiler'y, so read it at your own risk.

Here are some easy-for-me-to-write-in-human-language notes. See pastebin below with full diplomacy routine (written in more or less c, from disasm and decomp of the original game) for more detailed info.

1. there's "player's dominance" variable, conditions for it to be 1:

player is number 1 in powergraph ("4 advisors", variable value: 7)
player has more than 4 cities
and AI civ has more than 1 city
player doesn't have any nuclear bombs
and game turn is more than 200 (i.e. >= 1 A.D.)

if this variable is 1, AI civ will very unwilling to make peace and will make demands even if it is much weaker than you. So if you dominate the game, build 1 nuke just in case.

2. if both you and AI has at least 1 nuke, desired money tribute is divided by 2. Then, if you have more nukes than AI, tribute is decreased proportionally. Otherwise, it is increased proportionally. For example, if you have 1 nuke and AI has 3, then first: money/2, then: money*3/1, so result is: 3/2*money. If you have 4 nukes and AI has 2, then: money/2, then: money*2/4, and final result is: money/4

3. if AI is in vendetta with you, desired tribute is doubled

4. desired tribute is proportional to the game difficulty. Chieftain is *1, emperor is *5.

5. "aggressiveness" AI leader trait takes its part in determination of AI "fear" variable. Other factors are: "contact+war" status with other civs (and how strong they are compared to "our" AI civ), vendetta with you, and if you are stronger than AI civ or not.
If result "fear" is more than 0, AI changes its "want to attack" variable to 0, and there's also 50% chance that it will set its money demands to 0.
BUT if your "dominance" status (see p.1) is 1, AI will ignore its "fear" (including "aggressiveness" trait)

6. if AI under Republic, it will make a revolution (to monarchy) before talks if 1) "want to attack" variable is not 0 and 2) AI is not in vendetta with you and 3) AI military power *2 >= player military power*3 OR player_dominance is 1. If both of these last conditions are not true, AI simply will set its "want to attack" variable to 0, that's why AI with republican govt will not declare war on you. But if it's in vendetta with you, it will do nothing here, and further code doesn't prohibit AI from declare war under republic. So yes, vendetta AI can declare war under republic.

7. when you agree to cancel peace with 3rd civ, there's 50% chance that AI civ will not demand money from you (it will set "desired tribute" variable to 0). You also always get "war" and "vendetta" status with that 3rd civ, if you agreed to cancel peace. Btw, AI always selected last suitable civ to request/demand to cancel peace. For example, if AI at war with English and Mongols, their demand will always be the Mongols.

8. if you decline peace offer, "GIVECIV", "GIVECASH" and "GROVEL" responds will work only once, at the very first meeting with this civ. Even if you did not agreed to meet first time, flag of "first meeting" will be set anyway, and you cannot get these responds next time.

9. for "GROVEL" response (all money and all civ. advances for peace) AI (among other conditions) should have less than 2 cities

10. after making peace, on chieftain difficulty AI disbands all its units near your cities (if closest city from unit is yours and distance from it is 2 or less)

11. If only your civ and AI civ are active, game should make second option in "We respond..." ("have a military proposal for you") inactive (blue). But because the barbarians are also always active, this condition is never true and you still can select this option only to see nothing here. Sadly, it seems there's no place here to squeeze some bytes to fix that problem (without doing some ugly jumps)...

12. "mercenary" routine in "We respond..." is not working properly. AI will take your money, but then nothing will happen. There's simply no any code in the game here to change their diplomacy state to "war" with selected civ.

Anyway, formula for price here:
loc_merc_cost = FUN_minmax((((civ_military_power[att_civ])/2)*(civ_money[par_civ]/100))/50, 2, 9999)*50;
it cannot be less than 100$ and it's always 100$ when AI treasure is less than 100 or 3rd civ mil. power is less than 2 or when all this (civ_military_power[att_civ])/2)*(civ_money[par_civ]/100) expression is less than 150, which often is true.

The richer the AI civ and the stronger the 3rd civ, the more money AI civ will demand here.

13. With "instant advice" enabled, you will get *SCHISM from HELP.TXT message at the end of the negotiations, if next conditions are true:
1) number of AI cities is more than 4
2) and civilization place of your civ + 1 is less than civilization place of AI civ
3) and you is at war with AI civ
Notice that these conditions are not very correct: if there's no free civ slot, then civil war is still not possible, and your place actually should be only one position lower than AI for civil war (I have no idea why there's "1 place gap" here). And of course there's no check that AI civ even has a capital city.
Last edited:
Hello darkpanda. All of this in one location, overlay MZ 6, it contains logic for diplomacy screen. The biggest function here contains the logic (calculation of variables and then corresponding messages/dialog options), but some functions in MZ 6 also for animations of leader and advisors, for drawing text etc..

Calls for MZ 6 are in various places (some of these calls do not work for some reason: with messages *HELPME, *CRUSADE and *GAPE). AI/AI diplomacy exists in the main body of code, mostly in one place, I think, but I did not look closely.
Very interesting information. A lot of it can be gleaned from experience, but it's really cool to see exactly how it all works, so I'll be patiently waiting for your progress. I'm especially interested in the 'if-then' routine for negotiations.

About the 'vendetta' feature, it appears that when an AI has a vendetta against you it will ignore its senate and refuse peace even if it is running a republic. I think vendettas may ignore the UN too, but I don't remember well.
7) "mercenary" routine in "We respond..." is not working properly. AI will take your money, but then nothing will happen. There's simply no any code in the game here to change their diplomacy state to "war" with selected civ.

Very interesting information...
Precisely not so long ago I asked about this same topic but from what you say nothing can be done about it as it does not have any function.

How diplomacy timer works:

for AI unit to call you, current civ should have no contact* status with other civ (current civ can be your civ or AI civ, and other civ can be your or AI)
OR game_turn - timer should be >= 16
*no contact status resets every 16 turns (on game turn 16, 32 etc.)

1) at the start, civ diplomacy timer is -1 (so AI can call you anytime, but only after game turn 15, but its ok because you don't have a contact anyway)
2) if you captured AI city, timer is changed to -2 (so AI can call you anytime after game turn 14)
3) if AI captured your city, timer is changed to -1
4) if AI nukes you, timer is changed to -2
5) if AI produced a nuke and after that number of its nukes is 1, timer is changed to -1
6) when you launch your spaceship, timer is changed to 0 for all civs from 1 to 7 (so AI can call you anytime after game turn 16)
7) at civil war event, new civ sets its timer to game_turn-8 (so it can call you after 8 turns, but you don't have a contact with this new civ, so it doesn't matter, I think)
8) at the start of negotiations, timer is set to game_turn (so next talks will be after 16 turns or later)
9) if you make peace (select "yes" at peace offer): timer is set to game_turn+16 (so next talks will be after 32 turns or later)
10) if game call "set peace" function during negotiations, this function also set timer to game_turn+16. It happens in case (9) (so timer is set twice), but also:
if AI gives you a tech for peace and you agree; if AI gives you money for peace and you agree; if AI gives you all tech and money and you agree;
if you overruled by Senate;
11) if you demanded money on "We respond..." dialog and AI agreed: timer is set to game_turn (so next talks will be after 16 turns or later)
12) after "CRUSADE" screen, timer is set to game_turn+16, but probably this screen never works...

Values -1 and -2 have a special meaning as flags in the diplomacy routine. For example, money_demand is divided by 4 if you are not in vendetta and timer is -2.

EDIT: small addition: if AI has nothing to tell you, then game will not even call "Emissary from civ wants to talk with you. Will you recieve him?" dialog, but flags will be set anyway (including NUCLEAR TALKS flag) and timer will be set to game_turn+16 anyway.
Last edited:
Last edited:
Meaning of diplomacy flags:

0x1 - contact, game sets it to 1 after talks, resets to 0 every 16 turns, if 0x10 status is already 0 (see below). If 0, AI can call other AI or you to talk. "Proper" war status is only when contact is 1 (contact+no peace). If you "dominate the game" (biggest civ in the world, > 4 cities, no nukes and game turn is > 200), then, if you at war with civ and this civ has more than 1 city, it's set automatically each turn.

0x2 - peace. If 0: war (default), but not a "proper" war without contact flag. In some places game checks only 0x2 flag, but in some others - both 0x1 and 0x2.

0x4 - ally. AI will not demand anything from you, if it don't want to attack you and you are allies with him. Probably should be set in non-functional "crusade" and "helpme" logic. Also if civ2 is ally with player, this is one of conditions for civ1 to declare war on civ2. Ally status is canceled after declaration of war. Ally with barbarians is used as pseudo-anarchy flag for AI and as flag for "democracy collapse" anarchy for you.

0x8 - vendetta. After your sneak attack or after nuking. Also after civil war. If AI's in vendetta with other AI (which is possible only after civil war), they will not talk to each other. Vendetta is set to 0 after revolution.

0x10 - you can demand something for peace. Game sets it to 1 after every possibly talks between civs and sets it to 0 every 16th game turn. You can demand money/tech/everything for peace only when this flag is 0. After you meet AI or one AI meets another, both contact and "demand" flags are set. BUT when you use diplomat to talk with AI, these flags are not set. You can send your diplomat to an empty city and never encounter enemy units (for example, kill them with battleships), then you can demand something for peace as long as you wish (if AI is willing to give something to you, of course).
For AI/AI, the war can be "ended" (with embassy: message "War between A and B has been ended" or something) only if this flag is already off. So, first this flag goes off, and then contact flag goes off.

0x20 - military actions. Game sets it to 1 both ways after one civ is attacked other civ. This status is canceled after signing of peace. Has some meaning in diplomacy (for example, AI will not exchange techs in some cases). Set to 0 after talks.

0x40 - embassy. Gives you messages/changes type of some messages/gives you intelligence report. But also (I think?) changes something about what enemy unit movements for game to draw...

0x80 - nuclear status. Set to 1 after talks, even if you did not agree to talk. Game thinks that now you know about enemy nukes, so enemy can use them. Also set automatically after nuking, for unhindered retaliation.

0x100 - AI is ready to cancel peace treaty one-way (you will still be in the peace with AI, but AI will not longer be at the peace with you). Chance to do this is 25% every turn. If you "dominate the game" (biggest civ in the world, > 4 cities, no nukes and game turn is > 200), and AI has more than one city and is in peace with you, it's set automatically every turn. In some cases it also can be set to 1 after negotiations.

0x200 - AI canceled peace treaty one-way. Used to show you "sneak attack" message in this case.

EDIT2023-03-20: 0x10 is NOT "first contact", but "you can demand something for peace". Also, _this_ flag is set to 0 every 16 turns, not contact flag. Contact flag is set to 0 every 16 turns only if 0x10 flag is already 0.
Last edited:
Top Bottom