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
• Difficulty Factor is 1 on Expert, 1.5 on Standard, and 2 on Picnic.
• If no weapon is equipped, then aWATK is equal to (aLVL + aSTR) / 2.
• If Clear Strike is used, substitute all instances of aSTR and abSTR with aTEC and abTEC.
• If Shield Smite or Shield Rush are used, substitute aWATK with ShieldDEF * 3.
• If the attacker has an arm bind, aSTR is halved and rounded down.
• In the case of Clear Strike, if the attacker has a head bind, aTEC is halved and rounded down.
• If Ecstasy is cast, the damage is multiplied by a certain amount depending on the number of binds:
• No binds: Multiply the damage by a certain value ranging from 1.2 to 2.55 depending on the skill level.
• 1 bind: Multiply the damage by 2.
• 2 binds: Multiply the damage by 3.15.
• 3 binds: Multiply the damage by 5.6225.
Key Takeaways:
• The difference between the attacker's STR and the enemy's VIT plays a very large role in determining final damage.
• The higher an enemy's VIT is, the less damage a point of STR is worth. 50 STR vs. 49 VIT gets a ~2% increase to damage compared to 49 STR vs. 49 VIT, while 99 STR vs. 98 VIT gets a ~1% damage increase to damage compared to 99 STR vs. 99 VIT.

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
• Difficulty Factor is 1 on Expert, 1.5 on Standard, and 2 on Picnic.
• If the attacker has a head bind, aTEC is halved and rounded down.
• If the target has a head bind, dTEC is halved and rounded down.
• If the player casts Revenge Curse, an extra part is attached to this formula.
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:
• VIT is not used for calculating enemy defense against TEC-based damage at all.
• Binding an enemy's head massively amplifies TEC-based damage against them.
• The difference between the attacker's TEC and the enemy's TEC plays a very large role in determining final damage.
• A given value of TEC, when compared to the same value assigned to STR along with a weapon appropriate for that point in the game, will end up giving more base damage.
• Because enemy TEC stats tend to be less than their VIT (sometimes considerably so), TEC damage is going to often end up being higher than STR-based damage of equivalent stats.

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
• Difficulty Factor is 1 on Expert, 0.6 on Standard, and 0.2 on Picnic.
• If the attacker has an arm bind, aSTR is halved and rounded down.
• If an enemy attacks another enemy, the Defense factor and Difficulty Factor changes to these instead.
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:
• DEF plays a far smaller role in reducing damage against the player than VIT does. The Ability Multiplier reduces damage far more than Defense does, especially as you go further into the game.
• The same note under Player vs. Enemy STR about proportional increases also applies here.

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
• If the attacker has a head bind, aTEC is halved and rounded down.
• If the target has a head bind, dTEC is halved and rounded down.
Key Takeaways:
• VIT and DEF are used for calculating player defense against TEC-based damage, but they play such a small role in it that it barely matters.
• A player character whose head is bound will take considerably amplified TEC damage.

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:
• AGI is more important for attacker accuracy, LUC is more important for defender evasion.

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:
• TEC is more important for inflicting disables, LUC is more important for resisting disables.
• A sufficiently high attacker TEC/LUC spread compared to the defender TEC/LUC spread can massively Boost the infliction rate, up to a cap of 50x.

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:
• Inflicting a disable reduces that entity's vulnerability to it by 50% initially.
• Each turn, if an entity has accumulative resistance to a disable and is not currently afflicted with that disable, their accumulative resistance is reduced by 7%.
• There is a limit on how high accumulative resistance can go, but you're very unlikely to ever actually have it matter that much.

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:
• If your party has a low average LUC, even if you have a high LUC character like a Hexer inflict a disable, the duration of disables you inflict is still going to be hampered.
• Disables have a hard time limit of 5 turns.

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:
• Each point of TEC is roughly equal to an extra 1% tick damage.
• Every five points of TEC is equal to one extra point of base damage.

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:
• Each point of TEC is roughly equal to an extra 1% of healing.

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:
• Weapons:
• Swords: 0
• Axes: -5
• Staves: -5
• Katanas: +5
• Bows: 0
• Whips: +5
• Guns: -5
• Spears: 0
• Sonic Dagger: +30
• Armor:
• Heavy armor: -10
• Light armor: 0
• Clothes: 5
• Helmets: 0
• Gloves: +5
• Boots: +10
• Shields -5
• Accessories: 0
• Cianotedae: -50
Key Takeaways
• Equipment plays a very large role in determining turn order.

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:
• Preemptive chances are capped at ~30%, and have a floor of ~1.2%.
• Predator's values mean it has a minuscule chance of actually working.
• Predator also, effectively, reduces the chance of being blindsided, due to how the math works.

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:
• Blindside chances are capped at ~20%, and have a floor of ~0.8%.

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:
• Escape rates are the goddamned pits no matter what you do.