Functions
gx_include
- Includes
filenamein 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_create_unit
table params = {
string m_unitType, // Required
int m_playerID, // Required
Vec2 m_pos = {}, // Optional
string m_location = {}, // Optional
int m_level = 1 // Optional, default unit level = 1
}
local new_unit = gx_create_unit({ m_unitType = "Brute", m_playerID = 1, m_location = "my_cool_location" })
- Will create unit of type
m_unitTypeat 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) - Refer to Vec2 if needed.
gx_get_sim_tick
- Returns the current sim tick number in simulation.
- The gx_sim_init call will have
tick = 0 - The first gx_sim_update call will have
tick = 1 - The second gx_sim_update call will have
tick = 2, etc.. - every tick corresponds to 50ms real time
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_units_touching
- Returns
trueif the two units are "touching" (nearby eachother)
gx_get_nearby_units / 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_unitTypes[], // Optional, Filter for certain unit types
string m_exceptUnitTypes[], // 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 / 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_unitTypes[], // Optional, Filter for certain unit types
string m_exceptUnitTypes[], // 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
- Refer to BoundsCheck if needed.
gx_create_explosion
table params = {
float m_size = {}, // Optional, Diameter of explosion
Vec3 m_color = Vec3(1, 1, 0) // Optional, ColorSRGB of explosion.
string m_location = {}, // Optional, Location for explosion
bool m_bPlaySound = true // Optional, defualt true
string m_sound = {} // Optional, Sound to play
string m_soundPack = {} // Optional, Play random sound from soundpack
}
- Refer to Vec3 if needed.
- Only one
m_soundorm_soundPackshould be set - If neither
m_soundnorm_soundPackis set, default sound will be played.
Example:
- it is undefined behavior to set both
m_locationandm_pos - if
m_sizeis not set andm_locationis set, the resolved size will be the minimum width/height ofm_location - if
m_sizeis not set andm_posis set, the resolved size will be1 - Explosions are purely visual. They do not do any damage.
- Default value for
m_colorisVec3(1,1,0)aka0xFFFF00(yellow) - Refer to Vec2 and Vec3 if needed.
gx_kill_unit
- kills the unit
unit_id. - It is safe to call this function on already killed units
gx_kill_all_units
- kills all units for any players that match the params
- It is valid to have both
m_forceIDsandm_playerIDsset -- the players fromm_forceIDsandm_playerIDswill be merged. - if neither m_playerIDs or m_forceIDs is set, all units will be killed
gx_get_kills
- if
m_playerIDis set, none ofm_bAlliedKills,m_bSelfKills,m_bNonAlliedKillsshould be set - if empty {} is passed in for params, all kills will be returned, equivalent to:
{ m_bAlliedKills = true, m_bSelfKills = rue, m_bNonAlliedKills = true } - Allied kills does not include self kills
gx_is_unit_killed
- returns if the unit
unit_idis killed - returns
trueif unit does not exist - equivalent to calling
!gx_is_unit_alive(unit_id)
gx_remove_unit
- marks the unit to be removed by game
unit_idwill be removed from game before the next gx_sim_update call- It is safe to call this function on already killed or removed units
gx_is_unit_removed
- returns if unit is marked to be removed
- will still return
trueif unit_id does not exist
gx_unit_exists
- checks if unit still exists in the game
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_get_unit_position
- returns position of unit
- returns Vec3(0.0, 0.0, 0.0) if unit no longer exists
gx_set_unit_position
Example:
- it is undefined to not set
m_location - if
m_locationdoes not exist, unit will be teleported to Vec2(0.0, 0.0)
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_players
table params = {
int m_forceIDs[], # Optional if set, only consider players part of these forces
int m_playerIDs[], # Optional, if set, only consider these players
VictoryStatus m_allowedVictoryStates[] # filter
bool m_bIncludeNormalPlayers = true; # filter, default true
bool m_bIncludeNeutralPlayer = false; # filter, default false
bool m_bIncludeRescuePlayer = false; # filter, default false
bool m_bIncludeHostilePlayer = false; # filter, default false
bool m_bPlayerMustBeInGame = true; # filter, default true
}
m_allowedVictoryStates is not set, any victory state will be considered
- It is valid to have both m_forceIDs and m_playerIDs set -- the players from m_forceIDs and m_playerIDs will be merged.
gx_get_player
- returns theplayer_id for unit unit_id
- if unit does not exist, will return 0
gx_print
table params = {
int m_forceIDs = [], // Optional, send message to only force_id
int m_playerIDs = [], // Optional, send message to only player_id
bool m_bPlaySound = true // Optional, default true
string m_sound = {} // Optional, sound to play,
string m_soundPack = {} // Optional, play random sound from soundPack
}
- If both
m_forceIDsandm_playerIDsare undefined, message will be sent to all players
Example
// display chat message 'Hello World!' to player 3
gx_print("Hello World!", { m_playerID = 3 } )
// display chat message 'Hello World!' to everyone in force 2
gx_print("Hello World!", { m_forceID = 2 } )
// display chat message 'Hello World!' to everyone
gx_print("Hello World!")
// equivalent to above, display chat message 'Hello World!' to everyone
gx_print("Hello World!", {})
- outputs text to game chat (or map editor console)
- useful for debugging as well
print(message)is equivalent togx_print(message, {})paramsare ignored when running in map editor's console
gx_modify_scoreboard
- Set
m_bDisplayto show scoreboard, must betrueif you want to display - Set
m_bShowForceScoresto show scores for forces - Set
m_bShowPlayerScoresto show scores for players - You can set/add/get scores by using property-getterssetters
Example:
gx_modify_scoreboard({
m_bDisplay = true,
m_bShowPlayerScores = true,
m_bShowForceScores = false
})
// Set score for 'Player 3' to 7
gx_set_player_prop(PlayerProp.Score, 3, 7)
gx_set_victory_status
table params = {
int m_status = VictoryStatus.Victory, // Optional
// Valid options: VictoryStatus.Victory or VictoryStatus.Defeat
// Default: VictoryStatus.Victory
int m_playerIDs[], // Optional
int m_forceIDs[], // Optional
bool m_bAllPlayers = false, // Optional, (default: false)
bool m_bAllForces = false, // Optional, (default: 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
}
- once a player or force is set to
victoryordefeat, future calls for that player/force will be ignored
gx_is_players_mutually_allied
- Returns
trueif all the players represented bym_forceIDsandm_playerIDsare mutually allied with each other. - It is valid to have both
m_forceIDsandm_playerIDsset -- the players fromm_forceIDsandm_playerIDswill be merged. - If the number of resolved players from
m_forceIDsandm_playerIDsis 1 or less, this function will always returntrue.
gx_is_player_allied_to
gx_set_player_allied_to
gx_map_init_copy_ud
Creates a copy of a unit_data.
A unit_data serves as a 'definition' for a type of unit.
Required for creating new custom unit types.
The example below creates a new type of unit called "User_BabyBrute" It copies the existing definition of "Brute" to "User_BabyBrute".
Example:
- NOTE!! It's preferred to use the Drift Wars Map Editor to add/edit units!!
- These functions are only for convenience
- new unit type name MUST begin with
User_. This is to prevent naming collisions for future added official units. - this function will be a no-op if
new_unit_typename does not begin withUser_ - This function will return empty string if
new_unit_typealready exists or if it does not start withUser_. udis short forunit_definition- Can only be called during gx_map_init
- any attempt to call this outside of the gx_map_init will be ignored.
gx_map_init_modify_ud_props
table params = {
string m_friendlyName = {}, // Optional, set unit's friendly name
int m_maxHealth = {}, // Optional, set max health
float m_maxSpeed = {}, // Optional, set max speed
int m_baseArmor = {}, // Optional, sets base armor
int m_size = {} // Optional, set unit size,
int m_gemstoneCost = {},
int m_fungusCost = {},
int m_supplyCost = {},
int m_buildTime = {}
}
The example below creates a new type of unit called "User_BabyBrute".
It copies the existing unit_definition of "Brute" to "User_BabyBrute".
It then sets properties such as friendly name, maxHealth, baseArmor, and size.
Example:
gx_map_init_copy_ud("Brute", "User_BabyBrute")
gx_map_init_modify_ud_props("User_BabyBrute", {
m_friendlyName = "Baby Brute",
m_maxHealth = 30,
m_baseArmor = 0,
m_size = 1
})
- Sets properties for a specific
unit_type udis short forunit_definition- Can only be called during gx_map_init
- any attempt to call this outside of the gx_map_init will be ignored.
gx_map_init_add_build_structure_item
table params = {
string m_structure = {}, // name of structure to build, i.e. "Microwave"
Vec2 m_position = {}, // position in command card to place at, leaving empty will use default
bool bBuildAdvanced = false // default is false, if set to True, will be placed in 'build advanced' tab
}
- Can only be called during gx_map_init
gx_map_init_remove_all_build_structure_items
- Remove all build structure items from worker
- Can only be called during gx_map_init
gx_map_init_add_build_item
table params = {
string m_unitType = {}, // unit type to add
string m_research ={}, // research to add
Vec2 m_position = {} // position in command card
}
- Only one
m_unitTypeorm_researchshould be set - Can only be called during gx_map_init
- Remove all build items from structure
gx_map_init_remove_all_build_items
- Remove all build items from structure
- Can only be called during gx_map_init
gx_fling_unit
throws the unit
table params = {
Vec2 m_dir2d = {}, // Optional, 2d direction to throw unit. Does not need to be normalized.
Vec3 m_dir3d = {}, // Optional, 3d direction to throw unit. Does not need to be normalized.
float m_force = 1 // Optional, velocity to throw unit
m_bFlingLookAtDir = false // Optional, will fling unit in direction it is facing
m_bFlingStructures = false // Optional, if true, structures will be thrown
}
- If neither
m_dir2dnorm_dir3dis set, unit will be thrown in random direction - Only
m_dir2dorm_dir3dshould be set. Setting both is undefined behavior. - Refer to Vec2 and Vec3 if needed.
gx_set_area_vision
table params = {
string m_location = {}, // location to give or take away vision of (depending on m_bSet)
string m_triangleGroup = {}, // triangle group to give or take away vision of (depending on m_bSet)
bool m_bFullMapVision = {} // If set to true, will give or take away vision of entire map (depending on m_bSet)
bool m_bSet = true // If true gives vision, else takes away vision. (default: true)
}
- This function gives or removes permanent vision of a
m_location,m_triangleGroup, orentire map. - Only one of
m_location,m_triangleGroup, orm_bFullMapVisionshould be set. - The only valid value of
m_bFullMapVisionistrue. Setting tofalseisundefined. - If you want to give
Full Map Visionto a player, setm_bFullMapVisiontotrueandm_bSettotrue. - If you want to remove
Full Map Visionfrom a player, setm_bFullMapVisiontotrueandm_bSettofalse. - The value of
m_bSetdetermines if vision is given or taken away from player.
gx_get_area_vision
table params = {
string m_location = {}, // location to query vision for
string m_triangleGroup = {}, // triangle group to query vision for
bool m_bFullMapVision = {} // If set to true, queries if player has full map vision
}
- This function queries if the player has permanent vision of a
location,triangleGroup, orentire map. - Only one of
m_location,m_triangleGroup, orm_bFullMapVisionshould be set. - The only valid value of
m_bFullMapVisionistrue. Setting tofalseisundefined.
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)
Vec2 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"
})
- Refer to TerrainType for valid
m_typevalues - If
m_typeis set toTerrainType.Normal,m_secondarymust be one of SecondaryTerrainTypeNormal values - Refer to Vec2 if needed.
- if only
m_indexis set, the square atm_indexis set to terrain type (i.e. both bottom and top triangle) - if
m_locationis set, the triangles within them_locationare set to the new terrain type - if
m_triangleGroupis set, the triangles withinm_triangleGroupare set to the new terrain type - if
m_locationis set, it isundefined behaviorto also setm_index,m_index2, orm_triangleGroup - if
m_triangleGroupis set, is itundefined behaviorto also setm_index,m_index2, orm_location - if
m_indexis set, it isundefined behaviorto also setm_location, andm_triangleGroup
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_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 by gx_lock_player_camera - equivalent to calling
gx_lock_player_camera(player_id, {})
gx_queue_command
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
Vec2 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 - See CommandType for possible command values
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|set|add)_unit_ammo
int gx_get_unit_ammo(int unit_id, string ammoName)
void gx_set_unit_ammo(int unit_id, string ammoName, int count)
void gx_add_unit_ammo(int unit_id, string ammoName, int count)
- Can query and set how much
unit ammoof typeammoNamethe unit is holding
gx_(get|set|add)_player_ammo_in_unit
int gx_get_player_ammo_in_unit(int unit_id, string ammoName)
void gx_set_player_ammo_in_unit(int unit_id, string ammoName, int count)
void gx_add_player_ammo_in_unit(int unit_id, string ammoName, int count)
- Can query and set how much
player ammoof typeammoNamethe unit is holding
gx_get_player_ammo_total
- Returns how much
player ammoof typeammoNamethe player has
local params = {
string m_tag, // Required (string)
int m_player_id = 0 // Optional, used to Filter. Default = 0. (int)
}
- 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.
Property Getters/Setters
- Allows you to get/set certain properties for
simulation,forces,players, andunits, and other things
// getters
mixed gx_get_map_prop(MapProp prop)
mixed gx_get_force_prop(ForceProp prop, int force_id)
mixed gx_get_player_prop(PlayerProp prop, int player_id)
mixed gx_get_unit_prop(UnitProp prop, int unit_id)
mixed gx_get_location_prop(LocationProp prop, string location)
mixed gx_get_decal_prop(DecalProp prop, int decal_id)
// setters
void gx_set_map_prop(MapProp prop, mixed val)
void gx_set_force_prop(ForceProp prop, int force_id, mixed val)
void gx_set_player_prop(PlayerProp prop, int player_id, mixed val)
void gx_set_unit_prop(UnitProp prop, int unit_id, mixed val)
void gx_set_decal_prop(DecalProp prop, int decal_id, mixed val)
// adders
void gx_add_force_prop(ForceProp prop, int force_id, mixed val)
void gx_add_player_prop(PlayerProp prop, int player_id, mixed val)
void gx_add_unit_prop(UnitProp prop, int unit_id, mixed val)
- Please refer to MapProp, ForceProp, PlayerProp, UnitProp, DecalProp, and LocationProp for possibles values you can get/set (and their types).
- Properties that are
intorfloatand areRead-Writecan use thegx_add_*functions
UserData Getters/Setters
- Allows you to get/set userdata integers for
simulation,forces,players, andunits, and other things for your own purposes
// getters
int gx_get_sim_variable(string varName)
int gx_get_force_variable(int force_id, string varName)
int gx_get_player_variable(int player_id, string varName)
int gx_get_unit_variable(int unit_id, string varName)
// setters
void gx_set_sim_variable(string varName, int varValue)
void gx_set_force_variable(int force_id, string varName, int varValue)
void gx_set_player_variable(int player_id, string varName, int varValue)
void gx_set_unit_variable(int unit_id, string varName, int varValue)
// adders
void gx_add_sim_variable(string varName, int varValue)
void gx_add_force_variable(int force_id, string varName, int varValue)
void gx_add_player_variable(int player_id, string varName, int varValue)
void gx_add_unit_variable(int unit_id, string varName, int varValue)
- Calling
gx_get_*to retrieve a non-existingvarValuewill return0. - Only
intvalues can be set.
gx_modulo
- function for wrapping
aaroundb - If both
aandbare integer, the result will be integer - If at least one
aorbis a float, result will be float - The return value will have same sign as
b - differs from the
%operator for negative numbers
local result = 0
result = 2 % 5 // 2
result = gx_modulo(2, 5) // 2
result = 5 % 5 // 0
result = gx_modulo(5, 5) // 0
result = 6 % 5 // 1
result = gx_modulo(6, 5) // 1
result = -1 % 5 // -1
result = gx_modulo(-1, 5) // 4 !! <-- DIFFERENT THAN % operator
gx_triangle_lerp
gx_str_starts_with
- returns
trueifstrstarts withval
gx_str_ends_with
- returns
trueifstrends withval
gx_str_insert
- return a new string with
toInsertinserted at positionindex
gx_str_encode_color_id
gx_str_encode_color
gx_str_encode_color_hex3
gx_str_encode_complex_color
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_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_sound2d_create
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
}
m_sound or m_soundPack (but not both).
- If neither m_forceIDs nor m_playerIDs are 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
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
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
Vec2 m_pos2d, // Optional, 2d position for sound
Vec3 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
params = {
float m_volume, // Optional, volume multiplier
float m_pitch, // Optional, pitch of sound
Vec2 m_pos2d, // Optional
Vec3 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_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 = {},
Vec4 m_color = {}, // srgb with alpha
Vec2 m_pos = {},
float m_rotation = {}, // radians
float m_size = {},
Vec2 m_size = {}, // size, can either be Vec2<float> or float
string m_tag = {},
string m_texture = {}, // icon to use
float m_speedFactor = 1.0 // animation speed if m_texture is animated GIF
}
- create decal with properties, all fields are optional
- only one (or zero) of
m_sizeorm_size2dshould be set
gx_decal_modify
table params = {
string m_preset = {}, # decal preset
int m_alphaFn = {},
int m_colorFn = {},
bool m_bAlwaysDisplay = {}, # ignore fog of war checks
bool m_bDisplayOnMinimap = {},
Vec4 m_color = {}, # srgb with alpha
Vec2 m_pos = {},
float m_rotation = {}, # radians
float m_size = {},
string m_tag = {},
string m_texture = {}, # icon to use
float m_speedFactor = 1.0 animation speed if m_texture is animated GIF
}
- 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_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_get_sim_image_colors
- Returns all the pixels in the image in hex3 format
- Alpha channel is ignored and not returned
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_set_terrain_glow_color
table params = {
int m_index, // Glow index to change, required
int m_hex, // srgb hex3 code for color to set
Vec3<float> m_color // srgb color (each component [0.0-1.0]) for new color to set
}
- Only one
m_hexorm_colorshould be set, not both. - Internally,
m_hexis converted tom_color. m_hexparameter is only given for convenience.
gx_set_map_theme_color
gx_get_map_theme_color
gx_set_map_glow_color
gx_get_map_glow_color
gx_color_*
Vec3<float> gx_color_hsv_to_srgb(Vec3 hsv)
Vec3<float> gx_color_srgb_to_hsv(Vec3 srgb)
Vec3<float> gx_color_hsl_to_srgb(Vec3 hsl)
Vec3<float> gx_color_srgb_to_hsl(Vec3 srgb)
Vec3<float> gx_color_hex3_to_srgb(int hex3)
int gx_color_srgb_to_hex3(Vec3 srgb)
Vec4<float> gx_color_hsva_to_srgba(Vec4 hsva)
Vec4<float> gx_color_srgba_to_hsva(Vec4 srgba)
Vec4<float> gx_color_hsla_to_srgba(Vec4 hsla)
Vec4<float> gx_color_srgba_to_hsla(Vec4 srgba)
Vec4<float> gx_color_hex4_to_srgba(int hex4)
int gx_color_srgba_to_hex4(Vec4 srgba)
int gx_color_hex3_to_hex4(int hex3, int alpha = 0xFF)
int gx_color_hex4_to_hex3(int hex4)
- color conversion functions
hsla:hsla.m_xis hue[0-360],hsla.m_yis saturation[0-100],hsla.m_zis lightness[0-100],hsla.m_wis alpha[0-1]hsva:hsva.m_xis hue[0-360],hsva.m_yis saturation[0-100],hsva.m_zis value[0-100],hsva.m_wis alpha[0-1]srgba:srgba.m_xis red[0-1],srgba.m_yis green[0-1],srgba.m_zis blue[0-1],srgba.m_wis alpha[0-1]hex4is an integer with value0xAARRGGBBwhere AA is alpha, RR is red, GG is green, BB is bluehex3is an integer with value0x00RRGGBBwhere RR is red, GG is green, BB is blue
gx_rand_float
gx_rand_int
gx_rand_unit_vec*
gx_unit_vec_or_random
Vec2<float> gx_unit_vec_or_random(Vec2 v)
Vec3<float> gx_unit_vec_or_random(Vec3 v)
Vec4<float> gx_unit_vec_or_random(Vec4 v)
v.
- Will return random unit vector if v has magnitude of 0.
gx_unit_vec_or_zero
Vec2<float> gx_unit_vec_or_zero(Vec2 v)
Vec3<float> gx_unit_vec_or_zero(Vec3 v)
Vec4<float> gx_unit_vec_or_zero(Vec4 v)
- Computes the unit vector of
v. - Will return zero-magnitude vector if unit vector
vhas magnitude of0.
gx_terrain_offset_z_add
gx_terrain_offset_z_add_2
table params = {
AABR<int> m_aabrs[], # Optional
string m_locations[], # Optional
Vec2<int> m_vertices[], # Optional
float m_val, # Required
}
gx_terrain_offset_z_set
gx_terrain_offset_z_set_2
table params = {
AABR<int> m_aabrs[], # Optional
string m_locations[], # Optional
Vec2<int> m_vertices[], # Optional
float m_val, # Required
}
gx_terrain_offset_z_get
gx_aabr_contains
gx_aabr_contains_or_touching
gx_create_effect
table params = {
EffectType m_type,
Vec2<float> m_pos,
int m_duration,
Vec4<float> m_color, # srgb
int m_playerID
}
- Creates the Effect of type
m_typeand returns the Effect ID - See EffectType for effects
gx_destroy_effect
- Destroys effect if it can be removedgx_create_nuke_unit
- Creates a nuke unit
gx_register_for_location_events
- Register to receive
UnitEnteredLocationandUnitExitedLocationevents - no optional parameters currently
- Usually you will want to only call this one time time in the
gx_sim_initfunction - See EventType and Event Queue for more information
gx_triangle_lerp
- Lerp function
gx_is_event_queue_empty
- Check if event queue is empty.
- See Event Queue
gx_pop_event_from_queue
- Pop event from event queue.
- See Event Queue