Decompiled source of Smart Zombies v1.0.0
plugins/OvrSlepr_SmartZombies.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("OvrSlepr_SmartZombies")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("OvrSlepr_SmartZombies")] [assembly: AssemblyTitle("OvrSlepr_SmartZombies")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } public class SmartZombieItemThrow : MonoBehaviourPun { private const float PickupRadius = 3f; private const float PickupCooldown = 1f; private const float PickupRequestTimeout = 3f; private const float PickupReservationTimeout = 5f; private const float ThrowDelay = 2.5f; private const float ThrowCooldown = 2.5f; private const float PickupAfterThrowCooldown = 10f; private const float ThrowForce = 20f; private const float ThrowUpForce = 3f; private const float SelfCollisionIgnoreTime = 0.6f; private const float RecentlyThrownIgnoreTime = 5f; private const float RequiredThrowDistance = 9f; private const float LyingRagdollDotThreshold = 0.45f; private const float FallRecoveryDotThreshold = 0.6f; private const float FallRecoveryDelay = 0.75f; private const float PickupChance = 40f; private static readonly MethodInfo? SetStateMethod = typeof(Item).GetMethod("SetState", BindingFlags.Instance | BindingFlags.NonPublic); private MushroomZombie? zombie; private Character? character; private PhotonView? zombieView; private Item? heldItem; private Collider[]? heldColliders; private bool[]? originalColliderStates; private float nextPickupTime; private float nextThrowTime; private float pickupRequestTime; private float heldSince; private float nextScanDebugTime; private float nextThrowDebugTime; private float uprightSince = -1f; private bool pickupRequested; private bool throwRequested; private bool pickupBlockedByFall; private int reservedItemViewID = -1; private float reservationExpiresAt; private int lastThrownItemViewID = -1; private float lastThrownItemIgnoreUntil; private void Awake() { zombie = ((Component)this).GetComponent<MushroomZombie>(); character = ((Component)this).GetComponent<Character>(); zombieView = ((Component)this).GetComponent<PhotonView>(); GlobalEvents.OnCharacterFell = (Action<Character, float>)Delegate.Combine(GlobalEvents.OnCharacterFell, new Action<Character, float>(HandleCharacterFell)); GlobalEvents.OnCharacterPassedOut = (Action<Character>)Delegate.Combine(GlobalEvents.OnCharacterPassedOut, new Action<Character>(HandleCharacterPassedOut)); Debug.Log((object)"[Smart Zombies] ItemThrow: Component initialized."); } private void OnDestroy() { GlobalEvents.OnCharacterFell = (Action<Character, float>)Delegate.Remove(GlobalEvents.OnCharacterFell, new Action<Character, float>(HandleCharacterFell)); GlobalEvents.OnCharacterPassedOut = (Action<Character>)Delegate.Remove(GlobalEvents.OnCharacterPassedOut, new Action<Character>(HandleCharacterPassedOut)); RestoreItemColliders(); } private void HandleCharacterFell(Character fallenCharacter, float fallTime) { if (!((Object)(object)fallenCharacter != (Object)(object)character) && !((Object)(object)zombie == (Object)null) && zombie.isNPCZombie && !((Object)(object)zombieView == (Object)null) && zombieView.IsMine) { pickupBlockedByFall = true; uprightSince = -1f; Debug.Log((object)"[Smart Zombies] ItemThrow: NPC fell. Pickup blocked."); DropHeldItem("Character fell"); } } private void HandleCharacterPassedOut(Character passedOutCharacter) { if (!((Object)(object)passedOutCharacter != (Object)(object)character) && !((Object)(object)zombie == (Object)null) && zombie.isNPCZombie && !((Object)(object)zombieView == (Object)null) && zombieView.IsMine) { pickupBlockedByFall = true; uprightSince = -1f; Debug.Log((object)"[Smart Zombies] ItemThrow: NPC passed out. Pickup blocked."); DropHeldItem("Character passed out"); } } private void DropHeldItem(string reason) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)heldItem == (Object)null || (Object)(object)zombieView == (Object)null || (Object)(object)((MonoBehaviourPun)heldItem).photonView == (Object)null) { return; } int viewID = ((MonoBehaviourPun)heldItem).photonView.ViewID; Vector3 position = heldItem.transform.position; Quaternion rotation = heldItem.transform.rotation; Vector3 val = Vector3.zero; if ((Object)(object)character != (Object)null) { Dictionary<BodypartType, Bodypart> partDict = character.refs.ragdoll.partDict; if (partDict.TryGetValue((BodypartType)0, out var value) && (Object)(object)value != (Object)null && (Object)(object)value.Rig != (Object)null) { val = value.Rig.linearVelocity; } } Debug.Log((object)("[Smart Zombies] ItemThrow: " + reason + " | Dropping held item: " + ((Object)heldItem).name)); zombieView.RPC("RPC_DropHeldItem", (RpcTarget)0, new object[4] { viewID, position, rotation, val }); } private void Update() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Invalid comparison between Unknown and I4 //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 if ((Object)(object)zombie == (Object)null || (Object)(object)character == (Object)null || (Object)(object)zombieView == (Object)null || !zombie.isNPCZombie || !zombieView.IsMine) { return; } if ((int)zombie.currentState == 6) { if ((Object)(object)heldItem != (Object)null) { DropHeldItem("NPC died"); } return; } UpdateFallRecovery(); if ((Object)(object)heldItem != (Object)null) { if ((int)heldItem.itemState == 1) { if (!IsPickupBlocked()) { TryThrowItem(); } return; } Debug.LogWarning((object)"[Smart Zombies] ItemThrow: Held item was lost."); RestoreItemColliders(); heldItem = null; throwRequested = false; nextPickupTime = Time.time + 1f; } if (pickupRequested && Time.time - pickupRequestTime > 3f) { Debug.LogWarning((object)"[Smart Zombies] ItemThrow: Pickup request timed out."); pickupRequested = false; nextPickupTime = Time.time + 1f; } TryPickupItem(); } private Transform? GetBodypartTransform(BodypartType type) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { return null; } Dictionary<BodypartType, Bodypart> partDict = character.refs.ragdoll.partDict; if (!partDict.TryGetValue(type, out var value)) { return null; } if ((Object)(object)value == (Object)null || (Object)(object)value.Rig == (Object)null) { return null; } return ((Component)value.Rig).transform; } private Vector3 GetPickupOrigin() { //IL_0015: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) //IL_004e: Unknown result type (might be due to invalid IL or missing references) Transform bodypartTransform = GetBodypartTransform((BodypartType)0); if ((Object)(object)bodypartTransform != (Object)null) { return bodypartTransform.position; } if ((Object)(object)character != (Object)null) { return ((Component)character).transform.position; } return ((Component)this).transform.position; } private Vector3 GetTargetVelocity(Character target) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) Dictionary<BodypartType, Bodypart> partDict = target.refs.ragdoll.partDict; if (partDict.TryGetValue((BodypartType)0, out var value) && (Object)(object)value != (Object)null && (Object)(object)value.Rig != (Object)null) { return value.Rig.linearVelocity; } return Vector3.zero; } private Vector3 GetTargetPosition(Character target) { //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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) Dictionary<BodypartType, Bodypart> partDict = target.refs.ragdoll.partDict; if (partDict.TryGetValue((BodypartType)2, out var value) && (Object)(object)value != (Object)null && (Object)(object)value.Rig != (Object)null) { return value.Rig.position; } return ((Component)target).transform.position + Vector3.up; } private float GetTargetDistance(Character target) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(GetPickupOrigin(), GetTargetPosition(target)); } private bool IsLyingInRagdoll() { //IL_0030: 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_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_0044: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Transform bodypartTransform = GetBodypartTransform((BodypartType)0); Transform bodypartTransform2 = GetBodypartTransform((BodypartType)4); if ((Object)(object)bodypartTransform == (Object)null || (Object)(object)bodypartTransform2 == (Object)null) { return false; } Vector3 val = bodypartTransform2.position - bodypartTransform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; float num = Vector3.Dot(normalized, Vector3.up); return num < 0.45f; } private bool IsPickupBlocked() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Invalid comparison between Unknown and I4 if ((Object)(object)zombie == (Object)null || (Object)(object)character == (Object)null) { return true; } if ((int)zombie.currentState == 6) { return true; } if (pickupBlockedByFall) { return true; } if (IsLyingInRagdoll()) { return true; } return false; } private void UpdateFallRecovery() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) if (!pickupBlockedByFall || (Object)(object)character == (Object)null || (Object)(object)zombie == (Object)null) { return; } if ((int)zombie.currentState == 6) { uprightSince = -1f; return; } Transform bodypartTransform = GetBodypartTransform((BodypartType)0); Transform bodypartTransform2 = GetBodypartTransform((BodypartType)4); if ((Object)(object)bodypartTransform == (Object)null || (Object)(object)bodypartTransform2 == (Object)null) { uprightSince = -1f; return; } Vector3 val = bodypartTransform2.position - bodypartTransform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; float num = Vector3.Dot(normalized, Vector3.up); if (num < 0.6f) { uprightSince = -1f; } else if (uprightSince < 0f) { uprightSince = Time.time; } else if (!(Time.time - uprightSince < 0.75f)) { pickupBlockedByFall = false; uprightSince = -1f; Debug.Log((object)"[Smart Zombies] ItemThrow: NPC recovered. Pickup enabled."); } } private bool TryCalculateHoldPose(Item item, out Vector3 position, out Quaternion rotation) { //IL_0008: 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_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: 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_0196: 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_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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_014e: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: 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_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: 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_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) position = item.transform.position; rotation = item.transform.rotation; Transform bodypartTransform = GetBodypartTransform((BodypartType)10); if ((Object)(object)bodypartTransform == (Object)null) { return false; } Transform val = item.transform.Find("Hand_R"); if ((Object)(object)val == (Object)null) { Debug.LogError((object)("[Smart Zombies] ItemThrow: Item has no Hand_R marker: " + ((Object)item).name)); return false; } if (item.rightHandOnly) { rotation = bodypartTransform.rotation * Quaternion.Inverse(val.localRotation); Vector3 val2 = Vector3.Scale(val.localPosition, item.transform.lossyScale); position = bodypartTransform.position - rotation * val2; return true; } Transform bodypartTransform2 = GetBodypartTransform((BodypartType)7); Transform val3 = item.transform.Find("Hand_L"); if ((Object)(object)bodypartTransform2 == (Object)null || (Object)(object)val3 == (Object)null) { rotation = bodypartTransform.rotation * Quaternion.Inverse(val.localRotation); Vector3 val4 = Vector3.Scale(val.localPosition, item.transform.lossyScale); position = bodypartTransform.position - rotation * val4; return true; } Vector3 val5 = val3.localPosition - val.localPosition; Vector3 val6 = bodypartTransform2.position - bodypartTransform.position; if (((Vector3)(ref val5)).sqrMagnitude < 0.0001f || ((Vector3)(ref val6)).sqrMagnitude < 0.0001f) { return false; } Vector3 val7 = val.localRotation * Vector3.forward; Vector3 val8 = bodypartTransform.forward; Vector3 val9 = Vector3.ProjectOnPlane(val7, ((Vector3)(ref val5)).normalized); val7 = ((Vector3)(ref val9)).normalized; val9 = Vector3.ProjectOnPlane(val8, ((Vector3)(ref val6)).normalized); val8 = ((Vector3)(ref val9)).normalized; if (((Vector3)(ref val7)).sqrMagnitude < 0.0001f || ((Vector3)(ref val8)).sqrMagnitude < 0.0001f) { return false; } Quaternion val10 = Quaternion.LookRotation(val7, ((Vector3)(ref val5)).normalized); Quaternion val11 = Quaternion.LookRotation(val8, ((Vector3)(ref val6)).normalized); rotation = val11 * Quaternion.Inverse(val10); Vector3 val12 = Vector3.Scale(val.localPosition, item.transform.lossyScale); position = bodypartTransform.position - rotation * val12; return true; } private bool RollPickupChance() { float num = Random.Range(0f, 100f); bool flag = num < 40f; Debug.Log((object)("[Smart Zombies] ItemThrow: Pickup chance | " + $"Roll={num:F1} | " + $"Chance={40f}% | " + "Result=" + (flag ? "SUCCESS" : "FAILED"))); return flag; } private bool IsRecentlyThrownItem(Item item) { if ((Object)(object)item == (Object)null || (Object)(object)((MonoBehaviourPun)item).photonView == (Object)null) { return false; } return ((MonoBehaviourPun)item).photonView.ViewID == lastThrownItemViewID && Time.time < lastThrownItemIgnoreUntil; } private void TryPickupItem() { //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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Invalid comparison between Unknown and I4 //IL_0239: Unknown result type (might be due to invalid IL or missing references) if (pickupRequested || Time.time < nextPickupTime || (Object)(object)character == (Object)null || (Object)(object)zombieView == (Object)null || IsPickupBlocked()) { return; } Item val = null; float num = 3f; int num2 = 0; int num3 = 0; int num4 = 0; int num5 = 0; Vector3 pickupOrigin = GetPickupOrigin(); for (int i = 0; i < Item.ALL_ITEMS.Count; i++) { Item val2 = Item.ALL_ITEMS[i]; if ((Object)(object)val2 == (Object)null) { continue; } num2++; float num6 = Vector3.Distance(pickupOrigin, val2.transform.position); if (num6 <= 3f) { num5++; } if ((int)val2.itemState > 0) { continue; } num3++; if (!((Object)(object)val2.rig == (Object)null) && !((Object)(object)((MonoBehaviourPun)val2).photonView == (Object)null) && !val2.rig.isKinematic && !IsRecentlyThrownItem(val2)) { num4++; if (!(num6 >= num)) { num = num6; val = val2; } } } if (Time.time >= nextScanDebugTime) { nextScanDebugTime = Time.time + 3f; Debug.Log((object)("[Smart Zombies] ItemThrow: SCAN | " + $"Total={num2} | " + $"Ground={num3} | " + $"Valid={num4} | " + $"Nearby={num5} | " + "Nearest=" + (((Object)(object)val != (Object)null) ? ((Object)val).name : "NONE") + " | " + $"Distance={num:F2} | " + $"Origin={pickupOrigin} | " + "Held=" + (((Object)(object)heldItem != (Object)null) ? ((Object)heldItem).name : "NONE"))); } if (!((Object)(object)val == (Object)null)) { if (!RollPickupChance()) { nextPickupTime = Time.time + 1f; return; } pickupRequested = true; pickupRequestTime = Time.time; nextPickupTime = Time.time + 1f; Debug.Log((object)("[Smart Zombies] ItemThrow: Requesting pickup: " + ((Object)val).name + " | Distance=" + num.ToString("F2"))); zombieView.RPC("RPC_RequestPickup", (RpcTarget)2, new object[1] { ((MonoBehaviourPun)val).photonView.ViewID }); } } [PunRPC] private void RPC_RequestPickup(int itemViewID) { //IL_0114: 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_0162: Unknown result type (might be due to invalid IL or missing references) if (!PhotonNetwork.IsMasterClient || (Object)(object)zombie == (Object)null || (Object)(object)character == (Object)null || (Object)(object)zombieView == (Object)null) { return; } if (!zombie.isNPCZombie || IsPickupBlocked() || (Object)(object)heldItem != (Object)null) { RejectPickup(); return; } if (reservedItemViewID != -1 && Time.time >= reservationExpiresAt) { Debug.LogWarning((object)"[Smart Zombies] ItemThrow: Expired pickup reservation released."); reservedItemViewID = -1; } if (reservedItemViewID != -1) { RejectPickup(); return; } PhotonView photonView = PhotonNetwork.GetPhotonView(itemViewID); if ((Object)(object)photonView == (Object)null) { RejectPickup(); return; } Item component = ((Component)photonView).GetComponent<Item>(); if ((Object)(object)component == (Object)null || (Object)(object)component.rig == (Object)null || (int)component.itemState != 0 || component.rig.isKinematic) { RejectPickup(); return; } if (IsRecentlyThrownItem(component)) { RejectPickup(); return; } float num = Vector3.Distance(GetPickupOrigin(), component.transform.position); if (num > 3.5f) { Debug.Log((object)("[Smart Zombies] ItemThrow: Master rejected pickup by distance. " + $"Distance={num:F2}")); RejectPickup(); return; } reservedItemViewID = itemViewID; reservationExpiresAt = Time.time + 5f; Debug.Log((object)("[Smart Zombies] ItemThrow: Master approved and reserved pickup: " + ((Object)component).name)); zombieView.RPC("RPC_PickupItem", (RpcTarget)0, new object[1] { itemViewID }); } private void RejectPickup() { if (!((Object)(object)zombieView == (Object)null)) { zombieView.RPC("RPC_PickupRejected", (RpcTarget)0, Array.Empty<object>()); } } [PunRPC] private void RPC_PickupRejected() { reservedItemViewID = -1; reservationExpiresAt = 0f; pickupRequested = false; nextPickupTime = Time.time + 1f; Debug.Log((object)"[Smart Zombies] ItemThrow: Pickup rejected."); } [PunRPC] private void RPC_PickupItem(int itemViewID) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Invalid comparison between Unknown and I4 //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Invalid comparison between Unknown and I4 //IL_00f2: 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_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null) { return; } if ((Object)(object)heldItem != (Object)null) { if (!((Object)(object)((MonoBehaviourPun)heldItem).photonView != (Object)null) || ((MonoBehaviourPun)heldItem).photonView.ViewID != itemViewID) { Debug.LogWarning((object)"[Smart Zombies] ItemThrow: Pickup RPC received while another item is held."); } return; } PhotonView photonView = PhotonNetwork.GetPhotonView(itemViewID); if ((Object)(object)photonView == (Object)null) { ClearPickupReservation(); pickupRequested = false; return; } Item component = ((Component)photonView).GetComponent<Item>(); if ((Object)(object)component == (Object)null || (Object)(object)component.rig == (Object)null) { ClearPickupReservation(); pickupRequested = false; return; } if ((int)component.itemState > 0) { Debug.LogWarning((object)("[Smart Zombies] ItemThrow: Pickup aborted. Item is no longer Ground: " + ((Object)component).name + " | State=" + ((object)component.itemState/*cast due to .constrained prefix*/).ToString())); ClearPickupReservation(); pickupRequested = false; return; } SetItemState(component, (ItemState)1, character); if ((int)component.itemState != 1) { Debug.LogError((object)("[Smart Zombies] ItemThrow: Failed to set item state to Held: " + ((Object)component).name)); ClearPickupReservation(); pickupRequested = false; return; } if (!TryCalculateHoldPose(component, out var position, out var rotation)) { Debug.LogError((object)("[Smart Zombies] ItemThrow: Could not calculate hold pose: " + ((Object)component).name)); SetItemState(component, (ItemState)0); component.rig.isKinematic = false; component.rig.useGravity = true; ClearPickupReservation(); pickupRequested = false; return; } component.rig.linearVelocity = Vector3.zero; component.rig.angularVelocity = Vector3.zero; component.rig.useGravity = false; component.rig.isKinematic = true; DisableItemColliders(component); component.transform.SetPositionAndRotation(position, rotation); heldItem = component; heldSince = Time.time; pickupRequested = false; ClearPickupReservation(); Debug.Log((object)("[Smart Zombies] ItemThrow: Picked up: " + ((Object)component).name + " | TwoHanded=" + !component.rightHandOnly + " | ItemOwner=" + ((MonoBehaviourPun)component).photonView.OwnerActorNr)); } private void ClearPickupReservation() { reservedItemViewID = -1; reservationExpiresAt = 0f; } private void FixedUpdate() { //IL_0089: 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) if (!((Object)(object)zombie == (Object)null) && !((Object)(object)character == (Object)null) && zombie.isNPCZombie && !((Object)(object)heldItem == (Object)null) && !((Object)(object)heldItem.rig == (Object)null) && TryCalculateHoldPose(heldItem, out var position, out var rotation)) { heldItem.rig.MovePosition(position); heldItem.rig.MoveRotation(rotation); } } private bool TryThrowItem() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0263: 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_026d: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_028a: 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_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_0380: 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_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)heldItem == (Object)null || throwRequested) { return false; } if (Time.time < nextThrowTime) { return false; } if ((Object)(object)character == (Object)null || (Object)(object)zombie == (Object)null || (Object)(object)zombieView == (Object)null) { return false; } if ((int)zombie.currentState == 6) { return false; } if (IsPickupBlocked()) { return false; } if (Time.time - heldSince < 2.5f) { return false; } Character currentTarget = zombie.currentTarget; if ((Object)(object)currentTarget == (Object)null) { return false; } float targetDistance = GetTargetDistance(currentTarget); if (Time.time >= nextThrowDebugTime) { nextThrowDebugTime = Time.time + 1f; Debug.Log((object)("[Smart Zombies] ItemThrow: THROW CHECK | Target=" + ((Object)currentTarget).name + " | " + $"Distance={targetDistance:F2} | " + $"RequiredDistance={9f} | " + "Held=" + ((Object)heldItem).name + " | " + $"HeldTime={Time.time - heldSince:F2}")); } if (targetDistance <= 9f) { return false; } if ((Object)(object)((MonoBehaviourPun)heldItem).photonView == (Object)null || (Object)(object)heldItem.rig == (Object)null) { return false; } Vector3 targetPosition = GetTargetPosition(currentTarget); Vector3 targetVelocity = GetTargetVelocity(currentTarget); Vector3 val = ((Vector3)(ref character.data.lookDirection)).normalized; if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = ((Component)character).transform.forward; } Vector3 val2 = heldItem.transform.position + val * 0.9f; Vector3 velocity = Vector3.zero; float flightTime = 0f; bool flag = false; Vector3 val3 = targetPosition; for (int i = 0; i < 4; i++) { flag = TrySolveBallisticVelocity(val2, val3, 20f, out velocity, out flightTime); if (!flag) { break; } val3 = targetPosition + targetVelocity * flightTime; } if (!flag) { Vector3 val4 = val3 - val2; Vector3 normalized = ((Vector3)(ref val4)).normalized; if (((Vector3)(ref normalized)).sqrMagnitude < 0.01f) { return false; } velocity = normalized * 20f + Vector3.up * 3f; flightTime = 0f; } targetDistance = GetTargetDistance(currentTarget); if (targetDistance <= 9f) { Debug.Log((object)("[Smart Zombies] ItemThrow: Throw cancelled. " + $"Target is too close: {targetDistance:F2}m")); return false; } Quaternion rotation = heldItem.transform.rotation; int viewID = ((MonoBehaviourPun)heldItem).photonView.ViewID; throwRequested = true; nextThrowTime = Time.time + 2.5f; Debug.Log((object)("[Smart Zombies] ItemThrow: AIM | Target=" + ((Object)currentTarget).name + " | " + $"Distance={targetDistance:F2} | " + $"TargetPosition={targetPosition} | " + $"TargetVelocity={targetVelocity} | " + $"FlightTime={flightTime:F2} | " + $"Velocity={velocity}")); zombieView.RPC("RPC_ThrowItem", (RpcTarget)0, new object[4] { viewID, val2, rotation, velocity }); return true; } private bool TrySolveBallisticVelocity(Vector3 origin, Vector3 target, float speed, out Vector3 velocity, out float flightTime) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: 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_0016: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) velocity = Vector3.zero; flightTime = 0f; Vector3 val = target - origin; Vector3 gravity = Physics.gravity; float num = 0.25f * ((Vector3)(ref gravity)).sqrMagnitude; float num2 = 0f - (Vector3.Dot(val, gravity) + speed * speed); float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (Mathf.Abs(num) < 1E-06f) { return false; } float num3 = num2 * num2 - 4f * num * sqrMagnitude; if (num3 < 0f) { return false; } float num4 = Mathf.Sqrt(num3); float num5 = (0f - num2 - num4) / (2f * num); float num6 = (0f - num2 + num4) / (2f * num); float num7 = float.MaxValue; if (num5 > 0f) { num7 = num5; } if (num6 > 0f && num6 < num7) { num7 = num6; } if (num7 == float.MaxValue) { return false; } flightTime = Mathf.Sqrt(num7); if (flightTime <= 0.001f) { return false; } velocity = (val - 0.5f * gravity * num7) / flightTime; return true; } [PunRPC] private void RPC_ThrowItem(int itemViewID, Vector3 position, Quaternion rotation, Vector3 velocity) { //IL_00e4: 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_0163: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)zombieView == (Object)null) { return; } PhotonView photonView = PhotonNetwork.GetPhotonView(itemViewID); if ((Object)(object)photonView == (Object)null) { return; } Item component = ((Component)photonView).GetComponent<Item>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.rig == (Object)null)) { Debug.Log((object)("[Smart Zombies] ItemThrow: THROW START | Item=" + ((Object)component).name + " | " + $"ItemOwner={((MonoBehaviourPun)component).photonView.OwnerActorNr} | " + $"LocalActor={PhotonNetwork.LocalPlayer.ActorNumber} | " + $"IsMine={((MonoBehaviourPun)component).photonView.IsMine} | " + $"Velocity={velocity}")); RestoreItemColliders(); heldItem = null; throwRequested = false; pickupRequested = false; ClearPickupReservation(); nextPickupTime = Time.time + 10f; Debug.Log((object)"[Smart Zombies] ItemThrow: Pickup cooldown started | 10 seconds."); lastThrownItemViewID = itemViewID; lastThrownItemIgnoreUntil = Time.time + 5f; SetItemState(component, (ItemState)0); component.transform.SetPositionAndRotation(position, rotation); component.rig.isKinematic = false; component.rig.useGravity = true; component.rig.linearVelocity = Vector3.zero; component.rig.angularVelocity = Vector3.zero; ((MonoBehaviour)this).StartCoroutine(IgnoreZombieCollision(component)); ((MonoBehaviourPun)component).photonView.RPC("RPC_SetThrownData", (RpcTarget)0, new object[2] { zombieView.ViewID, 1f }); if (((MonoBehaviourPun)component).photonView.IsMine) { component.rig.linearVelocity = velocity; component.rig.angularVelocity = Vector3.Cross(((Vector3)(ref velocity)).normalized, Vector3.up) * 3f; Debug.Log((object)("[Smart Zombies] ItemThrow: VELOCITY APPLIED | " + $"Velocity={velocity}")); } else { Debug.LogWarning((object)("[Smart Zombies] ItemThrow: VELOCITY NOT APPLIED! " + $"ItemOwner={((MonoBehaviourPun)component).photonView.OwnerActorNr} | " + $"LocalActor={PhotonNetwork.LocalPlayer.ActorNumber}")); } } } private static bool SetItemState(Item item, ItemState state, Character? holder = null) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)item == (Object)null) { return false; } if (SetStateMethod == null) { Debug.LogError((object)"[Smart Zombies] ItemThrow: Could not find Item.SetState!"); return false; } try { SetStateMethod.Invoke(item, new object[2] { state, holder }); return item.itemState == state; } catch (Exception ex) { Debug.LogError((object)("[Smart Zombies] ItemThrow: SetItemState failed: " + ex)); return false; } } private void DisableItemColliders(Item item) { heldColliders = ((Component)item).GetComponentsInChildren<Collider>(true); originalColliderStates = new bool[heldColliders.Length]; for (int i = 0; i < heldColliders.Length; i++) { if (!((Object)(object)heldColliders[i] == (Object)null)) { originalColliderStates[i] = heldColliders[i].enabled; heldColliders[i].enabled = false; } } Debug.Log((object)"[Smart Zombies] ItemThrow: Disabled held item colliders."); } private void RestoreItemColliders() { if (heldColliders == null || originalColliderStates == null) { return; } for (int i = 0; i < heldColliders.Length; i++) { if (!((Object)(object)heldColliders[i] == (Object)null)) { heldColliders[i].enabled = originalColliderStates[i]; } } heldColliders = null; originalColliderStates = null; Debug.Log((object)"[Smart Zombies] ItemThrow: Restored item colliders."); } private IEnumerator IgnoreZombieCollision(Item item) { if ((Object)(object)character == (Object)null || (Object)(object)item == (Object)null) { yield break; } Collider[] itemColliders = ((Component)item).GetComponentsInChildren<Collider>(true); Collider[] zombieColliders = ((Component)character).GetComponentsInChildren<Collider>(true); Collider[] array = itemColliders; foreach (Collider itemCollider in array) { if ((Object)(object)itemCollider == (Object)null) { continue; } Collider[] array2 = zombieColliders; foreach (Collider zombieCollider in array2) { if (!((Object)(object)zombieCollider == (Object)null)) { Physics.IgnoreCollision(itemCollider, zombieCollider, true); } } } yield return (object)new WaitForSeconds(0.6f); Collider[] array3 = itemColliders; foreach (Collider itemCollider2 in array3) { if ((Object)(object)itemCollider2 == (Object)null) { continue; } Collider[] array4 = zombieColliders; foreach (Collider zombieCollider2 in array4) { if (!((Object)(object)zombieCollider2 == (Object)null)) { Physics.IgnoreCollision(itemCollider2, zombieCollider2, false); } } } } [PunRPC] private void RPC_DropHeldItem(int itemViewID, Vector3 position, Quaternion rotation, Vector3 velocity) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_013e: 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) PhotonView photonView = PhotonNetwork.GetPhotonView(itemViewID); if ((Object)(object)photonView == (Object)null) { return; } Item component = ((Component)photonView).GetComponent<Item>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.rig == (Object)null) && (!((Object)(object)heldItem != (Object)null) || !((Object)(object)((MonoBehaviourPun)heldItem).photonView != (Object)null) || ((MonoBehaviourPun)heldItem).photonView.ViewID == itemViewID)) { RestoreItemColliders(); heldItem = null; throwRequested = false; pickupRequested = false; ClearPickupReservation(); nextPickupTime = Time.time + 1f; SetItemState(component, (ItemState)0); component.transform.SetPositionAndRotation(position, rotation); component.rig.isKinematic = false; component.rig.useGravity = true; component.rig.linearVelocity = Vector3.zero; component.rig.angularVelocity = Vector3.zero; if (((MonoBehaviourPun)component).photonView.IsMine) { component.rig.linearVelocity = velocity; } Debug.Log((object)("[Smart Zombies] ItemThrow: Item dropped because NPC fell | " + $"Item={((Object)component).name} | Velocity={velocity}")); } } } [HarmonyPatch(typeof(MushroomZombie), "Awake")] public static class SmartZombieItemThrowPatch { [HarmonyPostfix] private static void Postfix(MushroomZombie __instance) { if (!((Object)(object)__instance == (Object)null) && __instance.isNPCZombie && !((Object)(object)((Component)__instance).GetComponent<SmartZombieItemThrow>() != (Object)null)) { ((Component)__instance).gameObject.AddComponent<SmartZombieItemThrow>(); Debug.Log((object)"[Smart Zombies] ItemThrow: Added component to NPC zombie."); } } } namespace OvrSlepr.SmartZombies { [HarmonyPatch(typeof(BananaPeel), "Update")] internal static class BananaPeelZombieUpdatePatch { private sealed class PeelCheckState { public float NextCheckTime; public float NextAllowedSlipTime; } private static readonly Dictionary<int, PeelCheckState> States = new Dictionary<int, PeelCheckState>(); private const float CheckInterval = 0.25f; private const float SlipCooldown = 3f; private const float SlipDistance = 1f; private const float MinimumSpeed = 1.5f; private static void Postfix(BananaPeel __instance) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Invalid comparison between Unknown and I4 //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { return; } Item component = ((Component)__instance).GetComponent<Item>(); if ((Object)(object)component == (Object)null || (int)component.itemState > 0) { return; } int instanceID = ((Object)__instance).GetInstanceID(); if (!States.TryGetValue(instanceID, out PeelCheckState value)) { value = new PeelCheckState(); States[instanceID] = value; } if (Time.time < value.NextCheckTime || Time.time < value.NextAllowedSlipTime) { return; } value.NextCheckTime = Time.time + 0.25f; PhotonView component2 = ((Component)__instance).GetComponent<PhotonView>(); if ((Object)(object)component2 == (Object)null) { return; } MushroomZombie[] array = Object.FindObjectsByType<MushroomZombie>((FindObjectsSortMode)0); MushroomZombie[] array2 = array; foreach (MushroomZombie val in array2) { if ((Object)(object)val == (Object)null || !val.isNPCZombie) { continue; } Character component3 = ((Component)val).GetComponent<Character>(); if ((Object)(object)component3 == (Object)null || (Object)(object)component3.data == (Object)null) { continue; } PhotonView component4 = ((Component)component3).GetComponent<PhotonView>(); if (!((Object)(object)component4 == (Object)null) && component4.IsMine && component3.data.isGrounded) { Vector3 val2 = component3.Center - ((Component)__instance).transform.position; if (!(((Vector3)(ref val2)).sqrMagnitude > 1f) && !(((Vector3)(ref component3.data.avarageVelocity)).magnitude < 1.5f)) { value.NextAllowedSlipTime = Time.time + 3f; component2.RPC("RPCA_TriggerBanana", (RpcTarget)0, new object[1] { component4.ViewID }); break; } } } } } [HarmonyPatch(typeof(BananaPeel), "RPCA_TriggerBanana")] internal static class BananaPeelZombieTriggerPatch { private static bool Prefix(BananaPeel __instance, int viewID) { //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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) PhotonView val = PhotonView.Find(viewID); if ((Object)(object)val == (Object)null) { return true; } Character component = ((Component)val).GetComponent<Character>(); if ((Object)(object)component == (Object)null) { return true; } MushroomZombie component2 = ((Component)component).GetComponent<MushroomZombie>(); if ((Object)(object)component2 == (Object)null || !component2.isNPCZombie) { return true; } if ((Object)(object)component.data == (Object)null) { return false; } Rigidbody component3 = ((Component)__instance).GetComponent<Rigidbody>(); if ((Object)(object)component3 != (Object)null) { component3.AddForce((component.data.lookDirection_Flat * 0.5f + Vector3.up) * 40f, (ForceMode)1); } component.RPCA_Fall(2f, 0f); Rigidbody value = Traverse.Create((object)component).Method("GetBodypartRig", new object[1] { (object)(BodypartType)16 }).GetValue<Rigidbody>(); Rigidbody value2 = Traverse.Create((object)component).Method("GetBodypartRig", new object[1] { (object)(BodypartType)13 }).GetValue<Rigidbody>(); Rigidbody value3 = Traverse.Create((object)component).Method("GetBodypartRig", new object[1] { (object)(BodypartType)0 }).GetValue<Rigidbody>(); Rigidbody value4 = Traverse.Create((object)component).Method("GetBodypartRig", new object[1] { (object)(BodypartType)4 }).GetValue<Rigidbody>(); Vector3 lookDirection_Flat = component.data.lookDirection_Flat; if ((Object)(object)value != (Object)null) { value.AddForce((lookDirection_Flat + Vector3.up) * 200f, (ForceMode)1); } if ((Object)(object)value2 != (Object)null) { value2.AddForce((lookDirection_Flat + Vector3.up) * 200f, (ForceMode)1); } if ((Object)(object)value3 != (Object)null) { value3.AddForce(Vector3.up * 1500f, (ForceMode)1); } if ((Object)(object)value4 != (Object)null) { value4.AddForce(lookDirection_Flat * -300f, (ForceMode)1); } SFX_Instance[] slipSFX = __instance.slipSFX; if (slipSFX != null) { SFX_Instance[] array = slipSFX; foreach (SFX_Instance val2 in array) { if ((Object)(object)val2 != (Object)null) { val2.Play(((Component)__instance).transform.position); } } } return false; } } [HarmonyPatch(typeof(SlipperyJellyfish), "OnTriggerEnter")] internal static class JellyfishOnTriggerEnterPatch { private static readonly Dictionary<int, float> Cooldowns = new Dictionary<int, float>(); private static bool Prefix(SlipperyJellyfish __instance, Collider other) { if ((Object)(object)__instance == (Object)null || (Object)(object)other == (Object)null) { return true; } Character val = default(Character); if (!CharacterRagdoll.TryGetCharacterFromCollider(other, ref val)) { return true; } if ((Object)(object)val == (Object)null) { return true; } MushroomZombie component = ((Component)val).GetComponent<MushroomZombie>(); if ((Object)(object)component == (Object)null || !component.isNPCZombie) { return true; } PhotonView component2 = ((Component)val).GetComponent<PhotonView>(); if ((Object)(object)component2 == (Object)null || !component2.IsMine) { return false; } int instanceID = ((Object)__instance).GetInstanceID(); if (Cooldowns.TryGetValue(instanceID, out var value) && Time.time - value < 3f) { return false; } TriggerRelay value2 = Traverse.Create((object)__instance).Field("relay").GetValue<TriggerRelay>(); if ((Object)(object)value2 == (Object)null) { return false; } PhotonView value3 = Traverse.Create((object)value2).Field("view").GetValue<PhotonView>(); if ((Object)(object)value3 == (Object)null) { return false; } Cooldowns[instanceID] = Time.time; value3.RPC("RPCA_TriggerWithTarget", (RpcTarget)0, new object[2] { ((Component)__instance).transform.GetSiblingIndex(), component2.ViewID }); return false; } } [HarmonyPatch(typeof(SlipperyJellyfish), "Trigger")] internal static class JellyfishZombieTriggerPatch { private static bool Prefix(SlipperyJellyfish __instance, int targetID) { //IL_012d: 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) PhotonView val = PhotonView.Find(targetID); if ((Object)(object)val == (Object)null) { return true; } Character component = ((Component)val).GetComponent<Character>(); if ((Object)(object)component == (Object)null) { return true; } MushroomZombie component2 = ((Component)component).GetComponent<MushroomZombie>(); if ((Object)(object)component2 == (Object)null || !component2.isNPCZombie) { return true; } if ((Object)(object)component.data == (Object)null) { return false; } component.RPCA_Fall(2f, 0f); Rigidbody value = Traverse.Create((object)component).Method("GetBodypartRig", new object[1] { (object)(BodypartType)16 }).GetValue<Rigidbody>(); Rigidbody value2 = Traverse.Create((object)component).Method("GetBodypartRig", new object[1] { (object)(BodypartType)13 }).GetValue<Rigidbody>(); Rigidbody value3 = Traverse.Create((object)component).Method("GetBodypartRig", new object[1] { (object)(BodypartType)0 }).GetValue<Rigidbody>(); Rigidbody value4 = Traverse.Create((object)component).Method("GetBodypartRig", new object[1] { (object)(BodypartType)4 }).GetValue<Rigidbody>(); Vector3 lookDirection_Flat = component.data.lookDirection_Flat; if ((Object)(object)value != (Object)null) { value.AddForce((lookDirection_Flat + Vector3.up) * 200f, (ForceMode)1); } if ((Object)(object)value2 != (Object)null) { value2.AddForce((lookDirection_Flat + Vector3.up) * 200f, (ForceMode)1); } if ((Object)(object)value3 != (Object)null) { value3.AddForce(Vector3.up * 1500f, (ForceMode)1); } if ((Object)(object)value4 != (Object)null) { value4.AddForce(lookDirection_Flat * -300f, (ForceMode)1); } SFX_Instance[] slipSFX = __instance.slipSFX; if (slipSFX != null) { SFX_Instance[] array = slipSFX; foreach (SFX_Instance val2 in array) { if ((Object)(object)val2 != (Object)null) { val2.Play(((Component)__instance).transform.position); } } } return false; } } internal class SmartZombieAggro : MonoBehaviour { private const float ChaseDistance = 10f; private MushroomZombie zombie; private Character zombieCharacter; private bool isAggressive; private static readonly MethodInfo SetCurrentTargetMethod = AccessTools.Method(typeof(MushroomZombie), "SetCurrentTarget", new Type[2] { typeof(Character), typeof(float) }, (Type[])null); private static readonly MethodInfo StartChasingMethod = AccessTools.Method(typeof(MushroomZombie), "StartChasing", (Type[])null, (Type[])null); public bool IsAggressive => isAggressive; private void Awake() { zombie = ((Component)this).GetComponent<MushroomZombie>(); zombieCharacter = ((Component)this).GetComponent<Character>(); } private void Update() { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Invalid comparison between Unknown and I4 //IL_008e: 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_00a1: Invalid comparison between Unknown and I4 //IL_00e0: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Invalid comparison between Unknown and I4 if ((Object)(object)zombie == (Object)null || (Object)(object)zombieCharacter == (Object)null || (Object)(object)((MonoBehaviourPun)zombie).photonView == (Object)null || !((MonoBehaviourPun)zombie).photonView.IsMine) { return; } if (!zombie.isNPCZombie) { isAggressive = false; return; } if ((int)zombie.currentState == 6 || (int)zombie.currentState == 0 || (int)zombie.currentState == 1) { isAggressive = false; return; } Character val = FindNearestPlayer(); if ((Object)(object)val == (Object)null) { isAggressive = false; return; } float num = Vector3.Distance(zombieCharacter.Center, val.Center); if (num > 10f) { isAggressive = true; if ((Object)(object)zombie.currentTarget != (Object)(object)val) { SetCurrentTargetMethod?.Invoke(zombie, new object[2] { val, 0f }); } if ((int)zombie.currentState == 2) { StartChasingMethod?.Invoke(zombie, null); Debug.Log((object)("[Smart Zombies] Aggro activated! Distance: " + num.ToString("F1") + "m")); } } else { isAggressive = false; } } private Character FindNearestPlayer() { //IL_00a1: 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) Character result = null; float num = float.MaxValue; foreach (Character allCharacter in Character.AllCharacters) { if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter == (Object)(object)zombieCharacter) && !allCharacter.isBot && !allCharacter.isZombie && !allCharacter.data.dead && !allCharacter.data.passedOut && !allCharacter.data.fullyPassedOut && !((Object)(object)((MonoBehaviourPun)allCharacter).photonView == (Object)null)) { float num2 = Vector3.Distance(zombieCharacter.Center, allCharacter.Center); if (num2 < num) { num = num2; result = allCharacter; } } } return result; } } [HarmonyPatch(typeof(MushroomZombie), "Awake")] internal static class SmartZombieAggroAwakePatch { private static void Postfix(MushroomZombie __instance) { if (!((Object)(object)__instance == (Object)null) && (Object)(object)((Component)__instance).GetComponent<SmartZombieAggro>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<SmartZombieAggro>(); } } } [HarmonyPatch(typeof(MushroomZombie), "WalkTowards", new Type[] { typeof(Vector3), typeof(float), typeof(bool), typeof(bool), typeof(bool) })] internal static class SmartZombieAggroSprintPatch { private static void Prefix(MushroomZombie __instance, ref bool forceSprint) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)((MonoBehaviourPun)__instance).photonView == (Object)null) && ((MonoBehaviourPun)__instance).photonView.IsMine) { SmartZombieAggro component = ((Component)__instance).GetComponent<SmartZombieAggro>(); if ((Object)(object)component != (Object)null && component.IsAggressive) { forceSprint = true; } } } } [HarmonyPatch(typeof(MushroomZombie), "Awake")] internal static class SmartZombieClimbLungeAwakePatch { private static void Postfix(MushroomZombie __instance) { if (!((Object)(object)__instance == (Object)null) && __instance.isNPCZombie && (Object)(object)((Component)__instance).GetComponent<SmartZombieClimbLunge>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<SmartZombieClimbLunge>(); Debug.Log((object)"[Smart Zombies][ClimbLunge] Component added to zombie."); } } } [HarmonyPatch(typeof(MushroomZombie), "Update")] internal static class SmartZombieClimbLungeUpdatePatch { private static void Postfix(MushroomZombie __instance) { if (!((Object)(object)__instance == (Object)null)) { SmartZombieClimbLunge component = ((Component)__instance).GetComponent<SmartZombieClimbLunge>(); if ((Object)(object)component != (Object)null) { component.AfterZombieUpdate(); } } } } internal class SmartZombieClimbLunge : MonoBehaviourPun { private const float LungeInterval = 3f; private const float LungeForce = 8f; private MushroomZombie zombie; private Character character; private CharacterClimbing climbing; private float lungeTimer; private bool wasClimbing; private void Awake() { zombie = ((Component)this).GetComponent<MushroomZombie>(); character = ((Component)this).GetComponent<Character>(); climbing = ((Component)this).GetComponent<CharacterClimbing>(); Debug.Log((object)("[Smart Zombies][ClimbLunge] Awake. " + $"Character: {(Object)(object)character != (Object)null}, " + $"Climbing: {(Object)(object)climbing != (Object)null}")); } public void AfterZombieUpdate() { //IL_0108: 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_013f: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)zombie == (Object)null || (Object)(object)character == (Object)null || (Object)(object)climbing == (Object)null || !((MonoBehaviourPun)this).photonView.IsMine) { return; } if (!character.data.isClimbing) { if (wasClimbing) { Debug.Log((object)"[Smart Zombies][ClimbLunge] Zombie stopped climbing. Timer reset."); } wasClimbing = false; lungeTimer = 0f; return; } if (!wasClimbing) { Debug.Log((object)"[Smart Zombies][ClimbLunge] Zombie started climbing. Lunge timer started."); wasClimbing = true; lungeTimer = 0f; } lungeTimer += Time.deltaTime; if (!(lungeTimer < 3f)) { lungeTimer = 0f; Vector2 val = ((Vector2)(ref character.input.movementInput)).normalized; if (((Vector2)(ref val)).sqrMagnitude < 0.001f) { val = Vector2.up; Debug.LogWarning((object)"[Smart Zombies][ClimbLunge] Movement input is zero. Using upward direction."); } Debug.Log((object)("[Smart Zombies][ClimbLunge] Lunge triggered! " + $"Direction: {val}, Force: {8f}")); ((MonoBehaviourPun)this).photonView.RPC("RPC_ApplyClimbLunge", (RpcTarget)0, new object[1] { val }); } } [PunRPC] private void RPC_ApplyClimbLunge(Vector2 direction) { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)character == (Object)null || (Object)(object)climbing == (Object)null) { Debug.LogWarning((object)"[Smart Zombies][ClimbLunge] RPC failed: Character or CharacterClimbing is missing."); return; } if (!character.data.isClimbing) { Debug.LogWarning((object)"[Smart Zombies][ClimbLunge] RPC received, but zombie is no longer climbing."); return; } character.data.sinceClimbJump = 0f; CharacterClimbing obj = climbing; obj.playerSlide += ((Vector2)(ref direction)).normalized * 8f; Debug.Log((object)("[Smart Zombies][ClimbLunge] RPC applied successfully. " + $"PlayerSlide: {climbing.playerSlide}")); } } [HarmonyPatch(typeof(CharacterGrabbing), "FixedUpdate")] internal static class SmartZombieHelpingPlayerPatch { private const float HelpDistance = 4f; private const float HelpAngle = 60f; private const float RequestInterval = 0.12f; private static readonly Dictionary<int, float> NextRequestTime = new Dictionary<int, float>(); private static void Postfix(CharacterGrabbing __instance) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)null) { return; } Character component = ((Component)__instance).GetComponent<Character>(); if ((Object)(object)component == (Object)null || (Object)(object)((MonoBehaviourPun)component).photonView == (Object)null || !((MonoBehaviourPun)component).photonView.IsMine || !component.data.isReaching || __instance.isKickMode || (Object)(object)component.data.currentItem != (Object)null || component.data.isClimbing || component.data.isRopeClimbing || component.data.isVineClimbing) { return; } ZombieManager instance = ZombieManager.Instance; if ((Object)(object)instance == (Object)null || instance.zombies == null) { return; } Vector3 pullTarget = CatchPlayersCompatibility.GetPullTarget(component, __instance); MushroomZombie val = null; float num = float.MaxValue; foreach (MushroomZombie zombie in instance.zombies) { if ((Object)(object)zombie == (Object)null || (Object)(object)((MonoBehaviourPun)zombie).photonView == (Object)null || !zombie.isNPCZombie) { continue; } Character zombieCharacter = SmartZombieReflection.GetZombieCharacter(zombie); if ((Object)(object)zombieCharacter == (Object)null || !zombieCharacter.data.isClimbing) { continue; } float num2 = Vector3.Distance(component.Center, zombieCharacter.Center); if (!(num2 > 4f)) { float num3 = Vector3.Angle(component.data.lookDirection, zombieCharacter.Center - component.Center); if (!(num3 > 60f) && CharacterGrabbing.TargetCanBeHelped(zombieCharacter, pullTarget) && num2 < num) { num = num2; val = zombie; } } } if ((Object)(object)val == (Object)null) { return; } int viewID = ((MonoBehaviourPun)val).photonView.ViewID; if (Time.time < GetNextRequestTime(viewID)) { return; } NextRequestTime[viewID] = Time.time + 0.12f; SmartZombieHelpingReceiver component2 = ((Component)val).GetComponent<SmartZombieHelpingReceiver>(); if ((Object)(object)component2 == (Object)null) { return; } if (((MonoBehaviourPun)val).photonView.IsMine) { component2.ReceiveHelpRequest(component); return; } PhotonView photonView = ((MonoBehaviourPun)val).photonView; if (photonView.Owner != null) { photonView.RPC("RPC_RequestHelp", photonView.Owner, new object[1] { ((MonoBehaviourPun)component).photonView.ViewID }); } } private static float GetNextRequestTime(int zombieViewID) { if (NextRequestTime.TryGetValue(zombieViewID, out var value)) { return value; } return 0f; } } internal static class CatchPlayersCompatibility { private static bool searched; private static object pullStrengthEntry; private static PropertyInfo valueProperty; internal static bool TryGetPullStrength(out float strength) { strength = 70f; if (!searched) { searched = true; FindCatchPlayersSetting(); } if (pullStrengthEntry == null || valueProperty == null) { return false; } try { object value = valueProperty.GetValue(pullStrengthEntry, null); if (value == null) { return false; } strength = Convert.ToSingle(value); return true; } catch { strength = 70f; return false; } } private static void FindCatchPlayersSetting() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type[] types; try { types = assembly.GetTypes(); } catch (ReflectionTypeLoadException ex) { types = ex.Types; } catch { continue; } Type[] array = types; foreach (Type type in array) { if (type == null || type.Name != "Catch_Players") { continue; } MemberInfo memberInfo = type.GetField("PullStrength", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (memberInfo == null) { memberInfo = type.GetProperty("PullStrength", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); } if (memberInfo == null) { continue; } object obj2 = null; try { if (memberInfo is FieldInfo fieldInfo) { obj2 = fieldInfo.GetValue(null); } else if (memberInfo is PropertyInfo propertyInfo) { obj2 = propertyInfo.GetValue(null, null); } } catch { continue; } if (obj2 != null) { PropertyInfo property = obj2.GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public); if (!(property == null)) { pullStrengthEntry = obj2; valueProperty = property; return; } } } } } internal static Vector3 GetPullTarget(Character helper, CharacterGrabbing grabbing) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //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) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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) if (TryGetPullStrength(out var _)) { return helper.Center; } return helper.Center + Util.ZeroY(helper.data.lookDirection * grabbing.extendReachDistance); } internal static float GetPullForce() { float strength; return TryGetPullStrength(out strength) ? strength : 70f; } } internal class SmartZombieHelpingReceiver : MonoBehaviourPun { private const float RequestTimeout = 0.3f; private MushroomZombie zombie; private Character zombieCharacter; private int helperViewID = -1; private float lastRequestTime; private void Awake() { zombie = ((Component)this).GetComponent<MushroomZombie>(); zombieCharacter = ((Component)this).GetComponent<Character>(); } [PunRPC] public void RPC_RequestHelp(int requestingPlayerViewID, PhotonMessageInfo info) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (!((MonoBehaviourPun)this).photonView.IsMine) { return; } PhotonView photonView = PhotonNetwork.GetPhotonView(requestingPlayerViewID); if (!((Object)(object)photonView == (Object)null)) { Character component = ((Component)photonView).GetComponent<Character>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)((MonoBehaviourPun)component).photonView == (Object)null) && photonView.Owner != null && info.Sender != null && photonView.Owner.ActorNumber == info.Sender.ActorNumber) { StoreHelpRequest(component); } } } public void ReceiveHelpRequest(Character helper) { if (((MonoBehaviourPun)this).photonView.IsMine && !((Object)(object)helper == (Object)null) && !((Object)(object)((MonoBehaviourPun)helper).photonView == (Object)null) && ((MonoBehaviourPun)helper).photonView.IsMine) { StoreHelpRequest(helper); } } private void StoreHelpRequest(Character helper) { if (!((Object)(object)helper == (Object)null) && helper.data.isReaching && !((Object)(object)zombie == (Object)null) && !((Object)(object)zombieCharacter == (Object)null) && zombie.isNPCZombie && zombieCharacter.data.isClimbing) { helperViewID = ((MonoBehaviourPun)helper).photonView.ViewID; lastRequestTime = Time.time; } } private void FixedUpdate() { //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) if (!((MonoBehaviourPun)this).photonView.IsMine || helperViewID < 0) { return; } if (Time.time - lastRequestTime > 0.3f) { helperViewID = -1; return; } if ((Object)(object)zombie == (Object)null || (Object)(object)zombieCharacter == (Object)null || !zombie.isNPCZombie || !zombieCharacter.data.isClimbing) { helperViewID = -1; return; } PhotonView photonView = PhotonNetwork.GetPhotonView(helperViewID); if ((Object)(object)photonView == (Object)null) { helperViewID = -1; return; } Character component = ((Component)photonView).GetComponent<Character>(); if ((Object)(object)component == (Object)null || !component.data.isReaching || (Object)(object)component.data.currentItem != (Object)null || component.data.isClimbing || component.data.isRopeClimbing || component.data.isVineClimbing) { helperViewID = -1; return; } CharacterGrabbing component2 = ((Component)component).GetComponent<CharacterGrabbing>(); if ((Object)(object)component2 == (Object)null) { helperViewID = -1; return; } Vector3 pullTarget = CatchPlayersCompatibility.GetPullTarget(component, component2); float num = Vector3.Distance(component.Center, zombieCharacter.Center); float num2 = Vector3.Angle(component.data.lookDirection, zombieCharacter.Center - component.Center); if (num > 4f || num2 > 60f || !CharacterGrabbing.TargetCanBeHelped(zombieCharacter, pullTarget)) { helperViewID = -1; return; } SmartZombieReflection.DragTowards(zombieCharacter, pullTarget, CatchPlayersCompatibility.GetPullForce()); SmartZombieReflection.LimitFalling(zombieCharacter); zombieCharacter.data.sinceGrabFriend = 0f; } } [HarmonyPatch(typeof(MushroomZombie), "Awake")] internal static class SmartZombieHelpingZombiePatch { private static void Postfix(MushroomZombie __instance) { if (!((Object)(object)__instance == (Object)null) && __instance.isNPCZombie && (Object)(object)((Component)__instance).GetComponent<SmartZombieHelpingReceiver>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<SmartZombieHelpingReceiver>(); } } } internal static class SmartZombieReflection { private static readonly FieldInfo ZombieCharacterField = AccessTools.Field(typeof(MushroomZombie), "character"); private static readonly MethodInfo DragTowardsMethod = AccessTools.Method(typeof(Character), "DragTowards", new Type[2] { typeof(Vector3), typeof(float) }, (Type[])null); private static readonly MethodInfo LimitFallingMethod = AccessTools.Method(typeof(Character), "LimitFalling", (Type[])null, (Type[])null); internal static Character GetZombieCharacter(MushroomZombie zombie) { object? obj = ZombieCharacterField?.GetValue(zombie); return (Character)((obj is Character) ? obj : null); } internal static void DragTowards(Character character, Vector3 target, float force) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) DragTowardsMethod?.Invoke(character, new object[2] { target, force }); } internal static void LimitFalling(Character character) { LimitFallingMethod?.Invoke(character, null); } } [HarmonyPatch(typeof(MushroomZombie), "Awake")] internal static class SmartZombieKickAwakePatch { private static void Postfix(MushroomZombie __instance) { if (!((Object)(object)__instance == (Object)null) && (Object)(object)((Component)__instance).GetComponent<SmartZombieKick>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<SmartZombieKick>(); } } } [HarmonyPatch(typeof(MushroomZombie), "Update")] internal static class SmartZombieKickUpdatePatch { private static void Postfix(MushroomZombie __instance) { if (!((Object)(object)__instance == (Object)null)) { SmartZombieKick component = ((Component)__instance).GetComponent<SmartZombieKick>(); if ((Object)(object)component != (Object)null) { component.AfterZombieUpdate(); } } } } internal class SmartZombieKick : MonoBehaviourPun { private static AudioClip[] zombieKickVoices; private static AudioClip kickImpactClip; private const float KickRange = 2.8f; private const float KickFallTime = 1.5f; private const float HorizontalForce = 150f; private const float VerticalForce = 80f; private const float ForceRadius = 2f; private const float KickImpactDelay = 0.45f; private const string KickTrigger = "Kick"; private MushroomZombie zombie; private Character zombieCharacter; private Animator zombieAnimator; private bool kickedThisRecovery; private static readonly MethodInfo ClimbTowardsMethod = AccessTools.Method(typeof(MushroomZombie), "ClimbTowards", new Type[2] { typeof(Vector3), typeof(float) }, (Type[])null); private static readonly MethodInfo WalkTowardsMethod = AccessTools.Method(typeof(MushroomZombie), "WalkTowards", new Type[5] { typeof(Vector3), typeof(float), typeof(bool), typeof(bool), typeof(bool) }, (Type[])null); private static readonly MethodInfo FallMethod = AccessTools.Method(typeof(Character), "Fall", new Type[2] { typeof(float), typeof(float) }, (Type[])null); private void FindZombieKickAudio() { AudioClip[] array = Resources.FindObjectsOfTypeAll<AudioClip>(); zombieKickVoices = (AudioClip[])(object)new AudioClip[2]; AudioClip[] array2 = array; foreach (AudioClip val in array2) { if (!((Object)(object)val == (Object)null)) { switch (((Object)val).name) { case "Au_Voice_Zombie_KnockedOut1": zombieKickVoices[0] = val; break; case "Au_Voice_Zombie_KnockedOut2": zombieKickVoices[1] = val; break; case "Au_DMG_Bodyhit_3": kickImpactClip = val; break; } } } Debug.Log((object)("[Smart Zombies] Kick audio loaded: " + $"Voice 1: {(Object)(object)zombieKickVoices[0] != (Object)null}, " + $"Voice 2: {(Object)(object)zombieKickVoices[1] != (Object)null}, " + $"Impact: {(Object)(object)kickImpactClip != (Object)null}")); } private void Awake() { FindZombieKickAudio(); zombie = ((Component)this).GetComponent<MushroomZombie>(); zombieCharacter = ((Component)this).GetComponent<Character>(); if ((Object)(object)zombieCharacter != (Object)null && zombieCharacter.refs != null) { zombieAnimator = zombieCharacter.refs.animator; } if ((Object)(object)zombieAnimator == (Object)null) { Debug.LogError((object)"[Smart Zombies] Zombie Animator not found!"); } if (FallMethod == null) { Debug.LogError((object)"[Smart Zombies] Could not find Character.Fall!"); } } public void AfterZombieUpdate() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Invalid comparison between Unknown and I4 //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_00df: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: 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_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)zombie == (Object)null || (Object)(object)zombieCharacter == (Object)null || !((MonoBehaviourPun)this).photonView.IsMine) { return; } if ((int)zombie.currentState != 5) { kickedThisRecovery = false; } else { if (kickedThisRecovery || zombieCharacter.data.fallSeconds > 0f || zombieCharacter.data.passedOut || zombieCharacter.data.fullyPassedOut) { return; } Character val = FindNearestPlayer(); if ((Object)(object)val == (Object)null) { zombieCharacter.input.movementInput = Vector2.zero; return; } Vector3 val2 = val.Center - zombieCharacter.Center; float magnitude = ((Vector3)(ref val2)).magnitude; Vector3 val3 = val2; val3.y = 0f; if (magnitude <= 2.8f) { zombieCharacter.input.movementInput = Vector2.zero; zombieCharacter.input.sprintIsPressed = false; if (((Vector3)(ref val3)).sqrMagnitude > 0.001f) { ((Vector3)(ref val3)).Normalize(); } else { val3 = ((Component)zombieCharacter).transform.forward; } kickedThisRecovery = true; int num = Random.Range(0, 2); ((MonoBehaviourPun)this).photonView.RPC("RPC_ApplyKick", (RpcTarget)0, new object[3] { ((MonoBehaviourPun)val).photonView.ViewID, val3, num }); } else if (zombieCharacter.data.isClimbing) { if (ClimbTowardsMethod != null) { ClimbTowardsMethod.Invoke(zombie, new object[2] { val.Head, 1.2f }); } } else if (WalkTowardsMethod != null) { WalkTowardsMethod.Invoke(zombie, new object[5] { val.Head, 1.2f, true, true, true }); } } } private Character FindNearestPlayer() { //IL_0090: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) Character result = null; float num = float.MaxValue; foreach (Character allCharacter in Character.AllCharacters) { if (!((Object)(object)allCharacter == (Object)null) && !((Object)(object)allCharacter == (Object)(object)zombieCharacter) && !allCharacter.isBot && !allCharacter.isZombie && !allCharacter.data.dead && !allCharacter.data.fullyPassedOut && !((Object)(object)((MonoBehaviourPun)allCharacter).photonView == (Object)null)) { Vector3 val = allCharacter.Center - zombieCharacter.Center; val.y = 0f; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (!(sqrMagnitude >= num)) { num = sqrMagnitude; result = allCharacter; } } } return result; } private void PlayRandomZombieKickVoice(int voiceIndex) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (voiceIndex >= 0 && voiceIndex < zombieKickVoices.Length) { AudioClip val = zombieKickVoices[voiceIndex]; if ((Object)(object)val == (Object)null) { Debug.LogWarning((object)("[Smart Zombies] Zombie kick voice not loaded: " + voiceIndex)); return; } GameObject val2 = new GameObject("ZombieKickVoice"); val2.transform.position = zombieCharacter.Center; AudioSource val3 = val2.AddComponent<AudioSource>(); val3.clip = val; val3.volume = 1f; val3.spatialBlend = 1f; val3.minDistance = 1f; val3.maxDistance = 30f; val3.Play(); Object.Destroy((Object)(object)val2, val.length + 0.2f); } } private void PlayKickImpactSound(Character target) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)kickImpactClip == (Object)null) { Debug.LogError((object)"[Smart Zombies] Au_DMG_Bodyhit_3 not found!"); return; } GameObject val = new GameObject("ZombieKickImpactSound"); val.transform.position = target.Center; AudioSource val2 = val.AddComponent<AudioSource>(); val2.clip = kickImpactClip; val2.volume = 1f; val2.spatialBlend = 1f; val2.minDistance = 1f; val2.maxDistance = 30f; val2.Play(); Object.Destroy((Object)(object)val, kickImpactClip.length + 0.2f); } [PunRPC] private void RPC_ApplyKick(int targetViewID, Vector3 direction, int voiceIndex) { //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Invalid comparison between Unknown and I4 if ((Object)(object)zombieAnimator == (Object)null && (Object)(object)zombieCharacter != (Object)null && zombieCharacter.refs != null) { zombieAnimator = zombieCharacter.refs.animator; } if ((Object)(object)zombieAnimator != (Object)null) { bool flag = false; AnimatorControllerParameter[] parameters = zombieAnimator.parameters; foreach (AnimatorControllerParameter val in parameters) { if (val.name == "Kick" && (int)val.type == 9) { flag = true; break; } } if (flag) { zombieAnimator.ResetTrigger("Kick"); zombieAnimator.SetTrigger("Kick"); PlayRandomZombieKickVoice(voiceIndex); } else { Debug.LogWarning((object)"[Smart Zombies] Kick Trigger not found!"); } } ((MonoBehaviour)this).StartCoroutine(ApplyKickImpactAfterAnimation(targetViewID, direction)); } private IEnumerator ApplyKickImpactAfterAnimation(int targetViewID, Vector3 direction) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) yield return (object)new WaitForSeconds(0.45f); PhotonView targetView = PhotonNetwork.GetPhotonView(targetViewID); if ((Object)(object)targetView == (Object)null) { yield break; } Character target = ((Component)targetView).GetComponent<Character>(); if ((Object)(object)target == (Object)null || target.data.dead || target.data.fullyPassedOut || (Object)(object)zombieCharacter == (Object)null) { yield break; } float distance = Vector3.Distance(zombieCharacter.Center, target.Center); if (distance > 2.8f) { yield break; } PlayKickImpactSound(target); if (targetView.IsMine) { if (FallMethod != null) { FallMethod.Invoke(target, new object[2] { 1.5f, 0f }); } Vector3 force = direction * 150f + Vector3.up * 80f; targetView.RPC("RPCA_AddForceAtPosition", (RpcTarget)0, new object[3] { force, target.Center, 2f }); } } } [HarmonyPatch(typeof(MushroomZombie), "DoLunging")] internal static class SmartZombieKickRecoveryPatch { private static readonly MethodInfo PushStateMethod = AccessTools.Method(typeof(MushroomZombie), "PushState", (Type[])null, (Type[])null); private static void Postfix(MushroomZombie __instance) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 if ((Object)(object)__instance == (Object)null || !((MonoBehaviourPun)__instance).photonView.IsMine || !__instance.isNPCZombie || (int)__instance.currentState != 5) { return; } Character component = ((Component)__instance).GetComponent<Character>(); if (!((Object)(object)component == (Object)null)) { component.data.fallSeconds = 0.5f; if (PushStateMethod != null) { PushStateMethod.Invoke(__instance, null); } } } } [BepInPlugin("OvrSlepr.SmartZombies", "Smart Zombies", "1.0.0")] public class SmartZombiesPlugin : BaseUnityPlugin { private Harmony? harmony; internal static SmartZombiesPlugin? Instance { get; private set; } internal static void LogMessage(string message) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)message); } } private void Awake() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown Instance = this; harmony = new Harmony("OvrSlepr.SmartZombies"); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Smart Zombies loaded!"); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Banana peel zombie patch registered."); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Jellyfish zombie patch registered."); } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); harmony = null; } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public sealed class ZombieSeparationController : MonoBehaviour { private const float SeparationHeight = 70f; private const int ZombiesPerWave = 3; private const float CheckInterval = 1f; private const float SpawnRadius = 8f; private readonly List<MushroomZombie> currentWave = new List<MushroomZombie>(); private float nextCheckTime; private static readonly MethodInfo? WakeUpMethod = AccessTools.Method(typeof(MushroomZombie), "WakeUpFromSleep", (Type[])null, (Type[])null); private static readonly MethodInfo? StartChasingMethod = AccessTools.Method(typeof(MushroomZombie), "StartChasing", (Type[])null, (Type[])null); private void Update() { if (!PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient || Time.time < nextCheckTime) { return; } nextCheckTime = Time.time + 1f; currentWave.RemoveAll((MushroomZombie zombie) => (Object)(object)zombie == (Object)null); if (currentWave.Count <= 0) { float heightDifference; Character val = FindHighestPlayer(out heightDifference); if (!((Object)(object)val == (Object)null) && !(heightDifference < 70f)) { SpawnWave(val); } } } private Character? FindHighestPlayer(out float heightDifference) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) heightDifference