summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjiangzhengwenjz <jiangzhengwenjzw@qq.com>2019-08-02 05:05:35 +0800
committerjiangzhengwenjz <jiangzhengwenjzw@qq.com>2019-08-02 05:05:35 +0800
commitc2964e818143757ca5586b1a811669a1c287e870 (patch)
treea0e7eed74397995d6e7f4970d43a40f6e9a97b9c
parent3eb1f1bc783308dac445eaacc05c9f14e9b78822 (diff)
ported battle_util from pokeem
-rw-r--r--asm/battle_2.s154
-rw-r--r--asm/battle_script_commands.s72
-rw-r--r--asm/battle_util.s3283
-rw-r--r--data/data.s2
-rw-r--r--include/battle.h4
-rw-r--r--include/battle_scripts.h75
-rw-r--r--include/battle_util.h50
-rw-r--r--include/constants/pokemon.h6
-rw-r--r--ld_script.txt1
-rw-r--r--src/battle_ai_script_commands.c2
-rw-r--r--src/battle_util.c882
-rw-r--r--sym_ewram.txt8
12 files changed, 1031 insertions, 3508 deletions
diff --git a/asm/battle_2.s b/asm/battle_2.s
index a80099a6a..f29f29fe6 100644
--- a/asm/battle_2.s
+++ b/asm/battle_2.s
@@ -7848,7 +7848,7 @@ _08013C58:
ldrb r0, [r0]
cmp r0, 0
beq _08013CB0
- ldr r1, _08013CA4 @ =gUnknown_2023BE3
+ ldr r1, _08013CA4 @ =gCurrentActionFuncId
movs r0, 0xC
strb r0, [r1]
ldr r1, _08013CA8 @ =gBattleMainFunc
@@ -7867,7 +7867,7 @@ _08013C94: .4byte gBattleScripting
_08013C98: .4byte gBattleMoveDamage
_08013C9C: .4byte gMoveResultFlags
_08013CA0: .4byte gBattleCommunication
-_08013CA4: .4byte gUnknown_2023BE3
+_08013CA4: .4byte gCurrentActionFuncId
_08013CA8: .4byte gBattleMainFunc
_08013CAC: .4byte RunTurnActionsFunctions
_08013CB0:
@@ -9712,7 +9712,7 @@ _08014BB4:
ands r0, r1
cmp r0, 0
bne _08014BFA
- ldr r0, _08014C1C @ =gUnknown_825011C
+ ldr r0, _08014C1C @ =gBattleScriptingCommandsTable
ldrb r1, [r4]
lsls r1, 2
adds r1, r0
@@ -9731,7 +9731,7 @@ _08014C0C: .4byte gBattlescriptCurrInstr
_08014C10: .4byte gSelectionBattleScripts
_08014C14: .4byte gBattleControllerExecFlags
_08014C18: .4byte gBitTable
-_08014C1C: .4byte gUnknown_825011C
+_08014C1C: .4byte gBattleScriptingCommandsTable
_08014C20:
ldr r3, _08014C88 @ =gBattleControllerExecFlags
ldr r1, _08014C8C @ =gBitTable
@@ -10927,7 +10927,7 @@ _0801555E:
ldr r1, _080155A0 @ =gUnknown_2023BE2
movs r0, 0
strb r0, [r1]
- ldr r1, _080155A4 @ =gUnknown_2023BE3
+ ldr r1, _080155A4 @ =gCurrentActionFuncId
ldr r0, _080155A8 @ =gUnknown_2023BDA
movs r3, 0
ldrb r0, [r0]
@@ -10957,7 +10957,7 @@ _08015598:
bx r0
.align 2, 0
_080155A0: .4byte gUnknown_2023BE2
-_080155A4: .4byte gUnknown_2023BE3
+_080155A4: .4byte gCurrentActionFuncId
_080155A8: .4byte gUnknown_2023BDA
_080155AC: .4byte gDynamicBasePower
_080155B0: .4byte gBattleStruct
@@ -10973,7 +10973,7 @@ RunTurnActionsFunctions: @ 80155C8
push {r4-r6,lr}
ldr r6, _0801561C @ =gBattleOutcome
ldrb r0, [r6]
- ldr r2, _08015620 @ =gUnknown_2023BE3
+ ldr r2, _08015620 @ =gCurrentActionFuncId
cmp r0, 0
beq _080155D8
movs r0, 0xC
@@ -11013,7 +11013,7 @@ _080155D8:
b _0801565C
.align 2, 0
_0801561C: .4byte gBattleOutcome
-_08015620: .4byte gUnknown_2023BE3
+_08015620: .4byte gCurrentActionFuncId
_08015624: .4byte gBattleStruct
_08015628: .4byte gUnknown_2023BE2
_0801562C: .4byte gUnknown_8250038
@@ -11048,7 +11048,7 @@ _0801566C: .4byte 0xfff7ffff
thumb_func_start sub_8015670
sub_8015670: @ 8015670
push {r4,lr}
- ldr r1, _080156A8 @ =gUnknown_2023BE3
+ ldr r1, _080156A8 @ =gCurrentActionFuncId
movs r0, 0
strb r0, [r1]
ldr r0, _080156AC @ =gBattleTypeFlags
@@ -11074,7 +11074,7 @@ sub_8015670: @ 8015670
strb r0, [r4]
b _0801576E
.align 2, 0
-_080156A8: .4byte gUnknown_2023BE3
+_080156A8: .4byte gCurrentActionFuncId
_080156AC: .4byte gBattleTypeFlags
_080156B0: .4byte gBattleTextBuff1
_080156B4: .4byte gBattleOutcome
@@ -11170,7 +11170,7 @@ _08015788: .4byte sub_8015910
thumb_func_start sub_801578C
sub_801578C: @ 801578C
push {r4,lr}
- ldr r1, _080157C4 @ =gUnknown_2023BE3
+ ldr r1, _080157C4 @ =gCurrentActionFuncId
movs r0, 0
strb r0, [r1]
ldr r0, _080157C8 @ =gBattleTypeFlags
@@ -11197,7 +11197,7 @@ sub_801578C: @ 801578C
strb r0, [r4]
b _08015830
.align 2, 0
-_080157C4: .4byte gUnknown_2023BE3
+_080157C4: .4byte gCurrentActionFuncId
_080157C8: .4byte gBattleTypeFlags
_080157CC: .4byte gBattleTextBuff1
_080157D0: .4byte gBattleOutcome
@@ -11263,7 +11263,7 @@ _0801584C: .4byte sub_8015910
thumb_func_start sub_8015850
sub_8015850: @ 8015850
push {lr}
- ldr r1, _08015878 @ =gUnknown_2023BE3
+ ldr r1, _08015878 @ =gCurrentActionFuncId
movs r0, 0
strb r0, [r1]
ldr r1, _0801587C @ =gProtectStructs
@@ -11282,7 +11282,7 @@ sub_8015850: @ 8015850
ldr r0, _08015888 @ =gUnknown_81D8916
b _080158A0
.align 2, 0
-_08015878: .4byte gUnknown_2023BE3
+_08015878: .4byte gCurrentActionFuncId
_0801587C: .4byte gProtectStructs
_08015880: .4byte gBattlerAttacker
_08015884: .4byte gBattlescriptCurrInstr
@@ -11313,7 +11313,7 @@ _080158B8: .4byte sub_8015910
thumb_func_start sub_80158BC
sub_80158BC: @ 80158BC
- ldr r1, _080158F0 @ =gUnknown_2023BE3
+ ldr r1, _080158F0 @ =gCurrentActionFuncId
movs r0, 0
strb r0, [r1]
ldr r1, _080158F4 @ =gBattleTextBuff1
@@ -11340,7 +11340,7 @@ sub_80158BC: @ 80158BC
str r0, [r1]
bx lr
.align 2, 0
-_080158F0: .4byte gUnknown_2023BE3
+_080158F0: .4byte gCurrentActionFuncId
_080158F4: .4byte gBattleTextBuff1
_080158F8: .4byte gBattlerAttacker
_080158FC: .4byte gBattlerPartyIndexes
@@ -11353,7 +11353,7 @@ _0801590C: .4byte sub_8015910
thumb_func_start sub_8015910
sub_8015910: @ 8015910
push {r4-r7,lr}
- ldr r0, _08015974 @ =gUnknown_2023BE3
+ ldr r0, _08015974 @ =gCurrentActionFuncId
ldrb r0, [r0]
subs r0, 0xB
lsls r0, 24
@@ -11401,7 +11401,7 @@ _08015942:
bl StringCopy
b _080159AA
.align 2, 0
-_08015974: .4byte gUnknown_2023BE3
+_08015974: .4byte gCurrentActionFuncId
_08015978: .4byte gBattleTypeFlags
_0801597C: .4byte 0x00080b92
_08015980: .4byte gActiveBattler
@@ -11464,7 +11464,7 @@ _08015A04:
ldr r0, [r0]
cmp r0, 0
bne _08015A1E
- ldr r1, _08015A28 @ =gUnknown_825011C
+ ldr r1, _08015A28 @ =gBattleScriptingCommandsTable
ldr r0, _08015A2C @ =gBattlescriptCurrInstr
ldr r0, [r0]
ldrb r0, [r0]
@@ -11478,7 +11478,7 @@ _08015A1E:
bx r0
.align 2, 0
_08015A24: .4byte gBattleControllerExecFlags
-_08015A28: .4byte gUnknown_825011C
+_08015A28: .4byte gBattleScriptingCommandsTable
_08015A2C: .4byte gBattlescriptCurrInstr
thumb_func_end sub_8015910
@@ -11708,7 +11708,7 @@ _08015BFC: .4byte gEnemyParty
thumb_func_start RunBattleScriptCommands_PopCallbacksStack
RunBattleScriptCommands_PopCallbacksStack: @ 8015C00
push {lr}
- ldr r0, _08015C3C @ =gUnknown_2023BE3
+ ldr r0, _08015C3C @ =gCurrentActionFuncId
ldrb r0, [r0]
subs r0, 0xB
lsls r0, 24
@@ -11738,7 +11738,7 @@ _08015C24:
str r0, [r2]
b _08015C62
.align 2, 0
-_08015C3C: .4byte gUnknown_2023BE3
+_08015C3C: .4byte gCurrentActionFuncId
_08015C40: .4byte gBattleResources
_08015C44: .4byte gBattleMainFunc
_08015C48:
@@ -11746,7 +11746,7 @@ _08015C48:
ldr r0, [r0]
cmp r0, 0
bne _08015C62
- ldr r1, _08015C6C @ =gUnknown_825011C
+ ldr r1, _08015C6C @ =gBattleScriptingCommandsTable
ldr r0, _08015C70 @ =gBattlescriptCurrInstr
ldr r0, [r0]
ldrb r0, [r0]
@@ -11759,18 +11759,18 @@ _08015C62:
bx r0
.align 2, 0
_08015C68: .4byte gBattleControllerExecFlags
-_08015C6C: .4byte gUnknown_825011C
+_08015C6C: .4byte gBattleScriptingCommandsTable
_08015C70: .4byte gBattlescriptCurrInstr
thumb_func_end RunBattleScriptCommands_PopCallbacksStack
- thumb_func_start sub_8015C74
-sub_8015C74: @ 8015C74
+ thumb_func_start RunBattleScriptCommands
+RunBattleScriptCommands: @ 8015C74
push {lr}
ldr r0, _08015C94 @ =gBattleControllerExecFlags
ldr r0, [r0]
cmp r0, 0
bne _08015C90
- ldr r1, _08015C98 @ =gUnknown_825011C
+ ldr r1, _08015C98 @ =gBattleScriptingCommandsTable
ldr r0, _08015C9C @ =gBattlescriptCurrInstr
ldr r0, [r0]
ldrb r0, [r0]
@@ -11783,9 +11783,9 @@ _08015C90:
bx r0
.align 2, 0
_08015C94: .4byte gBattleControllerExecFlags
-_08015C98: .4byte gUnknown_825011C
+_08015C98: .4byte gBattleScriptingCommandsTable
_08015C9C: .4byte gBattlescriptCurrInstr
- thumb_func_end sub_8015C74
+ thumb_func_end RunBattleScriptCommands
thumb_func_start sub_8015CA0
sub_8015CA0: @ 8015CA0
@@ -11817,7 +11817,7 @@ sub_8015CA0: @ 8015CA0
ands r2, r0
cmp r2, 0
beq _08015CF8
- ldr r1, _08015CF4 @ =gUnknown_2023BE3
+ ldr r1, _08015CF4 @ =gCurrentActionFuncId
movs r0, 0xC
b _0801634C
.align 2, 0
@@ -11826,7 +11826,7 @@ _08015CE4: .4byte gBattlerByTurnOrder
_08015CE8: .4byte gUnknown_2023BE2
_08015CEC: .4byte gBattleStruct
_08015CF0: .4byte gBitTable
-_08015CF4: .4byte gUnknown_2023BE3
+_08015CF4: .4byte gCurrentActionFuncId
_08015CF8:
ldr r1, _08015D6C @ =gCritMultiplier
movs r0, 0x1
@@ -11843,8 +11843,8 @@ _08015CF8:
strb r2, [r0]
ldr r0, _08015D7C @ =gBattleCommunication
strb r2, [r0, 0x6]
- ldr r2, _08015D80 @ =gUnknown_2023D48
- ldr r3, _08015D84 @ =gUnknown_2023D49
+ ldr r2, _08015D80 @ =gCurrMovePos
+ ldr r3, _08015D84 @ =gChosenMovePos
mov r9, r3
ldrb r0, [r6]
ldr r4, _08015D88 @ =gBattleStruct
@@ -11891,8 +11891,8 @@ _08015D70: .4byte gBattleScripting
_08015D74: .4byte gMoveResultFlags
_08015D78: .4byte gUnknown_2023D72
_08015D7C: .4byte gBattleCommunication
-_08015D80: .4byte gUnknown_2023D48
-_08015D84: .4byte gUnknown_2023D49
+_08015D80: .4byte gCurrMovePos
+_08015D84: .4byte gChosenMovePos
_08015D88: .4byte gBattleStruct
_08015D8C: .4byte gProtectStructs
_08015D90: .4byte gCurrentMove
@@ -12580,7 +12580,7 @@ _0801632C:
adds r0, r3
ldr r0, [r0]
str r0, [r4]
- ldr r1, _08016370 @ =gUnknown_2023BE3
+ ldr r1, _08016370 @ =gCurrentActionFuncId
movs r0, 0xA
_0801634C:
strb r0, [r1]
@@ -12597,7 +12597,7 @@ _08016360: .4byte gBattlescriptCurrInstr
_08016364: .4byte gUnknown_81D65A8
_08016368: .4byte gBattleMoves
_0801636C: .4byte gCurrentMove
-_08016370: .4byte gUnknown_2023BE3
+_08016370: .4byte gCurrentActionFuncId
thumb_func_end sub_8015CA0
thumb_func_start sub_8016374
@@ -12644,7 +12644,7 @@ sub_8016374: @ 8016374
ldr r1, _08016408 @ =gBattlescriptCurrInstr
ldr r0, _0801640C @ =gUnknown_81D894D
str r0, [r1]
- ldr r1, _08016410 @ =gUnknown_2023BE3
+ ldr r1, _08016410 @ =gCurrentActionFuncId
movs r0, 0xA
strb r0, [r1]
ldr r1, _08016414 @ =gBattleResults
@@ -12670,7 +12670,7 @@ _08016400: .4byte gBattleStruct
_08016404: .4byte gBattleScripting
_08016408: .4byte gBattlescriptCurrInstr
_0801640C: .4byte gUnknown_81D894D
-_08016410: .4byte gUnknown_2023BE3
+_08016410: .4byte gCurrentActionFuncId
_08016414: .4byte gBattleResults
thumb_func_end sub_8016374
@@ -12743,13 +12743,13 @@ _0801649C:
ldr r1, _080164BC @ =gUnknown_81D99FC
ldr r1, [r1]
str r1, [r0]
- ldr r1, _080164C0 @ =gUnknown_2023BE3
+ ldr r1, _080164C0 @ =gCurrentActionFuncId
mov r10, r1
b _0801671E
.align 2, 0
_080164B8: .4byte gBattlescriptCurrInstr
_080164BC: .4byte gUnknown_81D99FC
-_080164C0: .4byte gUnknown_2023BE3
+_080164C0: .4byte gCurrentActionFuncId
_080164C4:
movs r0, 0xAF
lsls r0, 1
@@ -12759,13 +12759,13 @@ _080164C4:
ldr r1, _080164E0 @ =gUnknown_81D99FC
ldr r1, [r1, 0x4]
str r1, [r0]
- ldr r2, _080164E4 @ =gUnknown_2023BE3
+ ldr r2, _080164E4 @ =gCurrentActionFuncId
mov r10, r2
b _0801671E
.align 2, 0
_080164DC: .4byte gBattlescriptCurrInstr
_080164E0: .4byte gUnknown_81D99FC
-_080164E4: .4byte gUnknown_2023BE3
+_080164E4: .4byte gCurrentActionFuncId
_080164E8:
ldrb r0, [r4]
bl GetBattlerSide
@@ -12777,13 +12777,13 @@ _080164E8:
ldr r1, [r1]
str r1, [r0]
_080164FC:
- ldr r0, _0801650C @ =gUnknown_2023BE3
+ ldr r0, _0801650C @ =gCurrentActionFuncId
mov r10, r0
b _0801671E
.align 2, 0
_08016504: .4byte gBattlescriptCurrInstr
_08016508: .4byte gUnknown_81D99E4
-_0801650C: .4byte gUnknown_2023BE3
+_0801650C: .4byte gCurrentActionFuncId
_08016510:
ldr r3, _08016548 @ =gBattleScripting
ldrb r0, [r4]
@@ -12802,7 +12802,7 @@ _08016510:
ldr r6, _08016554 @ =gUnknown_81D99E4
mov r12, r3
adds r7, r2, 0
- ldr r2, _08016558 @ =gUnknown_2023BE3
+ ldr r2, _08016558 @ =gCurrentActionFuncId
mov r10, r2
cmp r0, 0x4
bls _0801653C
@@ -12818,7 +12818,7 @@ _08016548: .4byte gBattleScripting
_0801654C: .4byte gBattleStruct
_08016550: .4byte gBattlescriptCurrInstr
_08016554: .4byte gUnknown_81D99E4
-_08016558: .4byte gUnknown_2023BE3
+_08016558: .4byte gCurrentActionFuncId
_0801655C: .4byte _08016560
.align 2, 0
_08016560:
@@ -12848,7 +12848,7 @@ _08016574:
ldr r1, _080165B4 @ =gBattlescriptCurrInstr
mov r9, r1
ldr r6, _080165B8 @ =gUnknown_81D99E4
- ldr r2, _080165BC @ =gUnknown_2023BE3
+ ldr r2, _080165BC @ =gCurrentActionFuncId
mov r10, r2
cmp r0, 0
bne _080165A6
@@ -12862,12 +12862,12 @@ _080165AC: .4byte gBattleCommunication
_080165B0: .4byte gBattlerAttacker
_080165B4: .4byte gBattlescriptCurrInstr
_080165B8: .4byte gUnknown_81D99E4
-_080165BC: .4byte gUnknown_2023BE3
+_080165BC: .4byte gCurrentActionFuncId
_080165C0:
ldr r0, _080165FC @ =gBattlescriptCurrInstr
mov r9, r0
ldr r6, _08016600 @ =gUnknown_81D99E4
- ldr r1, _08016604 @ =gUnknown_2023BE3
+ ldr r1, _08016604 @ =gCurrentActionFuncId
mov r10, r1
mov r4, r8
adds r3, r7, 0
@@ -12898,7 +12898,7 @@ _080165D0:
.align 2, 0
_080165FC: .4byte gBattlescriptCurrInstr
_08016600: .4byte gUnknown_81D99E4
-_08016604: .4byte gUnknown_2023BE3
+_08016604: .4byte gCurrentActionFuncId
_08016608:
ldr r3, _0801663C @ =gBattleCommunication
movs r0, 0x4
@@ -12923,7 +12923,7 @@ _08016608:
ldr r2, _08016644 @ =gBattlescriptCurrInstr
mov r9, r2
ldr r6, _08016648 @ =gUnknown_81D99E4
- ldr r0, _0801664C @ =gUnknown_2023BE3
+ ldr r0, _0801664C @ =gCurrentActionFuncId
mov r10, r0
b _08016706
.align 2, 0
@@ -12931,7 +12931,7 @@ _0801663C: .4byte gBattleCommunication
_08016640: .4byte gBattlerAttacker
_08016644: .4byte gBattlescriptCurrInstr
_08016648: .4byte gUnknown_81D99E4
-_0801664C: .4byte gUnknown_2023BE3
+_0801664C: .4byte gCurrentActionFuncId
_08016650:
ldr r3, _080166C4 @ =gBattleTextBuff1
movs r4, 0xFD
@@ -12955,7 +12955,7 @@ _08016650:
ldr r1, _080166CC @ =gBattlescriptCurrInstr
mov r9, r1
ldr r6, _080166D0 @ =gUnknown_81D99E4
- ldr r0, _080166D4 @ =gUnknown_2023BE3
+ ldr r0, _080166D4 @ =gCurrentActionFuncId
mov r10, r0
cmp r2, 0
bne _080166B4
@@ -12997,7 +12997,7 @@ _080166C4: .4byte gBattleTextBuff1
_080166C8: .4byte gBattleTextBuff2
_080166CC: .4byte gBattlescriptCurrInstr
_080166D0: .4byte gUnknown_81D99E4
-_080166D4: .4byte gUnknown_2023BE3
+_080166D4: .4byte gCurrentActionFuncId
_080166D8:
ldr r0, _080166EC @ =gBattleTypeFlags
ldr r1, [r0]
@@ -13021,7 +13021,7 @@ _080166F8:
ldr r1, _0801673C @ =gBattlescriptCurrInstr
mov r9, r1
ldr r6, _08016740 @ =gUnknown_81D99E4
- ldr r2, _08016744 @ =gUnknown_2023BE3
+ ldr r2, _08016744 @ =gCurrentActionFuncId
mov r10, r2
_08016706:
mov r1, r8
@@ -13052,7 +13052,7 @@ _08016734: .4byte gBattleCommunication
_08016738: .4byte gBattlerAttacker
_0801673C: .4byte gBattlescriptCurrInstr
_08016740: .4byte gUnknown_81D99E4
-_08016744: .4byte gUnknown_2023BE3
+_08016744: .4byte gCurrentActionFuncId
thumb_func_end sub_8016418
thumb_func_start sub_8016748
@@ -13328,14 +13328,14 @@ _0801694C:
ldr r1, _08016980 @ =gBattlescriptCurrInstr
ldr r0, _08016984 @ =gUnknown_81D893A
str r0, [r1]
- ldr r1, _08016988 @ =gUnknown_2023BE3
+ ldr r1, _08016988 @ =gCurrentActionFuncId
movs r0, 0xA
b _080169D6
.align 2, 0
_0801697C: .4byte gBattleCommunication
_08016980: .4byte gBattlescriptCurrInstr
_08016984: .4byte gUnknown_81D893A
-_08016988: .4byte gUnknown_2023BE3
+_08016988: .4byte gCurrentActionFuncId
_0801698C:
ldr r1, _080169B4 @ =gBattleMons
ldrb r2, [r4]
@@ -13354,7 +13354,7 @@ _0801698C:
ldr r1, _080169C0 @ =gBattlescriptCurrInstr
ldr r0, _080169C4 @ =gUnknown_81D893A
str r0, [r1]
- ldr r1, _080169C8 @ =gUnknown_2023BE3
+ ldr r1, _080169C8 @ =gCurrentActionFuncId
movs r0, 0xA
b _080169D6
.align 2, 0
@@ -13363,7 +13363,7 @@ _080169B8: .4byte 0x0400e000
_080169BC: .4byte gBattleCommunication
_080169C0: .4byte gBattlescriptCurrInstr
_080169C4: .4byte gUnknown_81D893A
-_080169C8: .4byte gUnknown_2023BE3
+_080169C8: .4byte gCurrentActionFuncId
_080169CC:
ldr r0, _080169E0 @ =gBattlersCount
ldrb r0, [r0]
@@ -13470,7 +13470,7 @@ _08016A9C:
ldr r0, _08016AB8 @ =gUnknown_81D9A04
ldr r0, [r0]
str r0, [r1]
- ldr r1, _08016ABC @ =gUnknown_2023BE3
+ ldr r1, _08016ABC @ =gCurrentActionFuncId
movs r0, 0xA
strb r0, [r1]
pop {r4,r5}
@@ -13480,7 +13480,7 @@ _08016A9C:
_08016AB0: .4byte gBattleCommunication
_08016AB4: .4byte gBattlescriptCurrInstr
_08016AB8: .4byte gUnknown_81D9A04
-_08016ABC: .4byte gUnknown_2023BE3
+_08016ABC: .4byte gCurrentActionFuncId
thumb_func_end sub_80169E8
thumb_func_start sub_8016AC0
@@ -13508,7 +13508,7 @@ sub_8016AC0: @ 8016AC0
ldr r0, _08016B18 @ =gUnknown_81D99B0
ldr r0, [r0, 0x14]
str r0, [r1]
- ldr r1, _08016B1C @ =gUnknown_2023BE3
+ ldr r1, _08016B1C @ =gCurrentActionFuncId
movs r0, 0xA
strb r0, [r1]
bx lr
@@ -13522,7 +13522,7 @@ _08016B0C: .4byte gNumSafariBalls
_08016B10: .4byte gLastUsedItem
_08016B14: .4byte gBattlescriptCurrInstr
_08016B18: .4byte gUnknown_81D99B0
-_08016B1C: .4byte gUnknown_2023BE3
+_08016B1C: .4byte gCurrentActionFuncId
thumb_func_end sub_8016AC0
thumb_func_start sub_8016B20
@@ -13582,7 +13582,7 @@ _08016B86:
ldr r0, _08016BB8 @ =gUnknown_81D9A04
ldr r0, [r0, 0x8]
str r0, [r1]
- ldr r1, _08016BBC @ =gUnknown_2023BE3
+ ldr r1, _08016BBC @ =gCurrentActionFuncId
movs r0, 0xA
strb r0, [r1]
pop {r4-r7}
@@ -13597,7 +13597,7 @@ _08016BAC: .4byte gBattle_BG0_Y
_08016BB0: .4byte gBattleStruct
_08016BB4: .4byte gBattlescriptCurrInstr
_08016BB8: .4byte gUnknown_81D9A04
-_08016BBC: .4byte gUnknown_2023BE3
+_08016BBC: .4byte gCurrentActionFuncId
thumb_func_end sub_8016B20
thumb_func_start sub_8016BC0
@@ -13657,7 +13657,7 @@ _08016C26:
ldr r0, _08016C58 @ =gUnknown_81D9A04
ldr r0, [r0, 0x4]
str r0, [r1]
- ldr r1, _08016C5C @ =gUnknown_2023BE3
+ ldr r1, _08016C5C @ =gCurrentActionFuncId
movs r0, 0xA
strb r0, [r1]
pop {r4-r7}
@@ -13672,7 +13672,7 @@ _08016C4C: .4byte gBattle_BG0_Y
_08016C50: .4byte gBattleStruct
_08016C54: .4byte gBattlescriptCurrInstr
_08016C58: .4byte gUnknown_81D9A04
-_08016C5C: .4byte gUnknown_2023BE3
+_08016C5C: .4byte gCurrentActionFuncId
thumb_func_end sub_8016BC0
thumb_func_start HandleAction_SafriZoneRun
@@ -13736,7 +13736,7 @@ HandleAction_Action9: @ 8016C9C
ldr r0, _08016D08 @ =gUnknown_81D9A04
ldr r0, [r0, 0xC]
str r0, [r1]
- ldr r1, _08016D0C @ =gUnknown_2023BE3
+ ldr r1, _08016D0C @ =gCurrentActionFuncId
movs r0, 0xA
strb r0, [r1]
ldr r1, _08016D10 @ =gUnknown_2023BDA
@@ -13753,7 +13753,7 @@ _08016CFC: .4byte gBattleTextBuff1
_08016D00: .4byte gBattlerPartyIndexes
_08016D04: .4byte gBattlescriptCurrInstr
_08016D08: .4byte gUnknown_81D9A04
-_08016D0C: .4byte gUnknown_2023BE3
+_08016D0C: .4byte gCurrentActionFuncId
_08016D10: .4byte gUnknown_2023BDA
thumb_func_end HandleAction_Action9
@@ -13769,7 +13769,7 @@ HandleAction_Action11: @ 8016D14
ldr r0, [r0]
adds r0, 0x4D
strb r1, [r0]
- ldr r1, _08016D38 @ =gUnknown_2023BE3
+ ldr r1, _08016D38 @ =gCurrentActionFuncId
movs r0, 0xC
strb r0, [r1]
_08016D30:
@@ -13777,7 +13777,7 @@ _08016D30:
bx r0
.align 2, 0
_08016D34: .4byte gBattleStruct
-_08016D38: .4byte gUnknown_2023BE3
+_08016D38: .4byte gCurrentActionFuncId
thumb_func_end HandleAction_Action11
thumb_func_start HandleAction_NothingIsFainted
@@ -13786,7 +13786,7 @@ HandleAction_NothingIsFainted: @ 8016D3C
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
- ldr r3, _08016D60 @ =gUnknown_2023BE3
+ ldr r3, _08016D60 @ =gCurrentActionFuncId
ldr r2, _08016D64 @ =gUnknown_2023BDA
ldrb r0, [r1]
adds r0, r2
@@ -13800,7 +13800,7 @@ HandleAction_NothingIsFainted: @ 8016D3C
bx lr
.align 2, 0
_08016D5C: .4byte gUnknown_2023BE2
-_08016D60: .4byte gUnknown_2023BE3
+_08016D60: .4byte gCurrentActionFuncId
_08016D64: .4byte gUnknown_2023BDA
_08016D68: .4byte gHitMarker
_08016D6C: .4byte 0xf1e892af
@@ -13813,7 +13813,7 @@ HandleAction_ActionFinished: @ 8016D70
ldrb r0, [r1]
adds r0, 0x1
strb r0, [r1]
- ldr r3, _08016DE8 @ =gUnknown_2023BE3
+ ldr r3, _08016DE8 @ =gCurrentActionFuncId
ldr r2, _08016DEC @ =gUnknown_2023BDA
ldrb r0, [r1]
adds r0, r2
@@ -13867,7 +13867,7 @@ HandleAction_ActionFinished: @ 8016D70
bx r0
.align 2, 0
_08016DE4: .4byte gUnknown_2023BE2
-_08016DE8: .4byte gUnknown_2023BE3
+_08016DE8: .4byte gCurrentActionFuncId
_08016DEC: .4byte gUnknown_2023BDA
_08016DF0: .4byte gHitMarker
_08016DF4: .4byte 0xf1e892af
diff --git a/asm/battle_script_commands.s b/asm/battle_script_commands.s
index 765eb317a..568f794d0 100644
--- a/asm/battle_script_commands.s
+++ b/asm/battle_script_commands.s
@@ -16,13 +16,13 @@ atk00_attackcanceler: @ 801D760
ldrb r0, [r0]
cmp r0, 0
beq _0801D784
- ldr r1, _0801D780 @ =gUnknown_2023BE3
+ ldr r1, _0801D780 @ =gCurrentActionFuncId
movs r0, 0xC
strb r0, [r1]
b _0801DAFC
.align 2, 0
_0801D77C: .4byte gBattleOutcome
-_0801D780: .4byte gUnknown_2023BE3
+_0801D780: .4byte gCurrentActionFuncId
_0801D784:
ldr r2, _0801D7B4 @ =gBattleMons
ldr r0, _0801D7B8 @ =gBattlerAttacker
@@ -74,7 +74,7 @@ _0801D7D6:
b _0801DAFC
_0801D7EE:
ldr r4, _0801D848 @ =gBattleMons
- ldr r0, _0801D84C @ =gUnknown_2023D48
+ ldr r0, _0801D84C @ =gCurrMovePos
ldrb r1, [r0]
ldr r3, _0801D850 @ =gBattlerAttacker
ldrb r2, [r3]
@@ -118,7 +118,7 @@ _0801D7EE:
.align 2, 0
_0801D844: .4byte gBattlerTarget
_0801D848: .4byte gBattleMons
-_0801D84C: .4byte gUnknown_2023D48
+_0801D84C: .4byte gCurrMovePos
_0801D850: .4byte gBattlerAttacker
_0801D854: .4byte gHitMarker
_0801D858: .4byte gCurrentMove
@@ -1433,7 +1433,7 @@ _0801E2E6:
cmp r4, 0
bne _0801E3CC
ldr r2, _0801E34C @ =gBattleMons
- ldr r3, _0801E354 @ =gUnknown_2023D48
+ ldr r3, _0801E354 @ =gCurrMovePos
ldr r1, _0801E358 @ =gBattlerAttacker
ldrb r5, [r1]
movs r0, 0x58
@@ -1478,7 +1478,7 @@ _0801E2E6:
_0801E348: .4byte gBattlerTarget
_0801E34C: .4byte gBattleMons
_0801E350: .4byte gHitMarker
-_0801E354: .4byte gUnknown_2023D48
+_0801E354: .4byte gCurrMovePos
_0801E358: .4byte gBattlerAttacker
_0801E35C: .4byte gProtectStructs
_0801E360:
@@ -3321,7 +3321,7 @@ _0801F186:
bcs _0801F1C4
ldrb r0, [r5]
movs r1, 0x27
- bl sub_80C7208
+ bl RecordItemEffectBattle
ldr r2, _0801F250 @ =gSpecialStatuses
ldrb r1, [r5]
lsls r0, r1, 2
@@ -3525,7 +3525,7 @@ _0801F336:
bcs _0801F374
ldrb r0, [r5]
movs r1, 0x27
- bl sub_80C7208
+ bl RecordItemEffectBattle
ldr r2, _0801F3E4 @ =gSpecialStatuses
ldrb r1, [r5]
lsls r0, r1, 2
@@ -10716,14 +10716,14 @@ atk3D_end: @ 8022CCC
strb r1, [r0]
ldr r0, _08022CE4 @ =gActiveBattler
strb r1, [r0]
- ldr r1, _08022CE8 @ =gUnknown_2023BE3
+ ldr r1, _08022CE8 @ =gCurrentActionFuncId
movs r0, 0xB
strb r0, [r1]
bx lr
.align 2, 0
_08022CE0: .4byte gMoveResultFlags
_08022CE4: .4byte gActiveBattler
-_08022CE8: .4byte gUnknown_2023BE3
+_08022CE8: .4byte gCurrentActionFuncId
thumb_func_end atk3D_end
thumb_func_start atk3E_end2
@@ -10731,13 +10731,13 @@ atk3E_end2: @ 8022CEC
ldr r1, _08022CFC @ =gActiveBattler
movs r0, 0
strb r0, [r1]
- ldr r1, _08022D00 @ =gUnknown_2023BE3
+ ldr r1, _08022D00 @ =gCurrentActionFuncId
movs r0, 0xB
strb r0, [r1]
bx lr
.align 2, 0
_08022CFC: .4byte gActiveBattler
-_08022D00: .4byte gUnknown_2023BE3
+_08022D00: .4byte gCurrentActionFuncId
thumb_func_end atk3E_end2
thumb_func_start atk3F_end3
@@ -16653,18 +16653,18 @@ atk63_jumptorandomattack: @ 8025C9C
cmp r1, 0
beq _08025CC0
ldr r0, _08025CB8 @ =gCurrentMove
- ldr r1, _08025CBC @ =gUnknown_2023D4E
+ ldr r1, _08025CBC @ =gCalledMove
ldrh r1, [r1]
strh r1, [r0]
b _08025CCE
.align 2, 0
_08025CB4: .4byte gBattlescriptCurrInstr
_08025CB8: .4byte gCurrentMove
-_08025CBC: .4byte gUnknown_2023D4E
+_08025CBC: .4byte gCalledMove
_08025CC0:
ldr r2, _08025CEC @ =gChosenMove
ldr r1, _08025CF0 @ =gCurrentMove
- ldr r0, _08025CF4 @ =gUnknown_2023D4E
+ ldr r0, _08025CF4 @ =gCalledMove
ldrh r0, [r0]
strh r0, [r1]
strh r0, [r2]
@@ -16688,7 +16688,7 @@ _08025CCE:
.align 2, 0
_08025CEC: .4byte gChosenMove
_08025CF0: .4byte gCurrentMove
-_08025CF4: .4byte gUnknown_2023D4E
+_08025CF4: .4byte gCalledMove
_08025CF8: .4byte gUnknown_81D65A8
_08025CFC: .4byte gBattleMoves
thumb_func_end atk63_jumptorandomattack
@@ -17102,7 +17102,7 @@ _0802602E:
bcs _0802606C
ldrb r0, [r5]
movs r1, 0x27
- bl sub_80C7208
+ bl RecordItemEffectBattle
ldr r2, _080260F8 @ =gSpecialStatuses
ldrb r1, [r5]
lsls r0, r1, 2
@@ -22294,7 +22294,7 @@ _0802895A:
bcs _08028998
ldrb r0, [r5]
movs r1, 0x27
- bl sub_80C7208
+ bl RecordItemEffectBattle
ldr r2, _080289DC @ =gSpecialStatuses
ldrb r1, [r5]
lsls r0, r1, 2
@@ -23875,7 +23875,7 @@ _08029628:
_08029646:
cmp r2, 0x4
bne _08029728
- ldr r5, _080296A0 @ =gUnknown_2023D48
+ ldr r5, _080296A0 @ =gCurrMovePos
ldrb r1, [r5]
lsls r1, 1
mov r2, r9
@@ -23917,7 +23917,7 @@ _08029646:
b _080296C4
.align 2, 0
_0802969C: .4byte gBattlescriptCurrInstr
-_080296A0: .4byte gUnknown_2023D48
+_080296A0: .4byte gCurrMovePos
_080296A4: .4byte gLastMoves
_080296A8: .4byte gBattlerTarget
_080296AC: .4byte gBattleMoves
@@ -25184,7 +25184,7 @@ _0802A08A:
beq _0802A090
b _0802A190
_0802A090:
- ldr r4, _0802A17C @ =gUnknown_2023D48
+ ldr r4, _0802A17C @ =gCurrMovePos
ldrb r1, [r4]
lsls r1, 1
mov r2, r10
@@ -25296,7 +25296,7 @@ _0802A16C: .4byte gBattleMons
_0802A170: .4byte gBattlerAttacker
_0802A174: .4byte gUnknown_2023D90
_0802A178: .4byte gBattlerTarget
-_0802A17C: .4byte gUnknown_2023D48
+_0802A17C: .4byte gCurrMovePos
_0802A180: .4byte gBattleMoves
_0802A184: .4byte gActiveBattler
_0802A188: .4byte gBattleTextBuff1
@@ -25541,7 +25541,7 @@ _0802A334:
ands r0, r6
cmp r0, 0
bne _0802A334
- ldr r4, _0802A3A8 @ =gUnknown_2023D4E
+ ldr r4, _0802A3A8 @ =gCalledMove
ldr r2, _0802A3AC @ =gBattleMons
lsls r1, r5, 1
ldr r0, _0802A3B0 @ =gBattlerAttacker
@@ -25553,7 +25553,7 @@ _0802A334:
adds r1, r2
ldrh r0, [r1]
strh r0, [r4]
- ldr r0, _0802A3B4 @ =gUnknown_2023D48
+ ldr r0, _0802A3B4 @ =gCurrMovePos
strb r5, [r0]
ldr r2, _0802A3B8 @ =gHitMarker
ldr r0, [r2]
@@ -25588,10 +25588,10 @@ _0802A394:
bx r0
.align 2, 0
_0802A3A4: .4byte gBitTable
-_0802A3A8: .4byte gUnknown_2023D4E
+_0802A3A8: .4byte gCalledMove
_0802A3AC: .4byte gBattleMons
_0802A3B0: .4byte gBattlerAttacker
-_0802A3B4: .4byte gUnknown_2023D48
+_0802A3B4: .4byte gCurrMovePos
_0802A3B8: .4byte gHitMarker
_0802A3BC: .4byte 0xfffffbff
_0802A3C0: .4byte gBattlerTarget
@@ -27392,9 +27392,9 @@ _0802B1A2:
ldr r0, _0802B280 @ =gBattlersCount
ldr r2, _0802B284 @ =gCurrentMove
mov r8, r2
- ldr r7, _0802B288 @ =gUnknown_2023D48
+ ldr r7, _0802B288 @ =gCurrMovePos
mov r10, r7
- ldr r2, _0802B28C @ =gUnknown_2023D49
+ ldr r2, _0802B28C @ =gChosenMovePos
mov r9, r2
ldr r7, _0802B290 @ =gHitMarker
mov r12, r7
@@ -27457,8 +27457,8 @@ _0802B278: .4byte gDisableStructs
_0802B27C: .4byte gChosenMoveByBattler
_0802B280: .4byte gBattlersCount
_0802B284: .4byte gCurrentMove
-_0802B288: .4byte gUnknown_2023D48
-_0802B28C: .4byte gUnknown_2023D49
+_0802B288: .4byte gCurrMovePos
+_0802B28C: .4byte gChosenMovePos
_0802B290: .4byte gHitMarker
_0802B294: .4byte gBattlerByTurnOrder
_0802B298: .4byte gUnknown_2023BDA
@@ -30496,7 +30496,7 @@ _0802CA3C:
ldr r1, _0802CAA4 @ =0xfffffbff
ands r0, r1
str r0, [r2]
- ldr r4, _0802CAA8 @ =gUnknown_2023D4E
+ ldr r4, _0802CAA8 @ =gCalledMove
bl Random
movs r1, 0xFF
ands r1, r0
@@ -30528,7 +30528,7 @@ _0802CA98: .4byte 0x0000ffff
_0802CA9C: .4byte gUnknown_82507E8
_0802CAA0: .4byte gHitMarker
_0802CAA4: .4byte 0xfffffbff
-_0802CAA8: .4byte gUnknown_2023D4E
+_0802CAA8: .4byte gCalledMove
_0802CAAC: .4byte gBattlerTarget
_0802CAB0: .4byte gBattlescriptCurrInstr
_0802CAB4:
@@ -33169,17 +33169,17 @@ _0802E010: .4byte gBattlescriptCurrInstr
thumb_func_start sub_802E014
sub_802E014: @ 802E014
- ldr r1, _0802E01C @ =gUnknown_2023BE3
+ ldr r1, _0802E01C @ =gCurrentActionFuncId
movs r0, 0xC
strb r0, [r1]
bx lr
.align 2, 0
-_0802E01C: .4byte gUnknown_2023BE3
+_0802E01C: .4byte gCurrentActionFuncId
thumb_func_end sub_802E014
thumb_func_start sub_802E020
sub_802E020: @ 802E020
- ldr r1, _0802E030 @ =gUnknown_2023BE3
+ ldr r1, _0802E030 @ =gCurrentActionFuncId
movs r0, 0xC
strb r0, [r1]
ldr r1, _0802E034 @ =gUnknown_2023BE2
@@ -33188,7 +33188,7 @@ sub_802E020: @ 802E020
strb r0, [r1]
bx lr
.align 2, 0
-_0802E030: .4byte gUnknown_2023BE3
+_0802E030: .4byte gCurrentActionFuncId
_0802E034: .4byte gUnknown_2023BE2
_0802E038: .4byte gBattlersCount
thumb_func_end sub_802E020
diff --git a/asm/battle_util.s b/asm/battle_util.s
deleted file mode 100644
index a6b77a6e4..000000000
--- a/asm/battle_util.s
+++ /dev/null
@@ -1,3283 +0,0 @@
- .include "asm/macros.inc"
- .include "constants/constants.inc"
-
- .syntax unified
-
- .text
-
- thumb_func_start BattleScriptExecute
-BattleScriptExecute: @ 801BBE4
- ldr r1, _0801BC10 @ =gBattlescriptCurrInstr
- str r0, [r1]
- ldr r0, _0801BC14 @ =gBattleResources
- ldr r0, [r0]
- ldr r2, [r0, 0xC]
- adds r3, r2, 0
- adds r3, 0x20
- ldrb r0, [r3]
- adds r1, r0, 0x1
- strb r1, [r3]
- lsls r0, 24
- lsrs r0, 22
- adds r2, r0
- ldr r1, _0801BC18 @ =gBattleMainFunc
- ldr r0, [r1]
- str r0, [r2]
- ldr r0, _0801BC1C @ =RunBattleScriptCommands_PopCallbacksStack
- str r0, [r1]
- ldr r1, _0801BC20 @ =gUnknown_2023BE3
- movs r0, 0
- strb r0, [r1]
- bx lr
- .align 2, 0
-_0801BC10: .4byte gBattlescriptCurrInstr
-_0801BC14: .4byte gBattleResources
-_0801BC18: .4byte gBattleMainFunc
-_0801BC1C: .4byte RunBattleScriptCommands_PopCallbacksStack
-_0801BC20: .4byte gUnknown_2023BE3
- thumb_func_end BattleScriptExecute
-
- thumb_func_start BattleScriptPushCursorAndCallback
-BattleScriptPushCursorAndCallback: @ 801BC24
- push {r4,lr}
- adds r4, r0, 0
- bl BattleScriptPushCursor
- ldr r0, _0801BC58 @ =gBattlescriptCurrInstr
- str r4, [r0]
- ldr r0, _0801BC5C @ =gBattleResources
- ldr r0, [r0]
- ldr r2, [r0, 0xC]
- adds r3, r2, 0
- adds r3, 0x20
- ldrb r0, [r3]
- adds r1, r0, 0x1
- strb r1, [r3]
- lsls r0, 24
- lsrs r0, 22
- adds r2, r0
- ldr r1, _0801BC60 @ =gBattleMainFunc
- ldr r0, [r1]
- str r0, [r2]
- ldr r0, _0801BC64 @ =sub_8015C74
- str r0, [r1]
- pop {r4}
- pop {r0}
- bx r0
- .align 2, 0
-_0801BC58: .4byte gBattlescriptCurrInstr
-_0801BC5C: .4byte gBattleResources
-_0801BC60: .4byte gBattleMainFunc
-_0801BC64: .4byte sub_8015C74
- thumb_func_end BattleScriptPushCursorAndCallback
-
- thumb_func_start ItemBattleEffects
-ItemBattleEffects: @ 801BC68
- push {r4-r7,lr}
- mov r7, r10
- mov r6, r9
- mov r5, r8
- push {r5-r7}
- sub sp, 0x2C
- lsls r0, 24
- lsrs r0, 24
- str r0, [sp, 0x8]
- lsls r1, 24
- lsrs r7, r1, 24
- lsls r2, 24
- lsrs r6, r2, 24
- movs r0, 0
- mov r10, r0
- movs r1, 0
- str r1, [sp, 0xC]
- add r0, sp, 0x4
- strb r1, [r0]
- ldr r4, _0801BCB4 @ =gLastUsedItem
- ldr r1, _0801BCB8 @ =gBattleMons
- movs r0, 0x58
- muls r0, r7
- adds r0, r1
- ldrh r0, [r0, 0x2E]
- strh r0, [r4]
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0xAF
- bne _0801BCC0
- ldr r1, _0801BCBC @ =gEnigmaBerries
- lsls r0, r7, 3
- subs r0, r7
- lsls r0, 2
- adds r0, r1
- ldrb r5, [r0, 0x7]
- ldrb r0, [r0, 0x1A]
- b _0801BCD4
- .align 2, 0
-_0801BCB4: .4byte gLastUsedItem
-_0801BCB8: .4byte gBattleMons
-_0801BCBC: .4byte gEnigmaBerries
-_0801BCC0:
- ldrh r0, [r4]
- bl ItemId_GetHoldEffect
- lsls r0, 24
- lsrs r5, r0, 24
- ldrh r0, [r4]
- bl ItemId_GetHoldEffectParam
- lsls r0, 24
- lsrs r0, 24
-_0801BCD4:
- mov r9, r0
- ldr r1, _0801BCFC @ =gBattleMons
- ldr r0, _0801BD00 @ =gBattlerAttacker
- ldrb r2, [r0]
- movs r0, 0x58
- muls r0, r2
- adds r0, r1
- ldrh r0, [r0, 0x2E]
- str r0, [sp, 0x14]
- cmp r0, 0xAF
- bne _0801BD08
- ldr r1, _0801BD04 @ =gEnigmaBerries
- lsls r0, r2, 3
- subs r0, r2
- lsls r0, 2
- adds r0, r1
- ldrb r3, [r0, 0x7]
- mov r8, r3
- ldrb r0, [r0, 0x1A]
- b _0801BD1E
- .align 2, 0
-_0801BCFC: .4byte gBattleMons
-_0801BD00: .4byte gBattlerAttacker
-_0801BD04: .4byte gEnigmaBerries
-_0801BD08:
- ldr r0, [sp, 0x14]
- bl ItemId_GetHoldEffect
- lsls r0, 24
- lsrs r0, 24
- mov r8, r0
- ldr r0, [sp, 0x14]
- bl ItemId_GetHoldEffectParam
- lsls r0, 24
- lsrs r0, 24
-_0801BD1E:
- str r0, [sp, 0x10]
- ldr r2, _0801BD54 @ =gBattleMons
- ldr r0, _0801BD58 @ =gBattlerTarget
- ldrb r1, [r0]
- movs r0, 0x58
- muls r0, r1
- adds r0, r2
- ldrh r4, [r0, 0x2E]
- cmp r4, 0xAF
- beq _0801BD3E
- adds r0, r4, 0
- bl ItemId_GetHoldEffect
- adds r0, r4, 0
- bl ItemId_GetHoldEffectParam
-_0801BD3E:
- ldr r0, [sp, 0x8]
- cmp r0, 0x4
- bls _0801BD48
- bl _0801CFA6
-_0801BD48:
- lsls r0, 2
- ldr r1, _0801BD5C @ =_0801BD60
- adds r0, r1
- ldr r0, [r0]
- mov pc, r0
- .align 2, 0
-_0801BD54: .4byte gBattleMons
-_0801BD58: .4byte gBattlerTarget
-_0801BD5C: .4byte _0801BD60
- .align 2, 0
-_0801BD60:
- .4byte _0801BD74
- .4byte _0801BE04
- .4byte _0801CFA6
- .4byte _0801C9FC
- .4byte _0801CE4C
-_0801BD74:
- cmp r5, 0x17
- beq _0801BD94
- cmp r5, 0x20
- beq _0801BD80
- bl _0801CFA6
-_0801BD80:
- ldr r0, _0801BD90 @ =gBattleStruct
- ldr r0, [r0]
- adds r0, 0x4A
- movs r1, 0x2
- strb r1, [r0]
- bl _0801CFA6
- .align 2, 0
-_0801BD90: .4byte gBattleStruct
-_0801BD94:
- ldr r1, _0801BDEC @ =gBattleMons
- mov r8, r1
- movs r0, 0x58
- adds r1, r7, 0
- muls r1, r0
- mov r0, r8
- adds r0, 0x18
- adds r1, r0
- movs r2, 0x6
- movs r3, 0x7
- mov r10, r3
-_0801BDAA:
- movs r0, 0
- ldrsb r0, [r1, r0]
- cmp r0, 0x5
- bgt _0801BDB8
- strb r2, [r1]
- movs r5, 0x5
- str r5, [sp, 0xC]
-_0801BDB8:
- adds r1, 0x1
- movs r0, 0x1
- negs r0, r0
- add r10, r0
- mov r3, r10
- cmp r3, 0
- bge _0801BDAA
- ldr r5, [sp, 0xC]
- cmp r5, 0
- bne _0801BDD0
- bl _0801CFA6
-_0801BDD0:
- ldr r0, _0801BDF0 @ =gBattleScripting
- strb r7, [r0, 0x17]
- ldr r0, _0801BDF4 @ =gPotentialItemEffectBattler
- strb r7, [r0]
- ldr r1, _0801BDF8 @ =gActiveBattler
- ldr r0, _0801BDFC @ =gBattlerAttacker
- strb r7, [r0]
- strb r7, [r1]
- ldr r0, _0801BE00 @ =BattleScript_WhiteHerbEnd2
- bl BattleScriptExecute
- bl _0801CFA6
- .align 2, 0
-_0801BDEC: .4byte gBattleMons
-_0801BDF0: .4byte gBattleScripting
-_0801BDF4: .4byte gPotentialItemEffectBattler
-_0801BDF8: .4byte gActiveBattler
-_0801BDFC: .4byte gBattlerAttacker
-_0801BE00: .4byte BattleScript_WhiteHerbEnd2
-_0801BE04:
- ldr r1, _0801BE2C @ =gBattleMons
- movs r0, 0x58
- muls r0, r7
- adds r0, r1
- ldrh r0, [r0, 0x28]
- mov r8, r1
- cmp r0, 0
- bne _0801BE18
- bl _0801CFA6
-_0801BE18:
- subs r0, r5, 0x1
- cmp r0, 0x2A
- bls _0801BE22
- bl _0801C952
-_0801BE22:
- lsls r0, 2
- ldr r1, _0801BE30 @ =_0801BE34
- adds r0, r1
- ldr r0, [r0]
- mov pc, r0
- .align 2, 0
-_0801BE2C: .4byte gBattleMons
-_0801BE30: .4byte _0801BE34
- .align 2, 0
-_0801BE34:
- .4byte _0801BEE0
- .4byte _0801C6C0
- .4byte _0801C784
- .4byte _0801C6F0
- .4byte _0801C724
- .4byte _0801C754
- .4byte _0801BF2C
- .4byte _0801C7C0
- .4byte _0801C7F0
- .4byte _0801C0F8
- .4byte _0801C178
- .4byte _0801C1F4
- .4byte _0801C288
- .4byte _0801C31C
- .4byte _0801C3B0
- .4byte _0801C418
- .4byte _0801C46C
- .4byte _0801C4C0
- .4byte _0801C528
- .4byte _0801C58C
- .4byte _0801C5D8
- .4byte _0801C952
- .4byte _0801C02C
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C91C
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C952
- .4byte _0801C098
-_0801BEE0:
- movs r0, 0x58
- muls r0, r7
- mov r1, r8
- adds r2, r0, r1
- ldrh r0, [r2, 0x2C]
- ldrh r1, [r2, 0x28]
- lsrs r0, 1
- cmp r1, r0
- bls _0801BEF6
- bl _0801C952
-_0801BEF6:
- cmp r6, 0
- beq _0801BEFE
- bl _0801C952
-_0801BEFE:
- ldr r4, _0801BF24 @ =gBattleMoveDamage
- mov r3, r9
- str r3, [r4]
- ldrh r3, [r2, 0x28]
- mov r5, r9
- adds r0, r3, r5
- ldrh r1, [r2, 0x2C]
- cmp r0, r1
- ble _0801BF14
- subs r0, r1, r3
- str r0, [r4]
-_0801BF14:
- ldr r0, [r4]
- negs r0, r0
- str r0, [r4]
- ldr r0, _0801BF28 @ =BattleScript_ItemHealHP_RemoveItem
- bl BattleScriptExecute
- b _0801C27E
- .align 2, 0
-_0801BF24: .4byte gBattleMoveDamage
-_0801BF28: .4byte BattleScript_ItemHealHP_RemoveItem
-_0801BF2C:
- cmp r6, 0
- beq _0801BF34
- bl _0801C952
-_0801BF34:
- adds r0, r7, 0
- bl GetBattlerSide
- lsls r0, 24
- cmp r0, 0
- bne _0801BF58
- ldr r1, _0801BF50 @ =gBattlerPartyIndexes
- lsls r0, r7, 1
- adds r0, r1
- ldrh r1, [r0]
- movs r0, 0x64
- muls r1, r0
- ldr r0, _0801BF54 @ =gPlayerParty
- b _0801BF66
- .align 2, 0
-_0801BF50: .4byte gBattlerPartyIndexes
-_0801BF54: .4byte gPlayerParty
-_0801BF58:
- ldr r1, _0801BFD4 @ =gBattlerPartyIndexes
- lsls r0, r7, 1
- adds r0, r1
- ldrh r1, [r0]
- movs r0, 0x64
- muls r1, r0
- ldr r0, _0801BFD8 @ =gEnemyParty
-_0801BF66:
- adds r4, r1, r0
- movs r1, 0
- mov r10, r1
- add r5, sp, 0x4
-_0801BF6E:
- mov r1, r10
- adds r1, 0xD
- adds r0, r4, 0
- bl GetMonData
- lsls r0, 16
- lsrs r6, r0, 16
- mov r1, r10
- adds r1, 0x11
- adds r0, r4, 0
- bl GetMonData
- strb r0, [r5]
- adds r0, r4, 0
- movs r1, 0x15
- bl GetMonData
- lsls r0, 24
- lsrs r1, r0, 24
- cmp r6, 0
- beq _0801BF9E
- ldrb r0, [r5]
- cmp r0, 0
- beq _0801BFA8
-_0801BF9E:
- movs r2, 0x1
- add r10, r2
- mov r3, r10
- cmp r3, 0x3
- ble _0801BF6E
-_0801BFA8:
- mov r5, r10
- cmp r5, 0x4
- bne _0801BFB2
- bl _0801C952
-_0801BFB2:
- lsls r2, r5, 24
- lsrs r2, 24
- adds r0, r6, 0
- bl CalculatePPWithBonus
- lsls r0, 24
- lsrs r2, r0, 24
- add r0, sp, 0x4
- ldrb r0, [r0]
- mov r3, r9
- adds r1, r0, r3
- cmp r1, r2
- ble _0801BFDC
- add r0, sp, 0x4
- strb r2, [r0]
- b _0801BFE0
- .align 2, 0
-_0801BFD4: .4byte gBattlerPartyIndexes
-_0801BFD8: .4byte gEnemyParty
-_0801BFDC:
- add r0, sp, 0x4
- strb r1, [r0]
-_0801BFE0:
- ldr r1, _0801C020 @ =gBattleTextBuff1
- movs r0, 0xFD
- strb r0, [r1]
- movs r0, 0x2
- strb r0, [r1, 0x1]
- strb r6, [r1, 0x2]
- lsrs r0, r6, 8
- strb r0, [r1, 0x3]
- movs r0, 0xFF
- strb r0, [r1, 0x4]
- ldr r0, _0801C024 @ =BattleScript_BerryPPHealEnd2
- bl BattleScriptExecute
- mov r1, r10
- adds r1, 0x9
- lsls r1, 24
- lsrs r1, 24
- add r5, sp, 0x4
- str r5, [sp]
- movs r0, 0
- movs r2, 0
- movs r3, 0x1
- bl BtlController_EmitSetMonData
- ldr r0, _0801C028 @ =gActiveBattler
- ldrb r0, [r0]
- bl MarkBattlerForControllerExec
- movs r0, 0x3
- str r0, [sp, 0xC]
- bl _0801C95A
- .align 2, 0
-_0801C020: .4byte gBattleTextBuff1
-_0801C024: .4byte BattleScript_BerryPPHealEnd2
-_0801C028: .4byte gActiveBattler
-_0801C02C:
- ldr r0, _0801C080 @ =gBattleMons
- movs r1, 0x58
- muls r1, r7
- adds r0, 0x18
- adds r1, r0
- movs r2, 0x6
- movs r3, 0x7
- mov r10, r3
-_0801C03C:
- movs r0, 0
- ldrsb r0, [r1, r0]
- cmp r0, 0x5
- bgt _0801C04A
- strb r2, [r1]
- movs r5, 0x5
- str r5, [sp, 0xC]
-_0801C04A:
- adds r1, 0x1
- movs r0, 0x1
- negs r0, r0
- add r10, r0
- mov r3, r10
- cmp r3, 0
- bge _0801C03C
- movs r5, 0x8
- mov r10, r5
- ldr r0, [sp, 0xC]
- cmp r0, 0
- bne _0801C066
- bl _0801CFA6
-_0801C066:
- ldr r0, _0801C084 @ =gBattleScripting
- strb r7, [r0, 0x17]
- ldr r0, _0801C088 @ =gPotentialItemEffectBattler
- strb r7, [r0]
- ldr r1, _0801C08C @ =gActiveBattler
- ldr r0, _0801C090 @ =gBattlerAttacker
- strb r7, [r0]
- strb r7, [r1]
- ldr r0, _0801C094 @ =BattleScript_WhiteHerbEnd2
- bl BattleScriptExecute
- bl _0801C952
- .align 2, 0
-_0801C080: .4byte gBattleMons
-_0801C084: .4byte gBattleScripting
-_0801C088: .4byte gPotentialItemEffectBattler
-_0801C08C: .4byte gActiveBattler
-_0801C090: .4byte gBattlerAttacker
-_0801C094: .4byte BattleScript_WhiteHerbEnd2
-_0801C098:
- movs r0, 0x58
- muls r0, r7
- mov r2, r8
- adds r1, r0, r2
- ldrh r0, [r1, 0x28]
- ldrh r3, [r1, 0x2C]
- cmp r0, r3
- bcc _0801C0AC
- bl _0801C952
-_0801C0AC:
- cmp r6, 0
- beq _0801C0B4
- bl _0801C952
-_0801C0B4:
- ldr r3, _0801C0F0 @ =gBattleMoveDamage
- ldrh r0, [r1, 0x2C]
- lsrs r0, 4
- str r0, [r3]
- cmp r0, 0
- bne _0801C0C4
- movs r0, 0x1
- str r0, [r3]
-_0801C0C4:
- ldrh r2, [r1, 0x28]
- ldr r0, [r3]
- adds r0, r2, r0
- ldrh r1, [r1, 0x2C]
- cmp r0, r1
- ble _0801C0D4
- subs r0, r1, r2
- str r0, [r3]
-_0801C0D4:
- ldr r0, [r3]
- negs r0, r0
- str r0, [r3]
- ldr r0, _0801C0F4 @ =BattleScript_ItemHealHP_End2
- bl BattleScriptExecute
- movs r0, 0x4
- str r0, [sp, 0xC]
- adds r0, r7, 0
- adds r1, r5, 0
- bl sub_80C7208
- bl _0801C952
- .align 2, 0
-_0801C0F0: .4byte gBattleMoveDamage
-_0801C0F4: .4byte BattleScript_ItemHealHP_End2
-_0801C0F8:
- movs r0, 0x58
- adds r1, r7, 0
- muls r1, r0
- str r1, [sp, 0x18]
- adds r4, r1, 0
- add r4, r8
- ldrh r0, [r4, 0x2C]
- ldrh r1, [r4, 0x28]
- lsrs r0, 1
- cmp r1, r0
- bls _0801C112
- bl _0801C952
-_0801C112:
- cmp r6, 0
- beq _0801C11A
- bl _0801C952
-_0801C11A:
- ldr r1, _0801C170 @ =gBattleTextBuff1
- movs r0, 0xFD
- strb r0, [r1]
- movs r0, 0x8
- strb r0, [r1, 0x1]
- strb r6, [r1, 0x2]
- movs r0, 0xFF
- strb r0, [r1, 0x3]
- ldr r5, _0801C174 @ =gBattleMoveDamage
- ldrh r0, [r4, 0x2C]
- mov r1, r9
- bl __divsi3
- str r0, [r5]
- cmp r0, 0
- bne _0801C13E
- movs r0, 0x1
- str r0, [r5]
-_0801C13E:
- ldrh r2, [r4, 0x28]
- ldr r0, [r5]
- adds r0, r2, r0
- ldrh r1, [r4, 0x2C]
- cmp r0, r1
- ble _0801C14E
- subs r0, r1, r2
- str r0, [r5]
-_0801C14E:
- ldr r0, [r5]
- negs r0, r0
- str r0, [r5]
- mov r0, r8
- adds r0, 0x48
- ldr r2, [sp, 0x18]
- adds r0, r2, r0
- ldr r0, [r0]
- movs r1, 0
- bl GetFlavorRelationByPersonality
- lsls r0, 24
- cmp r0, 0
- bge _0801C16C
- b _0801C2F8
-_0801C16C:
- b _0801C30C
- .align 2, 0
-_0801C170: .4byte gBattleTextBuff1
-_0801C174: .4byte gBattleMoveDamage
-_0801C178:
- movs r0, 0x58
- adds r5, r7, 0
- muls r5, r0
- str r5, [sp, 0x1C]
- add r5, r8
- ldrh r0, [r5, 0x2C]
- ldrh r1, [r5, 0x28]
- lsrs r0, 1
- cmp r1, r0
- bls _0801C190
- bl _0801C952
-_0801C190:
- cmp r6, 0
- beq _0801C198
- bl _0801C952
-_0801C198:
- ldr r1, _0801C1EC @ =gBattleTextBuff1
- movs r0, 0xFD
- strb r0, [r1]
- movs r0, 0x8
- strb r0, [r1, 0x1]
- movs r6, 0x1
- strb r6, [r1, 0x2]
- movs r0, 0xFF
- strb r0, [r1, 0x3]
- ldr r4, _0801C1F0 @ =gBattleMoveDamage
- ldrh r0, [r5, 0x2C]
- mov r1, r9
- bl __divsi3
- str r0, [r4]
- cmp r0, 0
- bne _0801C1BC
- str r6, [r4]
-_0801C1BC:
- ldrh r2, [r5, 0x28]
- ldr r0, [r4]
- adds r0, r2, r0
- ldrh r1, [r5, 0x2C]
- cmp r0, r1
- ble _0801C1CC
- subs r0, r1, r2
- str r0, [r4]
-_0801C1CC:
- ldr r0, [r4]
- negs r0, r0
- str r0, [r4]
- mov r0, r8
- adds r0, 0x48
- ldr r1, [sp, 0x1C]
- adds r0, r1, r0
- ldr r0, [r0]
- movs r1, 0x1
- bl GetFlavorRelationByPersonality
- lsls r0, 24
- cmp r0, 0
- bge _0801C1EA
- b _0801C38A
-_0801C1EA:
- b _0801C3A0
- .align 2, 0
-_0801C1EC: .4byte gBattleTextBuff1
-_0801C1F0: .4byte gBattleMoveDamage
-_0801C1F4:
- movs r0, 0x58
- adds r3, r7, 0
- muls r3, r0
- str r3, [sp, 0x20]
- adds r5, r3, 0
- add r5, r8
- ldrh r0, [r5, 0x2C]
- ldrh r1, [r5, 0x28]
- lsrs r0, 1
- cmp r1, r0
- bls _0801C20C
- b _0801C952
-_0801C20C:
- cmp r6, 0
- beq _0801C212
- b _0801C952
-_0801C212:
- ldr r1, _0801C26C @ =gBattleTextBuff1
- movs r0, 0xFD
- strb r0, [r1]
- movs r0, 0x8
- strb r0, [r1, 0x1]
- movs r0, 0x2
- strb r0, [r1, 0x2]
- movs r0, 0xFF
- strb r0, [r1, 0x3]
- ldr r4, _0801C270 @ =gBattleMoveDamage
- ldrh r0, [r5, 0x2C]
- mov r1, r9
- bl __divsi3
- str r0, [r4]
- cmp r0, 0
- bne _0801C238
- movs r0, 0x1
- str r0, [r4]
-_0801C238:
- ldrh r2, [r5, 0x28]
- ldr r0, [r4]
- adds r0, r2, r0
- ldrh r1, [r5, 0x2C]
- cmp r0, r1
- ble _0801C248
- subs r0, r1, r2
- str r0, [r4]
-_0801C248:
- ldr r0, [r4]
- negs r0, r0
- str r0, [r4]
- mov r0, r8
- adds r0, 0x48
- ldr r5, [sp, 0x20]
- adds r0, r5, r0
- ldr r0, [r0]
- movs r1, 0x2
- bl GetFlavorRelationByPersonality
- lsls r0, 24
- cmp r0, 0
- bge _0801C278
- ldr r0, _0801C274 @ =BattleScript_BerryConfuseHealEnd2
- bl BattleScriptExecute
- b _0801C27E
- .align 2, 0
-_0801C26C: .4byte gBattleTextBuff1
-_0801C270: .4byte gBattleMoveDamage
-_0801C274: .4byte BattleScript_BerryConfuseHealEnd2
-_0801C278:
- ldr r0, _0801C284 @ =BattleScript_ItemHealHP_RemoveItem
- bl BattleScriptExecute
-_0801C27E:
- movs r0, 0x4
- str r0, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C284: .4byte BattleScript_ItemHealHP_RemoveItem
-_0801C288:
- movs r0, 0x58
- adds r1, r7, 0
- muls r1, r0
- str r1, [sp, 0x24]
- adds r5, r1, 0
- add r5, r8
- ldrh r0, [r5, 0x2C]
- ldrh r1, [r5, 0x28]
- lsrs r0, 1
- cmp r1, r0
- bls _0801C2A0
- b _0801C952
-_0801C2A0:
- cmp r6, 0
- beq _0801C2A6
- b _0801C952
-_0801C2A6:
- ldr r1, _0801C300 @ =gBattleTextBuff1
- movs r0, 0xFD
- strb r0, [r1]
- movs r0, 0x8
- strb r0, [r1, 0x1]
- movs r0, 0x3
- strb r0, [r1, 0x2]
- movs r0, 0xFF
- strb r0, [r1, 0x3]
- ldr r4, _0801C304 @ =gBattleMoveDamage
- ldrh r0, [r5, 0x2C]
- mov r1, r9
- bl __divsi3
- str r0, [r4]
- cmp r0, 0
- bne _0801C2CC
- movs r0, 0x1
- str r0, [r4]
-_0801C2CC:
- ldrh r2, [r5, 0x28]
- ldr r0, [r4]
- adds r0, r2, r0
- ldrh r1, [r5, 0x2C]
- cmp r0, r1
- ble _0801C2DC
- subs r0, r1, r2
- str r0, [r4]
-_0801C2DC:
- ldr r0, [r4]
- negs r0, r0
- str r0, [r4]
- mov r0, r8
- adds r0, 0x48
- ldr r2, [sp, 0x24]
- adds r0, r2, r0
- ldr r0, [r0]
- movs r1, 0x3
- bl GetFlavorRelationByPersonality
- lsls r0, 24
- cmp r0, 0
- bge _0801C30C
-_0801C2F8:
- ldr r0, _0801C308 @ =BattleScript_BerryConfuseHealEnd2
- bl BattleScriptExecute
- b _0801C312
- .align 2, 0
-_0801C300: .4byte gBattleTextBuff1
-_0801C304: .4byte gBattleMoveDamage
-_0801C308: .4byte BattleScript_BerryConfuseHealEnd2
-_0801C30C:
- ldr r0, _0801C318 @ =BattleScript_ItemHealHP_RemoveItem
- bl BattleScriptExecute
-_0801C312:
- movs r3, 0x4
- str r3, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C318: .4byte BattleScript_ItemHealHP_RemoveItem
-_0801C31C:
- movs r0, 0x58
- adds r5, r7, 0
- muls r5, r0
- str r5, [sp, 0x28]
- add r5, r8
- ldrh r0, [r5, 0x2C]
- ldrh r1, [r5, 0x28]
- lsrs r0, 1
- cmp r1, r0
- bls _0801C332
- b _0801C952
-_0801C332:
- cmp r6, 0
- beq _0801C338
- b _0801C952
-_0801C338:
- ldr r1, _0801C394 @ =gBattleTextBuff1
- movs r0, 0xFD
- strb r0, [r1]
- movs r0, 0x8
- strb r0, [r1, 0x1]
- movs r0, 0x4
- strb r0, [r1, 0x2]
- movs r0, 0xFF
- strb r0, [r1, 0x3]
- ldr r4, _0801C398 @ =gBattleMoveDamage
- ldrh r0, [r5, 0x2C]
- mov r1, r9
- bl __divsi3
- str r0, [r4]
- cmp r0, 0
- bne _0801C35E
- movs r0, 0x1
- str r0, [r4]
-_0801C35E:
- ldrh r2, [r5, 0x28]
- ldr r0, [r4]
- adds r0, r2, r0
- ldrh r1, [r5, 0x2C]
- cmp r0, r1
- ble _0801C36E
- subs r0, r1, r2
- str r0, [r4]
-_0801C36E:
- ldr r0, [r4]
- negs r0, r0
- str r0, [r4]
- mov r0, r8
- adds r0, 0x48
- ldr r1, [sp, 0x28]
- adds r0, r1, r0
- ldr r0, [r0]
- movs r1, 0x4
- bl GetFlavorRelationByPersonality
- lsls r0, 24
- cmp r0, 0
- bge _0801C3A0
-_0801C38A:
- ldr r0, _0801C39C @ =BattleScript_BerryConfuseHealEnd2
- bl BattleScriptExecute
- b _0801C3A6
- .align 2, 0
-_0801C394: .4byte gBattleTextBuff1
-_0801C398: .4byte gBattleMoveDamage
-_0801C39C: .4byte BattleScript_BerryConfuseHealEnd2
-_0801C3A0:
- ldr r0, _0801C3AC @ =BattleScript_ItemHealHP_RemoveItem
- bl BattleScriptExecute
-_0801C3A6:
- movs r2, 0x4
- str r2, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C3AC: .4byte BattleScript_ItemHealHP_RemoveItem
-_0801C3B0:
- movs r0, 0x58
- muls r0, r7
- mov r3, r8
- adds r5, r0, r3
- ldrh r4, [r5, 0x28]
- ldrh r0, [r5, 0x2C]
- mov r1, r9
- bl __divsi3
- cmp r4, r0
- ble _0801C3C8
- b _0801C952
-_0801C3C8:
- cmp r6, 0
- beq _0801C3CE
- b _0801C952
-_0801C3CE:
- movs r0, 0x19
- ldrsb r0, [r5, r0]
- cmp r0, 0xB
- ble _0801C3D8
- b _0801C952
-_0801C3D8:
- ldr r1, _0801C408 @ =gBattleTextBuff1
- movs r2, 0xFD
- strb r2, [r1]
- movs r0, 0x5
- strb r0, [r1, 0x1]
- movs r0, 0x1
- strb r0, [r1, 0x2]
- movs r0, 0xFF
- strb r0, [r1, 0x3]
- ldr r1, _0801C40C @ =gBattleTextBuff2
- strb r2, [r1]
- strb r6, [r1, 0x1]
- movs r0, 0xD2
- strb r0, [r1, 0x2]
- strb r6, [r1, 0x3]
- subs r0, 0xD3
- strb r0, [r1, 0x4]
- ldr r0, _0801C410 @ =gEffectBattler
- strb r7, [r0]
- ldr r1, _0801C414 @ =gBattleScripting
- movs r0, 0x11
- strb r0, [r1, 0x1A]
- movs r0, 0xF
- b _0801C56C
- .align 2, 0
-_0801C408: .4byte gBattleTextBuff1
-_0801C40C: .4byte gBattleTextBuff2
-_0801C410: .4byte gEffectBattler
-_0801C414: .4byte gBattleScripting
-_0801C418:
- movs r0, 0x58
- muls r0, r7
- mov r1, r8
- adds r5, r0, r1
- ldrh r4, [r5, 0x28]
- ldrh r0, [r5, 0x2C]
- mov r1, r9
- bl __divsi3
- cmp r4, r0
- ble _0801C430
- b _0801C952
-_0801C430:
- cmp r6, 0
- beq _0801C436
- b _0801C952
-_0801C436:
- movs r0, 0x1A
- ldrsb r0, [r5, r0]
- cmp r0, 0xB
- ble _0801C440
- b _0801C952
-_0801C440:
- ldr r1, _0801C460 @ =gBattleTextBuff1
- movs r0, 0xFD
- strb r0, [r1]
- movs r0, 0x5
- strb r0, [r1, 0x1]
- movs r0, 0x2
- strb r0, [r1, 0x2]
- movs r0, 0xFF
- strb r0, [r1, 0x3]
- ldr r0, _0801C464 @ =gEffectBattler
- strb r7, [r0]
- ldr r1, _0801C468 @ =gBattleScripting
- movs r0, 0x12
- strb r0, [r1, 0x1A]
- movs r0, 0x10
- b _0801C506
- .align 2, 0
-_0801C460: .4byte gBattleTextBuff1
-_0801C464: .4byte gEffectBattler
-_0801C468: .4byte gBattleScripting
-_0801C46C:
- movs r0, 0x58
- muls r0, r7
- mov r3, r8
- adds r5, r0, r3
- ldrh r4, [r5, 0x28]
- ldrh r0, [r5, 0x2C]
- mov r1, r9
- bl __divsi3
- cmp r4, r0
- ble _0801C484
- b _0801C952
-_0801C484:
- cmp r6, 0
- beq _0801C48A
- b _0801C952
-_0801C48A:
- movs r0, 0x1B
- ldrsb r0, [r5, r0]
- cmp r0, 0xB
- ble _0801C494
- b _0801C952
-_0801C494:
- ldr r1, _0801C4B4 @ =gBattleTextBuff1
- movs r0, 0xFD
- strb r0, [r1]
- movs r0, 0x5
- strb r0, [r1, 0x1]
- movs r0, 0x3
- strb r0, [r1, 0x2]
- movs r0, 0xFF
- strb r0, [r1, 0x3]
- ldr r0, _0801C4B8 @ =gEffectBattler
- strb r7, [r0]
- ldr r1, _0801C4BC @ =gBattleScripting
- movs r0, 0x13
- strb r0, [r1, 0x1A]
- movs r0, 0x11
- b _0801C56C
- .align 2, 0
-_0801C4B4: .4byte gBattleTextBuff1
-_0801C4B8: .4byte gEffectBattler
-_0801C4BC: .4byte gBattleScripting
-_0801C4C0:
- movs r0, 0x58
- muls r0, r7
- mov r1, r8
- adds r5, r0, r1
- ldrh r4, [r5, 0x28]
- ldrh r0, [r5, 0x2C]
- mov r1, r9
- bl __divsi3
- cmp r4, r0
- ble _0801C4D8
- b _0801C952
-_0801C4D8:
- cmp r6, 0
- beq _0801C4DE
- b _0801C952
-_0801C4DE:
- movs r0, 0x1C
- ldrsb r0, [r5, r0]
- cmp r0, 0xB
- ble _0801C4E8
- b _0801C952
-_0801C4E8:
- ldr r1, _0801C518 @ =gBattleTextBuff1
- movs r0, 0xFD
- strb r0, [r1]
- movs r0, 0x5
- strb r0, [r1, 0x1]
- movs r0, 0x4
- strb r0, [r1, 0x2]
- movs r0, 0xFF
- strb r0, [r1, 0x3]
- ldr r0, _0801C51C @ =gEffectBattler
- strb r7, [r0]
- ldr r1, _0801C520 @ =gBattleScripting
- movs r0, 0x14
- strb r0, [r1, 0x1A]
- movs r0, 0x12
-_0801C506:
- strb r0, [r1, 0x10]
- strb r6, [r1, 0x11]
- ldr r0, _0801C524 @ =BattleScript_BerryStatRaiseEnd2
- bl BattleScriptExecute
- movs r2, 0x5
- str r2, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C518: .4byte gBattleTextBuff1
-_0801C51C: .4byte gEffectBattler
-_0801C520: .4byte gBattleScripting
-_0801C524: .4byte BattleScript_BerryStatRaiseEnd2
-_0801C528:
- movs r0, 0x58
- muls r0, r7
- mov r3, r8
- adds r5, r0, r3
- ldrh r4, [r5, 0x28]
- ldrh r0, [r5, 0x2C]
- mov r1, r9
- bl __divsi3
- cmp r4, r0
- ble _0801C540
- b _0801C952
-_0801C540:
- cmp r6, 0
- beq _0801C546
- b _0801C952
-_0801C546:
- movs r0, 0x1D
- ldrsb r0, [r5, r0]
- cmp r0, 0xB
- ble _0801C550
- b _0801C952
-_0801C550:
- ldr r1, _0801C57C @ =gBattleTextBuff1
- movs r0, 0xFD
- strb r0, [r1]
- movs r0, 0x5
- strb r0, [r1, 0x1]
- strb r0, [r1, 0x2]
- movs r0, 0xFF
- strb r0, [r1, 0x3]
- ldr r0, _0801C580 @ =gEffectBattler
- strb r7, [r0]
- ldr r1, _0801C584 @ =gBattleScripting
- movs r0, 0x15
- strb r0, [r1, 0x1A]
- movs r0, 0x13
-_0801C56C:
- strb r0, [r1, 0x10]
- strb r6, [r1, 0x11]
- ldr r0, _0801C588 @ =BattleScript_BerryStatRaiseEnd2
- bl BattleScriptExecute
- movs r5, 0x5
- str r5, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C57C: .4byte gBattleTextBuff1
-_0801C580: .4byte gEffectBattler
-_0801C584: .4byte gBattleScripting
-_0801C588: .4byte BattleScript_BerryStatRaiseEnd2
-_0801C58C:
- movs r0, 0x58
- adds r5, r7, 0
- muls r5, r0
- mov r1, r8
- adds r0, r5, r1
- ldrh r4, [r0, 0x28]
- ldrh r0, [r0, 0x2C]
- mov r1, r9
- bl __divsi3
- cmp r4, r0
- ble _0801C5A6
- b _0801C952
-_0801C5A6:
- cmp r6, 0
- beq _0801C5AC
- b _0801C952
-_0801C5AC:
- mov r0, r8
- adds r0, 0x50
- adds r1, r5, r0
- ldr r2, [r1]
- movs r3, 0x80
- lsls r3, 13
- adds r0, r2, 0
- ands r0, r3
- cmp r0, 0
- beq _0801C5C2
- b _0801C952
-_0801C5C2:
- orrs r2, r3
- str r2, [r1]
- ldr r0, _0801C5D4 @ =BattleScript_BerryFocusEnergyEnd2
- bl BattleScriptExecute
- movs r2, 0x2
- str r2, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C5D4: .4byte BattleScript_BerryFocusEnergyEnd2
-_0801C5D8:
- cmp r6, 0
- beq _0801C5DE
- b _0801C952
-_0801C5DE:
- movs r0, 0x58
- adds r5, r7, 0
- muls r5, r0
- mov r3, r8
- adds r0, r5, r3
- ldrh r4, [r0, 0x28]
- ldrh r0, [r0, 0x2C]
- mov r1, r9
- bl __divsi3
- cmp r4, r0
- ble _0801C5F8
- b _0801C952
-_0801C5F8:
- movs r0, 0
- mov r10, r0
- adds r0, r5, 0x1
- mov r1, r8
- adds r1, 0x18
- adds r0, r1
- ldrb r0, [r0]
- lsls r0, 24
- asrs r0, 24
- cmp r0, 0xB
- ble _0801C628
- mov r0, r8
- adds r0, 0x19
- adds r1, r5, r0
-_0801C614:
- adds r1, 0x1
- movs r2, 0x1
- add r10, r2
- mov r3, r10
- cmp r3, 0x4
- bgt _0801C628
- movs r0, 0
- ldrsb r0, [r1, r0]
- cmp r0, 0xB
- bgt _0801C614
-_0801C628:
- mov r5, r10
- cmp r5, 0x5
- bne _0801C630
- b _0801C952
-_0801C630:
- movs r0, 0x58
- muls r0, r7
- adds r4, r0, 0x1
- ldr r5, _0801C6A8 @ =gUnknown_2023BFC
-_0801C638:
- bl Random
- lsls r0, 16
- lsrs r0, 16
- movs r1, 0x5
- bl __umodsi3
- lsls r0, 16
- lsrs r0, 16
- mov r10, r0
- adds r0, r4
- adds r0, r5
- ldrb r0, [r0]
- lsls r0, 24
- asrs r0, 24
- cmp r0, 0xC
- beq _0801C638
- ldr r1, _0801C6AC @ =gBattleTextBuff1
- movs r2, 0
- movs r3, 0xFD
- strb r3, [r1]
- movs r0, 0x5
- strb r0, [r1, 0x1]
- mov r0, r10
- adds r0, 0x1
- strb r0, [r1, 0x2]
- movs r0, 0xFF
- strb r0, [r1, 0x3]
- ldr r0, _0801C6B0 @ =gBattleTextBuff2
- strb r3, [r0]
- strb r2, [r0, 0x1]
- movs r1, 0xD1
- strb r1, [r0, 0x2]
- strb r2, [r0, 0x3]
- strb r2, [r0, 0x4]
- movs r1, 0xD2
- strb r1, [r0, 0x5]
- strb r2, [r0, 0x6]
- subs r1, 0xD3
- strb r1, [r0, 0x7]
- ldr r0, _0801C6B4 @ =gEffectBattler
- strb r7, [r0]
- ldr r1, _0801C6B8 @ =gBattleScripting
- mov r0, r10
- adds r0, 0x21
- strb r0, [r1, 0x1A]
- adds r0, 0x6
- strb r0, [r1, 0x10]
- strb r2, [r1, 0x11]
- ldr r0, _0801C6BC @ =BattleScript_BerryStatRaiseEnd2
- bl BattleScriptExecute
- movs r0, 0x5
- str r0, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C6A8: .4byte gUnknown_2023BFC
-_0801C6AC: .4byte gBattleTextBuff1
-_0801C6B0: .4byte gBattleTextBuff2
-_0801C6B4: .4byte gEffectBattler
-_0801C6B8: .4byte gBattleScripting
-_0801C6BC: .4byte BattleScript_BerryStatRaiseEnd2
-_0801C6C0:
- movs r0, 0x58
- adds r1, r7, 0
- muls r1, r0
- mov r0, r8
- adds r0, 0x4C
- adds r1, r0
- ldr r2, [r1]
- movs r0, 0x40
- ands r0, r2
- cmp r0, 0
- bne _0801C6D8
- b _0801C952
-_0801C6D8:
- movs r0, 0x41
- negs r0, r0
- ands r2, r0
- str r2, [r1]
- ldr r0, _0801C6EC @ =BattleScript_BerryCurePrlzEnd2
- bl BattleScriptExecute
- movs r1, 0x1
- str r1, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C6EC: .4byte BattleScript_BerryCurePrlzEnd2
-_0801C6F0:
- movs r0, 0x58
- adds r1, r7, 0
- muls r1, r0
- mov r0, r8
- adds r0, 0x4C
- adds r1, r0
- ldr r2, [r1]
- movs r0, 0x88
- ands r0, r2
- cmp r0, 0
- bne _0801C708
- b _0801C952
-_0801C708:
- ldr r0, _0801C71C @ =0xfffff077
- ands r2, r0
- str r2, [r1]
- ldr r0, _0801C720 @ =BattleScript_BerryCurePsnEnd2
- bl BattleScriptExecute
- movs r2, 0x1
- str r2, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C71C: .4byte 0xfffff077
-_0801C720: .4byte BattleScript_BerryCurePsnEnd2
-_0801C724:
- movs r0, 0x58
- adds r1, r7, 0
- muls r1, r0
- mov r0, r8
- adds r0, 0x4C
- adds r1, r0
- ldr r2, [r1]
- movs r0, 0x10
- ands r0, r2
- cmp r0, 0
- bne _0801C73C
- b _0801C952
-_0801C73C:
- movs r0, 0x11
- negs r0, r0
- ands r2, r0
- str r2, [r1]
- ldr r0, _0801C750 @ =BattleScript_BerryCureBrnEnd2
- bl BattleScriptExecute
- movs r3, 0x1
- str r3, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C750: .4byte BattleScript_BerryCureBrnEnd2
-_0801C754:
- movs r0, 0x58
- adds r1, r7, 0
- muls r1, r0
- mov r0, r8
- adds r0, 0x4C
- adds r1, r0
- ldr r2, [r1]
- movs r0, 0x20
- ands r0, r2
- cmp r0, 0
- bne _0801C76C
- b _0801C952
-_0801C76C:
- movs r0, 0x21
- negs r0, r0
- ands r2, r0
- str r2, [r1]
- ldr r0, _0801C780 @ =BattleScript_BerryCureFrzEnd2
- bl BattleScriptExecute
- movs r5, 0x1
- str r5, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C780: .4byte BattleScript_BerryCureFrzEnd2
-_0801C784:
- movs r0, 0x58
- adds r3, r7, 0
- muls r3, r0
- mov r0, r8
- adds r0, 0x4C
- adds r2, r3, r0
- ldr r1, [r2]
- movs r0, 0x7
- ands r0, r1
- cmp r0, 0
- bne _0801C79C
- b _0801C952
-_0801C79C:
- movs r0, 0x8
- negs r0, r0
- ands r1, r0
- str r1, [r2]
- mov r1, r8
- adds r1, 0x50
- adds r1, r3, r1
- ldr r0, [r1]
- ldr r2, _0801C7B8 @ =0xf7ffffff
- ands r0, r2
- str r0, [r1]
- ldr r0, _0801C7BC @ =BattleScript_BerryCureSlpEnd2
- b _0801C906
- .align 2, 0
-_0801C7B8: .4byte 0xf7ffffff
-_0801C7BC: .4byte BattleScript_BerryCureSlpEnd2
-_0801C7C0:
- movs r0, 0x58
- adds r1, r7, 0
- muls r1, r0
- mov r0, r8
- adds r0, 0x50
- adds r1, r0
- ldr r2, [r1]
- movs r0, 0x7
- ands r0, r2
- cmp r0, 0
- bne _0801C7D8
- b _0801C952
-_0801C7D8:
- movs r0, 0x8
- negs r0, r0
- ands r2, r0
- str r2, [r1]
- ldr r0, _0801C7EC @ =BattleScript_BerryCureConfusionEnd2
- bl BattleScriptExecute
- movs r1, 0x2
- str r1, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C7EC: .4byte BattleScript_BerryCureConfusionEnd2
-_0801C7F0:
- movs r0, 0x58
- adds r5, r7, 0
- muls r5, r0
- mov r0, r8
- adds r0, 0x4C
- adds r4, r5, r0
- ldr r2, [r4]
- ldrb r0, [r4]
- cmp r0, 0
- bne _0801C816
- mov r0, r8
- adds r0, 0x50
- adds r0, r5, r0
- ldr r0, [r0]
- movs r1, 0x7
- ands r0, r1
- cmp r0, 0
- bne _0801C816
- b _0801C952
-_0801C816:
- movs r3, 0
- mov r10, r3
- movs r0, 0x88
- ands r2, r0
- cmp r2, 0
- beq _0801C82E
- ldr r0, _0801C8BC @ =gBattleTextBuff1
- ldr r1, _0801C8C0 @ =gStatusConditionString_PoisonJpn
- bl StringCopy
- movs r0, 0x1
- mov r10, r0
-_0801C82E:
- ldr r0, [r4]
- movs r1, 0x7
- mov r9, r1
- ands r0, r1
- mov r6, r8
- adds r6, 0x50
- cmp r0, 0
- beq _0801C854
- adds r2, r5, r6
- ldr r0, [r2]
- ldr r1, _0801C8C4 @ =0xf7ffffff
- ands r0, r1
- str r0, [r2]
- ldr r0, _0801C8BC @ =gBattleTextBuff1
- ldr r1, _0801C8C8 @ =gStatusConditionString_SleepJpn
- bl StringCopy
- movs r2, 0x1
- add r10, r2
-_0801C854:
- ldr r0, [r4]
- movs r1, 0x40
- ands r0, r1
- cmp r0, 0
- beq _0801C86A
- ldr r0, _0801C8BC @ =gBattleTextBuff1
- ldr r1, _0801C8CC @ =gStatusConditionString_ParalysisJpn
- bl StringCopy
- movs r3, 0x1
- add r10, r3
-_0801C86A:
- ldr r0, [r4]
- movs r1, 0x10
- ands r0, r1
- cmp r0, 0
- beq _0801C880
- ldr r0, _0801C8BC @ =gBattleTextBuff1
- ldr r1, _0801C8D0 @ =gStatusConditionString_BurnJpn
- bl StringCopy
- movs r0, 0x1
- add r10, r0
-_0801C880:
- ldr r0, [r4]
- movs r1, 0x20
- ands r0, r1
- cmp r0, 0
- beq _0801C896
- ldr r0, _0801C8BC @ =gBattleTextBuff1
- ldr r1, _0801C8D4 @ =gStatusConditionString_IceJpn
- bl StringCopy
- movs r1, 0x1
- add r10, r1
-_0801C896:
- adds r0, r5, r6
- ldr r0, [r0]
- mov r2, r9
- ands r0, r2
- cmp r0, 0
- beq _0801C8AE
- ldr r0, _0801C8BC @ =gBattleTextBuff1
- ldr r1, _0801C8D8 @ =gStatusConditionString_ConfusionJpn
- bl StringCopy
- movs r3, 0x1
- add r10, r3
-_0801C8AE:
- mov r5, r10
- cmp r5, 0x1
- bgt _0801C8E0
- ldr r1, _0801C8DC @ =gBattleCommunication
- movs r0, 0
- b _0801C8E4
- .align 2, 0
-_0801C8BC: .4byte gBattleTextBuff1
-_0801C8C0: .4byte gStatusConditionString_PoisonJpn
-_0801C8C4: .4byte 0xf7ffffff
-_0801C8C8: .4byte gStatusConditionString_SleepJpn
-_0801C8CC: .4byte gStatusConditionString_ParalysisJpn
-_0801C8D0: .4byte gStatusConditionString_BurnJpn
-_0801C8D4: .4byte gStatusConditionString_IceJpn
-_0801C8D8: .4byte gStatusConditionString_ConfusionJpn
-_0801C8DC: .4byte gBattleCommunication
-_0801C8E0:
- ldr r1, _0801C910 @ =gBattleCommunication
- movs r0, 0x1
-_0801C8E4:
- strb r0, [r1, 0x5]
- ldr r2, _0801C914 @ =gBattleMons
- movs r0, 0x58
- adds r3, r7, 0
- muls r3, r0
- adds r0, r2, 0
- adds r0, 0x4C
- adds r0, r3, r0
- movs r1, 0
- str r1, [r0]
- adds r2, 0x50
- adds r3, r2
- ldr r0, [r3]
- subs r1, 0x8
- ands r0, r1
- str r0, [r3]
- ldr r0, _0801C918 @ =BattleScript_BerryCureChosenStatusEnd2
-_0801C906:
- bl BattleScriptExecute
- movs r0, 0x1
- str r0, [sp, 0xC]
- b _0801C95A
- .align 2, 0
-_0801C910: .4byte gBattleCommunication
-_0801C914: .4byte gBattleMons
-_0801C918: .4byte BattleScript_BerryCureChosenStatusEnd2
-_0801C91C:
- movs r0, 0x58
- adds r1, r7, 0
- muls r1, r0
- mov r0, r8
- adds r0, 0x50
- adds r1, r0
- ldr r2, [r1]
- movs r0, 0xF0
- lsls r0, 12
- ands r0, r2
- cmp r0, 0
- beq _0801C952
- ldr r0, _0801C978 @ =0xfff0ffff
- ands r2, r0
- str r2, [r1]
- ldr r0, _0801C97C @ =gBattleTextBuff1
- ldr r1, _0801C980 @ =gStatusConditionString_LoveJpn
- bl StringCopy
- ldr r0, _0801C984 @ =BattleScript_BerryCureChosenStatusEnd2
- bl BattleScriptExecute
- ldr r1, _0801C988 @ =gBattleCommunication
- movs r0, 0
- strb r0, [r1, 0x5]
- movs r1, 0x2
- str r1, [sp, 0xC]
-_0801C952:
- ldr r2, [sp, 0xC]
- cmp r2, 0
- bne _0801C95A
- b _0801CFA6
-_0801C95A:
- ldr r0, _0801C98C @ =gBattleScripting
- strb r7, [r0, 0x17]
- ldr r0, _0801C990 @ =gPotentialItemEffectBattler
- strb r7, [r0]
- ldr r4, _0801C994 @ =gActiveBattler
- ldr r0, _0801C998 @ =gBattlerAttacker
- strb r7, [r0]
- strb r7, [r4]
- ldr r3, [sp, 0xC]
- cmp r3, 0x1
- beq _0801C99C
- cmp r3, 0x3
- beq _0801C9A2
- b _0801CFA6
- .align 2, 0
-_0801C978: .4byte 0xfff0ffff
-_0801C97C: .4byte gBattleTextBuff1
-_0801C980: .4byte gStatusConditionString_LoveJpn
-_0801C984: .4byte BattleScript_BerryCureChosenStatusEnd2
-_0801C988: .4byte gBattleCommunication
-_0801C98C: .4byte gBattleScripting
-_0801C990: .4byte gPotentialItemEffectBattler
-_0801C994: .4byte gActiveBattler
-_0801C998: .4byte gBattlerAttacker
-_0801C99C:
- movs r0, 0x58
- muls r0, r7
- b _0801CE08
-_0801C9A2:
- ldr r4, _0801C9F0 @ =gBattleMons
- movs r0, 0x58
- adds r3, r7, 0
- muls r3, r0
- adds r0, r4, 0
- adds r0, 0x50
- adds r0, r3, r0
- ldr r0, [r0]
- movs r1, 0x80
- lsls r1, 14
- ands r0, r1
- cmp r0, 0
- beq _0801C9BE
- b _0801CFA6
-_0801C9BE:
- ldr r1, _0801C9F4 @ =gDisableStructs
- lsls r0, r7, 3
- subs r0, r7
- lsls r0, 2
- adds r0, r1
- ldrb r1, [r0, 0x18]
- lsrs r1, 4
- ldr r2, _0801C9F8 @ =gBitTable
- mov r5, r10
- lsls r0, r5, 2
- adds r0, r2
- ldr r0, [r0]
- ands r1, r0
- cmp r1, 0
- beq _0801C9DE
- b _0801CFA6
-_0801C9DE:
- adds r1, r5, r3
- adds r0, r4, 0
- adds r0, 0x24
- adds r1, r0
- add r0, sp, 0x4
- ldrb r0, [r0]
- strb r0, [r1]
- b _0801CFA6
- .align 2, 0
-_0801C9F0: .4byte gBattleMons
-_0801C9F4: .4byte gDisableStructs
-_0801C9F8: .4byte gBitTable
-_0801C9FC:
- movs r7, 0
- ldr r0, _0801CA2C @ =gBattlersCount
- ldrb r0, [r0]
- cmp r7, r0
- bcc _0801CA08
- b _0801CFA6
-_0801CA08:
- ldr r4, _0801CA30 @ =gLastUsedItem
- ldr r1, _0801CA34 @ =gBattleMons
- movs r0, 0x58
- muls r0, r7
- adds r0, r1
- ldrh r0, [r0, 0x2E]
- strh r0, [r4]
- lsls r0, 16
- lsrs r0, 16
- cmp r0, 0xAF
- bne _0801CA3C
- ldr r1, _0801CA38 @ =gEnigmaBerries
- lsls r0, r7, 3
- subs r0, r7
- lsls r0, 2
- adds r0, r1
- ldrb r5, [r0, 0x7]
- b _0801CA4C
- .align 2, 0
-_0801CA2C: .4byte gBattlersCount
-_0801CA30: .4byte gLastUsedItem
-_0801CA34: .4byte gBattleMons
-_0801CA38: .4byte gEnigmaBerries
-_0801CA3C:
- ldrh r0, [r4]
- bl ItemId_GetHoldEffect
- lsls r0, 24
- lsrs r5, r0, 24
- ldrh r0, [r4]
- bl ItemId_GetHoldEffectParam
-_0801CA4C:
- subs r0, r5, 0x2
- cmp r0, 0x1A
- bls _0801CA54
- b _0801CDF0
-_0801CA54:
- lsls r0, 2
- ldr r1, _0801CA60 @ =_0801CA64
- adds r0, r1
- ldr r0, [r0]
- mov pc, r0
- .align 2, 0
-_0801CA60: .4byte _0801CA64
- .align 2, 0
-_0801CA64:
- .4byte _0801CAD0
- .4byte _0801CBC0
- .4byte _0801CB0C
- .4byte _0801CB48
- .4byte _0801CB84
- .4byte _0801CDF0
- .4byte _0801CC08
- .4byte _0801CC9C
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CD90
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CDF0
- .4byte _0801CC44
-_0801CAD0:
- ldr r1, _0801CB00 @ =gBattleMons
- movs r0, 0x58
- muls r0, r7
- adds r1, 0x4C
- adds r2, r0, r1
- ldr r1, [r2]
- movs r0, 0x40
- ands r0, r1
- cmp r0, 0
- bne _0801CAE6
- b _0801CDF0
-_0801CAE6:
- movs r0, 0x41
- negs r0, r0
- ands r1, r0
- str r1, [r2]
- bl BattleScriptPushCursor
- ldr r1, _0801CB04 @ =gBattlescriptCurrInstr
- ldr r0, _0801CB08 @ =BattleScript_BerryCureParRet
- str r0, [r1]
- movs r0, 0x1
- str r0, [sp, 0xC]
- b _0801CDF6
- .align 2, 0
-_0801CB00: .4byte gBattleMons
-_0801CB04: .4byte gBattlescriptCurrInstr
-_0801CB08: .4byte BattleScript_BerryCureParRet
-_0801CB0C:
- ldr r1, _0801CB38 @ =gBattleMons
- movs r0, 0x58
- muls r0, r7
- adds r1, 0x4C
- adds r2, r0, r1
- ldr r1, [r2]
- movs r0, 0x88
- ands r0, r1
- cmp r0, 0
- bne _0801CB22
- b _0801CDF0
-_0801CB22:
- ldr r0, _0801CB3C @ =0xfffff077
- ands r1, r0
- str r1, [r2]
- bl BattleScriptPushCursor
- ldr r1, _0801CB40 @ =gBattlescriptCurrInstr
- ldr r0, _0801CB44 @ =BattleScript_BerryCurePsnRet
- str r0, [r1]
- movs r1, 0x1
- str r1, [sp, 0xC]
- b _0801CDF6
- .align 2, 0
-_0801CB38: .4byte gBattleMons
-_0801CB3C: .4byte 0xfffff077
-_0801CB40: .4byte gBattlescriptCurrInstr
-_0801CB44: .4byte BattleScript_BerryCurePsnRet
-_0801CB48:
- ldr r1, _0801CB78 @ =gBattleMons
- movs r0, 0x58
- muls r0, r7
- adds r1, 0x4C
- adds r2, r0, r1
- ldr r1, [r2]
- movs r0, 0x10
- ands r0, r1
- cmp r0, 0
- bne _0801CB5E
- b _0801CDF0
-_0801CB5E:
- movs r0, 0x11
- negs r0, r0
- ands r1, r0
- str r1, [r2]
- bl BattleScriptPushCursor
- ldr r1, _0801CB7C @ =gBattlescriptCurrInstr
- ldr r0, _0801CB80 @ =BattleScript_BerryCureBrnRet
- str r0, [r1]
- movs r2, 0x1
- str r2, [sp, 0xC]
- b _0801CDF6
- .align 2, 0
-_0801CB78: .4byte gBattleMons
-_0801CB7C: .4byte gBattlescriptCurrInstr
-_0801CB80: .4byte BattleScript_BerryCureBrnRet
-_0801CB84:
- ldr r1, _0801CBB4 @ =gBattleMons
- movs r0, 0x58
- muls r0, r7
- adds r1, 0x4C
- adds r2, r0, r1
- ldr r1, [r2]
- movs r0, 0x20
- ands r0, r1
- cmp r0, 0
- bne _0801CB9A
- b _0801CDF0
-_0801CB9A:
- movs r0, 0x21
- negs r0, r0
- ands r1, r0
- str r1, [r2]
- bl BattleScriptPushCursor
- ldr r1, _0801CBB8 @ =gBattlescriptCurrInstr
- ldr r0, _0801CBBC @ =BattleScript_BerryCureFrzRet
- str r0, [r1]
- movs r3, 0x1
- str r3, [sp, 0xC]
- b _0801CDF6
- .align 2, 0
-_0801CBB4: .4byte gBattleMons
-_0801CBB8: .4byte gBattlescriptCurrInstr
-_0801CBBC: .4byte BattleScript_BerryCureFrzRet
-_0801CBC0:
- ldr r2, _0801CBF8 @ =gBattleMons
- movs r0, 0x58
- adds r4, r7, 0
- muls r4, r0
- adds r0, r2, 0
- adds r0, 0x4C
- adds r3, r4, r0
- ldr r1, [r3]
- movs r0, 0x7
- ands r0, r1
- cmp r0, 0
- bne _0801CBDA
- b _0801CDF0
-_0801CBDA:
- movs r0, 0x8
- negs r0, r0
- ands r1, r0
- str r1, [r3]
- adds r2, 0x50
- adds r2, r4, r2
- ldr r0, [r2]
- ldr r1, _0801CBFC @ =0xf7ffffff
- ands r0, r1
- str r0, [r2]
- bl BattleScriptPushCursor
- ldr r1, _0801CC00 @ =gBattlescriptCurrInstr
- ldr r0, _0801CC04 @ =BattleScript_BerryCureSlpRet
- b _0801CD58
- .align 2, 0
-_0801CBF8: .4byte gBattleMons
-_0801CBFC: .4byte 0xf7ffffff
-_0801CC00: .4byte gBattlescriptCurrInstr
-_0801CC04: .4byte BattleScript_BerryCureSlpRet
-_0801CC08:
- ldr r1, _0801CC38 @ =gBattleMons
- movs r0, 0x58
- muls r0, r7
- adds r1, 0x50
- adds r2, r0, r1
- ldr r1, [r2]
- movs r0, 0x7
- ands r0, r1
- cmp r0, 0
- bne _0801CC1E
- b _0801CDF0
-_0801CC1E:
- movs r0, 0x8
- negs r0, r0
- ands r1, r0
- str r1, [r2]
- bl BattleScriptPushCursor
- ldr r1, _0801CC3C @ =gBattlescriptCurrInstr
- ldr r0, _0801CC40 @ =BattleScript_BerryCureConfusionRet
- str r0, [r1]
- movs r0, 0x2
- str r0, [sp, 0xC]
- b _0801CDF6
- .align 2, 0
-_0801CC38: .4byte gBattleMons
-_0801CC3C: .4byte gBattlescriptCurrInstr
-_0801CC40: .4byte BattleScript_BerryCureConfusionRet
-_0801CC44:
- ldr r1, _0801CC80 @ =gBattleMons
- movs r0, 0x58
- muls r0, r7
- adds r1, 0x50
- adds r2, r0, r1
- ldr r1, [r2]
- movs r0, 0xF0
- lsls r0, 12
- ands r0, r1
- cmp r0, 0
- bne _0801CC5C
- b _0801CDF0
-_0801CC5C:
- ldr r0, _0801CC84 @ =0xfff0ffff
- ands r1, r0
- str r1, [r2]
- ldr r0, _0801CC88 @ =gBattleTextBuff1
- ldr r1, _0801CC8C @ =gStatusConditionString_LoveJpn
- bl StringCopy
- bl BattleScriptPushCursor
- ldr r1, _0801CC90 @ =gBattleCommunication
- movs r0, 0
- strb r0, [r1, 0x5]
- ldr r1, _0801CC94 @ =gBattlescriptCurrInstr
- ldr r0, _0801CC98 @ =BattleScript_BerryCureChosenStatusRet
- str r0, [r1]
- movs r1, 0x2
- str r1, [sp, 0xC]
- b _0801CDF6
- .align 2, 0
-_0801CC80: .4byte gBattleMons
-_0801CC84: .4byte 0xfff0ffff
-_0801CC88: .4byte gBattleTextBuff1
-_0801CC8C: .4byte gStatusConditionString_LoveJpn
-_0801CC90: .4byte gBattleCommunication
-_0801CC94: .4byte gBattlescriptCurrInstr
-_0801CC98: .4byte BattleScript_BerryCureChosenStatusRet
-_0801CC9C:
- ldr r4, _0801CD60 @ =gBattleMons
- movs r0, 0x58
- adds r5, r7, 0
- muls r5, r0
- adds r0, r4, 0
- adds r0, 0x4C
- adds r6, r5, r0
- ldr r2, [r6]
- ldrb r0, [r6]
- cmp r0, 0
- bne _0801CCC4
- adds r0, r4, 0
- adds r0, 0x50
- adds r0, r5, r0
- ldr r0, [r0]
- movs r1, 0x7
- ands r0, r1
- cmp r0, 0
- bne _0801CCC4
- b _0801CDF0
-_0801CCC4:
- movs r0, 0x88
- ands r2, r0
- cmp r2, 0
- beq _0801CCD4
- ldr r0, _0801CD64 @ =gBattleTextBuff1
- ldr r1, _0801CD68 @ =gStatusConditionString_PoisonJpn
- bl StringCopy
-_0801CCD4:
- ldr r0, [r6]
- movs r2, 0x7
- mov r8, r2
- ands r0, r2
- adds r4, 0x50
- cmp r0, 0
- beq _0801CCF4
- adds r2, r5, r4
- ldr r0, [r2]
- ldr r1, _0801CD6C @ =0xf7ffffff
- ands r0, r1
- str r0, [r2]
- ldr r0, _0801CD64 @ =gBattleTextBuff1
- ldr r1, _0801CD70 @ =gStatusConditionString_SleepJpn
- bl StringCopy
-_0801CCF4:
- ldr r0, [r6]
- movs r1, 0x40
- ands r0, r1
- cmp r0, 0
- beq _0801CD06
- ldr r0, _0801CD64 @ =gBattleTextBuff1
- ldr r1, _0801CD74 @ =gStatusConditionString_ParalysisJpn
- bl StringCopy
-_0801CD06:
- ldr r0, [r6]
- movs r1, 0x10
- ands r0, r1
- cmp r0, 0
- beq _0801CD18
- ldr r0, _0801CD64 @ =gBattleTextBuff1
- ldr r1, _0801CD78 @ =gStatusConditionString_BurnJpn
- bl StringCopy
-_0801CD18:
- ldr r0, [r6]
- movs r1, 0x20
- ands r0, r1
- cmp r0, 0
- beq _0801CD2A
- ldr r0, _0801CD64 @ =gBattleTextBuff1
- ldr r1, _0801CD7C @ =gStatusConditionString_IceJpn
- bl StringCopy
-_0801CD2A:
- adds r5, r4
- ldr r0, [r5]
- mov r3, r8
- ands r0, r3
- cmp r0, 0
- beq _0801CD3E
- ldr r0, _0801CD64 @ =gBattleTextBuff1
- ldr r1, _0801CD80 @ =gStatusConditionString_ConfusionJpn
- bl StringCopy
-_0801CD3E:
- movs r4, 0
- str r4, [r6]
- ldr r0, [r5]
- movs r1, 0x8
- negs r1, r1
- ands r0, r1
- str r0, [r5]
- bl BattleScriptPushCursor
- ldr r0, _0801CD84 @ =gBattleCommunication
- strb r4, [r0, 0x5]
- ldr r1, _0801CD88 @ =gBattlescriptCurrInstr
- ldr r0, _0801CD8C @ =BattleScript_BerryCureChosenStatusRet
-_0801CD58:
- str r0, [r1]
- movs r5, 0x1
- str r5, [sp, 0xC]
- b _0801CDF6
- .align 2, 0
-_0801CD60: .4byte gBattleMons
-_0801CD64: .4byte gBattleTextBuff1
-_0801CD68: .4byte gStatusConditionString_PoisonJpn
-_0801CD6C: .4byte 0xf7ffffff
-_0801CD70: .4byte gStatusConditionString_SleepJpn
-_0801CD74: .4byte gStatusConditionString_ParalysisJpn
-_0801CD78: .4byte gStatusConditionString_BurnJpn
-_0801CD7C: .4byte gStatusConditionString_IceJpn
-_0801CD80: .4byte gStatusConditionString_ConfusionJpn
-_0801CD84: .4byte gBattleCommunication
-_0801CD88: .4byte gBattlescriptCurrInstr
-_0801CD8C: .4byte BattleScript_BerryCureChosenStatusRet
-_0801CD90:
- ldr r0, _0801CDDC @ =gBattleMons
- mov r8, r0
- movs r0, 0x58
- adds r1, r7, 0
- muls r1, r0
- mov r0, r8
- adds r0, 0x18
- adds r1, r0
- movs r2, 0x6
- movs r3, 0x7
- mov r10, r3
-_0801CDA6:
- movs r0, 0
- ldrsb r0, [r1, r0]
- cmp r0, 0x5
- bgt _0801CDB4
- strb r2, [r1]
- movs r5, 0x5
- str r5, [sp, 0xC]
-_0801CDB4:
- adds r1, 0x1
- movs r0, 0x1
- negs r0, r0
- add r10, r0
- mov r3, r10
- cmp r3, 0
- bge _0801CDA6
- ldr r5, [sp, 0xC]
- cmp r5, 0
- beq _0801CE34
- ldr r0, _0801CDE0 @ =gBattleScripting
- strb r7, [r0, 0x17]
- ldr r0, _0801CDE4 @ =gPotentialItemEffectBattler
- strb r7, [r0]
- bl BattleScriptPushCursor
- ldr r1, _0801CDE8 @ =gBattlescriptCurrInstr
- ldr r0, _0801CDEC @ =BattleScript_WhiteHerbRet
- str r0, [r1]
- b _0801CFA6
- .align 2, 0
-_0801CDDC: .4byte gBattleMons
-_0801CDE0: .4byte gBattleScripting
-_0801CDE4: .4byte gPotentialItemEffectBattler
-_0801CDE8: .4byte gBattlescriptCurrInstr
-_0801CDEC: .4byte BattleScript_WhiteHerbRet
-_0801CDF0:
- ldr r0, [sp, 0xC]
- cmp r0, 0
- beq _0801CE34
-_0801CDF6:
- ldr r0, _0801CE24 @ =gBattleScripting
- strb r7, [r0, 0x17]
- ldr r0, _0801CE28 @ =gPotentialItemEffectBattler
- strb r7, [r0]
- ldr r4, _0801CE2C @ =gActiveBattler
- strb r7, [r4]
- ldrb r1, [r4]
- movs r0, 0x58
- muls r0, r1
-_0801CE08:
- ldr r1, _0801CE30 @ =gUnknown_2023C30
- adds r0, r1
- str r0, [sp]
- movs r0, 0
- movs r1, 0x28
- movs r2, 0
- movs r3, 0x4
- bl BtlController_EmitSetMonData
- ldrb r0, [r4]
- bl MarkBattlerForControllerExec
- b _0801CFA6
- .align 2, 0
-_0801CE24: .4byte gBattleScripting
-_0801CE28: .4byte gPotentialItemEffectBattler
-_0801CE2C: .4byte gActiveBattler
-_0801CE30: .4byte gUnknown_2023C30
-_0801CE34:
- adds r0, r7, 0x1
- lsls r0, 24
- lsrs r7, r0, 24
- ldr r0, _0801CE48 @ =gBattlersCount
- ldrb r0, [r0]
- cmp r7, r0
- bcs _0801CE44
- b _0801CA08
-_0801CE44:
- b _0801CFA6
- .align 2, 0
-_0801CE48: .4byte gBattlersCount
-_0801CE4C:
- ldr r7, _0801CE64 @ =gBattleMoveDamage
- ldr r0, [r7]
- cmp r0, 0
- bne _0801CE56
- b _0801CFA6
-_0801CE56:
- mov r1, r8
- cmp r1, 0x1E
- beq _0801CE68
- cmp r1, 0x3E
- beq _0801CF10
- b _0801CFA6
- .align 2, 0
-_0801CE64: .4byte gBattleMoveDamage
-_0801CE68:
- ldr r0, _0801CEF4 @ =gMoveResultFlags
- ldrb r1, [r0]
- movs r0, 0x29
- ands r0, r1
- cmp r0, 0
- beq _0801CE76
- b _0801CFA6
-_0801CE76:
- ldr r2, _0801CEF8 @ =gSpecialStatuses
- ldr r4, _0801CEFC @ =gBattlerTarget
- ldrb r1, [r4]
- lsls r0, r1, 2
- adds r0, r1
- lsls r1, r0, 2
- adds r0, r2, 0
- adds r0, 0x8
- adds r0, r1, r0
- ldr r0, [r0]
- cmp r0, 0
- bne _0801CE9C
- adds r0, r2, 0
- adds r0, 0xC
- adds r0, r1, r0
- ldr r0, [r0]
- cmp r0, 0
- bne _0801CE9C
- b _0801CFA6
-_0801CE9C:
- bl Random
- lsls r0, 16
- lsrs r0, 16
- movs r1, 0x64
- bl __umodsi3
- lsls r0, 16
- lsrs r0, 16
- cmp r0, r9
- bcs _0801CFA6
- ldr r2, _0801CF00 @ =gBattleMoves
- ldr r0, _0801CF04 @ =gCurrentMove
- ldrh r1, [r0]
- lsls r0, r1, 1
- adds r0, r1
- lsls r0, 2
- adds r0, r2
- ldrb r1, [r0, 0x8]
- movs r0, 0x20
- ands r0, r1
- cmp r0, 0
- beq _0801CFA6
- ldr r2, _0801CF08 @ =gBattleMons
- ldrb r1, [r4]
- movs r0, 0x58
- muls r0, r1
- adds r0, r2
- ldrh r0, [r0, 0x28]
- cmp r0, 0
- beq _0801CFA6
- ldr r1, _0801CF0C @ =gBattleCommunication
- movs r0, 0x8
- strb r0, [r1, 0x3]
- bl BattleScriptPushCursor
- movs r0, 0
- movs r1, 0
- bl SetMoveEffect
- bl BattleScriptPop
- b _0801CFA6
- .align 2, 0
-_0801CEF4: .4byte gMoveResultFlags
-_0801CEF8: .4byte gSpecialStatuses
-_0801CEFC: .4byte gBattlerTarget
-_0801CF00: .4byte gBattleMoves
-_0801CF04: .4byte gCurrentMove
-_0801CF08: .4byte gBattleMons
-_0801CF0C: .4byte gBattleCommunication
-_0801CF10:
- ldr r0, _0801CFB8 @ =gMoveResultFlags
- ldrb r0, [r0]
- movs r5, 0x29
- ands r5, r0
- cmp r5, 0
- bne _0801CFA6
- ldr r1, _0801CFBC @ =gSpecialStatuses
- ldr r4, _0801CFC0 @ =gBattlerTarget
- ldrb r2, [r4]
- lsls r0, r2, 2
- adds r0, r2
- lsls r0, 2
- adds r6, r1, 0x4
- adds r0, r6
- ldr r1, [r0]
- cmp r1, 0
- beq _0801CFA6
- ldr r0, _0801CFC4 @ =0x0000ffff
- cmp r1, r0
- beq _0801CFA6
- ldr r0, _0801CFC8 @ =gBattlerAttacker
- ldrb r3, [r0]
- cmp r3, r2
- beq _0801CFA6
- ldr r2, _0801CFCC @ =gBattleMons
- ldrb r1, [r0]
- movs r0, 0x58
- muls r0, r1
- adds r0, r2
- ldrh r1, [r0, 0x28]
- ldrh r0, [r0, 0x2C]
- cmp r1, r0
- beq _0801CFA6
- cmp r1, 0
- beq _0801CFA6
- ldr r0, _0801CFD0 @ =gLastUsedItem
- mov r2, sp
- ldrh r2, [r2, 0x14]
- strh r2, [r0]
- ldr r0, _0801CFD4 @ =gPotentialItemEffectBattler
- strb r3, [r0]
- ldr r0, _0801CFD8 @ =gBattleScripting
- strb r3, [r0, 0x17]
- ldrb r1, [r4]
- lsls r0, r1, 2
- adds r0, r1
- lsls r0, 2
- adds r0, r6
- ldr r0, [r0]
- ldr r1, [sp, 0x10]
- bl __divsi3
- negs r0, r0
- str r0, [r7]
- ldrb r1, [r4]
- cmp r0, 0
- bne _0801CF88
- movs r0, 0x1
- negs r0, r0
- str r0, [r7]
-_0801CF88:
- lsls r0, r1, 2
- adds r0, r1
- lsls r0, 2
- adds r0, r6
- str r5, [r0]
- bl BattleScriptPushCursor
- ldr r1, _0801CFDC @ =gBattlescriptCurrInstr
- ldr r0, _0801CFE0 @ =BattleScript_ItemHealHP_Ret
- str r0, [r1]
- ldr r0, [sp, 0xC]
- adds r0, 0x1
- lsls r0, 24
- lsrs r0, 24
- str r0, [sp, 0xC]
-_0801CFA6:
- ldr r0, [sp, 0xC]
- add sp, 0x2C
- pop {r3-r5}
- mov r8, r3
- mov r9, r4
- mov r10, r5
- pop {r4-r7}
- pop {r1}
- bx r1
- .align 2, 0
-_0801CFB8: .4byte gMoveResultFlags
-_0801CFBC: .4byte gSpecialStatuses
-_0801CFC0: .4byte gBattlerTarget
-_0801CFC4: .4byte 0x0000ffff
-_0801CFC8: .4byte gBattlerAttacker
-_0801CFCC: .4byte gBattleMons
-_0801CFD0: .4byte gLastUsedItem
-_0801CFD4: .4byte gPotentialItemEffectBattler
-_0801CFD8: .4byte gBattleScripting
-_0801CFDC: .4byte gBattlescriptCurrInstr
-_0801CFE0: .4byte BattleScript_ItemHealHP_Ret
- thumb_func_end ItemBattleEffects
-
- thumb_func_start ClearFuryCutterDestinyBondGrudge
-ClearFuryCutterDestinyBondGrudge: @ 801CFE4
- lsls r0, 24
- lsrs r0, 24
- ldr r2, _0801D01C @ =gDisableStructs
- lsls r1, r0, 3
- subs r1, r0
- lsls r1, 2
- adds r1, r2
- movs r2, 0
- strb r2, [r1, 0x10]
- ldr r1, _0801D020 @ =gBattleMons
- movs r2, 0x58
- adds r3, r0, 0
- muls r3, r2
- adds r1, 0x50
- adds r3, r1
- ldr r1, [r3]
- ldr r2, _0801D024 @ =0xfdffffff
- ands r1, r2
- str r1, [r3]
- ldr r1, _0801D028 @ =gStatuses3
- lsls r0, 2
- adds r0, r1
- ldr r1, [r0]
- ldr r2, _0801D02C @ =0xffffbfff
- ands r1, r2
- str r1, [r0]
- bx lr
- .align 2, 0
-_0801D01C: .4byte gDisableStructs
-_0801D020: .4byte gBattleMons
-_0801D024: .4byte 0xfdffffff
-_0801D028: .4byte gStatuses3
-_0801D02C: .4byte 0xffffbfff
- thumb_func_end ClearFuryCutterDestinyBondGrudge
-
- thumb_func_start HandleAction_RunBattleScript
-HandleAction_RunBattleScript: @ 801D030
- push {lr}
- ldr r0, _0801D050 @ =gBattleControllerExecFlags
- ldr r0, [r0]
- cmp r0, 0
- bne _0801D04C
- ldr r1, _0801D054 @ =gUnknown_825011C
- ldr r0, _0801D058 @ =gBattlescriptCurrInstr
- ldr r0, [r0]
- ldrb r0, [r0]
- lsls r0, 2
- adds r0, r1
- ldr r0, [r0]
- bl _call_via_r0
-_0801D04C:
- pop {r0}
- bx r0
- .align 2, 0
-_0801D050: .4byte gBattleControllerExecFlags
-_0801D054: .4byte gUnknown_825011C
-_0801D058: .4byte gBattlescriptCurrInstr
- thumb_func_end HandleAction_RunBattleScript
-
- thumb_func_start GetMoveTarget
-GetMoveTarget: @ 801D05C
- push {r4-r7,lr}
- mov r7, r8
- push {r7}
- sub sp, 0x4
- lsls r0, 16
- lsrs r7, r0, 16
- lsls r1, 24
- lsrs r0, r1, 24
- movs r5, 0
- cmp r0, 0
- beq _0801D07A
- subs r0, 0x1
- lsls r0, 24
- lsrs r6, r0, 24
- b _0801D086
-_0801D07A:
- ldr r1, _0801D098 @ =gBattleMoves
- lsls r0, r7, 1
- adds r0, r7
- lsls r0, 2
- adds r0, r1
- ldrb r6, [r0, 0x6]
-_0801D086:
- cmp r6, 0x40
- bls _0801D08C
- b _0801D39C
-_0801D08C:
- lsls r0, r6, 2
- ldr r1, _0801D09C @ =_0801D0A0
- adds r0, r1
- ldr r0, [r0]
- mov pc, r0
- .align 2, 0
-_0801D098: .4byte gBattleMoves
-_0801D09C: .4byte _0801D0A0
- .align 2, 0
-_0801D0A0:
- .4byte _0801D1A4
- .4byte _0801D2A4
- .4byte _0801D398
- .4byte _0801D39C
- .4byte _0801D2BC
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D2A4
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D398
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D2A4
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D39C
- .4byte _0801D2A4
-_0801D1A4:
- ldr r0, _0801D284 @ =gBattlerAttacker
- ldrb r0, [r0]
- bl GetBattlerSide
- movs r1, 0x1
- eors r0, r1
- lsls r0, 24
- lsrs r4, r0, 24
- ldr r1, _0801D288 @ =gSideTimers
- lsls r0, r4, 1
- adds r0, r4
- lsls r0, 2
- adds r2, r0, r1
- ldrb r0, [r2, 0x8]
- cmp r0, 0
- beq _0801D1D6
- ldr r1, _0801D28C @ =gBattleMons
- ldrb r4, [r2, 0x9]
- movs r0, 0x58
- muls r0, r4
- adds r0, r1
- ldrh r0, [r0, 0x28]
- cmp r0, 0
- beq _0801D1D6
- b _0801D2EC
-_0801D1D6:
- ldr r0, _0801D284 @ =gBattlerAttacker
- ldrb r0, [r0]
- bl GetBattlerSide
- lsls r0, 24
- lsrs r4, r0, 24
- lsls r0, r7, 1
- mov r8, r0
-_0801D1E6:
- bl Random
- lsls r0, 16
- lsrs r0, 16
- ldr r1, _0801D290 @ =gBattlersCount
- ldrb r1, [r1]
- bl __modsi3
- lsls r0, 24
- lsrs r5, r0, 24
- ldr r6, _0801D284 @ =gBattlerAttacker
- ldrb r3, [r6]
- cmp r5, r3
- beq _0801D1E6
- adds r0, r5, 0
- bl GetBattlerSide
- lsls r0, 24
- lsrs r0, 24
- cmp r4, r0
- beq _0801D1E6
- ldr r0, _0801D294 @ =gAbsentBattlerFlags
- ldrb r2, [r0]
- ldr r1, _0801D298 @ =gBitTable
- lsls r0, r5, 2
- adds r0, r1
- ldr r0, [r0]
- ands r2, r0
- cmp r2, 0
- bne _0801D1E6
- ldr r0, _0801D29C @ =gBattleMoves
- mov r3, r8
- adds r1, r3, r7
- lsls r1, 2
- adds r1, r0
- ldrb r0, [r1, 0x2]
- cmp r0, 0xD
- beq _0801D234
- b _0801D39C
-_0801D234:
- ldrb r1, [r6]
- str r2, [sp]
- movs r0, 0x10
- movs r2, 0x1F
- movs r3, 0
- bl AbilityBattleEffects
- lsls r0, 24
- cmp r0, 0
- bne _0801D24A
- b _0801D39C
-_0801D24A:
- ldr r2, _0801D28C @ =gBattleMons
- movs r1, 0x58
- adds r0, r5, 0
- muls r0, r1
- adds r0, r2
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x1F
- bne _0801D25E
- b _0801D39C
-_0801D25E:
- movs r4, 0x2
- eors r5, r4
- adds r0, r5, 0
- muls r0, r1
- adds r0, r2
- adds r0, 0x20
- ldrb r1, [r0]
- adds r0, r5, 0
- bl RecordAbilityBattle
- ldr r1, _0801D2A0 @ =gSpecialStatuses
- lsls r0, r5, 2
- adds r0, r5
- lsls r0, 2
- adds r0, r1
- ldrb r1, [r0]
- orrs r1, r4
- strb r1, [r0]
- b _0801D39C
- .align 2, 0
-_0801D284: .4byte gBattlerAttacker
-_0801D288: .4byte gSideTimers
-_0801D28C: .4byte gBattleMons
-_0801D290: .4byte gBattlersCount
-_0801D294: .4byte gAbsentBattlerFlags
-_0801D298: .4byte gBitTable
-_0801D29C: .4byte gBattleMoves
-_0801D2A0: .4byte gSpecialStatuses
-_0801D2A4:
- ldr r0, _0801D2B8 @ =gBattlerAttacker
- ldrb r0, [r0]
- bl GetBattlerPosition
- adds r1, r0, 0
- movs r2, 0x1
- movs r0, 0x1
- ands r0, r1
- eors r0, r2
- b _0801D34E
- .align 2, 0
-_0801D2B8: .4byte gBattlerAttacker
-_0801D2BC:
- ldr r0, _0801D2F0 @ =gBattlerAttacker
- ldrb r0, [r0]
- bl GetBattlerSide
- movs r1, 0x1
- eors r0, r1
- lsls r0, 24
- lsrs r4, r0, 24
- ldr r1, _0801D2F4 @ =gSideTimers
- lsls r0, r4, 1
- adds r0, r4
- lsls r0, 2
- adds r2, r0, r1
- ldrb r0, [r2, 0x8]
- cmp r0, 0
- beq _0801D2FC
- ldr r1, _0801D2F8 @ =gBattleMons
- ldrb r4, [r2, 0x9]
- movs r0, 0x58
- muls r0, r4
- adds r0, r1
- ldrh r0, [r0, 0x28]
- cmp r0, 0
- beq _0801D2FC
-_0801D2EC:
- adds r5, r4, 0
- b _0801D39C
- .align 2, 0
-_0801D2F0: .4byte gBattlerAttacker
-_0801D2F4: .4byte gSideTimers
-_0801D2F8: .4byte gBattleMons
-_0801D2FC:
- ldr r0, _0801D330 @ =gBattleTypeFlags
- ldr r0, [r0]
- movs r4, 0x1
- ands r0, r4
- cmp r0, 0
- beq _0801D378
- movs r0, 0x4
- ands r6, r0
- cmp r6, 0
- beq _0801D378
- ldr r0, _0801D334 @ =gBattlerAttacker
- ldrb r0, [r0]
- bl GetBattlerSide
- lsls r0, 24
- cmp r0, 0
- bne _0801D33C
- bl Random
- adds r1, r4, 0
- ands r1, r0
- cmp r1, 0
- beq _0801D338
- movs r0, 0x1
- b _0801D34E
- .align 2, 0
-_0801D330: .4byte gBattleTypeFlags
-_0801D334: .4byte gBattlerAttacker
-_0801D338:
- movs r0, 0x3
- b _0801D34E
-_0801D33C:
- bl Random
- adds r1, r4, 0
- ands r1, r0
- cmp r1, 0
- beq _0801D34C
- movs r0, 0
- b _0801D34E
-_0801D34C:
- movs r0, 0x2
-_0801D34E:
- bl GetBattlerAtPosition
- lsls r0, 24
- lsrs r5, r0, 24
- ldr r0, _0801D370 @ =gAbsentBattlerFlags
- ldrb r1, [r0]
- ldr r2, _0801D374 @ =gBitTable
- lsls r0, r5, 2
- adds r0, r2
- ldr r0, [r0]
- ands r1, r0
- cmp r1, 0
- beq _0801D39C
- movs r0, 0x2
- eors r5, r0
- b _0801D39C
- .align 2, 0
-_0801D370: .4byte gAbsentBattlerFlags
-_0801D374: .4byte gBitTable
-_0801D378:
- ldr r0, _0801D394 @ =gBattlerAttacker
- ldrb r0, [r0]
- bl GetBattlerPosition
- adds r1, r0, 0
- movs r2, 0x1
- movs r0, 0x1
- ands r0, r1
- eors r0, r2
- bl GetBattlerAtPosition
- lsls r0, 24
- lsrs r5, r0, 24
- b _0801D39C
- .align 2, 0
-_0801D394: .4byte gBattlerAttacker
-_0801D398:
- ldr r0, _0801D3B8 @ =gBattlerAttacker
- ldrb r5, [r0]
-_0801D39C:
- ldr r0, _0801D3B8 @ =gBattlerAttacker
- ldrb r0, [r0]
- ldr r1, _0801D3BC @ =gBattleStruct
- ldr r1, [r1]
- adds r0, r1
- strb r5, [r0, 0xC]
- adds r0, r5, 0
- add sp, 0x4
- pop {r3}
- mov r8, r3
- pop {r4-r7}
- pop {r1}
- bx r1
- .align 2, 0
-_0801D3B8: .4byte gBattlerAttacker
-_0801D3BC: .4byte gBattleStruct
- thumb_func_end GetMoveTarget
-
- thumb_func_start HasObedientBitSet
-HasObedientBitSet: @ 801D3C0
- push {r4-r7,lr}
- lsls r0, 24
- lsrs r4, r0, 24
- adds r0, r4, 0
- bl GetBattlerSide
- lsls r0, 24
- lsrs r0, 24
- cmp r0, 0x1
- beq _0801D406
- ldr r0, _0801D40C @ =gBattlerPartyIndexes
- lsls r4, 1
- adds r5, r4, r0
- ldrh r0, [r5]
- movs r7, 0x64
- muls r0, r7
- ldr r6, _0801D410 @ =gPlayerParty
- adds r0, r6
- movs r1, 0xB
- movs r2, 0
- bl GetMonData
- movs r1, 0xCD
- lsls r1, 1
- cmp r0, r1
- beq _0801D414
- ldrh r0, [r5]
- muls r0, r7
- adds r0, r6
- movs r1, 0xB
- movs r2, 0
- bl GetMonData
- cmp r0, 0x97
- beq _0801D414
-_0801D406:
- movs r0, 0x1
- b _0801D42A
- .align 2, 0
-_0801D40C: .4byte gBattlerPartyIndexes
-_0801D410: .4byte gPlayerParty
-_0801D414:
- ldr r0, _0801D430 @ =gBattlerPartyIndexes
- adds r0, r4, r0
- ldrh r1, [r0]
- movs r0, 0x64
- muls r0, r1
- ldr r1, _0801D434 @ =gPlayerParty
- adds r0, r1
- movs r1, 0x50
- movs r2, 0
- bl GetMonData
-_0801D42A:
- pop {r4-r7}
- pop {r1}
- bx r1
- .align 2, 0
-_0801D430: .4byte gBattlerPartyIndexes
-_0801D434: .4byte gPlayerParty
- thumb_func_end HasObedientBitSet
-
- thumb_func_start IsMonDisobedient
-IsMonDisobedient: @ 801D438
- push {r4-r7,lr}
- mov r7, r8
- push {r7}
- sub sp, 0x10
- movs r6, 0
- ldr r0, _0801D4F8 @ =gBattleTypeFlags
- ldr r0, [r0]
- ldr r1, _0801D4FC @ =0x00010002
- ands r0, r1
- cmp r0, 0
- bne _0801D4F4
- ldr r4, _0801D500 @ =gBattlerAttacker
- ldrb r0, [r4]
- bl GetBattlerSide
- lsls r0, 24
- lsrs r0, 24
- cmp r0, 0x1
- beq _0801D4F4
- ldrb r0, [r4]
- bl HasObedientBitSet
- cmp r0, 0
- beq _0801D4BE
- ldr r2, _0801D504 @ =gBattleMons
- ldrb r1, [r4]
- movs r0, 0x58
- muls r1, r0
- adds r0, r2, 0
- adds r0, 0x54
- adds r0, r1, r0
- ldr r0, [r0]
- adds r2, 0x3C
- adds r1, r2
- bl IsOtherTrainer
- lsls r0, 24
- cmp r0, 0
- beq _0801D4F4
- ldr r0, _0801D508 @ =0x00000827
- bl FlagGet
- lsls r0, 24
- cmp r0, 0
- bne _0801D4F4
- movs r6, 0xA
- ldr r0, _0801D50C @ =0x00000821
- bl FlagGet
- lsls r0, 24
- cmp r0, 0
- beq _0801D4A2
- movs r6, 0x1E
-_0801D4A2:
- ldr r0, _0801D510 @ =0x00000823
- bl FlagGet
- lsls r0, 24
- cmp r0, 0
- beq _0801D4B0
- movs r6, 0x32
-_0801D4B0:
- ldr r0, _0801D514 @ =0x00000825
- bl FlagGet
- lsls r0, 24
- cmp r0, 0
- beq _0801D4BE
- movs r6, 0x46
-_0801D4BE:
- ldr r5, _0801D504 @ =gBattleMons
- ldr r0, _0801D500 @ =gBattlerAttacker
- mov r8, r0
- ldrb r0, [r0]
- movs r7, 0x58
- muls r0, r7
- adds r0, r5
- adds r0, 0x2A
- ldrb r0, [r0]
- cmp r0, r6
- bls _0801D4F4
- bl Random
- movs r1, 0xFF
- ands r1, r0
- mov r2, r8
- ldrb r0, [r2]
- adds r2, r0, 0
- muls r2, r7
- adds r0, r2, r5
- adds r0, 0x2A
- ldrb r0, [r0]
- adds r0, r6
- muls r0, r1
- asrs r4, r0, 8
- cmp r4, r6
- bge _0801D518
-_0801D4F4:
- movs r0, 0
- b _0801D738
- .align 2, 0
-_0801D4F8: .4byte gBattleTypeFlags
-_0801D4FC: .4byte 0x00010002
-_0801D500: .4byte gBattlerAttacker
-_0801D504: .4byte gBattleMons
-_0801D508: .4byte 0x00000827
-_0801D50C: .4byte 0x00000821
-_0801D510: .4byte 0x00000823
-_0801D514: .4byte 0x00000825
-_0801D518:
- ldr r3, _0801D554 @ =gCurrentMove
- ldrh r0, [r3]
- cmp r0, 0x63
- bne _0801D52E
- adds r0, r5, 0
- adds r0, 0x50
- adds r0, r2, r0
- ldr r1, [r0]
- ldr r2, _0801D558 @ =0xff7fffff
- ands r1, r2
- str r1, [r0]
-_0801D52E:
- mov r1, r8
- ldrb r0, [r1]
- muls r0, r7
- adds r1, r5, 0
- adds r1, 0x4C
- adds r0, r1
- ldr r0, [r0]
- movs r1, 0x7
- ands r0, r1
- cmp r0, 0
- beq _0801D564
- ldrh r0, [r3]
- cmp r0, 0xAD
- beq _0801D54E
- cmp r0, 0xD6
- bne _0801D564
-_0801D54E:
- ldr r1, _0801D55C @ =gBattlescriptCurrInstr
- ldr r0, _0801D560 @ =BattleScript_IgnoresWhileAsleep
- b _0801D6E2
- .align 2, 0
-_0801D554: .4byte gCurrentMove
-_0801D558: .4byte 0xff7fffff
-_0801D55C: .4byte gBattlescriptCurrInstr
-_0801D560: .4byte BattleScript_IgnoresWhileAsleep
-_0801D564:
- bl Random
- movs r1, 0xFF
- ands r1, r0
- ldr r2, _0801D608 @ =gBattleMons
- ldr r0, _0801D60C @ =gBattlerAttacker
- ldrb r3, [r0]
- movs r0, 0x58
- muls r0, r3
- adds r0, r2
- adds r0, 0x2A
- ldrb r0, [r0]
- adds r0, r6
- muls r0, r1
- asrs r4, r0, 8
- cmp r4, r6
- bge _0801D634
- ldr r0, _0801D610 @ =gCurrentMove
- ldrh r1, [r0]
- movs r0, 0x84
- lsls r0, 1
- cmp r1, r0
- beq _0801D634
- ldr r6, _0801D614 @ =gBitTable
- ldr r5, _0801D618 @ =gUnknown_2023D48
- ldrb r0, [r5]
- lsls r0, 2
- adds r0, r6
- ldrb r1, [r0]
- adds r0, r3, 0
- movs r2, 0xFF
- bl CheckMoveLimitations
- lsls r0, 24
- lsrs r4, r0, 24
- cmp r4, 0xF
- bne _0801D5B0
- b _0801D6D2
-_0801D5B0:
- ldr r2, _0801D61C @ =gUnknown_2023D49
- mov r8, r2
- movs r7, 0x3
-_0801D5B6:
- bl Random
- ands r0, r7
- mov r1, r8
- strb r0, [r1]
- strb r0, [r5]
- ldrb r0, [r5]
- lsls r0, 2
- adds r0, r6
- ldr r0, [r0]
- ands r0, r4
- cmp r0, 0
- bne _0801D5B6
- ldr r4, _0801D620 @ =gUnknown_2023D4E
- ldr r3, _0801D608 @ =gBattleMons
- ldr r0, _0801D618 @ =gUnknown_2023D48
- ldrb r0, [r0]
- lsls r0, 1
- ldr r1, _0801D60C @ =gBattlerAttacker
- ldrb r2, [r1]
- movs r1, 0x58
- muls r1, r2
- adds r0, r1
- adds r3, 0xC
- adds r0, r3
- ldrh r0, [r0]
- strh r0, [r4]
- ldr r1, _0801D624 @ =gBattlescriptCurrInstr
- ldr r0, _0801D628 @ =BattleScript_IgnoresAndUsesRandomMove
- str r0, [r1]
- ldrh r0, [r4]
- movs r1, 0
- bl GetMoveTarget
- ldr r1, _0801D62C @ =gBattlerTarget
- strb r0, [r1]
- ldr r2, _0801D630 @ =gHitMarker
- ldr r0, [r2]
- movs r1, 0x80
- lsls r1, 14
- b _0801D732
- .align 2, 0
-_0801D608: .4byte gBattleMons
-_0801D60C: .4byte gBattlerAttacker
-_0801D610: .4byte gCurrentMove
-_0801D614: .4byte gBitTable
-_0801D618: .4byte gUnknown_2023D48
-_0801D61C: .4byte gUnknown_2023D49
-_0801D620: .4byte gUnknown_2023D4E
-_0801D624: .4byte gBattlescriptCurrInstr
-_0801D628: .4byte BattleScript_IgnoresAndUsesRandomMove
-_0801D62C: .4byte gBattlerTarget
-_0801D630: .4byte gHitMarker
-_0801D634:
- ldr r5, _0801D6B8 @ =gBattleMons
- ldr r2, _0801D6BC @ =gBattlerAttacker
- mov r8, r2
- ldrb r0, [r2]
- movs r7, 0x58
- muls r0, r7
- adds r0, r5
- adds r0, 0x2A
- ldrb r0, [r0]
- subs r0, r6
- lsls r0, 24
- lsrs r6, r0, 24
- bl Random
- movs r2, 0xFF
- adds r4, r2, 0
- ands r4, r0
- cmp r4, r6
- bge _0801D6CC
- mov r1, r8
- ldrb r0, [r1]
- adds r1, r0, 0
- muls r1, r7
- adds r0, r5, 0
- adds r0, 0x4C
- adds r0, r1, r0
- ldr r0, [r0]
- ands r0, r2
- cmp r0, 0
- bne _0801D6CC
- adds r0, r1, r5
- adds r0, 0x20
- ldrb r0, [r0]
- cmp r0, 0x48
- beq _0801D6CC
- cmp r0, 0xF
- beq _0801D6CC
- movs r2, 0
- ldr r0, _0801D6C0 @ =gBattlersCount
- ldrb r3, [r0]
- adds r7, r0, 0
- cmp r2, r3
- bge _0801D6AA
- ldr r0, [r5, 0x50]
- movs r1, 0x70
- ands r0, r1
- cmp r0, 0
- bne _0801D6AA
- adds r1, r5, 0
- adds r1, 0x50
- movs r5, 0x70
-_0801D69A:
- adds r1, 0x58
- adds r2, 0x1
- cmp r2, r3
- bge _0801D6AA
- ldr r0, [r1]
- ands r0, r5
- cmp r0, 0
- beq _0801D69A
-_0801D6AA:
- ldrb r7, [r7]
- cmp r2, r7
- bne _0801D6CC
- ldr r1, _0801D6C4 @ =gBattlescriptCurrInstr
- ldr r0, _0801D6C8 @ =BattleScript_IgnoresAndFallsAsleep
- b _0801D6E2
- .align 2, 0
-_0801D6B8: .4byte gBattleMons
-_0801D6BC: .4byte gBattlerAttacker
-_0801D6C0: .4byte gBattlersCount
-_0801D6C4: .4byte gBattlescriptCurrInstr
-_0801D6C8: .4byte BattleScript_IgnoresAndFallsAsleep
-_0801D6CC:
- subs r4, r6
- cmp r4, r6
- blt _0801D6F4
-_0801D6D2:
- bl Random
- ldr r2, _0801D6E8 @ =gBattleCommunication
- movs r1, 0x3
- ands r1, r0
- strb r1, [r2, 0x5]
- ldr r1, _0801D6EC @ =gBattlescriptCurrInstr
- ldr r0, _0801D6F0 @ =BattleScript_MoveUsedLoafingAround
-_0801D6E2:
- str r0, [r1]
- movs r0, 0x1
- b _0801D738
- .align 2, 0
-_0801D6E8: .4byte gBattleCommunication
-_0801D6EC: .4byte gBattlescriptCurrInstr
-_0801D6F0: .4byte BattleScript_MoveUsedLoafingAround
-_0801D6F4:
- ldr r4, _0801D744 @ =gBattlerAttacker
- ldrb r1, [r4]
- movs r0, 0x58
- muls r1, r0
- ldr r0, _0801D748 @ =gBattleMons
- adds r1, r0
- movs r0, 0x28
- str r0, [sp]
- movs r0, 0
- str r0, [sp, 0x4]
- ldrb r0, [r4]
- str r0, [sp, 0x8]
- ldrb r0, [r4]
- str r0, [sp, 0xC]
- adds r0, r1, 0
- movs r2, 0x1
- movs r3, 0
- bl CalculateBaseDamage
- ldr r1, _0801D74C @ =gBattleMoveDamage
- str r0, [r1]
- ldr r1, _0801D750 @ =gBattlerTarget
- ldrb r0, [r4]
- strb r0, [r1]
- ldr r1, _0801D754 @ =gBattlescriptCurrInstr
- ldr r0, _0801D758 @ =BattleScript_IgnoresAndHitsItself
- str r0, [r1]
- ldr r2, _0801D75C @ =gHitMarker
- ldr r0, [r2]
- movs r1, 0x80
- lsls r1, 12
-_0801D732:
- orrs r0, r1
- str r0, [r2]
- movs r0, 0x2
-_0801D738:
- add sp, 0x10
- pop {r3}
- mov r8, r3
- pop {r4-r7}
- pop {r1}
- bx r1
- .align 2, 0
-_0801D744: .4byte gBattlerAttacker
-_0801D748: .4byte gBattleMons
-_0801D74C: .4byte gBattleMoveDamage
-_0801D750: .4byte gBattlerTarget
-_0801D754: .4byte gBattlescriptCurrInstr
-_0801D758: .4byte BattleScript_IgnoresAndHitsItself
-_0801D75C: .4byte gHitMarker
- thumb_func_end IsMonDisobedient
-
- .align 2, 0 @ Don't pad with nop.
diff --git a/data/data.s b/data/data.s
index 65f48e4f3..8b3e66bdc 100644
--- a/data/data.s
+++ b/data/data.s
@@ -281,7 +281,7 @@ gUnknown_82500CC:: @ 82500CC
.section .rodata.825011C
.balign 4
-gUnknown_825011C:: @ 825011C
+gBattleScriptingCommandsTable:: @ 825011C
.incbin "baserom.gba", 0x25011C, 0x3E0
gUnknown_82504FC:: @ 82504FC
diff --git a/include/battle.h b/include/battle.h
index 7db128430..357bbbd8c 100644
--- a/include/battle.h
+++ b/include/battle.h
@@ -987,6 +987,8 @@ extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT];
extern u8 gMoveResultFlags;
extern s32 gTakenDmg[MAX_BATTLERS_COUNT];
extern u8 gTakenDmgByBattler[MAX_BATTLERS_COUNT];
-
+extern u8 gCurrentActionFuncId;
+extern u8 gCurrMovePos;
+extern u8 gChosenMovePos;
#endif // GUARD_BATTLE_H
diff --git a/include/battle_scripts.h b/include/battle_scripts.h
index 185f6228d..c592ba6b8 100644
--- a/include/battle_scripts.h
+++ b/include/battle_scripts.h
@@ -28,16 +28,8 @@ extern const u8 BattleScript_LocalBattleLost[];
extern const u8 BattleScript_LocalBattleLostPrintWhiteOut[];
extern const u8 BattleScript_LocalBattleLostEnd[];
extern const u8 BattleScript_CheckDomeDrew[];
-extern const u8 BattleScript_82DAA0B[];
-extern const u8 BattleScript_82DAA31[];
extern const u8 BattleScript_LinkBattleWonOrLost[];
-extern const u8 BattleScript_82DAA5C[];
-extern const u8 BattleScript_82DAA83[];
extern const u8 BattleScript_FrontierTrainerBattleWon[];
-extern const u8 BattleScript_82DAAAB[];
-extern const u8 BattleScript_82DAAAE[];
-extern const u8 BattleScript_82DAACB[];
-extern const u8 BattleScript_82DAADA[];
extern const u8 BattleScript_SmokeBallEscape[];
extern const u8 BattleScript_RanAwayUsingMonAbility[];
extern const u8 BattleScript_GotAwaySafely[];
@@ -47,11 +39,6 @@ extern const u8 BattleScript_PrintFailedToRunString[];
extern const u8 BattleScript_PrintCantEscapeFromBattle[];
extern const u8 BattleScript_PrintFullBox[];
extern const u8 BattleScript_ActionSwitch[];
-extern const u8 BattleScript_82DAB35[];
-extern const u8 BattleScript_82DAB37[];
-extern const u8 BattleScript_82DAB44[];
-extern const u8 BattleScript_82DAB77[];
-extern const u8 BattleScript_82DABB8[];
extern const u8 BattleScript_Pausex20[];
extern const u8 BattleScript_LevelUp[];
extern const u8 BattleScript_RainContinuesOrEnds[];
@@ -64,13 +51,10 @@ extern const u8 BattleScript_SideStatusWoreOff[];
extern const u8 BattleScript_SafeguardProtected[];
extern const u8 BattleScript_SafeguardEnds[];
extern const u8 BattleScript_LeechSeedTurnDrain[];
-extern const u8 BattleScript_82DAD47[];
-extern const u8 BattleScript_82DAD4D[];
extern const u8 BattleScript_BideStoringEnergy[];
extern const u8 BattleScript_BideAttack[];
extern const u8 BattleScript_BideNoEnergyToAttack[];
extern const u8 BattleScript_SuccessForceOut[];
-extern const u8 BattleScript_82DADF1[];
extern const u8 BattleScript_MistProtected[];
extern const u8 BattleScript_RageIsBuilding[];
extern const u8 BattleScript_MoveUsedIsDisabled[];
@@ -81,32 +65,16 @@ extern const u8 BattleScript_SelectingUnusableMoveInPalace[];
extern const u8 BattleScript_EncoredNoMore[];
extern const u8 BattleScript_DestinyBondTakesLife[];
extern const u8 BattleScript_SpikesOnAttacker[];
-extern const u8 BattleScript_82DAE7A[];
extern const u8 BattleScript_SpikesOnTarget[];
-extern const u8 BattleScript_82DAEB1[];
extern const u8 BattleScript_SpikesOngBank1[];
-extern const u8 BattleScript_82DAEE8[];
-extern const u8 BattleScript_82DAEFE[];
extern const u8 BattleScript_PerishSongTakesLife[];
extern const u8 BattleScript_PerishSongCountGoesDown[];
extern const u8 BattleScript_AllStatsUp[];
-extern const u8 BattleScript_82DAF54[];
-extern const u8 BattleScript_82DAF72[];
-extern const u8 BattleScript_82DAF86[];
-extern const u8 BattleScript_82DAF9A[];
-extern const u8 BattleScript_82DAFAE[];
-extern const u8 BattleScript_82DAFC2[];
extern const u8 BattleScript_RapidSpinAway[];
extern const u8 BattleScript_WrapFree[];
extern const u8 BattleScript_LeechSeedFree[];
extern const u8 BattleScript_SpikesFree[];
extern const u8 BattleScript_MonTookFutureAttack[];
-extern const u8 BattleScript_82DB001[];
-extern const u8 BattleScript_82DB008[];
-extern const u8 BattleScript_82DB020[];
-extern const u8 BattleScript_82DB027[];
-extern const u8 BattleScript_82DB03F[];
-extern const u8 BattleScript_82DB058[];
extern const u8 BattleScript_NoMovesLeft[];
extern const u8 BattleScript_SelectingMoveWithNoPP[];
extern const u8 BattleScript_NoPPForMove[];
@@ -119,8 +87,6 @@ extern const u8 BattleScript_SelectingNotAllowedMoveTauntInPalace[];
extern const u8 BattleScript_WishComesTrue[];
extern const u8 BattleScript_IngrainTurnHeal[];
extern const u8 BattleScript_AtkDefDown[];
-extern const u8 BattleScript_82DB144[];
-extern const u8 BattleScript_82DB167[];
extern const u8 BattleScript_KnockedOff[];
extern const u8 BattleScript_MoveUsedIsImprisoned[];
extern const u8 BattleScript_SelectingImprisonedMove[];
@@ -131,15 +97,11 @@ extern const u8 BattleScript_SnatchedMove[];
extern const u8 BattleScript_EnduredMsg[];
extern const u8 BattleScript_OneHitKOMsg[];
extern const u8 BattleScript_SAtkDown2[];
-extern const u8 BattleScript_82DB1FE[];
extern const u8 BattleScript_FocusPunchSetUp[];
extern const u8 BattleScript_MoveUsedIsAsleep[];
extern const u8 BattleScript_MoveUsedWokeUp[];
extern const u8 BattleScript_MonWokeUpInUproar[];
extern const u8 BattleScript_PoisonTurnDmg[];
-extern const u8 BattleScript_82DB243[];
-extern const u8 BattleScript_82DB245[];
-extern const u8 BattleScript_82DB25E[];
extern const u8 BattleScript_BurnTurnDmg[];
extern const u8 BattleScript_MoveUsedIsFrozen[];
extern const u8 BattleScript_MoveUsedUnfroze[];
@@ -149,8 +111,6 @@ extern const u8 BattleScript_MoveUsedFlinched[];
extern const u8 BattleScript_PrintUproarOverTurns[];
extern const u8 BattleScript_ThrashConfuses[];
extern const u8 BattleScript_MoveUsedIsConfused[];
-extern const u8 BattleScript_82DB2D4[];
-extern const u8 BattleScript_82DB2FF[];
extern const u8 BattleScript_MoveUsedIsConfusedNoMore[];
extern const u8 BattleScript_PrintPayDayMoneyString[];
extern const u8 BattleScript_WrapTurnDmg[];
@@ -162,7 +122,6 @@ extern const u8 BattleScript_NightmareTurnDmg[];
extern const u8 BattleScript_CurseTurnDmg[];
extern const u8 BattleScript_TargetPRLZHeal[];
extern const u8 BattleScript_MoveEffectSleep[];
-extern const u8 BattleScript_82DB374[];
extern const u8 BattleScript_YawnMakesAsleep[];
extern const u8 BattleScript_MoveEffectPoison[];
extern const u8 BattleScript_MoveEffectBurn[];
@@ -186,14 +145,6 @@ extern const u8 BattleScript_ShedSkinActivates[];
extern const u8 BattleScript_WeatherFormChanges[];
extern const u8 BattleScript_WeatherFormChangesLoop[];
extern const u8 BattleScript_CastformChange[];
-extern const u8 BattleScript_82DB4AF[];
-extern const u8 BattleScript_82DB4B8[];
-extern const u8 BattleScript_82DB4BE[];
-extern const u8 BattleScript_82DB4C1[];
-extern const u8 BattleScript_82DB4CD[];
-extern const u8 BattleScript_82DB510[];
-extern const u8 BattleScript_82DB51B[];
-extern const u8 BattleScript_82DB51C[];
extern const u8 BattleScript_DroughtActivates[];
extern const u8 BattleScript_TookAttack[];
extern const u8 BattleScript_SturdyPreventsOHKO[];
@@ -221,12 +172,9 @@ extern const u8 BattleScript_ApplySecondaryEffect[];
extern const u8 BattleScript_SynchronizeActivates[];
extern const u8 BattleScript_NoItemSteal[];
extern const u8 BattleScript_AbilityCuredStatus[];
-extern const u8 BattleScript_82DB695[];
extern const u8 BattleScript_IgnoresAndUsesRandomMove[];
extern const u8 BattleScript_MoveUsedLoafingAround[];
-extern const u8 BattleScript_82DB6C7[];
extern const u8 BattleScript_IgnoresAndFallsAsleep[];
-extern const u8 BattleScript_82DB6F0[];
extern const u8 BattleScript_SubstituteFade[];
extern const u8 BattleScript_BerryCurePrlzEnd2[];
extern const u8 BattleScript_BerryCureParRet[];
@@ -252,18 +200,8 @@ extern const u8 BattleScript_SelectingNotAllowedMoveChoiceItem[];
extern const u8 BattleScript_HangedOnMsg[];
extern const u8 BattleScript_BerryConfuseHealEnd2[];
extern const u8 BattleScript_BerryStatRaiseEnd2[];
-extern const u8 BattleScript_82DB85B[];
extern const u8 BattleScript_BerryFocusEnergyEnd2[];
extern const u8 BattleScript_ActionSelectionItemsCantBeUsed[];
-extern const u8 BattleScript_82DB87D[];
-extern const u8 BattleScript_82DB881[];
-extern const u8 BattleScript_82DB887[];
-extern const u8 BattleScript_82DB89D[];
-extern const u8 BattleScript_82DB8BE[];
-extern const u8 BattleScript_82DB8E0[];
-extern const u8 BattleScript_82DB8F3[];
-extern const u8 BattleScript_82DB973[];
-extern const u8 BattleScript_82DB992[];
extern const u8 BattleScript_AskIfWantsToForfeitMatch[];
extern const u8 BattleScript_PrintPlayerForfeited[];
extern const u8 BattleScript_PrintPlayerForfeitedLinkBattle[];
@@ -271,27 +209,18 @@ extern const u8 BattleScript_BallThrow[];
extern const u8 BattleScript_BallThrowByWally[];
extern const u8 BattleScript_SafariBallThrow[];
extern const u8 BattleScript_SuccessBallThrow[];
-extern const u8 BattleScript_82DBD92[];
-extern const u8 BattleScript_82DBDA5[];
-extern const u8 BattleScript_82DBDC2[];
-extern const u8 BattleScript_82DBDC3[];
extern const u8 BattleScript_WallyBallThrow[];
extern const u8 BattleScript_ShakeBallThrow[];
-extern const u8 BattleScript_82DBE01[];
extern const u8 BattleScript_TrainerBallBlock[];
-extern const u8 BattleScript_82DBE12[];
-extern const u8 BattleScript_82DBE1C[];
-extern const u8 BattleScript_82DBE4B[];
-extern const u8 BattleScript_82DBE6F[];
-extern const u8 BattleScript_82DBE91[];
extern const u8 BattleScript_RunByUsingItem[];
extern const u8 BattleScript_ActionWatchesCarefully[];
extern const u8 BattleScript_ActionGetNear[];
extern const u8 BattleScript_ActionThrowPokeblock[];
-extern const u8 BattleScript_82DBEE3[];
extern const u8 gUnknown_81D9192[];
extern const u8 gUnknown_81D9180[];
extern const u8 BattleScript_IntimidateActivates[];
extern const u8 BattleScript_IntimidateActivatesEnd3[];
+extern const u8 BattleScript_IgnoresWhileAsleep[];
+extern const u8 BattleScript_IgnoresAndHitsItself[];
#endif // GUARD_BATTLE_SCRIPTS_H
diff --git a/include/battle_util.h b/include/battle_util.h
index dfe7be60a..797f0ef52 100644
--- a/include/battle_util.h
+++ b/include/battle_util.h
@@ -52,45 +52,41 @@
#define BS_GET_PLAYER2 13
#define BS_GET_OPPONENT2 14
-u8 GetBattleBank(u8 caseId);
-void PressurePPLose(u8 bankDef, u8 bankAtk, u16 move);
-void PressurePPLoseOnUsingPerishSong(u8 bankAtk);
-void PressurePPLoseOnUsingImprison(u8 bankAtk);
-void MarkAllBattlersForControllerExec(void); // unused
-void MarkBattlerForControllerExec(u8 bank);
-void sub_803F850(u8 arg0);
-void CancelMultiTurnMoves(u8 bank);
-bool8 WasUnableToUseMove(u8 bank);
-void PrepareStringBattle(u16 stringId, u8 bank);
+u8 GetBattlerForBattleScript(u8 caseId);
+void PressurePPLose(u8 target, u8 attacker, u16 move);
+void PressurePPLoseOnUsingImprison(u8 attacker);
+void PressurePPLoseOnUsingPerishSong(u8 attacker);
+void MarkAllBattlersForControllerExec(void);
+void MarkBattlerForControllerExec(u8 battlerId);
+void sub_8017298(u8 arg0);
+void CancelMultiTurnMoves(u8 battler);
+bool8 WasUnableToUseMove(u8 battler);
+void PrepareStringBattle(u16 stringId, u8 battler);
void ResetSentPokesToOpponentValue(void);
-void sub_803F9EC(u8 bank);
-void sub_803FA70(u8 bank);
-void BattleScriptPush(const u8* bsPtr);
+void sub_8017434(u8 battler);
+void sub_80174B8(u8 battler);
+void BattleScriptPush(const u8 *bsPtr);
void BattleScriptPushCursor(void);
void BattleScriptPop(void);
u8 TrySetCantSelectMoveBattleScript(void);
-u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check);
+u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check);
bool8 AreAllMovesUnusable(void);
-u8 GetImprisonedMovesCount(u8 bank, u16 move);
+u8 GetImprisonedMovesCount(u8 battlerId, u16 move);
u8 DoFieldEndTurnEffects(void);
u8 DoBattlerEndTurnEffects(void);
bool8 HandleWishPerishSongOnTurnEnd(void);
bool8 HandleFaintedMonActions(void);
void TryClearRageStatuses(void);
u8 AtkCanceller_UnableToUseMove(void);
-bool8 sub_80423F4(u8 bank, u8 r1, u8 r2);
-u8 CastformDataTypeChange(u8 bank);
-u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg);
-void BattleScriptExecute(const u8* BS_ptr);
-void BattleScriptPushCursorAndCallback(const u8* BS_ptr);
-u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn);
-void ClearFuryCutterDestinyBondGrudge(u8 bank);
+bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2);
+u8 CastformDataTypeChange(u8 battler);
+u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveArg);
+void BattleScriptExecute(const u8 *BS_ptr);
+void BattleScriptPushCursorAndCallback(const u8 *BS_ptr);
+u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn);
+void ClearFuryCutterDestinyBondGrudge(u8 battlerId);
void HandleAction_RunBattleScript(void);
-u8 GetMoveTarget(u16 move, u8 useMoveTarget);
+u8 GetMoveTarget(u16 move, u8 setTarget);
u8 IsMonDisobedient(void);
-void MarkBattlerForControllerExec(u8 battlerId);
-void sub_80174B8(u8 battlerId);
-void sub_8017298(u8 battlerId);
-bool8 HasNoMonsToSwitch(u8 battler, u8 partyIdBattlerOn1, u8 partyIdBattlerOn2);
#endif // GUARD_BATTLE_UTIL_H
diff --git a/include/constants/pokemon.h b/include/constants/pokemon.h
index 78c1583b4..6942fee83 100644
--- a/include/constants/pokemon.h
+++ b/include/constants/pokemon.h
@@ -77,4 +77,10 @@
#define STAT_ACC 6 // only in battles
#define STAT_EVASION 7 // only in battles
+#define NUM_STATS 6
+#define NUM_BATTLE_STATS 8
+
+// Shiny odds
+#define SHINY_ODDS 8 // Actual probability is SHINY_ODDS/65536
+
#endif // GUARD_CONSTANTS_POKEMON_H
diff --git a/ld_script.txt b/ld_script.txt
index fb98e6fdd..f52bcb988 100644
--- a/ld_script.txt
+++ b/ld_script.txt
@@ -68,7 +68,6 @@ SECTIONS {
asm/battle_1.o(.text);
asm/battle_2.o(.text);
src/battle_util.o(.text);
- asm/battle_util.o(.text);
asm/battle_script_commands.o(.text);
src/battle_util2.o(.text);
asm/battle_controller_player.o(.text);
diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c
index 913068aed..1be10d228 100644
--- a/src/battle_ai_script_commands.c
+++ b/src/battle_ai_script_commands.c
@@ -485,7 +485,7 @@ void RecordAbilityBattle(u8 a, u8 b)
BATTLE_HISTORY->abilities[GetBattlerPosition(a) & 1] = b;
}
-void sub_80C7208(u8 a, u8 b)
+void RecordItemEffectBattle(u8 a, u8 b)
{
if (GetBattlerSide(a) == 0)
BATTLE_HISTORY->itemEffects[GetBattlerPosition(a) & 1] = b;
diff --git a/src/battle_util.c b/src/battle_util.c
index 55f674215..cf91b122f 100644
--- a/src/battle_util.c
+++ b/src/battle_util.c
@@ -8,25 +8,28 @@
#include "pokemon.h"
#include "string_util.h"
#include "field_weather.h"
+#include "event_data.h"
#include "battle.h"
#include "battle_anim.h"
#include "battle_scripts.h"
#include "battle_message.h"
+#include "constants/battle_anim.h"
#include "battle_controllers.h"
+#include "battle_string_ids.h"
#include "battle_ai_script_commands.h"
#include "constants/battle.h"
#include "constants/moves.h"
#include "constants/items.h"
+#include "constants/flags.h"
#include "constants/species.h"
#include "constants/weather.h"
#include "constants/abilities.h"
#include "constants/pokemon.h"
-#include "constants/battle_anim.h"
#include "constants/hold_effects.h"
#include "constants/battle_move_effects.h"
#include "constants/battle_script_commands.h"
-const u16 sSoundMovesTable[] =
+static const u16 sSoundMovesTable[] =
{
MOVE_GROWL, MOVE_ROAR, MOVE_SING, MOVE_SUPERSONIC, MOVE_SCREECH, MOVE_SNORE,
MOVE_UPROAR, MOVE_METAL_SOUND, MOVE_GRASS_WHISTLE, MOVE_HYPER_VOICE, 0xFFFF
@@ -392,6 +395,7 @@ u8 GetImprisonedMovesCount(u8 battlerId, u16 move)
if (battlerSide != GetBattlerSide(i) && gStatuses3[i] & STATUS3_IMPRISONED_OTHERS)
{
s32 j;
+
for (j = 0; j < MAX_MON_MOVES && move != gBattleMons[i].moves[j]; ++j);
if (j < MAX_MON_MOVES)
++imprisonedMoves;
@@ -914,6 +918,7 @@ u8 DoBattlerEndTurnEffects(void)
if (gDisableStructs[gActiveBattler].disableTimer != 0)
{
s32 i;
+
for (i = 0; i < MAX_MON_MOVES; ++i)
{
if (gDisableStructs[gActiveBattler].disabledMove == gBattleMons[gActiveBattler].moves[i])
@@ -1582,7 +1587,6 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (gBattlerAttacker >= gBattlersCount)
gBattlerAttacker = battler;
-
if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
pokeAtk = &gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]];
else
@@ -1992,7 +1996,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
}
break;
case ABILITYEFFECT_IMMUNITY: // 5
- for (battler = 0; battler < gBattlersCount; battler++)
+ for (battler = 0; battler < gBattlersCount; ++battler)
{
switch (gBattleMons[battler].ability)
{
@@ -2323,3 +2327,873 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
}
return effect;
}
+
+void BattleScriptExecute(const u8 *BS_ptr)
+{
+ gBattlescriptCurrInstr = BS_ptr;
+ gBattleResources->battleCallbackStack->function[gBattleResources->battleCallbackStack->size++] = gBattleMainFunc;
+ gBattleMainFunc = RunBattleScriptCommands_PopCallbacksStack;
+ gCurrentActionFuncId = 0;
+}
+
+void BattleScriptPushCursorAndCallback(const u8 *BS_ptr)
+{
+ BattleScriptPushCursor();
+ gBattlescriptCurrInstr = BS_ptr;
+ gBattleResources->battleCallbackStack->function[gBattleResources->battleCallbackStack->size++] = gBattleMainFunc;
+ gBattleMainFunc = RunBattleScriptCommands;
+}
+
+enum
+{
+ ITEM_NO_EFFECT,
+ ITEM_STATUS_CHANGE,
+ ITEM_EFFECT_OTHER,
+ ITEM_PP_CHANGE,
+ ITEM_HP_CHANGE,
+ ITEM_STATS_CHANGE,
+};
+
+u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
+{
+ int i = 0;
+ u8 effect = ITEM_NO_EFFECT;
+ u8 changedPP = 0;
+ u8 battlerHoldEffect, atkHoldEffect, defHoldEffect;
+ u8 battlerHoldEffectParam, atkHoldEffectParam, defHoldEffectParam;
+ u16 atkItem, defItem;
+
+ gLastUsedItem = gBattleMons[battlerId].item;
+ if (gLastUsedItem == ITEM_ENIGMA_BERRY)
+ {
+ battlerHoldEffect = gEnigmaBerries[battlerId].holdEffect;
+ battlerHoldEffectParam = gEnigmaBerries[battlerId].holdEffectParam;
+ }
+ else
+ {
+ battlerHoldEffect = ItemId_GetHoldEffect(gLastUsedItem);
+ battlerHoldEffectParam = ItemId_GetHoldEffectParam(gLastUsedItem);
+ }
+
+ atkItem = gBattleMons[gBattlerAttacker].item;
+ if (atkItem == ITEM_ENIGMA_BERRY)
+ {
+ atkHoldEffect = gEnigmaBerries[gBattlerAttacker].holdEffect;
+ atkHoldEffectParam = gEnigmaBerries[gBattlerAttacker].holdEffectParam;
+ }
+ else
+ {
+ atkHoldEffect = ItemId_GetHoldEffect(atkItem);
+ atkHoldEffectParam = ItemId_GetHoldEffectParam(atkItem);
+ }
+
+ // def variables are unused
+ defItem = gBattleMons[gBattlerTarget].item;
+ if (defItem == ITEM_ENIGMA_BERRY)
+ {
+ defHoldEffect = gEnigmaBerries[gBattlerTarget].holdEffect;
+ defHoldEffectParam = gEnigmaBerries[gBattlerTarget].holdEffectParam;
+ }
+ else
+ {
+ defHoldEffect = ItemId_GetHoldEffect(defItem);
+ defHoldEffectParam = ItemId_GetHoldEffectParam(defItem);
+ }
+ switch (caseID)
+ {
+ case ITEMEFFECT_ON_SWITCH_IN:
+ switch (battlerHoldEffect)
+ {
+ case HOLD_EFFECT_DOUBLE_PRIZE:
+ gBattleStruct->moneyMultiplier = 2;
+ break;
+ case HOLD_EFFECT_RESTORE_STATS:
+ for (i = 0; i < NUM_BATTLE_STATS; ++i)
+ {
+ if (gBattleMons[battlerId].statStages[i] < 6)
+ {
+ gBattleMons[battlerId].statStages[i] = 6;
+ effect = ITEM_STATS_CHANGE;
+ }
+ }
+ if (effect)
+ {
+ gBattleScripting.battler = battlerId;
+ gPotentialItemEffectBattler = battlerId;
+ gActiveBattler = gBattlerAttacker = battlerId;
+ BattleScriptExecute(BattleScript_WhiteHerbEnd2);
+ }
+ break;
+ }
+ break;
+ case 1:
+ if (gBattleMons[battlerId].hp)
+ {
+ switch (battlerHoldEffect)
+ {
+ case HOLD_EFFECT_RESTORE_HP:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / 2 && !moveTurn)
+ {
+ gBattleMoveDamage = battlerHoldEffectParam;
+ if (gBattleMons[battlerId].hp + battlerHoldEffectParam > gBattleMons[battlerId].maxHP)
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP - gBattleMons[battlerId].hp;
+ gBattleMoveDamage *= -1;
+ BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem);
+ effect = 4;
+ }
+ break;
+ case HOLD_EFFECT_RESTORE_PP:
+ if (!moveTurn)
+ {
+ struct Pokemon *mon;
+ u8 ppBonuses;
+ u16 move;
+
+ if (GetBattlerSide(battlerId) == B_SIDE_PLAYER)
+ mon = &gPlayerParty[gBattlerPartyIndexes[battlerId]];
+ else
+ mon = &gEnemyParty[gBattlerPartyIndexes[battlerId]];
+ for (i = 0; i < MAX_MON_MOVES; ++i)
+ {
+ move = GetMonData(mon, MON_DATA_MOVE1 + i);
+ changedPP = GetMonData(mon, MON_DATA_PP1 + i);
+ ppBonuses = GetMonData(mon, MON_DATA_PP_BONUSES);
+ if (move && changedPP == 0)
+ break;
+ }
+ if (i != MAX_MON_MOVES)
+ {
+ u8 maxPP = CalculatePPWithBonus(move, ppBonuses, i);
+ if (changedPP + battlerHoldEffectParam > maxPP)
+ changedPP = maxPP;
+ else
+ changedPP = changedPP + battlerHoldEffectParam;
+ PREPARE_MOVE_BUFFER(gBattleTextBuff1, move);
+ BattleScriptExecute(BattleScript_BerryPPHealEnd2);
+ BtlController_EmitSetMonData(0, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP);
+ MarkBattlerForControllerExec(gActiveBattler);
+ effect = ITEM_PP_CHANGE;
+ }
+ }
+ break;
+ case HOLD_EFFECT_RESTORE_STATS:
+ for (i = 0; i < NUM_BATTLE_STATS; ++i)
+ {
+ if (gBattleMons[battlerId].statStages[i] < 6)
+ {
+ gBattleMons[battlerId].statStages[i] = 6;
+ effect = ITEM_STATS_CHANGE;
+ }
+ }
+ if (effect)
+ {
+ gBattleScripting.battler = battlerId;
+ gPotentialItemEffectBattler = battlerId;
+ gActiveBattler = gBattlerAttacker = battlerId;
+ BattleScriptExecute(BattleScript_WhiteHerbEnd2);
+ }
+ break;
+ case HOLD_EFFECT_LEFTOVERS:
+ if (gBattleMons[battlerId].hp < gBattleMons[battlerId].maxHP && !moveTurn)
+ {
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP / 16;
+ if (gBattleMoveDamage == 0)
+ gBattleMoveDamage = 1;
+ if (gBattleMons[battlerId].hp + gBattleMoveDamage > gBattleMons[battlerId].maxHP)
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP - gBattleMons[battlerId].hp;
+ gBattleMoveDamage *= -1;
+ BattleScriptExecute(BattleScript_ItemHealHP_End2);
+ effect = ITEM_HP_CHANGE;
+ RecordItemEffectBattle(battlerId, battlerHoldEffect);
+ }
+ break;
+ case HOLD_EFFECT_CONFUSE_SPICY:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / 2 && !moveTurn)
+ {
+ PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, FLAVOR_SPICY);
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP / battlerHoldEffectParam;
+ if (gBattleMoveDamage == 0)
+ gBattleMoveDamage = 1;
+ if (gBattleMons[battlerId].hp + gBattleMoveDamage > gBattleMons[battlerId].maxHP)
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP - gBattleMons[battlerId].hp;
+ gBattleMoveDamage *= -1;
+ if (GetFlavorRelationByPersonality(gBattleMons[battlerId].personality, FLAVOR_SPICY) < 0)
+ BattleScriptExecute(BattleScript_BerryConfuseHealEnd2);
+ else
+ BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem);
+ effect = ITEM_HP_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CONFUSE_DRY:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / 2 && !moveTurn)
+ {
+ PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, FLAVOR_DRY);
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP / battlerHoldEffectParam;
+ if (gBattleMoveDamage == 0)
+ gBattleMoveDamage = 1;
+ if (gBattleMons[battlerId].hp + gBattleMoveDamage > gBattleMons[battlerId].maxHP)
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP - gBattleMons[battlerId].hp;
+ gBattleMoveDamage *= -1;
+ if (GetFlavorRelationByPersonality(gBattleMons[battlerId].personality, FLAVOR_DRY) < 0)
+ BattleScriptExecute(BattleScript_BerryConfuseHealEnd2);
+ else
+ BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem);
+ effect = ITEM_HP_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CONFUSE_SWEET:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / 2 && !moveTurn)
+ {
+ PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, FLAVOR_SWEET);
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP / battlerHoldEffectParam;
+ if (gBattleMoveDamage == 0)
+ gBattleMoveDamage = 1;
+ if (gBattleMons[battlerId].hp + gBattleMoveDamage > gBattleMons[battlerId].maxHP)
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP - gBattleMons[battlerId].hp;
+ gBattleMoveDamage *= -1;
+ if (GetFlavorRelationByPersonality(gBattleMons[battlerId].personality, FLAVOR_SWEET) < 0)
+ BattleScriptExecute(BattleScript_BerryConfuseHealEnd2);
+ else
+ BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem);
+ effect = ITEM_HP_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CONFUSE_BITTER:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / 2 && !moveTurn)
+ {
+ PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, FLAVOR_BITTER);
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP / battlerHoldEffectParam;
+ if (gBattleMoveDamage == 0)
+ gBattleMoveDamage = 1;
+ if (gBattleMons[battlerId].hp + gBattleMoveDamage > gBattleMons[battlerId].maxHP)
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP - gBattleMons[battlerId].hp;
+ gBattleMoveDamage *= -1;
+ if (GetFlavorRelationByPersonality(gBattleMons[battlerId].personality, FLAVOR_BITTER) < 0)
+ BattleScriptExecute(BattleScript_BerryConfuseHealEnd2);
+ else
+ BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem);
+ effect = ITEM_HP_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CONFUSE_SOUR:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / 2 && !moveTurn)
+ {
+ PREPARE_FLAVOR_BUFFER(gBattleTextBuff1, FLAVOR_SOUR);
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP / battlerHoldEffectParam;
+ if (gBattleMoveDamage == 0)
+ gBattleMoveDamage = 1;
+ if (gBattleMons[battlerId].hp + gBattleMoveDamage > gBattleMons[battlerId].maxHP)
+ gBattleMoveDamage = gBattleMons[battlerId].maxHP - gBattleMons[battlerId].hp;
+ gBattleMoveDamage *= -1;
+ if (GetFlavorRelationByPersonality(gBattleMons[battlerId].personality, FLAVOR_SOUR) < 0)
+ BattleScriptExecute(BattleScript_BerryConfuseHealEnd2);
+ else
+ BattleScriptExecute(BattleScript_ItemHealHP_RemoveItem);
+ effect = ITEM_HP_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_ATTACK_UP:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_ATK] < 0xC)
+ {
+ PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK);
+ PREPARE_STRING_BUFFER(gBattleTextBuff2, STRINGID_STATROSE);
+ gEffectBattler = battlerId;
+ SET_STATCHANGER(STAT_ATK, 1, FALSE);
+ gBattleScripting.animArg1 = 0xE + STAT_ATK;
+ gBattleScripting.animArg2 = 0;
+ BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
+ effect = ITEM_STATS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_DEFENSE_UP:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_DEF] < 0xC)
+ {
+ PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_DEF);
+ gEffectBattler = battlerId;
+ SET_STATCHANGER(STAT_DEF, 1, FALSE);
+ gBattleScripting.animArg1 = 0xE + STAT_DEF;
+ gBattleScripting.animArg2 = 0;
+ BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
+ effect = ITEM_STATS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_SPEED_UP:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPEED] < 0xC)
+ {
+ PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPEED);
+ gEffectBattler = battlerId;
+ SET_STATCHANGER(STAT_SPEED, 1, FALSE);
+ gBattleScripting.animArg1 = 0xE + STAT_SPEED;
+ gBattleScripting.animArg2 = 0;
+ BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
+ effect = ITEM_STATS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_SP_ATTACK_UP:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPATK] < 0xC)
+ {
+ PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPATK);
+ gEffectBattler = battlerId;
+ SET_STATCHANGER(STAT_SPATK, 1, FALSE);
+ gBattleScripting.animArg1 = 0xE + STAT_SPATK;
+ gBattleScripting.animArg2 = 0;
+ BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
+ effect = ITEM_STATS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_SP_DEFENSE_UP:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && gBattleMons[battlerId].statStages[STAT_SPDEF] < 0xC)
+ {
+ PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_SPDEF);
+ gEffectBattler = battlerId;
+ SET_STATCHANGER(STAT_SPDEF, 1, FALSE);
+ gBattleScripting.animArg1 = 0xE + STAT_SPDEF;
+ gBattleScripting.animArg2 = 0;
+ BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
+ effect = ITEM_STATS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CRITICAL_UP:
+ if (gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam && !moveTurn && !(gBattleMons[battlerId].status2 & STATUS2_FOCUS_ENERGY))
+ {
+ gBattleMons[battlerId].status2 |= STATUS2_FOCUS_ENERGY;
+ BattleScriptExecute(BattleScript_BerryFocusEnergyEnd2);
+ effect = ITEM_EFFECT_OTHER;
+ }
+ break;
+ case HOLD_EFFECT_RANDOM_STAT_UP:
+ if (!moveTurn && gBattleMons[battlerId].hp <= gBattleMons[battlerId].maxHP / battlerHoldEffectParam)
+ {
+ for (i = 0; i < 5 && gBattleMons[battlerId].statStages[STAT_ATK + i] >= 0xC; ++i);
+ if (i != 5)
+ {
+ do
+ i = Random() % 5;
+ while (gBattleMons[battlerId].statStages[STAT_ATK + i] == 0xC);
+ PREPARE_STAT_BUFFER(gBattleTextBuff1, i + 1);
+ gBattleTextBuff2[0] = B_BUFF_PLACEHOLDER_BEGIN;
+ gBattleTextBuff2[1] = B_BUFF_STRING;
+ gBattleTextBuff2[2] = STRINGID_STATSHARPLY;
+ gBattleTextBuff2[3] = STRINGID_STATSHARPLY >> 8;
+ gBattleTextBuff2[4] = B_BUFF_STRING;
+ gBattleTextBuff2[5] = STRINGID_STATROSE;
+ gBattleTextBuff2[6] = STRINGID_STATROSE >> 8;
+ gBattleTextBuff2[7] = EOS;
+ gEffectBattler = battlerId;
+ SET_STATCHANGER(i + 1, 2, FALSE);
+ gBattleScripting.animArg1 = 0x21 + i + 6;
+ gBattleScripting.animArg2 = 0;
+ BattleScriptExecute(BattleScript_BerryStatRaiseEnd2);
+ effect = ITEM_STATS_CHANGE;
+ }
+ }
+ break;
+ case HOLD_EFFECT_CURE_PAR:
+ if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS)
+ {
+ gBattleMons[battlerId].status1 &= ~(STATUS1_PARALYSIS);
+ BattleScriptExecute(BattleScript_BerryCurePrlzEnd2);
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CURE_PSN:
+ if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
+ {
+ gBattleMons[battlerId].status1 &= ~(STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER);
+ BattleScriptExecute(BattleScript_BerryCurePsnEnd2);
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CURE_BRN:
+ if (gBattleMons[battlerId].status1 & STATUS1_BURN)
+ {
+ gBattleMons[battlerId].status1 &= ~(STATUS1_BURN);
+ BattleScriptExecute(BattleScript_BerryCureBrnEnd2);
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CURE_FRZ:
+ if (gBattleMons[battlerId].status1 & STATUS1_FREEZE)
+ {
+ gBattleMons[battlerId].status1 &= ~(STATUS1_FREEZE);
+ BattleScriptExecute(BattleScript_BerryCureFrzEnd2);
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CURE_SLP:
+ if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
+ {
+ gBattleMons[battlerId].status1 &= ~(STATUS1_SLEEP);
+ gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE);
+ BattleScriptExecute(BattleScript_BerryCureSlpEnd2);
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CURE_CONFUSION:
+ if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
+ {
+ gBattleMons[battlerId].status2 &= ~(STATUS2_CONFUSION);
+ BattleScriptExecute(BattleScript_BerryCureConfusionEnd2);
+ effect = ITEM_EFFECT_OTHER;
+ }
+ break;
+ case HOLD_EFFECT_CURE_STATUS:
+ if (gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
+ {
+ i = 0;
+ if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
+ {
+ StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn);
+ ++i;
+ }
+ if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
+ {
+ gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE);
+ StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn);
+ ++i;
+ }
+ if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS)
+ {
+ StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn);
+ ++i;
+ }
+ if (gBattleMons[battlerId].status1 & STATUS1_BURN)
+ {
+ StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn);
+ ++i;
+ }
+ if (gBattleMons[battlerId].status1 & STATUS1_FREEZE)
+ {
+ StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn);
+ ++i;
+ }
+ if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
+ {
+ StringCopy(gBattleTextBuff1, gStatusConditionString_ConfusionJpn);
+ ++i;
+ }
+ if (!(i > 1))
+ gBattleCommunication[MULTISTRING_CHOOSER] = 0;
+ else
+ gBattleCommunication[MULTISTRING_CHOOSER] = 1;
+ gBattleMons[battlerId].status1 = 0;
+ gBattleMons[battlerId].status2 &= ~(STATUS2_CONFUSION);
+ BattleScriptExecute(BattleScript_BerryCureChosenStatusEnd2);
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CURE_ATTRACT:
+ if (gBattleMons[battlerId].status2 & STATUS2_INFATUATION)
+ {
+ gBattleMons[battlerId].status2 &= ~(STATUS2_INFATUATION);
+ StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn);
+ BattleScriptExecute(BattleScript_BerryCureChosenStatusEnd2);
+ gBattleCommunication[MULTISTRING_CHOOSER] = 0;
+ effect = ITEM_EFFECT_OTHER;
+ }
+ break;
+ }
+ if (effect)
+ {
+ gBattleScripting.battler = battlerId;
+ gPotentialItemEffectBattler = battlerId;
+ gActiveBattler = gBattlerAttacker = battlerId;
+ switch (effect)
+ {
+ case ITEM_STATUS_CHANGE:
+ BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battlerId].status1);
+ MarkBattlerForControllerExec(gActiveBattler);
+ break;
+ case ITEM_PP_CHANGE:
+ if (!(gBattleMons[battlerId].status2 & STATUS2_TRANSFORMED) && !(gDisableStructs[battlerId].mimickedMoves & gBitTable[i]))
+ gBattleMons[battlerId].pp[i] = changedPP;
+ break;
+ }
+ }
+ }
+ break;
+ case 2:
+ break;
+ case ITEMEFFECT_MOVE_END:
+ for (battlerId = 0; battlerId < gBattlersCount; ++battlerId)
+ {
+ gLastUsedItem = gBattleMons[battlerId].item;
+ if (gBattleMons[battlerId].item == ITEM_ENIGMA_BERRY)
+ {
+ battlerHoldEffect = gEnigmaBerries[battlerId].holdEffect;
+ battlerHoldEffectParam = gEnigmaBerries[battlerId].holdEffectParam;
+ }
+ else
+ {
+ battlerHoldEffect = ItemId_GetHoldEffect(gLastUsedItem);
+ battlerHoldEffectParam = ItemId_GetHoldEffectParam(gLastUsedItem);
+ }
+ switch (battlerHoldEffect)
+ {
+ case HOLD_EFFECT_CURE_PAR:
+ if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS)
+ {
+ gBattleMons[battlerId].status1 &= ~(STATUS1_PARALYSIS);
+ BattleScriptPushCursor();
+ gBattlescriptCurrInstr = BattleScript_BerryCureParRet;
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CURE_PSN:
+ if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
+ {
+ gBattleMons[battlerId].status1 &= ~(STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER);
+ BattleScriptPushCursor();
+ gBattlescriptCurrInstr = BattleScript_BerryCurePsnRet;
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CURE_BRN:
+ if (gBattleMons[battlerId].status1 & STATUS1_BURN)
+ {
+ gBattleMons[battlerId].status1 &= ~(STATUS1_BURN);
+ BattleScriptPushCursor();
+ gBattlescriptCurrInstr = BattleScript_BerryCureBrnRet;
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CURE_FRZ:
+ if (gBattleMons[battlerId].status1 & STATUS1_FREEZE)
+ {
+ gBattleMons[battlerId].status1 &= ~(STATUS1_FREEZE);
+ BattleScriptPushCursor();
+ gBattlescriptCurrInstr = BattleScript_BerryCureFrzRet;
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CURE_SLP:
+ if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
+ {
+ gBattleMons[battlerId].status1 &= ~(STATUS1_SLEEP);
+ gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE);
+ BattleScriptPushCursor();
+ gBattlescriptCurrInstr = BattleScript_BerryCureSlpRet;
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_CURE_CONFUSION:
+ if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
+ {
+ gBattleMons[battlerId].status2 &= ~(STATUS2_CONFUSION);
+ BattleScriptPushCursor();
+ gBattlescriptCurrInstr = BattleScript_BerryCureConfusionRet;
+ effect = ITEM_EFFECT_OTHER;
+ }
+ break;
+ case HOLD_EFFECT_CURE_ATTRACT:
+ if (gBattleMons[battlerId].status2 & STATUS2_INFATUATION)
+ {
+ gBattleMons[battlerId].status2 &= ~(STATUS2_INFATUATION);
+ StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn);
+ BattleScriptPushCursor();
+ gBattleCommunication[MULTISTRING_CHOOSER] = 0;
+ gBattlescriptCurrInstr = BattleScript_BerryCureChosenStatusRet;
+ effect = ITEM_EFFECT_OTHER;
+ }
+ break;
+ case HOLD_EFFECT_CURE_STATUS:
+ if (gBattleMons[battlerId].status1 & STATUS1_ANY || gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
+ {
+ if (gBattleMons[battlerId].status1 & STATUS1_PSN_ANY)
+ {
+ StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn);
+ }
+ if (gBattleMons[battlerId].status1 & STATUS1_SLEEP)
+ {
+ gBattleMons[battlerId].status2 &= ~(STATUS2_NIGHTMARE);
+ StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn);
+ }
+ if (gBattleMons[battlerId].status1 & STATUS1_PARALYSIS)
+ {
+ StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn);
+ }
+ if (gBattleMons[battlerId].status1 & STATUS1_BURN)
+ {
+ StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn);
+ }
+ if (gBattleMons[battlerId].status1 & STATUS1_FREEZE)
+ {
+ StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn);
+ }
+ if (gBattleMons[battlerId].status2 & STATUS2_CONFUSION)
+ {
+ StringCopy(gBattleTextBuff1, gStatusConditionString_ConfusionJpn);
+ }
+ gBattleMons[battlerId].status1 = 0;
+ gBattleMons[battlerId].status2 &= ~(STATUS2_CONFUSION);
+ BattleScriptPushCursor();
+ gBattleCommunication[MULTISTRING_CHOOSER] = 0;
+ gBattlescriptCurrInstr = BattleScript_BerryCureChosenStatusRet;
+ effect = ITEM_STATUS_CHANGE;
+ }
+ break;
+ case HOLD_EFFECT_RESTORE_STATS:
+ for (i = 0; i < NUM_BATTLE_STATS; ++i)
+ {
+ if (gBattleMons[battlerId].statStages[i] < 6)
+ {
+ gBattleMons[battlerId].statStages[i] = 6;
+ effect = ITEM_STATS_CHANGE;
+ }
+ }
+ if (effect)
+ {
+ gBattleScripting.battler = battlerId;
+ gPotentialItemEffectBattler = battlerId;
+ BattleScriptPushCursor();
+ gBattlescriptCurrInstr = BattleScript_WhiteHerbRet;
+ return effect;
+ }
+ break;
+ }
+ if (effect)
+ {
+ gBattleScripting.battler = battlerId;
+ gPotentialItemEffectBattler = battlerId;
+ gActiveBattler = battlerId;
+ BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
+ MarkBattlerForControllerExec(gActiveBattler);
+ break;
+ }
+ }
+ break;
+ case ITEMEFFECT_KINGSROCK_SHELLBELL:
+ if (gBattleMoveDamage)
+ {
+ switch (atkHoldEffect)
+ {
+ case HOLD_EFFECT_FLINCH:
+ if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
+ && TARGET_TURN_DAMAGED
+ && (Random() % 100) < battlerHoldEffectParam
+ && gBattleMoves[gCurrentMove].flags & FLAG_KINGSROCK_AFFECTED
+ && gBattleMons[gBattlerTarget].hp)
+ {
+ gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_FLINCH;
+ BattleScriptPushCursor();
+ SetMoveEffect(0, 0);
+ BattleScriptPop();
+ }
+ break;
+ case HOLD_EFFECT_SHELL_BELL:
+ if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
+ && gSpecialStatuses[gBattlerTarget].dmg != 0
+ && gSpecialStatuses[gBattlerTarget].dmg != 0xFFFF
+ && gBattlerAttacker != gBattlerTarget
+ && gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP
+ && gBattleMons[gBattlerAttacker].hp != 0)
+ {
+ gLastUsedItem = atkItem;
+ gPotentialItemEffectBattler = gBattlerAttacker;
+ gBattleScripting.battler = gBattlerAttacker;
+ gBattleMoveDamage = (gSpecialStatuses[gBattlerTarget].dmg / atkHoldEffectParam) * -1;
+ if (gBattleMoveDamage == 0)
+ gBattleMoveDamage = -1;
+ gSpecialStatuses[gBattlerTarget].dmg = 0;
+ BattleScriptPushCursor();
+ gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret;
+ ++effect;
+ }
+ break;
+ }
+ }
+ break;
+ }
+ return effect;
+}
+
+void ClearFuryCutterDestinyBondGrudge(u8 battlerId)
+{
+ gDisableStructs[battlerId].furyCutterCounter = 0;
+ gBattleMons[battlerId].status2 &= ~(STATUS2_DESTINY_BOND);
+ gStatuses3[battlerId] &= ~(STATUS3_GRUDGE);
+}
+
+void HandleAction_RunBattleScript(void) // identical to RunBattleScriptCommands
+{
+ if (!gBattleControllerExecFlags)
+ gBattleScriptingCommandsTable[*gBattlescriptCurrInstr]();
+}
+
+u8 GetMoveTarget(u16 move, u8 setTarget)
+{
+ u8 targetBattler = 0;
+ u8 moveTarget;
+ u8 side;
+
+ if (setTarget)
+ moveTarget = setTarget - 1;
+ else
+ moveTarget = gBattleMoves[move].target;
+ switch (moveTarget)
+ {
+ case MOVE_TARGET_SELECTED:
+ side = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE;
+ if (gSideTimers[side].followmeTimer && gBattleMons[gSideTimers[side].followmeTarget].hp)
+ targetBattler = gSideTimers[side].followmeTarget;
+ else
+ {
+ side = GetBattlerSide(gBattlerAttacker);
+ do
+ {
+ targetBattler = Random() % gBattlersCount;
+ } while (targetBattler == gBattlerAttacker || side == GetBattlerSide(targetBattler) || gAbsentBattlerFlags & gBitTable[targetBattler]);
+ if (gBattleMoves[move].type == TYPE_ELECTRIC
+ && AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBattlerAttacker, ABILITY_LIGHTNING_ROD, 0, 0)
+ && gBattleMons[targetBattler].ability != ABILITY_LIGHTNING_ROD)
+ {
+ targetBattler ^= BIT_FLANK;
+ RecordAbilityBattle(targetBattler, gBattleMons[targetBattler].ability);
+ gSpecialStatuses[targetBattler].lightningRodRedirected = 1;
+ }
+ }
+ break;
+ case MOVE_TARGET_DEPENDS:
+ case MOVE_TARGET_BOTH:
+ case MOVE_TARGET_FOES_AND_ALLY:
+ case MOVE_TARGET_OPPONENTS_FIELD:
+ targetBattler = GetBattlerAtPosition((GetBattlerPosition(gBattlerAttacker) & BIT_SIDE) ^ BIT_SIDE);
+ if (gAbsentBattlerFlags & gBitTable[targetBattler])
+ targetBattler ^= BIT_FLANK;
+ break;
+ case MOVE_TARGET_RANDOM:
+ side = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE;
+ if (gSideTimers[side].followmeTimer && gBattleMons[gSideTimers[side].followmeTarget].hp)
+ targetBattler = gSideTimers[side].followmeTarget;
+ else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && moveTarget & MOVE_TARGET_RANDOM)
+ {
+ if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
+ {
+ if (Random() & 1)
+ targetBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
+ else
+ targetBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
+ }
+ else
+ {
+ if (Random() & 1)
+ targetBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
+ else
+ targetBattler = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
+ }
+ if (gAbsentBattlerFlags & gBitTable[targetBattler])
+ targetBattler ^= BIT_FLANK;
+ }
+ else
+ targetBattler = GetBattlerAtPosition((GetBattlerPosition(gBattlerAttacker) & BIT_SIDE) ^ BIT_SIDE);
+ break;
+ case MOVE_TARGET_USER_OR_SELECTED:
+ case MOVE_TARGET_USER:
+ targetBattler = gBattlerAttacker;
+ break;
+ }
+ *(gBattleStruct->moveTarget + gBattlerAttacker) = targetBattler;
+ return targetBattler;
+}
+
+static bool32 HasObedientBitSet(u8 battlerId)
+{
+ if (GetBattlerSide(battlerId) == B_SIDE_OPPONENT
+ || (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES, NULL) != SPECIES_DEOXYS
+ && GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_SPECIES, NULL) != SPECIES_MEW))
+ return TRUE;
+ return GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerId]], MON_DATA_OBEDIENCE, NULL);
+}
+
+u8 IsMonDisobedient(void)
+{
+ s32 rnd;
+ s32 calc;
+ u8 obedienceLevel = 0;
+
+ if ((gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_POKEDUDE)) || GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT)
+ return 0;
+ if (HasObedientBitSet(gBattlerAttacker)) // only if species is Mew or Deoxys
+ {
+ if (!IsOtherTrainer(gBattleMons[gBattlerAttacker].otId, gBattleMons[gBattlerAttacker].otName) || FlagGet(FLAG_0x827))
+ return 0;
+ obedienceLevel = 10;
+ if (FlagGet(FLAG_0x821))
+ obedienceLevel = 30;
+ if (FlagGet(FLAG_0x823))
+ obedienceLevel = 50;
+ if (FlagGet(FLAG_0x825))
+ obedienceLevel = 70;
+ }
+ if (gBattleMons[gBattlerAttacker].level <= obedienceLevel)
+ return 0;
+ rnd = (Random() & 255);
+ calc = (gBattleMons[gBattlerAttacker].level + obedienceLevel) * rnd >> 8;
+ if (calc < obedienceLevel)
+ return 0;
+ // is not obedient
+ if (gCurrentMove == MOVE_RAGE)
+ gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_RAGE);
+ if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP && (gCurrentMove == MOVE_SNORE || gCurrentMove == MOVE_SLEEP_TALK))
+ {
+ gBattlescriptCurrInstr = BattleScript_IgnoresWhileAsleep;
+ return 1;
+ }
+ rnd = (Random() & 255);
+ calc = (gBattleMons[gBattlerAttacker].level + obedienceLevel) * rnd >> 8;
+ if (calc < obedienceLevel && gCurrentMove != MOVE_FOCUS_PUNCH) // Additional check for focus punch in FR
+ {
+ calc = CheckMoveLimitations(gBattlerAttacker, gBitTable[gCurrMovePos], 0xFF);
+ if (calc == 0xF) // all moves cannot be used
+ {
+ gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3;
+ gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround;
+ return 1;
+ }
+ else // use a random move
+ {
+ do
+ gCurrMovePos = gChosenMovePos = Random() & 3;
+ while (gBitTable[gCurrMovePos] & calc);
+ gCalledMove = gBattleMons[gBattlerAttacker].moves[gCurrMovePos];
+ gBattlescriptCurrInstr = BattleScript_IgnoresAndUsesRandomMove;
+ gBattlerTarget = GetMoveTarget(gCalledMove, 0);
+ gHitMarker |= HITMARKER_x200000;
+ return 2;
+ }
+ }
+ else
+ {
+ obedienceLevel = gBattleMons[gBattlerAttacker].level - obedienceLevel;
+ calc = (Random() & 255);
+ if (calc < obedienceLevel && !(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY) && gBattleMons[gBattlerAttacker].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gBattlerAttacker].ability != ABILITY_INSOMNIA)
+ {
+ // try putting asleep
+ int i;
+
+ for (i = 0; i < gBattlersCount; ++i)
+ if (gBattleMons[i].status2 & STATUS2_UPROAR)
+ break;
+ if (i == gBattlersCount)
+ {
+ gBattlescriptCurrInstr = BattleScript_IgnoresAndFallsAsleep;
+ return 1;
+ }
+ }
+ calc -= obedienceLevel;
+ if (calc < obedienceLevel)
+ {
+ gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerAttacker], MOVE_POUND, 0, 40, 0, gBattlerAttacker, gBattlerAttacker);
+ gBattlerTarget = gBattlerAttacker;
+ gBattlescriptCurrInstr = BattleScript_IgnoresAndHitsItself;
+ gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
+ return 2;
+ }
+ else
+ {
+ gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3;
+ gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround;
+ return 1;
+ }
+ }
+}
diff --git a/sym_ewram.txt b/sym_ewram.txt
index cc42726a0..9ce1e58a3 100644
--- a/sym_ewram.txt
+++ b/sym_ewram.txt
@@ -195,7 +195,7 @@ gBattlerByTurnOrder: @ 2023BDE
gUnknown_2023BE2: @ 2023BE2
.space 0x1
-gUnknown_2023BE3: @ 2023BE3
+gCurrentActionFuncId: @ 2023BE3
.space 0x1
gBattleMons: @ 2023BE4
@@ -222,10 +222,10 @@ gUnknown_2023C34: @ 2023C34
gBattlerSpriteIds: @ 2023D44
.space 0x4
-gUnknown_2023D48: @ 2023D48
+gCurrMovePos: @ 2023D48
.space 0x1
-gUnknown_2023D49: @ 2023D49
+gChosenMovePos: @ 2023D49
.space 0x1
gCurrentMove: @ 2023D4A
@@ -234,7 +234,7 @@ gCurrentMove: @ 2023D4A
gChosenMove: @ 2023D4C
.space 0x2
-gUnknown_2023D4E: @ 2023D4E
+gCalledMove: @ 2023D4E
.space 0x2
gBattleMoveDamage: @ 2023D50