Facts
Games
39 · 1986–2008
Evidence
Code (50)
Unsourced (1)
Sources
31
On this page
  1. Where the roll falls
  2. Across the Final Fantasy games
  3. Dragon Warrior and the Mother games
  4. Pokémon
  5. Other games
  6. Related
  7. Games
  8. References
  9. Sources

A damage formula turns an attack into hit points lost. Most of the role-playing games below subtract the defender’s stat from the attacker’s1,2,3,4. Final Fantasy VI, Chrono Trigger, and Arcana let defense remove a share of the damage instead, and Pokémon Red and Blue divide by it5,6,7,8. In the table, A is the attacker’s attack stat and D the defender’s defense.

GameDefenseRandom partOrder
Dragon Warriorsubtracts half: X=A−⌊D/2⌋keeps ¼ to ½ of X, evenlydefense, then the roll1
Final Fantasysubtracts absorb from each hit, at least 1B to 2B for a damage stat B, each swingthe roll, then absorb2
Dragon Warrior IIas Dragon Warrior8/256 to 248/256 of X, bunched near ½defense, then the roll9
Final Fantasy IIsubtracts it from each hit, at least 0A to 2A, each hitthe roll, then defense10
Dragon Warrior IIIas Dragon Warrior25/64 to 38/64 of X, bunched near ½defense, then the roll11
EarthBound Beginningssubtracts half, or gives (3A−D)/4 when A<D±0–24%, mostly 10% or lessdefense, then the spread3,12
Final Fantasy IIIsubtracts it, at least 0A to 1.5A, once for all the hitsthe roll, element, critical, defense, then times the hits13
Final Fantasy IVas Final Fantasy IIIas Final Fantasy IIIas Final Fantasy III, held to 1–9,99914,15
Paladin’s Questsubtracts nine tenths of it, at least 1A to A+25A/255the roll, then defense16
Arcanaremoves a share: (255−D)/256adds 0 to about 15%defense, row, element, race, critical, then the spread7,17
Final Fantasy Vsubtracts it, then multiplies: (A−D)×Ma sword’s attack plus 0 to ⅛the roll, defense, then the multiplier18
Lufiasubtracts: about half of A−Dabout ×127/128, closer for larger hits, plus up to about an eighth of Adefense, critical, then the roll4
EarthBoundsubtracts it from twice the attack: 2A−D±0–25%, mostly smalldefense, then the spread19
Final Fantasy VIremoves a share: (255−D)/256×224/256 to 255/256the roll, then defense, which scales the roll too5,20
Chrono Triggerremoves a share: (256−D)/256adds 0 to ⅓ of Powerdefense, then the bonus, which defense doesn’t reduce21,6
Lufia IIsubtracts half, then halves the restadds a random share of the base, below the action’s variance in 256thsthe roll, defense, halving, then a damage factor22
Pokémon Red and Bluedivides: attack over defense×217/255 to 255/255base, STAB and type, then the roll23,24
Final Fantasy VIIremoves a share: (512−D)/512×3,841/4,096 to 4,096/4,096defense inside the base step25
  • Fixed tableMetroid (1986). One contact damage per area.26,27,28Dune II (1992). Each unit's table damage, no roll and no armor, halved per quarter tile from the explosion.29,30,31The Legend of Zelda: Link's Awakening (1993). A damage per monster health group; DX's Blue Tunic halves it.32,33Perfect Dark (2000). The Falcon 2's shot carries a fixed damage of 1 with no roll, scaled by body part and difficulty.34,35
  • Roll by rangeWolfenstein 3D (1992). A roll of 0 to 255 divided down by distance band: a gun deals a quarter of it within 2 tiles and a sixth beyond, an enemy's shot a quarter, an eighth, or a sixteenth.36,37
  • Base plus a rollDuke Nukem 3D (1996). A gun shot carries its CON strength plus 0 to 5, less 1 at the target; a blast rolls in three distance bands of the strength.38,39,40Quake II (1997). Fixed amounts, except the rocket's 100 plus a roll of 0 to 19; a player's non-splash hit on a monster that hasn't noticed anyone does double.41,42
  • Random multipleDoom (1993). A base times 1–3, 1–8, or 1–10 from the table, and only a player's armor takes a share.43,44,45,46,47
  • Defense tableZelda II: The Adventure of Link (1987). An 8 × 8 table by the monster's damage code and Link's life level, halved by Shield.48
  • Attack minus defenseDragon Warrior (1986). A hit deals a quarter to a half of what the attack beats half the defense by, so a monster that outclasses the hero shrugs off his blows.49,1,50,51,52,53,54,55,56,57,58Dragon Warrior II (1987). A blow deals about half of what the attack beats half the defense by, seldom far from that.9,59Dragon Warrior III (1988). A blow deals about half of what the attack beats half the defense by, never far from that.11Final Fantasy II (1988). Each hit deals between the attack and twice it, less the target's defense.10EarthBound Beginnings (1989). Offense less half the Defense, then a ±0–24% spread weighted toward small changes.3,12Final Fantasy III (1990). A strike deals the attack plus up to half again, less the target's defense.13Final Fantasy IV (1991). A strike deals the attack plus up to half again, less the target's defense.14,15Final Fantasy V (1992). Attack less defense, multiplied, so a sword hits harder as its wielder's level and strength rise.18Paladin's Quest (1992). Attack plus a random 0 to 25/255 of it, less nine tenths of defense, at least 1.16Lufia & the Fortress of Doom (1993). About half of attack less defense, doubled on a critical, then a small roll.4EarthBound (1994). 2 × Offense − Defense, ±25% weighted toward small changes.19,60Lufia II: Rise of the Sinistrals (1995). The base gets a random bonus, loses half the defense, is halved, then trimmed by a factor.22
  • Attack minus defense, no rollFire Emblem: The Sacred Stones (2004). Might, triangle, and strength less defense, tripled on a critical and held within 0–127.61
  • Attack over defensePokémon Red and Blue (1996). Level, power, and Attack over Defense, capped at 997 plus 2, then STAB, the type rows, and a 217–255 roll.8,23,24,62Pokémon Yellow (1998). Red and Blue's formula and 217–255 roll, unchanged.63Pokémon Gold and Silver (1999). A random factor of 217–255 over 255, which Crystal keeps.64Pokémon Crystal (2000). Red and Blue's order, with held-item boosts and the critical's ×2 inside the base step.65,66,67Pokémon Ruby and Sapphire (2002). The random factor is 100 − rand % 16 percent, about the old 217–255 over 255.68Pokémon Emerald (2004). A critical doubles the base damage, and the random factor becomes 85–100%.69,70,71Pokémon FireRed and LeafGreen (2004). Emerald's damage and 85–100% random factor, unchanged.72
  • Defense as a fractionArcana (1992). Attack times (255 − defense) / 256, then row, element, and race factors and a spread of up to about 15%.7,17Final Fantasy VI (1994). A random 224–255 over 256, then 255 − defense over 256.5Chrono Trigger (1995). The technique's power times the attacker's stats makes a magnitude, which 256 − defense over 256 scales; a random bonus is added after, which defense doesn't reduce.73,21,74,6,20Final Fantasy VII (1997). A base from attack and level, times power/16 and (512 − defense)/512, then 3,841–4,096 over 4,096.25

#Where the roll falls

Dragon Warrior subtracts first, so a hero whose attack power barely beats half the defense deals 0 or 1 whatever the roll50. A monster whose attack the hero’s defense blunts by about half or more deals only 0 to about a sixth of its attack51. Final Fantasy rolls first and subtracts absorb from each swing, so a weak swing can come down to its minimum of 12.

Chrono Trigger reverses Final Fantasy VI’s order for the random part. Final Fantasy VI multiplies by its random variance and then by the defense factor, so defense also scales the roll, but Chrono Trigger adds its bonus after the defense step, so armor never reduces it20.

The spread’s shape differs too. Dragon Warrior’s single random byte spreads damage evenly from a quarter to a half of X, and Dragon Warrior II and III keep X but draw a roll bunched around one half1,9,11. EarthBound Beginnings draws its spread from a table in which 92 of 128 entries are 10% or less, and EarthBound draws two random bytes and keeps the one nearer the middle, so small changes are the most common in both12,19.

#Across the Final Fantasy games

Final Fantasy II rolls damage and a critical for each hit and adds them up, where Final Fantasy III rolls once and multiplies by the net hits75. Final Fantasy IV keeps Final Fantasy III’s single roll and adds the crit bonus before defense15. Final Fantasy V multiplies what attack beats defense by, so a sword hits harder as its wielder’s level and strength rise18. Final Fantasy VI turns defense into a fraction5.

In Final Fantasy a critical adds the swing’s damage roll again, and a character’s crit chance is the weapon’s index number, a bug76,77. Its physical weakness bonus can never trigger, and no stat of the caster enters spell damage78,79.

#Dragon Warrior and the Mother games

EarthBound Beginnings makes Dragon Warrior’s subtraction of half the defense, then applies its own spread3,1. EarthBound keeps the order of a plain attack but deals twice the Offense less the Defense60. One hero attack in 32 in Dragon Warrior is an “excellent move” that ignores defense, and monsters have none80,81. The hero’s spells skip the formula and deal fixed ranges, Hurt 5–12, Hurtmore 58–6553.

#Pokémon

Red and Blue, Crystal, and Emerald apply STAB and type effectiveness to base damage, then the random factor23,65,69. Red and Blue’s base damage is ⌊⌊(⌊2L/5⌋+2)⋅P⋅A/D⌋/50⌋, ≤997, +28. The random factor is ×217–255 / 25524 in Red and Blue and Crystal66, and ×85–100 / 10070 in Emerald. Pokémon Yellow keeps Red and Blue’s calculation, and Pokémon FireRed and LeafGreen keep Emerald’s63,72. A move’s type makes it physical or special in all three; Pokémon Platinum reads each move’s own class instead62,67,71,82. The critical-hit and hit-chance pages cover their tests.

#Other games

In the US version of Paper Mario, Mario’s damage starts from the move’s own amount, adds badges and statuses, and stops at 9983 before the target’s defense is subtracted. Wolfenstein 3D’s gun divides a random byte by a larger number at middle range than up close36.

Games

GameYearHowNote
Metroid1986Fixed tableone contact damage per area
The Legend of Zelda1986Fixed tablea damage byte per monster type, halved per ring
Dune II1992Fixed tableeach unit's table damage, no roll and no armor, halved per quarter tile from the explosion
The Legend of Zelda: Link's Awakening1993Fixed tablea damage per monster health group; DX's Blue Tunic halves it
Perfect Dark2000Fixed tablethe Falcon 2's shot carries a fixed damage of 1 with no roll, scaled by body part and difficulty
The Legend of Zelda: Oracle of Seasons and Oracle of Ages2001Fixed tablethe enemy's own damage, changed by the one ring Link wears
Wolfenstein 3D1992Roll by rangea roll of 0 to 255 divided down by distance band: a gun deals a quarter of it within 2 tiles and a sixth beyond, an enemy's shot a quarter, an eighth, or a sixteenth
Duke Nukem 3D1996Base plus a rolla gun shot carries its CON strength plus 0 to 5, less 1 at the target; a blast rolls in three distance bands of the strength
Quake II1997Base plus a rollfixed amounts, except the rocket's 100 plus a roll of 0 to 19; a player's non-splash hit on a monster that hasn't noticed anyone does double
Doom1993Random multiplea base times 1–3, 1–8, or 1–10 from the table, and only a player's armor takes a share
Zelda II: The Adventure of Link1987Defense tablean 8 × 8 table by the monster's damage code and Link's life level, halved by Shield
The Legend of Zelda: A Link to the Past1991Defense tablea 10 × 3 table by the monster's damage class and Link's mail
Dragon Warrior1986Attack minus defensea hit deals a quarter to a half of what the attack beats half the defense by, so a monster that outclasses the hero shrugs off his blows
Dragon Warrior II1987Attack minus defensea blow deals about half of what the attack beats half the defense by, seldom far from that
Final Fantasy1987Attack minus defenseeach hit deals between the attacker's damage stat and twice it, less the target's armor, and never less than 1
Dragon Warrior III1988Attack minus defensea blow deals about half of what the attack beats half the defense by, never far from that
Final Fantasy II1988Attack minus defenseeach hit deals between the attack and twice it, less the target's defense
EarthBound Beginnings1989Attack minus defenseOffense less half the Defense, then a ±0–24% spread weighted toward small changes
Final Fantasy III1990Attack minus defensea strike deals the attack plus up to half again, less the target's defense
Final Fantasy IV1991Attack minus defensea strike deals the attack plus up to half again, less the target's defense
Final Fantasy V1992Attack minus defenseattack less defense, multiplied, so a sword hits harder as its wielder's level and strength rise
Paladin's Quest1992Attack minus defenseattack plus a random 0 to 25/255 of it, less nine tenths of defense, at least 1
Lufia & the Fortress of Doom1993Attack minus defenseabout half of attack less defense, doubled on a critical, then a small roll
EarthBound1994Attack minus defense2 × Offense − Defense, ±25% weighted toward small changes
Lufia II: Rise of the Sinistrals1995Attack minus defensethe base gets a random bonus, loses half the defense, is halved, then trimmed by a factor
Paper Mario2000Attack minus defense, no rollMario's damage, after badges and charges and a cap of 99, less the target's defense, floored at 0
Fire Emblem: The Sacred Stones2004Attack minus defense, no rollmight, triangle, and strength less defense, tripled on a critical and held within 0–127
Pokémon Red and Blue1996Attack over defenselevel, power, and Attack over Defense, capped at 997 plus 2, then STAB, the type rows, and a 217–255 roll
Pokémon Yellow1998Attack over defenseRed and Blue's formula and 217–255 roll, unchanged
Pokémon Gold and Silver1999Attack over defensea random factor of 217–255 over 255, which Crystal keeps
Pokémon Crystal2000Attack over defenseRed and Blue's order, with held-item boosts and the critical's ×2 inside the base step
Pokémon Ruby and Sapphire2002Attack over defensethe random factor is 100 − rand % 16 percent, about the old 217–255 over 255
Pokémon Emerald2004Attack over defensea critical doubles the base damage, and the random factor becomes 85–100%
Pokémon FireRed and LeafGreen2004Attack over defenseEmerald's damage and 85–100% random factor, unchanged
Pokémon Platinum2008Attack over defenseeach move's own class picks Attack or Special Attack, not its type
Arcana1992Defense as a fractionattack times (255 − defense) / 256, then row, element, and race factors and a spread of up to about 15%
Final Fantasy VI1994Defense as a fractiona random 224–255 over 256, then 255 − defense over 256
Chrono Trigger1995Defense as a fractionthe technique's power times the attacker's stats makes a magnitude, which 256 − defense over 256 scales; a random bonus is added after, which defense doesn't reduce
Final Fantasy VII1997Defense as a fractiona base from attack and level, times power/16 and (512 − defense)/512, then 3,841–4,096 over 4,096
Every claim about this mechanic, by game (121)
Castlevania 1986An enemy's touch costs Simon 8 HP in stages 0 to 6, 12 in stages 7 to 11, and 16 from stage 12 on, or anywhere while a flag not identified here is set. It counts when their centers are less than the enemy's half width plus 4 apart across and its half height plus 12 (10 while he crouches) apart up and down. It is skipped during the knockback and one other state, while he is invincible, and for candles, items, and the flames of anything already destroyed, so a whipped enemy is harmless from the hit's frame.Code
Dragon Warrior 1986Physical strikes roll randomized damage from attack minus half defense, falling back to a 50% 0-or-1 hit for heroes when that difference is below 2 and a scaled weak-hit roll for monsters when it does not exceed half monster attack; against non-Dragonlord enemies, heroes also have a 1 in 32 chance for a defense-ignoring excellent move, and awake enemies dodge at probability d/64 from their low magic-defense nibble d.Code
The hero's attack power is Strength plus the weapon's bonus; defense power is half of Agility, rounded down, plus the armor's and shield's bonuses, plus 2 with the Dragon's Scale.Code
The hero's hit-damage routine takes X=A−⌊D/2⌋, the hero's attack power less half the monster's defense byte; if X≥2, damage is ⌊(X+⌊r(X+1)/256⌋)/4⌋ for a random byte r, so from ⌊X/4⌋ to ⌊X/2⌋.Code
When the hero's attack power less half the monster's defense, rounded down, is under 2, the hero deals 0 or 1 damage, each half the time.Code
Before the normal formula, a 1-in-32 roll gives the hero an "excellent move", except against the Dragonlord; for attack power A it deals A−⌊r⌊A/2⌋/256⌋ for a random byte r, from ⌈A/2⌉+1 to A (more than half to all of the attack power), and ignores defense.Code
The monster's hit-damage routine ($EFF4) takes X=A−⌊D/2⌋, the monster's attack less half the hero's defense power; if X≥⌊A/2⌋+1, it uses the hero's normal formula, and otherwise the monster deals ⌊(⌊r(⌊A/2⌋+1)/256⌋+2)/3⌋, from 0 to about A/6.Code
A monster's HP is its base value less up to a quarter, H−⌊⌊rH/256⌋/4⌋; the foe of the game's last fight always has its base HP.Code
The hero's Hurt deals 5–12 damage and Hurtmore 58–65, whatever the stats on either side; either is blocked instead when a roll of 0–15 falls below the monster's spell resistance, a value from 0 to 15.Code
A monster's Hurt deals 3–10 damage and Hurtmore 30–45; against a hero in Magic Armor or Erdrick's Armor, either's damage d is cut to 2⌊d/3⌋.Code
Measured in the ROM over all 65,536 generator states, attack power 60 against a defense byte of 40 deals 10–20 damage, each of 10 to 19 in 25 of 256 rolls and 20 in 6; attack power 20 deals 0 or 1, half each.Verified
Measured in the ROM over all 65,536 generator states, a monster's attack of 90 against the hero's defense power of 60 deals 15–30 damage, and an attack of 20 against defense power 40 deals 0–4, mostly 1–3.Verified
Measured on Rev 0 for every value of the random byte, the hero's Heal restores 10–17 HP and Healmore 85–100, each amount equally likely, never past maximum HP. The map's spell command and the battle's call the same two routines.Verified
The booklets misstate the NES game's healing. Both the NES and the Famicom manual give Heal 10–15 HP, Healmore 75–100, and an Herb 20–35; the NES Explorer's Handbook gives Heal "about 10 to 20" and an Herb "about 20 to 30". The NES game's own figures are 10–17, 85–100, and 23–30 (heal-amounts, herb).Manual
The NES manual gives the hero's Hurt 2–15 damage where the Famicom manual gives 5–12, and the game deals 5–12 (hero-spells, hurt-measured): the NES booklet's figure matches neither.Manual
Measured on Rev 0 for every value of the random byte, the hero's Hurt deals 5–12 damage and Hurtmore 58–65, each amount equally likely, once the spell has passed the monster's resistance.Verified
Metroid 1986An enemy's touch costs Samus an amount set by her area rather than by the enemy: 8 units in Brinstar, 10 in Norfair, 20 in Kraid's hideout, 24 in Ridley's hideout, and 30 in Tourian, before the Varia suit halves it. The touch costs nothing while her screw attack is active, from an enemy whose status is 4 or more, or from an enemy type that the area's table marks with $10; and the subtraction itself charges nothing while the escape timer runs or Mother Brain is dying.Code
With the Varia suit, the routine that subtracts health halves every amount it takes from Samus.Code
Measured in the ROM, a crawler held against Samus in Brinstar's first room takes 8 units with each hit, and the next hit lands 50 game frames later; one of the two gaps also held 2 lag frames, for 52 frames of video.Verified
The Legend of Zelda 1986Link's health is a byte whose high nibble is the heart containers less one and whose low nibble is the full hearts, plus a partial heart in a second byte from $00 to $FF; a new file starts at $22 and $FF, three containers and three hearts.Code
A monster's contact damage comes from a damage table, one byte per object type, whose low nibble is whole hearts and whose high nibble is sixteenths of a heart; of its 93 entries, 30 are half a heart, 24 one heart, 18 two hearts, and 3 four hearts.Code
Each level of ring halves the damage before it is subtracted, so the first ring takes half and the second a quarter.Code
When the partial heart can't cover the damage, the game takes a full heart and refills the partial heart to $FF rather than $100, so each such borrow costs Link an extra 1/256 of a heart.Code
Measured in Rev 1, a Tektite held against Link hurts him every 47 or 48 frames, taking half a heart each time; from three hearts, five hits leave $20 and $7D, 3/256 of a heart under a half heart.Verified
The wooden, white, and magical swords take $10, $20, and $40 from a monster's hit points; fire takes $10, a bomb $40, and the boomerang none, setting the monster's stun timer to $10 instead.Code
Double Dragon 1987Landing a hit selects an attack record by attacker type and attack index—seven bytes for Mode A slot-0 player attacks and five bytes for enemy or Mode B attacks—adding 1 to the knockback reaction index and promoting hit reaction state 5 to 6 when attacker and victim face the same direction, before updating the victim's entity state, subtracting damage clamped at zero, applying a six-byte velocity block whose horizontal component negates when facing left, and clearing animation counters on knockdown.Code
Dragon Warrior II 1987In Dragon Warrior II (NA NES), a hero's attack takes X=A−⌊D/2⌋, attack power less half the monster's defense; if X is under 2 the hit deals 0 or 1, and otherwise ⌊Xr/256⌋, where r is 8 plus the sum of sixteen random 0–15 rolls (8 to 248, centered on 128), so about half of X; a hero under Surround deals 0 one time in 4.Code
In Dragon Warrior II (NA NES), as in Dragon Warrior, each monster starts a fight with its base HP less up to a quarter; the order changes, as Dragon Warrior II quarters the base HP before multiplying by a random byte, H−⌊⌊H/4⌋r/256⌋, where Dragon Warrior quarters the product.Code
Final Fantasy 1987A character's damage stat rises by 1 whenever a level-up raises Strength to an even number, and by the weapon's damage when it is equipped; the weapon's hit bonus adds to hit rate the same way.Code
Against a sleeping or stunned defender, base damage rises by a quarter, and the attacker's hit rate and the defender's evade drop out, so the hit chance stays at 168 apart from Dark's 40 either way.Code
Each swing that rolls under 200 also rolls damage from the base B to 2B, capped at 255; a hit subtracts the defender's absorb, with a minimum of 1, and the swings' damage adds up to one total.Code
A swing is critical when its roll is at most the crit chance, which is capped at the hit chance; a critical adds the swing's random damage again, with no absorb taken from it.Code
A damage spell always connects, for a random value from its power E to 2E; its roll of 0–200 against 148 + the spell's hit rate − the target's magic defense doubles the damage instead of deciding a hit.Code
A resisted element halves a damage spell's power and drops the 148 from its doubling chance; a weakness multiplies the power by 1.5 and adds 40 to the chance.Code
A damage spell's damage and its chance to double come from the spell's power, hit rate, and element, the target's magic defense, resistances, and weaknesses, and two random rolls. No stat of the caster enters either, so Intelligence adds nothing to spell damage.Code
TMPR and SABR, whose spell effect adds the spell's power to the target's attack, do nothing when cast on a character: the routine that loads a character's stats for a spell doesn't load attack, and the routine that saves them back skips it.Code
At each level-up, an unarmed Black Belt or Master gets absorb equal to their level and a damage stat of twice their level, whatever armor they wear: the level replaces the absorb their armor gave. The level-up checks only the four weapon slots, but the equip menu's own recalculation sets that absorb only when the armor adds none.Code
Measured in the ROM over all 256 battle-RNG states, one swing with base damage 20, hit rate 10, and crit chance 1 against evade 6 and absorb 4 hits 221 times and is critical 4 times; with the attacker in Dark it hits 170 times, and against a sleeping defender 216 times.Verified
Zelda II: The Adventure of Link 1987A monster's damage code (0–7) and Link's life level (1–8) pick the life a hit takes from an 8 × 8 table, halved while the Shield spell is on. Code 0 takes 16 units at life level 1 and 4 at level 8; code 6 takes 224 and 80; code 7 takes 255 at every level.Code
A sword hit takes 2, 3, 4, 6, 9, 12, 18, or 24 hit points from a monster for attack levels 1 to 8, and the Thunder spell's entry is 50.Code
Dragon Warrior III 1988In Dragon Warrior III (NA NES), a hero's attack takes X=A−⌊D/2⌋, attack power less half the monster's defense; under 2 it deals 0 or 1, and otherwise ⌊X⌊r/4⌋/64⌋, where r is a bell-shaped roll centered on 128 clamped to 102–153, so 25/64 to 38/64 of X.Code
Final Fantasy II 1988Each hit that gets through deals attack plus a random 0 to attack, less the target's defense (at least 0), and the hits add up; a cursed attacker's attack is halved first, and so is a cursed target's defense. Each hit also rolls 0–100, and a roll under 5 makes it critical, adding the attack again.Code
When the weapon's type bonus matches the target's type, or the weapon's element matches one of the target's weak elements, the attack power gains 20 before the damage is rolled.Code
EarthBound Beginnings 1989In EarthBound Beginnings (the English build that the 2015 Virtual Console release uses), a shared routine adds random spread to a value: it moves the value by a weight in percent drawn from a 128-entry table by a random byte, up or down at even odds. The weights run from 0 to 24, and 92 of the 128 entries are 10 or less, so most rolls move the value by a few percent. Damage and the turn-order Speed roll both use it.Code
In EarthBound Beginnings (English build), a normal attack deals the attacker's Offense less half the target's Defense; when the Offense is below the Defense it deals (3 × Offense − Defense) ÷ 4 instead, at least 1. The damage routine then applies the ±0–24% spread, halves the result for a shielded or guarding target, and deals at least 1.Code
Final Fantasy III 1990The damage roll is attack plus a random 0 to half of it (the half kept to 8 bits, so it wraps for an attack of 512 or more), times the elemental multiplier (stored doubled and halved back), plus the crit bonus on a critical, less defense (at least 0; skipped when a character hits a character); that times the net hits, divided by the targets hit, is capped at 9,999.Code
Final Fantasy II rolls damage, attack plus 0 to attack less defense, and a critical for each hit that gets through and adds them up; Final Fantasy III rolls damage once, attack plus 0 to half of it, and multiplies it by the net hits, and its single critical roll uses the job's crit probability in place of Final Fantasy II's fixed roll under 5.Code
The Legend of Zelda: A Link to the Past 1991A monster's bump damage class (0–9) and Link's mail (green, blue, or red) pick the damage of a touch from a 10 × 3 table, in eighths of a heart. Class 3 takes 8, 4, or 2; class 9 takes 64, 48, or 24; class 1 takes 4 whatever the mail.Code
Final Fantasy IV 1991The damage routine takes attack power plus a random 0 to half of it, applies the elemental and creature-type multipliers, adds the crit bonus on a critical, and subtracts defense (floored at 0); that times the net hits, divided by the number of targets, is held to 1–9,999. A Fight command has one target.Code
Final Fantasy IV keeps Final Fantasy III's physical attack: percentage rolls per point of an attack multiplier, the target's successful evade rolls subtracted, and one damage roll of attack plus 0 to half of it, with the crit bonus added before defense, multiplied by the net hits and capped at 9,999.Code
Arcana 1992A weapon hit's damage, with each product rounded down to a whole number: attack = power x (Strength figure x share / 256 + buff + 205 - share) / 256, where the Strength figure is Strength x 191 / 256 + 64, share is the weapon's strength-share byte, power is the weapon's power word (10 bare-handed), and buff is 25, or 50 with one of the attack flag bits set and 0 with the other. Defense = armor x 102 / 256 + shield x 51 / 256 + (Endurance x 223 / 256 + 32) x 51 / 256, plus 25, 50 or 0 by its own two flag bits. The damage is attack x (255 - defense) / 256, times the row factor (1, 1, or about 0.88, 0.76 or 0.64), the element factor, the race factor, 0.75 when bit 8 of the target's state is set and 2 on a critical, before the random spread.Code
Healing spells skip the roll to land, and spells of effect class 8 and up (from Dodge All on, arcana-tables/spells) always land; Ruinous Mission and Flee face only the immunity check. Every other spell rolls to land: chance = its accuracy + the caster's magic figure - the target's, where the magic figure is (Intelligence - 55) x 66 / 256 and 0 below 55 Intelligence; Chaos Wind, Entomb and Destroy add 52 to the caster's side when the element factor is 1.6 and to the target's when it is 0.4. It lands when a random number modulo 255 is below the chance (capped at 255; below 0 it misses). A damage spell then deals power x (205 + (Intelligence - 55) x 393 / 256) / 256, times (255 - magic defense) / 256, then add 1, times the element factor, before the random spread; magic defense is the shield's byte plus (Intelligence - 55) x 99 / 256, capped at 255. Healing spells give their power plus a spread of 13/256.Code
Dune II 1992The executable's unit table sets hit points, speed (out of 256), range in tiles, fire delay, and damage per shot: the Trike 100, 45, 3, 50, and 5; the Quad 130, 40, 3, 50, and 7; the combat tank 200, 25, 4, 80, and 25; the siege tank 300, 20, 5, 90, and 30; the rocket launcher 100, 30, 9, 120, and 75; the Devastator 400, 10, 5, 100, and 40; and the sonic tank 110, 30, 8, 80, and 60. PROFILE.INI, read from the game data at start, can replace any of these.Code
A shot carries its unit's table damage, with no roll; only troopers and trooper squads firing beyond 2 tiles switch to a missile at damage − damage/4. The whole damage applies at the point of impact and within a quarter tile of it, where a unit, or a structure on the impact tile, loses it from its hit points, down to 0, with no armor or defense stat; units farther from the point take less (dune2/splash). Units flagged to fire twice (among them the Trike, Quad, rocket launcher, siege tank, and Devastator) follow a shot with a second after a delay of 5 rather than twice their fire delay (at normal game speed), but only while above half health; every fire delay gets 0 or 1 added at random.Code
A shell or missile damages where it explodes, not the unit it was fired at: the explosion damages every unit within one tile of the point (two for the Death Hand explosion), its own side's included, by the damage halved once per quarter tile of distance, so full within a quarter tile, half to a half, a quarter to three quarters, and an eighth to one tile; the frigate and bullets in flight take none. A structure on the impact tile takes the full damage. A shell flies to the target's position at the moment of firing and explodes there, or earlier on a wall, structure, or mountain tile in its path; a turret's shell passes over its own side's walls and structures.Code
Final Fantasy V 1992Physical damage is (Attack − Defense) × M, at most 9,999, and 0 when Defense is at least Attack. For swords, Attack is the weapon's attack power plus a random 0 to an eighth of it, and M is Level × Strength ÷ 128 + 2.Code
Final Fantasy Mystic Quest 1992How Final Fantasy Mystic Quest computes physical and magic damage hasn't been read yet.Unsourced
Paladin's Quest 1992When a party member casts an attack spell other than Storm, Heat or Crush, the damage is the spell's power, raised or lowered by how far the caster's mastery outruns the target's defense against it: power plus (mastery minus twice the defense) times power / 64, at least 1. The mastery is the sum of the caster's mastery of each of the spell's spirits, doubled for a single-spirit spell, so one spirit at 30 counts the same as two at 30; Spirit, built from all eight, sums all eight. The defense is the target's value for the spell's type plus 1, and 100 more while the target has a status coded 2.Code
A physical hit does the attacker's attack, plus a random 0 to 25/255 of it, minus nine tenths of the target's defense, at least 1. A target whose chosen command is the one coded 3 (14 for an enemy) takes half, rounded up. A battle flag raises the attack by a quarter, and a status raises the target's defense by an eighth.Code
Doom 1993Each bullet from Doom's pistol, chaingun, or shotgun deals 5 × (r mod 3 + 1) for a random byte r, so 5, 10, or 15; the shotgun fires 7 such pellets. Over one pass of the table the multipliers 1, 2, and 3 come up 75, 88, and 93 times.Code
Doom's fist deals 2 × (r mod 10 + 1) for a random byte r, 2 to 20, multiplied by 10 while the player has the berserk strength power; the chainsaw deals 2 to 20.Code
A Doom projectile that hits a shootable thing, other than a monster of its shooter's species, deals (r mod 8 + 1) times its type's damage value, for a random byte r: a rocket's 20 gives 20 to 160, a plasma ball's 5 gives 5 to 40, a BFG ball's 100 gives 100 to 800, and an imp's fireball's 3 gives 3 to 24.Code
A Doom rocket's explosion deals 128 minus the distance to each shootable thing in sight of the blast, measured as the larger of the x and y gaps less the thing's radius and no less than 0, so a thing 128 or more units out takes nothing; the Cyberdemon and Spider Mastermind take none.Code
When a Doom BFG ball's explosion reaches its third frame, 40 traces fan across 90° around the ball's heading, each starting from the player who fired it and reaching 1,024 units, and each trace that finds a target deals the sum of 15 rolls of 1 to 8, so 15 to 120.Code
Doom's monster attacks use the same multiple-of-a-base form, for a random byte r: a zombieman's bullet deals 3 × (r mod 5 + 1), 3 to 15; an imp's claw 3 × (r mod 8 + 1), 3 to 24; a demon's bite 4 × (r mod 10 + 1), 4 to 40; and a Baron of Hell's claw 10 × (r mod 8 + 1), 10 to 80, an attack function the code shares with Doom II's Hell Knight.Code
Damage to a Doom player is halved on the easiest skill, and then armor takes a share: a third with the armor pickup (type 1) and half with the MegaArmor (type 2), until its points run out; monsters have no armor or defense value.Code
The Legend of Zelda: Link's Awakening 1993A monster's touch costs Link the damage its health group lists, in eighths of a heart, mostly 4 or 8. In Link's Awakening DX the Blue Tunic halves it. Without the tunic, the Guardian Acorn halves it too and cancels a half-heart touch outright; the tunic is tested first and the two don't stack, so with the tunic a half-heart touch costs 2.Code
The 1993 Game Boy release has the same hit code as DX without the tunic check. It reads the damage from its health-group table, applies the Guardian Acorn's rule, and stores the same $50 in the invincibility counter.Code
Lufia & the Fortress of Doom 1993A physical hit's damage starts from ATP − DFP: (ATP − DFP + 1) ÷ 2 + 1 when ATP is higher, 2 when they are within 16 of each other the other way (or equal), and 0 when DFP is 16 or more higher. A critical hit doubles that base, and makes a base of 0 into 2. The base is then multiplied by a factor of 96 plus the mean of (base ÷ 16 + 2) rolls of random(64), over 128, so the larger the base the closer the factor stays to about 127 (computed), and the mean, rounded up, of two rolls of random(r) is added, where r is ATP ÷ 8 rounded to the nearest, plus 1. DFP counts one and a half times against a target in one state the code tests (not identified here), and an attack with ATP 0 misses. Steps for slayer types, elements, weapon specials, a stone target (no damage) and drain follow and aren't covered here.Code
EarthBound 1994In EarthBound (US release), a bash deals 2 × the attacker's Offense − the target's Defense, moved up or down by up to 25%, and at least 1. The spread draws two random bytes and keeps the one nearer 128; its distance d from 128 moves the damage by d/512 of it, down when the byte is under 128 and up when over, so small changes are the most common.Code
EarthBound (US release) keeps EarthBound Beginnings' order of a plain attack, with the "SMAAAASH!!" rolled before the dodge so it can't be dodged, but changes the numbers: the chance comes from the attacker's Guts, counted as at least 25 for a party member (about Guts in 500), instead of Fight against Fight; the SMAAAASH deals 4 × Offense − Defense instead of the full Offense; a normal hit deals 2 × Offense − Defense, where EarthBound Beginnings deals Offense − Defense ÷ 2, or (3 × Offense − Defense) ÷ 4 when the Offense is below the Defense; and the dodge comes from Speed instead of Fight.Code
In EarthBound (US release), the level 1, 3 and 4 physical attacks each run the miss check, SMAAAASH and the dodge in that order, then deal Offense, 3 × Offense or 4 × Offense less the target's Defense, spread by up to 25% when positive and at least 1, and cure feeling strange on a hit. Level 2 is the same damage step at 2 × Offense with no checks of its own; Shoot runs the miss check (with the shot's miss message) and the dodge, no SMAAAASH, then the level 2 damage, and doesn't cure strangeness. The double bash is two bashes.Code
Final Fantasy VI 1994The damage-modification routine multiplies the damage by a random variance and then by 255 − the target's Defense (Magic Defense for a magic attack), each over 256 plus 1. The variance is a random byte ORed with $E0, so 224–255; the routine's comment says 240–255.Code
Chrono Trigger 1995A damaging technique runs in four steps: the battle loads the technique's formula and defense-selector bytes, computes a magnitude by that formula, resolves the target's defense value, and applies it. Formulas 1, 2 and 4 first wake the target: if the target's status byte +$1E has bit $02 or $04 set, both are cleared and its turn counter restarts from its reload value. The defense step clears the same two bits for every formula, without the restart.Code
Formula 1 sets the magnitude to power × (12 × the attacker's byte +$36 + 5 × its byte +$43) / 18, where power is the technique's power byte, and draws a random bonus from 0 to a third of byte +$36 (rounded down). The disassembly labels +$36 the live Power and +$43 a value computed when the battle loads. The bonus is added after the defense step, so defense does not reduce it.Code
Formula 2 sets the magnitude to power × (8 × the attacker's byte +$3A + 8 × its byte +$43) / 18 and draws a random bonus from 0 to ⌊77 × byte +$3A / 256⌋, about 30% of it. The disassembly labels +$3A the live Hit.Code
Formula 3 sets the magnitude to power × (12 × the attacker's byte +$12 + 12 × its byte +$39) / 15 and draws a random bonus from 0 to ⌊77 × byte +$39 / 256⌋. The disassembly labels +$12 the level and +$39 the live Magic. Unlike formulas 1, 2 and 4 it does not restart the target's turn counter.Code
Formula 4 sets the magnitude to power × 2 × the attacker's byte +$3D / 18 and draws a random bonus from 0 to one more than about a fifth of byte +$3D: (52s − ⌊s/2⌋ − ⌊s/4⌋) / 256, rounded down, for a stat s. The disassembly labels +$3D the live Attack and calls formula 4 the enemies' physical attack.Code
After the formula, the attacker's statuses scale the magnitude. Bits of its bytes +$21 and +$26 (ORed) are tested in order and only the first that is set applies: $80 multiplies by 1.5 and skips everything else, $08 halves and then triples, $02 quarters and then multiplies by 5. Then each set bit of its byte +$1E applies in turn: $40 multiplies by 8/10, $20 by 8/10, and $04 divides by 4. The bonus drawn by the formula is not scaled.Code
The defense value is one of two target bytes, as the technique's defense selector picks: $3E reads byte +$3E as is, $3C reads byte +$3C × 5 / 2 (the disassembly labels them Defense and Magic Defense). The target's statuses lower it: bit $02 or $80 of its byte +$1E multiplies it by 16/20 and skips the next three; otherwise each of bit $40, bits $05 and bit $20 multiplies it by 18/20. The low two bits n of the technique's property byte 8, when not 0, then scale it by n/4 (the disassembly's comment says only two property records set them and no player technique uses either), and the value is capped at 255. Damage is then magnitude × (256 − defense) / 256 plus the formula's bonus, and a result of 0 becomes 1.Code
The battle's random draws come from a table read in sequence, by an index that wraps after 256: a draw from low to high returns low + the next table byte mod (high − low), then moves the index on. It returns high unchanged when low is $FF, high is 0, or high equals low, and the raw table byte, without moving on, when high − low is $FF. When bit $20 of the battle-settings byte that the start-battle event command writes is set, every draw returns low, except when low is $FF, so the formulas add no bonus.Code
When its damage modification runs (a flag can skip it) and the attack doesn't ignore defense, Final Fantasy VI multiplies damage by a random 224–255 (computed: a random byte ORed with $E0) over 256, adding 1, and then by 255 minus the target's Defense or Magic Defense over 256, adding 1, so defense also scales the random part; on one path the second factor is a fixed $3F (computed) in place of the defense. Chrono Trigger multiplies its magnitude by 256 minus the defense over 256 and adds a separately drawn bonus afterwards, which defense does not reduce.Code
Lufia II: Rise of the Sinistrals 1995Once an action isn't rejected by the target's status or interrupted, its damage is a base value scaled, given a random bonus, cut by half the target's defense, halved, and trimmed by a factor: X = base × scale / 16; X + X × v / 256, with v random from 0 to the action's variance − 1; less half the target's defense, at least 0; halved; then less X × F / 256, where F is the action's damage-factor byte. First a roll from 0 to 99 is made against the action's chance byte: below it, the action's own scale stands and the target's defense counts as 0, a heavier hit that ignores defense; otherwise the scale is 16, times 1. Healing takes the scale and the random bonus only. A scaled base past 65,535 runs into a $00 byte in the code rather than a result. The base, chance, scale, variance, defense, and factor come from the action's battle script, which isn't read here, and the lines read hold no miss test.Code
Duke Nukem 3D 1996Each shot a Duke Nukem 3D player fires from the pistol, shotgun, or chaingun carries the strength its actor declares in the CON script plus a random number modulo 6 (0 to 5): 6 to 11 for the pistol, 10 to 15 for each of the shotgun's 7 pellets, and 9 to 14 for the chaingun; a monster's shot carries the strength alone. Each bullet from Doom's pistol, chaingun, or shotgun deals 5, 10, or 15.Code
A Duke Nukem 3D sprite's pending damage is set to −1 when the sprite is created and again each time the weapon-hit check takes it; a shot that the sprite-hit handler takes in its default branch adds its damage to the pending total, and the weapon-hit check subtracts the total from the target's health, so a target hit once between checks loses 1 less than the shot carries, and several hits between checks take 1 less than their sum (computed). An explosion's radius damage sets the pending damage outright for the targets it rolls for, so those lose the full roll.Code
A Duke Nukem 3D pipe bomb that goes off passes its strength, 140, to the radius-damage routine with the radius 2,500; each sprite in lists 1, 6, 10, or 12 (not flammable) with health (duke3d/pending-damage) of 0 or more that is a tripbomb, a monster, a QUEBALL, a STRIPEBALL, a DUKELYINGDEAD, or solid (cstat&257), within that distance and in sight of the blast, takes 105 to 139 inside a third of the radius, 70 to 104 inside two thirds, and 35 to 69 beyond: three quarters, a half, or a quarter of the strength plus a random number modulo the next band's gap, 35 (computed). A monster in sprite list 2, which the hit wakes into list 1, goes through the sprite-hit handler instead unless a sight test at a random height fails, and loses 139 at any distance in the radius, the bomb's 140 added to its pending −1; a bomb set off by a hit first loses that hit's damage from its strength. A Doom rocket's blast falls off linearly, 128 minus the distance.Code
Pokémon Red and Blue 1996Type picks the stats: Fire, Water, Grass, Electric, Psychic, Ice, and Dragon (the first special type upward) use Special on both sides; the rest use Attack against Defense.Code
In Red and Blue, a damaging move runs the critical-hit test, the base formula, the type adjustment (STAB, then type rows), the random factor, and then the hit test (accuracy).Code
The base-damage routine computes ⌊⌊(⌊2×Level/5⌋+2)×Power×Attack/Defense⌋/50⌋, caps it at 997, and adds 2, so the type step receives 2–999. For a move with the explode effect it halves Defense first (to at least 1).Code
The damage-randomizing routine multiplies damage by a random byte, 217–255, and integer-divides by 255, leaving 0 or 1 damage untouched.Code
A critical hit doubles the attacker's level in the damage formula and ignores stat stages, Reflect, and Light Screen: the player's Pokémon's attacking or defending stat comes from its party data, and the opponent's is recomputed from its base stat, level, and DVs, without stat experience, or read from its party data in a link battle.Code
Super Mario RPG 1996An attack's damage is its power less the target's defense, at least 1 unless the power is 0, and at most 9999. An ordinary attack's power is the attacker's Attack, against the target's Defense. A special's is the caster's Magic Attack plus the special's own power, against Magic Defense, except that the four specials that restore HP (Therapy, Group Hug, HP Rain and Come Back) take no defense off (computed). An item's is its own power, with no defense taken off and no multiplier. A party member's ordinary attack first moves its Attack by a random amount: from Attack less the weapon's variance (0 if that is negative) up by 0 to twice the variance. A monster's ordinary attack has no variance; its power, a number from 0 to 7, picks a multiplier applied after the subtraction: ×1, ×1.5 (the half rounded down), ×2, ×4, ×8, ×16, ×32 or ×64. A monster's magic attack uses its Magic Attack plus that number against Magic Defense, and deals 0 when the number is 0. The halving and ×1.5 steps (super-mario-rpg/damage-status-steps) and the elements, which can make the damage 0 (super-mario-rpg/damage-elements), follow, then the 9999 cap. Three kinds of attack skip the formula (super-mario-rpg/damage-skips). A timed hit's extra comes after all of this, from the damage as applied, and has no cap of its own (super-mario-rpg/timed-hit).Code
Three kinds of attack skip the damage formula (super-mario-rpg/damage-formula). One marked to deal nothing deals 0. One marked to knock out deals 9999 when it hits; it is of two kinds, and on a miss one does nothing while the other goes through the formula after all (super-mario-rpg/hit-chance). One marked to take a share deals its power in sixteenths of the target's current HP, rounded down, or, if it heals, restores that many sixteenths of the target's maximum HP, rounded down; only the 9999 cap applies after it, and it holds while the share stays under 42,768 (computed). A monster attack's knock-out bit gives the kind that does nothing on a miss; none of the party's 27 specials carries either of the other two marks (computed, super-mario-rpg-tables/specials), and which attacks do is not read here.Code
After the subtraction and multiplier, damage that isn't a heal is halved once (rounded down, but not below 1) if any of these holds: the attacker has the status Terrorize inflicts (bit 0x08) or status bit 0x20 (one of the two the Trueform Pin guards against); the target has status bit 0x20; the target's boost bit 0x04 is set (what sets it is not read); or the target has the boost that halves that type of attack, bit 0x40 for ordinary attacks and 0x20 for specials and items (the two bits the Bracer, the Crystalline and the Ghost Medal give). It is then raised by half once (×1.5, the half rounded down) if the target has Terrorize's status, or the attacker has the boost for its type, bit 0x10 for ordinary attacks and 0x08 for others (the two bits Geno Boost, the Energizer, the Power Blast and the Troopa Pin give). A heal skips both steps. An ordinary attack on a target with the status Sleepy Time inflicts (bit 0x02) wakes it, clearing its statuses.Code
Final Fantasy VII 1997In the North American release, the physical damage routine takes the attacker's physical attack S (after stat multipliers) and the action's level L and computes (⌊L·S/32⌋ · ⌊(L + S)/32⌋ + S) × (512 − the target's defense) × the attack's power, over 8,192: a base of S + ⌊L·S/32⌋·⌊(L + S)/32⌋, scaled by power/16 and by (512 − defense)/512 (computed). It then doubles the damage when bit $2 of the action's damage flags is set, the bit a critical sets and that this same function also sets for any attack whose attack-flag bit $2000 is clear (ff7/critical), multiplies it by 1.5 under Berserk, for a short-range attack or an enemy's Attack command halves it once if the target or the attacker is in the back row (other attacks ignore rows), halves it for a defending target, multiplies it by a multiplier the target holds, over 8, when bit 0 of the unnamed field at 0x234 is set, quarters it under Frog, applies the Sadness, multi-target, and Barrier modifiers, and sets it to 0 under Mini. Last, the variance routine multiplies by 3,841 plus a random byte, over 4,096 (93.8–100%, computed), and raises 0 to 1, so a Mini attacker deals 1. Final Fantasy VI's damage-modification routine also lets defense remove a share, but as (255 − Defense)/256, with a variance of 224–255 over 256 applied before it.Code
Quake II 1997A Quake II rocket's direct hit does 100 plus a random whole number below 20 damage, 100 to 119, the roll made when it is fired; the explosion then does radius damage to everything else within 120 units, the rocket's 120 less half the distance from the explosion to the center of the target's box, and the target hit directly takes no splash. A quad damage multiplies both by 4. The railgun's damage is a constant, 150 in single player and 100 in deathmatch.Code
Quake II's damage routine doubles the damage a player does to a living monster that has no enemy yet, commented "bonus damage for suprising a monster", unless the damage is radius damage; the doubling comes after Easy's halving, which applies only to players.Code
Pokémon Yellow 1998Yellow keeps Red and Blue's damage calculation and its random factor unchanged, so base damage is still capped at 997 plus 2 and scaled by a random 217–255 over 255.Code
Pokémon Gold and Silver 1999Gold and Silver's damage-variation command leaves 0 or 1 damage alone and otherwise multiplies by a random byte, rotated, redrawn until it is at least 217 (85 percent + 1), and divides by 255 (100 percent); Crystal keeps the command unchanged. Their damage-calculation command differs from Crystal's only in comments and one doubling written sla a where Crystal has add a.Code
Paper Mario 2000In the US version of Paper Mario, the routine for Mario's damage to an enemy works by subtraction. A forced immune hit skips the calculation, and some hits return before it: an illusory, transparent, or buried target (buried unless the attack is a quake) is missed; a stone target takes nothing; a jump on a spiky top without Spike Shield, a contact attack on an explode-on-contact part, on a fiery part without Fire Shield or Ice Power, or on a part with the alternate spiky flag without Spike Shield backfires, the last two unless the attack suppresses that event; and a fire attack that sets off a part that explodes on fire returns before damage. Otherwise it starts from the move's damage, which the move script passes, adds the Power Plus badges, and adds or takes fixed amounts for Merlee, the jump and hammer charges, other badges, and statuses. All or Nothing adds 1 when the attack isn't a first strike, and without a nice or super hit it sets the damage to 0, and outside the Japanese build the defense too; a shrunk Mario's damage is halved, but stays at least 1; a blast on a part that explodes on ignition sets the damage to the target's HP and the defense to 0; and an attack typed to always hit for its status sets both to 0. The total is capped at 99, and the target's defense is then subtracted: the part's defense against the attack's element, plus the defense boost unless the attack ignores defense, plus 127 for a part flagged extreme defense, or 0 when the total is below 0. A result below 0 becomes 0, and a Power Bounce then adds its counter, keeping a hit above 0 at least 1. The routine's one random draw, a fear attack's scare-away test, runs after the damage is taken off the target's HP.Code
Perfect Dark 2000The Falcon 2's single shot in Perfect Dark carries a damage of 1 in its single-shot definition, read by the gun's damage lookup. A guard adds each hit to its damage total against a maximum that the character setup sets to 4 (a level's AI script can set another), and the damage reaction starts its death once the total reaches it; so on Perfect Agent a default guard takes 4 Falcon 2 shots to a limb, 2 to the torso, or 1 to the head (computed). The player's health starts at 1, and a hit takes its damage × 0.125 from it, so a guard's Falcon 2 bullet takes an eighth on Perfect Agent (computed). Each Doom pistol bullet deals 5, 10, or 15 against a zombieman's 20.Code
Pokémon Crystal 2000Type still picks the stats: Steel is physical (numbered below the first special type); Dark is special, using Special Attack against Special Defense.Code
A plain damaging move takes these steps in order: the critical-hit roll; loading the attacking and defending stats; the base damage formula, then held-item type boosts and the critical ×2; then weather, badge type boosts, the same-type ×1.5, and the type chart rows; then the random factor; and last the accuracy check.Code
As in Red and Blue, damage is multiplied by a random byte from 217 to 255 and divided by 255, and 0 or 1 damage is left untouched.Code
A critical hit doubles the damage after held-item boosts and before the cap at 997 and the final +2. Unless the attacker's attacking-stat stage is higher than the defender's defending-stat stage, it also uses both Pokémon's stats without stages, which drops Reflect and Light Screen; pret's comment asks for the defender's stage to be higher, but the code takes this path at equal stages too.Code
The Legend of Zelda: Oracle of Seasons and Oracle of Ages 2001In both US releases a hit copies the enemy's damage value to Link as a negative number, and Link's one active ring changes it: Power Rings L1–L3 add 2, 4, and 8 units, Armor Rings L1–L3 take 1, 2, and 3 off, the Blue Ring halves it with an arithmetic shift that rounds toward more damage (3 units become 2), the Green Ring takes three quarters (rounded toward less damage), and the Cursed Ring doubles it. A hit always costs at least one unit, and the Protection Ring makes every hit 8. Health then drops a quarter heart per 2 units, so a unit is an eighth of a heart (computed, from the quarter hearts a comment gives). Link's Awakening DX's health is in eighths by its annotators' comment ($08 = 1 heart), and its Blue Tunic also halves damage.Code
Pokémon Ruby and Sapphire 2002Ruby and Sapphire already use Emerald's random factor, damage × (100 − rand % 16) / 100, raised to 1 if that gives 0 from damage that wasn't 0 (zero damage stays 0); Gen 1 and 2 reach about the same 85–100% spread as a byte from 217 to 255 over 255.Code
Fire Emblem: The Sacred Stones 2004In the North American build, damage is attack less defense, where attack is the weapon's might plus the triangle's damage bonus, tripled when the attacker or its weapon is effective against the target (doubled instead when the effective weapon is one of eight legendary weapons), plus the attacker's strength, and defense is terrain defense plus Defense, or terrain resistance plus Resistance against magic; no roll changes it except three skills: Pierce (which sets defense to 0), Great Shield (which sets the damage to 0), and Silencer: on a critical its check, a roll against the attacker's Silencer rate that never passes against the Demon King or, in two of the chapters, the Necromancer, sets the damage to 127, the maximum, and clears Great Shield's mark when it passes; any other critical triples it, and the result is held within 0–127.Code
Pokémon Emerald 2004Type still decides physical or special in Emerald, by whether it comes before or after type 9, "???".Code
A plain damaging move rolls for a critical hit, computes the base damage, applies the type step (STAB, then the type rows), and then applies the random factor.Code
The random factor changes form from Crystal's random byte over 255: Emerald multiplies nonzero damage by 100 − (a random number mod 16), 85 to 100, divides by 100, and raises a 0 result to 1.Code
The damage-calculation battle command multiplies the base damage by 2 on a critical; the base-damage formula then ignores the attacker's lowered attacking stat, the defender's raised defending stat, and Reflect or Light Screen.Code
In Emerald a plain damaging move checks accuracy before it computes damage, the reverse of Red, Blue, and Crystal.Code
Pokémon FireRed and LeafGreen 2004FireRed and LeafGreen's damage-calculation and damage-adjustment commands diff identical with Emerald's: the damage calculation multiplies the base damage by the critical multiplier, 2 on a critical hit, and the random factor is damage × (100 − rand % 16) / 100, 85–100%.Code
The Legend of Zelda: The Minish Cap 2004The Minish Cap takes a touch's effects from a collision matrix: the entry at the toucher's hit type × 34 + the touched one's hurt type. For an Octorok or a Leever (hit type 25) touching Link in his normal state (hurt type 0), the US ROM's entry gives Link 30 invincibility frames, a knockback duration of 8, and 2 damage, a quarter heart. The collision loop skips a pair while either has a nonzero iframe count, unless either has one collision flag set, bit 6. Link's count steps one toward 0 each frame his update runs, so the protection lasts 30 frames. Link's Awakening sets its count to 80 and A Link to the Past to 58.Code
Pokémon Platinum 2008In Platinum the damage formula reads each move's own class (physical, special, or status) and uses Attack against Defense for a physical move, Special Attack against Special Defense for a special one, whatever the move's type. Emerald picks the pair by type, below or above type 9 in the type list, so Thunder Punch (Electric) is special in Emerald and physical in Platinum, and Shadow Ball (Ghost) is physical in Emerald and special in Platinum.Code
A critical multiplies Platinum's damage by 2 after the base formula (its +2 included), at the same step as Emerald, and by 3 when the attacker has Sniper; Emerald's multiplier has no such case. As in Emerald, the critical then ignores the attacker's lowered attacking stat, the defender's raised defending stat, and Reflect or Light Screen.Code
In Platinum the ability Technician multiplies a move's power by 15/10 (rounded down) when that power is 60 or less, Struggle excepted. The test reads the power after the battle's power multiplier, Charge, and Helping Hand have changed it.Code
Symphony of War: The Nephilim Saga 2022Every damage formula in Symphony of War subtracts the defender's power from the attacker's and multiplies what's left: damage is (attack − defense) × the damage modifiers, then × the row and cover modifiers, and never below 0. Attack and defense are each a fixed number plus stats times the formula's weights, and each has modifiers of its own.Code
The weights differ by weapon. A melee attack's power is 25 + 2 × Strength + Weapon, against the target's 10 + Armor + half its Strength. A bow's is 15 + 2 × Strength + Weapon, against 10 + 1.25 × Armor + a quarter of Strength. A gun's is 10 + Weapon, against 10 + a quarter of Armor + 0.06 × Strength; a crossbow's is 10 + Weapon, against 10 + 0.75 × Armor + 0.19 × Strength. A spell's is 50 + 2 × Magic + Weapon + 2 × level, against 10 + 3.5 × the target's Magic.Code
With New Game+'s damage rebalance on (it's off by default), a stat counts in full only up to 30 for Strength, Armor and Magic and 100 for Weapon. Past that, the excess is multiplied by a rate and raised to a power: 0.8 and 0.9 for Strength and Armor, 0.75 and 0.9 for Magic, 0.9 and 0.95 for Weapon. Off, every stat counts in full.Code

References

  1. ^ abcdeCodenmikstas/dragon-warrior-disassembly · Ryan8bit, DW FormulasBank03.asm 6719–6722, 8491–8500, 8541–8560
    How we know

    The hero's hit-damage routine takes X=A−⌊D/2⌋, the hero's attack power less half the monster's defense byte; if X≥2, damage is ⌊(X+⌊r(X+1)/256⌋)/4⌋ for a random byte r, so from ⌊X/4⌋ to ⌊X/2⌋.

    source_files/Bank03.asm at ebe6a13
    Our readingattack ← the displayed attack6719–6720defense ← the monster's base defense6721–6722defense ÷ 28492A ← attack − that8493–8495a borrow: weak attack (by its label)84962 or more: normal attack (not quoted)8498–8499else: weak attack (not quoted)8500base ← A (not quoted)8542factor ← A + 18543–8544a random number (not quoted)8545product ← its high byte × factor (not quoted)8547–8552A ← product's high byte + base8554–8556÷ 2 with the carry, then ÷ 28557–8558damage ← it (not quoted)8559
    (HeroAttack - EnemyAgility / 2) / 4,
    II.B, Hero attack formulas · archived copy ↗

    Claim page

  2. ^ abcCodeDisch, FF1 disassemblybank_0C.asm 4312–4313, 3994–3996, 4482–4526
    How we know

    Each swing that rolls under 200 also rolls damage from the base B to 2B, capped at 255; a hit subtracts the defender's absorb, with a minimum of 1, and the swings' damage adds up to one total.

    4312    LDA btl_attacker_strength   ; base damage of attacker's strength value
    
    Final Fantasy Disassembly/bank_0C.asm lines 4312–4313 at cbb87d3 · upstream ↗
    3994    LDY #btlch_dmg                  ; IB damage
    3995    LDA (btl_ib_charstat_ptr), Y
    3996    STA btl_attacker_strength
    
    Final Fantasy Disassembly/bank_0C.asm lines 3994–3996 at cbb87d3 · upstream ↗
    4482  : LDX $6BAD
    4483    LDA #$00
    4484    JSR RandAX
    4485    CLC
    4486    ADC $6BAD
    4487    STA math_basedamage     ; random between [basedmg, basedmg*2]
    ⋮
    4500    JSR MathBuf_Sub                         ;   subtract defender's absorb
    ⋮
    4510      INC math_dmgcalc
    ⋮
    4520      JSR MathBuf_Add
    ⋮
    4526    JSR MathBuf_Add16               ; total damage += dmgcalc
    
    Final Fantasy Disassembly/bank_0C.asm lines 4482–4526 at cbb87d3 · upstream ↗

    Claim page

  3. ^ abcdCodeNathan-R-Og/motherbattle.asm 3399–3427, 3444–3448, 4569–4572, 5285–5290, 4593–4610
    How we know

    In EarthBound Beginnings (English build), a normal attack deals the attacker's Offense less half the target's Defense; when the Offense is below the Defense it deals (3 × Offense − Defense) ÷ 4 instead, at least 1. The damage routine then applies the ±0–24% spread, halves the result for a shielded or guarding target, and deals at least 1.

    src/global/prg/battle.asm at e0b3e3f
    Our readingdefense, offense (not quoted)3402–3417offense below defense: the weak bash (by its label)3418–3419defense ÷ 23420–3421damage ← offense − that (not quoted)3422–3427damage 0: 13445–3448keep the target4570–4571copy the input, then on to RNG_WORD4572working value ← the input5286–5289then RNG_WORD5290shielded: halve (by the comment)4594–4598guarding: halve again (by the comment)4600–4604resistances (by the comment)4606damage 0: 14607–4610

    Claim page

  4. ^ abcdCode“Lufia & the Fortress of Doom (USA)” · TequilaJosh/Lufia-ForgeGameDataLabels.cs 133–137
    How we know

    A physical hit's damage starts from ATP − DFP: (ATP − DFP + 1) ÷ 2 + 1 when ATP is higher, 2 when they are within 16 of each other the other way (or equal), and 0 when DFP is 16 or more higher. A critical hit doubles that base, and makes a base of 0 into 2. The base is then multiplied by a factor of 96 plus the mean of (base ÷ 16 + 2) rolls of random(64), over 128, so the larger the base the closer the factor stays to about 127 (computed), and the mean, rounded up, of two rolls of random(r) is added, where r is ATP ÷ 8 rounded to the nearest, plus 1. DFP counts one and a half times against a target in one state the code tests (not identified here), and an attack with ATP 0 misses. Steps for slayer types, elements, weapon specials, a stone target (no damage) and drain follow and aren't covered here.

    In the cartridge (“Lufia & the Fortress of Doom (USA)”): $08:BFCF-$BFE2: attack = $1452, defense = $1456, then the damage routine; $08:C0A5-$C17C: miss if the target fails its check or attack is 0; d = attack - defense: d > 0: (d + 1)/2 + 1; d = 0 or -16 < d < 0: 2; d <= -16: 0; critical doubles it ($C01E); n = base/16 + 2; factor = 96 + (sum of n random(64)) / n; damage = base x factor x 2 / 256; r = (attack >> 3) + 1 + the carry out (bit 2 of attack); + (random(r) + random(r)) / 2 with the carry added; then the type-match, element, weapon-special and status steps; $08:C01E-$C045: if the critical flag is set: base x 2 (a base of 0 becomes 2); $08:B9DB-$BA04: the target's stat $18 (DFP), times 1.5 when the target's state ($BD69) is 1; $08:BA05-$BA10: the attacker's stat $10 (ATP); $08:B829-$B85A, random(n): the next of 55 bytes at $1466 (the index wraps at $37, when $B8A1 refills them) times n's low byte, keeping the product's high byte; $08:F30C-$F32B: the monster record's offset per stat code: $10 is +$15 and $18 is +$17 (record +20 and +22). We don't reproduce the bytes.

    133    public static readonly ByteOption[] StatKinds =
    ⋮
    135        new(0x00, "Nothing"), new(0x10, "ATP"), new(0x18, "DFP"), new(0x20, "AGL"),
    136        new(0x28, "INT"), new(0x38, "MGR"),
    
    LufiaForge/LufiaForge/Modules/GameData/GameDataLabels.cs lines 133–137 at 0f32a62 · upstream ↗

    Claim page

  5. ^ abcdCodeeverything8215, FF6 disassemblycalc_dmg.asm 153–193, 239–248; math.asm 41–45
    How we know

    The damage-modification routine multiplies the damage by a random variance and then by 255 − the target's Defense (Magic Defense for a magic attack), each over 256 plus 1. The variance is a random byte ORed with $E0, so 224–255; the routine's comment says 240–255.

    153; [ calculate damage modification ]
    ⋮
    155; random variance, defense stat, shell/safe, defending, row, morph, friendly fire
    ⋮
    157CalcDmgMod:
    ⋮
    165        jsr     Rand
    166        ora     #$e0        ; random variance (240..255)
    167        sta     $e8
    168        jsr     MultDmg
    ⋮
    178        lda     near wTargetProp2::MagicDefense,y
    179        bcc     @0cd4
    180        lda     near wTargetProp2::Defense,y
    181@0cd4:  inc
    ⋮
    190        dec
    ⋮
    
    src/battle/calc_dmg.asm lines 153–193 at 8130132 · upstream ↗
    239; [ multiply damage by fraction ($e8 / 255) ]
    ⋮
    241MultDmg:
    242@0d3d:  php
    243        longa
    244        lda     $f0
    245        jsr     Mult24
    246        inc
    247        sta     $f0
    
    src/battle/calc_dmg.asm lines 239–248 at 8130132 · upstream ↗
    41; [ +a *= $e8 / 256 ]
    ⋮
    43; ++$e8 = +a * $e8
    ⋮
    45Mult24:
    
    src/battle/math.asm lines 41–45 at 8130132 · upstream ↗

    Claim page

  6. ^ abcCodedscotton/ct_disassemblybank_C1.asm 29284–29319, 29320–29339, 29343–29423, 28032–28065; battle_work.asm 38–48, 71–75
    How we know

    The defense value is one of two target bytes, as the technique's defense selector picks: $3E reads byte +$3E as is, $3C reads byte +$3C × 5 / 2 (the disassembly labels them Defense and Magic Defense). The target's statuses lower it: bit $02 or $80 of its byte +$1E multiplies it by 16/20 and skips the next three; otherwise each of bit $40, bits $05 and bit $20 multiplies it by 18/20. The low two bits n of the technique's property byte 8, when not 0, then scale it by n/4 (the disassembly's comment says only two property records set them and no player technique uses either), and the value is capped at 255. Damage is then magnitude × (256 − defense) / 256 plus the formula's bonus, and a result of 0 becomes 1.

    Battle_ResolveStatOperand: LDA.B $18 ; Resolve + modify the TARGET DEFENSE operand $18. (1) If $18 (TechProperty byte6) is a stat-index sentinel 0x3E/0x3C, replace it with the target's actual stat at $5E2D + $B1F6 + $18 (byte6 selects which defense stat); else literal. (2) Apply TARGET-STATUS defense modifiers from StatusCur1 ($5E4B): bits 0x80/0x02 (Stop/Sleep) -> def x16/20 (0.8); bit 0x40 (Poison) / bits 0x04+0x01 (Confused+Blind) / bit 0x20 -> def x18/20 (0.9) -- i.e. ailing targets defend worse. (3) byte8 DEFENSE-PIERCE (C1E748): if ActTech_Byte8 & 3 != 0 -> def = def*(byte8&3)/4; only property records 0x45/0x47 set this and NO player tech references them, so it is dormant for player techs (likely enemy-attack records). (4) Clamp def to 0xFF. Result $18 feeds Battle_ApplyDefenseReduction (dmg = magnitude*(256-def)/256). CMP.B #$3E BNE + REP #$20 LDA.B $18 CLC ADC.W $B1F6 TAX TDC SEP #$20 LDA.W !PC1Portrait,X STA.B $18 …
    bank_C1.asm#L29284-L29319 · upstream ↗
    Our readingselector $3E: the target's byte +$3E29285–29296selector $3C: the target's byte +$3C × 5 ÷ 229297–29319
    STX.B $18 ++ LDX.W $B1F6 LDA.W BatWork_StatusCur1,X STA.B $0E AND.B #$82 BEQ + TDC ; status Stop/Sleep (0x82): $18(def) = def * 16/20 (x0.8) LDA.B $18 TAX STX.B $28 LDX.W #$0010 STX.B $2A …
    bank_C1.asm#L29320-L29339 · upstream ↗
    Our readingtarget +$1E bits $82: × 16 ÷ 20, skip the next checks29321–29339
    + LDA.B $0E AND.B #$40 BEQ + TDC ; status Poison (0x40): $18(def) = def * 18/20 (x0.9) LDA.B $18 TAX STX.B $28 LDX.W #$0012 STX.B $2A JSR.W Battle_Mul16 LDX.B $2C STX.B $28 …
    bank_C1.asm#L29343-L29423 · upstream ↗
    Our readingbit $40: × 18 ÷ 2029343–29359bits $05: × 18 ÷ 2029361–29377bit $20: × 18 ÷ 2029379–29395low two bits n of property byte 8: × n ÷ 429398–29411cap at 25529415–29421
    Battle_ApplyDefenseReduction: TDC ; Final damage step: $AD89 = $16 * (256 - $18) / 256, i.e. base magnitude $16 reduced by the defense fraction $18 (0-255). Also clears target status bits 0x06 ($5E4B[tgt] &= 0xF9). LDX.W $B1F6 LDA.W BatWork_StatusCur1,X AND.B #$F9 STA.W BatWork_StatusCur1,X REP #$20 LDA.W #$0100 SEC SBC.B $18 SEP #$20 TAX STX.B $28 …
    bank_C1.asm#L28032-L28065 · upstream ↗
    Our readingclear the target's +$1E bits $02 and $0428033–28036magnitude × (256 − defense) ÷ 25628037–28054plus the bonus28055–280590 becomes 128062–28065
    38BatWork_Calc43     = $5E70   ; +0x43     computed-on-load value used in the damage magnitude
    39                             ;           (x5 sel.1 / x8 sel.2 w/ currentPower); exact stat TBD
    40BatWork_CurPower   = $5E63   ; +0x36     live Power
    41BatWork_CurStamina = $5E64   ; +0x37     live Stamina
    42BatWork_CurSpeed   = $5E65   ; +0x38     live Speed
    43BatWork_CurMagic   = $5E66   ; +0x39     live Magic
    44BatWork_CurHit     = $5E67   ; +0x3A     live Hit (accuracy)
    45BatWork_CurEvade   = $5E68   ; +0x3B     live Evade
    46BatWork_CurMagDef  = $5E69   ; +0x3C     live Magic Defense
    47BatWork_CurAttack  = $5E6A   ; +0x3D     live Attack
    48BatWork_CurDefense = $5E6B   ; +0x3E     live Defense
    
    battle_work.asm lines 38–48 at eeae27a · upstream ↗
    71ActTech_Byte8   = $AEEE   ; byte8  -> $AE4E (via Battle_LatchTechBytes7and8). LOW 2 BITS = a DEFENSE-PIERCE
    72                          ;        multiplier: in Battle_ResolveStatOperand (C1E741) if byte8&3 != 0
    73                          ;        the target defense $18 = def*(byte8&3)/4. Only property records
    74                          ;        0x45/0x47 set it ($3E=x0.5, $01=x0.25) and NO player tech uses
    75                          ;        those records -> dormant for players (enemy-attack records).
    
    battle_work.asm lines 71–75 at eeae27a · upstream ↗

    Claim page

  7. ^ abcCode“Arcana (USA)”
    How we know

    A weapon hit's damage, with each product rounded down to a whole number: attack = power x (Strength figure x share / 256 + buff + 205 - share) / 256, where the Strength figure is Strength x 191 / 256 + 64, share is the weapon's strength-share byte, power is the weapon's power word (10 bare-handed), and buff is 25, or 50 with one of the attack flag bits set and 0 with the other. Defense = armor x 102 / 256 + shield x 51 / 256 + (Endurance x 223 / 256 + 32) x 51 / 256, plus 25, 50 or 0 by its own two flag bits. The damage is attack x (255 - defense) / 256, times the row factor (1, 1, or about 0.88, 0.76 or 0.64), the element factor, the race factor, 0.75 when bit 8 of the target's state is set and 2 on a critical, before the random spread.

    In the cartridge (“Arcana (USA)”): $00:C0CB-$C16B: attack (C4CA), defense (C526) plus the buff ($00:C04F x $33 / 256); attack x ($FF - defense) / 256; x row factor ($00:C176); x element factor (C30C); x race factor (C431); x $C0 / 256 if the target's state has bit 8; x 2 if critical; then the spread at $00:C2AB; $00:C4CA-$C525: share = C6DC(1); (Strength figure x share / 256 + buff x $33 / 256 + $CD - share) x power (C6DC(2)) / 256; $00:C526-$C565: armor (C781) x $66 / 256 + accessory (C7D1) x $33 / 256 + Endurance figure x $33 / 256; $00:C658-$C67B: Strength x $BF / 256 + $40; Endurance x $DF / 256 + $20; $00:C88B-$C8C1: the 8 x 8 and 16 x 8 multiplies. We don't reproduce the bytes.

    Claim page

  8. ^ abcCodepret/pokeredcore.asm 4299–4318, 4343–4459, 4030–4034; battle_constants.asm 53–54
    How we know

    The base-damage routine computes ⌊⌊(⌊2×Level/5⌋+2)×Power×Attack/Defense⌋/50⌋, caps it at 997, and adds 2, so the type step receives 2–999. For a move with the explode effect it halves Defense first (to at least 1).

    engine/battle/core.asm at af51989
    Our readingthe attacker's move effect (not quoted)4306–4310not the explode effect: on4314–4315defense ÷ 24316 0: 14317–4318level × 24344–4345 carry into the high byte (not quoted)4346–4353÷ 54356–4361+ 24364–4365× power4370–4371× attack4374–4375÷ defense4378–4380÷ 504383–4385quotient's low byte + the damage's high byte4389–4392back into the quotient (not quoted)4393 a carry: next byte + 1; it wraps: cap (not quoted)4394–4400quotient's second byte not 0: cap (not quoted)4403–4407quotient 998 or more: cap (not quoted)4409–4418add the quotient into the damage (not quoted)4421–4431 a carry out: cap (not quoted)4432damage 998 or more: cap (not quoted)4434–4444cap: 9974446–4450+ 24454–4457 a carry: high byte + 1 (not quoted)4458–4459damage ← 04031–4034
    53DEF MIN_NEUTRAL_DAMAGE EQU 2
    54DEF MAX_NEUTRAL_DAMAGE EQU 999
    
    constants/battle_constants.asm lines 53–54 at af51989 · upstream ↗

    Claim page

  9. ^ abcCodeNathan-R-Og/dq2bank4.asm 6284–6290, 9138–9142, 5098–5126, 6299–6309, 3025, 5214–5240
    How we know

    In Dragon Warrior II (NA NES), a hero's attack takes X=A−⌊D/2⌋, attack power less half the monster's defense; if X is under 2 the hit deals 0 or 1, and otherwise ⌊Xr/256⌋, where r is 8 plus the sum of sixteen random 0–15 rolls (8 to 248, centered on 128), so about half of X; a hero under Surround deals 0 one time in 4.

    src/us/prg/bank4.asm at 0fb64a4
    Our reading$99 ← byte $0B of the record at $B96285–6287$9B ← byte 6 of the record at $B7, the defense6288–6290record byte 6 ← the monster's stat byte 69138–9142defense ÷ 25098–5100attack − that (by the comment)5101below 0: 0 or 1 at random (by the comment)5103under 2: the same (by the comment)5105–5109else: a random factor near $80 (by the comment)5111–5112× it, keeping the high byte (by the comment)5114–5120the 0-or-1 roll: a random number to 2 (by the comment)5124–5126Surround bit ($02) of the record at $B9 clear: on (not quoted)6299–6302a random number to 4, not 0: on (by the comment)6303–6306else: damage ← 06307–6309
    Midenhall status (80 = Alive, 40 = Sleep, 20 = Poison, 10 = ?, 08 = ?, 04 = In Party, 02 = Surround, 01 = Silence)
    src/us/prg/bank4.asm#L3025-L3025 · upstream ↗
    src/us/prg/bank4.asm at 0fb64a4
    Our readingmask ← $0F5214–5217sum ← $885219–522016 times: sum + a random byte AND the mask (not quoted)5221–5234sum − $805235–5238

    Claim page

  10. ^ abCodeeverything8215, FF2 disassemblyff2j.asm 18008–18074, 16173–16174; ram-map.txt 591–596
    How we know

    Each hit that gets through deals attack plus a random 0 to attack, less the target's defense (at least 0), and the hits add up; a cursed attacker's attack is halved first, and so is a cursed target's defense. Each hit also rolls 0–100, and a roll under 5 makes it critical, adding the attack again.

    18008; [ calculate damage ]
    ⋮
    18010;  $44: attack
    18011;  $46: defense
    18012;  $48: number of hits
    18013; +$4A: damage
    ⋮
    180190C/BC90: 20 71 AF  JSR $AF71          ; get attacker status 1
    180200C/BC93: 29 08     AND #$08
    180210C/BC95: F0 04     BEQ $BC9B
    180220C/BC97: 46 45     LSR $45
    180230C/BC99: 66 44     ROR $44
    180240C/BC9B: B1 A1     LDA ($A1),Y
    180250C/BC9D: 29 08     AND #$08
    ⋮
    
    ff2j.asm lines 18008–18074 at 8d26190 · upstream ↗
    161730C/AF71: A0 08     LDY #$08
    161740C/AF73: B1 9F     LDA ($9F),Y        ; status 1
    
    ff2j.asm lines 16173–16174 at 8d26190 · upstream ↗
    $08 abcdefgh status 1 … e: curse
    ram-map.txt#L591-L596 · upstream ↗

    Claim page

  11. ^ abcCode“Dragon Warrior III (USA)” · zeromus/DragonWarrior3bank04.inc 7009–7062, 8954–8962, 3466–3483, 6683–6723, 6905–6911, 9560–9606
    How we know

    In Dragon Warrior III (NA NES), a hero's attack takes X=A−⌊D/2⌋, attack power less half the monster's defense; under 2 it deals 0 or 1, and otherwise ⌊X⌊r/4⌋/64⌋, where r is a bell-shaped roll centered on 128 clamped to 102–153, so 25/64 to 38/64 of X.

    In the cartridge (“Dragon Warrior III (USA)”): bank 4 $ACD9-$AD2B, attack less half of _enemy_DEF ($0520), the under-2 branch, the clamp, and the multiply and divide; bank 4 $BA64-$BA98, the roll; 16 plus thirty-two 4-bit random numbers, less 128, drawn again until it fits in a byte. We don't reproduce the bytes.

    7009sub_6ACD6:
    7010		JSR		sub_6B777
    ⋮
    7013sub_6ACD9:
    ⋮
    7018		JSR		_sram_b0_s17_player_rATK_read
    7019		LSR		byte_5A
    7020		ROR		byte_59
    7021		LDA		word_4
    7022		SEC
    7023		SBC		byte_59
    7024		STA		word_4
    7025		LDA		word_4+1
    7026		SBC		byte_5A
    ⋮
    
    disassembly/bank04.inc lines 7009–7062 at b35d5fd · upstream ↗
    8954sub_6B777:
    8955		LDA		_acting_enemy
    8956		ASL
    8957		TAX
    8958		LDA		_enemy_DEF,X
    8959		STA		byte_59
    8960		LDA		byte_530+1,X
    8961		STA		byte_5A
    8962		RTS
    
    disassembly/bank04.inc lines 8954–8962 at b35d5fd · upstream ↗
    3466; Player attacking logic (one attack)
    ⋮
    3483		JSR		_bs_some_attack_command
    
    disassembly/bank04.inc lines 3466–3483 at b35d5fd · upstream ↗
    disassembly/bank04.inc at b35d5fd
    Our readingmask ← 15, count ← 329561–9563sum ← count ÷ 2 = 169575–957832 times: sum += a random byte AND 159579–9591sum ← sum − 1289597–9602not 0–255: roll again9604

    2 more excerpts on the claim page

  12. ^ abcCodeNathan-R-Og/mother · “EarthBound Beginnings (USA, Europe) (Virtual Console)” · “Mother (Japan)”constant.asm 9867–9918, 9943–9970; battle.asm 5285–5290
    How we know

    In EarthBound Beginnings (the English build that the 2015 Virtual Console release uses), a shared routine adds random spread to a value: it moves the value by a weight in percent drawn from a 128-entry table by a random byte, up or down at even odds. The weights run from 0 to 24, and 92 of the 128 entries are 10 or less, so most rolls move the value by a few percent. Damage and the turn-order Speed roll both use it.

    src/global/prg/constant.asm at e0b3e3f
    Our readingvalue × 649867–9872$62 ← 0; push the value's three bytes (not quoted)9873–9879divisor ← $64; B31_113d9880–9882A ← a random byte ÷ 2, its low bit kept as the sign9883–9885X ← A9886multiplier ← the weight table's entry X9887–9888value × it9889sign bit set: to the subtraction9890–9891else: saved + product, three bytes (not quoted)9892–9900subtraction: saved − product, three bytes (not quoted)9904–9912X ← 69914three bytes ÷ 2, X times (not quoted)9916–9918
    9943; $F37D - This table is indexed by (rand() >> 1) -- wtf is this layout
    9944; WEIGHT
    9945B31_137d:
    
    src/global/prg/constant.asm lines 9943–9970 at e0b3e3f · upstream ↗

    In the cartridge (“EarthBound Beginnings (USA, Europe) (Virtual Console)”): the fixed bank's $F37D, the 128 weights as the ROM has them. We don't reproduce the bytes.

    src/global/prg/battle.asm at e0b3e3f
    Our readingthe routine's word ← the input number5286–5289on into RNG_WORD5290

    In the cartridge (“Mother (Japan)”): B31_137d; B31_137d. We don't reproduce the bytes.

    Claim page

  13. ^ abCodeeverything8215, FF3 disassemblyff3j.asm 11974–12064
    How we know

    The damage roll is attack plus a random 0 to half of it (the half kept to 8 bits, so it wraps for an attack of 512 or more), times the elemental multiplier (stored doubled and halved back), plus the crit bonus on a critical, less defense (at least 0; skipped when a character hits a character); that times the net hits, divided by the targets hit, is capped at 9,999.

    11974; [ calculate damage ]
    ⋮
    11976; $24: no. of hits (before hit % check)
    11977; $25: attack
    11978; $26: defense
    11979; $27: damage multiplier (gets divided by 2)
    11980; $28: crit bonus
    11981; $29: crit flag
    11982; $2A: number of targets hit (divide damage)
    11983; $2B: attack msb
    ⋮
    1198531/BB44: A5 2B     LDA $2B
    1198631/BB46: 4A        LSR 
    1198731/BB47: A5 25     LDA $25
    ⋮
    
    ff3j.asm lines 11974–12064 at 1acef81 · upstream ↗

    Claim page

  14. ^ abCodeeverything8215, FF4 disassemblydamage.asm 33–99; fight.asm 341–342
    How we know

    The damage routine takes attack power plus a random 0 to half of it, applies the elemental and creature-type multipliers, adds the crit bonus on a critical, and subtracts defense (floored at 0); that times the net hits, divided by the number of targets, is held to 1–9,999. A Fight command has one target.

    33CalcDmg:
    34@c99f:  ldx     $3902       ; base attack
    35        stx     $3956
    36        stx     $3958
    37        lsr     $3957
    38        ror     $3956
    ⋮
    42        stx     $3956
    ⋮
    44        lda     $3956
    45        jsr     RandXA
    ⋮
    47        stx     $3956
    48        jsr     Add16
    ⋮
    50        stx     $a4
    ⋮
    
    battle/damage.asm lines 33–99 at a360e2e · upstream ↗
    341@c75f:  lda     #$01
    342        sta     $3906       ; single target (don't divide damage)
    
    battle/fight.asm lines 341–342 at a360e2e · upstream ↗

    Claim page

  15. ^ abcCodeeverything8215, FF3 disassembly · everything8215, FF4 disassemblyff3j.asm 11959–11970, 11985–12062; damage.asm 16–27, 33–99
    How we know

    Final Fantasy IV keeps Final Fantasy III's physical attack: percentage rolls per point of an attack multiplier, the target's successful evade rolls subtracted, and one damage roll of attack plus 0 to half of it, with the crit bonus added before defense, multiplied by the net hits and capped at 9,999.

    ff3j.asm at 1acef81
    Our readinghits ← 011959–11960no hit rolls: skip (by the comment)11961–11962each roll: random 0 to $63 against the hit % (by the comment)11963–11965 below it: hits + 111966–11967 until the rolls run out11968–11970roll ← random 0 to half the attack (by the comment)11985–11989damage ← attack × 1 to 3/2 (by the comment)11992multiplier ÷ 2 is 0: damage ÷ 211996–12008else: damage × (multiplier ÷ 2), the halving rounded down12009–12010crit bonus × crit flag (by the comment)12015–12017damage ← attack + crit bonus (by the comment)12021the attacker a monster: subtract defense (by the comment)12025–12026attacker not a monster, target a character: skip it12027–12028− defense, at least 012029–12039× total hits (by the comment)12040–12048÷ $2A (by the comment)12049–12053over 9999: 999912054–12062
    battle/damage.asm at a360e2e
    Our readinghits ← 017no base hits: return18–19each base hit, counting down in Y:20 a Rand99 roll against the hit rate (by its label)21–22 below it: hits + 123–24 until the base hits run out25–26base attack34half of it, at most 25535–42attack + random 0 to that (by its label)43–48× element and creature type multipliers (by the comment)49–54a crit: + crit bonus55–63− defense $3904, at least 064–73× $38FC (by its label)74–79overflow: $FFFF80–83÷ $3906 (by its label)84–919999 or more: 999992–950: 196–98

    Claim page

  16. ^ abCode“Paladin's Quest (USA)”
    How we know

    A physical hit does the attacker's attack, plus a random 0 to 25/255 of it, minus nine tenths of the target's defense, at least 1. A target whose chosen command is the one coded 3 (14 for an enemy) takes half, rounded up. A battle flag raises the attack by a quarter, and a status raises the target's defense by an eighth.

    In the cartridge (“Paladin's Quest (USA)”): $01:A063-$A12B: defense D (plus D/8 under status bit 3); attack A (plus A/4 when bit 7 of $1A0F is set); A + (A times a roll below 26)/255 - (D - D/10), 1 if zero or below; halved, rounding up, when the target's command byte is 3 for a party member or $0E for an enemy; $01:A1F1-$A1FA: an enemy's attack becomes its action's power. We don't reproduce the bytes.

    Claim page

  17. ^ abCode“Arcana (USA)”
    How we know

    Damage gets a random spread on top: with S = base x 38 / 256 + 1 (at most 255), the result is the base plus a random number modulo S, then held between 1 and 999. A base of 100 comes out 100 to 114. Healing spells use 13 in place of 38.

    In the cartridge (“Arcana (USA)”): $00:C2AB-$C2ED: S = (base x $26) / 256 + 1, at most $FF; base + random mod S; below 1: 1; 1000 or more: 999. We don't reproduce the bytes.

    Claim page

  18. ^ abcCodeeverything8215, FF5 disassemblybattle-main.asm 22910–22945, 19430–19467
    How we know

    Physical damage is (Attack − Defense) × M, at most 9,999, and 0 when Defense is at least Attack. For swords, Attack is the weapon's attack power plus a random 0 to an eighth of it, and M is Level × Strength ÷ 128 + 2.

    src/battle/battle-main.asm at 997c87d
    Our readingattack − defense22920–229230 or below: base damage ← 022924–22927 return (not quoted)22928–22929else: an M of 0 counts as 1 (not quoted)22933–22936net × M22938–229399999 or more: 999922940–22942base damage ← it (not quoted)22943attack power19441–19443attack ← it + random 0 to it ÷ 8 (by the comment)19444–19450M ← Level × Strength ÷ 128 + 2 (by the comment)19452–19462defense ← the target's19464–19467

    Claim page

  19. ^ abcCodeHerringway/ebsrclevel_2_attack.asm 7–30; 25_percent_variance.asm 11–93; +1 files
    How we know

    In EarthBound (US release), a bash deals 2 × the attacker's Offense − the target's Defense, moved up or down by up to 25%, and at least 1. The spread draws two random bytes and keeps the one nearer 128; its distance d from 128 moves the damage by d/512 of it, down when the byte is under 128 and up when over, so small changes are the most common.

    src/battle/actions/level_2_attack.asm at 68aec5c
    Our readingdamage ← 2 × the attacker's offense − the target's defense7–13above 0: TWENTY_FIVE_PERCENT_VARIANCE on it14–18 keep the result19above 0: on21–24else: 125–26then CALC_RESIST_DAMAGE, given $FF28–30
    src/battle/25_percent_variance.asm at 68aec5c
    Our readingkeep the damage11first ← a random byte (by its label)12–16second ← a random byte (by its label)17–20the first's distance from $8021–38the second's distance from $8039–55the first's distance at most the second's: keep the first56–58else: take the second and its distance59–60the byte taken below $8062–66 damage − (damage × distance ÷ 256) ÷ 267–76above $8080–83 damage + (damage × distance ÷ 256) ÷ 284–93exactly $80: unchanged83
    src/system/math/truncate_16_to_8.asm at 68aec5c
    Our readingbyte ← A, the distance10–11int ← X, the damage13–14int × byte (by its label)16–18shifted right 8: ÷ 256 (by its label)19–21return it22

    Claim page

  20. ^ abcCodeeverything8215, FF6 disassembly · dscotton/ct_disassemblycalc_dmg.asm 153–193, 239–248; math.asm 41–45; +1 files
    How we know

    When its damage modification runs (a flag can skip it) and the attack doesn't ignore defense, Final Fantasy VI multiplies damage by a random 224–255 (computed: a random byte ORed with $E0) over 256, adding 1, and then by 255 minus the target's Defense or Magic Defense over 256, adding 1, so defense also scales the random part; on one path the second factor is a fixed $3F (computed) in place of the defense. Chrono Trigger multiplies its magnitude by 256 minus the defense over 256 and adds a separately drawn bonus afterwards, which defense does not reduce.

    src/battle/calc_dmg.asm at 8130132
    Our readingskipped when the flag is 0163–164random byte ORed with $E0, multiply165–168an attack flag skips the defense multiply174–176Defense or Magic Defense: 255 − it, or $3F on one path177–193multiply, then add 1243–247
    41; [ +a *= $e8 / 256 ]
    ⋮
    43; ++$e8 = +a * $e8
    ⋮
    45Mult24:
    
    src/battle/math.asm lines 41–45 at 8130132 · upstream ↗
    REP #$20 LDA.W #$0100 SEC SBC.B $18 SEP #$20 TAX STX.B $28 LDX.B $16 STX.B $2A JSR.W Battle_Mul16 LDX.B $2C STX.B $28 …
    bank_C1.asm#L28037-L28059 · upstream ↗
    Our readingmagnitude × (256 − defense) ÷ 25628037–28054plus the bonus28055–28059

    Claim page

  21. ^ abCodedscotton/ct_disassemblybank_C1.asm 28591–28660; battle_work.asm 38–48
    How we know

    Formula 1 sets the magnitude to power × (12 × the attacker's byte +$36 + 5 × its byte +$43) / 18, where power is the technique's power byte, and draws a random bonus from 0 to a third of byte +$36 (rounded down). The disassembly labels +$36 the live Power and +$43 a value computed when the battle loads. The bonus is added after the defense step, so defense does not reduce it.

    Battle_DamageMagnitude: TDC ; Compute base damage magnitude; dispatches on $16 = byte5 (a FORMULA SELECTOR, not raw power). Selector 1: magnitude = power(byte9 ActTech_Power) * (5*atkStat$5E70 + 12*atkStat$5E63) / 0x12, and a variance factor $B2BE = Battle_RandRange(atkStat$5E63/3 + 1). Selector 2 ($C1E184): magnitude from atkStat$5E67*8 + atkStat$5E70*8. Selector 3 = Battle_MagicDamage ($C1E203): power*(Level+Magic)*12/15. Selector 4 ($C1E276) = ENEMY PHYSICAL ATTACK: power*CurAttack*2/0x12 (see comment there). Selector 5+ -> $C1E2D3. Result magnitude -> $2C/$30, then JMP $C1E575 (applies the $B2BE variance) -> Battle_ApplyDefenseReduction. LDA.B $16 CMP.B #$01 BEQ + JMP.W Battle_DmgMag_TrySel2 + JSR.W Battle_WakeTargetOnDamage LDX.W $B1F4 TDC LDA.W BatWork_CurPower,X TAX STX.B $28 LDA.B #$0C …
    bank_C1.asm#L28591-L28660 · upstream ↗
    Our readingformula 1 only28592–2859512 × byte +$3628600–28608plus 5 × byte +$4328610–28621times the technique's power28624–28635over 1828638–28642bonus: random 0 to (byte +$36 / 3)28645–28657keep the magnitude and go to the status step28658–28660
    38BatWork_Calc43     = $5E70   ; +0x43     computed-on-load value used in the damage magnitude
    39                             ;           (x5 sel.1 / x8 sel.2 w/ currentPower); exact stat TBD
    40BatWork_CurPower   = $5E63   ; +0x36     live Power
    41BatWork_CurStamina = $5E64   ; +0x37     live Stamina
    42BatWork_CurSpeed   = $5E65   ; +0x38     live Speed
    43BatWork_CurMagic   = $5E66   ; +0x39     live Magic
    44BatWork_CurHit     = $5E67   ; +0x3A     live Hit (accuracy)
    45BatWork_CurEvade   = $5E68   ; +0x3B     live Evade
    46BatWork_CurMagDef  = $5E69   ; +0x3C     live Magic Defense
    47BatWork_CurAttack  = $5E6A   ; +0x3D     live Attack
    48BatWork_CurDefense = $5E6B   ; +0x3E     live Defense
    
    battle_work.asm lines 38–48 at eeae27a · upstream ↗

    Claim page

  22. ^ abcCodeCellenseres/Lufia2Decomp · vinheim3/lufia2-disasmbattle_target_action.c 717–798, 129–217; bank_005.s 12249–12400; +1 files
    How we know

    Once an action isn't rejected by the target's status or interrupted, its damage is a base value scaled, given a random bonus, cut by half the target's defense, halved, and trimmed by a factor: X = base × scale / 16; X + X × v / 256, with v random from 0 to the action's variance − 1; less half the target's defense, at least 0; halved; then less X × F / 256, where F is the action's damage-factor byte. First a roll from 0 to 99 is made against the action's chance byte: below it, the action's own scale stands and the target's defense counts as 0, a heavier hit that ignores defense; otherwise the scale is 16, times 1. Healing takes the scale and the random bonus only. A scaled base past 65,535 runs into a $00 byte in the code rather than a result. The base, chance, scale, variance, defense, and factor come from the action's battle script, which isn't read here, and the lines read hold no miss test.

    src/battle/battle_target_action.c at 6fc15bb
    Our readingentry requires the direct page at 0722–725if the action's flags meet the target's status bits: result 3 or 2; stop731–755run the target scripts764–766if the action was interrupted: result 3; stop767–773v = random(variance); the MP variance likewise774–781roll = random(100)782–784if roll ≥ chance: scale = 16785–789else: the hit counter + 1; defense = 0790–797scale the HP change798X = |change| × scale / 16; a product past 16 bits is left to the original code @129-145, 165-185P = X × v186–192if damage: X = X + P / 256 − defense / 2, at least 0 @147-159, 194-195X = X / 2196–197change = −(X − X × factor / 256)199–208if healing: change = X + P / 256209–215
    code/bank_005.s at aab3894
    Our readingif $7F:F4D0 has bit 1: result 3; end12249–12255v = random(v); the MP variance likewise12258–12263if random(100) < the chance byte ($7F:F45E): take the defense-ignoring branch12264–12267else: scale ($7F:F460) = 1612269–12272$7F:FAB7 + 1; defense ($7F:F4CC) = 0, by tdc with the direct page at 012274–12280damage: X = |change| × scale / 16; a high byte left over runs into a $00 byte12289–12321X = X + X × v / 256 − defense / 2, at least 0; X / 212324–12347change = −(X − X × factor / 256)12349–12362healing: change = X + X × v / 25612364–12397store the change12399–12400
    code/bank_000.s at aab3894
    Our readingevery 55th call refreshes the random bytes408–416random(A) = (A × the next random byte) / 256, from 0 to A − 1419–425

    Claim page

  23. ^ abcCodepret/pokeredcore.asm 3140–3150, 5531–5543
    How we know

    In Red and Blue, a damaging move runs the critical-hit test, the base formula, the type adjustment (STAB, then type rows), the random factor, and then the hit test (accuracy).

    3144	call CalculateDamage
    ⋮
    3147	call AdjustDamageForMoveType
    3148	call RandomizeDamage
    3149.moveHitTest
    3150	call MoveHitTest
    
    engine/battle/core.asm lines 3140–3150 at af51989 · upstream ↗
    engine/battle/core.asm#L5531-L5543 · upstream ↗

    Claim page

  24. ^ abcCodepret/pokeredcore.asm 5420–5454; data.asm 3
    How we know

    The damage-randomizing routine multiplies damage by a random byte, 217–255, and integer-divides by 255, leaving 0 or 1 damage untouched.

    5436; loop until a random number greater than or equal to 217 is generated
    ⋮
    5440	cp 85 percent + 1
    
    engine/battle/core.asm lines 5420–5454 at af51989 · upstream ↗
    3DEF percent EQUS "* $ff / 100"
    
    macros/data.asm line 3 at af51989 · upstream ↗

    Claim page

  25. ^ abCodeXeeynamo/ff7-decomp · everything8215, FF6 disassemblybattle.c 4491–4497, 4569–4623, 4552–4565; btlrand.c 19; +1 files
    How we know

    In the North American release, the physical damage routine takes the attacker's physical attack S (after stat multipliers) and the action's level L and computes (⌊L·S/32⌋ · ⌊(L + S)/32⌋ + S) × (512 − the target's defense) × the attack's power, over 8,192: a base of S + ⌊L·S/32⌋·⌊(L + S)/32⌋, scaled by power/16 and by (512 − defense)/512 (computed). It then doubles the damage when bit $2 of the action's damage flags is set, the bit a critical sets and that this same function also sets for any attack whose attack-flag bit $2000 is clear (ff7/critical), multiplies it by 1.5 under Berserk, for a short-range attack or an enemy's Attack command halves it once if the target or the attacker is in the back row (other attacks ignore rows), halves it for a defending target, multiplies it by a multiplier the target holds, over 8, when bit 0 of the unnamed field at 0x234 is set, quarters it under Frog, applies the Sadness, multi-target, and Barrier modifiers, and sets it to 0 under Mini. Last, the variance routine multiplies by 3,841 plus a random byte, over 4,096 (93.8–100%, computed), and raises 0 to 1, so a Mini attacker deals 1. Final Fantasy VI's damage-modification routine also lets defense remove a share, but as (255 − Defense)/256, with a variance of 224–255 over 256 applied before it.

    src/battle/battle.c at fc71ccc
    Our readingattack flag 4: magic attack (not quoted)4491–4493else: stat ← physical attack, multiplied4494–4497attack flag $2000 clear: damage flag $2 (not quoted)4580–4582S ← the attack stat4583L ← the level4584product term ← L × S ÷ 324585sum term ← (L + S) ÷ 324586raw ← (product × sum + S) × (512 − defense)4587 × power4587damage ← raw ÷ 8,1924588damage flag $2: × 24589–4590Berserk: × 3 ÷ 24592–4594halve ← target in the back row4596–4597short range or an enemy's Attack:4598 attacker in the back row: halve4599–4600else: don't halve4602–4603halve: ÷ 2 (not quoted)4605–4606target defending: ÷ 24609–4610unk234 bit 0: × back multiplier ÷ 8 (not quoted)4612–4614Frog: ÷ 44615–4616the Sadness modifier (by its label)4618the split-target modifier (by its label)4618the Barrier modifier (by its label)4618Mini: 04619–4620add the variance, raise 0 (by its label)4622× (random byte + 3,841) ÷ 4,0964559–45600: 14561–4563
    src/main/btlrand.c at fc71ccc
    Our readingthe next byte of the random table19
    src/battle/calc_dmg.asm at 8130132
    Our readingan unnamed flag 0: skip it all163–164variance ← random byte | $E0165–167damage × variance (by its label)168magic defense, or defense on carry178–180defense 255: factor 0181–182two unnamed bytes, either bit 7 clear: defense 192183–188factor ← 255 − defense189–192damage × factor (by its label)193

    Claim page

  26. ^Codenmikstas/metroid-disassembly · “Metroid (USA)”Bank07.asm 7985–8001, 7935–7954, 7741, 2506–2521, 2533–2544; Bank01.asm 1829–1830; +5 files
    How we know

    An enemy's touch costs Samus an amount set by her area rather than by the enemy: 8 units in Brinstar, 10 in Norfair, 20 in Kraid's hideout, 24 in Ridley's hideout, and 30 in Tourian, before the Varia suit halves it. The touch costs nothing while her screw attack is active, from an enemy whose status is 4 or more, or from an enemy type that the area's table marks with $10; and the subtraction itself charges nothing while the escape timer runs or Mother Brain is dying.

    7985LF2ED:  bcs +
    7986    jsr LF2DF
    7987    tya
    7988    pha
    7989    jsr IsScrewAttackActive     ;($CD9C)Check if screw attack active.
    7990    pla
    7991    tay
    7992    bcc +
    7993    lda #$80
    7994    sta $010F
    7995    jsr LF332
    7996    jsr LF270
    ⋮
    
    Source_Files/Bank07.asm lines 7985–8001 at 4270d57 · upstream ↗
    1829L95CE:  .byte $80           ;Base damage caused by area enemies to lower health byte.
    1830L95CF:  .byte $00           ;Base damage caused by area enemies to upper health byte.
    
    Source_Files/Bank01.asm lines 1829–1830 at 4270d57 · upstream ↗
    1844L95CE:  .byte $00           ;Base damage caused by area enemies to lower health byte.
    1845L95CF:  .byte $01           ;Base damage caused by area enemies to upper health byte.
    
    Source_Files/Bank02.asm lines 1844–1845 at 4270d57 · upstream ↗

    In the cartridge (“Metroid (USA)”): bank 7 $F306, the load; bank 1 $95CE, Brinstar's bytes; banks 2-5 hold the others at the same address. We don't reproduce the bytes.

    8 more excerpts on the claim page

  27. ^Codenmikstas/metroid-disassembly · “Metroid (USA)”Bank07.asm 2523–2531
    How we know

    With the Varia suit, the routine that subtracts health halves every amount it takes from Samus.

    2523LCEAC:  lda SamusGear           ;
    2524LCEAF:  and #gr_VARIA           ;Check is Samus has Varia.
    2525LCEB1:  beq +               ;
    2526LCEB3:  lsr HealthLoChange      ;If Samus has Varia, divide damage by 2.
    2527LCEB5:  lsr HealthHiChange      ;
    
    Source_Files/Bank07.asm lines 2523–2531 at 4270d57 · upstream ↗

    In the cartridge (“Metroid (USA)”): bank 7 SubtractHealth, $CE92. We don't reproduce the bytes.

    Claim page

  28. ^Codenmikstas/metroid-disassembly · “Metroid (USA)”Metroid_Defines.asm 270–272; Bank07.asm 8211–8212
    How we know

    Samus's health is binary-coded decimal in tenths of a unit; the byte at $0107 holds the full energy tanks in its high nibble and the tens digit in its low nibble, and the byte at $0106 holds the ones digit in its high nibble.

    270.alias HealthLo         $0106   ;Lower health digit in upper 4 bits.
    271.alias HealthHi         $0107   ;Upper health digit in lower 4 bits
    272                                ;# of full tanks in upper 4 bits.
    
    Source_Files/Metroid_Defines.asm lines 270–272 at 4270d57 · upstream ↗
    8211    ldx #$00            ;Increase HealthHi by 0.
    8212    ldy #$50            ;Increase HealthLo by 5.
    
    Source_Files/Bank07.asm lines 8211–8212 at 4270d57 · upstream ↗

    In the cartridge (“Metroid (USA)”): bank 7 $CE92, SubtractHealth, which subtracts in base 10. We don't reproduce the bytes.

    Claim page

  29. ^CodeOpenDUNEunitinfo.c 967–1031, 1113–1177, 675–739, 748–812, 529–593, 821–885, 894–958; unit.h 197; +2 files
    How we know

    The executable's unit table sets hit points, speed (out of 256), range in tiles, fire delay, and damage per shot: the Trike 100, 45, 3, 50, and 5; the Quad 130, 40, 3, 50, and 7; the combat tank 200, 25, 4, 80, and 25; the siege tank 300, 20, 5, 90, and 30; the rocket launcher 100, 30, 9, 120, and 75; the Devastator 400, 10, 5, 100, and 40; and the sonic tank 110, 30, 8, 80, and 60. PROFILE.INI, read from the game data at start, can replace any of these.

    967		/* name                 */ "Trike",
    ⋮
    986		/* hitpoints            */ 100,
    ⋮
    989		/* buildCredits         */ 150,
    990		/* buildTime            */ 40,
    ⋮
    1022		/* movingSpeedFactor    */ 45,
    ⋮
    1029		/* fireDelay            */ 50,
    1030		/* fireDistance         */ 3,
    1031		/* damage               */ 5,
    
    src/table/unitinfo.c lines 967–1031 at ebea79a · upstream ↗
    1113		/* name                 */ "Quad",
    ⋮
    1132		/* hitpoints            */ 130,
    ⋮
    1135		/* buildCredits         */ 200,
    1136		/* buildTime            */ 48,
    ⋮
    1168		/* movingSpeedFactor    */ 40,
    ⋮
    1175		/* fireDelay            */ 50,
    1176		/* fireDistance         */ 3,
    1177		/* damage               */ 7,
    
    src/table/unitinfo.c lines 1113–1177 at ebea79a · upstream ↗
    675		/* name                 */ "Tank",
    ⋮
    694		/* hitpoints            */ 200,
    ⋮
    697		/* buildCredits         */ 300,
    698		/* buildTime            */ 64,
    ⋮
    730		/* movingSpeedFactor    */ 25,
    ⋮
    737		/* fireDelay            */ 80,
    738		/* fireDistance         */ 4,
    739		/* damage               */ 25,
    
    src/table/unitinfo.c lines 675–739 at ebea79a · upstream ↗

    7 more excerpts on the claim page

  30. ^CodeOpenDUNEunit.c 623–628, 658–659, 683–692, 1544–1548; map.c 427–431; +2 files
    How we know

    A shot carries its unit's table damage, with no roll; only troopers and trooper squads firing beyond 2 tiles switch to a missile at damage − damage/4. The whole damage applies at the point of impact and within a quarter tile of it, where a unit, or a structure on the impact tile, loses it from its hit points, down to 0, with no armor or defense stat; units farther from the point take less (dune2/splash). Units flagged to fire twice (among them the Trike, Quad, rocket launcher, siege tank, and Devastator) follow a shot with a second after a delay of 5 rather than twice their fire delay (at normal game speed), but only while above half health; every fire delay gets 0 or 1 added at random.

    623	damage = ui->damage;
    ⋮
    626	fireTwice = ui->flags.firesTwice && u->o.hitpoints > ui->o.hitpoints / 2;
    ⋮
    628	if ((u->o.type == UNIT_TROOPERS || u->o.type == UNIT_TROOPER) && (int16)distance > 512) typeID = UNIT_MISSILE_TROOPER;
    
    src/script/unit.c lines 623–628 at ebea79a · upstream ↗
    659			damage -= damage / 4;
    
    src/script/unit.c lines 658–659 at ebea79a · upstream ↗
    683	u->fireDelay = Tools_AdjustToGameSpeed(ui->fireDelay * 2, 1, 0xFFFF, true);
    ⋮
    687		if (u->o.flags.s.fireTwiceFlip) u->fireDelay = Tools_AdjustToGameSpeed(5, 1, 10, true);
    ⋮
    692	u->fireDelay += Tools_Random_256() & 1;
    
    src/script/unit.c lines 683–692 at ebea79a · upstream ↗

    8 more excerpts on the claim page

  31. ^CodeOpenDUNEmap.c 405–431, 488–501; unit.c 1540, 1981–1983, 2020–2021, 1438–1444, 1399–1412; +2 files
    How we know

    A shell or missile damages where it explodes, not the unit it was fired at: the explosion damages every unit within one tile of the point (two for the Death Hand explosion), its own side's included, by the damage halved once per quarter tile of distance, so full within a quarter tile, half to a half, a quarter to three quarters, and an eighth to one tile; the frigate and bullets in flight take none. A structure on the impact tile takes the full damage. A shell flies to the target's position at the moment of firing and explodes there, or earlier on a wall, structure, or mountain tile in its path; a turret's shell passes over its own side's walls and structures.

    405	uint16 reactionDistance = (type == EXPLOSION_DEATH_HAND) ? 32 : 16;
    ⋮
    427			distance = Tile_GetDistance(position, u->o.position) >> 4;
    428			if (distance >= reactionDistance) continue;
    ⋮
    430			if (!(u->o.type == UNIT_SANDWORM && type == EXPLOSION_SANDWORM_SWALLOW) && u->o.type != UNIT_FRIGATE) {
    431				Unit_Damage(u, hitpoints >> (distance >> 2), 0);
    
    src/map.c lines 405–431 at ebea79a · upstream ↗
    489		Structure *s = Structure_Get_ByPackedTile(positionPacked);
    ⋮
    501			Structure_Damage(s, hitpoints, 0);
    
    src/map.c lines 488–501 at ebea79a · upstream ↗
    1540	if (!ui->flags.isNormalUnit && unit->o.type != UNIT_SANDWORM) return false;
    
    src/unit.c line 1540 at ebea79a · upstream ↗
    src/table/unitinfo.c at ebea79a
    Our readingDeath Hand missile: not a normal unit1332–1382Rocket: not a normal unit1405–1455ARocket: not a normal unit1478–1528GRocket: not a normal unit1551–1601MiniRocket: not a normal unit1624–1674Bullet: not a normal unit1697–1747Sonic Blast: not a normal unit1770–1820

    5 more excerpts on the claim page

  32. ^Codezladx/LADX-Disassembly · “Legend of Zelda, The - Link's Awakening (USA, Europe) (Rev 2)”bank3.asm 5313–5341; damages.asm 4–9; +1 files
    How we know

    A monster's touch costs Link the damage its health group lists, in eighths of a heart, mostly 4 or 8. In Link's Awakening DX the Blue Tunic halves it. Without the tunic, the Guardian Acorn halves it too and cancels a half-heart touch outright; the tunic is tested first and the two don't stack, so with the tunic a half-heart touch costs 2.

    src/code/entities/bank3.asm at 2a5c2c0
    Our readingthe entity's health group5313–5316damage ← EntityDamagesForGroup at it5318–5320Blue Tunic: halve, skipping the Acorn test5323–5325no Guardian Acorn: to damageModifiersEnd (not quoted)5328–5330damage not 4: to takeHalfDamages5332–53344: 05337takeHalfDamages: damage ÷ 25339–5341
    4EntityDamagesForGroup::
    5._00 db $04
    6._01 db $04
    7._02 db $08
    8._03 db $08
    9._04 db $18
    
    src/data/entities/damages.asm lines 4–9 at 2a5c2c0 · upstream ↗
    src/code/bank2.asm at 2a5c2c0
    Our readingmax hearts, at most MAX_HEARTS (not quoted)5305–5308× 85312–5315health not that: to incrementHealth (not quoted)5317–5319

    In the cartridge (“Legend of Zelda, The - Link's Awakening (USA, Europe) (Rev 2)”): the 1993 release's damage table, bank 3; its first 48 groups match DX's byte for byte. We don't reproduce the bytes.

    Claim page

  33. ^Code“Legend of Zelda, The - Link's Awakening (USA, Europe) (Rev 2)” · zladx/LADX-Disassemblybank3.asm 5323–5325
    How we know

    The 1993 Game Boy release has the same hit code as DX without the tunic check. It reads the damage from its health-group table, applies the Guardian Acorn's rule, and stores the same $50 in the invincibility counter.

    In the cartridge (“Legend of Zelda, The - Link's Awakening (USA, Europe) (Rev 2)”): bank 3; from the counter test to the `$50` store, DX's bytes less the 7-byte tunic test. We don't reproduce the bytes.

    5323    ld   a, [wTunicType]                          ;; 03:6D94 $FA $0F $DC
    5324    cp   TUNIC_BLUE                               ;; 03:6D97 $FE $02
    5325    jr   z, .takeHalfDamages                      ;; 03:6D99 $28 $0E
    
    src/code/entities/bank3.asm lines 5323–5325 at 2a5c2c0 · upstream ↗

    Claim page

  34. ^Coderyandwyer/perfect-dark · id-Software/DOOMinvitems.c 485–495; types.h 2920–2924; +7 files
    How we know

    The Falcon 2's single shot in Perfect Dark carries a damage of 1 in its single-shot definition, read by the gun's damage lookup. A guard adds each hit to its damage total against a maximum that the character setup sets to 4 (a level's AI script can set another), and the damage reaction starts its death once the total reaches it; so on Perfect Agent a default guard takes 4 Falcon 2 shots to a limb, 2 to the torso, or 1 to the head (computed). The player's health starts at 1, and a hit takes its damage × 0.125 from it, so a guard's Falcon 2 bullet takes an eighth on Perfect Agent (computed). Each Doom pistol bullet deals 5, 10, or 15 against a zombieman's 20.

    485struct funcdef_shootsingle invfunc_falcon2_singleshot = {
    486	INVENTORYFUNCTYPE_SHOOT_SINGLE,
    ⋮
    495	1, // damage
    
    src/game/invitems.c lines 485–495 at 46d3393 · upstream ↗
    2920struct funcdef_shoot {
    2921	struct funcdef base;
    2922	/*0x14*/ struct recoilsettings *recoilsettings;
    2923	/*0x18*/ s8 recoverytime60;
    2924	/*0x1c*/ f32 damage;
    
    src/include/types.h lines 2920–2924 at 46d3393 · upstream ↗
    475f32 gset_get_damage(struct gset *gset)
    ⋮
    481		if ((func->type & 0xff) == INVENTORYFUNCTYPE_SHOOT) {
    482			struct funcdef_shoot *shootfunc = (struct funcdef_shoot *)func;
    483			damage = shootfunc->damage;
    
    src/game/gset.c lines 475–483 at 46d3393 · upstream ↗

    11 more excerpts on the claim page

  35. ^Coderyandwyer/perfect-dark · id-Software/DOOMchraction.c 4262–4273, 4368–4370, 4390–4400, 4413–4422, 4707–4751, 10361–10385; constants.h 1396–1413; +1 files
    How we know

    Perfect Dark's character damage routine scales a hit by the body part it struck: a head hit is multiplied by 4 and a torso hit doubled, the limbs and pelvis keep the damage, and a hit on the held gun or a hat deals none. Outside normal multiplayer a gun shot fired by a player multiplies a head hit by a further 25, 100 in all, unless a shield took it; a Skedar's head is only doubled, and its tail takes 10 times. A hit with no part (as when a guard's bullet hits the player) is halved and then doubled as the torso, so it keeps its damage. Doom's hitscan attack passes a bullet's damage to the thing it hits with no body part.

    4262void chr_damage(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset,
    4263		struct prop *aprop, s32 hitpart, bool damageshield, struct prop *prop2,
    ⋮
    4273	f32 headshotdamagescale = 1;
    
    src/game/chraction.c lines 4262–4273 at 46d3393 · upstream ↗
    4368	if (ismelee) {
    4369		isshoot = false;
    
    src/game/chraction.c lines 4368–4370 at 46d3393 · upstream ↗
    4390	// Apply damage scaling based on difficulty settings
    4391	if (g_Vars.mplayerisrunning == false) {
    4392		// Solo
    ⋮
    4397		} else if (aprop && aprop->type == PROPTYPE_PLAYER) {
    4398			// Player is attacking
    4399			damage *= g_PlayerDamageTxScale;
    4400			headshotdamagescale = 25;
    
    src/game/chraction.c lines 4390–4400 at 46d3393 · upstream ↗

    5 more excerpts on the claim page

  36. ^ abCodeid-Software/wolf3dWL_AGENT.C 1196–1242; WL_MAIN.C 1282–1283; +2 files
    How we know

    A Wolfenstein 3D gun shot picks a target instead of tracing a bullet's path: it takes the nearest visible shootable actor within a tenth of the view's width of the screen's center column and hits it if the line-of-sight check returns true, which its header comment describes as "a straight line between the player and ob is unobstructed"; as written, the loop's second pass looks only for actors nearer than that one, so a blocked line is a miss (computed). The damage is a random roll (0 to 255) by the larger of the x and y tile distances: under 2 tiles the roll / 4 (0 to 63), under 4 the roll / 6 (0 to 42), and farther a miss when a first roll / 12 is below the distance, otherwise a second roll / 6.

    WOLFSRC/WL_AGENT.C at 0516778
    Our readingrepeat:1196 last ← the closest1198 for each actor after the player1200 shootable, visible, within shootdelta of the center column1201–1203 nearer than the nearest so far: it is the closest1206–1209 no new closest: return, a miss1213–1214 CheckLine true: stop looking1219–1220x, y distances ← |its tile − the player's tile|1227–1228distance ← the larger1229under 2: damage ← a roll ÷ 41231–1232else under 4: a roll ÷ 61233–1234else: a roll ÷ 12 below the distance: return, a miss1237–1238 else: damage ← a roll ÷ 61239damage the actor1242
    WOLFSRC/WL_MAIN.C at 0516778
    Our readingcenter column ← the view's width ÷ 2 − 11282shootdelta ← the view's width ÷ 101283
    1030= CheckLine
    ⋮
    1032= Returns true if a straight line between the player and ob is unobstructed
    
    WOLFSRC/WL_STATE.C lines 1030–1032 at 0516778 · upstream ↗
    WOLFSRC/ID_US_A.ASM at 0516778
    Our readingsegment setup (not quoted)88–89index + 1, & $FF, stored back (not quoted)90–93AL ← the table's entry at the index; AH ← 094–95

    Claim page

  37. ^Codeid-Software/wolf3dWL_ACT2.C 3449–3490; WL_DEF.H 75
    How we know

    An enemy's shot in Wolfenstein 3D traces no bullet either: when the shooter's area connects to the player's and the line-of-sight check finds a clear line, it hits if a random roll is below a chance of 256 less 16 per tile of distance, or less 8 per tile when the shooter isn't visible on the player's screen, starting from 160 instead of 256 when the player's thrust this frame reached 6,000; SS guards and bosses count two-thirds of the distance. A hit deals the roll >> 2 (0 to 63) under 2 tiles, >> 3 (0 to 31) under 4, and >> 4 (0 to 15) farther.

    3449	hitchance = 128;
    ⋮
    3451	if (!areabyplayer[ob->areanumber])
    3452		return;
    ⋮
    3454	if (!CheckLine (ob))			// player is behind a wall
    3455	  return;
    ⋮
    3457	dx = abs(ob->tilex - player->tilex);
    3458	dy = abs(ob->tiley - player->tiley);
    3459	dist = dx>dy ? dx:dy;
    ⋮
    3461	if (ob->obclass == ssobj || ob->obclass == bossobj)
    3462		dist = dist*2/3;					// ss are better shots
    ⋮
    3464	if (thrustspeed >= RUNSPEED)
    ⋮
    3466		if (ob->flags&FL_VISABLE)
    ⋮
    
    WOLFSRC/WL_ACT2.C lines 3449–3490 at 0516778 · upstream ↗
    75#define RUNSPEED   		6000
    
    WOLFSRC/WL_DEF.H line 75 at 0516778 · upstream ↗

    Claim page

  38. ^Code3D Realms, duke3dsource.zip · id-Software/DOOMPLAYER.C 557–561, 674–675, 3647–3650, 3690–3702, 3759; GAMEDEF.C 849–881; +3 files
    How we know

    Each shot a Duke Nukem 3D player fires from the pistol, shotgun, or chaingun carries the strength its actor declares in the CON script plus a random number modulo 6 (0 to 5): 6 to 11 for the pistol, 10 to 15 for each of the shotgun's 7 pellets, and 9 to 14 for the chaingun; a monster's shot carries the strength alone. Each bullet from Doom's pistol, chaingun, or shotgun deals 5, 10, or 15.

    557            if(p >= 0)
    ⋮
    559                k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,10,10,sa,0,0,i,4);
    560                sprite[k].extra = *actorscrptr[atwith];
    561                sprite[k].extra += (TRAND%6);
    
    source/PLAYER.C lines 557–561 at e75bb06 · upstream ↗
    674                k = EGS(hitsect,hitx,hity,hitz,SHOTSPARK1,-15,24,24,sa,0,0,i,4);
    675                sprite[k].extra = *actorscrptr[atwith];
    
    source/PLAYER.C lines 674–675 at e75bb06 · upstream ↗
    849            scriptptr--;
    850            parsing_actor = scriptptr;
    ⋮
    853            scriptptr--;
    854            actorscrptr[*scriptptr] = parsing_actor;
    ⋮
    865                        scriptptr--;
    ⋮
    881                    *(parsing_actor+j) = *(scriptptr-1);
    
    source/GAMEDEF.C lines 849–881 at e75bb06 · upstream ↗

    8 more excerpts on the claim page

  39. ^Code3D Realms, duke3dsource.zipGAME.C 3038, 3143; SECTOR.C 2329–2335; +1 files
    How we know

    A Duke Nukem 3D sprite's pending damage is set to −1 when the sprite is created and again each time the weapon-hit check takes it; a shot that the sprite-hit handler takes in its default branch adds its damage to the pending total, and the weapon-hit check subtracts the total from the target's health, so a target hit once between checks loses 1 less than the shot carries, and several hits between checks take 1 less than their sum (computed). An explosion's radius damage sets the pending damage outright for the targets it rolls for, so those lose the full roll.

    3038    hittype[i].extra = -1;
    
    source/GAME.C line 3038 at e75bb06 · upstream ↗
    3143        hittype[i].extra = -1;
    
    source/GAME.C line 3143 at e75bb06 · upstream ↗
    2329                if( sprite[i].statnum != 2 )
    ⋮
    2334                    hittype[i].picnum = sprite[sn].picnum;
    2335                    hittype[i].extra += sprite[sn].extra;
    
    source/SECTOR.C lines 2329–2335 at e75bb06 · upstream ↗

    3 more excerpts on the claim page

  40. ^Code3D Realms, duke3dsource.zip · id-Software/DOOMUSER.CON 127, 149; GAME.CON 3168; +6 files
    How we know

    A Duke Nukem 3D pipe bomb that goes off passes its strength, 140, to the radius-damage routine with the radius 2,500; each sprite in lists 1, 6, 10, or 12 (not flammable) with health (duke3d/pending-damage) of 0 or more that is a tripbomb, a monster, a QUEBALL, a STRIPEBALL, a DUKELYINGDEAD, or solid (cstat&257), within that distance and in sight of the blast, takes 105 to 139 inside a third of the radius, 70 to 104 inside two thirds, and 35 to 69 beyond: three quarters, a half, or a quarter of the strength plus a random number modulo the next band's gap, 35 (computed). A monster in sprite list 2, which the hit wakes into list 1, goes through the sprite-hit handler instead unless a sight test at a random height fails, and loses 139 at any distance in the radius, the bomb's 140 added to its pending −1; a bomb set off by a hit first loses that hit's damage from its strength. A Doom rocket's blast falls off linearly, 128 minus the distance.

    127define PIPEBOMBRADIUS           2500
    
    testdata/USER.CON line 127 at e75bb06 · upstream ↗
    149define HANDBOMB_WEAPON_STRENGTH        140
    
    testdata/USER.CON line 149 at e75bb06 · upstream ↗
    3168actor HEAVYHBOMB HANDBOMB_WEAPON_STRENGTH enda
    
    testdata/GAME.CON line 3168 at e75bb06 · upstream ↗

    11 more excerpts on the claim page

  41. ^Codeid-Software/Quake-2p_weapon.c 767–774, 1310–1318; g_weapon.c 589–607; +2 files
    How we know

    A Quake II rocket's direct hit does 100 plus a random whole number below 20 damage, 100 to 119, the roll made when it is fired; the explosion then does radius damage to everything else within 120 units, the rocket's 120 less half the distance from the explosion to the center of the target's box, and the target hit directly takes no splash. A quad damage multiplies both by 4. The railgun's damage is a constant, 150 in single player and 100 in deathmatch.

    game/p_weapon.c at 372afde
    Our readingdamage ← 100 + random × 20, truncated767splash 120 within 120768–769quad: both × 4770–773
    game/g_weapon.c at 372afde
    Our readinghit something that takes damage: the rocket's damage589–591else, outside net games (not quoted)593–596 not warp, see-through or flowing (not quoted)598 0 to 4 debris (not quoted)600–602splash, sparing the thing hit607
    game/g_combat.c at 372afde
    Our readingeach entity in the radius:554 the spared one: skip556–557 can't take damage: skip (not quoted)558–559 distance ← from the blast to its box centre561–563 points ← damage − distance ÷ 2564 the attacker: half (not quoted)565–566 above 0 and reachable (not quoted)567–569 deal the points as radius damage572
    game/g_utils.c at 372afde
    Our readingoffset to the box centre94beyond the radius: skip (not quoted)95
    game/p_weapon.c at 372afde
    Our readingdeathmatch: damage 100, kick 2001310–1313else: damage 1501317 kick 250 (not quoted)1318

    Claim page

  42. ^Codeid-Software/Quake-2g_combat.c 421–423
    How we know

    Quake II's damage routine doubles the damage a player does to a living monster that has no enemy yet, commented "bonus damage for suprising a monster", unless the damage is radius damage; the doubling comes after Easy's halving, which applies only to players.

    421// bonus damage for suprising a monster
    422	if (!(dflags & DAMAGE_RADIUS) && (targ->svflags & SVF_MONSTER) && (attacker->client) && (!targ->enemy) && (targ->health > 0))
    423		damage *= 2;
    
    game/g_combat.c lines 421–423 at 372afde · upstream ↗

    Claim page

  43. ^Codeid-Software/DOOMp_pspr.c 625–639, 660–661, 684–687, 751–753; m_random.c 31–51
    How we know

    Each bullet from Doom's pistol, chaingun, or shotgun deals 5 × (r mod 3 + 1) for a random byte r, so 5, 10, or 15; the shotgun fires 7 such pellets. Over one pass of the table the multipliers 1, 2, and 3 come up 75, 88, and 93 times.

    626P_GunShot
    ⋮
    633    damage = 5*(P_Random ()%3+1);
    ⋮
    639    P_LineAttack (mo, angle, MISSILERANGE, bulletslope, damage);
    
    linuxdoom-1.10/p_pspr.c lines 625–639 at a77dfb9 · upstream ↗
    660    P_BulletSlope (player->mo);
    661    P_GunShot (player->mo, !player->refire);
    
    linuxdoom-1.10/p_pspr.c lines 660–661 at a77dfb9 · upstream ↗
    684    P_BulletSlope (player->mo);
    ⋮
    686    for (i=0 ; i<7 ; i++)
    687	P_GunShot (player->mo, false);
    
    linuxdoom-1.10/p_pspr.c lines 684–687 at a77dfb9 · upstream ↗

    2 more excerpts on the claim page

  44. ^Codeid-Software/DOOMp_pspr.c 476–479, 510
    How we know

    Doom's fist deals 2 × (r mod 10 + 1) for a random byte r, 2 to 20, multiplied by 10 while the player has the berserk strength power; the chainsaw deals 2 to 20.

    476    damage = (P_Random ()%10+1)<<1;
    ⋮
    478    if (player->powers[pw_strength])	
    479	damage *= 10;
    
    linuxdoom-1.10/p_pspr.c lines 476–479 at a77dfb9 · upstream ↗
    510    damage = 2*(P_Random ()%10+1);
    
    linuxdoom-1.10/p_pspr.c line 510 at a77dfb9 · upstream ↗

    Claim page

  45. ^Codeid-Software/DOOMp_map.c 290–291, 322–324; info.c 1966–1986, 1992–2012, 2018–2038, 1914–1934; +1 files
    How we know

    A Doom projectile that hits a shootable thing, other than a monster of its shooter's species, deals (r mod 8 + 1) times its type's damage value, for a random byte r: a rocket's 20 gives 20 to 160, a plasma ball's 5 gives 5 to 40, a BFG ball's 100 gives 100 to 800, and an imp's fireball's 3 gives 3 to 24.

    290    // missiles can hit other things
    291    if (tmthing->flags & MF_MISSILE)
    
    linuxdoom-1.10/p_map.c lines 290–291 at a77dfb9 · upstream ↗
    322	// damage / explode
    323	damage = ((P_Random()%8)+1)*tmthing->info->damage;
    324	P_DamageMobj (thing, tmthing, tmthing->target, damage);
    
    linuxdoom-1.10/p_map.c lines 322–324 at a77dfb9 · upstream ↗
    1966    {		// MT_ROCKET
    ⋮
    1986	20,		// damage
    
    linuxdoom-1.10/info.c lines 1966–1986 at a77dfb9 · upstream ↗

    4 more excerpts on the claim page

  46. ^Codeid-Software/DOOMp_enemy.c 802–818, 913–925, 935–945, 979–989; f_finale.c 340–349, 348, 212–223; +2 files
    How we know

    Doom's monster attacks use the same multiple-of-a-base form, for a random byte r: a zombieman's bullet deals 3 × (r mod 5 + 1), 3 to 15; an imp's claw 3 × (r mod 8 + 1), 3 to 24; a demon's bite 4 × (r mod 10 + 1), 4 to 40; and a Baron of Hell's claw 10 × (r mod 8 + 1), 10 to 80, an attack function the code shares with Doom II's Hell Knight.

    802void A_PosAttack (mobj_t* actor)
    ⋮
    817    damage = ((P_Random()%5)+1)*3;
    818    P_LineAttack (actor, angle, MISSILERANGE, slope, damage);
    
    linuxdoom-1.10/p_enemy.c lines 802–818 at a77dfb9 · upstream ↗
    913void A_TroopAttack (mobj_t* actor)
    ⋮
    921    if (P_CheckMeleeRange (actor))
    ⋮
    923	S_StartSound (actor, sfx_claw);
    924	damage = (P_Random()%8+1)*3;
    
    linuxdoom-1.10/p_enemy.c lines 913–925 at a77dfb9 · upstream ↗
    935void A_SargAttack (mobj_t* actor)
    ⋮
    945	damage = ((P_Random()%10)+1)*4;
    
    linuxdoom-1.10/p_enemy.c lines 935–945 at a77dfb9 · upstream ↗

    15 more excerpts on the claim page

  47. ^Codeid-Software/DOOMp_inter.c 798–800, 854–869, 370–380, 886–887; d_englsh.h 80–81
    How we know

    Damage to a Doom player is halved on the easiest skill, and then armor takes a share: a third with the armor pickup (type 1) and half with the MegaArmor (type 2), until its points run out; monsters have no armor or defense value.

    798    player = target->player;
    799    if (player && gameskill == sk_baby)
    800	damage >>= 1; 	// take half damage in trainer mode
    
    linuxdoom-1.10/p_inter.c lines 798–800 at a77dfb9 · upstream ↗
    854	if (player->armortype)
    ⋮
    856	    if (player->armortype == 1)
    857		saved = damage/3;
    858	    else
    859		saved = damage/2;
    ⋮
    861	    if (player->armorpoints <= saved)
    ⋮
    863		// armor is used up
    864		saved = player->armorpoints;
    865		player->armortype = 0;
    ⋮
    867	    player->armorpoints -= saved;
    868	    damage -= saved;
    
    linuxdoom-1.10/p_inter.c lines 854–869 at a77dfb9 · upstream ↗
    370      case SPR_ARM1:
    371	if (!P_GiveArmor (player, 1))
    ⋮
    376      case SPR_ARM2:
    377	if (!P_GiveArmor (player, 2))
    
    linuxdoom-1.10/p_inter.c lines 370–380 at a77dfb9 · upstream ↗

    2 more excerpts on the claim page

  48. ^CodeFiendsOfTheElements/z2disassemblyprg7.asm 5401–5410, 5436–5451
    How we know

    A monster's damage code (0–7) and Link's life level (1–8) pick the life a hit takes from an 8 × 8 table, halved while the Shield spell is on. Code 0 takes 16 units at life level 1 and 4 at level 8; code 6 takes 224 and 80; code 7 takes 255 at every level.

    .byt $10,$0C,$0C,$0C,$08,$04,$04,$04; … ;Damage Code 0 … .byt $E0,$C0,$A0,$90,$80,$70,$60,$50; … ;Damage Code 6 … .byt $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF; … ;Damage Code 7
    src/prg7.asm#L5401-L5410 · upstream ↗
    5440    ADC      $0779                     ; 0x1e332 $E322 6D 79 07                ; Add Life Power (1-8)
    ⋮
    5445    LSR                                ; 0x1e33e $E32E 4A                      ; Divide by 2 (if Shield is cast)
    
    src/prg7.asm lines 5436–5451 at c4c3a4c · upstream ↗

    Claim page

  49. ^Codenmikstas/dragon-warrior-disassemblyBank03.asm 8655–8704
    How we know

    The hero's attack power is Strength plus the weapon's bonus; defense power is half of Agility, rounded down, plus the armor's and shield's bonuses, plus 2 with the Dragon's Scale.

    8655AddItemBonuses:
    ⋮
    8663LF0D4:  TAX                     ;Use the 3 bits above as index into the WeaponsBonusTbl.
    8664LF0D5:  LDA WeaponsBonusTbl,X   ;
    ⋮
    8666LF0D8:  CLC                     ;
    8667LF0D9:  ADC DisplayedStr        ;Add bonus from weapons table to strength attribute.
    8668LF0DB:  STA DisplayedAttck      ;
    ⋮
    8670LF0DD:  LDA DisplayedAgi        ;
    8671LF0DF:  LSR                     ;Divide agility by 2 and add to defense attribute.
    8672LF0E0:  STA DisplayedDefns      ;
    ⋮
    8679LF0E8:  TAX                     ;Use the 3 bits above as index into the ArmorBonusTbl.
    8680LF0E9:  LDA ArmorBonusTbl,X     ;
    ⋮
    8682LF0EC:  CLC                     ;
    ⋮
    
    source_files/Bank03.asm lines 8655–8704 at ebe6a13 · upstream ↗

    Claim page

  50. ^ abCodenmikstas/dragon-warrior-disassemblyBank03.asm 8491–8500, 8533–8539
    How we know

    When the hero's attack power less half the monster's defense, rounded down, is under 2, the hero deals 0 or 1 damage, each half the time.

    8491PlyrCalcHitDmg:
    8492LEFE5:  LSR DefenseStat         ;
    8493LEFE7:  LDA AttackStat          ;
    8494LEFE9:  SEC                     ; A = AttackStat - DefenseStat/2. 
    8495LEFEA:  SBC DefenseStat         ;
    8496LEFEC:  BCC PlyrWeakAttack      ;
    ⋮
    8498LEFEE:  CMP #$02                ;Did A go negative or is only 1 greater than enemy defense/2?
    8499LEFF0:  BCS NormalAttack        ;If so, branch to do a weak attack. enemy is strong!
    8500LEFF2:  BCC PlyrWeakAttack      ;Else branch to do a normal attack.
    
    source_files/Bank03.asm lines 8491–8500 at ebe6a13 · upstream ↗
    8533PlyrWeakAttack:
    8534LF026:  JSR UpdateRandNum       ;($C55B)Get random number.
    ⋮
    8536LF029:  LDA RandNumUB           ;
    8537LF02B:  AND #$01                ;Player is too weak to fight this enemy. 50% chance 
    8538LF02D:  STA CalcDamage          ;of doing 1 point of damage or 50% chance of missing.
    8539LF02F:  RTS                     ;
    
    source_files/Bank03.asm lines 8533–8539 at ebe6a13 · upstream ↗

    Claim page

  51. ^ abCodenmikstas/dragon-warrior-disassembly · Ryan8bit, DW FormulasBank03.asm 7761–7765, 8502–8531
    How we know

    The monster's hit-damage routine ($EFF4) takes X=A−⌊D/2⌋, the monster's attack less half the hero's defense power; if X≥⌊A/2⌋+1, it uses the hero's normal formula, and otherwise the monster deals ⌊(⌊r(⌊A/2⌋+1)/256⌋+2)/3⌋, from 0 to about A/6.

    7761LEBCD:  LDA EnBaseAtt           ;Make a copy of enemy's attack stat.
    7762LEBD0:  STA AttackStat          ;
    7763LEBD2:  LDA DisplayedDefns      ;Make a copy of player's defense stat.
    7764LEBD4:  STA DefenseStat         ;
    
    source_files/Bank03.asm lines 7761–7765 at ebe6a13 · upstream ↗
    8503LEFF4:  LSR DefenseStat         ;
    8504LEFF6:  LDA AttackStat          ;
    8505LEFF8:  LSR                     ;A = AttackStat - DefenseStat/2.
    8506LEFF9:  STA MultNum2LB          ;
    8507LEFFB:  INC MultNum2LB          ;
    ⋮
    8513LF004:  CMP MultNum2LB          ;Is enemy AttackStat more than 2X player DefenseStat?
    8514LF006:  BCS NormalAttack        ;If so, branch to do normal attack damage.
    ⋮
    8527LF01B:  ADC #$02                ;
    
    source_files/Bank03.asm lines 8502–8531 at ebe6a13 · upstream ↗
    So the end result is floor(((((EnemyStrength >> 1 + 1) * RAND) >> 8) + 2) / 3).
    III.C, Combat · archived copy ↗

    Claim page

  52. ^Codenmikstas/dragon-warrior-disassemblyBank03.asm 6614–6652; Bank01.asm 4596–4598
    How we know

    A monster's HP is its base value less up to a quarter, H−⌊⌊rH/256⌋/4⌋; the foe of the game's last fight always has its base HP.

    6614LE583:  LDA EnNumber            ;Is this the end boss?
    6615LE585:  CMP #EN_DRAGONLORD2     ;
    6616LE587:  BNE EnAppearText        ;If not, branch to display standard enemy approaching text.
    ⋮
    6621LE58D:  LDA EnBaseHP            ;Dragonlord's HP is set to a constant value every time.
    6622LE590:  BNE SetEnHP             ;Branch always.
    ⋮
    6630ModEnHitPoints:
    6631LE599:  LDA EnBaseHP            ;Prepare to multiply enemy HP by random number(0 to 255).
    6632LE59C:  STA MultNum2LB          ;
    6633LE59E:  JSR UpdateRandNum       ;($C55B)Get random number.
    ⋮
    6635LE5A1:  LDA RandNumUB           ;
    6636LE5A3:  STA MultNum1LB          ;
    ⋮
    6640LE5AB:  JSR WordMultiply        ;($C1C9)Multiply 2 16-bit words.
    ⋮
    
    source_files/Bank03.asm lines 6614–6652 at ebe6a13 · upstream ↗
    4596;Enemy $27-Dragonlord True Self.
    4597;             Att  Def   HP  Spel Agi  Mdef Exp  Gld   |--------------Unused--------------|
    
    source_files/Bank01.asm lines 4596–4598 at ebe6a13 · upstream ↗

    Claim page

  53. ^ abCodenmikstas/dragon-warrior-disassemblyBank03.asm 6924–6960, 7306–7316
    How we know

    The hero's Hurt deals 5–12 damage and Hurtmore 58–65, whatever the stats on either side; either is blocked instead when a roll of 0–15 falls below the monster's spell resistance, a value from 0 to 15.

    6924LE736:* CMP #SPL_HURT           ;Was the hurt spell cast?
    6925LE738:  BNE +                   ;If not, branch to move on.
    ⋮
    6927LE73A:  LDA EnBaseMDef          ;
    6928LE73D:  LSR                     ;
    6929LE73E:  LSR                     ;Get the enemy's magical defense and divide by 16.
    6930LE73F:  LSR                     ;
    6931LE740:  LSR                     ;
    ⋮
    6933LE741:  JSR ChkSpellFail        ;($E946)Check if the spell will fail or succeed.
    6934LE744:  JSR UpdateRandNum       ;($C55B)Get random number.
    ⋮
    6936LE747:  LDA RandNumUB           ;
    6937LE749:  AND #$07                ;Hurt will do between 5 and 12 damage.
    6938LE74B:  CLC                     ;
    ⋮
    
    source_files/Bank03.asm lines 6924–6960 at ebe6a13 · upstream ↗
    7306ChkSpellFail:
    7307LE946:  STA GenByte3E           ;Store spell test byte.
    ⋮
    7310LE94B:  LDA RandNumUB           ;Get 4 bits from the random number(0-15).
    7311LE94D:  AND #$0F                ;
    ⋮
    7313LE94F:  CMP GenByte3E           ;Is the spell test byte greater than the random number?
    7314LE951:  BCC SpellFailed         ;If so, branch. The spell failed.
    ⋮
    7316LE953:  RTS                     ;Spell succeeded. Return.
    
    source_files/Bank03.asm lines 7306–7316 at ebe6a13 · upstream ↗

    Claim page

  54. ^Codenmikstas/dragon-warrior-disassemblyBank03.asm 7821–7867; Dragon_Warrior_Defines.asm 835–842
    How we know

    A monster's Hurt deals 3–10 damage and Hurtmore 30–45; against a hero in Magic Armor or Erdrick's Armor, either's damage d is cut to 2⌊d/3⌋.

    7821EnCastHurt:
    ⋮
    7826LEC2A:  JSR UpdateRandNum       ;($C55B)Get random number.
    7827LEC2D:  LDA RandNumUB           ;
    7828LEC2F:  AND #$07                ;Keep 3 bits of random number(0-7).
    7829LEC31:  CLC                     ;
    7830LEC32:  ADC #$03                ;Hurt spel will do between 7 and 10 damage.
    ⋮
    7832EnCalcSpllDmg:
    7833LEC34:  STA PlyrDamage          ;Store base damage player will take.
    ⋮
    7835LEC36:  LDA EqippedItems        ;
    7836LEC38:  AND #AR_ARMOR           ;Does player have Erdrick's armor?
    7837LEC3A:  CMP #AR_ERDK_ARMR       ;If so, branch to reduce damage to 2/3.
    7838LEC3C:  BEQ ReducedSpellDmg     ;
    ⋮
    
    source_files/Bank03.asm lines 7821–7867 at ebe6a13 · upstream ↗
    835.alias AR_MAGIC_ARMR    $18     ;Magic armor.
    836.alias AR_ERDK_ARMR     $1C     ;Erdrick's armor.
    ⋮
    842.alias AR_ARMOR         $1C     ;Bitmask for armor.
    
    source_files/Dragon_Warrior_Defines.asm lines 835–842 at ebe6a13 · upstream ↗

    Claim page

  55. ^Verified“Dragon Warrior (USA) (Rev 1)” · nmikstas/dragon-warrior-disassemblyBank03.asm 8491–8560
    How we know

    Measured in the ROM over all 65,536 generator states, attack power 60 against a defense byte of 40 deals 10–20 damage, each of 10 to 19 in 25 of 256 rolls and 20 in 6; attack power 20 deals 0 or 1, half each.

    In the cartridge (“Dragon Warrior (USA) (Rev 1)”): bank 3 $EFE5-$F04F, PlyrCalcHitDmg through NormalAttack. We don't reproduce the bytes.

    LSR DefenseStat LDA AttackStat SEC SBC DefenseStat BCC PlyrWeakAttack … AND #$01 STA CalcDamage … ADC BaseAttack ROR LSR …
    source_files/Bank03.asm#L8491-L8560 · upstream ↗

    Measured by a script in MesenCE 2.2.1 (build 4b8a196), on Dragon Warrior (USA) (Rev 1) (SHA-1 66809063b828…). It fails if the result disagrees with the claim.

    Claim page

  56. ^Verified“Dragon Warrior (USA) (Rev 1)” · nmikstas/dragon-warrior-disassemblyBank03.asm 8502–8560
    How we know

    Measured in the ROM over all 65,536 generator states, a monster's attack of 90 against the hero's defense power of 60 deals 15–30 damage, and an attack of 20 against defense power 40 deals 0–4, mostly 1–3.

    In the cartridge (“Dragon Warrior (USA) (Rev 1)”): bank 3 $EFF4-$F04F, EnCalcHitDmg through NormalAttack. We don't reproduce the bytes.

    LSR DefenseStat LDA AttackStat LSR STA MultNum2LB INC MultNum2LB … CMP MultNum2LB BCS NormalAttack … LDA MultRsltUB CLC ADC #$02 …
    source_files/Bank03.asm#L8502-L8560 · upstream ↗

    Measured by a script in MesenCE 2.2.1 (build 4b8a196), on Dragon Warrior (USA) (Rev 1) (SHA-1 66809063b828…). It fails if the result disagrees with the claim.

    Claim page

  57. ^Verifiednmikstas/dragon-warrior-disassemblyBank03.asm 6924–6960
    How we know

    Measured on Rev 0 for every value of the random byte, the hero's Hurt deals 5–12 damage and Hurtmore 58–65, each amount equally likely, once the spell has passed the monster's resistance.

    6924LE736:* CMP #SPL_HURT           ;Was the hurt spell cast?
    6925LE738:  BNE +                   ;If not, branch to move on.
    ⋮
    6927LE73A:  LDA EnBaseMDef          ;
    6928LE73D:  LSR                     ;
    6929LE73E:  LSR                     ;Get the enemy's magical defense and divide by 16.
    6930LE73F:  LSR                     ;
    6931LE740:  LSR                     ;
    ⋮
    6933LE741:  JSR ChkSpellFail        ;($E946)Check if the spell will fail or succeed.
    6934LE744:  JSR UpdateRandNum       ;($C55B)Get random number.
    ⋮
    6936LE747:  LDA RandNumUB           ;
    6937LE749:  AND #$07                ;Hurt will do between 5 and 12 damage.
    6938LE74B:  CLC                     ;
    ⋮
    
    source_files/Bank03.asm lines 6924–6960 at ebe6a13 · upstream ↗

    Measured by a script in MesenCE 2.2.1 (build 4b8a196), on . It fails if the result disagrees with the claim.

    Claim page

  58. ^ManualDragon Warrior NES manual · Dragon Quest FC manual
    How we know

    The NES manual gives the hero's Hurt 2–15 damage where the Famicom manual gives 5–12, and the game deals 5–12 (hero-spells, hurt-measured): the NES booklet's figure matches neither.

    inflicts 2-15 points of damage on the enemy, and you lose 2 points of MP
    p. 26, Hurt · archived copy ↗
    1回の攻撃で、5〜12ポイントのダメージを敵に与え、2ポイントのMPを消費します
    p. 34, ギラ · archived copy ↗

    Claim page

  59. ^CodeNathan-R-Og/dq2 · nmikstas/dragon-warrior-disassemblybank4.asm 9138–9162, 5289–5297, 9052–9082, 9342, 6361–6372; Bank03.asm 6614–6652
    How we know

    In Dragon Warrior II (NA NES), as in Dragon Warrior, each monster starts a fight with its base HP less up to a quarter; the order changes, as Dragon Warrior II quarters the base HP before multiplying by a random byte, H−⌊⌊H/4⌋r/256⌋, where Dragon Warrior quarters the product.

    9138B04_B6AB:
    ⋮
    9140    lda ($BB), y
    ⋮
    9142    sta ($B7), y
    9143    ldy #$00
    9144    lda ($BB), y
    9145    sta $99
    9146    lsr $99
    9147    lsr $99
    ⋮
    9152    lda $32 ; RNG byte 0
    ⋮
    9154    sta $9B
    ⋮
    9157    ldy #$00
    9158    lda ($BB), y
    ⋮
    
    src/us/prg/bank4.asm lines 9138–9162 at 0fb64a4 · upstream ↗
    5289; 16-bit multiplication: ($99-$9A) = ($99-$9A) * ($9B), overflow in $9E, copy of ($99-$9A) in ($A1-$9D)
    ⋮
    5297    sta $9D ; result byte 1
    
    src/us/prg/bank4.asm lines 5289–5297 at 0fb64a4 · upstream ↗
    9052    jsr B04_9EDC ; given an index + 1 (in A) into the array of enemy stat structures at $B7F5, set $BB-$BC to the address of the corresponding item inside that structure
    ⋮
    9066    jsr B04_9EE9 ; given an index (in A) into the array of structures at $068F, set $B7-$B8 to the address of the corresponding item inside that structure
    ⋮
    9082    jsr B04_B6AB
    
    src/us/prg/bank4.asm lines 9052–9082 at 0fb64a4 · upstream ↗
    ; Enemy Stats (Max HP, [4-bit evade chance / 64, 4-bit unused], Max Gold dropped, EXP low byte, AGI
    src/us/prg/bank4.asm#L9342 · upstream ↗

    2 more excerpts on the claim page

  60. ^ abCodeNathan-R-Og/mother · Herringway/ebsrcbattle_data.asm 585–608; battle.asm 3137–3146, 3399–3428, 3483–3488, 3455–3480; +4 files
    How we know

    EarthBound (US release) keeps EarthBound Beginnings' order of a plain attack, with the "SMAAAASH!!" rolled before the dodge so it can't be dodged, but changes the numbers: the chance comes from the attacker's Guts, counted as at least 25 for a party member (about Guts in 500), instead of Fight against Fight; the SMAAAASH deals 4 × Offense − Defense instead of the full Offense; a normal hit deals 2 × Offense − Defense, where EarthBound Beginnings deals Offense − Defense ÷ 2, or (3 × Offense − Defense) ÷ 4 when the Offense is below the Defense; and the dodge comes from Speed instead of Fight.

    src/global/battle_data.asm at e0b3e3f
    Our readingpick the target again (not quoted)586not both alive: plain attack (not quoted)587blind test passes: plain attack (not quoted)588tank: tank attack (not quoted)589crit test passes: crit (by its label)590plain attack: the sound and text (not quoted)591–593 dodge test false: dodged (by its label)596 blinded: miss; else damage (not quoted)597–601crit: sound, text, flash (not quoted)602–605 "SMAAAASH" text (by the comment)606 crit damage607–608
    src/global/prg/battle.asm at e0b3e3f
    Our readinginvincibility scripts on: skip3138–3139first ← attacker's Fight, second ← target's Fight3140–3145the Fight equation (mother1/smaaaash)3146keep the target's defense (not quoted)3401–3406offense − defense below 0: the weak bash, next3407–3419else: defense ÷ 23420–3421damage ← offense − defense ÷ 23422–3428damage ← the attacker's Offense3485–3488
    src/battle/actions/bash.asm at 68aec5c
    Our readingthe SMAAAASH check not 0: on to an unnamed label11–13the dodge check not 0: on to another14–16else: the level-2 attack17
    src/battle/smaaaash.asm at 68aec5c
    Our readingchance ← the attacker's Guts10–12a party member below the floor: the floor13–21succeed out of 500 with it22–24Offense × 460–62− the target's Defense63–65
    src/battle/actions/level_2_attack.asm at 68aec5c
    Our readingOffense × 2 − the target's Defense8–12
    src/battle/determine_dodge.asm at 68aec5c
    Our readingthe target's Speed × 2 − the attacker's Speed34–39
    src/global/prg/battle.asm at e0b3e3f
    Our readingweak bash: offense × 23455–3457+ offense: 3 × offense3458–3464− defense3465–3471below 0: 03472–3475÷ 43476–3479

    Claim page

  61. ^Codefireemblem8ubmbattle.c 511–517, 527–557, 1022–1028, 1030–1039, 1043–1047, 974–993, 884; bmbattle.h 16–17
    How we know

    In the North American build, damage is attack less defense, where attack is the weapon's might plus the triangle's damage bonus, tripled when the attacker or its weapon is effective against the target (doubled instead when the effective weapon is one of eight legendary weapons), plus the attacker's strength, and defense is terrain defense plus Defense, or terrain resistance plus Resistance against magic; no roll changes it except three skills: Pierce (which sets defense to 0), Great Shield (which sets the damage to 0), and Silencer: on a critical its check, a roll against the attacker's Silencer rate that never passes against the Demon King or, in two of the chapters, the Necromancer, sets the damage to 127, the maximum, and clears Great Shield's mark when it passes; any other critical triples it, and the result is held within 0–127.

    src/bmbattle.c at 04d1edb
    Our readingthe foe's weapon does magic damage:512 resistance + terrain resistance513the foe's weapon magic: the same (not quoted)514–515else: defense + terrain defense517attack ← might + triangle bonus527unit effective: × 3530–531weapon effective:533 attack ← might + bonus again (not quoted)534 the eight legendary weapons: × 2538–546 others: × 3549–550attack + strength556–557Pierce: defense ← 01022–1023damage ← attack − defense1025Great Shield: 01027–1028crit roll succeeds:1030 Silencer's check passes:1031 damage ← 127, the cap (the header's)1034 Great Shield's mark cleared1036 else: × 31039above 127: 1271043–1044below 0: 01046–1047
    16    // Maximum battle damage
    17    BATTLE_MAX_DAMAGE = 127,
    
    include/bmbattle.h lines 16–17 at 04d1edb · upstream ↗
    src/bmbattle.c at 04d1edb
    Our readingby the target's class:975 the Demon King: fails977–978 the Necromancer:980 in chapter E_21 or I_21: fails981–985a roll against the Silencer rate: passes989–990else: fails992the roll's Silencer rate ← the attacker's884

    Claim page

  62. ^ abCodepret/pokeredcore.asm 4040–4042; type_constants.asm 19–26
    How we know

    Type picks the stats: Fire, Water, Grass, Electric, Psychic, Ice, and Dragon (the first special type upward) use Special on both sides; the rest use Attack against Defense.

    4041	cp SPECIAL ; types >= SPECIAL are all special
    4042	jr nc, .specialAttack
    
    engine/battle/core.asm lines 4040–4042 at af51989 · upstream ↗
    constants/type_constants.asm#L19-L26 · upstream ↗

    Claim page

  63. ^ abCodepret/pokeyellow · pret/pokeredcore.asm 5618–5625, 4559–4621, 4299–4466; battle_constants.asm 55–56
    How we know

    Yellow keeps Red and Blue's damage calculation and its random factor unchanged, so base damage is still capped at 997 plus 2 and scaled by a random 217–255 over 255.

    5618; loop until a random number greater than or equal to 217 is generated
    ⋮
    5625	call Multiply ; multiply damage by the random number, which is in the range [217, 255]
    
    engine/battle/core.asm lines 5618–5625 at b6696f2 · upstream ↗
    4559; Capped at MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE: 999 - 2 = 997.
    ⋮
    4597	ld [hld], a
    ⋮
    4617.cap
    4618	ld a, HIGH(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE)
    4619	ld [hli], a
    4620	ld a, LOW(MAX_NEUTRAL_DAMAGE - MIN_NEUTRAL_DAMAGE)
    4621	ld [hld], a
    
    engine/battle/core.asm lines 4559–4621 at b6696f2 · upstream ↗
    55DEF MIN_NEUTRAL_DAMAGE EQU 2
    56DEF MAX_NEUTRAL_DAMAGE EQU 999
    
    constants/battle_constants.asm lines 55–56 at b6696f2 · upstream ↗
    engine/battle/core.asm#L4299-L4466 · upstream ↗

    Claim page

  64. ^Codepret/pokegold · pret/pokecrystaleffect_commands.asm 1503–1543, 3111–3113, 3113–3115, 1496–1545; data.asm 23
    How we know

    Gold and Silver's damage-variation command leaves 0 or 1 damage alone and otherwise multiplies by a random byte, rotated, redrawn until it is at least 217 (85 percent + 1), and divides by 255 (100 percent); Crystal keeps the command unchanged. Their damage-calculation command differs from Crystal's only in comments and one doubling written sla a where Crystal has add a.

    engine/battle/effect_commands.asm at fc702b6
    Our readingdamage's high byte not 0: on (not quoted)1511–1514else low byte below 2: return (not quoted)1515–1517multiplicand ← the damage (not quoted)1521–1527loop:1530 a random byte, rotated right1531–1532 below 85 percent + 1: again1533–1534multiplier ← it; multiply (not quoted)1536–1537divisor ← 100 percent1540–1541divide (not quoted)1542–1543
    23DEF percent EQUS "* $ff / 100"
    
    macros/data.asm line 23 at fc702b6 · upstream ↗
    engine/battle/effect_commands.asm at fc702b6
    Our readingA ← the quotient's low byte, × 2 by a shift3112–3113
    engine/battle/effect_commands.asm at 97187cd
    Our readingA ← the quotient's low byte, × 2 by an add3114–3115damage's high byte not 0: on (not quoted)1504–1507else low byte below 2: return (not quoted)1508–1510multiplicand ← the damage (not quoted)1514–1520loop: a random byte, rotated right (not quoted)1523–1525 compare it with 85 percent + 11526 below: again (not quoted)1527multiplier ← it; multiply (not quoted)1529–1530÷ 100 percent (not quoted)1533–1536damage ← the quotient's low two bytes (not quoted)1539–1543

    Claim page

  65. ^ abCodepret/pokecrystaleffects.asm 5–14; effect_command_pointers.asm 12–16; +2 files
    How we know

    A plain damaging move takes these steps in order: the critical-hit roll; loading the attacking and defending stats; the base damage formula, then held-item type boosts and the critical ×2; then weather, badge type boosts, the same-type ×1.5, and the type chart rows; then the random factor; and last the accuracy check.

    5NormalHit:
    6	checkobedience
    7	usedmovetext
    8	doturn
    9	critical
    10	damagestats
    11	damagecalc
    12	stab
    13	damagevariation
    14	checkhit
    
    data/moves/effects.asm lines 5–14 at 97187cd · upstream ↗
    12	dw BattleCommand_Critical
    13	dw BattleCommand_DamageStats
    14	dw BattleCommand_Stab
    15	dw BattleCommand_DamageVariation
    16	dw BattleCommand_CheckHit
    
    data/battle/effect_command_pointers.asm lines 12–16 at 97187cd · upstream ↗
    1201	call BattleRandom
    1202	cp [hl]
    1203	ret nc
    1204	ld a, 1
    1205	ld [wCriticalHit], a
    
    engine/battle/effect_commands.asm lines 1201–1205 at 97187cd · upstream ↗

    7 more excerpts on the claim page

  66. ^ abCodepret/pokecrystaleffect_commands.asm 1503–1536; data.asm 23
    How we know

    As in Red and Blue, damage is multiplied by a random byte from 217 to 255 and divided by 255, and 0 or 1 damage is left untouched.

    1503; No point in reducing 1 or 0 damage.
    1504	ld hl, wCurDamage
    1505	ld a, [hli]
    1506	and a
    1507	jr nz, .go
    1508	ld a, [hl]
    1509	cp 2
    1510	ret c
    ⋮
    1512.go
    ⋮
    1517	ld a, [hli]
    ⋮
    1519	ld a, [hl]
    ⋮
    1523.loop
    ⋮
    
    engine/battle/effect_commands.asm lines 1503–1536 at 97187cd · upstream ↗
    23DEF percent EQUS "* $ff / 100"
    
    macros/data.asm line 23 at 97187cd · upstream ↗

    Claim page

  67. ^ abCodepret/pokecrystaleffect_commands.asm 2543–2545; type_constants.asm 9–35
    How we know

    Type still picks the stats: Steel is physical (numbered below the first special type); Dark is special, using Special Attack against Special Defense.

    2544	cp SPECIAL
    2545	jr nc, .special
    
    engine/battle/effect_commands.asm lines 2543–2545 at 97187cd · upstream ↗
    constants/type_constants.asm#L9-L35 · upstream ↗

    Claim page

  68. ^Codepret/pokeruby · pret/pokeemeraldbattle_script_commands.c 1751–1763, 1639–1651
    How we know

    Ruby and Sapphire already use Emerald's random factor, damage × (100 − rand % 16) / 100, raised to 1 if that gives 0 from damage that wasn't 0 (zero damage stays 0); Gen 1 and 2 reach about the same 85–100% spread as a byte from 217 to 255 over 255.

    1751static inline void ApplyRandomDmgMultiplier(void)
    ⋮
    1753    u16 rand = Random();
    1754    u16 randPercent = 100 - (rand % 16);
    ⋮
    1756    if (gBattleMoveDamage != 0)
    ⋮
    1758        gBattleMoveDamage *= randPercent;
    1759        gBattleMoveDamage /= 100;
    1760        if (gBattleMoveDamage == 0)
    1761            gBattleMoveDamage = 1;
    
    src/battle_script_commands.c lines 1751–1763 at 5784633 · upstream ↗
    1639static inline void ApplyRandomDmgMultiplier(void)
    ⋮
    1641    u16 rand = Random();
    1642    u16 randPercent = 100 - (rand % 16);
    
    src/battle_script_commands.c lines 1639–1651 at 731ad5b · upstream ↗

    Claim page

  69. ^ abCodepret/pokeemeraldbattle_scripts_1.s 249–252; battle_script_commands.c 1658–1662
    How we know

    A plain damaging move rolls for a critical hit, computes the base damage, applies the type step (STAB, then the type rows), and then applies the random factor.

    249	critcalc
    250	damagecalc
    251	typecalc
    252	adjustnormaldamage
    
    data/battle_scripts_1.s lines 249–252 at 731ad5b · upstream ↗
    1658static void Cmd_adjustnormaldamage(void)
    ⋮
    1662    ApplyRandomDmgMultiplier();
    
    src/battle_script_commands.c lines 1658–1662 at 731ad5b · upstream ↗

    Claim page

  70. ^ abCodepret/pokeemeraldbattle_script_commands.c 1641–1649
    How we know

    The random factor changes form from Crystal's random byte over 255: Emerald multiplies nonzero damage by 100 − (a random number mod 16), 85 to 100, divides by 100, and raises a 0 result to 1.

    1641    u16 rand = Random();
    1642    u16 randPercent = 100 - (rand % 16);
    ⋮
    1644    if (gBattleMoveDamage != 0)
    ⋮
    1646        gBattleMoveDamage *= randPercent;
    1647        gBattleMoveDamage /= 100;
    1648        if (gBattleMoveDamage == 0)
    1649            gBattleMoveDamage = 1;
    
    src/battle_script_commands.c lines 1641–1649 at 731ad5b · upstream ↗

    Claim page

  71. ^ abCodepret/pokeemeraldbattle.h 466–467
    How we know

    Type still decides physical or special in Emerald, by whether it comes before or after type 9, "???".

    466#define IS_TYPE_PHYSICAL(moveType) (moveType < TYPE_MYSTERY)
    467#define IS_TYPE_SPECIAL(moveType) (moveType > TYPE_MYSTERY)
    
    include/battle.h lines 466–467 at 731ad5b · upstream ↗

    Claim page

  72. ^ abCodepret/pokefirered · pret/pokeemeraldbattle_script_commands.c 1209–1215, 1202–1205, 1558–1570, 1577–1581, 1290–1296
    How we know

    FireRed and LeafGreen's damage-calculation and damage-adjustment commands diff identical with Emerald's: the damage calculation multiplies the base damage by the critical multiplier, 2 on a critical hit, and the random factor is damage × (100 − rand % 16) / 100, 85–100%.

    1209static void Cmd_damagecalc(void)
    ⋮
    1215    gBattleMoveDamage = gBattleMoveDamage * gCritMultiplier * gBattleScripting.dmgMultiplier;
    
    src/battle_script_commands.c lines 1209–1215 at ce6406d · upstream ↗
    1202        gCritMultiplier = 2;
    1203    else
    1204        gCritMultiplier = 1;
    
    src/battle_script_commands.c lines 1202–1205 at ce6406d · upstream ↗
    1558static inline void ApplyRandomDmgMultiplier(void)
    ⋮
    1560    u16 rand = Random();
    1561    u16 randPercent = 100 - (rand % 16);
    ⋮
    1565        gBattleMoveDamage *= randPercent;
    1566        gBattleMoveDamage /= 100;
    
    src/battle_script_commands.c lines 1558–1570 at ce6406d · upstream ↗

    2 more excerpts on the claim page

  73. ^Codedscotton/ct_disassemblybank_C1.asm 26881–26884, 26680–26688, 29266–29282
    How we know

    A damaging technique runs in four steps: the battle loads the technique's formula and defense-selector bytes, computes a magnitude by that formula, resolves the target's defense value, and applies it. Formulas 1, 2 and 4 first wake the target: if the target's status byte +$1E has bit $02 or $04 set, both are cleared and its turn counter restarts from its reload value. The defense step clears the same two bits for every formula, without the restart.

    + JSR.W Battle_LoadFormulaDefStat JSR.W Battle_DamageMagnitude JSR.W Battle_ResolveStatOperand JSR.W Battle_ApplyDefenseReduction
    bank_C1.asm#L26881-L26884 · upstream ↗
    Battle_LoadFormulaDefStat: TDC TAX STX.B $16 STX.B $18 LDA.W ActTech_Formula STA.B $16 LDA.W ActTech_DefStat STA.B $18 RTS
    bank_C1.asm#L26680-L26688 · upstream ↗
    Our readingthe technique's formula and defense-selector bytes26684–26687
    Battle_WakeTargetOnDamage: TDC LDX.W $B1F6 LDA.W BatWork_StatusCur1,X BIT.B #$06 BEQ + AND.B #$F9 STA.W $5E4B,X TDC LDA.W $B1FD TAX LDA.B #$01 STA.W $B03A,X …
    bank_C1.asm#L29266-L29282 · upstream ↗
    Our readingif the target's byte +$1E has bit $02 or $0429267–29270clear them and reload the turn counter29271–29279

    Claim page

  74. ^Codedscotton/ct_disassemblybank_C1.asm 28721–28780; battle_work.asm 38–48, 15
    How we know

    Formula 3 sets the magnitude to power × (12 × the attacker's byte +$12 + 12 × its byte +$39) / 15 and draws a random bonus from 0 to ⌊77 × byte +$39 / 256⌋. The disassembly labels +$12 the level and +$39 the live Magic. Unlike formulas 1, 2 and 4 it does not restart the target's turn counter.

    + CMP.B #$03 BEQ Battle_MagicDamage JMP.W Battle_DmgMag_TrySel4 Battle_MagicDamage: TDC ; Single-target magic damage (effect type 3): dmg = magicPower($7EAEEF) * (stat $7E5E3F + stat $7E5E66) * 0x0C / 0x0F, via Battle_Mul16/Battle_Div16; defense applied via $C1C063. Multi-target variant at $C1E276. LDX.W $B1F4 LDA.W BatWork_Level,X TAX STX.B $28 LDA.B #$0C TAX STX.B $2A JSR.W Battle_Mul16 …
    bank_C1.asm#L28721-L28780 · upstream ↗
    Our readingformula 328721–2872212 × byte +$12 plus 12 × byte +$3928726–28749times power, over 1528752–28768bonus: random 0 to 30% of byte +$3928770–28779
    38BatWork_Calc43     = $5E70   ; +0x43     computed-on-load value used in the damage magnitude
    39                             ;           (x5 sel.1 / x8 sel.2 w/ currentPower); exact stat TBD
    40BatWork_CurPower   = $5E63   ; +0x36     live Power
    41BatWork_CurStamina = $5E64   ; +0x37     live Stamina
    42BatWork_CurSpeed   = $5E65   ; +0x38     live Speed
    43BatWork_CurMagic   = $5E66   ; +0x39     live Magic
    44BatWork_CurHit     = $5E67   ; +0x3A     live Hit (accuracy)
    45BatWork_CurEvade   = $5E68   ; +0x3B     live Evade
    46BatWork_CurMagDef  = $5E69   ; +0x3C     live Magic Defense
    47BatWork_CurAttack  = $5E6A   ; +0x3D     live Attack
    48BatWork_CurDefense = $5E6B   ; +0x3E     live Defense
    
    battle_work.asm lines 38–48 at eeae27a · upstream ↗
    15BatWork_Level      = $5E3F   ; +0x12     level
    
    battle_work.asm line 15 at eeae27a · upstream ↗

    Claim page

  75. ^Codeeverything8215, FF2 disassembly · everything8215, FF3 disassemblyff2j.asm 18030–18073; ff3j.asm 11985–11992, 12042–12046, 8278–8282
    How we know

    Final Fantasy II rolls damage, attack plus 0 to attack less defense, and a critical for each hit that gets through and adds them up; Final Fantasy III rolls damage once, attack plus 0 to half of it, and multiplies it by the net hits, and its single critical roll uses the job's crit probability in place of Final Fantasy II's fixed roll under 5.

    18030; start of hit loop
    ⋮
    180350C/BCAF: 65 44     ADC $44            ; attack * (0..1)
    ⋮
    180610C/BCE2: C9 05     CMP #$05
    180620C/BCE4: B0 11     BCS $BCF7          ; 5% chance for crit
    ⋮
    180720C/BCF7: 88        DEY                ; next hit
    180730C/BCF8: D0 AD     BNE $BCA7
    
    ff2j.asm lines 18030–18073 at 8d26190 · upstream ↗
    1198531/BB44: A5 2B     LDA $2B
    1198631/BB46: 4A        LSR 
    1198731/BB47: A5 25     LDA $25
    1198831/BB49: 6A        ROR 
    1198931/BB4A: 20 B4 BE  JSR $BEB4          ; random (0..A)
    1199031/BB4D: 18        CLC 
    1199131/BB4E: 65 25     ADC $25
    1199231/BB50: 85 18     STA $18            ; +$18 = attack * (1..3/2)
    
    ff3j.asm lines 11985–11992 at 1acef81 · upstream ↗
    1204231/BBB3: AD 7C 00  LDA $007C          ; total no. of hits
    ⋮
    1204631/BBBD: 85 18     STA $18            ; +$18 = net damage
    
    ff3j.asm lines 12042–12046 at 1acef81 · upstream ↗

    1 more excerpts on the claim page

  76. ^CodeDisch, FF1 disassemblybank_0C.asm 4401–4405, 4514–4521
    How we know

    A swing is critical when its roll is at most the crit chance, which is capped at the hit chance; a critical adds the swing's random damage again, with no absorb taken from it.

    4404      LDA math_hitchance                ; crit chance cannot exceed hit chance
    
    Final Fantasy Disassembly/bank_0C.asm lines 4401–4405 at cbb87d3 · upstream ↗
    4515    LDA math_critchance     ; see if hit value is <= crit chance  (this will be impossible if the attack was a miss)
    ⋮
    4519      LDX math_basedamage                   ; add random damage to our total
    4520      JSR MathBuf_Add
    4521      INC battle_critsconnected
    
    Final Fantasy Disassembly/bank_0C.asm lines 4514–4521 at cbb87d3 · upstream ↗

    Claim page

  77. ^CodeDisch, FF1 disassemblybank_0C.asm 5692–5697, 27, 5719–5743; bank_0F.asm 10916–10928
    How we know

    A weapon's crit rate in its data goes unused: a character's crit chance is the equipped weapon's index number instead. An unarmed Black Belt or Master gets twice their level.

    Final Fantasy Disassembly/bank_0C.asm at cbb87d3
    Our readingcrit rate ← the weapon index, low 7 bits (by the comment)5693–5695
    27;;  byte 2:  Critial rate (BUGGED - not used .. see LoadOneCharacterIBStats for offending code)
    
    Final Fantasy Disassembly/bank_0C.asm line 27 at cbb87d3 · upstream ↗
    Final Fantasy Disassembly/bank_0F.asm at cbb87d3
    Our readingY ← 010917hit rate + the weapon's byte 0 (not quoted)10919–10922Y + 110923damage + its byte 1 (not quoted)10925–10928
    Final Fantasy Disassembly/bank_0C.asm at cbb87d3
    Our readingthe class (not quoted)5719–5720class 2, Black Belt: to BB_Master (by the comment)5721–5722not 8, Master: done (by the comment)5723–5724BB_Master: a weapon graphic set: done (not quoted)5727–5729unarmed: fist graphics (not quoted)5732–5737crit rate ← level × 25739–5743

    Claim page

  78. ^CodeDisch, FF1 disassemblybank_0C.asm 4334–4357, 3998–4004, 4166–4172, 5668–5673
    How we know

    A physical attack gains 40 hit chance and 4 base damage when its category or element matches the defender's, but neither side of a battle can trigger it: a character's attack reads the character's own category and weakness bytes instead of the weapon's, and a monster's attack is matched against a character's, and all four bytes are always 0.

    Final Fantasy Disassembly/bank_0C.asm at cbb87d3
    Our readingattacker's category & defender's category4334–4335attacker's element & defender's weakness4338–4339either nonzero (not quoted)4342–4344 hit chance + 40, at most 255 (not quoted)4345–4352 base damage + 4 (not quoted)4354–4357attacker's category ← the character's category byte (not quoted)3998–4000attacker's element ← the character's weakness byte (not quoted)4002–4004defender's category ← the character's category byte (not quoted)4167–4169defender's weakness ← the character's weakness byte (not quoted)4171–4172the character's category and weakness bytes ← 05669–5673

    Claim page

  79. ^CodeDisch, FF1 disassemblybank_0C.asm 7116–7126, 8283–8316, 8153–8171, 8207–8211, 8325–8338
    How we know

    A damage spell's damage and its chance to double come from the spell's power, hit rate, and element, the target's magic defense, resistances, and weaknesses, and two random rolls. No stat of the caster enters either, so Intelligence adds nothing to spell damage.

    Final Fantasy Disassembly/bank_0C.asm at cbb87d3
    Our readingelement ← the spell's7116–7118hit rate ← the spell's7120–7122effectivity ← the spell's7124–7126mark the spell connected (by its label)8284load the base hit chance (by its label)8285damage ← effectivity (by its label)8286resisted: zero chance, halve damage (not quoted)8288–8293weak: chance + 40, damage × 1.5 (not quoted)8295–8313add the hit rate and rolls (by its label)8316hit chance += the spell's hit rate8154–8156hit chance −= the target's magic defense8158–8160damage += a roll up to damage (not quoted)8162–8168crit roll ← 0 to 200 (by its label)8170–8171hit chance ← 1488208–8209crit roll is 200: no double8326–8328else connected as a crit (by its label)8329–8330 damage × 28331–8332HP −= damage8337

    Claim page

  80. ^Codenmikstas/dragon-warrior-disassembly · Ryan8bit, DW FormulasBank03.asm 6724–6759
    How we know

    Before the normal formula, a 1-in-32 roll gives the hero an "excellent move", except against the Dragonlord; for attack power A it deals A−⌊r⌊A/2⌋/256⌋ for a random byte r, from ⌈A/2⌉+1 to A (more than half to all of the attack power), and ignores defense.

    6724LE615:  LDA EnNumber            ;Is player fighting the dragonlord's first form?
    6725LE617:  CMP #EN_DRAGONLORD1     ;
    6726LE619:  BEQ ChkPlyrMiss         ;If so, branch. no excellent moves permitted.
    ⋮
    6728LE61B:  CMP #EN_DRAGONLORD2     ;Is player fighting the dragonlord's final form?
    6729LE61D:  BEQ ChkPlyrMiss         ;If so, branch. no excellent moves permitted.
    ⋮
    6731LE61F:  JSR UpdateRandNum       ;($C55B)Get random number.
    6732LE622:  LDA RandNumUB           ;
    6733LE624:  AND #$1F                ;Did player get an excellent move(1/32 chance)?
    6734LE626:  BNE ChkPlyrMiss         ;If not, branch to see if player missed.
    ⋮
    6745LE634:  JSR UpdateRandNum       ;($C55B)Get random number.
    6746LE637:  LDA RandNumUB           ;
    6747LE639:  STA MultNum1LB          ;
    ⋮
    
    source_files/Bank03.asm lines 6724–6759 at ebe6a13 · upstream ↗
    Excellent moves have a 1/32 chance of happening per attack
    II.B, Hero attack formulas · archived copy ↗

    Claim page

  81. ^Codenmikstas/dragon-warrior-disassemblyBank03.asm 7751–7774
    How we know

    A monster's physical attack has no critical branch and no dodge roll for the hero; the monster's physical-attack code goes straight to its hit-damage routine ($EFF4), and only 0 damage misses.

    7765LEBD6:  JSR EnCalcHitDmg        ;($EFF4)Calculate enemy hit damage on player.
    ⋮
    7767LEBD9:  LDA CalcDamage          ;Did enemy do damage to the player?
    7768LEBDB:  BNE EnHitsPlayer        ;If so, branch to subtract damage from player's HP.
    
    source_files/Bank03.asm lines 7751–7774 at ebe6a13 · upstream ↗

    Claim page

  82. ^Codepret/pokeplatinum · pret/pokeemeraldmove_table.h 12–15; move_classes.txt 1–3; +6 files
    How we know

    In Platinum the damage formula reads each move's own class (physical, special, or status) and uses Attack against Defense for a physical move, Special Attack against Special Defense for a special one, whatever the move's type. Emerald picks the pair by type, below or above type 9 in the type list, so Thunder Punch (Electric) is special in Emerald and physical in Platinum, and Shadow Ball (Ghost) is physical in Emerald and special in Platinum.

    12typedef struct MoveTable {
    13    u16 effect;
    14    u8 class;
    15    u8 power;
    
    include/move_table.h lines 12–15 at 49f78f3 · upstream ↗
    1CLASS_PHYSICAL
    2CLASS_SPECIAL
    3CLASS_STATUS
    
    generated/move_classes.txt lines 1–3 at 49f78f3 · upstream ↗
    src/battle/battle_lib.c at 49f78f3
    Our readingattacker's Attack6635defender's Defense6636attacker's Sp. Attack6637defender's Sp. Defense6638move class ← the move's own6704physical:6947 a crit: attack stage above default: boosted (not quoted)6948–6951 else: raw attack (not quoted)6953 no crit: boosted attack (not quoted)6956–6957 × power × (level × 2 ÷ 5 + 2) (not quoted)6960–6961 defense the same way, stage below default (not quoted)6963–6972 ÷ defense, ÷ 50 (not quoted)6975–6976 burned without Guts: ÷ 2 (not quoted)6978–6979 Reflect, no crit, not a screen-breaker (not quoted)6982–6984 doubles, 2 alive: × 2/3 (not quoted)6985–6987 else: ÷ 2 (not quoted)6989special:6992
    10    "class": "CLASS_PHYSICAL",
    11    "type": "TYPE_ELECTRIC",
    
    res/moves/thunder_punch/data.json lines 10–11 at 49f78f3 · upstream ↗
    include/battle.h at 731ad5b
    Our readingphysical: the type below TYPE_MYSTERY466special: the type above it467
    src/pokemon.c at 731ad5b
    Our readingphysical by IS_TYPE_PHYSICAL of the type3232special by IS_TYPE_SPECIAL of the type3287

    4 more excerpts on the claim page

  83. ^Codepmret/papermariodmg_player.c 240, 292–380, 443–459, 462–492, 536–576, 578–598, 630, 672–674, 1548
    How we know

    In the US version of Paper Mario, the routine for Mario's damage to an enemy works by subtraction. A forced immune hit skips the calculation, and some hits return before it: an illusory, transparent, or buried target (buried unless the attack is a quake) is missed; a stone target takes nothing; a jump on a spiky top without Spike Shield, a contact attack on an explode-on-contact part, on a fiery part without Fire Shield or Ice Power, or on a part with the alternate spiky flag without Spike Shield backfires, the last two unless the attack suppresses that event; and a fire attack that sets off a part that explodes on fire returns before damage. Otherwise it starts from the move's damage, which the move script passes, adds the Power Plus badges, and adds or takes fixed amounts for Merlee, the jump and hammer charges, other badges, and statuses. All or Nothing adds 1 when the attack isn't a first strike, and without a nice or super hit it sets the damage to 0, and outside the Japanese build the defense too; a shrunk Mario's damage is halved, but stays at least 1; a blast on a part that explodes on ignition sets the damage to the target's HP and the defense to 0; and an attack typed to always hit for its status sets both to 0. The total is capped at 99, and the target's defense is then subtracted: the part's defense against the attack's element, plus the defense boost unless the attack ignores defense, plus 127 for a part flagged extreme defense, or 0 when the total is below 0. A result below 0 becomes 0, and a Power Bounce then adds its counter, keeping a hit above 0 at least 1. The routine's one random draw, a fear attack's scare-away test, runs after the damage is taken off the target's HP.

    240HitResult calc_player_damage_enemy(void) {
    
    src/battle/dmg_player.c line 240 at 1104f1f · upstream ↗
    src/battle/dmg_player.c at 1104f1f
    Our readingforced immune hit: no damage292–294else:295 Ice Power: contact attacks turn ice (not quoted)296–300 illusory, transparent, or buried but no quake: miss302–306 stone: the immune bonk, a 0 popup, a hit with no damage309–318 note an element immunity (not quoted)320–322 jump on a spiky top, no Spike Shield: backfire325–333 contact, not smash:336 part explodes on contact: backfire337–342 fiery, no burn suppression, Fire Shield, or Ice Power: backfire344–353 events on, fire, part explodes on fire: a hit357–368 contact, alt spiky, no Spike Shield or suppression: backfire371–380defense ← the part's defense for the element443not ignoring defense: + the defense boost445–447extreme defense: + 127449–451damage ← the move's damage + Power Plus453–454Merlee boost, with power-ups or a jump: + it456–459jump charge, a jump: + it462–465hammer charge, a quake hammer, throw, or smash: + it467–470unk_98 not 0: + 2 (not quoted)472–474Berserker: + 2476–478P-Up D-Down: + 1480–482P-Down D-Up: − 1484–486turbo charge: + 1488–490+ Mario's attack boost492not a first strike, All or Nothing:537–539 + 1540 no nice or super hit: damage 0; defense 0 outside the JP build542–547shrunk, damage above 0: halved, at least 1555–563blast on an ignition-exploding part: damage ← HP, no defense565–571status-always-hits: damage 0, defense 0573–576above 99: 99578–580below 0: defense ← 0582–584damage − defense586–587below 0: 0589–591Power Bounce, damage above 0: + its counter, at least 1593–598target's HP − damage630events on, fear: random(99) under escape × chance ÷ 100672–674move's damage ← the script's next argument1548

    Claim page

  84. ^Unsourced
    How we know

    How Final Fantasy Mystic Quest computes physical and magic damage hasn't been read yet.

    Claim page

  85. ^Codepret/pokecrystaleffect_commands.asm 2983–3028, 3087–3098, 3108–3120, 2660–2701, 2548–2592, 2797–2835; core.asm 6688–6694
    How we know

    A critical hit doubles the damage after held-item boosts and before the cap at 997 and the final +2. Unless the attacker's attacking-stat stage is higher than the defender's defending-stat stage, it also uses both Pokémon's stats without stages, which drops Reflect and Light Screen; pret's comment asks for the defender's stage to be higher, but the code takes this path at equal stages too.

    2983; Item boosts
    2984	call GetUserItem
    ⋮
    3021.DoneItem:
    3022; Critical hits
    3023	call .CriticalMultiplier
    ⋮
    3025; Update wCurDamage. Max 999 (capped at 997, then add 2).
    3026DEF MAX_DAMAGE EQU 999
    3027DEF MIN_DAMAGE EQU 2
    3028DEF DAMAGE_CAP EQU MAX_DAMAGE - MIN_DAMAGE
    
    engine/battle/effect_commands.asm lines 2983–3028 at 97187cd · upstream ↗
    3087.Cap:
    3088	ld a, HIGH(DAMAGE_CAP)
    3089	ld [hli], a
    3090	ld a, LOW(DAMAGE_CAP)
    3091	ld [hld], a
    ⋮
    3093.dont_cap_3
    3094; Add back MIN_DAMAGE (capping at 999).
    3095	inc hl
    3096	ld a, [hl]
    3097	add MIN_DAMAGE
    3098	ld [hld], a
    
    engine/battle/effect_commands.asm lines 3087–3098 at 97187cd · upstream ↗
    3108.CriticalMultiplier:
    3109	ld a, [wCriticalHit]
    3110	and a
    3111	ret z
    ⋮
    3113; x2
    3114	ldh a, [hQuotient + 3]
    3115	add a
    3116	ldh [hQuotient + 3], a
    ⋮
    3118	ldh a, [hQuotient + 2]
    3119	rl a
    3120	ldh [hQuotient + 2], a
    
    engine/battle/effect_commands.asm lines 3108–3120 at 97187cd · upstream ↗

    4 more excerpts on the claim page

  86. ^Codepret/pokeemeraldbattle_script_commands.c 1296; pokemon.c 3234–3268
    How we know

    The damage-calculation battle command multiplies the base damage by 2 on a critical; the base-damage formula then ignores the attacker's lowered attacking stat, the defender's raised defending stat, and Reflect or Light Screen.

    1296    gBattleMoveDamage = gBattleMoveDamage * gCritMultiplier * gBattleScripting.dmgMultiplier;
    
    src/battle_script_commands.c line 1296 at 731ad5b · upstream ↗
    3234        if (gCritMultiplier == 2)
    ⋮
    3236            // Critical hit, if attacker has lost attack stat stages then ignore stat drop
    ⋮
    3248        if (gCritMultiplier == 2)
    ⋮
    3250            // Critical hit, if defender has gained defense stat stages then ignore stat increase
    ⋮
    3267        if ((sideStatus & SIDE_STATUS_REFLECT) && gCritMultiplier == 1)
    
    src/pokemon.c lines 3234–3268 at 731ad5b · upstream ↗

    Claim page

Sources

Code

Secondary