diff --git a/ArrowMod.csproj b/ArrowMod.csproj index d32494e..543459e 100644 --- a/ArrowMod.csproj +++ b/ArrowMod.csproj @@ -37,25 +37,27 @@ ..\..\..\..\SteamLibrary\steamapps\common\TheLongDark\tld_Data\Managed\Assembly-CSharp.dll False - - False - - - False + + False + ..\..\..\..\Games\SteamLibrary\steamapps\common\TheLongDark\MelonLoader\Managed\Il2Cppmscorlib.dll - - False + + + False + ..\..\..\..\Games\SteamLibrary\steamapps\common\TheLongDark\MelonLoader\MelonLoader.dll False False - - False + + False + ..\..\..\..\Games\SteamLibrary\steamapps\common\TheLongDark\MelonLoader\Managed\UnhollowerBaseLib.dll - False + False + ..\..\..\..\Games\SteamLibrary\steamapps\common\TheLongDark\MelonLoader\Managed\UnhollowerRuntimeLib.dll ..\..\..\..\SteamLibrary\steamapps\common\TheLongDark\tld_Data\Managed\UnityEngine.dll diff --git a/README.md b/README.md index ff1ea99..b082d71 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ This mod for *The Long Dark* allows you to adjust how arrows are crafted. Requir 2. Arrowhead craft time can be adjusted. This also accurately adjusts the crafting time of the 7-arrowhead recipe in [ForgeBlueprintsMod](https://github.com/ds5678/ForgeBlueprintsMod) (or any other mod that will modifiy resutling quantity). 3. Optionally, lines can be required for crafting arrows. However, it will not be visible in the crafting menu. This is caused by TLD and will probably not change. 4. Optionally, arrow shafts can also be crafted from hardwood - intended for late game, based on archery skill. +5. Optionally, arrows can be crafted using birch bark as fletching instead of fethers - intended for late game, based on archery skill. ## Installation @@ -18,4 +19,4 @@ This mod for *The Long Dark* allows you to adjust how arrows are crafted. Requir ## Notes -Many thanks to all TLD moding commniunity for support and assist. Additionall thanks to ds5678 for maitiaingin this mod while I was away. +Many thanks to all TLD moding commniunity for support and assist. diff --git a/src/ArrowMod.cs b/src/ArrowMod.cs index c1f918f..0fe1620 100644 --- a/src/ArrowMod.cs +++ b/src/ArrowMod.cs @@ -1,4 +1,5 @@ using MelonLoader; + using UnityEngine; namespace ArrowMod @@ -9,7 +10,7 @@ public static class BuildInfo public const string Description = "A mod to make arrow crafting more realistic."; // Description for the Mod. (Set as null if none) public const string Author = "ttr, ds5678"; // Author of the Mod. (MUST BE SET) public const string Company = null; // Company that made the Mod. (Set as null if none) - public const string Version = "1.5.0"; // Version of the Mod. (MUST BE SET) + public const string Version = "1.6.0"; // Version of the Mod. (MUST BE SET) public const string DownloadLink = null; // Download Link for the Mod. (Set as null if none) } internal class ArrowMod : MelonMod diff --git a/src/Patches.cs b/src/Patches.cs index 533b40f..798a7d1 100644 --- a/src/Patches.cs +++ b/src/Patches.cs @@ -1,6 +1,6 @@ using MelonLoader; -using Harmony; using UnhollowerBaseLib; +using HarmonyLib; using UnityEngine; @@ -33,7 +33,7 @@ private static void Postfix() bpi.m_RequiresLight = true; bpi.m_RequiresLitFire = false; bpi.m_RequiredCraftingLocation = CraftingLocation.Workbench; - bpi.m_DurationMinutes = Settings.options.arrowCraftTime; + bpi.m_DurationMinutes = Settings.options.arrowCraftTime; // whaever, we need to set this in ItemPassFilter bpi.m_CraftingAudio = "PLAY_CRAFTINGARROWS"; bpi.m_AppliedSkill = SkillType.None; bpi.m_ImprovedSkill = SkillType.None; @@ -51,35 +51,74 @@ private static void Postfix() [2] = 1, [3] = 1 }; + + if (Settings.options.craftFletchingFromBark) + { + BlueprintItem bpi2 = GameManager.GetBlueprints().AddComponent(); + // Inputs + bpi2.m_KeroseneLitersRequired = 0f; + bpi2.m_GunpowderKGRequired = 0f; + bpi2.m_RequiredTool = GetToolItemPrefab("GEAR_Knife"); + bpi2.m_OptionalTools = new Il2CppReferenceArray(0); + + // Outputs + bpi2.m_CraftedResult = GetGearItemPrefab("GEAR_Arrow"); + bpi2.m_CraftedResultCount = 1; + + // Process + bpi2.m_Locked = false; + bpi2.m_AppearsInStoryOnly = false; + bpi2.m_RequiresLight = true; + bpi2.m_RequiresLitFire = false; + bpi2.m_RequiredCraftingLocation = CraftingLocation.Workbench; + bpi2.m_DurationMinutes = 2 * (Settings.options.arrowCraftTime + Settings.options.craftFletchingFromBarkTime); // whaever, we need to set this in ItemPassFilter + bpi2.m_CraftingAudio = "PLAY_CRAFTINGARROWS"; + bpi2.m_AppliedSkill = SkillType.None; + bpi2.m_ImprovedSkill = SkillType.None; + bpi2.m_RequiredGear = new Il2CppReferenceArray(4) + { + [0] = GetGearItemPrefab("GEAR_Line"), + [1] = GetGearItemPrefab("GEAR_BarkTinder"), + [2] = GetGearItemPrefab("GEAR_ArrowShaft"), + [3] = GetGearItemPrefab("GEAR_ArrowHead") + }; + bpi2.m_RequiredGearUnits = new Il2CppStructArray(4) + { + [0] = 1, + [1] = 1, + [2] = 1, + [3] = 1 + }; + } } if (Settings.options.craftArrowFromWood) { - BlueprintItem bpi = GameManager.GetBlueprints().AddComponent(); + BlueprintItem bpi3 = GameManager.GetBlueprints().AddComponent(); // Inputs - bpi.m_KeroseneLitersRequired = 0f; - bpi.m_GunpowderKGRequired = 0f; - bpi.m_RequiredTool = GetToolItemPrefab("GEAR_Knife"); ; - bpi.m_OptionalTools = new Il2CppReferenceArray(0); + bpi3.m_KeroseneLitersRequired = 0f; + bpi3.m_GunpowderKGRequired = 0f; + bpi3.m_RequiredTool = GetToolItemPrefab("GEAR_Knife"); + bpi3.m_OptionalTools = new Il2CppReferenceArray(0); // Outputs - bpi.m_CraftedResult = GetGearItemPrefab("GEAR_ArrowShaft"); - bpi.m_CraftedResultCount = 3; + bpi3.m_CraftedResult = GetGearItemPrefab("GEAR_ArrowShaft"); + bpi3.m_CraftedResultCount = 3; // Process - bpi.m_Locked = false; - bpi.m_AppearsInStoryOnly = false; - bpi.m_RequiresLight = true; - bpi.m_RequiresLitFire = false; - bpi.m_RequiredCraftingLocation = CraftingLocation.Workbench; - bpi.m_DurationMinutes = 180; // with knife it will be 1/2 of this time; it will be much longer than from branch but it takes time to cut arrow from plank - bpi.m_CraftingAudio = "PLAY_CRAFTINGARROWS"; - bpi.m_AppliedSkill = SkillType.None; - bpi.m_ImprovedSkill = SkillType.None; - bpi.m_RequiredGear = new Il2CppReferenceArray(1) + bpi3.m_Locked = false; + bpi3.m_AppearsInStoryOnly = false; + bpi3.m_RequiresLight = true; + bpi3.m_RequiresLitFire = false; + bpi3.m_RequiredCraftingLocation = CraftingLocation.Workbench; + bpi3.m_DurationMinutes = 180; // with knife it will be 1/2 of this time; it will be much longer than from branch but it takes time to cut arrow from plank + bpi3.m_CraftingAudio = "PLAY_CRAFTINGARROWS"; + bpi3.m_AppliedSkill = SkillType.None; + bpi3.m_ImprovedSkill = SkillType.None; + bpi3.m_RequiredGear = new Il2CppReferenceArray(1) { [0] = GetGearItemPrefab("GEAR_Hardwood") }; - bpi.m_RequiredGearUnits = new Il2CppStructArray(1) + bpi3.m_RequiredGearUnits = new Il2CppStructArray(1) { [0] = 1 }; @@ -98,7 +137,14 @@ private static void Postfix(Panel_Crafting __instance, ref bool __result, Bluepr { __result = false; } - bpi.m_DurationMinutes = Settings.options.arrowCraftTime; + if (bpi.m_RequiredGear[1] == GetGearItemPrefab("GEAR_BarkTinder")) + { + bpi.m_DurationMinutes = (Settings.options.arrowCraftTime + Settings.options.craftFletchingFromBarkTime) * 2; + } + else + { + bpi.m_DurationMinutes = Settings.options.arrowCraftTime; + } } else if (bpi?.m_CraftedResult?.name == "GEAR_ArrowHead") { @@ -125,7 +171,16 @@ private static void Postfix(Panel_Crafting __instance) { int currentArcherySkill = GameManager.GetSkillArchery().GetCurrentTierNumber() + 1; int requiredArcherySkill = Settings.options.craftArrowFromWoodLevel; - MelonLogger.Log(currentArcherySkill + "<" + requiredArcherySkill); + if (currentArcherySkill < requiredArcherySkill) + { + __instance.m_SelectedDescription.text = "Required Archery skill " + requiredArcherySkill.ToString(); + __instance.m_SelectedDescription.color = redColor; + } + } + if (bpi.m_CraftedResult == GetGearItemPrefab("GEAR_Arrow") && bpi.m_RequiredGear[1] == GetGearItemPrefab("GEAR_BarkTinder")) + { + int currentArcherySkill = GameManager.GetSkillArchery().GetCurrentTierNumber() + 1; + int requiredArcherySkill = Settings.options.craftFletchingFromBarkLevel; if (currentArcherySkill < requiredArcherySkill) { __instance.m_SelectedDescription.text = "Required Archery skill " + requiredArcherySkill.ToString(); @@ -147,7 +202,6 @@ private static void Postfix(ref bool __result, BlueprintItem __instance) { int currentArcherySkill = GameManager.GetSkillArchery().GetCurrentTierNumber() + 1; int requiredArcherySkill = Settings.options.craftArrowFromWoodLevel; - MelonLogger.Log("BPI-test: " + currentArcherySkill + "<" + requiredArcherySkill); if (currentArcherySkill < requiredArcherySkill) { __result = false; diff --git a/src/Settings.cs b/src/Settings.cs index 044aee6..b6adb23 100644 --- a/src/Settings.cs +++ b/src/Settings.cs @@ -15,7 +15,7 @@ internal class ArrowModSettings : JsonModSettings public int arrowCraftTime = 90; [Name("Use line")] - [Description("Require 1 line to craft an arrow. Will not display as a requirement in the crafting menu.")] + [Description("Require 1 line to craft an arrow. Note: Due to game limitation, only 3 first ingredients are disaied in crafing menu - eneblaing this will require 4, so arrow head, even if not disaplyed, still is needed.")] public bool arrowUseLine = false; [Name("Craft Arrowshaft from Hardwood")] @@ -27,6 +27,20 @@ internal class ArrowModSettings : JsonModSettings [Slider(0, 5)] public int craftArrowFromWoodLevel = 5; + [Name("Craft arrow fletchings from Bark")] + [Description("Allow to use birch bark to craft arrow fletchings. NOTE: Require 'Use line' to be turn on. NOTE2: resulting arrow is same as vanilla one, meaning deconstricting it will yeld feathers.")] + public bool craftFletchingFromBark = false; + + [Name("... skill level")] + [Description("Archery skill required to craft fletchings from bark - designed to be late game - recommended is 4-5.")] + [Slider(0, 5)] + public int craftFletchingFromBarkLevel = 5; + + [Name("... additional time")] + [Description("Additional time in minutes per arrow needed to craft fletchings.")] + [Slider(0, 20)] + public int craftFletchingFromBarkTime = 5; + } internal static class Settings {