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 Battle | |
Loaded in Frontend |
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:
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:clone_force(string
old force key, string
new force key)
-
Clones an existing force to the random army manager
Parameters:
1
string
the key of the force to be cloned
2
string
a unique key for this new force
Returns:
boolean
Returns true if the force was cloned successfully
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 77
-
random_army_manager:combine_forces(string
new force key, ...
old force keys)
-
Combines existing forces to the random army manager. If all specified forces have the same faction, then that faction is given to the new force. Otherwise, the faction of the new force is left blank.
Parameters:
1
string
a unique key for this new force
2
...
One or more existing force keys
Returns:
boolean
Returns true if the forces were combined successfully
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 97
-
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:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 145
-
random_army_manager:add_mandatory_unit(
key of the force
string,
key of the unit
string,
amount of these units
number
) -
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:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 166
-
random_army_manager:set_faction(string
key of the force, string
key of the faction)
-
Sets the faction key associated with this force - Allows you to store the faction key used to spawn the army from the force
Parameters:
1
string
key of the force
2
string
key of the faction
Returns:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 187
-
random_army_manager:generate_force(
Key of the force.
string
,
Number of units to spawn
[number
],
Return as table
[boolean
]
) -
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
Key of the force.
2
optional, default value=nil
If you have no non-mandatory units specified, this must equal the sum of all mandatory units (since no optional units are available for generating additional units). If unspecified, only the sum of your mandatory units will be spawned.
3
optional, default value=nil
Pass
true
to return the force as a table,false
to get a comma separated string.Returns:
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 202
-
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:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 249
-
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:
nil
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 263
-
random_army_manager:get_force_by_key(string
key of the force)
-
Returns the force of the specified key, false if it's not found
Parameters:
1
string
key of the force
Returns:
table
Returns the force
defined in ../../Warhammer/working_data/script/_lib/lib_campaign_random_army.lua, line 275