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

Fixes to work with Mistlands #4

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
5 changes: 1 addition & 4 deletions BetterStamina/BetterStamina.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using System.Reflection;
using UnityEngine;

namespace BetterStamina
{
[BepInPlugin("bakaSpaceman.BetterStamina", "Better Stamina", "1.2.0.0")]
[BepInPlugin("bakaSpaceman.BetterStamina", "Better Stamina", "2.0.0")]
public class BetterStaminaPlugin : BepInPluginTemplate
{
// Config - Debug
Expand Down
38 changes: 12 additions & 26 deletions BetterStamina/BetterStamina.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BetterStamina</RootNamespace>
<AssemblyName>BetterStamina</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -31,22 +32,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\_Libs\0Harmony.dll</HintPath>
</Reference>
<Reference Include="assembly_guiutils, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\_Libs\assembly_guiutils.dll</HintPath>
</Reference>
<Reference Include="assembly_valheim">
<HintPath>..\..\_Libs\assembly_valheim.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>..\..\_Libs\BepInEx.dll</HintPath>
</Reference>
<Reference Include="BepInEx.Harmony">
<HintPath>..\..\_Libs\BepInEx.Harmony.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -55,12 +40,6 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\_Libs\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\_Libs\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BetterStamina.cs" />
Expand All @@ -70,11 +49,18 @@
<Compile Include="ToolsPatches.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BepInEx.Core">
<Version>5.4.21</Version>
</PackageReference>
<PackageReference Include="Digitalroot.Valheim.Common.References">
<Version>0.216.902</Version>
</PackageReference>
</ItemGroup>
<Import Project="..\UnityUtils\UnityUtils.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>"$(SolutionDir)\..\_Debug Resources\pdb2mdb\pdb2mdb.exe" "$(TargetFileName)"
xcopy /y "$(TargetPath)" "$(ValheimRoot)\BepInEx\scripts\"
xcopy /y "$(TargetPath).mdb" "$(ValheimRoot)\BepInEx\scripts\"</PostBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
10 changes: 5 additions & 5 deletions BetterStamina/GeneralStaminaPatches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,25 @@ private static float CalculateNewStamina(Player __instance, bool ___m_wallRunnin
float num1 = 1f;
if (__instance.IsBlocking())
num1 *= 0.8f;
if (((__instance.IsSwiming() && !__instance.IsOnGround() || (__instance.InAttack() || __instance.InDodge()) ? 1 : (___m_wallRunning ? 1 : 0)) | (__instance.IsEncumbered() ? 1 : 0)) != 0)
if (((__instance.IsSwimming() && !__instance.IsOnGround() || (__instance.InAttack() || __instance.InDodge()) ? 1 : (___m_wallRunning ? 1 : 0)) | (__instance.IsEncumbered() ? 1 : 0)) != 0)
num1 = 0.0f;

float maxStamina = __instance.GetMaxStamina();
float missingStaminaMod = (float)(1.0 - (double)___m_stamina / (double)maxStamina);
float missingStaminaMod = (float)(1.0 - ___m_stamina / (double)maxStamina);
float num2 = (___m_staminaRegen + missingStaminaMod * ___m_staminaRegen * __instance.m_staminaRegenTimeMultiplier) * num1;
float staminaMultiplier = 1f;
___m_seman.ModifyStaminaRegen(ref staminaMultiplier);
float num3 = num2 * staminaMultiplier;
___m_staminaRegenTimer -= dt;

float returnStamina = ___m_stamina;
if ((double)___m_stamina < (double)maxStamina && (double)___m_staminaRegenTimer <= 0.0)
if (___m_stamina < (double)maxStamina && ___m_staminaRegenTimer <= 0.0)
returnStamina = Mathf.Min(maxStamina, ___m_stamina + num3 * dt);

float staminaChange = returnStamina - ___m_stamina;
if (Mathf.Abs(staminaChange) > 0f)
{
BetterStaminaPlugin.DebugLog($"StaminaChangeThisFrame: {num3}(dt-{staminaChange}), base regen - {___m_staminaRegen}; activity mult - {num1}; base mult - {__instance.m_staminaRegenTimeMultiplier}; missing mult - {missingStaminaMod}; SE mult - {staminaMultiplier}");
BepInPluginTemplate.DebugLog($"StaminaChangeThisFrame: {num3}(dt-{staminaChange}), base regen - {___m_staminaRegen}; activity mult - {num1}; base mult - {__instance.m_staminaRegenTimeMultiplier}; missing mult - {missingStaminaMod}; SE mult - {staminaMultiplier}");
}

return returnStamina;
Expand All @@ -65,7 +65,7 @@ private static void UpdateStats_Prefix(Player __instance, float dt, SEMan ___m_s

if (BetterStaminaPlugin.enableStaminaRegenLogging != null && BetterStaminaPlugin.enableStaminaRegenLogging.Value)
{
float newStamina = CalculateNewStamina(__instance, ___m_wallRunning, ___m_staminaRegen, ___m_stamina, ___m_seman, ref ___m_staminaRegenTimer, dt);
CalculateNewStamina(__instance, ___m_wallRunning, ___m_staminaRegen, ___m_stamina, ___m_seman, ref ___m_staminaRegenTimer, dt);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions BetterStamina/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BetterStamina")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Rebalances stamina system to make it more forgiving and improve the combat flow.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterStamina")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyCopyright("Copyright © bakaspaceman 2021-2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.0.0.0")]
1 change: 0 additions & 1 deletion BetterStamina/StatusEffectPatches.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using BetterStamina;
using HarmonyLib;
using System.Collections.Generic;
using UnityEngine;

internal static class StatusEffectPatches
{
Expand Down
25 changes: 11 additions & 14 deletions LastUsedWeapons/LastUsedWeapons.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,27 @@
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using System;
using System.Diagnostics;
using System.Reflection;
using UnityEngine;

namespace LastUsedWeapons
{
[BepInPlugin("bakaSpaceman.LastUsedWeapons", "Last Used Weapons", "1.1.0.0")]
[BepInPlugin("bakaSpaceman.LastUsedWeapons", "Last Used Weapons", "2.0.1")]
public class LastUsedWeapons : BepInPluginTemplate
{
// Config - General
static public ConfigEntry<int> nexusID;
private ConfigEntry<KeyboardShortcut> toggleLastEquippedShortcut;
static public ConfigEntry<bool> autoEquipAfterSwimming;

static MethodInfo _toggleEquipedMethod = typeof(Humanoid).GetMethod("ToggleEquiped", BindingFlags.Instance | BindingFlags.NonPublic);
static MethodInfo _takeInputMethod = typeof(Player).GetMethod("TakeInput", BindingFlags.Instance | BindingFlags.NonPublic);
static MethodInfo _toggleEquipedMethod = typeof(Humanoid).GetMethod(nameof(Humanoid.ToggleEquipped), BindingFlags.Instance | BindingFlags.NonPublic);
static MethodInfo _takeInputMethod = typeof(Player).GetMethod(nameof(Player.TakeInput), BindingFlags.Instance | BindingFlags.NonPublic);

static FieldInfo _hiddenRightItemField = typeof(Humanoid).GetField("m_hiddenRightItem", BindingFlags.Instance | BindingFlags.NonPublic);
static FieldInfo _hiddenLeftItemField = typeof(Humanoid).GetField("m_hiddenLeftItem", BindingFlags.Instance | BindingFlags.NonPublic);
static FieldInfo _rightItemField = typeof(Humanoid).GetField("m_rightItem", BindingFlags.Instance | BindingFlags.NonPublic);
static FieldInfo _leftItemField = typeof(Humanoid).GetField("m_leftItem", BindingFlags.Instance | BindingFlags.NonPublic);
static FieldInfo _hiddenRightItemField = typeof(Humanoid).GetField(nameof(Humanoid.m_hiddenRightItem), BindingFlags.Instance | BindingFlags.NonPublic);
static FieldInfo _hiddenLeftItemField = typeof(Humanoid).GetField(nameof(Humanoid.m_hiddenLeftItem), BindingFlags.Instance | BindingFlags.NonPublic);
static FieldInfo _rightItemField = typeof(Humanoid).GetField(nameof(Humanoid.m_rightItem), BindingFlags.Instance | BindingFlags.NonPublic);
static FieldInfo _leftItemField = typeof(Humanoid).GetField(nameof(Humanoid.m_leftItem), BindingFlags.Instance | BindingFlags.NonPublic);

static ItemDrop.ItemData _lastRightItem = null;
static ItemDrop.ItemData _lastLeftItem = null;
Expand Down Expand Up @@ -59,7 +57,7 @@ void Update()
ToggleLastEquippedItems();
}

if (autoEquipAfterSwimming.Value && (!Player.m_localPlayer.IsSwiming() || Player.m_localPlayer.IsOnGround()))
if (autoEquipAfterSwimming.Value && (!Player.m_localPlayer.IsSwimming() || Player.m_localPlayer.IsOnGround()))
{
if (_hiddenItemsForSwimming)
{
Expand Down Expand Up @@ -228,7 +226,7 @@ static bool HideHandItems_Prefix(Humanoid __instance)
if (__instance != Player.m_localPlayer)
return true;

if (__instance.IsSwiming() && !__instance.IsOnGround())
if (__instance.IsSwimming() && !__instance.IsOnGround())
{
if ((ItemDrop.ItemData)_rightItemField.GetValue(__instance) != null ||
(ItemDrop.ItemData)_leftItemField.GetValue(__instance) != null)
Expand Down Expand Up @@ -267,7 +265,7 @@ void ToggleLastEquippedItems()
if ((ItemDrop.ItemData)_hiddenLeftItemField.GetValue(Player.m_localPlayer) != null ||
(ItemDrop.ItemData)_hiddenRightItemField.GetValue(Player.m_localPlayer) != null)
{
if (!Player.m_localPlayer.IsSwiming() || Player.m_localPlayer.IsOnGround())
if (!Player.m_localPlayer.IsSwimming() || Player.m_localPlayer.IsOnGround())
{
DebugLog("");
DebugLog("--- [Toggle Last Equipped] START ---");
Expand Down Expand Up @@ -308,15 +306,14 @@ void ToggleLastEquippedItems()
}

DebugLog($"Trying to equip {_lastRightItem.m_shared.m_name}({_lastRightItem.m_shared.m_itemType}) to right arm");

bool bNewItemIsTool = _lastRightItem.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Tool;
equippedRightItem = (bool)_toggleEquipedMethod.Invoke(Player.m_localPlayer, new object[] { _lastRightItem });
if (equippedRightItem)
{
DebugLog("Successful");

_lastRightItem = tempLastRightItem;

if (_lastRightItem != null)
{
DebugLog($"ToggleLastEquippedItems: last RIGHT set - {_lastRightItem.m_shared.m_name}, type - {_lastRightItem.m_shared.m_itemType}");
Expand Down
39 changes: 14 additions & 25 deletions LastUsedWeapons/LastUsedWeapons.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LastUsedWeapons</RootNamespace>
<AssemblyName>LastUsedWeapons</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
Expand All @@ -21,6 +22,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand All @@ -29,20 +31,9 @@
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\_Libs\0Harmony.dll</HintPath>
</Reference>
<Reference Include="assembly_valheim">
<HintPath>..\..\_Libs\assembly_valheim.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>..\..\_Libs\BepInEx.dll</HintPath>
</Reference>
<Reference Include="BepInEx.Harmony">
<HintPath>..\..\_Libs\BepInEx.Harmony.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -51,25 +42,23 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\_Libs\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\_Libs\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule">
<HintPath>..\..\_Libs\UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="LastUsedWeapons.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BepInEx.Core">
<Version>5.4.21</Version>
</PackageReference>
<PackageReference Include="Digitalroot.Valheim.Common.References">
<Version>0.216.902</Version>
</PackageReference>
</ItemGroup>
<Import Project="..\UnityUtils\UnityUtils.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>"$(SolutionDir)\..\_Debug Resources\pdb2mdb\pdb2mdb.exe" "$(TargetFileName)"
xcopy /y "$(TargetPath)" "$(ValheimRoot)\BepInEx\scripts\"
xcopy /y "$(TargetPath).mdb" "$(ValheimRoot)\BepInEx\scripts\"</PostBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
10 changes: 5 additions & 5 deletions LastUsedWeapons/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("LastUsedWeapons")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyDescription("Adds new shortcut to equip items you last held in your hands. Think 'Q' in CS.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyCompany("bakaspaceman")]
[assembly: AssemblyProduct("LastUsedWeapons")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyCopyright("Copyright © bakaspaceman 2021-2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("2.0.1")]
[assembly: AssemblyFileVersion("2.0.1")]
35 changes: 10 additions & 25 deletions NoWorkbenchRestrictions/NoCraftingStationRestrictions.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="0Harmony">
<HintPath>..\..\_Libs\0Harmony.dll</HintPath>
</Reference>
<Reference Include="assembly_valheim">
<HintPath>..\..\_Libs\assembly_valheim.dll</HintPath>
</Reference>
<Reference Include="BepInEx">
<HintPath>..\..\_Libs\BepInEx.dll</HintPath>
</Reference>
<Reference Include="BepInEx.Harmony">
<HintPath>..\..\_Libs\BepInEx.Harmony.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
Expand All @@ -51,26 +39,23 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnityEngine">
<HintPath>..\..\_Libs\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule">
<HintPath>..\..\_Libs\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.UI, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\_Libs\UnityEngine.UI.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="NoCraftingStationRestrictions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BepInEx.Core">
<Version>5.4.21</Version>
</PackageReference>
<PackageReference Include="Digitalroot.Valheim.Common.References">
<Version>0.216.902</Version>
</PackageReference>
</ItemGroup>
<Import Project="..\UnityUtils\UnityUtils.projitems" Label="Shared" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>"$(SolutionDir)\..\_Debug Resources\pdb2mdb\pdb2mdb.exe" "$(TargetFileName)"
xcopy /y "$(TargetPath)" "$(ValheimRoot)\BepInEx\scripts\"
xcopy /y "$(TargetPath).mdb" "$(ValheimRoot)\BepInEx\scripts\"</PostBuildEvent>
<PostBuildEvent>
</PostBuildEvent>
</PropertyGroup>
</Project>
Loading