Decompiled source of Scrumpie WeaponStatEditor v1.3.4

plugins/WeaponCooldownRemover.dll

Decompiled 8 months ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using Configgy;
using HarmonyLib;
using UnityEngine;
using UnityEngine.AddressableAssets;
using WeaponStatEditor.Prefabs;

[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.2.1")]
	[BepInProcess("ULTRAKILL.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	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 = Configs.P_PlayerAirAcceleration;
				___jumpPower = Configs.P_PlayerJumpPower;
				___walkSpeed = Configs.P_PlayerMovementSpeed;
				___wallJumpPower = Configs.P_PlayerWallJumpPower;
			}
		}

		[HarmonyPatch(typeof(NewMovement), "Update")]
		private class InfiniteStamina
		{
			[HarmonyPostfix]
			private static void AlwaysInfiniteStamina(NewMovement __instance, ref int ___rocketRides)
			{
				if (((ConfigValueElement<bool>)(object)Configs.P_PlayerInfiniteStamina).Value)
				{
					__instance.FullStamina();
				}
				if (((ConfigValueElement<bool>)(object)Configs.P_PlayerNoAntiHp).Value)
				{
					__instance.ResetHardDamage();
				}
				if (((ConfigValueElement<bool>)(object)Configs.P_PlayerInfiniteRocketRides).Value)
				{
					___rocketRides = 0;
				}
			}
		}

		[HarmonyPatch(typeof(Revolver), "Update")]
		private class RemoveRevolverCooldown
		{
			[HarmonyPostfix]
			private static void MakeRevolverAlwaysReady(Revolver __instance)
			{
				if (Input.GetMouseButtonDown(0) && ((ConfigValueElement<bool>)(object)Configs.P_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(RevolverBeam __instance, ref bool ___canHitProjectiles, ref float ___bulletForce, ref float ___damage, ref bool ___strongAlt)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Invalid comparison between Unknown and I4
				if ((int)__instance.beamType == 0)
				{
					___canHitProjectiles = true;
					___damage = 10000f;
				}
			}
		}

		[HarmonyPatch(typeof(RevolverBeam), "HitSomething")]
		private class ExplodeOnHit
		{
			[HarmonyPostfix]
			private static void RevolverExplosionOveride(RevolverBeam __instance, ref RaycastHit ___hit)
			{
				//IL_0002: 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_0029: Unknown result type (might be due to invalid IL or missing references)
				if ((int)__instance.beamType == 0 && ((ConfigValueElement<bool>)(object)Configs.P_RevolverExplodes).Value)
				{
					GameObject val = Object.Instantiate<GameObject>(explosion, ((RaycastHit)(ref ___hit)).point, Quaternion.identity);
					Explosion componentInChildren = val.GetComponentInChildren<Explosion>();
					if (Configs.P_RevolverExplosionDamage == 0)
					{
						componentInChildren.damage = Mathf.RoundToInt(1f * Configs.P_RevolverDamageMultiplier);
					}
					else
					{
						componentInChildren.damage = Mathf.RoundToInt((float)Configs.P_RevolverExplosionDamage);
					}
					componentInChildren.maxSize = Configs.P_RevolverExplosionSize;
					componentInChildren.friendlyFire = true;
					componentInChildren.harmless = false;
					componentInChildren.rocketExplosion = false;
					componentInChildren.unblockable = ((ConfigValueElement<bool>)(object)Configs.P_RevExplosionUnblockable).Value;
					componentInChildren.electric = true;
					componentInChildren.speed = Configs.P_RevExplosionSpeed;
				}
			}
		}

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

		[HarmonyPatch(typeof(Grenade), "Start")]
		public class GrenadeEdit
		{
			[HarmonyPostfix]
			private static void RocketDamageOveride(ref float ___totalDamageMultiplier, ref bool ___rocket, Grenade __instance, ref float ___rocketSpeed, ref GameObject ___explosion)
			{
				if (___rocket)
				{
					___rocketSpeed = Configs.P_RocketSpeed;
					___explosion = explosion;
					Explosion component = explosion.GetComponent<Explosion>();
					component.damage = 100;
					component.harmless = false;
					component.rocketExplosion = false;
				}
			}
		}

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

		[HarmonyPatch(typeof(Projectile), "Start")]
		private class SetShotgunBulletAttributes
		{
			[HarmonyPostfix]
			private static void PelletDamageOveride(ref float ___damage, ref float ___speed, ref bool ___explosive, Projectile __instance, ref GameObject ___explosionEffect)
			{
				if (!__instance.playerBullet)
				{
					return;
				}
				___damage = Configs.P_ShotgunDamage;
				___speed = ((ConfigValueElement<float>)(object)Configs.P_ShotgunBulletSpeed).Value;
				if (!((ConfigValueElement<bool>)(object)Configs.P_EnableShotgunPelletExplosions).Value)
				{
					return;
				}
				___explosive = true;
				__instance.bigExplosion = false;
				___explosionEffect = explosion;
				Explosion componentInChildren = ___explosionEffect.GetComponentInChildren<Explosion>();
				componentInChildren.lowQuality = true;
				if (((ConfigValueElement<bool>)(object)Configs.P_ShotExplosionsUsesBaseDamage).Value)
				{
					componentInChildren.damage = Mathf.RoundToInt(___damage);
				}
				else
				{
					componentInChildren.damage = Configs.P_ShotExplosionDamageOveride;
				}
				componentInChildren.friendlyFire = ((ConfigValueElement<bool>)(object)Configs.P_ShotExplosionFriendlyFire).Value;
				componentInChildren.harmless = false;
				componentInChildren.maxSize = Configs.P_ShotExplosionSize;
				componentInChildren.speed = Configs.P_ShotExplosionSpeed;
				componentInChildren.unblockable = ((ConfigValueElement<bool>)(object)Configs.P_ShotUnblockable).Value;
				Explosion[] componentsInChildren = ___explosionEffect.GetComponentsInChildren<Explosion>();
				Explosion[] array = componentsInChildren;
				foreach (Explosion val in array)
				{
					if (((Object)((Component)val).gameObject).name == "Sphere_8 (1)")
					{
						((Component)val).gameObject.SetActive(false);
					}
				}
			}
		}

		private class EditShotgunChainsawStats
		{
			[HarmonyPatch(typeof(Chainsaw), "Start")]
			[HarmonyPostfix]
			private static void ChainsawEdit(Chainsaw __instance, ref float ___damage)
			{
				___damage = Configs.P_ChainsawDamage;
			}
		}

		[HarmonyPatch(typeof(Shotgun), "Update")]
		private class RemoveShotgunCooldown
		{
			[HarmonyPostfix]
			private static void ShotgunShotOveride(Shotgun __instance)
			{
				if (Input.GetMouseButtonDown(0) && ((ConfigValueElement<bool>)(object)Configs.P_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 = Configs.P_NailDamage;
				}
				else
				{
					___damage = Configs.P_SawDamage;
				}
			}
		}

		[HarmonyPatch(typeof(Nailgun), "Start")]
		private class EditNailgunProperties
		{
			[HarmonyPostfix]
			private static void NailgunPropertyOveride(Nailgun __instance, ref float ___fireRate, ref float ___spread)
			{
				if (!__instance.altVersion)
				{
					___fireRate = ((ConfigValueElement<float>)(object)Configs.P_NailgunFirerate).Value;
					___spread = ((ConfigValueElement<float>)(object)Configs.P_NailgunSpread).Value;
				}
				else
				{
					___fireRate = ((ConfigValueElement<float>)(object)Configs.P_SawbladeFirerate).Value;
					___spread = ((ConfigValueElement<float>)(object)Configs.P_SawbladeSpread).Value;
				}
			}
		}

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

		internal static ManualLogSource Logger;

		private ConfigBuilder config;

		public static GameObject explosion;

		public static GameObject superExplosion;

		private const string modGUID = "Scrumpie.WeaponStatEditor";

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

		private const string modVersion = "0.0.2.1";

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

		private void Awake()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			config = new ConfigBuilder("Scrumpie.WeaponStatEditor", "Scrumpie's Weapon And Player Stat Editor");
			config.BuildAll();
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin Scrumpie.WeaponStatEditor is loaded!");
			explosion = Prefab.Fetch<GameObject>(Prefab.explosion_path);
			superExplosion = Prefab.Fetch<GameObject>(Prefab.explosionSuper_path);
			harmony.PatchAll();
		}
	}
	public class Configs : MonoBehaviour
	{
		[Configgable("Player Stats", "Movement Speed", 0, "How fast the player will move while walking.")]
		public static float P_PlayerMovementSpeed = 750f;

		[Configgable("Player Stats", "Jump Power", 1, "How high the player will jump.")]
		public static float P_PlayerJumpPower = 90f;

		[Configgable("Player Stats", "Air Acceleration", 2, "How fast will the player change directions in midair?")]
		public static float P_PlayerAirAcceleration = 6000f;

		[Configgable("Player Stats", "Walljump Power", 2, "How far the player will go when jumping off of a wall.")]
		public static float P_PlayerWallJumpPower = 150f;

		[Configgable("Player Stats", "Infinite Stamina", 2, "Self explainitory. What were you expecting?")]
		public static ConfigToggle P_PlayerInfiniteStamina = new ConfigToggle(false);

		[Configgable("Player Stats", "Disable AntiHp", 2, "Will you accumulate hard damage from being stupid?")]
		public static ConfigToggle P_PlayerNoAntiHp = new ConfigToggle(false);

		[Configgable("Player Stats", "Infinite Rocket Rides", 2, "Will subsequent rocket rides have less and less height?")]
		public static ConfigToggle P_PlayerInfiniteRocketRides = new ConfigToggle(false);

		[Configgable("Rocket Launcher", "Rate of Fire", 0, "How fast the rocket launcher will recover. The closer to 0, the faster.")]
		public static float P_RocketLauncherRateOfFire = 1f;

		[Configgable("Rocket Launcher", "Damage Multiplier", 0, "How much damage the rocket launcher will do.")]
		public static float P_RocketDamageMultiplier = 1f;

		[Configgable("Rocket Launcher", "Rocket Speed", 0, "How fast the rocket will travel. High values may ruin collision.")]
		public static float P_RocketSpeed;

		[Configgable("Revolver", "Instafire", 2, "Will the revolver instantly fire when you press mouse1? (Will also fire when your in the menu, gonna figure out how to fix that soon.)")]
		public static ConfigToggle P_Instafire_Revolver = new ConfigToggle(false);

		[Configgable("Revolver", "Damage Multiplier", 2, "How much damage the revolver beam will do.")]
		public static float P_RevolverDamageMultiplier = 1f;

		[Configgable("Revolver", "Enable Revolver Explosion", 3, "Enables revolver explosion along with all of its settings.")]
		public static ConfigToggle P_RevolverExplodes = new ConfigToggle(false);

		[Configgable("Revolver", "Explosion Damage", 4, "How much damage the explosion from the revolver will do. Int only.")]
		public static int P_RevolverExplosionDamage = 3;

		[Configgable("Revolver", "Explosion Size", 4, "How big the explosion will be.")]
		public static float P_RevolverExplosionSize = 1f;

		[Configgable("Revolver", "Explosion Friendly Fire", 4, "Can the explosion harm you?")]
		public static ConfigToggle P_RevExplosionFriendlyFire = new ConfigToggle(false);

		[Configgable("Revolver", "Explosion Expansion speed", 4, "How fast the explosion will expand.")]
		public static float P_RevExplosionSpeed = 1f;

		[Configgable("Revolver", "Explosion Unblockable", 4, "Can enemies such as the soldier block the revolver explosion?")]
		public static ConfigToggle P_RevExplosionUnblockable = new ConfigToggle(false);

		[Configgable("Shotgun", "Shotgun Damage", 1, "How much damage each individual shotgun pellet will deal.")]
		public static float P_ShotgunDamage = 1f;

		[Configgable("Shotgun", "Pellet Speed", 1, "How fast the pellets will go. They're pretty fast by default.")]
		public static FloatSlider P_ShotgunBulletSpeed = new FloatSlider(66f, 0f, 100f);

		[Configgable("Shotgun", "Shotgun Instafire", 0, "Toggles whether the shotgun will fire when you press m1 regardless of the situation, even in the menues (Being fixed)")]
		public static ConfigToggle P_ShotgunInstafire = new ConfigToggle(false);

		[Configgable("Shotgun", "Chainsaw variant damage", 1, "How much damage the chansaw does.")]
		public static float P_ChainsawDamage = 0.75f;

		[Configgable("Shotgun", "Pellet Explosions", 2, "Enables shotgun pellets exploding on impact. This is incredibly loud (Will fix) so enable at your own risk.")]
		public static ConfigToggle P_EnableShotgunPelletExplosions = new ConfigToggle(false);

		[Configgable("Shotgun", "Explosions use base damage", 2, "Toggles whether the explosions will use the shotgun pellets base damage. Disables below setting.")]
		public static ConfigToggle P_ShotExplosionsUsesBaseDamage = new ConfigToggle(true);

		[Configgable("Shotgun", "Explosion Damage Overide", 3, "If the above setting is false, this will set the damage of the explosion.")]
		public static int P_ShotExplosionDamageOveride = 0;

		[Configgable("Shotgun", "Explosion Friendly Fire", 3, "Will the explosion damage you?")]
		public static ConfigToggle P_ShotExplosionFriendlyFire = new ConfigToggle(false);

		[Configgable("Shotgun", "Explosion Expansion Speed", 3, "How fast the explosions from the pellets expand.")]
		public static float P_ShotExplosionSpeed = 0.125f;

		[Configgable("Shotgun", "Unblockable Explosion", 3, "Whether enemies such as the soldiers can block the explosions from the pellets.")]
		public static ConfigToggle P_ShotUnblockable = new ConfigToggle(false);

		[Configgable("Shotgun", "Explosion size", 3, "How big the explosions will be. This does not change volume (womp womp) or damage")]
		public static float P_ShotExplosionSize = 0.2f;

		[Configgable("Nailgun", "Firerate", 1, "How fast the nailgun will fire. The lower the value the faster it will fire.")]
		public static FloatSlider P_NailgunFirerate = new FloatSlider(4f, 0f, 15f);

		[Configgable("Nailgun", "Spread", 1, "How much the nails will deviate from the crosshair. Lower values mean less spread.")]
		public static FloatSlider P_NailgunSpread = new FloatSlider(20f, 0f, 100f);

		[Configgable("Nailgun", "Damage", 0, "What are you, retarded? You know DAMN well what this does.")]
		public static float P_NailDamage = 0.185f;

		[Configgable("Sawblade Launcher", "Firerate", 1, "How fast the sawblade launcher will fire. The lower the value the faster it will fire.")]
		public static FloatSlider P_SawbladeFirerate = new FloatSlider(24f, 0f, 50f);

		[Configgable("Sawblade Launcher", "Spread", 1, "Why would you change this?")]
		public static FloatSlider P_SawbladeSpread = new FloatSlider(0f, 0f, 1500f);

		[Configgable("Sawblade Launcher", "Damage", 0, "Are you stupid?")]
		public static float P_SawDamage = 0.75f;
	}
}
namespace WeaponStatEditor.Prefabs
{
	public class Prefab
	{
		public static readonly string explosion_path = "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion.prefab";

		public static readonly string explosionSuper_path = "Assets/Prefabs/Attacks and Projectiles/Explosions/Explosion Super.prefab";

		public static T Fetch<T>(string key)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<T>((object)key).WaitForCompletion();
		}
	}
	public class AssetBundleThing
	{
	}
}