General Info
Guides & Resources
Info For Beginners
Glossary
Game Mechanics
Guides & Information
Useful Tools
Guides & Resources (old)
Forks
Info For Beginners
Glossary
Game Mechanics
Guides & Information
Useful Tools
Guides & Resources (old)
Forks
While FF4's battle RNG generally can't be manipulated without a TAS, the results are still far from random.
FF4's pseudorandom number generator (PRNG) relies on a table of the numbers from 0 to 255, in a predetermined order.1) In battle, the game keeps track of the current index into this table, and each RNG roll takes the number at the current index and increments the index. The index is also incremented once per frame.
Since the PRNG table itself can only return values from 0 to 255, in order to roll a number in a specific range the value from the PRNG table is divided by the size of the range, and the remainder is used as the result2). This introduces bias into the results if the range's size does not divide evenly into 256.
This bias is very apparent in percentage-based rolls, which work by choosing a pseudorandom number from 0-98. For most rolls in the game, if this result is less than the threshold (% chance to hit, etc.), the roll succeeds.3)
To give some intuition about how this bias occurs: there are 99 numbers in the range 0-98. Looking at the remainders that can result from dividing the PRNG table values by 99:
So the chances of getting a roll of 0-57 are much higher than the chances of getting a roll of 58-98. Since low rolls are more likely to succeed, this means percentage-based rolls have a higher probability of success than their stated percentage.
Here's a chart showing the bias of percentage-based rolls- mouse over the line to see exact numbers:
Since the PRNG table is just a list of numbers stored in a predetermined order, patterns can arise in RNG results.
When a spell is reflected, the game chooses a slot4) at random for the new target, regardless of whether that slot is occupied. If there is nothing in that slot, it keeps trying until it rolls a slot with an eligible target. If most slots are empty, the game can go through quite a few PRNG values before it gets to a usable one. This leads to patterns in the PRNG rolls that follow, which includes damage calculations.
In the extreme case of reflecting a spell at a single living monster, only 32 possible PRNG values (1 in 8) will result in the correct targeting, meaning the PRNG index will be in one of 32 specific places in the table. This limits the possible damage amounts based on the slot the monster is in and the spell used.
Since the Zeromus fight has only one valid monster target, spells reflected off of party members are limited to a specific set of damage rolls. As it turns out, a reflected Nuke against a monster in the second slot5) will generally roll slightly lower damage than expected.
The actual values are hard to calculate due to the PRNG index also incrementing once per frame, but are somewhere in the range of 5-50 less damage on average for a 4-roll Nuke.
Attempting to reflect Float onto the CPU's Attacker orb can make Quake a safe option for handling the fight. However, due to patterns in the PRNG table, when all three targets are alive, the chances of a reflected spell hitting CPU are likely higher.
According to this spreadsheet a reflected spell has a 40% chance of hitting CPU, vs 30% for each small orb. With only CPU and Attacker alive, the chances are 51% for CPU and 49% for Attacker. However, the spreadsheet does not account for the possibility of the target-picking loop taking more than one frame, so it may not be accurate.
Similar to reflected spells, monsters' attack targeting also chooses a slot at random until it finds a valid target. This means that when at least one party slot is empty or otherwise untargetable (dead, hidden, jumping, etc.), there will be patterns to which slot gets targeted and the ensuing damage rolls. In theory this could be used to improve survivability in extreme situations, such as helping Edward live long enough to Hide from EvilWall.