Claim set · data/claims/ff7.yaml

Final Fantasy VII (Xeeynamo's ff7-decomp)

Game: Final Fantasy VII.

In the North American release, BattleSetTmpDmgAsPhysical takes the attacker's physical attack S (physAttack after stat multipliers) and the action's level L (characterLevel) 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 damageFlags bit $2 is set, the bit a critical sets and that this same function also sets for any attack whose attackFlags 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 the target's backDamageMult/8 when the unnamed unk234 bit 0 is set, quarters it under Frog, applies the Sadness, multi-target, and Barrier modifiers, and sets it to 0 under Mini. Last, BattleAddRndModifierAndZeroCheck 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 CalcDmgMod also lets defense remove a share, but as (255 − Defense)/256, with a variance of 224–255 over 256 applied before it. ff7/physical-damage

About: Final Fantasy VII Damage formula

Value
{
 "levelDivisor": 32,
 "powerUnit": 16,
 "defenseFrom": 512,
 "varianceMin": 3841,
 "varianceMax": 4096,
 "varianceOf": 4096
}
Codeff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L4491-L4497if (g_CurrentAction->attackFlags & 4) { … } else { attack = g_BattleState.combatant[g_CurrentAction->actorId].physAttack; g_CurrentAction->attackStat = BattleApplyStatMult(g_CurrentAction->actorId, attack, STAT_MULT_PHYS_ATTACK); }ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L4569-L4623void BattleSetTmpDmgAsPhysical(void) { … stat = g_CurrentAction->attackStat; level = g_CurrentAction->characterLevel; mulTerm = (level * stat) / 32; sumTerm = (level + stat) / 32; raw = ((mulTerm * sumTerm) + stat) * (0x200 - g_CurrentAction->targetDefense) * g_CurrentAction->power; damage = raw / 0x2000; if (g_CurrentAction->damageFlags & 2) { damage *= 2; } if (g_CurrentAction->attackerStatus & STATUS_BERSERK) { …ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L4552-L4565// scale arg0 by a fixed-point random variance factor (~93.77%..100%), then // clamp the result to a minimum of 1 static s32 BattleAddRndModifierAndZeroCheck(s32 arg0) { … temp_s0 = ((s32)(var_v0 * (SysGetRandomByteFromTable() + 0xF01))) >> 0xC; var_v0 = temp_s0; if (temp_s0 == 0) { var_v0 = 1; } return var_v0; }ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/main/btlrand.c#L19u8 SysGetRandomByteFromTable(void) { return g_KernRndTable[g_KernRndTablePos[g_KernRndTableIndex]++]; }Final Fantasy VI Disassembly · src/battle/calc_dmg.asm#L153-L193; [ calculate damage modification ] ; random variance, defense stat, shell/safe, defending, row, morph, friendly fire CalcDmgMod: … jsr Rand ora #$e0 ; random variance (240..255) sta $e8 jsr MultDmg … lda near wTargetProp2::MagicDefense,y bcc @0cd4 lda near wTargetProp2::Defense,y …Checked by claude-agent, 2026-10-22 — read each pinned range against every part of the statement

Cited by: Damage formula, Final Fantasy VII

In the North American release, BattleRollPhysicalHit hits when a roll of 1–100 (BattleGetRnd164) is under the hit chance: the attack's hit % (targetAttackPercent) plus a quarter of the attacker's dexterity, plus the attacker's Df%, less the target's Df%, cut by 30% under Fury, and raised to at least 1, which never hits. A party member's Df% is a quarter of its dexterity plus its physical evade and an enemy's is its physical evade alone, so a party attacker's dexterity counts twice. The chance is instead 255 against a target under Death, Sleep, Confusion, Stop, Petrify, Manipulate, or Paralysis, for the Death, Nullify, and Absorb affinities and one unnamed affinity flag, and for two flags the code leaves unnamed (unk234 bit 0, unk218 bit 5). Before the roll, a 0–99 roll under the attacker's luck/4 makes a sure hit; failing that, when an enemy attacks a party member and the same roll is under the target's luck/4, the attack misses, even at 255. BattleGetRnd164 scales a 16-bit random number by 99/65,535 and adds 1, so it gives 100 only for $FFFF, and a chance h of 2–100 hits about (h − 1) times in 99 (computed for evenly spread 16-bit values). Final Fantasy VI instead scales the hit rate by the target's stored evade (magic evade, through a bug) and rolls 0–99 against it. ff7/physical-hit

About: Final Fantasy VII Hit chance

Codeff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L5702-L5780void BattleRollPhysicalHit(void) { … const s32 vulnerableStatusMask = STATUS_DEATH | STATUS_SLEEP | STATUS_CONFU | STATUS_STOP | STATUS_PETRIFY | STATUS_MANIPULATE | STATUS_PARALYSIS; … hitChance = -1; if (g_CurrentAction->unk234 & 1) { hitChance = 255; } // Auto-hit on element Death-weakness, Auto-Hit weakness, Immune or Absorb if (g_CurrentAction->affinityFlags & (AFFINITY_DEATH | AFFINITY_UNK2 | AFFINITY_NULLIFY | AFFINITY_ABSORB)) { …ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L5920-L5929s32 BattleCalcDefPercent(s32 arg0) { s32 evade; if (arg0 < START_ENEMY) { evade = g_BattleState.combatant[arg0].dexterity / 4 + g_BattleState.combatant[arg0].physEvade; } else { evade = g_BattleState.combatant[arg0].physEvade; } return BattleApplyStatMult(arg0, evade, STAT_MULT_PHYS_EVADE); }ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L6008-L6013static s32 BattleApplyFuryHitChanceReduction(s32 hitChance) { if ((hitChance < 0xFF) && (g_CurrentAction->attackerStatus & STATUS_FURY)) { hitChance -= (hitChance * 3) / 10; } return hitChance; }ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L6667-L6670u16 BattleGetRndU16(void) { return SysRandomTwoBytes(); } // scale a 16-bit value into the range 1..100 static s32 BattleGetRnd164(void) { return (((BattleGetRndU16() & 0xFFFF) * 0x63) / 0xFFFF) + 1; }ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/main/btlrand.c#L19-L21u8 SysGetRandomByteFromTable(void) { return g_KernRndTable[g_KernRndTablePos[g_KernRndTableIndex]++]; } u8 SysGetRandomByteRange(s32 upperBound) { return (SysGetRandomByteFromTable() * upperBound) >> 8; }Final Fantasy VI Disassembly · src/battle/check_hit.asm#L166-L210.else lda near wTargetProp2::Evade,y bcs @2347 lda near wTargetProp2::MagicEvade,y @2347: pha bcc @2388 .endif … @2388: pla xba lda $ee jsr MultAB …Checked by claude-agent, 2026-10-22 — read each pinned range against every part of the statement

Cited by: Final Fantasy VII, Hit chance

In the North American release, BattleRollCriticalHit is entry 2 of the hit-formula table, so it runs only for an attack whose hit-formula script includes it, and only if the hit roll didn't mark a miss. Its chance is (the action's level + the attacker's luck − the target's level)/4, plus the weapon's critical % for a party member, or 255 under Lucky Girl; a 1–100 roll at or under the chance sets bit 1 ($2) of damageFlags. BattleSetTmpDmgAsPhysical doubles the damage when that bit is set, and sets it itself for an attack whose attackFlags bit $2000 is clear. So a chance c of 0–99 crits about c times in 99 (computed for evenly spread 16-bit values). Final Fantasy VI crits on a random byte under 8, 1 in 32, whatever the stats, and a critical adds 2 to the damage multiplier, which its code comments as damage ×2. ff7/critical

About: Final Fantasy VII Critical hit

Value
{
 "divisor": 4,
 "multiplier": 2
}
Codeff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L5825-L5847static void BattleRollCriticalHit(void) { … if (!(g_CurrentAction->unk218 & 1)) { critChance = 0xFF; if (!(g_CurrentAction->attackerStatus & STATUS_LUCKY_GIRL)) { v = (g_CurrentAction->characterLevel + g_BattleState.combatant[attacker].luck) - g_BattleState.combatant[target].level; critChance = v / 4; if (attacker < NUM_PARTY) { critChance += g_BattleWork.setup[attacker].criticalHitChance; } } …ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/batini.c#L346setup->criticalHitChance = character->weapon.criticalPercent;ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L5044-L5053const BattleFormula g_BattleHitFormulaJmpTbl[] = { /* 0x0 */ BattleRollPhysicalHit, /* 0x1 */ BattleRollMagicalHit, /* 0x2 */ BattleRollCriticalHit,ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L4443-L4451void BattleDmgFormulaRun(void) { BattleFormula fnDamageFormula = g_BattleDmgFormulaJmpTbl[g_CurrentAction->dmgFormulaId]; s32 i = g_BattleHitFormulaOffs[g_CurrentAction->hitFormulaId]; s32 op; while ((op = g_BattleHitFormulaOpcodeStream[i++]) != HIT_OPCODE_DELIM) { g_BattleHitFormulaJmpTbl[op](); }ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L4580-L4591if (!(g_CurrentAction->attackFlags & 0x2000)) { g_CurrentAction->damageFlags |= 2; } … if (g_CurrentAction->damageFlags & 2) { damage *= 2; }ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L6669-L6670// scale a 16-bit value into the range 1..100 static s32 BattleGetRnd164(void) { return (((BattleGetRndU16() & 0xFFFF) * 0x63) / 0xFFFF) + 1; }Final Fantasy VI Disassembly · src/battle/attack.asm#L332-L348@33f2: lda #$02 bit zb3 beq @340c ; auto-crit bit zb2 bne @3414 bit zba beq @3414 jsr Rand cmp #$08 bcs @3414 ; 31/32 chance to branch lda near w7e3eb0 + 25 beq @3414 ; branch if there are no targets …Checked by claude-agent, 2026-10-22 — read each pinned range against every part of the statement

Cited by: Critical hit, Final Fantasy VII

In the North American release, when an enemy's action takes HP from a party member, BattleApplyDamageAndChargeLimitGauge adds ⌊300 × damage / max HP⌋ × 256 over the character's HP divisor to the Limit gauge, with 512 in place of 256 under Fury and 128 under Sadness, and caps the gauge at 255; the damage counts in full, even past the HP the character had left. It adds nothing for healing, MP damage, a character whose limit level is 4 or more, or a turn flag the code leaves unnamed (turnFlags bit 3). The divisor is read from KERNEL.BIN per character and limit level (hpDivisor), so the code alone doesn't give its values. ff7/limit-gauge

About: Final Fantasy VII Limit Break

Value
{
 "scale": 300,
 "normal": 256,
 "fury": 512,
 "sadness": 128,
 "cap": 255
}
Codeff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/battle.c#L4252-L4311void BattleApplyDamageAndChargeLimitGauge(void) { BattleUnit* target = &g_BattleState.combatant[g_CurrentAction->targetId]; s32 isHeal = g_CurrentAction->damageFlags & 1; … if (g_CurrentAction->damageFlags & 4) { oldValue = target->curMP; target->curMP = SysAddSubWithMaxMinBound(oldValue, g_CurrentAction->tmpDamage, target->maxMP, isHeal); return; } … // only party members charge their limit gauge, and only from enemy attacks if (g_CurrentAction->targetId >= NUM_PARTY || g_CurrentAction->actorId < START_ENEMY || isHeal) { …ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · src/battle/batini.c#L388party->limitBreakHPDivisor = D_80082268[charId].hpDivisor[limitLevel];ff7-decomp: a matching decompilation of Final Fantasy VII for the PlayStation (Xeeynamo/ff7-decomp) · include/game.h#L786-L797// Per-character record of KERNEL.BIN section 3 (battle and growth data), 0x38 bytes // each, nine of them from 0x80082268. The limit commands and HP divisors the // limit-break code reads are the third and last fields. … /* 0x28 */ s32 hpDivisor[4]; // by limit levelChecked by claude-agent, 2026-10-22 — read each pinned range against every part of the statement

Cited by: Final Fantasy VII, Limit Break