DocsMegalithLanguage

Players, teams and the round

current_player means the player selected by a loop or event; saved player and team references work too.

The player

biped
The player's body, or no_object while they're dead.
score
Their score this round, to read or change, by up to 100 points at a time. The game type's score limit still ends the round.
team
Their team, to read or change. Changing it needs a team game and a team the map allows or the mode declares; neutral_team and no_team aren't teams to join.
is_not_respawning()
(condition) True while the player is alive.
get_death_count()
Their deaths this round, including one followed by a respawn between ticks. Stays through respawns, resets on leaving or a new round.
get_kill_count()
Enemy kills this round, including by a projectile that lands after the player died. Suicides and kills of teammates don't count.
get_infection_death_count()
Deaths to a lethal Infection Form bite this round.
get_respawn_time()
Whole seconds left on their respawn countdown; 0 while alive or once they may respawn.
get_killer()
The player who killed them last; no_player after a suicide, a betrayal or a death to the world.
get_death_damage_mod()
How they died last: damage_mod.none, damage_mod.pummel (a beat-down; the sword's and the hammer's strikes are weapon kills) or damage_mod.assassination (an attack from behind, theirs too).
get_time_out_of_combat()
Whole seconds since an enemy last hurt them or they hurt one: a player, in a body or a vehicle, or the AI. Falls and their own damage don't count.
get_crosshair_target()
The object under their crosshair, up to 100 Forge units away, unless the level is in the way; no_object for none or a dead player.
apply_traits(script_traits[0])
Gives them a trait set for this tick. See traits.
play_sound("path")
Plays a sound once, for that player alone.
set_fx("look" or none, percent)
A look over their own view, 1% to 100% strong (100 without a percent): one of Forge's screen effects by its name, "Warm", "Cold", "Sepia", "Black and white", "Vivid", "Faded", "Haze", "Blood", "Toxic", "Golden", "Bright", "Bleached", "Rich", "Dim", "Colorblind", "Next Gen", "Juicy", "Nova", "Olde Timey", "Pen and Ink", "Dusk", "Eerie" or "Golden Hour". none takes it off.
set_ui_menu(true), is_ui_menu_open()
Opens or closes their script menu; 1 while it's open. On a controller the D-pad walks its clickable widgets and A clicks.
is_button_held(button.ability_1)
(condition) True while they hold that button. See buttons.

Movement and aim

set_movement(share, percent or none)
A share of how their bodies move on foot, in percent of the body's own value, 0 to 1000; none gives the body's own again. Kept until changed, and the same on every PC. The shares: run_speed and crouch_speed, the speeds they reach; acceleration and air_acceleration, how fast they gather speed on the ground and in the air while the stick is pushed; deceleration and air_deceleration, how fast they lose it once it's let go. set_movement(air_deceleration, 0) keeps a body's speed through the air until it lands.
get_view_yaw(), get_view_pitch()
Where they look, in degrees: yaw from the world's x axis toward y, 0 to 360; pitch up, −90 to 90. Thousandths in fine units.
get_crosshair_x(), get_crosshair_y(), get_crosshair_z(), has_crosshair_point(), get_crosshair_obj()
The point their aim meets within 100 Forge units, the level included; (condition) whether there is one; and the object there, as get_crosshair_target() gives it.
is_airborne(), is_crouched()
(conditions) Whether their body is in the air, and whether it's crouched more than halfway down. Neither without a body on foot.

A body's own speed through the world is the object's: set_velocity, add_velocity, get_velocity_x and is_grounded.

Weapons and damage

get_weapon(primary), get_weapon(secondary)
The weapon in the body's hands, and the other it carries.
set_weapon(weapon)
The weapon the mode keeps in their hands: a name such as battle_rifle, or a weapon's tag path, including a mod's or another game's weapon loaded on this map. Given at once, again to each new body, and again if they drop it. none stops.
set_secondary_weapon(weapon)
The weapon the mode keeps beside the one in their hands, their second weapon, named as set_weapon names one. Given at once, in place of the other weapon they carried when they carry two, and to each new body. A body that already carries one of that weapon keeps it; one they drop isn't given again. none stops.
get_ammo(), set_ammo(rounds)
The rounds of the weapon in their hands, 0 to 999.
refill_ammo()
Every weapon the living player carries gets a full magazine and its most rounds.
give_equipment(name)
Equipment for their body to use, in place of what it carried; none takes it away. See give equipment.
set_weapon_pickup(weapon, 0 or 1)
Whether they may pick up a weapon: a weapon's name, a weapon's tag path, or all. all, 0 bars every weapon and all, 1 lifts every bar; at most 16 bars. The mode's own gives still arm them.
set_damage_modifier(percent)
The damage they deal, 10% to 300% of their own.
set_damage_resistance(percent)
How much damage they shrug off: what they take is divided by this, 10% to 1000%.
set_lethal_damage(0 or 1)
Whether their damage to other players kills outright.

Vehicles and seats

get_vehicle()
The vehicle the body rides.
get_seat()
The seat's number in the vehicle; −1 on foot.
is_driver()
(condition) The body has a driver's seat.
force_into_vehicle(vehicle)
The body takes a free seat of the vehicle it may take, the driver's first, wherever it is; nothing when none is free or the vehicle is overturned. The script sees the seat at once: get_vehicle, get_seat and is_driver read it in the same tick when a player on foot is forced into a vehicle with a seat no player sits in, and the game's own answer follows the next tick.
force_into_vehicle(vehicle, seat)
That seat alone, by its number in the vehicle (as get_seat() reads one), if it's free and theirs to take. get_seat() read in the same tick is certain for the driver's seat; for another seat it's the game's own answer from the next tick on.
set_vehicle_exit_allowed(0 or 1)
Whether they may leave a seat themselves. The script still takes them out, with force_into_vehicle(no_object).
vehicle.get_driver(), vehicle.get_seat_occupant(seat)
The player driving a vehicle, or in its seat of that number; no_player for none.
vehicle.get_occupant_count(), vehicle.get_seat_count()
The players riding a vehicle, and the seats it has.
set_respawn_vehicle(name)
Each new body rides a new vehicle of this kind, made where it stands: a stock vehicle's name such as mongoose, a vehicle's tag path, or none to stop. The player's empty one from a life before goes.
set_driver_use(vehicles, 0 or 1)
Whether they may take the driver's or pilot's seat: vehicle (every one), a kind of vehicle, a stock vehicle's name such as hornet, or a vehicle's tag path. They still ride as passengers and gunners; vehicle, 1 lifts every bar. At most 16 bars.
set_vehicle_use(0 or 1), set_turret_use(0 or 1)
Whether their bodies may ride vehicles, or use turrets. See health, shields and seats.

The body

set_biped(body)
Moves a living player into a living, unattached biped no other player has. See players in other bodies.
set_max_health(percent), set_max_shields(percent)
Their bodies' health and shields, 1% to 1000% of the normal, for every life from now on.
set_camera_mode(0 or 1), get_camera_mode()
0 Halo 3's camera, 1 third person on foot. Vehicles and death keep Halo 3's.
get_squad(), set_squad(n), get_last_deployment_class()
See squads and classes.
set_primary_respawn_object(object), set_respawn_time(seconds)
See spawning and reviving.
set_model, set_armor, set_armor_color, set_visor_color, reset_look
See looks.

Teams and the game

team[0].score
The team's score: its players' scores added up. Read only.
team[0].has_any_players()
(condition) True when someone's on the team.
team[0].has_alliance_status(team[1], enemies)
(condition) Tests two teams, with allies, enemies or neutral: a team is allied with itself, two different teams are enemies, and the neutral team is neutral. It doesn't change alliances.
team[0].end_round()
Ends the round with this team as winner. Needs a team game and an occupied playable team; a neutral or empty team stops the script.
team[0].get_native_score()
The team's score in the game type itself, such as Territories' points.
team[0].get_territory_count()
The territories it holds.
team[0].get_vip()
The team's VIP in a Halo 3 VIP game; no_player in any other game type, or while the team has none.
team[0].get_player_count(), get_living_player_count(), get_squad_player_count(squad)
A team's players in the game, those alive, and those of one of its squads.
team[0].set_name("Squad %n", 1), team[0].set_color(255, 140, 0)
See team names and colors.
game.end_round()
Ends the round. Points the script gave first still count; the round has no chosen winner, so the score decides. A second call in the same tick, or one after the round has ended, changes nothing.
game.get_round()
The round's number, 0 the first.
game.get_tick()
The ticks run since the round began, 1 on the first. Count ticks and take a remainder where a timer would do.
game.get_ticks_per_second()
The game's ticks a second, 30 or 60: mod(game.get_tick(), game.get_ticks_per_second()) == 0 is once a second, without a timer.
game.get_juggernaut()
The Juggernaut in a Halo 3 Juggernaut game; no_player in any other, or while nobody is.
game.get_current_hill()
The active hill's object in a Halo 3 King of the Hill game; no_object in any other.
game.raycast(x1, y1, z1, x2, y2, z2)
A line between two points, which the host follows through the level and its objects. From the next tick on, game.raycast_hit() (condition) says whether it met something, game.get_raycast_x(), _y() and _z() give the point, and game.get_raycast_hit_object() the object there, no_object for the level. One line at a time: a new one takes the last one's place.
game.get_game_type()
The game type's number.
game.get_territory_count()
The map's territories in a Territories game.
game.set_ai_team(label, team)
See Forge and AI.
game.play_sound("path"), game.start_looping_sound, game.stop_looping_sound
See sounds.
game.respawn_objects("label")
See taken away and made again.

Scripted team changes can leave a team empty without the game type's last-team forfeit, so give the mode a round-ending rule of its own. A dedicated server can also turn on one_team_ends_scripted_games (Experimental, off by default): a scripted game then ends, as Halo 3's own game types do, once only one team has been left for 5 seconds, unless the mode ends the round first. A game that began with one team is never ended this way, and a round in which the mode itself gathers everyone on one team, such as an Infection round's start, ends nothing.

Health, shields and seats

A script can give any character more or less health and shields than Halo 3 does, and keep it out of vehicles or turrets. On a body, such as current_player.biped:

max_health = 200, max_shields = 50
The maximum health and shields, in percent of the character's own, 1 to 1000. 100 is as Halo 3 has it; 200 takes twice the damage to drain. Shields change only on characters that have them. Changing a maximum keeps the share of each that's left.
health = 50, shields = 150
How much is left right now, in percent of the maximum. health takes 1 to 100; use kill(false) for none. shields takes 0 to 400, past 100 an overshield like an overshield powerup's. Health and shields set lower wait to recharge, as after a hit.
set_vehicle_use(false)
Keeps the character out of every vehicle seat: driver, gunner and passenger, a Warthog's or Scorpion's gun included.
set_turret_use(false)
Keeps it out of turrets: the stand-alone guns, such as the machine-gun turret, plasma cannon and missile pod, and the Shade.
  • Refused seats: a player trying to get in sees Halo 3's “can't use” prompt, AI stops choosing those seats, and a character already in one gets out. true lets it in again.
  • On a player's body the values belong to the player and stay for every life from then on; each new life starts full at the new maximum.
  • On an AI's body they belong to that AI, and on any other object, such as a vehicle, to that object.
  • The host sets them, and every player sees the result.

UNSC vs Covenant vs Flood gives each of its classes its own this way, on every body:

Part of faction-battlefront.rmeg
-- Hunters: twice the health, too big for any seat.
if class == 33 then
    current_player.set_max_health(200)
    current_player.set_vehicle_use(false)
    current_player.set_turret_use(false)
end