Latest versions of MelonLoader are known to have issues with some games. Use version 0.5.4 until the issue has been fixed!
Decompiled source of ProcedualAnimation v1.1.1
Procudeal aimation.dll
Decompiled 3 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using HarmonyLib; using MelonLoader; using ModThatIsNotMod.BoneMenu; using ModThatIsNotMod.MonoBehaviours; using Procudeal_aimation; using PuppetMasta; using StressLevelZero.AI; using StressLevelZero.Props.Weapons; using UnhollowerBaseLib; using UnhollowerRuntimeLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(Main), "Procudeal aimation", "5.6.1", "Jeb", null)] [assembly: MelonGame("Stress Level Zero", "BONEWORKS")] [assembly: AssemblyTitle("Procudeal aimation")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("Procudeal aimation")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e02c3ff9-db33-4862-8ec0-1d1790eb4fef")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ModThatIsNotMod.MonoBehaviours { public class OriginalPuppetProperties : MonoBehaviour { public float damper; public float weight; public float animSpeed; public OriginalPuppetProperties(IntPtr ptr) : base(ptr) { } } public class AgonyLogic : MonoBehaviour { private AIBrain _brain; private List<Rigidbody> _limbs = new List<Rigidbody>(); private List<Rigidbody> _legs = new List<Rigidbody>(); private Rigidbody _pelvis; private Rigidbody _chest; private Transform _pelvisTransform; private Transform _chestTransform; private List<Rigidbody> _knees = new List<Rigidbody>(); private List<Rigidbody> _feet = new List<Rigidbody>(); public Rigidbody lastHitBone; public bool isSuffering = false; public float sufferingStartTime = 0f; private bool _isSmallEnemy = false; private bool _isInitialized = false; private string[] legKeywords = new string[6] { "foot", "calf", "thigh", "knee", "toe", "leg" }; private string[] armKeywords = new string[5] { "hand", "arm", "shoulder", "wrist", "elbow" }; private string[] coreKeywords = new string[3] { "chest", "spine", "neck" }; private string[] pelvisKeywords = new string[3] { "pelvis", "hip", "root" }; public AgonyLogic(IntPtr ptr) : base(ptr) { } private void Awake() { _brain = ((Component)this).GetComponent<AIBrain>(); } public void ProcessHit() { if (!((Object)(object)_brain == (Object)null) && !isSuffering) { if (!_isInitialized) { InitializeBodyParts(); _isInitialized = true; } isSuffering = true; sufferingStartTime = Time.time; MelonCoroutines.Start(Struggle()); } } public void MercyKill() { isSuffering = false; } private void InitializeBodyParts() { _isSmallEnemy = false; _limbs.Clear(); _legs.Clear(); _knees.Clear(); _feet.Clear(); PuppetMaster puppetMaster = _brain.puppetMaster; if ((Object)(object)puppetMaster == (Object)null || puppetMaster.muscles == null || ((Il2CppArrayBase<Muscle>)(object)puppetMaster.muscles).Length == 0) { return; } string text = ((Object)((Component)_brain).gameObject).name.ToLower(); if (text.Contains("crab") || text.Contains("headcrab")) { _isSmallEnemy = true; return; } _pelvis = ((Il2CppArrayBase<Muscle>)(object)puppetMaster.muscles)[0].rigidbody; foreach (Muscle item in (Il2CppArrayBase<Muscle>)(object)puppetMaster.muscles) { if ((Object)(object)item.rigidbody == (Object)null) { continue; } string text2 = ((Object)item.rigidbody).name.ToLower(); string[] array = pelvisKeywords; foreach (string value in array) { if (text2.Contains(value)) { _pelvis = item.rigidbody; break; } } string[] array2 = coreKeywords; foreach (string value2 in array2) { if (text2.Contains(value2)) { _chest = item.rigidbody; break; } } bool flag = false; string[] array3 = legKeywords; foreach (string value3 in array3) { if (text2.Contains(value3)) { _legs.Add(item.rigidbody); flag = true; break; } } if (!flag) { string[] array4 = armKeywords; foreach (string value4 in array4) { if (text2.Contains(value4)) { _limbs.Add(item.rigidbody); break; } } } if (text2.Contains("calf") || text2.Contains("knee") || text2.Contains("lowerleg")) { _knees.Add(item.rigidbody); } if (text2.Contains("foot") || text2.Contains("toe")) { _feet.Add(item.rigidbody); } } if ((Object)(object)_pelvis != (Object)null) { _pelvisTransform = ((Component)_pelvis).transform; } if ((Object)(object)_chest != (Object)null) { _chestTransform = ((Component)_chest).transform; } } private IEnumerator Struggle() { if (_isSmallEnemy) { isSuffering = false; yield break; } yield return (object)new WaitForFixedUpdate(); float elapsed = 0f; float roll = Random.Range(0f, 100f); bool isBicycle = roll < 11f; bool isCrawling = roll >= 11f && roll < 21f; bool isFetalCurl = roll >= 21f && roll < 56f; bool isArmBicycleCrawl = roll >= 56f && roll < 71f; Vector3 lockedCrawlDir = Vector3.forward; if ((Object)(object)_chest != (Object)null && (Object)(object)_pelvis != (Object)null) { lockedCrawlDir = _chest.position - _pelvis.position; lockedCrawlDir.y = 0f; if (((Vector3)(ref lockedCrawlDir)).sqrMagnitude < 0.0001f) { lockedCrawlDir = Vector3.forward; } else { ((Vector3)(ref lockedCrawlDir)).Normalize(); } } float nextSwitchTime = 2f; bool isBucking = false; while (isSuffering && elapsed < Main.struggleTime) { elapsed += Time.fixedDeltaTime; float force = Main.pullForce; Vector3 val; if (isCrawling && (Object)(object)_chest != (Object)null && (Object)(object)_pelvis != (Object)null) { Vector3 crawlDir = lockedCrawlDir; float upDot = Vector3.Dot(_chestTransform.up, Vector3.up); if (upDot < -0.2f) { _chest.AddTorque(_chestTransform.forward * (force * 2f), (ForceMode)0); _pelvis.AddTorque(_pelvisTransform.forward * (force * 2f), (ForceMode)0); } else { Vector3 chestUpTorque = Vector3.Cross(_chestTransform.up, Vector3.up); _chest.AddTorque(chestUpTorque * (force * 2f), (ForceMode)0); Vector3 pelvisUpTorque = Vector3.Cross(_pelvisTransform.up, Vector3.up); _pelvis.AddTorque(pelvisUpTorque * (force * 2f), (ForceMode)0); } Vector3 currentSpineDir = _chest.position - _pelvis.position; currentSpineDir.y = 0f; if (((Vector3)(ref currentSpineDir)).sqrMagnitude > 0.0001f) { ((Vector3)(ref currentSpineDir)).Normalize(); Vector3 chestTorque = Vector3.Cross(currentSpineDir, crawlDir); _chest.AddTorque(chestTorque * (force * 4f), (ForceMode)0); Vector3 pelvisTorque = Vector3.Cross(currentSpineDir, crawlDir); _pelvis.AddTorque(pelvisTorque * (force * 4f), (ForceMode)0); } float crawlSpeed = 1.2f; float phase = Mathf.Sin(elapsed * (float)Math.PI * crawlSpeed); Vector3 rightDir = Vector3.Cross(crawlDir, Vector3.up); for (int i = 0; i < _limbs.Count; i++) { Rigidbody hand = _limbs[i]; if ((Object)(object)hand == (Object)null) { continue; } float sidePhase = ((i % 2 == 0) ? phase : (0f - phase)); float sideSign = ((i % 2 == 0) ? 1f : (-1f)); Vector3 armSpread = rightDir * sideSign; if (sidePhase > 0f) { float liftArc = Mathf.Sin(sidePhase * (float)Math.PI); Vector3 reachDir = crawlDir + armSpread * 0.4f + Vector3.up * (0.6f * liftArc); hand.AddForce(((Vector3)(ref reachDir)).normalized * (force * 1.8f), (ForceMode)0); } else { Vector3 pullDir = -crawlDir + armSpread * 0.2f - Vector3.up * 1.5f; hand.AddForce(((Vector3)(ref pullDir)).normalized * (force * 1.5f), (ForceMode)0); Vector3 forwardVel = Vector3.Project(_chest.velocity, crawlDir); if (((Vector3)(ref forwardVel)).sqrMagnitude < 1.44f) { float pullIntensity = 0f - sidePhase; float pulseMultiplier = pullIntensity * pullIntensity; _chest.AddForce(crawlDir * (force * 8f * pulseMultiplier), (ForceMode)0); _chest.AddForce(Vector3.up * (force * 1.2f * pulseMultiplier), (ForceMode)0); } } hand.velocity = Vector3.Lerp(hand.velocity, Vector3.zero, Time.fixedDeltaTime * 4.5f); } } else if (isFetalCurl && (Object)(object)_chest != (Object)null && (Object)(object)_pelvis != (Object)null) { Rigidbody chest = _chest; val = _pelvis.position - _chest.position; chest.AddForce(((Vector3)(ref val)).normalized * (force * 3f), (ForceMode)0); Rigidbody pelvis = _pelvis; val = _chest.position - _pelvis.position; pelvis.AddForce(((Vector3)(ref val)).normalized * (force * 3f), (ForceMode)0); foreach (Rigidbody hand2 in _limbs) { if (!((Object)(object)hand2 == (Object)null)) { val = _chest.position - hand2.position; Vector3 pullDir2 = ((Vector3)(ref val)).normalized; hand2.AddForce(pullDir2 * (force * 3.5f), (ForceMode)0); _chest.AddForce(-pullDir2 * (force * 3.5f), (ForceMode)0); } } foreach (Rigidbody knee in _knees) { if (!((Object)(object)knee == (Object)null)) { val = _chest.position - knee.position; Vector3 pullDir3 = ((Vector3)(ref val)).normalized; knee.AddForce(pullDir3 * (force * 4.5f), (ForceMode)0); _chest.AddForce(-pullDir3 * (force * 4.5f), (ForceMode)0); } } } else if (isBicycle) { if (elapsed >= nextSwitchTime) { isBucking = !isBucking; nextSwitchTime = elapsed + Random.Range(1.5f, 3f); } float speedFluctuation = Mathf.PerlinNoise(Time.time * 3f, 10f) * 4f; float cycleSpeed = 8f + speedFluctuation; float pedalPhase = elapsed * cycleSpeed; for (int j = 0; j < _knees.Count; j++) { Rigidbody knee2 = _knees[j]; if (!((Object)(object)knee2 == (Object)null) && !((Object)(object)_pelvis == (Object)null)) { Vector3 localPos = _pelvisTransform.InverseTransformPoint(knee2.position); if (Mathf.Abs(localPos.x) > 0.2f) { Vector3 correction = new Vector3(0f - localPos.x, 0f, 0f); knee2.AddForce(_pelvisTransform.TransformDirection(correction) * (force * 1f), (ForceMode)0); } float buckingOffset = ((j % 2 == 0) ? 0f : (0.45f + Mathf.Sin(Time.time * 2.5f) * 0.15f)); float pedalOffset = ((j % 2 == 0) ? 0f : ((float)Math.PI + Mathf.Sin(Time.time * 1.5f) * 0.2f)); float offset = (isBucking ? buckingOffset : pedalOffset); float forwardDrive = Mathf.Sin(pedalPhase + offset); float verticalLift = Mathf.Cos(pedalPhase + offset); Vector3 bodyForward = _pelvisTransform.forward; bodyForward.y = 0f; bodyForward = ((!(((Vector3)(ref bodyForward)).sqrMagnitude < 0.0001f)) ? ((Vector3)(ref bodyForward)).normalized : Vector3.forward); Vector3 pedalVector = bodyForward * forwardDrive + Vector3.up * verticalLift * 1.5f; knee2.AddForce(pedalVector * (force * 3.5f), (ForceMode)0); if (j < _feet.Count && (Object)(object)_feet[j] != (Object)null) { _feet[j].AddForce(pedalVector * (force * 0.5f), (ForceMode)0); } } } } else if (isArmBicycleCrawl && (Object)(object)_chest != (Object)null && (Object)(object)_pelvis != (Object)null) { float speedFluctuation2 = Mathf.PerlinNoise(Time.time * 2f, 0f) * 4f; float cycleSpeed2 = 6f + speedFluctuation2; float pedalPhase2 = elapsed * cycleSpeed2; Vector3 slideDir = _pelvisTransform.forward; slideDir.y = 0f; slideDir = ((((Vector3)(ref slideDir)).sqrMagnitude < 0.0001f) ? Vector3.forward : ((Vector3)(ref slideDir)).normalized); for (int k = 0; k < _limbs.Count; k++) { Rigidbody hand3 = _limbs[k]; if (!((Object)(object)hand3 == (Object)null)) { float baseOffset = ((k == 0) ? 0f : 0.45f); float driftingOffset = baseOffset + Mathf.Sin(Time.time * 0.8f) * 0.25f; float forwardDrive2 = Mathf.Sin(pedalPhase2 + driftingOffset); float rawLift = Mathf.Cos(pedalPhase2 + driftingOffset); float verticalLift2 = Mathf.Max(-0.15f, rawLift) * 1.1f; float jitterX = (Mathf.PerlinNoise(Time.time * 25f, (float)k * 10f) - 0.5f) * 0.2f; float jitterZ = (Mathf.PerlinNoise((float)k * 10f, Time.time * 25f) - 0.5f) * 0.2f; Vector3 jitter = new Vector3(jitterX, 0f, jitterZ); Vector3 armBicycleVector = slideDir * forwardDrive2 + Vector3.up * verticalLift2 + jitter; hand3.AddForce(armBicycleVector * (force * 0.7f), (ForceMode)0); float downwardScrape = ((forwardDrive2 < 0f) ? 0.6f : 0.1f); hand3.AddForce(Vector3.down * (force * downwardScrape), (ForceMode)0); } } } else { if ((Object)(object)_chest != (Object)null && (Object)(object)_pelvis != (Object)null) { Rigidbody chest2 = _chest; val = _pelvis.position - _chest.position; chest2.AddForce(((Vector3)(ref val)).normalized * (force * 1.2f), (ForceMode)0); } foreach (Rigidbody hand4 in _limbs) { if (!((Object)(object)hand4 == (Object)null)) { if ((Object)(object)lastHitBone != (Object)null) { val = lastHitBone.position - hand4.position; hand4.AddForce(((Vector3)(ref val)).normalized * (force * 1.5f), (ForceMode)0); } else if ((Object)(object)_pelvis != (Object)null) { val = _pelvis.position - hand4.position; hand4.AddForce(((Vector3)(ref val)).normalized * force, (ForceMode)0); } } } foreach (Rigidbody knee3 in _knees) { if (!((Object)(object)knee3 == (Object)null) && !((Object)(object)_pelvis == (Object)null)) { Vector3 localPos2 = _pelvisTransform.InverseTransformPoint(knee3.position); if (Mathf.Abs(localPos2.x) > 0.05f) { Vector3 idealLocalPos = new Vector3(0f, localPos2.y, localPos2.z); Vector3 idealWorldPos = _pelvisTransform.TransformPoint(idealLocalPos); val = idealWorldPos - knee3.position; Vector3 pullDir4 = ((Vector3)(ref val)).normalized; knee3.AddForce(pullDir4 * (force * 0.6f), (ForceMode)0); } if (Random.value > 0.96f) { knee3.AddForce(Random.onUnitSphere * (force * 0.4f), (ForceMode)1); } } } } yield return (object)new WaitForFixedUpdate(); } yield return ResetSequence(); isSuffering = false; } private IEnumerator ResetSequence() { PuppetMaster pm = _brain.puppetMaster; OriginalPuppetProperties props = ((Component)this).GetComponent<OriginalPuppetProperties>(); if (!((Object)(object)pm == (Object)null) && !((Object)(object)props == (Object)null)) { if ((Object)(object)pm.targetAnimator != (Object)null) { ((Behaviour)pm.targetAnimator).enabled = true; pm.targetAnimator.speed = 0f; } pm.muscleDamper = props.damper; pm.muscleWeight = props.weight; } yield break; } } } namespace Procudeal_aimation { public class Main : MelonMod { public static bool modEnabled = true; public static float pullForce = 35f; public static float struggleTime = 8f; private bool _isScannerRunning = false; public override void OnApplicationStart() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown MelonLogger.Msg(ConsoleColor.Cyan, "the proceudal ANIMAtion IS ACTIVE - Max Safe Optimization"); ClassInjector.RegisterTypeInIl2Cpp<AgonyLogic>(); ClassInjector.RegisterTypeInIl2Cpp<OriginalPuppetProperties>(); Harmony val = new Harmony("com.jeb.proceduralanimation"); val.PatchAll(); SetupMenu(); } public override void OnSceneWasInitialized(int buildIndex, string sceneName) { if (!_isScannerRunning) { _isScannerRunning = true; MelonCoroutines.Start(OptimizedScanner()); } } private IEnumerator OptimizedScanner() { WaitForSeconds waitTime = new WaitForSeconds(1.5f); while (true) { if (modEnabled) { Il2CppArrayBase<AIBrain> allBrains = Resources.FindObjectsOfTypeAll<AIBrain>(); foreach (AIBrain brain in allBrains) { if (!((Object)(object)brain == (Object)null)) { if ((Object)(object)((Component)brain).gameObject.GetComponent<AgonyLogic>() == (Object)null) { ((Component)brain).gameObject.AddComponent<AgonyLogic>(); } PuppetMaster pm = brain.puppetMaster; if ((Object)(object)pm != (Object)null && (int)pm.state != 1 && (Object)(object)pm.targetAnimator != (Object)null && pm.targetAnimator.speed == 0f) { ((Behaviour)pm.targetAnimator).enabled = true; pm.targetAnimator.speed = 1f; } } } } yield return waitTime; } } private void SetupMenu() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) MenuCategory val = MenuManager.CreateCategory("Procudeal aimation", Color.red); val.CreateBoolElement("Mod Active", Color.white, true, (Action<bool>)delegate(bool v) { modEnabled = v; }); val.CreateFloatElement("Force", Color.red, 35f, (Action<float>)delegate(float v) { pullForce = v; }, 5f, -2.1474836E+09f, 2.1474836E+09f, false); val.CreateFloatElement("Duration", Color.white, 8f, (Action<float>)delegate(float v) { struggleTime = v; }, 1f, -2.1474836E+09f, 2.1474836E+09f, false); } } [HarmonyPatch(typeof(Gun), "OnFire", new Type[] { })] public class GunFirePatch { [HarmonyPostfix] public static void Postfix(Gun __instance) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (!Main.modEnabled || (Object)(object)__instance.firePointTransform == (Object)null) { return; } Ray val = default(Ray); ((Ray)(ref val))..ctor(__instance.firePointTransform.position, __instance.firePointTransform.forward); RaycastHit val2 = default(RaycastHit); if (!Physics.Raycast(val, ref val2, 500f)) { return; } AIBrain componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<AIBrain>(); if (!((Object)(object)componentInParent != (Object)null)) { return; } AgonyLogic component = ((Component)componentInParent).GetComponent<AgonyLogic>(); if ((Object)(object)component != (Object)null) { if (component.isSuffering && Time.time - component.sufferingStartTime >= 2f) { component.MercyKill(); } else { component.lastHitBone = ((Component)((RaycastHit)(ref val2)).collider).GetComponent<Rigidbody>(); } } } } [HarmonyPatch(typeof(PuppetMaster), "Kill", new Type[] { })] public class PuppetMasterKillPatch { [HarmonyPrefix] public static void Prefix(PuppetMaster __instance) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) if (!Main.modEnabled) { return; } AIBrain componentInParent = ((Component)__instance).GetComponentInParent<AIBrain>(); if ((Object)(object)componentInParent == (Object)null) { return; } OriginalPuppetProperties component = ((Component)componentInParent).GetComponent<OriginalPuppetProperties>(); if ((Object)(object)component == (Object)null) { component = ((Component)componentInParent).gameObject.AddComponent<OriginalPuppetProperties>(); component.damper = __instance.muscleDamper; component.weight = __instance.muscleWeight; if ((Object)(object)__instance.targetAnimator != (Object)null) { component.animSpeed = __instance.targetAnimator.speed; } } if ((Object)(object)__instance.targetAnimator != (Object)null) { ((Behaviour)__instance.targetAnimator).enabled = false; } __instance.stateSettings = new StateSettings(0f, 0f, 0f, 0f, false, false); __instance.muscleDamper = 0f; __instance.muscleWeight = 0.5f; AgonyLogic component2 = ((Component)componentInParent).GetComponent<AgonyLogic>(); if ((Object)(object)component2 != (Object)null) { component2.ProcessHit(); } } } }