# Diplomacy Internals (for HoMM III 3.2 and 4.0) 1. [Hero_Power]
Hero_Power = sqrt((1 + 0.05 * Attack) * (1 + 0.05 * Defense));

2. [Total_Army_Power]
Total_Army_Power = floor(Hero_Power * Army_Power);

3. [k]
k = Total_Army_Power / Neutrals_Power;

4. [Power_Factor] (fixed)
Power_Factor = 11 if k >= 7;
Power_Factor = floor(2*(k – 1)) if 1 <= k < 7;
Power_Factor = -1 if 0.5 < k < 1;
Power_Factor = -2 if 0.333 < k <= 0.5;
Power_Factor = -3 if k <= 0.333;

Note: 0.333 means 333/1000, not 1/3!

5. [Sympathy]
Sympathy = 0 if there are no creatures of the same kind as neutrals in hero’s army;
Sympathy = 1 if there is at least one creature (or upgrade/downgrade) of the same kind as neutrals in hero’s army;
Sympathy = 2 if total number of creatures (or their upgrades/downgrades) of the same kind as neutrals in hero’s army are strictly bigger than number of all the other beings in the army;

The notes below are for join calculations only!
Note: earth, water and fire elementals don’t have upgrades while air ones do!
Note: magma, ice and energy elementals don’t have downgrades while storm ones do!

6. [Charisma (Ch)]
Ch = Power_Factor + Diplomacy_Level + Sympathy;

7. [Aggression (X)]
X = -4 (always) for compliant neutrals;
X = 10 (always) for savage neutrals;
X = 1..7 for friendly neutrals;
X = 1..10! for aggressive neutrals;
X = 4..10! for hostile neutrals;

Note: for friendly, aggressive and hostile neutrals Õ is a pseudo-random value which is generated at creation of new game. You can see it when using LM Oracle 3.72 program.

8. if Ch < X neutrals will fight;

9. if Ch >= X there are two cases:
a) if Sympathy + Diplomacy_Level + 1 >= X neutrals will join for free;
b) Only if the first condition is false: if Sympathy + 2 * Diplomacy_Level + 1 >= X neutrals will join for gold provided you have enough money to buy them all (no resources are needed).

Note: if you reject an offer to join monsters:
a) flee (if Ch > X and they CAN flee i.e. they are not set to never flee);
b) take offence and attack (if Ch = X).

Note: on Easy difficult all heroes have a hidden Diplomacy level which is used for join calculations (only?). For example, if your hero has Basic Diplomacy then Diplomacy_Level is two instead of one. Nevertheless, Diplomacy_Level cannot exceed three