-
Notifications
You must be signed in to change notification settings - Fork 1
Functions
Functions
Returns true when value has any of the bits defined by bits set to 1; otherwise false.
assert(check_bits(3, 2))
Returns value with all bits defined by bits set to 0.
assert(clear_bits(3, 2) == 1)
Blocks for ms milliseconds while keeping the game loop running.
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)
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.
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.
Returns the manhattan distance between two map squares defined by the parameters. Does not take any kind of map blockers into account.
Returns the signed distance between two map squares along given direction.
Returns the shortest distance between a point and a rectangle.
Returns the shortest distance between two rectangles.
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.
Returns a if cond is true; otherwise b.
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
Removes a hook from an event programmatically.
Returns value with bits defined by bits set to 1.
assert(set_bits(4, 7) == 7)
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.
Returns an item from a random index of the array-like t. Returns nil for map-like tables.
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.
Converts various game objects into a string that you can show on the user interface.
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
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. |
Returns true when a mob specified by mob can move to direction dir.
Returns true when the x,y coordinates are valid for the given map; otherwise false.
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.
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.
See facings for an interpretation of values.
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.
Converts dx, dy to a cardinal (NSEW) direction [0-3].
Converts dx, dy to a direction [0-7].
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
Converts specified facing to radians. Does not normalize facing, so keep the value between [0,7].
Returns true when dir is logically N, E, S or W, i.e. between [0,3]; otherwise false.
Returns true when dir is logically NE, SE, SW or NW, i.e. between [4,7]; otherwise false.
Converts deltas to a facing as defined by atan2 function.
Returns the opposite direction of dir.
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 |
Iterates through all map objects.
for index,obj in all_map_objs(map) do
-- do something with the object
end
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
Iterates through all adjacent cells of a mob.
for packed_coord, x, y in adjacent_cells_for_mob(mob) do
-- do something
end
Iterates through all map cells.
for x, y in map_cells(map) do
-- do something
end
Iterates through all mobs on the map.
for index, mob in map_mobs(map) do
-- do something with the mob
end
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
Iterates through all map cells in random order.
for x, y in random_map_cells(map) do
-- do something
end
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. |
Make the game activate a spawner group defined by spawn_group_index on round round.
Clears all scheduled reinforcements from the map.
Returns a number, which indicates how many rounds further is the next scheduled reinforcement. Returns nil when there are no reinforcements coming.
Returns true when obj is a spawner.
Clears async dialogue boxes introduced with say_line_async.
Adds a map marker at x,y and returns it. marker_type must be either "default" or "attack".
Gets a map marker at x, y; or nil if there is no map marker.
Removes a map marker returned by add_map_marker.
Removes a map marker from map square x,y.
Removes all map markers from the map.
Flips off a flag on the specified object. See Object Flags.
Destroys an object from the map.
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
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.
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.
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
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
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")
Returns true if obj has the flag set on; otherwise false. See Object Flags.
Returns a vector that describes the scaling factor of the object.
Returns a vector that describes the position of the object in world space.
Returns a number that describes the height of the object, i.e. the Y axis coordinate in world space.
Returns the rotation matrix for the object.
Extracts euler angles from the object's rotation matrix.
local rot_x, rot_y, rot_z = get_world_rot_euler(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
Returns true when objects occupy adjacent cells, i.e. the distance between them is exactly 1 square. Does not take edge blockers into account.
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)
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.
Returns the point from obj footprint that is closest to x,y.
Returns the manhattan distance between obj1 and obj2.
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
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
Returns w and h ordered correctly based on 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
Converts a vector in world space to map square coordinates for obj.
Orients an object to specified facing. See facings.
Orients an object towards a square defined by x and y. This function prefers diagonals; you may get better results with set_facing + octant.
Flips on a flag on the specified object. See Object Flags.
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 non-uniform scaling for an object.
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.
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.
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.
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.
Rotate obj by mat.
set_world_rot(obj, mat.look_at(vec(1.0, 2.0, 3.0)))
Rotate obj using euler angles given by x-, y-, and z-parameters.
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
Spawns and returns an object of type obj_type in the square occupied by obj.
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
Clears the mob flag specified by flag for mob. See Mob Flags.
Clears all conditions from mob.
Clears condition cond from mob. Set silent to true to skip audiovisual side-effects related to clearing the condition in question. See conditions.
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. |
Returns true when mob has the condition defined by cond; otherwise false. See conditions.
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.
Returns true if obj has the flag set on; otherwise false. See Mob Flags.
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
Returns true when mob has cover; otherwise false.
Returns true if the obj is a mob; otherwise false. Remember that things are also mobs.
Returns true if the obj is a thing; otherwise false.
Returns the default blocking flags for mob based on the type of the mob. See block flags.
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.
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 |
Returns a number, which specifies the attack range of the mob, optionally wielding an item.
Returns a number, which specifies the reach of the mob, optionally wielding an item. Reach applies to melee attacks.
Returns a number, which specifies the width/height of the mobs footprint. Only symmetric mobs are supported by the game!
Returns a number, which specifies how many movement points the mob receives each round.
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 |
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)
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 |
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 |
Make mob move one square to direction specified by dir. This blocks until the mob has moved.
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 |
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.
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
Makes the mob say something without block the UI. See clear_async_dialogue_boxes.
Sets the mob flag specified by flag on for mob. See Mob Flags.
Updates and animates world space transforms for all moving mobs. Use push_mob() and push_mob_async() to actually move the game objects.
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
Gets the hero with the green circle. Might be nil.
Returns true when mob is the active hero; otherwise false.
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...)
Returns true when mob is in the party; otherwise false.
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")
Make mob the active hero. Call only with party members...
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.
Make mob scabbard the weapons with an animation. Works properly only for main player characters. This function exits on the same frame.
Make mob pull out the weapons with an animation. Works properly only for main player characters. This function exits on the same frame.
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"
}
}
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"
}
}
For showing/disabling new arrival indicator on cards in merchant dialog, value should be true or false.
Returns true when mob can use item with name item_name; otherwise false.
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
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
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. |
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().
Clamps the path to maximum movement range of mob and returns the clamped 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.
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.
ai_sorceress_find_teleport_location(mob, targets, min_jump_dist, preferred_min_dist, preferred_max_dist)
Retrieves a value from the persistent hashmap using the unique key. Returns nil if not defined.
See also set_registry.
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! |
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
}
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)