Skip to content

Functions

Jussi Sammaltupa edited this page Aug 21, 2019 · 25 revisions

Functions

General Utilities

bool2str(value)

check_bits(value, bits)

Returns true when value has any of the bits defined by bits set to 1; otherwise false.

assert(check_bits(3, 2))

clear_bits(value, bits)

Returns value with all bits defined by bits set to 0.

assert(clear_bits(3, 2) == 1)

delay(ms)

Blocks for ms milliseconds while keeping the game loop running.

delay_call(f, ...)

Provide a lambda to be executed later. E.g. counter-attacks are delayed until the previous action has been completed.

function counter_attack(target, attacker)
    -- ...
end

delay_call(counter_attack, target, attacker)

delay_frames(frames)

Blocks for a duration defined by frames while keeping the game loop running. The function blocks does not actually count frames, but instead how long the frames would be shown at 60 FPS.

delta_time()

Gets a number that specifies in seconds how much the time was advanced in the beginning of the frame. May differ from the wall clock due to the time multiplier. See get_time_multiplier.

distance(x1, y1, x2, y2)

Returns the manhattan distance between two map squares defined by the parameters. Does not take any kind of map blockers into account.

distance_along_axis(x1, y1, x2, y2, dir)

Returns the signed distance between two map squares along given direction.

distance_point_rectangle(x, y, rx, ry, rw, rh)

Returns the shortest distance between a point and a rectangle.

distance_rectangle_rectangle(x1, y1, w1, h1, x2, y2, w2, h2)

Returns the shortest distance between two rectangles.

get_time_multiplier()

Returns the current time multiplier, which is usually 1. When the work for a new frame is started by the game, the current time returned by time() is advanced by the wall clock difference from last frame multiplied by the time multiplier.

iff(cond, a, b)

Returns a if cond is true; otherwise b.

handle_text_substitutions(text)

hex32str(x)

random_range(range)

register_hook(obj, event, callback, [check_validity])

Registers a hook programmatically.

param description
obj
event the name of the hook
callback the name of the callback as defined in the level script
check_validity When set to true, shows a warning if there is no such callback in the level script. Defaults to true.
-- A partial example from the Arken Temple
nuala_escaped = false
nuala_killed = false

function on_init_map(map)
    local nuala = find_obj(map, "nuala")
    register_hook(nuala, "on_post_damage", "on_nuala_damaged")
end

function on_escape_from_battle(mob)
    if mob.arch.name == "nuala" then nuala_escaped = true end
end

function on_nuala_damaged(mob, damage, damage_type)
    -- called after nuala has been damaged; check if nuala is dead
    if mob.hp == 0 and not nuala_escaped then
        -- delay the call to flip the bit after the game is ready for action
        delay_call(function() nuala_killed = true end)
    end
end

function on_draw_objectives(map, ctx)
    local status
    if nuala_escaped then status = true end
    if nuala_killed then status = false end
    ctx.objective("protect_nuala", "Protect Nuala", status)
    -- ...
end

remove_hook(obj, event)

Removes a hook from an event programmatically.

set_bits(value, bits)

Returns value with bits defined by bits set to 1.

assert(set_bits(4, 7) == 7)

set_time_multiplier(time_mult)

Sets the current time multiplier, which is usually 1. When the work for a new frame is started by the game, the current time returned by time() is advanced by the wall clock difference from last frame multiplied by the time multiplier.

shuffle_table(t, rng)

table_random(t)

Returns an item from a random index of the array-like t. Returns nil for map-like tables.

time()

Returns the number of seconds elapsed since the game was started in game time. When the work for a new frame is started by the game, the time is advanced by the wall clock difference from last frame multiplied by the time multiplier.

ui_name(what)

Converts various game objects into a string that you can show on the user interface.

unpack_xy(i, width)

Extracts x- and y-coordinates from a "packed" number:

local packed_coordinate = (mob.y * map.width) + mob.x

-- use the packed coordinate e.g. as a hash map key:
locations[packed_coordinate] = true
-- ...
for xy in pairs(locations) do
    local x, y = unpack_xy(xy, map.width)
    -- do something
end

Map Utilities

get_cell_flag(map, x, y, flag)

get_cell_room(map, x, y)

get_cover(map, x, y, facing)

get_edge_blocker(map, x, y, facing)

get_edge_blocker_forcefield(map, x, y, facing)

get_edge_blocker_sight(map, x, y, facing)

get_enemies_remaining(map)

get_floor_height(map, x, y)

get_fog_tile(map, x, y)

get_move_cost(map, x, y)

is_blocked(map, x, y, block_flags, [ignore_mobs], [ignore_obj])

Returns true when the map coordinates given by x and y are blocked when considering block_flags; otherwise false.

param description
map
x x coordinate of the map square to check
y y coordinate of the map square to check
block_flags what flags should be checked. See object flags.
ignore_mobs when set to true, mobs are ignored during the check. Defaults to false.
ignore_obj when set, the object will be ignored from the check.

is_move_blocked(map, x, y, size, dir, block_flags, [ignore_mob], [ignore_x], [ignore_y], [ignore_flags])

Returns true, when an object of size size, with block flags block_flags can move from map square (x,y) to direction specified by dir; otherwise returns false.

param description
map
x x coordinate of the starting location
y y coordinate of the starting location
size size of the moving object in squares (e.g. wood_troll -> 2)
dir direction of movement. See facings.
block_flags what flags should be checked. See object flags.
ignore_mob a mob, which should be ignored while checking. Optional.
ignore_x a map square, which should be ignored while checking.
ignore_y a map square, which should be ignored while checking. Optional.
ignore_flags Ignore stuff when making the check. See ignore flags. Optional.

is_move_blocked2(mob, dir, [block_flags], [ignore_flags])

Returns true when a mob specified by mob can move to direction dir.

is_room_revealed(map, room)

is_valid_cell(map, x, y)

Returns true when the x,y coordinates are valid for the given map; otherwise false.

is_world_map(map)

map_timestamp(map)

sample_height(map, world_pos)

Samples the floor height at the given world space coordinates taking heightmaps, platforms and (elevated) floors into account. Returns the height, i.e. the y in world coordinates, if something is found; otherwise 0.0.

sample_height_with_radius(map, world_pos, [radius])

Takes 5 samples of the floor height at the given world space coordinates + radius, taking heightmaps, platforms and (elevated) floors into account. Returns the maximum of found heights, i.e. the y in world coordinates, if something is found; otherwise 0.0.

set_cell_flag(map, x, y, flag, value)

set_cell_room(map, x, y, room)

Directions

See facings for an interpretation of values.

add_dir45(dir, delta)

Turns dir clockwise by delta * 45 deg when delta > 0.

Turns dir counter-clockwise by delta * 45 deg when delta < 0.

Returns a new direction, normalized to the Druidstone's facing value.

dir_towards(dx, dy)

Converts dx, dy to a cardinal (NSEW) direction [0-3].

dir_towards2(dx, dy)

Converts dx, dy to a direction [0-7].

dxdy(dir)

Returns dx,dy where

  • dx specifies the x increment towards direction dir
  • dy specifies the y increment towards direction dir
local dx, dy = dxdy(4)  --> dx = 1, dy = -1
local dx, dy = dxdy(6)  --> dx = -1, dy = 1

facing_to_angle(facing)

Converts specified facing to radians. Does not normalize facing, so keep the value between [0,7].

is_cardinal_dir(dir)

Returns true when dir is logically N, E, S or W, i.e. between [0,3]; otherwise false.

is_diagonal_dir(dir)

Returns true when dir is logically NE, SE, SW or NW, i.e. between [4,7]; otherwise false.

is_left_turn(dir1, dir2)

is_right_turn(dir1, dir2)

octant(dx, dy)

Converts deltas to a facing as defined by atan2 function.

opposing_dir(dir)

Returns the opposite direction of dir.

relative_dir(dir1, dir2)

Returns the relative direction in increments of 45 degrees when turning from dir1 to dir2. The return values are in range [-3,4] and correspond to following turns:

return value
-3 turn 135 degrees counter-clockwise
-2 turn 90 degrees counter-clockwise
-1 turn 45 degrees counter-clockwise
0 no turn
1 turn 45 degrees clockwise
2 turn 90 degrees clockwise
3 turn 135 degrees clockwise
4 turn 180 degrees clockwise

which_corner(obj1, obj2)

which_side(attacker, target)

Cell Iterators

all_map_objs(map)

Iterates through all map objects.

for index,obj in all_map_objs(map) do
    -- do something with the object
end

adjacent_cells(map, x, y, [num_neighbours])

Iterates through all adjacent cells of a map square defined by x and y. num_neighbours must be 4 or 8 (default).

for dir, x, y in adjacent_cells(map, x, y) do
    -- do something
end

adjacent_cells_for_mob(mob)

Iterates through all adjacent cells of a mob.

for packed_coord, x, y in adjacent_cells_for_mob(mob) do
    -- do something
end

map_cells(map)

Iterates through all map cells.

for x, y in map_cells(map) do
    -- do something
end

map_mobs(map)

Iterates through all mobs on the map.

for index, mob in map_mobs(map) do
    -- do something with the mob
end

map_objs_at(map, x, y)

Iterates through all objects in the map square specified by x and y.

for index, obj in map_objs_at(map, x, y) do
    -- do something
end

random_map_cells(map)

Iterates through all map cells in random order.

for x, y in random_map_cells(map) do
    -- do something
end

AoE Iterators

aoe_blast_cells(map, x, y)

aoe_blast_cells_with_radius(map, x, y, radius, square)

aoe_cone_cells(map, origin_x, origin_y, target_x, target_y, range, block_flags)

aoe_ice_cells(map, x, y)

aoe_line_cells(map, x1, y1, x2, y2)

aoe_move_sweep(mob)

aoe_single_cell(map, x, y)

Spawners and Reinforcements

activate_spawner_group(map, spawn_group_index, [delay_value], [on_spawn], [flags], [camera_height])

Activates a group of spawner objects immediately.

parameter description
map
spawn_group_index the index of the spawner group to activate. Set from the editor using the Spawner panel.
delay_value delay in ms between activating individual spawners within the group. Defaults to 0.
on_spawn called for each activated spawner: function(mob, spawner). Optional.
flags see spawner flags
camera_height sets the camera to the specified height in meters - good values are between 15-30.

add_reinforcements(map, round, spawn_group_index)

Make the game activate a spawner group defined by spawn_group_index on round round.

clear_reinforcements(map)

Clears all scheduled reinforcements from the map.

get_time_to_next_reinforcement(map)

Returns a number, which indicates how many rounds further is the next scheduled reinforcement. Returns nil when there are no reinforcements coming.

is_spawner(obj)

Returns true when obj is a spawner.

spawnfx_darkness(mob, silent)

spawnfx_dire_wolf(mob, silent)

spawnfx_dissolve(mob, silent)

spawnfx_drop_above(mob, silent)

spawnfx_raise_from_water(mob, silent)

spawnfx_siren(mob, silent)

spawnfx_teleport(mob, silent)

spawnfx_undead_crawl(mob, silent)

Manipulation

apply_darkness_to_map(map, animated, switch_music)

clear_async_dialogue_boxes(map)

Clears async dialogue boxes introduced with say_line_async.

clear_darkness_from_map(map, animated)

reveal_map(map, show)

reveal_room(map, room_number, show)

kill_delayed(map)

Map Markers

add_map_marker(map, x, y, [marker_type])

Adds a map marker at x,y and returns it. marker_type must be either "default" or "attack".

fade_movement_marker(mob)

get_map_marker(map, x, y)

Gets a map marker at x, y; or nil if there is no map marker.

hide_active_hero_marker(map)

hide_movement_marker(mob)

remove_map_marker(map, marker)

Removes a map marker returned by add_map_marker.

remove_map_marker_at(map, x, y)

Removes a map marker from map square x,y.

remove_map_markers(map)

Removes all map markers from the map.

show_active_hero_marker(mob)

show_movement_marker(mob, x, y)

Objects

attach_obj(obj, parent_obj)

clear_flag(obj, flag)

Flips off a flag on the specified object. See Object Flags.

destroy(obj)

Destroys an object from the map.

detach_object(obj)

drop_obj_from_above(obj)

find_arch_obj(obj_type)

Returns the architype definition for object of type obj_type if found; otherwise nil.

local arch_name = "skeleton_bosss"      -- yeah, well, this example aint the best
local arch = find_arch_obj(arch_name)
if arch then
    -- do something
end

find_loot_at(map, x, y, loot_type)

Finds loot object of type loot_type from map square given by x and y. Returns nil if nothing is found.

Loot types are declared in object definitions using loot_item_type.

find_named_obj(map, script_name)

Returns an object with the given script name; nil if the object is not found. Use the Object panel in editor to set the script name.

find_obj(map, obj_type)

Returns the first found object of type defined by obj_type; nil if no such object is found.

local boss = find_obj(map, "skeleton_boss")
if boss then
    -- do something with the boss
end

find_obj_at(map, obj_type, x, y)

Returns the first found object of type defined by obj_type in map coordinates defined x and y; nil if no such object is found.

local boss = find_obj(map, "skeleton_boss")
if boss then
    -- do something with the boss
end

find_obj_id(map, id)

get_arch_obj(obj_type)

Returns the architype definition for object of type obj_type. Raises an error if the architype cannot be found.

local arch = get_arch_obj("skeleton_boss")

get_flag(obj, flag)

Returns true if obj has the flag set on; otherwise false. See Object Flags.

get_obj_scale(obj)

Returns a vector that describes the scaling factor of the object.

get_world_pos(obj)

Returns a vector that describes the position of the object in world space.

get_world_pos_y(obj)

Returns a number that describes the height of the object, i.e. the Y axis coordinate in world space.

get_world_rot(obj)

Returns the rotation matrix for the object.

get_world_rot_euler(obj)

Extracts euler angles from the object's rotation matrix.

local rot_x, rot_y, rot_z = get_world_rot_euler(obj)

get_world_rot_z(obj)

is_ticker(obj)

is_timer(obj)

is_trigger(obj)

lerp_facing(obj, old_facing, new_facing, t)

move_obj(obj, ...)

Translates an object in world space.

move_obj(obj, 0.0, 1.0, 0.0)        -- translate obj 1m along positive Y-axis
move_obj(obj, vec(0.0, -1.0, 0.0))  -- translate obj 1m along negative Y-axis

obj_adjacent(obj1, obj2)

Returns true when objects occupy adjacent cells, i.e. the distance between them is exactly 1 square. Does not take edge blockers into account.

obj_behind(obj, target_obj)

obj_bounds(obj)

Returns x1, y1, x2, y2 where:

  • x1: the minimum x coordinate occupied by obj
  • y1: the minimum y coordinate occupied by obj
  • x2: the maximum x coordinate occupied by obj
  • y2: the maximum y coordinate occupied by obj

The object coordinates are clamped within map boundaries.

local x1, y1, x2, y2 = obj_bounds(obj)

obj_bounds2(x, y, w, h, facing)

Returns x1, y1, x2, y2 where:

  • x1: the minimum x coordinate
  • y1: the minimum y coordinate
  • x2: the maximum x coordinate
  • y2: the maximum y coordinate

... of an object with dimensions defined by the parameters.

obj_closest_point(obj, x, y)

Returns the point from obj footprint that is closest to x,y.

obj_distance(obj1, obj2)

Returns the manhattan distance between obj1 and obj2.

obj_name(obj)

obj_size(obj)

Returns the width and the height of the given object:

local troll = find_obj(map, "wood_troll")
if troll then
    local w,h = obj_size() --> w = 2, h = 2
    -- ...
end

obj_size_rotated(obj)

Returns the width and the height of the given object in its current facing:

local door_w, door_h = obj_size_rotated(door) --> 1,2 or 2,1 depending on the facing of the door

obj_size_rotated2(w, h, facing)

Returns w and h ordered correctly based on facing.

obj_world_pos(obj, x, y, facing)

Returns a world space vector that defines the position of the object when position to the specified square and facing.

TODO describe coordinate systems somewhere: square <-> world space

obj_world_to_map(obj, world_pos)

Converts a vector in world space to map square coordinates for obj.

set_facing(obj, facing)

Orients an object to specified facing. See facings.

set_facing_towards(obj, x, y)

Orients an object towards a square defined by x and y. This function prefers diagonals; you may get better results with set_facing + octant.

set_flag(obj, flag)

Flips on a flag on the specified object. See Object Flags.

set_obj_scale(obj, scale)

Set scaling for an object.

set_obj_scale(obj, 2.0)                 -- uniform scaling
set_obj_scale(obj, vec(1.0, 2.0, 3.0))  -- non-uniform scaling

set_obj_scale3(obj, x, y, z)

Set non-uniform scaling for an object.

set_pos(obj, x, y, update_transform)

Translate obj into map square defined by x and y. Set update_transform to false to prevent the object's world transform from being updated.

set_world_pos(obj, pos)

Translate obj to a position in world space defined by the vector pos.

This updates the world transform for the root node of the object; the map square coordinates are left untouched.

set_world_pos3(obj, x, y, z)

Translate obj to a position in world space defined by the x, y and z parameters.

This updates the world transform for the root node of the object; the map square coordinates are left untouched.

set_world_pos_y(obj, y)

Translate obj to the specified y coordinate in world space.

This updates the world transform for the root node of the object; the map square coordinates are left untouched.

set_world_rot(obj, mat)

Rotate obj by mat.

set_world_rot(obj, mat.look_at(vec(1.0, 2.0, 3.0)))

set_world_rot_euler(obj, x, y, z)

Rotate obj using euler angles given by x-, y-, and z-parameters.

shake_obj(obj, intensity, duration)

shatter_forcefield(obj)

spawn(obj_type, [map], [x], [y], [facing], [id], [respawn_obj], [spawn_flags])

Spawns an object and returns the new instance.

param Description
obj_type The name of the object to spawn.
map The map instance where the object spawned. Optional when x and y are not given.
x x coordinate of the map square where object's pivot is placed. Optional.
y y coordniate of the map square where object's pivot is placed. Optional.
facing The facing of the spawned object. Set to -1 for random orientation. Optional.
id Set to nil.
respawn_obj Set to nil.
spawn_flags See spawn flags.
local skelly1 = spawn("skeleton")    -- spawn a skeleton next to the active hero
local skelly2 = spawn("skeleton", map, some_x, some_y)  -- spawn skeleton on map at some_x, some_y

spawn_at_obj(obj_type, obj)

Spawns and returns an object of type obj_type in the square occupied by obj.

wait_drop_obj(map)

Mobs

add_inventory(inventory, item_name, count, insert_front)

can_act(mob, [check_confused])

Returns true when the mob can act:

  • is on the map, i.e. has not been destroyed
  • has positive HP
  • is not sleeping, petrified, frozen or stopped
  • is not disabled
  • is not confused: you can disable this with the optional parameter

can_interact(mob, target, target_x, target_y)

clear_mob_flag(obj, flag)

Clears the mob flag specified by flag for mob. See Mob Flags.

clear_all_conditions(mob)

Clears all conditions from mob.

clear_condition(mob, cond, [silent])

Clears condition cond from mob. Set silent to true to skip audiovisual side-effects related to clearing the condition in question. See conditions.

get_accessory(mob)

get_arch_item(mob, item_name)

get_armor(mob)

get_attack_params(mob, item_name)

Returns attack params for mob using an item.

key type description
damage number how much damage to deal if the attack hits, can be number or range.
damage_type number elemental damage type, see damage types.
damage_flags number see damage flags.
accuracy number accuracy of the attack in range 0-100.
pierce number how many points of armor the attack ignores.
inflict number condition to inflict on hit. See conditions.
inflict_chance number percentile chance to inflict the condition (default 100).
inflict_crit number condition to inflict on critical hit. See conditions.
leech number how many points the attacker heals on hit.
leech_kill number how many points the attacker heals on kill.
timestamp number timestamp used to prevent hitting large creatures more than once.
on_attack_hit function(attacker, target) called when attack hits.

get_condition(mob, cond)

Returns true when mob has the condition defined by cond; otherwise false. See conditions.

get_condition_value(mob, cond)

get_mob(map, x, y)

Returns a mob (or a thing) that occupies map square defined by x and y; or nil when there is no mob in the square.

get_mob_flag(obj, flag)

Returns true if obj has the flag set on; otherwise false. See Mob Flags.

get_move_cost_for_mob(mob, x, y)

get_weapon(mob)

has_any_condition(mob, ...)

Returns true when mob has any of the listed conditions; otherwise false. See conditions.

if not has_any_condition(mob, C_FREEZE, C_STOPPED, C_PETRIFIED) then
    -- do something
end

has_cover(mob)

Returns true when mob has cover; otherwise false.

healing_effect(mob, sound_name)

heal_mob(mob, amount, play_healing_effect)

hide_weapons(mob)

is_ai_controlled(mob)

is_ally(mob1, mob2)

is_dual_wielding(mob)

is_harmful_condition(cond)

is_immune(mob, cond)

is_massive(mob)

is_mob_moving(mob)

is_enemy(mob1, mob2)

is_equippable(mob, card_name)

is_equipped(mob, card_name)

is_mob(obj)

Returns true if the obj is a mob; otherwise false. Remember that things are also mobs.

is_thing(obj)

Returns true if the obj is a thing; otherwise false.

kill_mob(mob, flags, attacker)

knockback_mob(mob, dir, damage_flags)

knockback_mobs(map, x, y, damage_flags)

lerp_mob_to_facing(mob, speed)

lerp_mob_towards_precise(mob, target_x, target_y, speed)

mob_affinity(mob, damage_type)

mob_armor(mob)

mob_block_flags(mob)

Returns the default blocking flags for mob based on the type of the mob. See block flags.

mob_bump(mob, dir)

mob_dir_towards(mob, target_x, target_y)

Returns a facing number, which specifies a direction from the center of the mob towards the center of the specified map square. Use this when determining which way to turn a mob when attacking. See facings.

mob_faction(mob)

Returns a number, which specifies whether the mob is an ally of the heroes, a neutral or an enemy of the heroes.

return value description
-1 the mob is an enemy
0 the mob is neutral
1 the mob is an ally

mob_range(mob, [item_name])

Returns a number, which specifies the attack range of the mob, optionally wielding an item.

mob_reach(mob, [item_name])

Returns a number, which specifies the reach of the mob, optionally wielding an item. Reach applies to melee attacks.

mob_size(mob)

Returns a number, which specifies the width/height of the mobs footprint. Only symmetric mobs are supported by the game!

mob_speed(mob)

Returns a number, which specifies how many movement points the mob receives each round.

mob_surrenders(mob)

mob_turn_params(mob, facing, turn_around_dir, force_turn_anims)

mob_xp(mob)

move_to(mob, x, y, [movement_mode], [ignore_allies], [offset])

Make mob walk to map square specified by x and y. Use in cinematics only.

parameter description
mob
x
y
movement_mode "walk" or nil
ignore_allies When true, allies are ignore while finding a path to given map square
offset an optional vector offset to move to a location that is not on the map grid

move_to_async(mob, x, y, [movement_mode], [ignore_allies], [offset])

Prepare a plan for mob move to specified coordinates. Use in cinematics only. wait_pending_moves(map) does the actual moving part. This is useful for moving multiple mobs concurrently.

parameter description
mob
x
y
movement_mode "walk" or nil
ignore_allies When true, allies are ignore while finding a path to given map square
offset an optional vector offset to move to a location that is not on the map grid
for i,hero in ipairs(party) do
    move_to_async(hero, hero.x, hero.y - 3, "walk", true)
end
wait_pending_moves(map)

move_to_waypoint(mob, waypoint_name, [movement_mode], [ignore_allies], [offset])

Make mob move immediately to the same square as an object with script name waypoint_name. Use in cinematics only. This function blocks until the mob has moved.

parameter description
mob
waypoint_name the script name of the marker object. Prefer dummy_object objects.
movement_mode "walk" or nil
ignore_allies When true, allies are ignore while finding a path to given map square
offset an optional vector offset to move to a location that is not on the map grid

move_to_waypoint_async(mob, waypoint_name, movement_mode, ignore_allies, delay_in_seconds, offset)

Prepare a plan for mob to move to the same square as an object with script name waypoint_name. Use in cinematics only. wait_pending_moves(map) does the actual moving part. This is useful for moving multiple mobs concurrently.

parameter description
mob
waypoint_name the script name of the marker object. Prefer dummy_object objects.
movement_mode "walk" or nil
ignore_allies When true, allies are ignore while finding a path to given map square
delay_in_seconds time to wait before the mob starts walking
offset an optional vector offset to move to a location that is not on the map grid

push_mob(mob, dir, [move_flags])

Make mob move one square to direction specified by dir. This blocks until the mob has moved.

push_mob_async(mob, dir, move_flags, time_multiplier)

Make mob move one square to direction specified by dir.

This updates only game mechanics and exits immediately. Use together with update_mob_movement(), which moves all the model(s) in place for pushed mobs.

When succesful, returns true; on failure returns false, error

error description
"cannot_act" the mob is dead or otherwise disabled
"moved" the mob was moved to a unexpected location (e.g. teleport, knockback)
"blocked" the move is blocked
"custom" callback triggered and prevented the movement

push_mobs_away(map, x, y, visited)

revive_mob(mob, instant)

restore_weapons(mob, duration)

set_condition(mob, cond, [duration], [silent])

Make mob have condition specified by cond. Use duration to specify a non-standard duration for the condition; usually nil. Set silent to true to skip audiovisual side-effects related to setting the condition in question. See conditions.

set_cooldown(mob, ability_name, cooldown)

say_line(mob, text, flags, responses, color)

Makes the mob say something. See flags.

local COLOR_PURPLE = 0xff76ffff
local aava = require_hero("dryad")
local sorceress = find_named_obj(map, "sorceress")  
local function Aava(text) say_line(aava, text) end
local function Demon(text) say_line(sorceress, text, nil, nil, COLOR_PURPLE) end
Aava "Hello, Elo Sphaera!"
Demon "Hello in Purple!"

-- we can also ask for responses:
local response = say_line(aava, "What is the answer to the ultimate question?", nil, { "40", "41", "42" })
if response == 3 then
    Demon "Well done!"
end

say_line_async(mob, text, flags, responses, color)

Makes the mob say something without block the UI. See clear_async_dialogue_boxes.

set_skin(mob, skin)

set_head_tracking_target(mob, target, offset_y)

set_mob_flag(obj, flag)

Sets the mob flag specified by flag on for mob. See Mob Flags.

set_mob_shader_params(mob, saturation)

teleport_mob(mob, x, y, facing)

teleport_to_waypoint(mob, waypoint_name)

turn_mob(mob, facing, speed, turn_around_dir, force_turn_anims)

turn_mob_async(mob, facing, delay_in_seconds)

turn_mob_relative(mob, rel_dir)

turn_mob_towards(mob, x, y, speed, force_turn_anims)

turn_mob_towards_async(mob, x, y, delay_in_seconds)

update_mob_movement(map)

Updates and animates world space transforms for all moving mobs. Use push_mob() and push_mob_async() to actually move the game objects.

update_weapons(mob)

Heroes

activate_hero(mob)

find_able_hero(preferred_hero)

find_hero(name)

Returns a hero from the current map; or nil if the hero is not on the map. See also require_hero.

local leonhard = require_hero("hero")
if leonhard then
    -- do something with leonhard
end

get_ability_level(hero_name, ability_name)

get_active_hero()

Gets the hero with the green circle. Might be nil.

is_active_hero(mob)

Returns true when mob is the active hero; otherwise false.

is_any_hero_alive()

Returns true when there is a non-petrified hero in the party with positive HP; otherwise false. Guest stars, i.e. summoned PCs / NPCs do not count. (Stirling, the Shido...)

is_hero(mob)

Returns true when mob is in the party; otherwise false.

is_hero_unlocked(name)

is_item_usable_by_hero(mob, item_name)

is_known_ability(mob, ability_name)

require_hero(name)

For easy cinematics: finds a hero from the current map or spawns it if not found. See also find_hero.

local leonhard = require_hero("hero")
local aava = require_hero("dryad")
local oiko = require_hero("mage")
local mochizuki = require_hero("ninja")
local stirling = require_hero("thief")

revive_heroes(instant)

set_active_hero(mob)

Make mob the active hero. Call only with party members...

scabbard_weapons(mob)

Make mob scabbard the weapons with an animation. Works properly only for main player characters. This function blocks until the mob has scabbarded the weapons.

scabbard_weapons_async(mob)

Make mob scabbard the weapons with an animation. Works properly only for main player characters. This function exits on the same frame.

unscabbard_weapons_async(mob)

Make mob pull out the weapons with an animation. Works properly only for main player characters. This function exits on the same frame.

Inventories

dump_inventory(inventory)

get_inventory(inventory, item_name)

get_inventory_raw(inventory, item_name)

get_merchant_inventory()

Returns an array containing the items in the merchant's inventory. The structure is as

{
  {
    count = 1,
    item_name = "spear"
  },
  {
    count = 1,
    item_name = "axe"
  }
}

get_party_inventory()

Returns an array containing the items in the party's shared inventory. The structure is as follows:

{
  {
    count = 1,
    item_name = "2h_axe"
  },
  {
    count = 1,
    item_name = "2h_hammer"
  }
}

has_inventory(inventory, item_name)

remove_inventory(inventory, item_name, count, remove_when_depleted)

set_inventory(inventory, item_name, count, remove_when_depleted, insert_front)

set_new_arrival(item_name, value)

For showing/disabling new arrival indicator on cards in merchant dialog, value should be true or false.

sort_inventory(inventory)

spend_inventory(inventory, item_name, count, remove_when_depleted)

Cards

def_card(...)

find_card(card_name)

get_card(card_name)

item_price(card_name)

Implementing Abilities

can_use_item(mob, item_name)

Returns true when mob can use item with name item_name; otherwise false.

choose_multiple_targets(mob, item_name, flags, num_targets, options)

Triggers target selection mode for multiple targets. num_targets specifies how many targets to select. See other parameters described below.

function use_caltrops(mob, item_name, target_x, target_y)
    local num_caltrops = 3
    local map = mob.map

    local targets
    if target_x then
        targets = { target_x + target_y * map.width }
    else
        local flags = TARGET_UNBLOCKED_FOR_MOVE + TARGET_LOS_FROM_MOB + TARGET_TRAJECTORY + TARGET_NO_STACKING
        targets = choose_multiple_targets(mob, item_name, flags, num_caltrops)
    end
    if targets == nil then return false end
    -- ...
    -- throw caltrops to selected squares
    for i=1,#targets do
        local target_x, target_y = unpack_xy(targets[i], map.width)
        -- ...
    end
    -- ...
end

choose_target(mob, item_name, flags, options)

Triggers target selection mode for an item named item_name.

param description
mob the acting mob
item_name the name of the item, ability or spell.
flags See target flags.
options options is a table with optional parameters, all fields are optional, listed below.
option description
range number, override card's range parameter
aoe_iterator(map, target_x, target_y, opt_path) function which, given the target coordinates, iterates the affected cells. Optionally the iterator may receive an A* path to target coords.
origin_x number, override the source coordinates of the attack
origin_y number, override the source coordinates of the attack
validity_map a set of packed cell xy-coordinates, these cells are visualized as the range of the attack
damage_preview_callback(mob, item_name, x, y) a function which can modify the preview damage
info_callback(target, x, y) a callback for draw additional info to the screen (e.g. immunities)
validate_target_callback(target, x, y) a function for doing extra validation to the target, the function may return false and error message to prevent targetting
redirect_callback(target, x, y) a function for redirection targeting to another object (e.g. for draw)
click_callback(target, x, y) called when clicking on a target (valid or not), return false to invalidate target
button_text if given, a button with the given text is added to the use item dialog
flags2 even more targetting flags. See flags.
-- the actual code from the game for e.g. firing a bow:
function use_ranged_weapon(mob, item_name, target_x, target_y)
    if target_x == nil then
        local flags = TARGET_MOB + TARGET_THING + TARGET_LOS_FROM_MOB + TARGET_TRAJECTORY
        target_x, target_y = choose_target(mob, item_name, flags)
        if target_x == nil then return false end
    end

    spend_item(mob, item_name)
    ranged_attack(mob, item_name, target_x, target_y)
    return true
end

compute_damage(mob, damage, damage_flags, damage_type, pierce)

confirm_use_item(mob, item_name, button_text, is_cell_affected, max_affected_range, color, disable_use_button, frame_callback)

damage_tile(map, x, y, [dir], [dmg], [damage_flags], [damage_type], [pierce], [timestamp], [attacker])

Inflicts damage to a map square defined by x and y. Returns true, dmg when damage was dealt.

parameter description
map
x
y
dir the direction where the damage came from; use -1 for random direction. Defaults to -1.
dmg how many points of damage. Defaults to 1.
damage_flags see damage flags. Defauls to none.
damage_type see damage types. Defaults to DT_PHYSICAL.
pierce how many points of armor to pierce. Optional.
timestamp specify a timestamp to prevent AoE attacks from damaging the same large mob multiple times. Optional. See map_timestamp().
attacker the mob that committed the attack. Optional.

execute_attack(map, attacker, target_x, target_y, attack_params)

Executes an attack by mob attacker at map square defined by x and y using an attack defined by attack_params. Returns true when the attack took place.

See get_attack_params().

explosion(map, x, y, radius, dmg, damage_flags, attacker, height)

get_attack_type(attack_params)

is_ranged_weapon(weapon_name)

ranged_attack(mob, weapon_name, target_x, target_y, attack_params, execute_attack_callback)

prepare_spell(mob, spell_name, target_x, target_y, counterspell)

reset_damage_previews(map)

spend_action_point(mob)

spend_item(mob, item_name)

throw_grenade(mob, grenade_item_name, target_x, target_y)

Models

attach_bone(obj, parent_obj, bone_name)

fade_model(obj, target_dissolve, time)

fade_model_async(obj, target_dissolve, time, destroy_obj)

get_bone_world_pos(obj, bone_name)

get_model_dissolve(obj)

get_model_height(obj)

get_model_local_bounds(obj)

get_model_materials(obj)

get_model_pass_mask(obj)

get_model_skeleton(obj)

get_model_stats(obj)

get_model_world_bounds(obj)

hide_model(obj, hide)

is_model(obj)

is_model_hidden(obj)

resolve_parent_node(obj, parent_name)

set_model_cast_shadow(obj, cast_shadow)

set_model_dissolve(obj, dissolve, shadow_dissolve, mesh_name)

set_model_dissolving(enabled, immediate)

set_model_local_bounds(obj, pos, hsize)

set_model_material(obj, material)

set_model_pass_mask(obj, pass_mask)

set_model_pass_mask_bits(obj, pass_mask_bits)

Lights

fade_light(obj, target_value, time, destroy)

get_light_blur_shadow_map(obj)

get_light_cascade_count(obj)

get_light_cast_shadow(obj)

get_light_color(obj, index)

get_light_depth_bias(obj)

get_light_intensity(obj)

get_light_max_shadow_distance(obj)

get_light_range(obj)

get_light_shadow_map_size(obj)

get_light_slope_scaled_depth_bias(obj)

get_light_spot_angle(obj)

get_light_spot_sharpness(obj)

get_light_type(obj)

hide_light(obj, hide)

is_light(obj)

is_light_hidden(obj)

set_light_blur_shadow_map(obj, enable)

set_light_cascade_count(obj, count)

set_light_cast_shadow(obj, enable)

set_light_color(obj, color, index)

set_light_depth_bias(obj, value)

set_light_flicker(obj, frequency, amplitude)

set_light_intensity(obj, intensity)

set_light_max_shadow_distance(obj, max_dist)

set_light_pass_mask(obj, pass_mask)

set_light_range(obj, range)

set_light_shadow_map_size(obj, size)

set_light_slope_scaled_depth_bias(obj, value)

set_light_spot_angle(obj, angle)

set_light_spot_sharpness(obj, sharpness)

set_light_type(obj, type)

Particles

def_particles(def)

fade_particles(obj, time)

hide_particles(obj, hide)

is_particle(obj)

kill_particles(obj)

reset_particles(obj)

set_particle_system_opacity(obj, opacity)

stop_particles(obj)

Animations

cross_fade_anim(obj, name, fade, wrap_mode, use_diagonals)

cross_fade_anim_and_resume_idle(obj, name, fade, use_diagonals)

def_anim_events(filename, ...)

enable_animator(obj, enable)

end_wait_anim_event(obj, timeout)

get_anim_event_time(obj, anim_name, event_name)

get_anim_length(obj, name)

get_anim_remaining(obj, name)

get_anim_set_index(obj)

get_anim_speed(obj, name)

get_anim_time(obj, name)

has_anim(obj, name)

has_anim_in_current_set(obj, name)

has_animator(obj)

is_anim_playing(obj, name, check_diagonals)

is_animator_enabled(obj)

on_anim_event(obj, event_name, func)

on_anim_finished(obj, anim_name, func, use_diagonals)

play_anim(obj, name, wrap_mode, use_diagonals)

play_anim_and_resume_idle(obj, name, use_diagonals)

play_gesture(hero, gesture_anim, delay_in_seconds)

sample_anim(obj, name, time)

set_anim_loop_range(obj, name, loop_start, loop_end)

set_anim_set(obj, anim_set_index)

set_anim_speed(obj, name, speed)

set_anim_time(obj, name, time)

stop_anim(obj)

wait_anim(obj, name)

wait_anim_event(obj, event_name, timeout)

Effects

double_ring_effect(mob)

fan_effect(map, source_pos, target_pos)

fire_wave_effect(map, origin, ring_velocity, duration, emission_rate)

flicker_effect(obj, duration, hide_obj)

ring_of_fury_effect(mob, brightness, fade_in)

summon_effect(mobs, duration, speed)

swirling_trails_effect(parent_obj, trail_texture, trail_color, duration, radius)

teleport_effect(mob)

unsummon_effect(mobs, duration, speed)

Paths

clamp_path(path, mob, [block_flags])

Clamps the path to maximum movement range of mob and returns the clamped path.

dump_path(path)

find_path(map, x1, y1, x2, y2, [size], [target_size], [astar_flags], [block_flags], [ignore_mob], [preferred_edge], [mob], [max_path_length])

Finds a path between map squares x1,y1 and x2,y2. This is the "low level" path finding function.

param type description
map map
x1 number
y1 number
x2 number
y2 number
size number the size of the mob that needs to squeezed through the path
target_size number the size of the target with pivot at x2,y2
astar_flags number see A* flags
block_flags number see blocking related flags from object flags
ignore_mob mob ignore this mob during the path find
preferred_edge number direction that defines the edge preference, used for selecting between different equal length paths with mouse. Optional.
mob mob the mob that is moving. Optional, but must be specified when using ASTAR_IGNORE_ALLIES, *NEUTRAL, *ENEMIES flags.
max_path_length number the maximum move cost to follow

Returns a number when ASTAR_DISTANCE (total number of steps; not move cost!) is set on; otherwise a an array-like table, where each index contains the x and y coordinates and the table itself the total move cost of the path:

local path = find_path(...)
local total_move_cost = path.move_cost
for i=1,#path do
    local node = path[i]
    local x, y = node.x, node.y
    -- do something with x and y
end

find_path_for_mob(mob, target_x, target_y, target_size, astar_flags, ignore_mob, preferred_edge, max_path_length)

A convenience function for finding paths for mobs.

follow_path(mob, path, adjacent_mode)

Makes a mob walk along a path. This is rather low-level, but it might be useful in some rare cases in cinematics.

Prefer ai_follow_path() over this when implementing AI for AI controlled mobs, and move_to* functions when implementing cinematics.

Returns true if the mob was able to follow the path through; otherwise false.

is_path_blocked(path, mob)

AI

ai_advance(mob, targets)

ai_basilisk_petrify(mob, item_name)

ai_boar_charge(mob, item_name)

ai_break_forcefield(mob, item_name)

ai_centipede_poison_attack(mob, item_name)

ai_charm(mob, item_name)

ai_choose_target(mob, max_range, targets)

ai_confuse(mob, item_name)

ai_confused(mob)

ai_coppe_steal_spell(mob, item_name)

ai_cure(mob, item_name)

ai_cure_self(mob, item_name)

ai_dark_knight_rally(mob, item_name)

ai_destroy_obstacles(mob, item_name)

ai_dire_wolf_freezing_breath(mob, item_name)

ai_dispel(mob, item_name)

ai_dynamite(mob, item_name)

ai_escape1_turn_off_lightning(mob, item_name)

ai_find_enemies(mob, filter_callback)

ai_find_firing_location(mob, max_range, targets)

ai_fire(mob, item_name)

ai_flank(mob, item_name)

ai_flee(mob)

ai_follow_heroes(mob)

ai_follow_path(mob, path, move_flags)

ai_forcebolt(mob, item_name)

ai_guard(mob, item_name)

ai_haste_self(mob, item_name)

ai_ice(mob, item_name)

ai_lightning(mob, item_name)

ai_melee(mob, item_name, targets)

ai_move(mob, dir, first_move, last_move, move_flags)

ai_move_to(mob, x, y, move_flags)

ai_move_to_cautious(mob, x, y, allowed_damage, hp_margin, astar_flags, move_flags)

ai_open_door(mob, door_name, unlock_doors)

ai_possess(mob, item_name, targets)

ai_potion_self(mob, item_name)

ai_protect(mob, item_name)

ai_protect_self(mob, item_name)

ai_ranged_attack(mob, item_name, targets)

ai_shield_self(mob, item_name)

ai_simulate_attack(mob, item_name, target)

ai_simulate_path(mob, path)

ai_sleep(mob, item_name)

ai_sorceress_find_teleport_location(mob, targets, min_jump_dist, preferred_min_dist, preferred_max_dist)

ai_sorceress_forcebolt(mob, item_name)

ai_sorceress_summon(mob, item_name)

ai_sorceress_teleport(mob, item_name)

ai_sorceress_true_form_acid_bolt(mob, item_name, target_x, target_y)

ai_sorceress_true_form_advance(mob, item_name, targets)

ai_sorceress_true_form_beam_attack(mob, item_name, target_x, target_y)

ai_sorceress_true_form_defend(mob, item_name)

ai_sorceress_true_form_find_targets(mob, max_range)

ai_sorceress_true_form_melee_attack(mob, item_name, targets)

ai_sorceress_true_form_regenerate(mob, item_name)

ai_sorceress_true_form_summon(mob, item_name)

ai_sorceress_true_form_warp_space(mob, item_name)

ai_stalker_phase_in_out(mob, item_name)

ai_stalker_phase_out(mob, item_name)

ai_suffocate(mob, item_name)

ai_target_aoe(mob, firing_loc_x, firing_loc_y, aoe_cells, max_range, max_radius, targets)

ai_use_item(mob, item_name)

ai_void_haunt_boss_raise_undead(mob, item_name)

ai_void_haunt_raise_undead(mob, item_name)

clear_ai_flag(obj, flag)

get_ai_flag(obj, flag)

get_ai_target(mob)

set_ai_flag(obj, flag)

set_ai_routine(mob, ai_routine)

set_ai_target(mob, target)

Game State

clear_game_flag(flag)

clear_story_event(flag)

find_persistent_hero_state(name)

gain_xp(hero_state, amount)

get_enabled_hero_count()

get_persistent_hero_state(name)

get_game_flag(flag)

get_registry(key)

Retrieves a value from the persistent hashmap using the unique key. Returns nil if not defined.

See also set_registry.

get_story_event(flag)

get_total_ability_uses(hero_state, ability_name, add_power_bonuses)

get_xp_for_next_level(current_level)

set_game_flag(flag)

set_registry(key)

Stores a value to a persistent hashmap. Useful for storing mod specific state to savegames.

parameter type description
key string a unique key for the value
value nil, number, string, boolean or table cyclic tables not supported!

Campaign

def_mission(def)

Declares a new mission.

def_mission{
	name = "testmod.test",
	site = "testmod.test_site",
	ui_name = "Test Mission",
	level_filename = "mod_data/levels/test.level",
	letter_text =
		"From: The devs\n" ..
		"To: To all modders\n" ..
		"Subject: Welcome!\n\n" ..
		"Welcome to modding Druidstone! We hope to see lots of cool mods in the coming months.",
	locked = false,
	loot = { "testmod.shovel", "testmod.t_shirt", "testmod.necklace" },	-- contents of the loot box
}

World Map

def_site(def)

Declares a new site. After declaration, the site needs to visualized on the world map using global hook on_enter_world_map.

-- define a new site on the world map
def_site{
	name = "testmod.test_site",
	ui_name = "O'Mighty Site of Testing",
}

-- make alterations to the world map
register_global_hook("on_enter_world_map", function(map)
	local site = spawn("map_herb_plant", map, 0, 0, 0)
	register_named_obj(map, site, "testmod.test_site")
	set_world_pos3(site, 103.9435, 1.2914, -129.9235)
	set_world_rot_euler(site, 0.0, math.rad(39,4243), 0.0)
	set_obj_scale3(site, 0.45, 0.45, 0.45)
end)

hide_site(map, site_name, hide)

reveal_site(map, site_name)

GUI

add_damage_text(text, obj, color, font, delay_in_seconds, flags)

add_damage_text2(map, text, pos, color, font, delay_in_seconds, flags)

checkbox(text, id, x, y, value, styles)

confirm_dialog(title, text, ...)

combobox(id, x, y, width, value, values, styles)

focus_scroll_area(id, target_min, target_max, height, total_height)

get_font(font_name)

hide_cursor()

image_button(id, image, hover_image, x, y, styles, scale, color)

is_any_gui_item_hovered()

is_modal_dialog_open()

hud_print(map, text, duration)

show_cursor()

slider(id, x, y, value, min_value, max_value, tooltip_format_func, tooltip_color)

tab_button(text, x, y, width, selected, font, styles)

text_button(text, x, y, width, styles, font, color, button_alpha)

text_input(text, max_length, cursor_x)

wait_dialog()

Input

get_input_event()

is_mouse_pressed(button)

mouse_rect(x, y, width, height)

wait_input()

Camera

camera_shake(intensity, duration)

focus_camera(target, instant, wait_until_focused)

focus_camera_to_group(targets, instant, wait_until_focused)

get_camera_controls()

get_camera_height()

get_camera_target()

play_camera_anim(mob, duration, title, camera_anim, flags, fov)

play_camera_anim_async(map, fov, near, far, update_func)

play_special_attack_anim(mob, title, camera_anim, duration)

project_world_point(point)

reset_camera()

set_active_camera(camera)

set_camera_angle(angle, instant)

set_camera_controls(enable)

set_camera_height(height, instant)

set_camera_mode(mode)

set_camera_target(obj, wait_until_focused)

stop_camera_anim(map)

smooth_lerp_camera(target, target_height, time)

smooth_lerp_camera_async(map, target, target_height, time)

Audio

def_audio_stream(name, filename, volume, loop_start_sec, loop_end_sec)

def_sound(name, filename, volume, pitch, pitch_random)

fade_music(time, volume)

fade_music_async(time, volume)

get_music_volume()

is_sound(obj)

is_sound_defined(name)

set_music_volume(volume, mute)

get_sfx_volume()

set_sfx_volume(volume, mute)

play_music(name, flags, fade_time_in_seconds)

play_sound(name, flags)

play_sound_stream(name, volume, loop)

resume_music(flags)

stop_music()

stop_sound(handle)

toggle_music()

wait_fade_music()

Functions yet to be classified

begin_cinematic(map)

begin_interaction(mob, obj, dir, delta)

card_description(card, mob_opt, strip_line_breaks, focused)

check_lof_directional(map, x1, y1, x2, y2)

check_los(map, x1, y1, x2, y2, block_flags, debug_draw, ignore_last_cell, ignore_obj)

check_los_area(map, x1, y1, w1, h1, x2, y2, w2, h2)

check_los_cover(map, x1, y1, x2, y2)

check_los_mob(mob1, mob2)

check_melee_attack(attacker, target, reach)

check_melee_attack2(attacker, target_x, target_y, reach)

check_opportunity_attack(mob)

close_door(obj)

close_door_async(obj)

close_portcullis(obj)

close_portcullis_async(obj)

complete_bonus_objective(mission_name, objective_id)

complete_mission(difficulty, mission_name)

condition_description(condition, value)

counter_attack(mob, target)

create_dynamic_geometry_obj(map, func)

create_ticker_func(obj, initial_value, delta, ticker_func)

create_timed_event(map, delay, func)

create_timer_func(obj, timer_func)

create_timer_obj(map, timer_func)

def_aux(desc)

def_aux_card(defs)

def_breakable(name, spawn_on_death, hp, flags)

def_campaign(def)

def_edit_tool(def)

def_gui_element(name, format)

def_material(def)

def_mob(def)

def_object(desc, aux, remember)

def_shader(def)

def_swipe(name, material, speed)

def_texture(filename, format)

def_texture_array(filename, width, height, array_size, format)

dump_attack_params(attack_params)

dump_nodes(node, indent)

enable_trail(obj, enable)

end_cinematic(map)

end_interaction(mob)

fade(target, time, color, flags)

fade_async(target, time, color, flags)

fade_room(map, room, show)

fade_wall(x, y, speed)

find_mission(mission_name)

found_item(mob, item, x, y)

found_item_type(mob, item_name, where, flags, count)

get_campaign(name)

get_current_campaign()

get_current_mission()

get_equipped_card(mob, slot)

get_mission(mission_name)

get_mission_completed_count(mission_name)

get_mission_rating(site_name, envs)

get_mission_rewards_formatted(mission_name, dummy_map, env)

get_power_upgrades(hero_state, card_name)

get_site_ui_name(site)

get_ticker_delta(obj)

get_ticker_value(obj)

init_hero_equipment(mob)

interact_chest(mob, chest, dir)

interact_door(mob, door, dir)

interact_exploding_barrel(mob, barrel, dir)

interact_lever(mob, lever, dir)

interact_loot_box(mob, box, dir)

interact_merchant(mob, merchant, dir)

interact_monolith(mob, monolith, dir)

interact_spellbook(mob, spellbook, dir)

interact_with_obj(mob, obj, target_x, target_y)

is_bonus_objective_completed(mission_name, objective_id)

is_door_open(obj)

is_main_campaign_mission(mission_name)

is_main_menu_map(map)

is_melee_weapon(weapon_name)

is_mission_available(mission_name)

is_mission_completed(mission_name)

is_mission_completed2(mission_name, difficulty)

is_mission_locked(mission_name)

load_texture(filename, format)

load_texture_array(filename, width, height, array_size, format)

los_raycast(map, x1, y1, x2, y2, block_flags, debug_draw, ignore_last_cell, ignore_obj)

make_attack_params(damage, damage_flags, damage_type)

make_unique_material(obj, material_name)

map_edge_world_pos(map, x, y, edge)

map_to_world(map, x, y)

map_vertex_world_pos(map, x, y)

mark_completed_objectves(map)

melee_attack(attacker, target_x, target_y, attack_params, use_off_hand_weapon)

message(text, where, title_image, frame_type, num_options)

message_box(title, text, paragraph_width, ...)

open_door(obj)

open_door_async(obj)

open_door_instant(obj)

preview_damage_for_sweep(map, attack_params)

random_location(map, block_flags, filter_callback)

random_location_in_room(map, room, block_flags, w, h)

random_location_near(map, x, y, w, h, block_flags)

random_location_within_range(map, x, y, range, block_flags)

remove_harmful_conditions(mob)

remove_hero(mob)

remove_lightning_bolt(map, id)

remove_lightning_bolts(map)

request_end_battle(status, end_flags)

request_unlock_mission(mission_name)

reset_cooldowns(mob)

reset_fade(color, value, flags)

reset_ticker(obj)

reset_trail(obj)

set_damage_flags(attack_params, damage_flags)

set_edge_blocker(map, x, y, facing, edge_width, value)

set_fog_tile(map, x, y, tile)

set_hand_item(mob, bone_name, item_name)

set_story_event(flag)

set_stroke_shader(font, stroke_size)

set_ticker_delta(obj, delta)

set_ticker_value(obj, value)

set_timer_value(obj, value)

set_tooltip_text(text)

set_trail_color(obj, color)

set_trail_intensity(obj, intensity)

set_weapon(mob, weapon_name, no_idle_anim)

shoot_fireball(statue)

shoot_projectile(map, projectile_type, origin, target, origin_bone_name)

shoot_projectile_async(map, projectile_type, origin, target, origin_bone_name, hit_callback)

show_mission_briefing_dialog(ctx, site)

site_completed(map, site_name, ctx)

spend_gold(amount)

start_mission(mission_name, ...)

strip_text_formatting(text)

subliminal_message(text, fade_in, fade_out, timeout)

substitute_reward_glyphs(rewards, grey)

talking_head(x, y, w, h, portrait, align, text)

text_color(color)

text_width(text, font)

title_bar_width(text, font)

toggle_door(obj)

toggle_door_async(obj)

ui_name_decorated(obj)

uncomplete_mission(difficulty, mission_name)

unlock_hero(name)

unlock_mission(mission_name)

update_passives(map)

update_texcoord_anim_material(material, scale_x, scale_y, offset_x, offset_y, r, g, b, a)

use_melee_attack_2x2(mob, item_name, target_x, target_y)

use_melee_attack_3x3(mob, item_name, target_x, target_y)

use_melee_attack_diagonal_lerp(mob, item_name, target_x, target_y)

use_melee_weapon(mob, item_name, target_x, target_y)

wait_fade()

wait_pending_moves(map)

wait_projectiles(map)

wait_spawnfx(map)

warn(format, ...)

warn_once(key, format, ...)

wavelength_color(t)

world_to_map(map, world_pos)

Clone this wiki locally