Decompiled source of WeaponDamageMod v1.0.0

plugins/WeaponDamageMod.dll

Decompiled 3 weeks ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
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("WeaponDamageMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WeaponDamageMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0d5b48e2-6419-42d0-ad35-7754a52a60b7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WeaponDamageMod
{
	[BepInPlugin("MarioThinks.WeaponDamageMod", "WeaponDamageMod", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		internal static ConfigEntry<int> ShovelDamage;

		internal static ConfigEntry<int> KnifeDamage;

		internal static ConfigEntry<int> ShotgunDamage;

		private readonly Harmony harmony = new Harmony("MarioThinks.WeaponDamageMod");

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			ShovelDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Weapons", "ShovelDamage", 2, "Shovel hit force (default: 2)");
			KnifeDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Weapons", "KnifeDamage", 2, "Knife hit force (default: 2)");
			ShotgunDamage = ((BaseUnityPlugin)this).Config.Bind<int>("Weapons", "ShotgunDamage", 10, "Shotgun shoot force (default: 10)");
			harmony.PatchAll();
		}
	}
}
namespace WeaponDamageMod.Utils
{
	public class Logging
	{
		internal static void Log(string message)
		{
			Plugin.Log.LogWarning((object)("[WeapongDamageMod] ============= " + message + " ============="));
		}
	}
}
namespace WeaponDamageMod.Patches
{
	[HarmonyPatch(typeof(KnifeItem), "HitKnife")]
	internal class KnifePatch
	{
		private static void Prefix(KnifeItem __instance)
		{
			__instance.knifeHitForce = Plugin.KnifeDamage.Value;
		}
	}
	[HarmonyPatch(typeof(ShotgunItem), "ShootGun")]
	internal class ShotgunPatch
	{
		private const int Index = 11;

		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			for (int num = list.Count - 1; num >= 0; num--)
			{
				if (list[num].opcode == OpCodes.Stloc_S && ((LocalBuilder)list[num].operand).LocalIndex == 11)
				{
					list.InsertRange(num + 2, (IEnumerable<CodeInstruction>)(object)new CodeInstruction[2]
					{
						new CodeInstruction(OpCodes.Ldc_I4, (object)Plugin.ShotgunDamage.Value),
						new CodeInstruction(OpCodes.Stloc_S, (object)(byte)11)
					});
					break;
				}
			}
			return list;
		}
	}
	[HarmonyPatch(typeof(Shovel), "HitShovel")]
	internal class ShovelPatch
	{
		private static void Prefix(Shovel __instance)
		{
			__instance.shovelHitForce = Plugin.ShovelDamage.Value;
		}
	}
}