jojobear13 / shinpokered

Mostly-vanilla hack of Pokémon Red/Blue focused on bugfixes and trainer ai
214 stars 42 forks source link

Badge Boosts #10

Closed AndyJ01 closed 4 years ago

AndyJ01 commented 4 years ago

Hi, concerning the bug where the thunder and soul badges have effects opposite their descriptions, I think the original text is correct and the effect is wrong. It seems like the intention was for the thunder badge to boost speed (Surge's style is X Speed and paralysis to keep the initiative) and the soul badge to boost defense (Koga's strategy is high defense stats with evasion, accuracy, and poison moves). FireRed and LeafGreen were revised in this way as well. I was trying to find where to change this for my own use but I don't know anything about assembly yet. Thanks.

jojobear13 commented 4 years ago

This is handled by ApplyBadgeStatBoosts: in engine/battle/core.asm. While what you say is true from a narrative perspective, the red/blue was intentionally coded to have Thunder badge give Defense and Soul Bade give Speed. That is because the order of these badges match the order of the stats in memory. Stat-related addresses are always ordered from lowest to highest address as: ATK, DEF, SPD, SPE. Likewise, tracking the badges that give stat boosts are always ordered from lowest bit to highest bit: Boulder, Thunder, Soul, Volcano. Each of these four stats take up 2 bytes for a total of 8 bytes, and 8 bits are used to track all the badges. This allows the programmer to match each badge bit to a stat byte. The four badges that boost were only chosen so because their respective bits match to the lower bytes of the four stats. Any, it was done this way because it allows the programmer to check acquired badges for boosts by using simple shifts and compares. This is faster and uses less space than programming a search algorithm.

If anything, this might indicate that Surge and Koga swapped places at some point during development.