Skip to content

Commit

Permalink
Release v2.12 - Stable
Browse files Browse the repository at this point in the history
  • Loading branch information
welles authored Oct 28, 2022
2 parents d046dd4 + 09e70d6 commit 962fcd5
Show file tree
Hide file tree
Showing 17 changed files with 199 additions and 16 deletions.
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project>
<PropertyGroup>
<Version>2.11.0.0</Version>
<Version>2.12.0.0</Version>
<GameVersion>v1.0.0</GameVersion>
<GameBranch>Stable</GameBranch>
<HarmonyVersion>2.2.2</HarmonyVersion>
<MCMVersion>4.7.11</MCMVersion>
<MCMVersion>5.0.0</MCMVersion>
<TargetFramework>net472</TargetFramework>
<LangVersion>8.0</LangVersion>
<GameFolder>C:\SteamCMD\apps\mb2b_stable</GameFolder>
Expand Down
6 changes: 6 additions & 0 deletions Extensions/PartyExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ public static bool IsPlayerParty(this PartyBase party)
return false;
}

// Disable for caravans
if (party?.MobileParty?.IsCaravan == true)
{
return false;
}

return owner?.IsHumanPlayerCharacter ?? false;
}

Expand Down
27 changes: 27 additions & 0 deletions L10N.resx
Original file line number Diff line number Diff line change
Expand Up @@ -907,4 +907,31 @@ Thank you!</value>
<data name="SettlementsNeverRebel_Desc" xml:space="preserve">
<value>If enabled, player owned settlements will never start a rebellion.</value>
</data>
<data name="NeverDieOfOldAge_Name" xml:space="preserve">
<value>Never Die Of Old Age</value>
</data>
<data name="NeverDieOfOldAge_Desc" xml:space="preserve">
<value>If enabled, your main character will still get sick and old, but will never actually die from old age or sickness.</value>
</data>
<data name="KillCharacterMessageTitle" xml:space="preserve">
<value>Kill {0}?</value>
</data>
<data name="KillCharacterMessage" xml:space="preserve">
<value>Should this character die?</value>
</data>
<data name="Cancel" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="KillCharacterConfirm" xml:space="preserve">
<value>Kill!</value>
</data>
<data name="TransferSettlementMessageTitle" xml:space="preserve">
<value>Transfer {0}?</value>
</data>
<data name="TransferSettlementMessage" xml:space="preserve">
<value>Should the ownership of this settlement be transfered to you?</value>
</data>
<data name="TransferSettlementConfirm" xml:space="preserve">
<value>Transfer!</value>
</data>
</root>
9 changes: 7 additions & 2 deletions Localization/L10N.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,17 @@ static L10N()

public static string GetText(string key)
{
return L10N.Values[key];
return L10N.Values.TryGetValue(key, out var text) ? text : key;
}

public static string GetTextFormat(string key, params object[] formatValues)
{
var text = Values[key];
var found = L10N.Values.TryGetValue(key, out var text);

if (!found)
{
return key;
}

for (int i = 0; i < formatValues.Length; i++)
{
Expand Down
4 changes: 2 additions & 2 deletions Localization/LocalizedSettingProperty.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MCM.Abstractions.Settings.Definitions;
using System;
using System;
using MCM.Abstractions;

namespace BannerlordCheats.Localization
{
Expand Down
2 changes: 1 addition & 1 deletion Localization/LocalizedSettingPropertyBool.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MCM.Abstractions.Settings.Definitions;
using MCM.Abstractions;

namespace BannerlordCheats.Localization
{
Expand Down
2 changes: 1 addition & 1 deletion Localization/LocalizedSettingPropertyFloatingInteger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MCM.Abstractions.Settings.Definitions;
using MCM.Abstractions;
using System;

namespace BannerlordCheats.Localization
Expand Down
2 changes: 1 addition & 1 deletion Localization/LocalizedSettingPropertyGroup.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using MCM.Abstractions.Settings.Definitions;
using MCM.Abstractions;

namespace BannerlordCheats.Localization
{
Expand Down
2 changes: 1 addition & 1 deletion Localization/LocalizedSettingPropertyInteger.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MCM.Abstractions.Settings.Definitions;
using MCM.Abstractions;

namespace BannerlordCheats.Localization
{
Expand Down
2 changes: 1 addition & 1 deletion Localization/LocalizedSettingPropertyPercent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MCM.Abstractions.Settings.Definitions;
using MCM.Abstractions;

namespace BannerlordCheats.Localization
{
Expand Down
38 changes: 38 additions & 0 deletions Patches/Characters/NeverDieOfOldAge.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;
using BannerlordCheats.Extensions;
using BannerlordCheats.Settings;
using HarmonyLib;
using JetBrains.Annotations;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.Actions;

namespace BannerlordCheats.Patches.Characters
{
[HarmonyPatch(typeof(KillCharacterAction), nameof(KillCharacterAction.ApplyByOldAge))]
public static class NeverDieOfOldAge
{
[HarmonyPrefix]
[UsedImplicitly]
public static bool ApplyByOldAge(
ref Hero victim,
ref bool showNotification)
{
try
{
if (victim.IsPlayer()
&& BannerlordCheatsSettings.Instance?.NeverDieOfOldAge == true)
{
return false;
}

return true;
}
catch (Exception e)
{
SubModule.LogError(e, typeof(NeverDieOfOldAge));

return true;
}
}
}
}
2 changes: 2 additions & 0 deletions Patches/General/EnableHotkeyTipsEncyclopedia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public static void OpenEncyclopedia()
Message.Show("Encyclopedia Screen Cheat Hotkeys:");
Message.Show("CTRL + H: Add 1 soldier of the selected troop type to the party.");
Message.Show("CTRL + SHIFT + H: Add 10 soldiers of the selected troop type to the party.");
Message.Show("CTRL + X: Kill the selected character.");
Message.Show("CTRL + H: Transfer ownership of settlement to you.");
}
}
catch (Exception e)
Expand Down
45 changes: 45 additions & 0 deletions Patches/General/EnableHotkeysKillCharacter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using BannerlordCheats.Extensions;
using BannerlordCheats.Localization;
using BannerlordCheats.Settings;
using HarmonyLib;
using JetBrains.Annotations;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.ViewModelCollection.Encyclopedia.Pages;
using TaleWorlds.InputSystem;
using TaleWorlds.Library;

namespace BannerlordCheats.Patches.General
{
[HarmonyPatch(typeof(EncyclopediaPageVM), "OnTick")]
public static class EnableHotkeysKillCharacter
{
[UsedImplicitly]
[HarmonyPostfix]
public static void OnTick(ref EncyclopediaPageVM __instance)
{
try
{
if (__instance is EncyclopediaHeroPageVM
&& __instance.Obj is Hero hero
&& BannerlordCheatsSettings.Instance?.EnableHotkeys == true)
{
if (Keys.IsKeyPressed(InputKey.X, InputKey.LeftControl))
{
InformationManager.ShowInquiry(
new InquiryData(L10N.GetTextFormat("KillCharacterMessageTitle", hero.Name),
L10N.GetText("KillCharacterMessage"), true, true,
L10N.GetText("KillCharacterConfirm"), L10N.GetText("Cancel"),
() => KillCharacterAction.ApplyByMurder(hero), null), true, true);
}
}
}
catch (Exception e)
{
SubModule.LogError(e, typeof(EnableHotkeysKillCharacter));
}
}
}
}
46 changes: 46 additions & 0 deletions Patches/General/EnableHotkeysTransferSettlement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using BannerlordCheats.Extensions;
using BannerlordCheats.Localization;
using BannerlordCheats.Settings;
using HarmonyLib;
using JetBrains.Annotations;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.CampaignSystem.ViewModelCollection.Encyclopedia.Pages;
using TaleWorlds.InputSystem;
using TaleWorlds.Library;

namespace BannerlordCheats.Patches.General
{
[HarmonyPatch(typeof(EncyclopediaPageVM), "OnTick")]
public static class EnableHotkeysTransferSettlement
{
[UsedImplicitly]
[HarmonyPostfix]
public static void OnTick(ref EncyclopediaPageVM __instance)
{
try
{
if (__instance is EncyclopediaSettlementPageVM
&& __instance.Obj is Settlement settlement
&& (settlement.IsCastle || settlement.IsTown)
&& BannerlordCheatsSettings.Instance?.EnableHotkeys == true)
{
if (Keys.IsKeyPressed(InputKey.H, InputKey.LeftControl))
{
InformationManager.ShowInquiry(
new InquiryData(L10N.GetTextFormat("TransferSettlementMessageTitle", settlement.Name),
L10N.GetText("TransferSettlementMessage"), true, true,
L10N.GetText("TransferSettlementConfirm"), L10N.GetText("Cancel"),
() => ChangeOwnerOfSettlementAction.ApplyByDefault(Hero.MainHero, settlement), null), true, true);
}
}
}
catch (Exception e)
{
SubModule.LogError(e, typeof(EnableHotkeysTransferSettlement));
}
}
}
}
16 changes: 12 additions & 4 deletions Patches/Settlements/RebellionChancePercentage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using BannerlordCheats.Extensions;
using System;
using BannerlordCheats.Extensions;
using BannerlordCheats.Settings;
using HarmonyLib;
using JetBrains.Annotations;
Expand All @@ -16,10 +17,17 @@ public static void CheckRebellionEvent(
ref Settlement settlement,
ref bool __result)
{
if (settlement.IsPlayerSettlement()
&& BannerlordCheatsSettings.Instance?.SettlementsNeverRebel == true)
try
{
__result = false;
if (settlement.IsPlayerSettlement()
&& BannerlordCheatsSettings.Instance?.SettlementsNeverRebel == true)
{
__result = false;
}
}
catch (Exception e)
{
SubModule.LogError(e, typeof(RebellionChancePercentage));
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion Settings/BannerlordCheatsSettings.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using BannerlordCheats.Localization;
using System.Reflection;
using System.Text.RegularExpressions;
using MCM.Abstractions.Settings.Base.PerSave;
using MCM.Abstractions.Base.PerSave;

namespace BannerlordCheats.Settings
{
Expand Down Expand Up @@ -329,6 +329,10 @@ public BannerlordCheatsSettings()
[LocalizedSettingPropertyBool(nameof(PerfectRelationships))]
public bool PerfectRelationships { get; set; } = false;

[LocalizedSettingPropertyGroup(CharactersGroupName)]
[LocalizedSettingPropertyBool(nameof(NeverDieOfOldAge))]
public bool NeverDieOfOldAge { get; set; } = false;

[LocalizedSettingPropertyGroup(CharactersGroupName)]
[LocalizedSettingPropertyBool(nameof(BarterOfferAlwaysAccepted))]
public bool BarterOfferAlwaysAccepted { get; set; } = false;
Expand Down
2 changes: 2 additions & 0 deletions hotkeys.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ CTRL + SHIFT + X │ Inventory │ Add 100.000 gold to y
CTRL + X │ Clan │ Add 1.000 influence to your clan
CTRL + H │ Encyclopedia page of a troop type │ Add 1 soldiers of the troop type to your party
CTRL + SHIFT + H │ Encyclopedia page of a troop type │ Add 10 soldiers of the troop type to your party
CTRL + X │ Encyclopedia page of a character │ Kill the character
CTRL + H │ Encyclopedia page of a settlement │ Transfer ownership of the settlement to you
CTRL + H │ Inventory (with item selected) │ Add 1 of the selected item to your inventory
CTRL + SHIFT + H │ Inventory (with item selected) │ Add 100 of the selected item to your inventory
CTRL + X │ Party (with troop selected) │ Add experience to the selected troop
Expand Down

0 comments on commit 962fcd5

Please sign in to comment.