Spherical Ice

Age 21
Bristol, UK
Online now
Posted 4 Weeks Ago
5,249 posts
11.7 Years
I've made a fully functional Close Combat effect for FireRed, with the animation varying when one stat is already at its minimum (i.e. only lowering one), when both aren't at their minimum (i.e. lowering both) and when both are at their minimum (i.e. skipping the drops altogether). This does use ASM but I've since been told that it could be done with the jumpifstat command. I'm going to post this anyway. You'll need to have the battle script callasm command, too.

Battle Script (use this for the effect ID):
#dynamic 0x800000
#freespacebyte 0xFF

#org @start
attackcanceler
accuracycheck 0x81D695E 0x0
attackstring
ppreduce
calculatedamage
attackanimation
waitanimation
missmessage
cmd5c 0x0
waitstate
graphicalhpupdate 0x0
datahpupdate 0x0
critmessage
waitmessage 0x40
resultmessage
waitmessage 0x40
faintpokemon 0x0 0x0 0x8000000
callasm 0x8AABBCC + 1
ASM at AABBCC:
.text
.align 2
.thumb
.thumb_func

Main:
ldr r1, .BattleData
ldr r0, .UserBank
ldrb r0, [r0]
mov r2, #0x58
mul r2, r0
add r1, #0x1a
add r1, r2
ldrb r0, [r1]
ldrb r2, [r1, #0x3]
mov r3, #0x0
cmp r0, r3
beq DefIsZero
cmp r2, r3
beq SpDefIsZero
ldr r4, .LowerBothBS
b End

DefIsZero:
cmp r2, r3
beq BothBS
ldr r4, .LowerSpDefBS
b End

SpDefIsZero:
ldr r4, .LowerDefBS
b End

BothBS:
ldr r4, .EndBS

End:
ldr r5, .ActiveBSPointer
str r4, [r5, #0x0]
bx lr

.align 2
.BattleData:		.word 0x02023BE4
.UserBank:		.word 0x02023D6B
.ActiveBSPointer:	.word 0x02023D74
.LowerSpDefBS:		.word 0x08SSSSSS
.LowerDefBS:		.word 0x08DDDDDD
.LowerBothBS:		.word 0x08BBBBBB
.EndBS:			.word 0x081D694E
Battle script at SSSSSS (lowers SDef only):
#dynamic 0x800000
#freespacebyte 0xFF

#org @start
setbyte 0x2023FDF 0x0
playstatchangeanimation 0x1 0x4 0x1
setbyte 0x2023FDE 0x92
statbuffchange 0x80 true @end
jumpifbyte 0x0 statchange 0x2 @end
printfromtable 0x83FE588
waitmessage 0x40

#org @end
goto 0x81D694E
Battle script at DDDDDD (lowers Def only):
#dynamic 0x800000
#freespacebyte 0xFF

#org @start
setbyte 0x2023FDF 0x0
playstatchangeanimation 0x1 0x20 0x1
setbyte 0x2023FDE 0x95
statbuffchange 0x80 true @end
jumpifbyte 0x0 statchange 0x2 @end
printfromtable 0x83FE588
waitmessage 0x40

#org @end
goto 0x81D694E
Battle script at BBBBBB (lowers both):
#dynamic 0x800000
#freespacebyte 0xFF

#org @start
setbyte 0x2023FDF 0x0
playstatchangeanimation 0x1 0x24 0x1
setbyte 0x2023FDE 0x92
statbuffchange 0x80 true @end
jumpifbyte 0x0 statchange 0x2 @end
printfromtable 0x83FE588
waitmessage 0x40
setbyte 0x2023FDE 0x95
statbuffchange 0x80 true @end
jumpifbyte 0x0 statchange 0x2 @end
printfromtable 0x83FE588
waitmessage 0x40

#org @end
goto 0x81D694E
The bolded offsets points to these battle scripts from vanilla FireRed:
#org 0x1D695E
attackstring
ppreduce
pause 0x20
missmessage
resultmessage
waitmessage 0x40
goto 0x81D694E
#org 0x1D694E
setbyte 0x2023FD8 0x0
cmd49 0x0 0x0
end
Thanks to DoesntKnowHowToPlay for troubleshooting with me.