Payload String Constructor

When constructing mission definitions from a string, a particularly fiddly point is assembling the payload strings for mission rewards. The payload table contains utility functions that should hopefully make this process a bit easier.

The various functions provided in the payload table can each be called with the minimum of vital data. Each will return a string which can be plugged in to mission_manager:add_payload (or equivalent functions) to specify that the mission should deliver that reward.

The payload table also provides a basic remapping feature. This is useful for when a particular faction doesn't take a particular reward (usually money) but another reward in its place (e.g. a race-specific currency like daemonic glory). Rather than having to manually override each mission record for a particular faction which would be time-consuming and error-prone, data is provided which a remapping function can use to replace the mission rewards with something more appropriate.

Example:

local mm = mission_manager:new(faction_key, mission_key);
mm:add_new_objective("SEARCH_RUINS");
mm:add_condition("total 1");
mm:add_payload(payload.money(500));
Loaded in Campaign Loaded in Campaign
Loaded in Battle Loaded in Battle
Loaded in Frontend Loaded in Frontend
Back to top

Payload Remapping

payload.add_money_equivalence_mapping(string faction key, function remapping callback)

Adds a payload remapping for a particular faction, for money. Once this remapping is established, payloads for this faction set up with payload.money will instead be replaced with an alternative. The alternative is determined by the callback that is supplied to this function.
When a money payload is requested, the callback will be called and supplied three arguments - the amount of money to add, the faction key, and a table of arbitrary parameters supplied to payload.money that can be used to determine the equivalent payload. What goes in to this table of arbitrary parameters can be decided by the implementer, but what is added to each mission specification should match what the callback looks for.

Parameters:

1

string

faction key

2

function

remapping callback

Returns:

  1. nil

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 1951

payload.add_ancillary_equivalence_mapping(string faction key, function remapping callback)

Adds a payload remapping for a particular faction, for ancillary payloads. Once this remapping is established, payloads for this faction set up with payload.ancillary_mission_payload will instead be replaced with an alternative. The alternative is determined by the callback that is supplied to this function.
When an ancillary payload is requested, the callback will be called and supplied three arguments - the faction key, the ancillary category string, and the ancillary rarity string.

Parameters:

1

string

faction key

2

function

remapping callback

Returns:

  1. nil

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 1969

Back to top

Money Payloads

payload.money_direct(number amount)

Returns a payload string which defines a money reward for a string mission definition. No money-equivalence is looked up when this function is called - use payload.money to return a money-equivalent reward when appropriate.

Parameters:

1

number

amount

Returns:

  1. string payload string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 1994

payload.money(number amount, string faction key, table equivalence parameters)

Returns a payload string which defines a money reward (or equivalent) for a string mission definition. When this function is called, a money-equivalence mapping is looking up based on the supplied faction key. If one was previously added with payload.add_money_equivalence_mapping then the mapping callback that was supplied to that function is called, and the returned result of that callback is returned by this function. If no remapping for this faction is found, then a money payload string is returned.

Parameters:

1

number

amount

2

string

faction key

3

table

equivalence parameters

Returns:

  1. string payload string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2007

Back to top

Text Override Payloads

payload.text_display(string text key)

Returns a payload string which defines a text override for the payload description. If a text override is specified, the mission panel will display that message as the mission reward instead of trying to generate one itself. This is useful in certain circumstances, such as if completing the mission brings some custom scripted reward that the game does not natively support.

Parameters:

1

string

Key of text to display, from the campaign_payloads_ui_details database table.

Returns:

  1. string payload string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2036

Back to top

Agent Payloads

payload.agent(string spawn region, string agent type, string agent subtype, [number action points])

Returns a payload string which defines an agent reward for a string mission definition. No kind of equivalence is looked up.

Parameters:

1

string

Key of region in which to spawn the agent, from the regions database table.

2

string

Agent type key, from the agents database table.

3

string

Agent subtype key, from the agent_subtypes database table.

4

number

optional, default value=100

Percentage of action points that the spawned agent should start with. By default the agent starts with 100% action points.

Returns:

  1. string payload string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2063

payload.agent_for_faction(
  
string faction key,
  string
agent type,
  [string
agent subtype],
  [number
action points]
)

Returns a payload string which defines an agent reward for a string mission definition, for a faction. This differs from payload.agent in that this function takes a faction key, and looks up the home region of that faction. If the faction has no home region, then a script error is thrown and money is substituted.

Parameters:

1

string

Key of faction for which the agent is being spawned, from the factions table. This is used to specify the region in which the agent is spawned - the home region of the faction is used.

2

string

Agent type key, from the agents database table.

3

string

optional, default value=nil

Agent subtype key, from the agent_subtypes database table.

4

number

optional, default value=100

Percentage of action points that the spawned agent should start with. By default the agent starts with 100% action points.

Returns:

  1. string payload string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2101

Back to top

Ancillary Payloads

payload.ancillary_mission_payload(
  
string ancillary key,
  string
faction key,
  string
ancillary category,
  string
ancillary rarity
)

Returns a mission reward string that adds the specified ancillary to the faction pool when the mission being constructed is completed.

Parameters:

1

string

Ancillary key, from the ancillaries database table.

2

string

Faction key, from the factions database table.

3

string

Ancillary category. Valid values are presently "armour", "enchanted_item">, "banner">, "talisman">, "weapon" and "arcane_item". Arcane items may only be equipped by spellcasters.

4

string

Ancillary rarity. Valid values are presently "common", "uncommon" and "rare".

Returns:

  1. ancillary mission reward string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2141

Back to top

Pooled Resource Payloads

payload.pooled_resource_mission_payload(string pooled resource key, number quantity, [string factor key])

Returns a mission reward string that adds the specified quantity of the specified pooled resource with the specified factor when the mission being constructed is completed.

Parameters:

1

string

Pooled resource key, from the pooled_resources database table.

2

number

Quantity of pooled resource to award.

3

string

optional, default value="troy_resource_factor_events"

Factor key, from the factor field in the pooled_resource_factor_junctions database table.

Returns:

  1. string pooled resource mission reward string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2186

payload.food(number amount)

Returns a payload string which defines a food reward for a mission definition. No kind of equivalence is looked up.

Parameters:

1

number

amount

Returns:

  1. string payload string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2199

payload.stone(number amount)

Returns a payload string which defines a stone reward for a mission definition. No kind of equivalence is looked up.

Parameters:

1

number

amount

Returns:

  1. string payload string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2212

payload.wood(number amount)

Returns a payload string which defines a wood reward for a mission definition. No kind of equivalence is looked up.

Parameters:

1

number

amount

Returns:

  1. string payload string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2225

payload.bronze(number amount)

Returns a payload string which defines a bronze reward for a mission definition. No kind of equivalence is looked up.

Parameters:

1

number

amount

Returns:

  1. string payload string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2238

payload.gold(number amount)

Returns a payload string which defines a gold reward for a mission definition. No kind of equivalence is looked up.

Parameters:

1

number

amount

Returns:

  1. string payload string

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2251

Back to top

Mercenary Payloads

payload.mercenary_mission_payload(string unit key, number quantity)

Returns a mission reward string that adds the specified quantity of the specified unit to the faction's mercenary pool when the mission being constructed is completed. This would only have an effect for faction's that feature a mercenary pool.

Parameters:

1

string

Unit key, from the main_units database table.

2

number

Quantity of units to add.

Returns:

  1. nil

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2276

Back to top

Effect Bundles

payload.effect_bundle_mission_payload(string effect bundle key, number turns)

Returns a mission reward string that applies the specified effect bundle to the faction when the mission being constructed is completed. An optional duration in turns may be specified.

Parameters:

1

string

Effect bundle key, from the effect_bundles database table.

2

number

Number of turns the effect should be applied for. If this is omitted

Returns:

  1. nil

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_mission_manager.lua, line 2297

Last updated 8/23/2024 4:55:15 PM