Scripted Tour Helpers

This interface provides a list of functions to empower scripted tour mechanics in battle.

Loaded in Campaign Loaded in Campaign
Loaded in Battle Loaded in Battle
Loaded in Frontend Loaded in Frontend
Back to top

Building Queries

st_helper.get_building_from_list(table building list, function filter function)

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 a boolean result - true if the filter passes, or false 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 then nil is returned.

Parameters:

1

table

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 the Building Lists section of this documentation.

2

function

Filter function. This should take a battle_building object as a single argument and return a boolean result.

Returns:

  1. battle_building matched building, or 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(
  
battle_vector position,
  table
building list,
  [function
filter 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 a boolean result - true if the filter passes, or false otherwise.

Parameters:

1

battle_vector

Position to test against.

2

table

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 the Building Lists section of this documentation.

3

function

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:

  1. battle_building closest building

defined in ../../warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 74

st_helper.building_is_standard_fort_wall(battle_building building)

Returns whether the supplied building is a fort wall but not a gate or a tower.

Parameters:

1

battle_building

building

Returns:

  1. boolean building is standard fort wall

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(
  
battle_building building,
  number
connections,
  [number
allow non-standard connections]
)

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

battle_building

Building.

2

number

Number of connections to test.

3

number

optional, default value=false

Includes connections to buildings that are not standard fort walls (e.g. gates, towers).

Returns:

  1. boolean building is connected

defined in ../../warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 135

st_helper.get_closest_connected_wall_building(
  
battle_vector position,
  number
connections,
  [number
allow non-standard connections]
)

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_times

Parameters:

1

battle_vector

Position to test against.

2

number

Number of connections to test for each building.

3

number

optional, default value=false

Includes connections to buildings that are not standard fort walls (e.g. gates, towers).

Returns:

  1. battle_building closest 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:

  1. boolean capture location of type exists

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:

  1. boolean capture location of type exists

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:

  1. boolean capture location of type exists

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:

  1. boolean capture location of type exists

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:

  1. boolean fort walls exist

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:

  1. boolean fort gates exist

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:

  1. boolean selectable towers exist

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:

  1. boolean capture location exists

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:

  1. boolean selectable towers exist

defined in ../../warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 296

st_helper.capture_location_of_type_exists(string capture location type, [boolean partial match])

Returns whether a capture location of the specified type exists on the battlefield.

Parameters:

1

string

Capture location type, from the capture_point_types database table.

2

boolean

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:

  1. boolean capture location of type exists

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(
  [
string capture location type],
  [boolean
partial match]
)

Returns whether a capture location of the specified type exists on the battlefield with associated toggleable slots.

Parameters:

1

string

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

boolean

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:

  1. boolean capture location of type exists

defined in ../../warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 342

st_helper.get_closest_capture_location_of_type(
  
battle_vector position,
  [string
capture location type],
  [boolean
partial match]
)

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

battle_vector

Position.

2

string

optional, default value=nil

Capture location type, from the capture_location_types<\code> database table.

3

boolean

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:

  1. string capture location as context string

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(
  
battle_vector position,
  [string
capture location type],
  [boolean
partial match]
)

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

battle_vector

Position.

2

string

optional, default value=nil

Capture location type, from the capture_location_types<\code> database table.

3

boolean

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:

  1. string capture location as context string

defined in ../../warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 434

Back to top

General Camera Offset Functions

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(
  
battle_vector camera target,
  battle_vector
initial camera position,
  [number
delta]
)

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

battle_vector

Camera target.

2

battle_vector

Initial camera position.

3

number

optional, default value=0.1745

horizontal bearing delta in radians. The default value is equivalent to 10 degrees.

Returns:

  1. 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(
  
battle_vector target,
  [number
distance],
  [number
horizontal bearing],
  [number
vertical bearing],
  [number
delta]
)

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

battle_vector

Target position.

2

number

optional, default value=100

Camera-to-target distance in m.

3

number

optional, default value=0

Horizontal bearing (i.e. looking from above) from camera target to initial camera position in radians.

4

number

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

number

optional, default value=0.1745

Horizontal bearing delta in radians. The default value is equivalent to 10 degrees.

Returns:

  1. battle_vector start camera position
  2. battle_vector end camera position (or 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(
  
battle_vector camera target,
  number
x offset,
  number
z offset,
  number
horizontal bearing,
  [number
vertical bearing],
  [number
delta]
)

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

battle_vector

Camera target.

2

number

X offset of the first camera position from the camera target, based on the horizontal bearing.

3

number

Z offset of the first camera position from the camera target, based on the horizontal bearing.

4

number

Horizontal bearing (i.e. looking from top down) in radians from which to take the offset, from the camera target.

5

number

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

number

optional, default value=0.1745

Horizontal bearing delta in radians. The default value is equivalent to 10 degrees.

Returns:

  1. battle_vector start camera position
  2. battle_vector end camera position (or 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(
  
battle_vector camera target,
  battle_vector
bearing vector,
  [number
distance],
  [number
v bearing],
  [number
delta]
)

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

battle_vector

Camera target.

2

battle_vector

Bearing vector, which defines the horizontal bearing of the first computed camera position.

3

number

optional, default value=100

Distance in metres from camera target to computed camera positions.

4

number

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

number

optional, default value=0.1745

Horizontal bearing delta in radians. The default value is equivalent to 10 degrees.

Returns:

  1. battle_vector start camera position
  2. battle_vector end camera position (or nil if delta is 0)

defined in ../../warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 693

Back to top

Specialised Camera Offset Functions

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,
  number
x-offset,
  number
z-offset,
  [number
vertical bearing],
  [number
delta]
)

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

script_unit

Subject script unit.

2

number

X-offset of first camera position from the script unit, by that unit's facing.

3

number

Z-offset of first camera position from the script unit, by that unit's facing.

4

number

optional, default value=0.6175

Vertical bearing from subject unit to first camera position. The default value is equivalent to 30 degrees.

5

number

optional, default value=0.1745

Horizontal bearing delta in radians. The default value is equivalent to 10 degrees.

Returns:

  1. battle_vector camera target
  2. battle_vector start camera position
  3. battle_vector end camera position (or 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,
  number
x-offset,
  number
z-offset,
  [number
vertical bearing],
  [number
horizontal bearing override],
  [number
delta],
  [boolean
relaxed pose]
)

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

script_units

Subject script units.

2

number

X-offset of first camera position from the script unit, by that unit's facing.

3

number

Z-offset of first camera position from the script unit, by that unit's facing.

4

number

optional, default value=0.6175

Vertical bearing from subject unit to first camera position. The default value is equivalent to 30 degrees.

5

number

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

number

optional, default value=0.1745

Horizontal bearing delta in radians. The default value is equivalent to 10 degrees.

7

boolean

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:

  1. battle_vector camera target
  2. battle_vector start camera position
  3. battle_vector end camera position (or 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:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

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:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

defined in ../../warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 846

st_helper.get_offset_camera_positions_from_gate([boolean is attacker])

Returns camera offset positions for a fortified gate. The subject gate is chosen automatically.

Parameters:

1

boolean

optional, default value=false

Return offset positions as the attacker i.e. from outside the fort.

Returns:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

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:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

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:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

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:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

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:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

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:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

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:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

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:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

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:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

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:

  1. battle_vector camera target
  2. battle_vector first camera position
  3. battle_vector second camera position

defined in ../../warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1205

Back to top

Navigable Tour Section Factory

st_helper.navigable_tour_section_battle_factory(
  
string section name,
  [function
camera positions generator],
  [string
advice key],
  [table
infotext],
  [number
advice delay],
  [string
objective],
  [function
objective test],
  [boolean
leave objective],
  [string
windowed movie path]
)

Builds and returns a navigable_tour_section with certain standardised behaviours.

Parameters:

1

string

Section name for the navigable tour section being created.

2

function

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

string

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

table

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

number

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

string

optional, default value=nil

Objective key of objective to show. This should be a key for a record from the scripted_objectives database table. If nil is supplied then no objective is shown.

7

function

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

boolean

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

string

optional, default value=nil

Path of movie to play in window, if one is required for this navigable tour section.

Returns:

  1. nil

defined in ../../warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1273

Back to top

Tour Start and End

st_helper.setup_tour_start(navigable_tour navigable tour, [boolean suppress record camera position])

A generic function for setting up aspects of the UI at the start of a navigable tour in battle.

Parameters:

1

navigable_tour

Host navigable tour.

2

boolean

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:

  1. nil

defined in ../../warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1646

st_helper.setup_tour_end(navigable_tour navigable tour)

A generic function for setting up aspects of the UI at the end of a navigable tour in battle.

Parameters:

1

navigable_tour

navigable tour

Returns:

  1. nil

defined in ../../warhammer/working_data/script/battle/scripted_tours/scripted_tour_helper_functions.lua, line 1700

Last updated 7/9/2024 11:45:05 AM