Esempio n. 1
0
        public (string response, string color) OnCall(ReferenceHub sender, string[] args)
        {
            (string message, bool isValid) = CheckMessageValidity(args.GetMessage(), sender);

            if (!isValid)
            {
                return(message, "red");
            }

            message = $"[{sender.GetNickname()}][{Language.Team} ({sender.GetRole().ToString().ToUpper()})]: {message}";

            IEnumerable <ReferenceHub>     targets     = Player.GetHubs().Where(chatPlayer => chatPlayer != sender && chatPlayer.GetTeam() == sender.GetTeam());
            List <Collections.Chat.Player> chatTargets = targets.GetChatPlayers();

            if (chatTargets.Count == 0)
            {
                return(Language.NoAvailablePlayersToChatWithError, "red");
            }

            color = sender.GetColor();

            if (Configs.saveChatToDatabase)
            {
                SaveMessage(message, sender.GetChatPlayer(), chatTargets, type);
            }

            SendMessage(ref message, sender, targets);

            return(message, color);
        }
Esempio n. 2
0
        private IEnumerator <float> TeleportToOutput(ReferenceHub hub, Vector3 oldPos, Vector3 tpPos, Inventory inv, float healthPerc)
        {
            yield return(Timing.WaitForSeconds(1.5f));

            DebugBoi("Teleporting " + hub.nicknameSync.MyNick + " to the output of 914.");

            hub.playerStats.SetHPAmount(hub.characterClassManager.Classes.SafeGet(hub.GetRole()).maxHP);
            hub.plyMovementSync.OverridePosition(oldPos + tpPos, hub.gameObject.transform.rotation.y);

            yield return(Timing.WaitForSeconds(0.5f));

            hub.inventory.Clear();
            foreach (var item in inv.items)
            {
                hub.AddItem(item);
            }
            hub.SetHealth(hub.characterClassManager.Classes.SafeGet(hub.GetRole()).maxHP *healthPerc);
        }
Esempio n. 3
0
        /// <summary>
        /// Checks if a player's role type is any NTF type <see cref="ReferenceHub"/>.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public static bool IsNTF(this ReferenceHub hub)
        {
            switch (hub.GetRole())
            {
            case RoleType.NtfCadet:
            case RoleType.NtfScientist:
            case RoleType.NtfLieutenant:
            case RoleType.NtfCommander:
                return(true);

            default:
                return(false);
            }
        }
Esempio n. 4
0
        public static IEnumerator <float> DOTDamage(ReferenceHub target, int perDamage, int maxLimitDamage, float interval, DamageTypes.DamageType type)
        {
            int      curDamageAmount = 0;
            Vector3  curDeathPos     = target.characterClassManager.NetworkDeathPosition;
            RoleType curRole         = target.GetRole();

            while (curDamageAmount < maxLimitDamage)
            {
                if (target.characterClassManager.NetworkDeathPosition != curDeathPos || target.GetRole() != curRole)
                {
                    break;
                }
                target.playerStats.HurtPlayer(new PlayerStats.HitInfo(perDamage, "WORLD", type, 0), target.gameObject);
                curDamageAmount += perDamage;
                yield return(Timing.WaitForSeconds(interval));
            }
            if (DOTDamages.ContainsKey(target))
            {
                Log.Debug($"[939DOT] Removed {target.GetNickname()}");
                DOTDamages.Remove(target);
            }
            yield break;
        }
Esempio n. 5
0
 /// <summary>
 /// Gets the <see cref="Team"/> a <see cref="ReferenceHub"/> belongs to.
 /// </summary>
 /// <param name="player">Player</param>
 /// <returns>Team</returns>
 public static Team GetTeam(this ReferenceHub player) => player.GetRole().GetTeam();
Esempio n. 6
0
 public static void SetRole(this ReferenceHub player, RoleType newRole, bool keepPosition)
 {
     if (keepPosition)
     {
         player.characterClassManager.NetworkCurClass = newRole;
         player.playerStats.SetHPAmount(player.characterClassManager.Classes.SafeGet(player.GetRole()).maxHP);
     }
     else
     {
         SetRole(player, newRole);
     }
 }
Esempio n. 7
0
        public void OnConsoleCommand(ConsoleCommandEvent ev)
        {
            try
            {
                if (Cooldowns.CheckCooldown(Cooldowns.ChaosCmdCool))
                {
                    ev.ReturnMessage = $"<color=red>You must wait {Cooldowns.ChaosCmdCool} seconds to use abilities.</color>";
                    return;
                }

                if (ev.Player != hub)
                {
                    return;
                }

                if (ev.Command.StartsWith("emp"))
                {
                    bool Does173Exist = new bool();
                    if (!EventHandlers.ChaosDevice)
                    {
                        ev.Color         = "red";
                        ev.ReturnMessage = "You must wait until another round to access this command.";
                        return;
                    }
                    foreach (ReferenceHub hub in Player.GetHubs())
                    {
                        if (hub.GetRole() == RoleType.Scp173)
                        {
                            Does173Exist = true;
                        }
                    }
                    if (Does173Exist)
                    {
                        ev.Color         = "red";
                        ev.ReturnMessage = "Blackout cancelled. Entity in the facility has been found to directly benefit from the darkness.";
                        Does173Exist     = false;
                        return;
                    }
                    ev.Color                  = "yellow";
                    ev.ReturnMessage          = "Facility blacked out for 60 seconds.";
                    EventHandlers.ChaosDevice = false;
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Methods.DoBlackout()));
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoChsCommandCooldown()));
                }
                else if (ev.Command.StartsWith("respawn"))
                {
                    if (Cooldowns.CheckCooldown(Cooldowns.ChaosRespawnTime))
                    {
                        ev.Color         = "red";
                        ev.ReturnMessage = $"You must wait {Cooldowns.ChaosRespawnTime} seconds to respawn another wave.";
                        return;
                    }
                    GameCore.Console.singleton.TypeCommand("/SERVER_EVENT FORCE_CI_RESPAWN");
                    ev.ReturnMessage = "<color=cyan>An Chaos unit has been alerted to immediately come to your location.</color>";
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoChaosRespawnCooldown()));
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoChsCommandCooldown()));
                }
                else if (ev.Command.StartsWith("hack"))
                {
                    if (Cooldowns.CheckCooldown(Cooldowns.HackTime))
                    {
                        ev.Color         = "red";
                        ev.ReturnMessage = $"You must wait {Cooldowns.HackTime} seconds to attempt another hack.";
                        return;
                    }

                    string Cmd      = string.Empty;
                    int    CoolTime = new int();

                    if (ev.Command.Contains("scan"))
                    {
                        Cmd      = "scan";
                        CoolTime = 600;
                    }
                    else if (ev.Command.Contains("teslas"))
                    {
                        Cmd      = "teslas";
                        CoolTime = 120;
                    }
                    else
                    {
                        ev.ReturnMessage = "You must specify a command to hack: .hack (scan/teslas)";
                        return;
                    }
                    ev.ReturnMessage = null;
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Methods.HackSequence(hub, Cmd)));
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoHackCooldown(CoolTime)));
                    EventHandlers.Coroutines.Add(Timing.RunCoroutine(Cooldowns.DoChsCommandCooldown()));
                }
                else if (ev.Command.StartsWith("help"))
                {
                    ev.Color         = "white";
                    ev.ReturnMessage =
                        "\n.help: Shows all commands and delays " +
                        "\n.emp: Blacksout the facility and disabled tesla gates, also lets anybody open any door - Can only be used once per round" +
                        "\n.respawn: Forces a Chaos respawn - Cooldown: 10 minutes" +
                        "\n.hack (scan/teslas): Attempts to mimick the NTF commanders ability's - Cooldowns: (scan 10 min/teslas 2 min)";
                }
            }
            catch (Exception e)
            {
                Log.Error($"BetterRespawns exception for ChaosCommander ConsoleCommand: {e}");
            }
        }