Module:UnitData/doc

This module provides functions to display unit data, store them into the wiki database, and automatically adjust unit data for derived maps. It is heavy optimized and designed to replace its template equivalent.

Usage
The entry point of this module is simply. Two different sets of parameters are accepted by the module, depending on whether unit data is defined or retrieved from the database.

Unit definitions
To define units for a map, add the following to the map page itself:


 * mapImage: (Optional) Map image using Template:MapLayout or . Initial units should not be added, they are automatically populated by this module. The same map image is used for all unit tabs. This parameter is required if any unit specified in the module is a reinforcement unit.
 * globalai: (Optional) The default AI setting for units that do not have their own ai specifications. This is mostly useful for manually inputted unit data. Apart from the values accepted for unit definitions, the following string values expand to commonly used settings:
 * : . This is also the default AI setting if this parameter is not given.
 * no cargo: (Optional) If true, do not store any units into the Cargo database. Random units (see below) are never stored regardless of whether this parameter is set.
 * no ai: (Optional) If true, do not show the AI settings tables.
 * Other parameters: Any parameter name that isn't one of the parameters listed above or a derived map parameter is considered a tab name. The parameter value is an ObjectArg list of hashes defining the units for the Normal tab. The difficulty of the tab is automatically determined from the tab name.
 * no ai: (Optional) If true, do not show the AI settings tables.
 * Other parameters: Any parameter name that isn't one of the parameters listed above or a derived map parameter is considered a tab name. The parameter value is an ObjectArg list of hashes defining the units for the Normal tab. The difficulty of the tab is automatically determined from the tab name.

Unlike the old templates, units no longer need to be defined in separate groups depending on their armies and reinforcement settings; the module automatically groups units and generates multiple unit tables as necessary.

Derived maps
To display units for a derived map, use the following parameters instead:


 * battle: Battle number for the derived map, e.g. 1 for the first battle.
 * derived: One of the tags for derived maps. See below for a complete list of supported values.
 * derivedMap: (Optional) Page name of the base map where the derived units were originally defined. Defaults to the current page (it is possible to display derived unit stats on the same page they are defined, but this is no longer done).
 * derivedTabs: An ObjectArg hash which maps tab names from the original map to tab names of the derived map. In the example above, the Normal tab contains derived units from the original map at Normal difficulty, while the Lunatic tab contains derived units from Hard difficulty. The new tab names must be supported by the derived setting for unit promotion to occur.
 * mapImage: Map image using Template:MapLayout or . Initial units should not be added, they are automatically populated by this module. The same map image is used for all unit tabs.
 * allyPos: Comma-separated list of ally starting positions, same as in Template:MapLayout. On derived maps with reinforcements, these starting positions must be declared outside the mapImage parameter, so that they will be placed only in the infobox but not in reinforcement layouts.

List of derived map settings
A list of values that can be used for the derived parameter, followed by the tab names supported by that setting. The tags have the following usage:
 * is applied to all Blessed Gardens.
 * is applied to all odd-numbered Grounds (e.g. Grounds of Earth: Earth 1, Grounds of Fire: Fire 3), similarly for.
 * is applied to odd-numbered Paralogue chapters with corresponding part numbers.  is for single-chapter Chain Challenges,   is for double-chapter Chain Challenges.   is for even-numbered chapters.
 * and  are used similarly but for story maps. Book number does not matter.
 * is applied to all Squad Assault maps.

Unit definition
Each hash inside a unit data list defines a single ally or enemy unit, corresponding to a single use of the old Template:UnitData. More precisely, each hash represents a spawn entry which may be used to produce multiple identical reinforcement units.


 * unit: Page name of the unit.
 * pos: Coordinate of the unit. Like Template:MapLayout,  corresponds to the bottom left corner.
 * rarity: Rarity of the unit.
 * level: Level of the unit. Levels above 40 can be obtained from internal map definitions, but all known values for 40+ levels can be deduced from the map mode alone.
 * slot: Internal slot order of the unit. The slot order 1 is assigned to the first unit defined in the map file, and increments by 1 for every other unit defined. On maps without reinforcements, this is equal to the slot index assigned to the spawned unit, and can be obtained by experimenting with the game AI.
 * stats: A 5-element array containing the base stats of the unit, excluding any stats coming from equipped skills and other skill adjustments such as Arena bonuses or blessings. This is not always equal to final stat subtracted by stat modifiers from skills because the game clamps final stats between 0 and 99, but such cases are extremely rare; consult the internal map definitions when in doubt.
 * weapon: Page name of the unit's equipped weapon. Use  to indicate absence of an equipped weapon.
 * refine: (Optional) Refine path of the unit's weapon. Must be one of,  ,  ,  ,  , or.
 * assist, special, a, b, c, seal: Skill name of the unit's equipped Assist / Special / Passive A / Passive B / Passive C / Sacred Seal. Use  to indicate absence of an equipped skill.
 * accessory: (Optional) Page name of the unit's equipped accessory.
 * cooldown: (Optional) Initial Special cooldown count of the unit. Only needed for units with a non-default cooldown count (but the module does not check whether the given count is indeed less than the default count).
 * max_cooldown: (Optional) Maximum Special cooldown count of the unit. Only needed for units with a non-default maximum cooldown count.
 * properties: (Optional) Comma-separated list of properties applied to the unit. Currently the following properties are accepted:
 * : Indicates that the unit is an ally unit rather than an enemy unit. Ally units have their own sections separate from enemy units.
 * : When used on an enemy unit that has both playable and enemy variants (e.g. ), indicates that the playable variant should be used for stat calculation and skill promotion on derived maps.
 * : When used on an ally unit that has both playable and enemy variants, indicates that the enemy variant should be used for stat calculation and skill promotion on derived maps.
 * ai: (Optional) AI settings for the individual unit. If omitted, uses the globalai value of the module invocation, otherwise completely overrides that default setting (note that this parameter does not accept simple string values). It should be a hash with the following subfields, all optional:
 * turn: The first turn from which the unit starts moving on its own.
 * group: The AI group number of the unit; when any unit from a group is engaged, all units from that group start moving.
 * delay: The number of turns the unit may wait after its AI group is engaged but before the unit starts moving.
 * break_walls: Indicates the unit will destroy breakable terrain.
 * tether: Indicates the unit will return to its starting position if it has no actions to take. (Needs further investigation.)
 * spawn: (Optional) Spawn settings for the unit. If omitted, the unit appears in the initial setup of the map, otherwise this entry represents one or multiple reinforcements. It should be a hash with the following subfields, all optional:
 * turn: The first turn starting from which reinforcements appear.
 * count: The maximum number of reinforcement units to appear.
 * target: The page name of the target unit used to check for spawning.
 * remain: The maximum number of target units remaining on the map before reinforcements appear.
 * kills: The minimum number of target units to kill before reinforcements appear.
 * cond: Only for old special map pages where reinforcement settings can no longer be tested. If present, overrides the other setting fields and uses it as the reinforcement description in the map visual.

The module tracks pages containing unit definitions where any of the weapon, assist, special, a, b, c, or seal parameters are not given.

Random units
On Tempest Trials only, random units can also be specified through this template. The unit definition takes a shorter format: {pos=;rarity=;slot=;level=;ai=;spawn=;random={moves=;weapons=;staff=};}; The pos, rarity, slot, level, ai, and spawn fields share their meanings with non-random units. The random argument is a hash with the following subfields:
 * moves: (Optional) Move type of the unit. Omit to allow all move types.
 * weapons: (Optional) Weapon type of the unit, or any of the weapon class names such as "Ranged" or "Physical". Omit to allow all weapon types.
 * staff: (Optional) If explicitly set to false, excludes staff weapon types.