Example #1
0
        public override void OnEnable()
        {
            if (!Config.GetBool("util_enable", true))
            {
                return;
            }

            Info("Loading Common-Utils, created by the EXILED Team!");

            Instance = this;

            HarmonyInstance = HarmonyInstance.Create("exiled.common.utils");
            HarmonyInstance.PatchAll();

            bool enable914Configs = Config.GetBool("util_914_enable", true);

            if (enable914Configs)
            {
                Dictionary <string, string> configHealth = KConf.ExiledConfiguration.GetDictonaryValue(Config.GetString("util_role_health", "NtfCommander:400,NtfScientist:350"));

                try
                {
                    foreach (KeyValuePair <string, string> kvp in configHealth)
                    {
                        roleHealth.Add((RoleType)Enum.Parse(typeof(RoleType), kvp.Key), int.Parse(kvp.Value));
                        DebugBoi(kvp.Key + "'s default health is now: " + kvp.Value);
                    }
                    Info("Loaded " + configHealth.Keys.Count() + "('s) default health classes.");
                }
                catch (Exception e)
                {
                    Error("Failed to add custom health to roles. Check your 'util_role_health' config values for errors!\n" + e);
                }

                Dictionary <string, string> configRoles =
                    KConf.ExiledConfiguration.GetDictonaryValue(Config.GetString("util_914_roles", ""));
                try
                {
                    foreach (KeyValuePair <string, string> kvp in configRoles)
                    {
                        scp914Roles.Add(Scp914PlayerUpgrade.ParseString(kvp.Key),
                                        (Scp914Knob)Enum.Parse(typeof(Scp914Knob), kvp.Value));
                    }

                    Info("Loaded " + configRoles.Count + "('s) custom 914 upgrade classes.");
                }
                catch (Exception e)
                {
                    Error($"Failed to parse 914 role upgrade settings. {e}");
                }



                Dictionary <string, string> configItems = KConf.ExiledConfiguration.GetDictonaryValue(Config.GetString("util_914_items", "Painkillers-Medkit:Fine,Coin-Flashlight:OneToOne"));

                try
                {
                    foreach (KeyValuePair <string, string> kvp in configItems)
                    {
                        scp914Items.Add(Scp914ItemUpgrade.ParseString(kvp.Key), (Scp914Knob)Enum.Parse(typeof(Scp914Knob), kvp.Value));
                    }

                    Info("Loaded " + configItems.Count + "('s) custom 914 recipes.");
                }
                catch (Exception e)
                {
                    Error("Failed to add items to 914. Check your 'util_914_items' config values for errors!\n" + e);
                }
            }

            bool enableCustomInv = Config.GetBool("util_enable_inventories", false);

            if (enableCustomInv)
            {
                // Custom items
                try
                {
                    Inventories               = new CustomInventory();
                    Inventories.ClassD        = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_classd_inventory", null)));
                    Inventories.Chaos         = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_chaos_inventory", null)));
                    Inventories.NtfCadet      = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_ntfcadet_inventory", null)));
                    Inventories.NtfCommander  = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_ntfcommander_inventory", null)));
                    Inventories.NtfLieutenant = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_ntflieutenant_inventory", null)));
                    Inventories.NtfScientist  = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_ntfscientist_inventory", null)));
                    Inventories.Scientist     = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_scientist_inventory", null)));
                    Inventories.Guard         = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_guard_inventory", null)));
                    Info("Loaded Inventories.");
                }
                catch (Exception e)
                {
                    Error("Failed to add items to custom inventories! Check your inventory config values for errors!\n[EXCEPTION] For Developers:\n" + e);
                    return;
                }
            }

            bool upgradeHeldItems = Config.GetBool("util_914_upgrade_hand", true);

            bool enableBroadcasting = Config.GetBool("util_broadcast_enable", true);

            string broadcastMessage = Config.GetString("util_broadcast_message", "<color=lime>This server is running <b><color=red>EXILED-CommonUtils</color></b>, enjoy playing!</color>");

            int boradcastSeconds = Config.GetInt("util_broadcast_seconds", 300); // 300 is 5 minutes. :D
            int boradcastTime    = Config.GetInt("util_broadcast_time", 4);

            string joinMessage     = Config.GetString("util_joinMessage", "<color=lime>Welcome <b>%player%</b>! <i>Please read our rules!</i></color>");
            int    joinMessageTime = Config.GetInt("util_joinMessage_time", 6); // 6 seconds duhhhhh

            bool enableAutoNuke = Config.GetBool("util_enable_autonuke", false);

            int   autoNukeTime      = Config.GetInt("util_autonuke_time", 600); // 600 seconds is 10 minutes.
            bool  clearRagdolls     = Config.GetBool("util_cleanup_ragdolls", true);
            float clearRagdollTimer = Config.GetFloat("util_cleanup_interval", 250f);
            bool  clearOnlyPocket   = Config.GetBool("util_cleanup_only_pocket", false);
            bool  clearItems        = Config.GetBool("util_cleanup_items", true);

            EventHandler = new EventHandlers(upgradeHeldItems, scp914Roles, scp914Items, roleHealth, broadcastMessage, joinMessage, boradcastTime, boradcastSeconds, joinMessageTime, Inventories, autoNukeTime, enableAutoNuke, enable914Configs, enableBroadcasting, enableCustomInv, clearRagdolls, clearRagdollTimer, clearOnlyPocket, clearItems)
            {
                LockAutoNuke = Config.GetBool("util_autonuke_lock", false)
            };
            Events.PlayerJoinEvent        += EventHandler.PlayerJoin;
            Events.Scp914UpgradeEvent     += EventHandler.SCP914Upgrade;
            Events.RoundStartEvent        += EventHandler.RoundStart;
            Events.RoundEndEvent          += EventHandler.OnRoundEnd;
            Events.WaitingForPlayersEvent += EventHandler.OnWaitingForPlayers;

            Info("Common-Utils Loaded! Created by the EXILED Team.");

            if (!enableBroadcasting)
            {
                return;
            }

            cor = Timing.RunCoroutine(EventHandler.CustomBroadcast());
        }
Example #2
0
        public override void OnEnable()
        {
            if (!Config.GetBool("util_enable", true))
            {
                return;
            }

            Log.Info("Loading Common-Utils, created by the EXILED Team!");

            Instance = this;

            HarmonyInstance = HarmonyInstance.Create($"exiled.common.utils-{PatchCounter}");
            PatchCounter++;
            HarmonyInstance.PatchAll();

            bool enable914Configs = Config.GetBool("util_914_enable", true);

            try
            {
                List <string> teslaIgnoredStrings =
                    KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_tesla_ignores", "Tutorial"));

                foreach (string s in teslaIgnoredStrings)
                {
                    RoleType type = (RoleType)Enum.Parse(typeof(RoleType), s);
                    if (!TeslaIgnoredRoles.Contains(type))
                    {
                        TeslaIgnoredRoles.Add(type);
                    }
                }
            }
            catch (Exception e)
            {
                Log.Error($"Tesla ignored roles error: {e}");
            }

            if (enable914Configs)
            {
                Dictionary <string, string> configHealth = KConf.ExiledConfiguration.GetDictonaryValue(Config.GetString("util_role_health", "NtfCommander:400,NtfScientist:350"));

                try
                {
                    foreach (KeyValuePair <string, string> kvp in configHealth)
                    {
                        roleHealth.Add((RoleType)Enum.Parse(typeof(RoleType), kvp.Key), int.Parse(kvp.Value));
                        DebugBoi(kvp.Key + "'s default health is now: " + kvp.Value);
                    }
                    Log.Info("Loaded " + configHealth.Keys.Count() + "('s) default health classes.");
                }
                catch (Exception e)
                {
                    Log.Error("Failed to add custom health to roles. Check your 'util_role_health' config values for errors!\n" + e);
                }

                Dictionary <string, string> configRoles =
                    KConf.ExiledConfiguration.GetDictonaryValue(Config.GetString("util_914_roles", ""));
                try
                {
                    foreach (KeyValuePair <string, string> kvp in configRoles)
                    {
                        scp914Roles.Add(Scp914PlayerUpgrade.ParseString(kvp.Key),
                                        (Scp914Knob)Enum.Parse(typeof(Scp914Knob), kvp.Value));
                    }

                    Log.Info("Loaded " + configRoles.Count + "('s) custom 914 upgrade classes.");
                }
                catch (Exception e)
                {
                    Log.Error($"Failed to parse 914 role upgrade settings. {e}");
                }



                Dictionary <string, string> configItems = KConf.ExiledConfiguration.GetDictonaryValue(Config.GetString("util_914_items", "Painkillers-Medkit:Fine,Coin-Flashlight:OneToOne"));

                try
                {
                    foreach (KeyValuePair <string, string> kvp in configItems)
                    {
                        scp914Items.Add(Scp914ItemUpgrade.ParseString(kvp.Key), (Scp914Knob)Enum.Parse(typeof(Scp914Knob), kvp.Value));
                    }

                    Log.Info("Loaded " + configItems.Count + "('s) custom 914 recipes.");
                }
                catch (Exception e)
                {
                    Log.Error("Failed to add items to 914. Check your 'util_914_items' config values for errors!\n" + e);
                }
            }

            bool enableCustomInv = Config.GetBool("util_enable_inventories", false);

            EnableRandomInv = Config.GetBool("util_enable_random_chances", false);

            if (enableCustomInv)
            {
                // Custom items
                try
                {
                    Inventories = new CustomInventory();

                    if (EnableRandomInv)
                    {
                        Dictionary <string, int> classD =
                            KConf.ExiledConfiguration.GetRandomListValue(
                                Config.GetString("util_classd_inventory", null));
                        Dictionary <string, int> chaos =
                            KConf.ExiledConfiguration.GetRandomListValue(
                                Config.GetString("util_chaos_inventory", null));
                        Dictionary <string, int> sci =
                            KConf.ExiledConfiguration.GetRandomListValue(
                                Config.GetString("util_scientist_inventory", null));
                        Dictionary <string, int> cadet =
                            KConf.ExiledConfiguration.GetRandomListValue(
                                Config.GetString("util_ntfcadet_inventory", null));
                        Dictionary <string, int> lt =
                            KConf.ExiledConfiguration.GetRandomListValue(
                                Config.GetString("util_ntflieutenant_inventory", null));
                        Dictionary <string, int> cmd =
                            KConf.ExiledConfiguration.GetRandomListValue(
                                Config.GetString("util_ntfcommander_inventory", null));
                        Dictionary <string, int> guard =
                            KConf.ExiledConfiguration.GetRandomListValue(
                                Config.GetString("util_guard_inventory", null));
                        Dictionary <string, int> ntfSci =
                            KConf.ExiledConfiguration.GetRandomListValue(
                                Config.GetString("util_ntfscientist_inventory", null));

                        Inventories.ClassDRan    = CustomInventory.ConvertToRandomItemList(classD);
                        Inventories.ChaosRan     = CustomInventory.ConvertToRandomItemList(chaos);
                        Inventories.ScientistRan = CustomInventory.ConvertToRandomItemList(sci);
                        Inventories.NtfCadetRan  = CustomInventory.ConvertToRandomItemList(cadet);
                        Inventories.NtfLtRan     = CustomInventory.ConvertToRandomItemList(lt);
                        Inventories.NtfCmdRan    = CustomInventory.ConvertToRandomItemList(cmd);
                        Inventories.NtfSciRan    = CustomInventory.ConvertToRandomItemList(ntfSci);
                        Inventories.GuardRan     = CustomInventory.ConvertToRandomItemList(guard);
                    }
                    else
                    {
                        Inventories.ClassD = CustomInventory.ConvertToItemList(
                            KConf.ExiledConfiguration.GetListStringValue(
                                Config.GetString("util_classd_inventory", null)));
                        Inventories.Chaos = CustomInventory.ConvertToItemList(
                            KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_chaos_inventory",
                                                                                          null)));
                        Inventories.NtfCadet = CustomInventory.ConvertToItemList(
                            KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_ntfcadet_inventory",
                                                                                          null)));
                        Inventories.NtfCommander = CustomInventory.ConvertToItemList(
                            KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_ntfcommander_inventory",
                                                                                          null)));
                        Inventories.NtfLieutenant = CustomInventory.ConvertToItemList(
                            KConf.ExiledConfiguration.GetListStringValue(
                                Config.GetString("util_ntflieutenant_inventory", null)));
                        Inventories.NtfScientist = CustomInventory.ConvertToItemList(
                            KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_ntfscientist_inventory",
                                                                                          null)));
                        Inventories.Scientist = CustomInventory.ConvertToItemList(
                            KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_scientist_inventory",
                                                                                          null)));
                        Inventories.Guard = CustomInventory.ConvertToItemList(
                            KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_guard_inventory",
                                                                                          null)));
                    }

                    Log.Info("Loaded Inventories.");
                }
                catch (Exception e)
                {
                    Log.Error("Failed to add items to custom inventories! Check your inventory config values for errors!\n[EXCEPTION] For Developers:\n" + e);
                    return;
                }
            }

            bool upgradeHeldItems = Config.GetBool("util_914_upgrade_hand", true);

            bool   enableBroadcasting = Config.GetBool("util_broadcast_enable", false); //nobody wants this true on default -rin
            string broadcastMessage   = Config.GetString("util_broadcast_message", "<color=lime>This server is running <b><color=red>EXILED-CommonUtils</color></b>, enjoy playing!</color>");

            int boradcastSeconds = Config.GetInt("util_broadcast_seconds", 300); // 300 is 5 minutes. :D
            int boradcastTime    = Config.GetInt("util_broadcast_time", 4);

            bool   enableJoinmessage = Config.GetBool("util_joinmessage_enable", true);
            string joinMessage       = Config.GetString("util_joinMessage", "<color=lime>Welcome <b>%player%</b>! <i>Please read our rules!</i></color>");
            int    joinMessageTime   = Config.GetInt("util_joinMessage_time", 6); // 6 seconds duhhhhh

            bool enableAutoNuke = Config.GetBool("util_enable_autonuke", false);

            int   autoNukeTime      = Config.GetInt("util_autonuke_time", 600); // 600 seconds is 10 minutes.
            bool  clearRagdolls     = Config.GetBool("util_cleanup_ragdolls", true);
            float clearRagdollTimer = Config.GetFloat("util_cleanup_interval", 250f);
            bool  clearOnlyPocket   = Config.GetBool("util_cleanup_only_pocket", false);
            bool  clearItems        = Config.GetBool("util_cleanup_items", true);

            Scp049Healing     = Config.GetBool("util_049_healing", true);
            Scp049HealAmount  = Config.GetInt("util_049_heal_amount", 25);
            Scp049HealPow     = Config.GetFloat("util_049_heal_power", 1.25f);
            Scp0492Healing    = Config.GetBool("util_0492_healing", true);
            Scp0492HealAmount = Config.GetInt("util_0492_heal_amount", 25);
            Scp096Healing     = Config.GetBool("util_096_healing", true);
            Scp096Heal        = Config.GetInt("util_096_heal_amount", 150);
            Scp106Healing     = Config.GetBool("util_106_healing", true);
            Scp106HealAmount  = Config.GetInt("util_106_heal_amount", 75);
            Scp173Healing     = Config.GetBool("util_173_healing", true);
            Scp173HealAmount  = Config.GetInt("util_173_heal_amount", 150);
            Scp939Healing     = Config.GetBool("util_939_healing", true);
            Scp939Heal        = Config.GetInt("util_939_heal_amount", 125);


            EventHandler = new EventHandlers(upgradeHeldItems, scp914Roles, scp914Items, roleHealth, broadcastMessage, joinMessage, boradcastTime, boradcastSeconds, joinMessageTime, Inventories, autoNukeTime, enableAutoNuke, enable914Configs, enableJoinmessage, enableBroadcasting, enableCustomInv, clearRagdolls, clearRagdollTimer, clearOnlyPocket, TeslaIgnoredRoles, clearItems)
            {
                LockAutoNuke = Config.GetBool("util_autonuke_lock", false)
            };
            Events.PlayerJoinEvent        += EventHandler.PlayerJoin;
            Events.Scp914UpgradeEvent     += EventHandler.SCP914Upgrade;
            Events.RoundStartEvent        += EventHandler.RoundStart;
            Events.PlayerSpawnEvent       += EventHandler.OnPlayerSpawn;
            Events.RoundEndEvent          += EventHandler.OnRoundEnd;
            Events.WaitingForPlayersEvent += EventHandler.OnWaitingForPlayers;
            Events.TriggerTeslaEvent      += EventHandler.OnTriggerTesla;
            Events.PlayerDeathEvent       += EventHandler.OnPlayerDeath;
            Events.PocketDimDeathEvent    += EventHandler.OnPocketDeath;
            Events.Scp096EnrageEvent      += EventHandler.OnEnrage;
            Events.Scp096CalmEvent        += EventHandler.OnCalm;
            Events.PlayerHurtEvent        += EventHandler.OnPlayerHurt;

            Log.Info("Common-Utils Loaded! Created by the EXILED Team.");

            if (!enableBroadcasting)
            {
                return;
            }

            cor = Timing.RunCoroutine(EventHandler.CustomBroadcast());
        }
Example #3
0
        public override void OnEnable()
        {
            if (!Config.GetBool("util_enable", true))
            {
                return;
            }

            Info("Loading Common-Utils, created by the EXILED Team!");

            Dictionary <string, string> configHealth = KConf.ExiledConfiguration.GetDictonaryValue(Config.GetString("util_role_health", "NtfCommander:400,NtfScientist:350"));

            try
            {
                foreach (KeyValuePair <string, string> kvp in configHealth)
                {
                    roleHealth.Add((RoleType)Enum.Parse(typeof(RoleType), kvp.Key), int.Parse(kvp.Value));
                }
            }
            catch (Exception e)
            {
                Error("Failed to add custom health to roles. Check your 'util_role_health' config values for errors!\n" + e);
                return;
            }

            Info("Loaded " + configHealth.Count() + "('s) default health classes.");

            Dictionary <string, string> configRoles =
                KConf.ExiledConfiguration.GetDictonaryValue(Config.GetString("util_914_roles", ""));

            try
            {
                foreach (KeyValuePair <string, string> kvp in configRoles)
                {
                    scp914Roles.Add(Scp914PlayerUpgrade.ParseString(kvp.Key), (Scp914Knob)Enum.Parse(typeof(Scp914Knob), kvp.Value));
                    Info($"Loaded {kvp.Key} - {kvp.Value} custom 914 upgrade");
                }
            }
            catch (Exception e)
            {
                Error($"Failed to parse 914 role upgrade settings. {e}");
                return;
            }

            Info("Loaded " + configRoles.Count + "('s) custom 914 upgrade classes.");

            Dictionary <string, string> configItems = KConf.ExiledConfiguration.GetDictonaryValue(Config.GetString("util_914_items", "Painkillers-Medkit:Fine,Coin-Flashlight:OneToOne"));

            try
            {
                foreach (KeyValuePair <string, string> kvp in configItems)
                {
                    scp914Items.Add(Scp914ItemUpgrade.ParseString(kvp.Key), (Scp914Knob)Enum.Parse(typeof(Scp914Knob), kvp.Value));
                }
            }
            catch (Exception e)
            {
                Error("Failed to add items to 914. Check your 'util_914_items' config values for errors!\n" + e);
                return;
            }

            Info("Loaded " + configItems.Count + "('s) custom 914 recipes.");

            // Custom items
            try
            {
                Inventories               = new CustomInventory();
                Inventories.ClassD        = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_classd_inventory", null)));
                Inventories.Chaos         = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_choas_inventory", null)));
                Inventories.NtfCadet      = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_ntfcadet_inventory", null)));
                Inventories.NtfCommander  = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_ntfcommander_inventory", null)));
                Inventories.NtfLieutenant = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_ntflieutenant_inventory", null)));
                Inventories.NtfScientist  = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_ntfscientist_inventory", null)));
                Inventories.Scientist     = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_scientist_inventory", null)));
                Inventories.Guard         = CustomInventory.ConvertToItemList(KConf.ExiledConfiguration.GetListStringValue(Config.GetString("util_guard_inventory", null)));
            }
            catch (Exception e)
            {
                Error("Failed to add items to custom inventorys!. Check your inventory config values for errors!\n[EXCEPTION] For Developers:\n" + e);
                return;
            }

            Info("Loaded Inventories.");

            bool upgradeHeldItems = Config.GetBool("util_914_upgrade_hand", true);

            string broadcastMessage = Config.GetString("util_broadcast_message", "<color=lime>This server is running <color=red>EXILED-CommonUtils</color>, enjoy playing!</color>");

            int boradcastSeconds = Config.GetInt("util_broadcast_seconds", 300); // 300 is 5 minutes. :D
            int boradcastTime    = Config.GetInt("util_broadcast_time", 4);

            string joinMessage     = Config.GetString("util_joinMessage", "<color=lime>Welcome %player%! Please read our rules!</color>");
            int    joinMessageTime = Config.GetInt("util_joinMessage_time", 6);

            EventHandler               = new EventHandlers(upgradeHeldItems, scp914Roles, scp914Items, roleHealth, broadcastMessage, joinMessage, boradcastTime, boradcastSeconds, joinMessageTime, Inventories);
            Events.PlayerJoinEvent    += EventHandler.PlayerJoin;
            Events.Scp914UpgradeEvent += EventHandler.SCP914Upgrade;
            Events.SetClassEvent      += EventHandler.SetClass;

            cor = Timing.RunCoroutine(EventHandler.CustomBroadcast());

            Info("Common-Utils Loaded! Created by the EXILED Team.");
        }