Skip to content
This repository has been archived by the owner on Jul 17, 2023. It is now read-only.

Commit

Permalink
crafting stamina, hero health, workshop amount
Browse files Browse the repository at this point in the history
  • Loading branch information
Cytraen committed Jun 23, 2020
1 parent 7dc6924 commit a093fcc
Show file tree
Hide file tree
Showing 8 changed files with 258 additions and 3 deletions.
58 changes: 58 additions & 0 deletions Patches/CraftingCampaignBehaviorPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
Copyright (C) 2020 ashakoor
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,
or any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

using HarmonyLib;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.CampaignBehaviors;

namespace UnlimitLord.Patches
{
internal static class CraftingCampaignBehaviorPatch
{
[HarmonyPatch(typeof(CraftingCampaignBehavior), "GetMaxHeroCraftingStamina")]
internal static class MaximumStamina
{
internal static int Postfix(int result, Hero hero)
{
var settings = Settings.Instance;
if (!WhoToApplyTo.DoesPatchApply(settings.CraftingStaminaAppliesTo.SelectedValue.GetWho(), hero))
return result;

return (int)Math.Clamp(
result * settings.CraftingStaminaMultiplier,
settings.MinimumCraftingStamina,
settings.MaximumCraftingStamina
);
}
}

[HarmonyPatch(typeof(CraftingCampaignBehavior), "GetHeroCraftingStamina")]
internal static class InfiniteStamina
{
internal static int Postfix(int result, Hero hero)
{
if (!WhoToApplyTo.DoesPatchApply(Settings.Instance.CraftingStaminaAppliesTo.SelectedValue.GetWho(), hero))
return result;

return CampaignBehaviorBase
.GetCampaignBehavior<CraftingCampaignBehavior>()
.GetMaxHeroCraftingStamina(hero)
;
}
}
}
}
40 changes: 40 additions & 0 deletions Patches/DefaultCharacterStatsModelPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
Copyright (C) 2020 ashakoor
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,
or any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

using HarmonyLib;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.GameComponents;

namespace UnlimitLord.Patches
{
[HarmonyPatch(typeof(DefaultCharacterStatsModel), "MaxHitpoints")]
internal static class DefaultCharacterStatsModelPatch
{
public static int Postfix(int result, CharacterObject character, StatExplainer explanation)
{
var settings = Settings.Instance;
if (!WhoToApplyTo.DoesPatchApply(settings.HeroHealthAmountAppliesTo.SelectedValue.GetWho(), character?.HeroObject))
return result;

return (int)Math.ClampAndExplain(
result * settings.HeroHealthAmountMultiplier, explanation,
settings.MinimumHeroHealthAmount,
settings.MaximumHeroHealthAmount
);
}
}
}
19 changes: 18 additions & 1 deletion Patches/DefaultClanFinanceModelPatch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
using HarmonyLib;
/*
Copyright (C) 2020 ashakoor
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,
or any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

using HarmonyLib;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.GameComponents;

Expand Down
19 changes: 18 additions & 1 deletion Patches/DefaultClanTierModelPatch.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
using HarmonyLib;
/*
Copyright (C) 2020 ashakoor
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,
or any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

using HarmonyLib;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.GameComponents;

Expand Down
36 changes: 36 additions & 0 deletions Patches/DefaultWorkshopModelPatch.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright (C) 2020 ashakoor
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License,
or any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

using HarmonyLib;
using TaleWorlds.CampaignSystem.SandBox.GameComponents;

namespace UnlimitLord.Patches
{
[HarmonyPatch(typeof(DefaultWorkshopModel), "GetMaxWorkshopCountForPlayer")]
internal static class DefaultWorkshopModelPatch
{
internal static int Postfix(int result)
{
var settings = Settings.Instance;
return (int)Math.Clamp(
result * settings.WorkshopAmountMultiplier,
settings.MinimumWorkshopAmount,
settings.MaximumWorkshopAmount
);
}
}
}
84 changes: 84 additions & 0 deletions Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,4 +290,88 @@ internal sealed partial class Settings
[SettingPropertyInteger("Maximum Companion Amount", 0, 1000000000, Order = 3, RequireRestart = false)]
public int MaximumCompanionAmount { get; set; } = 1000000000;
}

// Crafting stamina settings
internal sealed partial class Settings
{
[SettingPropertyGroup("Crafting Stamina")]
[SettingPropertyDropdown("Who is affected", Order = 0, RequireRestart = false)]
public DefaultDropdown<WhoToApplyTo> CraftingStaminaAppliesTo { get; set; } = new DefaultDropdown<WhoToApplyTo>(new[]
{
new WhoToApplyTo(WhoToApplyToEnum.PlayerOnly),
new WhoToApplyTo(WhoToApplyToEnum.PlayerCompanions)
}, 0);

[SettingPropertyGroup("Crafting Stamina")]
[SettingPropertyBool("Infinite Crafting Stamina Enabled", Order = 1, RequireRestart = false)]
public bool InfiniteCraftingStaminaEnabled { get; set; } = false;

[SettingPropertyGroup("Crafting Stamina")]
[SettingPropertyBool("Crafting Stamina Amount Enabled", Order = 2, RequireRestart = false)]
public bool CraftingStaminaAmountEnabled { get; set; } = false;

[SettingPropertyGroup("Crafting Stamina")]
[SettingPropertyFloatingInteger("Crafting Stamina Multiplier", 0.01f, 1000000f, Order = 3, RequireRestart = false)]
public float CraftingStaminaMultiplier { get; set; } = 1f;

[SettingPropertyGroup("Crafting Stamina")]
[SettingPropertyInteger("Minimum Crafting Stamina", 0, 1000000000, Order = 4, RequireRestart = false)]
public int MinimumCraftingStamina { get; set; } = 0;

[SettingPropertyGroup("Crafting Stamina")]
[SettingPropertyInteger("Maximum Crafting Stamina", 0, 1000000000, Order = 5, RequireRestart = false)]
public int MaximumCraftingStamina { get; set; } = 1000000000;
}

// Workshop amount settings
internal sealed partial class Settings
{
[SettingPropertyGroup("Workshop Amount", IsMainToggle = true)]
[SettingPropertyBool("Workshop Amount Enabled", RequireRestart = false)]
public bool WorkshopAmountEnabled { get; set; } = false;

[SettingPropertyGroup("Workshop Amount")]
[SettingPropertyFloatingInteger("Workshop Amount Multiplier", 0.01f, 1000000f, Order = 1, RequireRestart = false)]
public float WorkshopAmountMultiplier { get; set; } = 1f;

[SettingPropertyGroup("Workshop Amount")]
[SettingPropertyInteger("Minimum Workshop Amount", 0, 1000000000, Order = 2, RequireRestart = false)]
public int MinimumWorkshopAmount { get; set; } = 0;

[SettingPropertyGroup("Workshop Amount")]
[SettingPropertyInteger("Maximum Workshop Amount", 0, 1000000000, Order = 3, RequireRestart = false)]
public int MaximumWorkshopAmount { get; set; } = 1000000000;
}

// Hero health amount settings
internal sealed partial class Settings
{
[SettingPropertyGroup("Hero Health Amount", IsMainToggle = true)]
[SettingPropertyBool("Hero Health Amount Enabled", RequireRestart = false)]
public bool HeroHealthAmountEnabled { get; set; } = false;

[SettingPropertyGroup("Hero Health Amount")]
[SettingPropertyDropdown("Who is affected", Order = 0, RequireRestart = false)]
public DefaultDropdown<WhoToApplyTo> HeroHealthAmountAppliesTo { get; set; } = new DefaultDropdown<WhoToApplyTo>(new[]
{
new WhoToApplyTo(WhoToApplyToEnum.PlayerOnly),
new WhoToApplyTo(WhoToApplyToEnum.PlayerCompanions),
new WhoToApplyTo(WhoToApplyToEnum.PlayerClan),
new WhoToApplyTo(WhoToApplyToEnum.PlayerArmy),
new WhoToApplyTo(WhoToApplyToEnum.PlayerKingdom),
new WhoToApplyTo(WhoToApplyToEnum.Everyone)
}, 0);

[SettingPropertyGroup("Hero Health Amount")]
[SettingPropertyFloatingInteger("Hero Health Amount Multiplier", 0.01f, 1000000f, Order = 1, RequireRestart = false)]
public float HeroHealthAmountMultiplier { get; set; } = 1f;

[SettingPropertyGroup("Hero Health Amount")]
[SettingPropertyInteger("Minimum Hero Health Amount", 0, 1000000000, Order = 2, RequireRestart = false)]
public int MinimumHeroHealthAmount { get; set; } = 0;

[SettingPropertyGroup("Hero Health Amount")]
[SettingPropertyInteger("Maximum Hero Health Amount", 0, 1000000000, Order = 3, RequireRestart = false)]
public int MaximumHeroHealthAmount { get; set; } = 1000000000;
}
}
1 change: 1 addition & 0 deletions UnlimitLord.sln.DotSettings
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:Boolean x:Key="/Default/UserDictionary/Words/=ashakoor/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Bannerlord/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Hitpoints/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Unlimit/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=unlimitlord/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
4 changes: 3 additions & 1 deletion WhoToApplyTo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,13 @@ public static bool DoesPatchApply(WhoToApplyToEnum applyToEnum, Hero hero)

case WhoToApplyToEnum.PlayerParty:
goto default;

case WhoToApplyToEnum.PlayerClan:
return hero.IsThisHeroInPlayerClan();

case WhoToApplyToEnum.PlayerArmy:
goto default;
return hero.IsThisHeroInPlayerArmy();

case WhoToApplyToEnum.PlayerKingdom:
return hero.IsThisHeroInPlayerKingdom() || hero.IsThisHeroInPlayerClan();

Expand Down

0 comments on commit a093fcc

Please sign in to comment.