I was digging deeper into diplomacy and I thought I would share my findings.
1. Declaration of War.
-If a diplomatic penalty from Spell of Mastery is applied, there is a 10% chance of DoW.
-If you attack their city overland and win, DoW is automatic.
-If the wizard has a Chaotic personality there is a random chance of Difficulty Level/300 for DoW.
-When a "Declare War on" proposal is successful
-When threatening fails too badly
-When relationship falls below -75 and the AI still remembers a negative diplomatic action of any size.
-When the AI remembers a negative action, Relation+Hidden Relation+Personality Modifier-random(100)+Treaty Willingness<=-100, the AI will break treaty or if no such is present and the check is failed at least twice, then War is declared only if Remembered action strength+Personality Modifier<random(100)
-At end of turn if 2 AI wizards are allied and one is at war with a 3rd Ai wizard but the other is not then the other will also declare war on that wizard, this one is for AI wizards only.
2. Breaking of Treaty or Declaration of War if no Treaty is present.
Called once every end of turn, but only after turn 100 or if both wizards involved are AI, a BTODW is made if
-The wizard is militarist or expansionist, not lawful, at an 5% chance if a check for Military situation+relation+hidden relation+personality modifier falls below -150. Military situation checks the cost of units on the wizard's fortress continent so it's pretty unrelated to any actual military power they would have over each other in an actual war.
-The exact same as above repeated for any wizard.
-If the number of wizards at war with the player is fewer than the difficulty level and relationship is worse than -30 then there is an abs(relationship/10) to 15 chance.
-Finally, if wizard A is allied with wizard B, but wizard B is at war with the player, then wizard A will BTODW on any wizard at a 10% chance. This is looking quite buggy and the intended functionality is most likely that if wizard B is at war with any wizard, war is declared on that wizard. Note that wizard B cannot be the player, so your allies will never break their treaties and declare war on your enemies from this effect unless you ask them to yourself. (and it's buggy and declares wars on random people, anyway)
3. Threatening
Success is based on a value of Military modifier+Relation+Hidden Relation+Personality modifier+random(100)+random(100).
Military modifier is the same as before so if you want it to work you should load all your sky drakes on their land and not on the ocean square near their capital. Or something like that, I don't really know if you need more, or fewer troops for success but I would assume more.
4. Proposing a treaty of any sort
x=Relationship+ hidden relationship+personality modifier+Military Modifier+random(100)+ 40 if allied - Treaty type success difficulty +Treaty Type wizard relation.
if x>0 then successful, if below -75 failure, in between the AI will ask for something in exchange.
5. Diplomatic Relation changing events
-Casting a global enchantment (varying amount of penalty)
-Keeping a global enchantment in play (10% of the above penalty per turn)
-Having larger military strength in astrologer than the AI : at most 5% chance to -10 per turn for the player only
-Having a Wizard's pact : 50% chance to +3 per turn
-Having an Alliance : 50% chance to +6 per turn
-When the number of owned towns exceed (Land size+1)*3 : when ((Land Size+1)*3-Towns)/(6+Land Size-Difficulty)*random(4)/3*4 is below zero then a negative event happens for half of that many points, at a 25% chance per turn for the player only. So Tiny land = 3, Small = 6, Medium = 9, Large = 12, Huge = 15, any more and there is a recurring penalty which is scaled up by difficulty.
-Trading a spell successfully if the given spell had a higher research than the received : +5
-5% chance when AI vs AI positive diplomatic action is attempted (like trading a spell), +5+random(5)
-If there is a unit near a town when you hold a wizard's pact or alliance, first warning : -random(5)
-If there is a unit near a town when you hold a wizard's pact or alliance, third warning : -5 and the wizard breaks treaty. This adds to the hidden relation modifier of that wizard and also to everyone else.
-if there is a unit near town, there is no pact or alliance, at a 5% chance : -random(5)
-Defeating a wizard : -40 to everyone else
-Banishing a wizard : -20 to everyone else
-Attacking despite a treaty : -40
-Attacking a town a winning : -40 (also comes with DoW)
-Attacking a town and losing : -20 but -60 if fortress. The latter causes overflow for lawful wizards which double it and the penalty turns positive.
-At end of combat, based on the other player's losses : -20 per hero, -random(20) per unit, additional -10 for engineers and settlers
-Casting Evil Presence, Famine, Chaos Rift on a town : -5
-Casting Pestilence : -8
-Casting Earthquake : -9
-Casting Call of the Void : -20
-Casting Corruption : -25
-Casting Raise Volcano : -50
-Starting to cast the Spell of Mastery : -50, and another -5 per turn, this also has a recurring chance of DoW directly.
-Casting Black Wind, Fire Storm, Ice Storm on their units : -3
6. Tired of diplomacy penalties
There are hidden modifiers by type of diplomacy. Whenever diplomacy actions are done, whether successful or not, all 3 types get a -10 penalty a set number of times. 10 is refilled per turn.
-1x whenever a Treaty is proposed. Additional loss of 20+random(30) points to "Treaty Modifier" only.
-1x whenever spell trading is attempted
-2x whenever successfully traded a spell
-4x! after every trading attempt, whether successful or not
-2x after a proposal of a Peace Treaty regardless of success
-10x after threatening a wizard
-2x after AI offering peace himself
-1x after unknown negotiating attempt
-3x if AI vs AI end of turn diplomacy was attempted
7. Offering Peace
The AI will sometimes offer peace on his own.
This happens if there is a war and all of the following criteria are met
-Relation+Hidden Relation+personality modifier+random(100)+"Tired of diplomacy 3rd type">=50
-A roll for 1/8 chance is successful
-30*Own Total Power/Player total power<=random(100)
-Relation+Hidden Relation+Personality Modifier-random(100)+Treaty Willingness<=-100
Yep, if the relation is too good, peace will not be offered as the entire diplomacy process is skipped. But if it isn't good enough, it also won't be. lol
If it happens, there is a 25% chance that a spell will be offered, if one is available.
Otherwise gold will be offered proportional to the player's number of towns controlled+ the number of the current turn, rounded down to the nearest 25 gold.
"Total power" most likely refers to the size of the bar on the F4 screen, the sum of astrologer "Army", "Power" and "Research".
8. Offering Treaties or any other possible diplomatic action
These have to pass the exact same check as peace treaty, being
Relation+Hidden Relation+Personality Modifier-random(100)+Treaty Willingness<=-100
but let's be honest about it, if the relations are negative, there is no way a good offer will make the further checks, and so they never happen.
If the bug wasn't there then the chance to run the procedure to offer a treaty was random(100)<3+Last positive action strength plus AND it also had to pass a roll for 25% success chance on top of that one.
Once inside the procedure, various treaties are considered.
To offer a Wizard Pact :
-Visible relations need to be 15 or higher
-random(100)+Relation+Visible Relation+Personality modifier+Treaty Willingness needs to be >=50
To offer an Alliance :
-Visible relations need to be 50 or higher
-random(100)+Relation+Visible Relation+Personality modifier+Treaty Willingness needs to be >=100
To ask for a War with another wizard :
-Asker has to be at war with the target.
-A roll for 10% chance has to be made
-If that wizard is really hated for some reason, a spell or gold will be offered
To offer a Spell Exchange :
-random(100)+Relation+Visible Relation+Personality modifier+Treaty Willingness needs to be >=25
-Valid spell targets need to be available.
If none of the others were selected, in that order of priority then
-If player's number of towns controlled exceeds own, a Wizard Pact is offered.
Finally, if an offer for a pact or alliance was chosen, based on the player's number of towns controlled and random chances, gold or a spell might be added to the offer.
All of this is information from the code, as these never happen in the unedited game due to a very similar relationship sum as the ones used here needs to be -100 or lower for any diplomatic action to be ever considered.
1. Declaration of War.
-If a diplomatic penalty from Spell of Mastery is applied, there is a 10% chance of DoW.
-If you attack their city overland and win, DoW is automatic.
-If the wizard has a Chaotic personality there is a random chance of Difficulty Level/300 for DoW.
-When a "Declare War on" proposal is successful
-When threatening fails too badly
-When relationship falls below -75 and the AI still remembers a negative diplomatic action of any size.
-When the AI remembers a negative action, Relation+Hidden Relation+Personality Modifier-random(100)+Treaty Willingness<=-100, the AI will break treaty or if no such is present and the check is failed at least twice, then War is declared only if Remembered action strength+Personality Modifier<random(100)
-At end of turn if 2 AI wizards are allied and one is at war with a 3rd Ai wizard but the other is not then the other will also declare war on that wizard, this one is for AI wizards only.
2. Breaking of Treaty or Declaration of War if no Treaty is present.
Called once every end of turn, but only after turn 100 or if both wizards involved are AI, a BTODW is made if
-The wizard is militarist or expansionist, not lawful, at an 5% chance if a check for Military situation+relation+hidden relation+personality modifier falls below -150. Military situation checks the cost of units on the wizard's fortress continent so it's pretty unrelated to any actual military power they would have over each other in an actual war.
-The exact same as above repeated for any wizard.
-If the number of wizards at war with the player is fewer than the difficulty level and relationship is worse than -30 then there is an abs(relationship/10) to 15 chance.
-Finally, if wizard A is allied with wizard B, but wizard B is at war with the player, then wizard A will BTODW on any wizard at a 10% chance. This is looking quite buggy and the intended functionality is most likely that if wizard B is at war with any wizard, war is declared on that wizard. Note that wizard B cannot be the player, so your allies will never break their treaties and declare war on your enemies from this effect unless you ask them to yourself. (and it's buggy and declares wars on random people, anyway)
3. Threatening
Success is based on a value of Military modifier+Relation+Hidden Relation+Personality modifier+random(100)+random(100).
Military modifier is the same as before so if you want it to work you should load all your sky drakes on their land and not on the ocean square near their capital. Or something like that, I don't really know if you need more, or fewer troops for success but I would assume more.
4. Proposing a treaty of any sort
x=Relationship+ hidden relationship+personality modifier+Military Modifier+random(100)+ 40 if allied - Treaty type success difficulty +Treaty Type wizard relation.
if x>0 then successful, if below -75 failure, in between the AI will ask for something in exchange.
5. Diplomatic Relation changing events
-Casting a global enchantment (varying amount of penalty)
-Keeping a global enchantment in play (10% of the above penalty per turn)
-Having larger military strength in astrologer than the AI : at most 5% chance to -10 per turn for the player only
-Having a Wizard's pact : 50% chance to +3 per turn
-Having an Alliance : 50% chance to +6 per turn
-When the number of owned towns exceed (Land size+1)*3 : when ((Land Size+1)*3-Towns)/(6+Land Size-Difficulty)*random(4)/3*4 is below zero then a negative event happens for half of that many points, at a 25% chance per turn for the player only. So Tiny land = 3, Small = 6, Medium = 9, Large = 12, Huge = 15, any more and there is a recurring penalty which is scaled up by difficulty.
-Trading a spell successfully if the given spell had a higher research than the received : +5
-5% chance when AI vs AI positive diplomatic action is attempted (like trading a spell), +5+random(5)
-If there is a unit near a town when you hold a wizard's pact or alliance, first warning : -random(5)
-If there is a unit near a town when you hold a wizard's pact or alliance, third warning : -5 and the wizard breaks treaty. This adds to the hidden relation modifier of that wizard and also to everyone else.
-if there is a unit near town, there is no pact or alliance, at a 5% chance : -random(5)
-Defeating a wizard : -40 to everyone else
-Banishing a wizard : -20 to everyone else
-Attacking despite a treaty : -40
-Attacking a town a winning : -40 (also comes with DoW)
-Attacking a town and losing : -20 but -60 if fortress. The latter causes overflow for lawful wizards which double it and the penalty turns positive.
-At end of combat, based on the other player's losses : -20 per hero, -random(20) per unit, additional -10 for engineers and settlers
-Casting Evil Presence, Famine, Chaos Rift on a town : -5
-Casting Pestilence : -8
-Casting Earthquake : -9
-Casting Call of the Void : -20
-Casting Corruption : -25
-Casting Raise Volcano : -50
-Starting to cast the Spell of Mastery : -50, and another -5 per turn, this also has a recurring chance of DoW directly.
-Casting Black Wind, Fire Storm, Ice Storm on their units : -3
6. Tired of diplomacy penalties
There are hidden modifiers by type of diplomacy. Whenever diplomacy actions are done, whether successful or not, all 3 types get a -10 penalty a set number of times. 10 is refilled per turn.
-1x whenever a Treaty is proposed. Additional loss of 20+random(30) points to "Treaty Modifier" only.
-1x whenever spell trading is attempted
-2x whenever successfully traded a spell
-4x! after every trading attempt, whether successful or not
-2x after a proposal of a Peace Treaty regardless of success
-10x after threatening a wizard
-2x after AI offering peace himself
-1x after unknown negotiating attempt
-3x if AI vs AI end of turn diplomacy was attempted
7. Offering Peace
The AI will sometimes offer peace on his own.
This happens if there is a war and all of the following criteria are met
-Relation+Hidden Relation+personality modifier+random(100)+"Tired of diplomacy 3rd type">=50
-A roll for 1/8 chance is successful
-30*Own Total Power/Player total power<=random(100)
-Relation+Hidden Relation+Personality Modifier-random(100)+Treaty Willingness<=-100
Yep, if the relation is too good, peace will not be offered as the entire diplomacy process is skipped. But if it isn't good enough, it also won't be. lol
If it happens, there is a 25% chance that a spell will be offered, if one is available.
Otherwise gold will be offered proportional to the player's number of towns controlled+ the number of the current turn, rounded down to the nearest 25 gold.
"Total power" most likely refers to the size of the bar on the F4 screen, the sum of astrologer "Army", "Power" and "Research".
8. Offering Treaties or any other possible diplomatic action
These have to pass the exact same check as peace treaty, being
Relation+Hidden Relation+Personality Modifier-random(100)+Treaty Willingness<=-100
but let's be honest about it, if the relations are negative, there is no way a good offer will make the further checks, and so they never happen.
If the bug wasn't there then the chance to run the procedure to offer a treaty was random(100)<3+Last positive action strength plus AND it also had to pass a roll for 25% success chance on top of that one.
Once inside the procedure, various treaties are considered.
To offer a Wizard Pact :
-Visible relations need to be 15 or higher
-random(100)+Relation+Visible Relation+Personality modifier+Treaty Willingness needs to be >=50
To offer an Alliance :
-Visible relations need to be 50 or higher
-random(100)+Relation+Visible Relation+Personality modifier+Treaty Willingness needs to be >=100
To ask for a War with another wizard :
-Asker has to be at war with the target.
-A roll for 10% chance has to be made
-If that wizard is really hated for some reason, a spell or gold will be offered
To offer a Spell Exchange :
-random(100)+Relation+Visible Relation+Personality modifier+Treaty Willingness needs to be >=25
-Valid spell targets need to be available.
If none of the others were selected, in that order of priority then
-If player's number of towns controlled exceeds own, a Wizard Pact is offered.
Finally, if an offer for a pact or alliance was chosen, based on the player's number of towns controlled and random chances, gold or a spell might be added to the offer.
All of this is information from the code, as these never happen in the unedited game due to a very similar relationship sum as the ones used here needs to be -100 or lower for any diplomatic action to be ever considered.