using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NerfBuffBossHealth")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NerfBuffBossHealth")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("260c10ac-6c86-41da-be4b-e5891db32a21")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NerfBuffBossHealth;
[HarmonyPatch(typeof(Character), "SetMaxHealth")]
public class MaxHealthPatch
{
public static void Prefix(Character __instance, ref float health)
{
if (!ThisPlugin.PluginEnabled.Value || !((Object)(object)__instance != (Object)null) || !__instance.IsBoss() || Player.GetAllPlayers().Count > ThisPlugin.NumberOfPlayersMax.Value)
{
return;
}
string text = __instance.m_name.ToLower();
float? num = null;
if (text == "$enemy_eikthyr" && ThisPlugin.ModifyEikthyr.Value)
{
num = ThisPlugin.HealthEikthyr.Value;
}
else if (text == "$enemy_gdking" && ThisPlugin.ModifyElder.Value)
{
num = ThisPlugin.HealthElder.Value;
}
else if (text == "$enemy_bonemass" && ThisPlugin.ModifyBonemass.Value)
{
num = ThisPlugin.HealthBonemass.Value;
}
else if (text == "$enemy_dragon" && ThisPlugin.ModifyModer.Value)
{
num = ThisPlugin.HealthModer.Value;
}
else if (text == "$enemy_goblinking" && ThisPlugin.ModifyYagluth.Value)
{
num = ThisPlugin.HealthYagluth.Value;
}
else if (text == "$enemy_seekerqueen" && ThisPlugin.ModifyQueen.Value)
{
num = ThisPlugin.HealthQueen.Value;
}
else if (text == "$enemy_fader" && ThisPlugin.ModifyFader.Value)
{
num = ThisPlugin.HealthFader.Value;
}
if (num.HasValue)
{
health = num.Value;
if (ThisPlugin.DebugOutput.Value)
{
Debug.Log((object)("NerfBuffBossHealth.MaxHealthPatch :: " + text + " :: " + health));
}
}
}
}
[BepInPlugin("NerfBuffBossHealth", "NerfBuffBossHealth", "0.1.0")]
[BepInProcess("valheim.exe")]
public class ThisPlugin : BaseUnityPlugin
{
public const string PluginName = "NerfBuffBossHealth";
public const string PluginAuthor = "k-Knight";
public const string PluginVersion = "0.1.0";
public const string PluginGUID = "NerfBuffBossHealth";
public static ConfigEntry<bool> PluginEnabled;
public static ConfigEntry<bool> DebugOutput;
public static ConfigEntry<int> NumberOfPlayersMax;
public static ConfigEntry<float> RegenerationMultiplier;
public static ConfigEntry<bool> ModifyEikthyr;
public static ConfigEntry<bool> ModifyElder;
public static ConfigEntry<bool> ModifyBonemass;
public static ConfigEntry<bool> ModifyModer;
public static ConfigEntry<bool> ModifyYagluth;
public static ConfigEntry<bool> ModifyQueen;
public static ConfigEntry<bool> ModifyFader;
public static ConfigEntry<float> HealthEikthyr;
public static ConfigEntry<float> HealthElder;
public static ConfigEntry<float> HealthBonemass;
public static ConfigEntry<float> HealthModer;
public static ConfigEntry<float> HealthYagluth;
public static ConfigEntry<float> HealthQueen;
public static ConfigEntry<float> HealthFader;
private static ThisPlugin thisInstance;
public static ThisPlugin instance => thisInstance;
public void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
thisInstance = this;
LoadSettings();
if (PluginEnabled.Value)
{
new Harmony("NerfBuffBossHealth").PatchAll();
}
if (DebugOutput.Value)
{
DumpConfiguration();
}
}
public void OnDestroy()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
new Harmony("NerfBuffBossHealth").UnpatchSelf();
}
public static void LoadSettings()
{
PluginEnabled = ((BaseUnityPlugin)instance).Config.Bind<bool>("General", "Enabled", true, "Enable/disable this pulgin.");
DebugOutput = ((BaseUnityPlugin)instance).Config.Bind<bool>("General", "Debug", false, "Enable/disable debug logging.");
NumberOfPlayersMax = ((BaseUnityPlugin)instance).Config.Bind<int>("General", "NumberOfPlayersMax", 1, "Maximum number of active players to modify health and regen.");
RegenerationMultiplier = ((BaseUnityPlugin)instance).Config.Bind<float>("General", "RegenerationMultiplier", 0f, "Multiply base game regen by this decimal value (0 disables, 0.5 is 50% of normal value)");
ModifyEikthyr = ((BaseUnityPlugin)instance).Config.Bind<bool>("Boss Toggle", "ModifyEikthyr", true, "Modify Eikthyr health and regen.");
ModifyElder = ((BaseUnityPlugin)instance).Config.Bind<bool>("Boss Toggle", "ModifyElder", true, "Modify Elder health and regen.");
ModifyBonemass = ((BaseUnityPlugin)instance).Config.Bind<bool>("Boss Toggle", "ModifyBonemass", true, "Modify Bonemass health and regen.");
ModifyModer = ((BaseUnityPlugin)instance).Config.Bind<bool>("Boss Toggle", "ModifyModer", true, "Modify Moder health and regen.");
ModifyYagluth = ((BaseUnityPlugin)instance).Config.Bind<bool>("Boss Toggle", "ModifyYagluth", true, "Modify Yagluth health and regen.");
ModifyQueen = ((BaseUnityPlugin)instance).Config.Bind<bool>("Boss Toggle", "ModifyQueen", true, "Modify Queen health and regen.");
ModifyFader = ((BaseUnityPlugin)instance).Config.Bind<bool>("Boss Toggle", "ModifyFader", true, "Modify Fader health and regen.");
HealthEikthyr = ((BaseUnityPlugin)instance).Config.Bind<float>("Boss Health", "HealthEikthyr", 750f, "New Eikthyr max health.");
HealthElder = ((BaseUnityPlugin)instance).Config.Bind<float>("Boss Health", "HealthElder", 2500f, "New Elder max health.");
HealthBonemass = ((BaseUnityPlugin)instance).Config.Bind<float>("Boss Health", "HealthBonemass", 5000f, "New Bonemass max health.");
HealthModer = ((BaseUnityPlugin)instance).Config.Bind<float>("Boss Health", "HealthModer", 7500f, "New Moder max health.");
HealthYagluth = ((BaseUnityPlugin)instance).Config.Bind<float>("Boss Health", "HealthYagluth", 10000f, "New Yagluth max health.");
HealthQueen = ((BaseUnityPlugin)instance).Config.Bind<float>("Boss Health", "HealthQueen", 12500f, "New Queen max health.");
HealthFader = ((BaseUnityPlugin)instance).Config.Bind<float>("Boss Health", "HealthFader", 15000f, "New Fader max health.");
}
public static void DumpConfiguration()
{
Debug.Log((object)"------------ NerfBuffBossHealth CFG START ------------");
if ((Object)(object)ZNet.instance != (Object)null)
{
Debug.Log((object)("NerfBuffBossHealth,IsServer," + ZNet.instance.IsServer()));
}
Debug.Log((object)("NerfBuffBossHealth.GetAllPlayers," + Player.GetAllPlayers().Count));
Debug.Log((object)("NerfBuffBossHealth.NumberOfPlayersMax," + NumberOfPlayersMax.Value));
Debug.Log((object)("NerfBuffBossHealth.RegenerationMultiplier," + RegenerationMultiplier.Value));
Debug.Log((object)("NerfBuffBossHealth.ModifyEikthyr," + ModifyEikthyr.Value));
Debug.Log((object)("NerfBuffBossHealth.ModifyElder," + ModifyElder.Value));
Debug.Log((object)("NerfBuffBossHealth.ModifyBonemass," + ModifyBonemass.Value));
Debug.Log((object)("NerfBuffBossHealth.ModifyModer," + ModifyModer.Value));
Debug.Log((object)("NerfBuffBossHealth.ModifyYagluth," + ModifyYagluth.Value));
Debug.Log((object)("NerfBuffBossHealth.ModifyQueen," + ModifyQueen.Value));
Debug.Log((object)("NerfBuffBossHealth.ModifyFader," + ModifyFader.Value));
Debug.Log((object)("NerfBuffBossHealth.HealthEikthyr," + HealthEikthyr.Value));
Debug.Log((object)("NerfBuffBossHealth.HealthElder," + HealthElder.Value));
Debug.Log((object)("NerfBuffBossHealth.HealthBonemass," + HealthBonemass.Value));
Debug.Log((object)("NerfBuffBossHealth.HealthModer," + HealthModer.Value));
Debug.Log((object)("NerfBuffBossHealth.HealthYagluth," + HealthYagluth.Value));
Debug.Log((object)("NerfBuffBossHealth.HealthQueen," + HealthQueen.Value));
Debug.Log((object)("NerfBuffBossHealth.HealthFader," + HealthFader.Value));
Debug.Log((object)"------------- NerfBuffBossHealth CFG END -------------");
}
}
[HarmonyPatch(typeof(Character), "Heal")]
public class RegenPatch
{
public static void Prefix(Character __instance, ref float hp)
{
if (!ThisPlugin.PluginEnabled.Value || !((Object)(object)__instance != (Object)null) || !__instance.IsBoss() || !((Object)(object)ZNet.instance != (Object)null) || !ZNet.instance.IsServer() || Player.GetAllPlayers().Count > ThisPlugin.NumberOfPlayersMax.Value)
{
return;
}
string text = __instance.m_name.ToLower();
bool flag = false;
if (text == "$enemy_eikthyr" && ThisPlugin.ModifyEikthyr.Value)
{
flag = true;
}
else if (text == "$enemy_gdking" && ThisPlugin.ModifyElder.Value)
{
flag = true;
}
else if (text == "$enemy_bonemass" && ThisPlugin.ModifyBonemass.Value)
{
flag = true;
}
else if (text == "$enemy_dragon" && ThisPlugin.ModifyModer.Value)
{
flag = true;
}
else if (text == "$enemy_goblinking" && ThisPlugin.ModifyYagluth.Value)
{
flag = true;
}
else if (text == "$enemy_seekerqueen" && ThisPlugin.ModifyQueen.Value)
{
flag = true;
}
else if (text == "$enemy_fader" && ThisPlugin.ModifyFader.Value)
{
flag = true;
}
if (flag)
{
hp *= ThisPlugin.RegenerationMultiplier.Value;
if (ThisPlugin.DebugOutput.Value)
{
Debug.Log((object)("NerfBuffBossHealth.RegenPatch :: " + text + " :: " + __instance.GetHealth() + " / " + __instance.GetMaxHealth()));
}
}
}
}