Halo Script (HSC), also known as Blam Scripting Language (BSL), is a scripting language that map designers can use to have greater control over how their map works. It is primarily used in controlling the mission structure of single player maps, but can also be used to achieve certain effects in multiplayer, such as synchronizing destructable vehicles.

Halo Script is based on Lisp. Scripts are compiled into the scenario of a map using Sapien. Scripts can be extracted from a scenario using Refinery.

Compiling a script into a scenario

Sapien searches for scripts in the data version of your scenario's path. For example, if your scenario is tags\levels\test\tutorial\tutorial.scenario, you would place your script file in data\levels\test\tutorial\scripts\. Your script file can be named anything, but must have a .hsc file extension.

Open your scenario in Sapien, then under the file menu, click "Compile Scripts". If there are any compilation errors, Sapien will display them in the Game View screen.

HSC reference

Additional important script engine info below

Basics

Scripts have the following structure:

(script <script type> <return type (static scripts only)> <script name>
  <code>
)

Example:

(script startup say_this_map_r0x
  (sv_say "This map r0xx0rz!")
)

Global variables are defined with the following syntax:

(global <global type> <global name> <value(s)>)

Example:

(global boolean kornman_is_leet true)

Script types

Type

Comments

Example

continuous

Runs every tick (simulation frame of the engine), at 30 ticks per second.

(script continuous kill_players_in_zone
  (if (volume_test_object kill_volume (list_get (players) 0))
    (unit_kill (unit (list_get (players) 0)))
  )
  (if (volume_test_object kill_volume (list_get (players) 1))
    (unit_kill (unit (list_get (players) 1)))
  )
)
dormant

Sleeps until started with wake, runs until there are no instructions left, then stops. Calling wake a second time will not restart the script.

(script dormant save_valley_canyon
  (sleep_until (= 0 (ai_living_count valley_canyon)) 10)
  (game_save_no_timeout)
)
startup

Performed only on map startup.

(script startup mission_a30
  (hud_show_motion_sensor false)
  (fade_out 0 0 0 0)
  (print "mission script is running")
  (ai_allegiance player human)
  ;...
)
static

Performed when called from another script.

(script static "unit" player0
  (unit (list_get (players) 0))
)
stub

A stub script by itself does nothing. It allows you to pre-declare a static script without providing a script body. This allows other scripts to invoke a static script without the full function body being declared yet.

The script you override a stub with must have the same "signature" ( i.e. name, parameters, and return type). A stub cannot be declared more than once. The full implementation of a stub may be placed in another script file.

If you're familiar with C function prototypes, this is very similar.

(script stub object player0)

Value types

Type

Details

Example

boolean

A value that is true or false

true
false
1
0

real

Floating point (decimal) value
Value Range: 3.4E +/- 38 (6 digits)

3.000000

short

Short integer value
Value Range: +/- 32,767

2

long

Long integer value
Value Range: +/- 2,147,483,648

2000000000

string

String of characters in double quotes
Max number of characters: 32

"This is a string."

trigger_volume

A "Trigger Volumes" value (a block in the scenario tag)

cutscene_flag

A "Cutscene Flags" value (a block in the scenario tag)

cutscene_camera_point

A "Cutscene Camera Points" value (a block in the scenario tag)

cutscene_title

A "Cutscene Titles" value (a block in the scenario tag)

cutscene_recording

A "Cutscene Recording" value that isn't in the public HaloCE scenario tag?

device_group

A "Device Groups" value (a block in the scenario tag)

ai

An "Encounters" value

ai_command_list

A "Command Lists" value (a block in the scenario tag)

starting_profile

A "Player Starting Profile" value (a block in the scenario tag)

conversation

A "AI Conversations" value (a block in the scenario tag)

navpoint
hud_message

HUD message text

object_list

An object list

sound

Sound

effect

Effect

damage

Damage Effect

looping_sound

Sound Looping

animation_graph

Model Animations

actor_variant

Actor variant

damage_effect

Damage Effect

object_definition
game_difficulty

easy
normal
hard
impossible

team

player
human
covenant
flood
sentinal

ai_default_state

none
sleeping
alert
moving
guarding
searching
fleeing

actor_type

ie, elite

hud_corner

top_left
top_right
bottom_left
bottom_right

object

Object

unit

Unit

vehicle

Vehicle

weapon

Weapon

device

Device

scenery

Scenery

object_name

An "Object Names" value (a block in the scenario tag)

unit_name

A "Bipeds" value (a block in the scenario tag)

vehicle_name

A "Vehicles" value (a block in the scenario tag)

weapon_name

A "Weapons" value (a block in the scenario tag)

device_name

A "Device" value (a block in the scenario tag)

scenery_name

A "Scenery" value (a block in the scenario tag)

Operators and keywords

Expression

Example

(+ <number_1> <number_2> [... <number_n>])

Returns the sum of all specified expressions.

(+ 5 6 7 8 9)
; returns: 35
(- <number_1> <number_2>)

Returns the difference of two expressions.

(- 10 5)
; returns: 5
(* <number_1> <number_2> [... <number_n>])

Returns the product of all specified expressions.

(* 5 5)
; returns: 25
(* 5.5 6)
; returns: 33
(/ <number_1> <number_2>)

Returns the quotient of two expressions.

(/ 10 5)
; returns: 2
(/ 2.5 2)
; returns: 1.25
(= <expression_1> <expression_2>)

Returns true if two expressions are equal.

(= (hud_get_timer_ticks) 0)
(!= <expression_1> <expression_2>)

Returns true if two expressions are not equal.

(!= (hud_get_timer_ticks) 0)
(> <number_1> <number_2>)

Returns true if number_1 is larger than number_2.

(> 10 5)
; returns: true
(> 5 10)
; returns: false
(< <number_1> <number_2>)

Returns true if number_1 is smaller than number_2.

(> 4 8)
; returns: true
(> 8 4)
; returns: false
(>= <number_1> <number_2>)

Returns true if number_1 is larger than or equal number_2.

(>= 10 10)
; returns: true
(>= 5 10)
; returns: false
(<= <number_1> <number_2>)

Returns true if number_1 is smaller than or equal number_2.

(>= 4 4)
; returns: true
(>= 8 4)
; returns: false
(and <boolean_1> <boolean_2> [... <boolean_n>])

Returns true if all specified expressions are true.

(and (player_action_test_action) true)
(begin
  <expression_1>
  <expression_2>
  [... <expression_n>]
)

Returns the last expression in a sequence after evaluating the sequence in order

(begin
  something
  something_else
  20
)
; returns: 20
(begin_random
  <expression_1>
  <expression_2>
  [... <expression_n>]
)

Evaluates the sequence of expressions in random order and returns the last value evaluated. This function can contain up to 32 expressions.

(begin_random
  something
  something_else
  20
)
(cond
  (<boolean_1> <result_1>)
  [(<boolean_2> <result_2>) [...]]
)

Returns the value associated with the first true condition. Has no default value.

(cond
  (false_val 10)
  (true_val 20)
)
; returns: 20
(global <type> <name> <inital value>)

Makes a new global script variable.

(global boolean bsl_sucks true)
(if <boolean>
  <expression>
  [<else>]
)

Returns one of two values based on the value of a condition.

(if (bsl_sucks)
  (print "Stop whining.")
)
(inspect <expression>)

Prints the value of an expression to the screen for debugging purposes.

(inspect (+ 3 4))
; outputs: 7
(min <number_1> <number_2> [... <number_n>])

Returns the minimum of all specified expressions.

(min 60 5 10)
; returns: 5
(max <number_1> <number_2> [... <number_n>])

Returns the maximum of all specified expressions.

(max 60 5 10)
; returns: 60
(not <boolean>)

Returns the opposite of the expression.

(not bsl_sucks)
; returns: false
(or <boolean_1> <boolean_2> [... <boolean_n>])

Returns true if any specified expressions are true.

(or (player_action_test_action) true)
; returns: true
(script <script type> [<return type>] <name>)

Defines a new script.

See above example

(set <variable name> <value>)

Sets the value of a defined global variable.

(set bsl_sucks true)
(sleep <short> [<script>])

Pauses execution of this script (or, optionally, another script) for the specified number of ticks (1 tick = 1/30 second)

(sleep 30 more_weapons)
(sleep_until <condition> [short_1] [short_2])

Pauses execution of this script until condition is true. By default, this checks once per second. If short_1 is specified, it checks every short_1 ticks instead. By default, this will await the condition indefinitely. short_2 can be used to timeout after a certain number of ticks, instead. After the timeout, the script will continue on as if condition became true.

(sleep_until false 5 600)
(wake <script name>)

Wakes a sleeping or dormant script in the next update.

(wake more_weapons)
(thread_sleep <long>)

Sleeps the calling thread for the specified number of ms.

(thread_sleep 20)
; returns: sleeps for 20ms

Functions

Function

(activate_nav_point_flag <navpoint> <unit> <cutscene_flag> <real>)

Activates a nav point type <string> attached to (local) player <unit> anchored to a flag with a vertical offset <real>. If the player is not local to the machine, this will fail.

(activate_nav_point_object <navpoint> <unit> <object> <real>)

Activates a nav point type attached to (local) player anchored to an object with a vertical offset . If the player is not local to the machine, this will fail.

(activate_team_nav_point_flag <navpoint> <team> <cutscene_flag> <real>)

Activates a nav point type attached to a team anchored to a flag with a vertical offset . If the player is not local to the machine, this will fail.

(activate_team_nav_point_object <navpoint> <team> <object> <real>)

Activates a nav point type attached to a team anchored to an object with a vertical offset . If the player is not local to the machine, this will fail.

(ai_actors <ai>)

Converts an ai reference to an object list

(ai_allegiance <team> <team>)

Creates an allegiance between two teams

(ai_allegiance_broken <team> <team>)

Returns whether two teams have an allegiance that is currently broken by traitorous behavior

(ai_allegiance_remove <team> <team>)

Destroys an allegiance between two teams

(ai_allow_charge <ai> <boolean>)

Either enables or disables charging behavior for a group of actors

(ai_allow_dormant <ai> <boolean>)

Either enables or disables automatic dormancy for a group of actors

(ai_attach <unit> <ai>)

Attaches the specified unit to the specified encounter

(ai_attach_free <unit> <actor_variant>)

Attaches a unit to a newly created free actor of the specified type

(ai_attack <ai>)

Makes the specified platoon(s) go into the attacking state

(ai_automatic_migration_target <ai> <boolean>)

Enables or disables a squad as being an automatic migration target

(ai_berserk <ai> <boolean>)

Forces a group of actors to start or stop berserking

(ai_braindead <ai> <boolean>)

Makes a group of actors braindead, or restores them to life (in their initial state)

(ai_braindead_by_unit <object_list> <boolean>)

Makes a list of objects braindead, or restores them to life. If you pass in a vehicle index, it makes all actors in that vehicle braindead (including any built-in guns).

(ai_command_list <ai> <ai_command_list>)

Tells a group of actors to begin executing the specified command list

(ai_command_list_advance <ai>)

Tells a group of actors that are running a command list that they may advance further along the list (if they are waiting for a stimulus)

(ai_command_list_advance_by_unit <unit>)

Just like ai_command_list_advance but operates upon a unit instead

(ai_command_list_by_unit <unit> <ai_command_list>)

Tells a named unit to begin executing the specified command list

(ai_command_list_status <object_list>)

Gets the status of a number of units running command lists: 0 = none, 1 = finished command list, 2 = waiting for stimulus, 3 = running command list

(ai_conversation_status <conversation>)

Returns the status of a conversation (0=none, 1=trying to begin, 2=waiting for guys to get in position, 3=playing, 4=waiting to advance, 5=could not begin, 6=finished successfully, 7=aborted midway)

(ai_conversation <conversation>)

Tries to add an entry to the list of conversations waiting to play. Returns FALSE if the required units could not be found to play the conversation, or if the player is too far away and the 'delay' flag is not set.

(ai_conversation_advance <conversation>)

Tells a conversation that it may advance

(ai_conversation_line <conversation>)

Returns which line the conversation is currently playing, or 999 if the conversation is not currently playing.

(ai_conversation_stop <conversation>)

Stops a conversation from playing or trying to play

(ai_debug_communication_focus <string(s)>)

Focuses (or stops focusing) a set of unit vocalization types

(ai_debug_communication_ignore <string(s)>)

Ignores (or stops ignoring) a set of AI communication types when printing out communications

(ai_debug_communication_suppress <string(s)>)

Suppresses (or stops suppressing) a set of AI communication types

(ai_debug_sound_point_set)

Drops the AI debugging sound point at the camera location

(ai_debug_speak <string>)
(ai_debug_speak "pain minor")

Makes the currently selected AI speak a vocalization

(ai_debug_speak_list <string>)
(ai_debug_speak_list "involuntary")

Makes the currently selected AI speak a list of vocalizations

(ai_debug_teleport_to <ai>)

Teleports all players to the specified encounter

(ai_debug_vocalize <string> <string>)

Makes the selected AI vocalize

(ai_defend <ai>)

Makes the specified platoon(s) go into the defending state

(ai_deselect)

Clears the selected encounter

(ai_detach <unit>)

Detaches the specified unit from all AI

(ai_dialogue_triggers <boolean>)
(ai_dialogue_triggers true)
(ai_dialogue_triggers false)

Turns impromptu dialogue on or off

(ai_disregard <object_list> <boolean>)
(ai_disregard (players) true)
(ai_disregard (players) false)

If true, forces all actors to completely disregard the specified units, otherwise lets them acknowledge the units again.

(ai_erase <ai>)

Erases the specified encounter and/or squad

(ai_erase_all)

Erases all AI

(ai_exit_vehicle <ai>)

Tells a group of actors to get out of any vehicles that they are in

(ai_follow_distance <ai> <real>)

Sets the distance threshold which will cause squads to migrate when following someone

(ai_follow_target_ai <ai> <ai>)

Sets the follow target for an encounter to be a group of AI (encounter, squad or platoon)

(ai_follow_target_disable <ai>)

Turns off following for an encounter

(ai_follow_target_players <ai>)

Sets the follow target for an encounter to be the closest player. AI follow their target by moving to firing positions near their target with the same letter label.

(ai_follow_target_unit <ai> <unit>)

Sets the follow target for an encounter to be a specific unit.

(ai_force_active <ai> <boolean>)

Forces an encounter to remain active (i.e. not freeze in place) even if there are no players nearby

(ai_force_active_by_unit <unit> <boolean>)

Forces a named actor that is NOT in an encounter to remain active (i.e. not freeze in place) even if there are no players nearby

(ai_free <ai>)

Removes a group of actors from their encounter and sets them free

(ai_free_units <object_list>)

Removes a set of units from their encounter (if any) and sets them free

(ai_going_to_vehicle <unit>)

Return the number of actors that are still trying to get into the specified vehicle

(ai_go_to_vehicle <ai> <unit> <string>)

Tells a group of actors to get into a vehicle, in the substring-specified seats (e.g. passenger for pelican). Does not interrupt any actors who are already going to vehicles.

(ai_go_to_vehicle_override <ai> <unit> <string>)

Tells a group of actors to get into a vehicle, in the substring-specified seats (e.g. passenger for pelican). Any actors who are already going to vehicles will stop and go to this one instead!

(ai_grenades <boolean>)

Turns grenade inventory on or off

(ai_is_attacking <ai>)

Returns whether a platoon is in the attacking mode (or if an encounter is specified, returns whether any platoon in that encounter is attacking)

(ai_kill <ai>)

Instantly kills the specified encounter and/or squad

(ai_kill_silent <ai>)

Instantly and silently (no animation or sound played) kills the specified encounter and/or squad

(ai_lines)

Cycles through AI line-spray modes

(ai_living_count <ai>)

Return the number of living actors in the specified encounter and/or squad

(ai_living_fraction <ai>)

Return the fraction [0-1] of living actors in the specified encounter and/or squad

(ai_look_at_object <unit> <object>)

Tells an actor to look at an object until further notice

(ai_magically_see_encounter <ai> <ai>)

Makes one encounter magically aware of another

(ai_magically_see_players <ai>)

Makes an encounter magically aware of nearby players

(ai_magically_see_unit <ai> <unit>)

Makes an encounter magically aware of the specified unit

(ai_maneuver <ai>)

Makes all squads in the specified platoon(s) maneuver to their designated maneuver squads

(ai_maneuver_enable <ai> <boolean>)

Enables or disables the maneuver/retreat rule for an encounter or platoon. The rule will still trigger, but none of the actors will be given the order to change squads.

(ai_migrate <ai> <ai>)

Makes all or part of an encounter move to another encounter

(ai_migrate_and_speak <ai> <ai> <string>)

Makes all or part of an encounter move to another encounter, and say their advance or retreat speech lines.

(ai_migrate_by_unit <object_list> <ai>)

Makes a named vehicle or group of units move to another encounter

(ai_nonswarm_count <ai>)

Return the number of non-swarm actors in the specified encounter and/or squad

(ai_place <ai>)

Places the specified encounter on the map

(ai_playfight <ai> <boolean>)

Sets an encounter to be playfighting or not

(ai_prefer_target <object_list> <boolean>)

If true, ALL enemies will prefer to attack the specified units. If false, removes the preference.

(ai_reconnect)

Reconnects all AI information to the current structure bsp (use this after you create encounters or command lists in sapien, or place new firing points or command list points)

(ai_renew <ai>)

Refreshes the health and grenade count of a group of actors, so they are as good as new

(ai_retreat <ai>)

Makes all squads in the specified platoon(s) maneuver to their designated maneuver squads

(ai_select <ai>)

Selects the specified encounter

(ai_set_blind <ai> <boolean>)

Enables or disables sight for actors in the specified encounter

(ai_set_current_state <ai> <ai_default_state>)

Sets the current state of a group of actors. WARNING: may have unpredictable results on actors that are in combat.

(ai_set_deaf <ai> <boolean>)

Enables or disables hearing for actors in the specified encounter

(ai_set_respawn <ai> <boolean>)

Enables or disables respawning in the specified encounter

(ai_set_return_state <ai> <ai_default_state>)

Sets the state that a group of actors will return to when they have nothing to do

(ai_set_team <ai> <team>)

Makes an encounter change to a new team

(ai_spawn_actor <ai>)

Spawns a single actor in the specified encounter and/or squad

(ai_status <ai>)

Returns the most severe combat status of a group of actors (0=inactive, 1=noncombat, 2=guarding, 3=search/suspicious, 4=definite enemy(heard or magic awareness), 5=visible enemy, 6=engaging in combat)

(ai_stop_looking <unit>)

Tells an actor to stop looking at whatever it's looking at

(ai_strength <ai>)

Return the current strength (average body vitality from 0-1) of the specified encounter and/or squad

(ai_swarm_count <ai>)

Return the number of swarm actors in the specified encounter and/or squad

(ai_teleport_to_starting_location <ai>)

Teleports a group of actors to the starting locations of their current squad(s)

(ai_teleport_to_starting_location_if_unsupported <ai>)

Teleports a group of actors to the starting locations of their current squad(s), only if they are not supported by solid ground (i.e. if they are falling after switching BSPs).

(ai_try_to_fight <ai> <ai>)

Causes a group of actors to preferentially target another group of actors

(ai_try_to_fight_nothing <ai>)

Removes the preferential target setting from a group of actors

(ai_try_to_fight_player <ai>)

Causes a group of actors to preferentially target the player

(ai_vehicle_encounter <unit> <ai>)

Sets a vehicle to "belong" to a particular encounter/squad. Any actors who get into the vehicle will be placed in this squad. Vehicles potentially drivable by multiple teams need their own encounter!

(ai_vehicle_enterable_actors <unit> <ai>)

Sets a vehicle as being impulsively enterable for a certain encounter/squad of actors

(ai_vehicle_enterable_actor_type <unit> <actor_type>)

Sets a vehicle as being impulsively enterable for actors of a certain type (grunt, elite, marine etc)

(ai_vehicle_enterable_disable <unit>)

Disables actors from impulsively getting into a vehicle (this is the default state for newly placed vehicles)

(ai_vehicle_enterable_distance <unit> <real>)

Sets a vehicle as being impulsively enterable for actors within a certain distance

(ai_vehicle_enterable_team <unit> <team>)

Sets a vehicle as being impulsively enterable for actors on a certain team

(attract_mode_start)

N/A in pc

(bind <string> <string> <string>)

Binds an input device/button combination to a game control

(breakable_surfaces_enable <boolean>)
(breakable_surfaces_enable false)

Enables or disables breakability of all breakable surfaces in the level

(breakable_surfaces_reset)

Restores all breakable surfaces

(camera_control <boolean>)
(camera_control true)
(camera_control false)

Toggles script control of the camera

(camera_set <cutscene_camera_point> <short>)
(camera_set somewhere_point 100)

Moves the camera to the specified camera point over the specified number of ticks

(camera_set_animation <animation_graph> <string>)

Begins a prerecorded camera animation

(camera_set_dead <unit>)
(camera_set_dead (player0))

Makes the scripted camera zoom out around a unit as if it were dead

(camera_set_first_person <unit>)
(camera_set_first_person (player0))

Makes the scripted camera follow a unit

(camera_set_relative <cutscene_camera_point> <short> <object>)
(camera_set_relative somewhere_point 200 warthog_mp_1)

Moves the camera to the specified camera point over the specified number of ticks (position is relative to the specified object)

(camera_time)

Returns the number of ticks remaining in the current camera interpolation

(change_team <short>)
(change_team 0)
; changes you to red
(change_team 1)
; changes you to blue
(change_team 2)
; auto balance

Change your team (0=red, 1=blue, else=auto)

(cheats_load)

Reloads the cheats.txt file

(cheat_active_camouflage)

Gives the player active camouflage

(cheat_active_camouflage_local_player <short>)
(cheat_active_camouflage_local_player 1)

Gives the player active camouflage

(cheat_all_powerups)

Drops all powerups near player

(cheat_all_vehicles)

Drops all vehicles on player

(cheat_all_weapons)

Drops all weapons near player

(cheat_spawn_warthog)

Drops a warthog near player

(cheat_teleport_to_camera)

Teleports player to camera location

(checkpoint_load <string>)

Load a saved checkpoint

(checkpoint_save)

Save last solo checkpoint

(cinematic_abort)

Aborts a cinematic

(cinematic_screen_effect_set_convolution <short> <short> <real> <real> <real>)

Sets the convolution effect

(cinematic_screen_effect_set_filter <real> <real> <real> <real> <boolean> <real>)

Sets the filter effect

(cinematic_screen_effect_set_filter_desaturation_tint <real> <real> <real>)

Sets the desaturation filter tint color

(cinematic_screen_effect_set_video <short> <real>)

Sets the video effect: <noise intensity[0,1]>, <overbright: 0=none, 1=2x, 2=4x>

(cinematic_screen_effect_start <boolean>)

Starts screen effect; pass true to clear

(cinematic_screen_effect_stop)

Returns control of the screen effects to the rest of the game

(cinematic_set_near_clip_distance <real>)
(cinematic_set_title <cutscene_title>)

Activates the chapter title

(cinematic_set_title_delayed <cutscene_title> <real>)

Activates the chapter title, delayed by seconds

(cinematic_show_letterbox <boolean>)
(cinematic_show_letterbox true)
(cinematic_show_letterbox false)

Sets or removes the letterbox bars

(cinematic_skip_start_internal)
(cinematic_skip_stop_internal)
(cinematic_start)

Initializes game to start a cinematic (interruptive) cutscene

(cinematic_stop)

Initializes the game to end a cinematic (interruptive) cutscene

(cinematic_suppress_bsp_object_creation <boolean>)
(cinematic_suppress_bsp_object_creation true)
(cinematic_suppress_bsp_object_creation false)

Suppresses or enables the automatic creation of objects during cutscenes due to a bsp switch

(config_one_control <string>)

Test function to configure a single control

(connect <string> <string>)

Attempt to connect to server - use ip:port password as parameters

(crash <string>)
(crash "Something is wrong")

Crashes (for debugging)

(custom_animation <unit> <animation_graph> <string> <boolean>)

Starts a custom animation playing on a unit (interpolates into animation if last parameter is true)

(custom_animation_list <object_list> <animation_graph> <string> <boolean>)

Starts a custom animation playing on a unit list (interpolates into animation if last parameter is true)

(damage_new <damage> <cutscene_flag>)
(damage_new "scenery\emitters\burning_flame\flame" enter_lava_flag)

Causes the specified damage at the specified flag

(damage_object <damage> <object>)
(damage_object "weapons\assault rifle\bullet" (player0))

Causes the specified damage at the specified object

(deactivate_nav_point_flag <unit> <cutscene_flag>)

Deactivates a nav point type attached to a player anchored to a flag

(deactivate_nav_point_object <unit> <object>)

Deactivates a nav point type attached to a player anchored to an object

(deactivate_team_nav_point_flag <team> <cutscene_flag>)

Deactivates a nav point type attached to a team anchored to a flag

(deactivate_team_nav_point_object <team> <object>)

Deactivates a nav point type attached to a team anchored to an object

(debug_camera_load)

Loads the saved camera position and facing

(debug_camera_save)

Saves the camera position and facing

(debug_memory)

Dumps memory leaks

(debug_memory_by_file)

Dumps memory leaks by source file

(debug_memory_for_file <string>)
(debug_memory_for_file "\halopc\haloce\source\tag_files\tag_groups.c")

Dumps memory leaks from the specified source file

(debug_sounds_distances <string> <real> <real>)

Changes the minimum and maximum distances for all sound classes matching the substring

(debug_sounds_enable <string> <boolean>)

Enables or disabled all sound classes matching the substring

(debug_sounds_wet <string> <real>)

Changes the reverb level for all sound classes matching the substring

(debug_tags)

Writes all memory being used by tag files into tag_dump.txt

(debug_teleport_player <short> <short>)
(delete_save_game_files)

Delete all custom profile files

(device_get_position <device>)

Gets the current position of the given device (used for devices without explicit device groups)

(device_get_position <device>)

Gets the current position of the given device (used for devices without explicit device groups)

(device_get_power <device>)

Gets the current power of a named device

(device_group_change_only_once_more_set <device_group> <boolean>)

true allows a device to change states only once

(device_group_get <device_group>)

Returns the desired value of the specified device group

(device_group_set <device_group> <real>)

Changes the desired value of the specified device group

(device_group_set_immediate <device_group> <real>)

Instantaneously changes the value of the specified device group

(device_one_sided_set <device> <boolean>)

true makes the given device one-sided (only able to be opened from one direction), false makes it two-sided

(device_operates_automatically_set <device> <boolean>)

true makes the given device open automatically when any biped is nearby, false makes it not

(device_set_position <device> <real>)
(device_set_position <device> 1.0)

Set the desired position of the given device (used for devices without explicit device groups)

(device_set_position_immediate <device> <real>)
(device_set_position_immediate <device> 1.0)

Instantaneously changes the position of the given device (used for devices without explicit device groups

(device_set_power <device> <real>)
(device_set_power <device> 1.0)

Immediately sets the power of a named device to the given value

(display_scenario_help <short>)
(display_scenario_help 1)

Display in-game help dialog

(effect_new <effect> <cutscene_flag>)
(effect_new "effects\coop teleport" teleporting_flag)

Starts the specified effect at the specified flag

(effect_new_on_object_marker <effect> <object> <string>)
(effect_new_on_object_marker "effects\burning large" warthog_mp "driver")

Starts the specified effect on the specified object at the specified marker

(enable_hud_help_flash <boolean>)
(enable_hud_help_flash true)
(enable_hud_help_flash false)

Starts/stops the help text flashing

(error_overflow_suppression <boolean>)
(error_overflow_suppression true)
(error_overflow_suppression false)

Enables or disables the suppression of error spamming

(fade_in <real> <real> <real> <short>)
(fade_in 0.0 0.0 0.0 100)

Does a screen fade in from a particular color in the amount of ticks

(fade_out <real> <real> <real> <short>)
(fade_out 1.0 1.0 1.0 100)

Does a screen fade out to a particular color in the amount of ticks

(fast_setup_network_server <string> <string> <boolean>)

Sets up a network server with the given map name, game variant, and true for remote connections, false for not

(game_all_quiet)

Returns false if there are bad guys around, projectiles in the air, etc.

(game_difficulty_get)

Returns the current difficulty setting, but lies to you and will never return easy, instead returning normal

(game_difficulty_get_real)

Returns the actual current difficulty setting without lying

(game_difficulty_set <game_difficulty>)
(game_difficulty_set easy)
(game_difficulty_set normal)
(game_difficulty_set hard)
(game_difficulty_set impossible)

Changes the difficulty setting for the next map to be loaded

(game_is_cooperative)

Returns true if the game is cooperative

(game_lost)

Causes the player to revert to their previous saved checkpoint. For example, this is used when Keyes dies in Truth and Reconciliation.

(game_revert)

Reverts to last saved game, if any (for testing, the first bastard that does this to me gets it in the head)

(game_reverted)

Don't use this for anything, you black-hearted bastards

(game_safe_to_save)

Returns false if it would be a bad idea to save the player's game right now

(game_safe_to_speak)

Returns false if it would be a bad idea to save the player's game right now

(game_save)

Checks to see if it is safe to save game, then saves (gives up after 8 seconds)

(game_save_cancel)

Cancels any pending game_save, timeout or not. This prevents a checkpoint from being created during a known loss situation.

(game_save_no_timeout)

Checks to see if it is safe to save game, then saves (this version never gives up)

(game_save_totally_unsafe)

Saves disregarding player's current situation

(game_saving)

Checks to see if the game is trying to save a checkpoint

(game_skip_ticks <short>)
(game_skip_ticks 5)

Skips amount of game ticks. ONLY USE IN CUTSCENES!!!

(game_speed <real>)
(game_speed 0.5)

Changes the game speed

(game_time)

Gets ticks elapsed since the start of the game

(game_won)

Causes the player to successfully finish the current level and move on to the next

(garbage_collect_now)

Causes all garbage objects except those visible to a player to be collected immediately

(get_digital_forward_throttle <short>)

Gets the amount of forward throttle applied by digital device stimuli

(get_digital_pitch_increment <short>)

Gets the increment in pitch applied by digital device stimuli

(get_digital_strafe_throttle <short>)

Gets the amount of strafe throttle applied by digital device stimuli

(get_digital_yaw_increment <short>)

Gets the increment in yaw applied by digital device stimuli

(get_gamepad_forward_threshold <short>)

Gets the threshold beyond which gamepad movement is full forward throttle

(get_gamepad_pitch_scale <short>)

Gets the scale for gamepad control of pitch

(get_gamepad_strafe_threshold <short>)

Gets the threshold beyond which gamepad movement is full strafe throttle

(get_gamepad_yaw_scale <short>)

Gets the scale for gamepad control of yaw

(get_mouse_forward_threshold <short>)

Gets the threshold beyond which mouse movement is full forward throttle

(get_mouse_pitch_scale <short>)

Gets the scale for mouse control of pitch

(get_mouse_strafe_threshold <short>)

Gets the threshold beyond which mouse movement is full strafe throttle

(get_mouse_yaw_scale <short>)

Gets the scale for mouse control of yaw

(get_pitch_rate <short>)

Gets the yaw rate for the given player number

(get_yaw_rate <short>)

Gets the yaw rate for the given player number

(hammer_begin <string> <string> <long> <short> <short>)

Hammers the server by connecting and disconnecting repeatedly

(hammer_stop)

Stops hammering the server

(help <string>)
(help cheats_load)

Prints a description of the named function

(hud_clear_messages)

Clears all non-state messages on the hud

(hud_get_timer_ticks)

Returns the ticks left on the hud timer

(hud_help_flash_restart)

Resets the timer for the help text flashing

(input_activate_joy <short> <short>)

Activates an enumerated joystick into a logical joystick slot

(input_deactivate_joy <short>)

Deactivates an enumerated joystick, freeing up the logical joystick slot

(input_find_default <string>)

Test function that looks up a default profile for a deviceid

(input_find_joystick <string>)

Test function to find a joystick by GUID (string representation)

(input_get_joy_count)

Test function to return the number of joysticks enumerated

(input_is_joy_active <short>)

Test function to determine if an enumerated joystick is activated or not

(input_show_joystick_info)

Test function to show the enumerated joystick information for all joystick

(list_count <object_list>)
(list_count the_warthogs)

Returns the number of objects in a list

(list_get <object_list> <short>)
(list_get the_warthogs 3)

Returns an item in an object list

(magic_melee_attack)

Causes player's unit to start a melee attack

(magic_seat_name <string>)

All units controlled by the player will assume the given seat name (valid values are 'asleep', 'alert', 'stand', 'crouch' and 'flee')

(map_name <string>)
(map_name "a10")

Changes the name of the solo player map

(map_reset)

Starts the map from the beginning

(message_metrics_clear)

Clears network messaging metrics

(message_metrics_dump <string>)
(message_metrics_dump "")

Dumps network messaging metrics to given file ("" for default)

(multiplayer_map_name <string>)
(multiplayer_map_name "schwinnzno1_alpha01a")

Changes the name of the multiplayer map

(network_client_dump)

Dumps info on network client

(network_server_dump)

Dumps info on network server

(net_graph_clear)

Clears the net_graph

(net_graph_show <string> <string>)

Changes the net_graph display (bytes/packets, sent/received)

(numeric_countdown_timer_get <short>)
(numeric_countdown_timer_get 1)
(numeric_countdown_timer_get -1)

<digit_index>

(numeric_countdown_timer_restart)

Reset the timer

(numeric_countdown_timer_set <long> <boolean>)
(numeric_countdown_timer_set 15500 false)
(numeric_countdown_timer_set 10000 false)

<milliseconds>, <auto_start>

(numeric_countdown_timer_stop)

Stop the timer

(objects_attach <object> <string> <object> <string>)
(objects_attach chief "right hand" ar1 "")

Attaches the second object to the first; both strings can be empty

(objects_can_see_flag <object_list> <cutscene_flag> <real>)
(objects_can_see_flag the_warthogs tunnel_flag 45)

Returns true if any of the specified units are looking within the specified number of degrees of the flag

(objects_can_see_object <object_list> <object> <real>)
(objects_can_see_object the_warthogs (player0) 90)

Returns true if any of the specified units are looking within the specified number of degrees of the object

(objects_delete_by_definition <object_definition>)

Deletes all objects of type <definition>

(objects_detach <object> <object>)
(objects_detach chief ar1)

Detaches from the given parent object the given child object

(objects_predict <object_list>)
(objects_predict the_bipeds)

Loads textures necessary to draw a objects that are about to come on-screen

(object_beautify <object> <boolean>)
(object_beautify chief true)
(object_beautify chief false)

Makes an object pretty for the remainder of the levels' cutscenes

(object_cannot_take_damage <object_list>)
(object_cannot_take_damage (players))

Prevents an object from taking damage

(object_can_take_damage <object_list>)
(object_can_take_damage (players))

Allows an object to take damage again

(object_create <object_name>)
(object_create warthog_mp_1)

Creates an object from the scenario

(object_create_anew <object_name>)
(object_create_anew banshee_mp_1)

Creates an object, destroying it first if it already exists

(object_create_anew_containing <string>)
(object_create_anew_containing "pelican")

Creates anew all objects from the scenario whose names contain the given substring

(object_create_containing <string>)
(object_create_containing "warthog")

Creates all objects from the scenario whose names contain the given substring

(object_destroy <object>)

Destroys an object

(object_destroy_all)

Destroys all non player objects

(object_destroy_containing <string>)
(object_destroy_containing "pelican")

Destroys all objects from the scenario whose names contain the given substring

(object_pvs_activate <object>)

Just another (old) name for object_pvs_set_object

(object_pvs_clear)

Removes the special place that activates everything it sees

(object_pvs_set_camera <cutscene_camera_point>)

Sets the specified cutscene camera point as the special place that activates everything it sees

(object_pvs_set_object <object>)

Sets the specified object as the special place that activates everything it sees

(object_set_collideable <object> <boolean>)
(object_set_collideable (player0) true)
(object_set_collideable (player0) false)

false prevents any object from colliding with the given object

(object_set_facing <object> <cutscene_flag>)
(object_set_facing (player0) blue_base_flag)

Turns the specified object in the direction of the specified flag

(object_set_melee_attack_inhibited <object> <boolean>)
(object_set_melee_attack_inhibited (player0) true)
(object_set_melee_attack_inhibited (player0) false)

false prevents object from using melee attack

(object_set_permutation <object> <string> <string>)
(object_set_permutation (player0) "right arm" ~damaged)

Sets the desired region (use "" for all regions) to the permutation with the given name

(object_set_ranged_attack_inhibited <object> <boolean>)
(object_set_ranged_attack_inhibited (player0) true)
(object_set_ranged_attack_inhibited (player0) false)

false prevents object from using ranged attack

(object_set_scale <object> <real> <short>)
(object_set_scale (player0) 1.5 10)
(object_set_scale insertion_pelican 0.25 30)

sets the scale for a given object and interpolates over the given number of frames to achieve that scale

(object_set_shield <object> <real>)
(object_set_shield (player0) 1.0)

Sets the shield vitality of the specified object (between 0 and 1)

(object_teleport <object> <cutscene_flag>)
(object_teleport (player0) red_base_flag)

Moves the specified object to the specified flag

(object_type_predict <object_definition>)

Loads textures necessary to draw an object that's about to come on-screen

(pause_hud_timer <boolean>)
(pause_hud_timer true)
(pause_hud_timer false)

Pauses or unpauses the hud timer

(playback)

Starts game in film playback mode

(player0_joystick_set_is_normal)

Returns true if (player0) is using the normal joystick set

(player0_look_invert_pitch <boolean>)

Invert player0's look

(player0_look_pitch_is_inverted)

Returns true if (player0)'s look pitch is inverted

(players_unzoom_all)

Resets zoom levels on all players

(player_action_test_accept)

Returns true if any player has hit accept since the last call to (player_action_test_reset)

(player_action_test_action)

Returns true if any player has hit the action key since the last call to (player_action_test_reset)

(player_action_test_back)

Returns true if any player has hit the back key since the last call to (player_action_test_reset)

(player_action_test_grenade_trigger)

Returns true if any player has used grenade trigger since the last call to (player_action_test_reset)

(player_action_test_jump)

Returns true if any player has jumped since the last call to (player_action_test_reset)

(player_action_test_look_relative_all_directions)

Returns true if any player has looked up, down, left, and right since the last call to (player_action_test_reset)

(player_action_test_look_relative_down)

Returns true if any player has looked down since the last call to (player_action_test_reset)

(player_action_test_look_relative_left)

Returns true if any player has looked left since the last call to (player_action_test_reset)

(player_action_test_look_relative_right)

Returns true if any player has looked right since the last call to (player_action_test_reset)

(player_action_test_look_relative_up)

Returns true if any player has looked up since the last call to (player_action_test_reset)

(player_action_test_move_relative_all_directions)

Returns true if any player has moved forward, backward, left, and right since the last call to (player_action_test_reset)

(player_action_test_primary_trigger)

Returns true if any player has used primary trigger since the last call to (player_action_test_reset)

(player_action_test_reset)

Resets the player action test state so that all tests will return false

(player_action_test_zoom)

Returns true if any player has hit the zoom button since the last call to (player_action_test_reset)

(player_add_equipment <unit> <starting_profile> <boolean>)

Adds/resets the player's health, shield, and inventory (weapons and grenades) to the named profile. Resets if third parameter is true, adds if false.

(player_camera_control <boolean>)
(player_camera_control true)
(player_camera_control false)

Enables/disables camera control globally

(player_effect_set_max_rotation <real> <real> <real>)

<yaw> <pitch> <roll>

(player_effect_set_max_translation <real> <real> <real>)

<x> <y> <z>

(player_effect_set_max_vibrate <real> <real>)

<left> <right>

(player_effect_start <real> <real>)

<max_intensity> <attack time>

(player_effect_stop <real>)

<decay>

(player_enable_input <boolean>)
(player_enable_input true)
(player_enable_input false)

Toggle player input. The player can still free-look, but nothing else.

(play_update_history <long> <boolean>)

Playback client input history starting from the specified last completed update id

(print <string>)
(print "50 dollars for this?!")

Prints a string to the console. Printed text will not appear in the console unless devmode is enabled (devmode 4). You can give a print call a format string (e.g. "I have %d apples"), but cannot give it format arguments, meaning a format string can cause the function to read invalid memory and crash the game!

(print_binds)

Prints a list of all input bindings

(profile_activate <string>)

Activates profile sections based on a substring

(profile_deactivate <string>)

Deactivates profile sections based on a substring

(profile_dump <string>)

Dumps profile based on a substring

(profile_graph_toggle <string>)

Enables or disables profile graph display of a particular value

(profile_load <string>)
(profile_load "a hobo")
; loads the profile "a hobo"

Load any included builtin profiles and create profiles on disk

(profile_reset)

Resets profiling data

(profile_service_clear_timers)

Clears the timers that are present in the profiling service

(profile_service_dump_timers)

Dumps the profiling service timers

(profile_unlock_solo_levels)

Unlocks all the solo player levels for player 1's profile

(quit)

Quits the game

(rasterizer_decals_flush)

Flush all decals

(rasterizer_fixed_function_ambient <long>)
(rasterizer_fixed_function_ambient 200)

Set the ambient light value for fixed function

(rasterizer_fps_accumulate)

Average fps

(rasterizer_lights_reset_for_new_map)
(rasterizer_model_ambient_reflection_tint <real> <real> <real> <real>)
(rasterizer_reload_effects)

Check for shader changes

(recording_kill <unit>)
(recording_kill (player0))

Kill the specified unit's cutscene recording

(recording_play <unit> <cutscene_recording>)

Make the specified unit run the specified cutscene recording

(recording_play_and_delete <unit> <cutscene_recording>)

Make the specified unit run the specified cutscene recording, deletes the unit when the animation finishes

(recording_play_and_hover <vehicle> <cutscene_recording>)

Make the specified vehicle run the specified cutscene recording, hovers the vehicle when the animation finishes

(recording_time <unit>)
(recording_time (player0))

Return the time remaining in the specified unit's cutscene recording

(render_effects <boolean>)
(render_effects true)
(render_effects false)

Render game effects if true

(render_lights <boolean>)
(render_lights true)
(render_lights false)

Enables/disables dynamic lights

(scenery_animation_start <scenery> <animation_graph> <string>)
(scenery_animation_start fighter_clouds "cinematics\animations\h_fighter\x70\x70" "x70_3")

Starts a custom animation playing on a piece of scenery.

(scenery_animation_start_at_frame <scenery> <animation_graph> <string> <short>)
(scenery_animation_start_at_frame fighter_launch "cinematics\animations\h_fighter\x70\x70" "x70_2" 100)

Starts a custom animation playing on a piece of scenery at a specific frame.

(scenery_get_animation_time <scenery>)
(scenery_get_animation_time fighter_launch)

Returns the number of ticks/frames remaining in a custom animation (or zero, if the animation is over). This function intentionally returns a value 2 frames lower than the actual remaining frame count so scripts waiting for the animation to end can do something before it's over.

(script_recompile)

Recompiles scripts

(script_screen_effect_set_value <short> <real>)

Sets a screen effect script value

(set_digital_forward_throttle <short> <real>)

Sets the amount of forward throttle applied by digital device stimuli

(set_digital_pitch_increment <short> <real>)

Sets the increment in pitch applied by digital device stimuli

(set_digital_strafe_throttle <short> <real>)

Sets the amount of strafe throttle applied by digital device stimuli

(set_digital_yaw_increment <short> <real>)

Sets the increment in yaw applied by digital device stimuli

(set_gamepad_forward_threshold <short> <real>)

Sets the threshold beyond which gamepad movement is full forward throttle

(set_gamepad_pitch_scale <short> <real>)

Sets the scale for gamepad control of pitch

(set_gamepad_strafe_threshold <short> <real>)

Sets the threshold beyond which gamepad movement is full strafe throttle

(set_gamepad_yaw_scale <short> <real>)

Sets the scale for gamepad control of yaw

(set_gamma <long>)
(set_gamma 200)

Set the gamma

(set_mouse_forward_threshold <short> <real>)

Sets the threshold beyond which mouse movement is full forward throttle

(set_mouse_pitch_scale <short> <real>)

Sets the scale for mouse control of pitch

(set_mouse_strafe_threshold <short> <real>)

Sets the threshold beyond which mouse movement is full strafe throttle

(set_mouse_yaw_scale <short> <real>)

Sets the scale for mouse control of yaw

(set_pitch_rate <short> <real>)

Sets the yaw rate for the given player number

(set_yaw_rate <short> <real>)

Sets the yaw rate for the given player number

(show_hud <boolean>)
(show_hud true)
(show_hud false)

Shows or hides the hud

(show_hud_help_text <boolean>)
(show_hud_help_text true)
(show_hud_help_text false)

Shows or hides the hud help text

(show_hud_timer <boolean>)
(show_hud_timer true)
(show_hud_timer false)

Displays the hud timer

(show_player_update_stats)

Shows update history playback stats

(sound_cache_dump_to_file)
(sound_cache_flush)
(sound_class_set_gain <string> <real> <short>)

Changes the gain on the specified sound class(es) to the specified game over the specified number of ticks.

(sound_eax_enabled)

Returns true if EAX extensions are enabled

(sound_enable <boolean>)
(sound_enable true)
(sound_enable false)

Enables or disables all sound

(sound_enable_eax <boolean>)
(sound_enable_eax true)
(sound_enable_eax false)

Enable or disable EAX extensions

(sound_enable_hardware <boolean> <boolean>)

Enable or disable hardware sound buffers

(sound_get_effects_gain)

Returns the game's effects gain

(sound_get_gain <string>)

Absolutely do not use this either

(sound_get_master_gain)

Returns the game's master gain

(sound_get_music_gain)

Returns the game's music gain

(sound_get_supplementary_buffers)

Get the amount of supplementary buffers

(sound_impulse_predict <sound> <boolean>)
(sound_impulse_predict "sound\sfx\impulse\ting\ting" true)
(sound_impulse_predict "sound\sfx\impulse\ting\ting" false)

Loads an impulse sound into the sound cache ready for playback

(sound_impulse_start <sound> <object> <real>)

Plays an impulse sound from the specified source object (or "none"), with the specified scale

(sound_impulse_stop <sound>)

Stops the specified impulse sound

(sound_impulse_time <sound>)

Returns the time remaining for the specified impulse sound

(sound_looping_predict <looping_sound>)
(sound_looping_set_alternate <looping_sound> <boolean>)

Enables or disables the alternate loop/alternate end for a looping sound

(sound_looping_set_scale <looping_sound> <real>)

Changes the scale of the sound (which should affect the volume) within the range 0 to 1

(sound_looping_start <looping_sound> <object> <real>)

Plays a looping sound from the specified source object (or "none"), with the specified scale

(sound_looping_stop <looping_sound>)

Stops the specified looping sound

(sound_set_effects_gain <real>)
(sound_set_effects_gain 2.0)

Set the game's effects gain

(sound_set_env <short>)
(sound_set_env 1)

Change environment preset

(sound_set_factor <real>)

Set the DSound factor value

(sound_set_gain <string> <real>)

Absolutely do not use this

(sound_set_master_gain <real>)
(sound_set_master_gain 0.5)

Set the game's master gain

(sound_set_music_gain <real>)
(sound_set_music_gain 3.0)

Set the game's music gain

(sound_set_rolloff <real>)

Set the DSound rolloff value

(sound_set_supplementary_buffers <short> <boolean>)

Set the amount of supplementary buffers

(structure_bsp_index)

Returns the current structure bsp index

(structure_lens_flares_place)

Places lens flares in the structure bsp

(sv_ban <player index or name> [duration(m,h,d)])

(Server Only) The given player is kicked and added to banned.txt. Use sv_players to find the player's index. You can also specify an optional duration for timed ban. Use 0 to follow sv_ban_penalty rules.

(sv_banlist)

Print a list of banned players

(sv_end_game)

End the current game

(sv_kick <player index or name>)
(sv_kick "Micro$oft")

(Server Only) Kicks the specified player from the server

(sv_map <string> <string>)
(sv_map bloodgulch slayer)

(Server Only) Usage: sv_map <mapname> <variantname>
Aborts the current game and playlist, and starts the specified game mode on the specified map.

(sv_mapcycle)

Print the contents of the currently loaded mapcycle file

(sv_mapcycle_add <string> <string>)

Usage: sv_mapcycle_add <mapname> <variantname>
Add a new game to the end of the mapcycle file

(sv_mapcycle_begin)

Restart or begin playing the currently loaded mapcycle file

(sv_mapcycle_del <long>)

Usage: sv_mapcycle_del <index>
Removes the game at <index>. Will not affect running games.

(sv_map_next)

(Server Only) Abort the current game and begin the next game in the playlist

(sv_map_reset)

(Server Only) Reset the current game

(sv_maxplayers [short])
(sv_maxplayers 10)

Sets the maximum number of players (between 1 and 16). If no value is given, displays the current value.

(sv_name [name])
(sv_name)
(sv_name "yousuck")

Sets the name of the server. If no name is given, displays the current name.

(sv_parameters_dump)

Dumps out the local parameter configuration to parameters.cfg file

(sv_parameters_reload)

(Server Only) Reloads the parameters.cfg file

(sv_password [password])
(sv_password)
(sv_password "1234")

Sets the server password. If no password is given, displays the current password.

(sv_players)

(Server Only) Prints (not returns) a list of players in the current game

(sv_status)

Shows status of the server

(sv_unban <long>)
(sv_unban 1)

(Server Only) Usage: sv_unban <index>
Removes player at index in the banlist. Use sv_banlist to find the index.

(switch_bsp <short>)
(switch_bsp 0)

Switches to a different structure bsp

(texture_cache_flush)

Don't make me kick your ass

(time_code_reset)

Resets the time code timer

(time_code_show <boolean>)
(time_code_show true)
(time_code_show false)

Shows the time code timer

(time_code_start <boolean>)
(time_code_start true)
(time_code_start false)

Starts/stops the time code timer

(ui_widget_show_path <boolean>)
(ui_widget_show_path true)
(ui_widget_show_path false)
(unbind <string> <string>)

Unbinds an input device/button combination

(unit <object>)
(unit (list_get (players) 0))

Converts an object to a unit

(units_set_current_vitality <object_list> <real> <real>)
(units_set_current_vitality (players) 75 75)

Sets a group of units' current body and shield vitality

(units_set_desired_flashlight_state <object_list> <boolean>)
(units_set_desired_flashlight_state (players) true)
(units_set_desired_flashlight_state (players) false)

Sets the units' desired flashlight state

(units_set_maximum_vitality <object_list> <real> <real>)
(units_set_maximum_vitality (players) 75 75)

Sets a group of units' maximum body and shield vitality

(unit_aim_without_turning <unit> <boolean>)

Allows a unit to aim in place without turning

(unit_close <unit>)

Closes the hatches on a given unit

(unit_custom_animation_at_frame <unit> <animation_graph> <string> <boolean> <short>)

Starts a custom animation playing on a unit at a specific frame index (interpolates into animation if next to last parameter is true).

(unit_doesnt_drop_items <object_list>)
(unit_doesnt_drop_items (players))

Prevents any of the given units from dropping weapons or grenades when they die

(unit_enter_vehicle <unit> <vehicle> <string>)
(unit_enter_vehicle (player0) warthog_mp_2 "gunner")

Puts the specified unit in the specified vehicle (in the named seat)

(unit_exit_vehicle <unit>)

Makes a unit exit its vehicle

(unit_get_current_flashlight_state <unit>)
(unit_get_current_flashlight_state (player0))

Gets the unit's current flashlight state

(unit_get_custom_animation_time <unit>)
(unit_get_custom_animation_time chief_insertion)

Returns the number of ticks remaining in a unit's custom animation (or zero, if the animation is over). This function intentionally returns a value 2 frames lower than the actual remaining frame count so scripts waiting for the animation to end can do something before it's over.

(unit_get_health <unit>)
(unit_get_health (player0))

Returns the health of the given unit as a real between 0 and 1]. Returns -1 if the unit does not exist.

(unit_get_shield <unit>)
(unit_get_shield (player0))

Returns the shield of the given unit as a real between 0 and 1. Returns -1 if the unit does not exist.

(unit_get_total_grenade_count <unit>)
(unit_get_total_grenade_count (player0))

Returns the total number of grenades for the given unit, or 0 if the unit does not exist.

(unit_has_weapon <unit> <object_definition>)
(unit_has_weapon (player0) plasma_cannon)

Returns true if the has as a weapon, false otherwise

(unit_has_weapon_readied <unit> <object_definition>)
(unit_has_weapon_readied (player0) plasma_cannon)

Returns true if the has as the primary weapon, false otherwise

(unit_impervious <object_list> <boolean>)
(unit_impervious (players) true)
(unit_impervious (players) false)

Prevents any of the given units from being knocked around or playing ping animations

(unit_is_playing_custom_animation <unit>)

Returns true if the given unit is still playing a custom animation

(unit_kill <unit>)

Kills a given unit, no saving throw

(unit_kill_silent <unit>)

Kills a given unit silently (doesn't make them play their normal death animation or sound)

(unit_open <unit>)

Opens the hatches on the given unit

(unit_set_current_vitality <unit> <real> <real>)

Sets a unit's current body and shield vitality

(unit_set_desired_flashlight_state <unit> <boolean>)
(unit_set_desired_flashlight_state (player0) true)
(unit_set_desired_flashlight_state (player0) false)

Turns the unit's flashlight on or off

(unit_set_emotion <unit> <short>)

Sets a unit's facial expression (-1 is none, other values depend on unit)

(unit_set_emotion_animation <unit> <string>)

Sets the emotion animation to be used for the given unit

(unit_set_enterable_by_player <unit> <boolean>)
(unit_set_enterable_by_player warthog_mp_3 true)
(unit_set_enterable_by_player warthog_mp_3 false)

Can be used to prevent the player from entering a vehicle

(unit_set_maximum_vitality <unit> <real> <real>)

Sets a unit's maximum body and shield vitality

(unit_set_seat <unit> <string>)
(unit_set_seat (player0) "driver")

This unit will assume the named seat

(unit_solo_player_integrated_night_vision_is_active)

Returns whether the night-vision mode could be activated via the flashlight button

(unit_stop_custom_animation <unit>)

Stops the custom animation running on the given unit

(unit_suspended <unit> <boolean>)
(unit_suspended (player0) true)
(unit_suspended (player0) false)

Stops gravity from working on the given unit

(vehicle_driver <unit>)
(vehicle_driver the_ghost)

Returns the driver of a vehicle

(vehicle_gunner <unit>)
(vehicle_gunner the_warthog)

Returns the gunner of a vehicle

(vehicle_hover <vehicle> <boolean>)
(vehicle_hover "vehicles\warthog\warthog" true)
(vehicle_hover "vehicles\warthog\warthog" false)

Stops the vehicle from running real physics and runs fake hovering physics instead

(vehicle_load_magic <unit> <string> <object_list>)
(vehicle_load_magic pelican_1 "" (players))

Makes a list of units (named or by encounter) magically get into a vehicle, in the substring-specified seats (e.g. "CD-passenger". Empty string matches all seats).

(vehicle_riders <unit>)
(vehicle_riders the_tanks)

Returns a list of all riders in a vehicle

(vehicle_test_seat <vehicle> <string> <unit>)
(vehicle_test_seat banshee_mp_1 "driver" (player0))

Tests whether the named seat has a specified unit in it

(vehicle_test_seat_list <vehicle> <string> <object_list>)
(vehicle_test_seat_list ghost_mp_2 "driver" (players))

Tests whether the named seat has an object in the object list

(vehicle_unload <unit> <string>)
(vehicle_unload hog w-driver)

Makes units get out of a vehicle from the substring-specified seats (e.g. "CD-passenger". Empty string matches all seats).

(version)

Prints the build version

(volume_teleport_players_not_inside <trigger_volume> <cutscene_flag>)
(volume_teleport_players_not_inside hidden_trigger omgtelprot)

Moves all players outside a specified trigger volume to a specified flag

(volume_test_object <trigger_volume> <object>)
(volume_test_object trig_volume1 (player0))

Returns true if the specified object is within the specified volume

(volume_test_objects <trigger_volume> <object_list>)
(volume_test_objects trig_volume2 (players))

Returns true if any of the specified objects are within the specified volume

(volume_test_objects_all <trigger_volume> <object_list>)
(volume_test_objects_all trig_volume2 (players))

Returns true if all of the specified objects are within the specified volume

Mechanics

Script threads

HSC has the notion of threads, i.e. multiple scripts running at the same time (as opposed to waiting until the previous script is done to run). This is not actual multithreading (the game still runs on a single CPU core). Continuous, dormant, and startup scripts all run in their own threads. Static scripts do not run in their own thread, by virtue of being called by other scripts. For example, a sleep within a static script will put the thread of the calling script to sleep. Multiple threads can call the same static script at the same time with no issue. Every thread has its own stack.

Implicit returns

Several control structures implicitly return the value of their final expression to the caller. This applies to if, else, begin, begin_random, and cond blocks, as well as static scripts.

; The second condition is true, so 6 will be returned from
; the cond block, since it is the final expression.
(cond
  (
    (= 0 1)
    (print "I will never run")
    5
  )
  (
    (= 1 1)
    (print "I will always run!")
    6
  )
  (
    (= 2 2)
    (print "I would run if the code above me hadn't.")
    7
  )
)

Gotchas and limits

Using begin_random in startup scripts

The random number generator used for things like begin_random is seeded on the same tick that startup scripts run. This means the first expression selected by a begin_random block in a startup script will always be the same. Generally since the first expression will take a variable amount of time to complete evaluation, the following items will be random as expected.

Syntax nodes are limited

The exact limit of syntax nodes is not currently known.

Syntax nodes are sections of memory that the game allocates to handle the structure of scripts when it compiles them. Syntax data is stuff like parentheses, function names, variable names... anything that has syntactic meaning for the script system.

There is a maximum number of syntax nodes that the game can allocate when compiling scripts. If you exceed this limit, scripts will not compile. This limit is cumulative across both individual scenarios and child scenarios. So, even if the main scenario compiles, it might not work once you add its children (if its children have scripts of their own). If you hit this limit, your only choice is to remove some syntax data. It can come from anywhere, but something has to go. This can sometimes be a long and painful process.

Total scripts and globals are limited

In addition to syntax nodes, the total number of globals and scripts (startup, dormant, etc...) is also limited.

Type Limit
scripts 1024
globals 128
threads 256

Source file size is limited

The game will not compile scripts for a source file above a given size. Comments and whitespace are counted in this size! If you hit this limit, you can either remove stuff from the script, or move stuff from one source file into another source file. Comments and unnecessary whitespace are non-functional things that can be removed to reduce size, but only do this if you need to!

Comments and indentation are important for understanding your own scripts. Most projects will not be big enough to need to worry about exceeding source file size, so good coding conventions should be used until they can't be!

Tools like the Halo Script Preprocessor (see below) can strip comments and whitespace in the final script, while keeping them in your source file.

Number of source files is limited

A scenario's scripts can be split into multiple files, but the number of files you can have is limited to 8.

Sapien silently fails to load all of the files if there are more than 8. It loads the first 8 in some determined order ("asciibetical"?), then excludes the rest. No errors are thrown unless scripts fail to compile because of the excluded files.

Stack space is limited

If you've never heard of a stack in the context of computer programming before, skim through this.

Halo allocates a certain amount of memory for each scripting thread in a scenario, called the "stack". Stack memory is used to hold results of invoking functions, parameters for script functions, and so on. Notably, nesting function calls will consume additional stack memory.

; Nested statements are statements like these, where many
; things happen that are "nested" within one another

(if ;; some condition
  (begin
    (if ;; some condition
      (begin
        ;; ... do something
      )
    )
    ;; ... do something else
  )
)

It is very, very easy to exceed the limits of this memory if you have enough nested statements. The maximum number of nested statements is somewhere between 10 and 16 levels deep, depending on if you're invoking static scripts, if you're invoking methods with parameters, and other things.

WARNING: The game DOES NOT guard against exceeding stack memory!!

If you exceed a script's stack memory, it will overflow into other scripts' stack memory!

This means that one script can COMPLETELY break another script if it nests too deeply. If another script's memory is clobbered, it can end up doing arbitrary things. It might wake up when it's supposed to be asleep. It might switch to a new BSP for no reason. It might crash the game. It might make objects flicker randomly.

There is not currently a reliable way to exactly tell when stack memory has been exceeded. The "10 to 16 nested levels" advice is an estimate based on experimentation, and also directly depends on the number of parameters in function calls.

Console scripts

Things manually entered into the console ingame also share script space with the scenario's baked in scripts. In rare circumstances (e.g. you're just on the cusp of using too much memory), a console script's memory can overflow into a scenario script's memory, causing the above mentioned issues.

When to use short vs long

There are two integer variable types: short and long. Both hold whole numbers, but long variables can hold much larger numbers than short variables. The tradeoff is that short variables only consume half as much memory as long variables. Given HSC's tight memory constraints, this means you should only use long when you need large numbers!

Extensions

The Halo Script Preprocessor is effectively a super-set of Halo Script that adds support for C-like #define pre-processor macros. The program takes a file with macros in it, then spits out a standard HSC file. This means this program is purely for making writing HSC easier. Scripts using the Halo Script Preprocessor are still subject to all of the above limits.

For example, the following block:

#define UNIT_IN_COMBAT (= 6 (ai_command_list_status my_unit))

(if UNIT_IN_COMBAT
  (sleep 30)
)

...becomes this:

(if (= 6 (ai_command_list_status my_unit))
  (sleep 30)
)

Acknowledgements

Thanks to the following individuals for their research or contributions to this topic:

  • Ifafudafi (Script limits information)
  • Kornman00 (Original Blam Scripting Language Bible, http://www.modacity.net/docs/bslbible/)
  • Mimickal (Additional background on scripting, edits for clarity and extra information)
  • TehLag (Additional script information (limits, types, functionality, etc...))