Skip to content

Commit

Permalink
fix: Fix game start null exception
Browse files Browse the repository at this point in the history
Issue was caused by KeyInput changing to Key from InputSystem lib in Patch 0.217.38
  • Loading branch information
afilbert committed Dec 16, 2023
1 parent d0190bc commit a71ad12
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 15 deletions.
Binary file modified Libs/BepInEx.dll
Binary file not shown.
Binary file added Libs/Unity.InputSystem.dll
Binary file not shown.
Binary file modified Libs/UnityEngine.CoreModule.dll
Binary file not shown.
Binary file modified Libs/UnityEngine.dll
Binary file not shown.
Binary file modified Libs/assembly_guiutils.dll
Binary file not shown.
Binary file modified Libs/assembly_utils.dll
Binary file not shown.
Binary file modified Libs/assembly_valheim.dll
Binary file not shown.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,7 @@ So v0.0.7 introduces a configurable safety valve to detoggle sprint after an ela

v0.0.3 introduced the ability to equip/switch weapons during auto-run while sprinting. Sometimes you know you're getting close to a battle, and want to arrive prepared. Stock Valheim won't let you equip/switch weapons while sprinting, but now you can!

## Config

The [Official BepInEx ConfigurationManager](https://github.com/BepInEx/BepInEx.ConfigurationManager) is a required dependency.
### Config

Configuration allows:

Expand Down Expand Up @@ -102,6 +100,8 @@ Built with [BepInEx](https://valheim.thunderstore.io/package/denikson/BepInExPac

Releases in github repo are packaged for Thunderstore Mod Manager.

* 0.1.3 Fix nil bomb caused by patch 0.217.38. Fixes broken menu translations when loading the game
* Drop requirement for [Official BepInEx ConfigurationManager](https://valheim.thunderstore.io/package/Azumatt/Official_BepInEx_ConfigurationManager/) from Thunderstore manifest.json to allow flexibility
* 0.1.2 Fix bug that disabled vanilla autorun when AutorunToggle was disabled in config
* 0.1.1 Fix bug that locked character movement after game patch 0.216.9
* 0.1.0 Fix bug that prevented alternative Run toggle key from instantiating correctly
Expand Down
21 changes: 13 additions & 8 deletions ToggleMovementMod.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;

namespace ValheimMovementMods
{
Expand All @@ -14,7 +15,7 @@ public class ToggleMovementMod : BaseUnityPlugin
{
const string pluginGUID = "afilbert.ValheimToggleMovementMod";
const string pluginName = "Valheim - Toggle Movement Mod";
const string pluginVersion = "0.1.2";
const string pluginVersion = "0.1.3";
public static ManualLogSource logger;

private readonly Harmony _harmony = new Harmony(pluginGUID);
Expand Down Expand Up @@ -79,7 +80,11 @@ private class ToggleMovement
{
private static void Prefix(ref Player __instance, ref Vector3 movedir, ref bool run, ref bool autoRun, ref bool crouch, ref Vector3 ___m_lookDir, ref Vector3 ___m_moveDir, ref bool ___m_autoRun, ref bool ___m_crouchToggled, ref string ___m_actionAnimation, ref List<Player.MinorActionData> ___m_actionQueue)
{
if (!__instance || _plugin.IsInMenu() || !EnableToggle.Value)
if (!EnableToggle.Value)
{
return;
}
if (!__instance || _plugin.IsInMenu())
{
autoRun = false;
___m_autoRun = false;
Expand Down Expand Up @@ -189,7 +194,7 @@ private static void Prefix(ref Player __instance, ref Vector3 movedir, ref bool
autoRun = false;
___m_autoRun = false;
}
}
}
else
{
if (__instance.GetHealthPercentage() < SprintHealthThreshold && SafeguardStaminaOnLowHealth.Value)
Expand Down Expand Up @@ -225,11 +230,11 @@ private class ZInput_PatchReset
{
private static void Postfix(ZInput __instance)
{
KeyCode key = (KeyCode)Enum.Parse(typeof(KeyCode), AutorunFreelookKey.Value);
Key key = (Key)Enum.Parse(typeof(Key), AutorunFreelookKey.Value);
__instance.AddButton("Caps", key);
key = (KeyCode)Enum.Parse(typeof(KeyCode), "Escape");
key = (Key)Enum.Parse(typeof(Key), "Escape");
__instance.AddButton("Esc", key);
key = (KeyCode)Enum.Parse(typeof(KeyCode), SprintToggleAlternateKey.Value);
key = (Key)Enum.Parse(typeof(Key), SprintToggleAlternateKey.Value);
__instance.AddButton("Sprint", key);
}
}
Expand Down Expand Up @@ -257,12 +262,12 @@ private void Update()
{
if (Started && EnableToggle.Value && !IsInMenu())
{
bool run;
bool run = false;
if (SprintToggleAlternate.Value)
{
run = ZInput.GetButtonUp("Sprint");
}
else
else if (SprintToggle.Value)
{
run = ZInput.GetButtonUp("Run") || ZInput.GetButtonUp("JoyRun");
}
Expand Down
15 changes: 11 additions & 4 deletions ToggleMovementMod.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>Libs\assembly_valheim.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<Reference Include="BepInEx, Version=5.4.21.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libs\BepInEx.dll</HintPath>
</Reference>
<Reference Include="BepInEx.Harmony">
<Reference Include="BepInEx.Harmony, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libs\BepInEx.Harmony.dll</HintPath>
</Reference>
<Reference Include="System" />
Expand All @@ -58,10 +60,15 @@
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<Reference Include="Unity.InputSystem">
<HintPath>Libs\Unity.InputSystem.dll</HintPath>
</Reference>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libs\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>Libs\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
Expand Down

0 comments on commit a71ad12

Please sign in to comment.