The PokéCommunity Forums

The PokéCommunity Forums (https://www.pokecommunity.com/index.php)
-   Binary ROM Hacking (https://www.pokecommunity.com/forumdisplay.php?f=284)
-   -   Battle Removing badge stat boosts in FireRed (https://www.pokecommunity.com/showthread.php?t=399990)

SP458 September 24th, 2017 10:40 PM

Removing badge stat boosts in FireRed
 
Hey everyone!

I'm making a harder version (partially inspired from Crystal_'s Pokémon Pyrite) of FireRed and one of its features is the removal of stat boosts granted by badges. All I've found is a post referencing flag checks which didn't really help me, but is there a script or another way to remove these boosts?

ghoulslash September 25th, 2017 12:57 PM

Quote:

Originally Posted by SP458 (Post 9761623)
Hey everyone!

I'm making a harder version (partially inspired from Crystal_'s Pokémon Pyrite) of FireRed and one of its features is the removal of stat boosts granted by badges. All I've found is a post referencing flag checks which didn't really help me, but is there a script or another way to remove these boosts?

Unfortunately this would require assembly hacking. You would need to edit the battle engine routines to skip the flag checks / automatically jump to the portion of the routine as if the badge flag were never set.

For starters, Mr. Dollsteak had rewritten the turn order loader routine which includes the relevant badge check. Removing the badge check would simply require removing the BadgeCheck portion, like so:

Code:

ChoiceScarfCheck:
        cmp r0, #0x1D
        bne StatusCheck
        bl 0x9A948
        lsl r0, r0, #0x18
        lsl r0, r0, #0x18
        cmp r0, #0x2
        bne StatusCheck
        lsr r0, r5, #0x1
        add r5, r0, r5

StatusCheck:
        ldr r0, [r6, #0x4c]
        add r6, #0x20
        ldrb r1, [r6, #0x0]
        cmp r1, #0x9B
        bne ParalysisCheck



The attack and defense boosts would likely be found in the base damage calculation function, or battle command 0x5 (starting at 0x0801E59C)

SP458 September 27th, 2017 9:59 PM

Thanks for your answer. I'm a beginner in ASM and I only know hex editing at small scale and inserting existing routines (also, battle commands?). I'm currently reading a few ASM tutorials. Still, even if I learn ASM, is there a way to find out when the function is called in-game with an emulator? (I'm using mGBA)

ghoulslash September 28th, 2017 2:43 PM

Quote:

Originally Posted by SP458 (Post 9763396)
Thanks for your answer. I'm a beginner in ASM and I only know hex editing at small scale and inserting existing routines (also, battle commands?). I'm currently reading a few ASM tutorials. Still, even if I learn ASM, is there a way to find out when the function is called in-game with an emulator? (I'm using mGBA)

battle commands are called by the battle engine when you use a move in battle. Every damaging move will call the damage calculation commands within 'battle scripts,' which are essentially just strings of battle commands for move effects, between-turn effects, etc. You can use VBA-SDL-H or IDA Pro to see where the game is calling certain functions. FBI's ASM tutorials teach you how to use the former. But that shouldn't be necessary, I've given you the address of the basic damage calculation function (0801E59C). If you open the disassembler tool in VBA, or use IDA Pro you can view the assembly code of this function and you will likely find the badge flag checks. Then it 's just a matter of writing your own assembly routine to skip the checks.

SP458 November 5th, 2017 5:09 AM

After learning ASM and studying the battle function and MDS's speed routine, I've made significant progress.

I've found the badge-relevant subroutines starting at 0x3EE10 for attack/defense stats (0x3EE10 for Attack, 0x3EE44 for Defense, 0x3EE7A for Special Attack, and 0x3EEB2 for Special Defense) and two subroutines for Speed at 0x14E08 and 0x14EF0. They all have similar bodies, notably a "beq" instruction happening four lines after the loading into r0 of a badge flag (Boulder Badge: 0x820, Soul Badge: 0x824, Volcano Badge: 0x826, Thunder Badge: 0x822). That "beq" never branches if you have the badge, and always branches without it. I need to study further the register values, but it could be done with simple hex editing. As all six branches compare r0 with 0, just setting r0 to 0 (= 00 20 in hex) before the comparisons (instead of a left shift) should do the trick. The locations of the left shifts which must be replaced are 0x3EE24, 0x3EE56, 0x3EE8C, 0x3EEC4, 0x14E1A and 0x14F02.

Blah November 5th, 2017 3:42 PM

Well done :)

BluRose November 6th, 2017 2:48 PM

Quote:

Originally Posted by FBI (Post 9788809)
Well done :)

no kidding; it's very nice to see your initiative around here


All times are GMT -8. The time now is 9:13 AM.


Like our Facebook Page Follow us on Twitter © 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.

Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.