Пример #1
0
        private static bool Prefix(PlayableScps.Scp049 __instance, byte num, GameObject go)
        {
            try
            {
                if (num == 2)
                {
                    if (!__instance._interactRateLimit.CanExecute() || go == null)
                    {
                        return(false);
                    }

                    Ragdoll component = go.GetComponent <Ragdoll>();
                    if (component == null)
                    {
                        return(false);
                    }

                    ReferenceHub referenceHub = null;
                    foreach (GameObject player in PlayerManager.players)
                    {
                        ReferenceHub hub = ReferenceHub.GetHub(player);
                        if (hub.queryProcessor.PlayerId == component.owner.PlayerId)
                        {
                            referenceHub = hub;
                            break;
                        }
                    }

                    if (referenceHub == null)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; no target found", MessageImportance.LessImportant);
                        return(false);
                    }

                    if (!__instance._recallInProgressServer ||
                        referenceHub.gameObject != __instance._recallObjectServer ||
                        __instance._recallProgressServer < 0.85f)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; Debug code: ", MessageImportance.LessImportant);
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#1 " + (__instance._recallInProgressServer ? "<color=green>PASSED</color>" : ("<color=red>ERROR</color> - " + __instance._recallInProgressServer)), MessageImportance.LessImportant, true);
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#2 " + ((referenceHub.gameObject == __instance._recallObjectServer) ? "<color=green>PASSED</color>" : string.Concat("<color=red>ERROR</color> - ", referenceHub.queryProcessor.PlayerId, "-", (__instance._recallObjectServer == null) ? "null" : ReferenceHub.GetHub(__instance._recallObjectServer).queryProcessor.PlayerId.ToString())), MessageImportance.LessImportant);
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#3 " + ((__instance._recallProgressServer >= 0.85f) ? "<color=green>PASSED</color>" : ("<color=red>ERROR</color> - " + __instance._recallProgressServer)), MessageImportance.LessImportant, true);
                        return(false);
                    }

                    if (referenceHub.characterClassManager.CurClass != RoleType.Spectator)
                    {
                        return(false);
                    }

                    var ev = new FinishingRecallEventArgs(API.Features.Player.Get(referenceHub.gameObject), API.Features.Player.Get(__instance.Hub.gameObject));

                    Handlers.Scp049.OnFinishingRecall(ev);

                    if (!ev.IsAllowed)
                    {
                        return(false);
                    }

                    Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' accepted", MessageImportance.LessImportant);
                    RoundSummary.changed_into_zombies++;
                    referenceHub.characterClassManager.SetClassID(RoleType.Scp0492);
                    referenceHub.GetComponent <PlayerStats>().Health =
                        referenceHub.characterClassManager.Classes.Get(RoleType.Scp0492).maxHP;
                    if (component.CompareTag("Ragdoll"))
                    {
                        NetworkServer.Destroy(component.gameObject);
                    }

                    __instance._recallInProgressServer = false;
                    __instance._recallObjectServer     = null;
                    __instance._recallProgressServer   = 0f;
                    return(false);
                }

                if (num != 1)
                {
                    return(true);
                }
                {
                    if (!__instance._interactRateLimit.CanExecute())
                    {
                        return(false);
                    }

                    if (go == null)
                    {
                        return(false);
                    }

                    Ragdoll component2 = go.GetComponent <Ragdoll>();
                    if (component2 == null)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object is not a dead body", MessageImportance.LessImportant);
                        return(false);
                    }

                    if (!component2.allowRecall)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object can't be recalled", MessageImportance.LessImportant);
                        return(false);
                    }

                    ReferenceHub referenceHub2 = null;
                    foreach (GameObject player2 in PlayerManager.players)
                    {
                        ReferenceHub hub2 = ReferenceHub.GetHub(player2);
                        if (hub2 != null && hub2.queryProcessor.PlayerId == component2.owner.PlayerId)
                        {
                            referenceHub2 = hub2;
                            break;
                        }
                    }

                    if (referenceHub2 == null)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; target not found", MessageImportance.LessImportant);
                        return(false);
                    }

                    if (Vector3.Distance(component2.transform.position, __instance.Hub.PlayerCameraReference.transform.position) >=
                        PlayableScps.Scp049.ReviveDistance * 1.3f)
                    {
                        return(false);
                    }

                    var ev = new StartingRecallEventArgs(API.Features.Player.Get(referenceHub2.gameObject), API.Features.Player.Get(__instance.Hub.gameObject));

                    Handlers.Scp049.OnStartingRecall(ev);

                    if (!ev.IsAllowed)
                    {
                        return(false);
                    }

                    Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' accepted", MessageImportance.LessImportant);
                    __instance._recallObjectServer     = referenceHub2.gameObject;
                    __instance._recallProgressServer   = 0f;
                    __instance._recallInProgressServer = true;
                    return(false);
                }
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Scp049.StartingAndFinishingRecall: {e}\n{e.StackTrace}");

                return(true);
            }
        }
Пример #2
0
        public static bool Prefix(Scp079PlayerScript __instance, string command, GameObject target)
        {
            if (EventPlugin.Scp079TriggerTeslaPatchDisable)
            {
                return(true);
            }

            try
            {
                if (!__instance._interactRateLimit.CanExecute() || !__instance.iAm079)
                {
                    return(false);
                }
                Console.AddDebugLog("SCP079", "Command received from a client: " + command,
                                    MessageImportance.LessImportant);
                if (!command.Contains(":"))
                {
                    return(false);
                }
                string[] strArray = command.Split(':');
                __instance.RefreshCurrentRoom();
                if (!__instance.CheckInteractableLegitness(__instance.currentRoom, __instance.currentZone, target,
                                                           true))
                {
                    return(false);
                }

                string s = strArray[0];

                if (s != "TESLA")
                {
                    return(true);
                }
                float manaFromLabel2 = __instance.GetManaFromLabel("Tesla Gate Burst", __instance.abilities);
                if (manaFromLabel2 > (double)__instance.curMana)
                {
                    __instance.RpcNotEnoughMana(manaFromLabel2, __instance.curMana);
                    return(false);
                }

                GameObject go1 = GameObject.Find(__instance.currentZone + "/" + __instance.currentRoom + "/Gate");
                if (!(go1 != null))
                {
                    return(false);
                }

                bool allow = true;
                Events.InvokeScp079TriggerTesla(__instance.gameObject, ref allow);
                if (!allow)
                {
                    return(false);
                }

                go1.GetComponent <TeslaGate>().RpcInstantBurst();
                __instance.AddInteractionToHistory(go1, strArray[0], true);
                __instance.Mana -= manaFromLabel2;
                return(false);
            }
            catch (Exception exception)
            {
                Log.Error($"Scp079TriggerTeslaEvent error: {exception}");
                return(true);
            }
        }
Пример #3
0
        private static bool Prefix(PlayableScps.Scp049 __instance, byte num, GameObject go)
        {
            try
            {
                switch (num)
                {
                case 1:
                {
                    if (!__instance._interactRateLimit.CanExecute())
                    {
                        return(false);
                    }

                    if (go == null)
                    {
                        return(false);
                    }

                    Ragdoll component2 = go.GetComponent <Ragdoll>();
                    if (component2 == null)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object is not a dead body", MessageImportance.LessImportant);
                        return(false);
                    }

                    if (!component2.allowRecall)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object can't be recalled", MessageImportance.LessImportant);
                        return(false);
                    }

                    if (component2.CurrentTime > Scp049.ReviveEligibilityDuration)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; provided object has decayed too far", MessageImportance.LessImportant);
                        return(false);
                    }

                    // Removed useless FOREACH
                    ReferenceHub referenceHub2 = ReferenceHub.GetHub(component2.owner.PlayerId);

                    if (referenceHub2 == null)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; target not found", MessageImportance.LessImportant);
                        return(false);
                    }

                    bool        flag = false;
                    Rigidbody[] componentsInChildren = component2.GetComponentsInChildren <Rigidbody>();
                    for (int i = 0; i < componentsInChildren.Length; i++)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' accepted", MessageImportance.LessImportant);

                        if (Vector3.Distance(componentsInChildren[i].transform.position, __instance.Hub.PlayerCameraReference.transform.position) <= Scp049.ReviveDistance * 1.3f)
                        {
                            flag = true;
                            referenceHub2.characterClassManager.NetworkDeathPosition = __instance.Hub.playerMovementSync.RealModelPosition;
                            break;
                        }
                    }

                    if (!flag)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP - 049 | Request 'start recalling' rejected; Distance was too great.", MessageImportance.LessImportant);
                        break;
                    }

                    var ev = new StartingRecallEventArgs(API.Features.Player.Get(referenceHub2.gameObject), API.Features.Player.Get(__instance.Hub.gameObject));

                    Handlers.Scp049.OnStartingRecall(ev);

                    if (!ev.IsAllowed)
                    {
                        return(false);
                    }

                    Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' accepted", MessageImportance.LessImportant);
                    __instance._recallObjectServer     = referenceHub2.gameObject;
                    __instance._recallProgressServer   = 0f;
                    __instance._recallInProgressServer = true;
                    return(false);
                }

                case 2:
                {
                    if (!__instance._interactRateLimit.CanExecute() || go == null)
                    {
                        return(false);
                    }

                    Ragdoll component = go.GetComponent <Ragdoll>();
                    if (component == null)
                    {
                        return(false);
                    }

                    ReferenceHub referenceHub = null;
                    foreach (GameObject player in PlayerManager.players)
                    {
                        ReferenceHub hub = ReferenceHub.GetHub(player);
                        if (hub.queryProcessor.PlayerId == component.owner.PlayerId)
                        {
                            referenceHub = hub;
                            break;
                        }
                    }

                    if (referenceHub == null)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; no target found", MessageImportance.LessImportant);
                        return(false);
                    }

                    if (!__instance._recallInProgressServer ||
                        referenceHub.gameObject != __instance._recallObjectServer ||
                        __instance._recallProgressServer < 0.85f)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; Debug code: ", MessageImportance.LessImportant);
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#1 " + (__instance._recallInProgressServer ? "<color=green>PASSED</color>" : ("<color=red>ERROR</color> - " + __instance._recallInProgressServer)), MessageImportance.LessImportant, true);
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#2 " + ((referenceHub.gameObject == __instance._recallObjectServer) ? "<color=green>PASSED</color>" : string.Concat("<color=red>ERROR</color> - ", referenceHub.queryProcessor.PlayerId, "-", (__instance._recallObjectServer == null) ? "null" : ReferenceHub.GetHub(__instance._recallObjectServer).queryProcessor.PlayerId.ToString())), MessageImportance.LessImportant);
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | CONDITION#3 " + ((__instance._recallProgressServer >= 0.85f) ? "<color=green>PASSED</color>" : ("<color=red>ERROR</color> - " + __instance._recallProgressServer)), MessageImportance.LessImportant, true);
                        return(false);
                    }

                    if (referenceHub.characterClassManager.CurClass != RoleType.Spectator)
                    {
                        return(false);
                    }

                    var ev = new FinishingRecallEventArgs(API.Features.Player.Get(referenceHub.gameObject), API.Features.Player.Get(__instance.Hub.gameObject));

                    Handlers.Scp049.OnFinishingRecall(ev);

                    if (!ev.IsAllowed)
                    {
                        return(false);
                    }

                    Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' accepted", MessageImportance.LessImportant);
                    RoundSummary.changed_into_zombies++;
                    referenceHub.characterClassManager.SetClassID(RoleType.Scp0492);
                    referenceHub.GetComponent <PlayerStats>().Health =
                        referenceHub.characterClassManager.Classes.Get(RoleType.Scp0492).maxHP;
                    if (component.CompareTag("Ragdoll"))
                    {
                        NetworkServer.Destroy(component.gameObject);
                    }

                    __instance._recallInProgressServer = false;
                    __instance._recallObjectServer     = null;
                    __instance._recallProgressServer   = 0f;
                    return(false);
                }

                default:
                    return(true);
                }

                return(false);
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"Exiled.Events.Patches.Events.Scp049.StartingAndFinishingRecall: {e}\n{e.StackTrace}");

                return(true);
            }
        }
Пример #4
0
        // ReSharper disable once InconsistentNaming
        public static bool Prefix(Scp049 __instance, ref byte num, ref GameObject go)
        {
            try
            {
                if (num == 0)
                {
                    if (!__instance._interactRateLimit.CanExecute())
                    {
                        return(false);
                    }
                    if (go == null)
                    {
                        return(false);
                    }
                    if (Vector3.Distance(go.transform.position, __instance.Hub.playerMovementSync.RealModelPosition) >=
                        Scp049.AttackDistance * 1.25f)
                    {
                        return(false);
                    }
                    __instance.Hub.playerStats.HurtPlayer(
                        new PlayerStats.HitInfo(4949f,
                                                __instance.Hub.nicknameSync.MyNick + " (" + __instance.Hub.characterClassManager.UserId +
                                                ")", DamageTypes.Scp049, __instance.Hub.queryProcessor.PlayerId), go);
                    Console.AddDebugLog("SCPCTRL", "SCP-049 | Sent 'death time' RPC", MessageImportance.LessImportant);
                    __instance.Hub.scpsController.RpcTransmit_Byte(0);
                    return(false);
                }

                if (num != 1)
                {
                    if (num != 2)
                    {
                        return(false);
                    }
                    if (!__instance._interactRateLimit.CanExecute())
                    {
                        return(false);
                    }
                    if (go == null)
                    {
                        return(false);
                    }
                    var component = go.GetComponent <Ragdoll>();
                    if (component == null)
                    {
                        return(false);
                    }
                    var target = PlayerManager.players.Select(ReferenceHub.GetHub)
                                 .FirstOrDefault(hub => hub.queryProcessor.PlayerId == component.owner.PlayerId).GetPlayer();
                    if (target == null)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; no target found",
                                            MessageImportance.LessImportant);
                        return(false);
                    }

                    if (!__instance._recallInProgressServer ||
                        target.gameObject != __instance._recallObjectServer ||
                        __instance._recallProgressServer < 0.85f)
                    {
                        Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' rejected; Debug code: ",
                                            MessageImportance.LessImportant);
                        Console.AddDebugLog("SCPCTRL",
                                            "SCP-049 | CONDITION#1 " + (__instance._recallInProgressServer
                                ? "<color=green>PASSED</color>"
                                : "<color=red>ERROR</color> - " + __instance._recallInProgressServer),
                                            MessageImportance.LessImportant, true);
                        Console.AddDebugLog("SCPCTRL",
                                            "SCP-049 | CONDITION#2 " + (target == __instance._recallObjectServer
                                ? "<color=green>PASSED</color>"
                                : string.Concat("<color=red>ERROR</color> - ", target.PlayerId,
                                                "-",
                                                __instance._recallObjectServer == null
                                        ? "null"
                                        : ReferenceHub.GetHub(__instance._recallObjectServer).queryProcessor.PlayerId
                                                .ToString())), MessageImportance.LessImportant);
                        Console.AddDebugLog("SCPCTRL",
                                            "SCP-049 | CONDITION#3 " + (__instance._recallProgressServer >= 0.85f
                                ? "<color=green>PASSED</color>"
                                : "<color=red>ERROR</color> - " + __instance._recallProgressServer),
                                            MessageImportance.LessImportant, true);
                        return(false);
                    }

                    if (target.Hub.characterClassManager.CurClass != RoleType.Spectator)
                    {
                        return(false);
                    }

                    //Event
                    var   allow = true;
                    var   role  = RoleType.Scp0492;
                    float live  = target.Hub.characterClassManager.Classes.Get(RoleType.Scp0492).maxHP;
                    Events.InvokeScp049RecallEvent(__instance.Hub.GetPlayer(), ref component, ref target, ref allow, ref role,
                                                   ref live);

                    Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'finish recalling' accepted",
                                        MessageImportance.LessImportant);
                    RoundSummary.changed_into_zombies++;

                    var pos3 = component.transform.position;
                    pos3.y     += 2;
                    target.Role = role;
                    Timing.CallDelayed(0.5f, () => target.Position = pos3);
                    target.GetComponent <PlayerStats>().Health     = live;
                    if (component.CompareTag("Ragdoll"))
                    {
                        NetworkServer.Destroy(component.gameObject);
                    }
                    __instance._recallInProgressServer = false;
                    __instance._recallObjectServer     = null;
                    __instance._recallProgressServer   = 0f;
                    return(false);
                }

                if (!__instance._interactRateLimit.CanExecute())
                {
                    return(false);
                }
                if (go == null)
                {
                    return(false);
                }
                var component2 = go.GetComponent <Ragdoll>();
                if (component2 == null)
                {
                    Console.AddDebugLog("SCPCTRL",
                                        "SCP-049 | Request 'start recalling' rejected; provided object is not a dead body",
                                        MessageImportance.LessImportant);
                    return(false);
                }

                if (!component2.allowRecall)
                {
                    Console.AddDebugLog("SCPCTRL",
                                        "SCP-049 | Request 'start recalling' rejected; provided object can't be recalled",
                                        MessageImportance.LessImportant);
                    return(false);
                }

                var referenceHub2 = PlayerManager.players.Select(ReferenceHub.GetHub).FirstOrDefault(hub2 =>
                                                                                                     hub2 != null && hub2.queryProcessor.PlayerId == component2.owner.PlayerId);
                if (referenceHub2 == null)
                {
                    Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' rejected; target not found",
                                        MessageImportance.LessImportant);
                    return(false);
                }

                if (Vector3.Distance(component2.transform.position,
                                     __instance.Hub.PlayerCameraReference.transform.position) >=
                    Scp049.ReviveDistance * 1.3f)
                {
                    return(false);
                }
                Console.AddDebugLog("SCPCTRL", "SCP-049 | Request 'start recalling' accepted",
                                    MessageImportance.LessImportant);
                __instance._recallObjectServer     = referenceHub2.gameObject;
                __instance._recallProgressServer   = 0f;
                __instance._recallInProgressServer = true;

                return(false);
            }
            catch (Exception e)
            {
                Log.Error($"Scp049RecallEvent Error: {e}");
                return(true);
            }
        }