Skip to content

Commit 3e1a773

Browse files
fix the calculation of charcoal (#2)
* fix a bug of index change fix a bug that skip smelting some weapons because index change * fix calculation of charcoal in smelting fix a bug that didn't calculate the cost of charcoal, which will cause game freezing. * Update TLSmithingFasterSubModule.cs update version
1 parent 142163f commit 3e1a773

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

TLSmithingFasterMod/TLSmithingFasterOperationCounts.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using TaleWorlds.CampaignSystem;
55
using TaleWorlds.CampaignSystem.GameState;
66

7+
78
namespace TLSmithingFasterMod
89
{
910
public static class TLSmithingFasterOperationCounts
@@ -36,6 +37,17 @@ public static int GetMaxCounts(ref CraftingCampaignBehavior instance, Hero hero,
3637
ItemRoster itemRoster = MobileParty.MainParty.ItemRoster;
3738
int energyCostForSmelting = Campaign.Current.Models.SmithingModel.GetEnergyCostForSmelting(item, hero);
3839
int result = instance.GetHeroCraftingStamina(hero) / energyCostForSmelting;
40+
string charcoal = "charcoal";
41+
int charcoal_num = 0;
42+
int max_item_count = itemRoster.Count;
43+
for (int i = 0; i < max_item_count; i++)
44+
{
45+
if (itemRoster.GetItemAtIndex(i).ToString() == charcoal)
46+
{
47+
charcoal_num = itemRoster.GetItemNumber(itemRoster.GetItemAtIndex(i));
48+
}
49+
}
50+
result = Math.Min(result, charcoal_num);
3951
//return Math.Min(result, MaxForInput(itemRoster, item, 1));
4052
return result;
4153
}

TLSmithingFasterMod/TLSmithingFasterSubModule.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ protected override void OnSubModuleLoad()
1515
protected override void OnBeforeInitialModuleScreenSetAsRoot()
1616
{
1717
base.OnBeforeInitialModuleScreenSetAsRoot();
18-
InformationManager.DisplayMessage(new InformationMessage("TL Smithing Faster Mod e1.2.1 is successfully loaded. HarmonyLib 2.0.0.10"));
18+
InformationManager.DisplayMessage(new InformationMessage("TL Smithing Faster Mod e1.2.1.2 is successfully loaded. HarmonyLib 2.0.0.10"));
1919
}
2020
}
2121
}

0 commit comments

Comments
 (0)