-
Notifications
You must be signed in to change notification settings - Fork 79
Quickchat
An example of a bot using quick chat
Sending
from rlbot.agents.base_agent import BaseAgent
from rlbot.utils.structures.quick_chats import QuickChats
class QuickChatExampleAgent(BaseAgent):
def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
controller = SimpleControllerState()
self.send_quick_chat(QuickChats.CHAT_EVERYONE, QuickChats.Reactions_Wow)
return controller
This is just a simple example that spams "Wow!" until chat gets temporarily disabled for the bot.
We must import QuickChats
from the rlbot module in order to use quick chats (line 2). The method send_quick_chat
(line 8) exists in the BaseAgent
class, so our QuickChatExampleAgent
automatically inherits this class method when deriving from BaseAgent
.
The first parameter of send_quick_chat
is the visibility of our chat message we're going to send. This is a bool
(True
for team-only or False
for everyone), but it is recommended to use QuickChat.CHAT_TEAM_ONLY
, QuickChat.CHAT_EVERYONE
, or QuickChat.CHAT_NONE
instead for clarity's sake.
The second parameter of send_quick_chat
is the actual message of the chat message. A few examples are Information_IGotIt
, Compliments_GreatClear
, Reactions_Calculated
, Apologies_NoProblem
, or PostGame_Gg
. You can find the full list below (or here).
Receiving
To act or respond to another bot's quickchat messages, we do the following.
from rlbot.agents.base_agent import BaseAgent
from rlbot.utils.structures.quick_chats import QuickChats
class QuickChatExampleAgent(BaseAgent):
def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
return SimpleControllerState()
def handle_quick_chat(self, index, team, quick_chat):
self.send_quick_chat(QuickChats.CHAT_EVERYONE, QuickChats.Reactions_Okay)
Whenever another bot sends a quickchat message, our bot's handle_quick_chat
function will be called. The index
and team
parameters are the index and team of the sender, and quick_chat
is an enum describing the quick chat message.
In the case above, whenever a message is received, our bot will respond with the "Wow!" message.
Now that we've covered how to send quick chats, let's take a look at an example that sends "Nice shot!" whenever the other team scores against the bot.
from rlbot.agents.base_agent import BaseAgent
from rlbot.utils.structures.quick_chats import QuickChats
def get_game_score(packet: GameTickPacket):
score = [0, 0] # Index 0 is team0, index 1 is team1
for car in packet.game_cars:
score[car.team] += car.score_info.goals
return score
class QuickChatExampleAgent(BaseAgent):
def initialize_agent():
self.previous_frame_opponent_score = 0
def get_output(self, packet: GameTickPacket) -> SimpleControllerState:
controller = SimpleControllerState()
current_score = get_game_score(packet)
if self.previous_frame_opponent_score < current_score[not self.team]:
self.send_quick_chat(QuickChats.CHAT_EVERYONE, QuickChats.Compliments_NiceShot)
self.previous_frame_opponent_score = current_score[not self.team]
return controller
def handle_quick_chat(self, index, team, quick_chat):
if team != self.team and quick_chat == QuickChats.Compliments_NiceShot:
self.send_quick_chat(QuickChats.CHAT_EVERYONE, QuickChats.Compliments_Thanks)
We've implemented the get_game_score
function since RLBot doesn't provide a value that shows the team's overall goals, but just individual goals. We use self.previous_frame_opponent_score
so that we can see if the other team's score has increased. We send the quick chat message if the opponent's score has increased since last frame.
Additionally, by using the handle_quick_chat
function in BaseAgent
, we respond to other bot's quick chats as well. So whenever another bot says nice shot, we can say thanks.
Note: initialize_agent
is called after the bot is ready to start. This is when we want to declare variables like self.previous_frame_opponent_score
. It is recommended to use initialize_agent
instead of overriding __init__
and calling super
, because the bot may not be fully ready (e.g. self.get_field_info
will not work) when the bot object is being created.
The following quickchat commands are available to use.
- Information_IGotIt
- Information_NeedBoost
- Information_TakeTheShot
- Information_Defending
- Information_GoForIt
- Information_Centering
- Information_AllYours
- Information_InPosition
- Information_Incoming
- Compliments_NiceShot
- Compliments_GreatPass
- Compliments_Thanks
- Compliments_WhatASave
- Compliments_NiceOne
- Compliments_WhatAPlay
- Compliments_GreatClear
- Compliments_NiceBlock
- Reactions_OMG
- Reactions_Noooo
- Reactions_Wow
- Reactions_CloseOne
- Reactions_NoWay
- Reactions_HolyCow
- Reactions_Whew
- Reactions_Siiiick
- Reactions_Calculated
- Reactions_Savage
- Reactions_Okay
- Apologies_Cursing
- Apologies_NoProblem
- Apologies_Whoops
- Apologies_Sorry
- Apologies_MyBad
- Apologies_Oops
- Apologies_MyFault
- PostGame_Gg
- PostGame_WellPlayed
- PostGame_ThatWasFun
- PostGame_Rematch
- PostGame_OneMoreGame
- PostGame_WhatAGame
- PostGame_NiceMoves
- PostGame_EverybodyDance
The following are custom quickchats made by bot makers.
- Custom_Toxic_WasteCPU ("Waste of CPU cycles")
- Custom_Toxic_GitGut ("Git gud*")
- Custom_Toxic_DeAlloc ("De-Allocate Yourself")
- Custom_Toxic_404NoSkill ("404: Your skill not found")
- Custom_Toxic_CatchVirus ("Get a virus")
- Custom_Useful_Passing ("Passing!")
- Custom_Useful_Faking ("Faking!")
- Custom_Useful_Demoing ("Demoing!")
- Custom_Useful_Bumping ("BOOPING")
- Custom_Compliments_TinyChances ("The chances of that was 47525 to 1*")
- Custom_Compliments_SkillLevel ("Who upped your skill level?")
- Custom_Compliments_proud ("Your programmer should be proud")
- Custom_Compliments_GC ("You're the GC of Bots")
- Custom_Compliments_Pro ("Are you Bot? *")
- Custom_Excuses_Lag ("Lag")
- Custom_Excuses_GhostInputs ("Ghost inputs")
- Custom_Excuses_Rigged ("RIGGED")
- Custom_Toxic_MafiaPlays ("Mafia plays!")
- Custom_Exclamation_Yeet ("Yeet!")