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
 public static Offset <QuickChat> CreateQuickChat(FlatBufferBuilder builder,
                                                  QuickChatSelection quickChatSelection = QuickChatSelection.Information_IGotIt,
                                                  int playerIndex = 0,
                                                  bool teamOnly   = false)
 {
     builder.StartObject(3);
     QuickChat.AddPlayerIndex(builder, playerIndex);
     QuickChat.AddTeamOnly(builder, teamOnly);
     QuickChat.AddQuickChatSelection(builder, quickChatSelection);
     return(QuickChat.EndQuickChat(builder));
 }
Exemple #3
0
        /// <summary>
        /// Sends a quick chat flat message.
        /// </summary>
        /// <param name="playerIndex">The index of the bot's car.</param>
        /// <param name="teamOnly">Flag indicating whether the quick chat message is for the player's team only or not.</param>
        /// <param name="quickChat">The quick chat selection to send.</param>
        public static void SendQuickChatFlat(int playerIndex, bool teamOnly, QuickChatSelection quickChat)
        {
            FlatBufferBuilder builder = new FlatBufferBuilder(50);

            var offset = QuickChat.CreateQuickChat(
                builder,
                quickChat,
                playerIndex,
                teamOnly);

            builder.Finish(offset.Value);
            byte[] bufferBytes = builder.SizedByteArray();
            SendQuickChat(bufferBytes, bufferBytes.Length);
        }
Exemple #4
0
 public static Offset <QuickChat> CreateQuickChat(FlatBufferBuilder builder,
                                                  QuickChatSelection quickChatSelection = QuickChatSelection.Information_IGotIt,
                                                  int playerIndex  = 0,
                                                  bool teamOnly    = false,
                                                  int messageIndex = 0,
                                                  float timeStamp  = 0.0f)
 {
     builder.StartObject(5);
     QuickChat.AddTimeStamp(builder, timeStamp);
     QuickChat.AddMessageIndex(builder, messageIndex);
     QuickChat.AddPlayerIndex(builder, playerIndex);
     QuickChat.AddTeamOnly(builder, teamOnly);
     QuickChat.AddQuickChatSelection(builder, quickChatSelection);
     return(QuickChat.EndQuickChat(builder));
 }
Exemple #5
0
        /// <summary>
        /// Sends a quick chat flat message.
        /// </summary>
        /// <param name="playerIndex">The index of the bot's car.</param>
        /// <param name="teamOnly">Flag indicating whether the quick chat message is for the player's team only or not.</param>
        /// <param name="quickChat">The quick chat selection to send.</param>
        public static void SendQuickChatFlat(int playerIndex, bool teamOnly, QuickChatSelection quickChat)
        {
            FlatBufferBuilder builder = new FlatBufferBuilder(50);

            var offset = QuickChat.CreateQuickChat(
                builder,
                quickChat,
                playerIndex,
                teamOnly);

            builder.Finish(offset.Value);
            byte[] bufferBytes = builder.SizedByteArray();
            int    status      = SendQuickChat(bufferBytes, bufferBytes.Length);

            if (status > 0)
            {
                throw NewRLBotCoreException((RLBotCoreStatus)status);
            }
        }
Exemple #6
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.");
            }
        }
Exemple #7
0
 public static void AddQuickChatSelection(FlatBufferBuilder builder, QuickChatSelection quickChatSelection)
 {
     builder.AddSbyte(0, (sbyte)quickChatSelection, 0);
 }