Skip to content

Script API

rmx edited this page May 30, 2016 · 1 revision

Script API

A list of API calls that we want to provide for user scripts. Written in functional style, although we might use OO style for the implementation.

Movement

  • unitGetPosition: (unit) -> position
    • returns the terrain position of a unit
  • unitTeleportTo: (unit, position) ->
    • instantly teleports the unit to the given position
  • unitMoveToward: (unit, position) ->
    • starts moving straight towards the given position
  • unitMoveAlongPath: (unit, path) ->
    • starts moving along the given path
  • unitSetSpeed: (unit, speed) ->
    • changes the movement speed of the unit

Terrain

  • terrainCreate: (name, tag) ->
    • loads the given terrain
  • terrainFindPath: (position, position) -> path
    • finds a path (list of waypoints) between the two positions
  • terrainGetPositionByName: (tag, name) -> position
    • returns a bookmarked position
  • terrainGetPositionAt: (tag, x, y, z) -> position
    • returns a terrain position at the given world coordinates
  • terrainGetTileByIndex: (tag, index) -> tile
    • returns a terrain tile by index
  • terrainPositionGetTile: (position) -> tile
    • returns the tile this position is located in
  • terrainPositionGetTerrain: (position) -> tag
    • returns the terrain this position is located in
  • terrainTileGetPosition: (tile, u, v) ->
    • returns a terrain position from local tile coordinates

Units

  • worldGetUnits: () -> [unit]
    • returns a list of all units
  • worldCreateUnit: (model, name, behavior, position) -> unit
    • creates a new unit in the encounter
  • worldDeleteUnit: (unit) ->
    • deletes a unit from the encounter

Game

  • gameDidStart: () ->
    • starts the game (everything before this event counts as the preparation phase)
  • gameDidEnd: (victory) ->
    • ends the game, with the given outcome

Spells

  • unitTriggerCooldown: (unit, cooldownName, cooldown) ->
    • triggers a cooldown
  • unitStartCast: (unit, spellName) ->
    • starts casting a spell

Attributes

  • unitChangeAttributeBy: (unit, attribName, delta) ->
    • changes an attribute (relative change)
  • unitSetAttribute: (unit, attribName, value) ->
    • changes an attribute (absolute change)

Clone this wiki locally