Mechanics: Algorithms

Do you like mathematical formulae? Do you like reading internal game formulae and inferring things based on it?

You probably don't! In any case, though, this update'll cover a variety of EOU's internal formulas, along with giving short summaries of what kinds of impacts these have on the game as a whole.

Credit for documenting these things goes to violentlycar, and most of the writeup formatting credit goes to Dr. Fetus.

Lowercase a in front of a variable means attacker. Lowercase d means defender. Lowercase b means base. For example, abSTR means "attacker base STR," which effectively means "base STR even if the attacker has their arms bound."


Player vs. Enemy Damage: STR-Based
Damage = (Base Damage - Defense) * Ability Multiplier * Skill Power * Difficulty Factor * Modifiers

Base Damage = (abSTR + aWATK + 10) * [(95 + (abSTR * 0.2)) / 100]
Defense = [250 + (dVIT * 2.5)] * (dVIT * 3.5) / 1000
Ability Multiplier = [((aSTR + 10) / (dVIT + 10)) + 1] * 0.3333
Key Takeaways:

Player vs. Enemy Damage: TEC-Based
Damage = (Base Damge - Defense) * Ability Multiplier * Skill Power * Difficulty Factor * Modifiers

Base Damage = [3.5 + (abTEC / 80)] * abTEC
Defense = [250 + (dTEC * 2.5)] * [dVIT + (dTEC * 2.5)] / 1000
Ability Multiplier = [((aTEC + 5) / (dTEC + 5)) + 1] * 0.3333
Revenge Damage = Damage * [1 + ((MaxHP - CurHP) * 20 / 10000] * [((Missing HP%) + (Missing HP% ^ 2) + 0.02) / 2]

Missing HP% = [100 - ((CurHP / MaxHP) * 100)] / 10
Key Takeaways:

Enemy vs. Player Damage: STR-Based
Damage = (Base Damage - Defense) * Ability Multiplier * Skill Power * Difficulty Factor * Modifiers

Base Damage = [5 + (abSTR / 40)] * abSTR
Defense = [((dVIT + dDEF) * (dDEF + 250)) / 1000)]
Ability Multiplier = [((aSTR + 10) / (dVIT + 10)) + 1] * 0.3333
Defense = [250 + (dVIT * 2.5)) * (dVIT * 3.5] / 1000
Difficulty Factor is to 1 on Expert, 1.5 on Standard, and 2 on Picnic.
Key Takeaways:

Enemy vs. Player Damage: TEC-Based
Damage = (Base Damage - Defense) * Ability Multiplier * Skill Power * Difficulty Factor * Modifiers

Base Damage = [3.5 + (abTEC / 80)] * abTEC
Defense = [(((dVIT + dDEF) * 0.28571) + (dTEC * 2.5)) * (250 + (dTEC * 2.5))] / 1000
Ability Multiplier = [((aTEC + 5) / (dTEC + 5)) + 1] * 0.3333
Key Takeaways:

Buff and Debuff Diminishing Returns
The game prioritizes the strength of the multipliers, from strongest to weakest when applying diminishing returns, not the order in the case of buffs.

The penalties are as follows:
10% for damage increasing passives.
15% for damage increasing buffs.
10% for defense increasing passives.
20% for defense increasing buffs.

For example, a 1.4x multiplier becomes 1.34x for 1 extra damage buff, and 1.28x for 2 extra damage buffs.

Enemy Targeting
Targeting:

VV = "Valid Value". Everyone has a VV of 2 by default.
TC = "Target Chance". Everyone has a TC of 10 by default.
PV = "Personal Value".

Here are things that affect PV:

If you are in the front row, +1 VV
If you have the most current HP, +1 VV
If you are asleep, +1 VV
If you have used Provoke, add base Provoke effect to VV
If you have used at least level 5 Chain Dance, add base Provoke effect to VV
If you have the least current HP, -1 VV

VV cannot go below 1 or exceed 6.

Here are the things that affect TC:

If you've used Provoke or Chain Dance, TC = TC + Aggro Value.

TC cannot go below 1 or exceed 255.

For targeting, let MV be highest VV among potential targets.
Roll a number between 1 and 100. If it's less than 49, subtract MV by 1.
Continue rolling until the number is greater than or equal to 49, or MV becomes 1.
Characters whose PV is lower than MV are disqualified from being targeted this turn.
Add the total TC of all remaining valid targets (tTC).

To determine who is hit among valid targets, use this formula:

For each character, starting from upper left slot and moving toward the back right row:

A = TC * 100 / tTC

Roll a number between 0 and 101. If that number is less than A, that character is targeted.

If no one is targeted this way, roll a number between 0 and 100.

If that number is 75 or lower, target the character with the most HP in the front row.
If that number is between 76 and 95 inclusive, target the character with the most HP in the back row.
If that number is 96 or higher, ???

Accuracy
A = [((aLUC + (aAGI * 2)) + 30) * 10] / [(dAGI + (dLUC * 2)) + 30]

A is rounded down.

If A < 10, B = [1 - ((1 - (A / 10)) ^ 2)] * [(Base Accuracy + Skill Modifier) * 10]
If A >= 10, B = [(87.5 + (((A / 20) * 50) * (A / 20))) * (Base Accuracy + Skill Modifier)] / 10]

Base Accuracy Parameters:
If a party member is using a skill that does not require a weapon, Base Accuracy = Skill Accuracy.
If a party member is using a skill that requires a weapon, Base Accuracy = Weapon Accuracy + Accuracy Modifier.
If a party member does not have a weapon equipped, Weapon Accuracy = 95.
If an enemy is using a regular attack, Base Accuracy = 99.
If an enemy is using a skill, Base Accuracy = Skill Accuracy.

C = B * Accuracy Modifiers * Evasion Modifiers

If C > 1500, C = 1500

If the attacker is blinded, D = C * 0.33

If the skill bypasses accuracy checks or the target is petrified, asleep, panicked, blinded, paralyzed, or leg bound, D = 1000

Else, D = C.

Roll a number between 1 and 1000. If that number is lower than or equal to D, the attack lands.
Key Takeaways:

Disable Infliction
A = [((aLUC + (aTEC * 2)) + 30) / ((dTEC + (dLUC * 2)) + 30)] * 10

IR = Skill's infliction rate

If A <= 2, B = IR
If A > 2 & A < 50, B = IR * A
If A >= 50, B = IR * 50

C = B * Vulnerability * Difficulty Factor * Modifiers

Vulnerability = Base Vulnerability - Accumualtive Vulnerability
Difficulty Factor for enemies is 1 on Expert, 0.6 on Standard, and 0.2 on Picnic. For players, this is always 1.

If C is greater than 1500, then set it to 1500.

Then roll a number between 0 and 1000. If that number is lower than or equal to C, the disable lands.
Key Takeaways:

Accumulative Resistance
Each time a disable (that isn't stun) is inflicted, a value of 50 is subtracted from the target's current accumulative resistance value for that particular disable, which always starts at 0, and a resistance cap is placed on the target.

Once the disable wears off, the accumulated resistance will gradually wear off. For each turn the target does not have the specified disable, a value of 7 is added to the accumulative resistance value. This continues until that same disable is inflicted again, at which point it would halt until the disable wears off, or until they run into the resistance cap, at which point it will halt until the disable is inflicted again.

The resistance cap is determined by this formula:

SA = Total successful applications of the disable.

If SA <= 3, then A = (0.85 ^ SA) * Base Vulnerability
If SA > 3, then A = [0.85 ^ (1 + (SA / 2))] * Base Vulnerability

This part of the formula: (1 + (SA / 2), is rounded up.

Resistance Cap = A - Base Vulnerability

The end result is rounded down. Accumulative Resistance cannot be greater than the Resistance Cap at any point.

If a player unit dies, then their Accumualative Resistance and Resistance Cap is set back to 0.
Key Takeaways:

Disable Recovery
rLUC = recovering character's LUC
etLUC = average LUC of the opposing team

T = Total times ailment recovery has failed.

M = 0 + Recovery Aria - Relapse Curse

A = sqrt[(rLUC + 20) / (etLUC + 20)] * 10

If A <= 5, B = (5 + (T * 7.5)) + M
If A > 5 and <= 20, (B = (10 + (T * 15)) * A / 10) + M
If A > 20, B = (20 + (T * 30)) + M

If T = 0, then B = 0

Check for a flag. If it's found, add to B a value found at [R4 + 0x4E]. This value would allow recovering from ailments on the same turn they are applied.

If B < 0, then B = 0
If B > 80, then B = 80

If T >= 4, then B = 100

Check for another flag. If it's found, then B = 100.

Roll a number between 0 and 99. If that number is less or equal to B, recover from the ailment.
Key Takeaways:

Severing Slash Activation
AR: Activation rate
LD: The difference in level between the user and the highest level enemy in the encounter + 20. This value is capped at 35.

If the level difference is less than or equal to 20:

A: [(LD ^ 3) / 80] * (AR / 100)

If the level difference is greater than 20:

A: [(LD ^ 2) / 4] * (AR / 100)

B: Random number between 0 and 1000.

If A > B, activate Severing Slash.

Poison Damage
RNG1 + [(RNG2 + (Base Poison Damage + (TEC / 5))) * (1 + (TEC / 100))]

RNG1: A random number from 0 to 5.
RNG2: A random number from 0 to 5.
Bug: If the target is defending, the damage is halved.
Key Takeaways:

Healing
[(Base Heal + (TEC / 5)) + RNG] * [1 + (TEC / 100)] * Difficulty Factor * Heal Mastery

RNG: A random number from 0 to 5.
Difficulty Factor for players is 1 on Expert and Standard. On Picnic, this increases to 1.5. For enemies, this is always 1.
Key Takeaways:

Speed
[(Equipment Speed Mod + 100) * AGI * Skill Speed Mod * Random number between 90 and 110 / 10000] * Modifiers
When a rare breed acts, their AGI is multiplied by 10.
Equipment Speed Modifiers:
Key Takeaways

Boost Gain
minB = Minimum Boost. This is 5 in all cases.
maxB = Maximum Boost. This is 15 in all cases.
SBU = Skill Boost Up
GBU = Gear Boost Up

minB = minB + (SBU * 0.1)
maxB = maxB + (SBU * 0.05)

Then,

minB = minB + (GBU * 0.1)
maxB = maxB + (GBU * 0.05)

Roll a random number between minB and maxB. This value is the amount of Boost you gain this turn.

When an ally dies, all remaining allies receive a Boost roll and the dead ally loses half their current Boost.

Axcelas add 10 to your current Boost.

Additionally, at the end of combat, each character rolls for Boost again.

Then, after the end of combat roll, characters get a further amount of Boost based on unknown factors. It always seems to be within the 5-15 range, though...

Preemptive Attacks
A = [((Party's Average AGI * 2) + Party's Average LUC + 20) * 10] / [Enemy's Average AGI + (Enemy's Average LUC * 2) + 20]

If A <= 2, B = 12
If A >= 50, B = 300
Else, B = A * 6

Roll a number between 1 and 999. If the rolled value is below B, the preemptive is successful.

If that fails, roll another number between 1 and 999 and check against Predator's preemptive chance. If that number is lower than Predator's value, the preemptive is successful. Otherwise, move onto the blindside check.
Key Takeaways:

Blindsides
A = [((Enemy's Average AGI * 2) + Enemy's Average LUC + 20) * 10] / [Party's Average AGI + (Party's Average LUC * 2) + 20]

If A <= 2, B = 8
If A >= 50, B = 200
Else, B = A * 4

Then, check B against the value that was previously rolled to check whether Predator was successful. If this roll succeeds, the blindside is successful. Otherwise, roll a number between 1 and 100 and check against the value of Awareness. If that number is lower than Awareness' value, the blindside fails. Otherwise, no one gets the advantage.
Key Takeaways:

Escaping
C = 10 * (A / B) ^ 2

A = Escaper's AGI + Escaper's LUC + 20
B = Enemy's Average AGI + Enemy's Average LUC + 20

If C <= 2:

Escape Rate = (30 * D * 2 / P) + (25 / P + E) / 5

If C > 2 & C < 40:

Escape Rate = (30 * D * 2 / P) + ((25 / P + E) * C) / 10

If C >= 40:

Escape Rate = (30 * D * 2 / P) + (25 / P + E) * 4

D = Number of allies who are either sleeping or panicked + (number of allies who are either dead or petrified * 2).
E = Previously attempted escapes.
P = Allies in party.

Then:

Check for a value in player stats then add that value to Escape Rate. (Unknown)
Check for a value in player stats then subtract that value from Escape Rate. (Unknown)
Add the escape bonus from Flee if applicable (Bug: Each attempt to escape with Flee adds Flee's bonus to itself. so, level 1 flee is 50% bonus on attempt 1, 100% bonus on attempt 2, 150% bonus on attempt 3, etc.)
Multiply the score by 3 if boosted.
Check if the score is over 100 and set it to 100 if it is.
Load another value in the escaper's stats. (Unknown)
Cap it to 90 if Flee isn't being used and cap it to 99 if is.
Key Takeaways:

Table of Contents