Decompiled source of RPGSkills v0.95.0

Linken-RpgSkills.dll

Decompiled a month ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("VitalitySkill")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VitalitySkill")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e0ff9c83-1101-4b55-9f0f-4a29b90e66a8")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace VitalitySkill;

[BepInPlugin("com.linken.rpgskills", "RPG Skills", "1.0.0")]
public class VitalitySkillPlugin : BaseUnityPlugin
{
	public static SkillType VitalitySkill;

	public static SkillType ResistanceSkill;

	public static SkillType WisdomSkill;

	public static SkillType ToughnessSkill;

	public static SkillType StrengthSkill;

	public static SkillType DexteritySkill;

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Expected O, but got Unknown
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Expected O, but got Unknown
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Expected O, but got Unknown
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Expected O, but got Unknown
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Expected O, but got Unknown
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		Harmony val = new Harmony("com.linken.rpgskills");
		val.PatchAll();
		SkillConfig val2 = new SkillConfig
		{
			Identifier = "com.linken.vitality",
			Name = "Vitalidad",
			Description = "Aumenta tu salud y regeneracion.",
			IncreaseStep = 1f,
			Icon = null
		};
		VitalitySkill = SkillManager.Instance.AddSkill(val2);
		SkillConfig val3 = new SkillConfig
		{
			Identifier = "com.linken.resistance",
			Name = "Resistencia",
			Description = "Aumenta tu stamina y regeneracion de stamina.",
			IncreaseStep = 1f,
			Icon = null
		};
		ResistanceSkill = SkillManager.Instance.AddSkill(val3);
		SkillConfig val4 = new SkillConfig
		{
			Identifier = "com.linken.wisdom",
			Name = "Sabiduria",
			Description = "Aumenta tu Eitr y regeneracion de Eitr.",
			IncreaseStep = 1f,
			Icon = null
		};
		WisdomSkill = SkillManager.Instance.AddSkill(val4);
		SkillConfig val5 = new SkillConfig
		{
			Identifier = "com.linken.toughness",
			Name = "Dureza",
			Description = "Aumenta tu armadura total en 1% por cada punto.",
			IncreaseStep = 1f,
			Icon = null
		};
		SkillConfig val6 = new SkillConfig
		{
			Identifier = "com.linken.strength",
			Name = "Fuerza",
			Description = "Aumenta tu daño con espadas, hachas, mazas, armas de asta y puños. Tambien sube en menor medida tu vida y peso máximo.",
			IncreaseStep = 1f,
			Icon = null
		};
		SkillConfig val7 = new SkillConfig
		{
			Identifier = "com.linken.dexterity",
			Name = "Destreza",
			Description = "Aumenta tu daño con cuchillas, lanzas, arcos y ballestas. También sube tu velocidad de ataque y movimiento.",
			IncreaseStep = 1f,
			Icon = null
		};
		DexteritySkill = SkillManager.Instance.AddSkill(val7);
		StrengthSkill = SkillManager.Instance.AddSkill(val6);
		ToughnessSkill = SkillManager.Instance.AddSkill(val5);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"RPG Skills cargado!");
	}
}
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
public static class RPGSkillsStatPatch
{
	private static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			float num = ((Character)__instance).GetSkillFactor(VitalitySkillPlugin.VitalitySkill) * 100f;
			hp += num;
			float num2 = ((Character)__instance).GetSkillFactor(VitalitySkillPlugin.ResistanceSkill) * 100f;
			stamina += num2;
			float num3 = ((Character)__instance).GetSkillFactor(VitalitySkillPlugin.WisdomSkill) * 100f;
			eitr += num3;
		}
	}
}
[HarmonyPatch(typeof(Player), "UpdateFood")]
public static class RPGSkillsRegenPatch
{
	private static float vitalityTimer;

	private static void Postfix(Player __instance, float dt)
	{
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
		{
			return;
		}
		vitalityTimer += dt;
		if (vitalityTimer >= 10f)
		{
			vitalityTimer = 0f;
			float num = ((Character)__instance).GetSkillFactor(VitalitySkillPlugin.VitalitySkill) * 100f;
			float num2 = num * 0.05f;
			if (((Character)__instance).GetHealth() < ((Character)__instance).GetMaxHealth())
			{
				((Character)__instance).Heal(num2, true);
			}
		}
		float num3 = ((Character)__instance).GetSkillFactor(VitalitySkillPlugin.WisdomSkill) * 100f;
		float num4 = num3 * 0.005f * dt;
		if (__instance.GetEitr() < ((Character)__instance).GetMaxEitr())
		{
			((Character)__instance).AddEitr(num4);
		}
	}
}
[HarmonyPatch(typeof(SEMan), "ModifyStaminaRegen")]
public static class ResistanceStaminaPatch
{
	private static void Postfix(SEMan __instance, ref float staminaMultiplier)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		Player localPlayer = Player.m_localPlayer;
		if (!((Object)(object)localPlayer == (Object)null))
		{
			float num = ((Character)localPlayer).GetSkillFactor(VitalitySkillPlugin.ResistanceSkill) * 100f;
			staminaMultiplier += num * 0.005f;
		}
	}
}
[HarmonyPatch(typeof(Player), "UseStamina")]
public static class ResistanceExpPatch
{
	private static void Prefix(Player __instance, float v)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			float num = v * 0.002f;
			((Character)__instance).RaiseSkill(VitalitySkillPlugin.ResistanceSkill, num);
		}
	}
}
[HarmonyPatch(typeof(Player), "UseEitr")]
public static class WisdomExpPatch
{
	private static void Prefix(Player __instance, float v)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			float num = v * 0.002f;
			((Character)__instance).RaiseSkill(VitalitySkillPlugin.WisdomSkill, num);
		}
	}
}
[HarmonyPatch(typeof(Player), "GetBodyArmor")]
public static class ToughnessArmorPatch
{
	private static void Postfix(Player __instance, ref float __result)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				float num = ((Character)__instance).GetSkillFactor(VitalitySkillPlugin.ToughnessSkill) * 100f;
				float num2 = 1f + num * 0.01f;
				__result *= num2;
			}
		}
	}
}
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
public static class StrengthStatsPatch
{
	private static void Postfix(Player __instance, ref float hp, ref float stamina, ref float eitr)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			float num = ((Character)__instance).GetSkillFactor(VitalitySkillPlugin.StrengthSkill) * 100f;
			hp += num * 0.2f;
		}
	}
}
[HarmonyPatch(typeof(Player), "GetMaxCarryWeight")]
public static class StrengthCarryPatch
{
	private static void Postfix(Player __instance, ref float __result)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			float num = ((Character)__instance).GetSkillFactor(VitalitySkillPlugin.StrengthSkill) * 100f;
			__result += num;
		}
	}
}
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public static class StrengthDamagePatch
{
	private static void Prefix(HitData hit)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Invalid comparison between Unknown and I4
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Invalid comparison between Unknown and I4
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Invalid comparison between Unknown and I4
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Invalid comparison between Unknown and I4
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Invalid comparison between Unknown and I4
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			return;
		}
		ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon();
		if (currentWeapon != null)
		{
			SkillType skillType = currentWeapon.m_shared.m_skillType;
			if ((int)skillType == 1 || (int)skillType == 7 || (int)skillType == 3 || (int)skillType == 4 || (int)skillType == 11)
			{
				float num = ((Character)localPlayer).GetSkillFactor(VitalitySkillPlugin.StrengthSkill) * 100f;
				float num2 = 1f + num * 0.005f;
				((DamageTypes)(ref hit.m_damage)).Modify(num2);
			}
		}
	}
}
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public static class DexterityDamagePatch
{
	private static void Prefix(HitData hit)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Invalid comparison between Unknown and I4
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Invalid comparison between Unknown and I4
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Invalid comparison between Unknown and I4
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Invalid comparison between Unknown and I4
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			return;
		}
		ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon();
		if (currentWeapon != null)
		{
			SkillType skillType = currentWeapon.m_shared.m_skillType;
			if ((int)skillType == 2 || (int)skillType == 5 || (int)skillType == 8 || (int)skillType == 14)
			{
				float num = ((Character)localPlayer).GetSkillFactor(VitalitySkillPlugin.DexteritySkill) * 100f;
				float num2 = 1f + num * 0.003f;
				((DamageTypes)(ref hit.m_damage)).Modify(num2);
			}
		}
	}
}
[HarmonyPatch(typeof(Player), "GetJogSpeedFactor")]
public static class DexterityMovementPatch
{
	private static void Postfix(Player __instance, ref float __result)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			float num = ((Character)__instance).GetSkillFactor(VitalitySkillPlugin.DexteritySkill) * 100f;
			float num2 = 1f + num * 0.01f;
			__result *= num2;
		}
	}
}
[HarmonyPatch(typeof(Player), "GetRunSpeedFactor")]
public static class DexterityRunSpeedPatch
{
	private static void Postfix(Player __instance, ref float __result)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
		{
			float num = ((Character)__instance).GetSkillFactor(VitalitySkillPlugin.DexteritySkill) * 100f;
			float num2 = 1f + num * 0.01f;
			__result *= num2;
		}
	}
}
[HarmonyPatch]
public static class DexterityAttackSpeedPatch
{
	private static FieldRef<Humanoid, Attack> _currentAttack = AccessTools.FieldRefAccess<Humanoid, Attack>("m_currentAttack");

	private static FieldRef<Attack, ZSyncAnimation> _zanim = AccessTools.FieldRefAccess<Attack, ZSyncAnimation>("m_zanim");

	[HarmonyPostfix]
	[HarmonyPatch(typeof(ZSyncAnimation), "SyncParameters")]
	public static void SyncParameters_Postfix(ZSyncAnimation __instance, Animator ___m_animator)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Expected O, but got Unknown
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)Player.m_localPlayer == (Object)null))
		{
			Attack val = _currentAttack.Invoke((Humanoid)Player.m_localPlayer);
			if (val != null && !((Object)(object)_zanim.Invoke(val) != (Object)(object)__instance) && ((Character)Player.m_localPlayer).InAttack())
			{
				float num = ((Character)Player.m_localPlayer).GetSkillFactor(VitalitySkillPlugin.DexteritySkill) * 100f;
				float num2 = num * 0.003f;
				___m_animator.speed += num2;
			}
		}
	}
}