Invasion Manager

The Invasion Manager is used to create and manage scripted A.I invasions in the campaign

The primary purpose of the Invasion Manager is to created, hold and manage invasion objects

See the invasion section below for details on how to set up and begin invasions

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

Creating Invasions

invasion_manager:new_invasion(
  string
key,
  string
faction_key,
  string
force_list,
  object
spawn_location,
  bool
is_CAI,
  string
cai_personnality
)

Adds a new invasion to the invasion manager

Parameters:

1

string

The key of this invasion

2

string

The key of the faction that this invasion belongs to

3

string

The units that will be part of this invasion

4

object

Pass either a table of x/y coordinates or a string for the key of a preset location

5

bool

Defines if this invasion will be immediatly handed to CAI or controlled via scripts

6

string

CAI Personnality key to provide if the invasion is handled by CAI

Returns:

  1. invasion The new invasion object created by this function

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 29

invasion_manager:new_spawn_location(string key, number x, number y)

Create a new spawn location that can be used later by referencing its key

Parameters:

1

string

The key of this location

2

number

The X coordinate of this location

3

number

The Y coordinate of this location

Returns:

  1. nil

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 113

Back to top

Selecting & Removing Invasions

invasion_manager:get_invasion(string key)

Returns an invasion from the invasion manager by its key

Parameters:

1

string

The key of the invasion object

Returns:

  1. invasion The invasion object with the key provided

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 195

invasion_manager:remove_invasion(string key)

Removes an invasion from the invasion manager by its key

Parameters:

1

string

The key of the invasion object

Returns:

  1. nil

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 207

invasion_manager:kill_invasion_by_key(string key)

Kills an invasion via the invasion manager, see the kill function on the invasion object for details

Parameters:

1

string

The key of the invasion object

Returns:

  1. nil

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 225

invasion_manager:generate_unique_invasion_key(string original_invasion_key - the key we want to use)

returns a key that is not used for an active invasion - adds a number to the end of the original key if it is already used. tries at max 100 times as a sanity check

Parameters:

1

string

original_invasion_key - the key we want to use

Returns:

  1. a key that is not used for any invasion so far

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 237


Invasion

Back to top

Setup

invasion:set_target(string target_type, object target, string target_faction_key)

Sets the target for an invasion
Target Types: REGION, CHARACTER, LOCATION, PATROL
  • REGION - Requires the target to be set as a region key
  • CHARACTER - Requires the target to be set as a character's CQI
  • LOCATION - Requires the target to be set as a table containing an x and y variable, e.g. {x = 5, y = 3}
  • PATROL - Requires the target to be set as a table containing any number of position tables, e.g. {{x = 5, y = 3}, {x = 9, y = 2}}

    Parameters:

    1

    string

    The type of the target

    2

    object

    The actual target

    3

    string

    The faction that is the indended target

    Returns:

    1. nil

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 277

  • invasion:remove_target()

    Sets this invasion to no longer have a target

    Returns:

    1. nil

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 329

    invasion:assign_general(character character)

    Sets a General to be used when spawning this invasion

    Parameters:

    1

    character

    The general that will be used (can optionally be a character CQI)

    Returns:

    1. nil

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 338

    invasion:create_general(
      boolean
    make_faction_leader,
      string
    agent_subtype,
      string
    forename,
      string
    clan_name,
      string
    family_name,
      string
    other_name
    )

    Sets up a general to be created to command this invasion force when it is spawned

    Parameters:

    1

    boolean

    If True this character will become the faction leader

    2

    string

    The key of this characters intended subtype

    3

    string

    The name key of this characters forename

    4

    string

    The name key of this characters clan name

    5

    string

    The name key of this characters family name

    6

    string

    The name key of this characters other name

    Returns:

    1. nil

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 349

    invasion:set_general_immortal(boolean should_stop)

    Sets whether the General leading this invasion should be immortal or not

    Parameters:

    1

    boolean

    General spawned will be immortal if True

    Returns:

    1. nil

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 370

    invasion:apply_effect(string effect_key, number turns)

    Allows you to apply an effect bundle to the forces in this invasion

    Parameters:

    1

    string

    The key of the effect bundle

    2

    number

    The turns the effect bundle will be applied for after the invasion is started

    Returns:

    1. nil

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 385

    invasion:add_character_experience(number experience_amount, boolean by_level)

    Allows you to add experience to the general in this invasion or set their level

    Parameters:

    1

    number

    The amount of experience to apply

    2

    boolean

    If true the experience amount supplied will set the level of the character and not their xp

    Returns:

    1. nil

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 405

    invasion:add_unit_experience(number unit_experience_amount)

    Allows you to add experience to the units of the army in this invasion

    Parameters:

    1

    number

    The amount of experience to apply

    Returns:

    1. nil

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 437

    Back to top

    Managing

    invasion:start_invasion(
      number
    budget,
      number
    unit count,
      [boolean
    declare_war],
      [boolean
    invite_attacker_allies],
      [boolean
    invite_defender_allies]
    )

    Starts the invasion, spawning its force if neccessary

    Parameters:

    1

    number

    If >0 will spawn an army with such a budget

    2

    number

    If >0 will spawn an army with this unit count (when using a budget)

    3

    boolean

    optional, default value=true

    If True the invasion will declare war on its targets

    4

    boolean

    optional, default value=true

    If True the invasion will invite its allies when declaring war

    5

    boolean

    optional, default value=true

    If True the invasions target will invite its allies when declaring war

    Returns:

    1. nil

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 456

    invasion:release()

    Releases the invasion force back to AI control

    Returns:

    1. nil

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 1156

    invasion:kill(boolean general_only)

    Kills this invasions General and the whole force (or just the General)

    Parameters:

    1

    boolean

    If True only the Generate will be killed and the force will remain

    Returns:

    1. nil

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 1177

    Back to top

    Inspecting

    invasion:get_general()

    Returns the character leading this invasion force

    Returns:

    1. character The general of the invasions force

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 1195

    invasion:get_commander()

    Returns the character that is the current leader of this force even if it is a colonel

    Returns:

    1. character The commander of the invasions force

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 1209

    invasion:get_force()

    Returns the force interface of this invasion

    Returns:

    1. military_force The military force belonging to the invasion

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 1235

    invasion:has_started()

    Checks if an invasion has started

    Returns:

    1. boolean Returns True if this invasion has started

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 1245

    invasion:turn_spawned()

    Checks what turn this invasion was spawned on

    Returns:

    1. number Returns the turn number that this invasion was started on, or 0 if it has not been

    defined in ../../Warhammer/working_data/script/_lib/lib_campaign_invasion_manager.lua, line 1252

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