Cite as
pret/pokeruby
Original
https://github.com/pret/pokeruby
Pinned
pret/pokeruby @ 5784633ce4ef7ade1a7f2d2d0c288e3d5e6cdd7f
Accessed
2026-10-21
Licence
none stated (no LICENSE file)
Credit
The pret community. See https://github.com/pret/pokeruby/graphs/contributors.
Notes
A matching decompilation of the English Ruby and Sapphire ROMs, sha1 f28b6ffc97847e94a6c21a63cacf633ee5c8df1e (Ruby) and 3ccbbd45f8553c36463f13b938e833f652b793e4 (Sapphire) (README), plus revisions and German builds. Function and variable names are the decompilers', not Game Freak's.

Cited on

Claims (13)

Ruby and Sapphire run the same formula and shake checks as Emerald, except that their status test leaves out bad poison (STATUS1_TOXIC_POISON, a separate status bit from poison), so a badly poisoned Pokémon gets no bonus. Emerald's test includes it.src/battle_script_commands.c L9452–9456src/battle_script_commands.c L9484–9486src/battle_script_commands.c L1033–1036include/constants/battle.h L85–89Code
Ruby and Sapphire's atk04_critcalc, which Emerald keeps apart from a renamed helper, sums Focus Energy (+2), a move whose effect is high-critical, Sky Attack, Blaze Kick, or Poison Tail (+1), a Scope Lens (+1), and Lucky Punch or Stick on their species (+2), caps the stage at 4, and hits critically 1 time in 16, 8, 4, 3, or 2. Battle Armor or Shell Armor on the target, the STATUS3_CANT_SCORE_A_CRIT flag on the attacker, Wally's tutorial, and the first battle rule it out.src/battle_script_commands.c L1387–1402src/battle_script_commands.c L822Code
Ruby and Sapphire's atk01_accuracycheck, which Emerald keeps with renamed constants, scales a move's percent accuracy by one combined stage ratio, applies Compound Eyes (×1.3), Sand Veil in a sandstorm and Hustle on physical moves (×0.8 each), and a target's evasion item, and misses when a roll from 1 to 100 exceeds the result.src/battle_script_commands.c L1272–1299Code
Ruby and Sapphire's gTypeEffectiveness holds the same 110 rows as Emerald's and Crystal's, in the same order, with literal 0xFE and 0xFF bytes where Emerald names TYPE_FORESIGHT and TYPE_ENDTABLE.data/type_effectiveness.inc L1–119Code
Ruby and Sapphire's atk06_typecalc applies STAB as damage×15/10 before the type rows, as Emerald's Cmd_typecalc does.src/battle_script_commands.c L1486–1490Code
Ruby and Sapphire already use Emerald's random factor, damage × (100 − rand % 16) / 100, raised to 1 if that gives 0; Gen 1 and 2 reach about the same 85–100% spread as a byte from 217 to 255 over 255.src/battle_script_commands.c L1751–1763Code
Ruby and Sapphire's atk8D_setmultihitcounter gives 2 or 3 hits with probability 3/8 each and 4 or 5 with 1/8 each, the same code as Emerald's; the multi-hit battle script runs accuracycheck once and then loops critcalc, damagecalc, and adjustnormaldamage for every hit.src/battle_script_commands.c L6697–6710data/battle_scripts_1.s L652–690Code
Ruby and Sapphire multiply the area's encounter rate by 16, cut it to 80% on the Mach or Acro Bike, apply the flute and Cleanse Tag modifiers, halve it for a lead with Stench and double it for Illuminate, cap it at 2,880, and start a battle when Random() % 2880 is below it. Emerald keeps the roll and adds more ability modifiers.src/wild_encounter.c L21src/wild_encounter.c L377–381src/wild_encounter.c L403–424Code
Ruby and Sapphire's TryRunFromBattle always escapes with a Smoke Ball or Run Away; otherwise, in a single battle, a Pokémon at least as fast as the foe escapes, and a slower one when ⌊128P/E⌋+30t, for t earlier tries, beats a random byte. Emerald adds only the Battle Pyramid's and Frontier's rules.src/battle_main.c L5465–5490Code
Ruby and Sapphire's GetWhoStrikesFirst puts the higher-priority move first; at equal priority the higher adjusted Speed goes first, and a tie is a coin flip. Adjusted Speed applies stat stages, doubles for Swift Swim in rain or Chlorophyll in sun, takes ×1.1 for the player's Pokémon with the third badge outside link battles, halves with a Macho Brace, and quarters under paralysis; a held Quick Claw sets it to the maximum when a per-turn random number is below its parameter, 20, as a percent of 0xFFFF.src/battle_main.c L4594–4641src/battle_main.c L4701–4718src/data/items_en.h L2932–2936Code
Ruby and Sapphire define 77 abilities, from Stench (1) to Air Lock (77); a species lists one or two, and when it has two, the lowest bit of the Pokémon's personality value picks which.include/constants/abilities.h L4–83src/pokemon_1.c L1465–1468src/pokemon_2.c L1056–1063Code
A Ruby and Sapphire Pokémon's nature is its personality value mod 25; each of the 25 raises one stat other than HP by 10% and lowers another by 10%, rounded down, except Hardy, Docile, Serious, Bashful, and Quirky, which change nothing.src/pokemon_3.c L261–264src/pokemon_3.c L627–657src/pokemon_1.c L1285–1313Code
In Ruby and Sapphire, rain, sandstorm, or drought on the overworld starts a battle in that weather with no turn limit, Drizzle sets lasting rain when its holder enters, and Cloud Nine or Air Lock on the field turns weather's effects off.src/battle_util.c L1794–1836include/battle_util.h L50src/battle_util.c L771–776Code