First, inside battle_config.xml, we could find some entries, helpfully labelled as skirmish configurations with some explanations.
Code:
<!-- skirmish configuration -->
<skirmish>
<infantry>
<default>
<!-- ignore targets at a distance greater than the maximum range times this scale factor -->
<max-range-scale>1.5</max-range-scale>
<!-- must skirmish if within this range -->
<min-range>40</min-range>
<!-- stop at this distance if the enemy is blocking the path -->
<min-stopping-range>50</min-stopping-range>
<!-- time to react to being intercepted -->
<collision-reaction-time>8</collision-reaction-time>
<!-- retreat buffer time -->
<retreat-time>12</retreat-time>
<!-- don't skirmish until attackers are within this fraction of the missile range -->
<range-factor>
<moving>1.1</moving>
<shooting>0.80</shooting>
</range-factor>
</default>
<gunpowder>
<!-- ignore targets at a distance greater than the maximum range times this scale factor -->
<max-range-scale>1.5</max-range-scale>
<!-- must skirmish if within this range -->
<min-range>40</min-range>
<!-- stop at this distance if the enemy is blocking the path -->
<min-stopping-range>50</min-stopping-range>
<!-- time to react to being intercepted -->
<collision-reaction-time>12</collision-reaction-time>
<!-- retreat buffer time -->
<retreat-time>14</retreat-time>
<!-- don't skirmish until attackers are within this fraction of the missile range -->
<range-factor>
<moving>1.15</moving>
<shooting>0.80</shooting>
</range-factor>
</gunpowder>
</infantry>
<cavalry>
<default>
<!-- ignore targets at a distance greater than the maximum range times this scale factor -->
<max-range-scale>1.5</max-range-scale>
<!-- must skirmish if within this range -->
<min-range>30</min-range>
<!-- stop at this distance if the enemy is blocking the path -->
<min-stopping-range>50</min-stopping-range>
<!-- time to react to being intercepted -->
<collision-reaction-time>8</collision-reaction-time>
<!-- retreat buffer time -->
<retreat-time>12</retreat-time>
<!-- don't skirmish until attackers are within this fraction of the missile range -->
<range-factor>
<moving>1.1</moving>
<shooting>0.80</shooting>
</range-factor>
<!-- reaction time for cantabrian circle -->
<cantabrian-reaction-time>20</cantabrian-reaction-time>
</default>
<gunpowder>
<!-- ignore targets at a distance greater than the maximum range times this scale factor -->
<max-range-scale>1.5</max-range-scale>
<!-- must skirmish if within this range -->
<min-range>30</min-range>
<!-- stop at this distance if the enemy is blocking the path -->
<min-stopping-range>50</min-stopping-range>
<!-- time to react to being intercepted -->
<collision-reaction-time>8</collision-reaction-time>
<!-- retreat buffer time -->
<retreat-time>12</retreat-time>
<!-- don't skirmish until attackers are within this fraction of the missile range -->
<range-factor>
<moving>1.1</moving>
<shooting>0.80</shooting>
</range-factor>
<!-- reaction time for cantabrian circle -->
<cantabrian-reaction-time>20</cantabrian-reaction-time>
</gunpowder>
</cavalry>
</skirmish>
(A useful note to know is that M2TW uses metres to calculate for its distance in both the EDU and battle_config.)
From the get-go, we can see that the skirmishing parameters are divided into four unit categories: infantry default, infantry gunpowder, cavalry default, and cavalry gunpowder - this will be a very important part to making short-ranged cavalry skirmishers (javelins and pistols) effective later. Distances as mentioned can be considered as the radius from the "middle" of a unit, roughly where the banner appears on top of it. Let's go down each parameters one by one, as they interact with each others in many ways:
Code:
<max-range-scale>
Is written as a multiplier, by default identical in all four unit categories as 1.5. Defining the upper range, distance at which the unit can start running away from a threatening unit.
Know that this is a "soft" number, in which the unit may not start skirmishing if it is firing a salvo or reloading. This is a multiplier to the next line.
When multiplied, should not yield a number greater than the missile range of the unit as defined in the EDU or the unit will never attack as it is constantly running!
Default is 1.5 for all units.
Code:
<min-range>
Is the only "hard" number in this case, and forces the unit to run away from the enemy if it is less than this distance from the skirmishing unit, overriding any other parameters.
Multiply this number by <max-range-scale> to acquire the upper range. Default is 40 for infantries, 30 for cavalries which is identical to that of the normal infantry charge distance.
Setting it to a greater number yields much better results as the unit can start running before being charged, may prevent short-ranged units from ever attacking if set too high.
Code:
<min-stopping-range>
This is almost exactly as written by the devs, the distance that the skirmishing unit considered itself to be "safe" from enemy units other than the one it has been targeting.
This line is useful if the skirmishing unit go deep inside an enemy formation, but only the targeted unit is pursuing it as it consider other units to be less of a "threat".
Default is 50 for all units.
Code:
<collision-reaction-time>
A controversial line, popular AI mods such as ReallyBadAI set this value to zero, assuming instant reaction times from the unit's "AI", which actually cripples the skirmishing unit.
In reality, this is a "smart" parameter for the unit to predict how soon an enemy unit will reach it in seconds based and how soon to start running away.
Should be based on how fast the skirmishing unit as well as its missile range, so slower units with short ranges such as foot skirmishers will need a higher value than cavalry archers.
Default is 8 seconds for non-gunpowder foot skirmishers, cavalry skirmishers both non-gunpowder and gunpowder. 12 seconds for foot gunpowder units.
Code:
<retreat-time>
An interesting parameter as skirmishing units in M2TW actually skirmishes in "bursts", in that they re-evaluate their current safety state after each bursts of speed.
While setting this to a low value such as 1 would make the unit much more agile, it actually affects when gunpowder units with "reload" animations will attempt to stop and reload.
So having a large number here would actually benefit units such as infantry gunners, in which they should only attempt to reload when they are in a safe distance away from the enemy.
Default is 12 seconds for all units.
Code:
<range-factor>, <moving>, <shooting>
These are again multipliers, however they are based on the missile range of the unit as defined in the EDU. These are the distances at which a unit will turn around during skirmish mode.
The <moving>, and <shooting> parameters is defined by the current status of the skirmishing unit, moving however only refers when the unit is not actively using its ranged attacks.
Shooting is when the unit is either in its "reload" or "firing" states. Keep in mind that cavalry skirmishers are considered to be <shooting> if attacking on the move.
It is important to know that this distance will actually be overrode by the actual distance covered by the skirmishing unit from <retreat-time> multiplied by its speed.
Again, this is great for infantry gunners who may actually want to run a little out of the range of their weapon to reload before returning to attack again.
Cavalry skirmishers should have a smaller multiplier than 1.0 for <shooting> than <moving> as it allows them to keep in range of their weapon while skirmishing.
Code:
<cantabrian-reaction-time>
Only applies for cavalry skirmishers as they are the only ones capable of the ability.
Appears to overrides the <collision-reaction-time> parameter for units currently in the shooting circle formation. Time in seconds.
Probably put in place as a balancing mechanic to make units using the Cantabrian circle more susceptible to melee as the ability allows for excellent missile evasion rates.
Second is the EDU, as we know as the basis to most mods as it offers an easy access to unit attributes. Below are three typical missile unit with the relevant information highlighted in
red:
Code:
type Aztec Archers
dictionary Aztec_Archers ; Aztec Archers
category infantry
class missile
voice_type Light
banner faction main_missile
soldier Aztec_Archers, 64, 0, 0.8
attributes sea_faring, hide_forest, can_withdraw, very_hardy, free_upkeep_unit
move_speed_mod 1.3
formation 1.2, 1.2, 2.4, 2.4, 4, square
stat_health 1, 0
stat_pri 7, 1, arrow, 140, 25, missile, missile_mechanical, piercing, none, 25, 1
;stat_pri_ex 0, 0, 0
stat_pri_attr no
stat_sec 5, 1, no, 0, 0, melee, melee_blade, blunt, mace, 25, 1.2
;stat_sec_ex 0, 0, 0
stat_sec_attr no
stat_pri_armour 2, 3, 5, leather
;stat_armour_ex 2, 0, 0, 0, 3, 5, 5, leather
stat_sec_armour 0, 0, flesh
stat_heat 0
stat_ground 1, 2, 3, -2
stat_mental 6, normal, trained
stat_charge_dist 30
stat_fire_delay 0
stat_food 60, 300
stat_cost 1, 260, 60, 55, 135, 380, 4, 110
armour_ug_levels 1
armour_ug_models Aztec_Archers
ownership aztecs, slave
era 0 aztecs
era 1 aztecs
era 2 aztecs
;unit_info 5, 5, 8
recruit_priority_offset 15
type ME Hand Gunners
dictionary ME_Hand_Gunners ; Hand Gunners
category infantry
class missile
voice_type Light
banner faction main_missile
banner holy crusade
soldier ME_Hand_Gunners, 56, 0, 0.8
attributes sea_faring, hide_forest, hardy, can_withdraw, gunpowder_unit, cannot_skirmish, gunmen
formation 1.2, 1.2, 2.4, 2.4, 3, square
stat_health 1, 0
stat_pri 14, 3, hand_gun_bullet, 100, 15, missile, missile_gunpowder, piercing, none, musket_shot_set, 25, 1
;stat_pri_ex 0, 0, 3
stat_pri_attr ap
stat_sec 9, 3, no, 0, 0, melee, melee_blade, piercing, sword, 25, 1
;stat_sec_ex 0, 0, 0
stat_sec_attr no
stat_pri_armour 3, 4, 0, metal
;stat_armour_ex 3, 5, 0, 0, 4, 0, 0, metal
stat_sec_armour 0, 0, flesh
stat_heat 1
stat_ground 1, 1, 0, -2
stat_mental 8, normal, trained
stat_charge_dist 30
stat_fire_delay 0
stat_food 60, 300
stat_cost 1, 550, 100, 60, 140, 580, 4, 210
armour_ug_levels 2, 3
armour_ug_models ME_Hand_Gunners, ME_Hand_Gunners_ug1
ownership moors, turks, timurids
era 1 moors, turks, timurids
era 2 moors, turks, timurids
;unit_info 9, 13, 7
recruit_priority_offset 15
type Jinetes
dictionary Jinetes ; Jinetes
category cavalry
class missile
voice_type Light
banner faction main_cavalry
banner holy crusade_cavalry
soldier Jinetes, 24, 0, 1
mount fast pony
mount_effect elephant -4, camel -4
attributes sea_faring, hide_forest, can_withdraw, cantabrian_circle
formation 2, 4.4, 3, 6, 3, square
stat_health 1, 0
stat_pri 9, 2, cav_javelin, 60, 8, thrown, missile_mechanical, piercing, spear, 25, 1
;stat_pri_ex 0, 0, 0
stat_pri_attr ap, thrown
stat_sec 7, 2, no, 0, 0, melee, melee_blade, piercing, sword, 25, 1
;stat_sec_ex 0, 0, 0
stat_sec_attr no
stat_pri_armour 2, 4, 6, leather
;stat_armour_ex 2, 3, 0, 0, 4, 6, 6, leather
stat_sec_armour 0, 0, flesh
stat_heat 1
stat_ground 0, 0, 0, 0
stat_mental 5, normal, trained
stat_charge_dist 45
stat_fire_delay 0
stat_food 60, 300
stat_cost 1, 640, 130, 65, 155, 640, 4, 190
armour_ug_levels 1, 2
armour_ug_models Jinetes, Jinetes_ug1
ownership spain, portugal, slave
era 0 spain, portugal
era 1 spain, portugal
;unit_info 7, 9, 12
recruit_priority_offset 10
The first highlighted line is
category, followed by
infantry (or
cavalry in the Jinetes unit below), this line defines whether the unit is considered a foot unit or a mounted unit. Mounted missile units are allowed to attack while moving if "fire at will" is enabled in battle, or while they are moving as a result of a skirmish action while firing. Foot units may not use their ranged attacks while moving.
The second line is an unique addition to M2TW after RTW, "
move_speed_mod 1.3" is a special modifier for the designated unit for it to move at the multiplier of speed over other units that uses the same animation set, in this case covers 30% more ground in the same time. This is a very useful line for the optimisation as we will discuss later.
The third unique highlighted number
140 is the "normal" maximum missile attack range for the "Aztec Archers" unit, that is, the distance at which the unit is allowed to make a ranged attack without taking into range modifiers such as elevations (where as generally, units in higher elevations can release their missiles as a longer range than units on flat grounds). This normal range is mainly used in the <range-factor> parameters in the battle_config file, but also interacts with other lines indirectly.
The fourth highlighted word is
gunpowder_unit, this is an unit attribute which makes the unit use the <gunpowder> parameters over <default> in the battle_config file as well as applying some hard-coded behaviour into the unit. A basic hard-coded behaviour is that the unit will have an extra "reload" animation after firing if the animation exists in the soldier's animation set. (An interesting design choice in M2TW is how gunpowder units pre-load their weapons, as opposed to crossbowmen, who keeps their weapons unloaded until just before they are ready to loose.)
Fifth is
cannot_skirmish, which dictates that the missile unit will not be able to engage in skirmish mode (nothing to stop manual control by the player of course). The devs likely implemented this for very short-ranged units such as foot javelin skirmishers, hand gunners, and grenadiers as a band-aid fix for them never using their ranged attacks due to skirmishing all the time rather than making them skirmish properly, we can get rid of this line completely once optimisation is complete.
Sixth is
cantabrian_circle attribute, only used for cavalries to engage in a rapidly spinning formation in battle to avoid missiles, unique, but not important to the optimisation process.
The seventh and the last highlight is
thrown, this is a special weapon attribute that makes the weapon disappear from the hand of the individual soldiers after the firing state. While this is great as eye candy, it is not so great for efficiency as the unit will take an extra ~2 seconds to "reload" after releasing a salvo, slowing down their fire rates significantly. Note that this attribute also gives the unit a
great boost in damage versus elephant type units, as well as a different ranged attack cursor.
Outside of battle_config.xml and the EDU, the speeds at which unit can discharge their weapon are largely decided by their animations, which is defined in descr_skeleton.txt. There are several lines of codes that does just that:
Code:
anim attack_missile_ready
anim attack_missile_hold
anim attack_missile_release
anim attack_missile_reload
anim attack_missile_reload_extended
Without working with the actual animation files themselves, the most that could be done is really the addition or the removal of lines (gunner animations with the reload/reload_extended lines removed are absolutely devastating), and the modification of "-if", or impact frames, which determines when the projectile is released at the defined frame in the animation. Animation files must be repacked after each modification, and the process is very involved, will not be covered here. (The animations themselves can also be sped up via a process known as SLERP.)