- 4
- Posts
- 4
- Years
- Seen Jun 25, 2021
Hello! I am working on my first rom hack and trying to create a new ability but I am running into a problem.
I am creating an ability called Molt which restores 20% and cures all status effects upon switch out. Basically it is a combination of regenerator and natural cure. Conveniently MrDollSteak has provided the code for regenerator (I would link it but it won't let me) which I started building off of.
Obviously just adding an update to the status effect doesn't do anything since it needs to be buffered,
but I cannot seem to find any documentation about how the buffering system works to be able to modify it. Has anyone done anything like this or know any resources I can look at to try and get this to work?
I am creating an ability called Molt which restores 20% and cures all status effects upon switch out. Basically it is a combination of regenerator and natural cure. Conveniently MrDollSteak has provided the code for regenerator (I would link it but it won't let me) which I started building off of.
Obviously just adding an update to the status effect doesn't do anything since it needs to be buffered,
Spoiler:
Code:
.text
.align 2
.thumb
.thumb_func
.global regenerator
AbilityBuffer:
add r0, r1, r3
add r0, #0x20
ldrb r0, [r0]
RegeneratorCheck:
mov r2, #0x1E
cmp r0, #0x51
beq AddHP
MoltCheck:
mov r2, #0x12
cmp r0, #0x57
beq Molt
NaturalCureCheck:
cmp r0, #0x1E
bne NoAbility
NaturalCure:
ldr r0, .Return
bx r0
NoAbility:
ldr r0, .Return2
bx r0
Molt:
push {r0-r6}
add r3, #0x4c
add r1, r1, r3
mov r0, #0x0
str r0, [r1, #0x0]
pop {r0-r6}
AddHP:
add r3, #0x28
add r3, r1, r3
ldrh r0, [r3, #0x4]
mov r1, r2
mul r0, r1
mov r1, #0x5A
push {r3}
bl Divide
pop {r3}
ldrh r1, [r3]
add r0, r0, r1
CheckHP:
ldrh r2, [r3, #0x4]
cmp r0, r2
ble StoreHP
MaxHP:
mov r0, r2
StoreHP:
strh r0, [r3]
BufferHealthChange:
ldr r2, .CommandTable
ldrb r1, [r4]
ldr r0, .RamLoc
ldr r0, [r0]
add r0, r1, r0
add r0, #0x58
ldrb r0, [r0]
lsl r0, r0, #0x2
add r0, r0, r2
ldrb r2, [r0]
mov r0, r1
mul r0, r6
add r0, r0, r3
str r0, [sp]
mov r0, #0x0
HealthChangeIndex:
mov r1, #0x2A
Success:
ldr r3, .Return3
bx r3
Divide:
ldr r3, .DivideLoc
bx r3
.align 2
.Return: .word 0x0802CCE7
.Return2: .word 0x0802CD1B
.CommandTable: .word 0x0825E45C
.RamLoc: .word 0x02023FE8
.Return3: .word 0x0802CD0F
.DivideLoc: .word 0x081E4019