Script Commands

//returns the turn count.
GetTurn()
 
//returns the tick in the current turn (in 30ths of a second)
GetTurnTick()
 
//end the battle setting the denoted side as the winner.  Will be ignored if the battle already has a winner...
EndBattle(winner)
 
//return a random number [min, max] i.e. with a min value of min and a max value of max inclusive.  MUST be multiplayer safe.
Rand(min, max)
 
//return a random number [min, max] i.e. with a min value of min and a max value of max inclusive.  Can be used for non-multiplayer/visual only tasks which are not multiplayer safe
FXRand(min, max)
 
//take a value [0,100] and scale using Sine.  Use to make random values clump around 100 more and be less likely to be 0
SinScale(value)
 
//Output a string to the debug stream, for debugging.  Can have up to 4 values which will also be logged.
Log(string, [value, value, value, value])
 
//returns the min of the 2 values
Min(a, b)
 
//returns the max of the 2 values
Max(a, b)
 
//clear out the work array to the specified value.  The work array is a set of 256 ints which can be used as a scratchpad.  Note that all scripts share the same array, so beware of side effects.
ClearArray(value)
 
//get a value from the work array
GetArray(index)
 
//set a value in the work array
SetArray(index, value)
 
//return the side id set for the mission, for the given side (0 or 1).  These are the value set using the side ID buttons in the editor
GetSideID(side)
 
//get a rand between and including the values of attrib[index] and attrib[index+1]
GetAttribRand(id, string, index)
 
//return the value of the give attrib for the give unit
GetAttrib(id, string)
 
//return the value of the give attrib at the index for the give unit (attrib[index])
GetAttribArray(id, string, index)
 
//return the base value of the give attrib for the give unit
GetBaseAttrib(id, string)
 
//return the base value of the give attrib at the index for the give unit (attrib[index])
GetBaseAttribArray(id, string, index)
 
//set the value of the give attrib for the give unit
SetAttrib(id, string, value)
 
//set the value of the give attrib at the index for the give unit (attrib[index])
SetAttribArray(id, string, index, value)
 
//create a new attrib (which will be available across all units) does nothing is attrib already exists.
AddAttrib(string)
 
//create a new attrib array (available across all units) does nothing is attrib already exists.
AddAttribArray(string)
 
//return the value of the campaign var, if index is not provided 0 is used.  index must be [0, 8]
GetCampaignVar(tag, [index])
 
//set the value of the campaign var, if index is not provided 0 is used.  index must be [0, 8]
SetCampaignVar(tag, value, [index])
 
//return the value saved to a univeral variable.  Returns 0 and creates if does not exist.This is accessible from any script.
GetUniversalVar(tag)
 
//set the value to a univeral variable.  Created if doesn't exist  This is accessible from any script.
SetUniversalVar(tag, value)
 
//return the value of the value stored in the options file.  index [0,31] Can be used for global flags to define behaviour.
GetOptionValue(index)
 
//set the value into the options file.  index [0,31]
SetOptionValue(index, value)
 
//returns 1 if in a deployment phase, 0 otherwise
IsDeploying()
 
//tells the game to skip the first player turn if the mission is set to have a deploy phase.  Obviously only useful to call on turn -1 or 0
SkipFirstPlayerTurn()
 
//tells the game not to show the onscreen start turn UI for this turn.  Only works when used in the StartTurn function
DisableStartTurn()
 
//returns a map ordinate reworked correctly for the current system (border sizes etc).  Should be used anywhere hardcoded coords are used.
MapX(x)
 
//returns a map ordinate reworked correctly for the current system (border sizes etc).  Should be used anywhere hardcoded coords are used.
MapY(y)
 
//return a value denoting whether the tile is valid.  1 means it is on the playable area, 0 means it is in the border, -1 means it is off the map entirely
IsValidTile(x,y)
 
//returns 1 if we are currently executing an AI turn in battle mode, 0 otherwise
IsAITurn()
 
//return the side whose turn it currently is
GetCurrentSide()
 
//returns the side who is currently viewing the map (used for tile LOS etc, to show what should be seen)
GetShowSide()
 
//return the id of the currently selected unit.  Returns -1 if none
GetCurrentSelectedUnit()
 
//set the currently selected unit.  Use -1 for none.
SetCurrentSelectedUnit(id)
 
//add a unit to the map.  The string is the unit name.  If the tile is not clear the unit is not added.  Returns the id of the new unit, or -1 if there was a problem
AddUnit(x, y, side, typeString)
 
//Set a squad to route to the designated tile.  react denotes whether the move triggers reaction fire.
SetRoute(id, x, y, [react])
 
//Set a squad to route to the designated tile, but reverse there.  react denotes whether the move triggers reaction fire.
SetRouteReverse(id, x, y, [react])
 
//set a squad route, but factor in the threat map denoted by the threatIndex, currently [0,2]
SetRouteUsingThreat(id, x, y, threatIndex)
 
//Find the route length for the given squad.  -1 if cannot find a route.  showroute show it on the map.  
// ignoreunits 0(can't route), 1(try to avoid), 2(route as if not there) | 128 then treat all tiles as same cost
GetRouteCost(id, x, y, [showRoute], [ignoreUnits])
 
//return 1 if the unit can step to the tile x,y (which must be adjacent).  Basically is a shortest route 2 tiles in length.
CheckTileStep(id, x, y)
 
//return the cost of this tile for this unit.  Useful to find whether a unit can sit on a tile, for example.
GetTileCost(id, x, y)
 
//Route cost for the squad.  -1 if cannot find route.  showroute show it on the map,use threat map denoted by the threatIndex, currently [0,2].  ignoreUnit 1=target, 2=all units
GetRouteCostUsingThreat(id, x, y, showRoute, ignoreUnit, threatIndex)
 
//get the X ordinate of the [index] entry into the route just generated by a call to GetRouteCost*
GetCheckRouteX(index)
 
//get the Y ordinate of the [index] entry into the route just generated by a call to GetRouteCost*
GetCheckRouteY(index)
 
//return the number of tiles in the route generated by a call to GetRouteCost*
GetCheckRouteLength()
 
//return the unit side
GetUnitSide(id)
 
//returns 1 if the id unit is of type string (e.g. Sherman) as per the Name field in the squads file.  0 otherwise
IsUnitType(id, string)
 
//returns 1 if the unit is of the squad type string (e.g. INFANTRY) as defined in the terrain file
IsUnitSquadType(id, string)
 
//returns 1 if the unit is moving, 0 otherwise
IsUnitMoving(id)
 
//returns 1 if the unit is set as fixed in the editor
IsUnitFixed(id)
 
//returns the point cost of the given unit
GetUnitCost(id)
 
//get the face that the enemy is presenting to my position.  front,side,back = 0,1,2
GetFacingFrom(me_id, enemy_id)
 
//get the angle the enemy is presenting to my position, 0=looking straight at me, 180=I am directly behind them
GetAngleFrom(me, enemy)
 
//get the angle the enemy is presenting to the denoted tile, 0=looking straight at me, 180=I am directly behind them
GetAngleFromTile(x, y, enemy)
 
//get the face that the enemy is presenting to my position.  front,side,back = 0,1,2
GetTurretFacingFrom(me_id, enemy_id)
 
//get the angle the enemy is presenting to my position, 0=looking straight at me, 180=I am directly behind them
GetTurretAngleFrom(me, enemy)
 
//get the angle the enemy is presenting to the denoted tile, 0=looking straight at me, 180=I am directly behind them
GetTurretAngleFromTile(x, y, enemy)
 
//return the unit's X coord
GetUnitX(id)
 
//return the unit's Y coord
GetUnitY(id)
 
//return the X coord of the specified man, in 100ths
GetManX(id, man)
 
//return the Y coord of the specified man, in 100ths
GetManY(id, man)
 
//place this unit on the tile.  Fails if the tile is occupied.
SetUnitTile(id, x, y)
 
//return how many men are in the unit
GetUnitMen(id)
 
//is this man dead?  0 = no, 1 = yes
GetUnitManDead(id, man)
 
//is the whole unit dead? 0 = no, 1 = yes
GetUnitDead(id)
 
//is the unit active (e.g. not dead, loaded, or removed from the map) 0 = no, 1 = yes
GetUnitActive(id)
 
//does this unit have LOS to the tile?  0 means no
GetUnitLOS(id, x, y)
 
//does this unit have LOS to the target?  0 means no
GetUnitLOSToUnit(id, target)
 
//return an id for the unit on a tile, -1 for none
GetUnitOnTile(x, y)
 
//tell our unit to turn and face the tile
SetUnitTurnToFace(id, x, y)
 
//flag this unit that enemies can react to what we just did
SetUnitForReaction(id)
 
//returns 1 if the unit has a turret, 0 otherwise
GetUnitTurret(id)
 
//returns the status of the unit, [0,3]
GetUnitStatus(id)
 
//sets the status of a unit.  Valid values are 0,1,2,3.  Changes the icon set used, and can be used to give extra abilities
SetUnitStatus(id, status)
 
//do an immediate switch for a unit to a given facing [0,359]
SetUnitFacing(id, angle)
 
//return the unit facing angle
GetUnitFacing(id)
 
//call a unit script each tick until fn returns 0.  Can only be checking one fn at any time.  Must be defined in the unit script.  Can ONLY be used to call 
// functions with up to 6 fixed params, one used forname.
SetUnitCheckFunction(id, function, [value, ...])
 
//show tracer fire, x,y are the end coords (in 100s), point is index of emitter 3d object, time is the duration in ticks, type is the visual type of the tracer
SetUnitTracer(me, man, x, y, point, time, type)
 
//set the weather.  0 = none, 1 = rain.  2 = snow.
SetWeather(mode)
 
//return the id of the unit if there is a clearable wreck on the tile, -1 if not
GetWreckOnTile(x,y)
 
//return 0 if the unit could sit on the tile, 1 if not
IsTileBlocked(id, x, y)
 
//move a unit instantly to this tile.  If there is a unit already there, it will be swapped with the current unit
UnitDeploy(id, x, y)
 
//if the unit script contains the function return the number of params, -1 otherwise
GetUnitFunction(id, functionName)
 
//call a function on a unit with params in the expected order, limited to functions with 6 params or less, returns the function result
CallUnitFunctionDirect(id, functionName, [value, ...])
 
//call a function on unit.  Assumed to have some/all of the params X, Y, UNIT, ME as per standard menu functions.
CallUnitFunction(id, functionName, x, y, me, unit)
 
//flag the men in the unit (as defined by the mask) as being dead
DestroyUnit(id, mask)
 
//remove this unit from play.  Flags = 0 just remove from tile, =1 immediate removal, =2 sink out of sight and remove
RemoveUnit(id, flags)
 
//resurrect the denoted men in a unit.  This will remove any dead bodies, will appear in place on the unit tile.  WILL NOT work on dead units
ReviveUnit(id, mask)
 
//return the width of the map
GetMapWidth()
 
//return the height of the map
GetMapHeight()
 
//clear threat map index with the provided value [0,255]
ClearThreatMap(index, value)
 
//get the threat map value from map index at x,y
GetThreatMapValue(x, y, index)
 
//set the threat map value from map index at x,y.  Value must be [0,255]
SetThreatMapValue(x, y, index, value)
 
//load the toBeLoadedID unit onto the id unit.  NOTE:  Units can have more than 1 loaded unit
LoadUnit(id, toBeLoadedID)
 
//does the unit have another unit loaded onto it.  Returns the first unit found if more than one loaded, -1 if none found.
GetLoadedUnit(id)
 
//unload the unit that we are carrying onto the given tile,  returns 0 on success, -1 otherwise
UnloadUnit(id, x, y)
 
//get the terrain cover value for the given x,y
GetTerrainCoverValue(x, y, index)
 
//get the terrain cover value for the given x,y, based on side's LOS to the tile
GetTerrainCoverValueFromLOS(x, y, index, side)
 
//return 1 if the tile is a water tile, 0 otherwise
IsTileWater(x, y)
 
//set the los of a tile.  Values are:  0=hide, 1=show
SetTileLOS(x, y, side, los)
 
//return the LOS value of a tile.  0=hidden, 1=shown, 2 = cover
GetTileLOS(x,y,side)
 
//return the cover flag for a tile.  1 set means can be hidden in
GetTileCoverFlag(x,y)
 
//damage a tile by the specified amount.  Tile damages ranges [0,255]
DamageTile(x, y, amount)
 
//return the damage on a given tile.  Tile damages ranges [0,255]
GetTileDamage(x, y)
 
//return the height of the center of a given tile, in 100ths.  So 0 would be ground level, 100 the top of a 1st level hill, etc
GetTileHeight(x,y)
 
//play an effect on these men in a unit, using the mask as per AddVizAnim
PlayEffect(id, mask, effect)
 
//return the distance between the two units
GetDistanceBetween(id, id)
 
//return the distance between two tiles
GetDistanceBetweenTiles(x1, y1, x2, y2)
 
//how far is the unit from the tile
GetDistanceFromUnit(id, x, y)
 
//play one of the defined sfxTypes for the the unit.  can optionally specify a bank to play from
PlayUnitUISFX(id, sfxType, [bank])
 
//play a specific UI sample. can optionally specify a bank to play from
PlayUISFX(sfx. [bank])
 
//play a world positioned sfx on the specified unit. can optionally specify a bank to play from
PlayUnitSFX(id, sfxType, [bank])
 
//play a sample at a specified position in the world (x,y are in 100ths). can optionally specify a bank to play from
PlaySFX(x, y, sfx, [bank])
 
//play a screen shake for N ticks, the scale determines the amount of movement, in 100ths, so 100 is the default x1 value
Shake(ticks, scale)
 
//tell the game whether or not to show the cover ? markers.  1 = yes, 0 = no
ShowCoverMarkers(show)
 
//show a text marker at the specified tile center.  flags is a mask.  1=show even if tile hidden. id is user defined.  must not be zero.  colour is a hex string
ShowTextMarker(id, x, y, string, fontid, colour, flags)
 
//hide the specified text marker
HideTextMarker(id)
 
//show anim at center of tile xy.  id is a user handle to allow for turning off etc-must NOT be zero. Use a negative id to loop the effect. sidemask=optional [0,1] 
// only that side can see.  Set MinimapColourString to non-zero to show
ShowEffectMarker(id, x, y, animFile, effect, [showside], [MinimapColourString])
 
//remove an effect marker
HideEffectMarker(id)
 
//set the flag for turning on or off the force visible flag.  0 for off, anything else for on
SetForceVisible(id, value)
 
//set the flag for player control of a unit.  0 for off, anything else for on
SetCannotControl(id, value)
 
//define which viz queue to use.  They both execute symultaneously.  Remember to set back to 0 when you are done.
UseVizQueue(queue)
 
//add a queued anim (string) to the unit, the mask is the men affected (1 == man 0, 2 == man 1, etc) neg mask means play until you tell it play something else
AddVizAnim(id, anim, mask)
 
//add a queued anim without a wait until the end (string) to the unit, the mask is the men affected (1 == man 0, 2 == man 1, etc.  neg mask means play until you play something else)
AddVizAnimNoWait(id, anim, mask)
 
//move the camera (if needed) to show this tile
AddVizCam(x, y)
 
//move the camera (if needed) to center the screen on this tile
AddVizCamCenter(x, y)
 
//move the camera (if needed) to point to this unit
AddVizCamUnit(id)
 
//insert a pause in the viz queue (and thus the game) of delay ticks
AddVizDelay(delay)
 
//add a display of text to the tile center, in the colour (colour is a string hex value).  alwaysShow means show even if tile is not visible to viewing side
AddVizText(x, y, text, colour, [alwaysShow])
 
//add a display of text to the unit, in the colour (colour is a string hex value).  alwaysShow means show even if tile is not visible to viewing side
AddVizUnitText(id, text, colour, [alwaysShow])
 
//on unit id, using the mask for men, play the file with the effect (-1 for none) and define the end time (1000ths of a sec, -1 for end of the anim).
// animFile must be in the campaign or core ANIM dir
AddVizUnitSpotAnim(id, mask, animFile, effect, endTime)
 
//at x,y (in 100ths) play the file with the effect (-1 for none) and define the end time (1000ths of a sec, -1 for end of the anim).  animFile must be in the campaign or core ANIM dir
AddVizSpotAnim(x, y, animFile, effect, endTime)
 
//turn the unit to face the specified tile. if nowait!=0 then it doesn't pause the main vizq, only the unit.
AddVizUnitTurnToFace(id, x, y, [noWait])
 
//turn the unit or the unit's turret (if it has one) to face the tile. if nowait!=0 then it doesn't pause the main vizq, only the unit.
AddVizUnitTurnToFire(id, x, y, [noWait])
 
//call a function from the vizQ.  Can ONLY be used to call functions with up to 7 fixed params, as one is used for the name.
AddVizFunctionCall(function, [value, ...])
 
//wait until the denoted unit has finished moving
AddVizWaitOnMove(id)
 
//Set the value of a global bonus base value
SetBonusBaseValue(name, side, value)
 
//Get the value of a global bonus base value
GetBonusBaseValue(name, side)
 
//Get the current value (taking into account player bonuses) of the global value.  If base is provided, we actually look for the string base+name as the global
GetBonusValue(name, side, [base])
 
//set the icon mask.  This is used when working out how to tag units.  Each of 8 bits add a different icon to the unit.  Sets the value, not OR.  Only used to pass the value back to the code.
SetIconMask(mask)
 
//set the icon mask.  Used by friendly units to show all the time, rather than to show actionable units for the current unit.  Uses same icon set.  ORs this value with the current value.
SetUnitIconMask(id, mask)
 
//turn off the bits in icon mask.  Used by friendly units to show all the time, rather than to show actionable units for the current unit.  Uses same icon set.  Turns off only the bits requested.
ResetUnitIconMask(id, mask)
 
//begin a new string construction
StartString()
 
//add the string defined by the string id to the current string construct
PrintString(stringID)
 
//add the string defined by the string id to the current string construct (e.g. IDS_STRING0 would be accesed by (IDS_STRING, 0)
PrintStringIndexed(stringID, index)
 
//print the contents of string into the string construct (mainly for spacing, newlines etc)
PrintStringLiteral(string)
 
//print the value into the construct string
PrintInt(value)
 
//returns the string height in the requested font
GetStringHeight(font)
 
//begin a new work string construction.  This is for building filenames etc.  Up to 16 strings, uses 0 if no index
StartWorkString([index])
 
//print a literal to the work string
PrintWorkStringLiteral(string, [index])
 
//print an integer to the work string
PrintWorkStringInt(value, [index])
 
//return the work string to any function which takes a string argument
GetWorkString([index])
 
//render the string to the screen.  colourString is a hex value (as is borderColourString if used, 0 for not used).  Returns the printed text height.  Everything done in 1024x768 space
RenderString(x, y, font, colourString, [borderColourString], [width], [height])
 
//flag an area of the screen as UI.  Means the UI won't treat the mouse as pointing to the map and will not show icons or options etc.  tooltip&1 then 
//take current string & uses as tooltip.  bits 8-15 used as an id passed through.
BlockUIArea(x, y, width, height, [tooltip])
 
//render an image based on its filename (UI/TEXTURES base dir unless path is given.  Resets the image area. Neg width/height flips)
RenderImage(x, y, width, height, colourString, imageName, [path])
 
//Sets a restricted area to render from on the next call to RenderImage.  All values are in 1000ths, so to only draw the bottom half of the image you would use 0, 500, 1000, 500
SetImageArea(x, y, width, height)
 
//Set the current UI object which is being rendered to the texture and colour (colour is a hex string).  Do not use the file extension
SetUITexture(filename, colour)
 
//set the current string as the tooltip which should be used by the UI for this control (if applicable) use in CHECK and/or UISETUP
SetUITooltip()
 
//set the colour the entire tooltip will be for the current control.
SetUITooltipColour(colourString)
 
//add some info to the tile tooltip which shows as the mouse is over the map.  Only really useful in the CHECK fn
AddTileTooltip()
 
//set the colour the entire tooltip will be.  Note if multiple functions attempt to use this in a single tick then the results will be whichever calls it last
SetTileTooltipColour(colourString)
 
//flags that this option can act as a single click if it is the only option, use in the CHECK fn
AllowUISingleClick()
 
//allows us to sort the order in which the onscreen order icons are shown.  Default priority for all icons is 0. Use in the CHECK fn.
SetIconPriority(priority)
 
//return the string which is the filename of the icon for the unit whose id is given
GetUnitIcon(id)
 
//return the string ID for the unit whose id is given
GetUnitStringID(id)
 
//returns the X ordinate of the rect bounded by any prior drawing in the DrawScenarioUI functions
GetUIDisplayLeft()
 
//returns the Y ordinate of the rect bounded by any prior drawing in the DrawScenarioUI functions
GetUIDisplayRight()
 
//returns the right edge ordinate of the rect bounded by any prior drawing in the DrawScenarioUI functions
GetUIDisplayTop()
 
//returns the bottom edge ordinate of the rect bounded by any prior drawing in the DrawScenarioUI functions
GetUIDisplayBottom()
 
//returns 1 if the key is down, 0 if not.  Valid values are 0 (shift), 1 (control)
IsModKeyDown(keyID)
 
//remove the ability of the player to do things.  locked should be 1 to lock the UI, and 0 to unlock and return to normal
LockUI(locked)
 
//returns 1 if the UI object with the objectName has the provided id.  Use in the handler function to see which object has been actioned
IsUIObject(id, objectName)
 
//sets the UI object to have the system string (from StartString etc) as its string property (if relevant)
SetUIObjectString(objectName)
 
//sets the UI object to have the system string (from StartString etc) as its tooltip property (if relevant)
SetUIObjectTooltip(objectName)
 
//enable or disable the UI object, disable if state = 0, otherwise enable
SetUIObjectEnabled(objectName, state)
 
//hide or reveal the object.  Hidden if state = 0, shown otherwise
SetUIObjectVisible(objectName, state)
 
//set the texture of the provided object, if possible.  If no path, comes from UI\TEXTURES (campaign or core)
SetUIObjectTexture(objectName, textureName, [path])
 
//cause a UI object to 'bounce' in size
SetUIObjectBounce(objectName)
 
//show a tip using the current UI string.  The string is made up of two parts, title and body text, seperated by a # symbol.  e.g. tip title#this is the tip text
ShowSystemTip()
 
//show an arrow pointing to the object. x,y start pt in 1024x768.  all vars in 1000ths, extent [0,1000] to animate
ArrowUIObject(objectName, x, y, colourString, borderString, size, flare, curve, extent)
 
//turn on tile display - this will show up tiles as per the movement when they have their tile display flag set.  Anything which causes a reset of the model, 
//like movement or selecting a new unit, turns it off
ShowTileDisplay()
 
//turn off the tile display
HideTileDisplay()
 
//set a texture for a tile display flag value, max of 4 atm
SetTileDisplayTexture(index, texture)
 
//returns 0 if tile display mode is off, 1 if it is on
GetTileDisplay()
 
//clear all the tile display flags
ClearTileDisplayFlags()
 
//set the tile display flag for this tile.  -1 is off, any other value is the index of the texture you want to show [0,3] atm
SetTileDisplayFlag(x, y, value)
 
//return the X ordinate of the Nth AI point
GetAIPointX(id)
 
//return the Y ordinate of the Nth AI point
GetAIPointY(id)
 
//set the coordinate of the Nth AI point
SetAIPoint(id, x, y)
 
//are all the units in the team at or as close as they can be to the destination.  0 for no, 1 for yes
CheckTeamDestination(side, team, x, y)
 
//set the done value of the team
SetTeamDone(side, team, value)
 
//return the done value for the team
GetTeamDone(side, team)
 
//set the team destination
SetTeamDestination(side, team, x, y)
 
//return the X ordinate of the team destination.  Usually use -1 for none set
GetTeamDestinationX(side, team)
 
//return the Y ordinate of the team destination.  Usually use -1 for none set
GetTeamDestinationY(side, team)
 
//return the aggression value
GetTeamAggression(side, team)
 
//set the aggression value
SetTeamAggression(side, team, aggr)
 
//set the target of the team to be the unit index (use -1 unit index to flag no target)
SetTeamTarget(side, team, unit)
 
//returns the team targeted unit, or -1 for none
GetTeamTarget(side, team)
 
//return an average team position X
GetTeamX(side, team)
 
//return an average team position Y
GetTeamY(side, team)
 
//return the data from the team.  The index can be [0, MAX_TEAM_DATA].  0 is generally used to denote any AI point that the team will head for, but this is dealt with in the script
GetTeamData(side, team, index)
 
//set the team data
SetTeamData(side, team, index, value)
 
//make a list of the units closest to the any member of the team - there is only one list.  Returns the number of units on the list
MakeClosestUnitsToTeamList(side, team, [includeHidden])
 
//make a list of the units closest to the unit - there is only one list.  Returns the number of units on the list
MakeClosestUnitsToUnitList(id, [includeHidden])
 
//returns the smallest distance from the tile x,y to any unit in the defined team, or -1 if the team does not exist (or is all dead)
FindDistanceFromTeam(side, team, x, y)
 
//get the closest unit on the current closest unit list.  -1 if invalid in some way
GetClosestUnit(index)
 
//Set the destination of this unit.  Must be a valid tile
SetUnitDestination(id, x, y)
 
//clear out the unit destination (set to -1, -1)
ClearUnitDestination(id)
 
//return the X unit destination.  -1 for none set
GetUnitDestinationX(id)
 
//return the Y unit destination.  -1 for none set
GetUnitDestinationY(id)
 
//set a target for the unit.  -1 for none
SetUnitTarget(id, target_id)
 
//return the id of the target unit.  -1 for none
GetUnitTarget(id)
 
//return the team ID of the specificed unit
GetUnitTeam(id)
 
//set the team value of the specified unit.  team should be [0,7]
SetUnitTeam(id, team)
 
//returns the number of sides in the game (usually 2)
GetSideCount()
 
//returns the unit count for the side.  Includes ALL units including those that are dead or inactive.
GetUnitCount(side)
 
//returns 0 if a unit is dead/hidden/inactive (loaded, etc).  1 otherwise
IsUnitValid(id)
 
//return the unit id of the Nth unit in a side
GetUnitID(side, index)
 
//set a route to a destination, but the actual route set is the route which costs up to the cost value in AP.  Always ignores anything on the target tile.
SetRouteWithCostWithThreat(id, x, y, cost, threatMapIndex)
 
//set a route to a destination, but the actual route set is the route which costs up to the cost value in AP.  Always ignores anything on the target tile.
SetRouteWithCost(id, x, y, cost)
 
// Call bonus function.  The function is called from a bonus script.  Returns function return value.  If the function is not in the mission, returns -999.  
// If the fn does not take a param it will be ignored
CallBonusFunction(functionName, side, x, y, unit)
 
//same as ShowUIScreen below, but sets this config as being the briefing screen so it can be reviewed later again by the player.  Does not show the screen.
SetBriefingScreen(screenName, animName, textTag, [imageTags])
 
//show the UI object screen, setting up with text of the form textTag_objName for each object.  Image tags are 1 or more obj:file pairs seperated by a $
ShowUIScreen(screenName, animName, textTag, [imageTags])
 
//show the briefing screen (if set up).  Just a helper to avoid having to maintain 2 data sets
ShowBriefing()
 
//hide a UI screen which is showing
HideUIScreen(screenName)
 
//Hides the custom UI if state is 0, otherwise shows it
ShowCustomUI(state)
 
//returns the ID of a given pairing of set/tile.  -1 means the tile doesn't exist.  These are the internal folder/tile names, not the displayed localised names.  
//NOTE: this will not be a constant as game data and custom data changes, so don't rely on it.
GetTileID(set, name)
 
//place a tile in its layer, replacing anything else there.   Rotation is [0,3]
PlaceTile(x, y, id, rotation)
 
//return the id of the tile on the tile at the layer.  Returns -1 if nothing there.
GetTileOnTile(layer, x, y)
 
//remove the denoted tile if it is on the tile.  You cannot remove the layer 0 (non-overlay) tile
RemoveTile(x, y, id)
 
//returns the difficulty mode.  0 for normal, 1 for easy
GetDiffMode()
 
//add the object at x,y (in 100ths) to the map.  Returns an id for use with other object functions - not constant across game runs. Returns -1 if not valid object
PlaceObject(x, y, objectSet, objectName)
 
//return the id of the Nth object on the given tile - not constant across game runs.  Returns -1 if no object at that index, so when you run out of objects.
GetTileObject(x, y, index)
 
//return the id of the Nth object on the map of the described type.  If objectSet is an empty string then any object matching the objectName will be returned.  
//Returns -1 if no more are found.  Not case sensitive
GetObjectFromName(objectSet, objectName, index)
 
//returns 1 if the object is part of the set provided, 0 otherwise.  Not case sensitive.
IsObjectSet(id, setName)
 
//returns 1 if the object is the type named, 0 otherwise.  Not case sensitive.
IsObjectName(id, objectName)
 
//set the data in an object, index must be [0,3].
SetObjectData(id, index, value)
 
//get the data in an object, index must be [0,3].
GetObjectData(id, index)
 
//change the position of an existing object (in 100ths)
SetObjectPosition(id, x, y)
 
//change the rotation of an existing object, in degrees and 100ths
SetObjectRotation(id, rotation)
 
//change the scale of an existing object, scale is in 100ths
SetObjectScale(id, scale)
 
//return the X position of an existing object in 100ths
GetObjectPositionX(id)
 
//return the Y position of an existing object in 100ths
GetObjectPositionY(id)
 
//return the rotation of an existing object, in degrees and 100ths
GetObjectRotation(id)
 
//return the scale of an existing object, scale is in 100ths
GetObjectScale(id)
 
//delete the object denoted by the id
DeleteObject(id)
 
//return the data held by tiles.  index 0 is used in carryover mechanics.  index must be [0,3].  All entries are unsigned bytes [0,255]
GetTileData(x, y, index)
 
//set the data held by tiles.  index 0 is used in carryover mechanics.  index must be [0,3].  value is an unsigned byte so [0,255]
SetTileData(x, y, index, value)
 
//return the number of carried over units for the given side from the given mission (first mission is index 0, etc)
GetCarryoverCount(missionIndex, side)
 
//return a new unit created from the carryover data for the index'th entry in the carryover data.  returns -1 if the unit cannot be created.
AddCarryoverUnit(x, y, missionIndex, side, index)
 
//returns 1 if the denoted global exists, 0 otherwise.  The script name must be the filename of the script, path is not required.
CheckScriptGlobal(scriptName, globalName)
 
//return the value of a global from a known script.  The script name must be the filename of the script, path is not required.  If either the script or global 
//cannot be found, zero is returned. Does not autocreate if missing.
GetScriptGlobal(scriptName, globalName)
 
//set the value of a global from a known script.  The script name is filename of the script, path is not required.  If the script or global not found, zero is 
//returned, otherwise 1.  The return value can be ignored as desired.  Does not autocreate if missing.
SetScriptGlobal(scriptName, globalName, value)
 
//enter the AI placement mode.  point must be [0,7] currently.  Marker can be 0 (use the default AI marker) or the ID of a user marker already on the map
PlaceAIPoint(point, marker)
 
//returns 1 if running in the editor, 0 otherwise.  Useful mainly in plugins as normal script functionality is off in the editor.
InEditor()
 
//close this plugin.  Can only be used within a plugin script
ClosePlugin()
stub_commands.txt · Last modified: 2012/03/22 17:41 by 174.3.224.234
 
Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki