Campaign Director army structure documentation
Campaign Director Army Templates
What do they do?
The campaign director army template tables control the armies and fleets the AI produces in the campaign and how it values units when working out whether to recruit them. The Ai in the campaign will try and pick a template for an army/fleet based on what it can recruit and will use that template for that force in future when recruiting for it. The templates can be swapped in some circumstances that will be explained later.
The tables
The tables that control this are:
- cdir_unit_balance_configs
- cdir_unit_balance_group_qualities
- cdir_unit_balance_groups
- cdir_unit_balance_template_junctions
- cdir_unit_balance_templates
- cdir_unit_balances
- cdir_unit_qualities
- cdir_unit_quality_configs
- cdir_unit_quality_groups
- start_pos_factions
How it works
The below is a quick overview of how the system works, some of the tables will be gone into in more detail.
In the start_pos_factions table factions are assigned a balance_config and a quality_config.
- The balance_config dictates what army/navy templates a faction will use
- The quality_config dictates the value of units for that faction
The ability to set different configs for different factions allows control over what kind of army make up it wants and the makeup of those armies, biasing different factions to different units.
- cdir_unit_qualities sets the qualities for units in the different quality_configs and assigns those units to a quality_group from cdir_unit_quality_groups. The quality values for units are relative to other units set to be in a quality_group, not against all units.
- cdir_unit_balance_group_qualities links the cdir_unit_quality_groups into a cdir_unit_balance_groups group for the different cdir_unit_balance_configs and allows the quality_groups to be organised by quality within each balance_group. In a similar way to the cdir_Unit_qualities table values in the quality field for each quality_group_key are measured relative to others assigned to the same group_key within a config_key
- cdir_unit_balance_templates contains the list of all the different army/navy templates
- cdir_unit_balance_template_junctions links the templates to the cdir_unit_balance_configs and sets a priority for each template within that config.
- cdir_unit_balances sets up the templates themselves by linking each template to various balance_groups, setting the ideal percentage of each balance_group in the template and min/max number of units allowed for each template
Balances
This table is perhaps the most powerful in the whole of this system. It controls what types of units, and how much of each type go into each balance template.
For each template you can add as many groups as you like (though the total ideal_pct should add up to 1), the groups being taken from the cdir_unit_balance_groups tables (which linked them to the groups used in cdir_unit_qualities) and for each group you can specify what percentage of an army should be made up of them, how much that pct can vary and if a minimum number of them are required.
Balance template junctions
This table links the balance templates to the balance configs and gives them a priority. You will notice that there are a lot of different balance_templates, some with negative priority values.
The large number of templates is needed to accommodate all the different possibilities of units a faction may be able to recruit (say for example all dojos are damaged and a faction can only recruit from the castle, or all buildings apart from the missile dojo is damaged) and if there is no available template to deal with what the AI can recruit, it will not recruit any units or will recruit very badly!
Negative values are used for these contingency templates as a way of saying to the AI they are less than ideal. The AI will check to see if it can replace the template a force is using with one of a higher priority if it has a negative one and will swap as soon as it is able to.