v0.1 ⌊ALPHA⌉
On this page
  1. Implementations
  2. Related
  3. References
  4. Sources

A move whose type matches one of its user’s types gets a damage bonus. pret names it STAB, “Same Type Attack Bonus”, in a comment in pokecrystal’s BattleCommand_Stab1. It runs in the same routine as type effectiveness, directly before the type rows2,3,4.

#Implementations

GameInteger math
Red and Blued+⌊d/2⌋2
Crystald+⌊d/2⌋3, after weather and badge boosts
Emerald⌊d×15/10⌋4

The forms agree for every non-negative d: ⌊15d/10⌋=d+⌊d/2⌋4. In Crystal and Emerald, Struggle skips the routine and never gets the bonus5,6.

References

  1. ^A comment in pokecrystal's BattleCommand_Stab expands STAB as “Same Type Attack Bonus”. T3pret/pokecrystal · engine/battle/effect_commands.asm L1214–1215
  2. ^ abAdjustDamageForMoveType applies STAB before any type row: damage+⌊damage/2⌋ when the move's type matches either attacker type. T3pret/pokered · engine/battle/core.asm L5101–5125
  3. ^ abBattleCommand_Stab applies weather and badge type boosts, then STAB (damage+⌊damage/2⌋ if either attacker type matches), then the type chart. T3pret/pokecrystal · engine/battle/effect_commands.asm L1251–1288
  4. ^ abcBefore the type chart, Cmd_typecalc applies STAB as damage×15/10 when either attacker type equals the move's type. T3pret/pokeemerald · src/battle_script_commands.c L1368–1373, include/battle.h L471
  5. ^Struggle returns from BattleCommand_Stab at once, so it skips weather, badge boosts, STAB, and the type chart. T3pret/pokecrystal · engine/battle/effect_commands.asm L1216–1219
  6. ^Struggle skips Cmd_typecalc entirely, so neither STAB nor the type chart touches it. T3pret/pokeemerald · src/battle_script_commands.c L1360–1364

Sources

Code