more renaming

This commit is contained in:
camthesaxman 2018-02-06 16:09:39 -06:00
parent aba388d332
commit c3dc14ba66
34 changed files with 2014 additions and 2014 deletions

View File

@ -29520,7 +29520,7 @@ sub_810D608: @ 810D608
ldrsh r0, [r0, r1] ldrsh r0, [r0, r1]
cmp r0, 0 cmp r0, 0
bne _0810D664 bne _0810D664
ldr r4, =gBattleMoveAttacker ldr r4, =gBattlerAttacker
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0x2 movs r1, 0x2
bl GetBattlerSpriteCoord bl GetBattlerSpriteCoord
@ -29808,7 +29808,7 @@ sub_810D874: @ 810D874
ldrsh r0, [r0, r1] ldrsh r0, [r0, r1]
cmp r0, 0 cmp r0, 0
bne _0810D8B8 bne _0810D8B8
ldr r4, =gBattleMoveAttacker ldr r4, =gBattlerAttacker
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0x2 movs r1, 0x2
bl GetBattlerSpriteCoord bl GetBattlerSpriteCoord
@ -40918,7 +40918,7 @@ sub_8113250: @ 8113250
ldr r0, =gBattleAnimArgs ldr r0, =gBattleAnimArgs
ldrh r0, [r0] ldrh r0, [r0]
strh r0, [r6, 0x3A] strh r0, [r6, 0x3A]
ldr r4, =gBattleMoveAttacker ldr r4, =gBattlerAttacker
ldrb r0, [r4] ldrb r0, [r4]
movs r1, 0 movs r1, 0
bl sub_80A861C bl sub_80A861C
@ -50065,7 +50065,7 @@ sub_8117E94: @ 8117E94
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldr r2, =gBattleAnimAttacker ldr r2, =gBattleAnimAttacker
ldr r1, =gBattleMoveTarget ldr r1, =gBattlerTarget
ldrb r1, [r1] ldrb r1, [r1]
strb r1, [r2] strb r1, [r2]
ldr r2, =gBattleAnimTarget ldr r2, =gBattleAnimTarget
@ -50117,7 +50117,7 @@ sub_8117F10: @ 8117F10
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldr r2, =gBattleAnimTarget ldr r2, =gBattleAnimTarget
ldr r1, =gBattleMoveTarget ldr r1, =gBattlerTarget
ldrb r1, [r1] ldrb r1, [r1]
strb r1, [r2] strb r1, [r2]
bl DestroyAnimVisualTask bl DestroyAnimVisualTask
@ -50132,7 +50132,7 @@ sub_8117F30: @ 8117F30
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
ldr r2, =gBattleAnimAttacker ldr r2, =gBattleAnimAttacker
ldr r1, =gBattleMoveAttacker ldr r1, =gBattlerAttacker
ldrb r1, [r1] ldrb r1, [r1]
strb r1, [r2] strb r1, [r2]
ldr r2, =gBattleAnimTarget ldr r2, =gBattleAnimTarget

View File

@ -34,12 +34,12 @@ _0817C988:
movs r1, 0x81 movs r1, 0x81
lsls r1, 2 lsls r1, 2
adds r7, r0, r1 adds r7, r0, r1
ldr r5, =gBattleMoveAttacker ldr r5, =gBattlerAttacker
ldrb r0, [r5] ldrb r0, [r5]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
ldr r0, =gBattleMoveTarget ldr r0, =gBattlerTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -83,7 +83,7 @@ _0817CA10:
str r1, [sp, 0x8] str r1, [sp, 0x8]
cmp r6, 0 cmp r6, 0
bne _0817CA3C bne _0817CA3C
ldr r0, =gBattleMoveTarget ldr r0, =gBattlerTarget
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r2 adds r0, r2
@ -94,7 +94,7 @@ _0817CA10:
b _0817CA4C b _0817CA4C
.pool .pool
_0817CA3C: _0817CA3C:
ldr r0, =gBattleMoveTarget ldr r0, =gBattlerTarget
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r2 adds r0, r2
@ -105,7 +105,7 @@ _0817CA3C:
_0817CA4C: _0817CA4C:
adds r1, r0 adds r1, r0
str r1, [sp, 0xC] str r1, [sp, 0xC]
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
ldr r1, =gStringInfo ldr r1, =gStringInfo
ldr r1, [r1] ldr r1, [r1]
@ -134,13 +134,13 @@ _0817CA4C:
bl _0817E0A2 bl _0817E0A2
.pool .pool
_0817CA9C: _0817CA9C:
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerPosition bl GetBattlerPosition
lsls r0, 24 lsls r0, 24
lsrs r0, 25 lsrs r0, 25
mov r8, r0 mov r8, r0
ldr r0, =gBattleMoveTarget ldr r0, =gBattlerTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerPosition bl GetBattlerPosition
lsls r0, 24 lsls r0, 24
@ -572,7 +572,7 @@ _0817D0DC:
lsls r3, 2 lsls r3, 2
adds r3, r7, r3 adds r3, r7, r3
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -602,7 +602,7 @@ _0817D124:
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -635,7 +635,7 @@ _0817D16C:
lsls r0, 2 lsls r0, 2
adds r5, r7, r0 adds r5, r7, r0
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -716,7 +716,7 @@ _0817D216:
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -776,7 +776,7 @@ _0817D296:
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -834,7 +834,7 @@ _0817D314:
adds r3, r0 adds r3, r0
adds r3, r7, r3 adds r3, r7, r3
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -940,8 +940,8 @@ _0817D3F2:
bne _0817D3FE bne _0817D3FE
bl _0817E0A6 bl _0817E0A6
_0817D3FE: _0817D3FE:
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldr r1, =gBattleMoveTarget ldr r1, =gBattlerTarget
ldrb r0, [r0] ldrb r0, [r0]
ldrb r1, [r1] ldrb r1, [r1]
cmp r0, r1 cmp r0, r1
@ -1015,7 +1015,7 @@ _0817D498:
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1092,7 +1092,7 @@ _0817D53C:
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1162,7 +1162,7 @@ _0817D5CE:
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1227,7 +1227,7 @@ _0817D65E:
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1314,7 +1314,7 @@ _0817D704:
lsls r4, 3 lsls r4, 3
adds r2, r4 adds r2, r4
adds r2, r7, r2 adds r2, r7, r2
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1354,7 +1354,7 @@ _0817D76C:
bl _0817E0A6 bl _0817E0A6
_0817D77E: _0817D77E:
ldr r6, =gBattlerPartyIndexes ldr r6, =gBattlerPartyIndexes
ldr r5, =gBattleMoveAttacker ldr r5, =gBattlerAttacker
ldrb r0, [r5] ldrb r0, [r5]
lsls r0, 1 lsls r0, 1
adds r0, r6 adds r0, r6
@ -1408,7 +1408,7 @@ _0817D7D8:
lsls r4, 3 lsls r4, 3
adds r2, r4 adds r2, r4
adds r2, r7, r2 adds r2, r7, r2
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1452,7 +1452,7 @@ _0817D838:
lsls r4, 3 lsls r4, 3
adds r2, r4 adds r2, r4
adds r2, r7, r2 adds r2, r7, r2
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1498,7 +1498,7 @@ _0817D8A4:
_0817D8B6: _0817D8B6:
ldr r2, =gBattlerPartyIndexes ldr r2, =gBattlerPartyIndexes
mov r8, r2 mov r8, r2
ldr r6, =gBattleMoveAttacker ldr r6, =gBattlerAttacker
ldrb r0, [r6] ldrb r0, [r6]
lsls r0, 1 lsls r0, 1
add r0, r8 add r0, r8
@ -1574,7 +1574,7 @@ _0817D94C:
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1640,7 +1640,7 @@ _0817D9C2:
lsls r4, 3 lsls r4, 3
adds r2, r4 adds r2, r4
adds r2, r7, r2 adds r2, r7, r2
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1672,7 +1672,7 @@ _0817D9C2:
.pool .pool
_0817DA24: _0817DA24:
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1715,7 +1715,7 @@ _0817DA68:
lsls r4, 3 lsls r4, 3
adds r2, r4 adds r2, r4
adds r2, r7, r2 adds r2, r7, r2
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1748,7 +1748,7 @@ _0817DA68:
.pool .pool
_0817DACC: _0817DACC:
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1803,7 +1803,7 @@ _0817DB24:
lsls r4, 3 lsls r4, 3
adds r3, r4 adds r3, r4
adds r3, r7, r3 adds r3, r7, r3
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r5 adds r0, r5
@ -1839,7 +1839,7 @@ _0817DB76:
.pool .pool
_0817DB90: _0817DB90:
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1876,7 +1876,7 @@ _0817DBD4:
adds r3, r0 adds r3, r0
adds r3, r7, r3 adds r3, r7, r3
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -1944,7 +1944,7 @@ _0817DC62:
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2022,7 +2022,7 @@ _0817DCFC:
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2050,7 +2050,7 @@ _0817DD38:
adds r2, r0 adds r2, r0
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2122,7 +2122,7 @@ _0817DDC8:
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2155,7 +2155,7 @@ _0817DE10:
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2254,7 +2254,7 @@ _0817DEDC:
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2332,7 +2332,7 @@ _0817DF70:
lsls r2, 2 lsls r2, 2
adds r2, r7, r2 adds r2, r7, r2
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2414,7 +2414,7 @@ _0817DFE6:
ands r0, r2 ands r0, r2
strb r0, [r1] strb r0, [r1]
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -2557,14 +2557,14 @@ _0817E122:
lsls r1, 2 lsls r1, 2
adds r1, r0, r1 adds r1, r0, r1
str r1, [sp, 0x8] str r1, [sp, 0x8]
ldr r2, =gBattleMoveAttacker ldr r2, =gBattlerAttacker
mov r10, r2 mov r10, r2
ldrb r0, [r2] ldrb r0, [r2]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
lsrs r0, 24 lsrs r0, 24
mov r9, r0 mov r9, r0
ldr r0, =gBattleMoveTarget ldr r0, =gBattlerTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -2812,7 +2812,7 @@ sub_817E32C: @ 817E32C
movs r1, 0x81 movs r1, 0x81
lsls r1, 2 lsls r1, 2
adds r4, r0, r1 adds r4, r0, r1
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -3244,12 +3244,12 @@ sub_817E684: @ 817E684
movs r2, 0x81 movs r2, 0x81
lsls r2, 2 lsls r2, 2
adds r7, r0, r2 adds r7, r0, r2
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
ldr r0, =gBattleMoveTarget ldr r0, =gBattlerTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -3298,7 +3298,7 @@ _0817E6F0:
.4byte _0817E760 .4byte _0817E760
_0817E760: _0817E760:
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -3330,7 +3330,7 @@ _0817E79C:
lsls r2, r0, 4 lsls r2, r0, 4
ldr r4, =0x0000ffff ldr r4, =0x0000ffff
ldr r1, [r1] ldr r1, [r1]
ldr r3, =gBattleMoveAttacker ldr r3, =gBattlerAttacker
ldrh r0, [r1] ldrh r0, [r1]
cmp r6, r0 cmp r6, r0
bne _0817E7E0 bne _0817E7E0
@ -3708,13 +3708,13 @@ sub_817EA80: @ 817EA80
movs r1, 0x81 movs r1, 0x81
lsls r1, 2 lsls r1, 2
adds r5, r0, r1 adds r5, r0, r1
ldr r3, =gBattleMoveAttacker ldr r3, =gBattlerAttacker
mov r8, r3 mov r8, r3
ldrb r0, [r3] ldrb r0, [r3]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
lsrs r4, r0, 24 lsrs r4, r0, 24
ldr r0, =gBattleMoveTarget ldr r0, =gBattlerTarget
ldrb r0, [r0] ldrb r0, [r0]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -4006,7 +4006,7 @@ _0817ECCC:
lsrs r0, 5 lsrs r0, 5
subs r6, r0, 0x1 subs r6, r0, 0x1
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -4165,7 +4165,7 @@ _0817EE1C:
bne _0817EEBC bne _0817EEBC
adds r2, r4, 0 adds r2, r4, 0
ldr r1, =gBattlerPartyIndexes ldr r1, =gBattlerPartyIndexes
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
lsls r0, 1 lsls r0, 1
adds r0, r1 adds r0, r1
@ -4269,7 +4269,7 @@ sub_817EECC: @ 817EECC
beq _0817EEE6 beq _0817EEE6
b _0817F1FA b _0817F1FA
_0817EEE6: _0817EEE6:
ldr r4, =gBattleMoveAttacker ldr r4, =gBattlerAttacker
ldrb r0, [r4] ldrb r0, [r4]
bl GetBattlerSide bl GetBattlerSide
lsls r0, 24 lsls r0, 24
@ -4291,7 +4291,7 @@ _0817EEF8:
bgt _0817EF10 bgt _0817EF10
b _0817F1FA b _0817F1FA
_0817EF10: _0817EF10:
ldr r0, =gBattleMoveTarget ldr r0, =gBattlerTarget
ldrb r0, [r0] ldrb r0, [r0]
muls r0, r1 muls r0, r1
adds r0, r5 adds r0, r5
@ -4367,7 +4367,7 @@ _0817EF8A:
beq _0817EF98 beq _0817EF98
b _0817F1FA b _0817F1FA
_0817EF98: _0817EF98:
ldr r2, =gBattleMoveAttacker ldr r2, =gBattlerAttacker
ldrb r0, [r2] ldrb r0, [r2]
adds r0, r6 adds r0, r6
ldrb r0, [r0] ldrb r0, [r0]
@ -4386,11 +4386,11 @@ _0817EF98:
mov r10, r3 mov r10, r3
mov r8, r0 mov r8, r0
add r7, sp, 0x10 add r7, sp, 0x10
ldr r4, =gBattleMoveTarget ldr r4, =gBattlerTarget
mov r9, r4 mov r9, r4
_0817EFC2: _0817EFC2:
lsls r1, r5, 1 lsls r1, r5, 1
ldr r6, =gBattleMoveAttacker ldr r6, =gBattlerAttacker
ldrb r0, [r6] ldrb r0, [r6]
movs r2, 0x58 movs r2, 0x58
muls r0, r2 muls r0, r2
@ -4420,7 +4420,7 @@ _0817EFC2:
lsls r1, 1 lsls r1, 1
adds r1, r4 adds r1, r4
ldrh r3, [r1] ldrh r3, [r1]
ldr r2, =gBattleMoveAttacker ldr r2, =gBattlerAttacker
ldrb r0, [r2] ldrb r0, [r2]
movs r4, 0x58 movs r4, 0x58
muls r0, r4 muls r0, r4
@ -4437,7 +4437,7 @@ _0817EFC2:
str r4, [sp] str r4, [sp]
movs r4, 0 movs r4, 0
str r4, [sp, 0x4] str r4, [sp, 0x4]
ldr r6, =gBattleMoveAttacker ldr r6, =gBattlerAttacker
ldrb r4, [r6] ldrb r4, [r6]
str r4, [sp, 0x8] str r4, [sp, 0x8]
mov r6, r9 mov r6, r9
@ -4448,7 +4448,7 @@ _0817EFC2:
ldr r4, =gBattleMoveDamage ldr r4, =gBattleMoveDamage
str r3, [r4] str r3, [r4]
ldr r1, =gStatuses3 ldr r1, =gStatuses3
ldr r2, =gBattleMoveAttacker ldr r2, =gBattlerAttacker
ldrb r0, [r2] ldrb r0, [r2]
lsls r0, 2 lsls r0, 2
adds r0, r1 adds r0, r1
@ -4472,7 +4472,7 @@ _0817EFC2:
str r0, [r4] str r0, [r4]
_0817F06A: _0817F06A:
ldr r0, =gProtectStructs ldr r0, =gProtectStructs
ldr r6, =gBattleMoveAttacker ldr r6, =gBattlerAttacker
ldrb r1, [r6] ldrb r1, [r6]
lsls r1, 4 lsls r1, 4
adds r1, r0 adds r1, r0
@ -4513,7 +4513,7 @@ _0817F0B4:
cmp r5, 0x3 cmp r5, 0x3
ble _0817EFC2 ble _0817EFC2
movs r5, 0 movs r5, 0
ldr r3, =gBattleMoveAttacker ldr r3, =gBattlerAttacker
ldr r6, =gMoveSelectionCursor ldr r6, =gMoveSelectionCursor
ldr r4, =gBattlerPartyIndexes ldr r4, =gBattlerPartyIndexes
mov r8, r4 mov r8, r4
@ -4545,9 +4545,9 @@ _0817F0D8:
movs r7, 0 movs r7, 0
_0817F0F6: _0817F0F6:
movs r5, 0 movs r5, 0
ldr r4, =gBattleMoveTarget ldr r4, =gBattlerTarget
ldr r6, =gEnemyParty ldr r6, =gEnemyParty
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
add r0, r10 add r0, r10
ldrb r3, [r0] ldrb r3, [r0]
@ -4582,7 +4582,7 @@ _0817F11A:
adds r6, r0, 0 adds r6, r0, 0
lsls r6, 16 lsls r6, 16
lsrs r6, 16 lsrs r6, 16
ldr r2, =gBattleMoveAttacker ldr r2, =gBattlerAttacker
ldrb r0, [r2] ldrb r0, [r2]
lsls r0, 1 lsls r0, 1
add r0, r8 add r0, r8
@ -4598,7 +4598,7 @@ _0817F11A:
adds r1, r0, 0 adds r1, r0, 0
lsls r1, 16 lsls r1, 16
lsrs r1, 16 lsrs r1, 16
ldr r4, =gBattleMoveAttacker ldr r4, =gBattlerAttacker
ldrb r3, [r4] ldrb r3, [r4]
mov r2, r10 mov r2, r10
adds r0, r3, r2 adds r0, r3, r2
@ -4625,7 +4625,7 @@ _0817F1D4:
_0817F1DC: _0817F1DC:
ldr r2, =gBattleMoveDamage ldr r2, =gBattleMoveDamage
ldr r1, =gMoveSelectionCursor ldr r1, =gMoveSelectionCursor
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
ldrb r0, [r0] ldrb r0, [r0]
@ -4695,7 +4695,7 @@ _0817F270:
cmp r2, 0x95 cmp r2, 0x95
bne _0817F294 bne _0817F294
ldr r2, =gBattleMons ldr r2, =gBattleMons
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r1, [r0] ldrb r1, [r0]
movs r0, 0x58 movs r0, 0x58
muls r0, r1 muls r0, r1

View File

@ -1058,9 +1058,9 @@ _080D8004:
strb r2, [r1, 0x3] strb r2, [r1, 0x3]
ldr r0, =gBattleTypeFlags ldr r0, =gBattleTypeFlags
str r4, [r0] str r4, [r0]
ldr r4, =gBattleMoveAttacker ldr r4, =gBattlerAttacker
strb r2, [r4] strb r2, [r4]
ldr r0, =gBattleMoveTarget ldr r0, =gBattlerTarget
strb r3, [r0] strb r3, [r0]
bl sub_80DB0C4 bl sub_80DB0C4
ldr r2, =gBattlerSpriteIds ldr r2, =gBattlerSpriteIds
@ -2548,7 +2548,7 @@ _080D8DD0:
adds r4, r0 adds r4, r0
strh r5, [r4, 0xC] strh r5, [r4, 0xC]
ldr r1, =gBattlerSpriteIds ldr r1, =gBattlerSpriteIds
ldr r0, =gBattleMoveAttacker ldr r0, =gBattlerAttacker
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
strb r5, [r0] strb r5, [r0]
@ -13798,7 +13798,7 @@ sub_80DEA20: @ 80DEA20
bl CreateInvisibleSpriteWithCallback bl CreateInvisibleSpriteWithCallback
ldr r1, =gBattlerSpriteIds ldr r1, =gBattlerSpriteIds
strb r0, [r1, 0x3] strb r0, [r1, 0x3]
ldr r0, =gBattleMoveTarget ldr r0, =gBattlerTarget
ldrb r0, [r0] ldrb r0, [r0]
adds r0, r1 adds r0, r1
ldrb r1, [r0] ldrb r1, [r0]
@ -13905,12 +13905,12 @@ _080DEAD0:
.4byte _080DEB60 .4byte _080DEB60
.4byte _080DEB60 .4byte _080DEB60
_080DEB54: _080DEB54:
ldr r1, =gBattleMoveTarget ldr r1, =gBattlerTarget
movs r0, 0x2 movs r0, 0x2
b _080DEB64 b _080DEB64
.pool .pool
_080DEB60: _080DEB60:
ldr r1, =gBattleMoveTarget ldr r1, =gBattlerTarget
movs r0, 0x3 movs r0, 0x3
_080DEB64: _080DEB64:
strb r0, [r1] strb r0, [r1]

View File

@ -100,7 +100,7 @@ _0806BDBC:
lsrs r0, 24 lsrs r0, 24
_0806BDC4: _0806BDC4:
str r0, [sp, 0x34] str r0, [sp, 0x34]
ldr r1, =gStringBank ldr r1, =gStringBattler
ldr r0, =gBankInMenu ldr r0, =gBankInMenu
ldrb r2, [r0] ldrb r2, [r0]
strb r2, [r1] strb r2, [r1]

View File

@ -735,7 +735,7 @@ BattleScript_AlreadyPoisoned::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_ImmunityProtected:: BattleScript_ImmunityProtected::
copybyte gEffectBank, gBattleMoveTarget copybyte gEffectBank, gBattlerTarget
setbyte cMULTISTRING_CHOOSER, 0x0 setbyte cMULTISTRING_CHOOSER, 0x0
call BattleScript_PSNPrevention call BattleScript_PSNPrevention
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -1055,7 +1055,7 @@ BattleScript_AlreadyParalyzed::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_LimberProtected:: BattleScript_LimberProtected::
copybyte gEffectBank, gBattleMoveTarget copybyte gEffectBank, gBattlerTarget
setbyte cMULTISTRING_CHOOSER, 0x0 setbyte cMULTISTRING_CHOOSER, 0x0
call BattleScript_PRLZPrevention call BattleScript_PRLZPrevention
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -1513,7 +1513,7 @@ BattleScript_EffectCurse::
jumpifstat ATTACKER, NOT_EQUAL, ATK, 0xC, BattleScript_CurseTrySpeed jumpifstat ATTACKER, NOT_EQUAL, ATK, 0xC, BattleScript_CurseTrySpeed
jumpifstat ATTACKER, EQUAL, DEF, 0xC, BattleScript_ButItFailed jumpifstat ATTACKER, EQUAL, DEF, 0xC, BattleScript_ButItFailed
BattleScript_CurseTrySpeed:: BattleScript_CurseTrySpeed::
copybyte gBattleMoveTarget, gBattleMoveAttacker copybyte gBattlerTarget, gBattlerAttacker
setbyte sANIM_TURN, 0x1 setbyte sANIM_TURN, 0x1
attackanimation attackanimation
waitanimation waitanimation
@ -1534,7 +1534,7 @@ BattleScript_CurseTryDefence::
BattleScript_CurseEnd:: BattleScript_CurseEnd::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_GhostCurse:: BattleScript_GhostCurse::
jumpifbytenotequal gBattleMoveAttacker, gBattleMoveTarget, BattleScript_DoGhostCurse jumpifbytenotequal gBattlerAttacker, gBattlerTarget, BattleScript_DoGhostCurse
getmovetarget ATTACKER getmovetarget ATTACKER
BattleScript_DoGhostCurse:: BattleScript_DoGhostCurse::
attackcanceler attackcanceler
@ -2217,7 +2217,7 @@ BattleScript_EffectWillOWisp::
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
BattleScript_WaterVeilPrevents:: BattleScript_WaterVeilPrevents::
copybyte gEffectBank, gBattleMoveTarget copybyte gEffectBank, gBattlerTarget
setbyte cMULTISTRING_CHOOSER, 0x0 setbyte cMULTISTRING_CHOOSER, 0x0
call BattleScript_BRNPrevention call BattleScript_BRNPrevention
goto BattleScript_MoveEnd goto BattleScript_MoveEnd
@ -2598,11 +2598,11 @@ BattleScript_EffectTeeterDance::
attackcanceler attackcanceler
attackstring attackstring
ppreduce ppreduce
setbyte gBattleMoveTarget, 0x0 setbyte gBattlerTarget, 0x0
BattleScript_TeeterDanceLoop:: BattleScript_TeeterDanceLoop::
movevaluescleanup movevaluescleanup
setmoveeffect EFFECT_CONFUSION setmoveeffect EFFECT_CONFUSION
jumpifbyteequal gBattleMoveAttacker, gBattleMoveTarget, BattleScript_TeeterDanceLoopIncrement jumpifbyteequal gBattlerAttacker, gBattlerTarget, BattleScript_TeeterDanceLoopIncrement
jumpifability TARGET, ABILITY_OWN_TEMPO, BattleScript_TeeterDanceOwnTempoPrevents jumpifability TARGET, ABILITY_OWN_TEMPO, BattleScript_TeeterDanceOwnTempoPrevents
jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_TeeterDanceSubstitutePrevents jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_TeeterDanceSubstitutePrevents
jumpifstatus2 TARGET, STATUS2_CONFUSION, BattleScript_TeeterDanceAlreadyConfused jumpifstatus2 TARGET, STATUS2_CONFUSION, BattleScript_TeeterDanceAlreadyConfused
@ -2618,8 +2618,8 @@ BattleScript_TeeterDanceDoMoveEndIncrement::
setbyte sMOVEEND_STATE, 0x0 setbyte sMOVEEND_STATE, 0x0
moveend 0x2, 0x10 moveend 0x2, 0x10
BattleScript_TeeterDanceLoopIncrement:: BattleScript_TeeterDanceLoopIncrement::
addbyte gBattleMoveTarget, 0x1 addbyte gBattlerTarget, 0x1
jumpifbytenotequal gBattleMoveTarget, gBattlersCount, BattleScript_TeeterDanceLoop jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TeeterDanceLoop
end end
BattleScript_TeeterDanceOwnTempoPrevents:: BattleScript_TeeterDanceOwnTempoPrevents::
@ -3228,7 +3228,7 @@ BattleScript_DamagingWeatherContinues::
playanimation2 ATTACKER, sANIM_ARG1, NULL playanimation2 ATTACKER, sANIM_ARG1, NULL
setbyte gBattleCommunication, 0x0 setbyte gBattleCommunication, 0x0
BattleScript_DamagingWeatherLoop:: BattleScript_DamagingWeatherLoop::
copyarraywithindex gBattleMoveAttacker, gBattleTurnOrder, gBattleCommunication, 0x1 copyarraywithindex gBattlerAttacker, gBattleTurnOrder, gBattleCommunication, 0x1
weatherdamage weatherdamage
jumpifword EQUAL, gBattleMoveDamage, 0x0, BattleScript_DamagingWeatherLoopIncrement jumpifword EQUAL, gBattleMoveDamage, 0x0, BattleScript_DamagingWeatherLoopIncrement
printfromtable gSandStormHailDmgStringIds printfromtable gSandStormHailDmgStringIds
@ -3521,7 +3521,7 @@ BattleScript_RapidSpinAway::
BattleScript_WrapFree:: BattleScript_WrapFree::
printstring STRINGID_PKMNGOTFREE printstring STRINGID_PKMNGOTFREE
waitmessage 0x40 waitmessage 0x40
copybyte gBattleMoveTarget, sBANK copybyte gBattlerTarget, sBANK
return return
BattleScript_LeechSeedFree:: BattleScript_LeechSeedFree::
@ -4053,7 +4053,7 @@ BattleScript_82DB4B8::
BattleScript_82DB4BE:: BattleScript_82DB4BE::
pause 0x20 pause 0x20
BattleScript_82DB4C1:: BattleScript_82DB4C1::
setbyte gBattleMoveTarget, 0x0 setbyte gBattlerTarget, 0x0
setstatchanger ATK, 1, TRUE setstatchanger ATK, 1, TRUE
BattleScript_82DB4CD:: BattleScript_82DB4CD::
trygetintimidatetarget BattleScript_82DB51B trygetintimidatetarget BattleScript_82DB51B
@ -4068,7 +4068,7 @@ BattleScript_82DB4CD::
printstring STRINGID_PKMNCUTSATTACKWITH printstring STRINGID_PKMNCUTSATTACKWITH
waitmessage 0x40 waitmessage 0x40
BattleScript_82DB510:: BattleScript_82DB510::
addbyte gBattleMoveTarget, 0x1 addbyte gBattlerTarget, 0x1
goto BattleScript_82DB4CD goto BattleScript_82DB4CD
BattleScript_82DB51B:: BattleScript_82DB51B::
return return

View File

@ -13,17 +13,18 @@
/* /*
* A battler may be in one of four positions on the field. The first bit determines * A battler may be in one of four positions on the field. The first bit determines
* what side the battler is on, either the player's side or the opponent's side. * what side the battler is on, either the player's side or the opponent's side.
* The second bit determines whether the pokemon is on the left or right of the * The second bit determines what flank the battler is on, either the left or right.
* given side. Note that the opponent's mons are drawn opposite because the position * Note that the opponent's flanks are drawn corresponding to their perspective, so
* numbers correspond to their perspective. The battler number is usually the same * their right mon appears on the left, and their left mon appears on the right.
* as the position, except in the case of link battles. * The battler ID is usually the same as the position, except in the case of link battles.
* *
* + ------------------------- + * + ------------------------- +
* | Opponent's side | * | Opponent's side |
* | Right Left |
* | 3 1 | * | 3 1 |
* | | * | |
* | |
* | Player's side | * | Player's side |
* | Left Right |
* | 0 2 | * | 0 2 |
* ----------------------------+ * ----------------------------+
* | | * | |
@ -38,12 +39,16 @@
#define B_POSITION_PLAYER_RIGHT 2 #define B_POSITION_PLAYER_RIGHT 2
#define B_POSITION_OPPONENT_RIGHT 3 #define B_POSITION_OPPONENT_RIGHT 3
#define B_POSITION_PARTNER(position) ((position) ^ 2) // These macros can be used with either battler ID or positions to get the partner or the opposite mon
#define B_POSITION_OPPOSITE(position) ((position) ^ 1) #define BATTLE_OPPOSITE(id) ((id) ^ 1)
#define BATTLE_PARTNER(id) ((id) ^ 2)
#define B_SIDE_PLAYER 0 #define B_SIDE_PLAYER 0
#define B_SIDE_OPPONENT 1 #define B_SIDE_OPPONENT 1
#define B_FLANK_LEFT 0
#define B_FLANK_RIGHT 1
#define BIT_SIDE 1 #define BIT_SIDE 1
#define BIT_FLANK 2 #define BIT_FLANK 2
@ -170,7 +175,7 @@ extern u8 gBattleOutcome;
extern u32 gStatuses3[MAX_BATTLERS_COUNT]; extern u32 gStatuses3[MAX_BATTLERS_COUNT];
// // Not really sure what a "hitmarker" is.
#define HITMARKER_x10 0x00000010 #define HITMARKER_x10 0x00000010
#define HITMARKER_x20 0x00000020 #define HITMARKER_x20 0x00000020
@ -214,21 +219,24 @@ extern u32 gHitMarker;
extern u16 gSideStatuses[2]; extern u16 gSideStatuses[2];
#define ACTION_USE_MOVE 0 // Battle Actions
#define ACTION_USE_ITEM 1 // These determine what each battler will do in a turn
#define ACTION_SWITCH 2 #define B_ACTION_USE_MOVE 0
#define ACTION_RUN 3 #define B_ACTION_USE_ITEM 1
#define ACTION_WATCHES_CAREFULLY 4 #define B_ACTION_SWITCH 2
#define ACTION_SAFARI_ZONE_BALL 5 #define B_ACTION_RUN 3
#define ACTION_POKEBLOCK_CASE 6 #define B_ACTION_SAFARI_WATCH_CAREFULLY 4
#define ACTION_GO_NEAR 7 #define B_ACTION_SAFARI_BALL 5
#define ACTION_SAFARI_ZONE_RUN 8 #define B_ACTION_SAFARI_POKEBLOCK 6
#define ACTION_9 9 #define B_ACTION_SAFARI_GO_NEAR 7
#define ACTION_RUN_BATTLESCRIPT 10 // when executing an action #define B_ACTION_SAFARI_RUN 8
#define ACTION_CANCEL_PARTNER 12 // when choosing an action // The exact purposes of these are unclear
#define ACTION_FINISHED 12 // when executing an action #define B_ACTION_UNKNOWN9 9
#define ACTION_NOTHING_FAINTED 13 // when choosing an action #define B_ACTION_EXEC_SCRIPT 10 // when executing an action
#define ACTION_INIT_VALUE 0xFF #define B_ACTION_CANCEL_PARTNER 12 // when choosing an action
#define B_ACTION_FINISHED 12 // when executing an action
#define B_ACTION_NOTHING_FAINTED 13 // when choosing an action
#define B_ACTION_NONE 0xFF
#define MOVE_RESULT_MISSED (1 << 0) #define MOVE_RESULT_MISSED (1 << 0)
#define MOVE_RESULT_SUPER_EFFECTIVE (1 << 1) #define MOVE_RESULT_SUPER_EFFECTIVE (1 << 1)
@ -421,8 +429,8 @@ struct DisableStruct
/*0x12*/ u8 chargeTimer2 : 4; /*0x12*/ u8 chargeTimer2 : 4;
/*0x13*/ u8 tauntTimer1:4; /*0x13*/ u8 tauntTimer1:4;
/*0x13*/ u8 tauntTimer2:4; /*0x13*/ u8 tauntTimer2:4;
/*0x14*/ u8 bankPreventingEscape; /*0x14*/ u8 battlerPreventingEscape;
/*0x15*/ u8 bankWithSureHit; /*0x15*/ u8 battlerWithSureHit;
/*0x16*/ u8 isFirstTurn; /*0x16*/ u8 isFirstTurn;
/*0x17*/ u8 unk17; /*0x17*/ u8 unk17;
/*0x18*/ u8 truantCounter : 1; /*0x18*/ u8 truantCounter : 1;
@ -594,10 +602,6 @@ struct BattleResources
extern struct BattleResources* gBattleResources; extern struct BattleResources* gBattleResources;
#define BATTLESCRIPTS_STACK (gBattleResources->battleScriptsStack)
#define BATTLE_CALLBACKS_STACK (gBattleResources->battleCallbackStack)
#define BATTLE_LVLUP_STATS (gBattleResources->statsBeforeLvlUp)
struct BattleResults struct BattleResults
{ {
u8 playerFaintCounter; // 0x0 u8 playerFaintCounter; // 0x0
@ -836,7 +840,7 @@ struct BattleScripting
u8 animArg2; u8 animArg2;
u16 tripleKickPower; u16 tripleKickPower;
u8 atk49_state; u8 atk49_state;
u8 bankWithAbility; u8 battlerWithAbility;
u8 multihitMoveEffect; u8 multihitMoveEffect;
u8 battler; u8 battler;
u8 animTurn; u8 animTurn;
@ -946,7 +950,7 @@ struct BattleBarInfo
struct BattleSpriteData struct BattleSpriteData
{ {
struct BattleSpriteInfo *bankData; struct BattleSpriteInfo *battlerData;
struct BattleHealthboxInfo *healthBoxesData; struct BattleHealthboxInfo *healthBoxesData;
struct BattleAnimationInfo *animationData; struct BattleAnimationInfo *animationData;
struct BattleBarInfo *battleBars; struct BattleBarInfo *battleBars;

View File

@ -4,9 +4,9 @@
void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves); void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves);
void BattleAI_SetupAIData(u8 defaultScoreMoves); void BattleAI_SetupAIData(u8 defaultScoreMoves);
u8 BattleAI_ChooseMoveOrAction(void); u8 BattleAI_ChooseMoveOrAction(void);
void ClearBankMoveHistory(u8 bank); void ClearBattlerMoveHistory(u8 bank);
void RecordAbilityBattle(u8 bank, u8 abilityId); void RecordAbilityBattle(u8 bank, u8 abilityId);
void ClearBankAbilityHistory(u8 bank); void ClearBattlerAbilityHistory(u8 bank);
void RecordItemEffectBattle(u8 bank, u8 itemEffect); void RecordItemEffectBattle(u8 bank, u8 itemEffect);
void ClearBankItemEffectHistory(u8 bank); void ClearBankItemEffectHistory(u8 bank);

View File

@ -54,7 +54,7 @@ enum
HEALTHBOX_SAFARI_BALLS_TEXT HEALTHBOX_SAFARI_BALLS_TEXT
}; };
u8 CreateHealthboxSprites(u8 bank); u8 CreateBattlerHealthboxSprites(u8 bank);
u8 CreateSafariPlayerHealthboxSprites(void); u8 CreateSafariPlayerHealthboxSprites(void);
void SetBattleBarStruct(u8 bank, u8 healthboxSpriteId, s32 maxVal, s32 currVal, s32 receivedValue); void SetBattleBarStruct(u8 bank, u8 healthboxSpriteId, s32 maxVal, s32 currVal, s32 receivedValue);
void SetHealthboxSpriteInvisible(u8 healthboxSpriteId); void SetHealthboxSpriteInvisible(u8 healthboxSpriteId);

View File

@ -9,7 +9,7 @@ void sub_8184DA4(u8 arg0);
void sub_8184E58(void); void sub_8184E58(void);
void RecordedBattle_SetBattlerAction(u8 bank, u8 action); void RecordedBattle_SetBattlerAction(u8 bank, u8 action);
void RecordedBattle_ClearBattlerAction(u8 bank, u8 bytesToClear); void RecordedBattle_ClearBattlerAction(u8 bank, u8 bytesToClear);
u8 RecordedBattle_GetBankAction(u8 bank); u8 RecordedBattle_GetBattlerAction(u8 bank);
u8 sub_81850D0(void); u8 sub_81850D0(void);
u8 sub_81850DC(u8 *arg0); u8 sub_81850DC(u8 *arg0);
void sub_81851A8(u8 *arg0); void sub_81851A8(u8 *arg0);

View File

@ -48,7 +48,7 @@ extern u32 gBattleTypeFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u16 gCurrentMove; extern u16 gCurrentMove;
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u16 gLastMoves[MAX_BATTLERS_COUNT]; extern u16 gLastMoves[MAX_BATTLERS_COUNT];
extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_A;
@ -179,7 +179,7 @@ static void BattleAICmd_if_holds_item(void);
// ewram // ewram
EWRAM_DATA const u8 *gAIScriptPtr = NULL; EWRAM_DATA const u8 *gAIScriptPtr = NULL;
EWRAM_DATA static u8 sBank_AI = 0; EWRAM_DATA static u8 sBattler_AI = 0;
// const rom data // const rom data
@ -363,18 +363,18 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves)
AI_THINKING_STRUCT->simulatedRNG[i] = 100 - (Random() % 16); AI_THINKING_STRUCT->simulatedRNG[i] = 100 - (Random() % 16);
} }
gBattleResources->AI_ScriptsStack->size = 0; gBattleResources->AI_ScriptsStack->size = 0;
sBank_AI = gActiveBattler; sBattler_AI = gActiveBattler;
// decide a random target bank in doubles // decide a random target bank in doubles
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
gBattleMoveTarget = (Random() & BIT_FLANK) + (GetBattlerSide(gActiveBattler) ^ BIT_SIDE); gBattlerTarget = (Random() & BIT_FLANK) + (GetBattlerSide(gActiveBattler) ^ BIT_SIDE);
if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
gBattleMoveTarget ^= BIT_FLANK; gBattlerTarget ^= BIT_FLANK;
} }
// in singles there's only one choice // in singles there's only one choice
else else
{ {
gBattleMoveTarget = sBank_AI ^ BIT_SIDE; gBattlerTarget = sBattler_AI ^ BIT_SIDE;
} }
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
@ -444,7 +444,7 @@ static u8 BattleAI_ChooseMoveOrAction_Singles(void)
for (i = 1; i < 4; i++) for (i = 1; i < 4; i++)
{ {
if (gBattleMons[sBank_AI].moves[i] != 0) // emerald adds an extra move ID check for some reason. if (gBattleMons[sBattler_AI].moves[i] != 0) // emerald adds an extra move ID check for some reason.
{ {
// in ruby, the order of these if statements are reversed. // in ruby, the order of these if statements are reversed.
if (currentMoveArray[0] == AI_THINKING_STRUCT->score[i]) if (currentMoveArray[0] == AI_THINKING_STRUCT->score[i])
@ -479,7 +479,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (i == sBank_AI || gBattleMons[i].hp == 0) if (i == sBattler_AI || gBattleMons[i].hp == 0)
{ {
actionOrMoveIndex[i] = -1; actionOrMoveIndex[i] = -1;
bestMovePointsForTarget[i] = -1; bestMovePointsForTarget[i] = -1;
@ -491,9 +491,9 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
else else
BattleAI_SetupAIData(0xF); BattleAI_SetupAIData(0xF);
gBattleMoveTarget = i; gBattlerTarget = i;
if ((i & BIT_SIDE) != (sBank_AI & BIT_SIDE)) if ((i & BIT_SIDE) != (sBattler_AI & BIT_SIDE))
RecordLastUsedMoveByTarget(); RecordLastUsedMoveByTarget();
AI_THINKING_STRUCT->aiLogicId = 0; AI_THINKING_STRUCT->aiLogicId = 0;
@ -521,7 +521,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
mostViableMovesNo = 1; mostViableMovesNo = 1;
for (j = 1; j < 4; j++) for (j = 1; j < 4; j++)
{ {
if (gBattleMons[sBank_AI].moves[j] != 0) if (gBattleMons[sBattler_AI].moves[j] != 0)
{ {
if (mostViableMovesScores[0] == AI_THINKING_STRUCT->score[j]) if (mostViableMovesScores[0] == AI_THINKING_STRUCT->score[j])
{ {
@ -542,7 +542,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
bestMovePointsForTarget[i] = mostViableMovesScores[0]; bestMovePointsForTarget[i] = mostViableMovesScores[0];
// don't use a move against ally if it has less than 100 pts // don't use a move against ally if it has less than 100 pts
if (i == (sBank_AI ^ BIT_FLANK) && bestMovePointsForTarget[i] < 100) if (i == (sBattler_AI ^ BIT_FLANK) && bestMovePointsForTarget[i] < 100)
{ {
bestMovePointsForTarget[i] = -1; bestMovePointsForTarget[i] = -1;
mostViableMovesScores[0] = mostViableMovesScores[0]; // needed to match mostViableMovesScores[0] = mostViableMovesScores[0]; // needed to match
@ -573,8 +573,8 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void)
} }
} }
gBattleMoveTarget = mostViableTargetsArray[Random() % mostViableTargetsNo]; gBattlerTarget = mostViableTargetsArray[Random() % mostViableTargetsNo];
return actionOrMoveIndex[gBattleMoveTarget]; return actionOrMoveIndex[gBattlerTarget];
} }
static void BattleAI_DoAIProcessing(void) static void BattleAI_DoAIProcessing(void)
@ -587,13 +587,13 @@ static void BattleAI_DoAIProcessing(void)
break; break;
case AIState_SettingUp: case AIState_SettingUp:
gAIScriptPtr = gBattleAI_ScriptsTable[AI_THINKING_STRUCT->aiLogicId]; // set AI ptr to logic ID. gAIScriptPtr = gBattleAI_ScriptsTable[AI_THINKING_STRUCT->aiLogicId]; // set AI ptr to logic ID.
if (gBattleMons[sBank_AI].pp[AI_THINKING_STRUCT->movesetIndex] == 0) if (gBattleMons[sBattler_AI].pp[AI_THINKING_STRUCT->movesetIndex] == 0)
{ {
AI_THINKING_STRUCT->moveConsidered = 0; AI_THINKING_STRUCT->moveConsidered = 0;
} }
else else
{ {
AI_THINKING_STRUCT->moveConsidered = gBattleMons[sBank_AI].moves[AI_THINKING_STRUCT->movesetIndex]; AI_THINKING_STRUCT->moveConsidered = gBattleMons[sBattler_AI].moves[AI_THINKING_STRUCT->movesetIndex];
} }
AI_THINKING_STRUCT->aiState++; AI_THINKING_STRUCT->aiState++;
break; break;
@ -627,18 +627,18 @@ static void RecordLastUsedMoveByTarget(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] == gLastMoves[gBattleMoveTarget]) if (gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] == gLastMoves[gBattlerTarget])
break; break;
if (gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] != gLastMoves[gBattleMoveTarget] // HACK: This redundant condition is a hack to make the asm match. if (gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] != gLastMoves[gBattlerTarget] // HACK: This redundant condition is a hack to make the asm match.
&& gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] == 0) && gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] == 0)
{ {
gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] = gLastMoves[gBattleMoveTarget]; gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] = gLastMoves[gBattlerTarget];
break; break;
} }
} }
} }
void ClearBankMoveHistory(u8 bank) void ClearBattlerMoveHistory(u8 bank)
{ {
s32 i; s32 i;
@ -651,7 +651,7 @@ void RecordAbilityBattle(u8 bank, u8 abilityId)
gBattleResources->battleHistory->abilities[bank] = abilityId; gBattleResources->battleHistory->abilities[bank] = abilityId;
} }
void ClearBankAbilityHistory(u8 bank) void ClearBattlerAbilityHistory(u8 bank)
{ {
gBattleResources->battleHistory->abilities[bank] = 0; gBattleResources->battleHistory->abilities[bank] = 0;
} }
@ -721,9 +721,9 @@ static void BattleAICmd_if_hp_less_than(void)
u16 bank; u16 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2]) if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -736,9 +736,9 @@ static void BattleAICmd_if_hp_more_than(void)
u16 bank; u16 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2]) if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -751,9 +751,9 @@ static void BattleAICmd_if_hp_equal(void)
u16 bank; u16 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2]) if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -766,9 +766,9 @@ static void BattleAICmd_if_hp_not_equal(void)
u16 bank; u16 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2]) if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3);
@ -782,9 +782,9 @@ static void BattleAICmd_if_status(void)
u32 status; u32 status;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -800,9 +800,9 @@ static void BattleAICmd_if_not_status(void)
u32 status; u32 status;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -818,9 +818,9 @@ static void BattleAICmd_if_status2(void)
u32 status; u32 status;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -836,9 +836,9 @@ static void BattleAICmd_if_not_status2(void)
u32 status; u32 status;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -854,9 +854,9 @@ static void BattleAICmd_if_status3(void)
u32 status; u32 status;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -872,9 +872,9 @@ static void BattleAICmd_if_not_status3(void)
u32 status; u32 status;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -890,9 +890,9 @@ static void BattleAICmd_if_side_affecting(void)
u32 side, status; u32 side, status;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
side = GET_BATTLER_SIDE(bank); side = GET_BATTLER_SIDE(bank);
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -909,9 +909,9 @@ static void BattleAICmd_if_not_side_affecting(void)
u32 side, status; u32 side, status;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
side = GET_BATTLER_SIDE(bank); side = GET_BATTLER_SIDE(bank);
status = AIScriptRead32(gAIScriptPtr + 2); status = AIScriptRead32(gAIScriptPtr + 2);
@ -1084,8 +1084,8 @@ static void BattleAICmd_if_user_has_attacking_move(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (gBattleMons[sBank_AI].moves[i] != 0 if (gBattleMons[sBattler_AI].moves[i] != 0
&& gBattleMoves[gBattleMons[sBank_AI].moves[i]].power != 0) && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].power != 0)
break; break;
} }
if (i == 4) if (i == 4)
@ -1100,8 +1100,8 @@ static void BattleAICmd_if_user_has_no_attacking_moves(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (gBattleMons[sBank_AI].moves[i] != 0 if (gBattleMons[sBattler_AI].moves[i] != 0
&& gBattleMoves[gBattleMons[sBank_AI].moves[i]].power != 0) && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].power != 0)
break; break;
} }
if (i != 4) if (i != 4)
@ -1123,16 +1123,16 @@ static void BattleAICmd_get_type(void)
switch (typeVar) switch (typeVar)
{ {
case AI_TYPE1_USER: // AI user primary type case AI_TYPE1_USER: // AI user primary type
AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type1; AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type1;
break; break;
case AI_TYPE1_TARGET: // target primary type case AI_TYPE1_TARGET: // target primary type
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleMoveTarget].type1; AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type1;
break; break;
case AI_TYPE2_USER: // AI user secondary type case AI_TYPE2_USER: // AI user secondary type
AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type2; AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type2;
break; break;
case AI_TYPE2_TARGET: // target secondary type case AI_TYPE2_TARGET: // target secondary type
AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleMoveTarget].type2; AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type2;
break; break;
case AI_TYPE_MOVE: // type of move being pointed to case AI_TYPE_MOVE: // type of move being pointed to
AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type; AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type;
@ -1146,14 +1146,14 @@ static u8 BattleAI_GetWantedBank(u8 bank)
switch (bank) switch (bank)
{ {
case AI_USER: case AI_USER:
return sBank_AI; return sBattler_AI;
case AI_TARGET: case AI_TARGET:
default: default:
return gBattleMoveTarget; return gBattlerTarget;
case AI_USER_PARTNER: case AI_USER_PARTNER:
return sBank_AI ^ BIT_FLANK; return sBattler_AI ^ BIT_FLANK;
case AI_TARGET_PARTNER: case AI_TARGET_PARTNER:
return gBattleMoveTarget ^ BIT_FLANK; return gBattlerTarget ^ BIT_FLANK;
} }
} }
@ -1203,17 +1203,17 @@ static void BattleAICmd_get_how_powerful_move_is(void)
{ {
for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++) for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++)
{ {
if (gBattleMoves[gBattleMons[sBank_AI].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i]) if (gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i])
break; break;
} }
if (gBattleMons[sBank_AI].moves[checkedMove] != MOVE_NONE if (gBattleMons[sBattler_AI].moves[checkedMove] != MOVE_NONE
&& sDiscouragedPowerfulMoveEffects[i] == 0xFFFF && sDiscouragedPowerfulMoveEffects[i] == 0xFFFF
&& gBattleMoves[gBattleMons[sBank_AI].moves[checkedMove]].power > 1) && gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].power > 1)
{ {
gCurrentMove = gBattleMons[sBank_AI].moves[checkedMove]; gCurrentMove = gBattleMons[sBattler_AI].moves[checkedMove];
AI_CalcDmg(sBank_AI, gBattleMoveTarget); AI_CalcDmg(sBattler_AI, gBattlerTarget);
TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget); TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
moveDmgs[checkedMove] = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[checkedMove] / 100; moveDmgs[checkedMove] = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[checkedMove] / 100;
if (moveDmgs[checkedMove] == 0) if (moveDmgs[checkedMove] == 0)
moveDmgs[checkedMove] = 1; moveDmgs[checkedMove] = 1;
@ -1246,9 +1246,9 @@ static void BattleAICmd_get_how_powerful_move_is(void)
static void BattleAICmd_get_last_used_bank_move(void) static void BattleAICmd_get_last_used_bank_move(void)
{ {
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
AI_THINKING_STRUCT->funcResult = gLastMoves[sBank_AI]; AI_THINKING_STRUCT->funcResult = gLastMoves[sBattler_AI];
else else
AI_THINKING_STRUCT->funcResult = gLastMoves[gBattleMoveTarget]; AI_THINKING_STRUCT->funcResult = gLastMoves[gBattlerTarget];
gAIScriptPtr += 2; gAIScriptPtr += 2;
} }
@ -1271,7 +1271,7 @@ static void BattleAICmd_if_not_equal_(void) // same as if_not_equal
static void BattleAICmd_if_user_goes(void) static void BattleAICmd_if_user_goes(void)
{ {
if (GetWhoStrikesFirst(sBank_AI, gBattleMoveTarget, TRUE) == gAIScriptPtr[1]) if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) == gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
else else
gAIScriptPtr += 6; gAIScriptPtr += 6;
@ -1279,7 +1279,7 @@ static void BattleAICmd_if_user_goes(void)
static void BattleAICmd_if_user_doesnt_go(void) static void BattleAICmd_if_user_doesnt_go(void)
{ {
if (GetWhoStrikesFirst(sBank_AI, gBattleMoveTarget, TRUE) != gAIScriptPtr[1]) if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) != gAIScriptPtr[1])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
else else
gAIScriptPtr += 6; gAIScriptPtr += 6;
@ -1303,9 +1303,9 @@ static void BattleAICmd_count_usable_party_mons(void)
AI_THINKING_STRUCT->funcResult = 0; AI_THINKING_STRUCT->funcResult = 0;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if (GetBattlerSide(bank) == B_SIDE_PLAYER) if (GetBattlerSide(bank) == B_SIDE_PLAYER)
party = gPlayerParty; party = gPlayerParty;
@ -1356,9 +1356,9 @@ static void BattleAICmd_get_ability(void)
u8 bank; u8 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if (gActiveBattler != bank) if (gActiveBattler != bank)
{ {
@ -1489,11 +1489,11 @@ static void BattleAICmd_get_highest_type_effectiveness(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
gBattleMoveDamage = AI_EFFECTIVENESS_x1; gBattleMoveDamage = AI_EFFECTIVENESS_x1;
gCurrentMove = gBattleMons[sBank_AI].moves[i]; gCurrentMove = gBattleMons[sBattler_AI].moves[i];
if (gCurrentMove) if (gCurrentMove)
{ {
TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget); TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
// reduce by 1/3. // reduce by 1/3.
if (gBattleMoveDamage == 120) if (gBattleMoveDamage == 120)
@ -1528,7 +1528,7 @@ static void BattleAICmd_if_type_effectiveness(void)
gBattleMoveDamage = AI_EFFECTIVENESS_x1; gBattleMoveDamage = AI_EFFECTIVENESS_x1;
gCurrentMove = AI_THINKING_STRUCT->moveConsidered; gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget); TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
if (gBattleMoveDamage == 120) if (gBattleMoveDamage == 120)
gBattleMoveDamage = AI_EFFECTIVENESS_x2; gBattleMoveDamage = AI_EFFECTIVENESS_x2;
@ -1569,10 +1569,10 @@ static void BattleAICmd_if_status_in_party(void)
switch(gAIScriptPtr[1]) switch(gAIScriptPtr[1])
{ {
case AI_USER: case AI_USER:
bank = sBank_AI; bank = sBattler_AI;
break; break;
default: default:
bank = gBattleMoveTarget; bank = gBattlerTarget;
break; break;
} }
@ -1606,10 +1606,10 @@ static void BattleAICmd_if_status_not_in_party(void)
switch(gAIScriptPtr[1]) switch(gAIScriptPtr[1])
{ {
case 1: case 1:
bank = sBank_AI; bank = sBattler_AI;
break; break;
default: default:
bank = gBattleMoveTarget; bank = gBattlerTarget;
break; break;
} }
@ -1667,9 +1667,9 @@ static void BattleAICmd_if_stat_level_less_than(void)
u32 bank; u32 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3]) if (gBattleMons[bank].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1682,9 +1682,9 @@ static void BattleAICmd_if_stat_level_more_than(void)
u32 bank; u32 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3]) if (gBattleMons[bank].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1697,9 +1697,9 @@ static void BattleAICmd_if_stat_level_equal(void)
u32 bank; u32 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3]) if (gBattleMons[bank].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1712,9 +1712,9 @@ static void BattleAICmd_if_stat_level_not_equal(void)
u32 bank; u32 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if (gBattleMons[bank].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3]) if (gBattleMons[bank].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3])
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4);
@ -1736,8 +1736,8 @@ static void BattleAICmd_if_can_faint(void)
gMoveResultFlags = 0; gMoveResultFlags = 0;
gCritMultiplier = 1; gCritMultiplier = 1;
gCurrentMove = AI_THINKING_STRUCT->moveConsidered; gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
AI_CalcDmg(sBank_AI, gBattleMoveTarget); AI_CalcDmg(sBattler_AI, gBattlerTarget);
TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget); TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100; gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
@ -1745,7 +1745,7 @@ static void BattleAICmd_if_can_faint(void)
if (gBattleMoveDamage == 0) if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1; gBattleMoveDamage = 1;
if (gBattleMons[gBattleMoveTarget].hp <= gBattleMoveDamage) if (gBattleMons[gBattlerTarget].hp <= gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else else
gAIScriptPtr += 5; gAIScriptPtr += 5;
@ -1765,14 +1765,14 @@ static void BattleAICmd_if_cant_faint(void)
gMoveResultFlags = 0; gMoveResultFlags = 0;
gCritMultiplier = 1; gCritMultiplier = 1;
gCurrentMove = AI_THINKING_STRUCT->moveConsidered; gCurrentMove = AI_THINKING_STRUCT->moveConsidered;
AI_CalcDmg(sBank_AI, gBattleMoveTarget); AI_CalcDmg(sBattler_AI, gBattlerTarget);
TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget); TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget);
gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100; gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100;
// this macro is missing the damage 0 = 1 assumption. // this macro is missing the damage 0 = 1 assumption.
if (gBattleMons[gBattleMoveTarget].hp > gBattleMoveDamage) if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else else
gAIScriptPtr += 5; gAIScriptPtr += 5;
@ -1788,7 +1788,7 @@ static void BattleAICmd_if_has_move(void)
case AI_USER: case AI_USER:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (gBattleMons[sBank_AI].moves[i] == *movePtr) if (gBattleMons[sBattler_AI].moves[i] == *movePtr)
break; break;
} }
if (i == 4) if (i == 4)
@ -1802,7 +1802,7 @@ static void BattleAICmd_if_has_move(void)
return; return;
} }
case AI_USER_PARTNER: case AI_USER_PARTNER:
if (gBattleMons[sBank_AI ^ BIT_FLANK].hp == 0) if (gBattleMons[sBattler_AI ^ BIT_FLANK].hp == 0)
{ {
gAIScriptPtr += 8; gAIScriptPtr += 8;
return; return;
@ -1811,7 +1811,7 @@ static void BattleAICmd_if_has_move(void)
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (gBattleMons[sBank_AI ^ BIT_FLANK].moves[i] == *movePtr) if (gBattleMons[sBattler_AI ^ BIT_FLANK].moves[i] == *movePtr)
break; break;
} }
} }
@ -1829,7 +1829,7 @@ static void BattleAICmd_if_has_move(void)
case AI_TARGET_PARTNER: case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i] == *movePtr) if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == *movePtr)
break; break;
} }
if (i == 4) if (i == 4)
@ -1856,7 +1856,7 @@ static void BattleAICmd_if_doesnt_have_move(void)
case AI_USER_PARTNER: // UB: no separate check for user partner case AI_USER_PARTNER: // UB: no separate check for user partner
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (gBattleMons[sBank_AI].moves[i] == *movePtr) if (gBattleMons[sBattler_AI].moves[i] == *movePtr)
break; break;
} }
if (i != 4) if (i != 4)
@ -1873,7 +1873,7 @@ static void BattleAICmd_if_doesnt_have_move(void)
case AI_TARGET_PARTNER: case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i] == *movePtr) if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == *movePtr)
break; break;
} }
if (i != 4) if (i != 4)
@ -1899,7 +1899,7 @@ static void BattleAICmd_if_has_move_with_effect(void)
case AI_USER_PARTNER: case AI_USER_PARTNER:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBank_AI].moves[i]].effect == gAIScriptPtr[2]) if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].effect == gAIScriptPtr[2])
break; break;
} }
if (i == 4) if (i == 4)
@ -1911,8 +1911,8 @@ static void BattleAICmd_if_has_move_with_effect(void)
case AI_TARGET_PARTNER: case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
// UB: checks sBank_AI instead of gBattleMoveTarget // UB: checks sBattler_AI instead of gBattlerTarget
if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i]].effect == gAIScriptPtr[2]) if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i]].effect == gAIScriptPtr[2])
break; break;
} }
if (i == 4) if (i == 4)
@ -1933,7 +1933,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
case AI_USER_PARTNER: case AI_USER_PARTNER:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if(gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBank_AI].moves[i]].effect == gAIScriptPtr[2]) if(gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].effect == gAIScriptPtr[2])
break; break;
} }
if (i != 4) if (i != 4)
@ -1945,7 +1945,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void)
case AI_TARGET_PARTNER: case AI_TARGET_PARTNER:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i]].effect == gAIScriptPtr[2]) if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i]].effect == gAIScriptPtr[2])
break; break;
} }
if (i != 4) if (i != 4)
@ -1961,9 +1961,9 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void)
u8 bank; u8 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if (gAIScriptPtr[2] == 0) if (gAIScriptPtr[2] == 0)
{ {
@ -2039,9 +2039,9 @@ static void BattleAICmd_get_hold_effect(void)
u8 bank; u8 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
if (gActiveBattler != bank) if (gActiveBattler != bank)
AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]); AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]);
@ -2057,7 +2057,7 @@ static void BattleAICmd_if_holds_item(void)
u16 item; u16 item;
u8 var1, var2; u8 var1, var2;
if ((bank & BIT_SIDE) == (sBank_AI & BIT_SIDE)) if ((bank & BIT_SIDE) == (sBattler_AI & BIT_SIDE))
item = gBattleMons[bank].item; item = gBattleMons[bank].item;
else else
item = BATTLE_HISTORY->itemEffects[bank]; item = BATTLE_HISTORY->itemEffects[bank];
@ -2077,9 +2077,9 @@ static void BattleAICmd_get_gender(void)
u8 bank; u8 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[bank].species, gBattleMons[bank].personality); AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[bank].species, gBattleMons[bank].personality);
@ -2091,9 +2091,9 @@ static void BattleAICmd_is_first_turn_for(void)
u8 bank; u8 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].isFirstTurn; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].isFirstTurn;
@ -2105,9 +2105,9 @@ static void BattleAICmd_get_stockpile_count(void)
u8 bank; u8 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].stockpileCounter; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].stockpileCounter;
@ -2126,9 +2126,9 @@ static void BattleAICmd_get_used_held_item(void)
u8 bank; u8 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
// This is likely a leftover from Ruby's code and its ugly ewram access // This is likely a leftover from Ruby's code and its ugly ewram access
#ifdef NONMATCHING #ifdef NONMATCHING
@ -2166,9 +2166,9 @@ static void BattleAICmd_get_protect_count(void)
u8 bank; u8 bank;
if (gAIScriptPtr[1] == AI_USER) if (gAIScriptPtr[1] == AI_USER)
bank = sBank_AI; bank = sBattler_AI;
else else
bank = gBattleMoveTarget; bank = gBattlerTarget;
AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].protectUses; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].protectUses;
@ -2221,7 +2221,7 @@ static void BattleAICmd_if_level_cond(void)
switch (gAIScriptPtr[1]) switch (gAIScriptPtr[1])
{ {
case 0: // greater than case 0: // greater than
if (gBattleMons[sBank_AI].level > gBattleMons[gBattleMoveTarget].level) if (gBattleMons[sBattler_AI].level > gBattleMons[gBattlerTarget].level)
{ {
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return; return;
@ -2229,7 +2229,7 @@ static void BattleAICmd_if_level_cond(void)
gAIScriptPtr += 6; gAIScriptPtr += 6;
return; return;
case 1: // less than case 1: // less than
if (gBattleMons[sBank_AI].level < gBattleMons[gBattleMoveTarget].level) if (gBattleMons[sBattler_AI].level < gBattleMons[gBattlerTarget].level)
{ {
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return; return;
@ -2237,7 +2237,7 @@ static void BattleAICmd_if_level_cond(void)
gAIScriptPtr += 6; gAIScriptPtr += 6;
return; return;
case 2: // equal case 2: // equal
if (gBattleMons[sBank_AI].level == gBattleMons[gBattleMoveTarget].level) if (gBattleMons[sBattler_AI].level == gBattleMons[gBattlerTarget].level)
{ {
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2);
return; return;
@ -2249,7 +2249,7 @@ static void BattleAICmd_if_level_cond(void)
static void BattleAICmd_if_target_taunted(void) static void BattleAICmd_if_target_taunted(void)
{ {
if (gDisableStructs[gBattleMoveTarget].tauntTimer1 != 0) if (gDisableStructs[gBattlerTarget].tauntTimer1 != 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else else
gAIScriptPtr += 5; gAIScriptPtr += 5;
@ -2257,7 +2257,7 @@ static void BattleAICmd_if_target_taunted(void)
static void BattleAICmd_if_target_not_taunted(void) static void BattleAICmd_if_target_not_taunted(void)
{ {
if (gDisableStructs[gBattleMoveTarget].tauntTimer1 == 0) if (gDisableStructs[gBattlerTarget].tauntTimer1 == 0)
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else else
gAIScriptPtr += 5; gAIScriptPtr += 5;
@ -2265,7 +2265,7 @@ static void BattleAICmd_if_target_not_taunted(void)
static void BattleAICmd_if_target_is_ally(void) static void BattleAICmd_if_target_is_ally(void)
{ {
if ((sBank_AI & BIT_SIDE) == (gBattleMoveTarget & BIT_SIDE)) if ((sBattler_AI & BIT_SIDE) == (gBattlerTarget & BIT_SIDE))
gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1);
else else
gAIScriptPtr += 5; gAIScriptPtr += 5;

View File

@ -39,7 +39,7 @@ static bool8 ShouldSwitchIfPerishSong(void)
&& gDisableStructs[gActiveBattler].perishSongTimer1 == 0) && gDisableStructs[gActiveBattler].perishSongTimer1 == 0)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
@ -60,7 +60,7 @@ static bool8 ShouldSwitchIfWonderGuard(void)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
return FALSE; return FALSE;
opposingPosition = B_POSITION_OPPOSITE(GetBattlerPosition(gActiveBattler)); opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler));
if (gBattleMons[GetBattlerAtPosition(opposingPosition)].ability != ABILITY_WONDER_GUARD) if (gBattleMons[GetBattlerAtPosition(opposingPosition)].ability != ABILITY_WONDER_GUARD)
return FALSE; return FALSE;
@ -121,7 +121,7 @@ static bool8 ShouldSwitchIfWonderGuard(void)
{ {
// we found a mon // we found a mon
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
} }
@ -151,10 +151,10 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
bankIn1 = gActiveBattler; bankIn1 = gActiveBattler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler)))]) if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))])
bankIn2 = gActiveBattler; bankIn2 = gActiveBattler;
else else
bankIn2 = GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler))); bankIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)));
} }
else else
{ {
@ -221,7 +221,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
{ {
// we found a mon // we found a mon
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
} }
@ -241,13 +241,13 @@ static bool8 ShouldSwitchIfNaturalCure(void)
if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1) if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 && Random() & 1) else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 && Random() & 1)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
@ -258,7 +258,7 @@ static bool8 ShouldSwitchIfNaturalCure(void)
if (Random() & 1) if (Random() & 1)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6;
BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
@ -273,7 +273,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng)
u8 moveFlags; u8 moveFlags;
u16 move; u16 move;
opposingPosition = B_POSITION_OPPOSITE(GetBattlerPosition(gActiveBattler)); opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler));
opposingBank = GetBattlerAtPosition(opposingPosition); opposingBank = GetBattlerAtPosition(opposingPosition);
if (!(gAbsentBattlerFlags & gBitTable[opposingBank])) if (!(gAbsentBattlerFlags & gBitTable[opposingBank]))
@ -297,7 +297,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng)
if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE))
return FALSE; return FALSE;
opposingBank = GetBattlerAtPosition(B_POSITION_PARTNER(opposingPosition)); opposingBank = GetBattlerAtPosition(BATTLE_PARTNER(opposingPosition));
if (!(gAbsentBattlerFlags & gBitTable[opposingBank])) if (!(gAbsentBattlerFlags & gBitTable[opposingBank]))
{ {
@ -357,10 +357,10 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE)
{ {
bankIn1 = gActiveBattler; bankIn1 = gActiveBattler;
if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler)))]) if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))])
bankIn2 = gActiveBattler; bankIn2 = gActiveBattler;
else else
bankIn2 = GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler))); bankIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)));
} }
else else
{ {
@ -426,7 +426,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0) if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i;
BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
return TRUE; return TRUE;
} }
} }
@ -611,7 +611,7 @@ void AI_TrySwitchOrUseItem(void)
} }
} }
BtlController_EmitTwoReturnValues(1, ACTION_USE_MOVE, (gActiveBattler ^ BIT_SIDE) << 8); BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, (gActiveBattler ^ BIT_SIDE) << 8);
} }
static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 *var) static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 *var)
@ -937,7 +937,7 @@ static bool8 ShouldUseItem(void)
if (shouldUse) if (shouldUse)
{ {
BtlController_EmitTwoReturnValues(1, ACTION_USE_ITEM, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_USE_ITEM, 0);
*(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2) = item; *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2) = item;
gBattleResources->battleHistory->trainerItems[i] = 0; gBattleResources->battleHistory->trainerItems[i] = 0;
return shouldUse; return shouldUse;

View File

@ -25,8 +25,8 @@
#define ANIM_SPRITE_INDEX_COUNT 8 #define ANIM_SPRITE_INDEX_COUNT 8
extern u8 gBattleMoveAttacker; extern u8 gBattlerAttacker;
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u16 gBattle_WIN0H; extern u16 gBattle_WIN0H;
extern u16 gBattle_WIN0V; extern u16 gBattle_WIN0V;
extern u16 gBattle_WIN1H; extern u16 gBattle_WIN1H;
@ -221,8 +221,8 @@ void ClearBattleAnimationVars(void)
void DoMoveAnim(u16 move) void DoMoveAnim(u16 move)
{ {
gBattleAnimAttacker = gBattleMoveAttacker; gBattleAnimAttacker = gBattlerAttacker;
gBattleAnimTarget = gBattleMoveTarget; gBattleAnimTarget = gBattlerTarget;
LaunchBattleAnimation(gBattleAnims_Moves, move, TRUE); LaunchBattleAnimation(gBattleAnims_Moves, move, TRUE);
} }
@ -665,7 +665,7 @@ bool8 IsBattlerSpriteVisible(u8 bank)
return FALSE; return FALSE;
if (IsContest()) if (IsContest())
return TRUE; // this line wont ever be reached. return TRUE; // this line wont ever be reached.
if (!gBattleSpritesDataPtr->bankData[bank].invisible || !gSprites[gBattlerSpriteIds[bank]].invisible) if (!gBattleSpritesDataPtr->battlerData[bank].invisible || !gSprites[gBattlerSpriteIds[bank]].invisible)
return TRUE; return TRUE;
return FALSE; return FALSE;

View File

@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gUnknown_020244B4[]; extern u8 gUnknown_020244B4[];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
@ -262,7 +262,7 @@ static void sub_8064520(void)
else else
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) && gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy)
{ {
r8 = TRUE; r8 = TRUE;
} }
@ -271,18 +271,18 @@ static void sub_8064520(void)
if (r8) if (r8)
{ {
if (r4 || !IsBattlerSpriteVisible(gActiveBattler ^ BIT_FLANK)) if (r4 || !IsBattlerSpriteVisible(BATTLE_PARTNER(gActiveBattler)))
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1)
return; return;
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].field_1_x1)
return; return;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 = 0; gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].flag_x80 = 0;
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1 = 0; gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].field_1_x1 = 0;
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
@ -318,23 +318,23 @@ static void sub_8064734(void)
sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]);
} }
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].flag_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].field_1_x1)
{ {
sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]); sub_8172EF0(BATTLE_PARTNER(gActiveBattler), &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]);
} }
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive)
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80)
{ {
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler ^ BIT_FLANK); sub_8076918(BATTLE_PARTNER(gActiveBattler));
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]);
} }
UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL);
sub_8076918(gActiveBattler); sub_8076918(gActiveBattler);
@ -345,7 +345,7 @@ static void sub_8064734(void)
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40
&& gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80
&& !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40 && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].field_1_x40
&& !IsCryPlayingOrClearCrySongs()) && !IsCryPlayingOrClearCrySongs())
{ {
if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20)
@ -379,8 +379,8 @@ static void sub_8064734(void)
if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); DestroySprite(&gSprites[gUnknown_03005D7C[BATTLE_PARTNER(gActiveBattler)]]);
SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES)); SetBattlerShadowSpriteCallback(BATTLE_PARTNER(gActiveBattler), GetMonData(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], MON_DATA_SPECIES));
} }
@ -485,7 +485,7 @@ static void sub_8064D60(void)
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_8064DD0; gBattlerControllerFuncs[gActiveBattler] = sub_8064DD0;
@ -1239,7 +1239,7 @@ static void DoSwitchOutAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1382,7 +1382,7 @@ static void LinkOpponentHandleFaintAnimation(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++;
} }
@ -1452,10 +1452,10 @@ static void LinkOpponentDoMoveAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
&& !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1473,10 +1473,10 @@ static void LinkOpponentDoMoveAnimation(void)
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3;
} }
@ -1763,10 +1763,10 @@ static void sub_8067618(u8 taskId)
{ {
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_8066494(gActiveBattler, FALSE); sub_8066494(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler = BATTLE_PARTNER(gActiveBattler);
gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler];
sub_8066494(gActiveBattler, FALSE); sub_8066494(gActiveBattler, FALSE);
gActiveBattler ^= BIT_FLANK; gActiveBattler = BATTLE_PARTNER(gActiveBattler);
} }
gBattlerControllerFuncs[gActiveBattler] = sub_8064734; gBattlerControllerFuncs[gActiveBattler] = sub_8064734;
gActiveBattler = savedActiveBank; gActiveBattler = savedActiveBank;

View File

@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gUnknown_020244B4[]; extern u8 gUnknown_020244B4[];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
@ -373,7 +373,7 @@ static void sub_814B4E0(void)
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_814B554; gBattlerControllerFuncs[gActiveBattler] = sub_814B554;
@ -1121,7 +1121,7 @@ static void DoSwitchOutAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1201,7 +1201,7 @@ static void LinkPartnerHandleFaintAnimation(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++;
} }
@ -1274,10 +1274,10 @@ static void LinkPartnerDoMoveAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
&& !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1295,10 +1295,10 @@ static void LinkPartnerDoMoveAnimation(void)
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3;
} }

View File

@ -30,7 +30,7 @@
extern u32 gBattleControllerExecFlags; extern u32 gBattleControllerExecFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern bool8 gDoingBattleAnim; extern bool8 gDoingBattleAnim;
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
@ -473,7 +473,7 @@ static void sub_805FC10(void)
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_805FC80; gBattlerControllerFuncs[gActiveBattler] = sub_805FC80;
} }
@ -1229,7 +1229,7 @@ static void DoSwitchOutAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1415,7 +1415,7 @@ static void OpponentHandleFaintAnimation(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++;
} }
@ -1484,10 +1484,10 @@ static void OpponentDoMoveAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
&& !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1505,10 +1505,10 @@ static void OpponentDoMoveAnimation(void)
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3;
} }
@ -1575,24 +1575,24 @@ static void OpponentHandleChooseMove(void)
switch (chosenMoveId) switch (chosenMoveId)
{ {
case 5: case 5:
BtlController_EmitTwoReturnValues(1, ACTION_WATCHES_CAREFULLY, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_WATCH_CAREFULLY, 0);
break; break;
case 4: case 4:
BtlController_EmitTwoReturnValues(1, ACTION_RUN, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_RUN, 0);
break; break;
case 6: case 6:
BtlController_EmitTwoReturnValues(1, 15, gBattleMoveTarget); BtlController_EmitTwoReturnValues(1, 15, gBattlerTarget);
break; break;
default: default:
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_x10)) if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_x10))
gBattleMoveTarget = gActiveBattler; gBattlerTarget = gActiveBattler;
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH) if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH)
{ {
gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT);
} }
BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (gBattleMoveTarget << 8)); BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (gBattlerTarget << 8));
break; break;
} }
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();

View File

@ -300,23 +300,23 @@ static void HandleInputChooseAction(void)
switch (gActionSelectionCursor[gActiveBattler]) switch (gActionSelectionCursor[gActiveBattler])
{ {
case 0: case 0:
BtlController_EmitTwoReturnValues(1, ACTION_USE_MOVE, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, 0);
break; break;
case 1: case 1:
BtlController_EmitTwoReturnValues(1, ACTION_USE_ITEM, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_USE_ITEM, 0);
break; break;
case 2: case 2:
BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
break; break;
case 3: case 3:
BtlController_EmitTwoReturnValues(1, ACTION_RUN, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_RUN, 0);
break; break;
} }
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
} }
else if (gMain.newKeys & DPAD_LEFT) else if (gMain.newKeys & DPAD_LEFT)
{ {
if (gActionSelectionCursor[gActiveBattler] & 1) // if is ACTION_USE_ITEM or ACTION_RUN if (gActionSelectionCursor[gActiveBattler] & 1) // if is B_ACTION_USE_ITEM or B_ACTION_RUN
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
@ -326,7 +326,7 @@ static void HandleInputChooseAction(void)
} }
else if (gMain.newKeys & DPAD_RIGHT) else if (gMain.newKeys & DPAD_RIGHT)
{ {
if (!(gActionSelectionCursor[gActiveBattler] & 1)) // if is ACTION_USE_MOVE or ACTION_SWITCH if (!(gActionSelectionCursor[gActiveBattler] & 1)) // if is B_ACTION_USE_MOVE or B_ACTION_SWITCH
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
@ -336,7 +336,7 @@ static void HandleInputChooseAction(void)
} }
else if (gMain.newKeys & DPAD_UP) else if (gMain.newKeys & DPAD_UP)
{ {
if (gActionSelectionCursor[gActiveBattler] & 2) // if is ACTION_SWITCH or ACTION_RUN if (gActionSelectionCursor[gActiveBattler] & 2) // if is B_ACTION_SWITCH or B_ACTION_RUN
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
@ -346,7 +346,7 @@ static void HandleInputChooseAction(void)
} }
else if (gMain.newKeys & DPAD_DOWN) else if (gMain.newKeys & DPAD_DOWN)
{ {
if (!(gActionSelectionCursor[gActiveBattler] & 2)) // if is ACTION_USE_MOVE or ACTION_USE_ITEM if (!(gActionSelectionCursor[gActiveBattler] & 2)) // if is B_ACTION_USE_MOVE or B_ACTION_USE_ITEM
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]);
@ -361,7 +361,7 @@ static void HandleInputChooseAction(void)
&& !(gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]) && !(gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)])
&& !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
if (gBattleBufferA[gActiveBattler][1] == ACTION_USE_ITEM) if (gBattleBufferA[gActiveBattler][1] == B_ACTION_USE_ITEM)
{ {
// Add item to bag if it is a ball // Add item to bag if it is a ball
if (itemId <= ITEM_PREMIER_BALL) if (itemId <= ITEM_PREMIER_BALL)
@ -370,7 +370,7 @@ static void HandleInputChooseAction(void)
return; return;
} }
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
BtlController_EmitTwoReturnValues(1, ACTION_CANCEL_PARTNER, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_CANCEL_PARTNER, 0);
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
} }
} }
@ -1107,7 +1107,7 @@ static void sub_8058EDC(void)
FreeSpriteTilesByTag(0x27F9); FreeSpriteTilesByTag(0x27F9);
FreeSpritePaletteByTag(0x27F9); FreeSpritePaletteByTag(0x27F9);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_8058FC0; gBattlerControllerFuncs[gActiveBattler] = sub_8058FC0;
@ -2278,7 +2278,7 @@ static void DoSwitchOutAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -2434,7 +2434,7 @@ static void PlayerHandleFaintAnimation(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++;
} }
@ -2522,10 +2522,10 @@ static void PlayerDoMoveAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
&& !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -2543,10 +2543,10 @@ static void PlayerDoMoveAnimation(void)
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3;
} }

View File

@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gUnknown_020244B4[]; extern u8 gUnknown_020244B4[];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
@ -560,7 +560,7 @@ static void sub_81BB92C(void)
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_81BB9A0; gBattlerControllerFuncs[gActiveBattler] = sub_81BB9A0;
@ -1308,7 +1308,7 @@ static void DoSwitchOutAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1395,7 +1395,7 @@ static void PlayerPartnerHandleFaintAnimation(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++;
} }
@ -1467,10 +1467,10 @@ static void PlayerPartnerDoMoveAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
&& !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1488,10 +1488,10 @@ static void PlayerPartnerDoMoveAnimation(void)
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3;
} }
@ -1545,15 +1545,15 @@ static void PlayerPartnerHandleChooseMove(void)
chosenMoveId = BattleAI_ChooseMoveOrAction(); chosenMoveId = BattleAI_ChooseMoveOrAction();
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_x10 | MOVE_TARGET_USER)) if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_x10 | MOVE_TARGET_USER))
gBattleMoveTarget = gActiveBattler; gBattlerTarget = gActiveBattler;
if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH) if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH)
{ {
gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT);
} }
BtlController_EmitTwoReturnValues(1, 10, chosenMoveId | (gBattleMoveTarget << 8)); BtlController_EmitTwoReturnValues(1, 10, chosenMoveId | (gBattlerTarget << 8));
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
} }

View File

@ -48,7 +48,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gUnknown_020244B4[]; extern u8 gUnknown_020244B4[];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
@ -255,21 +255,17 @@ static void sub_8186678(void)
if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)))
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded) && gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded)
{
var = TRUE; var = TRUE;
}
} }
else else
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy
&& gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy
&& gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded && gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded
&& gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].animEnded) && gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].animEnded)
{
var = TRUE; var = TRUE;
}
} }
if (var) if (var)
@ -469,7 +465,7 @@ static void sub_8186EA4(void)
{ {
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_8186F14; gBattlerControllerFuncs[gActiveBattler] = sub_8186F14;
@ -1225,7 +1221,7 @@ static void DoSwitchOutAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1314,7 +1310,7 @@ static void RecordedOpponentHandleFaintAnimation(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++;
} }
@ -1383,10 +1379,10 @@ static void RecordedOpponentDoMoveAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
&& !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1404,10 +1400,10 @@ static void RecordedOpponentDoMoveAnimation(void)
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3;
} }
@ -1443,7 +1439,7 @@ static void RecordedOpponentHandlePrintSelectionString(void)
static void RecordedOpponentHandleChooseAction(void) static void RecordedOpponentHandleChooseAction(void)
{ {
BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBankAction(gActiveBattler), 0); BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBattlerAction(gActiveBattler), 0);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }
@ -1460,8 +1456,8 @@ static void RecordedOpponentHandleChooseMove(void)
} }
else else
{ {
u8 moveId = RecordedBattle_GetBankAction(gActiveBattler); u8 moveId = RecordedBattle_GetBattlerAction(gActiveBattler);
u8 target = RecordedBattle_GetBankAction(gActiveBattler); u8 target = RecordedBattle_GetBattlerAction(gActiveBattler);
BtlController_EmitTwoReturnValues(1, 10, moveId | (target << 8)); BtlController_EmitTwoReturnValues(1, 10, moveId | (target << 8));
} }
@ -1475,7 +1471,7 @@ static void RecordedOpponentHandleChooseItem(void)
static void RecordedOpponentHandleChoosePokemon(void) static void RecordedOpponentHandleChoosePokemon(void)
{ {
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBankAction(gActiveBattler); *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBattlerAction(gActiveBattler);
BtlController_EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); BtlController_EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL);
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
} }

View File

@ -48,7 +48,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT];
extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT];
extern u16 gPartnerTrainerId; extern u16 gPartnerTrainerId;
extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId);
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gUnknown_020244B4[]; extern u8 gUnknown_020244B4[];
extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT];
@ -458,7 +458,7 @@ static void sub_818A2B4(void)
if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy)
{ {
CopyBattleSpriteInvisibility(gActiveBattler); CopyBattleSpriteInvisibility(gActiveBattler);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattlerControllerFuncs[gActiveBattler] = sub_818A328; gBattlerControllerFuncs[gActiveBattler] = sub_818A328;
@ -1206,7 +1206,7 @@ static void DoSwitchOutAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1313,7 +1313,7 @@ static void RecordedPlayerHandleFaintAnimation(void)
{ {
if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0)
{ {
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++;
} }
@ -1385,10 +1385,10 @@ static void RecordedPlayerDoMoveAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute
&& !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8)
{ {
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1;
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1;
@ -1406,10 +1406,10 @@ static void RecordedPlayerDoMoveAnimation(void)
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0;
} }
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3;
} }
@ -1447,7 +1447,7 @@ static void ChooseActionInBattlePalace(void)
{ {
if (gBattleCommunication[4] >= gBattlersCount / 2) if (gBattleCommunication[4] >= gBattlersCount / 2)
{ {
BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBankAction(gActiveBattler), 0); BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBattlerAction(gActiveBattler), 0);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
@ -1460,7 +1460,7 @@ static void RecordedPlayerHandleChooseAction(void)
} }
else else
{ {
BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBankAction(gActiveBattler), 0); BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBattlerAction(gActiveBattler), 0);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }
} }
@ -1478,8 +1478,8 @@ static void RecordedPlayerHandleChooseMove(void)
} }
else else
{ {
u8 moveId = RecordedBattle_GetBankAction(gActiveBattler); u8 moveId = RecordedBattle_GetBattlerAction(gActiveBattler);
u8 target = RecordedBattle_GetBankAction(gActiveBattler); u8 target = RecordedBattle_GetBattlerAction(gActiveBattler);
BtlController_EmitTwoReturnValues(1, 10, moveId | (target << 8)); BtlController_EmitTwoReturnValues(1, 10, moveId | (target << 8));
} }
@ -1493,7 +1493,7 @@ static void RecordedPlayerHandleChooseItem(void)
static void RecordedPlayerHandleChoosePokemon(void) static void RecordedPlayerHandleChoosePokemon(void)
{ {
*(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBankAction(gActiveBattler); *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBattlerAction(gActiveBattler);
BtlController_EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); BtlController_EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL);
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
} }

View File

@ -203,16 +203,16 @@ static void HandleInputChooseAction(void)
switch (gActionSelectionCursor[gActiveBattler]) switch (gActionSelectionCursor[gActiveBattler])
{ {
case 0: case 0:
BtlController_EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_BALL, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_BALL, 0);
break; break;
case 1: case 1:
BtlController_EmitTwoReturnValues(1, ACTION_POKEBLOCK_CASE, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_POKEBLOCK, 0);
break; break;
case 2: case 2:
BtlController_EmitTwoReturnValues(1, ACTION_GO_NEAR, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_GO_NEAR, 0);
break; break;
case 3: case 3:
BtlController_EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_RUN, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_RUN, 0);
break; break;
} }
SafariBufferExecCompleted(); SafariBufferExecCompleted();

View File

@ -233,7 +233,7 @@ static void WallyHandleActions(void)
if (--gBattleStruct->wallyWaitFrames == 0) if (--gBattleStruct->wallyWaitFrames == 0)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
BtlController_EmitTwoReturnValues(1, ACTION_USE_MOVE, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, 0);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
gBattleStruct->wallyBattleState++; gBattleStruct->wallyBattleState++;
gBattleStruct->wallyMovesState = 0; gBattleStruct->wallyMovesState = 0;
@ -244,7 +244,7 @@ static void WallyHandleActions(void)
if (--gBattleStruct->wallyWaitFrames == 0) if (--gBattleStruct->wallyWaitFrames == 0)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
BtlController_EmitTwoReturnValues(1, ACTION_USE_MOVE, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, 0);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
gBattleStruct->wallyBattleState++; gBattleStruct->wallyBattleState++;
gBattleStruct->wallyMovesState = 0; gBattleStruct->wallyMovesState = 0;
@ -275,7 +275,7 @@ static void WallyHandleActions(void)
if (--gBattleStruct->wallyWaitFrames == 0) if (--gBattleStruct->wallyWaitFrames == 0)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
BtlController_EmitTwoReturnValues(1, ACTION_USE_ITEM, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_USE_ITEM, 0);
WallyBufferExecCompleted(); WallyBufferExecCompleted();
} }
break; break;
@ -1162,7 +1162,7 @@ static void WallyDoMoveAnimation(void)
switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState)
{ {
case 0: case 0:
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON);
} }
@ -1181,7 +1181,7 @@ static void WallyDoMoveAnimation(void)
if (!gAnimScriptActive) if (!gAnimScriptActive)
{ {
sub_805EB9C(1); sub_805EB9C(1);
if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute)
{ {
InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE);
} }
@ -1490,7 +1490,7 @@ static void sub_816AA80(u8 bank)
{ {
u16 species; u16 species;
gBattleSpritesDataPtr->bankData[bank].transformSpecies = 0; gBattleSpritesDataPtr->battlerData[bank].transformSpecies = 0;
gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1]; gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1];
species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES); species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES);
gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714);

View File

@ -31,8 +31,8 @@ extern u8 gBattleBuffersTransferData[0x100];
extern u8 gUnknown_02022D08; extern u8 gUnknown_02022D08;
extern u8 gUnknown_02022D09; extern u8 gUnknown_02022D09;
extern u8 gUnknown_02022D0A; extern u8 gUnknown_02022D0A;
extern u8 gBattleMoveAttacker; extern u8 gBattlerAttacker;
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gEffectBank; extern u8 gEffectBank;
extern u16 gBattleWeather; extern u16 gBattleWeather;
@ -42,7 +42,7 @@ extern u16 gChosenMove;
extern u16 gLastUsedItem; extern u16 gLastUsedItem;
extern u8 gBattleOutcome; extern u8 gBattleOutcome;
extern u8 gLastUsedAbility; extern u8 gLastUsedAbility;
extern u8 gStringBank; extern u8 gStringBattler;
extern const struct BattleMove gBattleMoves[]; extern const struct BattleMove gBattleMoves[];
@ -752,8 +752,8 @@ void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data)
} }
gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_BUFFER_ID] = bufferId; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_BUFFER_ID] = bufferId;
gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ACTIVE_BANK] = gActiveBattler; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ACTIVE_BANK] = gActiveBattler;
gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ATTACKER] = gBattleMoveAttacker; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ATTACKER] = gBattlerAttacker;
gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_TARGET] = gBattleMoveTarget; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_TARGET] = gBattlerTarget;
gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_SIZE_LO] = alignedSize; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_SIZE_LO] = alignedSize;
gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_SIZE_HI] = (alignedSize & 0x0000FF00) >> 8; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_SIZE_HI] = (alignedSize & 0x0000FF00) >> 8;
gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ABSENT_BANK_FLAGS] = gAbsentBattlerFlags; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ABSENT_BANK_FLAGS] = gAbsentBattlerFlags;
@ -920,8 +920,8 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId)
if (!(gBattleTypeFlags & BATTLE_TYPE_WILD)) if (!(gBattleTypeFlags & BATTLE_TYPE_WILD))
{ {
gBattleMoveAttacker = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 2]; gBattlerAttacker = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 2];
gBattleMoveTarget = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 3]; gBattlerTarget = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 3];
gAbsentBattlerFlags = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 6]; gAbsentBattlerFlags = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 6];
gEffectBank = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 7]; gEffectBank = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 7];
} }
@ -1126,7 +1126,7 @@ void BtlController_EmitPrintString(u8 bufferId, u16 stringID)
stringInfo->scrActive = gBattleScripting.battler; stringInfo->scrActive = gBattleScripting.battler;
stringInfo->unk1605E = gBattleStruct->field_52; stringInfo->unk1605E = gBattleStruct->field_52;
stringInfo->hpScale = gBattleStruct->hpScale; stringInfo->hpScale = gBattleStruct->hpScale;
stringInfo->StringBank = gStringBank; stringInfo->StringBank = gStringBattler;
stringInfo->moveType = gBattleMoves[gCurrentMove].type; stringInfo->moveType = gBattleMoves[gCurrentMove].type;
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)

View File

@ -127,7 +127,7 @@ static const struct SpritePalette gUnknown_0832C128[2] =
void AllocateBattleSpritesData(void) void AllocateBattleSpritesData(void)
{ {
gBattleSpritesDataPtr = AllocZeroed(sizeof(struct BattleSpriteData)); gBattleSpritesDataPtr = AllocZeroed(sizeof(struct BattleSpriteData));
gBattleSpritesDataPtr->bankData = AllocZeroed(sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT); gBattleSpritesDataPtr->battlerData = AllocZeroed(sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT);
gBattleSpritesDataPtr->healthBoxesData = AllocZeroed(sizeof(struct BattleHealthboxInfo) * MAX_BATTLERS_COUNT); gBattleSpritesDataPtr->healthBoxesData = AllocZeroed(sizeof(struct BattleHealthboxInfo) * MAX_BATTLERS_COUNT);
gBattleSpritesDataPtr->animationData = AllocZeroed(sizeof(struct BattleAnimationInfo)); gBattleSpritesDataPtr->animationData = AllocZeroed(sizeof(struct BattleAnimationInfo));
gBattleSpritesDataPtr->battleBars = AllocZeroed(sizeof(struct BattleBarInfo) * MAX_BATTLERS_COUNT); gBattleSpritesDataPtr->battleBars = AllocZeroed(sizeof(struct BattleBarInfo) * MAX_BATTLERS_COUNT);
@ -141,7 +141,7 @@ void FreeBattleSpritesData(void)
FREE_AND_SET_NULL(gBattleSpritesDataPtr->battleBars); FREE_AND_SET_NULL(gBattleSpritesDataPtr->battleBars);
FREE_AND_SET_NULL(gBattleSpritesDataPtr->animationData); FREE_AND_SET_NULL(gBattleSpritesDataPtr->animationData);
FREE_AND_SET_NULL(gBattleSpritesDataPtr->healthBoxesData); FREE_AND_SET_NULL(gBattleSpritesDataPtr->healthBoxesData);
FREE_AND_SET_NULL(gBattleSpritesDataPtr->bankData); FREE_AND_SET_NULL(gBattleSpritesDataPtr->battlerData);
FREE_AND_SET_NULL(gBattleSpritesDataPtr); FREE_AND_SET_NULL(gBattleSpritesDataPtr);
} }
@ -432,12 +432,12 @@ bool8 TryHandleLaunchBattleTableAnimation(u8 activeBank, u8 atkBank, u8 defBank,
gBattleMonForms[activeBank] = (argument & ~(0x80)); gBattleMonForms[activeBank] = (argument & ~(0x80));
return TRUE; return TRUE;
} }
if (gBattleSpritesDataPtr->bankData[activeBank].behindSubstitute if (gBattleSpritesDataPtr->battlerData[activeBank].behindSubstitute
&& !ShouldAnimBeDoneRegardlessOfSubsitute(tableId)) && !ShouldAnimBeDoneRegardlessOfSubsitute(tableId))
{ {
return TRUE; return TRUE;
} }
if (gBattleSpritesDataPtr->bankData[activeBank].behindSubstitute if (gBattleSpritesDataPtr->battlerData[activeBank].behindSubstitute
&& tableId == B_ANIM_SUBSTITUTE_FADE && tableId == B_ANIM_SUBSTITUTE_FADE
&& gSprites[gBattlerSpriteIds[activeBank]].invisible) && gSprites[gBattlerSpriteIds[activeBank]].invisible)
{ {
@ -549,14 +549,14 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank)
monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY); monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
{ {
species = GetMonData(mon, MON_DATA_SPECIES); species = GetMonData(mon, MON_DATA_SPECIES);
currentPersonality = monsPersonality; currentPersonality = monsPersonality;
} }
else else
{ {
species = gBattleSpritesDataPtr->bankData[bank].transformSpecies; species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies;
currentPersonality = gTransformedPersonalities[bank]; currentPersonality = gTransformedPersonalities[bank];
} }
@ -568,7 +568,7 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank)
paletteOffset = 0x100 + bank * 16; paletteOffset = 0x100 + bank * 16;
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
lzPaletteData = GetMonFrontSpritePal(mon); lzPaletteData = GetMonFrontSpritePal(mon);
else else
lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality); lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality);
@ -585,7 +585,7 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank)
} }
// transform's pink color // transform's pink color
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
{ {
BlendPalette(paletteOffset, 16, 6, 0x7FFF); BlendPalette(paletteOffset, 16, 6, 0x7FFF);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
@ -602,21 +602,21 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank)
monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY); monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY);
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
{ {
species = GetMonData(mon, MON_DATA_SPECIES); species = GetMonData(mon, MON_DATA_SPECIES);
currentPersonality = monsPersonality; currentPersonality = monsPersonality;
} }
else else
{ {
species = gBattleSpritesDataPtr->bankData[bank].transformSpecies; species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies;
currentPersonality = gTransformedPersonalities[bank]; currentPersonality = gTransformedPersonalities[bank];
} }
otId = GetMonData(mon, MON_DATA_OT_ID); otId = GetMonData(mon, MON_DATA_OT_ID);
position = GetBattlerPosition(bank); position = GetBattlerPosition(bank);
if (sub_80688F8(1, bank) == 1 || gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) if (sub_80688F8(1, bank) == 1 || gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
{ {
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species], HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species],
gMonSpritesGfxPtr->sprites[position], gMonSpritesGfxPtr->sprites[position],
@ -631,7 +631,7 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank)
paletteOffset = 0x100 + bank * 16; paletteOffset = 0x100 + bank * 16;
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE)
lzPaletteData = GetMonFrontSpritePal(mon); lzPaletteData = GetMonFrontSpritePal(mon);
else else
lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality); lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality);
@ -648,7 +648,7 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank)
} }
// transform's pink color // transform's pink color
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
{ {
BlendPalette(paletteOffset, 16, 6, 0x7FFF); BlendPalette(paletteOffset, 16, 6, 0x7FFF);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
@ -804,7 +804,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank)
if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && *bank == 0) if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && *bank == 0)
gHealthboxSpriteIds[*bank] = CreateSafariPlayerHealthboxSprites(); gHealthboxSpriteIds[*bank] = CreateSafariPlayerHealthboxSprites();
else else
gHealthboxSpriteIds[*bank] = CreateHealthboxSprites(*bank); gHealthboxSpriteIds[*bank] = CreateBattlerHealthboxSprites(*bank);
(*bank)++; (*bank)++;
if (*bank == gBattlersCount) if (*bank == gBattlersCount)
@ -864,7 +864,7 @@ void ClearSpritesHealthboxAnimData(void)
static void ClearSpritesBankHealthboxAnimData(void) static void ClearSpritesBankHealthboxAnimData(void)
{ {
ClearSpritesHealthboxAnimData(); ClearSpritesHealthboxAnimData();
memset(gBattleSpritesDataPtr->bankData, 0, sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT); memset(gBattleSpritesDataPtr->battlerData, 0, sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT);
} }
void CopyAllBattleSpritesInvisibilities(void) void CopyAllBattleSpritesInvisibilities(void)
@ -872,12 +872,12 @@ void CopyAllBattleSpritesInvisibilities(void)
s32 i; s32 i;
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
gBattleSpritesDataPtr->bankData[i].invisible = gSprites[gBattlerSpriteIds[i]].invisible; gBattleSpritesDataPtr->battlerData[i].invisible = gSprites[gBattlerSpriteIds[i]].invisible;
} }
void CopyBattleSpriteInvisibility(u8 bank) void CopyBattleSpriteInvisibility(u8 bank)
{ {
gBattleSpritesDataPtr->bankData[bank].invisible = gSprites[gBattlerSpriteIds[bank]].invisible; gBattleSpritesDataPtr->battlerData[bank].invisible = gSprites[gBattlerSpriteIds[bank]].invisible;
} }
void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform) void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
@ -894,7 +894,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
paletteOffset = 0x100 + bankAtk * 16; paletteOffset = 0x100 + bankAtk * 16;
LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32); LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32);
gBattleMonForms[bankAtk] = gBattleSpritesDataPtr->animationData->animArg; gBattleMonForms[bankAtk] = gBattleSpritesDataPtr->animationData->animArg;
if (gBattleSpritesDataPtr->bankData[bankAtk].transformSpecies != SPECIES_NONE) if (gBattleSpritesDataPtr->battlerData[bankAtk].transformSpecies != SPECIES_NONE)
{ {
BlendPalette(paletteOffset, 16, 6, 0x7FFF); BlendPalette(paletteOffset, 16, 6, 0x7FFF);
CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32);
@ -970,7 +970,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform)
if (!IsContest()) if (!IsContest())
{ {
gBattleSpritesDataPtr->bankData[bankAtk].transformSpecies = targetSpecies; gBattleSpritesDataPtr->battlerData[bankAtk].transformSpecies = targetSpecies;
gBattleMonForms[bankAtk] = gBattleMonForms[bankDef]; gBattleMonForms[bankAtk] = gBattleMonForms[bankDef];
} }
@ -1040,12 +1040,12 @@ void LoadBattleMonGfxAndAnimate(u8 bank, bool8 loadMonSprite, u8 spriteId)
void TrySetBehindSubstituteSpriteBit(u8 bank, u16 move) void TrySetBehindSubstituteSpriteBit(u8 bank, u16 move)
{ {
if (move == MOVE_SUBSTITUTE) if (move == MOVE_SUBSTITUTE)
gBattleSpritesDataPtr->bankData[bank].behindSubstitute = 1; gBattleSpritesDataPtr->battlerData[bank].behindSubstitute = 1;
} }
void ClearBehindSubstituteBit(u8 bank) void ClearBehindSubstituteBit(u8 bank)
{ {
gBattleSpritesDataPtr->bankData[bank].behindSubstitute = 0; gBattleSpritesDataPtr->battlerData[bank].behindSubstitute = 0;
} }
void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank) void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank)
@ -1055,22 +1055,22 @@ void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank)
if (GetHPBarLevel(hp, maxHP) == HP_BAR_RED) if (GetHPBarLevel(hp, maxHP) == HP_BAR_RED)
{ {
if (!gBattleSpritesDataPtr->bankData[bank].lowHpSong) if (!gBattleSpritesDataPtr->battlerData[bank].lowHpSong)
{ {
if (!gBattleSpritesDataPtr->bankData[bank ^ BIT_FLANK].lowHpSong) if (!gBattleSpritesDataPtr->battlerData[bank ^ BIT_FLANK].lowHpSong)
PlaySE(SE_HINSI); PlaySE(SE_HINSI);
gBattleSpritesDataPtr->bankData[bank].lowHpSong = 1; gBattleSpritesDataPtr->battlerData[bank].lowHpSong = 1;
} }
} }
else else
{ {
gBattleSpritesDataPtr->bankData[bank].lowHpSong = 0; gBattleSpritesDataPtr->battlerData[bank].lowHpSong = 0;
if (!IsDoubleBattle()) if (!IsDoubleBattle())
{ {
m4aSongNumStop(SE_HINSI); m4aSongNumStop(SE_HINSI);
return; return;
} }
if (IsDoubleBattle() && !gBattleSpritesDataPtr->bankData[bank ^ BIT_FLANK].lowHpSong) if (IsDoubleBattle() && !gBattleSpritesDataPtr->battlerData[bank ^ BIT_FLANK].lowHpSong)
{ {
m4aSongNumStop(SE_HINSI); m4aSongNumStop(SE_HINSI);
return; return;
@ -1082,9 +1082,9 @@ void BattleStopLowHpSound(void)
{ {
u8 playerBank = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); u8 playerBank = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT);
gBattleSpritesDataPtr->bankData[playerBank].lowHpSong = 0; gBattleSpritesDataPtr->battlerData[playerBank].lowHpSong = 0;
if (IsDoubleBattle()) if (IsDoubleBattle())
gBattleSpritesDataPtr->bankData[playerBank ^ BIT_FLANK].lowHpSong = 0; gBattleSpritesDataPtr->battlerData[playerBank ^ BIT_FLANK].lowHpSong = 0;
m4aSongNumStop(SE_HINSI); m4aSongNumStop(SE_HINSI);
} }
@ -1168,11 +1168,11 @@ void SpriteCB_EnemyShadow(struct Sprite *shadowSprite)
} }
if (gAnimScriptActive || bankSprite->invisible) if (gAnimScriptActive || bankSprite->invisible)
invisible = TRUE; invisible = TRUE;
else if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE else if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE
&& gEnemyMonElevation[gBattleSpritesDataPtr->bankData[bank].transformSpecies] == 0) && gEnemyMonElevation[gBattleSpritesDataPtr->battlerData[bank].transformSpecies] == 0)
invisible = TRUE; invisible = TRUE;
if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[bank].behindSubstitute)
invisible = TRUE; invisible = TRUE;
shadowSprite->pos1.x = bankSprite->pos1.x; shadowSprite->pos1.x = bankSprite->pos1.x;
@ -1193,8 +1193,8 @@ void SetBattlerShadowSpriteCallback(u8 bank, u16 species)
if (GetBattlerSide(bank) == B_SIDE_PLAYER) if (GetBattlerSide(bank) == B_SIDE_PLAYER)
return; return;
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE)
species = gBattleSpritesDataPtr->bankData[bank].transformSpecies; species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies;
if (gEnemyMonElevation[species] != 0) if (gEnemyMonElevation[species] != 0)
gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_EnemyShadow; gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_EnemyShadow;
@ -1232,7 +1232,7 @@ void sub_805EF14(void)
void ClearTemporarySpeciesSpriteData(u8 bank, bool8 dontClearSubstitute) void ClearTemporarySpeciesSpriteData(u8 bank, bool8 dontClearSubstitute)
{ {
gBattleSpritesDataPtr->bankData[bank].transformSpecies = SPECIES_NONE; gBattleSpritesDataPtr->battlerData[bank].transformSpecies = SPECIES_NONE;
gBattleMonForms[bank] = 0; gBattleMonForms[bank] = 0;
if (!dontClearSubstitute) if (!dontClearSubstitute)
ClearBehindSubstituteBit(bank); ClearBehindSubstituteBit(bank);

View File

@ -898,7 +898,7 @@ void sub_80724A8(s16 arg0, s16 arg1, u16 *arg2)
// healthboxSpriteId_2 refers to the other part // healthboxSpriteId_2 refers to the other part
// there's also one other sprite that appears to be a black square? dont fully understand its role // there's also one other sprite that appears to be a black square? dont fully understand its role
u8 CreateHealthboxSprites(u8 bank) u8 CreateBattlerHealthboxSprites(u8 battler)
{ {
s16 data6 = 0; s16 data6 = 0;
u8 healthboxSpriteId_1, healthboxSpriteId_2; u8 healthboxSpriteId_1, healthboxSpriteId_2;
@ -907,7 +907,7 @@ u8 CreateHealthboxSprites(u8 bank)
if (!IsDoubleBattle()) if (!IsDoubleBattle())
{ {
if (GetBattlerSide(bank) == B_SIDE_PLAYER) if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{ {
healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[0], 240, 160, 1); healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[0], 240, 160, 1);
healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[0], 240, 160, 1); healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[0], 240, 160, 1);
@ -932,10 +932,10 @@ u8 CreateHealthboxSprites(u8 bank)
} }
else else
{ {
if (GetBattlerSide(bank) == B_SIDE_PLAYER) if (GetBattlerSide(battler) == B_SIDE_PLAYER)
{ {
healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1);
healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1);
gSprites[healthboxSpriteId_1].oam.affineParam = healthboxSpriteId_2; gSprites[healthboxSpriteId_1].oam.affineParam = healthboxSpriteId_2;
@ -947,8 +947,8 @@ u8 CreateHealthboxSprites(u8 bank)
} }
else else
{ {
healthboxSpriteId_1 = CreateSprite(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); healthboxSpriteId_1 = CreateSprite(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1);
healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1);
gSprites[healthboxSpriteId_1].oam.affineParam = healthboxSpriteId_2; gSprites[healthboxSpriteId_1].oam.affineParam = healthboxSpriteId_2;
@ -960,16 +960,16 @@ u8 CreateHealthboxSprites(u8 bank)
} }
} }
unkSpriteId = CreateSpriteAtEnd(&sUnknown_0832C1C0[gBattlerPositions[bank]], 140, 60, 0); unkSpriteId = CreateSpriteAtEnd(&sUnknown_0832C1C0[gBattlerPositions[battler]], 140, 60, 0);
unkSpritePtr = &gSprites[unkSpriteId]; unkSpritePtr = &gSprites[unkSpriteId];
SetSubspriteTables(unkSpritePtr, &sUnknown_0832C28C[GetBattlerSide(bank)]); SetSubspriteTables(unkSpritePtr, &sUnknown_0832C28C[GetBattlerSide(battler)]);
unkSpritePtr->subspriteMode = 2; unkSpritePtr->subspriteMode = 2;
unkSpritePtr->oam.priority = 1; unkSpritePtr->oam.priority = 1;
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_1), (void*)(OBJ_VRAM0 + unkSpritePtr->oam.tileNum * 32), 64); CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_1), (void*)(OBJ_VRAM0 + unkSpritePtr->oam.tileNum * 32), 64);
gSprites[healthboxSpriteId_1].data[5] = unkSpriteId; gSprites[healthboxSpriteId_1].data[5] = unkSpriteId;
gSprites[healthboxSpriteId_1].data[6] = bank; gSprites[healthboxSpriteId_1].data[6] = battler;
gSprites[healthboxSpriteId_1].invisible = 1; gSprites[healthboxSpriteId_1].invisible = 1;
gSprites[healthboxSpriteId_2].invisible = 1; gSprites[healthboxSpriteId_2].invisible = 1;
@ -1099,20 +1099,20 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority)
} }
} }
void InitBattlerHealthboxCoords(u8 bank) void InitBattlerHealthboxCoords(u8 battler)
{ {
s16 x = 0, y = 0; s16 x = 0, y = 0;
if (!IsDoubleBattle()) if (!IsDoubleBattle())
{ {
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(battler) != B_SIDE_PLAYER)
x = 44, y = 30; x = 44, y = 30;
else else
x = 158, y = 88; x = 158, y = 88;
} }
else else
{ {
switch (GetBattlerPosition(bank)) switch (GetBattlerPosition(battler))
{ {
case B_POSITION_PLAYER_LEFT: case B_POSITION_PLAYER_LEFT:
x = 159, y = 76; x = 159, y = 76;
@ -1129,7 +1129,7 @@ void InitBattlerHealthboxCoords(u8 bank)
} }
} }
UpdateSpritePos(gHealthboxSpriteIds[bank], x, y); UpdateSpritePos(gHealthboxSpriteIds[battler], x, y);
} }
static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl) static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl)
@ -1210,11 +1210,11 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent)
} }
else else
{ {
u8 bank; u8 battler;
memcpy(text, sUnknown_0832C3C4, sizeof(sUnknown_0832C3C4)); memcpy(text, sUnknown_0832C3C4, sizeof(sUnknown_0832C3C4));
bank = gSprites[healthboxSpriteId].data[6]; battler = gSprites[healthboxSpriteId].data[6];
if (IsDoubleBattle() == TRUE || GetBattlerSide(bank) == B_SIDE_OPPONENT) if (IsDoubleBattle() == TRUE || GetBattlerSide(battler) == B_SIDE_OPPONENT)
{ {
UpdateHpTextInHealthboxInDoubles(healthboxSpriteId, value, maxOrCurrent); UpdateHpTextInHealthboxInDoubles(healthboxSpriteId, value, maxOrCurrent);
} }
@ -1260,7 +1260,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8
if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER) if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER)
{ {
if (gBattleSpritesDataPtr->bankData[gSprites[healthboxSpriteId].data[6]].hpNumbersNoBars) // don't print text if only bars are visible if (gBattleSpritesDataPtr->battlerData[gSprites[healthboxSpriteId].data[6]].hpNumbersNoBars) // don't print text if only bars are visible
{ {
spriteTileNum = gSprites[gSprites[healthboxSpriteId].data[5]].oam.tileNum * 32; spriteTileNum = gSprites[gSprites[healthboxSpriteId].data[5]].oam.tileNum * 32;
objVram = (void*)(OBJ_VRAM0) + spriteTileNum; objVram = (void*)(OBJ_VRAM0) + spriteTileNum;
@ -1294,7 +1294,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8
memcpy(text, sUnknown_0832C3D8, sizeof(sUnknown_0832C3D8)); memcpy(text, sUnknown_0832C3D8, sizeof(sUnknown_0832C3D8));
bank = gSprites[healthboxSpriteId].data[6]; bank = gSprites[healthboxSpriteId].data[6];
if (gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars) // don't print text if only bars are visible if (gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars) // don't print text if only bars are visible
{ {
u8 var = 4; u8 var = 4;
u8 r7; u8 r7;
@ -1423,8 +1423,8 @@ void SwapHpBarsWithHpText(void)
{ {
bool8 noBars; bool8 noBars;
gBattleSpritesDataPtr->bankData[i].hpNumbersNoBars ^= 1; gBattleSpritesDataPtr->battlerData[i].hpNumbersNoBars ^= 1;
noBars = gBattleSpritesDataPtr->bankData[i].hpNumbersNoBars; noBars = gBattleSpritesDataPtr->battlerData[i].hpNumbersNoBars;
if (GetBattlerSide(i) == B_SIDE_PLAYER) if (GetBattlerSide(i) == B_SIDE_PLAYER)
{ {
if (!IsDoubleBattle()) if (!IsDoubleBattle())
@ -2062,7 +2062,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder + i) * 32), 32); CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder + i) * 32), 32);
if (!gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars) if (!gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars)
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_1), (void *)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 64); CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_1), (void *)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 64);
TryAddPokeballIconToHealthbox(healthboxSpriteId, TRUE); TryAddPokeballIconToHealthbox(healthboxSpriteId, TRUE);
@ -2077,7 +2077,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId)
CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder) * 32), 96); CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder) * 32), 96);
if (IsDoubleBattle() == TRUE || GetBattlerSide(bank) == B_SIDE_OPPONENT) if (IsDoubleBattle() == TRUE || GetBattlerSide(bank) == B_SIDE_OPPONENT)
{ {
if (!gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars) if (!gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars)
{ {
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_0), (void*)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 32); CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_0), (void*)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 32);
CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_65), (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId_2].oam.tileNum + 1) * 32), 32); CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_65), (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId_2].oam.tileNum + 1) * 32), 32);
@ -2275,7 +2275,7 @@ s32 sub_8074AA0(u8 bank, u8 healthboxSpriteId, u8 whichBar, u8 arg3)
8, expFraction); 8, expFraction);
} }
if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars)) if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars))
sub_8074B9C(bank, whichBar); sub_8074B9C(bank, whichBar);
if (var == -1) if (var == -1)

File diff suppressed because it is too large Load Diff

View File

@ -17,11 +17,11 @@
extern u16 gLastUsedItem; extern u16 gLastUsedItem;
extern u8 gLastUsedAbility; extern u8 gLastUsedAbility;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBattleMoveAttacker; extern u8 gBattlerAttacker;
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gStringBank; extern u8 gStringBattler;
extern u8 gEffectBank; extern u8 gEffectBank;
extern u8 gAbilitiesPerBank[MAX_BATTLERS_COUNT]; extern u8 gBattlerAbilities[MAX_BATTLERS_COUNT];
extern u32 gBattleTypeFlags; extern u32 gBattleTypeFlags;
extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_A;
extern u16 gTrainerBattleOpponent_B; extern u16 gTrainerBattleOpponent_B;
@ -1436,12 +1436,12 @@ void BufferStringBattle(u16 stringID)
gBattleScripting.battler = gStringInfo->scrActive; gBattleScripting.battler = gStringInfo->scrActive;
*(&gBattleStruct->field_52) = gStringInfo->unk1605E; *(&gBattleStruct->field_52) = gStringInfo->unk1605E;
*(&gBattleStruct->hpScale) = gStringInfo->hpScale; *(&gBattleStruct->hpScale) = gStringInfo->hpScale;
gStringBank = gStringInfo->StringBank; gStringBattler = gStringInfo->StringBank;
*(&gBattleStruct->stringMoveType) = gStringInfo->moveType; *(&gBattleStruct->stringMoveType) = gStringInfo->moveType;
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{ {
gAbilitiesPerBank[i] = gStringInfo->abilities[i]; gBattlerAbilities[i] = gStringInfo->abilities[i];
} }
for (i = 0; i < TEXT_BUFF_ARRAY_COUNT; i++) for (i = 0; i < TEXT_BUFF_ARRAY_COUNT; i++)
{ {
@ -1884,23 +1884,23 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = text; toCpy = text;
break; break;
case B_TXT_ATK_NAME_WITH_PREFIX_MON1: // attacker name with prefix, only bank 0/1 case B_TXT_ATK_NAME_WITH_PREFIX_MON1: // attacker name with prefix, only bank 0/1
HANDLE_NICKNAME_STRING_CASE(gBattleMoveAttacker, HANDLE_NICKNAME_STRING_CASE(gBattlerAttacker,
gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleMoveAttacker))]) gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattlerAttacker))])
break; break;
case B_TXT_ATK_PARTNER_NAME: // attacker partner name case B_TXT_ATK_PARTNER_NAME: // attacker partner name
if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleMoveAttacker)) + 2]], MON_DATA_NICKNAME, text); GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattlerAttacker)) + 2]], MON_DATA_NICKNAME, text);
else else
GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleMoveAttacker)) + 2]], MON_DATA_NICKNAME, text); GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattlerAttacker)) + 2]], MON_DATA_NICKNAME, text);
StringGetEnd10(text); StringGetEnd10(text);
toCpy = text; toCpy = text;
break; break;
case B_TXT_ATK_NAME_WITH_PREFIX: // attacker name with prefix case B_TXT_ATK_NAME_WITH_PREFIX: // attacker name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattleMoveAttacker, gBattlerPartyIndexes[gBattleMoveAttacker]) HANDLE_NICKNAME_STRING_CASE(gBattlerAttacker, gBattlerPartyIndexes[gBattlerAttacker])
break; break;
case B_TXT_DEF_NAME_WITH_PREFIX: // target name with prefix case B_TXT_DEF_NAME_WITH_PREFIX: // target name with prefix
HANDLE_NICKNAME_STRING_CASE(gBattleMoveTarget, gBattlerPartyIndexes[gBattleMoveTarget]) HANDLE_NICKNAME_STRING_CASE(gBattlerTarget, gBattlerPartyIndexes[gBattlerTarget])
break; break;
case B_TXT_EFF_NAME_WITH_PREFIX: // effect bank name with prefix case B_TXT_EFF_NAME_WITH_PREFIX: // effect bank name with prefix
HANDLE_NICKNAME_STRING_CASE(gEffectBank, gBattlerPartyIndexes[gEffectBank]) HANDLE_NICKNAME_STRING_CASE(gEffectBank, gBattlerPartyIndexes[gEffectBank])
@ -1930,10 +1930,10 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
{ {
if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI))
{ {
if ((gBattleScripting.multiplayerId != 0 && (gStringBank & BIT_SIDE)) if ((gBattleScripting.multiplayerId != 0 && (gStringBattler & BIT_SIDE))
|| (gBattleScripting.multiplayerId == 0 && !(gStringBank & BIT_SIDE))) || (gBattleScripting.multiplayerId == 0 && !(gStringBattler & BIT_SIDE)))
{ {
StringCopy(text, gEnigmaBerries[gStringBank].name); StringCopy(text, gEnigmaBerries[gStringBattler].name);
StringAppend(text, gText_BerrySuffix); StringAppend(text, gText_BerrySuffix);
toCpy = text; toCpy = text;
} }
@ -1944,9 +1944,9 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
} }
else else
{ {
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBank) if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBattler)
{ {
StringCopy(text, gEnigmaBerries[gStringBank].name); StringCopy(text, gEnigmaBerries[gStringBattler].name);
StringAppend(text, gText_BerrySuffix); StringAppend(text, gText_BerrySuffix);
toCpy = text; toCpy = text;
} }
@ -1970,16 +1970,16 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = gAbilityNames[gLastUsedAbility]; toCpy = gAbilityNames[gLastUsedAbility];
break; break;
case B_TXT_ATK_ABILITY: // attacker ability case B_TXT_ATK_ABILITY: // attacker ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBattleMoveAttacker]]; toCpy = gAbilityNames[gBattlerAbilities[gBattlerAttacker]];
break; break;
case B_TXT_DEF_ABILITY: // target ability case B_TXT_DEF_ABILITY: // target ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBattleMoveTarget]]; toCpy = gAbilityNames[gBattlerAbilities[gBattlerTarget]];
break; break;
case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability
toCpy = gAbilityNames[gAbilitiesPerBank[gBattleScripting.battler]]; toCpy = gAbilityNames[gBattlerAbilities[gBattleScripting.battler]];
break; break;
case B_TXT_EFF_ABILITY: // effect bank ability case B_TXT_EFF_ABILITY: // effect bank ability
toCpy = gAbilityNames[gAbilitiesPerBank[gEffectBank]]; toCpy = gAbilityNames[gBattlerAbilities[gEffectBank]];
break; break;
case B_TXT_TRAINER1_CLASS: // trainer class name case B_TXT_TRAINER1_CLASS: // trainer class name
if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE) if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE)
@ -2094,37 +2094,37 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst)
toCpy = gText_Someones; toCpy = gText_Someones;
break; break;
case B_TXT_ATK_PREFIX2: case B_TXT_ATK_PREFIX2:
if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix2; toCpy = gText_AllyPkmnPrefix2;
else else
toCpy = gText_FoePkmnPrefix3; toCpy = gText_FoePkmnPrefix3;
break; break;
case B_TXT_DEF_PREFIX2: case B_TXT_DEF_PREFIX2:
if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER) if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix2; toCpy = gText_AllyPkmnPrefix2;
else else
toCpy = gText_FoePkmnPrefix3; toCpy = gText_FoePkmnPrefix3;
break; break;
case B_TXT_ATK_PREFIX1: case B_TXT_ATK_PREFIX1:
if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix; toCpy = gText_AllyPkmnPrefix;
else else
toCpy = gText_FoePkmnPrefix2; toCpy = gText_FoePkmnPrefix2;
break; break;
case B_TXT_DEF_PREFIX1: case B_TXT_DEF_PREFIX1:
if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER) if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix; toCpy = gText_AllyPkmnPrefix;
else else
toCpy = gText_FoePkmnPrefix2; toCpy = gText_FoePkmnPrefix2;
break; break;
case B_TXT_ATK_PREFIX3: case B_TXT_ATK_PREFIX3:
if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix3; toCpy = gText_AllyPkmnPrefix3;
else else
toCpy = gText_FoePkmnPrefix4; toCpy = gText_FoePkmnPrefix4;
break; break;
case B_TXT_DEF_PREFIX3: case B_TXT_DEF_PREFIX3:
if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER) if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER)
toCpy = gText_AllyPkmnPrefix3; toCpy = gText_AllyPkmnPrefix3;
else else
toCpy = gText_FoePkmnPrefix4; toCpy = gText_FoePkmnPrefix4;
@ -2313,9 +2313,9 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst)
{ {
if (hword == ITEM_ENIGMA_BERRY) if (hword == ITEM_ENIGMA_BERRY)
{ {
if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBank) if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBattler)
{ {
StringCopy(dst, gEnigmaBerries[gStringBank].name); StringCopy(dst, gEnigmaBerries[gStringBattler].name);
StringAppend(dst, gText_BerrySuffix); StringAppend(dst, gText_BerrySuffix);
} }
else else

File diff suppressed because it is too large Load Diff

View File

@ -28,13 +28,13 @@ extern const u8* gSelectionBattleScripts[MAX_BATTLERS_COUNT];
extern const u8* gPalaceSelectionBattleScripts[MAX_BATTLERS_COUNT]; extern const u8* gPalaceSelectionBattleScripts[MAX_BATTLERS_COUNT];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gStringBank; extern u8 gStringBattler;
extern u16 gCurrentMove; extern u16 gCurrentMove;
extern u16 gLastUsedItem; extern u16 gLastUsedItem;
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern u32 gStatuses3[MAX_BATTLERS_COUNT]; extern u32 gStatuses3[MAX_BATTLERS_COUNT];
extern u8 gBattleMoveAttacker; extern u8 gBattlerAttacker;
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u16 gBattleWeather; extern u16 gBattleWeather;
extern u8 gBattleTurnOrder[MAX_BATTLERS_COUNT]; extern u8 gBattleTurnOrder[MAX_BATTLERS_COUNT];
@ -50,7 +50,7 @@ extern u32 gHitMarker;
extern u8 gEffectBank; extern u8 gEffectBank;
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern u8 gBank1; extern u8 gBank1;
extern u16 gChosenMovesByBanks[MAX_BATTLERS_COUNT]; extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT];
extern u8 gMoveResultFlags; extern u8 gMoveResultFlags;
extern s32 gTakenDmg[MAX_BATTLERS_COUNT]; extern s32 gTakenDmg[MAX_BATTLERS_COUNT];
extern u8 gTakenDmgBanks[MAX_BATTLERS_COUNT]; extern u8 gTakenDmgBanks[MAX_BATTLERS_COUNT];
@ -79,10 +79,10 @@ u8 GetBattleBank(u8 caseId)
switch (caseId) switch (caseId)
{ {
case BS_GET_TARGET: case BS_GET_TARGET:
ret = gBattleMoveTarget; ret = gBattlerTarget;
break; break;
case BS_GET_ATTACKER: case BS_GET_ATTACKER:
ret = gBattleMoveAttacker; ret = gBattlerAttacker;
break; break;
case BS_GET_EFFECT_BANK: case BS_GET_EFFECT_BANK:
ret = gEffectBank; ret = gEffectBank;
@ -335,17 +335,17 @@ void sub_803FA70(u8 battler)
void BattleScriptPush(const u8* bsPtr) void BattleScriptPush(const u8* bsPtr)
{ {
BATTLESCRIPTS_STACK->ptr[BATTLESCRIPTS_STACK->size++] = bsPtr; gBattleResources->battleScriptsStack->ptr[gBattleResources->battleScriptsStack->size++] = bsPtr;
} }
void BattleScriptPushCursor(void) void BattleScriptPushCursor(void)
{ {
BATTLESCRIPTS_STACK->ptr[BATTLESCRIPTS_STACK->size++] = gBattlescriptCurrInstr; gBattleResources->battleScriptsStack->ptr[gBattleResources->battleScriptsStack->size++] = gBattlescriptCurrInstr;
} }
void BattleScriptPop(void) void BattleScriptPop(void)
{ {
gBattlescriptCurrInstr = BATTLESCRIPTS_STACK->ptr[--BATTLESCRIPTS_STACK->size]; gBattlescriptCurrInstr = gBattleResources->battleScriptsStack->ptr[--gBattleResources->battleScriptsStack->size];
} }
u8 TrySetCantSelectMoveBattleScript(void) u8 TrySetCantSelectMoveBattleScript(void)
@ -421,7 +421,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
else else
holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item); holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item);
gStringBank = gActiveBattler; gStringBattler = gActiveBattler;
if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != move) if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != move)
{ {
@ -465,7 +465,7 @@ u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check)
else else
holdEffect = ItemId_GetHoldEffect(gBattleMons[bank].item); holdEffect = ItemId_GetHoldEffect(gBattleMons[bank].item);
gStringBank = bank; gStringBattler = bank;
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{ {
@ -536,10 +536,10 @@ u8 UpdateTurnCounters(void)
u8 effect = 0; u8 effect = 0;
s32 i; s32 i;
for (gBattleMoveAttacker = 0; gBattleMoveAttacker < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattleMoveAttacker]; gBattleMoveAttacker++) for (gBattlerAttacker = 0; gBattlerAttacker < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattlerAttacker]; gBattlerAttacker++)
{ {
} }
for (gBattleMoveTarget = 0; gBattleMoveTarget < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]; gBattleMoveTarget++) for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattlerTarget]; gBattlerTarget++)
{ {
} }
@ -575,7 +575,7 @@ u8 UpdateTurnCounters(void)
while (gBattleStruct->turnSideTracker < 2) while (gBattleStruct->turnSideTracker < 2)
{ {
sideBank = gBattleStruct->turnSideTracker; sideBank = gBattleStruct->turnSideTracker;
gActiveBattler = gBattleMoveAttacker = gSideTimers[sideBank].reflectBank; gActiveBattler = gBattlerAttacker = gSideTimers[sideBank].reflectBank;
if (gSideStatuses[sideBank] & SIDE_STATUS_REFLECT) if (gSideStatuses[sideBank] & SIDE_STATUS_REFLECT)
{ {
if (--gSideTimers[sideBank].reflectTimer == 0) if (--gSideTimers[sideBank].reflectTimer == 0)
@ -600,7 +600,7 @@ u8 UpdateTurnCounters(void)
while (gBattleStruct->turnSideTracker < 2) while (gBattleStruct->turnSideTracker < 2)
{ {
sideBank = gBattleStruct->turnSideTracker; sideBank = gBattleStruct->turnSideTracker;
gActiveBattler = gBattleMoveAttacker = gSideTimers[sideBank].lightscreenBank; gActiveBattler = gBattlerAttacker = gSideTimers[sideBank].lightscreenBank;
if (gSideStatuses[sideBank] & SIDE_STATUS_LIGHTSCREEN) if (gSideStatuses[sideBank] & SIDE_STATUS_LIGHTSCREEN)
{ {
if (--gSideTimers[sideBank].lightscreenTimer == 0) if (--gSideTimers[sideBank].lightscreenTimer == 0)
@ -626,7 +626,7 @@ u8 UpdateTurnCounters(void)
while (gBattleStruct->turnSideTracker < 2) while (gBattleStruct->turnSideTracker < 2)
{ {
sideBank = gBattleStruct->turnSideTracker; sideBank = gBattleStruct->turnSideTracker;
gActiveBattler = gBattleMoveAttacker = gSideTimers[sideBank].mistBank; gActiveBattler = gBattlerAttacker = gSideTimers[sideBank].mistBank;
if (gSideTimers[sideBank].mistTimer != 0 if (gSideTimers[sideBank].mistTimer != 0
&& --gSideTimers[sideBank].mistTimer == 0) && --gSideTimers[sideBank].mistTimer == 0)
{ {
@ -650,7 +650,7 @@ u8 UpdateTurnCounters(void)
while (gBattleStruct->turnSideTracker < 2) while (gBattleStruct->turnSideTracker < 2)
{ {
sideBank = gBattleStruct->turnSideTracker; sideBank = gBattleStruct->turnSideTracker;
gActiveBattler = gBattleMoveAttacker = gSideTimers[sideBank].safeguardBank; gActiveBattler = gBattlerAttacker = gSideTimers[sideBank].safeguardBank;
if (gSideStatuses[sideBank] & SIDE_STATUS_SAFEGUARD) if (gSideStatuses[sideBank] & SIDE_STATUS_SAFEGUARD)
{ {
if (--gSideTimers[sideBank].safeguardTimer == 0) if (--gSideTimers[sideBank].safeguardTimer == 0)
@ -678,7 +678,7 @@ u8 UpdateTurnCounters(void)
&& --gWishFutureKnock.wishCounter[gActiveBattler] == 0 && --gWishFutureKnock.wishCounter[gActiveBattler] == 0
&& gBattleMons[gActiveBattler].hp != 0) && gBattleMons[gActiveBattler].hp != 0)
{ {
gBattleMoveTarget = gActiveBattler; gBattlerTarget = gActiveBattler;
BattleScriptExecute(BattleScript_WishComesTrue); BattleScriptExecute(BattleScript_WishComesTrue);
effect++; effect++;
} }
@ -796,7 +796,7 @@ u8 TurnBasedEffects(void)
gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_x20); gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_x20);
while (gBattleStruct->turnEffectsBank < gBattlersCount && gBattleStruct->turnEffectsTracker <= TURNBASED_MAX_CASE) while (gBattleStruct->turnEffectsBank < gBattlersCount && gBattleStruct->turnEffectsTracker <= TURNBASED_MAX_CASE)
{ {
gActiveBattler = gBattleMoveAttacker = gBattleTurnOrder[gBattleStruct->turnEffectsBank]; gActiveBattler = gBattlerAttacker = gBattleTurnOrder[gBattleStruct->turnEffectsBank];
if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) if (gAbsentBattlerFlags & gBitTable[gActiveBattler])
{ {
gBattleStruct->turnEffectsBank++; gBattleStruct->turnEffectsBank++;
@ -839,12 +839,12 @@ u8 TurnBasedEffects(void)
&& gBattleMons[gStatuses3[gActiveBattler] & STATUS3_LEECHSEED_BANK].hp != 0 && gBattleMons[gStatuses3[gActiveBattler] & STATUS3_LEECHSEED_BANK].hp != 0
&& gBattleMons[gActiveBattler].hp != 0) && gBattleMons[gActiveBattler].hp != 0)
{ {
gBattleMoveTarget = gStatuses3[gActiveBattler] & STATUS3_LEECHSEED_BANK; //funny how the 'target' is actually the bank that receives HP gBattlerTarget = gStatuses3[gActiveBattler] & STATUS3_LEECHSEED_BANK; //funny how the 'target' is actually the bank that receives HP
gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 8; gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 8;
if (gBattleMoveDamage == 0) if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1; gBattleMoveDamage = 1;
gBattleScripting.animArg1 = gBattleMoveTarget; gBattleScripting.animArg1 = gBattlerTarget;
gBattleScripting.animArg2 = gBattleMoveAttacker; gBattleScripting.animArg2 = gBattlerAttacker;
BattleScriptExecute(BattleScript_LeechSeedTurnDrain); BattleScriptExecute(BattleScript_LeechSeedTurnDrain);
effect++; effect++;
} }
@ -953,29 +953,29 @@ u8 TurnBasedEffects(void)
case 10: // uproar case 10: // uproar
if (gBattleMons[gActiveBattler].status2 & STATUS2_UPROAR) if (gBattleMons[gActiveBattler].status2 & STATUS2_UPROAR)
{ {
for (gBattleMoveAttacker = 0; gBattleMoveAttacker < gBattlersCount; gBattleMoveAttacker++) for (gBattlerAttacker = 0; gBattlerAttacker < gBattlersCount; gBattlerAttacker++)
{ {
if ((gBattleMons[gBattleMoveAttacker].status1 & STATUS1_SLEEP) if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP)
&& gBattleMons[gBattleMoveAttacker].ability != ABILITY_SOUNDPROOF) && gBattleMons[gBattlerAttacker].ability != ABILITY_SOUNDPROOF)
{ {
gBattleMons[gBattleMoveAttacker].status1 &= ~(STATUS1_SLEEP); gBattleMons[gBattlerAttacker].status1 &= ~(STATUS1_SLEEP);
gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_NIGHTMARE); gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_NIGHTMARE);
gBattleCommunication[MULTISTRING_CHOOSER] = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 1;
BattleScriptExecute(BattleScript_MonWokeUpInUproar); BattleScriptExecute(BattleScript_MonWokeUpInUproar);
gActiveBattler = gBattleMoveAttacker; gActiveBattler = gBattlerAttacker;
BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
MarkBattlerForControllerExec(gActiveBattler); MarkBattlerForControllerExec(gActiveBattler);
break; break;
} }
} }
if (gBattleMoveAttacker != gBattlersCount) if (gBattlerAttacker != gBattlersCount)
{ {
effect = 2; // a pokemon was awaken effect = 2; // a pokemon was awaken
break; break;
} }
else else
{ {
gBattleMoveAttacker = gActiveBattler; gBattlerAttacker = gActiveBattler;
gBattleMons[gActiveBattler].status2 -= 0x10; // uproar timer goes down gBattleMons[gActiveBattler].status2 -= 0x10; // uproar timer goes down
if (WasUnableToUseMove(gActiveBattler)) if (WasUnableToUseMove(gActiveBattler))
{ {
@ -1138,16 +1138,16 @@ bool8 HandleWishPerishSongOnTurnEnd(void)
PREPARE_MOVE_BUFFER(gBattleTextBuff1, gWishFutureKnock.futureSightMove[gActiveBattler]); PREPARE_MOVE_BUFFER(gBattleTextBuff1, gWishFutureKnock.futureSightMove[gActiveBattler]);
gBattleMoveTarget = gActiveBattler; gBattlerTarget = gActiveBattler;
gBattleMoveAttacker = gWishFutureKnock.futureSightAttacker[gActiveBattler]; gBattlerAttacker = gWishFutureKnock.futureSightAttacker[gActiveBattler];
gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBattler]; gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBattler];
gSpecialStatuses[gBattleMoveTarget].moveturnLostHP = 0xFFFF; gSpecialStatuses[gBattlerTarget].moveturnLostHP = 0xFFFF;
BattleScriptExecute(BattleScript_MonTookFutureAttack); BattleScriptExecute(BattleScript_MonTookFutureAttack);
if (gWishFutureKnock.futureSightCounter[gActiveBattler] == 0 if (gWishFutureKnock.futureSightCounter[gActiveBattler] == 0
&& gWishFutureKnock.futureSightCounter[gActiveBattler ^ BIT_FLANK] == 0) && gWishFutureKnock.futureSightCounter[gActiveBattler ^ BIT_FLANK] == 0)
{ {
gSideStatuses[GET_BATTLER_SIDE(gBattleMoveTarget)] &= ~(SIDE_STATUS_FUTUREATTACK); gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)] &= ~(SIDE_STATUS_FUTUREATTACK);
} }
return TRUE; return TRUE;
} }
@ -1162,7 +1162,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void)
case 1: case 1:
while (gBattleStruct->wishPerishSongBank < gBattlersCount) while (gBattleStruct->wishPerishSongBank < gBattlersCount)
{ {
gActiveBattler = gBattleMoveAttacker = gBattleTurnOrder[gBattleStruct->wishPerishSongBank]; gActiveBattler = gBattlerAttacker = gBattleTurnOrder[gBattleStruct->wishPerishSongBank];
if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) if (gAbsentBattlerFlags & gBitTable[gActiveBattler])
{ {
gBattleStruct->wishPerishSongBank++; gBattleStruct->wishPerishSongBank++;
@ -1240,7 +1240,7 @@ bool8 HandleFaintedMonActions(void)
case 1: case 1:
do do
{ {
gBank1 = gBattleMoveTarget = gBattleStruct->faintedActionsBank; gBank1 = gBattlerTarget = gBattleStruct->faintedActionsBank;
if (gBattleMons[gBattleStruct->faintedActionsBank].hp == 0 if (gBattleMons[gBattleStruct->faintedActionsBank].hp == 0
&& !(gBattleStruct->field_DF & gBitTable[gBattlerPartyIndexes[gBattleStruct->faintedActionsBank]]) && !(gBattleStruct->field_DF & gBitTable[gBattlerPartyIndexes[gBattleStruct->faintedActionsBank]])
&& !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBank])) && !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBank]))
@ -1266,7 +1266,7 @@ bool8 HandleFaintedMonActions(void)
case 4: case 4:
do do
{ {
gBank1 = gBattleMoveTarget = gBattleStruct->faintedActionsBank; gBank1 = gBattlerTarget = gBattleStruct->faintedActionsBank;
if (gBattleMons[gBattleStruct->faintedActionsBank].hp == 0 if (gBattleMons[gBattleStruct->faintedActionsBank].hp == 0
&& !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBank])) && !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBank]))
{ {
@ -1300,7 +1300,7 @@ void TryClearRageStatuses(void)
int i; int i;
for (i = 0; i < gBattlersCount; i++) for (i = 0; i < gBattlersCount; i++)
{ {
if ((gBattleMons[i].status2 & STATUS2_RAGE) && gChosenMovesByBanks[i] != MOVE_RAGE) if ((gBattleMons[i].status2 & STATUS2_RAGE) && gChosenMoveByBattler[i] != MOVE_RAGE)
gBattleMons[i].status2 &= ~(STATUS2_RAGE); gBattleMons[i].status2 &= ~(STATUS2_RAGE);
} }
} }
@ -1316,17 +1316,17 @@ u8 AtkCanceller_UnableToUseMove(void)
switch (gBattleStruct->atkCancellerTracker) switch (gBattleStruct->atkCancellerTracker)
{ {
case 0: // flags clear case 0: // flags clear
gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_DESTINY_BOND); gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_DESTINY_BOND);
gStatuses3[gBattleMoveAttacker] &= ~(STATUS3_GRUDGE); gStatuses3[gBattlerAttacker] &= ~(STATUS3_GRUDGE);
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 1: // check being asleep case 1: // check being asleep
if (gBattleMons[gBattleMoveAttacker].status1 & STATUS1_SLEEP) if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP)
{ {
if (UproarWakeUpCheck(gBattleMoveAttacker)) if (UproarWakeUpCheck(gBattlerAttacker))
{ {
gBattleMons[gBattleMoveAttacker].status1 &= ~(STATUS1_SLEEP); gBattleMons[gBattlerAttacker].status1 &= ~(STATUS1_SLEEP);
gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_NIGHTMARE); gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_NIGHTMARE);
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 1;
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp; gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
@ -1335,15 +1335,15 @@ u8 AtkCanceller_UnableToUseMove(void)
else else
{ {
u8 toSub; u8 toSub;
if (gBattleMons[gBattleMoveAttacker].ability == ABILITY_EARLY_BIRD) if (gBattleMons[gBattlerAttacker].ability == ABILITY_EARLY_BIRD)
toSub = 2; toSub = 2;
else else
toSub = 1; toSub = 1;
if ((gBattleMons[gBattleMoveAttacker].status1 & STATUS1_SLEEP) < toSub) if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) < toSub)
gBattleMons[gBattleMoveAttacker].status1 &= ~(STATUS1_SLEEP); gBattleMons[gBattlerAttacker].status1 &= ~(STATUS1_SLEEP);
else else
gBattleMons[gBattleMoveAttacker].status1 -= toSub; gBattleMons[gBattlerAttacker].status1 -= toSub;
if (gBattleMons[gBattleMoveAttacker].status1 & STATUS1_SLEEP) if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP)
{ {
if (gCurrentMove != MOVE_SNORE && gCurrentMove != MOVE_SLEEP_TALK) if (gCurrentMove != MOVE_SNORE && gCurrentMove != MOVE_SLEEP_TALK)
{ {
@ -1354,7 +1354,7 @@ u8 AtkCanceller_UnableToUseMove(void)
} }
else else
{ {
gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_NIGHTMARE); gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_NIGHTMARE);
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 0;
gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp; gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp;
@ -1365,7 +1365,7 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 2: // check being frozen case 2: // check being frozen
if (gBattleMons[gBattleMoveAttacker].status1 & STATUS1_FREEZE) if (gBattleMons[gBattlerAttacker].status1 & STATUS1_FREEZE)
{ {
if (Random() % 5) if (Random() % 5)
{ {
@ -1382,7 +1382,7 @@ u8 AtkCanceller_UnableToUseMove(void)
} }
else // unfreeze else // unfreeze
{ {
gBattleMons[gBattleMoveAttacker].status1 &= ~(STATUS1_FREEZE); gBattleMons[gBattlerAttacker].status1 &= ~(STATUS1_FREEZE);
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze;
gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 0;
@ -1392,9 +1392,9 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 3: // truant case 3: // truant
if (gBattleMons[gBattleMoveAttacker].ability == ABILITY_TRUANT && gDisableStructs[gBattleMoveAttacker].truantCounter) if (gBattleMons[gBattlerAttacker].ability == ABILITY_TRUANT && gDisableStructs[gBattlerAttacker].truantCounter)
{ {
CancelMultiTurnMoves(gBattleMoveAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 0;
gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround; gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround;
@ -1404,11 +1404,11 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 4: // recharge case 4: // recharge
if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_RECHARGE) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_RECHARGE)
{ {
gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_RECHARGE); gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_RECHARGE);
gDisableStructs[gBattleMoveAttacker].rechargeCounter = 0; gDisableStructs[gBattlerAttacker].rechargeCounter = 0;
CancelMultiTurnMoves(gBattleMoveAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedMustRecharge; gBattlescriptCurrInstr = BattleScript_MoveUsedMustRecharge;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
effect = 1; effect = 1;
@ -1416,11 +1416,11 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 5: // flinch case 5: // flinch
if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_FLINCHED) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_FLINCHED)
{ {
gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_FLINCHED); gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_FLINCHED);
gProtectStructs[gBattleMoveAttacker].flinchImmobility = 1; gProtectStructs[gBattlerAttacker].flinchImmobility = 1;
CancelMultiTurnMoves(gBattleMoveAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedFlinched; gBattlescriptCurrInstr = BattleScript_MoveUsedFlinched;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
effect = 1; effect = 1;
@ -1428,11 +1428,11 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 6: // disabled move case 6: // disabled move
if (gDisableStructs[gBattleMoveAttacker].disabledMove == gCurrentMove && gDisableStructs[gBattleMoveAttacker].disabledMove != 0) if (gDisableStructs[gBattlerAttacker].disabledMove == gCurrentMove && gDisableStructs[gBattlerAttacker].disabledMove != 0)
{ {
gProtectStructs[gBattleMoveAttacker].usedDisabledMove = 1; gProtectStructs[gBattlerAttacker].usedDisabledMove = 1;
gBattleScripting.battler = gBattleMoveAttacker; gBattleScripting.battler = gBattlerAttacker;
CancelMultiTurnMoves(gBattleMoveAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsDisabled; gBattlescriptCurrInstr = BattleScript_MoveUsedIsDisabled;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
effect = 1; effect = 1;
@ -1440,10 +1440,10 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 7: // taunt case 7: // taunt
if (gDisableStructs[gBattleMoveAttacker].tauntTimer1 && gBattleMoves[gCurrentMove].power == 0) if (gDisableStructs[gBattlerAttacker].tauntTimer1 && gBattleMoves[gCurrentMove].power == 0)
{ {
gProtectStructs[gBattleMoveAttacker].usedTauntedMove = 1; gProtectStructs[gBattlerAttacker].usedTauntedMove = 1;
CancelMultiTurnMoves(gBattleMoveAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsTaunted; gBattlescriptCurrInstr = BattleScript_MoveUsedIsTaunted;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
effect = 1; effect = 1;
@ -1451,10 +1451,10 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 8: // imprisoned case 8: // imprisoned
if (GetImprisonedMovesCount(gBattleMoveAttacker, gCurrentMove)) if (GetImprisonedMovesCount(gBattlerAttacker, gCurrentMove))
{ {
gProtectStructs[gBattleMoveAttacker].usedImprisionedMove = 1; gProtectStructs[gBattlerAttacker].usedImprisionedMove = 1;
CancelMultiTurnMoves(gBattleMoveAttacker); CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsImprisoned; gBattlescriptCurrInstr = BattleScript_MoveUsedIsImprisoned;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
effect = 1; effect = 1;
@ -1462,10 +1462,10 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 9: // confusion case 9: // confusion
if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_CONFUSION) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_CONFUSION)
{ {
gBattleMons[gBattleMoveAttacker].status2--; gBattleMons[gBattlerAttacker].status2--;
if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_CONFUSION) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_CONFUSION)
{ {
if (Random() & 1) if (Random() & 1)
{ {
@ -1475,9 +1475,9 @@ u8 AtkCanceller_UnableToUseMove(void)
else // confusion dmg else // confusion dmg
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 1;
gBattleMoveTarget = gBattleMoveAttacker; gBattlerTarget = gBattlerAttacker;
gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattleMoveAttacker], &gBattleMons[gBattleMoveAttacker], MOVE_POUND, 0, 40, 0, gBattleMoveAttacker, gBattleMoveAttacker); gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerAttacker], MOVE_POUND, 0, 40, 0, gBattlerAttacker, gBattlerAttacker);
gProtectStructs[gBattleMoveAttacker].confusionSelfDmg = 1; gProtectStructs[gBattlerAttacker].confusionSelfDmg = 1;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
} }
gBattlescriptCurrInstr = BattleScript_MoveUsedIsConfused; gBattlescriptCurrInstr = BattleScript_MoveUsedIsConfused;
@ -1492,11 +1492,11 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 10: // paralysis case 10: // paralysis
if ((gBattleMons[gBattleMoveAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0) if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0)
{ {
gProtectStructs[gBattleMoveAttacker].prlzImmobility = 1; gProtectStructs[gBattlerAttacker].prlzImmobility = 1;
// This is removed in Emerald for some reason // This is removed in Emerald for some reason
//CancelMultiTurnMoves(gBattleMoveAttacker); //CancelMultiTurnMoves(gBattlerAttacker);
gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed; gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
effect = 1; effect = 1;
@ -1504,17 +1504,17 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 11: // infatuation case 11: // infatuation
if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_INFATUATION) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_INFATUATION)
{ {
gBattleScripting.battler = CountTrailingZeroBits((gBattleMons[gBattleMoveAttacker].status2 & STATUS2_INFATUATION) >> 0x10); gBattleScripting.battler = CountTrailingZeroBits((gBattleMons[gBattlerAttacker].status2 & STATUS2_INFATUATION) >> 0x10);
if (Random() & 1) if (Random() & 1)
BattleScriptPushCursor(); BattleScriptPushCursor();
else else
{ {
BattleScriptPush(BattleScript_MoveUsedIsParalyzedCantAttack); BattleScriptPush(BattleScript_MoveUsedIsParalyzedCantAttack);
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
gProtectStructs[gBattleMoveAttacker].loveImmobility = 1; gProtectStructs[gBattlerAttacker].loveImmobility = 1;
CancelMultiTurnMoves(gBattleMoveAttacker); CancelMultiTurnMoves(gBattlerAttacker);
} }
gBattlescriptCurrInstr = BattleScript_MoveUsedIsInLove; gBattlescriptCurrInstr = BattleScript_MoveUsedIsInLove;
effect = 1; effect = 1;
@ -1522,22 +1522,22 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 12: // bide case 12: // bide
if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_BIDE) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_BIDE)
{ {
gBattleMons[gBattleMoveAttacker].status2 -= 0x100; gBattleMons[gBattlerAttacker].status2 -= 0x100;
if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_BIDE) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_BIDE)
gBattlescriptCurrInstr = BattleScript_BideStoringEnergy; gBattlescriptCurrInstr = BattleScript_BideStoringEnergy;
else else
{ {
// This is removed in Emerald for some reason // This is removed in Emerald for some reason
//gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); //gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_MULTIPLETURNS);
if (gTakenDmg[gBattleMoveAttacker]) if (gTakenDmg[gBattlerAttacker])
{ {
gCurrentMove = MOVE_BIDE; gCurrentMove = MOVE_BIDE;
*bideDmg = gTakenDmg[gBattleMoveAttacker] * 2; *bideDmg = gTakenDmg[gBattlerAttacker] * 2;
gBattleMoveTarget = gTakenDmgBanks[gBattleMoveAttacker]; gBattlerTarget = gTakenDmgBanks[gBattlerAttacker];
if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) if (gAbsentBattlerFlags & gBitTable[gBattlerTarget])
gBattleMoveTarget = GetMoveTarget(MOVE_BIDE, 1); gBattlerTarget = GetMoveTarget(MOVE_BIDE, 1);
gBattlescriptCurrInstr = BattleScript_BideAttack; gBattlescriptCurrInstr = BattleScript_BideAttack;
} }
else else
@ -1548,11 +1548,11 @@ u8 AtkCanceller_UnableToUseMove(void)
gBattleStruct->atkCancellerTracker++; gBattleStruct->atkCancellerTracker++;
break; break;
case 13: // move thawing case 13: // move thawing
if (gBattleMons[gBattleMoveAttacker].status1 & STATUS1_FREEZE) if (gBattleMons[gBattlerAttacker].status1 & STATUS1_FREEZE)
{ {
if (gBattleMoves[gCurrentMove].effect == EFFECT_THAW_HIT) if (gBattleMoves[gCurrentMove].effect == EFFECT_THAW_HIT)
{ {
gBattleMons[gBattleMoveAttacker].status1 &= ~(STATUS1_FREEZE); gBattleMons[gBattlerAttacker].status1 &= ~(STATUS1_FREEZE);
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze;
gBattleCommunication[MULTISTRING_CHOOSER] = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 1;
@ -1569,7 +1569,7 @@ u8 AtkCanceller_UnableToUseMove(void)
if (effect == 2) if (effect == 2)
{ {
gActiveBattler = gBattleMoveAttacker; gActiveBattler = gBattlerAttacker;
BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
MarkBattlerForControllerExec(gActiveBattler); MarkBattlerForControllerExec(gActiveBattler);
} }
@ -1750,19 +1750,19 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
u32 pidAtk; u32 pidAtk;
u32 pidDef; u32 pidDef;
if (gBattleMoveAttacker >= gBattlersCount) if (gBattlerAttacker >= gBattlersCount)
gBattleMoveAttacker = battler; gBattlerAttacker = battler;
if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
pokeAtk = &gPlayerParty[gBattlerPartyIndexes[gBattleMoveAttacker]]; pokeAtk = &gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]];
else else
pokeAtk = &gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker]]; pokeAtk = &gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]];
if (gBattleMoveTarget >= gBattlersCount) if (gBattlerTarget >= gBattlersCount)
gBattleMoveTarget = battler; gBattlerTarget = battler;
if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER) if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER)
pokeDef = &gPlayerParty[gBattlerPartyIndexes[gBattleMoveTarget]]; pokeDef = &gPlayerParty[gBattlerPartyIndexes[gBattlerTarget]];
else else
pokeDef = &gEnemyParty[gBattlerPartyIndexes[gBattleMoveTarget]]; pokeDef = &gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]];
speciesAtk = GetMonData(pokeAtk, MON_DATA_SPECIES); speciesAtk = GetMonData(pokeAtk, MON_DATA_SPECIES);
pidAtk = GetMonData(pokeAtk, MON_DATA_PERSONALITY); pidAtk = GetMonData(pokeAtk, MON_DATA_PERSONALITY);
@ -1793,8 +1793,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
switch (caseID) switch (caseID)
{ {
case ABILITYEFFECT_ON_SWITCHIN: // 0 case ABILITYEFFECT_ON_SWITCHIN: // 0
if (gBattleMoveAttacker >= gBattlersCount) if (gBattlerAttacker >= gBattlersCount)
gBattleMoveAttacker = battler; gBattlerAttacker = battler;
switch (gLastUsedAbility) switch (gLastUsedAbility)
{ {
case ABILITYEFFECT_SWITCH_IN_WEATHER: case ABILITYEFFECT_SWITCH_IN_WEATHER:
@ -1911,7 +1911,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
case ABILITYEFFECT_ENDTURN: // 1 case ABILITYEFFECT_ENDTURN: // 1
if (gBattleMons[battler].hp != 0) if (gBattleMons[battler].hp != 0)
{ {
gBattleMoveAttacker = battler; gBattlerAttacker = battler;
switch (gLastUsedAbility) switch (gLastUsedAbility)
{ {
case ABILITY_RAIN_DISH: case ABILITY_RAIN_DISH:
@ -1961,7 +1961,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
} }
break; break;
case ABILITY_TRUANT: case ABILITY_TRUANT:
gDisableStructs[gBattleMoveAttacker].truantCounter ^= 1; gDisableStructs[gBattlerAttacker].truantCounter ^= 1;
break; break;
} }
} }
@ -1976,7 +1976,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
} }
if (sSoundMovesTable[i] != 0xFFFF) if (sSoundMovesTable[i] != 0xFFFF)
{ {
if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_MULTIPLETURNS) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)
gHitMarker |= HITMARKER_NO_PPDEDUCT; gHitMarker |= HITMARKER_NO_PPDEDUCT;
gBattlescriptCurrInstr = BattleScript_SoundproofProtected; gBattlescriptCurrInstr = BattleScript_SoundproofProtected;
effect = 1; effect = 1;
@ -1991,7 +1991,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
case ABILITY_VOLT_ABSORB: case ABILITY_VOLT_ABSORB:
if (moveType == TYPE_ELECTRIC && gBattleMoves[move].power != 0) if (moveType == TYPE_ELECTRIC && gBattleMoves[move].power != 0)
{ {
if (gProtectStructs[gBattleMoveAttacker].notFirstStrike) if (gProtectStructs[gBattlerAttacker].notFirstStrike)
gBattlescriptCurrInstr = BattleScript_MoveHPDrain; gBattlescriptCurrInstr = BattleScript_MoveHPDrain;
else else
gBattlescriptCurrInstr = BattleScript_MoveHPDrain_PPLoss; gBattlescriptCurrInstr = BattleScript_MoveHPDrain_PPLoss;
@ -2002,7 +2002,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
case ABILITY_WATER_ABSORB: case ABILITY_WATER_ABSORB:
if (moveType == TYPE_WATER && gBattleMoves[move].power != 0) if (moveType == TYPE_WATER && gBattleMoves[move].power != 0)
{ {
if (gProtectStructs[gBattleMoveAttacker].notFirstStrike) if (gProtectStructs[gBattlerAttacker].notFirstStrike)
gBattlescriptCurrInstr = BattleScript_MoveHPDrain; gBattlescriptCurrInstr = BattleScript_MoveHPDrain;
else else
gBattlescriptCurrInstr = BattleScript_MoveHPDrain_PPLoss; gBattlescriptCurrInstr = BattleScript_MoveHPDrain_PPLoss;
@ -2016,7 +2016,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gBattleResources->flags->flags[battler] & UNKNOWN_FLAG_FLASH_FIRE)) if (!(gBattleResources->flags->flags[battler] & UNKNOWN_FLAG_FLASH_FIRE))
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 0;
if (gProtectStructs[gBattleMoveAttacker].notFirstStrike) if (gProtectStructs[gBattlerAttacker].notFirstStrike)
gBattlescriptCurrInstr = BattleScript_FlashFireBoost; gBattlescriptCurrInstr = BattleScript_FlashFireBoost;
else else
gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss; gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss;
@ -2027,7 +2027,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
else else
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 1;
if (gProtectStructs[gBattleMoveAttacker].notFirstStrike) if (gProtectStructs[gBattlerAttacker].notFirstStrike)
gBattlescriptCurrInstr = BattleScript_FlashFireBoost; gBattlescriptCurrInstr = BattleScript_FlashFireBoost;
else else
gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss; gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss;
@ -2041,7 +2041,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
{ {
if (gBattleMons[battler].maxHP == gBattleMons[battler].hp) if (gBattleMons[battler].maxHP == gBattleMons[battler].hp)
{ {
if ((gProtectStructs[gBattleMoveAttacker].notFirstStrike)) if ((gProtectStructs[gBattlerAttacker].notFirstStrike))
gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless; gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless;
else else
gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless_PPLoss; gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless_PPLoss;
@ -2063,7 +2063,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& move != MOVE_STRUGGLE && move != MOVE_STRUGGLE
&& gBattleMoves[move].power != 0 && gBattleMoves[move].power != 0
&& (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special)
&& gBattleMons[battler].type1 != moveType && gBattleMons[battler].type1 != moveType
&& gBattleMons[battler].type2 != moveType && gBattleMons[battler].type2 != moveType
&& gBattleMons[battler].hp != 0) && gBattleMons[battler].hp != 0)
@ -2078,12 +2078,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
break; break;
case ABILITY_ROUGH_SKIN: case ABILITY_ROUGH_SKIN:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattleMoveAttacker].hp != 0 && gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special)
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT))
{ {
gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].maxHP / 16; gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16;
if (gBattleMoveDamage == 0) if (gBattleMoveDamage == 0)
gBattleMoveDamage = 1; gBattleMoveDamage = 1;
BattleScriptPushCursor(); BattleScriptPushCursor();
@ -2093,9 +2093,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
break; break;
case ABILITY_EFFECT_SPORE: case ABILITY_EFFECT_SPORE:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattleMoveAttacker].hp != 0 && gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special)
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (Random() % 10) == 0) && (Random() % 10) == 0)
{ {
@ -2116,9 +2116,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
break; break;
case ABILITY_POISON_POINT: case ABILITY_POISON_POINT:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattleMoveAttacker].hp != 0 && gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special)
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (Random() % 3) == 0) && (Random() % 3) == 0)
{ {
@ -2131,9 +2131,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
break; break;
case ABILITY_STATIC: case ABILITY_STATIC:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattleMoveAttacker].hp != 0 && gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special)
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (Random() % 3) == 0) && (Random() % 3) == 0)
{ {
@ -2146,10 +2146,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
break; break;
case ABILITY_FLAME_BODY: case ABILITY_FLAME_BODY:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattleMoveAttacker].hp != 0 && gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special)
&& (Random() % 3) == 0) && (Random() % 3) == 0)
{ {
gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_BURN; gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_BURN;
@ -2161,19 +2161,19 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
break; break;
case ABILITY_CUTE_CHARM: case ABILITY_CUTE_CHARM:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gBattleMons[gBattleMoveAttacker].hp != 0 && gBattleMons[gBattlerAttacker].hp != 0
&& !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg && !gProtectStructs[gBattlerAttacker].confusionSelfDmg
&& (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)
&& (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special)
&& gBattleMons[gBattleMoveTarget].hp != 0 && gBattleMons[gBattlerTarget].hp != 0
&& (Random() % 3) == 0 && (Random() % 3) == 0
&& gBattleMons[gBattleMoveAttacker].ability != ABILITY_OBLIVIOUS && gBattleMons[gBattlerAttacker].ability != ABILITY_OBLIVIOUS
&& GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != GetGenderFromSpeciesAndPersonality(speciesDef, pidDef)
&& !(gBattleMons[gBattleMoveAttacker].status2 & STATUS2_INFATUATION) && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_INFATUATION)
&& GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != MON_GENDERLESS && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != MON_GENDERLESS
&& GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) != MON_GENDERLESS) && GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) != MON_GENDERLESS)
{ {
gBattleMons[gBattleMoveAttacker].status2 |= STATUS2_INFATUATED_WITH(gBattleMoveTarget); gBattleMons[gBattlerAttacker].status2 |= STATUS2_INFATUATED_WITH(gBattlerTarget);
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_CuteCharmActivates; gBattlescriptCurrInstr = BattleScript_CuteCharmActivates;
effect++; effect++;
@ -2288,7 +2288,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON; gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON;
gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleStruct->synchronizeMoveEffect + MOVE_EFFECT_AFFECTS_USER; gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleStruct->synchronizeMoveEffect + MOVE_EFFECT_AFFECTS_USER;
gBattleScripting.battler = gBattleMoveTarget; gBattleScripting.battler = gBattlerTarget;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; gBattlescriptCurrInstr = BattleScript_SynchronizeActivates;
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
@ -2304,7 +2304,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON; gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON;
gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleStruct->synchronizeMoveEffect; gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleStruct->synchronizeMoveEffect;
gBattleScripting.battler = gBattleMoveAttacker; gBattleScripting.battler = gBattlerAttacker;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; gBattlescriptCurrInstr = BattleScript_SynchronizeActivates;
gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD;
@ -2512,7 +2512,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
void BattleScriptExecute(const u8 *BS_ptr) void BattleScriptExecute(const u8 *BS_ptr)
{ {
gBattlescriptCurrInstr = BS_ptr; gBattlescriptCurrInstr = BS_ptr;
BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size++] = gBattleMainFunc; gBattleResources->battleCallbackStack->function[gBattleResources->battleCallbackStack->size++] = gBattleMainFunc;
gBattleMainFunc = RunBattleScriptCommands_PopCallbacksStack; gBattleMainFunc = RunBattleScriptCommands_PopCallbacksStack;
gCurrentActionFuncId = 0; gCurrentActionFuncId = 0;
} }
@ -2521,7 +2521,7 @@ void BattleScriptPushCursorAndCallback(const u8 *BS_ptr)
{ {
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BS_ptr; gBattlescriptCurrInstr = BS_ptr;
BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size++] = gBattleMainFunc; gBattleResources->battleCallbackStack->function[gBattleResources->battleCallbackStack->size++] = gBattleMainFunc;
gBattleMainFunc = RunBattleScriptCommands; gBattleMainFunc = RunBattleScriptCommands;
} }
@ -2556,11 +2556,11 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
bankQuality = ItemId_GetHoldEffectParam(gLastUsedItem); bankQuality = ItemId_GetHoldEffectParam(gLastUsedItem);
} }
atkItem = gBattleMons[gBattleMoveAttacker].item; atkItem = gBattleMons[gBattlerAttacker].item;
if (atkItem == ITEM_ENIGMA_BERRY) if (atkItem == ITEM_ENIGMA_BERRY)
{ {
atkHoldEffect = gEnigmaBerries[gBattleMoveAttacker].holdEffect; atkHoldEffect = gEnigmaBerries[gBattlerAttacker].holdEffect;
atkQuality = gEnigmaBerries[gBattleMoveAttacker].holdEffectParam; atkQuality = gEnigmaBerries[gBattlerAttacker].holdEffectParam;
} }
else else
{ {
@ -2569,11 +2569,11 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
} }
// def variables are unused // def variables are unused
defItem = gBattleMons[gBattleMoveTarget].item; defItem = gBattleMons[gBattlerTarget].item;
if (defItem == ITEM_ENIGMA_BERRY) if (defItem == ITEM_ENIGMA_BERRY)
{ {
defHoldEffect = gEnigmaBerries[gBattleMoveTarget].holdEffect; defHoldEffect = gEnigmaBerries[gBattlerTarget].holdEffect;
defQuality = gEnigmaBerries[gBattleMoveTarget].holdEffectParam; defQuality = gEnigmaBerries[gBattlerTarget].holdEffectParam;
} }
else else
{ {
@ -2602,8 +2602,8 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
if (effect) if (effect)
{ {
gBattleScripting.battler = bank; gBattleScripting.battler = bank;
gStringBank = bank; gStringBattler = bank;
gActiveBattler = gBattleMoveAttacker = bank; gActiveBattler = gBattlerAttacker = bank;
BattleScriptExecute(BattleScript_WhiteHerbEnd2); BattleScriptExecute(BattleScript_WhiteHerbEnd2);
} }
break; break;
@ -2673,8 +2673,8 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
if (effect) if (effect)
{ {
gBattleScripting.battler = bank; gBattleScripting.battler = bank;
gStringBank = bank; gStringBattler = bank;
gActiveBattler = gBattleMoveAttacker = bank; gActiveBattler = gBattlerAttacker = bank;
BattleScriptExecute(BattleScript_WhiteHerbEnd2); BattleScriptExecute(BattleScript_WhiteHerbEnd2);
} }
break; break;
@ -3001,8 +3001,8 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
if (effect) if (effect)
{ {
gBattleScripting.battler = bank; gBattleScripting.battler = bank;
gStringBank = bank; gStringBattler = bank;
gActiveBattler = gBattleMoveAttacker = bank; gActiveBattler = gBattlerAttacker = bank;
switch (effect) switch (effect)
{ {
case ITEM_STATUS_CHANGE: case ITEM_STATUS_CHANGE:
@ -3149,7 +3149,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
if (effect) if (effect)
{ {
gBattleScripting.battler = bank; gBattleScripting.battler = bank;
gStringBank = bank; gStringBattler = bank;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_WhiteHerbRet; gBattlescriptCurrInstr = BattleScript_WhiteHerbRet;
return effect; // unnecessary return return effect; // unnecessary return
@ -3159,7 +3159,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
if (effect) if (effect)
{ {
gBattleScripting.battler = bank; gBattleScripting.battler = bank;
gStringBank = bank; gStringBattler = bank;
gActiveBattler = bank; gActiveBattler = bank;
BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1);
MarkBattlerForControllerExec(gActiveBattler); MarkBattlerForControllerExec(gActiveBattler);
@ -3174,10 +3174,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
{ {
case HOLD_EFFECT_FLINCH: case HOLD_EFFECT_FLINCH:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special)
&& (Random() % 100) < atkQuality && (Random() % 100) < atkQuality
&& gBattleMoves[gCurrentMove].flags & FLAG_KINGSROCK_AFFECTED && gBattleMoves[gCurrentMove].flags & FLAG_KINGSROCK_AFFECTED
&& gBattleMons[gBattleMoveTarget].hp) && gBattleMons[gBattlerTarget].hp)
{ {
gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_FLINCH; gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_FLINCH;
BattleScriptPushCursor(); BattleScriptPushCursor();
@ -3187,19 +3187,19 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn)
break; break;
case HOLD_EFFECT_SHELL_BELL: case HOLD_EFFECT_SHELL_BELL:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gSpecialStatuses[gBattleMoveTarget].moveturnLostHP != 0 && gSpecialStatuses[gBattlerTarget].moveturnLostHP != 0
&& gSpecialStatuses[gBattleMoveTarget].moveturnLostHP != 0xFFFF && gSpecialStatuses[gBattlerTarget].moveturnLostHP != 0xFFFF
&& gBattleMoveAttacker != gBattleMoveTarget && gBattlerAttacker != gBattlerTarget
&& gBattleMons[gBattleMoveAttacker].hp != gBattleMons[gBattleMoveAttacker].maxHP && gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP
&& gBattleMons[gBattleMoveAttacker].hp != 0) && gBattleMons[gBattlerAttacker].hp != 0)
{ {
gLastUsedItem = atkItem; gLastUsedItem = atkItem;
gStringBank = gBattleMoveAttacker; gStringBattler = gBattlerAttacker;
gBattleScripting.battler = gBattleMoveAttacker; gBattleScripting.battler = gBattlerAttacker;
gBattleMoveDamage = (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP / atkQuality) * -1; gBattleMoveDamage = (gSpecialStatuses[gBattlerTarget].moveturnLostHP / atkQuality) * -1;
if (gBattleMoveDamage == 0) if (gBattleMoveDamage == 0)
gBattleMoveDamage = -1; gBattleMoveDamage = -1;
gSpecialStatuses[gBattleMoveTarget].moveturnLostHP = 0; gSpecialStatuses[gBattlerTarget].moveturnLostHP = 0;
BattleScriptPushCursor(); BattleScriptPushCursor();
gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret; gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret;
effect++; effect++;
@ -3240,18 +3240,18 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget)
switch (moveTarget) switch (moveTarget)
{ {
case MOVE_TARGET_SELECTED: case MOVE_TARGET_SELECTED:
side = GetBattlerSide(gBattleMoveAttacker) ^ BIT_SIDE; side = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE;
if (gSideTimers[side].followmeTimer && gBattleMons[gSideTimers[side].followmeTarget].hp) if (gSideTimers[side].followmeTimer && gBattleMons[gSideTimers[side].followmeTarget].hp)
targetBank = gSideTimers[side].followmeTarget; targetBank = gSideTimers[side].followmeTarget;
else else
{ {
side = GetBattlerSide(gBattleMoveAttacker); side = GetBattlerSide(gBattlerAttacker);
do do
{ {
targetBank = Random() % gBattlersCount; targetBank = Random() % gBattlersCount;
} while (targetBank == gBattleMoveAttacker || side == GetBattlerSide(targetBank) || gAbsentBattlerFlags & gBitTable[targetBank]); } while (targetBank == gBattlerAttacker || side == GetBattlerSide(targetBank) || gAbsentBattlerFlags & gBitTable[targetBank]);
if (gBattleMoves[move].type == TYPE_ELECTRIC if (gBattleMoves[move].type == TYPE_ELECTRIC
&& AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBattleMoveAttacker, ABILITY_LIGHTNING_ROD, 0, 0) && AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBattlerAttacker, ABILITY_LIGHTNING_ROD, 0, 0)
&& gBattleMons[targetBank].ability != ABILITY_LIGHTNING_ROD) && gBattleMons[targetBank].ability != ABILITY_LIGHTNING_ROD)
{ {
targetBank ^= BIT_FLANK; targetBank ^= BIT_FLANK;
@ -3264,17 +3264,17 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget)
case MOVE_TARGET_BOTH: case MOVE_TARGET_BOTH:
case MOVE_TARGET_FOES_AND_ALLY: case MOVE_TARGET_FOES_AND_ALLY:
case MOVE_TARGET_OPPONENTS_FIELD: case MOVE_TARGET_OPPONENTS_FIELD:
targetBank = GetBattlerAtPosition((GetBattlerPosition(gBattleMoveAttacker) & BIT_SIDE) ^ BIT_SIDE); targetBank = GetBattlerAtPosition((GetBattlerPosition(gBattlerAttacker) & BIT_SIDE) ^ BIT_SIDE);
if (gAbsentBattlerFlags & gBitTable[targetBank]) if (gAbsentBattlerFlags & gBitTable[targetBank])
targetBank ^= BIT_FLANK; targetBank ^= BIT_FLANK;
break; break;
case MOVE_TARGET_RANDOM: case MOVE_TARGET_RANDOM:
side = GetBattlerSide(gBattleMoveAttacker) ^ BIT_SIDE; side = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE;
if (gSideTimers[side].followmeTimer && gBattleMons[gSideTimers[side].followmeTarget].hp) if (gSideTimers[side].followmeTimer && gBattleMons[gSideTimers[side].followmeTarget].hp)
targetBank = gSideTimers[side].followmeTarget; targetBank = gSideTimers[side].followmeTarget;
else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && moveTarget & MOVE_TARGET_RANDOM) else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && moveTarget & MOVE_TARGET_RANDOM)
{ {
if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER)
{ {
if (Random() & 1) if (Random() & 1)
targetBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); targetBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
@ -3292,15 +3292,15 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget)
targetBank ^= BIT_FLANK; targetBank ^= BIT_FLANK;
} }
else else
targetBank = GetBattlerAtPosition((GetBattlerPosition(gBattleMoveAttacker) & BIT_SIDE) ^ BIT_SIDE); targetBank = GetBattlerAtPosition((GetBattlerPosition(gBattlerAttacker) & BIT_SIDE) ^ BIT_SIDE);
break; break;
case MOVE_TARGET_USER: case MOVE_TARGET_USER:
case MOVE_TARGET_x10: case MOVE_TARGET_x10:
targetBank = gBattleMoveAttacker; targetBank = gBattlerAttacker;
break; break;
} }
*(gBattleStruct->moveTarget + gBattleMoveAttacker) = targetBank; *(gBattleStruct->moveTarget + gBattlerAttacker) = targetBank;
return targetBank; return targetBank;
} }
@ -3323,18 +3323,18 @@ u8 IsMonDisobedient(void)
if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))
return 0; return 0;
if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_OPPONENT) if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT)
return 0; return 0;
if (HasObedientBitSet(gBattleMoveAttacker)) // only if species is Mew or Deoxys if (HasObedientBitSet(gBattlerAttacker)) // only if species is Mew or Deoxys
{ {
if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattleMoveAttacker) == 2) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattlerAttacker) == 2)
return 0; return 0;
if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER)
return 0; return 0;
if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED)
return 0; return 0;
if (!IsOtherTrainer(gBattleMons[gBattleMoveAttacker].otId, gBattleMons[gBattleMoveAttacker].otName)) if (!IsOtherTrainer(gBattleMons[gBattlerAttacker].otId, gBattleMons[gBattlerAttacker].otName))
return 0; return 0;
if (FlagGet(FLAG_BADGE08_GET)) if (FlagGet(FLAG_BADGE08_GET))
return 0; return 0;
@ -3349,27 +3349,27 @@ u8 IsMonDisobedient(void)
obedienceLevel = 70; obedienceLevel = 70;
} }
if (gBattleMons[gBattleMoveAttacker].level <= obedienceLevel) if (gBattleMons[gBattlerAttacker].level <= obedienceLevel)
return 0; return 0;
rnd = (Random() & 255); rnd = (Random() & 255);
calc = (gBattleMons[gBattleMoveAttacker].level + obedienceLevel) * rnd >> 8; calc = (gBattleMons[gBattlerAttacker].level + obedienceLevel) * rnd >> 8;
if (calc < obedienceLevel) if (calc < obedienceLevel)
return 0; return 0;
// is not obedient // is not obedient
if (gCurrentMove == MOVE_RAGE) if (gCurrentMove == MOVE_RAGE)
gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_RAGE); gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_RAGE);
if (gBattleMons[gBattleMoveAttacker].status1 & STATUS1_SLEEP && (gCurrentMove == MOVE_SNORE || gCurrentMove == MOVE_SLEEP_TALK)) if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP && (gCurrentMove == MOVE_SNORE || gCurrentMove == MOVE_SLEEP_TALK))
{ {
gBattlescriptCurrInstr = BattleScript_82DB695; gBattlescriptCurrInstr = BattleScript_82DB695;
return 1; return 1;
} }
rnd = (Random() & 255); rnd = (Random() & 255);
calc = (gBattleMons[gBattleMoveAttacker].level + obedienceLevel) * rnd >> 8; calc = (gBattleMons[gBattlerAttacker].level + obedienceLevel) * rnd >> 8;
if (calc < obedienceLevel) if (calc < obedienceLevel)
{ {
calc = CheckMoveLimitations(gBattleMoveAttacker, gBitTable[gCurrMovePos], 0xFF); calc = CheckMoveLimitations(gBattlerAttacker, gBitTable[gCurrMovePos], 0xFF);
if (calc == 0xF) // all moves cannot be used if (calc == 0xF) // all moves cannot be used
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3; gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3;
@ -3383,19 +3383,19 @@ u8 IsMonDisobedient(void)
gCurrMovePos = gUnknown_020241E9 = Random() & 3; gCurrMovePos = gUnknown_020241E9 = Random() & 3;
} while (gBitTable[gCurrMovePos] & calc); } while (gBitTable[gCurrMovePos] & calc);
gRandomMove = gBattleMons[gBattleMoveAttacker].moves[gCurrMovePos]; gRandomMove = gBattleMons[gBattlerAttacker].moves[gCurrMovePos];
gBattlescriptCurrInstr = BattleScript_IgnoresAndUsesRandomMove; gBattlescriptCurrInstr = BattleScript_IgnoresAndUsesRandomMove;
gBattleMoveTarget = GetMoveTarget(gRandomMove, 0); gBattlerTarget = GetMoveTarget(gRandomMove, 0);
gHitMarker |= HITMARKER_x200000; gHitMarker |= HITMARKER_x200000;
return 2; return 2;
} }
} }
else else
{ {
obedienceLevel = gBattleMons[gBattleMoveAttacker].level - obedienceLevel; obedienceLevel = gBattleMons[gBattlerAttacker].level - obedienceLevel;
calc = (Random() & 255); calc = (Random() & 255);
if (calc < obedienceLevel && !(gBattleMons[gBattleMoveAttacker].status1 & STATUS1_ANY) && gBattleMons[gBattleMoveAttacker].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gBattleMoveAttacker].ability != ABILITY_INSOMNIA) if (calc < obedienceLevel && !(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY) && gBattleMons[gBattlerAttacker].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gBattlerAttacker].ability != ABILITY_INSOMNIA)
{ {
// try putting asleep // try putting asleep
int i; int i;
@ -3413,8 +3413,8 @@ u8 IsMonDisobedient(void)
calc -= obedienceLevel; calc -= obedienceLevel;
if (calc < obedienceLevel) if (calc < obedienceLevel)
{ {
gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattleMoveAttacker], &gBattleMons[gBattleMoveAttacker], MOVE_POUND, 0, 40, 0, gBattleMoveAttacker, gBattleMoveAttacker); gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerAttacker], MOVE_POUND, 0, 40, 0, gBattlerAttacker, gBattlerAttacker);
gBattleMoveTarget = gBattleMoveAttacker; gBattlerTarget = gBattlerAttacker;
gBattlescriptCurrInstr = BattleScript_82DB6F0; gBattlescriptCurrInstr = BattleScript_82DB6F0;
gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE;
return 2; return 2;

View File

@ -17,7 +17,7 @@
extern bool8 gDoingBattleAnim; extern bool8 gDoingBattleAnim;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u16 gBattlerPartyIndexes[]; extern u16 gBattlerPartyIndexes[];
extern u8 gBattlerSpriteIds[]; extern u8 gBattlerSpriteIds[];
extern u8 gHealthboxSpriteIds[]; extern u8 gHealthboxSpriteIds[];
@ -378,7 +378,7 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
switch (throwCaseId) switch (throwCaseId)
{ {
case POKEBALL_PLAYER_SENDOUT: case POKEBALL_PLAYER_SENDOUT:
gBattleMoveTarget = bank; gBattlerTarget = bank;
gSprites[ballSpriteId].pos1.x = 24; gSprites[ballSpriteId].pos1.x = 24;
gSprites[ballSpriteId].pos1.y = 68; gSprites[ballSpriteId].pos1.y = 68;
gSprites[ballSpriteId].callback = SpriteCB_PlayerMonSendOut_1; gSprites[ballSpriteId].callback = SpriteCB_PlayerMonSendOut_1;
@ -386,17 +386,17 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
case POKEBALL_OPPONENT_SENDOUT: case POKEBALL_OPPONENT_SENDOUT:
gSprites[ballSpriteId].pos1.x = GetBattlerSpriteCoord(bank, BANK_X_POS); gSprites[ballSpriteId].pos1.x = GetBattlerSpriteCoord(bank, BANK_X_POS);
gSprites[ballSpriteId].pos1.y = GetBattlerSpriteCoord(bank, BANK_Y_POS) + 24; gSprites[ballSpriteId].pos1.y = GetBattlerSpriteCoord(bank, BANK_Y_POS) + 24;
gBattleMoveTarget = bank; gBattlerTarget = bank;
gSprites[ballSpriteId].data[0] = 0; gSprites[ballSpriteId].data[0] = 0;
gSprites[ballSpriteId].callback = SpriteCB_OpponentMonSendOut; gSprites[ballSpriteId].callback = SpriteCB_OpponentMonSendOut;
break; break;
default: default:
gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT);
notSendOut = TRUE; notSendOut = TRUE;
break; break;
} }
gSprites[ballSpriteId].sBank = gBattleMoveTarget; gSprites[ballSpriteId].sBank = gBattlerTarget;
if (!notSendOut) if (!notSendOut)
{ {
DestroyTask(taskId); DestroyTask(taskId);
@ -405,12 +405,12 @@ static void Task_DoPokeballSendOutAnim(u8 taskId)
// this will perform an unused ball throw animation // this will perform an unused ball throw animation
gSprites[ballSpriteId].data[0] = 0x22; gSprites[ballSpriteId].data[0] = 0x22;
gSprites[ballSpriteId].data[2] = GetBattlerSpriteCoord(gBattleMoveTarget, BANK_X_POS); gSprites[ballSpriteId].data[2] = GetBattlerSpriteCoord(gBattlerTarget, BANK_X_POS);
gSprites[ballSpriteId].data[4] = GetBattlerSpriteCoord(gBattleMoveTarget, BANK_Y_POS) - 16; gSprites[ballSpriteId].data[4] = GetBattlerSpriteCoord(gBattlerTarget, BANK_Y_POS) - 16;
gSprites[ballSpriteId].data[5] = -40; gSprites[ballSpriteId].data[5] = -40;
sub_80A68D4(&gSprites[ballSpriteId]); sub_80A68D4(&gSprites[ballSpriteId]);
gSprites[ballSpriteId].oam.affineParam = taskId; gSprites[ballSpriteId].oam.affineParam = taskId;
gTasks[taskId].tOpponentBank = gBattleMoveTarget; gTasks[taskId].tOpponentBank = gBattlerTarget;
gTasks[taskId].func = TaskDummy; gTasks[taskId].func = TaskDummy;
PlaySE(SE_NAGERU); PlaySE(SE_NAGERU);
} }

View File

@ -16,8 +16,8 @@ struct Unknown_020249B4
extern u8 gAbsentBattlerFlags; extern u8 gAbsentBattlerFlags;
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBattleMoveAttacker; extern u8 gBattlerAttacker;
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gLastUsedAbility; extern u8 gLastUsedAbility;
extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_A;
extern u32 gBattleTypeFlags; extern u32 gBattleTypeFlags;
@ -55,14 +55,14 @@ u8 CountAliveMonsInBattle(u8 caseId)
case BATTLE_ALIVE_ATK_SIDE: case BATTLE_ALIVE_ATK_SIDE:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (GetBattlerSide(i) == GetBattlerSide(gBattleMoveAttacker) && !(gAbsentBattlerFlags & gBitTable[i])) if (GetBattlerSide(i) == GetBattlerSide(gBattlerAttacker) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++; retVal++;
} }
break; break;
case BATTLE_ALIVE_DEF_SIDE: case BATTLE_ALIVE_DEF_SIDE:
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (GetBattlerSide(i) == GetBattlerSide(gBattleMoveTarget) && !(gAbsentBattlerFlags & gBitTable[i])) if (GetBattlerSide(i) == GetBattlerSide(gBattlerTarget) && !(gAbsentBattlerFlags & gBitTable[i]))
retVal++; retVal++;
} }
break; break;

View File

@ -27,9 +27,9 @@ extern struct BattlePokemon gBattleMons[4];
extern struct BattleEnigmaBerry gEnigmaBerries[4]; extern struct BattleEnigmaBerry gEnigmaBerries[4];
extern u8 gActiveBattler; extern u8 gActiveBattler;
extern u8 gBankInMenu; extern u8 gBankInMenu;
extern u8 gBattleMoveTarget; extern u8 gBattlerTarget;
extern u8 gBattleMoveAttacker; extern u8 gBattlerAttacker;
extern u8 gStringBank; extern u8 gStringBattler;
extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_A;
extern u32 gBattleTypeFlags; extern u32 gBattleTypeFlags;
extern u8 gBattleMonForms[4]; extern u8 gBattleMonForms[4];
@ -210,7 +210,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit)
void sub_806CF24(s32 stat) void sub_806CF24(s32 stat)
{ {
gBattleMoveTarget = gBankInMenu; gBattlerTarget = gBankInMenu;
StringCopy(gBattleTextBuff1, gStatNamesTable[gUnknown_08329EC8[stat]]); StringCopy(gBattleTextBuff1, gStatNamesTable[gUnknown_08329EC8[stat]]);
StringCopy(gBattleTextBuff2, gText_StatRose); StringCopy(gBattleTextBuff2, gText_StatRose);
BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnsStatChanged2); BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnsStatChanged2);
@ -233,7 +233,7 @@ u8 *sub_806CF78(u16 itemId)
itemEffect = gItemEffectTable[itemId - 13]; itemEffect = gItemEffectTable[itemId - 13];
} }
gStringBank = gBankInMenu; gStringBattler = gBankInMenu;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
@ -247,7 +247,7 @@ u8 *sub_806CF78(u16 itemId)
} }
else else
{ {
gBattleMoveAttacker = gBankInMenu; gBattlerAttacker = gBankInMenu;
BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnGettingPumped); BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnGettingPumped);
} }
} }
@ -255,7 +255,7 @@ u8 *sub_806CF78(u16 itemId)
if (itemEffect[3] & 0x80) if (itemEffect[3] & 0x80)
{ {
gBattleMoveAttacker = gBankInMenu; gBattlerAttacker = gBankInMenu;
BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnShroudedInMist); BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnShroudedInMist);
} }

View File

@ -29,7 +29,7 @@ extern u8 gActiveBattler;
extern u8 gBattlersCount; extern u8 gBattlersCount;
extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT]; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT];
extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT];
extern u16 gChosenMovesByBanks[MAX_BATTLERS_COUNT]; extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT];
extern u8 gUnknown_03001278; extern u8 gUnknown_03001278;
extern u8 gUnknown_03001279; extern u8 gUnknown_03001279;
@ -221,7 +221,7 @@ void RecordedBattle_ClearBattlerAction(u8 bank, u8 bytesToClear)
} }
} }
u8 RecordedBattle_GetBankAction(u8 bank) u8 RecordedBattle_GetBattlerAction(u8 bank)
{ {
// trying to read past array or invalid action byte, battle is over // trying to read past array or invalid action byte, battle is over
if (sRecordedBytesNo[bank] >= BANK_RECORD_SIZE || sBattleRecords[bank][sRecordedBytesNo[bank]] == 0xFF) if (sRecordedBytesNo[bank] >= BANK_RECORD_SIZE || sBattleRecords[bank][sRecordedBytesNo[bank]] == 0xFF)
@ -1561,14 +1561,14 @@ void sub_818603C(u8 arg0)
u8 array3[8]; u8 array3[8];
u8 var; u8 var;
RecordedBattle_GetBankAction(bank); RecordedBattle_GetBattlerAction(bank);
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
ppBonuses[j] = ((gBattleMons[bank].ppBonuses & ((3 << (j << 1)))) >> (j << 1)); ppBonuses[j] = ((gBattleMons[bank].ppBonuses & ((3 << (j << 1)))) >> (j << 1));
} }
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
array1[j] = RecordedBattle_GetBankAction(bank); array1[j] = RecordedBattle_GetBattlerAction(bank);
movePp.moves[j] = gBattleMons[bank].moves[array1[j]]; movePp.moves[j] = gBattleMons[bank].moves[array1[j]];
movePp.pp[j] = gBattleMons[bank].pp[array1[j]]; movePp.pp[j] = gBattleMons[bank].pp[array1[j]];
array3[j] = ppBonuses[array1[j]]; array3[j] = ppBonuses[array1[j]];
@ -1612,7 +1612,7 @@ void sub_818603C(u8 arg0)
SetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_PP_BONUSES, &var); SetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_PP_BONUSES, &var);
} }
gChosenMovesByBanks[bank] = gBattleMons[bank].moves[*(gBattleStruct->chosenMovePositions + bank)]; gChosenMoveByBattler[bank] = gBattleMons[bank].moves[*(gBattleStruct->chosenMovePositions + bank)];
} }
} }
} }

View File

@ -46,8 +46,8 @@ extern u8 GetBattlerSpriteCoord(u8 bank, u8 caseId);
// this file's functions // this file's functions
static void CB2_ReshowBattleScreenAfterMenu(void); static void CB2_ReshowBattleScreenAfterMenu(void);
static bool8 LoadBankSpriteGfx(u8 bank); static bool8 LoadBattlerSpriteGfx(u8 bank);
static void CreateBankSprite(u8 bank); static void CreateBattlerSprite(u8 bank);
static void CreateHealthboxSprite(u8 bank); static void CreateHealthboxSprite(u8 bank);
static void sub_80A95F4(void); static void sub_80A95F4(void);
@ -118,32 +118,32 @@ static void CB2_ReshowBattleScreenAfterMenu(void)
} }
break; break;
case 7: case 7:
if (!LoadBankSpriteGfx(0)) if (!LoadBattlerSpriteGfx(0))
gBattleScripting.reshowMainState--; gBattleScripting.reshowMainState--;
break; break;
case 8: case 8:
if (!LoadBankSpriteGfx(1)) if (!LoadBattlerSpriteGfx(1))
gBattleScripting.reshowMainState--; gBattleScripting.reshowMainState--;
break; break;
case 9: case 9:
if (!LoadBankSpriteGfx(2)) if (!LoadBattlerSpriteGfx(2))
gBattleScripting.reshowMainState--; gBattleScripting.reshowMainState--;
break; break;
case 10: case 10:
if (!LoadBankSpriteGfx(3)) if (!LoadBattlerSpriteGfx(3))
gBattleScripting.reshowMainState--; gBattleScripting.reshowMainState--;
break; break;
case 11: case 11:
CreateBankSprite(0); CreateBattlerSprite(0);
break; break;
case 12: case 12:
CreateBankSprite(1); CreateBattlerSprite(1);
break; break;
case 13: case 13:
CreateBankSprite(2); CreateBattlerSprite(2);
break; break;
case 14: case 14:
CreateBankSprite(3); CreateBattlerSprite(3);
break; break;
case 15: case 15:
CreateHealthboxSprite(0); CreateHealthboxSprite(0);
@ -208,25 +208,25 @@ static void sub_80A95F4(void)
regBgcnt2->charBaseBlock = 0; regBgcnt2->charBaseBlock = 0;
} }
static bool8 LoadBankSpriteGfx(u8 bank) static bool8 LoadBattlerSpriteGfx(u8 battler)
{ {
if (bank < gBattlersCount) if (battler < gBattlersCount)
{ {
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(battler) != B_SIDE_PLAYER)
{ {
if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute) if (!gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battler]], battler);
else else
BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE); BattleLoadSubstituteOrMonSpriteGfx(battler, FALSE);
} }
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0)
DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, bank); DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, battler);
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0)
DecompressTrainerBackPic(BACK_PIC_WALLY, bank); DecompressTrainerBackPic(BACK_PIC_WALLY, battler);
else if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute) else if (!gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[bank]], bank); BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battler]], battler);
else else
BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE); BattleLoadSubstituteOrMonSpriteGfx(battler, FALSE);
gBattleScripting.reshowHelperState = 0; gBattleScripting.reshowHelperState = 0;
} }
@ -243,111 +243,111 @@ struct MonCoords
}; };
extern const struct MonCoords gTrainerBackPicCoords[]; extern const struct MonCoords gTrainerBackPicCoords[];
static void CreateBankSprite(u8 bank) static void CreateBattlerSprite(u8 battler)
{ {
if (bank < gBattlersCount) if (battler < gBattlersCount)
{ {
u8 posY; u8 posY;
if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute) if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute)
posY = GetSubstituteSpriteDefault_Y(bank); posY = GetSubstituteSpriteDefault_Y(battler);
else else
posY = GetBattlerSpriteDefault_Y(bank); posY = GetBattlerSpriteDefault_Y(battler);
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(battler) != B_SIDE_PLAYER)
{ {
if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
return; return;
sub_806A068(GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); sub_806A068(GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler));
gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(bank, 2), posY, sub_80A82E4(bank)); gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(battler, 2), posY, sub_80A82E4(battler));
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
gSprites[gBattlerSpriteIds[bank]].data[2] = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES); gSprites[gBattlerSpriteIds[battler]].data[2] = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], gBattleMonForms[battler]);
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_CASTFORM) if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies == SPECIES_CASTFORM)
gSprites[gBattlerSpriteIds[bank]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM]; gSprites[gBattlerSpriteIds[battler]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM];
} }
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0)
{ {
sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT)); sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT));
gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50, gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, 0x50,
(8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80, (8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80,
sub_80A82E4(0)); sub_80A82E4(0));
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
} }
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0)
{ {
sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(0)); sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(0));
gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50, gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, 0x50,
(8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords) * 4 + 80, (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords) * 4 + 80,
sub_80A82E4(0)); sub_80A82E4(0));
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
} }
else else
{ {
if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
return; return;
sub_806A068(GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); sub_806A068(GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler));
gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(bank, 2), posY, sub_80A82E4(bank)); gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(battler, 2), posY, sub_80A82E4(battler));
gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler;
gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy;
gSprites[gBattlerSpriteIds[bank]].data[0] = bank; gSprites[gBattlerSpriteIds[battler]].data[0] = battler;
gSprites[gBattlerSpriteIds[bank]].data[2] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES); gSprites[gBattlerSpriteIds[battler]].data[2] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES);
StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]); StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], gBattleMonForms[battler]);
if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_CASTFORM) if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies == SPECIES_CASTFORM)
gSprites[gBattlerSpriteIds[bank]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM]; gSprites[gBattlerSpriteIds[battler]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM];
} }
gSprites[gBattlerSpriteIds[bank]].invisible = gBattleSpritesDataPtr->bankData[bank].invisible; gSprites[gBattlerSpriteIds[battler]].invisible = gBattleSpritesDataPtr->battlerData[battler].invisible;
} }
} }
static void CreateHealthboxSprite(u8 bank) static void CreateHealthboxSprite(u8 battler)
{ {
if (bank < gBattlersCount) if (battler < gBattlersCount)
{ {
u8 healthboxSpriteId; u8 healthboxSpriteId;
if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0)
healthboxSpriteId = CreateSafariPlayerHealthboxSprites(); healthboxSpriteId = CreateSafariPlayerHealthboxSprites();
else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0)
return; return;
else else
healthboxSpriteId = CreateHealthboxSprites(bank); healthboxSpriteId = CreateBattlerHealthboxSprites(battler);
gHealthboxSpriteIds[bank] = healthboxSpriteId; gHealthboxSpriteIds[battler] = healthboxSpriteId;
InitBattlerHealthboxCoords(bank); InitBattlerHealthboxCoords(battler);
SetHealthboxSpriteVisible(healthboxSpriteId); SetHealthboxSpriteVisible(healthboxSpriteId);
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(battler) != B_SIDE_PLAYER)
UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gEnemyParty[gBattlerPartyIndexes[bank]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gEnemyParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI)
UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[gBattlerPartyIndexes[bank]], HEALTHBOX_SAFARI_ALL_TEXT); UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_SAFARI_ALL_TEXT);
else else
UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[gBattlerPartyIndexes[bank]], HEALTHBOX_ALL); UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL);
if (GetBattlerPosition(bank) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(bank) == B_POSITION_PLAYER_RIGHT) if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT)
DummyBattleInterfaceFunc(gHealthboxSpriteIds[bank], TRUE); DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], TRUE);
else else
DummyBattleInterfaceFunc(gHealthboxSpriteIds[bank], FALSE); DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], FALSE);
if (GetBattlerSide(bank) != B_SIDE_PLAYER) if (GetBattlerSide(battler) != B_SIDE_PLAYER)
{ {
if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
SetHealthboxSpriteInvisible(healthboxSpriteId); SetHealthboxSpriteInvisible(healthboxSpriteId);
} }
else if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) else if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI))
{ {
if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0)
SetHealthboxSpriteInvisible(healthboxSpriteId); SetHealthboxSpriteInvisible(healthboxSpriteId);
} }
} }

View File

@ -333,10 +333,10 @@ gLastUsedItem: @ 2024208
gLastUsedAbility: @ 202420A gLastUsedAbility: @ 202420A
.space 0x1 .space 0x1
gBattleMoveAttacker: @ 202420B gBattlerAttacker: @ 202420B
.space 0x1 .space 0x1
gBattleMoveTarget: @ 202420C gBattlerTarget: @ 202420C
.space 0x1 .space 0x1
gBank1: @ 202420D gBank1: @ 202420D
@ -345,7 +345,7 @@ gBank1: @ 202420D
gEffectBank: @ 202420E gEffectBank: @ 202420E
.space 0x1 .space 0x1
gStringBank: @ 202420F gStringBattler: @ 202420F
.space 0x1 .space 0x1
gAbsentBattlerFlags: @ 2024210 gAbsentBattlerFlags: @ 2024210
@ -360,7 +360,7 @@ gMultiHitCounter: @ 2024212
gBattlescriptCurrInstr: @ 2024214 gBattlescriptCurrInstr: @ 2024214
.space 0x8 .space 0x8
gActionForBanks: @ 202421C gChosenActionByBattler: @ 202421C
.space 0x4 .space 0x4
gSelectionBattleScripts: @ 2024220 gSelectionBattleScripts: @ 2024220
@ -390,7 +390,7 @@ gLockedMoves: @ 2024268
gLastHitBy: @ 2024270 gLastHitBy: @ 2024270
.space 0x4 .space 0x4
gChosenMovesByBanks: @ 2024274 gChosenMoveByBattler: @ 2024274
.space 0x8 .space 0x8
gMoveResultFlags: @ 202427C gMoveResultFlags: @ 202427C
@ -1165,7 +1165,7 @@ gUnknown_0203AB98: @ 203AB98
.include "src/coins.o" .include "src/coins.o"
.include "src/battle_transition.o" .include "src/battle_transition.o"
gAbilitiesPerBank: @ 203ABA4 gBattlerAbilities: @ 203ABA4
.space 0x4 .space 0x4
gStringInfo: @ 203ABA8 gStringInfo: @ 203ABA8