Decompiled source of HybridArmorMod v1.0.1

HybridArmorMod.dll

Decompiled 2 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HybridArmorMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HybridArmorMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("224bd8dc-e565-4dfc-b8b1-8b271a875caf")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.yourname.hybridarmor", "Hybrid Armor Mod", "1.0.0")]
public class HybridArmorMod : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("com.yourname.hybridarmor").PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"HybridArmorMod successfully loaded.");
	}
}
[HarmonyPatch(typeof(DamageTypes), "ApplyArmor", new Type[]
{
	typeof(float),
	typeof(float)
})]
public static class ApplyArmorPatch
{
	[HarmonyPrefix]
	public static bool Prefix(float dmg, float ac, ref float __result)
	{
		__result = HybridArmorCalculation(dmg, ac);
		return false;
	}

	private static float HybridArmorCalculation(float dmg, float ac)
	{
		if (ac >= 300f)
		{
			return 0f;
		}
		float num = ((ac < dmg / 2f) ? (dmg - ac) : (Mathf.Clamp01(dmg / (ac * 4f)) * dmg));
		float num2 = dmg * Mathf.Exp(-0.02f * dmg);
		float num3 = Mathf.Clamp01((dmg - 10f) / 40f);
		return Mathf.Lerp(num2, num, num3);
	}
}