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.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_building
as a single argument and return aboolean
result -true
if the filter passes, orfalse
otherwise. 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 thennil
is returned.Parameters:
1
List of buildings to test. This should be an indexed table of
battle_building
objects, such as (but not restricted to) those returned by functions documented in theBuilding Lists
section of this documentation.2
Filter function. This should take a
battle_building
object as a single argument and return a boolean result.Returns:
matched building, orbattle_building
nil
if no match
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 40
-
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_building
as a single argument and return aboolean
result -true
if the filter passes, orfalse
otherwise.Parameters:
1
Position to test against.
2
List of buildings to test. This should be an indexed table of
battle_building
objects, such as (but not restricted to) those returned by functions documented in theBuilding Lists
section of this documentation.3
optional, default value=nil
Filter function. This should take a
battle_building
object 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 74
-
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 126
-
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 135
-
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 170
-
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 227
-
st_helper.minor_supply_capture_location_with_toggleable_slot_exists()
-
Returns whether any minor key building capture locations with attached toggleable slots exist on the battlefield.
Returns:
capture location of type existsboolean
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 235
-
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 243
-
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 251
-
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 259
-
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 267
-
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 275
-
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 288
-
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 296
-
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_types
database 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 310
-
st_helper.capture_location_of_type_with_toggleable_slot_exists(
capture location type
[string
],
partial match
[boolean
]
) -
Returns whether a capture location of the specified type exists on the battlefield with associated toggleable slots.
Parameters:
1
optional, default value=nil
Capture location type, from the
capture_point_types
database table. If no type is specified then any type is matched.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 342
-
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. The capture location is returned as a context string identifier. 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 location as context stringstring
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 386
-
st_helper.get_closest_toggleable_slot_from_capture_location_of_type(
position
battle_vector
,
capture location type
[string
],
partial match
[boolean
]
) -
Returns the closest toggleable slot from any capture location of the specified type, to the supplied position. The toggleable slot is returned as a context string identifier. If the capture location 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 location as context stringstring
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 434
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 505
-
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_vector
end camera position (orbattle_vector
nil
if delta is 0)
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 553
-
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_vector
end camera position (orbattle_vector
nil
if delta is 0)
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 630
-
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_vector
end camera position (orbattle_vector
nil
if delta is 0)
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 693
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_vector
start camera positionbattle_vector
end camera position (orbattle_vector
nil
if delta is 0)
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 721
-
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_vector
start camera positionbattle_vector
end camera position (orbattle_vector
nil
if delta is 0)
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 764
-
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_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 828
-
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_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 846
-
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_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 909
-
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_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 928
-
st_helper.get_offset_camera_positions_from_capture_location()
-
Returns camera offset positions for a capture location of any type. The subject capture location is chosen automatically.
Returns:
camera targetbattle_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 954
-
st_helper.get_offset_camera_positions_from_gate_capture_location()
-
Returns camera offset positions for a capture location for a gate. The subject capture location is chosen automatically.
Returns:
camera targetbattle_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1008
-
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_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1074
-
st_helper.get_offset_camera_positions_from_minor_point_supplies_toggleable_slot_location()
-
Returns camera offset positions for a minor-key-building toggleable slot location. The subject slot location is chosen automatically.
Returns:
camera targetbattle_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1107
-
st_helper.get_offset_camera_positions_from_minor_point_supplies_capture_location()
-
Returns camera offset positions for a minor-key-building capture location. The subject capture location is chosen automatically.
Returns:
camera targetbattle_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1132
-
st_helper.get_offset_camera_positions_from_major_victory_point()
-
Returns camera offset positions for a major victory point. The subject victory point is chosen automatically.
Returns:
camera targetbattle_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1157
-
st_helper.get_offset_camera_positions_from_minor_victory_point()
-
Returns camera offset positions for a minor victory point. The subject victory point is chosen automatically.
Returns:
camera targetbattle_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1181
-
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_vector
first camera positionbattle_vector
second camera positionbattle_vector
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1205
-
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
]
) -
Builds and returns a
navigable_tour_section
with 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_vector
objects. 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
nil
is supplied then no advice is shown.4
optional, default value=nil
Table of infotext keys to show when the navigable tour section plays. If
nil
is 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
string
may 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_objectives
database table. Ifnil
is supplied then no objective is shown.7
optional, default value=nil
Objective completion test function. If supplied, a
battle_manager:watch
is 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
true
to suppress this behaviour.9
optional, default value=nil
Path of movie to play in window, if one is required for this navigable tour section.
Returns:
nil
defined in ../../Warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1273
-
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 1646
-
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 1700