WarScript API Reference

Native functions available in the global scope

Language

WarScript syntax reference — constructions, data types, and operators.

Basic Constructions

Variables

# plain types
a1 = 123
a2 = "hello world"

# class instance
left_tree_node = new TreeNode [ 1 ]
tree_node = new TreeNode [ 3, left_tree_node, new TreeNode [ 2 ] ]

# array
example_array = { 1, 2, "three", new TreeNode [ 4 ] }
empty_array = {}

Conditions

if a1 > 5 and tree_node :: value == 3
    # statements
elif a2 == "hello" or a3 == "world"
    # statements
else
    # statements
end

Print

print a1 + a2 + tree_node :: value

Import

import "lib/common.ws"

Functions

fun fibonacci_number [ n ]
    if n < 2
        return n
    end
    return fibonacci_number [ n - 1 ] + fibonacci_number [ n - 2 ]
end

Loops

# for loop
loop i in 0..10
    # statements
end

# with step
loop i in 0..100 by 5
    # statements
end

# while loop
loop health > 0
    # statements
end

# for-each
loop item in items
    # statements
end

# break and next
loop i in 0..10
    if i == 5
        break
    end
    if i == 3
        next
    end
end

Exceptions

class MyException [message]
end

begin
    raise new MyException ["Error message"]
rescue error
    print error :: message
ensure
    print "Always runs"
end

Default Parameters

Trailing function parameters can have default values. Omitting an argument passes null, which triggers the default.

fun greet [name, greeting = "Hello"]
    return greeting + ", " + name
end

greet ["World"]          # → "Hello, World"
greet ["World", "Hi"]  # → "Hi, World"

# All params can be optional
fun point [x = 0, y = 0, z = 0]
    return x + y + z
end
point []        # → 0
point [1, 2]    # → 3

Lambdas / First-Class Functions

Functions are values. Use fun [params] body end in any expression position — assignments, arguments, arrays, return values.

# Store in a variable
double = fun [x] return x * 2 end
print double [5]    # → 10

# Pass as argument
fun apply [arr, func]
    result = {}
    loop item in arr
        result << func [item]
    end
    return result
end
apply [{1, 2, 3}, fun [x] return x * 10 end]

# Return from a function
fun pick [mode]
    if mode == "double"
        return fun [x] return x * 2 end
    else
        return fun [x] return x + 1 end
    end
end

# Store in arrays
ops = {fun [a, b] return a + b end, fun [a, b] return a * b end}
f = ops{0}
print f [3, 4]    # → 7

Constants

Immutable global values. Reassignment raises a syntax error at parse time.

const MAX_HP = 100
const TEAM_NAME = "Red"
const HALF_HP = MAX_HP / 2    # runtime expressions work

# MAX_HP = 50  → SyntaxException: Cannot reassign constant

Enums

Named numeric constants grouped under a class instance. Access members with ::.

enum DamageType
    PHYSICAL
    MAGICAL
    TRUE = 5
end

# Access values
DamageType :: PHYSICAL    # → 0
DamageType :: TRUE        # → 5

# Reverse lookup
DamageType :: name [DamageType :: PHYSICAL]    # → "PHYSICAL"

# Iteration
loop v in DamageType :: values
    print DamageType :: name [v]
end

DamageType :: values    # → {0, 1, 5}
DamageType :: names     # → {"PHYSICAL", "MAGICAL", "TRUE"}
DamageType :: count     # → 3

Values auto-increment. Explicit values reset the counter:

enum Priority
    LOW = 10     # 10
    MEDIUM       # 11
    HIGH         # 12
    CRITICAL = 100  # 100
    EMERGENCY    # 101
end

Data Types

Numeric

number1 = 1
number2 = 3.21
number3 = .543
number4 = -1

Text

text = "hello world"
print text{1}
text{1} = "a"

String Interpolation

Embed expressions inside strings using {}. Any valid expression can appear inside the braces, including variables, arithmetic, function calls, and property access.

name = "Steve"
age = 25
print "Hello {name}, you are {age} years old"

# expressions inside braces
print "Next year: {age + 1}"

# class properties
class Entity [name, hp, max_hp]
end
e = new Entity ["Warrior", 75, 100]
print "{e :: name}: {e :: hp}/{e :: max_hp}"

# function calls
fun double [n]
    return n * 2
end
print "Result: {double [5]}"

# array access
arr = {10, 20, 30}
print "Second element: {arr{1}}"

Logical

logical1 = true
logical2 = false

Class

class Lamp [ type, is_on ]
    fun turn_on
        is_on = true
    end

    fun turn_off
        is_on = false
    end

    fun set_is_on [ is_on ]
        this :: is_on = is_on
    end
end

lamp = new Lamp [ "Halogen", false ]

# get/set properties
lamp_is_on = lamp :: is_on
lamp :: type = "Led"

# invoke functions
lamp :: turn_off []

# inheritance
class DerivedClass: BaseClass [ property ]
end

Arrays

items = { 1, 2, "three" }

# get/set by index
value = items{1}
items{1} = 123

# append
items << 3

Null

value = null

NativeObject<T>

fun on_unit_died[unit]
    print Unit_get_position[unit]
end

Operators

Operators ordered by precedence (lowest to highest):

OperatorSymbolPrecedenceExample
Assignment=1a = 5
Addition Assignment+=1a += 5
Subtraction Assignment-=1a -= 5
Multiplication Assignment*=1a *= 5
Division Assignment/=1a /= 5
Append to array<<1array << "value"
Logical ORor2true or false
Logical ANDand3true and true
Parentheses( )4
Equals==5a == 5
Not Equals!=5a != 5
Greater Than Or Equals>=5a >= 5
Greater Than>5a > 5
Less Than Or Equals<=5a <= 5
Less Than<5a < 5
Addition+6a + 5
Subtraction-6a - 5
Multiplication*7a * 5
Division/7a / 5
Modulo%7a % 5
NOT!8!false
Negate-8y = -x
Class Instancenew8new Type [ value ]
Nested Instance:: new8type :: new NestedType
Property Access::8type :: value
Castas8type as Supertype
Instance Ofis8type is Supertype

Exponentiation, floor division, square root, and other math operations are available as native functions: pow[base, exp], sqrt[n], floor[n], ceil[n], round[n], abs[n], min[a, b], max[a, b], clamp[n, lo, hi], lerp[a, b, t].

Coroutines

Coroutines allow functions to pause execution and resume on a later tick. This is useful for sequences that span multiple frames: movement, timers, cutscenes, patrol paths, dialog trees.

yield — pause until next tick

fun flash [entity]
    Entity_set_color [entity, "red"]
    yield
    Entity_set_color [entity, "white"]
    yield
    Entity_set_color [entity, "red"]
    yield
    Entity_set_color [entity, "white"]
end

start_coroutine ["flash", {my_entity}]

yield wait — pause for a duration (seconds)

fun spawn_wave []
    spawn_enemies [5]
    print "Wave 1 started"
    yield wait 10
    spawn_enemies [10]
    print "Wave 2 started"
    yield wait 15
    spawn_enemies [20]
    print "Final wave!"
end

start_coroutine ["spawn_wave", {}]

yield until — pause until a condition is true

fun wait_for_player [door]
    print "Waiting for player..."
    yield until player_near [door]
    open_door [door]
    print "Door opened"
end

start_coroutine ["wait_for_player", {my_door}]

Looping coroutines — restart from the beginning when complete

fun patrol [unit]
    move_to [unit, waypoint_a]
    yield until reached_target [unit]
    yield wait 2
    move_to [unit, waypoint_b]
    yield until reached_target [unit]
    yield wait 2
end

# Patrols forever until stopped
id = start_coroutine_loop ["patrol", {guard}]

# Stop when needed
stop_coroutine [id]

Variables are preserved across yields — local state survives suspension:

fun countdown [n]
    loop i in 0..n
        print "{n - i}..."
        yield wait 1
    end
    print "Go!"
end

start_coroutine ["countdown", {5}]

Engine integration: the engine calls TickCoroutines[dt] each frame to advance all active coroutines. Coroutines are fully deterministic — same inputs produce the same execution order on every client, making them safe for lockstep multiplayer.

Note: yield must appear at the top level of the function body. It cannot be nested inside if, loop, or begin blocks. Use start_coroutine_loop for repeating behavior.

engine Library

Engine configuration. Set tick rate, max players, and other server/multiplayer settings.

engine_get_additional_input_delay [] NumericValue

Returns the current additional input delay.

No parameters

engine_get_map_reset_seconds [] NumericValue

Returns the current map reset timer in seconds.

No parameters

engine_get_max_players [] NumericValue

Returns the maximum number of players per lobby.

No parameters

engine_get_maximum_tick_time [] NumericValue

Returns the current maximum tick time in seconds.

No parameters

engine_get_required_buffered_ticks [] NumericValue

Returns the current required buffered tick count.

No parameters

engine_get_tick_rate [] NumericValue

Returns the current simulation tick rate.

No parameters

engine_set_additional_input_delay [value]

Sets extra input delay ticks for multiplayer. Default: 2.

ParameterType
valueNumeric
engine_set_map_reset_seconds [value]

Sets how long (seconds) before an empty map resets. Default: 300.

ParameterType
valueNumeric
engine_set_max_players [value]

Sets the maximum number of players per lobby (1–255). Default: 8.

ParameterType
valueNumeric
engine_set_maximum_tick_time [value]

Sets the maximum time (seconds) allowed per tick before skipping. Default: 0.1.

ParameterType
valueNumeric
engine_set_required_buffered_ticks [value]

Sets the minimum buffered ticks required before simulation advances. Default: 1.

ParameterType
valueNumeric
engine_set_tick_rate [value]

Sets the simulation tick rate (ticks per second). Default: 30.

ParameterType
valueNumeric

game_result Library

Game result (victory/defeat). Stops simulation and shows result screen.

game_defeat [title, body]

Triggers a defeat. Stops the simulation and shows a result screen. Args: title, body.

ParameterType
titleText
bodyText
game_victory [title, body]

Triggers a victory. Stops the simulation and shows a result screen. Args: title, body.

ParameterType
titleText
bodyText

doodad Library

Doodad definition. Define doodads in .ws instead of binary .wdoodad.

doodad_begin [doodadId, prefab]

Begins a doodad with prefab config. Args: doodad id, prefab name.

ParameterType
doodadIdText
prefabText
doodad_config_bool [property, value]

Sets a bool property on prefab config. Args: property name, value.

ParameterType
propertyText
valueLogical
doodad_config_float [property, value]

Sets a float property on prefab config. Args: property name, value.

ParameterType
propertyText
valueNumeric
doodad_config_int [property, value]

Sets an int property on prefab config. Args: property name, value.

ParameterType
propertyText
valueNumeric
doodad_config_string [property, value]

Sets a string property on prefab config. Args: property name, value.

ParameterType
propertyText
valueText
doodad_define [doodadId, prefab]

Defines a doodad. Args: doodad id, prefab name.

ParameterType
doodadIdText
prefabText
doodad_end []

Finalizes the current doodad with config and registers it.

No parameters

quest Library

Quest definition. Define quests in .ws instead of binary .wquest.

quest_define [questId, nameTKey, descTKey, groupTKey]

Defines a quest. Args: id, name translation key, description translation key, group translation key.

ParameterType
questIdText
nameTKeyText
descTKeyText
groupTKeyText

room_editor Library

Programmatic room creation and terrain editing.

editor_biome [biomeName]

Sets the room's biome.

ParameterType
biomeNameText
editor_clear_all_doodads []

Removes all doodads from the room.

No parameters

editor_clear_doodads [doodadId]

Removes all instances of a doodad type.

ParameterType
doodadIdText
editor_clear_rect_doodads [x1, z1, x2, z2] NumericValue

Removes doodads in a world-space rectangle. Args: x1, z1, x2, z2.

ParameterType
x1Numeric
z1Numeric
x2Numeric
z2Numeric
editor_count_doodads [doodadId] NumericValue

Returns doodad instance count. Pass "" for total count.

ParameterType
doodadIdText
editor_get_depth [] NumericValue

Returns the room depth in cells.

No parameters

editor_get_height [x, y] NumericValue

Returns terrain height at (x, y).

ParameterType
xNumeric
yNumeric
editor_get_texture [x, y] NumericValue

Returns texture layer at (x, y).

ParameterType
xNumeric
yNumeric
editor_get_water [x, y] NumericValue

Returns water height at (x, y). 0 = no water.

ParameterType
xNumeric
yNumeric
editor_get_width [] NumericValue

Returns the room width in cells.

No parameters

editor_new_room [name, width, height]

Resets the room to a blank canvas. Args: name, width, height.

ParameterType
nameText
widthNumeric
heightNumeric
editor_noise_height [seed, scale, amplitude, baseHeight]

Applies Perlin noise to terrain. Args: seed, scale, amplitude, base_height.

ParameterType
seedNumeric
scaleNumeric
amplitudeNumeric
baseHeightNumeric
editor_paint [x, y, width, height, layerIndex]

Paints a texture layer in a rectangle. Args: x, y, width, height, layer_index.

ParameterType
xNumeric
yNumeric
widthNumeric
heightNumeric
layerIndexNumeric
editor_paint_fill [layerIndex]

Paints the entire room with a texture layer.

ParameterType
layerIndexNumeric
editor_place [doodadId, x, y, z, rotation, scale]

Places a doodad at world position. Args: doodad_id, x, y_up, z, rotation_degrees, scale.

ParameterType
doodadIdText
xNumeric
yNumeric
zNumeric
rotationNumeric
scaleNumeric
editor_place_at_terrain [doodadId, gridX, gridY, rotation, scale]

Places a doodad at terrain height. Args: doodad_id, grid_x, grid_y, rotation, scale.

ParameterType
doodadIdText
gridXNumeric
gridYNumeric
rotationNumeric
scaleNumeric
editor_ramp [x, y, width, height, enabled]

Sets or removes ramps in a rectangle. Args: x, y, width, height, enabled.

ParameterType
xNumeric
yNumeric
widthNumeric
heightNumeric
enabledLogical
editor_remove_water [x, y, width, height]

Removes water in a rectangle. Args: x, y, width, height.

ParameterType
xNumeric
yNumeric
widthNumeric
heightNumeric
editor_resize [width, height]

Resizes the room. Preserves existing terrain.

ParameterType
widthNumeric
heightNumeric
editor_save [] LogicalValue

Saves the current room to the ContentResolver.

No parameters

editor_scatter [doodadId, count, minX, minY, maxX, maxY, minScale, maxScale] NumericValue

Randomly scatters doodads. Args: id, count, minGX, minGY, maxGX, maxGY, minScale, maxScale.

ParameterType
doodadIdText
countNumeric
minXNumeric
minYNumeric
maxXNumeric
maxYNumeric
minScaleNumeric
maxScaleNumeric
editor_scatter_seeded [doodadId, count, seed, minX, minY, maxX, maxY, minScale, maxScale] NumericValue

Deterministic scatter. Args: id, count, seed, minGX, minGY, maxGX, maxGY, minScale, maxScale.

ParameterType
doodadIdText
countNumeric
seedNumeric
minXNumeric
minYNumeric
maxXNumeric
maxYNumeric
minScaleNumeric
maxScaleNumeric
editor_set_detail [x, y, detailType]

Low-level: sets detail variant at a point.

ParameterType
xNumeric
yNumeric
detailTypeNumeric
editor_set_height [x, y, height]

Low-level: sets raw terrain height at a point. Prefer editor_terrain[].

ParameterType
xNumeric
yNumeric
heightNumeric
editor_set_ramp [x, y, hasRamp]

Low-level: sets ramp flag at a point. Prefer editor_ramp[].

ParameterType
xNumeric
yNumeric
hasRampLogical
editor_set_texture [x, y, layerIndex]

Low-level: sets raw texture layer at a point. Prefer editor_paint[].

ParameterType
xNumeric
yNumeric
layerIndexNumeric
editor_set_water [x, y, height]

Low-level: sets raw water height at a point. Prefer editor_water[].

ParameterType
xNumeric
yNumeric
heightNumeric
editor_shift_height [change]

Adds a height offset to all terrain. Can be negative.

ParameterType
changeNumeric
editor_smooth_height [cx, cy, radius, strength]

Smooths terrain around (cx, cy) with radius and strength (0-1).

ParameterType
cxNumeric
cyNumeric
radiusNumeric
strengthNumeric
editor_terrain [x, y, width, height, terrainHeight]

Sets terrain height in a rectangle using the cliff system. Args: x, y, width, height, terrain_height.

ParameterType
xNumeric
yNumeric
widthNumeric
heightNumeric
terrainHeightNumeric
editor_terrain_fill [terrainHeight]

Sets the entire room to a terrain height.

ParameterType
terrainHeightNumeric
editor_water [x, y, width, height, terrainHeight, waterHeight]

Creates water in a rectangle. Args: x, y, width, height, terrain_height, water_height.

ParameterType
xNumeric
yNumeric
widthNumeric
heightNumeric
terrainHeightNumeric
waterHeightNumeric

room Library

Room metadata. Attach scripts, override biome, configure room properties.

room_biome [biomeName]

Overrides the room's biome. Must match a BiomeData name.

ParameterType
biomeNameText
room_define [roomId]

Begins room metadata definition. The room name must match a .wroom file.

ParameterType
roomIdText
room_end []

Finalizes room metadata and applies it to the room.

No parameters

room_music [clipName]

Sets the rooms music.

ParameterType
clipNameText
room_script [scriptPath]

Attaches a .ws script to the room. Runs when the room loads.

ParameterType
scriptPathText

sound Library

Declare sound assets for use in the game. All definitions run at bootstrap before any sound is played.

sound_define [name, type, clips, background, volume_change, pitch_change, load_async, override_mixer]

Declare a sound asset. type: effect | music | ui | local_ambience | global_ambience

ParameterType
nameText
typeText
clipsany
backgroundLogical
volume_changeNumeric
pitch_changeNumeric
load_asyncLogical
override_mixerText

save Library

Key-value save store for mod persistence. All data is scoped to the active mod.

save_clear []

Remove all keys from the current save.

No parameters

save_current_slot [] TextValue

Get the name of the currently loaded slot.

No parameters

save_delete_slot [slotName] LogicalValue

Delete a save slot from disk.

ParameterType
slotNameText
save_get [key] WarValue

Read any value by key. Returns null if key is missing.

ParameterType
keyText
save_get_bool [key, defaultValue] LogicalValue

Read a boolean value. Returns default if key is missing.

ParameterType
keyText
defaultValueLogical
save_get_float [key, defaultValue] NumericValue

Read a float value. Returns default if key is missing.

ParameterType
keyText
defaultValueNumeric
save_get_int [key, defaultValue] NumericValue

Read an integer value. Returns default if key is missing.

ParameterType
keyText
defaultValueNumeric
save_get_string [key, defaultValue] TextValue

Read a string value. Returns default if key is missing.

ParameterType
keyText
defaultValueText
save_get_table [key] ArrayValue

Read an array/table value. Returns empty array if key is missing.

ParameterType
keyText
save_has [key] LogicalValue

Check if a key exists in the current save.

ParameterType
keyText
save_list_slots [] ArrayValue

List all save slot names for the active mod.

No parameters

save_load_from_disk [slotName] LogicalValue

Load a save slot from disk into memory. Returns true if the slot was found.

ParameterType
slotNameText
save_new_slot [slotName]

Create a new empty save slot and set it as current.

ParameterType
slotNameText
save_remove [key]

Remove a key from the current save.

ParameterType
keyText
save_set [key, value]

Store any WarScript value by key.

ParameterType
keyText
valueany
save_set_bool [key, value]

Store a boolean value.

ParameterType
keyText
valueLogical
save_set_float [key, value]

Store a float value.

ParameterType
keyText
valueNumeric
save_set_int [key, value]

Store an integer value.

ParameterType
keyText
valueNumeric
save_set_string [key, value]

Store a string value.

ParameterType
keyText
valueText
save_set_table [key, value]

Store an array/table value. Supports nested arrays.

ParameterType
keyText
valueany
save_slot_exists [slotName] LogicalValue

Check if a save slot exists on disk.

ParameterType
slotNameText
save_to_disk [] LogicalValue

Write the current save data to disk. Requires a slot to be loaded or created.

No parameters

timer Library

Deterministic timers that fire WarScript callbacks. Ticked inside the lockstep simulation.

timer_create [interval, repeating, callbackName] NumericValue

Create a timer. Calls the named function when it fires. Returns a timer ID.

ParameterType
intervalNumeric
repeatingLogical
callbackNameText
timer_destroy [id] LogicalValue

Destroy a timer by ID. Safe to call from inside a timer callback.

ParameterType
idNumeric
timer_destroy_all []

Destroy all active timers.

No parameters

timer_is_active [id] LogicalValue

Check if a timer exists and hasn't been destroyed.

ParameterType
idNumeric
timer_pause [id] LogicalValue

Pause a timer. It stops counting down but isn't destroyed.

ParameterType
idNumeric
timer_remaining [id] NumericValue

Get the remaining seconds on a timer. Returns -1 if not found.

ParameterType
idNumeric
timer_resume [id] LogicalValue

Resume a paused timer.

ParameterType
idNumeric

translation Library

Translation and localization. Define translations in .ws instead of binary .wtext.

t [key, value]

Adds a translation entry (key → text) to the active translation. Call translation_create[] first.

ParameterType
keyText
valueText
translation_create [name]

Creates a new translation with the given language name. All subsequent t[] calls add entries to this translation.

ParameterType
nameText
translation_set [key, value]

Adds a translation entry (key → text) to the active translation. Verbose alias for t[].

ParameterType
keyText
valueText

map Library

Map definition. Define maps in .ws instead of binary .wmap.

map_begin [mapId, mapNameTKey]

Begins a map definition. Args: map id (used for lookup), display name translation key.

ParameterType
mapIdText
mapNameTKeyText
map_default_modifier [modifierName]

Adds a modifier applied once on map load.

ParameterType
modifierNameText
map_end []

Finalizes the current map and registers it. Must be called after map_begin[].

No parameters

map_enemy [enemyPresetName, weight]

Adds an enemy to the map's spawn table. Args: enemy preset name, weight.

ParameterType
enemyPresetNameText
weightNumeric
map_global_modifier [modifierName]

Adds a periodic global modifier by name.

ParameterType
modifierNameText
map_global_modifier_interval [interval]

Sets the global modifier tick interval in seconds (default: 1).

ParameterType
intervalNumeric
map_has_elites []

Marks the current map as having elite enemies.

No parameters

map_room [roomName]

Adds a room to the current map by name. Order determines layout.

ParameterType
roomNameText

bot Library

Bot AI definition. Create selectors, conditions, actions, and gambit brains.

bot_action_attack [target] WarValue

Issue a basic attack against the target.

ParameterType
targetany
bot_action_cast [slot, target] WarValue

Use a skill slot. 0 = special/potion, 1-4 = skills.

ParameterType
slotNumeric
targetany
bot_action_flee [from, distance] WarValue

Move away from the target until distance is reached.

ParameterType
fromany
distanceNumeric
bot_action_follow [target, stop_distance, recompute_threshold] WarValue

Follow the target, stopping within stop_distance.

ParameterType
targetany
stop_distanceNumeric
recompute_thresholdNumeric
bot_action_move_to [target, recompute_threshold] WarValue

Pathfind toward the target.

ParameterType
targetany
recompute_thresholdNumeric
bot_action_wander [radius, min_pause_ticks, max_pause_ticks] WarValue

Idle wander: mostly pause, occasionally walk to a nearby point.

ParameterType
radiusNumeric
min_pause_ticksNumeric
max_pause_ticksNumeric
bot_add_group [brain, name, trigger, gambits, min_hold_ticks]

Add a gambit group to the brain.

ParameterType
brainany
nameText
triggerany
gambitsArray
min_hold_ticksNumeric
bot_condition_always [] WarValue

Always returns true.

No parameters

bot_condition_and [a, b] WarValue

True when both conditions pass.

ParameterType
aany
bany
bot_condition_enemy_in_range [target, range] WarValue

True when the target enemy exists and is within range.

ParameterType
targetany
rangeNumeric
bot_condition_enemy_near_entity [entity, range] WarValue

True when any enemy is within range of the resolved entity (not self).

ParameterType
entityany
rangeNumeric
bot_condition_has_leader [] WarValue

True when the bot has a leader assigned.

No parameters

bot_condition_health_below [target, threshold] WarValue

True when the target's health is below the threshold (0-1).

ParameterType
targetany
thresholdNumeric
bot_condition_not [condition] WarValue

Inverts another condition.

ParameterType
conditionany
bot_condition_or [a, b] WarValue

True when either condition passes.

ParameterType
aany
bany
bot_condition_random_chance [probability] WarValue

True with the given probability (0-1) each tick.

ParameterType
probabilityNumeric
bot_condition_target_in_range [target, range] WarValue

True when any target exists, is alive, and is within range.

ParameterType
targetany
rangeNumeric
bot_gambit [condition, action, cooldown_ticks, interrupts_lock] WarValue

Create a gambit (condition + action pair).

ParameterType
conditionany
actionany
cooldown_ticksNumeric
interrupts_lockLogical
bot_new_brain [] WarValue

Create a new gambit brain builder.

No parameters

bot_selector_entity_by_id [entity_id] WarValue

Select a specific entity by instance ID.

ParameterType
entity_idNumeric
bot_selector_leader [] WarValue

Select the current leader. Returns null if no leader is set.

No parameters

bot_selector_lowest_health_ally [] WarValue

Select the allied entity with lowest health.

No parameters

bot_selector_nearest_enemy [range] WarValue

Select the nearest enemy within range.

ParameterType
rangeNumeric
bot_selector_self [] WarValue

Select the bot entity itself.

No parameters

bot_set_brain [brain]

Finalize and set the bot's gambit brain.

ParameterType
brainany

companion_config Library

Configure AI companion slots. Called during bootstrap to override inspector defaults.

companion_slot_add [scriptPath, subCompanionCount, subScript]

Add a companion slot. scriptPath is the .ws file for this bot. subCompanionCount is how many sub-bots it spawns. subScript is the .ws for sub-bots (empty string for none).

ParameterType
scriptPathText
subCompanionCountNumeric
subScriptText
companion_slot_clear []

Remove all companion slots. Call before adding new ones.

No parameters

companion_slot_count [] NumericValue

Get number of configured companion slots.

No parameters

Events

Callback functions called by the engine when implemented in your script.