using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SaneSkills")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ValheimStats")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9b8fca2d-9424-4c21-9593-53e63ced4f59")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SaneSkills;
[BepInPlugin("com.Horpheus.valheim.SaneSkills", "SaneSkills", "1.0.0")]
public class SaneSkills : BaseUnityPlugin
{
public const string PluginId = "com.Horpheus.valheim.SaneSkills";
private Harmony _harmony;
private void Awake()
{
_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "com.Horpheus.valheim.SaneSkills");
((BaseUnityPlugin)this).Logger.LogInfo((object)"SaneSkills Mod loaded!");
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
public static class Skills_Constructor_Patch
{
public static void Postfix(Skills __instance)
{
__instance.m_totalSkillCap = 2000f;
}
}
public static class SkillBuckets
{
public static readonly Dictionary<SkillType, SkillType[]> Buckets;
static SkillBuckets()
{
Dictionary<SkillType, SkillType[]> dictionary = new Dictionary<SkillType, SkillType[]>
{
{
(SkillType)1,
(SkillType[])(object)new SkillType[2]
{
(SkillType)2,
(SkillType)7
}
},
{
(SkillType)2,
(SkillType[])(object)new SkillType[2]
{
(SkillType)1,
(SkillType)7
}
},
{
(SkillType)7,
(SkillType[])(object)new SkillType[2]
{
(SkillType)1,
(SkillType)7
}
},
{
(SkillType)3,
(SkillType[])(object)new SkillType[1] { (SkillType)11 }
},
{
(SkillType)11,
(SkillType[])(object)new SkillType[1] { (SkillType)3 }
},
{
(SkillType)4,
(SkillType[])(object)new SkillType[1] { (SkillType)5 }
},
{
(SkillType)5,
(SkillType[])(object)new SkillType[1] { (SkillType)4 }
},
{
(SkillType)13,
(SkillType[])(object)new SkillType[1] { (SkillType)12 }
},
{
(SkillType)12,
(SkillType[])(object)new SkillType[1] { (SkillType)13 }
},
{
(SkillType)8,
(SkillType[])(object)new SkillType[1] { (SkillType)14 }
},
{
(SkillType)14,
(SkillType[])(object)new SkillType[1] { (SkillType)8 }
},
{
(SkillType)9,
(SkillType[])(object)new SkillType[1] { (SkillType)10 }
},
{
(SkillType)10,
(SkillType[])(object)new SkillType[1] { (SkillType)9 }
}
};
SkillType[] array = new SkillType[3];
RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
dictionary.Add((SkillType)100, (SkillType[])(object)array);
SkillType[] array2 = new SkillType[3];
RuntimeHelpers.InitializeArray(array2, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
dictionary.Add((SkillType)101, (SkillType[])(object)array2);
SkillType[] array3 = new SkillType[3];
RuntimeHelpers.InitializeArray(array3, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
dictionary.Add((SkillType)102, (SkillType[])(object)array3);
SkillType[] array4 = new SkillType[3];
RuntimeHelpers.InitializeArray(array4, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
dictionary.Add((SkillType)103, (SkillType[])(object)array4);
SkillType[] array5 = new SkillType[3];
RuntimeHelpers.InitializeArray(array5, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
dictionary.Add((SkillType)104, (SkillType[])(object)array5);
SkillType[] array6 = new SkillType[3];
RuntimeHelpers.InitializeArray(array6, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
dictionary.Add((SkillType)105, (SkillType[])(object)array6);
SkillType[] array7 = new SkillType[3];
RuntimeHelpers.InitializeArray(array7, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
dictionary.Add((SkillType)106, (SkillType[])(object)array7);
SkillType[] array8 = new SkillType[3];
RuntimeHelpers.InitializeArray(array8, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
dictionary.Add((SkillType)107, (SkillType[])(object)array8);
Buckets = dictionary;
}
}
[HarmonyPatch(typeof(Skills), "RaiseSkill")]
public static class RaiseSkill_Patch
{
private static bool _isRaisingExtraSkills;
public static void Postfix(Skills __instance, SkillType skillType, float factor)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Invalid comparison between Unknown and I4
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Invalid comparison between Unknown and I4
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Invalid comparison between Unknown and I4
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Invalid comparison between Unknown and I4
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
if (_isRaisingExtraSkills || (int)skillType == 0 || !SkillBuckets.Buckets.TryGetValue(skillType, out var value))
{
return;
}
try
{
_isRaisingExtraSkills = true;
SkillType[] array = value;
foreach (SkillType val in array)
{
float num = factor;
if ((int)val == 100 || (int)val == 101)
{
num *= 0.35f;
}
else if ((int)val == 103)
{
num *= 0.55f;
}
else if ((int)val == 102)
{
num *= 1.2f;
}
__instance.RaiseSkill(val, num);
}
}
finally
{
_isRaisingExtraSkills = false;
}
}
}