Skip to main content

Round hooks

Round hooks let your map react to its rounds: the game triggers entities with these names by itself at round starts and ends, lost rounds and the mission's end. A new round respawns the players but not the map, so a door that was opened in one round is still open in the next unless your map resets it. The hooks fire at these moments:

  • the start and the end of each round
  • the start of a given round number
  • a lost round
  • the end of the mission

If you give a trigger_relay, a multi_manager or any other entity the name of a hook, the game triggers it at that moment. Some entities also have a key that puts them back the way they were when the map loaded, at each round start.

game_round_start and game_round_end​

The game triggers every entity with one of these names:

NameWhen the game triggers itUse typeActivator
game_round_startAt each round start, after the round's players have spawnedToggleThe world
game_round_endAt each round endToggleThe world

Several entities can have the same name, and the game triggers all of them. The activator is the world and not a player, so use a trigger_entity_iterator to reach each player. At the end of a round, each trigger_camera that holds a player's view gives it back before the game triggers game_round_end.

When a round starts and ends depends on the game mode:

Game modeWhen a round startsWhen a round ends
Co-opWhen the round's players spawn and the screen shows ROUND STARTWhen the round is lost or won, when the players leave or when the mission ends
Battle RoyaleWhen the round's players spawnWhen the round has a winner or nobody is left
Bounty KillerWhen a player with a loadout spawns and the game picks the HuntedWhen the Hunted leaves or becomes a spectator, but not when a player kills the Hunted, because the killer then becomes the Hunted and the round goes on

Round numbers, lost rounds and the mission's result​

The game fires four more names the same way, with the use type Toggle and the world as the activator:

NameWhen the game triggers itGame modes
game_round_<N>, such as game_round_1 or game_round_2Right after the game_round_start of round NCo-op, where N is the round on the scoreboard, and Battle Royale, but not Bounty Killer, which counts no rounds
game_round_failedWhen a round is lost and the screen shows FAILED ROUND, after its game_round_end and before the pause and the next roundCo-op, where losing the last round fires game_mission_failed instead
game_mission_successWhen the mission succeeds through a game_end or a change_touch, after the round's game_round_endCo-op, once per map
game_mission_failedWhen the mission fails through a mission_failed or because the team lost its last round, after the round's game_round_endCo-op, once per map

Battle Royale and Bounty Killer have no lost rounds and no mission, so the last three names never fire there. The mission's result is already fixed when its hook fires, so if the hook triggers a game_end or a mission_failed, nothing changes.

One Co-op round: the Reset at round start entities go back, the players spawn, game_round_start and game_round_1, game_round_2 and so on fire, and the team plays. A lost round fires game_round_end, then game_round_failed and a 5 second pause before the next round, or game_mission_failed after the last round. A game_end or change_touch fires game_round_end, then game_mission_success

The entities that fire during one Co-op round

Reset at round start​

The key Reset at round start (round_reset) puts an entity back the way it was when the map loaded, at each round start before the players spawn. The reset fires nothing, and works in Co-op, Battle Royale and Bounty Killer.

These entities have the key:

A trigger_objective has the flag Reset on new round (2) for the same job.

Other entities, such as doors and counters, don't have this key, so they keep their state into the next round. To reset them, trigger them from an entity named game_round_start, for example by sending an Off to a door that has Obey Trigger Mode set.

Player hooks​

The game also triggers entities with these names when something happens to a player, with that player or the killer as the activator:

NameWhen the game triggers itActivator
game_playerjoinWhen a player joins the serverThe player
game_playerspawnWhen a player spawns, and when a player joinsThe player
game_playerdieWhen a player diesThe player who died
game_playerkillWhen a player kills another playerThe killer
game_playerleaveWhen a player leaves the serverThe player

Alive players​

Logic entities that count or look for players only see alive players. A player counts from the moment they spawn until they die, so spectators, the Game Master and players waiting for the next round never count. This applies, for example, to trigger_entity_iterator, trigger_sensor, trigger_inout, and the messages of env_tutor and game_messagebox.

Changes since 1.38​

  • game_round_start, game_round_end and the Reset at round start key are new
  • The game now triggers entities named game_round_<N> when round N starts, game_round_failed when a round is lost, and game_mission_success or game_mission_failed when the mission ends

See also​