Exemplo n.º 1
0
 public void ConfigValidator()
 {
     if (ScpSuicideTollerance < 0)
     {
         Log.Warn("Invalid config scputils_scp_suicide_tollerance, loading dafault one!");
         ScpSuicideTollerance = 5;
     }
     if (AutoKickThreshold >= AutoBanThreshold)
     {
         Log.Warn("Invalid config scputils_auto_kick_threshold OR scputils_auto_ban_threshold, loading dafault one!");
         AutoBanThreshold = 30.5f;
     }
     if (AutoRestartTime < 0)
     {
         Log.Warn("Invalid config scputils_auto_restart_time, loading dafault one!");
         AutoRestartTime = 15;
     }
     if (Scp079TeslaEventWait < 0)
     {
         Log.Warn("Invalid config scputils_scp_079_tesla_event_wait, loading dafault one!");
         Scp079TeslaEventWait = 2;
     }
     if (IgnoreDntRequests)
     {
         Log.Warn("You have set in server configs to ignore Do Not Track requests but that's a violation on Verified Server Rules (if your server is verified) and could cause punishement such as delist [Rule 8.11]");
     }
     if (!IsEnabled)
     {
         Log.Warn("You disabled the plugin in server configs!");
     }
 }
        /// <summary>
        /// Populates <see cref="_filteredSpawns"/> based on <see cref="SpawnSettings"/>
        /// </summary>
        /// <param name="role"></param>
        /// <param name="numberOfPoints"></param>
        public static void FilterSpawns(RoleType role, int numberOfPoints = 1)
        {
            Log.Error($"Filtering spawns for [{role}]");
            // Get spawns for role
            var spawns     = RoleGameObjectDictionary[role];
            var spawnCount = spawns.Count;

            if (spawnCount != 0 && DistanceInfo.TryGetValue(role, out var roleDistances))
            {
                _filteredSpawns = CachedDistances.CalculateSpawns(spawns, roleDistances, numberOfPoints);
            }
            else
            {
                return;
            }

            Log.Error($"Pruned free spawn list from {spawnCount} to {_filteredSpawns.Count}");

            _filteredSpawns.UnityShuffle();
            _filteredSpawnIndex = 0;
            _useFilteredSpawns  = true;
        }
Exemplo n.º 3
0
        private static bool Prefix(PlayerEffect __instance, byte newState)
        {
            try
            {
                if (__instance.Intensity == newState)
                {
                    return(false);
                }

                var ev = new ReceivingEffectEventArgs(API.Features.Player.Get(__instance.Hub.gameObject), __instance, newState, __instance.Intensity);
                Exiled.Events.Handlers.Player.OnReceivingEffect(ev);

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

                byte intensity = ev.CurrentState;
                __instance.Intensity = ev.State;
                if (NetworkServer.active)
                {
                    __instance.Hub.playerEffectsController.Resync();
                }
                __instance.ServerOnIntensityChange(intensity, ev.State);
                if (ev.Duration > 0.0f)
                {
                    Timing.CallDelayed(0.5f, () => __instance.Duration = ev.Duration);
                }
                return(false);
            }
            catch (Exception e)
            {
                Log.Error($"RecievingEffect: {e}");
                return(true);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Prefix of <see cref="Scp079PlayerScript.CallCmdInteract(string, GameObject)"/>.
        /// </summary>
        /// <param name="__instance">The <see cref="Scp079PlayerScript"/> instance.</param>
        /// <param name="command">The command to be executed.</param>
        /// <param name="target">The target game object.</param>
        /// <returns>Returns a value indicating whether the original method has to be executed or not.</returns>
        private static bool Prefix(Scp079PlayerScript __instance, string command, GameObject target)
        {
            try
            {
                if (!__instance._interactRateLimit.CanExecute())
                {
                    return(false);
                }

                if (!__instance.iAm079)
                {
                    return(false);
                }

                Console.AddDebugLog("SCP079", "Command received from a client: " + command, MessageImportance.LessImportant);
                if (!command.Contains(":"))
                {
                    return(false);
                }

                string[] array = command.Split(':');
                __instance.RefreshCurrentRoom();
                if (!__instance.CheckInteractableLegitness(__instance.currentRoom, __instance.currentZone, target, true))
                {
                    return(false);
                }

                List <string> list = ListPool <string> .Shared.Rent();

                ConfigFile.ServerConfig.GetStringCollection("scp079_door_blacklist", list);

                bool result = true;
                switch (array[0])
                {
                case "TESLA":
                {
                    float manaFromLabel = __instance.GetManaFromLabel("Tesla Gate Burst", __instance.abilities);
                    if (manaFromLabel > __instance.curMana)
                    {
                        __instance.RpcNotEnoughMana(manaFromLabel, __instance.curMana);
                        result = false;
                        break;
                    }

                    GameObject gameObject =
                        GameObject.Find(__instance.currentZone + "/" + __instance.currentRoom + "/Gate");
                    if (gameObject != null)
                    {
                        gameObject.GetComponent <TeslaGate>().RpcInstantBurst();
                        __instance.AddInteractionToHistory(gameObject, array[0], true);
                        __instance.Mana -= manaFromLabel;
                    }

                    result = false;
                    break;
                }

                case "DOOR":
                {
                    if (AlphaWarheadController.Host.inProgress)
                    {
                        result = false;
                        break;
                    }

                    if (target == null)
                    {
                        Console.AddDebugLog("SCP079", "The door command requires a target.", MessageImportance.LessImportant);
                        result = false;
                        break;
                    }

                    Door component = target.GetComponent <Door>();
                    if (component == null)
                    {
                        result = false;
                        break;
                    }

                    if (list != null && list.Count > 0 && list != null && list.Contains(component.DoorName))
                    {
                        Console.AddDebugLog("SCP079", "Door access denied by the server.", MessageImportance.LeastImportant);
                        result = false;
                        break;
                    }

                    float manaFromLabel = __instance.GetManaFromLabel(
                        "Door Interaction " + (string.IsNullOrEmpty(component.permissionLevel)
                                    ? "DEFAULT"
                                    : component.permissionLevel), __instance.abilities);
                    if (manaFromLabel > __instance.curMana)
                    {
                        Console.AddDebugLog("SCP079", "Not enough mana.", MessageImportance.LeastImportant);
                        __instance.RpcNotEnoughMana(manaFromLabel, __instance.curMana);
                        result = false;
                        break;
                    }

                    if (component != null && component.ChangeState079())
                    {
                        __instance.Mana -= manaFromLabel;
                        __instance.AddInteractionToHistory(target, array[0], true);
                        Console.AddDebugLog("SCP079", "Door state changed.", MessageImportance.LeastImportant);
                        result = true;
                        break;
                    }

                    Console.AddDebugLog("SCP079", "Door state failed to change.", MessageImportance.LeastImportant);
                    result = false;
                    break;
                }

                default:
                    result = true;
                    break;
                }

                ListPool <string> .Shared.Return(list);

                return(result);
            }
            catch (Exception e)
            {
                Log.Error($"Exiled.Events.Patches.Events.Scp079.Interacting: {e}\n{e.StackTrace}");

                return(true);
            }
        }