Skip to content

Commit 4382087

Browse files
authored
Merge pull request #194 from DiplomacyTeam/dev
v1.2.2 release
2 parents a3ab980 + 58cd1e2 commit 4382087

7 files changed

Lines changed: 73 additions & 32 deletions

File tree

build/common.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!--Module Version-->
44
<PropertyGroup>
5-
<Version>1.2.1</Version>
5+
<Version>1.2.2</Version>
66
<GameVersion>1.0.0</GameVersion>
77
</PropertyGroup>
88

changelog.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
---------------------------------------------------------------------------------------------------
2+
Version: 1.2.2
3+
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0
4+
* Added a way to add casualties that are not related to map events.
5+
* Adjusted war reparations calculation and related setting defaults to be considerably more mild.
6+
* Adjusted default settings for Kingdom Diplomacy.
7+
* Gold and Influence costs are joined under a single Costs heading for better usability.
8+
* Made sure that the settings are reset to default when you first start the game after updating from previous versions of the mod.
9+
---------------------------------------------------------------------------------------------------
210
Version: 1.2.1
311
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3,v1.1.0
412
* Fixed rare crash that happened when War Exhaustion event precedes the war.

src/Bannerlord.Diplomacy/Costs/DiplomacyCostCalculator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ private static KingdomWalletCost DetermineReparationsForMakingPeace(Kingdom king
110110
static int CalculateReparations(Kingdom kingdomPayingReparations, Kingdom otherKingdom, float payingKingdomWarExhaustion, float otherKingdomWarExhaustion, bool? payerLostWar = null)
111111
{
112112
var lossReparations = (payerLostWar ?? WarExhaustionManager.Instance.GetWarResult(kingdomPayingReparations, otherKingdom) == WarExhaustionManager.WarResult.Loss) ? Settings.Instance!.DefeatedGoldCost : 0;
113-
var warExhaustionReparations = otherKingdomWarExhaustion * ((payingKingdomWarExhaustion - otherKingdomWarExhaustion) * (WarExhaustionManager.IsCriticalWarExhaustion(otherKingdomWarExhaustion) ? 0.25f : 0.5f));
113+
var warExhaustionReparations = otherKingdomWarExhaustion * ((payingKingdomWarExhaustion - otherKingdomWarExhaustion) / (WarExhaustionManager.IsCriticalWarExhaustion(otherKingdomWarExhaustion) ? 8f : 4f));
114114
return (int) ((lossReparations + warExhaustionReparations) * GetKingdomScalingFactorForReparations(kingdomPayingReparations));
115115
}
116116

src/Bannerlord.Diplomacy/Settings.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ namespace Diplomacy
99
class Settings : AttributeGlobalSettings<Settings>
1010
{
1111
private const string HeadingKingdomDiplomacy = "{=sBw5Qzq3}Kingdom Diplomacy";
12-
private const string HeadingInfluenceCosts = "{=SEViwYTl}Influence Costs";
13-
private const string HeadingGoldCosts = "{=Ckd1Lsoa}Gold Costs";
12+
private const string Costs = "{=ldLFTs92}Costs";
13+
private const string HeadingGoldCosts = Costs + "/" + "{=Ckd1Lsoa}Gold Costs";
14+
private const string HeadingInfluenceCosts = Costs + "/" + "{=SEViwYTl}Influence Costs";
1415
private const string HeadingWarExhaustion = "{=V542tneW}War Exhaustion";
1516
private const string HeadingInfluenceBalancing = "{=8ZPKToTq}Influence Balancing";
1617
private const string HeadingInfluenceDecay = HeadingInfluenceBalancing + "/" + "{=vzKRX2JA}Influence Decay";
@@ -27,7 +28,7 @@ class Settings : AttributeGlobalSettings<Settings>
2728

2829
private bool _enableWarExhaustionCampaignMapWidget = true;
2930

30-
public override string Id => "DiplomacySettings_1";
31+
public override string Id => "DiplomacySettings_v1.2";
3132
public override string DisplayName => new TextObject("{=MYz8nKqq}Diplomacy").ToString();
3233
public override string FolderName => "Diplomacy";
3334
public override string FormatType => "json2";
@@ -37,25 +38,25 @@ class Settings : AttributeGlobalSettings<Settings>
3738
[SettingPropertyGroup(HeadingKingdomDiplomacy)]
3839
public bool EnableFiefFirstRight { get; set; } = true;
3940

40-
[SettingPropertyInteger("{=ZRlNvsev}Minimum War Duration in Days", 0, 500, Order = 1, RequireRestart = false, HintText = "{=vuFT5ns8}The minimum duration (in days) that a war can last before proposing peace. Default value is 10.")]
41+
[SettingPropertyInteger("{=ZRlNvsev}Minimum War Duration in Days", 0, 500, Order = 1, RequireRestart = false, HintText = "{=vuFT5ns8}The minimum duration (in days) that a war can last before proposing peace. Default value is 21 (quarter of a standard game year).")]
4142
[SettingPropertyGroup(HeadingKingdomDiplomacy)]
42-
public int MinimumWarDurationInDays { get; set; } = 10;
43+
public int MinimumWarDurationInDays { get; set; } = 21;
4344

44-
[SettingPropertyInteger("{=4MzQHMVj}Declare War Cooldown in Days", 0, 500, Order = 2, RequireRestart = false, HintText = "{=q2duqN8d}The minimum duration (in days) to declare war after making peace. Default value is 100.")]
45+
[SettingPropertyInteger("{=4MzQHMVj}Declare War Cooldown in Days", 0, 500, Order = 2, RequireRestart = false, HintText = "{=q2duqN8d}The minimum duration (in days) before re-declaring war on the same kingdom after making peace. Default value is 21 (quarter of a standard game year).")]
4546
[SettingPropertyGroup(HeadingKingdomDiplomacy)]
46-
public int DeclareWarCooldownInDays { get; set; } = 100;
47+
public int DeclareWarCooldownInDays { get; set; } = 21;
4748

4849
[SettingPropertyBool("{=2XC8QHkl}Enable Alliances", Order = 3, RequireRestart = false, HintText = "{=5YJBZx28}If disabled, this disables the ability to form alliances for both player and AI kingdoms. Default value is enabled.")]
4950
[SettingPropertyGroup(HeadingKingdomDiplomacy)]
5051
public bool EnableAlliances { get; set; } = true;
5152

52-
[SettingPropertyInteger("{=H6XMjwpF}Minimum Alliance Duration in Days", 0, 500, Order = 4, RequireRestart = false, HintText = "{=RrsWhIWi}The minimum duration (in days) that an alliance can last. Default value is 10.")]
53+
[SettingPropertyInteger("{=H6XMjwpF}Minimum Alliance Duration in Days", 0, 500, Order = 4, RequireRestart = false, HintText = "{=RrsWhIWi}The minimum duration (in days) that an alliance will last before it can be broken. Default value is 42 (half of a standard game year).")]
5354
[SettingPropertyGroup(HeadingKingdomDiplomacy)]
54-
public int MinimumAllianceDuration { get; set; } = 10;
55+
public int MinimumAllianceDuration { get; set; } = 42;
5556

56-
[SettingPropertyInteger("{=V35hUfcc}Non-Aggression Pact Duration in Days", 0, 1000, Order = 5, RequireRestart = false, HintText = "{=KXLGZEPh}The duration (in days) that a non-aggression pact will last. Default value is 100.")]
57+
[SettingPropertyInteger("{=V35hUfcc}Non-Aggression Pact Duration in Days", 0, 1000, Order = 5, RequireRestart = false, HintText = "{=KXLGZEPh}The duration (in days) that a non-aggression pact will last. Default value is 84 (one standard game year).")]
5758
[SettingPropertyGroup(HeadingKingdomDiplomacy)]
58-
public int NonAggressionPactDuration { get; set; } = 100;
59+
public int NonAggressionPactDuration { get; set; } = 84;
5960

6061
[SettingPropertyInteger("{=G8BhBnRG}Non-Aggression Pact Tendency", -100, 100, Order = 6, RequireRestart = false, HintText = "{=907ER5u9}Score modifier affecting the tendency of kingdoms to form non-aggression pacts. Increasing the modifier makes non-aggression pacts more desirable to AI kingdoms. Default value is 0.")]
6162
[SettingPropertyGroup(HeadingKingdomDiplomacy)]
@@ -184,9 +185,9 @@ public bool EnableWarExhaustionCampaignMapWidget
184185
[SettingPropertyGroup(HeadingGoldCosts)]
185186
public float ScalingWarReparationsGoldCostMultiplier { get; set; } = 50;
186187

187-
[SettingPropertyInteger(displayName: "{=Cr6a5Jap}Defeated War Reparations Gold Cost", 0, 10000, Order = 12, RequireRestart = false, HintText = "{=NH4GNKva}The cost in gold for losing a war of attrition against another kingdom, measured in millions. The default value is 500.")]
188+
[SettingPropertyInteger(displayName: "{=Cr6a5Jap}Defeated War Reparations Gold Cost", 0, 10000, Order = 12, RequireRestart = false, HintText = "{=NH4GNKva}The cost in gold for losing a war of attrition against another kingdom, measured in millions. The default value is 200.")]
188189
[SettingPropertyGroup(HeadingGoldCosts)]
189-
public int DefeatedGoldCost { get; set; } = 500;
190+
public int DefeatedGoldCost { get; set; } = 200;
190191

191192
// Influence Costs
192193

src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionManager.EventHandling.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ public void AddCasualtyWarExhaustion(Kingdoms kingdoms, MapEvent mapEvent)
3737
AddWarExhaustion(kingdoms, WarExhaustionType.Casualty, warExhaustionToAdd, battleCasualtyRecord);
3838
}
3939

40+
public void AddCasualtyWarExhaustion(Kingdom kingdom1, Kingdom kingdom2, int kingdom1Casualties, int kingdom2Casualties, TextObject? kingdom1PartyName = null, TextObject? kingdom2PartyName = null)
41+
{
42+
CreateKey(kingdom1, kingdom2, out var kingdoms);
43+
if (kingdoms is null) return;
44+
45+
var warExhaustionToAdd = GetCasualtyWarExhaustionDelta(kingdoms, kingdom1Casualties, kingdom2Casualties, kingdom1PartyName, kingdom2PartyName, out var battleCasualtyRecord);
46+
AddWarExhaustion(kingdoms, WarExhaustionType.Casualty, warExhaustionToAdd, battleCasualtyRecord);
47+
}
48+
4049
#if v100 || v101 || v102 || v103
4150
public void AddRaidWarExhaustion(Kingdoms kingdoms, MapEvent mapEvent)
4251
{
@@ -237,6 +246,27 @@ private static WarExhaustionRecord GetCasualtyWarExhaustionDelta(Kingdoms kingdo
237246
}
238247
}
239248

249+
private WarExhaustionRecord GetCasualtyWarExhaustionDelta(Kingdoms kingdoms, int kingdom1Casualties, int kingdom2Casualties, TextObject? kingdom1PartyName, TextObject? kingdom2PartyName, out BattleCasualtyRecord battleCasualtyRecord)
250+
{
251+
var warExhaustionPerCasualty = Settings.Instance!.WarExhaustionPerCasualty;
252+
float kingdom1WarExhaustion = kingdom1Casualties * warExhaustionPerCasualty;
253+
float kingdom2WarExhaustion = kingdom2Casualties * warExhaustionPerCasualty;
254+
255+
kingdom1PartyName ??= kingdoms.Kingdom1.Name;
256+
kingdom2PartyName ??= kingdoms.Kingdom2.Name;
257+
var hasActiveQuest = !IsValidQuestState(kingdoms.Kingdom1, kingdoms.Kingdom2);
258+
if (kingdoms.ReversedKeyOrder)
259+
{
260+
battleCasualtyRecord = new(CampaignTime.Now, kingdom2Casualties, kingdom2WarExhaustion, kingdom1Casualties, kingdom1WarExhaustion, kingdom2PartyName, kingdom1PartyName, eventRelatedSettlement: null);
261+
return new(kingdom2WarExhaustion, kingdom1WarExhaustion, hasActiveQuest: hasActiveQuest, considerRangeLimits: false);
262+
}
263+
else
264+
{
265+
battleCasualtyRecord = new(CampaignTime.Now, kingdom1Casualties, kingdom1WarExhaustion, kingdom2Casualties, kingdom2WarExhaustion, kingdom1PartyName, kingdom2PartyName, eventRelatedSettlement: null);
266+
return new(kingdom1WarExhaustion, kingdom2WarExhaustion, hasActiveQuest: hasActiveQuest, considerRangeLimits: false);
267+
}
268+
}
269+
240270
private WarExhaustionRecord GetRaidWarExhaustionDelta(Kingdoms kingdoms, Village raidedVillage, TextObject raidingPartyName, out RaidRecord raidRecord)
241271
{
242272
float attackerSideWarExhaustion = 0f;

src/Bannerlord.Diplomacy/WarExhaustion/WarExhaustionManager.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,10 @@ public List<WarExhaustionEventRecord> GetWarExhaustionEventRecords(Kingdom kingd
144144

145145
public static bool IsCriticalWarExhaustion(float warExhaustionValue, bool checkMaxWarExhaustion = false) => (warExhaustionValue / MaxWarExhaustion >= CriticalThresholdWarExhaustion) && (!checkMaxWarExhaustion || warExhaustionValue < MaxWarExhaustion);
146146

147-
private static bool KingdomsAreValid(Kingdom? kingdom1, Kingdom? kingdom2) => kingdom1 is not null && kingdom2 is not null && kingdom1.Id != default && kingdom2.Id != default && kingdom1.Id != kingdom2.Id;
147+
private static bool KingdomsAreValid(Kingdom? kingdom1, Kingdom? kingdom2) =>
148+
kingdom1 is not null && kingdom2 is not null && !kingdom1.IsEliminated && !kingdom2.IsEliminated
149+
&& kingdom1.Id != default && kingdom2.Id != default
150+
&& kingdom1.Id != kingdom2.Id && kingdom1.IsAtWarWith(kingdom2);
148151

149152
internal static string? CreateKey(Kingdom kingdom1, Kingdom kingdom2, out Kingdoms? kingdoms)
150153
{

src/Bannerlord.Diplomacy/_Module/ModuleData/Languages/std_module_strings_xml.xml

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -161,33 +161,42 @@
161161

162162
<string id="sBw5Qzq3" text="Kingdom Diplomacy" />
163163
<string id="ZRlNvsev" text="Minimum War Duration in Days" />
164-
<string id="vuFT5ns8" text="The minimum duration (in days) that a war can last before proposing peace. Default value is 10." />
164+
<string id="vuFT5ns8" text="The minimum duration (in days) that a war can last before proposing peace. Default value is 21 (quarter of a standard game year)." />
165165
<string id="4MzQHMVj" text="Declare War Cooldown in Days" />
166-
<string id="q2duqN8d" text="The minimum duration (in days) to declare war after making peace. Default value is 100." />
166+
<string id="q2duqN8d" text="The minimum duration (in days) before re-declaring war on the same kingdom after making peace. Default value is 21 (quarter of a standard game year)." />
167167
<string id="6m1SspFW" text="Enable Player Kingdom Diplomacy Control" />
168168
<string id="N5EouSSj" text="Gives the player full control over declaring war and making peace in the kingdom they belong to, even if they are just a vassal and not the leader of the kingdom. Default value is disabled." />
169169
<string id="tis8Ddzn" text="Allow Player To Claim Player-Taken Settlements" />
170170
<string id="TfxLCxcD" text="Gives the player the option to claim a settlement that they have taken rather than let it go to an election." />
171171
<string id="H6XMjwpF" text="Minimum Alliance Duration in Days" />
172-
<string id="RrsWhIWi" text="The minimum duration (in days) that an alliance can last. Default value is 10." />
172+
<string id="RrsWhIWi" text="The minimum duration (in days) that an alliance will last before it can be broken. Default value is 42 (half of a standard game year)." />
173173
<string id="V35hUfcc" text="Non-Aggression Pact Duration in Days"/>
174-
<string id="KXLGZEPh" text="The duration (in days) that a non-aggression pact will last. Default value is 100."/>
174+
<string id="KXLGZEPh" text="The duration (in days) that a non-aggression pact will last. Default value is 84 (one standard game year)."/>
175175
<string id="G8BhBnRG" text="Non-Aggression Pact Tendency" />
176176
<string id="907ER5u9" text="Score modifier affecting the tendency of kingdoms to form non-aggression pacts. Increasing the modifier makes non-aggression pacts more desirable to AI kingdoms. Default value is 0." />
177177
<string id="5a829TiT" text="Alliance Tendency" />
178178
<string id="7nSjs8UL" text="Score modifier affecting the tendency of kingdoms to form alliances. Increasing the modifier makes alliances more desirable to AI kingdoms. Default value is 0." />
179179
<string id="lhysZl9j" text="Action Tendency" />
180180

181+
<string id="ldLFTs92" text="Costs" />
182+
<string id="Ckd1Lsoa" text="Gold Costs" />
183+
<string id="t4hNAoD7" text="Enable Scaling Gold Costs" />
184+
<string id="5MMIDE5A" text="If enabled, this will scale gold costs of diplomatic actions and war reparations based on your kingdom size. Otherwise, the generic multipliers of 100 for diplomatic actions and 1000 for war reparations will apply. The default value is enabled." />
185+
<string id="vD270X6H" text="Scaling Gold Cost Multiplier" />
186+
<string id="Gd52NzBP" text="Multiplier for the scaling gold costs. Default value is 5." />
187+
<string id="HFtZsD6v" text="Scaling War Reparations Gold Cost Multiplier" />
188+
<string id="MIhbrqbr" text="Multiplier for the scaling of war reparations gold costs. Default value is 50." />
189+
<string id="Cr6a5Jap" text="Defeated War Reparations Gold Cost" />
190+
<string id="NH4GNKva" text="The cost in gold for losing a war of attrition against another kingdom, measured in millions. The default value is 200." />
191+
181192
<string id="SEViwYTl" text="Influence Costs" />
182193
<string id="WbOKuWbQ" text="Enable Influence Costs" />
183194
<string id="K2vLGalN" text="If disabled, this removes influence costs for war and peace declaration actions. Default value is enabled." />
184-
185195
<string id="9PlT57Nl" text="Influence Costs/Scaling" />
186196
<string id="P1g6Ht1e" text="Enable Scaling Influence Costs" />
187197
<string id="xfVFBxfj" text="If enabled, this will scale influence costs based on your kingdom size. Otherwise, flat influence costs are used. Default value is enabled." />
188198
<string id="TvAYJv5Q" text="Scaling Influence Cost Multiplier" />
189199
<string id="AQ5gRYN6" text="Multiplier for the scaling influence costs. Default value is 5." />
190-
191200
<string id="BazjeCZw" text="Influence Costs/Flat" />
192201
<string id="OnTeAgin" text="Flat Declare War Influence Cost" />
193202
<string id="O5XvybTI" text="Influence cost for declaring war on another kingdom. Default value is 500." />
@@ -204,16 +213,6 @@
204213
<string id="nMwWHj4h" text="Send Messenger Gold Cost" />
205214
<string id="ehMf7xvE" text="Gold cost for sending a messenger to another character. Default value is 100." />
206215

207-
<string id="Ckd1Lsoa" text="Gold Costs" />
208-
<string id="t4hNAoD7" text="Enable Scaling Gold Costs" />
209-
<string id="5MMIDE5A" text="If enabled, this will scale gold costs of diplomatic actions and war reparations based on your kingdom size. Otherwise, the generic multipliers of 100 for diplomatic actions and 1000 for war reparations will apply. The default value is enabled." />
210-
<string id="vD270X6H" text="Scaling Gold Cost Multiplier" />
211-
<string id="Gd52NzBP" text="Multiplier for the scaling gold costs. Default value is 5." />
212-
<string id="HFtZsD6v" text="Scaling War Reparations Gold Cost Multiplier" />
213-
<string id="MIhbrqbr" text="Multiplier for the scaling of war reparations gold costs. Default value is 50." />
214-
<string id="Cr6a5Jap" text="Defeated War Reparations Gold Cost" />
215-
<string id="NH4GNKva" text="The cost in gold for losing a war of attrition against another kingdom, measured in millions. The default value is 500." />
216-
217216
<string id="2XC8QHkl" text="Enable Alliances" />
218217
<string id="5YJBZx28" text="If disabled, this disables the ability to form alliances for both player and AI kingdoms. Default value is enabled." />
219218

0 commit comments

Comments
 (0)