Battle
The battle
object is the main interface through which the state of the running battle may be queried. The interface provides a variety of methods that can be used to interrogate and modify the battle state, chiefly access to the battle_hierarchy
from which objects battle_alliance
, battle_army
and battle_unit
objects may be derived.
Loaded in Campaign | |
Loaded in Battle | |
Loaded in Frontend |
A battle object may be created by calling empire_battle:new()
. Functions listed further down on this page may then be called on the returned battle
object in the form <object_name>:<function_name>(<args>)
.
Example:
-- creation
battle = empire_battle:new()
-- usage
if battle:is_tutorial() then
-- do tutorial stuff
end
It is strongly recommended to create and use a battle_manager
object in place of a raw battle
object. The battle_manager
interface provides much additional functionality and quality of life improvements on top of the raw battle
interface described here. Functions provided by the battle
interface may be called on a battle_manager
object - the battle manager passes the call through to the underlying battle
object if required.
Example - Create a battle manager instead of a battle object:
bm = battle_manager:new(empire_battle:new())
-
battle:out(
outputstring
)
-
Prints some output to the console. If this function is called on a
battle_manager
object then it is overridden bybattle_manager:out
, which prepends a timestamp to the output before printing it.Parameters:
1
output
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9301
-
battle:error(
messagestring
)
-
Shows an assert dialog with the supplied message.
Parameters:
1
message
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9340
-
battle:alliances()
-
Creates and returns a
battle_alliances
object listing all alliances on the battlefield.Returns:
alliances listbattle_alliances
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9356
-
battle:local_alliance()
-
Returns the index number of the
battle_alliance
that corresponds to the player on the local machine. This can be used to look up the player'sbattle_alliance
from within thebattle_alliances
collection that may be retrieved withbattle:alliances
. In any singleplayer battle this should return 1.Returns:
local alliance numbernumber
Example:
alliances = bm:alliances()
player_alliance = alliances:item(bm:local_alliance())
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9369
-
battle:local_army()
-
Returns the index number of the
battle_army
(within the relevantbattle_armies
collection object) that corresponds to the player on the local machine. This can be used to look up the player'sbattle_army
Returns:
local army numbernumber
Example:
alliances = bm:alliances()
player_alliance = alliances:item(bm:local_alliance())
player_army = player_alliance:armies():item(bm:local_army())
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9380
-
battle:is_spectator()
-
Returns whether the local game client is spectating the battle or not.
Returns:
is spectatingboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9392
-
battle:buildings()
-
Creates and returns a
battle_buildings
object listing all buildings on the battlefield.Returns:
buildings listbattle_buildings
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9401
-
battle:assault_equipment()
-
Creates and returns a
battle_assault_equipment
object listing all vehicles (such as siege towers and battering rams) on the battlefield.Returns:
assault equipment listbattle_assault_equipment
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9413
-
battle:debug_drawing()
-
Creates and returns a
battle_debug_drawing
object, allowing the script to draw debug lines on the battlefield.Returns:
debug drawing objectbattle_debug_drawing
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9426
-
battle:capture_location_manager()
-
Creates and returns a
battle_capture_location_manager
object, which can be queried to gain handles to individualbattle_capture_location
objects.Returns:
capture location managerbattle_capture_location_manager
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9438
-
battle:camera()
-
Creates and returns a
battle_camera
object.Returns:
battle camerabattle_camera
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9463
-
battle:subtitles()
-
Creates and returns a
battle_subtitles
object.Returns:
subtitlesbattle_subtitles
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9491
-
battle:reinforcements()
-
Creates and returns a
battle_reinforcements
object.Returns:
reinforcementsbattle_reinforcements
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9503
-
battle:toggle_system()
-
Creates and returns a
battle_toggle_system
objectReturns:
toggle_systembattle_toggle_system
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9517
-
battle:composite_scenes_system()
-
Creates and returns a
battle_composite_scenes_system
objectReturns:
composite scenes systembattle_composite_scenes_system
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9531
-
battle:register_input_handler(
input handler functionstring
)
-
Registers a function (by
string
name) as a handler for input events. Input events are triggered when the player makes certain inputs. Valid input events are:- "move forward"
- "move forward fast"
- "move backward"
- "move left"
- "move right"
- "rotate right"
- "rotate left"
- "move up"
- "move down"
- "rotate up"
- "rotate down"
- "edge rotate right"
- "edge rotate left"
- "edge move left"
- "edge move right"
- "edge move forward"
- "edge move backward"
When an input event occurs, the registered function is called with the relevant input event string as a single argument. Note that the function being registered must have already been declared whenregister_input_handler
is called.
Once registered, an input handler may be unregistered withbattle:unregister_input_handler
.Parameters:
1
input handler function
Returns:
nil
Example:
function my_input_handler(event_name)
if event_name == "move_forward" then
-- do something in response to the move_forward event
end
end
bm:register_input_handler("my_input_handler")
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9549
-
battle:unregister_input_handler()
-
Unregisters the currently-registered input handler function. An input handler may be registered with
battle:register_input_handler
.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9583
-
battle:register_unit_selection_handler(
input handler functionstring
)
-
Registers a function (by
string
name) as a handler for user selection events. These events are triggered when the player selects or deselects units. When such an event occurs, the registered function is called with two arguments - the first being abattle_unit
object representing the unit concerned, the second being aboolean
flag indicating whether the unit is being selected or deselected. Note that the function being registered must have already been declared whenregister_unit_selection_handler
is called.Parameters:
1
input handler function
Returns:
nil
Example:
function my_unit_selection_handler(unit, is_selected)
if is_selected then
-- track selected units
else
-- track unselected units
end
end
bm:register_unit_selection_handler("my_unit_selection_handler")
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9591
-
battle:unregister_unit_selection_handler()
-
Unregisters the currently-registered unit selection handler function. A unit selection handler may be registered with
battle:register_unit_selection_handler
.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9608
-
battle:register_command_handler(
command handler functionstring
)
-
Registers a function (by
string
name) as a handler for command events. Command events are triggered when the player (or script) issues certain commands. When such an event occurs, the registered function is called and passed anevent
object as a single argument. This object provides several methods which can be used to determine information about the issued command. These methods are listed below:
Note that each event type only provides methods that are relevant. The list of valid event types, and what methods they provide, are listed here:Method Description
event:get_name()
Returns the string
name of the issued command. This is provided for every event type.event:get_bool1()
Returns a boolean
value related to the issued command, if any.event:get_string1()
Returns a string
value related to the issued command, if any.event:get_position()
Returns a battle_vector
related to the issued command, if any.event:get_unit()
Returns a battle_unit
related to the issued command, if any.event:get_building()
Returns a battle_building
related to the issued command, if any.
Note that the function being registered must have already been declared whenEvent Type Event Description Method Provided Method Return Type Method Description
Group Created
A group has been created event:get_name()
string
Name of event Group Destroyed
A group has been disbanded event:get_name()
string
Name of event Repair Mode
A command to repair a ship has been issued event:get_name()
string
Name of event Move
A movement command has been issued event:get_name()
string
Name of event event:get_bool1()
boolean
Indicates whether the unit is now moving fast/running Move Orientation Width
A movement command with orientation and width has been issued event:get_name()
string
Name of event Move Rotation Angle
A rotation command has been issued event:get_name()
string
Name of event Change Speed
The speed of a unit has been toggled event:get_name()
string
Name of event event:get_bool1()
boolean
Indicates whether the unit is now moving fast/running Attack Unit
A command to attack a unit has been issued event:get_name()
string
Name of event event:get_bool1()
boolean
Indicates whether the unit is now moving fast/running event:get_unit()
battle_unit
Returns the target unit Change Skirmish
Skirmish mode has been toggled on a unit event:get_name()
string
Name of event event:get_bool1()
boolean
Indicates whether skirmish mode is now enabled Change Melee
Melee mode has been toggled on a unit event:get_name()
string
Name of event event:get_bool1()
boolean
Indicates whether melee mode is now enabled Change Formation
A command to change formation has been issued event:get_name()
string
Name of event event:get_string1()
string
Returns the name of the formation Attack Building
A command to attack a building has been issued event:get_name()
string
Name of event event:get_bool1()
boolean
Indicates whether the unit is now moving fast/running event:get_building()
battle_building
Returns the target building Climb/Dock Building
A command to climb a building has been issued event:get_name()
string
Name of event event:get_bool1()
boolean
Indicates whether the unit is now moving fast/running event:get_building()
battle_building
Returns the target building Special Ability
A command to use a special ability has been issued event:get_name()
string
Name of event event:get_string1()
string
Returns the name of the special ability Shot Type
A command to change shot type has been issued event:get_name()
string
Name of event event:get_string1()
string
Returns the name of the shot type Fire At Will
Fire-at-will mode has been toggled on a unit event:get_name()
string
Name of event Broadside Attack
A broadside attack command has been issued event:get_name()
string
Name of event event:get_bool1()
boolean
Returns true
if the broadside is on the left side of the ship,false
otherwiseNaval Shot Type
A command to change the shot type of a ship has been issued event:get_name()
string
Name of event event:get_string1()
string
Returns the name of the shot type Ram
A command to ram a ship has been issued event:get_name()
string
Name of event Withdraw
A command to withdraw a unit has been issued event:get_name()
string
Name of event event:get_bool1()
boolean
Indicates whether the unit is now moving fast/running Halt
A command to halt a unit has been issued event:get_name()
string
Name of event Double Click
The double-click UI gesture has been issued for the selected units event:get_name()
string
Name of event Entity Hit
A unit has been hit by a projectile event:get_name()
string
Name of event event:get_bool1()
boolean
Indicates whether artillery fired the projectile event:get_unit()
battle_unit
Returns the unit that was hit Double Click Unit Card
A unit card has been double-clicked upon event:get_name()
string
Name of event event:get_unit()
battle_unit
Returns the subject unit Unit Left Battlefield
A unit has left the battlefield event:get_name()
string
Name of event event:get_unit()
battle_unit
Returns the subject unit Battle Results
The battle has finished and the results have been issued event:get_name()
string
Name of event event:get_bool1()
boolean
Indicates whether the local alliance won the battle register_command_handler
is called.Parameters:
1
command handler function
Returns:
nil
Example:
function my_command_handler(event)
local event_name = event:get_name()
if event_name == "Move" then
-- handle move orders
elseif event_name == "Attack Unit" then
-- handle attack unit orders
end
end
bm:register_command_handler("my_command_handler")
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9616
-
battle:unregister_command_handler()
-
Unregisters the currently-registered command handler function. A command handler may be registered with
battle:register_command_handler
.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9673
-
battle:register_battle_phase_handler(
function namestring
)
-
Registers a function (by
string
name) as a handler for battle phase changes. Battle phase changes are triggered when the battle moves into various distinct phases, the most important being thedeployment
anddeployment
(combat) phases. When a battle phase occurs, the registered function is called and passed thestring
name of the new battle phase as a single argument. Valid phases are listed below:
Note that the function being registered must have already been declared whenPhase Name Description
Startup
This phase change is triggered after the scripts are loaded. PrebattleWeather
Triggered after Startup
phase.PrebattleCinematic
Triggered after PrebattleWeather
phase.Deployment
Deployment phase, when both alliances get to position their troops prior to combat. Deployed
Combat phase, in which the battle is fought. VictoryCountdown
A victor for the battle has been determined, and the battle is counting down to completion. Complete
The battle is completed. register_unit_selection_handler
is called. Furthermore, it is recommended thatbattle_manager:register_phase_change_callback
is used in place of this function.Parameters:
1
Function name to call when phase change event occurs.
Returns:
nil
Example:
function my_phase_change_handler(phase_change)
local
if phase_change == "deployment" then
-- handle deployment phase
elseif phase_change == "deployed" then
-- handle combat phase
end
end
bm:register_phase_change_handler("my_phase_change_handler")
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9681
-
battle:unregister_battle_phase_handler()
-
Unregisters the currently-registered phase change handler function. A phase change handler may be registered with
battle:register_battle_phase_handler
.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9708
-
battle:end_current_battle_phase()
-
Immediately ends the current battle phase, moving on to the next phase. The main use for this function is to force deployment phase to end - calling this function has no effect in combat phase. More information about battle phases can be found in the
Battle Phases
section of this documentation.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9716
The functions in this section describe the raw interface to the model timer system provided in battle to script. It's strongly recommended that client scripts make use of the functionality provided by the timer_manager
(and exposed through the battle_manager
- see the Timer Callbacks
section of this documentation), rather than calling battle:register_singleshot_timer
, battle:register_repeating_timer
or battle:unregister_timer
functions directly.
-
battle:timer_exists(
function namestring
)
-
Returns whether a timer exists for the specified function name. If a timer does exist, the amount of model time remaining before it triggers in ms is also returned as a second return parameter.
Parameters:
1
function name
Returns:
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9728
-
battle:register_singleshot_timer(
function namestring
,
intervalnumber
)
-
Registers a singleshot timer. A function name must be specified as a
string
, along with an interval. The battle model then calls the function with the given name after the specified interval. No arguments may be specified for the function. Only one timer instance can be registered for a given function - repeated calls tobattle:register_singleshot_timer
orbattle:register_repeating_timer
will overwrite any previous timers.
It is strongly recommended that client scripts do not call this directly but instead use thebattle_manager:callback
function, which allows arguments to be passed, multiple instances of timers for the same callback, and more flexible cancellation of the callback.Parameters:
1
Function name.
2
Interval in ms.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9739
-
battle:register_repeating_timer(
function namestring
,
intervalnumber
)
-
Registers a repeating timer. A function name must be specified as a
string
, along with an interval. The battle model then calls the function with the given name each time the specified interval elapses. No arguments may be specified for the function. Only one timer instance can be registered for a given function. Only one timer instance can be registered for a given function - repeated calls tobattle:register_singleshot_timer
orbattle:register_repeating_timer
will overwrite any previous timers.
It is strongly recommended that client scripts do not call this directly but instead use thebattle_manager:repeat_callback
function, which allows arguments to be passed, multiple instances of timers for the same callback, and more flexible cancellation of the callback.Parameters:
1
Function name.
2
Interval in ms.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9750
-
battle:unregister_timer(
function namestring
)
-
Unegisters a timer (whether registered with
battle:register_singleshot_timer
orbattle:register_repeating_timer
), by it'sstring
function name. In the case of a singleshot function this must be called before the function is triggered.
It is strongly recommended that client scripts usebattle_manager:callback
,battle_manager:repeat_callback
and thenbattle_manager:remove_process
due to ease-of-use.Parameters:
1
Function name to unregister.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9761
-
battle:time_elapsed_ms()
-
Returns the amount of model time that's elapsed since the start of the battle, in milliseconds.
Returns:
time elapsednumber
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9771
-
battle:model_tick_time_ms()
-
Returns the model tick time in milliseconds. This is the target interval over which the battle model repeatedly updates - 100ms or 200ms.
Returns:
tick timenumber
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9780
-
battle:remaining_conflict_time()
-
Returns the duration remaining before the battle time limit expires, in seconds. If no time limit is set then -1 is returned.
Returns:
remaining timenumber
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9789
-
battle:modify_battle_speed(
battle speednumber
)
-
Adjusts the game speed. The value supplied should be a unary proportion of normal speed, for example:
- Set a speed of
1
to run the battle at normal speed. - Set a speed of
3
to run the battle at triple speed. - Set a speed of
0.5
to run the battle at half speed. - Set a speed of
0
to pause the battle.
Beware that pausing the battle will prevent model time from advancing, which will also affect script.
The battle speed may be restored to the value previously set by the player by callingbattle:restore_battle_speed
.Parameters:
1
battle speed
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9798
- Set a speed of
-
battle:current_battle_speed()
-
Returns the current game speed.
Returns:
battle speednumber
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9813
-
battle:restore_battle_speed()
-
Restores the game speed to the value that was previously set when
battle:modify_battle_speed
was last called.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9822
-
battle:change_conflict_time_update_overridden(
disable updateboolean
)
-
Enables or disables the countdown of the conflict timer. Call with an argument of
true
to disable the countdown of the conflict timer, orfalse
to enable it again. With conflict time update overridden, time can pass but the victory timer will not count down.Parameters:
1
disable update
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9830
-
battle:change_victory_countdown_limit(
time limitnumber
)
-
Change the victory countdown limit. This is the grace period that begins counting down once a victor in the battle has been determined but before the battle actually ends, and is usually ten seconds. Battle scripts can use this function to adjust the duration of this countdown in order to display outro advice or cutscene content without having it cut off.
Supply a limit of less than 0 to make the victory countdown period infinite. If the battle enters the victory countdown phase with an infinite period set, and then a limit of 0 is set with a subsequent call to this function, the battle complete phase will trigger immediately.Parameters:
1
Time limit in seconds.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9839
-
battle:force_cant_chase_down_routers()
-
Force battle end to not wait for chasing routers
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9848
-
battle:cindy_preload(
scene pathstring
)
-
Preloads a cindy scene. Calling this prior to a cindy scene being played can help prevent a noticeable stall at the start of playback.
Parameters:
1
Path to the cindy scene manager file, from the working data folder.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9858
-
battle:cindy_playback(
scene pathstring
, [
blend innumber
], [
blend outnumber
])
-
Starts a cindy scene. This plays a cindy cinematic, taking control of the camera.
battle:cindy_preload
can be called prior to calling this function to preload the scene data.Parameters:
1
Path to the cindy scene manager file, from the working data folder.
2
optional, default value=0
Blend in duration in seconds.
3
optional, default value=10
Blend out duration in seconds.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9867
-
battle:cindy_playback_no_camera(
scene pathstring
,
clear sceneboolean
, [
save to replayboolean
])
-
Starts a cindy scene without a camera track. This can be run in parallel with a scene initiated with
battle:cindy_playback
.battle:cindy_preload
can be called prior to calling this function to preload the scene data.Parameters:
1
Path to the cindy scene manager file, from the working data folder.
2
Clear animated scenes on completion.
3
optional, default value=true
Saves the cindy scene into the battle replay, so if the replay is loaded the cindy scene plays again.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9878
-
battle:stop_cindy_playback([
clear animated scenesboolean
])
-
Stops a cindy scene that was started with
battle:cindy_playback
.Parameters:
1
optional, default value=false
clear animated scenes
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9889
-
battle:stop_cindy_playback_no_camera([
clear animated scenesboolean
])
-
Stops a cindy scene that was started with
battle:cindy_playback_no_camera
.Parameters:
1
optional, default value=false
clear animated scenes
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9898
-
battle:start_terrain_composite_scene(
scene keystring
)
-
Starts a composite scene. The composite scene should be specified by its path from the working data folder.
Parameters:
1
Composite scene key.
Returns:
nil
Example:
bm:start_terrain_composite_scene("composite_scene/seamonster/merwyrm_roar_02.csc")
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9907
-
battle:stop_terrain_composite_scene(
scene keystring
)
-
Stops a composite scene. The composite scene should be specified by its path from the working data folder.
Parameters:
1
Composite scene key.
Returns:
nil
Example:
bm:stop_terrain_composite_scene("composite_scene/seamonster/merwyrm_roar_02.csc")
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9917
-
battle:play_adc(
adc keystring
,
xnumber
,
ynumber
,
znumber
,
for playerboolean
)
-
Manually triggers an aide-de-camp message at a specified location on the battlefield.
Parameters:
1
Aide-de-camp key, from the
aide_de_camp_speeches
database table.2
X co-ordinate of message, in m.
3
Y co-ordinate (altitude) of message, in m.
4
Z co-ordinate of message, in m.
5
Aide-de-camp message is for the player's alliance.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9940
-
battle:suspend_contextual_advice(
should suspendboolean
)
-
Prevents advice from being triggered with
common.advance_contextual_advice_thread
, which has the effect of suspending advice not triggered deliberately by battle scripts. This has been made largely redundant by changes in the way scripts trigger advice, but can still be called.Parameters:
1
should suspend
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9953
-
battle:close_advisor()
-
Dismisses the advisor, if currently shown.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9962
-
battle:advice_finished()
-
Returns whether or not any advice is currently playing. A value of
true
is returned if no advice is playing,false
if it is.Returns:
advice finishedboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9970
-
battle:vo_finished()
-
Returns whether or not any voiceover sounds are currently playing. A value of
true
is returned if no voiceover sounds are playing,false
otherwise.Returns:
vo finishedboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9979
-
battle:suppress_unit_voices(
should suppressboolean
)
-
Disables or re-enables unit voices in battle. If unit voices are suppressed, ambient voiceover related to units will not be played.
Parameters:
1
should suppress
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 9989
-
battle:suppress_unit_musicians(
should suppressboolean
)
-
Disables or re-enables unit musicians in battle.
Parameters:
1
should suppress
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10005
-
battle:play_music(
music namestring
)
-
Plays a specified piece of music. The music to play is specified by its sound event name.
Parameters:
1
music name
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10014
-
battle:play_music_custom_fade(
music namestring
,
fade timenumber
)
-
Plays a specified piece of music with a custom fade-in duration. The music to play is specified by its sound event name.
Parameters:
1
Music sound event.
2
Fade time in seconds.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10023
-
battle:stop_music(
skippedboolean
)
-
Stops the currently-playing music.
Parameters:
1
whether this stop was because of a skipped cutscene
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10033
-
battle:stop_music_custom_fade(
skippedboolean
,
fade timenumber
)
-
Stops the currently-playing music with a custom fade time.
Parameters:
1
whether this stop was because of a skipped cutscene
2
Fade time in seconds.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10042
-
battle:get_volume(
volume typenumber
)
-
Gets the volume level of a specific volume type. Valid volume types are given in the
Volume Types
section of this documentation. The volume level will be returned as a number between 0 (inaudible) and 100 (full volume).Parameters:
1
volume type
Returns:
volume levelnumber
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10059
-
battle:set_volume(
volume typenumber
,
volume levelnumber
)
-
Sets the volume level of a specific volume type. Valid volume types are given in the
Volume Types
section of this documentation. The volume level should be set as a number between 0 (inaudible) and 100 (full volume).Parameters:
1
volume type
2
volume level
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10069
-
battle:fade_volume(
volume typenumber
,
target levelnumber
,
fade timenumber
)
-
Gradually fades the volume level of a specified volume type to a specified value over a specified interval. Valid volume types are given in the
Volume Types
section of this documentation. The volume level should be set as a number between 0 (inaudible) and 100 (full volume).Parameters:
1
Volume type.
2
Target volume level.
3
Fade time in seconds.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10079
-
battle:set_music_vm_variable(
variable name
string
,
or
boolean
string
ornumber
The value to set the target variable to
) -
Sets the value of the given music vm variable, this can be read by the battle music script
Parameters:
1
variable name
2
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10090
-
battle:add_ping_icon(
xnumber
,
ynumber
,
xnumber
, [
typenumber
], [
is waypointboolean
], [
rotationnumber
])
-
Adds a 3d ping marker model at a specified [x/y/z] position. It is sufficient just to supply the position, but a type can be used to change the model displayed - see the table below for a list of ping types.
List of ping types:
Type Number Type Name 0 MPT_NONE 1 MPT_STANDARD 2 MPT_MOVE 3 MPT_ATTACK 4 MPT_DEFEND 5 MPT_HELP_MOUNTABLE_ARTILLERY 6 MPT_HELP_DISEMBARK 7 MPT_NOTIFICATION 8 MPT_SCRIPT_LOOK_AT 9 MPT_SCRIPT_MOVE_TO 10 MPT_SCRIPT_SELECT 11 MPT_SCRIPT_POINTER 12 MPT_SCRIPT_LOOK_AT_VFX 13 MPT_SCRIPT_MOVE_TO_VFX 14 MPT_SCRIPT_SELECT_VFX 15 MPT_SCRIPT_OBJECTIVE The waypoint flag can be used to link models together. The rotation flag can be used to specify a rotation for the model - the default is to just fade the camera.16 MPT_SCRIPT_BATTLE_TRAP Parameters:
1
X co-ordinate in metres.
2
Y co-ordinate (altitude) in metres. This parameter specifies the height above the water plane, so if mis-set the marker can appear under the ground.
3
X co-ordinate in metres.
4
optional, default value=0
Marker type - see list of valid marker types above.
5
optional, default value=false
Is waypoint.
6
optional, default value=nil
Rotation.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10103
-
battle:remove_ping_icon(
xnumber
,
ynumber
,
xnumber
)
-
Removes the ping marker that was previously added with
battle:add_ping_icon
at a specified [x/y/z] position.Parameters:
1
X co-ordinate in metres.
2
Y co-ordinate (altitude) in metres.
3
X co-ordinate in metres.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10137
-
battle:show_objective(
objective keystring
,
durationnumber
,
fade durationnumber
)
-
Shows an objective message on-screen. This is an old method of showing an objective-style message, which will fade in at the bottom-centre of the screen, remain on-screen for a specified period and then fade out.
Parameters:
1
Objective key, from the
scripted_objectives
table.2
Duration that the objective should remain on-screen in ms.
3
Duration over which the objective should fade to transparent once its display duration has elapsed.
Returns:
nil
Example - Show an objective key for 5 seconds, then fading out over 2 seconds.:
bm:show_objective("my_objective_key", 5000, 2000)
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10148
-
battle:add_animated_arrow(
animation timenumber
,
remain timenumber
,
loopboolean
, ...
positions)
-
Adds an animated arrow on the terrain that can be used to indicate a path for the player. The arrow will animate between two or four supplied
battle_vector
positions.
The function returns a numeric index for the animated arrow. If necessary, this can be used to remove the arrow withbattle:remove_animated_arrow
.Parameters:
1
Time over which the arrow animation should play, in seconds.
2
Time for which the arrow should remain after its animation has finished, in seconds.
3
Sets whether the animation should loop indefinitely. If this is set then
battle:remove_animated_arrow
is the only method of removing the arrow.4
...
Two or four
battle_vector
positions can specified as co-ordinates through which the arrow animates.Returns:
arrow indexnumber
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10161
-
battle:remove_animated_arrow(
arrow indexnumber
)
-
Removes an animated arrow previously added with
battle:add_animated_arrow
. The arrow to remove is specified by the numeric index returned byadd_animated_arrow
.Parameters:
1
arrow index
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10175
-
battle:play_movie(
movie pathstring
,
play movie audioboolean
)
-
Plays a fullscreen movie during a battle. The movie should be specified by a file path from the
Movies
folder in working data (see thevideos
table for examples of valid paths).Parameters:
1
Path to movie file. The file extension may be omitted.
2
Play movie audio - if
false
is supplied then game audio is heard instead.Returns:
nil
Example:
bm:play_movie("startup_movie_01", true)
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10187
-
battle:is_movie_playing()
-
Returns whether or not a fullscreen movie is currently playing.
Returns:
is movie playingboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10198
-
battle:ui_component(
uicomponent namestring
)
-
Searches from the root uicomponent for a uicomponent with the specified name, returning the first that matches. It is encouraged that
find_uicomponent
is used in place of this function.Parameters:
1
uicomponent name
Returns:
uicomponent, oruicomponent
nil
if no component found
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10210
-
battle:enable_cinematic_ui(
enable cinematic ui
boolean
,
show cursor
[boolean
],
enable cinematic bars
[boolean
]
) -
Enables or disables a script lock on the state of the cinematic UI. Additional parameters may be used to enable/disable the mouse cursor and cinematic bars respectively.
Note that it is rare for clients scripts to need to call this directly - consider using thecutscene
functionality provided by the script libraries.Parameters:
1
Enable or disables the script lock on the cinematic UI. By setting this, the script will lock the state of the cinematic UI (whether the cursor is shown, or the cinematic bars are visible). If this is set the wider UI will not be able to show/unshow the cursor or cinematic bars until the lock is disabled again.
2
optional, default value=nil
Shows or hides the cursor. If this flag is not supplied then the state of the cursor will remain unchanged.
3
optional, default value=nil
Enables the cinematic bars. If this flag is not supplied then the state of the cinematic bars will remain unchanged.
Returns:
nil
Example - Enable the cinematic UI, disabling the mouse cursor and showing cinematic borders:
By enabling the cinematic UI with the first argument, the UI will know not to re-enable the mouse cursor or hide the cinematic borders.bm:enable_cinematic_ui(true, false, true)
Example - Disable the cinematic UI, re-enable the mouse and hide the cinematic borders afterwards:
bm:enable_cinematic_ui(false, true, false)
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10220
-
battle:enable_unit_ids(
show idsboolean
)
-
Enables or disables the unit IDs - the flags or icons floating above each unit in battle. This provides exactly the same functionality as
battle:set_banners_enabled
, except the removal/reinstatement of banners in this case will be preserved in replays.
Note that thecutscene
functionality provided by the script libraries automatically disables unit ids while the cutscene is playing - usecutscene:set_should_disable_unit_ids
to disable this for a given cutscene rather than calling this function directly.Parameters:
1
show ids
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10237
-
battle:enable_cinematic_camera(
enable cinematic cameraboolean
)
-
Enables or disables the cinematic camera. The cinematic camera is not limited by altitude or proximity to the player's army - it can be positioned anywhere on the battlefield, including below the ground. This can be enabled for cutscenes but should be disabled for live gameplay.
Note that it is rare for clients scripts to need to call this directly - consider using thecutscene
functionality provided by the script libraries. A cutscene can be prevented from enabling the cinematic camera withcutscene:set_should_enable_cinematic_camera
.Parameters:
1
enable cinematic camera
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10247
-
battle:enable_tooltips(
enable tooltipsboolean
)
-
Enables or disables tooltips.
Parameters:
1
enable tooltips
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10257
-
battle:force_minimised_tooltips(
set minimised tooltipsboolean
)
-
Forces tooltips into minimised mode.
Parameters:
1
set minimised tooltips
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10266
-
battle:disable_groups(
disable groupingboolean
)
-
Disables or enables grouping functionality.
Parameters:
1
disable grouping
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10275
-
battle:disable_formations(
disable formationsboolean
)
-
Disables or enables formations functionality.
Parameters:
1
disable formations
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10284
-
battle:disable_orders(
disable ordersboolean
)
-
Disables or enables the giving of any orders at all.
Parameters:
1
disable orders
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10293
-
battle:steal_escape_key()
-
Steals the escape key from the UI. This prevents the UI from intercepting ESC key presses and allows script to detect and process them instead. When the escape key is stolen, a script function called
Esc_Key_Pressed
will be called when the escape key is pressed by the player.
Note that the escape key will remain stolen from the UI untilbattle:release_escape_key
is called.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10302
-
battle:release_escape_key()
-
Releases the stolen escape key from the script, allows the UI to intercepting ESC key presses again. This must be called at some point after
battle:steal_escape_key
is called.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10311
-
battle:steal_input_focus()
-
Steals all keyboard input from the UI, effectively disabling the keyboard in the game. After input focus is stolen by a call to this function, it must be released again with
battle:release_input_focus
at some point.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10319
-
battle:release_input_focus()
-
Releases keyboard input back to the UI after its theft with
battle:steal_input_focus
.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10327
-
battle:disable_shortcut(
shortcut namestring
,
should disableboolean
)
-
Disables or re-enables a keyboard shortcut by name. A list of keyboard shortcuts is available from the UI team.
Parameters:
1
shortcut name
2
should disable
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10335
-
battle:set_banners_enabled(
show idsboolean
)
-
Enables or disables the unit IDs - the flags or icons floating above each unit in battle. This provides exactly the same functionality as
battle:enable_unit_ids
, except the removal/reinstatement of banners in this case will be not preserved in replays.
Note that thecutscene
functionality provided by the script libraries automatically disables unit ids while the cutscene is playing - usecutscene:set_should_disable_unit_ids
to disable this for a given cutscene rather than calling this function directly.Parameters:
1
show ids
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10345
-
battle:is_replay()
-
Returns whether this battle is a replay.
Returns:
is replayboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10358
-
battle:is_tutorial()
-
Returns the value of the
is_tutorial
flag. This can be set in the battle setup to activate certain behaviours.Returns:
is_tutorial flagboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10367
-
battle:is_multiplayer()
-
Returns whether this battle is running in multiplayer mode.
Returns:
is multiplayerboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10376
-
battle:is_from_campaign()
-
Returns whether this is a battle fought from campaign.
Returns:
is from campaignboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10385
-
battle:is_quest_battle()
-
Returns whether this battle is a quest battle.
Returns:
is quest battleboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10394
-
battle:prepare_for_fade_in()
-
Returns the value of the
prepare_for_fade_in
flag. This can be set in the battle setup to show a black screen when the battle starts up.Returns:
prepare_for_fade_in flagboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10403
-
battle:battle_outcome_decided()
-
Returns whether a victor has been decided in the battle, or whether the battle has been determined to be a draw. This happens when the
VictoryCountdown
phase change occurs.Returns:
outcome decidedboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10412
-
battle:victorious_alliance()
-
Returns the id of the alliance which has won the battle. If battle results are not finalised then
0
is returned. If the battle result is drawn then-1
is returned.Returns:
alliance idnumber
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10421
-
battle:is_draw()
-
Returns
true
if the battle result has been finalised and is a draw, orfalse
otherwise.Returns:
is drawboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10430
-
battle:is_siege_battle()
-
Returns whether or not the battle is a siege battle.
Returns:
is siege battleboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10439
-
battle:is_ambush_battle()
-
Returns whether or not the battle is an ambush battle.
Returns:
is ambush battleboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10448
-
battle:is_storm_of_magic_battle()
-
Returns whether this is a storm of magic battle.
Returns:
is storm of magic battleboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10457
-
battle:battle_type()
-
Returns the battle type as a string.
Returns:
battle typestring
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10466
-
battle:unit_scale_factor()
-
Returns the unit scale factor as a multiplier. The value returned is a multiplier of the unit size if the scale is set to ultra, so the multiplier should be greater than 0 and less than or equal to 1.
Returns:
unit scale factornumber
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10475
-
battle:unit_scale_factor_index()
-
Returns the unit scale factor index. This is
0
for small unit sizes,1
for normal unit sizes,2
for large unit sizes and3
for ultra unit sizes.Returns:
unit scale factor indexnumber
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10484
-
battle:get_terrain_height(
xnumber
,
ynumber
)
-
Returns the height of the terrain at the specified x/y co-ordinates. This is intended for use to calculate camera and ping marker positions.
Parameters:
1
X co-ordinate in m.
2
Y co-ordinate in m.
Returns:
height in m.number
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10493
-
battle:is_area_clear(
positionbattle_vector
,
bearingnumber
,
widthnumber
,
depthnumber
, [
is navalboolean
])
-
Returns whether an area is clear of pathfinding restrictions. The area is specified by a position, a bearing, and the width/depth of a bounding box centred at that position and drawn at that bearing.
Parameters:
1
Position.
2
Bearing in degrees.
3
Width of oriented-bounding box in metres.
4
Depth of oriented-bounding box in metres.
5
optional, default value=false
Is the area on sea.
Returns:
area is clearboolean
Example:
-- Checks if an area of 40m x 60m is clear of pathfinding restrictions.
-- The source position is [100, 100] and the area is drawn at a bearing of 90 degrees (i.e. east).
-- The corners of the area being checked would be at [70, 120], [130, 120], [130, 80], [70, 80]
return bm:is_area_clear(v(100, 100), 90, 40, 60);
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10504
-
battle:ground_type(
positionbattle_vector
)
-
Returns the ground type at a supplied position.
Parameters:
1
position
Returns:
ground typestring
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10522
-
battle:random_number()
-
Generate a battle-synchronised random number between 0 and 1.
Returns:
random numbernumber
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10532
-
battle:is_benchmarking_mode()
-
Returns whether this battle has been loaded in benchmarking mode or not. This should only return
true
if the battle was loaded through the benchmark menu on the frontend.Returns:
is benchmarking modeboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10544
-
battle:end_benchmark()
-
Ends a currently-running benchmark, showing benchmarking statistics and ending the battle.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10553
-
battle:quit_to_windows_from_script()
-
Causes the game to completely shut down.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10561
-
battle:appdata_screenshots()
-
Returns a path to the screenshots directory. This is used by the autotest system.
Returns:
screenshot directorystring
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10569
-
battle:set_stat_attribute(
attribute keystring
,
enable/disableboolean
)
-
Enables or disables a unit attribute for all units on the battlefield. Attribute keys are listed in the
Unit Attributes
section of this documentation.Parameters:
1
attribute key
2
enable/disable
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10591
-
battle:set_special_abilities_flags(
flag keystring
,
enable/disableboolean
)
-
Activates or deactivates a special ability flag for all units on the battlefield. Valid special ability flags are listed in the
Special Ability Flags
section of this documentation.Parameters:
1
flag key
2
enable/disable
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10614
-
battle:disable_all_abilities()
-
Disable all abilities on the battle
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10637
-
battle:enable_all_abilities()
-
Disable all abilities on the battle
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10643
-
battle:notify_survival_started()
-
Notifies the game that a survival battle has started.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10654
-
battle:notify_survival_total_waves(
total number of waves.number
)
-
Notifies the game how many total waves there are in a survival battle.
Parameters:
1
total number of waves.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10661
-
battle:notify_wave_state_changed(
wave indexnumber
,
new statestring
,
is final waveboolean
)
-
Instructs the game that a survival battle wave has changed state. This function is used to create a new survival battle wave, or update the state of an existing wave. Waves are specified a numeric index, starting from
0
- if a wave index is specified that the system has not seen before, then a new wave is started.
A survival battle wave can occupy one of three states -incoming
,in_progress
ordefeated
. The new state of the wave must be specified as a string.Parameters:
1
Index of survival battle wave to update (or create, if index has not been used before).
2
New state of survival battle wave, either
incoming
,in_progress
ordefeated
.3
Is this wave the final wave in the battle.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10669
-
battle:notify_wave_units_changed(
wave indexnumber
,
new statestring
,
is final waveboolean
)
-
Instructs the game that a survival battle wave unit composition has been changed on a specific wave id.
A survival battle wave can occupy one of three states -incoming
,in_progress
ordefeated
. The new state of the wave must be specified as a string.Parameters:
1
Index of survival battle wave to update (or create, if index has not been used before).
2
New state of survival battle wave, either
incoming
,in_progress
ordefeated
.3
Is this wave the final wave in the battle.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10680
-
battle:notify_wave_progress_changed(
wave indexnumber
,
progressnumber
)
-
Updates the progress bar on the UI of the specified survival battle wave. This gives the player an indication of how far through the wave they are.
Parameters:
1
Index of survival battle wave to update. This should match the index of the wave previously specified to
battle:notify_wave_state_changed
.2
Progress of the survival battle wave, specified as a unary (0-1) value.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10691
-
battle:notify_survival_completion()
-
Notifies the game that all survival battle waves are completed. This informs battle victory conditions related to survival battle waves that the survival battle has been successfully completed.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10701
-
battle:force_battle_end(
winning alliance number
number
,
reason
string
,
immediate
[boolean
],
force winner
[boolean
]
) -
Ends the battle in favour of one side or the other. A draw may also be specified.
A reason string must be specified from the following list:
none
timeout
kill_or_rout
kill_enemy
capture_settlement
capture_locations
sink_or_surrender_fleet
autoresolve
surrender
mp_disconnected
scripted
capture_baggage_train
avatar_autoresolve
mp_insufficient_human_players
scored_resoultion
tug_of_war
capture_location_score
wave_completion
capture_tickets
kill_or_rout_ignore_reinforcements
kill_or_rout_no_support_available
decision
Parameters:
1
Winning alliance number. If
0
is supplied then the battle will end as a draw.2
Reason why the battle is ending - see list above.
3
optional, default value=true
End the battle immediately. If
false
the battle will end in the next conflict phase update.4
optional, default value=true
Force the winning alliance value. If
false
is supplied the winning alliance will only be set if the battle has not already decided on a victor.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10715
-
battle:force_custom_battle_result(
result keystring
,
for winnerboolean
)
-
Forces a particular result for the battle being fought, for either the winner or the loser of the battle.
Parameters:
1
Result key, from the
battle_result_types
database table.2
Is the result for the battle winner - supply
false
to apply the result for the loser instead.Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10750
-
battle:trigger_projectile_launch(
projectile key
string
,
launch position
battle_vector
,
target position
battle_vector
) -
Trigger a projectile launch from one position to another. Be careful to shoot downwards if you have artillery projectiles, as they are designed to be lobbed.
Parameters:
1
Projectile key from the
projectiles
table.2
Launch position.
3
Target position.
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10766
-
battle:unlock_achievement(
achievement keystring
)
-
Unlocks a steam achievement by string key. Achievements have to be set up elsewhere to be unlockable with this function.
Parameters:
1
achievement key
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10777
-
battle:output_battle_xml(
filenamestring
)
-
Writes out a battle xml file with the supplied filename containing the current battle setup. This can be useful for creating scripted battles.
Parameters:
1
filename
Returns:
operation succeededboolean
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10786
-
battle:save_unit_pair_balance_data(
unit_1battle_unit
,
unit_2battle_unit
,
engagement_winnernumber
)
-
Called by the unit balance tests. Saves the unit pair battle statistics and stats in DBLOG. (text file or SQL database depending of build the configuration.
Parameters:
1
unit_1
2
unit_2
3
Alliance of the winner of this engagement, 0 to draw
Returns:
nil
defined in ../../common/EmpireBattle/Source/BattleScript/BattleEditorScriptInterface.cpp, line 10795