Functions
gx_get_bg_shader_val
- index must be between
[0-15] - get float value that is being used by the background gpu shader
gx_set_bg_shader_val
- index must be between
[0-15] - set float value that can be used by the background gpu shader
gx_sim_ticks_to_seconds
- converts simTicks to seconds
- equivalent to:
(simTicks / 20.0) - note: simulation runs every 50ms (20 times/second)
gx_seconds_to_sim_ticks
- converts
secondstosimTicks - equivalent to:
(seconds * 20).tointeger() - note: simulation runs every 50ms (20 times/second)
gx_get_seconds
- return game time in seconds
- equivalent to:
gx_sim_ticks_to_seconds(gx_get_sim_tick())
gx_str_encode_color_id
gx_str_encode_color
gx_str_encode_complex_color
gx_str_encode_color_hex3
gx_get_sim_tick
- Returns the current sim tick number in simulation.
- The
gx_sim_init()call will havetick = 0 - The first
gx_sim_update()call will havetick = 1 - The second
gx_sim_update()call will havetick = 2, etc.. - every tick corresponds to 50ms real time
gx_create_unit
table params = {
string m_ud, # required
int m_playerID, # required
Float2 m_pos,
string m_location,
int m_level,
bool m_bForceGhostMode,
bool m_bSieged,
bool m_bLiftedStructure,
bool m_bBurrowed
}
- Will create unit of type
m_udat positionm_posor at locationm_locationfor playerm_playerID. - It is undefined behavior to have both
m_posandm_locationset. - If neither
m_posnorm_locationis set, unit will be created at(0, 0) - Units may not be placed at the exact center of
m_location, if you need exact position usem_pos. - Setting
m_bForceGhostModeis shortcut so u don't need to setset_unit_prop(UnitProp.ForceGhostMode, ..)after unit creation.
gx_get_distance_between_units
- returns the distance between the edges of two units
- will return 0 if one or both of the units do not exist
gx_get_nearby_units
table params = {
int m_unitID, # unit_id to center search on
float m_radius, # search radius around unit
int m_playerIDs[], # Optional, Filter for player_id
int m_forceIDs[], # Optional, Filter for force_id
string m_uds[], # Optional, Filter for certain unit types
string m_exceptUds[], # Optional, ignore certain unit types
bool m_bIncludeAirUnits = true, # Optional, Set to false if you want to exclude air units
bool m_bIncludeGroundUnits = true, # Optional, set to false if you want to exclude ground units
bool m_bIncludeKilledUnits = false, # Optional, Set to true if you want to include killed units
bool m_bIncludeRemovedUnits = false, # Optional, set to true if you want to include removed units
bool m_bIncludeProjectiles = false # Optional, include projectiles (default: false)
}
m_unitIDrequired to be setm_radiusrequired to be set- returns units whos outer edges have a distance equal/less than
m_radiusfromm_unitID. note:m_unitIDwill be included in part of query result
gx_get_nearby_units_count
table params = {
int m_unitID, # unit_id to center search on
float m_radius, # search radius around unit
int m_playerIDs[], # Optional, Filter for player_id
int m_forceIDs[], # Optional, Filter for force_id
string m_uds[], # Optional, Filter for certain unit types
string m_exceptUds[], # Optional, ignore certain unit types
bool m_bIncludeAirUnits = true, # Optional, Set to false if you want to exclude air units
bool m_bIncludeGroundUnits = true, # Optional, set to false if you want to exclude ground units
bool m_bIncludeKilledUnits = false, # Optional, Set to true if you want to include killed units
bool m_bIncludeRemovedUnits = false, # Optional, set to true if you want to include removed units
bool m_bIncludeProjectiles = false # Optional, include projectiles (default: false)
}
m_unitIDrequired to be setm_radiusrequired to be set- returns units whos outer edges have a distance equal/less than
m_radiusfromm_unitID. note:m_unitIDwill be included in part of query result
gx_get_units
table params = {
string m_locations[], # Optional
string m_aabrs[], # Optional
string m_tags[], # Optional, Filter for unit tags
BoundsCheck m_boundsCheck # Default: BoundsCheck.Center
int m_playerIDs[], # Optional, Filter for player_id
int m_forceIDs[], # Optional, Filter for force_id
string m_uds[], # Optional, Filter for certain unit types
string m_exceptUds[], # Optional, ignore certain unit types
bool m_bIncludeAirUnits = true, # Optional, Set to false if you want to exclude air units
bool m_bIncludeGroundUnits = true, # Optional, set to false if you want to exclude ground units
bool m_bIncludeKilledUnits = false, # Optional, Set to true if you want to include killed units
bool m_bIncludeRemovedUnits = false, # Optional, set to true if you want to include removed units
bool m_bIncludeProjectiles = false # Optional, include projectiles (default: false)
}
- If
m_locationsis defined:- Searches at
m_locationsfor units
- Searches at
- If
m_aabrsis defined:- Searches at
m_aabrsfor units
- Searches at
- If
m_locationsandm_aabrsis not defined:- Searches for units on entire map
gx_get_units_count
table params = {
string m_locations[], # Optional
string m_aabrs[], # Optional
string m_tags[], # Optional, Filter for unit tags
BoundsCheck m_boundsCheck # Default: BoundsCheck.Center
int m_playerIDs[], # Optional, Filter for player_id
int m_forceIDs[], # Optional, Filter for force_id
string m_uds[], # Optional, Filter for certain unit types
string m_exceptUds[], # Optional, ignore certain unit types
bool m_bIncludeAirUnits = true, # Optional, Set to false if you want to exclude air units
bool m_bIncludeGroundUnits = true, # Optional, set to false if you want to exclude ground units
bool m_bIncludeKilledUnits = false, # Optional, Set to true if you want to include killed units
bool m_bIncludeRemovedUnits = false, # Optional, set to true if you want to include removed units
bool m_bIncludeProjectiles = false # Optional, include projectiles (default: false)
}
- If
m_locationsis defined:- Searches at
m_locationsfor units
- Searches at
- If
m_aabrsis defined:- Searches at
m_aabrsfor units
- Searches at
- If
m_locationsandm_aabrsis not defined:- Searches for units on entire map
gx_units_touching
- Returns
trueif the two units are "touching" (nearby eachother)
gx_create_explosion
table params = {
float m_size,
Float3 m_color,
ExplosionType m_type,
string m_location,
bool m_bPlaySound,
string m_sound,
string m_soundPack,
}
- Only one
m_soundorm_soundPackshould be set - If neither
m_soundnorm_soundPackis set, default sound will be played.
Example:
gx_kill_unit
- kills the unit
unit_id. - It is safe to call this function on already killed units
gx_unit_exists
- checks if unit still exists in the game
gx_remove_unit
- marks the unit to be removed by game
unit_idwill be removed from game before the nextgx_sim_updatecall- It is safe to call this function on already killed or removed units
gx_is_unit_alive_and_constructed
- returns
trueif unit is alive and constructed - returns
falseif unit_id is invalid or unit no longer exists in game
gx_is_unit_alive
- returns
trueif unit is alive - returns
falseif unit_id is invalid or unit no longer exists in game - Note: This function still returns
trueif unit is not yet fully constructed - equivalent to calling
!gx_is_unit_killed(unit_id)
gx_is_unit_killed
- returns
trueif the unitunit_idis killed - returns
trueif unit does not exist - equivalent to calling
!gx_is_unit_alive(unit_id)
gx_get_unit_position
- returns position of unit
- returns Float3(0.0, 0.0, 0.0) if unit no longer exists
gx_is_ground_unit
- returns if unit is currently a
groundunit - units are always in either the
groundorairstate - note: knock-back effect can cause
groundunits to temporarily becomeairunits - equivalent to calling
!gx_is_air_unit(unit_id)
gx_is_air_unit
- returns if unit is currently an
airunit - units are always in either the
groundorairstate - note: knock-back effect can cause
groundunits to temporarily becomeairunits - equivalent to calling
!gx_is_ground_unit(unit_id)
gx_get_player
- returns the
player_idfor unitunit_id - if unit does not exist, will return 0
gx_get_players
table params = {
int m_forceIDs[],
int m_playerIDs[],
VictoryStatus m_allowedVictoryStates[],
bool m_bIncludeNormalPlayers = true,
bool m_bIncludeNeutralPlayer = false,
bool m_bIncludeRescuePlayer = false,
bool m_bIncludeHostilePlayer = false,
bool m_bPlayerMustBeInGame = false
}
- Function is used to query and/or filter playerIDs based on simple coonditions
- If neither m_forceIDs[] nor m_playerIDs[] is set, then will consider all players
- If
m_allowedVictoryStatesis not set, any victory state will be considered - It is valid to have both
m_forceIDsandm_playerIDsset -- the players fromm_forceIDsandm_playerIDswill be merged.
gx_fling_unit
table params = {
Float3 m_dir2d,
Float3 m_dir3d,
float m_force,
bool m_bFlingLookAtDir = false,
bool m_bFlingStructures = false
}
- If neither
m_dir2dnorm_dir3dis set, unit will be thrown in random direction - Only
m_dir2dorm_dir3dshould be set. Setting both is undefined behavior.
gx_set_victory_status
table params = {
int m_status = VictoryStatus.Victory, # Valid options:
# VictoryStatus.Victory or VictoryStatus.Defeat
# Default: VictoryStatus.Victory
int m_playerIDs[],
int m_forceIDs[],
bool m_bAllPlayers = false,
bool m_bAllForces = false,
bool m_bKillAllUnits, # Optional
# if (m_status == VictoryStatus.Victory)
# default: false
# if (m_status == VictoryStatus.Defeat)
# default: true
string m_img, # Optional, (image to show)
float m_imgSpeedFactor = 1, # Optional, speed if m_img is animated gif
string m_sound, # Optional, (sound to play)
float m_volume = 1, # Optional, (default: 1)
float m_pitch = 1, # Optional, (default: 1)
ComplexColor m_color, # Optional, ComplexColor for m_img
ComplexColor m_bgColor, # Optional, Background ComplexColor
}
gx_print
table params = {
int m_forceIDs[],
int m_playerIDs[],
bool m_bPlaySound,
string m_sound,
string m_soundPack
}
- If both m_forceIDs and m_playerIDs are undefined, message will be sent to all players
gx_is_unit_removed
- returns if unit is marked to be removed
- will still return
trueif unit_id does not exist
gx_set_unit_position
Example:
- it is undefined to not set
m_location - if
m_locationdoes not exist, unit will be teleported to Float2(0.0, 0.0)
gx_set_terrain_type
table params = {
TerrainType m_type # Required. The type of terrain to change to. See TerrainType enum.
int m_secondary = 0 # Secondary terrain type. (default = 0)
Int2 m_index, # 2d index of square to change terrain type of
int m_index2, # 0 or 1, 0 indicates bottom triangle, 1 indicates top.
# If index2 is not defined, entire square specified by m_index
# will be set to terrain type (i.e. both triangles, top and bottom).
# m_index and index2 are ignored if m_location is set.
string m_location, # location to set terrain tile types.,
string m_triangleGroup # triangle group to set terrian tile stype
}
Example that sets terrain at location my_location to Pacifist type:
gx_set_terrain_type({
m_type = TerrainType.Normal,
m_secondary = SecondaryTerrainTypeNormal.Pacifist,
m_location = "my_location"
})
gx_set_terrain_type_2
table params = {
TerrainType m_type # Required. The type of terrain to change to. See TerrainType enum.
int m_secondary = 0 # Secondary terrain type. (default = 0)
string m_locations[], # location to set terrain tile types.,
AABR m_aabrs[], # aabrs to set terrain tile type
string m_excludeLocations[], # location to NOT set terrain tile types.,
AABR m_excludeAABRs[] # aabrs to NOT set terrian tile stype
}
gx_set_terrain_type_3
table params = {
float m_radius,
Float2 m_center,
TerrainType m_type,
int m_secondary,
int m_triGroups[]
}
- Set the triangle types overlapping region defined by
m_radiusandm_centertom_type/m_secondaryif they belong to any of the tri groups specified inm_triGroups - This function should be used if you are using barrels for 'destroying' terrain and making them space, or other terrain..
table params = { TerrainType m_type # Required. The type of terrain to change to. See TerrainType enum. int m_secondary = 0 # Secondary terrain type. (default = 0) string m_locations[], # location to set terrain tile types., AABR m_aabrs[], # aabrs to set terrain tile type string m_excludeLocations[], # location to NOT set terrain tile types., AABR m_excludeAABRs[] # aabrs to NOT set terrian tile stype }
gx_get_terrain_type
- returns primary terrain type in
vec.m_xand returns secondary terrain type invec.m_y
gx_get_area_vision
gx_set_area_vision
gx_set_player_camera_look_at
- Moves camera of
player_idto look atm_unitorm_location - One of
m_unitorm_locationshould be set. Not both.
gx_lock_player_camera
- locks
player_idcamera to look atm_unitIDorm_location. - camera will follow
m_unitIDorm_locationuntilm_unitIDis removed from game - can unlock camera by calling
gx_unlock_player_camera(player_id) - passing empty args for
paramswill unlock the camera forplayer_id.
gx_unlock_player_camera
- unlocks
player_idcamera position set bygx_lock_player_camera - equivalent to calling
gx_lock_player_camera(player_id, {})
gx_get_kills
gx_map_init_modify_ud_props
table params = {
string m_friendlyName,
bool m_bHasHealth,
int m_maxHealth,
float m_maxSpeed,
int m_baseArmor,
ArmorType m_armorType,
int m_size,
int m_gemstoneCost,
int m_fungusCost,
int m_supplyCost,
int m_buildTime,
bool m_bDriftMode,
bool m_bVisionBlocker,
Expr<bool> m_req,
Expr<int> m_attackLevel,
Expr<int> m_armorLevel,
string m_spells[],
BuildItemTable m_buildItems[],
BuildStructureItemTable m_buildStructuresBasic[],
BuildStructureItemTable m_buildStructuresAdv[],
AutoAttackTable m_autoAttacks[],
table<string, int> m_startingAmmo,
int m_fungusHarvestAmount,
int m_gemstoneHarvestAmount,
bool m_bDisableHarvest,
bool m_bDisableTransport,
bool m_bDisableMove,
bool m_bEnableCanRepair,
bool m_bStructureUnit,
bool m_bAirUnit,
bool m_bFish,
bool m_bCritterFlag,
bool m_bCanBeCarriedByProbe,
Expr<bool> m_canRideJeepReq,
int m_sizeInJeep,
int m_sizeInTransport,
int m_sizeInBunker,
Expr<bool> m_waterImmunity,
Expr<bool> m_lavaImmunity,
Expr<bool> m_terrainImmunity,
AuraTable m_aura,
float m_barrelExplodeDamage,
float m_barrelExplodeRadius,
float m_barrelExplodeThrowForce
}
BuildItemTable = {
BuildItemType m_type,
string m_name,
Int2 m_pos
}
BuildStructureItemTable = {
string m_name,
Int2 m_pos
}
AutoAttackTable {
float m_range,
int m_animDuration,
int m_cooldown,
bool m_bMelee,
bool m_bCanTargetAir,
bool m_bCanTargetGround,
string m_anim,
Expr<bool> m_req,
AttackTable m_attacks[]
}
AttackTable {
AttackType m_type,
bool m_bSplashDamage,
float m_splashRadius,
int m_dmg,
DamageExtraTable m_dmgExtra
}
DamageExtraTable {
int m_vsLight,
int m_vsMedium,
int m_vsHeavy
}
AuraTable {
float m_radiusMultiplier = 4,
bool m_bAttackSpeedIncrease = false,
bool m_bSpeedIncrease = false,
bool m_bHitReduce = false
}
- Feel free to request
BRZDRIFTto add more modifiable properties - Setting either
m_fungusHarvestAmountorm_gemstoneHarvestAmountwill enable harvesting (unlessm_bDisableHarvestistrue)- Note: Allowing harvesting will change attack priority and few other things
gx_map_init_copy_ud
- returns
newNameon success, returns empty string on failure newNamemust begin withUser_newNamemust not already be a unit datanamemust be an existing unit data
gx_ud_exists
- Checks if the unit data
udexists
gx_modify_scoreboard
gx_set_speech_bubble
table params = {
string m_text, # Speech Bubble text to display
int m_duration = 60 # duration to display in ticks
# set to -1 to make it last forever
# default: 60 ticks (3 seconds)
}
- set a speech bubble for unit_id
- returns an integer id for the speech bubble
gx_remove_speech_bubble
- setting
speechBubbleIDto0will remove current speech bubble - Remove speech bubble for unit if current speech bubble ID matches
speechBubbleID
gx_remove_current_speech_bubble
- Equivalent to calling
gx_remove_speech_bubble(unit_id, 0) - Remove speech bubble for unit
gx_get_sim_var
gx_set_sim_var
gx_add_sim_var
gx_get_force_var
gx_set_force_var
gx_add_force_var
gx_get_player_var
gx_set_player_var
gx_add_player_var
gx_get_unit_var
gx_set_unit_var
gx_add_unit_var
gx_set_unit_ammo
gx_get_unit_ammo
gx_add_unit_ammo
gx_set_player_ammo_in_unit
gx_get_player_ammo_in_unit
gx_add_player_ammo_in_unit
gx_get_player_ammo_total
table params = {
string m_tag, # Required (string)
int m_player_id = 0 # Optional, used to Filter. Default = 0. (int)
}
- Returns how much
player ammoof typeammoNamethe player has - returns unit_id with the given
m_nameor - unit name can be set in map editor.
- if multiple units have the same name, the first will be returned.
gx_kill_all_units
gx_is_players_mutually_allied
gx_is_player_allied_to
gx_set_player_allied_to
gx_str_color_username
Equivalent To / Implementation:
function gx_str_color_username(ComplexColor color, string username)
{
return gx_str_encode_complex_color(color) + username
}
gx_str_color_username_2
Equivalent To / Implementation:
function gx_str_color_username_2(ComplexColor complexColor, string username)
{
return Unicode.Special_PushColor
+ gx_str_color_username(complexColor, username)
+ Unicode.Special_PopColor
}
gx_sound2d_create
table params = {
string m_sound, # name of sound to play
string m_soundPack, # will play random sound from soundpack
int m_forceIDs[], # forceIDs that can hear the sound
int m_playerIDs[], # playerIDs that can hear the sound
float m_volume = 1, # Optional, volume multiplier (default = 1)
float m_pitch = 1, # Optional, pitch of sound (default = 1)
bool m_bLoop = false # Optional, controls if sound should loop
}
- You are required to set either
m_soundorm_soundPack(but not both). - If neither
m_forceIDsnorm_playerIDsare set, sound will be heard by all players - returns the
soundID
gx_sound2d_destroy
- Will force a sound to stop and then be destroyed
- This is the only way to stop a sound that is looping (
m_bLoop = true) - After calling this,
gx_sound2d_is_playingwill returnfalse - It is not required to call this. Sound will automatically be destroyed when it is finished playing (assuming not looping).
gx_sound2d_modify
table params = {
float m_volume, # Optional, volume multiplier
float m_pitch # Optional, pitch of sound
}
gx_sound2d_is_playing
- returns
trueif sound is currently playing
gx_sound3d_create
table params = {
string m_sound, # name of sound to play
string m_soundPack, # play random sound from soundpack
int m_unitID, # Optional, unit for sound to attach to
bool m_bStopSoundOnUnitDeath, # Optional, default true if m_unitID is set
Float2 m_pos2d, # Optional, 2d position for sound
Float3 m_pos3d, # Optional, 3d position for sound
float m_radius = 0, # Optional, sound radius, default = 0
float m_volume = 1, # Optional, volume multiplier (default = 1)
float m_pitch = 1, # Optional, pitch of sound (default = 1)
bool m_bLoop = false # Optional, controls if sound should loop
bool m_bRandomLoopStartTime = false # Optional
}
- Only one of
m_unitID,m_pos2d,m_pos3dshould be set - Only one of
m_soundorm_soundPackshould be set - Sound will only be played if current player has vision of circle created by the position of the sound and
m_radius - returns the
soundID
gx_sound3d_destroy
- Will force a sound to stop and then be destroyed
- This is the only way to stop a sound that is looping (
m_bLoop = true) - After calling this,
gx_sound3d_is_playingwill returnfalse - It is not required to call this. Sound will automatically be destroyed when it is finished playing (assuming not looping).
gx_sound3d_modify
table params = {
float m_volume, # Optional, volume multiplier
float m_pitch, # Optional, pitch of sound
Float2 m_pos2d, # Optional
Float3 m_pos3d # Optional
}
m_pos2dandm_pos3dwill be ignored if sound is attached to a unit
gx_sound3d_is_playing
- returns
trueif sound is currently playing
gx_str_parse_command
- splits a string based whitespace and handles quotes properly
- useful when handling the
EventType.TextCommandevent
gx_convert_to_str
- Safe function to convert a value to string
- returns
""on failure
gx_convert_to_int
- Safe function to convert a value to integer
- returns
0on failure
gx_convert_to_float
- Safe function to convert a value to float
- returns
0.0on failure
gx_color_srgba_to_hex4
gx_color_srgb_to_hex3
gx_color_hsva_to_srgba
gx_color_srgba_to_hsva
gx_color_hsv_to_srgb
gx_color_srgb_to_hsv
gx_color_hex3_to_hex4
gx_color_hex4_to_hex3
gx_color_hex4_to_srgba
gx_color_hex3_to_srgb
gx_draw_glow_image
table params = {
string m_img, # Required, Icon Name
AABR_int m_aabr, # AABR to draw to
string m_location, # Location to draw to
AABR_int m_excludeAABRs[], # Optional, AABRs not to draw to
string m_excludeLocations[], # Optional, locations not to draw to
}
m_imgmust be set- Exactly one of
m_abbrorm_locationmust be set
gx_get_sim_image_colors
- Returns all the pixels in the image in hex3 format
- Alpha channel is ignored and not returned
gx_decal_create
table params = {
string m_preset, # decal preset
int m_alphaFn,
int m_colorFn,
bool m_bAlwaysDisplay, # ignore fog of war checks
bool m_bDisplayOnMinimap,
Float4 m_color, # srgb with alpha
Float2 m_pos,
float m_rotation, # radians
Float2|float m_size, # size, can either be float or Float2
string m_tag,
string m_img, # icon to use
float m_speedFactor, # animation speed if m_img is animated GIF
bool m_bOverlayOnSpace,
bool m_bOverlayOnNormalTerrain
}
- create decal with properties, all fields are optional
- only one (or zero) of
m_sizeorm_size2dshould be set
gx_decal_modify
table params = {
int m_alphaFn,
int m_colorFn,
bool m_bAlwaysDisplay, # ignore fog of war checks
bool m_bDisplayOnMinimap,
Float4 m_color, # srgb with alpha
Float2 m_pos,
float m_rotation, # radians
float m_size,
Float2 m_size, # size, can either be Float2 or float
string m_tag,
string m_img, # icon to use
float m_speedFactor, # animation speed if m_img is animated GIF
bool m_bOverlayOnSpace,
bool m_bOverlayOnNormalTerrain
}
- modify/overwrite decal properties, all fields are optional
- only one (or zero) of
m_sizeorm_size2dshould be set
gx_decal_destroy
- remove the decal from game
gx_decal_get_all_by_tag
- return all decalIDs that have their
m_tagset totag
gx_decal_get_by_tag
gx_decal_query
table params = {
AABR m_aabrs[], # Optional
string m_locations[], # Optional
bool m_bAll = false # Optional, default false
}
- Searches inside all of the provided aabrs and locations for decals
- Query for decals inside
m_aabrsandm_locations. - Setting
m_bAllto true will return all decals on the map
gx_rand_unit_vec2
gx_rand_unit_vec3
gx_rand_unit_vec4
gx_unit_vec_or_random
Float2 gx_unit_vec_or_random(Float2 val)
Float3 gx_unit_vec_or_random(Float3 val)
Float4 gx_unit_vec_or_random(Float4 val)
- Computes the unit vector of
v. - Will return random unit vector if
vhas magnitude of0.
gx_unit_vec_or_zero
Float2 gx_unit_vec_or_zero(Float2 val)
Float3 gx_unit_vec_or_zero(Float3 val)
Float4 gx_unit_vec_or_zero(Float4 val)
- Computes the unit vector of
v. - Will return zero-magnitude vector if unit vector
vhas magnitude of0.
gx_shuffle_array
- Shuffles/randomizes items in array using the passed in
Randomobject
gx_terrain_offset_z_add
gx_terrain_offset_z_set
gx_terrain_offset_z_get
gx_terrain_offset_z_add_2
table params = {
AABR_int m_aabrs[], # Optional
string m_locations[], # Optional
Int2 m_vertices[], # Optional
float m_val, # Required
}
gx_terrain_offset_z_set_2
table params = {
AABR_int m_aabrs[], # Optional
string m_locations[], # Optional
Int2 m_vertices[], # Optional
float m_val, # Required
}
gx_aabr_contains
gx_aabr_contains_or_touching
gx_create_effect
table params = {
EffectType m_type,
Float2 m_pos,
int m_duration,
Float4 m_color, # srgb
int m_playerID,
int m_unitID
}
- Creates the Effect of type
m_typeand returns the Effect ID
gx_destroy_effect
- Destroys effect if it can be removed
gx_create_nuke_unit
table params = {
float m_damage,
int m_playerID,
Float2 m_pos,
float m_radius
}
- Creates a nuke unit
gx_triangle_lerp
- Lerp function
gx_queue_command
void gx_queue_command(int unit_ids[], CommandType command, table params = {}, bool bQueueCommand = false)
table params = {
int m_unitID, # unit to target
string m_location, # location to target
Float2 m_pos, # position to target
}
- only one (or zero) unit_id, m_location, m_pos should be set
- some commands/spells only work when certain params are set
- (i.e., a spell that can only target units cannot target a
m_posorm_location) CommandTypecan also be a spell identifier- if
bQueueCommandistrue, appends the command in the unit's command queue, otherwise command queue beforehand
gx_force_select_units
- clears player's unit selection, and sets unitIDs as new selection
gx_add_left_side_message
- Adds an event message visible on left side of screen
gx_display_ui_elements
table params = {
bool m_bAll,
bool m_bArmyCount,
bool m_bIdleWorkers,
bool m_bNumJeeps,
bool m_bNotEnoughSupply,
bool m_bResources,
bool m_bClock,
int m_forceIDs[],
int m_playerIDs[]
}
gx_add_center_message
- displays a player event message for player in middle of their screen for matching players
- if
m_durationis-1message will be displayed forever untilgx_clear_center_messagesorgx_clear_center_message_by_idis called. - returns
msgIDthat can be used bygx_clear_center_message_by_idif needed.
gx_clear_center_messages
- clears all messages for players match params
- if both
m_forceIDsandm_playerIDsare empty, messages will be cleared for all players
gx_update_map_hints
table params = {
int m_forceIDs[],
int m_playerIDs[],
string m_button,
string m_description,
string m_hover,
bool m_bDisplay
}
gx_clear_center_message_by_id
- clear message with msgID
msgID
gx_clear_terrain_paint
gx_paint_terrain
- only one of
m_locationorm_aabrshould be set.
gx_clear_resource_ui_items
gx_add_resource_ui_item
table params = {
int m_playerIDs[],
int m_forceIDs[],
Expr<int> m_val,
Expr<int> m_max,
Expr<bool> m_bDisplayRed,
string m_img
}
gx_get_common_uds
gx_get_ud_race
gx_get_ud_auto_attack_anims
gx_get_num_attacks_in_ud_auto_attack_anim
gx_is_ud_auto_attack_anim_for_siege_mode
gx_is_ud_auto_attack_anim_for_burrow
gx_is_ud_auto_attack_anim_for_normal
gx_set_terrain_unpassable_color
- slot should be
[0-15]
gx_get_terrain_unpassable_color
- slot should be
[0-15]
gx_set_terrain_transparent_color
- slot should be
[0-15]
gx_get_terrain_transparent_color
- slot should be
[0-15]
gx_set_terrain_glow_color
- slot should be
[0-31]
gx_get_terrain_glow_color
- slot should be
[0-31]
gx_to_debug_string
- can use this for debugging
- returns string for table/array/object
- do not rely on output staying the same
- output may differ depending on game version
gx_is_event_queue_empty
- Check if event queue is empty.
gx_pop_event_from_queue
- Pop event from event queue.
gx_include
- Includes filename in current compilation.
- A file is only included once by gx_include; subsequent calls are ignored.
- Typically called at the top of your drift script file.
gx_set_sim_prop
gx_get_sim_prop
gx_get_unit_prop
gx_set_unit_prop
gx_add_unit_prop
gx_get_ud_prop
- Get unit data property
gx_set_ud_prop
- Set unit data property
gx_get_location_prop
gx_set_location_prop
gx_get_player_prop
gx_set_player_prop
gx_add_player_prop
gx_get_decal_prop
gx_set_decal_prop
gx_get_force_prop
gx_set_force_prop
gx_add_force_prop
gx_is_map_init
- returns
trueif ingx_map_initstage of script
gx_get_common_seed
- returns a common random int that is the same in
gx_map_initandgx_sim_*stages.
hash
- internally invokes all objects
_hash()meta-function and combines the hashes together
object_id
- returns a unique object id for class instances, arrays, and tables
- return 0 for other types
rand_int
- returns random number from
[min max]
rand_float
- returns random number from
[min max]
rand
- returns 32-bit random number from
[0, +2147483647], or (0x7FFFFFFF)
rand_signed
- returns 32-bit random number from
[-2147483648, +2147483647]
rand64
- returns random number from
[0, +9223372036854775807]
rand64_signed
- returns random number from
[-9223372036854775808, +9223372036854775807]
sqrt
- returns square root of x
sin
- return sin of x
asin
- arcsin of x
cos
- return cos of x
acos
- arccos of x
tan
- return tan of x
atan
- arctan of x
atan2
- Computes the arc tangent of
y / xusing the signs of arguments to determine the correct quadrant
lerp
- linearly interpolate x -> y based on
[0, 1]
floor
ceil
fmod
- floating-point remainder function
- this is slighly different than the
%operatorfmodfollows truncated division semantics (Similar toC)- Sign will always be same as numerator
%follows floor division semantics (Similar toPython 3)- Sign will always be same as denominator
# fmod function:
fmod(5, 3) # +2.0
fmod(-5, 3) # -2.0
fmod(5, -3) # +2.0
fmod(-5, -3) # -2.0
# % Operator:
5.0 % 3.0 # +2.0
-5.0 % 3.0 # +1.0
5.0 % -3.0 # -1.0
-5.0 % -3.0 # -2.0
getroottable
- get DriftScript's internal "root" table
- this table contains all of the global functions and constants
getstackinfos
assert
- print message to all players in game
- also outputs to console in map editor
- see
gx_printfor more functionality
compilestring
newthread
suspend
array
array.len()
array.append(val)
array.extend(array)
array.empty()
array.push(val)
array.pop()
array.top()
array.insert(idx, val)
array.remove(idx)
array.resize([size], [fill])
array.reverse()
array.sort([compare_func])
array.slice(start[, end])
array.weakref()
array.tostring()
array.clear()
array.map(func(item_value, [item_index], [array_ref]))
array.apply(func([item_value, [item_index], [array_ref]))
array.reduce(func(prevval, curval)[, initializer])
array.filter(func(index, val))
array.find(value)
array.find_ref(value)
type
callee
dummy
- function that does nothing
abort
- essentially:
assert(false, msg)
min
- returns the minimum of x and y
max
- returns the maximum of x and y
abs
- return absolute value of x
clamp
- clamps val to be between
minandmax
pow
table
table.len()
table.empty()
table.tostring()
table.clear()
table.filter(func(key, val))
table.keys()
table.values()
# delete item:
delete table[key]
# check key in table:
key in table
# check key not in table:
key not_in table
string
string.len()
string.empty()
string.tointeger([base])
string.tofloat()
string.tostring()
string.replace(search, replace)
string.contains(search)
string.startswith(search)
string.endswith(search)
string.split(sep)
string.tolower()
string.toupper()
string.normalchars()
string.weakref()
is_numeric
- returns
trueisobjisintorfloat
Float2
- Helper function to create a
Vec2
Int2
- Helper function to create a
Vec2
Float3
- Helper function to create a
Vec3
Int3
- Helper function to create a
Vec3
Float4
- Helper function to create a
Vec4
Int4
- Helper function to create a
Vec4
AABR_float
- Helper function to make AABR
AABR_int
- Helper function to make AABR