Skip to content

Commit

Permalink
Merge pull request #20 from welles/develop
Browse files Browse the repository at this point in the history
Release v1.6.1 - Main
  • Loading branch information
welles authored Aug 22, 2020
2 parents a64c5dd + 7326657 commit 9179231
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 64 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
bin/
obj/
.vs/
packages/
packages/
.idea/
7 changes: 2 additions & 5 deletions BannerlordCheats.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -29,6 +30,7 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony, Version=2.0.2.0, Culture=neutral, processorArchitecture=MSIL">
Expand All @@ -37,8 +39,6 @@
<Reference Include="MCMv3, Version=3.1.9.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Bannerlord.MCM.3.1.9\lib\net472\MCMv3.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="SandBox">
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\Mount &amp; Blade II Bannerlord\Modules\SandBox\bin\Win64_Shipping_Client\SandBox.dll</HintPath>
<Private>False</Private>
Expand All @@ -47,7 +47,6 @@
<HintPath>..\..\..\..\Program Files (x86)\Steam\steamapps\common\Mount &amp; Blade II Bannerlord\Modules\SandBox\bin\Win64_Shipping_Client\SandBox.GauntletUI.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="TaleWorlds.CampaignSystem">
Expand Down Expand Up @@ -202,9 +201,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="L10N.resx">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<LastGenOutput>L10N.Designer.cs</LastGenOutput>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
17 changes: 4 additions & 13 deletions Patches/Army/ArmyCohesionPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,21 @@
using HarmonyLib;
using System.Linq;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.GameComponents.Map;

namespace BannerlordCheats.Patches
{
[HarmonyPatch(typeof(DefaultArmyManagementCalculationModel), nameof(DefaultArmyManagementCalculationModel.CalculateCohesionChange))]
[HarmonyPatch(typeof(Army), nameof(Army.CohesionChange), MethodType.Getter)]
public static class ArmyCohesionPatch
{
[HarmonyPostfix]
public static void CalculateCohesionChange(Army army, StatExplainer explanation, ref float __result)
public static void CohesionChange(ref Army __instance, ref float __result)
{
if (army != null
&& army.Parties.Any(x => x?.IsMainParty ?? false))
if (__instance != null
&& __instance.Parties.Any(x => x?.IsMainParty ?? false))
{
var factor = BannerlordCheatsSettings.Instance.ArmyCohesionLossPercentage / 100f;

__result *= factor;

if (explanation != null)
{
foreach (var line in explanation.Lines)
{
line.Number *= factor;
}
}
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion Patches/Combat/AlwaysCrushThrough.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using BannerlordCheats.Settings;
using HarmonyLib;
using SandBox;
using TaleWorlds.Core;
using TaleWorlds.MountAndBlade;

namespace BannerlordCheats.Patches.Combat
Expand All @@ -9,7 +10,7 @@ namespace BannerlordCheats.Patches.Combat
public class AlwaysCrushThrough
{
[HarmonyPostfix]
public static void DecideCrushedThrough(Agent attackerAgent, Agent defenderAgent, float totalAttackEnergy, float defenderStunPeriod, float impactPoint, ref bool __result)
public static void DecideCrushedThrough(Agent attackerAgent, Agent defenderAgent, float totalAttackEnergy, Agent.UsageDirection attackDirection, StrikeType strikeType, WeaponComponentData defendItem, bool isCouchedLanceHit, ref bool __result)
{
if ((attackerAgent?.IsPlayerControlled ?? false)
&& BannerlordCheatsSettings.Instance.AlwaysCrushThroughShields)
Expand Down
6 changes: 3 additions & 3 deletions Patches/Combat/BanditHideoutTroopLimitPatch.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
using BannerlordCheats.Settings;
using HarmonyLib;
using TaleWorlds.CampaignSystem.SandBox.GameComponents;
using TaleWorlds.CampaignSystem.SandBox.GameComponents.Map;

namespace BannerlordCheats.Patches
{
[HarmonyPatch(typeof(DefaultTroopCountLimitModel), nameof(DefaultTroopCountLimitModel.GetHideoutBattlePlayerMaxTroopCount))]
[HarmonyPatch(typeof(DefaultBanditDensityModel), nameof(DefaultBanditDensityModel.PlayerMaximumTroopCountForHideoutMission), MethodType.Getter)]
public static class BanditHideoutTroopLimitPatch
{
[HarmonyPostfix]
public static void GetHideoutBattlePlayerMaxTroopCount(ref int __result)
public static void PlayerMaximumTroopCountForHideoutMission(ref int __result)
{
__result += BannerlordCheatsSettings.Instance.BanditHideoutTroopLimit;
}
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

[assembly: AssemblyTitle("BannerlordCheats")]
[assembly: AssemblyDescription("Adds various cheats to Mount & Blade: Bannerlord.")]
[assembly: AssemblyVersion("1.6.0.0")]
[assembly: AssemblyVersion("1.6.1.0")]
42 changes: 3 additions & 39 deletions SubModule.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using HarmonyLib;
using System;
using System.Diagnostics;
using System.Text;
using System.Windows;
using TaleWorlds.MountAndBlade;

namespace BannerlordCheats
Expand All @@ -11,43 +7,11 @@ public class SubModule : MBSubModuleBase
{
protected override void OnSubModuleLoad()
{
try
{
base.OnSubModuleLoad();
base.OnSubModuleLoad();

var harmony = new Harmony("BannerlordCheats");
var harmony = new Harmony("BannerlordCheats");

harmony.PatchAll();
}
catch (Exception e)
{
var text = new StringBuilder();
text.AppendLine("Bannerlord Cheats could not load!");
text.AppendLine();
text.AppendLine("Please check if this game version is compatible with the mod.");
text.AppendLine();
text.AppendLine("If it is, please post the following error message to the mod page comments. (Click the OK button below to copy the error message to the clipboard and open the mod page.)");
text.AppendLine();
text.AppendLine("-------------------------------------------------------------------------------");
text.AppendLine();
text.AppendLine(e.ToString());

var result = MessageBox.Show(text.ToString(), "Bannerlord Cheats could not load!", MessageBoxButton.OKCancel, MessageBoxImage.Error, MessageBoxResult.OK);

if (result == MessageBoxResult.OK)
{
try
{
Clipboard.Clear();
Clipboard.SetText(e.ToString());

Process.Start("https://www.nexusmods.com/mountandblade2bannerlord/mods/1839?tab=posts");
}
catch { }
}

throw;
}
harmony.PatchAll();
}
}
}
2 changes: 1 addition & 1 deletion SubModule.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Module>
<Name value="Cheats"/>
<Id value="Cheats"/>
<Version value="v1.6.0"/>
<Version value="v1.6.1"/>
<SingleplayerModule value="true"/>
<MultiplayerModule value="false"/>
<Official value="false"/>
Expand Down

0 comments on commit 9179231

Please sign in to comment.