Random Army Manager

Used to create and manage multiple random or semi-random army templates that can be generated at any time throughout the campaign.

Example Usage:

1) Create an army template

random_army_manager:new_force("my_template");

2) Add 4 units to this army that will always be used when generating this template

random_army_manager:add_mandatory_unit("my_template", "unit_key1", 4);

3) Add units to the template that can be randomly generated, with their weighting (that is their chance of being picked, this is not how many will be picked)

random_army_manager:add_unit("my_template", "unit_key1", 1);

random_army_manager:add_unit("my_template", "unit_key2", 1);

random_army_manager:add_unit("my_template", "unit_key3", 2);

4) Generate a random army of 6 units from this template

local force = ram:generate_force("my_template", 6, false);

Output: "unit_key1,unit_key1,unit_key1,unit_key1,unit_key2,unit_key3"

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

Random Army Manager Functions

Functions relating to the Manager and its control over the various defined forces

random_army_manager:new_force(string force key)

Adds a new force to the random army manager

Parameters:

1

string

a unique key for this new force

Returns:

  1. boolean Returns true if the force was created successfully

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 44

random_army_manager:add_unit(string key of the force, string key of the unit, number weight value)

Adds a unit to a force, making it available for random selection if this force is generated. The weight value is an arbitrary figure that should be relative to other units in the force

Parameters:

1

string

key of the force

2

string

key of the unit

3

number

weight value

Returns:

  1. nil

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 66

random_army_manager:add_mandatory_unit(
  string
key of the force,
  string
key of the unit,
  number
amount of these units
)

Adds a mandatory unit to a force composition, making it so that if this force is generated this unit will always be part of it

Parameters:

1

string

key of the force

2

string

key of the unit

3

number

amount of these units

Returns:

  1. nil

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 82

random_army_manager:generate_force(
  string
key of the force,
  number
amount of units,
  boolean
pass true to return the force as a table
)

This generates a force randomly, first taking into account the mandatory unit and then making random selection of units based on weighting. Returns an array of unit keys or a comma separated string for use in the create_force function if the last boolean value is passed as true

Parameters:

1

string

key of the force

2

number

amount of units

3

boolean

false to get a comma separated string

Returns:

  1. object Either a table containing the unit keys, or a comma separated string of units

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 98

random_army_manager:remove_force(string key of the force)

Remove an existing force from the force list

Parameters:

1

string

key of the force

Returns:

  1. nil

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 141

random_army_manager:mandatory_unit_count(string key of the force)

Returns the amount of mandatory units specified in this force

Parameters:

1

string

key of the force

Returns:

  1. nil

defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 154

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