DoesntKnowHowToPlay
Tiny Umbrella with Lots and Lots of Good
- 265
- Posts
- 13
- Years
- Seen Feb 24, 2024
![[PokeCommunity.com] [FR] Inverse Battles [PokeCommunity.com] [FR] Inverse Battles](https://i.imgur.com/myyB1O5.png)
In XY, there is a new type of battle known as the Inverse Battle. In this mode, type match-ups are reversed- moves that are normally super-effective become ineffective, and moves that are normally resisted or would have no effect become super-effective. I did some poking at the type chart code recently and found that it's actually quite easy to implement these in FR.
"But that's easy! Just edit the well-documented type chart so every match-up is backwards!"
That isn't what this does. This hack hijacks the code that reads the type chart to make the game use the inverse of what's there. This means you can use a flag to have hacks with both regular and inverse battles.
The routine is as follows:
Code:
.align 2
.thumb
.thumb_func
push {r4, r5, lr}
mov r4, r0
mov r0, #0x02
lsl r0, #0x8
mov r1, #0x3D
add r0, r1
bl FlagCheck
cmp r0, #0x0
beq End
cmp r4, #0x0
beq SuperEffective
cmp r4, #0x5
beq SuperEffective
cmp r4, #0x14
beq Ineffective
b End
SuperEffective:
mov r4, #0x14
b End
Ineffective:
mov r4, #0x5
End:
ldr r5, .damageAddr
ldr r0, [r5, #0x0]
mul r0, r4
ldr r1, .returnAddr
bx r1
FlagCheck:
ldr r2, .flagAddr
bx r2
.align 2
.returnAddr: .word 0x0801e77d
.flagAddr: .word 0x0806e6d1
.damageAddr: .word 0x02023d50
.end
This code ties the Inverse Battle rules to flag x23D. If flag x23D is set, battles will use the Inverse Battle ruleset- otherwise they will work normally. If you want to use a different flag, you can change it quite easily by adjusting the values on the sixth and eighth lines. Note that in vanilla FireRed, flag x23D is used by the Pokeflute- if that script is still in the game you will want to pick a different one.