Decompiled source of Scrumpie Weapon Stat Editor v1.2.3

plugins/WeaponCooldownRemover.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
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("Scrumpie's Weapon And Player Stat Editor")]
[assembly: AssemblyDescription("A simple mod that lets you customise all sorts of aspects about the player and their weapons.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WeaponStatEditor")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("519ee713-d9b3-4ff8-85d2-4dbf0c179085")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WeaponStatEditor;

[BepInPlugin("Scrumpie.WeaponStatEditor", "Scrumpie's Weapon And Player Stat Editor", "0.0.1.1")]
[BepInProcess("ULTRAKILL.exe")]
public class WeaponPropertyEditor : BaseUnityPlugin
{
	[HarmonyPatch(typeof(NewMovement), "Start")]
	private class PlayerStats
	{
		[HarmonyPostfix]
		private static void OveridePlayerMovementStats(NewMovement __instance, ref float ___jumpPower, ref float ___walkSpeed, ref float ___airAcceleration, ref float ___wallJumpPower, ref int ___rocketRides)
		{
			___airAcceleration = C_PlayerAirAcceleration.Value;
			___jumpPower = C_PlayerJumpPower.Value;
			___walkSpeed = C_PlayerMovementSpeed.Value;
			___wallJumpPower = C_PlayerWallJumpPower.Value;
		}
	}

	[HarmonyPatch(typeof(NewMovement), "Update")]
	private class InfiniteStamina
	{
		[HarmonyPostfix]
		private static void AlwaysInfiniteStamina(NewMovement __instance, ref int ___rocketRides)
		{
			if (C_PlayerInfiniteStamina.Value)
			{
				__instance.FullStamina();
			}
			if (C_PlayerNoAntiHp.Value)
			{
				__instance.ResetHardDamage();
			}
			if (C_PlayerInfiniteRocketRides.Value)
			{
				___rocketRides = 0;
			}
		}
	}

	[HarmonyPatch(typeof(Revolver), "Update")]
	private class RemoveRevolverCooldown
	{
		[HarmonyPostfix]
		private static void MakeRevolverAlwaysReady(Revolver __instance)
		{
			if (Input.GetMouseButtonDown(0) && C_Instafire_Revolver.Value)
			{
				MethodInfo method = ((object)__instance).GetType().GetMethod("Shoot", BindingFlags.Instance | BindingFlags.NonPublic);
				method.Invoke(__instance, new object[1] { 1 });
			}
		}
	}

	[HarmonyPatch(typeof(RevolverBeam), "Start")]
	private class ChangeRevolverAttributes
	{
		[HarmonyPostfix]
		private static void RevolverAttributesOveride(ref bool ___canHitProjectiles, ref float ___bulletForce, ref float ___damage, ref bool ___strongAlt, RevolverBeam __instance)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Invalid comparison between Unknown and I4
			if ((int)__instance.beamType == 0)
			{
				___canHitProjectiles = true;
				___bulletForce = C_RevolverBulletForce.Value;
				___damage = 1f * C_RevolverDamageMultiplier.Value;
			}
		}
	}

	[HarmonyPatch(typeof(RocketLauncher), "Start")]
	private class SetLauncherCooldown
	{
		[HarmonyPostfix]
		private static void RocketLauncherOveride(ref float ___rateOfFire)
		{
			___rateOfFire = C_RocketLauncherRateOfFire.Value;
		}
	}

	[HarmonyPatch(typeof(Grenade), "Start")]
	public class GrenadeEdit
	{
		[HarmonyPostfix]
		private static void RocketDamageOveride(ref float ___totalDamageMultiplier, ref bool ___rocket, Grenade __instance, ref float ___rocketSpeed)
		{
			if (___rocket)
			{
				___totalDamageMultiplier = C_RocketDamageMultiplier.Value;
				___rocketSpeed = C_RocketSpeed.Value;
			}
		}
	}

	[HarmonyPatch(typeof(Punch), "Start")]
	private class SetPunchAttributes
	{
		[HarmonyPostfix]
		private static void PunchDamageOveride(ref float ___damage, ref float ___cooldownCost, ref float ___force)
		{
			___damage = 1f * C_BlueFistDamageMultiplier.Value;
			___force = 25f * C_BlueFistForceMultiplier.Value;
		}
	}

	[HarmonyPatch(typeof(Projectile), "Start")]
	private class SetShotgunBulletAttributes
	{
		[HarmonyPostfix]
		private static void PelletDamageOveride(ref float ___damage, ref float ___speed, ref bool ___explosive, Projectile __instance)
		{
			if (__instance.playerBullet)
			{
				___damage = C_ShotgunDamage.Value;
				___speed = C_ShotgunBulletSpeed.Value;
			}
		}
	}

	[HarmonyPatch(typeof(Shotgun), "Update")]
	private class RemoveShotgunCooldown
	{
		[HarmonyPostfix]
		private static void ShotgunShotOveride(Shotgun __instance)
		{
			if (Input.GetMouseButtonDown(0) && C_ShotgunInstafire.Value)
			{
				MethodInfo method = ((object)__instance).GetType().GetMethod("Shoot", BindingFlags.Instance | BindingFlags.NonPublic);
				method.Invoke(__instance, new object[0]);
			}
		}
	}

	[HarmonyPatch(typeof(Nail), "Start")]
	private class EditNailProperties
	{
		[HarmonyPostfix]
		private static void NailPropertyOveride(Nail __instance, ref float ___damage)
		{
			if (!__instance.sawblade)
			{
				___damage = C_NailDamage.Value;
			}
			else
			{
				___damage = C_SawDamage.Value;
			}
		}
	}

	[HarmonyPatch(typeof(Nailgun), "Start")]
	private class EditNailgunProperties
	{
		[HarmonyPostfix]
		private static void NailgunPropertyOveride(Nailgun __instance, ref float ___fireRate, ref float ___spread)
		{
			if (!__instance.altVersion)
			{
				___fireRate = C_NailgunFirerate.Value;
				___spread = C_NailgunSpread.Value;
			}
			else
			{
				___fireRate = C_SawbladeFirerate.Value;
				___spread = C_SawbladeSpread.Value;
			}
		}
	}

	[HarmonyPatch(typeof(WeaponCharges), "MaxCharges")]
	private class EditWeaponAmmoProperties
	{
		[HarmonyPostfix]
		private static void NailgunAmmoOveride(ref float ___naiAmmo, ref float ___naiSaws)
		{
			___naiAmmo = 200f;
			___naiSaws = 100f;
		}
	}

	private static ConfigEntry<string> C_greeting;

	private static ConfigEntry<float> C_PlayerMovementSpeed;

	private static ConfigEntry<float> C_PlayerJumpPower;

	private static ConfigEntry<float> C_PlayerAirAcceleration;

	private static ConfigEntry<float> C_PlayerWallJumpPower;

	private static ConfigEntry<bool> C_PlayerInfiniteStamina;

	private static ConfigEntry<bool> C_PlayerNoAntiHp;

	private static ConfigEntry<bool> C_PlayerInfiniteRocketRides;

	private static ConfigEntry<float> C_RocketLauncherRateOfFire;

	private static ConfigEntry<float> C_RocketDamageMultiplier;

	private static ConfigEntry<float> C_RocketSpeed;

	private static ConfigEntry<bool> C_Instafire_Revolver;

	private static ConfigEntry<float> C_RevolverDamageMultiplier;

	private static ConfigEntry<float> C_RevolverBulletForce;

	private static ConfigEntry<float> C_BlueFistDamageMultiplier;

	private static ConfigEntry<float> C_BlueFistCooldown;

	private static ConfigEntry<float> C_BlueFistForceMultiplier;

	private static ConfigEntry<float> C_ShotgunDamage;

	private static ConfigEntry<float> C_ShotgunBulletSpeed;

	private static ConfigEntry<bool> C_ShotgunInstafire;

	private static ConfigEntry<float> C_NailgunFirerate;

	private static ConfigEntry<float> C_NailgunSpread;

	private static ConfigEntry<float> C_NailDamage;

	private static ConfigEntry<float> C_SawbladeFirerate;

	private static ConfigEntry<float> C_SawbladeSpread;

	private static ConfigEntry<float> C_SawDamage;

	private const string modGUID = "Scrumpie.WeaponStatEditor";

	private const string modName = "Scrumpie's Weapon And Player Stat Editor";

	private const string modVersion = "0.0.1.1";

	private readonly Harmony harmony = new Harmony("Scrumpie.WeaponStatEditor");

	private void Awake()
	{
		C_greeting = ((BaseUnityPlugin)this).Config.Bind<string>("General", "GreetingText", "Hello! Thank you for downloading Scrumpie's 1st mod ever! Bashing my head against the walltrying to learn how to use Harmony X was surprisingly fun! I have more planned, so stay tuned!", "The Greeting Text to show when the game is launched. Its entirely useless, but I had to learn how to use configs somehow!");
		C_PlayerMovementSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Player", "Player Movement Speed", 750f, "How fast the player will move");
		C_PlayerJumpPower = ((BaseUnityPlugin)this).Config.Bind<float>("Player", "Player Jump Power", 90f, "How high the player will jump");
		C_PlayerAirAcceleration = ((BaseUnityPlugin)this).Config.Bind<float>("Player", "Player Air Acceleration", 6000f, "How fast the player will change directions in midair");
		C_PlayerWallJumpPower = ((BaseUnityPlugin)this).Config.Bind<float>("Player", "Player Walljump Power", 150f, "How high and far the wall will push you when you jump off it. Don't try to make this negative (Which means you should try it)");
		C_PlayerInfiniteStamina = ((BaseUnityPlugin)this).Config.Bind<bool>("Player", "Infinite Stamina", false, "Decides wether or not you will drain stamina. Works surprisingly well, with no annoying bar recover noise every frame.");
		C_PlayerNoAntiHp = ((BaseUnityPlugin)this).Config.Bind<bool>("Player", "Toggle no anti-hp", false, "Do you want anti hp or do you wanna go HAM (Probably breaks game balance)");
		C_PlayerInfiniteRocketRides = ((BaseUnityPlugin)this).Config.Bind<bool>("Player", "Infinite Rocket Rides", false, "Toggles Infinite Rocket Rides");
		C_Instafire_Revolver = ((BaseUnityPlugin)this).Config.Bind<bool>("Revolver", "Revolver Instafire", false, "Decides weather or not the revolver will fire when you press mouse1, regardless of cooldown.");
		C_RevolverDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Revolver", "Revolver Damage Multiplier", 1f, "A multiplier for the revolver's overall damage.");
		C_RevolverBulletForce = ((BaseUnityPlugin)this).Config.Bind<float>("Revolver", "Revolver Bullet Force", 5000f, "How much force will be exerted on enemies who are shot with the revolver. I wonder what negative values do?");
		C_RocketLauncherRateOfFire = ((BaseUnityPlugin)this).Config.Bind<float>("Rocket Launcher", "Rocket Launcher Rate of Fire", 1f, "How fast the rocket launcher will fire.");
		C_RocketDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Rocket Launcher", "Rocket Launcher Damage Multiplier", 1f, "Sets how much the Damage Multiplier of a ROCKET will be.");
		C_RocketSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Rocket Launcher", "Rocket Speed", 100f, "How fast the rocket launcher goes. It's really fast by default, and might break collision if it's too fast (Depends on wether it raytraces or not)");
		C_BlueFistDamageMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Fist", "Blue Fist Damage Multiplier", 1f, "Multiplier for Blue Fist damage");
		C_BlueFistCooldown = ((BaseUnityPlugin)this).Config.Bind<float>("Fist", "Blue Fist Cooldown", 2f, "The cooldown for the blue fist. Set to 2 in the vanilla game. Not in seconds.");
		C_BlueFistForceMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Fist", "Blue Fist Force Multiplier", 1f, "A multiplier for the force the blue fist exerts. Doesn't have gameplay advantages, just for fun.");
		C_ShotgunInstafire = ((BaseUnityPlugin)this).Config.Bind<bool>("Shotgun", "Shotgun Instafire Toggle", true, "Toggles Shotgun Instafire (Will always fire when you press mouse1)");
		C_ShotgunDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Shotgun", "Shotgun Damage", 1f, "How much damage each individual shotgun pellet will do.");
		C_ShotgunBulletSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Shotgun", "Shotgun Bullet Speed", 66f, "How fast the shotgun bullets will go. It's decently fast by default.");
		C_NailgunFirerate = ((BaseUnityPlugin)this).Config.Bind<float>("Nailgun", "Nailgun Firerate", 4f, "How fast the nailgun will fire. The lower the value, the higher the firerate.");
		C_NailgunSpread = ((BaseUnityPlugin)this).Config.Bind<float>("Nailgun", "Nailgun spread", 20f, "How far the nailgun's nails will stray from the cursor. The lower the value, the less the spread.");
		C_NailDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Nailgun", "Nail Damage", 0.185f, "How much damage each nail will do.");
		C_SawbladeFirerate = ((BaseUnityPlugin)this).Config.Bind<float>("Sawblade Launcher", "Sawblade Firerate", 24f, "How often the sawblade fires a saw. The lower the value, the faster the firerate.");
		C_SawbladeSpread = ((BaseUnityPlugin)this).Config.Bind<float>("Sawblade Launcher", "Sawblade Spread", 0f, "How much blades shot out will deviate from the crosshair. It usually has no spread, and I don't know why you would ever change this, but you can. Maybe you could mess around with negative values?");
		C_SawDamage = ((BaseUnityPlugin)this).Config.Bind<float>("Sawblade Launcher", "Saw Damage", 0.75f, "How much damage each sawblade does.");
		harmony.PatchAll();
	}
}