Level Editor/Scripting/Map entities
Besides zones, pickups and payload tracks, a server script can read and drive the other things a map places: doors, logic entities, map markers, switchable parts and bosses. It can also put up buildings and spawn bots of the map's own. Each of these is found by the name you give it in the editor. Everything here is on the server's GamemodeServerApi.
Doors
A door is named by its name in the scene tree.
- api.doors(): every door's name.
- api.door_open(name), api.door_close(name), api.door_toggle(name): move it. A locked door refuses to open.
- api.door_lock(name) and api.door_unlock(name).
- api.door_state(name):
api.DOOR_CLOSED,api.DOOR_OPENING,api.DOOR_OPENorapi.DOOR_CLOSING; api.door_locked(name). _door_changed(door, state): called whenever a door changes state, however it was moved (a player walking up, its wait running out, an output, or your script).
A setup time that keeps the attackers' gate shut for the first 60 seconds:
const SETUP_SECONDS := 60.0 var _clock: float = 0.0 func _start() -> void: api.door_lock(&"Gate") func _tick(delta: float) -> void: _clock += delta if _clock >= SETUP_SECONDS and api.door_locked(&"Gate"): api.door_unlock(&"Gate") api.door_open(&"Gate")
Outputs and logic
- api.fire_input(target, input, parameter, delay): send an input to every entity named
target, as an output would.parameteris text ("5");delayis in seconds. False, with a line in the log, for a name the map does not have. - api.counter_value(name): a Logic Counter's value.
_logic_event(entity, event, activator): a relay, timer, counter or button raised an event ("OnTrigger","OnTimer","OutValue","OnHitMin","OnHitMax","OnPressed"or"OnUseLocked").activatoris the player who set it off, 0 for nobody. Its outputs fire either way; this is where a mode reacts to a button press or a counter filling up.
See Outputs and logic.
Map markers
A Map Marker is a named spot and facing.
- api.markers(): every marker's name, in map order.
- api.marker(name): where it stands (the origin, and a line in the log, for a name the map does not place).
- api.marker_facing(name): the way it faces, level and one meter long. A point it looks at is
api.marker(n) + api.marker_facing(n) * distance.
Switchable parts
A group with Switchable ticked is a part: everything in it comes and goes together.
- api.parts(): every part's name.
- api.set_part_enabled(name, enabled): put the part in the world, or take it out: it is seen and it blocks, or it is neither, for every player, including those who join later.
- api.part_enabled(name): whether it is there now.
Bosses
A Boss Spawn places a boss. Bosses stand whether or not the mode mentions them.
- api.bosses(): every boss's entity id, in map order.
- api.entity_name, entity_team, entity_health, entity_max_health, entity_alive, entity_position and entity_zone (its arena zone) read one.
_entity_damaged(entity, amount, attacker)and_entity_died(entity, killer)report what happens to them. What a dead boss means for the match (killing the enemy's boss wins, say) is the mode's to decide.- api.revive_boss brings a dead boss back, for a practice boss.
- On the HUD, the
boss_healthwidget shows both teams' bosses; see Client HUD.
Buildings
- api.place_building: put up a building of the map's own (a sentry, dispenser or teleporter end), already built, at a level from 1 to 3, for a team, under a key you choose.
- api.remove_building(key) and api.has_building(key).
- api.forbid_building(zone) stops players building in a zone (a spawn room).
The map's own bots
Bots that belong to the map are fixtures such as training dummies, not stand-ins for players: nobody can kick them, and they take no player's seat.
- api.spawn_bot spawns one with a name, loadout and team; api.map_bots() and api.is_map_bot list and recognize them.
- Training orders: api.bot_idle (stand still, never shoot), api.bot_dodge (a moving target), api.bot_shoot (fire at one player only).
- api.bot_build, bot_demolish and bot_has_building: buildings for a map bot that holds a building tool.
- api.edit_bot_loadout lets a player change the loadout of map bots (for example from a zone's
_zone_used).
Tile maps
api.open_tile_map opens a grid plan on a player's screen for them to fill in (where to put sentries or walls, say), and _form_submitted(entity_id, form, values) hears what they applied. A player can apply the same map again, so make applying it twice harmless.