Campaign Custom Starts
Allows tweaks to be made to a faction's starting circumstances based on other conditions.
This script is to be used when creating a custom start that differs from the start_pos.
Please use this instead of editing a faction's unique start/prelude scripts - editing that file with start pos changes can only be done in SP as MP changes cause desync issues.
Loaded in Campaign | |
Loaded in Battle | |
Loaded in Frontend |
To use the custom start functions you need to declare a set of changes to enact in the custom_start
table.
Within a custom start, a set of changes to the campaign map can be specified. For example, region_change
can give a region to a particular faction.
The conditions under which a certain custom start executes can be defined with the is_human
and is_ai
values. These may be a faction string, or a list of faction strings, and ALL factions must be human, or AI, for is_human
and is_ai
respectively.
Example - Custom Start:
For Cult of Sotek, if Pestilens is AI then start war between Sotek and Pestilens, and give Pestilens the Shrine of Sotek. If Itza and Cult of Sotek are AI, they cannot declare war.
{
if_human = "wh2_dlc12_lzd_cult_of_sotek",
if_ai = "wh2_main_skv_clan_pestilens",
changes = {
{"region_change", "wh3_main_combi_region_shrine_of_sotek", "wh2_main_skv_clan_pestilens"},
{"force_diplomacy", "wh2_dlc12_lzd_cult_of_sotek", "wh2_main_skv_clan_pestilens", "war"},
}
}
{
if_ai = { "wh2_dlc12_lzd_cult_of_sotek", "wh2_main_lzd_itza" }
changes = {
{"block_diplomacy", "wh2_dlc12_lzd_cult_of_sotek", "wh2_main_lzd_itza", "war", false, false},
}
}
-
custom_starts:region_change(
region keystring
,
faction_namestring
)
-
Give a region to the specified faction.
Parameters:
1
The key of the region to be transferred.
2
The key of the faction to receive the region.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 348
-
custom_starts:absorb_other_faction(
absorbing faction keystring
,
absorbed_faction_keystring
)
-
Give all regions of the absorbed faction to the absorbing faction, and kill all absorbed faction's characters.
Parameters:
1
The key of the faction to absorb the other faction.
2
The key of the faction to be absorbed.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 373
-
custom_starts:primary_slot_change(
regionstring
,
buildingstring
)
-
Change the primary building at the specified region to the specified building.
Parameters:
1
The region at which the building should be changed.
2
The building to set the primary slot of the region to.
Returns:
Returnsboolean
true
of the primary slot successfully changed to the specified building key, otherwise returnsfalse
.
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 400
-
custom_starts:port_slot_change(
regionstring
,
buildingstring
)
-
Change the port slot at the specified region to the specified building.
Parameters:
1
The key of the region at which the port slot will change.
2
The key of the building to change the slot to.
Returns:
Returnsboolean
true
of the primary slot successfully changed to the specified building key, otherwise returnsfalse
.
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 430
-
custom_starts:secondary_slot_change(
regionstring
,
slot_indexnumber
,
buildingstring
)
-
Change the secondary slot at the given index of a specified region to a building.
Parameters:
1
The key of the region at which to change the building.
2
The zero-based index of the secondary slot at which to change the building.
3
The key of the building to which the slot should change.
Returns:
Returnsboolean
true
of the primary slot successfully changed to the specified building key, otherwise returnsfalse
.
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 466
-
custom_starts:create_army(
faction_name
string
,
or
number
string
unit_list,
region_name
string
,
x_pos
number
,
y_pos
number
,
agent_subtype
string
,
is_leader
boolean
,
name_table
table
) -
Spawn an army on the map for a certain faction using either a quantity of units, or a random army template key.
Parameters:
1
The key of the faction the army will belong to.
2
The quantity of units to be spawned (in which case random units are created) or the key of the random army template to be used.
3
The key of the region the army will spawn in.
4
The x coordinate the army will spawn at.
5
The y coordinate the army will spawn at.
6
Character subtype of character at the head of the army.
7
Make the spawned character the faction leader.
8
An array of 4 names, corresponding to the forename, clan name, family name, and other name of the general. Unfilled names must be empty strings. These should be given in the localised text lookup format i.e. a key from the
names
table with "names_name_" prepended.Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 509
-
custom_starts:create_army_for_faction_leader(
faction_name
string
,
region_name
string
,
x_pos
number
,
y_pos
number
,
or
number
string
unit_list
) -
Create an army for the leader of the specified faction.
Parameters:
1
The key of the faction whose leader gets an army.
2
The key of the region the army will spawn in.
3
The x coordinate at which the army will spawn.
4
The y coordinate at which the army will spawn.
5
The quantity of units to be spawned (in which case random units are created) or the key of the random army template to be used.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 597
-
custom_starts:teleport_character(
faction_name
string
,
start_x
number
,
start_y
number
,
end_x
number
,
end_y
number
,
is_general
boolean
) -
Teleport a character of a given faction, whichever character is closest to the provided start coordinates.
Parameters:
1
The key of the faction the teleported character belongs to.
2
The starting x coordinate - the closest character of the given faction to this position will be teleported.
3
The starting y coordinate - the closest character of the given faction to this position will be teleported.
4
The teleport x coordinate.
5
The teleport y coordinate.
6
Whether or not the target character is a general. This informs which character nearest the starting coord is selected.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 651
-
custom_starts:teleport_character_faction_leader(
faction_keystring
,
target_xnumber
,
target_ynumber
)
-
Teleport the leader of the specified faction to these coordinates.
Parameters:
1
The name of the faction whose leader is to be teleported.
2
The x coordinate to teleport to.
3
The y coordinate to teleport to.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 703
-
custom_starts:hide_faction_leader(
faction_keystring
,
startpos_IDnumber
,
kill_armyboolean
)
-
Hide the leader of the faction by killing them and restricting their recruitment.
Parameters:
1
The key of the faction whose leader will be hidden.
2
The startpos ID of the general to have their recruitment locked. This ought to match the leader of the specified faction.
3
Kill the faction leader's entire army, if true.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 717
-
custom_starts:modify_units_in_army(
faction_name
string
,
pos_x
number
,
pos_y
number
,
add_units_table
table
,
remove_units_table
table
,
general_forename
[string
],
general_surname
[string
]
) -
Add and remove the provided lists of units (removals occur per-instance, so three consecutive unit keys results in the removal of 3 units), to the factions' army found closest to the provided coordinate.
Parameters:
1
The key of the faction for which armies close to the coordinates will be considered.
2
The x coordinate close to the target army.
3
The y coordinate close to the target army.
4
A list of unit keys to be added. Provide an empty table if no units wanted.
5
A list of unit keys to be removed, per-instance of that unit. Provide an empty table if no units wanted.
6
optional, default value=nil
The forename of the general whose army will be adjusted. Can be used to handle different starting generals for the same faction receiving different starting units. Otherwise can be left blank.
7
optional, default value=nil
The surname of the general whose army will be adjusted.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 735
-
custom_starts:add_xp_to_units(
faction_namestring
,
unit_keystring
,
experiencenumber
)
-
Add XP to each instance of the given unit key in all of a faction's armies.
Parameters:
1
The faction for which all units of a type will receive XP.
2
The key of the unit type to receive XP.
3
The amount of XP given to each unit.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 806
-
custom_starts:force_diplomacy_change(
s_factionstring
,
t_factionstring
,
d_typestring
)
-
Force a change in diplomacy between the two factions.
Parameters:
1
The source faction.
2
The target faction.
3
The type of diplomacy to enforce. This is currently limited to 'peace' or 'war'. Allies are not invited to war.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 845
-
custom_starts:block_diplomacy(
s_faction
string
,
t_faction
string
,
diplomacy
string
,
can_offer
boolean
,
can_offer
boolean
) -
Restricts or unrestricts diplomacy types between two factions, using the diplomacy types available in
campaign_manager:force_diplomacy
. Groups of factions may be specified with the strings"all"
,"faction:faction_key"
,"subculture:subculture_key"
or"culture:culture_key"
.Parameters:
1
The source faction.
2
The target faction.
3
The diplomacy type being restricted or allowed, as specified in
campaign_manager:force_diplomacy
.4
If the source faction can offer this diplomatic relationship to the target.
5
If the source faction can accept this diplomatic relationship to the target.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 878
-
custom_starts:abandon_region(
region_keystring
)
-
Abandon the specified region key, turning it to ruins.
Parameters:
1
The key of the region to be abandoned.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 919
-
custom_starts:kill_faction(
faction_keystring
)
-
Kills the specified faction key, abandoning all its regions and killing all armies.
Parameters:
1
The key of the faction to be killed.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 936
-
custom_starts:apply_effect_bundle_character(
faction_name
string
,
x_pos
number
,
y_pos
number
,
bundle
number
,
duration
number
) -
Apply an effect bundle to the character of the specified faction nearest the provided location.
Parameters:
1
The key name of the faction for which characters will be considered.
2
The x coordinate from which the target character is searched.
3
The y coordinate from which the target character is searched.
4
The key of the bundle to apply.
5
The turn duration the bundle will last for, 0 being infinite turns.
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 990
-
custom_starts:force_change_faction_cai_personality(
faction_keystring
,
personality_keystring
)
-
Force the specified faction to adopt the specified AI personality.
Parameters:
1
Faction key
2
Personality key
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 1035
-
custom_starts:add_pooled_resource_to_faction(
faction_name
string
,
pooled_resource_key
string
,
pooled_resource_factor_key
string
,
the amount to adjust by
number
,
) -
Adjusts specified pooled resource to target faction.
Parameters:
1
The faction name to adjust the specified pooled resource for.
2
The pooled resource to adjust values for.
3
The factor through which the resource is adjusted for the faction
4
the amount to adjust by
Returns:
nil
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 1045
-
custom_starts:generate_random_army(
subculturestring
,
num_unitsnumber
)
-
Generate a random army using pre-defined army sets per subculture.
Parameters:
1
The subculture of the army to be generated: each subculture has a particular 'standard' army template in this function.
2
The size of the army to be generated.
Returns:
Returns a table of unit keys representing the army that was generated.string
defined in ../../Warhammer/working_data/script/campaign/wh2_campaign_custom_starts.lua, line 1068