The PokéCommunity Forums  

Go Back   The PokéCommunity Forums > Fan Games > Binary ROM Hacking
Reload this Page Battle Removing badge stat boosts in FireRed

Notices
For all updates, view the main page.

Binary ROM Hacking Need a helping hand or just want to talk about binary ROM hacks? Get comments and answers to any ROM Hacking-related problems, questions or thoughts you have here.

Ad Content
Reply
 
Thread Tools
  #1   Link to this post, but load the entire thread.  
Old September 24th, 2017 (10:40 PM).
SP458 SP458 is offline
 
Join Date: Apr 2013
Location: France
Age: 31
Gender: Male
Nature: Timid
Posts: 14
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?
Reply With Quote
  #2   Link to this post, but load the entire thread.  
Old September 25th, 2017 (12:57 PM).
ghoulslash's Avatar
ghoulslash ghoulslash is offline
 
Join Date: Mar 2016
Gender: Male
Posts: 238
Quote:
Originally Posted by SP458 View Post
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)
Reply With Quote
  #3   Link to this post, but load the entire thread.  
Old September 27th, 2017 (9:59 PM). Edited September 27th, 2017 by SP458.
SP458 SP458 is offline
 
Join Date: Apr 2013
Location: France
Age: 31
Gender: Male
Nature: Timid
Posts: 14
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)
Reply With Quote
  #4   Link to this post, but load the entire thread.  
Old September 28th, 2017 (2:43 PM).
ghoulslash's Avatar
ghoulslash ghoulslash is offline
 
Join Date: Mar 2016
Gender: Male
Posts: 238
Quote:
Originally Posted by SP458 View Post
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.
Reply With Quote
  #5   Link to this post, but load the entire thread.  
Old November 5th, 2017 (5:09 AM). Edited November 5th, 2017 by SP458.
SP458 SP458 is offline
 
Join Date: Apr 2013
Location: France
Age: 31
Gender: Male
Nature: Timid
Posts: 14
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.
Reply With Quote
  #6   Link to this post, but load the entire thread.  
Old November 5th, 2017 (3:42 PM).
Blah's Avatar
Blah Blah is offline
Free supporter
 
Join Date: Jan 2013
Location: Unknown Island
Gender: Male
Posts: 1,924
Well done :)
__________________
...
Reply With Quote
  #7   Link to this post, but load the entire thread.  
Old November 6th, 2017 (2:48 PM).
BluRose BluRose is offline
blu rass
 
Join Date: Apr 2014
Location: michigan tech
Age: 22
Gender: Male
Nature: Timid
Posts: 812
Quote:
Originally Posted by FBI View Post
Well done :)
no kidding; it's very nice to see your initiative around here
__________________
heyo check out my github:

BluRosie
highlights:
battle engine for heartgold
various feature branches in heart gold (fairy type, odd egg, mud slopes)

i'm a big part of the development team of pokemon firegold! all the code that i develop for that hack is also on my github

also on discord: BluRose#0412
Reply With Quote
Reply

Quick Reply

Join the conversation!

Create an account to post a reply in this thread, participate in other discussions, and more!

Create a PokéCommunity Account
Ad Content
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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