Пример #1
0
 private void OnPlayerChatted(UnturnedPlayer player, ref UnityEngine.Color color, string message, EChatMode chatMode, ref bool cancel)
 {
     if (UserList.ContainsKey(player.Id))
     {
         color = (UnityEngine.Color)UnturnedChat.GetColorFromHex(UserList[player.Id]);
     }
 }
Пример #2
0
        public static Color GetColorFromString(ref string message)
        {
            Color?color;
            int   l, r;

            if ((l = message.IndexOf('<')) == -1 || (r = message.IndexOf('>')) == -1)
            {
                return(Color.green);
            }

            var rawColor = message.Substring(++l, --r);

            if (string.IsNullOrEmpty(rawColor))
            {
                return(Color.green);
            }

            // Try get color from name
            switch (rawColor.Trim().ToLower())
            {
            case "black": color = Color.black; break;

            case "blue": color = Color.blue; break;

            case "clear": color = Color.clear; break;

            case "cyan": color = Color.cyan; break;

            case "gray": color = Color.gray; break;

            case "green": color = Color.green; break;

            case "grey": color = Color.grey; break;

            case "magenta": color = Color.magenta; break;

            case "red": color = Color.red; break;

            case "white": color = Color.white; break;

            case "yellow": color = Color.yellow; break;

            default: color = UnturnedChat.GetColorFromHex(rawColor); break;
            }

            // Remove <color>
            if (color.HasValue)
            {
                message = message.Replace($"<{rawColor}>", string.Empty);
            }

            return(color ?? Color.green);
        }
Пример #3
0
        public static IEnumerator Strike(float initialDelay, float delayBetweenStrikes, int strikeCount, float damageIntensity, int range, Vector3 startPoint)
        {
            const float DAMAGE = 200;

            // timer
            Airstrikes.Instance.Vectors.Add(startPoint);

            if (Airstrikes.Instance.Configuration.Instance.GlobalMessageColor.StartsWith("#"))
            {
                Color?hexColor = UnturnedChat.GetColorFromHex(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor);

                UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike_sec", startPoint.ToString(), initialDelay), hexColor ?? default(Color));
            }
            else
            {
                UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike_sec", startPoint.ToString(), initialDelay), UnturnedChat.GetColorFromName(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor, Color.green));
            }

            yield return(new WaitForSeconds(initialDelay));

            if (Airstrikes.Instance.Configuration.Instance.GlobalMessageColor.StartsWith("#"))
            {
                Color?hexColor = UnturnedChat.GetColorFromHex(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor);

                UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike_now", startPoint.ToString()), hexColor ?? default(Color));
            }
            else
            {
                UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike_now", startPoint.ToString()), UnturnedChat.GetColorFromName(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor, Color.green));
            }

            yield return(new WaitForSeconds(3f));

            Airstrikes.Instance.Vectors.Remove(startPoint);

            // strike...
            for (int i = 0; i < (strikeCount + 1); i++)
            {
                yield return(new WaitForSeconds(delayBetweenStrikes));

                Ray impactRay = new Ray(new Vector3(UnityEngine.Random.Range(startPoint.x - range, startPoint.x + range), startPoint.y + 50, UnityEngine.Random.Range(startPoint.z - range, startPoint.z + range)), Vector3.down);

                if (Physics.Raycast(impactRay, out RaycastHit hit))
                {
                    EffectManager.sendEffect(20, EffectManager.INSANE, hit.point);
                    DamageTool.explode(hit.point, damageIntensity, EDeathCause.MISSILE, CSteamID.Nil, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE);
                    Airstrikes.WriteDebug(hit.point.ToString());
                }
            }
        }
Пример #4
0
        public static Color GetColorFromString(ref string message)
        {
            Color?color = null;

            if (message.IndexOfAny(new[] { '<', '>' }) == -1)
            {
                return(Color.green);
            }

            var rawColor = message.Split('<')[1].Split('>')[0];

            switch (rawColor.Trim().ToLower())
            {
            case "black": color = Color.black; break;

            case "blue": color = Color.blue; break;

            case "clear": color = Color.clear; break;

            case "cyan": color = Color.cyan; break;

            case "gray": color = Color.gray; break;

            case "green": color = Color.green; break;

            case "grey": color = Color.grey; break;

            case "magenta": color = Color.magenta; break;

            case "red": color = Color.red; break;

            case "white": color = Color.white; break;

            case "yellow": color = Color.yellow; break;
            }

            if (!color.HasValue)
            {
                color = UnturnedChat.GetColorFromHex(rawColor);
            }

            if (color.HasValue)
            {
                message = message.Replace($"<{rawColor}>", "");
            }

            return(color ?? Color.green);
        }
Пример #5
0
        public void Execute(IRocketPlayer caller, string[] command)
        {
            bool error = false;

            string[] StoredRulesText  = new string[RocketRules.Instance.StoredRulesText.Length];
            string[] StoredRulesColor = new string[RocketRules.Instance.StoredRulesColor.Length];
            StoredRulesText  = RocketRules.Instance.StoredRulesText;
            StoredRulesColor = RocketRules.Instance.StoredRulesColor;
            int numRules    = RocketRules.Instance.numRules;
            int extraRules  = RocketRules.Instance.extraRules;
            int Pages       = RocketRules.Instance.Pages;
            int CommandPage = 0;

            if (caller is ConsolePlayer)
            {
                // Dump all rules to console
                for (int i = 0; i <= StoredRulesText.Length - 1; i++)
                {
                    Rocket.Core.Logging.Logger.Log(RocketRules.Instance.Translations.Instance.Translate("rule", StoredRulesText[i]), ConsoleColor.Yellow);
                }
            }
            else
            {
                // Grab page syntax, if it wasn't set by player, set it to 1.

                if (command.Length != 1)
                {
                    CommandPage = 1;
                }
                else if (command.Length == 1)
                {
                    try
                    {
                        CommandPage = Convert.ToInt32(command[0]);
                    }
                    catch (FormatException)
                    {
                        UnturnedChat.Say(caller, string.Format("Failed to convert {0} to a number!", command[0]));
                        error = true;
                    }
                    catch (OverflowException)
                    {
                        UnturnedChat.Say(caller, string.Format("Failed to convert {0} to a number!", command[0]));
                        error = true;
                    }
                }

                // Start rules dumping to the player. Don't dump if there was an error with the syntax.

                if (error == false)
                {
                    if (CommandPage < Pages)
                    {
                        try
                        {
                            bool reminder0 = false;
                            bool reminder1 = false;
                            bool reminder2 = false;
                            for (int i = ((CommandPage * 4) - 4); i <= ((CommandPage * 4) - 1); i++)
                            {
                                if (i == (CommandPage * 4 - 1))
                                {
                                    UnturnedChat.Say(caller, RocketRules.Instance.Translations.Instance.Translate("pages", Convert.ToString(CommandPage + 1)));
                                    reminder0 = true;
                                }
                                if (reminder0 == false && reminder1 == false && reminder2 == false)
                                {
                                    UnturnedChat.Say(caller, RocketRules.Instance.Translations.Instance.Translate("rule", StoredRulesText[i - (CommandPage - 1)]), UnturnedChat.GetColorFromHex(StoredRulesColor[i - (CommandPage - 1)]).Value);
                                }
                            }
                            reminder0 = false;
                            reminder1 = false;
                            reminder2 = false;
                        }
                        catch (IndexOutOfRangeException)
                        {
                            Rocket.Core.Logging.Logger.LogError("Unexpected error was encountered. If it's not caused because of your configuration, please report the error at https://github.com/persiafighter/Rocket-Rules/issues");
                        }
                    }
                    else if (CommandPage == Pages)
                    {
                        try
                        {
                            int counter = 0;
                            for (int i = ((CommandPage * 4) - 4); i <= ((CommandPage * 4) - 1); i++)
                            {
                                if (counter > extraRules - 1)
                                {
                                    UnturnedChat.Say(caller, RocketRules.Instance.Translations.Instance.Translate("endofrules"), Color.green);
                                    i = 500000;
                                }
                                else if (counter <= extraRules)
                                {
                                    UnturnedChat.Say(caller, RocketRules.Instance.Translations.Instance.Translate("rule", StoredRulesText[i - (CommandPage - 1)]), UnturnedChat.GetColorFromHex(StoredRulesColor[i - (CommandPage - 1)]).Value);
                                }
                                counter = counter + 1;
                            }
                        }
                        catch (IndexOutOfRangeException)
                        {
                            Rocket.Core.Logging.Logger.LogError("Unexpected error was encountered. If it's not caused because of your configuration, please report the error at https://github.com/persiafighter/Rocket-Rules/issues");
                        }
                    }
                    else if (CommandPage > Pages)
                    {
                        UnturnedChat.Say(caller, "That page does not exist");
                    }
                }
            }
        }
Пример #6
0
 private void Events_OnPlayerConnected(UnturnedPlayer player)
 {
     if (configDisplayOnConnect == true)
     {
         if (numRules == 1)
         {
             UnturnedChat.Say(player, Instance.Translations.Instance.Translate("rule", StoredRulesText[0]), UnturnedChat.GetColorFromHex(StoredRulesColor[0]).Value);
         }
         else if (numRules == 2)
         {
             UnturnedChat.Say(player, Instance.Translations.Instance.Translate("rule", StoredRulesText[0]), UnturnedChat.GetColorFromHex(StoredRulesColor[0]).Value);
             UnturnedChat.Say(player, Instance.Translations.Instance.Translate("rule", StoredRulesText[1]), UnturnedChat.GetColorFromHex(StoredRulesColor[1]).Value);
         }
         else if (numRules == 3)
         {
             UnturnedChat.Say(player, Instance.Translations.Instance.Translate("rule", StoredRulesText[0]), UnturnedChat.GetColorFromHex(StoredRulesColor[0]).Value);
             UnturnedChat.Say(player, Instance.Translations.Instance.Translate("rule", StoredRulesText[1]), UnturnedChat.GetColorFromHex(StoredRulesColor[1]).Value);
             UnturnedChat.Say(player, Instance.Translations.Instance.Translate("rule", StoredRulesText[2]), UnturnedChat.GetColorFromHex(StoredRulesColor[2]).Value);
         }
         else if (numRules >= 4)
         {
             UnturnedChat.Say(player, Instance.Translations.Instance.Translate("rule", StoredRulesText[0]), UnturnedChat.GetColorFromHex(StoredRulesColor[0]).Value);
             UnturnedChat.Say(player, Instance.Translations.Instance.Translate("rule", StoredRulesText[1]), UnturnedChat.GetColorFromHex(StoredRulesColor[1]).Value);
             UnturnedChat.Say(player, Instance.Translations.Instance.Translate("rule", StoredRulesText[2]), UnturnedChat.GetColorFromHex(StoredRulesColor[2]).Value);
             UnturnedChat.Say(player, Instance.Translations.Instance.Translate("rule", StoredRulesText[3]), UnturnedChat.GetColorFromHex(StoredRulesColor[3]).Value);
         }
     }
 }
Пример #7
0
        public static IEnumerator AutoStrike()
        {
            const float DAMAGE = 200;

            while (Airstrikes.Instance.Configuration.Instance.AutoAirstrike == true)
            {
                foreach (Config.Location Preset in Airstrikes.Instance.Configuration.Instance.Locations)
                {
                    Vector3 centerPoint     = new API().StringToVector3(Preset.Coords);
                    string  centerPointName = Preset.Name;
                    int     minutes         = Airstrikes.Instance.Configuration.Instance.MinutesBetweenAirstrikes - 1;
                    int     amt             = Airstrikes.Instance.Configuration.Instance.MinutesBetweenAirstrikes + 1;

                    // x minutes left...
                    for (int i = 0; i < minutes; i++)
                    {
                        amt--;

                        if (Airstrikes.Instance.Configuration.Instance.GlobalMessageColor.StartsWith("#"))
                        {
                            Color?hexColor = UnturnedChat.GetColorFromHex(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor);

                            UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike", centerPointName, amt), hexColor ?? default(Color));
                        }
                        else
                        {
                            UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike", centerPointName, amt), UnturnedChat.GetColorFromName(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor, Color.green));
                        }

                        yield return(new WaitForSeconds(60f));
                    }

                    // 1 minute left...
                    Airstrikes.Instance.Vectors.Add(centerPoint);

                    if (Airstrikes.Instance.Configuration.Instance.GlobalMessageColor.StartsWith("#"))
                    {
                        Color?hexColor = UnturnedChat.GetColorFromHex(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor);

                        UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike", centerPointName, 1), hexColor ?? default(Color));
                    }
                    else
                    {
                        UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike", centerPointName, 1), UnturnedChat.GetColorFromName(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor, Color.green));
                    }

                    yield return(new WaitForSeconds(60f));

                    // times up...
                    if (Airstrikes.Instance.Configuration.Instance.GlobalMessageColor.StartsWith("#"))
                    {
                        Color?hexColor = UnturnedChat.GetColorFromHex(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor);

                        UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike_now", centerPointName), hexColor ?? default(Color));
                    }
                    else
                    {
                        UnturnedChat.Say(Airstrikes.Instance.Translate("global_airstrike_now", centerPointName), UnturnedChat.GetColorFromName(Airstrikes.Instance.Configuration.Instance.GlobalMessageColor, Color.green));
                    }

                    yield return(new WaitForSeconds(3f));

                    Airstrikes.Instance.Vectors.Remove(centerPoint);

                    // strike...
                    for (int i = 0; i < (Preset.StrikeCount + 1); i++)
                    {
                        yield return(new WaitForSeconds(Preset.StrikeSpeed));

                        Ray impactRay = new Ray(new Vector3(UnityEngine.Random.Range(centerPoint.x - Preset.Range, centerPoint.x + Preset.Range), centerPoint.y + 50, UnityEngine.Random.Range(centerPoint.z - Preset.Range, centerPoint.z + Preset.Range)), Vector3.down);

                        if (Physics.Raycast(impactRay, out RaycastHit hit))
                        {
                            EffectManager.sendEffect(20, EffectManager.INSANE, hit.point);
                            DamageTool.explode(hit.point, Preset.DamageIntensity, EDeathCause.MISSILE, CSteamID.Nil, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE, DAMAGE);
                            Airstrikes.WriteDebug(hit.point.ToString());
                        }
                    }
                }
            }
        }