Hooks
Hooks are how you find out what’s going on in game!
Hooks are how you find out what’s going on in game. They are called when certain events happen, and you can use them to do things like log information, send messages, or even dispatch other actions.
If you’ve ever used Discord.JS or some other library with a .on
system, that’s what a hook is, we just needed a creative name for it.
Hook List
Each hook has a basic example and description of usage.
- authFail
- balanceUpdate
- banned
- challengeComplete
- chat
- close
- collectAmmo
- collectGrenade
- gameForcePause
- gameOptionsChange
- gameReset
- gameStateChange
- grenadeExploded
- packet
- pingUpdate
- playerBeginStreak
- playerChangeCharacter
- playerChangeGun
- playerDamaged
- playerDeath
- playerFire
- playerJoin
- playerLeave
- playerMelee
- playerPause
- playerReload
- playerRespawn
- playerSwapWeapon
- playerSwitchTeam
- playerThrowGrenade
- rocketHit
- selfDamaged
- selfMoved
- selfRespawnFail
- selfShieldHit
- selfShieldLost
- spawnItem
- tick
They are not individual files. I’m too lazy to create all of them!
Hooks
This is the entire list. My fingers will probably hurt.
authFail
This is called when the authentication flow fails.
reason
is a valid reason:bad_json
- auth returned a bad JSON - usually out of your control, check console for errorsfirebase_no_credentials
- you did not pass a valid email or passwordfirebase_no_token
- firebase didn’t return an ID token, check console for infofirebase_too_many_retries
- attempting to get auth info failed over 5 timesservices_closed_early
- the game websocket closed before sending back auth info - usually out of your controlunknown_socket_error
- the websocket itself errored, usually out of your control
balanceUpdate
This is called when the bot’s egg balance updates, likely due to the bot killing someone.
oldBalance
is a numbernewBalance
is a number
banned
This is called when the bot is banned and cannot complete authentication. If you get this event, the Bot can’t be further used.
banRemaining
is a string in the formatHH:MM:SS
challengeComplete
This is called when a challenge is completed.
player
- the player that completed the challenge- if the bot is in a game, this will be a GamePlayer object
- if the bot is not in a game, this will be
bot.account
challenge
- the challenge ID number- if the
CHALLENGES
intent is enabled AND the player is the bot, this will be frombot.account.challenges
- if the
close
This is called when the bot’s connection to the game is closed.
code
is a number
You can compare this to the CloseCode
constant.
collectAmmo
This is called when a player collects an ammo pack.
player
is a Player objectweapon
is a Gun class (see Gun)
collectGrenade
This is called when a player collects a grenade.
player
is a Player object
gameForcePause
This is called when the game is forcibly paused. It’s not horribly clear WHEN this is called.
gameOptionsChange
This is called when the game options change by a host in a private room.
oldOptions
is an object (specifically Bot.game.options)newOptions
is an object (specifically Bot.game.options)
gameReset
This is called when the game is reset by the host. This is probably when gameForcePause
is called.
gameStateChange
This is called when the game state changes. This is MAINLY used in the spatula & KOTC gamemodes, wich signify whe things like the spatula is dropped or someone starts/stops capturing a coop, among many other things.
oldState
is an object (specifically Bot.game.state)newState
is an object (specifically Bot.game.state)
The current game state can be accessed at any time with bot.game.state
. The object is so large, documenting it here would be a headache. See the Bot class for more information.
grenadeExploded
This is called when a grenade explodes somewhere on the map.
item
is an item (if theCOSMETIC_DATA
intent is enabled), and if not, it will be the item ID #pos
is an object with thex
,y
, andz
propertiesdamage
is a numberradius
is a number (float)
packet
This is called when any packet is sent. It sends the raw packet, so you should create a CommIn
and manually inspect it. Using this requires the Bot.Intents.PACKET_HOOK
intent.
packet
is an encoded packet string
If you are trying to get every event, you are much better off with bot.onAny
.
pingUpdate
This is called when the bot’s ping updates.
oldPing
is a numbernewPing
is a number
playerBeginStreak
This is called when a player begins a streak reward (2x damage, overheal, etc).
player
is a Player objectstreak
is a value of theShellStreaks
enum
playerChangeCharacter
This is called when a player changes their skin set.
player
is a Player objectoldCharacter
is an object (specifically Bot.game.players[player.id].character)newCharacter
is an object (specifically Bot.game.players[player.id].character)
playerChangeGun
This is called when a player changes their gun. The guns are a 0-6 index, with 0 being the eggk and 6 being the tri-hard (in order of gun list).
player
is a Player objectoldGun
is a number (0-6)newGun
is a number (0-6)
playerDamaged
This is called when a player is hurt (using gun/grenade/melee). It’s not clear if this is when ANYONE hits a player, or when just the bot hits a player.
player
is a Player objectoldHp
is a numbernewHp
is a number
playerDeath
This is called when a player dies.
player
is a Player objectkiller
is a Player object
playerFire
This is called when a player fires their gun.
player
is a Player objectweapon
is a Gun class (see Gun)
playerJoin
This is called when a player joins the game.
player
is a Player object
playerLeave
This is called when a player leaves the game.
player
is a Player object
playerMelee
This is called when a player melees. Damage is not sent, nor what players it hits.
player
is a Player object
playerPause
This is called when a player pauses the game (clicks ESC).
player
is a Player object
playerReload
This is called when a player reloads their gun.
player
is a Player objectweapon
is a Gun class (see Gun)
playerRespawn
This is called when a player respawns.
player
is a Player object
playerSwapWeapon
This is called when a player swaps their weapon (between primary and secondary).
player
is a Player objectnowActive
is a number (0 or 1)
playerSwitchTeam
This is called when a player switches teams.
player
is a Player objectoldTeam
is a number (see theTeams
enum)newTeam
is a number (see theTeams
enum)
playerThrowGrenade
This is called when a player throws a grenade.
player
is a Player objectpos
is an object with thex
,y
, andz
propertiesdir
is an object with thex
,y
, andz
properties
rocketHit
This is called when a rocket hits a location and creates an explosion.
pos
is an object with thex
,y
, andz
propertiesdamage
is a numberradius
is a number (float)
selfDamaged
This is called when the bot is hurt.
oldHp
is a numbernewHp
is a number
selfMoved
This is called when the bot moves.
oldPos
is an object with thex
,y
, andz
propertiesnewPos
is an object with thex
,y
, andz
properties
selfRespawnFail
This is called when the bot fails to respawn. This ideally should never be called, as our dispatch checks should stop this from happening.
selfShieldHit
This is called when the bot’s shield is hit.
oldShield
is a numbernewShield
is a number
selfShieldLost
This is called when the bot’s shield is lost.
spawnItem
This is called when an ammo pack or grenade is spawned in the game. The types are the numeric values of the CollectTypes
.
tick
This is called everytime an update fires. This is called incredibly often.