Decompiled source of AimHacksBL v1.0.3

Mods/AimHacksBL.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using AimHacksBL;
using BoneLib;
using BoneLib.BoneMenu;
using HarmonyLib;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Bonelab;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.AI;
using Il2CppSLZ.Marrow.PuppetMasta;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("AimHacksBL")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany(null)]
[assembly: AssemblyProduct("AimHacksBL")]
[assembly: AssemblyCopyright("Created by Adi")]
[assembly: AssemblyTrademark(null)]
[assembly: ComVisible(false)]
[assembly: AssemblyFileVersion("1.0.3")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: MelonInfo(typeof(global::AimHacksBL.AimHacksBL), "AimHacksBL", "1.0.3", "Adi", null)]
[assembly: MelonGame(null, null)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("1.0.3.0")]
namespace AimHacksBL;

public static class BuildInfo
{
	public const string Name = "AimHacksBL";

	public const string Author = "Adi";

	public const string Company = null;

	public const string Version = "1.0.3";

	public const string DownloadLink = null;
}
public class AimHacksBL : MelonMod
{
	public enum Target
	{
		Closest,
		Head,
		Chest
	}

	public enum MovementCompensationSmoothing
	{
		None,
		Adaptive,
		Low,
		Medium,
		High,
		VeryHigh
	}

	[RegisterTypeInIl2Cpp(false)]
	public class AimHacksNPCMonoBehaviour : MonoBehaviour
	{
		public TriggerRefProxy proxy;

		public Vector3[] SnapShots;

		private Vector3 previousVelocity;

		private Vector3 currentAcceleration;

		public static float TimeBetweenSnapshots = 0.0625f;

		public static byte SnapShotCount = 8;

		public float LastSnapshot;

		public int uuid;

		public bool dying;

		public bool bulletTravel;

		public AIBrain Brain => proxy.aiManager;

		public bool IsDead
		{
			get
			{
				if (!proxy.aiManager.isDead && !dying)
				{
					return bulletTravel;
				}
				return true;
			}
		}

		public bool IsVisible { get; private set; }

		public AimHacksNPCMonoBehaviour(IntPtr ptr)
			: base(ptr)
		{
		}

		public static void ChangeSmoothing(MovementCompensationSmoothing movementSmoothing)
		{
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			switch (movementSmoothing)
			{
			case MovementCompensationSmoothing.Adaptive:
				TimeBetweenSnapshots = 0.05f;
				SnapShotCount = 10;
				break;
			case MovementCompensationSmoothing.Low:
				TimeBetweenSnapshots = 0.05f;
				SnapShotCount = 5;
				break;
			case MovementCompensationSmoothing.Medium:
				TimeBetweenSnapshots = 0.05f;
				SnapShotCount = 10;
				break;
			case MovementCompensationSmoothing.High:
				TimeBetweenSnapshots = 0.0625f;
				SnapShotCount = 16;
				break;
			case MovementCompensationSmoothing.VeryHigh:
				TimeBetweenSnapshots = 0.075f;
				SnapShotCount = 20;
				break;
			}
			foreach (AimHacksNPCMonoBehaviour nPC in NPCs)
			{
				nPC.SnapShots = (Vector3[])(object)new Vector3[SnapShotCount];
				for (int i = 0; i < SnapShotCount; i++)
				{
					nPC.SnapShots[i] = Vector3.zero;
				}
			}
		}

		public void Start()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			NPCs.Add(this);
			SnapShots = (Vector3[])(object)new Vector3[SnapShotCount];
			for (int i = 0; i < SnapShotCount; i++)
			{
				SnapShots[i] = proxy.targetHead.velocity;
			}
		}

		public void FixedUpdate()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			if (Brain.isDead)
			{
				return;
			}
			if (smoothing == MovementCompensationSmoothing.None)
			{
				currentAcceleration = (proxy.targetHead.velocity - previousVelocity) / Time.fixedDeltaTime;
				Vector3 val = Vector3.zero;
				Enumerator<Rigidbody> enumerator = Brain.behaviour.selfRbs.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Rigidbody current = enumerator.Current;
					val += current.velocity;
				}
				val /= (float)Brain.behaviour.selfRbs.Count;
				previousVelocity = val;
			}
			else if (Time.fixedTime >= LastSnapshot + TimeBetweenSnapshots)
			{
				LastSnapshot = Time.fixedTime;
				for (int num = SnapShotCount - 1; num > 0; num--)
				{
					SnapShots[num] = SnapShots[num - 1];
				}
				Vector3 val2 = Vector3.zero;
				Enumerator<Rigidbody> enumerator = Brain.behaviour.selfRbs.GetEnumerator();
				while (enumerator.MoveNext())
				{
					Rigidbody current2 = enumerator.Current;
					val2 += current2.velocity;
				}
				val2 /= (float)Brain.behaviour.selfRbs.Count;
				SnapShots[0] = val2;
			}
		}

		public Vector3 GetAverageVelocity()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (smoothing == MovementCompensationSmoothing.None)
			{
				return proxy.targetHead.velocity;
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0f, 0f, 0f);
			byte b = 0;
			for (byte b2 = 0; b2 < SnapShotCount; b2++)
			{
				if (SnapShots[b2] == Vector3.zero || (smoothing == MovementCompensationSmoothing.Adaptive && Vector3.Angle(SnapShots[0], SnapShots[b2]) > 30f))
				{
					b++;
				}
				else
				{
					val += SnapShots[b2];
				}
			}
			if (b == SnapShotCount)
			{
				return Vector3.zero;
			}
			val /= (float)(SnapShotCount - b);
			return val;
		}

		public Vector3 GetAverageAcceleration()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			if (smoothing == MovementCompensationSmoothing.None)
			{
				return currentAcceleration;
			}
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0f, 0f, 0f);
			for (byte b = 0; b < SnapShotCount - 1; b++)
			{
				val += (SnapShots[b] - SnapShots[b + 1]) / TimeBetweenSnapshots / (float)(SnapShotCount - 1);
			}
			return val;
		}

		public static bool TryGetByID(int id, out AimHacksNPCMonoBehaviour npc)
		{
			npc = null;
			foreach (AimHacksNPCMonoBehaviour nPC in NPCs)
			{
				if (nPC != null && nPC.uuid == id)
				{
					npc = nPC;
					return true;
				}
			}
			return (Object)(object)npc != (Object)null;
		}
	}

	[RegisterTypeInIl2Cpp(false)]
	public class AimHacksGunMonoBehaviour : MonoBehaviour
	{
		private Gun gun;

		private int uuid;

		private Quaternion defaultRotation;

		private float lastFired;

		private GunTrigger[] triggers;

		public AimHacksNPCMonoBehaviour cachedEnemy;

		private bool triggerGrabbed
		{
			get
			{
				Hand hand = gun.triggerGrip.GetHand();
				if (!((Object)(object)((hand != null) ? hand.manager : null) == (Object)(object)Player.RigManager))
				{
					if (triggers != null)
					{
						return triggers.Any(delegate(GunTrigger i)
						{
							Hand hand2 = i.triggerGrip.GetHand();
							return (Object)(object)((hand2 != null) ? hand2.manager : null) == (Object)(object)Player.RigManager;
						});
					}
					return false;
				}
				return true;
			}
		}

		public AimHacksGunMonoBehaviour(IntPtr ptr)
			: base(ptr)
		{
		}

		public void Awake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			gun = ((Component)this).GetComponent<Gun>();
			uuid = ((Object)gun).GetInstanceID();
			defaultRotation = gun.firePointTransform.localRotation;
			Hooking.OnPreFireGun += OnPreFire;
			Hooking.OnPostFireGun += OnPostFire;
			Il2CppArrayBase<GunTrigger> componentsInChildren = ((Component)((Component)gun).transform.root).GetComponentsInChildren<GunTrigger>();
			if (componentsInChildren.Length > 0)
			{
				triggers = Il2CppArrayBase<GunTrigger>.op_Implicit(componentsInChildren);
			}
		}

		public void FixedUpdate()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			if (!triggerGrabbed || (int)gun.slideState != 1 || (gun.HasMagazine() ? gun.AmmoCount() : 0) + (((Object)(object)gun.chamberedCartridge != (Object)null) ? 1 : 0) == 0)
			{
				return;
			}
			cachedEnemy = null;
			if (triggerBot && lastFired + 1f / Mathf.Clamp(gun.roundsPerSecond, 0f, 600f) < Time.time)
			{
				if (aimBot)
				{
					Aimbot(noCompensation: true);
				}
				TriggerBot();
			}
		}

		private void TriggerBot()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			if (!Physics.Raycast(gun.firePointTransform.position, gun.firePointTransform.forward, ref val) || ((Component)((RaycastHit)(ref val)).collider).gameObject.layer != 26 || !AimHacksNPCMonoBehaviour.TryGetByID(((Object)((Component)((RaycastHit)(ref val)).collider).transform.root).GetInstanceID(), out var npc) || npc.IsDead || (hsOnly && !((Object)(object)((RaycastHit)(ref val)).collider.attachedRigidbody == (Object)(object)npc.proxy.targetHead)))
			{
				return;
			}
			float startVelocity = gun.defaultCartridge.projectile.startVelocity;
			if ((Object)(object)controller != (Object)null)
			{
				controller.isDevToolSpawned = controller.isDevToolSpawned || triggerBot || aimBot;
			}
			MelonCoroutines.Start(FuckyWucky(npc, Vector3.Distance(((RaycastHit)(ref val)).point, gun.firePointTransform.position) / (startVelocity * 0.95f)));
			if (!aimBot)
			{
				Vector3 val2 = ((RaycastHit)(ref val)).point;
				if (movementCompensation)
				{
					val2 += GetMovementCompensation(npc, ((RaycastHit)(ref val)).point, startVelocity);
					Transform firePointTransform = gun.firePointTransform;
					Vector3 val3 = val2 - gun.firePointTransform.position;
					firePointTransform.forward = ((Vector3)(ref val3)).normalized;
				}
				if (bulletDrop)
				{
					gun.firePointTransform.Rotate(CalculateAngle(val2, startVelocity), (Space)1);
				}
			}
			gun.Fire();
			gun.firePointTransform.localRotation = defaultRotation;
		}

		public Vector3 GetMovementCompensation(AimHacksNPCMonoBehaviour npc, Vector3 pos, float velocity)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			Vector3 averageVelocity = npc.GetAverageVelocity();
			Vector3 val = (acceleration ? npc.GetAverageAcceleration() : Vector3.zero);
			float num = Vector3.Distance(pos, gun.firePointTransform.position) / velocity;
			Vector3 val2 = averageVelocity * num + 0.5f * val * num * num;
			num = Vector3.Distance(pos + val2, gun.firePointTransform.position) / velocity;
			return averageVelocity * num + 0.5f * val * num * num;
		}

		private void Aimbot(bool noCompensation)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			gun.firePointTransform.localRotation = defaultRotation;
			AimHacksNPCMonoBehaviour aimHacksNPCMonoBehaviour = FindClosestEnemy();
			if ((Object)(object)aimHacksNPCMonoBehaviour == (Object)null)
			{
				return;
			}
			float startVelocity = gun.defaultCartridge.projectile.startVelocity;
			Vector3 val = ((target == Target.Head || (hsOnly && triggerBot)) ? aimHacksNPCMonoBehaviour.proxy.targetHead.position : aimHacksNPCMonoBehaviour.proxy.chestTran.position);
			if (target == Target.Closest)
			{
				float num = Vector3.Angle(gun.firePointTransform.forward, val - gun.firePointTransform.position);
				Enumerator<Rigidbody> enumerator = aimHacksNPCMonoBehaviour.Brain.behaviour.selfRbs.GetEnumerator();
				RaycastHit val3 = default(RaycastHit);
				while (enumerator.MoveNext())
				{
					Rigidbody current = enumerator.Current;
					if (!((Object)current).name.Contains("Shoulder_"))
					{
						Vector3 val2 = current.position - gun.firePointTransform.position;
						float num2 = Vector3.Angle(gun.firePointTransform.forward, val2);
						if (num2 < num && Physics.Raycast(gun.firePointTransform.position, val2, ref val3) && ((Component)((RaycastHit)(ref val3)).collider).gameObject.layer == 12)
						{
							val = current.position;
							num = num2;
						}
					}
				}
			}
			if (!noCompensation && AimHacksBL.movementCompensation)
			{
				Vector3 movementCompensation = GetMovementCompensation(aimHacksNPCMonoBehaviour, val, startVelocity);
				val += movementCompensation;
			}
			if ((Object)(object)controller != (Object)null)
			{
				controller.isDevToolSpawned = controller.isDevToolSpawned || triggerBot || aimBot;
			}
			Transform firePointTransform = gun.firePointTransform;
			Vector3 val4 = val - gun.firePointTransform.position;
			firePointTransform.forward = ((Vector3)(ref val4)).normalized;
			if (!noCompensation && bulletDrop)
			{
				Vector3 val5 = CalculateAngle(val, startVelocity);
				gun.firePointTransform.Rotate(val5, (Space)1);
			}
		}

		private Vector3 CalculateAngle(Vector3 targetPos, float velocity)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			if (Physics.gravity.x != 0f)
			{
				float num2 = Vector3.Distance(new Vector3(0f, gun.firePointTransform.position.y, gun.firePointTransform.position.z), new Vector3(0f, targetPos.y, targetPos.z));
				float num3 = gun.firePointTransform.position.x - targetPos.x;
				float num4 = Mathf.Atan2(num2, num3) * 180f / (float)Math.PI;
				float num5 = ((0f - Physics.gravity.x) * num2 * num2 / (velocity * velocity) - num3) / Mathf.Sqrt(num3 * num3 + num2 * num2);
				if (num5 <= 1f)
				{
					num = 90f - (Mathf.Acos(num5) * 180f / (float)Math.PI + num4) / 2f;
				}
			}
			float num6 = 0f;
			if (Physics.gravity.y != 0f)
			{
				float num7 = Vector3.Distance(new Vector3(gun.firePointTransform.position.x, 0f, gun.firePointTransform.position.z), new Vector3(targetPos.x, 0f, targetPos.z));
				float num8 = gun.firePointTransform.position.y - targetPos.y;
				float num9 = Mathf.Atan2(num7, num8) * 180f / (float)Math.PI;
				float num10 = ((0f - Physics.gravity.y) * num7 * num7 / (velocity * velocity) - num8) / Mathf.Sqrt(num8 * num8 + num7 * num7);
				if (num10 <= 1f)
				{
					num6 = 90f - (Mathf.Acos(num10) * 180f / (float)Math.PI + num9) / 2f;
				}
			}
			float num11 = 0f;
			if (Physics.gravity.z != 0f)
			{
				float num12 = Vector3.Distance(new Vector3(gun.firePointTransform.position.x, gun.firePointTransform.position.y, 0f), new Vector3(targetPos.x, targetPos.y, 0f));
				float num13 = gun.firePointTransform.position.x - targetPos.x;
				float num14 = Mathf.Atan2(num12, num13) * 180f / (float)Math.PI;
				float num15 = (Physics.gravity.z * num12 * num12 / (velocity * velocity) - num13) / Mathf.Sqrt(num13 * num13 + num12 * num12);
				if (num15 <= 1f)
				{
					num11 = 90f - (Mathf.Acos(num15) * 180f / (float)Math.PI + num14) / 2f;
				}
			}
			num *= (float)Math.Sign(gun.firePointTransform.position.z - targetPos.z);
			num11 *= (float)Math.Sign(gun.firePointTransform.position.x - targetPos.x);
			return new Vector3(0f - num6, 0f - num - num11, 0f);
		}

		private void OnPreFire(Gun gun)
		{
			if (aimBot && ((Object)gun).GetInstanceID() == uuid && gun.host.HandCount() >= 1 && !((Object)(object)gun.host._hands[0].manager != (Object)(object)Player.RigManager))
			{
				Aimbot(noCompensation: false);
			}
		}

		private void OnPostFire(Gun gun)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (((Object)gun).GetInstanceID() == uuid && gun.host.HandCount() >= 1 && !((Object)(object)gun.host._hands[0].manager != (Object)(object)Player.RigManager))
			{
				gun.firePointTransform.localRotation = defaultRotation;
				lastFired = Time.time;
			}
		}

		[HideFromIl2Cpp]
		public RaycastHit[] GetFirst3Hits(in RaycastHit[] arr)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit[] array = (RaycastHit[])(object)new RaycastHit[3]
			{
				arr[0],
				default(RaycastHit),
				default(RaycastHit)
			};
			for (int i = 1; i < arr.Length; i++)
			{
				if (((RaycastHit)(ref arr[i])).distance <= ((RaycastHit)(ref array[0])).distance && ((RaycastHit)(ref array[0])).distance - ((RaycastHit)(ref arr[i])).distance > 0.05f)
				{
					array[2] = array[1];
					array[1] = array[0];
					array[0] = arr[i];
				}
			}
			return (RaycastHit[])(object)new RaycastHit[1] { array[0] };
		}

		private AimHacksNPCMonoBehaviour FindClosestEnemy()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cachedEnemy != (Object)null)
			{
				return cachedEnemy;
			}
			if (NPCs.Count == 0)
			{
				return null;
			}
			float num = aimBotFOV / 2f;
			AimHacksNPCMonoBehaviour result = null;
			RaycastHit val2 = default(RaycastHit);
			foreach (AimHacksNPCMonoBehaviour nPC in NPCs)
			{
				if ((Object)(object)nPC != (Object)null && !nPC.IsDead && !nPC.IsVisible)
				{
					Vector3 val = nPC.proxy.targetHead.position - gun.firePointTransform.position;
					float num2 = Vector3.Angle(gun.firePointTransform.forward, val);
					if (num2 < num && Physics.Raycast(gun.firePointTransform.position, val, ref val2) && ((Object)((Component)((RaycastHit)(ref val2)).collider).transform.root).GetInstanceID() == ((Object)((Component)nPC).transform.root).GetInstanceID())
					{
						num = num2;
						result = nPC;
					}
				}
			}
			cachedEnemy = result;
			return result;
		}
	}

	public static bool triggerBot = false;

	public static bool aimBot = true;

	public static bool bulletDrop = true;

	public static bool movementCompensation = true;

	public static bool acceleration = true;

	public static bool hsOnly = false;

	public static Target target = Target.Head;

	public static float aimBotFOV = 180f;

	public static MovementCompensationSmoothing smoothing = MovementCompensationSmoothing.Adaptive;

	private static BaseGameController controller;

	public const string purpleHex = "#960ACD";

	public static HashSet<AimHacksNPCMonoBehaviour> NPCs = new HashSet<AimHacksNPCMonoBehaviour>();

	public static Dictionary<int, ImpactProperties> impactPropertyCache = new Dictionary<int, ImpactProperties>();

	public static Color HexToColor(string hex)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		Color result = default(Color);
		ColorUtility.TryParseHtmlString("#960ACD", ref result);
		return result;
	}

	public override void OnDeinitializeMelon()
	{
		Prefs.SavePrefs();
	}

	public override void OnInitializeMelon()
	{
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
		Prefs.CreatePrefs();
		Hooking.OnLevelLoaded += delegate
		{
			NPCs.Clear();
			impactPropertyCache.Clear();
		};
		Hooking.OnLevelUnloaded += delegate
		{
			NPCs.Clear();
			impactPropertyCache.Clear();
		};
		((MelonBase)this).HarmonyInstance.Patch((MethodBase)typeof(Gun).GetMethod("Start", AccessTools.all), (HarmonyMethod)null, MelonUtils.ToNewHarmonyMethod(typeof(AimHacksBL).GetMethod("GunPatch", AccessTools.all)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		((MelonBase)this).HarmonyInstance.Patch((MethodBase)typeof(BehaviourBaseNav).GetMethod("KillStart", AccessTools.all), (HarmonyMethod)null, MelonUtils.ToNewHarmonyMethod(typeof(AimHacksBL).GetMethod("KillStartPatch", AccessTools.all)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		((MelonBase)this).HarmonyInstance.Patch((MethodBase)typeof(BehaviourCrablet).GetMethod("KillStart", AccessTools.all), (HarmonyMethod)null, MelonUtils.ToNewHarmonyMethod(typeof(AimHacksBL).GetMethod("KillStartPatch2", AccessTools.all)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		((MelonBase)this).HarmonyInstance.Patch((MethodBase)typeof(TriggerRefProxy).GetMethod("Start", AccessTools.all), (HarmonyMethod)null, MelonUtils.ToNewHarmonyMethod(typeof(AimHacksBL).GetMethod("AiPatch", AccessTools.all)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		((MelonBase)this).HarmonyInstance.Patch((MethodBase)typeof(AIBrain).GetMethod("OnResurrection", AccessTools.all), (HarmonyMethod)null, MelonUtils.ToNewHarmonyMethod(typeof(AimHacksBL).GetMethod("AiPatch", AccessTools.all)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		((MelonBase)this).HarmonyInstance.Patch((MethodBase)typeof(BaseGameController).GetMethod("OnEnable", AccessTools.all), (HarmonyMethod)null, MelonUtils.ToNewHarmonyMethod(typeof(AimHacksBL).GetMethod("ControllerPatch", AccessTools.all)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		Page obj = Page.Root.CreatePage("Aim Hacks", Color.red, 0, true);
		obj.CreateBool("Aimbot", Color.red, aimBot, (Action<bool>)delegate(bool val)
		{
			aimBot = val;
			Prefs.SavePrefs();
			foreach (AimHacksNPCMonoBehaviour nPC in NPCs)
			{
				((Behaviour)nPC).enabled = aimBot || triggerBot;
			}
		});
		obj.CreateFloat("Aimbot FOV", Color.red, aimBotFOV, 3f, 0f, 360f, (Action<float>)delegate(float val)
		{
			aimBotFOV = val;
			Prefs.SavePrefs();
		});
		obj.CreateEnum("Target", Color.red, (Enum)target, (Action<Enum>)delegate(Enum val)
		{
			target = (Target)(object)val;
			Prefs.SavePrefs();
		});
		obj.CreateBool("Triggerbot", HexToColor("#960ACD"), triggerBot, (Action<bool>)delegate(bool val)
		{
			triggerBot = val;
			Prefs.SavePrefs();
			foreach (AimHacksNPCMonoBehaviour nPC2 in NPCs)
			{
				((Behaviour)nPC2).enabled = aimBot || triggerBot;
			}
		});
		obj.CreateBool("Headshots Only", HexToColor("#960ACD"), hsOnly, (Action<bool>)delegate(bool val)
		{
			hsOnly = val;
			Prefs.SavePrefs();
		});
		Page obj2 = obj.CreatePage("Advanced Options", Color.green, 0, true);
		obj2.CreateEnum("Movement Compensation Smoothing", Color.white, (Enum)smoothing, (Action<Enum>)delegate(Enum val)
		{
			AimHacksNPCMonoBehaviour.ChangeSmoothing(smoothing = (MovementCompensationSmoothing)(object)val);
			Prefs.SavePrefs();
		});
		obj2.CreateBool("Bullet Drop Compensation", Color.white, bulletDrop, (Action<bool>)delegate(bool val)
		{
			bulletDrop = val;
			Prefs.SavePrefs();
		});
		obj2.CreateBool("Movement Compensation", Color.white, movementCompensation, (Action<bool>)delegate(bool val)
		{
			movementCompensation = val;
			Prefs.SavePrefs();
		});
	}

	private static IEnumerator KillStart(AimHacksNPCMonoBehaviour npc)
	{
		npc.dying = true;
		while (!npc.Brain.isDead)
		{
			yield return null;
		}
		npc.dying = false;
	}

	private static IEnumerator FuckyWucky(AimHacksNPCMonoBehaviour npc, float time)
	{
		float time2 = Time.time + time * 1.1f;
		npc.bulletTravel = true;
		while (Time.time < time2)
		{
			yield return null;
		}
		npc.bulletTravel = false;
	}

	public static void GunPatch(Gun __instance)
	{
		if ((Object)(object)((Component)__instance).GetComponent<AimHacksGunMonoBehaviour>() == (Object)null && (Object)(object)((Component)((Component)__instance).transform.root).GetComponentInChildren<AIBrain>() == (Object)null)
		{
			((Component)__instance).gameObject.AddComponent<AimHacksGunMonoBehaviour>();
		}
	}

	public static void ControllerPatch(BaseGameController __instance)
	{
		controller = __instance;
	}

	public static void KillStartPatch(BehaviourBaseNav __instance)
	{
		if (AimHacksNPCMonoBehaviour.TryGetByID(((Object)((Component)__instance).transform.root).GetInstanceID(), out var npc))
		{
			MelonCoroutines.Start(KillStart(npc));
		}
	}

	public static void KillStartPatch2(BehaviourCrablet __instance)
	{
		if (AimHacksNPCMonoBehaviour.TryGetByID(((Object)((Component)__instance).transform.root).GetInstanceID(), out var npc))
		{
			MelonCoroutines.Start(KillStart(npc));
		}
	}

	public static void AiPatch(TriggerRefProxy __instance)
	{
		AIBrain aiManager = __instance.aiManager;
		if (!((Object)(object)aiManager == (Object)null) && (Object)(object)__instance != (Object)null && !((Object)((Component)aiManager).transform.root).name.StartsWith("OmniWay"))
		{
			AimHacksNPCMonoBehaviour aimHacksNPCMonoBehaviour = ((Component)__instance).gameObject.GetComponent<AimHacksNPCMonoBehaviour>();
			if ((Object)(object)aimHacksNPCMonoBehaviour == (Object)null)
			{
				aimHacksNPCMonoBehaviour = ((Component)__instance).gameObject.AddComponent<AimHacksNPCMonoBehaviour>();
			}
			aimHacksNPCMonoBehaviour.proxy = __instance;
			aimHacksNPCMonoBehaviour.dying = false;
			aimHacksNPCMonoBehaviour.uuid = ((Object)((Component)__instance).transform.root).GetInstanceID();
			((Behaviour)aimHacksNPCMonoBehaviour).enabled = aimBot || triggerBot;
			NPCs.Add(aimHacksNPCMonoBehaviour);
		}
	}
}
public class Prefs
{
	public static MelonPreferences_Category cat;

	public static MelonPreferences_Entry<bool> aimBot;

	public static MelonPreferences_Entry<bool> triggerBot;

	public static MelonPreferences_Entry<bool> bulletDrop;

	public static MelonPreferences_Entry<bool> movementCompensation;

	public static MelonPreferences_Entry<AimHacksBL.MovementCompensationSmoothing> movementCompensationSmoothing;

	public static MelonPreferences_Entry<float> fov;

	public static MelonPreferences_Entry<AimHacksBL.Target> target;

	public static MelonPreferences_Entry<bool> hsOnly;

	public static void CreatePrefs()
	{
		cat = MelonPreferences.CreateCategory("AimHacks");
		aimBot = cat.CreateEntry<bool>("Aimbot", AimHacksBL.aimBot, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		triggerBot = cat.CreateEntry<bool>("Triggerbot", AimHacksBL.triggerBot, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		fov = cat.CreateEntry<float>("Aimbot FOV", AimHacksBL.aimBotFOV, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		target = cat.CreateEntry<AimHacksBL.Target>("Target", AimHacksBL.target, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		movementCompensationSmoothing = cat.CreateEntry<AimHacksBL.MovementCompensationSmoothing>("MovementCompensationSmoothing", AimHacksBL.smoothing, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		bulletDrop = cat.CreateEntry<bool>("BulletDropCompensation", AimHacksBL.bulletDrop, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		movementCompensation = cat.CreateEntry<bool>("MovementCompensation", AimHacksBL.movementCompensation, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		hsOnly = cat.CreateEntry<bool>("HeadshotsOnly", AimHacksBL.hsOnly, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
		AimHacksBL.hsOnly = hsOnly.Value;
		AimHacksBL.aimBot = aimBot.Value;
		AimHacksBL.triggerBot = triggerBot.Value;
		AimHacksBL.aimBotFOV = fov.Value;
		AimHacksBL.target = target.Value;
		AimHacksBL.smoothing = movementCompensationSmoothing.Value;
		AimHacksBL.AimHacksNPCMonoBehaviour.ChangeSmoothing(AimHacksBL.smoothing);
	}

	public static void SavePrefs()
	{
		aimBot.Value = AimHacksBL.aimBot;
		triggerBot.Value = AimHacksBL.triggerBot;
		fov.Value = AimHacksBL.aimBotFOV;
		target.Value = AimHacksBL.target;
		movementCompensationSmoothing.Value = AimHacksBL.smoothing;
		hsOnly.Value = AimHacksBL.hsOnly;
		bulletDrop.Value = AimHacksBL.bulletDrop;
		movementCompensation.Value = AimHacksBL.movementCompensation;
	}
}