Exemple #1
0
        /// <summary>
        /// Passes the agent's quick chats to the other bots.
        /// </summary>
        /// <param name="teamOnly">
        /// If true, only bots on the agent's team will be able to see the quick chat.<br/>
        /// If false, the quick chat sent is global and every bot will be able to see it.
        /// </param>
        /// <param name="quickChat">The quick chat that should be sent</param>
        /// <remarks>
        /// The agent is limited to 5 quick chats in a 2 second period starting from the first chat.
        /// This means you can spread your chats out to be even within that 2 second period.
        /// You could spam them in a short duration but they will be then throttled.
        /// </remarks>
        /// <exception cref="FlatbuffersPacketException">Throws when the game has not started yet.</exception>
        /// <example>
        /// Sample code to send "What a save!" globally:
        /// <code>
        /// SendQuickChatFromAgent(false, QuickChatSelection.Compliments_WhatASave);
        /// </code>
        /// </example>
        protected void SendQuickChatFromAgent(bool teamOnly, QuickChatSelection quickChat)
        {
            try
            {
                TimeSpan timeSinceLastChat = DateTime.Now - lastChatTime;
                if (!resetChatTime && timeSinceLastChat.TotalSeconds >= MaxChatRate)
                {
                    resetChatTime = true;
                }

                if (resetChatTime)
                {
                    lastChatTime  = DateTime.Now;
                    chatCounter   = 0;
                    resetChatTime = false;
                }

                if (chatCounter < MaxChatCount)
                {
                    RLBotInterface.SendQuickChatFlat(index, teamOnly, quickChat);
                    chatCounter++;
                }
                else
                {
                    Console.WriteLine($"Quick chat disabled for {(int) (MaxChatRate - timeSinceLastChat.TotalSeconds)} seconds.");
                }
            }
            catch (FlatbuffersPacketException)
            {
                throw new FlatbuffersPacketException("The game did not send any information. " +
                                                     "This could mean that the match has not started yet. " +
                                                     "This happens when you run the bot before (or as soon as) RLBot.exe gets started " +
                                                     "and the game has not started the match yet. This usually happens on the map loading screen.");
            }
        }
Exemple #2
0
        protected void SendQuickChatFromAgent(bool teamOnly, QuickChatSelection quickChat)
        {
            /*
             *  Passes the agents quick chats to the other bots.
             *  This does perform limiting.
             *  You are limited to 5 quick chats in a 2 second period starting from the first chat.
             *  This means you can spread your chats out to be even within that 2 second period.
             *  You could spam them in the first little bit but then will be throttled.
             */
            try
            {
                TimeSpan timeSinceLastChat = DateTime.Now - lastChatTime;
                if (!resetChatTime && timeSinceLastChat.TotalSeconds >= MAX_CHAT_RATE)
                {
                    resetChatTime = true;
                }

                if (resetChatTime)
                {
                    lastChatTime  = DateTime.Now;
                    chatCounter   = 0;
                    resetChatTime = false;
                }

                if (chatCounter < MAX_CHAT_COUNT)
                {
                    RLBotInterface.SendQuickChatFlat(index, teamOnly, quickChat);
                    chatCounter++;
                }
                else
                {
                    Console.WriteLine($"Quick chat disabled for {(int)(MAX_CHAT_RATE - timeSinceLastChat.TotalSeconds)} seconds.");
                }
            }
            catch (FlatbuffersPacketException)
            {
                throw new FlatbuffersPacketException("The game did not send any information. " +
                                                     "This could mean that the match has not started yet. " +
                                                     "This happens when you run the bot before (or as soon as) the RLBot DLL is injected " +
                                                     "and the game has not started the match yet. This usually happens on the map loading screen.");
            }
        }