Decompiled source of NoMoreMagicVests v1.0.4

larpofgod.nomoremagicvests.dll

Decompiled 3 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("larpofgod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Makes armour let through a percentage of blunt damage from any bullet impact.")]
[assembly: AssemblyFileVersion("1.0.4.0")]
[assembly: AssemblyInformationalVersion("1.0.4+a0a7efa90a82dbda56695c1809aca274ace11ab4")]
[assembly: AssemblyProduct("larpofgod.nomoremagicvests")]
[assembly: AssemblyTitle("NoMoreMagicVests")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LarpOfGod
{
	[BepInPlugin("larpofgod.nomoremagicvests", "NoMoreMagicVests", "1.0.4")]
	[BepInProcess("h3vr.exe")]
	public class NoMoreMagicVests : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(SosigWearable), "Damage")]
		private class Patch
		{
			private static bool Prefix(ref Damage d, ref SosigWearable __instance)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Invalid comparison between Unknown and I4
				//IL_0315: Unknown result type (might be due to invalid IL or missing references)
				//IL_031b: Invalid comparison between Unknown and I4
				//IL_0291: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ad: Invalid comparison between Unknown and I4
				//IL_02be: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c4: Invalid comparison between Unknown and I4
				//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_02db: Invalid comparison between Unknown and I4
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_022b: Unknown result type (might be due to invalid IL or missing references)
				//IL_015d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				bool flag = false;
				if ((int)d.Class == 1)
				{
					if ((Object)(object)__instance.S != (Object)null)
					{
						if (__instance.WeakPointVolumes.Count > 0)
						{
							for (int i = 0; i < __instance.WeakPointVolumes.Count; i++)
							{
								if (__instance.TestVolumeBool(__instance.WeakPointVolumes[i].WeakPointBox, d.point))
								{
									float num = 1f;
									if (__instance.S.IsDamResist || __instance.S.IsDamMult)
									{
										num = __instance.S.BuffIntensity_DamResistHarm;
									}
									if (__instance.S.IsFragile)
									{
										num *= 100f;
									}
									__instance.S.SetLastIFFDamageSource(d.Source_IFF);
									if (d.Source_IFF != __instance.S.E.IFFCode && d.Source_IFF > -1)
									{
										__instance.S.SetLastDamageReceivedClass(d.Class);
									}
									__instance.S.ProcessDamage(d.Dam_Piercing * __instance.WeakPointVolumes[i].PiercingDamageTransmission * __instance.S.DamMult_Piercing * num, 0f, d.Dam_Blunt * __instance.WeakPointVolumes[i].BluntDamageTransmission * __instance.S.DamMult_Blunt * num, 0f, d.point, __instance.L);
									flag = true;
									break;
								}
							}
						}
						if (!flag && __instance.BluntDamageTransmission > 0.01f)
						{
							float num2 = 1f;
							if (__instance.S.IsDamResist || __instance.S.IsDamMult)
							{
								num2 = __instance.S.BuffIntensity_DamResistHarm;
							}
							if (__instance.S.IsFragile)
							{
								num2 *= 100f;
							}
							__instance.S.SetLastIFFDamageSource(d.Source_IFF);
							if (d.Source_IFF != __instance.S.E.IFFCode && d.Source_IFF > -1)
							{
								__instance.S.SetLastDamageReceivedClass(d.Class);
							}
							Damage obj = d;
							obj.Dam_Piercing *= 0f;
							d.Dam_Blunt = d.Dam_TotalKinetic;
							Damage obj2 = d;
							obj2.Dam_Blunt *= __instance.BluntDamageTransmission / damageAbsorbtionMultiplier.Value;
							__instance.L.Damage(d);
						}
					}
					float num3 = 1f;
					if ((int)__instance.L.BodyPart == 0)
					{
						num3 = 1f;
					}
					else if ((int)__instance.L.BodyPart == 1)
					{
						num3 = 0.4f;
					}
					else if ((int)__instance.L.BodyPart == 2)
					{
						num3 = 0.1f;
					}
					else if ((int)__instance.L.BodyPart == 3)
					{
						num3 = 0.1f;
					}
					float num4 = d.Dam_Blunt * num3;
					float num5 = Mathf.Lerp(0f, 10f, num4 / 4000f);
					__instance.S.Concuss(num5);
					return false;
				}
				if ((int)d.Class == 3 && (Object)(object)__instance.L != (Object)null)
				{
					__instance.L.Damage(d);
				}
				return false;
			}
		}

		public const string Id = "larpofgod.nomoremagicvests";

		public static ConfigEntry<float> damageAbsorbtionMultiplier;

		public static string Name => "NoMoreMagicVests";

		public static string Version => "1.0.4";

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			damageAbsorbtionMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "damageAbsorbtionMultiplier", 2f, "Higher values mean armor absorbs more damage (bottom capped at 1)");
			damageAbsorbtionMultiplier.Value = Mathf.Max(1f, damageAbsorbtionMultiplier.Value);
			Harmony.CreateAndPatchAll(typeof(Patch), (string)null);
			Logger.LogMessage((object)("Hello, world! Sent from larpofgod.nomoremagicvests " + Name + " " + Version));
		}
	}
}