Unit Pairing

Unit pairing is a feature in The Legend of Masaug, which allows two units to combine together to form one (ideally) stronger unit.

Basic Stat Changes
Pairing two units into one will adjust their stats according to the following:

Their Mana and Spirit will remain separate. However, spellcasting in pairs works differently than attacking, as you will be able to select a spell for each unit to cast. Each unit will then spend Mana equal to the cost of the spell that they individually cast. If one of the units has not castable spells, or does not have enough Mana to cast any of their spells, then they will not get to perform an action. This makes it less advantageous to pair a spellcaster with a non-spellcaster, as this will significantly affect their damage output.

Their Health and Strength will add. This makes it advantageous to use unit pairings to eliminate single units when on the offensive. The health addition "adds" both current health and maximum health. For example, if unit A has 75/80 health, and unit B has 4/70 health, then the pairing of units A and B will have 79/150 health. This means that you can "save" a low health unit by pairing them with a healthier unit to effectively "tank" incoming damage for them.

Their Defense will be a weighted average of the Defense stat of each unit, weighted as 3/4 the higher defense stat, and 1/4 the lower defense stat. This can be advantageous in protecting lower defense units if they are under attack, especially once Synergy is considered.

Their Agility and Mobility will each be the lower of the two units. This means that pairing two units with significant differences in these stats can be disadvantageous, and should be considered more carefully than pairing units with small differences in these stats.

Their Morale will be calculated using the following formula:

$$M = \frac{200}{1+19 e^{-\frac{M_A}{25}}}$$

Where M is the Morale of the paired units, and $$ M_A $$ is the average of the two individual units' Morale. This function always results in M being greater than $$ M_A $$, while asymptotically increasing to 200, the upper limit on Morale (also known as a Logistic Function).

Finally, pairing two units will take one turn, so if you plan on using paired units offensively, it is best to pair them before they are needed to attack.

Synergy
Main Article: Synergy

In addition to the rules given above, there is a synergy multiplier that is applied to the pairing's Strength, Defense, and Agility. This synergy multiplier is pair-specific, encouraging the player to know how well different characters work together, and to prioritize pairing units that have high synergy.

Unpairing
Upon unpairing, the two units will return to their individual Strength, Defense, Agility, and Mobility. In addition, the units' individual Morale will become the greater of 94% of their combined Morale, or 50. Notably, both units will unpair with equal morales, which will often (but not always) be greater than their average pre-paired morales.

To calculate the health of each unpaired unit, the following process is performed:
 * 1) Each unit is restored to the health that they were at before the unit pairing.
 * 2) Each unit then individually receives 1/2 of the total healing that the pair received. If the healing was an odd number, then the unit that is "weaker" will be given the 1 extra point of healing.
 * 3) If one unit received enough healing to "overheal" (have more current health than their max health), then the difference is given to the other unit.
 * 4) Each unit then receives damage equal to the lower of: (a) 1/2 of the damage the pair took, or (b) exactly enough damage to bring them down to 1 health.
 * 5) If (b) is applied above, then the difference is applied to the other unit in the pair, provided this does not bring the unit below 1 health (The only case where this is possible is if the units unpair while the pair has 1 health, in which case, both units will have 1 health when unpaired).

Note: to calculate which unit is "weaker", the following stats between the unpaired units are compared, and for the first stat in this list for which there is a difference between the two unit, the lower-stat unit will be considered weaker. If (for some reason), the two units have the same value for every one of these stats, both of them will receive the extra 1 point of healing. However, this in general should not happen, since every character has different stat curves.
 * Current Health
 * Defense
 * Strength
 * Max Health
 * Agility

Unpairing two units also takes 1 turn to discourage repetitive pairing and unpairing.