Skip to content

Commit

Permalink
1.6.0 add bark as feathers replacement
Browse files Browse the repository at this point in the history
  • Loading branch information
ttr committed Aug 22, 2021
1 parent d4011a0 commit 3caf6f9
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 36 deletions.
22 changes: 12 additions & 10 deletions ArrowMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,25 +37,27 @@
<HintPath>..\..\..\..\SteamLibrary\steamapps\common\TheLongDark\tld_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Il2Cppmscorlib, Version=3.7.1.6, Culture=neutral, processorArchitecture=MSIL">
<Private>False</Private>
</Reference>
<Reference Include="Il2CppSystem, Version=3.7.1.6, Culture=neutral, processorArchitecture=MSIL">
<Private>False</Private>
<Reference Include="Il2Cppmscorlib, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Games\SteamLibrary\steamapps\common\TheLongDark\MelonLoader\Managed\Il2Cppmscorlib.dll</HintPath>
</Reference>
<Reference Include="MelonLoader.ModHandler, Version=0.2.7.4, Culture=neutral, processorArchitecture=MSIL">
<Private>False</Private>
<Reference Include="Il2CppSystem, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
<Reference Include="MelonLoader, Version=0.4.3.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Games\SteamLibrary\steamapps\common\TheLongDark\MelonLoader\MelonLoader.dll</HintPath>
</Reference>
<Reference Include="ModSettings, Version=1.7.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="UnhollowerBaseLib, Version=0.4.10.0, Culture=neutral, processorArchitecture=MSIL">
<Private>False</Private>
<Reference Include="UnhollowerBaseLib, Version=0.4.15.4, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Games\SteamLibrary\steamapps\common\TheLongDark\MelonLoader\Managed\UnhollowerBaseLib.dll</HintPath>
</Reference>
<Reference Include="UnhollowerRuntimeLib, Version=0.4.10.0, Culture=neutral, processorArchitecture=MSIL">
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\..\Games\SteamLibrary\steamapps\common\TheLongDark\MelonLoader\Managed\UnhollowerRuntimeLib.dll</HintPath>
</Reference>
<Reference Include="UnityEngine">
<HintPath>..\..\..\..\SteamLibrary\steamapps\common\TheLongDark\tld_Data\Managed\UnityEngine.dll</HintPath>
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
3 changes: 2 additions & 1 deletion src/ArrowMod.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MelonLoader;

using UnityEngine;

namespace ArrowMod
Expand All @@ -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
Expand Down
100 changes: 77 additions & 23 deletions src/Patches.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using MelonLoader;
using Harmony;
using UnhollowerBaseLib;
using HarmonyLib;
using UnityEngine;


Expand Down Expand Up @@ -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;
Expand All @@ -51,35 +51,74 @@ private static void Postfix()
[2] = 1,
[3] = 1
};

if (Settings.options.craftFletchingFromBark)
{
BlueprintItem bpi2 = GameManager.GetBlueprints().AddComponent<BlueprintItem>();
// Inputs
bpi2.m_KeroseneLitersRequired = 0f;
bpi2.m_GunpowderKGRequired = 0f;
bpi2.m_RequiredTool = GetToolItemPrefab("GEAR_Knife");
bpi2.m_OptionalTools = new Il2CppReferenceArray<ToolsItem>(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<GearItem>(4)
{
[0] = GetGearItemPrefab("GEAR_Line"),
[1] = GetGearItemPrefab("GEAR_BarkTinder"),
[2] = GetGearItemPrefab("GEAR_ArrowShaft"),
[3] = GetGearItemPrefab("GEAR_ArrowHead")
};
bpi2.m_RequiredGearUnits = new Il2CppStructArray<int>(4)
{
[0] = 1,
[1] = 1,
[2] = 1,
[3] = 1
};
}
}
if (Settings.options.craftArrowFromWood)
{
BlueprintItem bpi = GameManager.GetBlueprints().AddComponent<BlueprintItem>();
BlueprintItem bpi3 = GameManager.GetBlueprints().AddComponent<BlueprintItem>();
// Inputs
bpi.m_KeroseneLitersRequired = 0f;
bpi.m_GunpowderKGRequired = 0f;
bpi.m_RequiredTool = GetToolItemPrefab("GEAR_Knife"); ;
bpi.m_OptionalTools = new Il2CppReferenceArray<ToolsItem>(0);
bpi3.m_KeroseneLitersRequired = 0f;
bpi3.m_GunpowderKGRequired = 0f;
bpi3.m_RequiredTool = GetToolItemPrefab("GEAR_Knife");
bpi3.m_OptionalTools = new Il2CppReferenceArray<ToolsItem>(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<GearItem>(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<GearItem>(1)
{
[0] = GetGearItemPrefab("GEAR_Hardwood")
};
bpi.m_RequiredGearUnits = new Il2CppStructArray<int>(1)
bpi3.m_RequiredGearUnits = new Il2CppStructArray<int>(1)
{
[0] = 1
};
Expand All @@ -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")
{
Expand All @@ -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();
Expand All @@ -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;
Expand Down
16 changes: 15 additions & 1 deletion src/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -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
{
Expand Down

0 comments on commit 3caf6f9

Please sign in to comment.