Current Suggested improvements…
Reference damage per hit to accuracy (ie the defense sword versus white spear problem)
Add in sub wiki pages for the extra details instead of referencing other's guides (problem with originality of data?).
Refer to The algorithms guide for more details on the exact calculations. Most of this information is referenced from here.
The formulas wiki page has more details about specific multipliers, and calculations of damage numbers.
Refer to The magic guide for details about spells.
The spell data wiki page has a few tables of most magic spells.
Refer to FF4 Enemy Stats for enemy statistics, such as attack, defense, resistances, weaknesses, race, etc.
Refer to The FF4 equipment Doc for weapon/armor stats.
Damage in FF4 is handled in a couple steps, the first is calculating the damage per hit, and the second is calculating the number of times your character hits. Lets start with the damage per hit calculation first…
Base damage for most characters is Weapon Base + Str/4 + Level/4, this is also the value shown in the menu, so calculating it isn't needed.
Bows, Yang and Edge follow slightly different formulas, more details here
Base damage is modified depending on various status effects and conditions, such as critical hits, berserk status, using the jump command, hitting elemental/racial weaknesses, etc.
Example, hitting a mage enemy with a mage killing weapon does increases base damage by 4x.
Tables of all the different modifiers listed here.
After all these modifiers, you are left with an attack value, which is then multiplied by a random number between 1 and 1.5, and then defense is subtracted. Note the multiplication is before the subtraction, which is why sometimes you can get hit for 1 damage, then the next hit deals several hundred.
Damage Per Hit = Final Attack Power * (Random between 1 and 1.5) - Target Defense.
Its also important to note that defense is doubled if the target is in the back row, including enemy targets. An enemy is backrow if the “frontmost” enemy sprite does not vertically share any space with target. The backrow bit does not affect this defense doubling.
This end result is the amount of damage per hit. Now we just need to calculate how many hits land…
Each character has an attack multiplier, and an accuracy value.
The number of attack multipliers is equal to Str/8 +Agi/16 +1.
Accuracy is weapon base accuracy + level/4.
Several things effect accuracy as well, most notably being in the back row. If you don’t have the longrange bit set, attacking from the back row halves accuracy, and if your target is in the backrow, accuracy is also halved. This means accuracy can be 1/4th its value if both conditions are active.
A list of all accuracy modifiers can be found here
For each attack multiplier, a random number is rolled, and based on accuracy its determined if it hits or not. So for 10 attacks with 80% accuracy, about 8 of them should hit, though this could be more or less.
However there is a chance for evading attacks. Enemies are bugged such that evasion isn't loaded unless set by their script, which only kainazzo and valvalis do. For those 2 and your party members however, you have an evade % and evade multipliers, and these are rolled to reduce the number of hits that land.
For example, at Fabul in the FE randomizer, Valvalis has 5 evades at 70% chance… and thus she will usually dodge 3-4 of your attacks. If you don't land more attacks than she evades, you won't do any damage.
Finally, once the number of landed hits is calculated, this is multiplied by the damage per hit, and you have your final damage.
Damage Dealt = Damage Per Hit * Number of Hits
The longrange bit (sometimes called backrow bit) is the games flag for using a long range weapon. No enemies have this bit, and for the SNES version of FF4, once the bit is set, it can’t be removed. This means if you equip a longrange weapon, such as the dwarf axe, then you don’t lose accuracy for being in the backrow for the rest of the game.
For people who can weapons in both hands, equipping the longrange weapon in the right hand will ensure they get the glitch, you don’t need to equip in both, only the right. Bows don’t care which way they are equipped for the glitch (though there is a damage penalty for equipping the bow in the primary hand).
For yang and edge who can equip weapons in both hands, weapon accuracy is also the average of the two weapons equipped. So a charm claw + catclaw yang would have ( 50%+99% )/2 , or 75% accuracy. If only the catclaw was equipped though, its accuracy would be used, or 99%.
Another significant modifier for accuracy is character in the middle slot has their accuracy increased by 5/4. So if someone with 50% accuracy was in the middle slot, this would become 62.5% accuracy. this applies to spells as well.
Once crucial note is Rosa’s aim ability sets evasion to 0%, and rosa’s accuracy to 255, so she can ignore val's tornado (beware of using this in the middle slot though, since the accuracy increase will overflow the value, to about 65% accuracy).
Magic damage is handled much the same as physical damage is, except spell power is drawn from a table. You can look here for a list of most spells power and accuracy, or refer to the Magic Guide, for the base power of every spell. This is also modified by resistances and stuff, much the same as physical attacks. Refer to the algorithm guide for a complete list of spell power modifiers.
Accuracy and spell attack modifiers are also handled similar to the physical system.
White magic multipliers are Will/4+1
All other magic Multipliers are Wisdom/4+1.
Note some spells only use a solo multiplier (such as the weak spell, or life spell). The magic guide lists this attribute on the spells.
Spell accuracy is the base spell accuracy+ wisdom or willpower/2 (based on magic type). Note this accuracy is also effected by the middle row, and can be helpful for some low accuracy spells.
Just like physical damage, spell damage per hit is spell power after modifiers, times random number between 1 and 1.5, minus magic defense.
If a spell has the option to be single cast, or multi-targeted, spell power will be divided by the number of targets.
Enemies are bugged such that magic evasion is never applied, but for characters you can calculate their magic evade based on stats and equipment, and magic evade multipliers based on stats.
Note that if magic defense equals 255, all spells automatically miss (valvalis and some twinharp bosses).
At the start of every fight, FF4 runs a calculation to determine the “base speed” of everyone in battle, both party members and enemies. We refer to this as Relative Agility (RA). This is how many atb ticks the character/enemy will have to wait after their last action until they can re-enter the queue.
In order to keep fights a somewhat consistent speed, the vanilla game determines everyone's base speed off of Cecil's Agility. In FE, The highest slot character (typically the middle slot) is used in the calculation, unless vanilla agility is turned on. This character is usually referred to as the Agility Anchor (AA). In practice the game tries to make the AA RA 5, and scale everyone else to this value. The math is…
RA=Floor( 5 * [AA agility] / [Target Agility] )
For example, if the AA is 20 agility, and the Target has 15 agility, then that becomes 100/15=6 and 2/3. The game rounds this to RA 6.
Special Cases. If RA is zero, then RA is set to 1. If the AA has 0 agility, then all RAs are set to 1.
The best way to visualize the RA system is with the use of of a lua script. This is not race legal, but directions on how to use it for practice purposes can be found here. Otherwise the Relative Agility Tutorial video is a good place to start.
Note, this topic might be a little advanced for most people, and it is fine to ignore it. This is just to explain some oddities that occur in the game.
FF4 operates on a timer system, where most time based things have a number of atb ticks associated with them, and when this timer counts down to zero, the waiting is over.
However, FF4 also only allows 1 timer to resolve every atb tick, so it has a pointer that loops thru the characters and enemies, and if a timer is expired on the target, processes that specific timer. If no timer is expired it moves on.
This is a pretty complicated topic, but the gist of this is, if more then 1 timer is expired on an atb tick, the game handles only 1 of the timers, then advances to the next atb tick. In practice, this means if you add timers quickly enough, the game must handle the actions in character order.
As well, since each person can have multiple timers on them at once, and only 1 can be processed each time this can lead to some timers never getting processed. An example of this is if you use enough very fast zerkers against plague, even when the count reaches 0, your characters won't die, as it processes the attack timers before the count timer.
This can also lead to virus/sap, wall, and other status effects never running out.
Typically this is referred to as queue jam, there are so many actions waiting to be processed, that each character has to have multiple atb ticks pass before their timers are checked, and during these ticks, their timers do continue to count down. Example uses of this include, using enemy/character initial turns to queue actions/spells you wouldn't have time to cast normally (star-veil for wyvern, or use quake which takes 4 atb ticks to cast, on trapped chests like the ghost chest before they can act).
On this same line of thought, its important to recognize how this interacts with your party order. Characters are added to a queue to have their menu pop up based on this same system, which is why in low agility situations you will find your party tends to not change its order too much.
Its also interesting to look at how you get your turn, first you have to be added to the character queue, then next atb tick the menu can pop up, if you are fast enough, you can input an action that atb (basically BS 6 only), and finally the the action you input gets added to the timer system at the end of the next atb cycle. This means there is always at least 3 atb ticks of delay from when a character gets their turn, and your action goes off, so especially at the start of battles, this can make it difficult to perform actions such as throwing a star-veil against wyvern.
To handle the slow and fast spells, the game uses a speed modifier during battle. Initially this value starts at 16, and can range between 12, and 32. Any ATB delay is multiplied by speed mod/16, rounded down. This means if someone has a delay of 5, and their speed mod is 32, it would now take 10 atb ticks to process.
Slow increases the speed mod by 8, and silkweb increases it by 16. Fast decreases it by 3, and hermes decreases by 8. Normally using fast isn't worth it, as you can only reduce delay by 3/4, but sometimes it can be worth it. Notably, max application of fast will take meteo cast time from 20 atb ticks, to 15. On the other hand, it can be useful in berserk scenerios, as RA 2 will become RA 1 with just 1 cast of fast. In the zeromus fight this is less useful, as blackhole resets the speed mod on the party (but not zeromus).
The Battle speed setting decides how long the game waits before advancing the atb. Anytime, an animation isn't playing, the game isn't paused, a menu isn't open, or a message isn't being shown, the game is trying to update the atb, and this setting determines in a loose sense how many extra frames the game waits to advance.
Because the game typically updates very quickly, reducing the battlespeed and giving the player time to enter actions can drastically change the fight.
Here is a table of how quickly the ATB advances under the different battle speeds. Testing done by Riversmccown, specifically during the vanilla D. Mist Fight.
BS1: 7-9 frames per tick BS2: 12-16 frames per tick BS3: 20-25 frames per tick BS4: 29-34 frames per tick BS5: 37-43 frames per tick BS6: 52-56(!!) frames per tick
Noting that FF4 runs at 60 frames per second (ideally) at BS 6 you have one ATB tick per second, while at BS 1 you have 7-8 ATB ticks per second. While animations do stop the timer, assuming you take half a second to input a command on BS 1, thats 3-4 atb ticks gone, so if you really need an atb advantage, especially early in a fight, you might need to turn this speed down.
One way to artificially slow down the game is to try running during a fight you can't run from. This will cause a message to pop up, which halts the atb from advancing until the message goes away. This can give you a little bit more time to get into your menus. Typically any fight that has monsters lower level than 97 will let you run away the first atb tick you press the buttons. If the fight is marked as one you can't run away, the can't run message will display, freezing the atb for 1-2 seconds. Anytime this message is up, character menus can't appear, so using it too early is bad, but pressing it quickly enough can give you the split second you need to menu your character.
Just don't use it too much, because every time the message does pop up, 1 atb is advancing, and if you use it before your character's menu pops up, enemy atbs are still advancing, but your character menu won't appear. While it can save you 2-3 atbs on BS 1 if you are doing a complicated menu, by BS 3 you can usually get into the right menu only losing 1 atb, and by BS 6 you will have plenty of time to enter actions without needing to run buffer.
If you need your characters to be as fast as the enemy, putting your slowest character in the middle will usually work. You might even try a dwarf axe, drain sword, or cursed ring to slow them down more.
Due to the timer system, if you have enough actions happening quickly enough (especially from berserk) it can drastically change how a fight progresses.
If you are having trouble keeping up with a boss, specifically bosses with little margin for error (golbez, wyvern, kainazzo, ogopogo, zeromus, etc) using a lower BS might make the fight much easier. For example, In testing I have found doing reflect strats on zeromus (very menu intensive) take about the same total time on BS 1 and BS 3, simply cause you end the fight in less turns with BS 3.
By performing too many actions (with or without the help of the enemy) can cause status effects and such to never expire, which can be used to your advantage, or can cause difficulties in fights.