Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for e1.7.2 #1

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
## BannerLord Mods

A collection of mods for Mount & Blade II: Bannerlord, by me.
Updated version.
TODO: Fix text in Towns to reflect changes done in the config.

### Banks

Expand Down Expand Up @@ -60,4 +59,4 @@ I for one would rather pay may hard working army with a safe/steady income from

Also it felt super dumb that you are only a good trader/investor if you are actively slogging mules from town to town.

Each day a portion (currently 1%) of you earned interest will count as trade income, giving you a passive improvement to your trade skill.
Each day a portion (currently 1%) of you earned interest will count as trade income, giving you a passive improvement to your trade skill.
39 changes: 26 additions & 13 deletions src/BannerLord.Banks/BankCampaignBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
using System;
using System.Collections.Generic;
using Helpers;
using Newtonsoft.Json;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.CharacterDevelopment;
using TaleWorlds.CampaignSystem.GameMenus;
using TaleWorlds.CampaignSystem.Overlay;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Localization;
using Newtonsoft.Json;
using TaleWorlds.CampaignSystem.CharacterDevelopment.Managers;

namespace BannerLord.Banks
{
Expand All @@ -18,15 +20,24 @@ public class BankCampaignBehavior : CampaignBehaviorBase
private const string BANK_INFO_BALANCE_TEXT_VARIABLE = "BANK_INFO_BALANCE";
private const string BANK_INFO_WITHDRAW_TEXT_VARIABLE = "BANK_INFO_WITHDRAW";

private const float BASE_APY = 0.6f;
private const int DAYS_IN_A_YEAR = 120;
private const int PROSPEROUS_TOWN = 6000;
private const float WITHDRAW_FEE = 0.1f;
private const float TRADE_SKILL_PROFIT_MULTIPLIER = 0.1f;

private const string PORTFOLIO_DATA_KEY = "BannerLord.Banks.HeroPortfolios";
private Dictionary<string, HeroPortfolio> _heroPortfolios;

public float BASE_APY = MCMUISettings.Instance.TradeXP;
public int DAYS_IN_A_YEAR = MCMUISettings.Instance.DaysPerYear;
public int PROSPEROUS_TOWN = MCMUISettings.Instance.ProsperousTown;
public float WITHDRAW_FEE = MCMUISettings.Instance.WithdrawFee;
public float TRADE_SKILL_PROFIT_MULTIPLIER = MCMUISettings.Instance.TradeXP;

public void UpdateVariables()
{
BASE_APY = MCMUISettings.Instance.TradeXP;
DAYS_IN_A_YEAR = MCMUISettings.Instance.DaysPerYear;
PROSPEROUS_TOWN = MCMUISettings.Instance.ProsperousTown;
WITHDRAW_FEE = MCMUISettings.Instance.WithdrawFee;
TRADE_SKILL_PROFIT_MULTIPLIER = MCMUISettings.Instance.TradeXP;
}

public BankCampaignBehavior()
{
_heroPortfolios = new Dictionary<string, HeroPortfolio>();
Expand Down Expand Up @@ -354,24 +365,26 @@ private void DepositDenars(int denars)

private void HandleDailyTickClanEvent(Clan clan)
{
UpdateVariables();

var dailyInterest = new ExplainedNumber();

CalculateClanBankInterest(clan, ref dailyInterest);

SkillLevelingManager.OnTradeProfitMade(clan.Leader, (int)Math.Round(dailyInterest.ResultNumber * TRADE_SKILL_PROFIT_MULTIPLIER));
}

public void CalculateClanBankInterest(Clan clan, ref ExplainedNumber goldChange)
{
if(clan.Leader is null)
if (clan.Leader is null)
{
return;
}

var heroId = clan.Leader.Id.ToString();
var hasPortfolio = _heroPortfolios.ContainsKey(heroId);

if(!hasPortfolio)
if (!hasPortfolio)
{
return;
}
Expand All @@ -391,7 +404,7 @@ public void CalculateClanBankInterest(Clan clan, ref ExplainedNumber goldChange)
}
}
}

protected void AddTownBankWithdrawMenu(CampaignGameStarter starter)
{
// add bank withdraw menu
Expand Down Expand Up @@ -464,7 +477,7 @@ private void HandleBankInfoWithdrawText()
{
MBTextManager.SetTextVariable(
BANK_INFO_WITHDRAW_TEXT_VARIABLE,
new TextObject($"The withdrawl fee is currently {WITHDRAW_FEE*100:F0}%")
new TextObject($"The withdrawl fee is currently {WITHDRAW_FEE * 100:F0}%")
);
}

Expand Down
47 changes: 26 additions & 21 deletions src/BannerLord.Banks/BannerLord.Banks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,33 @@
</ItemGroup>

<ItemGroup>
<Reference Include="TaleWorlds.Core">
<HintPath>\Program Files (x86)\GOG Galaxy\Games\Mount &amp; Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.Core.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.Localization">
<HintPath>\Program Files (x86)\GOG Galaxy\Games\Mount &amp; Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.Localization.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.MountAndBlade">
<HintPath>\Program Files (x86)\GOG Galaxy\Games\Mount &amp; Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.DotNet">
<HintPath>\Program Files (x86)\GOG Galaxy\Games\Mount &amp; Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.DotNet.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.CampaignSystem">
<HintPath>\Program Files (x86)\GOG Galaxy\Games\Mount &amp; Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.ObjectSystem">
<HintPath>\Program Files (x86)\GOG Galaxy\Games\Mount &amp; Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.ObjectSystem.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>\Program Files (x86)\GOG Galaxy\Games\Mount &amp; Blade II Bannerlord\bin\Win64_Shipping_Client\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>F:\Games\Mount &amp; Blade II Bannerlord 1.7.2\bin\Win64_Shipping_Client\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.CampaignSystem">
<HintPath>F:\Games\Mount &amp; Blade II Bannerlord 1.7.2\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.Core">
<HintPath>F:\Games\Mount &amp; Blade II Bannerlord 1.7.2\bin\Win64_Shipping_Client\TaleWorlds.Core.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.DotNet">
<HintPath>F:\Games\Mount &amp; Blade II Bannerlord 1.7.2\bin\Win64_Shipping_Client\TaleWorlds.DotNet.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.Localization">
<HintPath>F:\Games\Mount &amp; Blade II Bannerlord 1.7.2\bin\Win64_Shipping_Client\TaleWorlds.Localization.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.MountAndBlade">
<HintPath>F:\Games\Mount &amp; Blade II Bannerlord 1.7.2\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.dll</HintPath>
</Reference>
<Reference Include="TaleWorlds.ObjectSystem">
<HintPath>F:\Games\Mount &amp; Blade II Bannerlord 1.7.2\bin\Win64_Shipping_Client\TaleWorlds.ObjectSystem.dll</HintPath>
</Reference>
<PackageReference Include="Bannerlord.MCM" Version="4.7.7" IncludeAssets="compile" />
</ItemGroup>

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy /Y &quot;$(TargetDir)$(TargetFileName)&quot; &quot;F:\Games\Mount &amp; Blade II Bannerlord 1.7.2\Modules\Bank\bin\Win64_Shipping_Client&quot;" />
</Target>


</Project>
2 changes: 1 addition & 1 deletion src/BannerLord.Banks/EnhancedClanFinanceModel.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.GameComponents;
using TaleWorlds.CampaignSystem.GameComponents;

namespace BannerLord.Banks
{
Expand Down
39 changes: 39 additions & 0 deletions src/BannerLord.Banks/ModSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Collections;
using System.Collections.Generic;
using MCM;
using MCM.Abstractions.Attributes;
using MCM.Abstractions.Attributes.v2;
using MCM.Abstractions.Settings.Base;
using MCM.Abstractions.Settings.Base.Global;

namespace BannerLord.Banks
{
internal sealed class MCMUISettings : AttributeGlobalSettings<MCMUISettings> // AttributePerSaveSettings<MCMUISettings>
{
public override string Id => "BankMod";
public override string DisplayName => $"Bank Settings";
public override string FolderName => "BankMod";
public override string FormatType => "json2";

[SettingPropertyFloatingInteger("Interest amount", 0f, 5f, "0%", Order = 0, RequireRestart = false, HintText = "Interest per year.\nCalculation: (this value / Days in a year) * (town prosp. / prosp. town setting) = interest per day.")]
[SettingPropertyGroup("General")]
public float Interest { get; set; } = 0.6f;

[SettingPropertyInteger("Days in a year", 1, 240, "0 Days", Order = 1, RequireRestart = false, HintText = "How many days does a year have.\nLower values -> more interest per day.")]
[SettingPropertyGroup("General")]
public int DaysPerYear { get; set; } = 120;

[SettingPropertyInteger("Prosperous Town", 1, 12000, "0 Prosperity", Order = 2, RequireRestart = false, HintText = "How much prosperity is needed to be counted Properous. Affects scaling of interest.\nIf town prosp. above this setting -> more interest per day.")]
[SettingPropertyGroup("General")]
public int ProsperousTown { get; set; } = 6000;

[SettingPropertyFloatingInteger("Withdraw fee", 0f, 2f, "0%", Order = 3, RequireRestart = false, HintText = "Withdraw fee.\nCalculation: Denars to withdraw * this value = fee.")]
[SettingPropertyGroup("General")]
public float WithdrawFee { get; set; } = 0.1f;

[SettingPropertyFloatingInteger("Trade Skill XP amount", 0f, 2f, "0%", Order = 4, RequireRestart = false, HintText = "You gain x% xp to trade skill.")]
[SettingPropertyGroup("General")]
public float TradeXP { get; set; } = 0.1f;
}
}
2 changes: 2 additions & 0 deletions src/BannerLord.Banks/PlayerTownVisitCampaignBehavior.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using System;
using Helpers;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.ComponentInterfaces;
using TaleWorlds.CampaignSystem.GameMenus;
using TaleWorlds.CampaignSystem.Settlements;

namespace BannerLord.Banks
{
Expand Down
2 changes: 1 addition & 1 deletion src/BannerLord.Banks/SubModule.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem;
using TaleWorlds.Core;
using TaleWorlds.MountAndBlade;

Expand Down
16 changes: 14 additions & 2 deletions src/BannerLord.Banks/SubModule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<SingleplayerModule value="true"/>
<MultiplayerModule value="false"/>
<DependedModules>
<DependedModule Id="SandBoxCore" DependentVersion="e1.7.1" Optional="false"/>
<DependedModule Id="Sandbox" DependentVersion="e1.7.1" Optional="false"/>
<DependedModule Id="SandBoxCore" DependentVersion="e1.7.2" Optional="false"/>
<DependedModule Id="Sandbox" DependentVersion="e1.7.2" Optional="false"/>
</DependedModules>
<SubModules>
<SubModule>
Expand All @@ -18,6 +18,18 @@
<Tag key="IsNoRenderModeElement" value="false" />
</Tags>
</SubModule>
<SubModule>
<Name value="MCMv4" />
<DLLName value="MCMv4.dll" />
<SubModuleClassType value="MCM.MCMSubModule" />
<Tags />
</SubModule>
<SubModule>
<Name value="MCMv4 Basic Implementation" />
<DLLName value="MCMv4.dll" />
<SubModuleClassType value="MCM.Implementation.MCMImplementationSubModule" />
<Tags />
</SubModule>
</SubModules>
<Xmls/>
</Module>