Scripted Tour Helpers
This interface provides a list of functions to empower scripted tour mechanics in battle.
| Loaded in Campaign | 
										 | 
								
| Loaded in Battle | 
										 | 
								
| Loaded in Frontend | 
										 | 
								
- 
							
st_helper.automatic_nts_advancement_monitor(the tour that is supposed to use that function.
navigable_tour,Unary hitpoints treshold that will trigger next section
number,an amount of time that the watcher will wait before triggering the next stage
[number],filter function
[function]
) - 
							Returns a 
booleanresult depending on if conditions for advancing the tour are met.
When the function is called, it will trigger a watch for wheter any army is routed or shattered or they have reached their hitpoint threshold.
This function must always have a corresponding call tofunctionstop_automatic_nts_advancement_monitor()Parameters:
1
the tour that is supposed to use that function.
2
Unary hitpoints treshold that will trigger next section
3
optional, default value=0
an amount of time that the watcher will wait before triggering the next stage
4
optional, default value=false
Filter function. This should take a
battle_buildingobject as a single argument and return a boolean result.Returns:
has the conditions for the automatic advancement been metboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 36
 
- 
							
st_helper.stop_automatic_nts_advancement_monitor() - 
							Removes the process triggered by 
functionautomatic_nts_advancement_monitorReturns:
nil
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 91
 
- 
							
st_helper.get_building_from_list(building listtable,filter functionfunction) - 
							Returns a building from a supplied list of buildings that matches a supplied filter function. The filter function should take a 
battle_buildingas a single argument and return abooleanresult -trueif the filter passes, orfalseotherwise. Each building in the list is tested sequentially, and the first building which passes the filter is returned.
If no building from the supplied list matches thennilis returned.Parameters:
1
List of buildings to test. This should be an indexed table of
battle_buildingobjects, such as (but not restricted to) those returned by functions documented in theBuilding Listssection of this documentation.2
Filter function. This should take a
battle_buildingobject as a single argument and return a boolean result.Returns:
matched building, orbattle_buildingnilif no match
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 104
 
- 
							
st_helper.get_closest_building_from_list(position
battle_vector,building list
table,filter function
[function]
) - 
							Returns the closest building from a supplied list of buildings. An optional filter function may also be supplied, which should take a 
battle_buildingas a single argument and return abooleanresult -trueif the filter passes, orfalseotherwise.Parameters:
1
Position to test against.
2
List of buildings to test. This should be an indexed table of
battle_buildingobjects, such as (but not restricted to) those returned by functions documented in theBuilding Listssection of this documentation.3
optional, default value=nil
Filter function. This should take a
battle_buildingobject as a single argument and return a boolean result. If no filter function is supplied then all buildings pass.Returns:
closest buildingbattle_building
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 138
 
- 
							
st_helper.building_is_standard_fort_wall(buildingbattle_building) - 
							Returns whether the supplied building is a fort wall but not a gate or a tower.
							
Parameters:
1
building
Returns:
building is standard fort wallboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 190
 
- 
							
st_helper.building_is_standard_fort_wall_connected_n_times(building
battle_building,connections
number,allow non-standard connections
[number]
) - 
							Returns whether the supplied building is a standard fort wall connected a supplied number of times on either side. Wall pieces are connected to adjacent pieces in the wall, so a wall piece that is connected n times would have n buildings to the left and to the right of it in the wall, meaning that it's not at or near the end of the wall.
							
Parameters:
1
Building.
2
Number of connections to test.
3
optional, default value=false
Includes connections to buildings that are not standard fort walls (e.g. gates, towers).
Returns:
building is connectedboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 199
 
- 
							
st_helper.get_closest_connected_wall_building(position
battle_vector,connections
number,allow non-standard connections
[number]
) - 
							Returns the closest fort wall building to the supplied position that is connected n times to other buildings. The connection test is performed by 
st_helper.building_is_standard_fort_wall_connected_n_timesParameters:
1
Position to test against.
2
Number of connections to test for each building.
3
optional, default value=false
Includes connections to buildings that are not standard fort walls (e.g. gates, towers).
Returns:
closest buildingbattle_building
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 234
 
- 
							
st_helper.minor_supply_capture_location_exists() - 
							Returns whether a minor key building capture location exists on the battlefield.
							
Returns:
capture location of type existsboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 291
 
- 
							
st_helper.victory_point_plaza_capture_location_exists() - 
							Returns whether a victory point capture location exists on the battlefield.
							
Returns:
capture location of type existsboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 299
 
- 
							
st_helper.major_key_building_capture_location_exists() - 
							Returns whether a major key building capture location exists on the battlefield.
							
Returns:
capture location of type existsboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 307
 
- 
							
st_helper.fort_wall_building_exists() - 
							Returns whether any fort wall buildings exist on the battlefield.
							
Returns:
fort walls existboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 315
 
- 
							
st_helper.fort_gate_building_exists() - 
							Returns whether any fort gate buildings exist on the battlefield.
							
Returns:
fort gates existboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 323
 
- 
							
st_helper.selectable_tower_exists() - 
							Returns whether any selectable tower buildings exist on the battlefield.
							
Returns:
selectable towers existboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 331
 
- 
							
st_helper.capture_location_exists() - 
							Returns whether any capture locations exist on the battlefield.
							
Returns:
capture location existsboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 344
 
- 
							
st_helper.capture_location_with_gate_exists() - 
							Returns whether any capture location with a gate exists on the battlefield.
							
Returns:
selectable towers existboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 354
 
- 
							
st_helper.capture_location_of_type_exists(capture location typestring, [partial matchboolean]) - 
							Returns whether a capture location of the specified type exists on the battlefield.
							
Parameters:
1
Capture location type, from the
capture_point_typesdatabase table.2
optional, default value=false
Perform a partial string match. This would allow a supplied capture location search string
"major_key_building"to match capture locations with types such as"major_key_building_magic"or"major_key_building_missile".Returns:
capture location of type existsboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 375
 
- 
							
st_helper.get_closest_capture_location_of_type(position
battle_vector,capture location type
[string],partial match
[boolean]
) - 
							Returns the closest capture location of the specified type to the supplied position. If the type is left blank then any capture location matches.
							
Parameters:
1
Position.
2
optional, default value=nil
Capture location type, from the
capture_location_types<\code> database table.3
optional, default value=false
Perform a partial string match. This would allow a supplied capture location search string
"major_key_building"to match capture locations with types such as"major_key_building_magic"or"major_key_building_missile".Returns:
capture locationbattle_capture_location
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 410
 
Scripted tour sections commonly have to find camera positions offset from a known camera target e.g. a unit, wall piece or capture location. Functions in this helpers library provide standardised ways to get camera co-ordinates for different types of battlefield objects that we may want to look at during a scripted tour.
The functions in this section are general-purpose, and are primarily for use by the more specific camera helper functions found in the Specialised Camera Offset Functions section.
- 
							
st_helper.get_second_offset_camera_position(camera target
battle_vector,initial camera position
battle_vector,delta
[number]
) - 
							Returns a second camera position from a supplied vector target and an initial camera position. The initial position and the second returned position defines a pair of camera co-ordinates that can be used to effect a camera rotation around the supplied target.
The returned position will be rotated around the camera target from the initial position by the horizontal delta.Parameters:
1
Camera target.
2
Initial camera position.
3
optional, default value=0.1745
horizontal bearing delta in radians. The default value is equivalent to 10 degrees.
Returns:
nil
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 477
 
- 
							
st_helper.get_offset_camera_positions_by_bearing(target
battle_vector,distance
[number],horizontal bearing
[number],vertical bearing
[number],delta
[number]
) - 
							Returns a pair of vectors that define camera positions around a supplied vector target. These camera positions can be used by scripted tour scripts to position and animate the camera as it rotates around the camera target. The positions are computed from the target vector, a distance, and horizontal/vertical bearings supplied from the target vector to the initial camera position.
A horizontal bearing delta, which defines how separated the two returned positions are, may also be supplied. If the supplied horizontal bearing is 0 then only one position vector is returned.Parameters:
1
Target position.
2
optional, default value=100
Camera-to-target distance in m.
3
optional, default value=0
Horizontal bearing (i.e. looking from above) from camera target to initial camera position in radians.
4
optional, default value=0.6175
Vertical vearing (i.e. looking from side) from camera target to initial camera position in radians. The default value is equivalent to 30 degrees.
5
optional, default value=0.1745
Horizontal bearing delta in radians. The default value is equivalent to 10 degrees.
Returns:
start camera positionbattle_vectorend camera position (orbattle_vectornilif delta is 0)
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 525
 
- 
							
st_helper.get_offset_camera_positions_by_offset_and_bearing(camera target
battle_vector,x offset
number,z offset
number,horizontal bearing
number,vertical bearing
[number],delta
[number]
) - 
							Returns a pair of vectors that define camera positions around a supplied vector target. The co-ordinates of the first camera position are determined by a supplied x/z offset from the camera target, the facing of which is determined by a supplied horizontal bearing, and a vertical bearing from the camera target to determine the height. The second returned camera position is offset from the first by an optional horizontal bearing delta. If this is set to 0 then only one camera position is returned.
							
Parameters:
1
Camera target.
2
X offset of the first camera position from the camera target, based on the horizontal bearing.
3
Z offset of the first camera position from the camera target, based on the horizontal bearing.
4
Horizontal bearing (i.e. looking from top down) in radians from which to take the offset, from the camera target.
5
optional, default value=0.6175
Vertical bearing (i.e. looking from side) in radians of the first camera position, from the camera target. The default value is equivalent to 30 degrees.
6
optional, default value=0.1745
Horizontal bearing delta in radians. The default value is equivalent to 10 degrees.
Returns:
start camera positionbattle_vectorend camera position (orbattle_vectornilif delta is 0)
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 602
 
- 
							
st_helper.get_offset_camera_positions_by_bearing_vector(camera target
battle_vector,bearing vector
battle_vector,distance
[number],v bearing
[number],delta
[number]
) - 
							Returns a pair of vectors that define camera positions around a supplied vector target. The co-ordinates of the first camera position are determined by a supplied bearing vector, which defines a horizontal bearing along which the first camera position lies, and is further fixed by a supplied distance and optional vertical bearing. The second returned camera position is offset from the first by an optional horizontal bearing delta. If this is set to 0 then only one camera position is returned.
							
Parameters:
1
Camera target.
2
Bearing vector, which defines the horizontal bearing of the first computed camera position.
3
optional, default value=100
Distance in metres from camera target to computed camera positions.
4
optional, default value=0.6175
Vertical bearing in radians from the camera target to the camera positions, in radians. The default value is equivalent to 30 degrees.
5
optional, default value=0.1745
Horizontal bearing delta in radians. The default value is equivalent to 10 degrees.
Returns:
start camera positionbattle_vectorend camera position (orbattle_vectornilif delta is 0)
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 665
 
These specialised camera offset functions can be used by specific scripted tour sections to provide camera position/target vectors for camera movement. The functions in this section will generally return three battle_vector objects - a camera target, and two camera positions. The contract is that a camera animated between the two supplied positions, looking at the supplied target, should provide a view of the camera target spinning slowly around it.
- 
							
st_helper.get_offset_camera_positions_from_sunit(script unit
script_unit,x-offset
number,z-offset
number,vertical bearing
[number],delta
[number]
) - 
							Returns camera offset positions for a supplied script unit. The first camera position is specified by an x and z offset from the supplied script unit, based on that unit's facing. The position height is determined by a vertical bearing (i.e. looking from the side) from the unit.
The second returned camera is rotated around the unit from the first by the horizontal delta. If the delta is 0 then only one camera position is returned.Parameters:
1
Subject script unit.
2
X-offset of first camera position from the script unit, by that unit's facing.
3
Z-offset of first camera position from the script unit, by that unit's facing.
4
optional, default value=0.6175
Vertical bearing from subject unit to first camera position. The default value is equivalent to 30 degrees.
5
optional, default value=0.1745
Horizontal bearing delta in radians. The default value is equivalent to 10 degrees.
Returns:
camera targetbattle_vectorstart camera positionbattle_vectorend camera position (orbattle_vectornilif delta is 0)
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 693
 
- 
							
st_helper.get_offset_camera_positions_from_sunits(script units
script_units,x-offset
number,z-offset
number,vertical bearing
[number],horizontal bearing override
[number],delta
[number],relaxed pose
[boolean]
) - 
							Returns camera offset positions for a supplied scriptunits collection. The first camera position is specified by an x and z offset from the centre-point of the scriptunits collection, based on their average bearing (or a bearing override). The position height is determined by a vertical bearing (i.e. looking from the side) from that central point.
The second returned camera is rotated around the unit from the first by the horizontal delta. If the delta is 0 then only one camera position is returned.Parameters:
1
Subject script units.
2
X-offset of first camera position from the script unit, by that unit's facing.
3
Z-offset of first camera position from the script unit, by that unit's facing.
4
optional, default value=0.6175
Vertical bearing from subject unit to first camera position. The default value is equivalent to 30 degrees.
5
optional, default value=nil
Horizontal bearing override in radians. By default, the average bearing of all units in the supplied scriptunits collection is used.
6
optional, default value=0.1745
Horizontal bearing delta in radians. The default value is equivalent to 10 degrees.
7
optional, default value=false
Activates relaxed pose. This raises the height of the camera target above the mean centre of the scriptunits collection, and changes the default vertical bearing from 30 degrees to 20 degrees. The scriptunits will be at the bottom-centre of the screen instead of the centre, with the camera raised, replicating a natural gameplay camera angle.
Returns:
camera targetbattle_vectorstart camera positionbattle_vectorend camera position (orbattle_vectornilif delta is 0)
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 736
 
- 
							
st_helper.get_offset_camera_positions_from_walls_as_attacker() - 
							Returns camera offset positions for fortified walls as the siege attacker. The subject wall piece is chosen automatically.
							
Returns:
camera targetbattle_vectorfirst camera positionbattle_vectorsecond camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 801
 
- 
							
st_helper.get_offset_camera_positions_from_walls_as_defender() - 
							Returns camera offset positions for fortified walls as the siege defender. The subject wall piece is chosen automatically.
							
Returns:
camera targetbattle_vectorfirst camera positionbattle_vectorsecond camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 819
 
- 
							
st_helper.get_offset_camera_positions_from_gate([is attackerboolean]) - 
							Returns camera offset positions for a fortified gate. The subject gate is chosen automatically.
							
Parameters:
1
optional, default value=false
Return offset positions as the attacker i.e. from outside the fort.
Returns:
camera targetbattle_vectorfirst camera positionbattle_vectorsecond camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 882
 
- 
							
st_helper.get_offset_camera_positions_from_tower() - 
							Returns camera offset positions for a tower building. The subject tower is chosen automatically.
							
Returns:
camera targetbattle_vectorfirst camera positionbattle_vectorsecond camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 901
 
- 
							
st_helper.get_offset_camera_positions_from_capture_location(filter callback
[function],closest capture location
battle_capture_location
) - 
							Returns camera offset positions for a capture location of any type. The subject capture location is chosen automatically.
A filter function may be provided which, if specified, is called with each capture location. The function must return true for the capture location to be considered in the results. If no filter callback is provided then all capture locations are considered eligible.Parameters:
1
optional, default value=nil
filter callback
2
closest capture location
Returns:
camera targetbattle_vectorfirst camera positionbattle_vectorsecond camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 927
 
- 
							
st_helper.get_offset_camera_positions_from_gate_capture_location(chosen capture location
battle_capture_location
) - 
							Returns camera offset positions for a capture location for a gate. The subject capture location is chosen automatically.
							
Parameters:
1
chosen capture location
Returns:
camera targetbattle_vectorfirst camera positionbattle_vectorsecond camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 985
 
- 
							
st_helper.get_offset_camera_positions_from_siege_weapons() - 
							Returns camera offset positions for a siege weapon. The subject siege weapon is chosen automatically.
							
Returns:
camera targetbattle_vectorfirst camera positionbattle_vectorsecond camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1049
 
- 
							
st_helper.get_offset_camera_positions_from_victory_point() - 
							Returns camera offset positions for a major victory point. The subject victory point is chosen automatically.
							
Returns:
camera targetbattle_vectorfirst camera positionbattle_vectorsecond camera positionbattle_vectorcapture locationbattle_capture_location
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1082
 
- 
							
st_helper.get_offset_camera_positions_for_siege_defence_start() - 
							Returns camera offset positions suitable for the opening shot of a siege defence. A camera position over the top of the controlled unit closest to the enemy army is chosen.
							
Returns:
camera targetbattle_vectorfirst camera positionbattle_vectorsecond camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1127
 
- 
							
st_helper.get_offset_camera_positions_for_building_list(building listtable) - 
							Returns camera offset positions from a list of supplied buildings. Camera positions offset from the closest of the supplied buildings to the current camera position are returned.
							
Parameters:
1
List of buildings, supplied as an indexed table.
Returns:
camera targetbattle_vectorfirst camera positionbattle_vectorsecond camera positionbattle_vectortarget buildingbattle_building
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1184
 
- 
							
st_helper.navigable_tour_section_battle_factory(section name
string,camera positions generator
[function],advice key
[string],infotext
[table],advice delay
[number],objective
[string],objective test
[function],leave objective
[boolean],windowed movie path
[string],destroy the windowed video after interval.
[number]
) - 
							Builds and returns a 
navigable_tour_sectionwith certain standardised behaviours.Parameters:
1
Section name for the navigable tour section being created.
2
optional, default value=nil
Camera positions generator function. If supplied, this function should return two or three
battle_vectorobjects. If two are supplied, these are assumed to be a camera target and position to pan the camera to when the navigable tour starts.3
optional, default value=nil
Key of advice to show when the navigable tour section plays. If
nilis supplied then no advice is shown.4
optional, default value=nil
Table of infotext keys to show when the navigable tour section plays. If
nilis supplied then no infotext is shown.5
optional, default value=1000
Interval before the advice, infotext and objectives begin to display. By default this is 1000ms. A
stringmay also be supplied, in which case it specifies an event which, when received, causes the advice/infotext/objectives to be triggered.6
optional, default value=nil
Objective key of objective to show. This should be a key for a record from the
scripted_objectivesdatabase table. Ifnilis supplied then no objective is shown.7
optional, default value=nil
Objective completion test function. If supplied, a
battle_manager:watchis set up with this function as the condition. When the condition passes, the supplied objective is marked as completed.8
optional, default value=false
Leave section objective on-screen after it has been completed. By default the section objective is removed from the screen once it's completed - set this value to
trueto suppress this behaviour.9
optional, default value=nil
Path of movie to play in window, if one is required for this navigable tour section.
10
optional, default value=6000
destroy the windowed video after interval.
Returns:
nil
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1239
 
- 
							
st_helper.setup_tour_start(navigable tournavigable_tour, [suppress record camera positionboolean]) - 
							A generic function for setting up aspects of the UI at the start of a navigable tour in battle.
							
Parameters:
1
Host navigable tour.
2
optional, default value=false
If set to
true, the current camera position is not recorded on the scripted tour. This is useful if the scripted tour has already done this.Returns:
nil
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1644
 
- 
							
st_helper.setup_tour_end(navigable tournavigable_tour) - 
							A generic function for setting up aspects of the UI at the end of a navigable tour in battle.
							
Parameters:
1
navigable tour
Returns:
nil
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1697