Skip to content

Commit

Permalink
Release v2.3 - Beta
Browse files Browse the repository at this point in the history
  • Loading branch information
welles authored Jun 21, 2021
2 parents d24174a + 15cf2c7 commit 15dc585
Show file tree
Hide file tree
Showing 16 changed files with 206 additions and 161 deletions.
8 changes: 4 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project>
<PropertyGroup>
<Version>2.2.0.0</Version>
<GameVersion>1.5.9</GameVersion>
<GameBranch>Stable</GameBranch>
<Version>2.3.0.0</Version>
<GameVersion>1.6.0</GameVersion>
<GameBranch>Beta</GameBranch>
<AdditionalInfo></AdditionalInfo>
<HarmonyVersion>2.0.4</HarmonyVersion>
<MCMVersion>4.3</MCMVersion>
<TargetFramework>net472</TargetFramework>
<LangVersion>8.0</LangVersion>
<GameFolder>C:\SteamCMD\mb2b_stable</GameFolder>
<GameFolder>C:\SteamCMD\mb2b_beta</GameFolder>
</PropertyGroup>
</Project>
7 changes: 4 additions & 3 deletions Extensions/SiegeExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using TaleWorlds.CampaignSystem;
using System.Linq;
using TaleWorlds.CampaignSystem;

namespace BannerlordCheats.Extensions
{
public static class SiegeExtensions
{
public static bool IsPlayerSiege(this SiegeEvent siege)
public static bool IsPlayerSide(this ISiegeEventSide side)
{
return siege?.IsPlayerSiegeEvent ?? false;
return side?.SiegeParties?.Any(x => x.IsPlayerParty()) ?? false;
}
}
}
4 changes: 2 additions & 2 deletions Launch.run.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Launch" type="RunExe" factoryName=".NET Executable">
<option name="EXE_PATH" value="$PROJECT_DIR$/../../../../SteamCMD/mb2b_stable/bin/Win64_Shipping_Client/Bannerlord.exe" />
<option name="EXE_PATH" value="$PROJECT_DIR$/../../../../SteamCMD/mb2b_beta/bin/Win64_Shipping_Client/Bannerlord.exe" />
<option name="PROGRAM_PARAMETERS" value="/singleplayer _MODULES_*Bannerlord.Harmony*Bannerlord.ButterLib*Bannerlord.UIExtenderEx*Bannerlord.MBOptionScreen*Native*SandBoxCore*CustomBattle*SandBox*StoryMode*Cheats*_MODULES_" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../../../../SteamCMD/mb2b_stable/bin/Win64_Shipping_Client" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../../../../SteamCMD/mb2b_beta/bin/Win64_Shipping_Client" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
Expand Down
8 changes: 6 additions & 2 deletions Patches/Combat/BattleInfluenceGainPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ namespace BannerlordCheats.Patches.Combat
public static class BattleInfluenceGainPatch
{
[HarmonyPostfix]
public static void CalculateInfluenceGain(ref PartyBase party, ref float influenceValueOfBattle, ref float contributionShare, ref ExplainedNumber result, ref float __result)
public static void CalculateInfluenceGain(
ref PartyBase party,
ref float influenceValueOfBattle,
ref float contributionShare,
ref ExplainedNumber __result)
{
if (party.IsPlayerParty()
&& BannerlordCheatsSettings.TryGetModifiedValue(x => x.InfluenceRewardMultiplier, out var influenceRewardMultiplier))
{
__result *= influenceRewardMultiplier;
__result.AddMultiplier(influenceRewardMultiplier);
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions Patches/Combat/BattleRenownGainPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ namespace BannerlordCheats.Patches.Combat
public static class BattleRenownGainPatch
{
[HarmonyPostfix]
public static void CalculateRenownGain(ref PartyBase party, ref float renownValueOfBattle, ref float contributionShare, ref ExplainedNumber result, ref float __result)
public static void CalculateRenownGain(
ref PartyBase party,
ref float renownValueOfBattle,
ref float contributionShare,
ref ExplainedNumber __result)
{
if (party.IsPlayerParty()
&& BannerlordCheatsSettings.TryGetModifiedValue(x => x.RenownRewardMultiplier, out var renownRewardMultiplier))
{
__result *= renownRewardMultiplier;
__result.AddMultiplier(renownRewardMultiplier);
}
}
}
Expand Down
31 changes: 22 additions & 9 deletions Patches/Combat/InfiniteAmmo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,38 @@
using BannerlordCheats.Settings;
using HarmonyLib;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.MountAndBlade;

namespace BannerlordCheats.Patches.Combat
{
[HarmonyPatch(typeof(Agent), "OnWeaponAmountChange")]
public static class InfiniteAmmoValue
[HarmonyPatch(typeof(Mission), "OnAgentShootMissile")]
public static class InfiniteAmmo
{
[HarmonyPrefix]
public static void OnWeaponAmountChange(ref EquipmentIndex slotIndex, ref short amount, ref Agent __instance)
[HarmonyPostfix]
public static void OnAgentShootMissile(
ref Agent shooterAgent,
ref EquipmentIndex weaponIndex,
ref Vec3 position,
ref Vec3 velocity,
ref Mat3 orientation,
ref bool hasRigidBody,
ref bool isPrimaryWeaponShot,
ref int forcedMissileIndex)
{
if (__instance.IsPlayer()
if (shooterAgent.IsPlayer()
&& BannerlordCheatsSettings.TryGetModifiedValue(x => x.InfiniteAmmo, out var infiniteAmmo)
&& infiniteAmmo)
{
var fullAmount = __instance.Equipment[slotIndex].MaxAmmo;

if (amount < fullAmount)
for (var index = EquipmentIndex.WeaponItemBeginSlot; index < EquipmentIndex.NumAllWeaponSlots; ++index)
{
__instance.SetWeaponAmountInSlot(slotIndex, fullAmount, false);
var missionWeapon = shooterAgent.Equipment[index];

if (missionWeapon.IsAnyConsumable(out _)
&& missionWeapon.Amount <= missionWeapon.ModifiedMaxAmount)
{
shooterAgent.SetWeaponAmountInSlot(index, missionWeapon.ModifiedMaxAmount, true);
}
}
}
}
Expand Down
56 changes: 36 additions & 20 deletions Patches/Combat/PartyInfiniteAmmo.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
using BannerlordCheats.Settings;
using BannerlordCheats.Extensions;
using BannerlordCheats.Settings;
using HarmonyLib;
using TaleWorlds.Core;
using TaleWorlds.Library;
using TaleWorlds.MountAndBlade;

namespace BannerlordCheats.Patches.Combat
{
// [HarmonyPatch(typeof(Agent), "OnWeaponAmountChange")]
// public static class PartyInfiniteAmmo
// {
// [HarmonyPrefix]
// public static void OnWeaponAmountChange(EquipmentIndex slotIndex, short amount, ref Agent __instance)
// {
// if (__instance != null
// && (Mission.Current?.PlayerTeam?.ActiveAgents.Contains(__instance) ?? false)
// && BannerlordCheatsSettings.Instance.PartyInfiniteAmmo)
// {
// var fullAmount = __instance.Equipment[slotIndex].MaxAmmo;
//
// if (amount < fullAmount)
// {
// __instance.SetWeaponAmountInSlot(slotIndex, fullAmount, false);
// }
// }
// }
// }
[HarmonyPatch(typeof(Mission), "OnAgentShootMissile")]
public static class PartyInfiniteAmmo
{
[HarmonyPostfix]
public static void OnAgentShootMissile(
ref Agent shooterAgent,
ref EquipmentIndex weaponIndex,
ref Vec3 position,
ref Vec3 velocity,
ref Mat3 orientation,
ref bool hasRigidBody,
ref bool isPrimaryWeaponShot,
ref int forcedMissileIndex)
{
if (!shooterAgent.IsPlayer()
&& shooterAgent.Origin.TryGetParty(out var party)
&& party.IsPlayerParty()
&& BannerlordCheatsSettings.TryGetModifiedValue(x => x.PartyInfiniteAmmo, out var partyInfiniteAmmo)
&& partyInfiniteAmmo)
{
for (var index = EquipmentIndex.WeaponItemBeginSlot; index < EquipmentIndex.NumAllWeaponSlots; ++index)
{
var missionWeapon = shooterAgent.Equipment[index];

if (missionWeapon.IsAnyConsumable(out _)
&& missionWeapon.Amount <= missionWeapon.ModifiedMaxAmount)
{
shooterAgent.SetWeaponAmountInSlot(index, missionWeapon.ModifiedMaxAmount, true);
}
}
}
}
}
}
43 changes: 25 additions & 18 deletions Patches/General/CharacterAttributesCheatPatch.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using BannerlordCheats.Extensions;
using BannerlordCheats.Extensions;
using BannerlordCheats.Localization;
using BannerlordCheats.Settings;
using HarmonyLib;
using SandBox.GauntletUI;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.ViewModelCollection;
using TaleWorlds.Core;
using TaleWorlds.Engine.Screens;
Expand All @@ -29,12 +29,12 @@ public static void OnApplicationTick()

var currentHero = charVM.CurrentCharacter.Hero;

currentHero.SetAttributeValue(CharacterAttributesEnum.Control, 10);
currentHero.SetAttributeValue(CharacterAttributesEnum.Cunning, 10);
currentHero.SetAttributeValue(CharacterAttributesEnum.Endurance, 10);
currentHero.SetAttributeValue(CharacterAttributesEnum.Intelligence, 10);
currentHero.SetAttributeValue(CharacterAttributesEnum.Social, 10);
currentHero.SetAttributeValue(CharacterAttributesEnum.Vigor, 10);
CharacterAttributesCheatPatch.SetMaximum(currentHero, DefaultCharacterAttributes.Control);
CharacterAttributesCheatPatch.SetMaximum(currentHero, DefaultCharacterAttributes.Cunning);
CharacterAttributesCheatPatch.SetMaximum(currentHero, DefaultCharacterAttributes.Endurance);
CharacterAttributesCheatPatch.SetMaximum(currentHero, DefaultCharacterAttributes.Intelligence);
CharacterAttributesCheatPatch.SetMaximum(currentHero, DefaultCharacterAttributes.Social);
CharacterAttributesCheatPatch.SetMaximum(currentHero, DefaultCharacterAttributes.Vigor);

charVM.RefreshValues();

Expand All @@ -44,46 +44,53 @@ public static void OnApplicationTick()
}
else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D1))
{
CharacterAttributesCheatPatch.AddPoint(CharacterAttributesEnum.Vigor);
CharacterAttributesCheatPatch.AddPoint(DefaultCharacterAttributes.Vigor);
}
else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D2))
{
CharacterAttributesCheatPatch.AddPoint(CharacterAttributesEnum.Control);
CharacterAttributesCheatPatch.AddPoint(DefaultCharacterAttributes.Control);
}
else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D3))
{
CharacterAttributesCheatPatch.AddPoint(CharacterAttributesEnum.Endurance);
CharacterAttributesCheatPatch.AddPoint(DefaultCharacterAttributes.Endurance);
}
else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D4))
{
CharacterAttributesCheatPatch.AddPoint(CharacterAttributesEnum.Cunning);
CharacterAttributesCheatPatch.AddPoint(DefaultCharacterAttributes.Cunning);
}
else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D5))
{
CharacterAttributesCheatPatch.AddPoint(CharacterAttributesEnum.Social);
CharacterAttributesCheatPatch.AddPoint(DefaultCharacterAttributes.Social);
}
else if (Keys.IsKeyPressed(InputKey.LeftControl, InputKey.D6))
{
CharacterAttributesCheatPatch.AddPoint(CharacterAttributesEnum.Intelligence);
CharacterAttributesCheatPatch.AddPoint(DefaultCharacterAttributes.Intelligence);
}
}
}

private static void AddPoint(CharacterAttributesEnum type)
private static void SetMaximum(Hero hero, CharacterAttribute attribute)
{
var changeAmount = 10 - hero.GetAttributeValue(attribute);

hero.HeroDeveloper.AddAttribute(attribute, changeAmount, false);
}

private static void AddPoint(CharacterAttribute attribute)
{
var charVM = ScreenManager.TopScreen.GetViewModel<CharacterDeveloperVM>();

var currentHero = charVM.CurrentCharacter.Hero;

var oldValue = currentHero.GetAttributeValue(type);
var oldValue = currentHero.GetAttributeValue(attribute);

if (oldValue >= 10) { return; }

currentHero.SetAttributeValue(type, oldValue + 1);
currentHero.HeroDeveloper.AddAttribute(attribute, 1, false);

charVM.RefreshValues();

var message = string.Format(L10N.GetText("AddAttributePointMessage"), Enum.GetName(typeof(CharacterAttributesEnum), type), currentHero.Name);
var message = string.Format(L10N.GetText("AddAttributePointMessage"), attribute.Name, currentHero.Name);

InformationManager.DisplayMessage(new InformationMessage(message, Color.White));
}
Expand Down
24 changes: 12 additions & 12 deletions Patches/General/CheatModeOverridePatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace BannerlordCheats.Patches.General
{
// [HarmonyPatch(typeof(Game), nameof(Game.CheatMode), MethodType.Getter)]
// public static class CheatModeOverridePatch
// {
// [HarmonyPostfix]
// public static void CheatMode(ref bool __result)
// {
// if (BannerlordCheatsSettings.TryGetModifiedValue(x => x.OverrideCheatMode, out var overrideCheatMode))
// {
// __result |= overrideCheatMode;
// }
// }
// }
[HarmonyPatch(typeof(Game), nameof(Game.CheatMode), MethodType.Getter)]
public static class CheatModeOverridePatch
{
[HarmonyPostfix]
public static void CheatMode(ref bool __result)
{
if (BannerlordCheatsSettings.TryGetModifiedValue(x => x.OverrideCheatMode, out var overrideCheatMode))
{
__result |= overrideCheatMode;
}
}
}
}
26 changes: 13 additions & 13 deletions Patches/Map/DefaultPartySpeedCalculatingModelPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

namespace BannerlordCheats.Patches.Map
{
[HarmonyPatch(typeof(DefaultPartySpeedCalculatingModel), nameof(DefaultPartySpeedCalculatingModel.CalculateFinalSpeed))]
public static class DefaultPartySpeedCalculatingModelPatch
{
[HarmonyPostfix]
public static void CalculateFinalSpeed(ref MobileParty mobileParty, ref ExplainedNumber finalSpeed, ref ExplainedNumber __result)
{
if (mobileParty.IsPlayerParty()
&& BannerlordCheatsSettings.TryGetModifiedValue(x => x.MapSpeedMultiplier, out var mapSpeedMultiplier))
{
__result.AddMultiplier(mapSpeedMultiplier);
}
}
}
// [HarmonyPatch(typeof(DefaultPartySpeedCalculatingModel), nameof(DefaultPartySpeedCalculatingModel.CalculateFinalSpeed))]
// public static class DefaultPartySpeedCalculatingModelPatch
// {
// [HarmonyPostfix]
// public static void CalculateFinalSpeed(ref MobileParty mobileParty, ref ExplainedNumber finalSpeed, ref ExplainedNumber __result)
// {
// if (mobileParty.IsPlayerParty()
// && BannerlordCheatsSettings.TryGetModifiedValue(x => x.MapSpeedMultiplier, out var mapSpeedMultiplier))
// {
// __result.AddMultiplier(mapSpeedMultiplier);
// }
// }
// }
}
26 changes: 13 additions & 13 deletions Patches/Map/SlowDownPartiesOnMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

namespace BannerlordCheats.Patches.Map
{
[HarmonyPatch(typeof(DefaultPartySpeedCalculatingModel), nameof(DefaultPartySpeedCalculatingModel.CalculateFinalSpeed))]
public static class SlowDownPartiesOnMap
{
[HarmonyPostfix]
public static void CalculateFinalSpeed(ref MobileParty mobileParty, ref ExplainedNumber finalSpeed, ref ExplainedNumber __result)
{
if (!mobileParty.IsPlayerParty()
&& BannerlordCheatsSettings.TryGetModifiedValue(x => x.NpcMapSpeedPercentage, out var npcMapSpeedPercentage))
{
__result.AddPercentage(npcMapSpeedPercentage);
}
}
}
// [HarmonyPatch(typeof(DefaultPartySpeedCalculatingModel), nameof(DefaultPartySpeedCalculatingModel.CalculateFinalSpeed))]
// public static class SlowDownPartiesOnMap
// {
// [HarmonyPostfix]
// public static void CalculateFinalSpeed(ref MobileParty mobileParty, ref ExplainedNumber finalSpeed, ref ExplainedNumber __result)
// {
// if (!mobileParty.IsPlayerParty()
// && BannerlordCheatsSettings.TryGetModifiedValue(x => x.NpcMapSpeedPercentage, out var npcMapSpeedPercentage))
// {
// __result.AddPercentage(npcMapSpeedPercentage);
// }
// }
// }
}
Loading

0 comments on commit 15dc585

Please sign in to comment.