diff --git a/asm/battle_anim_80A5C6C.s b/asm/battle_anim_80A5C6C.s index b543a5ec2..12aa61185 100644 --- a/asm/battle_anim_80A5C6C.s +++ b/asm/battle_anim_80A5C6C.s @@ -40,7 +40,7 @@ _080A5C9C: _080A5CB0: ldr r4, =gUnknown_08525F58 adds r0, r5, 0 - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 22 ldr r1, =gBattleTypeFlags @@ -56,7 +56,7 @@ _080A5CB0: _080A5CD8: ldr r4, =gUnknown_08525F58 adds r0, r5, 0 - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 22 ldr r1, =gBattleTypeFlags @@ -90,7 +90,7 @@ _080A5D24: b _080A5D9A _080A5D28: adds r0, r5, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A5D60 @@ -164,7 +164,7 @@ sub_80A5DB8: @ 80A5DB8 lsls r1, 16 lsrs r5, r1, 16 adds r0, r4, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A5DDA @@ -394,7 +394,7 @@ sub_80A5FA0: @ 80A5FA0 adds r7, r4, 0 movs r5, 0 adds r0, r6, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -445,7 +445,7 @@ sub_80A600C: @ 80A600C lsls r2, 24 lsrs r7, r2, 24 adds r0, r6, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A6030 @@ -476,7 +476,7 @@ _080A603E: lsrs r4, r0, 16 _080A605C: adds r0, r6, 0 - bl GetBankPosition + bl GetBattlerPosition ldr r3, =gUnknown_08525F58 lsls r0, 24 lsrs r0, 22 @@ -494,7 +494,7 @@ _080A605C: cmp r7, 0 beq _080A609C adds r0, r6, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _080A6096 @@ -605,7 +605,7 @@ GetSubstituteSpriteDefault_Y: @ 80A614C lsls r0, 24 lsrs r4, r0, 24 adds r0, r4, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A6170 @@ -650,7 +650,7 @@ sub_80A6190: @ 80A6190 cmp r0, 0 bne _080A6238 adds r0, r5, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A61E4 @@ -699,7 +699,7 @@ _080A621C: ldrh r4, [r1, 0x2] _080A621E: adds r0, r5, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A6238 @@ -1596,7 +1596,7 @@ sub_80A6864: @ 80A6864 .pool _080A68A4: ldrb r0, [r7] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A68BC @@ -1806,41 +1806,41 @@ _080A6A04: .pool thumb_func_end sub_80A69CC - thumb_func_start GetBankSide -GetBankSide: @ 80A6A30 + thumb_func_start GetBattlerSide +GetBattlerSide: @ 80A6A30 lsls r0, 24 lsrs r0, 24 - ldr r1, =gBankPositions + ldr r1, =gBattlerPositions adds r0, r1 ldrb r1, [r0] movs r0, 0x1 ands r0, r1 bx lr .pool - thumb_func_end GetBankSide + thumb_func_end GetBattlerSide - thumb_func_start GetBankPosition -GetBankPosition: @ 80A6A44 + thumb_func_start GetBattlerPosition +GetBattlerPosition: @ 80A6A44 lsls r0, 24 lsrs r0, 24 - ldr r1, =gBankPositions + ldr r1, =gBattlerPositions adds r0, r1 ldrb r0, [r0] bx lr .pool - thumb_func_end GetBankPosition + thumb_func_end GetBattlerPosition - thumb_func_start GetBankByPosition -GetBankByPosition: @ 80A6A54 + thumb_func_start GetBattlerAtPosition +GetBattlerAtPosition: @ 80A6A54 push {r4,lr} lsls r0, 24 lsrs r3, r0, 24 movs r1, 0 - ldr r0, =gBattleBanksCount + ldr r0, =gBattlersCount ldrb r2, [r0] cmp r1, r2 bcs _080A6A7E - ldr r4, =gBankPositions + ldr r4, =gBattlerPositions ldrb r0, [r4] cmp r0, r3 beq _080A6A7E @@ -1860,7 +1860,7 @@ _080A6A7E: pop {r1} bx r1 .pool - thumb_func_end GetBankByPosition + thumb_func_end GetBattlerAtPosition thumb_func_start IsBankSpritePresent IsBankSpritePresent: @ 80A6A90 @@ -1883,13 +1883,13 @@ IsBankSpritePresent: @ 80A6A90 b _080A6B18 .pool _080A6ABC: - ldr r0, =gBankPositions + ldr r0, =gBattlerPositions adds r0, r4, r0 ldrb r0, [r0] cmp r0, 0xFF beq _080A6B18 adds r0, r4, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A6AF0 @@ -3496,7 +3496,7 @@ _080A76F2: cmp r5, 0 beq _080A771A movs r0, 0 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 bl IsAnimBankSpriteVisible @@ -3504,7 +3504,7 @@ _080A76F2: cmp r0, 0 beq _080A771A movs r0, 0 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 adds r0, 0x10 @@ -3514,7 +3514,7 @@ _080A771A: cmp r6, 0 beq _080A7746 movs r0, 0x2 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 bl IsAnimBankSpriteVisible @@ -3522,7 +3522,7 @@ _080A771A: cmp r0, 0 beq _080A7746 movs r0, 0x2 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 adds r1, r0, 0 @@ -3534,7 +3534,7 @@ _080A7746: cmp r7, 0 beq _080A7772 movs r0, 0x1 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 bl IsAnimBankSpriteVisible @@ -3542,7 +3542,7 @@ _080A7746: cmp r0, 0 beq _080A7772 movs r0, 0x1 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 adds r1, r0, 0 @@ -3555,7 +3555,7 @@ _080A7772: cmp r0, 0 beq _080A77A0 movs r0, 0x3 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 bl IsAnimBankSpriteVisible @@ -3563,7 +3563,7 @@ _080A7772: cmp r0, 0 beq _080A77A0 movs r0, 0x3 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 adds r1, r0, 0 @@ -3592,7 +3592,7 @@ sub_80A77B4: @ 80A77B4 push {lr} lsls r0, 24 lsrs r0, 24 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 pop {r1} @@ -3672,7 +3672,7 @@ _080A7842: bl sub_80A69CC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A785C @@ -3718,7 +3718,7 @@ sub_80A78AC: @ 80A78AC bl sub_80A69CC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A78CC @@ -3811,7 +3811,7 @@ _080A7976: ldrb r6, [r0] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A798E @@ -4567,7 +4567,7 @@ _080A7F42: _080A7F78: lsls r0, r4, 24 lsrs r0, 24 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _080A7FD8 @@ -4959,7 +4959,7 @@ _080A825C: sub_80A8278: @ 80A8278 push {r4-r6,lr} movs r5, 0 - ldr r0, =gBattleBanksCount + ldr r0, =gBattlersCount ldrb r0, [r0] cmp r5, r0 bge _080A82D2 @@ -4998,7 +4998,7 @@ _080A8286: strb r2, [r0, 0x5] _080A82C8: adds r5, 0x1 - ldr r0, =gBattleBanksCount + ldr r0, =gBattlersCount ldrb r0, [r0] cmp r5, r0 blt _080A8286 @@ -5027,7 +5027,7 @@ _080A82FC: b _080A8320 _080A8300: adds r0, r4, 0 - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 24 movs r1, 0x1E @@ -5053,7 +5053,7 @@ sub_80A8328: @ 80A8328 push {r4,lr} lsls r0, 24 lsrs r0, 24 - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r4, r0, 24 bl IsContest @@ -5093,7 +5093,7 @@ sub_80A8364: @ 80A8364 cmp r0, 0 bne _080A838A adds r0, r4, 0 - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 24 cmp r0, 0 @@ -5486,7 +5486,7 @@ _080A86AC: .pool _080A86C4: mov r0, r8 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _080A8790 @@ -5943,7 +5943,7 @@ sub_80A8A6C: @ 80A8A6C bl sub_80A6838 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A8AAC @@ -6000,7 +6000,7 @@ sub_80A8AEC: @ 80A8AEC adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A8B1C @@ -6056,7 +6056,7 @@ sub_80A8B64: @ 80A8B64 bl sub_80A6838 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080A8B90 @@ -6108,7 +6108,7 @@ sub_80A8BC4: @ 80A8BC4 strh r0, [r5, 0x8] ldr r7, =gAnimBankAttacker ldrb r0, [r7] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 movs r1, 0x8 cmp r0, 0 @@ -6403,7 +6403,7 @@ sub_80A8E30: @ 80A8E30 lsrs r0, 24 strh r0, [r5, 0x22] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _080A8E68 @@ -6489,7 +6489,7 @@ sub_80A8EE4: @ 80A8EE4 strh r0, [r4, 0x36] ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _080A8F24 diff --git a/asm/battle_anim_80D51AC.s b/asm/battle_anim_80D51AC.s index 3b1e9dcce..514bf2594 100644 --- a/asm/battle_anim_80D51AC.s +++ b/asm/battle_anim_80D51AC.s @@ -200,7 +200,7 @@ _080D5320: _080D5324: movs r0, 0x3 _080D5326: - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r4, r0, 24 adds r0, r4, 0 @@ -844,7 +844,7 @@ sub_80D5830: @ 80D5830 lsrs r4, r0, 24 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080D584C @@ -873,7 +873,7 @@ sub_80D5860: @ 80D5860 strb r0, [r2] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080D5890 @@ -1144,7 +1144,7 @@ _080D5AB2: adds r0, r2, r0 ldrb r6, [r0] adds r0, r2, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080D5ADC @@ -1229,7 +1229,7 @@ _080D5B72: adds r0, r1, r0 ldrb r7, [r0] adds r0, r1, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080D5B9C @@ -1340,7 +1340,7 @@ sub_80D5C50: @ 80D5C50 lsrs r7, r0, 16 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080D5C82 @@ -1551,7 +1551,7 @@ _080D5E18: strh r2, [r5, 0x8] ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080D5E44 @@ -1624,7 +1624,7 @@ sub_80D5EB8: @ 80D5EB8 lsrs r5, r0, 24 ldr r6, =gAnimBankAttacker ldrb r0, [r6] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080D5ED4 @@ -1722,7 +1722,7 @@ sub_80D5F3C: @ 80D5F3C .pool _080D5F94: ldrb r0, [r4, 0x12] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _080D5FBC @@ -2002,7 +2002,7 @@ _080D61C8: ldr r0, =gAnimBankTarget _080D61CA: ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide movs r1, 0 lsls r0, 24 cmp r0, 0 @@ -2083,7 +2083,7 @@ _080D6274: ldr r0, =gAnimBankTarget _080D6276: ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080D6288 diff --git a/asm/battle_anim_80FE840.s b/asm/battle_anim_80FE840.s index 59e0556e7..7671f473d 100644 --- a/asm/battle_anim_80FE840.s +++ b/asm/battle_anim_80FE840.s @@ -24,7 +24,7 @@ sub_80FE840: @ 80FE840 strh r0, [r4, 0x30] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080FE87C @@ -388,7 +388,7 @@ sub_80FEB44: @ 80FEB44 lsrs r0, 24 strh r0, [r5, 0x22] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080FEB90 @@ -496,7 +496,7 @@ sub_80FEC48: @ 80FEC48 bl sub_80A69CC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080FEC68 @@ -1028,7 +1028,7 @@ sub_80FF090: @ 80FF090 adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080FF0B4 @@ -1082,7 +1082,7 @@ sub_80FF0F4: @ 80FF0F4 bl sub_80A69CC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080FF114 @@ -1141,11 +1141,11 @@ _080FF174: bl sub_80A68D4 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide adds r4, r0, 0 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r4, 24 lsls r0, 24 cmp r4, r0 @@ -1641,7 +1641,7 @@ sub_80FF53C: @ 80FF53C strh r1, [r5, 0x24] ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080FF586 @@ -1787,7 +1787,7 @@ sub_80FF698: @ 80FF698 _080FF6AA: ldr r6, =gAnimBankTarget ldrb r0, [r6] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _080FF6C2 @@ -2460,7 +2460,7 @@ sub_80FFBF4: @ 80FFBF4 lsls r0, 24 lsrs r6, r0, 24 ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0 @@ -2982,7 +2982,7 @@ sub_80FFFC0: @ 80FFFC0 bl sub_80A861C strh r0, [r5, 0x1E] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 movs r2, 0x1 @@ -3780,7 +3780,7 @@ _0810065C: _0810065E: ldrb r6, [r0] adds r0, r6, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08100688 @@ -4239,7 +4239,7 @@ sub_81009F8: @ 81009F8 adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08100A20 @@ -4279,7 +4279,7 @@ sub_8100A50: @ 8100A50 adds r5, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08100A6A @@ -4357,7 +4357,7 @@ sub_8100AE0: @ 8100AE0 lsrs r0, 24 strh r0, [r5, 0x22] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08100B14 @@ -4511,7 +4511,7 @@ _08100C3E: strh r4, [r6, 0x22] ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08100C56 @@ -4756,7 +4756,7 @@ sub_8100E1C: @ 8100E1C strh r0, [r5, 0x2E] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08100E44 @@ -4885,7 +4885,7 @@ _08100F06: adds r0, r4 strh r0, [r5, 0x22] ldrb r0, [r6] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08100F44 @@ -5525,7 +5525,7 @@ sub_8101440: @ 8101440 bl sub_80A6838 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08101474 @@ -5613,7 +5613,7 @@ sub_81014F4: @ 81014F4 bl sub_80A6838 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810152C @@ -6201,7 +6201,7 @@ sub_8101998: @ 8101998 strh r0, [r4, 0x2E] ldr r5, =gAnimBankAttacker ldrb r0, [r5] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 movs r2, 0x2 negs r2, r2 @@ -6246,7 +6246,7 @@ sub_81019E8: @ 81019E8 movs r1, 0 bl sub_80A7270 ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 strh r0, [r5, 0x3A] @@ -6303,7 +6303,7 @@ sub_8101A74: @ 8101A74 strh r0, [r4, 0x2E] ldr r5, =gAnimBankAttacker ldrb r0, [r5] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 movs r1, 0x3 cmp r0, 0 @@ -6367,12 +6367,12 @@ sub_8101AE8: @ 8101AE8 ldrb r0, [r0] strh r0, [r5, 0x34] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 strh r0, [r5, 0x3A] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08101B2C @@ -6472,7 +6472,7 @@ _08101BBC: ldrb r0, [r0] strh r0, [r4, 0x32] ldrb r0, [r2] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 strh r0, [r4, 0x34] @@ -6583,7 +6583,7 @@ sub_8101C94: @ 8101C94 movs r4, 0 strh r0, [r5, 0x8] ldrb r0, [r2] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r2, r0, 24 strh r2, [r5, 0xA] @@ -7539,7 +7539,7 @@ sub_8102434: @ 8102434 lsls r0, 24 lsrs r7, r0, 24 movs r4, 0 - ldr r0, =gBattleBanksCount + ldr r0, =gBattlersCount ldrb r0, [r0] cmp r4, r0 bcs _08102490 @@ -7551,7 +7551,7 @@ _08102448: cmp r0, 0x1 bne _08102464 adds r0, r4, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08102464 @@ -7564,7 +7564,7 @@ _08102464: cmp r0, 0x1 bne _08102482 adds r0, r4, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -7576,7 +7576,7 @@ _08102482: adds r0, r4, 0x1 lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gBattleBanksCount + ldr r0, =gBattlersCount ldrb r0, [r0] cmp r4, r0 bcc _08102448 @@ -7605,7 +7605,7 @@ _081024B2: lsls r0, 24 lsrs r4, r0, 24 _081024C2: - ldr r0, =gBattleBanksCount + ldr r0, =gBattlersCount ldrb r0, [r0] cmp r4, r0 bcc _081024B2 @@ -8115,7 +8115,7 @@ _08102862: _081028D4: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810291C @@ -8857,7 +8857,7 @@ sub_8102EB0: @ 8102EB0 adds r6, r0, 0 ldr r7, =gAnimBankAttacker ldrb r0, [r7] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -9149,7 +9149,7 @@ sub_810310C: @ 810310C lsls r0, 24 lsrs r5, r0, 24 adds r0, r5, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810312C @@ -9208,7 +9208,7 @@ _08103182: adds r1, r5, 0 bl sub_810310C adds r0, r4, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 negs r1, r0 @@ -9474,7 +9474,7 @@ _081033AE: adds r1, r5, 0 bl sub_810310C adds r0, r4, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _081033D4 @@ -9735,7 +9735,7 @@ sub_810358C: @ 810358C adds r0, r1 ldrb r6, [r0] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _081035E4 @@ -9876,7 +9876,7 @@ sub_81036DC: @ 81036DC ldrb r0, [r0] adds r1, r0, r1 ldrb r4, [r1] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08103718 @@ -9994,7 +9994,7 @@ sub_81037D8: @ 81037D8 bl sub_80A6838 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08103804 @@ -10020,7 +10020,7 @@ _08103810: strh r0, [r4, 0x22] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810384C @@ -10119,7 +10119,7 @@ sub_81038C8: @ 81038C8 _081038EC: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810390E @@ -10676,7 +10676,7 @@ _08103D54: strh r0, [r3, 0x4] b _08103DB6 _08103D5C: - ldr r1, =gBankPositions + ldr r1, =gBattlerPositions ldr r0, =gAnimBankTarget ldrb r0, [r0] adds r0, r1 @@ -11068,7 +11068,7 @@ sub_8104088: @ 8104088 lsrs r7, r0, 16 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _081040CC @@ -11147,7 +11147,7 @@ sub_8104154: @ 8104154 strh r0, [r4, 0x24] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08104178 @@ -11354,7 +11354,7 @@ sub_8104304: @ 8104304 bl sub_80A69CC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08104322 @@ -12347,7 +12347,7 @@ sub_8104B1C: @ 8104B1C adds r4, r0, 0 ldr r5, =gAnimBankAttacker ldrb r0, [r5] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08104B50 @@ -12419,7 +12419,7 @@ _08104BC8: _08104BCA: ldrb r5, [r0] adds r0, r5, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -12561,7 +12561,7 @@ sub_8104CA4: @ 8104CA4 strh r0, [r4, 0x1A] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -13235,7 +13235,7 @@ _08105234: lsls r0, 24 lsrs r4, r0, 24 adds r0, r5, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08105260 @@ -13335,7 +13335,7 @@ _08105308: str r3, [sp, 0x4] _08105310: adds r0, r7, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810536C @@ -13486,7 +13486,7 @@ _0810544C: strh r0, [r2, 0x2] _0810546C: mov r0, r8 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08105490 @@ -13583,7 +13583,7 @@ sub_8105538: @ 8105538 bl sub_80A69CC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 movs r1, 0xA0 cmp r0, 0 @@ -13624,7 +13624,7 @@ sub_810557C: @ 810557C strh r2, [r4, 0x2E] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 movs r1, 0xA0 cmp r0, 0 @@ -13952,7 +13952,7 @@ sub_8105810: @ 8105810 strh r0, [r4, 0x20] ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08105850 @@ -14686,7 +14686,7 @@ sub_8105DE8: @ 8105DE8 bl sub_80A69CC ldr r6, =gAnimBankAttacker ldrb r0, [r6] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08105E08 @@ -15563,7 +15563,7 @@ _0810653A: _08106578: ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -16653,7 +16653,7 @@ _08106E1C: _08106E1E: ldrb r6, [r0] adds r0, r6, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -17198,7 +17198,7 @@ sub_8107260: @ 8107260 adds r6, r0, 0 ldr r5, =gAnimBankAttacker ldrb r0, [r5] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08107290 @@ -17239,7 +17239,7 @@ _081072A2: strb r0, [r2] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _081072D8 @@ -17424,7 +17424,7 @@ sub_810744C: @ 810744C bl sub_80A69CC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810747C @@ -17797,7 +17797,7 @@ sub_8107730: @ 8107730 cmp r0, 0 bne _0810778A ldrb r0, [r7] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08107784 @@ -17848,11 +17848,11 @@ sub_81077C0: @ 81077C0 adds r6, r0, 0 ldr r5, =gAnimBankAttacker ldrb r0, [r5] - bl GetBankSide + bl GetBattlerSide adds r4, r0, 0 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r4, 24 lsls r0, 24 cmp r4, r0 @@ -17863,12 +17863,12 @@ sub_81077C0: @ 81077C0 negs r0, r0 strh r0, [r4] ldrb r0, [r5] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 cmp r0, 0 beq _08107802 ldrb r0, [r5] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -17900,7 +17900,7 @@ _08107828: bl sub_80A69CC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08107842 @@ -18071,7 +18071,7 @@ sub_8107954: @ 8107954 bl SetAnimBgAttribute ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -18176,7 +18176,7 @@ _08107A32: _08107AB4: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0x1 @@ -19280,7 +19280,7 @@ sub_8108384: @ 8108384 push {r4,r5,lr} ldr r4, =gAnimBankAttacker ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _081083B8 @@ -19578,7 +19578,7 @@ sub_81085C8: @ 81085C8 strh r0, [r4, 0xA] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08108600 @@ -19971,7 +19971,7 @@ sub_81088E4: @ 81088E4 lsrs r0, 24 strh r0, [r5, 0x10] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 movs r2, 0x1 negs r2, r2 @@ -20748,7 +20748,7 @@ sub_8108F4C: @ 8108F4C bl sub_80A6838 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08108F88 @@ -20800,7 +20800,7 @@ sub_8108FBC: @ 8108FBC adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08108FF0 @@ -20888,7 +20888,7 @@ sub_8109064: @ 8109064 bl sub_80A6838 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08109090 @@ -21039,24 +21039,24 @@ sub_8109198: @ 8109198 adds r6, r0, 0 ldr r5, =gAnimBankAttacker ldrb r0, [r5] - bl GetBankSide + bl GetBattlerSide adds r4, r0, 0 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r4, 24 lsls r0, 24 cmp r4, r0 bne _081091DE movs r0, 0x2 - bl GetBankByPosition + bl GetBattlerAtPosition ldrb r1, [r5] lsls r0, 24 lsrs r0, 24 cmp r1, r0 beq _081091D6 movs r0, 0x3 - bl GetBankByPosition + bl GetBattlerAtPosition ldrb r1, [r5] lsls r0, 24 lsrs r0, 24 @@ -21409,7 +21409,7 @@ sub_8109460: @ 8109460 strh r0, [r4, 0x10] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 strh r0, [r4, 0x12] @@ -21822,7 +21822,7 @@ sub_81097B4: @ 81097B4 ldrh r4, [r0, 0x20] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810980C @@ -21994,7 +21994,7 @@ sub_8109930: @ 8109930 lsrs r4, r0, 16 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08109970 @@ -22250,7 +22250,7 @@ _08109B18: strh r0, [r5, 0x3C] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08109B48 @@ -22281,7 +22281,7 @@ _08109B70: strh r0, [r5, 0x30] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08109B94 @@ -22580,7 +22580,7 @@ sub_8109DBC: @ 8109DBC adds r4, r1, r0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 movs r2, 0x1 negs r2, r2 @@ -23077,7 +23077,7 @@ sub_810A1A8: @ 810A1A8 adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810A1D0 @@ -23131,7 +23131,7 @@ sub_810A214: @ 810A214 adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810A23C @@ -23193,7 +23193,7 @@ sub_810A274: @ 810A274 strh r0, [r5, 0x22] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810A2C4 @@ -23578,7 +23578,7 @@ sub_810A5BC: @ 810A5BC bne _0810A5D8 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810A5E0 @@ -23645,7 +23645,7 @@ _0810A64E: cmp r0, 0 bne _0810A666 adds r0, r6, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810A66E @@ -24539,7 +24539,7 @@ sub_810AD98: @ 810AD98 movs r0, 0x10 strh r0, [r5, 0x3C] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -24654,7 +24654,7 @@ _0810AE90: lsrs r0, 24 strh r0, [r5, 0x24] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810AECC @@ -24822,7 +24822,7 @@ _0810AFFA: _0810AFFC: ldr r4, =gAnimBankAttacker ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 movs r2, 0x1 negs r2, r2 @@ -25985,7 +25985,7 @@ sub_810B8EC: @ 810B8EC strh r0, [r4, 0x32] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810B92C @@ -26051,7 +26051,7 @@ _0810B990: bl sub_80A8924 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810B9B6 @@ -26159,7 +26159,7 @@ _0810BA74: _0810BA86: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810BAAC @@ -26279,7 +26279,7 @@ sub_810BB60: @ 810BB60 strh r0, [r4, 0x2E] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 ldr r1, =0x0000ffec cmp r0, 0 @@ -26314,7 +26314,7 @@ sub_810BBC8: @ 810BBC8 adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 ldr r1, =0x0000ffec cmp r0, 0 @@ -26458,7 +26458,7 @@ _0810BCE0: _0810BCF2: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810BD1C @@ -26655,7 +26655,7 @@ _0810BE6C: bl sub_80A8924 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810BE92 @@ -26721,7 +26721,7 @@ _0810BEF4: movs r1, 0 bl sub_80A8924 ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810BF20 @@ -26764,7 +26764,7 @@ _0810BF52: movs r1, 0 bl sub_80A8924 ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810BF7C @@ -26808,7 +26808,7 @@ _0810BFB6: strh r0, [r5, 0x3A] ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810BFCC @@ -27474,7 +27474,7 @@ sub_810C560: @ 810C560 lsls r0, 8 strh r0, [r5, 0x3C] _0810C594: - ldr r3, =gBankPositions + ldr r3, =gBattlerPositions ldrb r0, [r7] adds r0, r3 ldrb r1, [r0] @@ -27699,7 +27699,7 @@ _0810C736: lsls r0, 24 cmp r0, 0 bne _0810C78C - ldr r1, =gBankPositions + ldr r1, =gBattlerPositions ldrb r0, [r6] adds r0, r1 ldrb r1, [r0] @@ -27843,7 +27843,7 @@ _0810C85A: lsls r0, 24 cmp r0, 0 bne _0810C8B4 - ldr r1, =gBankPositions + ldr r1, =gBattlerPositions ldr r0, =gAnimBankTarget ldrb r0, [r0] adds r0, r1 @@ -28050,7 +28050,7 @@ sub_810C9E4: @ 810C9E4 ldrh r0, [r4, 0x2] lsls r0, 20 lsrs r0, 24 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r5, r0, 24 adds r0, r5, 0 @@ -28373,7 +28373,7 @@ _0810CCA6: strh r0, [r5, 0x2E] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810CCCE @@ -28583,7 +28583,7 @@ sub_810CE68: @ 810CE68 bne _0810CE90 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810CE90 @@ -28771,7 +28771,7 @@ _0810D000: negs r0, r0 lsrs r4, r0, 16 _0810D012: - ldr r0, =gBankPositions + ldr r0, =gBattlerPositions add r0, r8 ldrb r1, [r0] adds r0, r7, 0 @@ -28983,7 +28983,7 @@ sub_810D1B4: @ 810D1B4 cmp r0, r1 bne _0810D1E0 ldrb r0, [r2] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -28999,7 +28999,7 @@ _0810D1E0: bl sub_80A6980 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810D1FE @@ -29520,7 +29520,7 @@ sub_810D608: @ 810D608 ldrsh r0, [r0, r1] cmp r0, 0 bne _0810D664 - ldr r4, =gBankAttacker + ldr r4, =gBattleAttacker ldrb r0, [r4] movs r1, 0x2 bl GetBankCoord @@ -29808,7 +29808,7 @@ sub_810D874: @ 810D874 ldrsh r0, [r0, r1] cmp r0, 0 bne _0810D8B8 - ldr r4, =gBankAttacker + ldr r4, =gBattleAttacker ldrb r0, [r4] movs r1, 0x2 bl GetBankCoord @@ -29857,7 +29857,7 @@ _0810D8BE: .pool _0810D8F8: adds r0, r4, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810D918 @@ -29954,7 +29954,7 @@ sub_810D984: @ 810D984 ldr r0, =gAnimMoveTurn ldrb r6, [r0] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810D9CE @@ -30020,7 +30020,7 @@ _0810DA34: _0810DA48: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810DA5E @@ -30130,7 +30130,7 @@ _0810DB1A: strh r0, [r4, 0x1C] ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810DB50 @@ -30273,7 +30273,7 @@ _0810DC44: bl sub_80A8924 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810DC72 @@ -30399,7 +30399,7 @@ sub_810DD50: @ 810DD50 bl sub_80A8924 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810DD7C @@ -30460,7 +30460,7 @@ _0810DDE0: bl sub_80A8924 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810DE06 @@ -30682,7 +30682,7 @@ sub_810DFA8: @ 810DFA8 bl sub_80A69CC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810DFC8 @@ -30750,7 +30750,7 @@ sub_810E044: @ 810E044 adds r5, r0, 0 ldr r4, =gAnimBankAttacker ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810E070 @@ -30931,7 +30931,7 @@ sub_810E1C8: @ 810E1C8 adds r5, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810E1F8 @@ -31107,7 +31107,7 @@ _0810E33C: _0810E33E: ldrb r6, [r0] adds r0, r6, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810E354 @@ -32108,7 +32108,7 @@ _0810EAC4: bne _0810EADC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810EAF2 @@ -32119,7 +32119,7 @@ _0810EADC: bne _0810EAF8 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810EAF8 @@ -33040,7 +33040,7 @@ sub_810F1EC: @ 810F1EC mov r8, r0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810F212 @@ -33064,7 +33064,7 @@ _0810F212: bne _0810F2B8 _0810F22E: movs r0, 0x1 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r4, r0, 24 adds r7, r4, 0 @@ -33111,7 +33111,7 @@ _0810F284: beq _0810F2B8 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810F2B0 @@ -33128,7 +33128,7 @@ _0810F2B0: _0810F2B8: ldr r6, =gAnimBankAttacker ldrb r0, [r6] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810F2CE @@ -33193,7 +33193,7 @@ sub_810F340: @ 810F340 push {r4,r5,lr} adds r5, r0, 0 movs r0, 0x1 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r4, r0, 24 movs r1, 0x3C @@ -33370,7 +33370,7 @@ sub_810F46C: @ 810F46C cmp r0, 0 bne _0810F502 movs r0, 0x1 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r4, r0, 24 adds r6, r4, 0 @@ -33441,7 +33441,7 @@ sub_810F524: @ 810F524 cmp r0, 0 bne _0810F57C movs r0, 0x1 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 adds r4, r0, 0 @@ -33507,7 +33507,7 @@ _0810F5A6: beq _0810F5EE ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0810F5E0 @@ -33582,7 +33582,7 @@ sub_810F634: @ 810F634 lsrs r0, 24 strh r0, [r5, 0x22] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0810F684 @@ -33645,7 +33645,7 @@ sub_810F6B0: @ 810F6B0 lsls r1, 16 lsrs r7, r1, 16 ldrb r0, [r6] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -33833,7 +33833,7 @@ sub_810F83C: @ 810F83C strh r1, [r4, 0xC] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 movs r1, 0x8 cmp r0, 0 @@ -35211,7 +35211,7 @@ sub_8110368: @ 8110368 _08110394: ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _081103C4 @@ -35299,7 +35299,7 @@ sub_8110438: @ 8110438 _0811045C: ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08110478 @@ -35467,7 +35467,7 @@ sub_81105B4: @ 81105B4 bl sub_80A8924 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _081105F0 @@ -35492,7 +35492,7 @@ _081105FC: strh r0, [r4, 0x22] ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08110618 @@ -35657,7 +35657,7 @@ sub_8110720: @ 8110720 _08110740: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08110762 @@ -35678,22 +35678,22 @@ _08110762: bne _081107B2 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide adds r4, r0, 0 ldr r5, =gAnimBankTarget ldrb r0, [r5] - bl GetBankSide + bl GetBattlerSide lsls r4, 24 lsls r0, 24 cmp r4, r0 bne _081107B2 ldrb r0, [r5] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 cmp r0, 0 beq _081107A0 ldrb r0, [r5] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -35782,7 +35782,7 @@ sub_8110850: @ 8110850 bl sub_80A69CC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08110870 @@ -36066,7 +36066,7 @@ sub_8110AB4: @ 8110AB4 bl AnimateSprite ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08110AE4 @@ -36256,7 +36256,7 @@ _08110C10: beq _08110C6E ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08110C6E @@ -36482,7 +36482,7 @@ sub_8110E4C: @ 8110E4C beq _08110E98 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08110E98 @@ -37195,7 +37195,7 @@ sub_8111418: @ 8111418 adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -38287,7 +38287,7 @@ _08111C80: strh r1, [r0, 0x2E] ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08111CF4 @@ -39596,7 +39596,7 @@ sub_8112758: @ 8112758 bl SetGpuReg ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _081127A0 @@ -39871,7 +39871,7 @@ sub_81129F0: @ 81129F0 bl sub_80A69CC ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08112A24 @@ -40066,7 +40066,7 @@ sub_8112B78: @ 8112B78 strh r0, [r5, 0x24] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08112B9C @@ -40303,7 +40303,7 @@ _08112D56: strh r7, [r5, 0x2E] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide movs r1, 0 lsls r0, 24 cmp r0, 0 @@ -40693,7 +40693,7 @@ sub_8113064: @ 8113064 lsrs r0, 24 strh r0, [r5, 0x22] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _081130B4 @@ -40767,7 +40767,7 @@ sub_8113100: @ 8113100 strh r0, [r5, 0x36] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08113164 @@ -40878,7 +40878,7 @@ sub_8113224: @ 8113224 adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0811323E @@ -40918,7 +40918,7 @@ sub_8113250: @ 8113250 ldr r0, =gBattleAnimArgs ldrh r0, [r0] strh r0, [r6, 0x3A] - ldr r4, =gBankAttacker + ldr r4, =gBattleAttacker ldrb r0, [r4] movs r1, 0 bl sub_80A861C @@ -42085,7 +42085,7 @@ sub_8113BAC: @ 8113BAC adds r0, 0x20 strh r0, [r5, 0x26] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08113C1C @@ -42500,7 +42500,7 @@ _08113F84: adds r0, 0x4 strh r0, [r5, 0x26] ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08113FD8 @@ -43204,13 +43204,13 @@ _0811455C: bne _081145D6 ldr r4, =gAnimBankAttacker ldrb r0, [r4] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 24 cmp r0, 0x3 beq _0811458C ldrb r0, [r4] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 cmp r0, 0 bne _081145D6 @@ -43264,7 +43264,7 @@ _081145D6: _08114614: ldr r4, =gAnimBankAttacker ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08114640 @@ -43586,7 +43586,7 @@ _08114902: beq _0811492E _08114908: adds r0, r4, 0 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r4, r0, 24 adds r0, r4, 0 @@ -43766,7 +43766,7 @@ sub_8114A7C: @ 8114A7C bl sub_80A6980 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08114A9C @@ -45335,7 +45335,7 @@ sub_811572C: @ 811572C strh r0, [r4, 0x2E] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r1, r0, 24 cmp r1, 0 @@ -45846,7 +45846,7 @@ sub_8115B0C: @ 8115B0C strh r1, [r0, 0x12] strh r5, [r0, 0x18] movs r4, 0 - ldr r0, =gBattleBanksCount + ldr r0, =gBattlersCount ldrb r1, [r0] mov r9, r3 mov r8, r2 @@ -46650,7 +46650,7 @@ _0811618A: cmp r0, 0x1 bhi _081161DC movs r4, 0 - ldr r5, =gBattleBanksCount + ldr r5, =gBattlersCount ldrb r0, [r5] cmp r4, r0 bcs _081161DC @@ -46957,7 +46957,7 @@ sub_8116420: @ 8116420 adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08116444 @@ -47869,13 +47869,13 @@ _08116BA2: bne _08116C26 ldr r5, =gAnimBankAttacker ldrb r0, [r5] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 24 cmp r0, 0x3 beq _08116BD2 ldrb r0, [r5] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 cmp r0, 0 bne _08116C26 @@ -47934,7 +47934,7 @@ _08116C26: _08116C64: ldr r4, =gAnimBankAttacker ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08116C90 @@ -48306,14 +48306,14 @@ _08116FBA: cmp r0, 0 bne _08117036 ldrb r0, [r1] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 24 cmp r0, 0x3 beq _08116FEC ldr r0, [r4] ldrb r0, [r0] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 cmp r0, 0 bne _08117036 @@ -48370,7 +48370,7 @@ _08117078: ldr r4, =gUnknown_0203A110 ldr r0, [r4] ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _081170A8 @@ -49098,7 +49098,7 @@ sub_8117660: @ 8117660 beq _0811769C ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0811769C @@ -49198,7 +49198,7 @@ sub_8117754: @ 8117754 lsrs r4, 24 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide ldr r1, =gBattleAnimArgs lsls r0, 24 lsrs r0, 24 @@ -49219,7 +49219,7 @@ sub_8117780: @ 8117780 lsrs r4, 24 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide ldr r1, =gBattleAnimArgs lsls r0, 24 lsrs r0, 24 @@ -49431,7 +49431,7 @@ _08117930: .pool _08117964: adds r0, r7, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08117988 @@ -50065,7 +50065,7 @@ sub_8117E94: @ 8117E94 lsls r0, 24 lsrs r0, 24 ldr r2, =gAnimBankAttacker - ldr r1, =gBankDefender + ldr r1, =gBattleDefender ldrb r1, [r1] strb r1, [r2] ldr r2, =gAnimBankTarget @@ -50085,11 +50085,11 @@ sub_8117EC4: @ 8117EC4 lsrs r5, r0, 24 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide adds r4, r0, 0 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r4, 24 lsls r0, 24 cmp r4, r0 @@ -50117,7 +50117,7 @@ sub_8117F10: @ 8117F10 lsls r0, 24 lsrs r0, 24 ldr r2, =gAnimBankTarget - ldr r1, =gBankDefender + ldr r1, =gBattleDefender ldrb r1, [r1] strb r1, [r2] bl DestroyAnimVisualTask @@ -50132,7 +50132,7 @@ sub_8117F30: @ 8117F30 lsls r0, 24 lsrs r0, 24 ldr r2, =gAnimBankAttacker - ldr r1, =gBankAttacker + ldr r1, =gBattleAttacker ldrb r1, [r1] strb r1, [r2] ldr r2, =gAnimBankTarget @@ -52078,7 +52078,7 @@ sub_8118FBC: @ 8118FBC lsls r5, 16 lsrs r5, 16 adds r0, r4, 0 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 ldr r1, =gMonSpritesGfxPtr diff --git a/asm/battle_anim_815A0D4.s b/asm/battle_anim_815A0D4.s index 09ce04a68..d4c1b90b9 100644 --- a/asm/battle_anim_815A0D4.s +++ b/asm/battle_anim_815A0D4.s @@ -778,7 +778,7 @@ sub_815A6C4: @ 815A6C4 bl sub_80A8924 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0815A6F8 @@ -921,7 +921,7 @@ sub_815A7EC: @ 815A7EC bne _0815A840 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0815A830 @@ -1019,7 +1019,7 @@ sub_815A8C8: @ 815A8C8 lsrs r4, r0, 24 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -2484,7 +2484,7 @@ sub_815B49C: @ 815B49C adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0815B4BC @@ -2515,7 +2515,7 @@ sub_815B4D4: @ 815B4D4 strh r0, [r4, 0x2E] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0815B4F8 @@ -3020,7 +3020,7 @@ _0815B8A8: .pool _0815B8E0: ldrb r0, [r5] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r1, r0, 24 _0815B8EA: @@ -3234,7 +3234,7 @@ _0815BAB6: bne _0815BAF6 ldr r4, =gAnimBankAttacker ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -3392,7 +3392,7 @@ _0815BC02: _0815BC34: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0815BC58 @@ -3998,7 +3998,7 @@ _0815C124: _0815C15C: ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r4, r0, 24 bl IsDoubleBattle @@ -4087,7 +4087,7 @@ _0815C224: strh r0, [r5, 0xE] ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -4327,7 +4327,7 @@ _0815C41E: strh r0, [r4, 0x32] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0815C450 @@ -4434,7 +4434,7 @@ _0815C508: ldr r0, =gAnimBankTarget _0815C50A: ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -4645,7 +4645,7 @@ sub_815C6B0: @ 815C6B0 adds r4, r0, 0 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0 @@ -4685,7 +4685,7 @@ sub_815C700: @ 815C700 strh r0, [r4, 0x2E] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0815C744 @@ -5172,7 +5172,7 @@ _0815CAD2: cmp r0, 0 bne _0815CAF8 ldrb r0, [r6, 0x1E] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsls r2, r5, 4 cmp r0, 0 @@ -5695,7 +5695,7 @@ sub_815CED8: @ 815CED8 _0815CF18: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0815CFC4 @@ -5733,7 +5733,7 @@ _0815CF18: cmp r0, 0 bne _0815CFBC adds r0, r2, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0815CF9C @@ -5801,7 +5801,7 @@ _0815CFC4: cmp r0, 0 bne _0815D054 adds r0, r2, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0815D03C @@ -6093,7 +6093,7 @@ _0815D26E: movs r0, 0x18 strh r0, [r4, 0x18] adds r0, r5, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -6829,7 +6829,7 @@ sub_815D870: @ 815D870 bl StartSpriteAffineAnim ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0815D896 @@ -7261,7 +7261,7 @@ sub_815DB90: @ 815DB90 strh r0, [r4, 0x14] _0815DBD4: ldrb r0, [r2] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0815DC04 @@ -7777,7 +7777,7 @@ sub_815E01C: @ 815E01C adds r5, r0, 0 ldr r6, =gAnimBankAttacker ldrb r0, [r6] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -7839,7 +7839,7 @@ _0815E09A: _0815E0A8: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0815E0C8 @@ -7925,7 +7925,7 @@ _0815E144: _0815E14E: ldr r5, =gAnimBankAttacker ldrb r0, [r5] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0815E188 @@ -8451,7 +8451,7 @@ _0815E4EE: bl sub_80A68D4 mov r1, r10 ldrb r0, [r1] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -9365,7 +9365,7 @@ _0815ECAC: _0815ECB4: ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0815ECD0 @@ -9617,7 +9617,7 @@ _0815EEAA: ldrh r0, [r4, 0x3C] lsls r0, 24 lsrs r0, 24 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -9999,7 +9999,7 @@ sub_815F18C: @ 815F18C movs r1, 0x3 bl GetBankCoord ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _0815F1B8 @@ -10362,7 +10362,7 @@ sub_815F48C: @ 815F48C adds r5, r0, 0 ldr r4, =gAnimBankTarget ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0815F4B8 @@ -10960,7 +10960,7 @@ _0815F940: strh r0, [r6, 0xA] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 mov r9, r4 cmp r0, 0 @@ -11047,7 +11047,7 @@ _0815F9F4: _0815FA28: ldr r4, =gAnimBankAttacker ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0815FAC8 @@ -11255,7 +11255,7 @@ _0815FBE8: strh r0, [r6, 0xA] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 mov r9, r4 cmp r0, 0 @@ -11309,7 +11309,7 @@ _0815FC56: bne _0815FCD6 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0815FCB4 @@ -11385,7 +11385,7 @@ _0815FD08: bl sub_80A8610 ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 mov r9, r4 cmp r0, 0 @@ -11444,7 +11444,7 @@ _0815FD8C: mov r10, r0 ldrb r0, [r0] str r2, [sp, 0x18] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 mov r9, r4 ldr r2, [sp, 0x18] @@ -11585,7 +11585,7 @@ _0815FE92: strb r0, [r2] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -11654,7 +11654,7 @@ _0815FF6E: strh r0, [r4, 0x32] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0815FF9C @@ -11900,7 +11900,7 @@ sub_8160164: @ 8160164 strh r0, [r4, 0xE] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 movs r2, 0x1 negs r2, r2 @@ -12074,7 +12074,7 @@ sub_81602E0: @ 81602E0 adds r4, r0, 0 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 ldrh r0, [r4, 0x2E] ldrh r1, [r4, 0x30] @@ -12117,7 +12117,7 @@ sub_8160338: @ 8160338 adds r4, r0, 0 ldr r0, =gAnimBankTarget ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0816037C diff --git a/asm/battle_anim_8170478.s b/asm/battle_anim_8170478.s index 956b30186..ad37b18d2 100644 --- a/asm/battle_anim_8170478.s +++ b/asm/battle_anim_8170478.s @@ -857,7 +857,7 @@ sub_8170BB0: @ 8170BB0 adds r1, r0, r1 ldrb r1, [r1] mov r9, r1 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _08170BF8 @@ -1283,7 +1283,7 @@ _08170F54: lsls r4, 24 lsrs r4, 24 movs r0, 0x1 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 bl sub_80A82E4 @@ -1335,7 +1335,7 @@ _08170F54: ldr r0, =SpriteCallbackDummy str r0, [r4] movs r0, 0 - bl GetBankByPosition + bl GetBattlerAtPosition ldr r1, =gBankSpriteIds lsls r0, 24 lsrs r0, 24 @@ -1371,7 +1371,7 @@ sub_8171030: @ 8171030 lsrs r5, r0, 24 ldr r6, =gSprites movs r0, 0 - bl GetBankByPosition + bl GetBattlerAtPosition ldr r1, =gBankSpriteIds lsls r0, 24 lsrs r0, 24 @@ -1422,7 +1422,7 @@ sub_81710A8: @ 81710A8 lsrs r5, r0, 24 ldr r6, =gSprites movs r0, 0 - bl GetBankByPosition + bl GetBattlerAtPosition ldr r4, =gBankSpriteIds lsls r0, 24 lsrs r0, 24 @@ -1438,7 +1438,7 @@ sub_81710A8: @ 81710A8 cmp r0, 0 bge _081710F4 movs r0, 0 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 adds r0, r4 @@ -4764,7 +4764,7 @@ _08172C36: adds r0, r4 strh r0, [r5, 0x8] ldrb r0, [r3] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08172C78 @@ -4838,7 +4838,7 @@ _08172CDA: adds r0, r2 strh r0, [r5, 0x8] ldrb r0, [r3] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08172D10 @@ -4879,7 +4879,7 @@ _08172D28: strh r1, [r0, 0x8] ldr r0, =gAnimBankAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r2, r0, 24 cmp r2, 0 @@ -5347,7 +5347,7 @@ _08173118: cmp r0, 0 bne _08173160 mov r0, r8 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 movs r1, 0x3F cmp r0, 0 @@ -5575,7 +5575,7 @@ sub_817330C: @ 817330C movs r0, 0x1E strh r0, [r4, 0x2E] movs r0, 0x1 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 movs r1, 0 @@ -5587,7 +5587,7 @@ sub_817330C: @ 817330C adds r0, r1 strh r0, [r4, 0x32] movs r0, 0x1 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r0, 24 movs r1, 0x1 @@ -5732,7 +5732,7 @@ sub_817345C: @ 817345C .pool _08173478: movs r0, 0 - bl GetBankByPosition + bl GetBattlerAtPosition ldr r1, =gAnimBankAttacker strb r0, [r1] movs r0, 0x1 @@ -5740,12 +5740,12 @@ _08173478: .pool _0817348C: movs r0, 0x1 - bl GetBankByPosition + bl GetBattlerAtPosition ldr r1, =gAnimBankAttacker strb r0, [r1] movs r0, 0 _08173498: - bl GetBankByPosition + bl GetBattlerAtPosition ldr r1, =gAnimBankTarget strb r0, [r1] _081734A0: diff --git a/asm/battle_anim_sound_tasks.s b/asm/battle_anim_sound_tasks.s index 949934e1d..85148c8b6 100644 --- a/asm/battle_anim_sound_tasks.s +++ b/asm/battle_anim_sound_tasks.s @@ -379,7 +379,7 @@ _08158E1E: .pool _08158E38: adds r0, r4, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08158E5C @@ -504,7 +504,7 @@ _08158F2E: .pool _08158F48: adds r0, r4, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _08158F6C diff --git a/asm/battle_link_817C95C.s b/asm/battle_link_817C95C.s index f1a398ad6..b9205632b 100644 --- a/asm/battle_link_817C95C.s +++ b/asm/battle_link_817C95C.s @@ -34,26 +34,26 @@ _0817C988: movs r1, 0x81 lsls r1, 2 adds r7, r0, r1 - ldr r5, =gBankAttacker + ldr r5, =gBattleAttacker ldrb r0, [r5] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gBankDefender + ldr r0, =gBattleDefender ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r6, r0, 24 ldr r0, =gEffectBank ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 mov r9, r0 ldr r0, =gStringInfo ldr r0, [r0] ldrb r0, [r0, 0x7] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 str r0, [sp, 0x4] @@ -83,7 +83,7 @@ _0817CA10: str r1, [sp, 0x8] cmp r6, 0 bne _0817CA3C - ldr r0, =gBankDefender + ldr r0, =gBattleDefender ldrb r0, [r0] lsls r0, 1 adds r0, r2 @@ -94,7 +94,7 @@ _0817CA10: b _0817CA4C .pool _0817CA3C: - ldr r0, =gBankDefender + ldr r0, =gBattleDefender ldrb r0, [r0] lsls r0, 1 adds r0, r2 @@ -105,7 +105,7 @@ _0817CA3C: _0817CA4C: adds r1, r0 str r1, [sp, 0xC] - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] ldr r1, =gStringInfo ldr r1, [r1] @@ -134,20 +134,20 @@ _0817CA4C: bl _0817E0A2 .pool _0817CA9C: - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 25 mov r8, r0 - ldr r0, =gBankDefender + ldr r0, =gBattleDefender ldrb r0, [r0] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r5, r0, 25 ldr r0, =gEffectBank ldrb r0, [r0] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r3, r0, 25 ldr r1, [sp] @@ -572,7 +572,7 @@ _0817D0DC: lsls r3, 2 adds r3, r7, r3 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -602,7 +602,7 @@ _0817D124: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -635,7 +635,7 @@ _0817D16C: lsls r0, 2 adds r5, r7, r0 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -716,7 +716,7 @@ _0817D216: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -776,7 +776,7 @@ _0817D296: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -834,7 +834,7 @@ _0817D314: adds r3, r0 adds r3, r7, r3 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -940,8 +940,8 @@ _0817D3F2: bne _0817D3FE bl _0817E0A6 _0817D3FE: - ldr r0, =gBankAttacker - ldr r1, =gBankDefender + ldr r0, =gBattleAttacker + ldr r1, =gBattleDefender ldrb r0, [r0] ldrb r1, [r1] cmp r0, r1 @@ -1015,7 +1015,7 @@ _0817D498: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1092,7 +1092,7 @@ _0817D53C: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1162,7 +1162,7 @@ _0817D5CE: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1227,7 +1227,7 @@ _0817D65E: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1314,7 +1314,7 @@ _0817D704: lsls r4, 3 adds r2, r4 adds r2, r7, r2 - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r5 @@ -1354,7 +1354,7 @@ _0817D76C: bl _0817E0A6 _0817D77E: ldr r6, =gBattlePartyID - ldr r5, =gBankAttacker + ldr r5, =gBattleAttacker ldrb r0, [r5] lsls r0, 1 adds r0, r6 @@ -1408,7 +1408,7 @@ _0817D7D8: lsls r4, 3 adds r2, r4 adds r2, r7, r2 - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r5 @@ -1452,7 +1452,7 @@ _0817D838: lsls r4, 3 adds r2, r4 adds r2, r7, r2 - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r5 @@ -1498,7 +1498,7 @@ _0817D8A4: _0817D8B6: ldr r2, =gBattlePartyID mov r8, r2 - ldr r6, =gBankAttacker + ldr r6, =gBattleAttacker ldrb r0, [r6] lsls r0, 1 add r0, r8 @@ -1574,7 +1574,7 @@ _0817D94C: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1640,7 +1640,7 @@ _0817D9C2: lsls r4, 3 adds r2, r4 adds r2, r7, r2 - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r5 @@ -1672,7 +1672,7 @@ _0817D9C2: .pool _0817DA24: ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1715,7 +1715,7 @@ _0817DA68: lsls r4, 3 adds r2, r4 adds r2, r7, r2 - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r5 @@ -1748,7 +1748,7 @@ _0817DA68: .pool _0817DACC: ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1803,7 +1803,7 @@ _0817DB24: lsls r4, 3 adds r3, r4 adds r3, r7, r3 - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r5 @@ -1839,7 +1839,7 @@ _0817DB76: .pool _0817DB90: ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1876,7 +1876,7 @@ _0817DBD4: adds r3, r0 adds r3, r7, r3 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1944,7 +1944,7 @@ _0817DC62: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2022,7 +2022,7 @@ _0817DCFC: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2050,7 +2050,7 @@ _0817DD38: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2122,7 +2122,7 @@ _0817DDC8: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2155,7 +2155,7 @@ _0817DE10: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2254,7 +2254,7 @@ _0817DEDC: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2332,7 +2332,7 @@ _0817DF70: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2414,7 +2414,7 @@ _0817DFE6: ands r0, r2 strb r0, [r1] ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2557,16 +2557,16 @@ _0817E122: lsls r1, 2 adds r1, r0, r1 str r1, [sp, 0x8] - ldr r2, =gBankAttacker + ldr r2, =gBattleAttacker mov r10, r2 ldrb r0, [r2] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 mov r9, r0 - ldr r0, =gBankDefender + ldr r0, =gBattleDefender ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r4, r0, 24 mov r1, r10 @@ -2593,7 +2593,7 @@ _0817E122: _0817E184: mov r2, r10 ldrb r0, [r2] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 25 lsls r0, 3 @@ -2617,7 +2617,7 @@ _0817E184: strb r1, [r0] mov r1, r10 ldrb r0, [r1] - bl GetBankPosition + bl GetBattlerPosition lsls r0, 24 lsrs r0, 25 lsls r0, 3 @@ -2812,9 +2812,9 @@ sub_817E32C: @ 817E32C movs r1, 0x81 lsls r1, 2 adds r4, r0, r1 - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r2, r0, 24 cmp r5, 0x12 @@ -3244,14 +3244,14 @@ sub_817E684: @ 817E684 movs r2, 0x81 lsls r2, 2 adds r7, r0, r2 - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gBankDefender + ldr r0, =gBattleDefender ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r3, r0, 24 mov r0, r10 @@ -3298,7 +3298,7 @@ _0817E6F0: .4byte _0817E760 _0817E760: ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -3330,7 +3330,7 @@ _0817E79C: lsls r2, r0, 4 ldr r4, =0x0000ffff ldr r1, [r1] - ldr r3, =gBankAttacker + ldr r3, =gBattleAttacker ldrh r0, [r1] cmp r6, r0 bne _0817E7E0 @@ -3708,15 +3708,15 @@ sub_817EA80: @ 817EA80 movs r1, 0x81 lsls r1, 2 adds r5, r0, r1 - ldr r3, =gBankAttacker + ldr r3, =gBattleAttacker mov r8, r3 ldrb r0, [r3] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gBankDefender + ldr r0, =gBattleDefender ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r2, r0, 24 lsls r0, r4, 1 @@ -4006,7 +4006,7 @@ _0817ECCC: lsrs r0, 5 subs r6, r0, 0x1 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -4165,7 +4165,7 @@ _0817EE1C: bne _0817EEBC adds r2, r4, 0 ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -4269,9 +4269,9 @@ sub_817EECC: @ 817EECC beq _0817EEE6 b _0817F1FA _0817EEE6: - ldr r4, =gBankAttacker + ldr r4, =gBattleAttacker ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 cmp r0, 0x1 @@ -4291,7 +4291,7 @@ _0817EEF8: bgt _0817EF10 b _0817F1FA _0817EF10: - ldr r0, =gBankDefender + ldr r0, =gBattleDefender ldrb r0, [r0] muls r0, r1 adds r0, r5 @@ -4367,7 +4367,7 @@ _0817EF8A: beq _0817EF98 b _0817F1FA _0817EF98: - ldr r2, =gBankAttacker + ldr r2, =gBattleAttacker ldrb r0, [r2] adds r0, r6 ldrb r0, [r0] @@ -4386,11 +4386,11 @@ _0817EF98: mov r10, r3 mov r8, r0 add r7, sp, 0x10 - ldr r4, =gBankDefender + ldr r4, =gBattleDefender mov r9, r4 _0817EFC2: lsls r1, r5, 1 - ldr r6, =gBankAttacker + ldr r6, =gBattleAttacker ldrb r0, [r6] movs r2, 0x58 muls r0, r2 @@ -4414,13 +4414,13 @@ _0817EFC2: ldr r4, =gSideStatuses mov r1, r9 ldrb r0, [r1] - bl GetBankPosition + bl GetBattlerPosition movs r1, 0x1 ands r1, r0 lsls r1, 1 adds r1, r4 ldrh r3, [r1] - ldr r2, =gBankAttacker + ldr r2, =gBattleAttacker ldrb r0, [r2] movs r4, 0x58 muls r0, r4 @@ -4437,7 +4437,7 @@ _0817EFC2: str r4, [sp] movs r4, 0 str r4, [sp, 0x4] - ldr r6, =gBankAttacker + ldr r6, =gBattleAttacker ldrb r4, [r6] str r4, [sp, 0x8] mov r6, r9 @@ -4448,7 +4448,7 @@ _0817EFC2: ldr r4, =gBattleMoveDamage str r3, [r4] ldr r1, =gStatuses3 - ldr r2, =gBankAttacker + ldr r2, =gBattleAttacker ldrb r0, [r2] lsls r0, 2 adds r0, r1 @@ -4472,7 +4472,7 @@ _0817EFC2: str r0, [r4] _0817F06A: ldr r0, =gProtectStructs - ldr r6, =gBankAttacker + ldr r6, =gBattleAttacker ldrb r1, [r6] lsls r1, 4 adds r1, r0 @@ -4513,7 +4513,7 @@ _0817F0B4: cmp r5, 0x3 ble _0817EFC2 movs r5, 0 - ldr r3, =gBankAttacker + ldr r3, =gBattleAttacker ldr r6, =gMoveSelectionCursor ldr r4, =gBattlePartyID mov r8, r4 @@ -4545,9 +4545,9 @@ _0817F0D8: movs r7, 0 _0817F0F6: movs r5, 0 - ldr r4, =gBankDefender + ldr r4, =gBattleDefender ldr r6, =gEnemyParty - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] add r0, r10 ldrb r3, [r0] @@ -4582,7 +4582,7 @@ _0817F11A: adds r6, r0, 0 lsls r6, 16 lsrs r6, 16 - ldr r2, =gBankAttacker + ldr r2, =gBattleAttacker ldrb r0, [r2] lsls r0, 1 add r0, r8 @@ -4598,7 +4598,7 @@ _0817F11A: adds r1, r0, 0 lsls r1, 16 lsrs r1, 16 - ldr r4, =gBankAttacker + ldr r4, =gBattleAttacker ldrb r3, [r4] mov r2, r10 adds r0, r3, r2 @@ -4625,7 +4625,7 @@ _0817F1D4: _0817F1DC: ldr r2, =gBattleMoveDamage ldr r1, =gMoveSelectionCursor - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] adds r0, r1 ldrb r0, [r0] @@ -4695,7 +4695,7 @@ _0817F270: cmp r2, 0x95 bne _0817F294 ldr r2, =gBattleMons - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r1, [r0] movs r0, 0x58 muls r0, r1 @@ -4801,7 +4801,7 @@ GetBankMoveSlotId: @ 817F33C lsls r1, 16 lsrs r7, r1, 16 adds r0, r5, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 ldr r6, =gEnemyParty cmp r0, 0 diff --git a/asm/contest.s b/asm/contest.s index ba451fbdb..8760464aa 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -1048,7 +1048,7 @@ _080D8004: bl sub_80DC594 bl sub_80DC5E8 bl sub_80DC7EC - ldr r1, =gBankPositions + ldr r1, =gBattlerPositions strb r4, [r1] movs r0, 0x1 strb r0, [r1, 0x1] @@ -1058,9 +1058,9 @@ _080D8004: strb r2, [r1, 0x3] ldr r0, =gBattleTypeFlags str r4, [r0] - ldr r4, =gBankAttacker + ldr r4, =gBattleAttacker strb r2, [r4] - ldr r0, =gBankDefender + ldr r0, =gBattleDefender strb r3, [r0] bl sub_80DB0C4 ldr r2, =gBankSpriteIds @@ -2548,7 +2548,7 @@ _080D8DD0: adds r4, r0 strh r5, [r4, 0xC] ldr r1, =gBankSpriteIds - ldr r0, =gBankAttacker + ldr r0, =gBattleAttacker ldrb r0, [r0] adds r0, r1 strb r5, [r0] @@ -13798,7 +13798,7 @@ sub_80DEA20: @ 80DEA20 bl CreateInvisibleSpriteWithCallback ldr r1, =gBankSpriteIds strb r0, [r1, 0x3] - ldr r0, =gBankDefender + ldr r0, =gBattleDefender ldrb r0, [r0] adds r0, r1 ldrb r1, [r0] @@ -13905,12 +13905,12 @@ _080DEAD0: .4byte _080DEB60 .4byte _080DEB60 _080DEB54: - ldr r1, =gBankDefender + ldr r1, =gBattleDefender movs r0, 0x2 b _080DEB64 .pool _080DEB60: - ldr r1, =gBankDefender + ldr r1, =gBattleDefender movs r0, 0x3 _080DEB64: strb r0, [r1] diff --git a/asm/party_menu.s b/asm/party_menu.s index 9232d0ac6..6112d2413 100644 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -16041,7 +16041,7 @@ _081B8AF8: b _081B8B24 _081B8AFC: adds r0, r4, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _081B8B1E @@ -16060,7 +16060,7 @@ _081B8B1E: lsls r0, 24 lsrs r4, r0, 24 _081B8B24: - ldr r0, =gBattleBanksCount + ldr r0, =gBattlersCount ldrb r0, [r0] cmp r4, r0 bcc _081B8AFC @@ -16228,7 +16228,7 @@ _081B8CBE: bne _081B8CFC movs r5, 0x1 movs r0, 0 - bl GetBankByPosition + bl GetBattlerAtPosition mov r2, sp ldr r1, =gBattlePartyID lsls r0, 24 @@ -16255,7 +16255,7 @@ _081B8CF0: _081B8CFC: movs r5, 0x2 movs r0, 0 - bl GetBankByPosition + bl GetBattlerAtPosition mov r1, sp ldr r4, =gBattlePartyID lsls r0, 24 @@ -16264,7 +16264,7 @@ _081B8CFC: ldrh r0, [r0] strb r0, [r1] movs r0, 0x2 - bl GetBankByPosition + bl GetBattlerAtPosition mov r1, sp lsls r0, 24 lsrs r0, 23 @@ -16339,24 +16339,24 @@ sub_81B8D88: @ 81B8D88 lsrs r7, r1, 24 lsls r0, 24 lsrs r0, 24 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _081B8DB0 movs r0, 0 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r4, r0, 24 movs r0, 0x2 b _081B8DBC _081B8DB0: movs r0, 0x1 - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r4, r0, 24 movs r0, 0x3 _081B8DBC: - bl GetBankByPosition + bl GetBattlerAtPosition lsls r0, 24 lsrs r6, r0, 24 bl sub_81B1250 diff --git a/asm/pokemon_1.s b/asm/pokemon_1.s index 15b4af009..0ab5a3307 100644 --- a/asm/pokemon_1.s +++ b/asm/pokemon_1.s @@ -581,7 +581,7 @@ _080689E4: beq _080689CE _080689F4: adds r0, r5, 0 - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 beq _080689CE diff --git a/asm/pokemon_item_effect.s b/asm/pokemon_item_effect.s index fb8ea0d3c..6da70ff2f 100644 --- a/asm/pokemon_item_effect.s +++ b/asm/pokemon_item_effect.s @@ -114,17 +114,17 @@ _0806BDC4: lsrs r1, r0, 24 cmp r1, 0 beq _0806BE64 - ldr r0, =gActiveBank + ldr r0, =gActiveBattler strb r2, [r0] ldrb r0, [r0] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 negs r1, r0 orrs r1, r0 lsrs r1, 31 str r1, [sp, 0x1C] - ldr r0, =gBattleBanksCount + ldr r0, =gBattlersCount ldr r4, [sp, 0xC] subs r4, 0xD ldrb r0, [r0] @@ -148,7 +148,7 @@ _0806BE3C: ldr r1, [sp, 0x1C] adds r1, 0x2 str r1, [sp, 0x1C] - ldr r0, =gBattleBanksCount + ldr r0, =gBattlersCount ldrb r0, [r0] cmp r1, r0 bge _0806BE70 @@ -165,7 +165,7 @@ _0806BE3C: b _0806BE70 .pool _0806BE64: - ldr r0, =gActiveBank + ldr r0, =gActiveBattler strb r1, [r0] movs r3, 0x4 str r3, [sp, 0x38] @@ -200,7 +200,7 @@ _0806BE9A: ands r0, r1 cmp r0, 0 beq _0806BECC - ldr r0, =gActiveBank + ldr r0, =gActiveBattler ldrb r1, [r0] lsls r0, r1, 3 subs r0, r1 @@ -297,7 +297,7 @@ _0806BF76: cmp r0, 0 beq _0806BFA4 ldr r1, =gBattleMons - ldr r0, =gActiveBank + ldr r0, =gActiveBattler ldrb r2, [r0] movs r0, 0x58 muls r0, r2 @@ -323,7 +323,7 @@ _0806BFA4: bl _0806CD4C _0806BFB2: ldr r6, =gBattleMons - ldr r5, =gActiveBank + ldr r5, =gActiveBattler ldrb r0, [r5] movs r4, 0x58 muls r0, r4 @@ -362,7 +362,7 @@ _0806BFFC: cmp r3, 0 beq _0806C042 ldr r7, =gBattleMons - ldr r5, =gActiveBank + ldr r5, =gActiveBattler ldrb r0, [r5] movs r4, 0x58 muls r0, r4 @@ -396,7 +396,7 @@ _0806C042: bl _0806CD4C _0806C050: ldr r6, =gBattleMons - ldr r5, =gActiveBank + ldr r5, =gActiveBattler ldrb r0, [r5] movs r4, 0x58 muls r0, r4 @@ -433,7 +433,7 @@ _0806C08C: cmp r3, 0 beq _0806C0D2 ldr r7, =gBattleMons - ldr r5, =gActiveBank + ldr r5, =gActiveBattler ldrb r0, [r5] movs r4, 0x58 muls r0, r4 @@ -467,7 +467,7 @@ _0806C0D2: bl _0806CD4C _0806C0E0: ldr r6, =gBattleMons - ldr r5, =gActiveBank + ldr r5, =gActiveBattler ldrb r0, [r5] movs r4, 0x58 muls r0, r4 @@ -506,9 +506,9 @@ _0806C120: cmp r0, 0 beq _0806C168 ldr r5, =gSideTimers - ldr r4, =gActiveBank + ldr r4, =gActiveBattler ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 lsls r1, r0, 1 @@ -519,7 +519,7 @@ _0806C120: cmp r0, 0 bne _0806C168 ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 lsrs r0, 24 lsls r1, r0, 1 @@ -965,7 +965,7 @@ _0806C4FC: ldr r3, [sp, 0x38] cmp r3, 0x4 beq _0806C55C - ldr r2, =gAbsentBankFlags + ldr r2, =gAbsentBattlerFlags ldr r1, =gBitTable lsls r0, r3, 2 adds r0, r1 @@ -983,14 +983,14 @@ _0806C4FC: lsrs r1, 24 ldr r0, [sp, 0x38] bl CopyPlayerPartyMonToBattleData - ldr r0, =gActiveBank + ldr r0, =gActiveBattler ldrb r0, [r0] b _0806C574 .pool _0806C55C: - ldr r3, =gAbsentBankFlags + ldr r3, =gAbsentBattlerFlags ldr r1, =gBitTable - ldr r2, =gActiveBank + ldr r2, =gActiveBattler ldrb r0, [r2] eors r0, r4 lsls r0, 2 @@ -1001,7 +1001,7 @@ _0806C55C: strb r0, [r3] ldrb r0, [r2] _0806C574: - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0806C5B2 @@ -1135,9 +1135,9 @@ _0806C65E: ands r0, r3 cmp r0, 0 bne _0806C6EC - ldr r4, =gActiveBank + ldr r4, =gActiveBattler ldrb r0, [r4] - bl GetBankSide + bl GetBattlerSide lsls r0, 24 cmp r0, 0 bne _0806C6EC diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 8ab5ea2f1..8c39348e2 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -735,7 +735,7 @@ BattleScript_AlreadyPoisoned:: goto BattleScript_MoveEnd BattleScript_ImmunityProtected:: - copybyte gEffectBank, gBankDefender + copybyte gEffectBank, gBattleDefender setbyte cMULTISTRING_CHOOSER, 0x0 call BattleScript_PSNPrevention goto BattleScript_MoveEnd @@ -1055,7 +1055,7 @@ BattleScript_AlreadyParalyzed:: goto BattleScript_MoveEnd BattleScript_LimberProtected:: - copybyte gEffectBank, gBankDefender + copybyte gEffectBank, gBattleDefender setbyte cMULTISTRING_CHOOSER, 0x0 call BattleScript_PRLZPrevention goto BattleScript_MoveEnd @@ -1513,7 +1513,7 @@ BattleScript_EffectCurse:: jumpifstat ATTACKER, NOT_EQUAL, ATK, 0xC, BattleScript_CurseTrySpeed jumpifstat ATTACKER, EQUAL, DEF, 0xC, BattleScript_ButItFailed BattleScript_CurseTrySpeed:: - copybyte gBankDefender, gBankAttacker + copybyte gBattleDefender, gBattleAttacker setbyte sANIM_TURN, 0x1 attackanimation waitanimation @@ -1534,7 +1534,7 @@ BattleScript_CurseTryDefence:: BattleScript_CurseEnd:: goto BattleScript_MoveEnd BattleScript_GhostCurse:: - jumpifbytenotequal gBankAttacker, gBankDefender, BattleScript_DoGhostCurse + jumpifbytenotequal gBattleAttacker, gBattleDefender, BattleScript_DoGhostCurse getmovetarget ATTACKER BattleScript_DoGhostCurse:: attackcanceler @@ -1603,7 +1603,7 @@ BattleScript_PerishSongLoop:: jumpifability SCRIPTING_BANK, ABILITY_SOUNDPROOF, BattleScript_PerishSongNotAffected BattleScript_PerishSongLoopIncrement:: addbyte sBANK, 0x1 - jumpifbytenotequal sBANK, gBattleBanksCount, BattleScript_PerishSongLoop + jumpifbytenotequal sBANK, gBattlersCount, BattleScript_PerishSongLoop goto BattleScript_MoveEnd BattleScript_PerishSongNotAffected:: @@ -2217,7 +2217,7 @@ BattleScript_EffectWillOWisp:: goto BattleScript_MoveEnd BattleScript_WaterVeilPrevents:: - copybyte gEffectBank, gBankDefender + copybyte gEffectBank, gBattleDefender setbyte cMULTISTRING_CHOOSER, 0x0 call BattleScript_BRNPrevention goto BattleScript_MoveEnd @@ -2598,11 +2598,11 @@ BattleScript_EffectTeeterDance:: attackcanceler attackstring ppreduce - setbyte gBankDefender, 0x0 + setbyte gBattleDefender, 0x0 BattleScript_TeeterDanceLoop:: movevaluescleanup setmoveeffect EFFECT_CONFUSION - jumpifbyteequal gBankAttacker, gBankDefender, BattleScript_TeeterDanceLoopIncrement + jumpifbyteequal gBattleAttacker, gBattleDefender, BattleScript_TeeterDanceLoopIncrement jumpifability TARGET, ABILITY_OWN_TEMPO, BattleScript_TeeterDanceOwnTempoPrevents jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_TeeterDanceSubstitutePrevents jumpifstatus2 TARGET, STATUS2_CONFUSION, BattleScript_TeeterDanceAlreadyConfused @@ -2618,8 +2618,8 @@ BattleScript_TeeterDanceDoMoveEndIncrement:: setbyte sMOVEEND_STATE, 0x0 moveend 0x2, 0x10 BattleScript_TeeterDanceLoopIncrement:: - addbyte gBankDefender, 0x1 - jumpifbytenotequal gBankDefender, gBattleBanksCount, BattleScript_TeeterDanceLoop + addbyte gBattleDefender, 0x1 + jumpifbytenotequal gBattleDefender, gBattlersCount, BattleScript_TeeterDanceLoop end BattleScript_TeeterDanceOwnTempoPrevents:: @@ -2935,7 +2935,7 @@ BattleScript_82DA908:: switchinanim GBANK_1, FALSE waitstate switchineffects 5 - jumpifbytenotequal gBank1, gBattleBanksCount, BattleScript_82DA908 + jumpifbytenotequal gBank1, gBattlersCount, BattleScript_82DA908 BattleScript_82DA92C:: end2 @@ -3228,7 +3228,7 @@ BattleScript_DamagingWeatherContinues:: playanimation2 ATTACKER, sANIM_ARG1, NULL setbyte gBattleCommunication, 0x0 BattleScript_DamagingWeatherLoop:: - copyarraywithindex gBankAttacker, gBanksByTurnOrder, gBattleCommunication, 0x1 + copyarraywithindex gBattleAttacker, gBattleTurnOrder, gBattleCommunication, 0x1 weatherdamage jumpifword EQUAL, gBattleMoveDamage, 0x0, BattleScript_DamagingWeatherLoopIncrement printfromtable gSandStormHailDmgStringIds @@ -3243,7 +3243,7 @@ BattleScript_DamagingWeatherLoop:: BattleScript_DamagingWeatherLoopIncrement:: jumpifbyte NOT_EQUAL, gBattleOutcome, 0, BattleScript_DamagingWeatherContinuesEnd addbyte gBattleCommunication, 0x1 - jumpifbytenotequal gBattleCommunication, gBattleBanksCount, BattleScript_DamagingWeatherLoop + jumpifbytenotequal gBattleCommunication, gBattlersCount, BattleScript_DamagingWeatherLoop BattleScript_DamagingWeatherContinuesEnd:: bicword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_GRUDGE end2 @@ -3521,7 +3521,7 @@ BattleScript_RapidSpinAway:: BattleScript_WrapFree:: printstring STRINGID_PKMNGOTFREE waitmessage 0x40 - copybyte gBankDefender, sBANK + copybyte gBattleDefender, sBANK return BattleScript_LeechSeedFree:: @@ -4032,7 +4032,7 @@ BattleScript_WeatherFormChanges:: BattleScript_WeatherFormChangesLoop:: trycastformdatachange addbyte sBANK, 0x1 - jumpifbytenotequal sBANK, gBattleBanksCount, BattleScript_WeatherFormChangesLoop + jumpifbytenotequal sBANK, gBattlersCount, BattleScript_WeatherFormChangesLoop return BattleScript_CastformChange:: @@ -4053,7 +4053,7 @@ BattleScript_82DB4B8:: BattleScript_82DB4BE:: pause 0x20 BattleScript_82DB4C1:: - setbyte gBankDefender, 0x0 + setbyte gBattleDefender, 0x0 setstatchanger ATK, 1, TRUE BattleScript_82DB4CD:: trygetintimidatetarget BattleScript_82DB51B @@ -4068,7 +4068,7 @@ BattleScript_82DB4CD:: printstring STRINGID_PKMNCUTSATTACKWITH waitmessage 0x40 BattleScript_82DB510:: - addbyte gBankDefender, 0x1 + addbyte gBattleDefender, 0x1 goto BattleScript_82DB4CD BattleScript_82DB51B:: return @@ -4474,7 +4474,7 @@ BattleScript_82DB887:: waitmessage 0x40 BattleScript_82DB89D:: addbyte gBattleCommunication + 1, 0x1 - jumpifbytenotequal gBattleCommunication + 1, gBattleBanksCount, BattleScript_82DB887 + jumpifbytenotequal gBattleCommunication + 1, gBattlersCount, BattleScript_82DB887 setbyte gBattleCommunication, 0x0 setbyte gBattleCommunication + 1, 0x0 end2 diff --git a/include/battle.h b/include/battle.h index a437f41d4..eafa72098 100644 --- a/include/battle.h +++ b/include/battle.h @@ -11,46 +11,45 @@ #include "battle_bg.h" /* - * Banks are a name given to what could be called a 'battlerId' or 'monControllerId'. * 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. * The second bit determines whether the pokemon is on the left or right of the * given side. Note that the opponent's mons are drawn opposite because the position - * numbers correspond to their perspective. The bank number is usually the same + * numbers correspond to their perspective. The battler number is usually the same * as the position, except in the case of link battles. * - * +---------------------- + - * | Opponent's side:| - * | 3 1 | - * | | - * | | - * |Player's side: | - * | 0 2 | - * ------------------------+ - * | | - * | | - * +-----------------------+ + * + ------------------------- + + * | Opponent's side | + * | 3 1 | + * | | + * | | + * | Player's side | + * | 0 2 | + * ----------------------------+ + * | | + * | | + * +---------------------------+ */ -#define BATTLE_BANKS_COUNT 4 +#define MAX_BATTLERS_COUNT 4 #define B_POSITION_PLAYER_LEFT 0 #define B_POSITION_OPPONENT_LEFT 1 #define B_POSITION_PLAYER_RIGHT 2 #define B_POSITION_OPPONENT_RIGHT 3 -#define B_POSITION_PARTNER(position) ((position) ^ 2) +#define B_POSITION_PARTNER(position) ((position) ^ 2) #define B_POSITION_OPPOSITE(position) ((position) ^ 1) -#define SIDE_PLAYER 0x0 -#define SIDE_OPPONENT 0x1 +#define B_SIDE_PLAYER 0 +#define B_SIDE_OPPONENT 1 -#define BIT_SIDE 0x1 -#define BIT_MON 0x2 +#define BIT_SIDE 1 +#define BIT_FLANK 2 -#define GET_BANK_POSITION(bank) (gBankPositions[bank]) -#define GET_BANK_SIDE(bank) (GetBankPosition(bank) & BIT_SIDE) -#define GET_BANK_SIDE2(bank) (GET_BANK_POSITION(bank) & BIT_SIDE) +#define GET_BATTLER_POSITION(battler) (gBattlerPositions[battler]) +#define GET_BATTLER_SIDE(battler) (GetBattlerPosition(battler) & BIT_SIDE) +#define GET_BATTLER_SIDE2(battler) (GET_BATTLER_POSITION(battler) & BIT_SIDE) // Battle Type Flags @@ -133,8 +132,8 @@ extern u8 gBattleOutcome; #define STATUS2_LOCK_CONFUSE 0x00000C00 #define STATUS2_MULTIPLETURNS 0x00001000 #define STATUS2_WRAPPED 0x0000E000 -#define STATUS2_INFATUATION 0x000F0000 // 4 bits, one for every bank -#define STATUS2_INFATUATED_WITH(bank) (gBitTable[bank] << 16) +#define STATUS2_INFATUATION 0x000F0000 // 4 bits, one for every battler +#define STATUS2_INFATUATED_WITH(battler) (gBitTable[battler] << 16) #define STATUS2_FOCUS_ENERGY 0x00100000 #define STATUS2_TRANSFORMED 0x00200000 #define STATUS2_RECHARGE 0x00400000 @@ -148,7 +147,7 @@ extern u8 gBattleOutcome; #define STATUS2_DEFENSE_CURL 0x40000000 #define STATUS2_TORMENT 0x80000000 -// Seems like per-bank statuses. Not quite sure how to categorize these +// Seems like per-battler statuses. Not quite sure how to categorize these #define STATUS3_LEECHSEED_BANK 0x3 #define STATUS3_LEECHSEED 0x4 #define STATUS3_ALWAYS_HITS 0x18 // two bits @@ -169,7 +168,7 @@ extern u8 gBattleOutcome; #define STATUS3_TRACE 0x100000 #define STATUS3_SEMI_INVULNERABLE (STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER) -extern u32 gStatuses3[BATTLE_BANKS_COUNT]; +extern u32 gStatuses3[MAX_BATTLERS_COUNT]; // @@ -197,8 +196,8 @@ extern u32 gStatuses3[BATTLE_BANKS_COUNT]; #define HITMARKER_OBEYS 0x02000000 #define HITMARKER_x4000000 0x04000000 #define HITMARKER_x8000000 0x08000000 -#define HITMARKER_FAINTED(bank) (gBitTable[bank] << 0x1C) -#define HITMARKER_UNK(bank) (0x10000000 << bank) +#define HITMARKER_FAINTED(battler) (gBitTable[battler] << 0x1C) +#define HITMARKER_UNK(battler) (0x10000000 << battler) extern u32 gHitMarker; @@ -339,7 +338,7 @@ struct TrainerMonNoItemDefaultMoves u16 species; }; -u8 GetBankSide(u8 bank); +u8 GetBattlerSide(u8 battler); struct TrainerMonItemDefaultMoves { @@ -434,7 +433,7 @@ struct DisableStruct /*0x1A*/ u8 unk1A[2]; }; -extern struct DisableStruct gDisableStructs[BATTLE_BANKS_COUNT]; +extern struct DisableStruct gDisableStructs[MAX_BATTLERS_COUNT]; struct ProtectStruct { @@ -474,7 +473,7 @@ struct ProtectStruct /* field_E */ u16 fieldE; }; -extern struct ProtectStruct gProtectStructs[BATTLE_BANKS_COUNT]; +extern struct ProtectStruct gProtectStructs[MAX_BATTLERS_COUNT]; struct SpecialStatus { @@ -496,7 +495,7 @@ struct SpecialStatus u8 field13; }; -extern struct SpecialStatus gSpecialStatuses[BATTLE_BANKS_COUNT]; +extern struct SpecialStatus gSpecialStatuses[MAX_BATTLERS_COUNT]; struct SideTimer { @@ -518,12 +517,12 @@ extern struct SideTimer gSideTimers[]; struct WishFutureKnock { - u8 futureSightCounter[BATTLE_BANKS_COUNT]; - u8 futureSightAttacker[BATTLE_BANKS_COUNT]; - s32 futureSightDmg[BATTLE_BANKS_COUNT]; - u16 futureSightMove[BATTLE_BANKS_COUNT]; - u8 wishCounter[BATTLE_BANKS_COUNT]; - u8 wishUserID[BATTLE_BANKS_COUNT]; + u8 futureSightCounter[MAX_BATTLERS_COUNT]; + u8 futureSightAttacker[MAX_BATTLERS_COUNT]; + s32 futureSightDmg[MAX_BATTLERS_COUNT]; + u16 futureSightMove[MAX_BATTLERS_COUNT]; + u8 wishCounter[MAX_BATTLERS_COUNT]; + u8 wishUserID[MAX_BATTLERS_COUNT]; u8 weatherDuration; u8 knockedOffPokes[2]; }; @@ -546,16 +545,16 @@ struct AI_ThinkingStruct struct UsedMoves { - u16 moves[BATTLE_BANKS_COUNT]; - u16 unknown[BATTLE_BANKS_COUNT]; + u16 moves[MAX_BATTLERS_COUNT]; + u16 unknown[MAX_BATTLERS_COUNT]; }; struct BattleHistory { - struct UsedMoves usedMoves[BATTLE_BANKS_COUNT]; - u8 abilities[BATTLE_BANKS_COUNT]; - u8 itemEffects[BATTLE_BANKS_COUNT]; - u16 trainerItems[BATTLE_BANKS_COUNT]; + struct UsedMoves usedMoves[MAX_BATTLERS_COUNT]; + u8 abilities[MAX_BATTLERS_COUNT]; + u8 itemEffects[MAX_BATTLERS_COUNT]; + u16 trainerItems[MAX_BATTLERS_COUNT]; u8 itemsNo; }; @@ -661,9 +660,9 @@ struct BattleStruct u16 expValue; u8 field_52; u8 sentInPokes; - bool8 selectionScriptFinished[BATTLE_BANKS_COUNT]; + bool8 selectionScriptFinished[MAX_BATTLERS_COUNT]; u8 field_58[4]; - u8 monToSwitchIntoId[BATTLE_BANKS_COUNT]; + u8 monToSwitchIntoId[MAX_BATTLERS_COUNT]; u8 field_60[4][3]; u8 runTries; u8 caughtMonNick[11]; @@ -675,8 +674,8 @@ struct BattleStruct u8 field_7D; u8 field_7E; u8 formToChangeInto; - u8 chosenMovePositions[BATTLE_BANKS_COUNT]; - u8 stateIdAfterSelScript[BATTLE_BANKS_COUNT]; + u8 chosenMovePositions[MAX_BATTLERS_COUNT]; + u8 stateIdAfterSelScript[MAX_BATTLERS_COUNT]; u8 field_88; u8 field_89; u8 field_8A; @@ -709,12 +708,12 @@ struct BattleStruct u8 synchronizeMoveEffect; u8 field_B3; void (*savedCallback)(void); - u16 usedHeldItems[BATTLE_BANKS_COUNT]; + u16 usedHeldItems[MAX_BATTLERS_COUNT]; u8 chosenItem[4]; // why is this an u8? u8 AI_itemType[2]; u8 AI_itemFlags[2]; - u16 choicedMove[BATTLE_BANKS_COUNT]; - u16 changedItems[BATTLE_BANKS_COUNT]; + u16 choicedMove[MAX_BATTLERS_COUNT]; + u16 changedItems[MAX_BATTLERS_COUNT]; u8 intimidateBank; u8 switchInItemsCounter; u8 field_DA; @@ -722,7 +721,7 @@ struct BattleStruct u8 fillerDC[0xDF-0xDC]; u8 field_DF; u8 mirrorMoveArrays[32]; - u16 castformPalette[BATTLE_BANKS_COUNT][16]; + u16 castformPalette[MAX_BATTLERS_COUNT][16]; u8 field_180; u8 field_181; u8 field_182; @@ -735,7 +734,7 @@ struct BattleStruct u8 field_1A4[96]; u8 field_204[104]; u8 field_26C[40]; - u8 AI_monToSwitchIntoId[BATTLE_BANKS_COUNT]; + u8 AI_monToSwitchIntoId[MAX_BATTLERS_COUNT]; u8 field_298[8]; u8 field_2A0; u8 field_2A1; @@ -839,7 +838,7 @@ struct BattleScripting u8 atk49_state; u8 bankWithAbility; u8 multihitMoveEffect; - u8 bank; + u8 battler; u8 animTurn; u8 animTargetsHit; u8 statChanger; @@ -871,9 +870,9 @@ enum }; // rom_80A5C6C -u8 GetBankSide(u8 bank); -u8 GetBankPosition(u8 bank); -u8 GetBankByPosition(u8 bank); +u8 GetBattlerSide(u8 bank); +u8 GetBattlerPosition(u8 bank); +u8 GetBattlerAtPosition(u8 bank); struct BattleSpriteInfo { diff --git a/include/battle_anim.h b/include/battle_anim.h index c208ee1a7..746e19bfe 100644 --- a/include/battle_anim.h +++ b/include/battle_anim.h @@ -47,7 +47,7 @@ extern s16 gBattleAnimArgs[ANIM_ARGS_COUNT]; extern u8 gAnimMoveTurn; extern u8 gAnimBankAttacker; extern u8 gAnimBankTarget; -extern u16 gAnimSpeciesByBanks[BATTLE_BANKS_COUNT]; +extern u16 gAnimSpeciesByBanks[MAX_BATTLERS_COUNT]; extern u8 gUnknown_02038440; void ClearBattleAnimationVars(void); diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 5dd9ecdc0..2ddc3fdfe 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -45,17 +45,17 @@ AI scripts. */ extern u32 gBattleTypeFlags; -extern u8 gActiveBank; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern u8 gActiveBattler; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern u16 gCurrentMove; -extern u8 gBankDefender; -extern u8 gAbsentBankFlags; -extern u16 gLastMoves[BATTLE_BANKS_COUNT]; +extern u8 gBattleDefender; +extern u8 gAbsentBattlerFlags; +extern u16 gLastMoves[MAX_BATTLERS_COUNT]; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; -extern u32 gStatuses3[BATTLE_BANKS_COUNT]; +extern u32 gStatuses3[MAX_BATTLERS_COUNT]; extern u16 gSideStatuses[2]; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u16 gDynamicBasePower; extern u8 gMoveResultFlags; extern s32 gBattleMoveDamage; @@ -352,7 +352,7 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves) defaultScoreMoves >>= 1; } - moveLimitations = CheckMoveLimitations(gActiveBank, 0, 0xFF); + moveLimitations = CheckMoveLimitations(gActiveBattler, 0, 0xFF); // ignore moves that aren't possible to use for (i = 0; i < 4; i++) @@ -363,18 +363,18 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves) AI_THINKING_STRUCT->simulatedRNG[i] = 100 - (Random() % 16); } gBattleResources->AI_ScriptsStack->size = 0; - sBank_AI = gActiveBank; + sBank_AI = gActiveBattler; // decide a random target bank in doubles if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - gBankDefender = (Random() & BIT_MON) + (GetBankSide(gActiveBank) ^ BIT_SIDE); - if (gAbsentBankFlags & gBitTable[gBankDefender]) - gBankDefender ^= BIT_MON; + gBattleDefender = (Random() & BIT_FLANK) + (GetBattlerSide(gActiveBattler) ^ BIT_SIDE); + if (gAbsentBattlerFlags & gBitTable[gBattleDefender]) + gBattleDefender ^= BIT_FLANK; } // in singles there's only one choice else { - gBankDefender = sBank_AI ^ BIT_SIDE; + gBattleDefender = sBank_AI ^ BIT_SIDE; } if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) @@ -491,7 +491,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void) else BattleAI_SetupAIData(0xF); - gBankDefender = i; + gBattleDefender = i; if ((i & BIT_SIDE) != (sBank_AI & BIT_SIDE)) RecordLastUsedMoveByTarget(); @@ -542,7 +542,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void) bestMovePointsForTarget[i] = mostViableMovesScores[0]; // don't use a move against ally if it has less than 100 pts - if (i == (sBank_AI ^ BIT_MON) && bestMovePointsForTarget[i] < 100) + if (i == (sBank_AI ^ BIT_FLANK) && bestMovePointsForTarget[i] < 100) { bestMovePointsForTarget[i] = -1; mostViableMovesScores[0] = mostViableMovesScores[0]; // needed to match @@ -573,8 +573,8 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void) } } - gBankDefender = mostViableTargetsArray[Random() % mostViableTargetsNo]; - return actionOrMoveIndex[gBankDefender]; + gBattleDefender = mostViableTargetsArray[Random() % mostViableTargetsNo]; + return actionOrMoveIndex[gBattleDefender]; } static void BattleAI_DoAIProcessing(void) @@ -627,12 +627,12 @@ static void RecordLastUsedMoveByTarget(void) for (i = 0; i < 4; i++) { - if (gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] == gLastMoves[gBankDefender]) + if (gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] == gLastMoves[gBattleDefender]) break; - if (gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] != gLastMoves[gBankDefender] // HACK: This redundant condition is a hack to make the asm match. - && gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] == 0) + if (gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] != gLastMoves[gBattleDefender] // HACK: This redundant condition is a hack to make the asm match. + && gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] == 0) { - gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] = gLastMoves[gBankDefender]; + gBattleResources->battleHistory->usedMoves[gBattleDefender].moves[i] = gLastMoves[gBattleDefender]; break; } } @@ -723,7 +723,7 @@ static void BattleAICmd_if_hp_less_than(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -738,7 +738,7 @@ static void BattleAICmd_if_hp_more_than(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -753,7 +753,7 @@ static void BattleAICmd_if_hp_equal(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -768,7 +768,7 @@ static void BattleAICmd_if_hp_not_equal(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -784,7 +784,7 @@ static void BattleAICmd_if_status(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -802,7 +802,7 @@ static void BattleAICmd_if_not_status(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -820,7 +820,7 @@ static void BattleAICmd_if_status2(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -838,7 +838,7 @@ static void BattleAICmd_if_not_status2(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -856,7 +856,7 @@ static void BattleAICmd_if_status3(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -874,7 +874,7 @@ static void BattleAICmd_if_not_status3(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -892,9 +892,9 @@ static void BattleAICmd_if_side_affecting(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; - side = GET_BANK_SIDE(bank); + side = GET_BATTLER_SIDE(bank); status = AIScriptRead32(gAIScriptPtr + 2); if ((gSideStatuses[side] & status) != 0) @@ -911,9 +911,9 @@ static void BattleAICmd_if_not_side_affecting(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; - side = GET_BANK_SIDE(bank); + side = GET_BATTLER_SIDE(bank); status = AIScriptRead32(gAIScriptPtr + 2); if ((gSideStatuses[side] & status) == 0) @@ -1126,13 +1126,13 @@ static void BattleAICmd_get_type(void) AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type1; break; case AI_TYPE1_TARGET: // target primary type - AI_THINKING_STRUCT->funcResult = gBattleMons[gBankDefender].type1; + AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleDefender].type1; break; case AI_TYPE2_USER: // AI user secondary type AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type2; break; case AI_TYPE2_TARGET: // target secondary type - AI_THINKING_STRUCT->funcResult = gBattleMons[gBankDefender].type2; + AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleDefender].type2; break; case AI_TYPE_MOVE: // type of move being pointed to AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type; @@ -1149,11 +1149,11 @@ static u8 BattleAI_GetWantedBank(u8 bank) return sBank_AI; case AI_TARGET: default: - return gBankDefender; + return gBattleDefender; case AI_USER_PARTNER: - return sBank_AI ^ BIT_MON; + return sBank_AI ^ BIT_FLANK; case AI_TARGET_PARTNER: - return gBankDefender ^ BIT_MON; + return gBattleDefender ^ BIT_FLANK; } } @@ -1212,8 +1212,8 @@ static void BattleAICmd_get_how_powerful_move_is(void) && gBattleMoves[gBattleMons[sBank_AI].moves[checkedMove]].power > 1) { gCurrentMove = gBattleMons[sBank_AI].moves[checkedMove]; - AI_CalcDmg(sBank_AI, gBankDefender); - TypeCalc(gCurrentMove, sBank_AI, gBankDefender); + AI_CalcDmg(sBank_AI, gBattleDefender); + TypeCalc(gCurrentMove, sBank_AI, gBattleDefender); moveDmgs[checkedMove] = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[checkedMove] / 100; if (moveDmgs[checkedMove] == 0) moveDmgs[checkedMove] = 1; @@ -1248,7 +1248,7 @@ static void BattleAICmd_get_last_used_bank_move(void) if (gAIScriptPtr[1] == AI_USER) AI_THINKING_STRUCT->funcResult = gLastMoves[sBank_AI]; else - AI_THINKING_STRUCT->funcResult = gLastMoves[gBankDefender]; + AI_THINKING_STRUCT->funcResult = gLastMoves[gBattleDefender]; 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) { - if (GetWhoStrikesFirst(sBank_AI, gBankDefender, TRUE) == gAIScriptPtr[1]) + if (GetWhoStrikesFirst(sBank_AI, gBattleDefender, TRUE) == gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -1279,7 +1279,7 @@ static void BattleAICmd_if_user_goes(void) static void BattleAICmd_if_user_doesnt_go(void) { - if (GetWhoStrikesFirst(sBank_AI, gBankDefender, TRUE) != gAIScriptPtr[1]) + if (GetWhoStrikesFirst(sBank_AI, gBattleDefender, TRUE) != gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -1305,9 +1305,9 @@ static void BattleAICmd_count_usable_party_mons(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(bank) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -1316,8 +1316,8 @@ static void BattleAICmd_count_usable_party_mons(void) { u32 position; bankOnField1 = gBattlePartyID[bank]; - position = GetBankPosition(bank) ^ BIT_MON; - bankOnField2 = gBattlePartyID[GetBankByPosition(position)]; + position = GetBattlerPosition(bank) ^ BIT_FLANK; + bankOnField2 = gBattlePartyID[GetBattlerAtPosition(position)]; } else // in singles there's only one bank by side { @@ -1358,9 +1358,9 @@ static void BattleAICmd_get_ability(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; - if (gActiveBank != bank) + if (gActiveBattler != bank) { if (BATTLE_HISTORY->abilities[bank] != 0) { @@ -1493,7 +1493,7 @@ static void BattleAICmd_get_highest_type_effectiveness(void) if (gCurrentMove) { - TypeCalc(gCurrentMove, sBank_AI, gBankDefender); + TypeCalc(gCurrentMove, sBank_AI, gBattleDefender); // reduce by 1/3. if (gBattleMoveDamage == 120) @@ -1528,7 +1528,7 @@ static void BattleAICmd_if_type_effectiveness(void) gBattleMoveDamage = AI_EFFECTIVENESS_x1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; - TypeCalc(gCurrentMove, sBank_AI, gBankDefender); + TypeCalc(gCurrentMove, sBank_AI, gBattleDefender); if (gBattleMoveDamage == 120) gBattleMoveDamage = AI_EFFECTIVENESS_x2; @@ -1572,11 +1572,11 @@ static void BattleAICmd_if_status_in_party(void) bank = sBank_AI; break; default: - bank = gBankDefender; + bank = gBattleDefender; break; } - party = (GetBankSide(bank) == SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + party = (GetBattlerSide(bank) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2); @@ -1609,11 +1609,11 @@ static void BattleAICmd_if_status_not_in_party(void) bank = sBank_AI; break; default: - bank = gBankDefender; + bank = gBattleDefender; break; } - party = (GetBankSide(bank) == SIDE_PLAYER) ? gPlayerParty : gEnemyParty; + party = (GetBattlerSide(bank) == B_SIDE_PLAYER) ? gPlayerParty : gEnemyParty; statusToCompareTo = AIScriptRead32(gAIScriptPtr + 2); @@ -1669,7 +1669,7 @@ static void BattleAICmd_if_stat_level_less_than(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; if (gBattleMons[bank].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); @@ -1684,7 +1684,7 @@ static void BattleAICmd_if_stat_level_more_than(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; if (gBattleMons[bank].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); @@ -1699,7 +1699,7 @@ static void BattleAICmd_if_stat_level_equal(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; if (gBattleMons[bank].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); @@ -1714,7 +1714,7 @@ static void BattleAICmd_if_stat_level_not_equal(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; if (gBattleMons[bank].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); @@ -1736,8 +1736,8 @@ static void BattleAICmd_if_can_faint(void) gMoveResultFlags = 0; gCritMultiplier = 1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; - AI_CalcDmg(sBank_AI, gBankDefender); - TypeCalc(gCurrentMove, sBank_AI, gBankDefender); + AI_CalcDmg(sBank_AI, gBattleDefender); + TypeCalc(gCurrentMove, sBank_AI, gBattleDefender); 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) gBattleMoveDamage = 1; - if (gBattleMons[gBankDefender].hp <= gBattleMoveDamage) + if (gBattleMons[gBattleDefender].hp <= gBattleMoveDamage) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1765,14 +1765,14 @@ static void BattleAICmd_if_cant_faint(void) gMoveResultFlags = 0; gCritMultiplier = 1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; - AI_CalcDmg(sBank_AI, gBankDefender); - TypeCalc(gCurrentMove, sBank_AI, gBankDefender); + AI_CalcDmg(sBank_AI, gBattleDefender); + TypeCalc(gCurrentMove, sBank_AI, gBattleDefender); gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100; // this macro is missing the damage 0 = 1 assumption. - if (gBattleMons[gBankDefender].hp > gBattleMoveDamage) + if (gBattleMons[gBattleDefender].hp > gBattleMoveDamage) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1802,7 +1802,7 @@ static void BattleAICmd_if_has_move(void) return; } case AI_USER_PARTNER: - if (gBattleMons[sBank_AI ^ BIT_MON].hp == 0) + if (gBattleMons[sBank_AI ^ BIT_FLANK].hp == 0) { gAIScriptPtr += 8; return; @@ -1811,7 +1811,7 @@ static void BattleAICmd_if_has_move(void) { for (i = 0; i < 4; i++) { - if (gBattleMons[sBank_AI ^ BIT_MON].moves[i] == *movePtr) + if (gBattleMons[sBank_AI ^ BIT_FLANK].moves[i] == *movePtr) break; } } @@ -1829,7 +1829,7 @@ static void BattleAICmd_if_has_move(void) case AI_TARGET_PARTNER: for (i = 0; i < 4; i++) { - if (BATTLE_HISTORY->usedMoves[gBankDefender].moves[i] == *movePtr) + if (BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i] == *movePtr) break; } if (i == 4) @@ -1873,7 +1873,7 @@ static void BattleAICmd_if_doesnt_have_move(void) case AI_TARGET_PARTNER: for (i = 0; i < 4; i++) { - if (BATTLE_HISTORY->usedMoves[gBankDefender].moves[i] == *movePtr) + if (BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i] == *movePtr) break; } if (i != 4) @@ -1911,8 +1911,8 @@ static void BattleAICmd_if_has_move_with_effect(void) case AI_TARGET_PARTNER: for (i = 0; i < 4; i++) { - // UB: checks sBank_AI instead of gBankDefender - if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankDefender].moves[i]].effect == gAIScriptPtr[2]) + // UB: checks sBank_AI instead of gBattleDefender + if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i]].effect == gAIScriptPtr[2]) break; } if (i == 4) @@ -1945,7 +1945,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void) case AI_TARGET_PARTNER: for (i = 0; i < 4; i++) { - if (BATTLE_HISTORY->usedMoves[gBankDefender].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankDefender].moves[i]].effect == gAIScriptPtr[2]) + if (BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleDefender].moves[i]].effect == gAIScriptPtr[2]) break; } if (i != 4) @@ -1963,7 +1963,7 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; if (gAIScriptPtr[2] == 0) { @@ -1993,7 +1993,7 @@ static void BattleAICmd_if_curr_move_disabled_or_encored(void) switch (gAIScriptPtr[1]) { case 0: - if (gDisableStructs[gActiveBank].disabledMove == AI_THINKING_STRUCT->moveConsidered) + if (gDisableStructs[gActiveBattler].disabledMove == AI_THINKING_STRUCT->moveConsidered) { gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); return; @@ -2001,7 +2001,7 @@ static void BattleAICmd_if_curr_move_disabled_or_encored(void) gAIScriptPtr += 6; return; case 1: - if (gDisableStructs[gActiveBank].encoredMove == AI_THINKING_STRUCT->moveConsidered) + if (gDisableStructs[gActiveBattler].encoredMove == AI_THINKING_STRUCT->moveConsidered) { gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); return; @@ -2041,9 +2041,9 @@ static void BattleAICmd_get_hold_effect(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; - if (gActiveBank != bank) + if (gActiveBattler != bank) AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]); else AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(gBattleMons[bank].item); @@ -2079,7 +2079,7 @@ static void BattleAICmd_get_gender(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[bank].species, gBattleMons[bank].personality); @@ -2093,7 +2093,7 @@ static void BattleAICmd_is_first_turn_for(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].isFirstTurn; @@ -2107,7 +2107,7 @@ static void BattleAICmd_get_stockpile_count(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].stockpileCounter; @@ -2128,7 +2128,7 @@ static void BattleAICmd_get_used_held_item(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; // This is likely a leftover from Ruby's code and its ugly ewram access #ifdef NONMATCHING @@ -2168,7 +2168,7 @@ static void BattleAICmd_get_protect_count(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankDefender; + bank = gBattleDefender; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].protectUses; @@ -2221,7 +2221,7 @@ static void BattleAICmd_if_level_cond(void) switch (gAIScriptPtr[1]) { case 0: // greater than - if (gBattleMons[sBank_AI].level > gBattleMons[gBankDefender].level) + if (gBattleMons[sBank_AI].level > gBattleMons[gBattleDefender].level) { gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); return; @@ -2229,7 +2229,7 @@ static void BattleAICmd_if_level_cond(void) gAIScriptPtr += 6; return; case 1: // less than - if (gBattleMons[sBank_AI].level < gBattleMons[gBankDefender].level) + if (gBattleMons[sBank_AI].level < gBattleMons[gBattleDefender].level) { gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); return; @@ -2237,7 +2237,7 @@ static void BattleAICmd_if_level_cond(void) gAIScriptPtr += 6; return; case 2: // equal - if (gBattleMons[sBank_AI].level == gBattleMons[gBankDefender].level) + if (gBattleMons[sBank_AI].level == gBattleMons[gBattleDefender].level) { gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); return; @@ -2249,7 +2249,7 @@ static void BattleAICmd_if_level_cond(void) static void BattleAICmd_if_target_taunted(void) { - if (gDisableStructs[gBankDefender].tauntTimer1 != 0) + if (gDisableStructs[gBattleDefender].tauntTimer1 != 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -2257,7 +2257,7 @@ static void BattleAICmd_if_target_taunted(void) static void BattleAICmd_if_target_not_taunted(void) { - if (gDisableStructs[gBankDefender].tauntTimer1 == 0) + if (gDisableStructs[gBattleDefender].tauntTimer1 == 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -2265,7 +2265,7 @@ static void BattleAICmd_if_target_not_taunted(void) static void BattleAICmd_if_target_is_ally(void) { - if ((sBank_AI & BIT_SIDE) == (gBankDefender & BIT_SIDE)) + if ((sBank_AI & BIT_SIDE) == (gBattleDefender & BIT_SIDE)) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); else gAIScriptPtr += 5; diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c index 60212f849..7d187559b 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -10,14 +10,14 @@ #include "constants/items.h" #include "pokemon_item_effects.h" -extern u8 gActiveBank; -extern u8 gAbsentBankFlags; +extern u8 gActiveBattler; +extern u8 gAbsentBattlerFlags; extern u32 gBattleTypeFlags; -extern u32 gStatuses3[BATTLE_BANKS_COUNT]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u16 gLastLandedMoves[BATTLE_BANKS_COUNT]; -extern u8 gLastHitBy[BATTLE_BANKS_COUNT]; +extern u32 gStatuses3[MAX_BATTLERS_COUNT]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u16 gLastLandedMoves[MAX_BATTLERS_COUNT]; +extern u8 gLastHitBy[MAX_BATTLERS_COUNT]; extern u16 gDynamicBasePower; extern u8 gMoveResultFlags; extern u8 gCritMultiplier; @@ -35,10 +35,10 @@ static bool8 ShouldUseItem(void); static bool8 ShouldSwitchIfPerishSong(void) { - if (gStatuses3[gActiveBank] & STATUS3_PERISH_SONG - && gDisableStructs[gActiveBank].perishSongTimer1 == 0) + if (gStatuses3[gActiveBattler] & STATUS3_PERISH_SONG + && gDisableStructs[gActiveBattler].perishSongTimer1 == 0) { - *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6; + *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; EmitTwoReturnValues(1, ACTION_SWITCH, 0); return TRUE; } @@ -60,15 +60,15 @@ static bool8 ShouldSwitchIfWonderGuard(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) return FALSE; - opposingPosition = B_POSITION_OPPOSITE(GetBankPosition(gActiveBank)); + opposingPosition = B_POSITION_OPPOSITE(GetBattlerPosition(gActiveBattler)); - if (gBattleMons[GetBankByPosition(opposingPosition)].ability != ABILITY_WONDER_GUARD) + if (gBattleMons[GetBattlerAtPosition(opposingPosition)].ability != ABILITY_WONDER_GUARD) return FALSE; // check if pokemon has a super effective move - for (opposingBank = GetBankByPosition(opposingPosition), i = 0; i < 4; i++) + for (opposingBank = GetBattlerAtPosition(opposingPosition), i = 0; i < 4; i++) { - move = gBattleMons[gActiveBank].moves[i]; + move = gBattleMons[gActiveBattler].moves[i]; if (move == MOVE_NONE) continue; @@ -80,7 +80,7 @@ static bool8 ShouldSwitchIfWonderGuard(void) // get party information if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) { - if ((gActiveBank & BIT_MON) == 0) + if ((gActiveBattler & BIT_FLANK) == 0) firstId = 0, lastId = 3; else firstId = 3, lastId = 6; @@ -90,7 +90,7 @@ static bool8 ShouldSwitchIfWonderGuard(void) firstId = 0, lastId = 6; } - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -104,13 +104,13 @@ static bool8 ShouldSwitchIfWonderGuard(void) continue; if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) continue; - if (i == gBattlePartyID[gActiveBank]) + if (i == gBattlePartyID[gActiveBattler]) continue; GetMonData(&party[i], MON_DATA_SPECIES); // unused return value GetMonData(&party[i], MON_DATA_ALT_ABILITY); // unused return value - for (opposingBank = GetBankByPosition(opposingPosition), j = 0; j < 4; j++) + for (opposingBank = GetBattlerAtPosition(opposingPosition), j = 0; j < 4; j++) { move = GetMonData(&party[i], MON_DATA_MOVE1 + j); if (move == MOVE_NONE) @@ -120,7 +120,7 @@ static bool8 ShouldSwitchIfWonderGuard(void) if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % 3 < 2) { // we found a mon - *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i; + *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; EmitTwoReturnValues(1, ACTION_SWITCH, 0); return TRUE; } @@ -141,42 +141,42 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (HasSuperEffectiveMoveAgainstOpponents(TRUE) && Random() % 3 != 0) return FALSE; - if (gLastLandedMoves[gActiveBank] == 0) + if (gLastLandedMoves[gActiveBattler] == 0) return FALSE; - if (gLastLandedMoves[gActiveBank] == 0xFFFF) + if (gLastLandedMoves[gActiveBattler] == 0xFFFF) return FALSE; - if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0) + if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0) return FALSE; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - bankIn1 = gActiveBank; - if (gAbsentBankFlags & gBitTable[GetBankByPosition(B_POSITION_PARTNER(GetBankPosition(gActiveBank)))]) - bankIn2 = gActiveBank; + bankIn1 = gActiveBattler; + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler)))]) + bankIn2 = gActiveBattler; else - bankIn2 = GetBankByPosition(B_POSITION_PARTNER(GetBankPosition(gActiveBank))); + bankIn2 = GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler))); } else { - bankIn1 = gActiveBank; - bankIn2 = gActiveBank; + bankIn1 = gActiveBattler; + bankIn2 = gActiveBattler; } - if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_FIRE) + if (gBattleMoves[gLastLandedMoves[gActiveBattler]].type == TYPE_FIRE) absorbingTypeAbility = ABILITY_FLASH_FIRE; - else if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_WATER) + else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].type == TYPE_WATER) absorbingTypeAbility = ABILITY_WATER_ABSORB; - else if (gBattleMoves[gLastLandedMoves[gActiveBank]].type == TYPE_ELECTRIC) + else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].type == TYPE_ELECTRIC) absorbingTypeAbility = ABILITY_VOLT_ABSORB; else return FALSE; - if (gBattleMons[gActiveBank].ability == absorbingTypeAbility) + if (gBattleMons[gActiveBattler].ability == absorbingTypeAbility) return FALSE; if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) { - if ((gActiveBank & BIT_MON) == 0) + if ((gActiveBattler & BIT_FLANK) == 0) firstId = 0, lastId = 3; else firstId = 3, lastId = 6; @@ -186,7 +186,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) firstId = 0, lastId = 6; } - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -220,7 +220,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (absorbingTypeAbility == monAbility && Random() & 1) { // we found a mon - *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i; + *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; EmitTwoReturnValues(1, ACTION_SWITCH, 0); return TRUE; } @@ -231,22 +231,22 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) static bool8 ShouldSwitchIfNaturalCure(void) { - if (!(gBattleMons[gActiveBank].status1 & STATUS1_SLEEP)) + if (!(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)) return FALSE; - if (gBattleMons[gActiveBank].ability != ABILITY_NATURAL_CURE) + if (gBattleMons[gActiveBattler].ability != ABILITY_NATURAL_CURE) return FALSE; - if (gBattleMons[gActiveBank].hp < gBattleMons[gActiveBank].maxHP / 2) + if (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 2) return FALSE; - if ((gLastLandedMoves[gActiveBank] == 0 || gLastLandedMoves[gActiveBank] == 0xFFFF) && Random() & 1) + if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1) { - *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6; + *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; EmitTwoReturnValues(1, ACTION_SWITCH, 0); return TRUE; } - else if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0 && Random() & 1) + else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 && Random() & 1) { - *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6; + *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; EmitTwoReturnValues(1, ACTION_SWITCH, 0); return TRUE; } @@ -257,7 +257,7 @@ static bool8 ShouldSwitchIfNaturalCure(void) return TRUE; if (Random() & 1) { - *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6; + *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; EmitTwoReturnValues(1, ACTION_SWITCH, 0); return TRUE; } @@ -273,14 +273,14 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng) u8 moveFlags; u16 move; - opposingPosition = B_POSITION_OPPOSITE(GetBankPosition(gActiveBank)); - opposingBank = GetBankByPosition(opposingPosition); + opposingPosition = B_POSITION_OPPOSITE(GetBattlerPosition(gActiveBattler)); + opposingBank = GetBattlerAtPosition(opposingPosition); - if (!(gAbsentBankFlags & gBitTable[opposingBank])) + if (!(gAbsentBattlerFlags & gBitTable[opposingBank])) { for (i = 0; i < 4; i++) { - move = gBattleMons[gActiveBank].moves[i]; + move = gBattleMons[gActiveBattler].moves[i]; if (move == MOVE_NONE) continue; @@ -297,13 +297,13 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) return FALSE; - opposingBank = GetBankByPosition(B_POSITION_PARTNER(opposingPosition)); + opposingBank = GetBattlerAtPosition(B_POSITION_PARTNER(opposingPosition)); - if (!(gAbsentBankFlags & gBitTable[opposingBank])) + if (!(gAbsentBattlerFlags & gBitTable[opposingBank])) { for (i = 0; i < 4; i++) { - move = gBattleMons[gActiveBank].moves[i]; + move = gBattleMons[gActiveBattler].moves[i]; if (move == MOVE_NONE) continue; @@ -328,8 +328,8 @@ static bool8 AreStatsRaised(void) for (i = 0; i < BATTLE_STATS_NO; i++) { - if (gBattleMons[gActiveBank].statStages[i] > 6) - buffedStatsValue += gBattleMons[gActiveBank].statStages[i] - 6; + if (gBattleMons[gActiveBattler].statStages[i] > 6) + buffedStatsValue += gBattleMons[gActiveBattler].statStages[i] - 6; } return (buffedStatsValue > 3); @@ -345,32 +345,32 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) u16 move; u8 moveFlags; - if (gLastLandedMoves[gActiveBank] == 0) + if (gLastLandedMoves[gActiveBattler] == 0) return FALSE; - if (gLastLandedMoves[gActiveBank] == 0xFFFF) + if (gLastLandedMoves[gActiveBattler] == 0xFFFF) return FALSE; - if (gLastHitBy[gActiveBank] == 0xFF) + if (gLastHitBy[gActiveBattler] == 0xFF) return FALSE; - if (gBattleMoves[gLastLandedMoves[gActiveBank]].power == 0) + if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0) return FALSE; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - bankIn1 = gActiveBank; - if (gAbsentBankFlags & gBitTable[GetBankByPosition(B_POSITION_PARTNER(GetBankPosition(gActiveBank)))]) - bankIn2 = gActiveBank; + bankIn1 = gActiveBattler; + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler)))]) + bankIn2 = gActiveBattler; else - bankIn2 = GetBankByPosition(B_POSITION_PARTNER(GetBankPosition(gActiveBank))); + bankIn2 = GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler))); } else { - bankIn1 = gActiveBank; - bankIn2 = gActiveBank; + bankIn1 = gActiveBattler; + bankIn2 = gActiveBattler; } if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) { - if ((gActiveBank & BIT_MON) == 0) + if ((gActiveBattler & BIT_FLANK) == 0) firstId = 0, lastId = 3; else firstId = 3, lastId = 6; @@ -380,7 +380,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) firstId = 0, lastId = 6; } - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -411,10 +411,10 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) else monAbility = gBaseStats[species].ability1; - moveFlags = AI_TypeCalc(gLastLandedMoves[gActiveBank], species, monAbility); + moveFlags = AI_TypeCalc(gLastLandedMoves[gActiveBattler], species, monAbility); if (moveFlags & flags) { - bankIn1 = gLastHitBy[gActiveBank]; + bankIn1 = gLastHitBy[gActiveBattler]; for (j = 0; j < 4; j++) { @@ -425,7 +425,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) moveFlags = AI_TypeCalc(move, gBattleMons[bankIn1].species, gBattleMons[bankIn1].ability); if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0) { - *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i; + *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; EmitTwoReturnValues(1, ACTION_SWITCH, 0); return TRUE; } @@ -446,19 +446,19 @@ static bool8 ShouldSwitch(void) s32 i; s32 availableToSwitch; - if (gBattleMons[*(activeBankPtr = &gActiveBank)].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) + if (gBattleMons[*(activeBankPtr = &gActiveBattler)].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) return FALSE; - if (gStatuses3[gActiveBank] & STATUS3_ROOTED) + if (gStatuses3[gActiveBattler] & STATUS3_ROOTED) return FALSE; - if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_SHADOW_TAG, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_SHADOW_TAG, 0, 0)) return FALSE; - if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_ARENA_TRAP, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_ARENA_TRAP, 0, 0)) return FALSE; // misses the flying or levitate check if (AbilityBattleEffects(ABILITYEFFECT_FIELD_SPORT, 0, ABILITY_MAGNET_PULL, 0, 0)) { - if (gBattleMons[gActiveBank].type1 == TYPE_STEEL) + if (gBattleMons[gActiveBattler].type1 == TYPE_STEEL) return FALSE; - if (gBattleMons[gActiveBank].type2 == TYPE_STEEL) + if (gBattleMons[gActiveBattler].type2 == TYPE_STEEL) return FALSE; } if (gBattleTypeFlags & BATTLE_TYPE_ARENA) @@ -468,10 +468,10 @@ static bool8 ShouldSwitch(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { bankIn1 = *activeBankPtr; - if (gAbsentBankFlags & gBitTable[GetBankByPosition(GetBankPosition(*activeBankPtr) ^ BIT_MON)]) + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(GetBattlerPosition(*activeBankPtr) ^ BIT_FLANK)]) bankIn2 = *activeBankPtr; else - bankIn2 = GetBankByPosition(GetBankPosition(*activeBankPtr) ^ BIT_MON); + bankIn2 = GetBattlerAtPosition(GetBattlerPosition(*activeBankPtr) ^ BIT_FLANK); } else { @@ -481,7 +481,7 @@ static bool8 ShouldSwitch(void) if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) { - if ((gActiveBank & BIT_MON) == 0) + if ((gActiveBattler & BIT_FLANK) == 0) firstId = 0, lastId = 3; else firstId = 3, lastId = 6; @@ -491,7 +491,7 @@ static bool8 ShouldSwitch(void) firstId = 0, lastId = 6; } - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -543,9 +543,9 @@ void AI_TrySwitchOrUseItem(void) u8 bankIn1, bankIn2; s32 firstId; s32 lastId; // + 1 - u8 bankIdentity = GetBankPosition(gActiveBank); + u8 bankIdentity = GetBattlerPosition(gActiveBattler); - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -554,25 +554,25 @@ void AI_TrySwitchOrUseItem(void) { if (ShouldSwitch()) { - if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) == 6) + if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) == 6) { s32 monToSwitchId = GetMostSuitableMonToSwitchInto(); if (monToSwitchId == 6) { if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - bankIn1 = GetBankByPosition(bankIdentity); + bankIn1 = GetBattlerAtPosition(bankIdentity); bankIn2 = bankIn1; } else { - bankIn1 = GetBankByPosition(bankIdentity); - bankIn2 = GetBankByPosition(bankIdentity ^ BIT_MON); + bankIn1 = GetBattlerAtPosition(bankIdentity); + bankIn2 = GetBattlerAtPosition(bankIdentity ^ BIT_FLANK); } if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) { - if ((gActiveBank & BIT_MON) == 0) + if ((gActiveBattler & BIT_FLANK) == 0) firstId = 0, lastId = 3; else firstId = 3, lastId = 6; @@ -599,10 +599,10 @@ void AI_TrySwitchOrUseItem(void) } } - *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = monToSwitchId; + *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = monToSwitchId; } - *(gBattleStruct->monToSwitchIntoId + gActiveBank) = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank); + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler); return; } else if (ShouldUseItem()) @@ -611,7 +611,7 @@ void AI_TrySwitchOrUseItem(void) } } - EmitTwoReturnValues(1, ACTION_USE_MOVE, (gActiveBank ^ BIT_SIDE) << 8); + EmitTwoReturnValues(1, ACTION_USE_MOVE, (gActiveBattler ^ BIT_SIDE) << 8); } static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 *var) @@ -651,34 +651,34 @@ u8 GetMostSuitableMonToSwitchInto(void) u8 invalidMons; u16 move; - if (*(gBattleStruct->monToSwitchIntoId + gActiveBank) != 6) - return *(gBattleStruct->monToSwitchIntoId + gActiveBank); + if (*(gBattleStruct->monToSwitchIntoId + gActiveBattler) != 6) + return *(gBattleStruct->monToSwitchIntoId + gActiveBattler); if (gBattleTypeFlags & BATTLE_TYPE_ARENA) - return gBattlePartyID[gActiveBank] + 1; + return gBattlePartyID[gActiveBattler] + 1; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - bankIn1 = gActiveBank; - if (gAbsentBankFlags & gBitTable[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)]) - bankIn2 = gActiveBank; + bankIn1 = gActiveBattler; + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)]) + bankIn2 = gActiveBattler; else - bankIn2 = GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON); + bankIn2 = GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK); // UB: It considers the opponent only player's side even though it can battle alongside player; - opposingBank = Random() & BIT_MON; - if (gAbsentBankFlags & gBitTable[opposingBank]) - opposingBank ^= BIT_MON; + opposingBank = Random() & BIT_FLANK; + if (gAbsentBattlerFlags & gBitTable[opposingBank]) + opposingBank ^= BIT_FLANK; } else { - opposingBank = GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_SIDE); - bankIn1 = gActiveBank; - bankIn2 = gActiveBank; + opposingBank = GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_SIDE); + bankIn1 = gActiveBattler; + bankIn2 = gActiveBattler; } if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) { - if ((gActiveBank & BIT_MON) == 0) + if ((gActiveBattler & BIT_FLANK) == 0) firstId = 0, lastId = 3; else firstId = 3, lastId = 6; @@ -688,7 +688,7 @@ u8 GetMostSuitableMonToSwitchInto(void) firstId = 0, lastId = 6; } - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -734,7 +734,7 @@ u8 GetMostSuitableMonToSwitchInto(void) for (i = 0; i < 4; i++) { move = GetMonData(&party[bestMonId], MON_DATA_MOVE1 + i); - if (move != MOVE_NONE && TypeCalc(move, gActiveBank, opposingBank) & MOVE_RESULT_SUPER_EFFECTIVE) + if (move != MOVE_NONE && TypeCalc(move, gActiveBattler, opposingBank) & MOVE_RESULT_SUPER_EFFECTIVE) break; } @@ -779,8 +779,8 @@ u8 GetMostSuitableMonToSwitchInto(void) gBattleMoveDamage = 0; if (move != MOVE_NONE && gBattleMoves[move].power != 1) { - AI_CalcDmg(gActiveBank, opposingBank); - TypeCalc(move, gActiveBank, opposingBank); + AI_CalcDmg(gActiveBattler, opposingBank); + TypeCalc(move, gActiveBattler, opposingBank); } if (bestDmg < gBattleMoveDamage) { @@ -817,10 +817,10 @@ static bool8 ShouldUseItem(void) u8 validMons = 0; bool8 shouldUse = FALSE; - if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBankPosition(gActiveBank) == B_POSITION_PLAYER_RIGHT) + if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT) return FALSE; - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -855,14 +855,14 @@ static bool8 ShouldUseItem(void) else itemEffects = gItemEffectTable[item - 13]; - *(gBattleStruct->AI_itemType + gActiveBank / 2) = GetAI_ItemType(item, itemEffects); + *(gBattleStruct->AI_itemType + gActiveBattler / 2) = GetAI_ItemType(item, itemEffects); - switch (*(gBattleStruct->AI_itemType + gActiveBank / 2)) + switch (*(gBattleStruct->AI_itemType + gActiveBattler / 2)) { case AI_ITEM_FULL_RESTORE: - if (gBattleMons[gActiveBank].hp >= gBattleMons[gActiveBank].maxHP / 4) + if (gBattleMons[gActiveBattler].hp >= gBattleMons[gActiveBattler].maxHP / 4) break; - if (gBattleMons[gActiveBank].hp == 0) + if (gBattleMons[gActiveBattler].hp == 0) break; shouldUse = TRUE; break; @@ -870,65 +870,65 @@ static bool8 ShouldUseItem(void) paramOffset = GetItemEffectParamOffset(item, 4, 4); if (paramOffset == 0) break; - if (gBattleMons[gActiveBank].hp == 0) + if (gBattleMons[gActiveBattler].hp == 0) break; - if (gBattleMons[gActiveBank].hp < gBattleMons[gActiveBank].maxHP / 4 || gBattleMons[gActiveBank].maxHP - gBattleMons[gActiveBank].hp > itemEffects[paramOffset]) + if (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 4 || gBattleMons[gActiveBattler].maxHP - gBattleMons[gActiveBattler].hp > itemEffects[paramOffset]) shouldUse = TRUE; break; case AI_ITEM_CURE_CONDITION: - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) = 0; - if (itemEffects[3] & 0x20 && gBattleMons[gActiveBank].status1 & STATUS1_SLEEP) + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) = 0; + if (itemEffects[3] & 0x20 && gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) { - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x20; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x20; shouldUse = TRUE; } - if (itemEffects[3] & 0x10 && (gBattleMons[gActiveBank].status1 & STATUS1_POISON || gBattleMons[gActiveBank].status1 & STATUS1_TOXIC_POISON)) + if (itemEffects[3] & 0x10 && (gBattleMons[gActiveBattler].status1 & STATUS1_POISON || gBattleMons[gActiveBattler].status1 & STATUS1_TOXIC_POISON)) { - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x10; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x10; shouldUse = TRUE; } - if (itemEffects[3] & 0x8 && gBattleMons[gActiveBank].status1 & STATUS1_BURN) + if (itemEffects[3] & 0x8 && gBattleMons[gActiveBattler].status1 & STATUS1_BURN) { - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x8; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x8; shouldUse = TRUE; } - if (itemEffects[3] & 0x4 && gBattleMons[gActiveBank].status1 & STATUS1_FREEZE) + if (itemEffects[3] & 0x4 && gBattleMons[gActiveBattler].status1 & STATUS1_FREEZE) { - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x4; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x4; shouldUse = TRUE; } - if (itemEffects[3] & 0x2 && gBattleMons[gActiveBank].status1 & STATUS1_PARALYSIS) + if (itemEffects[3] & 0x2 && gBattleMons[gActiveBattler].status1 & STATUS1_PARALYSIS) { - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x2; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x2; shouldUse = TRUE; } - if (itemEffects[3] & 0x1 && gBattleMons[gActiveBank].status2 & STATUS2_CONFUSION) + if (itemEffects[3] & 0x1 && gBattleMons[gActiveBattler].status2 & STATUS2_CONFUSION) { - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x1; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x1; shouldUse = TRUE; } break; case AI_ITEM_X_STAT: - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) = 0; - if (gDisableStructs[gActiveBank].isFirstTurn == 0) + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) = 0; + if (gDisableStructs[gActiveBattler].isFirstTurn == 0) break; if (itemEffects[0] & 0xF) - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x1; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x1; if (itemEffects[1] & 0xF0) - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x2; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x2; if (itemEffects[1] & 0xF) - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x4; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x4; if (itemEffects[2] & 0xF) - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x8; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x8; if (itemEffects[2] & 0xF0) - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x20; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x20; if (itemEffects[0] & 0x30) - *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x80; + *(gBattleStruct->AI_itemFlags + gActiveBattler / 2) |= 0x80; shouldUse = TRUE; break; case AI_ITEM_GUARD_SPECS: - bankSide = GetBankSide(gActiveBank); - if (gDisableStructs[gActiveBank].isFirstTurn != 0 && gSideTimers[bankSide].mistTimer == 0) + bankSide = GetBattlerSide(gActiveBattler); + if (gDisableStructs[gActiveBattler].isFirstTurn != 0 && gSideTimers[bankSide].mistTimer == 0) shouldUse = TRUE; break; case AI_ITEM_NOT_RECOGNIZABLE: @@ -938,7 +938,7 @@ static bool8 ShouldUseItem(void) if (shouldUse) { EmitTwoReturnValues(1, ACTION_USE_ITEM, 0); - *(gBattleStruct->chosenItem + (gActiveBank / 2) * 2) = item; + *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2) = item; gBattleResources->battleHistory->trainerItems[i] = 0; return shouldUse; } diff --git a/src/battle_anim.c b/src/battle_anim.c index c1051f93a..93d4de7b3 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -25,8 +25,8 @@ #define ANIM_SPRITE_INDEX_COUNT 8 -extern u8 gBankAttacker; -extern u8 gBankDefender; +extern u8 gBattleAttacker; +extern u8 gBattleDefender; extern u16 gBattle_WIN0H; extern u16 gBattle_WIN0V; extern u16 gBattle_WIN1H; @@ -35,8 +35,8 @@ extern u16 gBattle_BG1_X; extern u16 gBattle_BG1_Y; extern u16 gBattle_BG2_X; extern u16 gBattle_BG2_Y; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct MusicPlayerInfo gMPlayInfo_SE1; extern struct MusicPlayerInfo gMPlayInfo_SE2; @@ -132,7 +132,7 @@ EWRAM_DATA static u8 sAnimBackgroundFadeState = 0; EWRAM_DATA static u16 sAnimMoveIndex = 0; // set but unused. EWRAM_DATA u8 gAnimBankAttacker = 0; EWRAM_DATA u8 gAnimBankTarget = 0; -EWRAM_DATA u16 gAnimSpeciesByBanks[BATTLE_BANKS_COUNT] = {0}; +EWRAM_DATA u16 gAnimSpeciesByBanks[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA u8 gUnknown_02038440 = 0; // const rom data @@ -221,8 +221,8 @@ void ClearBattleAnimationVars(void) void DoMoveAnim(u16 move) { - gAnimBankAttacker = gBankAttacker; - gAnimBankTarget = gBankDefender; + gAnimBankAttacker = gBattleAttacker; + gAnimBankTarget = gBattleDefender; LaunchBattleAnimation(gBattleAnims_Moves, move, TRUE); } @@ -234,9 +234,9 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo { sub_80A8278(); UpdateOamPriorityInAllHealthboxes(0); - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { - if (GetBankSide(i) != 0) + if (GetBattlerSide(i) != 0) gAnimSpeciesByBanks[i] = GetMonData(&gEnemyParty[gBattlePartyID[i]], MON_DATA_SPECIES); else gAnimSpeciesByBanks[i] = GetMonData(&gPlayerParty[gBattlePartyID[i]], MON_DATA_SPECIES); @@ -613,7 +613,7 @@ static void ScriptCmd_monbg(void) if (IsAnimBankSpriteVisible(bank)) { - u8 position = GetBankPosition(bank); + u8 position = GetBattlerPosition(bank); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -629,10 +629,10 @@ static void ScriptCmd_monbg(void) } - bank ^= BIT_MON; + bank ^= BIT_FLANK; if (IsAnimBankSpriteVisible(bank)) { - u8 position = GetBankPosition(bank); + u8 position = GetBattlerPosition(bank); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -718,7 +718,7 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible) if (IsContest()) bankIdentity = 0; else - bankIdentity = GetBankPosition(bank); + bankIdentity = GetBattlerPosition(bank); sub_8118FBC(1, 0, 0, bankIdentity, unknownStruct.unk8, unknownStruct.unk0, unknownStruct.unk4, unknownStruct.unkA); @@ -750,7 +750,7 @@ void sub_80A438C(u8 bank, bool8 toBG_2, bool8 setSpriteInvisible) LoadPalette(&gPlttBufferUnfaded[0x100 + bank * 16], 0x90, 0x20); CpuCopy32(&gPlttBufferUnfaded[0x100 + bank * 16], (void*)(BG_PLTT + 0x120), 0x20); - sub_8118FBC(2, 0, 0, GetBankPosition(bank), unknownStruct.unk8, unknownStruct.unk0 + 0x1000, unknownStruct.unk4 + 0x400, unknownStruct.unkA); + sub_8118FBC(2, 0, 0, GetBattlerPosition(bank), unknownStruct.unk8, unknownStruct.unk0 + 0x1000, unknownStruct.unk4 + 0x400, unknownStruct.unkA); } } @@ -876,7 +876,7 @@ static void ScriptCmd_clearmonbg(void) if (sMonAnimTaskIdArray[0] != 0xFF) gSprites[gBankSpriteIds[bank]].invisible = 0; if (animBankId > 1 && sMonAnimTaskIdArray[1] != 0xFF) - gSprites[gBankSpriteIds[bank ^ BIT_MON]].invisible = 0; + gSprites[gBankSpriteIds[bank ^ BIT_FLANK]].invisible = 0; else animBankId = 0; @@ -893,7 +893,7 @@ static void sub_80A4980(u8 taskId) if (gTasks[taskId].data[1] != 1) { u8 to_BG2; - u8 position = GetBankPosition(gTasks[taskId].data[2]); + u8 position = GetBattlerPosition(gTasks[taskId].data[2]); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) to_BG2 = FALSE; else @@ -937,7 +937,7 @@ static void ScriptCmd_monbg_22(void) if (IsAnimBankSpriteVisible(bank)) { - u8 position = GetBankPosition(bank); + u8 position = GetBattlerPosition(bank); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -946,10 +946,10 @@ static void ScriptCmd_monbg_22(void) sub_80A438C(bank, toBG_2, FALSE); } - bank ^= BIT_MON; + bank ^= BIT_FLANK; if (animBankId > 1 && IsAnimBankSpriteVisible(bank)) { - u8 position = GetBankPosition(bank); + u8 position = GetBattlerPosition(bank); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -982,8 +982,8 @@ static void ScriptCmd_clearmonbg_23(void) if (IsAnimBankSpriteVisible(bank)) gSprites[gBankSpriteIds[bank]].invisible = 0; - if (animBankId > 1 && IsAnimBankSpriteVisible(bank ^ BIT_MON)) - gSprites[gBankSpriteIds[bank ^ BIT_MON]].invisible = 0; + if (animBankId > 1 && IsAnimBankSpriteVisible(bank ^ BIT_FLANK)) + gSprites[gBankSpriteIds[bank ^ BIT_FLANK]].invisible = 0; else animBankId = 0; @@ -1001,7 +1001,7 @@ static void sub_80A4BB0(u8 taskId) { bool8 toBG_2; u8 bank = gTasks[taskId].data[2]; - u8 position = GetBankPosition(bank); + u8 position = GetBattlerPosition(bank); if (position == B_POSITION_OPPONENT_LEFT || position == B_POSITION_PLAYER_RIGHT || IsContest()) toBG_2 = FALSE; else @@ -1009,7 +1009,7 @@ static void sub_80A4BB0(u8 taskId) if (IsAnimBankSpriteVisible(bank)) sub_80A477C(toBG_2); - if (gTasks[taskId].data[0] > 1 && IsAnimBankSpriteVisible(bank ^ BIT_MON)) + if (gTasks[taskId].data[0] > 1 && IsAnimBankSpriteVisible(bank ^ BIT_FLANK)) sub_80A477C(toBG_2 ^ 1); DestroyTask(taskId); @@ -1145,7 +1145,7 @@ static void ScriptCmd_fadetobgfromset(void) if (IsContest()) gTasks[taskId].tBackgroundId = bg3; - else if (GetBankSide(gAnimBankTarget) == SIDE_PLAYER) + else if (GetBattlerSide(gAnimBankTarget) == B_SIDE_PLAYER) gTasks[taskId].tBackgroundId = bg2; else gTasks[taskId].tBackgroundId = bg1; @@ -1272,7 +1272,7 @@ s8 BattleAnimAdjustPanning(s8 pan) { if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gAnimBankAttacker].statusAnimActive) { - if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER) + if (GetBattlerSide(gAnimBankAttacker) != B_SIDE_PLAYER) pan = PAN_SIDE_OPPONENT; else pan = PAN_SIDE_PLAYER; @@ -1282,9 +1282,9 @@ s8 BattleAnimAdjustPanning(s8 pan) if (gAnimBankAttacker != gAnimBankTarget || gAnimBankAttacker != 2 || pan != PAN_SIDE_OPPONENT) pan *= -1; } - else if (GetBankSide(gAnimBankAttacker) == SIDE_PLAYER) + else if (GetBattlerSide(gAnimBankAttacker) == B_SIDE_PLAYER) { - if (GetBankSide(gAnimBankTarget) == SIDE_PLAYER) + if (GetBattlerSide(gAnimBankTarget) == B_SIDE_PLAYER) { if (pan == PAN_SIDE_OPPONENT) pan = PAN_SIDE_PLAYER; @@ -1292,7 +1292,7 @@ s8 BattleAnimAdjustPanning(s8 pan) pan *= -1; } } - else if (GetBankSide(gAnimBankTarget) == SIDE_OPPONENT) + else if (GetBattlerSide(gAnimBankTarget) == B_SIDE_OPPONENT) { if (pan == PAN_SIDE_PLAYER) pan = PAN_SIDE_OPPONENT; @@ -1314,14 +1314,14 @@ s8 BattleAnimAdjustPanning2(s8 pan) { if (!IsContest() && gBattleSpritesDataPtr->healthBoxesData[gAnimBankAttacker].statusAnimActive) { - if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER) + if (GetBattlerSide(gAnimBankAttacker) != B_SIDE_PLAYER) pan = PAN_SIDE_OPPONENT; else pan = PAN_SIDE_PLAYER; } else { - if (GetBankSide(gAnimBankAttacker) != SIDE_PLAYER || IsContest()) + if (GetBattlerSide(gAnimBankAttacker) != B_SIDE_PLAYER || IsContest()) pan = -pan; } return pan; @@ -1705,7 +1705,7 @@ static void ScriptCmd_monbgprio_28(void) else bank = gAnimBankAttacker; - bankIdentity = GetBankPosition(bank); + bankIdentity = GetBattlerPosition(bank); if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT)) { SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); @@ -1731,14 +1731,14 @@ static void ScriptCmd_monbgprio_2A(void) wantedBank = sBattleAnimScriptPtr[1]; sBattleAnimScriptPtr += 2; - if (GetBankSide(gAnimBankAttacker) != GetBankSide(gAnimBankTarget)) + if (GetBattlerSide(gAnimBankAttacker) != GetBattlerSide(gAnimBankTarget)) { if (wantedBank != ANIM_ATTACKER) bank = gAnimBankTarget; else bank = gAnimBankAttacker; - bankIdentity = GetBankPosition(bank); + bankIdentity = GetBattlerPosition(bank); if (!IsContest() && (bankIdentity == B_POSITION_PLAYER_LEFT || bankIdentity == B_POSITION_OPPONENT_RIGHT)) { SetAnimBgAttribute(1, BG_ANIM_PRIORITY, 1); @@ -1778,7 +1778,7 @@ static void ScriptCmd_doublebattle_2D(void) wantedBank = sBattleAnimScriptPtr[1]; sBattleAnimScriptPtr += 2; if (!IsContest() && IsDoubleBattle() - && GetBankSide(gAnimBankAttacker) == GetBankSide(gAnimBankTarget)) + && GetBattlerSide(gAnimBankAttacker) == GetBattlerSide(gAnimBankTarget)) { if (wantedBank == ANIM_ATTACKER) { @@ -1813,7 +1813,7 @@ static void ScriptCmd_doublebattle_2E(void) wantedBank = sBattleAnimScriptPtr[1]; sBattleAnimScriptPtr += 2; if (!IsContest() && IsDoubleBattle() - && GetBankSide(gAnimBankAttacker) == GetBankSide(gAnimBankTarget)) + && GetBattlerSide(gAnimBankAttacker) == GetBattlerSide(gAnimBankTarget)) { if (wantedBank == ANIM_ATTACKER) { diff --git a/src/battle_bg.c b/src/battle_bg.c index 4bb1e65a9..cb106adae 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -363,7 +363,7 @@ void sub_8035D74(u8 taskId) case 0: if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { name = gLinkPlayers[i].name; linkPlayer = &gLinkPlayers[i]; diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 1733ee966..0c7d929a4 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -25,32 +25,32 @@ #include "data2.h" extern u32 gBattleExecBuffer; -extern u8 gActiveBank; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; -extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gBattleBanksCount; +extern u8 gActiveBattler; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; +extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gBattlersCount; extern bool8 gDoingBattleAnim; -extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); +extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gPreBattleCallback1)(void); -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct SpriteTemplate gUnknown_0202499C; extern u16 gSpecialVar_ItemId; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gBattleOutcome; extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; extern u16 gUnknown_020243FC; -extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; -extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; +extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; +extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBankDefender; -extern u8 gAbsentBankFlags; +extern u8 gBattleDefender; +extern u8 gAbsentBattlerFlags; extern u8 gUnknown_020244B4[]; -extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; +extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct UnusedControllerStruct gUnknown_02022D0C; extern u16 gTrainerBattleOpponent_A; @@ -203,15 +203,15 @@ static void nullsub_28(void) void SetControllerToLinkOpponent(void) { - gBattleBankFunc[gActiveBank] = LinkOpponentBufferRunCommand; + gBattlerFuncs[gActiveBattler] = LinkOpponentBufferRunCommand; } static void LinkOpponentBufferRunCommand(void) { - if (gBattleExecBuffer & gBitTable[gActiveBank]) + if (gBattleExecBuffer & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(sLinkOpponentBufferCommands)) - sLinkOpponentBufferCommands[gBattleBufferA[gActiveBank][0]](); + if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkOpponentBufferCommands)) + sLinkOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]](); else LinkOpponentBufferExecCompleted(); } @@ -219,32 +219,32 @@ static void LinkOpponentBufferRunCommand(void) static void CompleteOnBankSpriteCallbackDummy(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) LinkOpponentBufferExecCompleted(); } static void CompleteOnBankSpriteCallbackDummy2(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) LinkOpponentBufferExecCompleted(); } static void sub_8064470(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - FreeTrainerFrontPicPalette(gSprites[gBankSpriteIds[gActiveBank]].oam.affineParam); - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); + FreeTrainerFrontPicPalette(gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); LinkOpponentBufferExecCompleted(); } } static void sub_80644D8(void) { - if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 == 0xFF) + if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; LinkOpponentBufferExecCompleted(); } } @@ -256,13 +256,13 @@ static void sub_8064520(void) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) r8 = TRUE; } else { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gHealthBoxesIds[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) { r8 = TRUE; } @@ -271,39 +271,39 @@ static void sub_8064520(void) if (r8) { - if (r4 || !IsAnimBankSpriteVisible(gActiveBank ^ BIT_MON)) + if (r4 || !IsAnimBankSpriteVisible(gActiveBattler ^ BIT_FLANK)) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) return; - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) return; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); } else { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) return; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; - if (GetBankPosition(gActiveBank) == B_POSITION_OPPONENT_RIGHT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) { FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); } } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3; - gBattleBankFunc[gActiveBank] = sub_80644D8; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; + gBattlerFuncs[gActiveBattler] = sub_80644D8; } } @@ -311,48 +311,48 @@ static void sub_8064734(void) { bool32 r10 = FALSE; - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) { - sub_8172EF0(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); + sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); } if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1) + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) { - sub_8172EF0(gActiveBank ^ BIT_MON, &gEnemyParty[gBattlePartyID[gActiveBank ^ BIT_MON]]); + sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]]); } - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank ^ BIT_MON], &gEnemyParty[gBattlePartyID[gActiveBank ^ BIT_MON]], HEALTHBOX_ALL); - sub_8076918(gActiveBank ^ BIT_MON); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank ^ BIT_MON]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler ^ BIT_FLANK); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); } - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gEnemyParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; } - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x40 - && gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x40 + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40 && !IsCryPlayingOrClearCrySongs()) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) { - if (GetBankPosition(gActiveBank) == B_POSITION_OPPONENT_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT) m4aMPlayContinue(&gMPlayInfo_BGM); } else @@ -361,56 +361,56 @@ static void sub_8064734(void) } } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1; r10 = TRUE; } if (r10) { - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBankPosition(gActiveBank) == B_POSITION_OPPONENT_RIGHT) + if (gBattleTypeFlags & BATTLE_TYPE_MULTI && GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) { - if (++gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 == 1) + if (++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 1) return; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; } if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank ^ BIT_MON]]); - SetBankEnemyShadowSpriteCallback(gActiveBank ^ BIT_MON, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank ^ BIT_MON]], MON_DATA_SPECIES)); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); + SetBankEnemyShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES)); } - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - SetBankEnemyShadowSpriteCallback(gActiveBank, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); gBattleSpritesDataPtr->animationData->field_9_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; - gBattleBankFunc[gActiveBank] = sub_8064520; + gBattlerFuncs[gActiveBattler] = sub_8064520; } } } static void sub_8064B04(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].pos2.x == 0) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80) { - sub_8172EF0(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); + sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); } else { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); LinkOpponentBufferExecCompleted(); @@ -421,13 +421,13 @@ static void sub_8064B04(void) static void CompleteOnHealthbarDone(void) { - s16 hpValue = sub_8074AA0(gActiveBank, gHealthBoxesIds[gActiveBank], HEALTH_BAR, 0); + s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); if (hpValue != -1) { - UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBank], hpValue, HP_CURRENT); + UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); } else { @@ -437,21 +437,21 @@ static void CompleteOnHealthbarDone(void) static void sub_8064C14(void) { - if (!gSprites[gBankSpriteIds[gActiveBank]].inUse) + if (!gSprites[gBankSpriteIds[gActiveBattler]].inUse) { - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); LinkOpponentBufferExecCompleted(); } } static void sub_8064C58(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - EnemyShadowCallbackToSetInvisible(gActiveBank); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + EnemyShadowCallbackToSetInvisible(gActiveBattler); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); LinkOpponentBufferExecCompleted(); } } @@ -464,7 +464,7 @@ static void CompleteOnInactiveTextPrinter(void) static void DoHitAnimBlinkSpriteEffect(void) { - u8 spriteId = gBankSpriteIds[gActiveBank]; + u8 spriteId = gBankSpriteIds[gActiveBattler]; if (gSprites[spriteId].data[1] == 32) { @@ -483,21 +483,21 @@ static void DoHitAnimBlinkSpriteEffect(void) static void sub_8064D60(void) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleBankFunc[gActiveBank] = sub_8064DD0; + gBattlerFuncs[gActiveBattler] = sub_8064DD0; } } static void sub_8064DD0(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive && !IsCryPlayingOrClearCrySongs()) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs()) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy - || gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy_2) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy + || gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2) { m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); LinkOpponentBufferExecCompleted(); @@ -507,67 +507,67 @@ static void sub_8064DD0(void) static void sub_8064E50(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gEnemyParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); - CopyBattleSpriteInvisibility(gActiveBank); - gBattleBankFunc[gActiveBank] = sub_8064D60; + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); + CopyBattleSpriteInvisibility(gActiveBattler); + gBattlerFuncs[gActiveBattler] = sub_8064D60; } } static void sub_8064F40(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80) { - sub_8172EF0(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); + sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); } - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - SetBankEnemyShadowSpriteCallback(gActiveBank, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); - gBattleBankFunc[gActiveBank] = sub_8064E50; + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); + gBattlerFuncs[gActiveBattler] = sub_8064E50; } } static void CompleteOnFinishedStatusAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) LinkOpponentBufferExecCompleted(); } static void CompleteOnFinishedBattleAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive) LinkOpponentBufferExecCompleted(); } static void LinkOpponentBufferExecCompleted(void) { - gBattleBankFunc[gActiveBank] = LinkOpponentBufferRunCommand; + gBattlerFuncs[gActiveBattler] = LinkOpponentBufferRunCommand; if (gBattleTypeFlags & BATTLE_TYPE_LINK) { u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBank][0] = CONTROLLER_TERMINATOR_NOP; + gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { - gBattleExecBuffer &= ~gBitTable[gActiveBank]; + gBattleExecBuffer &= ~gBitTable[gActiveBattler]; } } @@ -578,13 +578,13 @@ static void LinkOpponentHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - size += CopyLinkOpponentMonData(gBattlePartyID[gActiveBank], monData); + size += CopyLinkOpponentMonData(gBattlePartyID[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -606,7 +606,7 @@ static u32 CopyLinkOpponentMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES); @@ -672,7 +672,7 @@ static u32 CopyLinkOpponentMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -687,7 +687,7 @@ static u32 CopyLinkOpponentMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -912,13 +912,13 @@ static void LinkOpponentHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - SetLinkOpponentMonData(gBattlePartyID[gActiveBank]); + SetLinkOpponentMonData(gBattlePartyID[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -931,11 +931,11 @@ static void LinkOpponentHandleSetMonData(void) static void SetLinkOpponentMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBank][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -976,10 +976,10 @@ static void SetLinkOpponentMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < 4; i++) @@ -993,196 +993,196 @@ static void SetLinkOpponentMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBank][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][7]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][8]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; } } static void LinkOpponentHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; + u8 *dst = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) - dst[i] = gBattleBufferA[gActiveBank][3 + i]; + for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) + dst[i] = gBattleBufferA[gActiveBattler][3 + i]; LinkOpponentBufferExecCompleted(); } static void LinkOpponentHandleLoadMonSprite(void) { - u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); - BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[gActiveBank]], gActiveBank); - sub_806A068(species, GetBankPosition(gActiveBank)); + BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + sub_806A068(species, GetBattlerPosition(gActiveBattler)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, - GetBankCoord(gActiveBank, 2), - GetBankSpriteDefault_Y(gActiveBank), - sub_80A82E4(gActiveBank)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, + GetBankCoord(gActiveBattler, 2), + GetBankSpriteDefault_Y(gActiveBattler), + sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], gBattleMonForms[gActiveBank]); + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); - SetBankEnemyShadowSpriteCallback(gActiveBank, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); + SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); - gBattleBankFunc[gActiveBank] = sub_8064B04; + gBattlerFuncs[gActiveBattler] = sub_8064B04; } static void LinkOpponentHandleSwitchInAnim(void) { - gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1]; - sub_8066494(gActiveBank, gBattleBufferA[gActiveBank][2]); - gBattleBankFunc[gActiveBank] = sub_8064F40; + gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; + sub_8066494(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlerFuncs[gActiveBattler] = sub_8064F40; } static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit) @@ -1194,7 +1194,7 @@ static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit) species = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); - sub_806A068(species, GetBankPosition(bank)); + sub_806A068(species, GetBattlerPosition(bank)); gBankSpriteIds[bank] = CreateSprite( &gUnknown_0202499C, @@ -1219,37 +1219,37 @@ static void sub_8066494(u8 bank, bool8 dontClearSubstituteBit) static void LinkOpponentHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBank][1] == 0) + if (gBattleBufferA[gActiveBattler][1] == 0) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = DoSwitchOutAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; } else { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - EnemyShadowCallbackToSetInvisible(gActiveBank); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + EnemyShadowCallbackToSetInvisible(gActiveBattler); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); LinkOpponentBufferExecCompleted(); } } static void DoSwitchOutAnimation(void) { - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON); - gBattleBankFunc[gActiveBank] = sub_8064C58; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON); + gBattlerFuncs[gActiveBattler] = sub_8064C58; } break; } @@ -1262,39 +1262,39 @@ static void LinkOpponentHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((GetBankPosition(gActiveBank) & BIT_MON) != 0) // second mon + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon xPos = 152; else // first mon xPos = 200; if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) { - if (gActiveBank == 1) + if (gActiveBattler == 1) trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A); else trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B); } else { - if ((gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_FIRE_RED - || (gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_LEAF_GREEN) + if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED + || (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN) { - if (gLinkPlayers[GetBankMultiplayerId(gActiveBank)].gender != 0) + if (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender != 0) trainerPicId = gUnknown_0831F578[0x4F]; else trainerPicId = gUnknown_0831F578[0x4E]; } - else if ((gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_RUBY - || (gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_SAPPHIRE) + else if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY + || (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE) { - if (gLinkPlayers[GetBankMultiplayerId(gActiveBank)].gender != 0) + if (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender != 0) trainerPicId = gUnknown_0831F578[0x51]; else trainerPicId = gUnknown_0831F578[0x50]; } else { - trainerPicId = PlayerGenderToFrontTrainerPicId(gLinkPlayers[GetBankMultiplayerId(gActiveBank)].gender); + trainerPicId = PlayerGenderToFrontTrainerPicId(gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender); } } } @@ -1327,73 +1327,73 @@ static void LinkOpponentHandleDrawTrainerPic(void) } } - DecompressTrainerFrontPic(trainerPicId, gActiveBank); - sub_806A12C(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, + DecompressTrainerFrontPic(trainerPicId, gActiveBattler); + sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, - sub_80A82E4(gActiveBank)); + sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 2; - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); - gSprites[gBankSpriteIds[gActiveBank]].oam.affineParam = trainerPicId; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 2; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); + gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; } static void LinkOpponentHandleTrainerSlide(void) { u32 trainerPicId; - if (gActiveBank == 1) + if (gActiveBattler == 1) trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A); else trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B); - DecompressTrainerFrontPic(trainerPicId, gActiveBank); - sub_806A12C(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, 176, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, 0x1E); + DecompressTrainerFrontPic(trainerPicId, gActiveBattler); + sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, 176, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, 0x1E); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 96; - gSprites[gBankSpriteIds[gActiveBank]].pos1.x += 32; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2; - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); - gSprites[gBankSpriteIds[gActiveBank]].oam.affineParam = trainerPicId; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 96; + gSprites[gBankSpriteIds[gActiveBattler]].pos1.x += 32; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); + gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy2; // this line is redundant, because LinkOpponentBufferExecCompleted changes the battle bank function + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; // this line is redundant, because LinkOpponentBufferExecCompleted changes the battle bank function LinkOpponentBufferExecCompleted(); } static void LinkOpponentHandleTrainerSlideBack(void) { - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 35; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = 280; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], SpriteCallbackDummy); - gBattleBankFunc[gActiveBank] = sub_8064470; + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); + gBattlerFuncs[gActiveBattler] = sub_8064470; } static void LinkOpponentHandleFaintAnimation(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } else { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_OPPONENT); - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_8039934; - gBattleBankFunc[gActiveBank] = sub_8064C14; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039934; + gBattlerFuncs[gActiveBattler] = sub_8064C14; } } } @@ -1420,25 +1420,25 @@ static void LinkOpponentHandlePause(void) static void LinkOpponentHandleMoveAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBank][3]; - gAnimMovePower = gBattleBufferA[gActiveBank][4] | (gBattleBufferA[gActiveBank][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBank][6] | (gBattleBufferA[gActiveBank][7] << 8) | (gBattleBufferA[gActiveBank][8] << 16) | (gBattleBufferA[gActiveBank][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBank][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBank][12] | (gBattleBufferA[gActiveBank][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBank][16]; - gTransformedPersonalities[gActiveBank] = gAnimDisableStructPtr->transformedMonPersonality; + gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; + gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleBufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { LinkOpponentBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = LinkOpponentDoMoveAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = LinkOpponentDoMoveAnimation; sub_817E0FC(move, gWeatherMoveAnim, gAnimDisableStructPtr); } } @@ -1446,26 +1446,26 @@ static void LinkOpponentHandleMoveAnimation(void) static void LinkOpponentDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); - u8 multihit = gBattleBufferA[gActiveBank][11]; + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleBufferA[gActiveBattler][11]; - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { sub_805EB9C(0); DoMoveAnim(move); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 2; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; } break; case 2: @@ -1473,20 +1473,20 @@ static void LinkOpponentDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) { - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } break; case 3: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; LinkOpponentBufferExecCompleted(); } break; @@ -1499,10 +1499,10 @@ static void LinkOpponentHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBank][2]); + stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); - gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; sub_817C95C(*stringId); } @@ -1546,23 +1546,23 @@ static void LinkOpponentHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { - u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); - u32 curHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); + u32 curHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, curHP, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); } else { - u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, 0, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); } - gBattleBankFunc[gActiveBank] = CompleteOnHealthbarDone; + gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } static void LinkOpponentHandleExpUpdate(void) @@ -1572,24 +1572,24 @@ static void LinkOpponentHandleExpUpdate(void) static void LinkOpponentHandleStatusIconUpdate(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { u8 bank; - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gEnemyParty[gBattlePartyID[gActiveBank]], HEALTHBOX_STATUS_ICON); - bank = gActiveBank; + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); + bank = gActiveBattler; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } static void LinkOpponentHandleStatusAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], - gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], + gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1646,7 +1646,7 @@ static void LinkOpponentHandleCmd37(void) static void LinkOpponentHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBank][1]; + gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; LinkOpponentBufferExecCompleted(); } @@ -1664,16 +1664,16 @@ static void LinkOpponentHandleCmd40(void) static void LinkOpponentHandleHitAnimation(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].invisible == TRUE) + if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) { LinkOpponentBufferExecCompleted(); } else { gDoingBattleAnim = TRUE; - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - DoHitAnimHealthboxEffect(gActiveBank); - gBattleBankFunc[gActiveBank] = DoHitAnimBlinkSpriteEffect; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + DoHitAnimHealthboxEffect(gActiveBattler); + gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; } } @@ -1686,25 +1686,25 @@ static void LinkOpponentHandlePlaySE(void) { s8 pan; - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) pan = PAN_SIDE_PLAYER; else pan = PAN_SIDE_OPPONENT; - PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan); + PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); LinkOpponentBufferExecCompleted(); } static void LinkOpponentHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBank][3]) + if (gBattleBufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } LinkOpponentBufferExecCompleted(); @@ -1712,7 +1712,7 @@ static void LinkOpponentHandlePlayFanfareOrBGM(void) static void LinkOpponentHandleFaintingCry(void) { - u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); PlayCry3(species, 25, 5); LinkOpponentBufferExecCompleted(); @@ -1720,7 +1720,7 @@ static void LinkOpponentHandleFaintingCry(void) static void LinkOpponentHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBank][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gUnknown_020243FC |= 1; LinkOpponentBufferExecCompleted(); } @@ -1730,46 +1730,46 @@ static void LinkOpponentHandleIntroTrainerBallThrow(void) u8 paletteNum; u8 taskId; - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 35; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = 280; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], sub_80676FC); + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_80676FC); taskId = CreateTask(sub_8067618, 5); - gTasks[taskId].data[0] = gActiveBank; + gTasks[taskId].data[0] = gActiveBattler; - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gBattleSpritesDataPtr->animationData->field_9_x1 = 1; - gBattleBankFunc[gActiveBank] = nullsub_28; + gBattlerFuncs[gActiveBattler] = nullsub_28; } static void sub_8067618(u8 taskId) { - u8 savedActiveBank = gActiveBank; + u8 savedActiveBank = gActiveBattler; - gActiveBank = gTasks[taskId].data[0]; + gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_8066494(gActiveBank, FALSE); + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_8066494(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_8066494(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_8066494(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_8066494(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_8066494(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; } - gBattleBankFunc[gActiveBank] = sub_8064734; - gActiveBank = savedActiveBank; + gBattlerFuncs[gActiveBattler] = sub_8064734; + gActiveBattler = savedActiveBank; DestroyTask(taskId); } @@ -1782,50 +1782,50 @@ static void sub_80676FC(struct Sprite *sprite) static void LinkOpponentHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == SIDE_PLAYER) + if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { LinkOpponentBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1 = 1; - if (gBattleBufferA[gActiveBank][2] != 0) + if (gBattleBufferA[gActiveBattler][2] != 0) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E < 2) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E < 2) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E++; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E++; return; } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E = 0; } } - gUnknown_020244B4[gActiveBank] = CreatePartyStatusSummarySprites(gActiveBank, (struct HpAndStatus *)&gBattleBufferA[gActiveBank][4], gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gUnknown_020244B4[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBank][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0x5D; + if (gBattleBufferA[gActiveBattler][2] != 0) + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; - gBattleBankFunc[gActiveBank] = sub_806782C; + gBattlerFuncs[gActiveBattler] = sub_806782C; } } static void sub_806782C(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5++ > 0x5C) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; LinkOpponentBufferExecCompleted(); } } static void LinkOpponentHandleCmd49(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; LinkOpponentBufferExecCompleted(); } @@ -1836,25 +1836,25 @@ static void LinkOpponentHandleCmd50(void) static void LinkOpponentHandleSpriteInvisibility(void) { - if (IsBankSpritePresent(gActiveBank)) + if (IsBankSpritePresent(gActiveBattler)) { - gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; - CopyBattleSpriteInvisibility(gActiveBank); + gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + CopyBattleSpriteInvisibility(gActiveBattler); } LinkOpponentBufferExecCompleted(); } static void LinkOpponentHandleBattleAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBank][1]; - u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + u8 animationId = gBattleBufferA[gActiveBattler][1]; + u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) LinkOpponentBufferExecCompleted(); else - gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; sub_817E32C(animationId); } @@ -1862,7 +1862,7 @@ static void LinkOpponentHandleBattleAnimation(void) static void LinkOpponentHandleLinkStandbyMsg(void) { - sub_81851A8(&gBattleBufferA[gActiveBank][2]); + sub_81851A8(&gBattleBufferA[gActiveBattler][2]); LinkOpponentBufferExecCompleted(); } @@ -1873,18 +1873,18 @@ static void LinkOpponentHandleResetActionMoveSelection(void) static void LinkOpponentHandleCmd55(void) { - sub_81851A8(&gBattleBufferA[gActiveBank][4]); + sub_81851A8(&gBattleBufferA[gActiveBattler][4]); - if (gBattleBufferA[gActiveBank][1] == B_OUTCOME_DREW) - gBattleOutcome = gBattleBufferA[gActiveBank][1]; + if (gBattleBufferA[gActiveBattler][1] == B_OUTCOME_DREW) + gBattleOutcome = gBattleBufferA[gActiveBattler][1]; else - gBattleOutcome = gBattleBufferA[gActiveBank][1] ^ B_OUTCOME_DREW; + gBattleOutcome = gBattleBufferA[gActiveBattler][1] ^ B_OUTCOME_DREW; - gSaveBlock2Ptr->field_CA9_b = gBattleBufferA[gActiveBank][2]; + gSaveBlock2Ptr->field_CA9_b = gBattleBufferA[gActiveBattler][2]; FadeOutMapMusic(5); BeginFastPaletteFade(3); LinkOpponentBufferExecCompleted(); - gBattleBankFunc[gActiveBank] = sub_80587B0; + gBattlerFuncs[gActiveBattler] = sub_80587B0; } static void nullsub_92(void) diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 9835f6cb2..d184370f4 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -25,32 +25,32 @@ #include "data2.h" extern u32 gBattleExecBuffer; -extern u8 gActiveBank; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; -extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gBattleBanksCount; +extern u8 gActiveBattler; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; +extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gBattlersCount; extern bool8 gDoingBattleAnim; -extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); +extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gPreBattleCallback1)(void); -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct SpriteTemplate gUnknown_0202499C; extern u16 gSpecialVar_ItemId; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gBattleOutcome; extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; extern u16 gUnknown_020243FC; -extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; -extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; +extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; +extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBankDefender; -extern u8 gAbsentBankFlags; +extern u8 gBattleDefender; +extern u8 gAbsentBattlerFlags; extern u8 gUnknown_020244B4[]; -extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; +extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern struct UnusedControllerStruct gUnknown_02022D0C; extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[]; @@ -198,15 +198,15 @@ static void nullsub_112(void) void SetControllerToLinkPartner(void) { - gBattleBankFunc[gActiveBank] = LinkPartnerBufferRunCommand; + gBattlerFuncs[gActiveBattler] = LinkPartnerBufferRunCommand; } static void LinkPartnerBufferRunCommand(void) { - if (gBattleExecBuffer & gBitTable[gActiveBank]) + if (gBattleExecBuffer & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(sLinkPartnerBufferCommands)) - sLinkPartnerBufferCommands[gBattleBufferA[gActiveBank][0]](); + if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sLinkPartnerBufferCommands)) + sLinkPartnerBufferCommands[gBattleBufferA[gActiveBattler][0]](); else LinkPartnerBufferExecCompleted(); } @@ -214,26 +214,26 @@ static void LinkPartnerBufferRunCommand(void) static void CompleteOnBankSpriteCallbackDummy(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) LinkPartnerBufferExecCompleted(); } static void sub_814AF54(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { nullsub_25(0); - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); LinkPartnerBufferExecCompleted(); } } static void sub_814AFBC(void) { - if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 == 0xFF) + if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; LinkPartnerBufferExecCompleted(); } } @@ -244,13 +244,13 @@ static void sub_814B004(void) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) r6 = TRUE; } else { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gHealthBoxesIds[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) { r6 = TRUE; } @@ -261,84 +261,84 @@ static void sub_814B004(void) if (r6) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3; - gBattleBankFunc[gActiveBank] = sub_814AFBC; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; + gBattlerFuncs[gActiveBattler] = sub_814AFBC; } } static void sub_814B0E8(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive - && gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy - && ++gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 != 1) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive + && gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy + && ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 != 1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank ^ BIT_MON]]); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank ^ BIT_MON], &gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], HEALTHBOX_ALL); - sub_8076918(gActiveBank ^ BIT_MON); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank ^ BIT_MON]); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler ^ BIT_FLANK); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); } - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); gBattleSpritesDataPtr->animationData->field_9_x1 = 0; - gBattleBankFunc[gActiveBank] = sub_814B004; + gBattlerFuncs[gActiveBattler] = sub_814B004; } } static void sub_814B290(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].animEnded && gSprites[gBankSpriteIds[gActiveBank]].pos2.x == 0) + if (gSprites[gBankSpriteIds[gActiveBattler]].animEnded && gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0) LinkPartnerBufferExecCompleted(); } static void CompleteOnHealthbarDone(void) { - s16 hpValue = sub_8074AA0(gActiveBank, gHealthBoxesIds[gActiveBank], HEALTH_BAR, 0); + s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); if (hpValue != -1) { - UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBank], hpValue, HP_CURRENT); + UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); } else { - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); LinkPartnerBufferExecCompleted(); } } static void sub_814B340(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].pos1.y + gSprites[gBankSpriteIds[gActiveBank]].pos2.y > DISPLAY_HEIGHT) + if (gSprites[gBankSpriteIds[gActiveBattler]].pos1.y + gSprites[gBankSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT) { - u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); nullsub_24(species); - FreeOamMatrix(gSprites[gBankSpriteIds[gActiveBank]].oam.matrixNum); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeOamMatrix(gSprites[gBankSpriteIds[gActiveBattler]].oam.matrixNum); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); LinkPartnerBufferExecCompleted(); } } static void sub_814B3DC(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); LinkPartnerBufferExecCompleted(); } } @@ -351,7 +351,7 @@ static void CompleteOnInactiveTextPrinter(void) static void DoHitAnimBlinkSpriteEffect(void) { - u8 spriteId = gBankSpriteIds[gActiveBank]; + u8 spriteId = gBankSpriteIds[gActiveBattler]; if (gSprites[spriteId].data[1] == 32) { @@ -370,20 +370,20 @@ static void DoHitAnimBlinkSpriteEffect(void) static void sub_814B4E0(void) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) { - CopyBattleSpriteInvisibility(gActiveBank); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + CopyBattleSpriteInvisibility(gActiveBattler); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleBankFunc[gActiveBank] = sub_814B554; + gBattlerFuncs[gActiveBattler] = sub_814B554; } } static void sub_814B554(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { LinkPartnerBufferExecCompleted(); } @@ -391,66 +391,66 @@ static void sub_814B554(void) static void sub_814B5A8(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); CreateTask(c3_0802FDF4, 10); - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); - gBattleBankFunc[gActiveBank] = sub_814B4E0; + gBattlerFuncs[gActiveBattler] = sub_814B4E0; } } static void sub_814B69C(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - sub_8172EF0(gActiveBank, &gPlayerParty[gBattlePartyID[gActiveBank]]); + sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); } - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - gBattleBankFunc[gActiveBank] = sub_814B5A8; + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + gBattlerFuncs[gActiveBattler] = sub_814B5A8; } } static void LinkPartnerBufferExecCompleted(void) { - gBattleBankFunc[gActiveBank] = LinkPartnerBufferRunCommand; + gBattlerFuncs[gActiveBattler] = LinkPartnerBufferRunCommand; if (gBattleTypeFlags & BATTLE_TYPE_LINK) { u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBank][0] = CONTROLLER_TERMINATOR_NOP; + gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { - gBattleExecBuffer &= ~gBitTable[gActiveBank]; + gBattleExecBuffer &= ~gBitTable[gActiveBattler]; } } static void CompleteOnFinishedStatusAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) LinkPartnerBufferExecCompleted(); } static void CompleteOnFinishedBattleAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive) LinkPartnerBufferExecCompleted(); } @@ -461,13 +461,13 @@ static void LinkPartnerHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - size += CopyLinkPartnerMonData(gBattlePartyID[gActiveBank], monData); + size += CopyLinkPartnerMonData(gBattlePartyID[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -489,7 +489,7 @@ static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); @@ -555,7 +555,7 @@ static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -570,7 +570,7 @@ static u32 CopyLinkPartnerMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -795,13 +795,13 @@ static void LinkPartnerHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - SetLinkPartnerMonData(gBattlePartyID[gActiveBank]); + SetLinkPartnerMonData(gBattlePartyID[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -814,11 +814,11 @@ static void LinkPartnerHandleSetMonData(void) static void SetLinkPartnerMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBank][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -859,10 +859,10 @@ static void SetLinkPartnerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < 4; i++) @@ -876,167 +876,167 @@ static void SetLinkPartnerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBank][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][7]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][8]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; } - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); } static void LinkPartnerHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; + u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) - dst[i] = gBattleBufferA[gActiveBank][3 + i]; + for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) + dst[i] = gBattleBufferA[gActiveBattler][3 + i]; LinkPartnerBufferExecCompleted(); } @@ -1045,28 +1045,28 @@ static void LinkPartnerHandleLoadMonSprite(void) { u16 species; - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); - sub_806A068(species, GetBankPosition(gActiveBank)); + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); + sub_806A068(species, GetBattlerPosition(gActiveBattler)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, - GetBankCoord(gActiveBank, 2), - GetBankSpriteDefault_Y(gActiveBank), - sub_80A82E4(gActiveBank)); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], gBattleMonForms[gActiveBank]); - gBattleBankFunc[gActiveBank] = sub_814B290; + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, + GetBankCoord(gActiveBattler, 2), + GetBankSpriteDefault_Y(gActiveBattler), + sub_80A82E4(gActiveBattler)); + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); + gBattlerFuncs[gActiveBattler] = sub_814B290; } static void LinkPartnerHandleSwitchInAnim(void) { - ClearTemporarySpeciesSpriteData(gActiveBank, gBattleBufferA[gActiveBank][2]); - gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1]; - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - sub_814CC98(gActiveBank, gBattleBufferA[gActiveBank][2]); - gBattleBankFunc[gActiveBank] = sub_814B69C; + ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + sub_814CC98(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlerFuncs[gActiveBattler] = sub_814B69C; } static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit) @@ -1077,7 +1077,7 @@ static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit) gBattlePartyID[bank] = gBattleBufferA[bank][1]; species = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); - sub_806A068(species, GetBankPosition(bank)); + sub_806A068(species, GetBattlerPosition(bank)); gBankSpriteIds[bank] = CreateSprite( &gUnknown_0202499C, @@ -1102,36 +1102,36 @@ static void sub_814CC98(u8 bank, bool8 dontClearSubstituteBit) static void LinkPartnerHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBank][1] == 0) + if (gBattleBufferA[gActiveBattler][1] == 0) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = DoSwitchOutAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; } else { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); LinkPartnerBufferExecCompleted(); } } static void DoSwitchOutAnimation(void) { - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); - gBattleBankFunc[gActiveBank] = sub_814B3DC; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); + gBattlerFuncs[gActiveBattler] = sub_814B3DC; } break; } @@ -1144,7 +1144,7 @@ static void LinkPartnerHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((GetBankPosition(gActiveBank) & BIT_MON) != 0) // second mon + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon xPos = 90; else // first mon xPos = 32; @@ -1154,31 +1154,31 @@ static void LinkPartnerHandleDrawTrainerPic(void) xPos = 80; } - if ((gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_FIRE_RED - || (gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_LEAF_GREEN) + if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED + || (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN) { - trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBank)].gender + BACK_PIC_RED; + trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender + BACK_PIC_RED; } - else if ((gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_RUBY - || (gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_SAPPHIRE) + else if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY + || (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE) { - trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBank)].gender + BACK_PIC_RS_BRENDAN; + trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender + BACK_PIC_RS_BRENDAN; } else { - trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBank)].gender; + trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender; } - DecompressTrainerBackPic(trainerPicId, gActiveBank); - sub_806A12C(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, xPos, (8 - gTrainerBackPicCoords[trainerPicId].coords) * 4 + 80, sub_80A82E4(gActiveBank)); + DecompressTrainerBackPic(trainerPicId, gActiveBattler); + sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, (8 - gTrainerBackPicCoords[trainerPicId].coords) * 4 + 80, sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; } static void LinkPartnerHandleTrainerSlide(void) @@ -1188,34 +1188,34 @@ static void LinkPartnerHandleTrainerSlide(void) static void LinkPartnerHandleTrainerSlideBack(void) { - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 35; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = -40; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], SpriteCallbackDummy); - gBattleBankFunc[gActiveBank] = sub_814AF54; + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); + gBattlerFuncs[gActiveBattler] = sub_814AF54; } static void LinkPartnerHandleFaintAnimation(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } else { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER); - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = 5; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_8039C00; - gBattleBankFunc[gActiveBank] = sub_814B340; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 5; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039C00; + gBattlerFuncs[gActiveBattler] = sub_814B340; } } } @@ -1242,25 +1242,25 @@ static void LinkPartnerHandlePause(void) static void LinkPartnerHandleMoveAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBank][3]; - gAnimMovePower = gBattleBufferA[gActiveBank][4] | (gBattleBufferA[gActiveBank][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBank][6] | (gBattleBufferA[gActiveBank][7] << 8) | (gBattleBufferA[gActiveBank][8] << 16) | (gBattleBufferA[gActiveBank][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBank][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBank][12] | (gBattleBufferA[gActiveBank][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBank][16]; - gTransformedPersonalities[gActiveBank] = gAnimDisableStructPtr->transformedMonPersonality; + gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; + gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleBufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { LinkPartnerBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = LinkPartnerDoMoveAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = LinkPartnerDoMoveAnimation; sub_817E0FC(move, gWeatherMoveAnim, gAnimDisableStructPtr); } } @@ -1268,26 +1268,26 @@ static void LinkPartnerHandleMoveAnimation(void) static void LinkPartnerDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); - u8 multihit = gBattleBufferA[gActiveBank][11]; + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleBufferA[gActiveBattler][11]; - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { sub_805EB9C(0); DoMoveAnim(move); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 2; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; } break; case 2: @@ -1295,20 +1295,20 @@ static void LinkPartnerDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) { - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } break; case 3: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; LinkPartnerBufferExecCompleted(); } break; @@ -1321,10 +1321,10 @@ static void LinkPartnerHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBank][2]); + stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); - gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; sub_817C95C(*stringId); } @@ -1368,23 +1368,23 @@ static void LinkPartnerHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { - u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); - u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); + u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, curHP, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); } else { - u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, 0, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); } - gBattleBankFunc[gActiveBank] = CompleteOnHealthbarDone; + gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } static void LinkPartnerHandleExpUpdate(void) @@ -1394,24 +1394,24 @@ static void LinkPartnerHandleExpUpdate(void) static void LinkPartnerHandleStatusIconUpdate(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { u8 bank; - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_STATUS_ICON); - bank = gActiveBank; + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); + bank = gActiveBattler; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } static void LinkPartnerHandleStatusAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], - gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], + gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1468,7 +1468,7 @@ static void LinkPartnerHandleCmd37(void) static void LinkPartnerHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBank][1]; + gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; LinkPartnerBufferExecCompleted(); } @@ -1486,16 +1486,16 @@ static void LinkPartnerHandleCmd40(void) static void LinkPartnerHandleHitAnimation(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].invisible == TRUE) + if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) { LinkPartnerBufferExecCompleted(); } else { gDoingBattleAnim = TRUE; - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - DoHitAnimHealthboxEffect(gActiveBank); - gBattleBankFunc[gActiveBank] = DoHitAnimBlinkSpriteEffect; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + DoHitAnimHealthboxEffect(gActiveBattler); + gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; } } @@ -1508,25 +1508,25 @@ static void LinkPartnerHandlePlaySE(void) { s8 pan; - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) pan = PAN_SIDE_PLAYER; else pan = PAN_SIDE_OPPONENT; - PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan); + PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); LinkPartnerBufferExecCompleted(); } static void LinkPartnerHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBank][3]) + if (gBattleBufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } LinkPartnerBufferExecCompleted(); @@ -1534,7 +1534,7 @@ static void LinkPartnerHandlePlayFanfareOrBGM(void) static void LinkPartnerHandleFaintingCry(void) { - u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); PlayCry3(species, -25, 5); LinkPartnerBufferExecCompleted(); @@ -1542,7 +1542,7 @@ static void LinkPartnerHandleFaintingCry(void) static void LinkPartnerHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBank][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gUnknown_020243FC |= 1; LinkPartnerBufferExecCompleted(); } @@ -1553,46 +1553,46 @@ static void LinkPartnerHandleIntroTrainerBallThrow(void) u8 taskId; u32 trainerPicId; - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 50; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = -40; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - gSprites[gBankSpriteIds[gActiveBank]].data[5] = gActiveBank; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 50; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + gSprites[gBankSpriteIds[gActiveBattler]].data[5] = gActiveBattler; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], sub_805CC00); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 1); + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_805CC00); + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 1); paletteNum = AllocSpritePalette(0xD6F9); - if ((gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_FIRE_RED - || (gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_LEAF_GREEN) + if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_FIRE_RED + || (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_LEAF_GREEN) { - trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBank)].gender + BACK_PIC_RED; + trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender + BACK_PIC_RED; } - else if ((gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_RUBY - || (gLinkPlayers[GetBankMultiplayerId(gActiveBank)].version & 0xFF) == VERSION_SAPPHIRE) + else if ((gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_RUBY + || (gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].version & 0xFF) == VERSION_SAPPHIRE) { - trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBank)].gender + BACK_PIC_RS_BRENDAN; + trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender + BACK_PIC_RS_BRENDAN; } else { - trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBank)].gender; + trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender; } LoadCompressedPalette(gTrainerBackPicPaletteTable[trainerPicId].data, 0x100 + paletteNum * 16, 32); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = paletteNum; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; taskId = CreateTask(sub_814DCCC, 5); - gTasks[taskId].data[0] = gActiveBank; + gTasks[taskId].data[0] = gActiveBattler; - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gBattleSpritesDataPtr->animationData->field_9_x1 = 1; - gBattleBankFunc[gActiveBank] = nullsub_112; + gBattlerFuncs[gActiveBattler] = nullsub_112; } static void sub_814DCCC(u8 taskId) @@ -1603,62 +1603,62 @@ static void sub_814DCCC(u8 taskId) } else { - u8 savedActiveBank = gActiveBank; + u8 savedActiveBank = gActiveBattler; - gActiveBank = gTasks[taskId].data[0]; + gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_814CC98(gActiveBank, FALSE); + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_814CC98(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_814CC98(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - sub_814CC98(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_814CC98(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + sub_814CC98(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; } - gBattleBankFunc[gActiveBank] = sub_814B0E8; - gActiveBank = savedActiveBank; + gBattlerFuncs[gActiveBattler] = sub_814B0E8; + gActiveBattler = savedActiveBank; DestroyTask(taskId); } } static void LinkPartnerHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == SIDE_PLAYER) + if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { LinkPartnerBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1 = 1; - gUnknown_020244B4[gActiveBank] = CreatePartyStatusSummarySprites(gActiveBank, (struct HpAndStatus *)&gBattleBufferA[gActiveBank][4], gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1 = 1; + gUnknown_020244B4[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBank][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0x5D; + if (gBattleBufferA[gActiveBattler][2] != 0) + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; - gBattleBankFunc[gActiveBank] = sub_814DE9C; + gBattlerFuncs[gActiveBattler] = sub_814DE9C; } } static void sub_814DE9C(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5++ > 0x5C) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; LinkPartnerBufferExecCompleted(); } } static void LinkPartnerHandleCmd49(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; LinkPartnerBufferExecCompleted(); } @@ -1669,25 +1669,25 @@ static void LinkPartnerHandleCmd50(void) static void LinkPartnerHandleSpriteInvisibility(void) { - if (IsBankSpritePresent(gActiveBank)) + if (IsBankSpritePresent(gActiveBattler)) { - gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; - CopyBattleSpriteInvisibility(gActiveBank); + gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + CopyBattleSpriteInvisibility(gActiveBattler); } LinkPartnerBufferExecCompleted(); } static void LinkPartnerHandleBattleAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBank][1]; - u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + u8 animationId = gBattleBufferA[gActiveBattler][1]; + u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) LinkPartnerBufferExecCompleted(); else - gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; sub_817E32C(animationId); } @@ -1695,7 +1695,7 @@ static void LinkPartnerHandleBattleAnimation(void) static void LinkPartnerHandleLinkStandbyMsg(void) { - sub_81851A8(&gBattleBufferA[gActiveBank][2]); + sub_81851A8(&gBattleBufferA[gActiveBattler][2]); LinkPartnerBufferExecCompleted(); } @@ -1706,13 +1706,13 @@ static void LinkPartnerHandleResetActionMoveSelection(void) static void LinkPartnerHandleCmd55(void) { - sub_81851A8(&gBattleBufferA[gActiveBank][4]); - gBattleOutcome = gBattleBufferA[gActiveBank][1]; - gSaveBlock2Ptr->field_CA9_b = gBattleBufferA[gActiveBank][2]; + sub_81851A8(&gBattleBufferA[gActiveBattler][4]); + gBattleOutcome = gBattleBufferA[gActiveBattler][1]; + gSaveBlock2Ptr->field_CA9_b = gBattleBufferA[gActiveBattler][2]; FadeOutMapMusic(5); BeginFastPaletteFade(3); LinkPartnerBufferExecCompleted(); - gBattleBankFunc[gActiveBank] = sub_80587B0; + gBattlerFuncs[gActiveBattler] = sub_80587B0; } static void nullsub_113(void) diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 6940fdc73..7131cbde6 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -29,26 +29,26 @@ #include "data2.h" extern u32 gBattleExecBuffer; -extern u8 gActiveBank; -extern u8 gBankDefender; -extern u8 gAbsentBankFlags; +extern u8 gActiveBattler; +extern u8 gBattleDefender; +extern u8 gAbsentBattlerFlags; extern bool8 gDoingBattleAnim; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern struct MusicPlayerInfo gMPlayInfo_BGM; -extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; -extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); +extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; +extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void *gUnknown_020244D8; extern void *gUnknown_020244DC; -extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; +extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern struct SpriteTemplate gUnknown_0202499C; extern struct UnusedControllerStruct gUnknown_02022D0C; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; -extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; +extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; extern u16 gUnknown_020243FC; @@ -207,15 +207,15 @@ static void nullsub_26(void) void SetControllerToOpponent(void) { - gBattleBankFunc[gActiveBank] = OpponentBufferRunCommand; + gBattlerFuncs[gActiveBattler] = OpponentBufferRunCommand; } static void OpponentBufferRunCommand(void) { - if (gBattleExecBuffer & gBitTable[gActiveBank]) + if (gBattleExecBuffer & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(sOpponentBufferCommands)) - sOpponentBufferCommands[gBattleBufferA[gActiveBank][0]](); + if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sOpponentBufferCommands)) + sOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]](); else OpponentBufferExecCompleted(); } @@ -223,32 +223,32 @@ static void OpponentBufferRunCommand(void) static void CompleteOnBankSpriteCallbackDummy(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) OpponentBufferExecCompleted(); } static void CompleteOnBankSpriteCallbackDummy2(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) OpponentBufferExecCompleted(); } static void sub_805F240(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - FreeTrainerFrontPicPalette(gSprites[gBankSpriteIds[gActiveBank]].oam.affineParam); - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); + FreeTrainerFrontPicPalette(gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); OpponentBufferExecCompleted(); } } static void sub_805F2A8(void) { - if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 == 0xFF) + if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; OpponentBufferExecCompleted(); } } @@ -260,42 +260,42 @@ static void sub_805F2F0(void) if (!IsDoubleBattle() || ((IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI)) || (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS))) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) var = TRUE; var2 = FALSE; } else { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gHealthBoxesIds[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) var = TRUE; var2 = TRUE; } - gUnknown_020244D8 = &gBattleSpritesDataPtr->healthBoxesData[gActiveBank]; - gUnknown_020244DC = &gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON]; + gUnknown_020244D8 = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler]; + gUnknown_020244DC = &gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK]; if (var) { if (var2 == TRUE) { - if (var2 && gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 && gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1) + if (var2 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); } else return; } - else if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) + else if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) { - if (GetBankPosition(gActiveBank) == 3) + if (GetBattlerPosition(gActiveBattler) == 3) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 == 0 && gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1 == 0) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 == 0 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1 == 0) { FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); @@ -303,14 +303,14 @@ static void sub_805F2F0(void) else return; } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; } else return; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3; - gBattleBankFunc[gActiveBank] = sub_805F2A8; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; + gBattlerFuncs[gActiveBattler] = sub_805F2A8; } } @@ -319,60 +319,60 @@ static void sub_805F560(void) bool32 sp = FALSE; bool32 r10 = FALSE; - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) - sub_8172EF0(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); - if (!(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI) && IsDoubleBattle() && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1) - sub_8172EF0(gActiveBank ^ BIT_MON, &gEnemyParty[gBattlePartyID[gActiveBank ^ BIT_MON]]); - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) + sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); + if (!(gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI) && IsDoubleBattle() && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) + sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]]); + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank ^ BIT_MON], &gEnemyParty[gBattlePartyID[gActiveBank ^ BIT_MON]], HEALTHBOX_ALL); - sub_8076918(gActiveBank ^ BIT_MON); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank ^ BIT_MON]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler ^ BIT_FLANK); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); } - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gEnemyParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; } - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x40 - && gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x40 + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40 && !IsCryPlayingOrClearCrySongs()) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) { - if (GetBankPosition(gActiveBank) == 1) + if (GetBattlerPosition(gActiveBattler) == 1) m4aMPlayContinue(&gMPlayInfo_BGM); } else m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1; sp = TRUE; } if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { r10 = TRUE; } } else { - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gUnknown_03005D7C[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) { r10 = TRUE; } @@ -382,29 +382,29 @@ static void sub_805F560(void) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank ^ BIT_MON]]); - SetBankEnemyShadowSpriteCallback(gActiveBank ^ BIT_MON, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank ^ BIT_MON]], MON_DATA_SPECIES)); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); + SetBankEnemyShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES)); } - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - SetBankEnemyShadowSpriteCallback(gActiveBank, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); gBattleSpritesDataPtr->animationData->field_9_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; - gBattleBankFunc[gActiveBank] = sub_805F2F0; + gBattlerFuncs[gActiveBattler] = sub_805F2F0; } } static void sub_805F994(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].pos2.x == 0 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) - sub_8172EF0(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); + if (gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) + sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy && gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); OpponentBufferExecCompleted(); @@ -413,11 +413,11 @@ static void sub_805F994(void) static void CompleteOnHealthbarDone(void) { - s16 hpValue = sub_8074AA0(gActiveBank, gHealthBoxesIds[gActiveBank], HEALTH_BAR, 0); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); if (hpValue != -1) { - UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBank], hpValue, HP_CURRENT); + UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); } else OpponentBufferExecCompleted(); @@ -425,21 +425,21 @@ static void CompleteOnHealthbarDone(void) static void sub_805FAC4(void) { - if (!gSprites[gBankSpriteIds[gActiveBank]].inUse) + if (!gSprites[gBankSpriteIds[gActiveBattler]].inUse) { - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); OpponentBufferExecCompleted(); } } static void sub_805FB08(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - EnemyShadowCallbackToSetInvisible(gActiveBank); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + EnemyShadowCallbackToSetInvisible(gActiveBattler); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); OpponentBufferExecCompleted(); } } @@ -452,7 +452,7 @@ static void CompleteOnInactiveTextPrinter(void) static void DoHitAnimBlinkSpriteEffect(void) { - u8 spriteId = gBankSpriteIds[gActiveBank]; + u8 spriteId = gBankSpriteIds[gActiveBattler]; if (gSprites[spriteId].data[1] == 32) { @@ -471,19 +471,19 @@ static void DoHitAnimBlinkSpriteEffect(void) static void sub_805FC10(void) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); - gBattleBankFunc[gActiveBank] = sub_805FC80; + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); + gBattlerFuncs[gActiveBattler] = sub_805FC80; } } static void sub_805FC80(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive && !IsCryPlayingOrClearCrySongs()) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs()) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy || gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy_2) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy || gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2) { m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); OpponentBufferExecCompleted(); @@ -493,60 +493,60 @@ static void sub_805FC80(void) static void sub_805FD00(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gEnemyParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); - CopyBattleSpriteInvisibility(gActiveBank); - gBattleBankFunc[gActiveBank] = sub_805FC10; + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); + CopyBattleSpriteInvisibility(gActiveBattler); + gBattlerFuncs[gActiveBattler] = sub_805FC10; } } static void sub_805FDF0(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) - sub_8172EF0(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) + sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - SetBankEnemyShadowSpriteCallback(gActiveBank, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); - gBattleBankFunc[gActiveBank] = sub_805FD00; + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); + gBattlerFuncs[gActiveBattler] = sub_805FD00; } } static void CompleteOnFinishedStatusAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) OpponentBufferExecCompleted(); } static void CompleteOnFinishedBattleAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive) OpponentBufferExecCompleted(); } static void OpponentBufferExecCompleted(void) { - gBattleBankFunc[gActiveBank] = OpponentBufferRunCommand; + gBattlerFuncs[gActiveBattler] = OpponentBufferRunCommand; if (gBattleTypeFlags & BATTLE_TYPE_LINK) { u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBank][0] = CONTROLLER_TERMINATOR_NOP; + gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { - gBattleExecBuffer &= ~gBitTable[gActiveBank]; + gBattleExecBuffer &= ~gBitTable[gActiveBattler]; } } @@ -557,13 +557,13 @@ static void OpponentHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - size += GetOpponentMonData(gBattlePartyID[gActiveBank], monData); + size += GetOpponentMonData(gBattlePartyID[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -585,7 +585,7 @@ static u32 GetOpponentMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES); @@ -651,7 +651,7 @@ static u32 GetOpponentMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -666,7 +666,7 @@ static u32 GetOpponentMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -884,14 +884,14 @@ static u32 GetOpponentMonData(u8 monId, u8 *dst) static void OpponentHandleGetRawMonData(void) { struct BattlePokemon battleMon; - u8 *src = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; - u8 *dst = (u8 *)&battleMon + gBattleBufferA[gActiveBank][1]; + u8 *src = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; + u8 *dst = (u8 *)&battleMon + gBattleBufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) + for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) dst[i] = src[i]; - EmitDataTransfer(1, gBattleBufferA[gActiveBank][2], dst); + EmitDataTransfer(1, gBattleBufferA[gActiveBattler][2], dst); OpponentBufferExecCompleted(); } @@ -900,13 +900,13 @@ static void OpponentHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - SetOpponentMonData(gBattlePartyID[gActiveBank]); + SetOpponentMonData(gBattlePartyID[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -919,11 +919,11 @@ static void OpponentHandleSetMonData(void) static void SetOpponentMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBank][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -964,10 +964,10 @@ static void SetOpponentMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < 4; i++) @@ -981,198 +981,198 @@ static void SetOpponentMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBank][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][7]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][8]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; } } static void OpponentHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; + u8 *dst = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) - dst[i] = gBattleBufferA[gActiveBank][3 + i]; + for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) + dst[i] = gBattleBufferA[gActiveBattler][3 + i]; OpponentBufferExecCompleted(); } static void OpponentHandleLoadMonSprite(void) { - u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); - BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[gActiveBank]], gActiveBank); - sub_806A068(species, GetBankPosition(gActiveBank)); + BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + sub_806A068(species, GetBattlerPosition(gActiveBattler)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, - GetBankCoord(gActiveBank, 2), - GetBankSpriteDefault_Y(gActiveBank), - sub_80A82E4(gActiveBank)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, + GetBankCoord(gActiveBattler, 2), + GetBankSpriteDefault_Y(gActiveBattler), + sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = species; - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], gBattleMonForms[gActiveBank]); + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = species; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); - SetBankEnemyShadowSpriteCallback(gActiveBank, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); + SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); - gBattleBankFunc[gActiveBank] = sub_805F994; + gBattlerFuncs[gActiveBattler] = sub_805F994; } static void OpponentHandleSwitchInAnim(void) { - *(gBattleStruct->monToSwitchIntoId + gActiveBank) = 6; - gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1]; - sub_80613DC(gActiveBank, gBattleBufferA[gActiveBank][2]); - gBattleBankFunc[gActiveBank] = sub_805FDF0; + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6; + gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; + sub_80613DC(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlerFuncs[gActiveBattler] = sub_805FDF0; } static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit) @@ -1184,7 +1184,7 @@ static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit) species = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); - sub_806A068(species, GetBankPosition(bank)); + sub_806A068(species, GetBattlerPosition(bank)); gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBankCoord(bank, 2), @@ -1209,37 +1209,37 @@ static void sub_80613DC(u8 bank, bool8 dontClearSubstituteBit) static void OpponentHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBank][1] == 0) + if (gBattleBufferA[gActiveBattler][1] == 0) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = DoSwitchOutAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; } else { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - EnemyShadowCallbackToSetInvisible(gActiveBank); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + EnemyShadowCallbackToSetInvisible(gActiveBattler); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); OpponentBufferExecCompleted(); } } static void DoSwitchOutAnimation(void) { - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON); - gBattleBankFunc[gActiveBank] = sub_805FB08; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON); + gBattlerFuncs[gActiveBattler] = sub_805FB08; } break; } @@ -1262,7 +1262,7 @@ static void OpponentHandleDrawTrainerPic(void) { if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) { - if (gActiveBank == 1) + if (gActiveBattler == 1) trainerPicId = sub_81D5588(gTrainerBattleOpponent_A); else trainerPicId = sub_81D5588(gTrainerBattleOpponent_B); @@ -1276,7 +1276,7 @@ static void OpponentHandleDrawTrainerPic(void) { if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) { - if (gActiveBank == 1) + if (gActiveBattler == 1) trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A); else trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B); @@ -1292,7 +1292,7 @@ static void OpponentHandleDrawTrainerPic(void) } else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) { - if (gActiveBank != 1) + if (gActiveBattler != 1) trainerPicId = gTrainers[gTrainerBattleOpponent_B].trainerPic; else trainerPicId = gTrainers[gTrainerBattleOpponent_A].trainerPic; @@ -1304,7 +1304,7 @@ static void OpponentHandleDrawTrainerPic(void) if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS)) { - if ((GetBankPosition(gActiveBank) & BIT_MON) != 0) // second mon + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon xPos = 152; else // first mon xPos = 200; @@ -1314,20 +1314,20 @@ static void OpponentHandleDrawTrainerPic(void) xPos = 176; } - DecompressTrainerFrontPic(trainerPicId, gActiveBank); - sub_806A12C(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, + DecompressTrainerFrontPic(trainerPicId, gActiveBattler); + sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, - sub_80A82E4(gActiveBank)); + sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 2; - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); - gSprites[gBankSpriteIds[gActiveBank]].oam.affineParam = trainerPicId; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 2; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); + gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; } static void OpponentHandleTrainerSlide(void) @@ -1346,7 +1346,7 @@ static void OpponentHandleTrainerSlide(void) { if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) { - if (gActiveBank == 1) + if (gActiveBattler == 1) trainerPicId = sub_81D5588(gTrainerBattleOpponent_A); else trainerPicId = sub_81D5588(gTrainerBattleOpponent_B); @@ -1360,7 +1360,7 @@ static void OpponentHandleTrainerSlide(void) { if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) { - if (gActiveBank == 1) + if (gActiveBattler == 1) trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A); else trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B); @@ -1376,7 +1376,7 @@ static void OpponentHandleTrainerSlide(void) } else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) { - if (gActiveBank != 1) + if (gActiveBattler != 1) trainerPicId = gTrainers[gTrainerBattleOpponent_B].trainerPic; else trainerPicId = gTrainers[gTrainerBattleOpponent_A].trainerPic; @@ -1386,47 +1386,47 @@ static void OpponentHandleTrainerSlide(void) trainerPicId = gTrainers[gTrainerBattleOpponent_A].trainerPic; } - DecompressTrainerFrontPic(trainerPicId, gActiveBank); - sub_806A12C(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, 176, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, 0x1E); + DecompressTrainerFrontPic(trainerPicId, gActiveBattler); + sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, 176, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, 0x1E); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 96; - gSprites[gBankSpriteIds[gActiveBank]].pos1.x += 32; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2; - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); - gSprites[gBankSpriteIds[gActiveBank]].oam.affineParam = trainerPicId; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 96; + gSprites[gBankSpriteIds[gActiveBattler]].pos1.x += 32; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); + gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy2; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; } static void OpponentHandleTrainerSlideBack(void) { - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 35; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = 280; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], SpriteCallbackDummy); - gBattleBankFunc[gActiveBank] = sub_805F240; + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); + gBattlerFuncs[gActiveBattler] = sub_805F240; } static void OpponentHandleFaintAnimation(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } else { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_OPPONENT); - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_8039934; - gBattleBankFunc[gActiveBank] = sub_805FAC4; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039934; + gBattlerFuncs[gActiveBattler] = sub_805FAC4; } } } @@ -1453,51 +1453,51 @@ static void OpponentHandlePause(void) static void OpponentHandleMoveAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBank][3]; - gAnimMovePower = gBattleBufferA[gActiveBank][4] | (gBattleBufferA[gActiveBank][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBank][6] | (gBattleBufferA[gActiveBank][7] << 8) | (gBattleBufferA[gActiveBank][8] << 16) | (gBattleBufferA[gActiveBank][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBank][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBank][12] | (gBattleBufferA[gActiveBank][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBank][16]; - gTransformedPersonalities[gActiveBank] = gAnimDisableStructPtr->transformedMonPersonality; + gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; + gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleBufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { OpponentBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = OpponentDoMoveAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = OpponentDoMoveAnimation; } } } static void OpponentDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); - u8 multihit = gBattleBufferA[gActiveBank][11]; + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleBufferA[gActiveBattler][11]; - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { sub_805EB9C(0); DoMoveAnim(move); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 2; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; } break; case 2: @@ -1505,20 +1505,20 @@ static void OpponentDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) { - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } break; case 3: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; OpponentBufferExecCompleted(); } break; @@ -1531,11 +1531,11 @@ static void OpponentHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBank][2]); + stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); - gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter; - sub_81A57E4(gActiveBank, *stringId); + gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; + sub_81A57E4(gActiveBattler, *stringId); } static void OpponentHandlePrintSelectionString(void) @@ -1564,7 +1564,7 @@ static void OpponentHandleChooseMove(void) else { u8 chosenMoveId; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); if (gBattleTypeFlags & (BATTLE_TYPE_TRAINER | BATTLE_TYPE_FIRST_BATTLE | BATTLE_TYPE_SAFARI | BATTLE_TYPE_ROAMER)) { @@ -1581,18 +1581,18 @@ static void OpponentHandleChooseMove(void) EmitTwoReturnValues(1, ACTION_RUN, 0); break; case 6: - EmitTwoReturnValues(1, 15, gBankDefender); + EmitTwoReturnValues(1, 15, gBattleDefender); break; default: if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_x10)) - gBankDefender = gActiveBank; + gBattleDefender = gActiveBattler; if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH) { - gBankDefender = GetBankByPosition(B_POSITION_PLAYER_LEFT); - if (gAbsentBankFlags & gBitTable[gBankDefender]) - gBankDefender = GetBankByPosition(B_POSITION_PLAYER_RIGHT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + if (gAbsentBattlerFlags & gBitTable[gBattleDefender]) + gBattleDefender = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); } - EmitTwoReturnValues(1, 10, (chosenMoveId) | (gBankDefender << 8)); + EmitTwoReturnValues(1, 10, (chosenMoveId) | (gBattleDefender << 8)); break; } OpponentBufferExecCompleted(); @@ -1607,11 +1607,11 @@ static void OpponentHandleChooseMove(void) } while (move == MOVE_NONE); if (gBattleMoves[move].target & (MOVE_TARGET_USER | MOVE_TARGET_x10)) - EmitTwoReturnValues(1, 10, (chosenMoveId) | (gActiveBank << 8)); + EmitTwoReturnValues(1, 10, (chosenMoveId) | (gActiveBattler << 8)); else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBankByPosition(Random() & 2) << 8)); + EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(Random() & 2) << 8)); else - EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBankByPosition(B_POSITION_PLAYER_LEFT) << 8)); + EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) << 8)); OpponentBufferExecCompleted(); } @@ -1620,7 +1620,7 @@ static void OpponentHandleChooseMove(void) static void OpponentHandleChooseItem(void) { - EmitOneReturnValue(1, *(gBattleStruct->chosenItem + (gActiveBank / 2) * 2)); + EmitOneReturnValue(1, *(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2)); OpponentBufferExecCompleted(); } @@ -1628,7 +1628,7 @@ static void OpponentHandleChoosePokemon(void) { s32 chosenMonId; - if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) == 6) + if (*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) == 6) { chosenMonId = GetMostSuitableMonToSwitchInto(); @@ -1638,17 +1638,17 @@ static void OpponentHandleChoosePokemon(void) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - bank2 = bank1 = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + bank2 = bank1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); } else { - bank1 = GetBankByPosition(B_POSITION_OPPONENT_LEFT); - bank2 = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + bank1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + bank2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); } if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) { - if (gActiveBank == 1) + if (gActiveBattler == 1) firstId = 0, lastId = 3; else firstId = 3, lastId = 6; @@ -1671,12 +1671,12 @@ static void OpponentHandleChoosePokemon(void) } else { - chosenMonId = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank); - *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = 6; + chosenMonId = *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler); + *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; } - *(gBattleStruct->monToSwitchIntoId + gActiveBank) = chosenMonId; + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId; EmitChosenMonReturnValue(1, chosenMonId, NULL); OpponentBufferExecCompleted(); } @@ -1691,23 +1691,23 @@ static void OpponentHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = (gBattleBufferA[gActiveBank][3] << 8) | gBattleBufferA[gActiveBank][2]; + hpVal = (gBattleBufferA[gActiveBattler][3] << 8) | gBattleBufferA[gActiveBattler][2]; if (hpVal != INSTANT_HP_BAR_DROP) { - u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); - u32 curHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); + u32 curHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, curHP, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); } else { - u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, 0, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); } - gBattleBankFunc[gActiveBank] = CompleteOnHealthbarDone; + gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } static void OpponentHandleExpUpdate(void) @@ -1717,24 +1717,24 @@ static void OpponentHandleExpUpdate(void) static void OpponentHandleStatusIconUpdate(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { u8 bank; - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gEnemyParty[gBattlePartyID[gActiveBank]], HEALTHBOX_STATUS_ICON); - bank = gActiveBank; + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); + bank = gActiveBattler; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } static void OpponentHandleStatusAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], - gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], + gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1791,7 +1791,7 @@ static void OpponentHandleCmd37(void) static void OpponentHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBank][1]; + gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; OpponentBufferExecCompleted(); } @@ -1809,16 +1809,16 @@ static void OpponentHandleCmd40(void) static void OpponentHandleHitAnimation(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].invisible == TRUE) + if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) { OpponentBufferExecCompleted(); } else { gDoingBattleAnim = TRUE; - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - DoHitAnimHealthboxEffect(gActiveBank); - gBattleBankFunc[gActiveBank] = DoHitAnimBlinkSpriteEffect; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + DoHitAnimHealthboxEffect(gActiveBattler); + gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; } } @@ -1831,25 +1831,25 @@ static void OpponentHandlePlaySE(void) { s8 pan; - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) pan = PAN_SIDE_PLAYER; else pan = PAN_SIDE_OPPONENT; - PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan); + PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); OpponentBufferExecCompleted(); } static void OpponentHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBank][3]) + if (gBattleBufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } OpponentBufferExecCompleted(); @@ -1857,7 +1857,7 @@ static void OpponentHandlePlayFanfareOrBGM(void) static void OpponentHandleFaintingCry(void) { - u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); PlayCry3(species, 25, 5); OpponentBufferExecCompleted(); @@ -1865,7 +1865,7 @@ static void OpponentHandleFaintingCry(void) static void OpponentHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBank][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gUnknown_020243FC |= 1; OpponentBufferExecCompleted(); } @@ -1875,23 +1875,23 @@ static void OpponentHandleIntroTrainerBallThrow(void) u8 paletteNum; u8 taskId; - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 35; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = 280; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], sub_806280C); + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_806280C); taskId = CreateTask(sub_8062828, 5); - gTasks[taskId].data[0] = gActiveBank; + gTasks[taskId].data[0] = gActiveBattler; - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gBattleSpritesDataPtr->animationData->field_9_x1 = 1; - gBattleBankFunc[gActiveBank] = nullsub_26; + gBattlerFuncs[gActiveBattler] = nullsub_26; } static void sub_806280C(struct Sprite *sprite) @@ -1903,79 +1903,79 @@ static void sub_806280C(struct Sprite *sprite) static void sub_8062828(u8 taskId) { - u8 savedActiveBank = gActiveBank; + u8 savedActiveBank = gActiveBattler; - gActiveBank = gTasks[taskId].data[0]; + gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_80613DC(gActiveBank, FALSE); + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_80613DC(gActiveBattler, FALSE); } else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS)) { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_80613DC(gActiveBank, FALSE); + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_80613DC(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_80613DC(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_80613DC(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_80613DC(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_80613DC(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; } - gBattleBankFunc[gActiveBank] = sub_805F560; - gActiveBank = savedActiveBank; + gBattlerFuncs[gActiveBattler] = sub_805F560; + gActiveBattler = savedActiveBank; DestroyTask(taskId); } static void OpponentHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == SIDE_PLAYER) + if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { OpponentBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1 = 1; - if (gBattleBufferA[gActiveBank][2] != 0) + if (gBattleBufferA[gActiveBattler][2] != 0) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E < 2) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E < 2) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E++; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E++; return; } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E = 0; } } - gUnknown_020244B4[gActiveBank] = CreatePartyStatusSummarySprites(gActiveBank, (struct HpAndStatus *)&gBattleBufferA[gActiveBank][4], gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gUnknown_020244B4[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBank][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0x5D; + if (gBattleBufferA[gActiveBattler][2] != 0) + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; - gBattleBankFunc[gActiveBank] = sub_8062A2C; + gBattlerFuncs[gActiveBattler] = sub_8062A2C; } } static void sub_8062A2C(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5++ > 0x5C) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; OpponentBufferExecCompleted(); } } static void OpponentHandleCmd49(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; OpponentBufferExecCompleted(); } @@ -1986,25 +1986,25 @@ static void OpponentHandleCmd50(void) static void OpponentHandleSpriteInvisibility(void) { - if (IsBankSpritePresent(gActiveBank)) + if (IsBankSpritePresent(gActiveBattler)) { - gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; - CopyBattleSpriteInvisibility(gActiveBank); + gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + CopyBattleSpriteInvisibility(gActiveBattler); } OpponentBufferExecCompleted(); } static void OpponentHandleBattleAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBank][1]; - u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + u8 animationId = gBattleBufferA[gActiveBattler][1]; + u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) OpponentBufferExecCompleted(); else - gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; } } diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index e8a6898f8..8d52ee377 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -28,31 +28,31 @@ #include "data2.h" extern u32 gBattleExecBuffer; -extern u8 gActiveBank; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; -extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gAbsentBankFlags; -extern u8 gBattleBanksCount; +extern u8 gActiveBattler; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; +extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gAbsentBattlerFlags; +extern u8 gBattlersCount; extern bool8 gDoingBattleAnim; extern u8 gPlayerDpadHoldFrames; -extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); +extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gPreBattleCallback1)(void); -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gMultiUsePlayerCursor; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern u16 gPartnerTrainerId; extern struct SpriteTemplate gUnknown_0202499C; -extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; +extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gSpecialVar_ItemId; extern u8 gUnknown_0203CEE8; extern u8 gUnknown_0203CEE9; extern u8 gUnknown_0203CF00[]; -extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gBattleOutcome; extern u8 gNumberOfMovesToChoose; extern u16 gBattle_BG0_X; @@ -60,7 +60,7 @@ extern u16 gBattle_BG0_Y; extern s32 gUnknown_0203CD70; extern u8 gBankInMenu; extern u32 gBattlePalaceMoveSelectionRngValue; -extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; +extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u8 gUnknown_020244B4[]; extern u16 gUnknown_020243FC; extern struct UnusedControllerStruct gUnknown_02022D0C; @@ -243,33 +243,33 @@ void nullsub_21(void) void SetControllerToPlayer(void) { - gBattleBankFunc[gActiveBank] = PlayerBufferRunCommand; + gBattlerFuncs[gActiveBattler] = PlayerBufferRunCommand; gDoingBattleAnim = FALSE; gPlayerDpadHoldFrames = 0; } static void PlayerBufferExecCompleted(void) { - gBattleBankFunc[gActiveBank] = PlayerBufferRunCommand; + gBattlerFuncs[gActiveBattler] = PlayerBufferRunCommand; if (gBattleTypeFlags & BATTLE_TYPE_LINK) { u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBank][0] = CONTROLLER_TERMINATOR_NOP; + gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { - gBattleExecBuffer &= ~gBitTable[gActiveBank]; + gBattleExecBuffer &= ~gBitTable[gActiveBattler]; } } static void PlayerBufferRunCommand(void) { - if (gBattleExecBuffer & gBitTable[gActiveBank]) + if (gBattleExecBuffer & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(sPlayerBufferCommands)) - sPlayerBufferCommands[gBattleBufferA[gActiveBank][0]](); + if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sPlayerBufferCommands)) + sPlayerBufferCommands[gBattleBufferA[gActiveBattler][0]](); else PlayerBufferExecCompleted(); } @@ -277,16 +277,16 @@ static void PlayerBufferRunCommand(void) static void CompleteOnBankSpritePosX_0(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].pos2.x == 0) + if (gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0) PlayerBufferExecCompleted(); } static void HandleInputChooseAction(void) { - u16 itemId = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + u16 itemId = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - dp11b_obj_instanciate(gActiveBank, 1, 7, 1); - dp11b_obj_instanciate(gActiveBank, 0, 7, 1); + dp11b_obj_instanciate(gActiveBattler, 1, 7, 1); + dp11b_obj_instanciate(gActiveBattler, 0, 7, 1); if (gMain.newAndRepeatedKeys & DPAD_ANY && gSaveBlock2Ptr->optionsButtonMode == 2) gPlayerDpadHoldFrames++; @@ -297,7 +297,7 @@ static void HandleInputChooseAction(void) { PlaySE(SE_SELECT); - switch (gActionSelectionCursor[gActiveBank]) + switch (gActionSelectionCursor[gActiveBattler]) { case 0: EmitTwoReturnValues(1, ACTION_USE_MOVE, 0); @@ -316,52 +316,52 @@ static void HandleInputChooseAction(void) } else if (gMain.newKeys & DPAD_LEFT) { - if (gActionSelectionCursor[gActiveBank] & 1) // if is ACTION_USE_ITEM or ACTION_RUN + if (gActionSelectionCursor[gActiveBattler] & 1) // if is ACTION_USE_ITEM or ACTION_RUN { PlaySE(SE_SELECT); - ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]); - gActionSelectionCursor[gActiveBank] ^= 1; - ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0); + ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); + gActionSelectionCursor[gActiveBattler] ^= 1; + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } else if (gMain.newKeys & DPAD_RIGHT) { - if (!(gActionSelectionCursor[gActiveBank] & 1)) // if is ACTION_USE_MOVE or ACTION_SWITCH + if (!(gActionSelectionCursor[gActiveBattler] & 1)) // if is ACTION_USE_MOVE or ACTION_SWITCH { PlaySE(SE_SELECT); - ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]); - gActionSelectionCursor[gActiveBank] ^= 1; - ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0); + ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); + gActionSelectionCursor[gActiveBattler] ^= 1; + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } else if (gMain.newKeys & DPAD_UP) { - if (gActionSelectionCursor[gActiveBank] & 2) // if is ACTION_SWITCH or ACTION_RUN + if (gActionSelectionCursor[gActiveBattler] & 2) // if is ACTION_SWITCH or ACTION_RUN { PlaySE(SE_SELECT); - ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]); - gActionSelectionCursor[gActiveBank] ^= 2; - ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0); + ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); + gActionSelectionCursor[gActiveBattler] ^= 2; + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } else if (gMain.newKeys & DPAD_DOWN) { - if (!(gActionSelectionCursor[gActiveBank] & 2)) // if is ACTION_USE_MOVE or ACTION_USE_ITEM + if (!(gActionSelectionCursor[gActiveBattler] & 2)) // if is ACTION_USE_MOVE or ACTION_USE_ITEM { PlaySE(SE_SELECT); - ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]); - gActionSelectionCursor[gActiveBank] ^= 2; - ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0); + ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); + gActionSelectionCursor[gActiveBattler] ^= 2; + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } else if (gMain.newKeys & B_BUTTON || gPlayerDpadHoldFrames > 59) { if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - && GetBankPosition(gActiveBank) == B_POSITION_PLAYER_RIGHT - && !(gAbsentBankFlags & gBitTable[GetBankByPosition(B_POSITION_PLAYER_LEFT)]) + && GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT + && !(gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - if (gBattleBufferA[gActiveBank][1] == ACTION_USE_ITEM) + if (gBattleBufferA[gActiveBattler][1] == ACTION_USE_ITEM) { // Add item to bag if it is a ball if (itemId <= ITEM_PREMIER_BALL) @@ -382,9 +382,9 @@ static void HandleInputChooseAction(void) static void sub_80577F0(void) // unused { - dp11b_obj_free(gActiveBank, 1); - dp11b_obj_free(gActiveBank, 0); - gBattleBankFunc[gActiveBank] = HandleInputChooseTarget; + dp11b_obj_free(gActiveBattler, 1); + dp11b_obj_free(gActiveBattler, 0); + gBattlerFuncs[gActiveBattler] = HandleInputChooseTarget; } static void HandleInputChooseTarget(void) @@ -397,14 +397,14 @@ static void HandleInputChooseTarget(void) // what a weird loop i = 0; - if (gBattleBanksCount != 0) + if (gBattlersCount != 0) { do { if (i != gMultiUsePlayerCursor) dp11b_obj_free(i, 1); i++; - } while (i < gBattleBanksCount); + } while (i < gBattlersCount); } if (gMain.heldKeys & DPAD_ANY && gSaveBlock2Ptr->optionsButtonMode == 2) @@ -416,7 +416,7 @@ static void HandleInputChooseTarget(void) { PlaySE(SE_SELECT); gSprites[gBankSpriteIds[gMultiUsePlayerCursor]].callback = sub_8039B2C; - EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBank] | (gMultiUsePlayerCursor << 8)); + EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); dp11b_obj_free(gMultiUsePlayerCursor, 1); PlayerBufferExecCompleted(); } @@ -424,9 +424,9 @@ static void HandleInputChooseTarget(void) { PlaySE(SE_SELECT); gSprites[gBankSpriteIds[gMultiUsePlayerCursor]].callback = sub_8039B2C; - gBattleBankFunc[gActiveBank] = HandleInputChooseMove; - dp11b_obj_instanciate(gActiveBank, 1, 7, 1); - dp11b_obj_instanciate(gActiveBank, 0, 7, 1); + gBattlerFuncs[gActiveBattler] = HandleInputChooseMove; + dp11b_obj_instanciate(gActiveBattler, 1, 7, 1); + dp11b_obj_instanciate(gActiveBattler, 0, 7, 1); dp11b_obj_free(gMultiUsePlayerCursor, 1); } else if (gMain.newKeys & (DPAD_LEFT | DPAD_UP)) @@ -436,9 +436,9 @@ static void HandleInputChooseTarget(void) do { - u8 currSelIdentity = GetBankPosition(gMultiUsePlayerCursor); + u8 currSelIdentity = GetBattlerPosition(gMultiUsePlayerCursor); - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { if (currSelIdentity == identities[i]) break; @@ -447,17 +447,17 @@ static void HandleInputChooseTarget(void) { if (--i < 0) i = 4; // UB: array out of range - gMultiUsePlayerCursor = GetBankByPosition(identities[i]); - } while (gMultiUsePlayerCursor == gBattleBanksCount); + gMultiUsePlayerCursor = GetBattlerAtPosition(identities[i]); + } while (gMultiUsePlayerCursor == gBattlersCount); i = 0; - switch (GetBankPosition(gMultiUsePlayerCursor)) + switch (GetBattlerPosition(gMultiUsePlayerCursor)) { case B_POSITION_PLAYER_LEFT: case B_POSITION_PLAYER_RIGHT: - if (gActiveBank != gMultiUsePlayerCursor) + if (gActiveBattler != gMultiUsePlayerCursor) i++; - else if (gBattleMoves[GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MOVE1 + gMoveSelectionCursor[gActiveBank])].target & MOVE_TARGET_USER) + else if (gBattleMoves[GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MOVE1 + gMoveSelectionCursor[gActiveBattler])].target & MOVE_TARGET_USER) i++; break; case B_POSITION_OPPONENT_LEFT: @@ -466,7 +466,7 @@ static void HandleInputChooseTarget(void) break; } - if (gAbsentBankFlags & gBitTable[gMultiUsePlayerCursor]) + if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor]) i = 0; } while (i == 0); gSprites[gBankSpriteIds[gMultiUsePlayerCursor]].callback = sub_8039AD8; @@ -478,9 +478,9 @@ static void HandleInputChooseTarget(void) do { - u8 currSelIdentity = GetBankPosition(gMultiUsePlayerCursor); + u8 currSelIdentity = GetBattlerPosition(gMultiUsePlayerCursor); - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { if (currSelIdentity == identities[i]) break; @@ -489,17 +489,17 @@ static void HandleInputChooseTarget(void) { if (++i > 3) i = 0; - gMultiUsePlayerCursor = GetBankByPosition(identities[i]); - } while (gMultiUsePlayerCursor == gBattleBanksCount); + gMultiUsePlayerCursor = GetBattlerAtPosition(identities[i]); + } while (gMultiUsePlayerCursor == gBattlersCount); i = 0; - switch (GetBankPosition(gMultiUsePlayerCursor)) + switch (GetBattlerPosition(gMultiUsePlayerCursor)) { case B_POSITION_PLAYER_LEFT: case B_POSITION_PLAYER_RIGHT: - if (gActiveBank != gMultiUsePlayerCursor) + if (gActiveBattler != gMultiUsePlayerCursor) i++; - else if (gBattleMoves[GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MOVE1 + gMoveSelectionCursor[gActiveBank])].target & MOVE_TARGET_USER) + else if (gBattleMoves[GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MOVE1 + gMoveSelectionCursor[gActiveBattler])].target & MOVE_TARGET_USER) i++; break; case B_POSITION_OPPONENT_LEFT: @@ -508,7 +508,7 @@ static void HandleInputChooseTarget(void) break; } - if (gAbsentBankFlags & gBitTable[gMultiUsePlayerCursor]) + if (gAbsentBattlerFlags & gBitTable[gMultiUsePlayerCursor]) i = 0; } while (i == 0); gSprites[gBankSpriteIds[gMultiUsePlayerCursor]].callback = sub_8039AD8; @@ -518,7 +518,7 @@ static void HandleInputChooseTarget(void) static void HandleInputChooseMove(void) { bool32 canSelectTarget = FALSE; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); if (gMain.heldKeys & DPAD_ANY && gSaveBlock2Ptr->optionsButtonMode == 2) gPlayerDpadHoldFrames++; @@ -530,7 +530,7 @@ static void HandleInputChooseMove(void) u8 moveTarget; PlaySE(SE_SELECT); - if (moveInfo->moves[gMoveSelectionCursor[gActiveBank]] == MOVE_CURSE) + if (moveInfo->moves[gMoveSelectionCursor[gActiveBattler]] == MOVE_CURSE) { if (moveInfo->monType1 != TYPE_GHOST && moveInfo->monType2 != TYPE_GHOST) moveTarget = MOVE_TARGET_x10; @@ -539,17 +539,17 @@ static void HandleInputChooseMove(void) } else { - moveTarget = gBattleMoves[moveInfo->moves[gMoveSelectionCursor[gActiveBank]]].target; + moveTarget = gBattleMoves[moveInfo->moves[gMoveSelectionCursor[gActiveBattler]]].target; } if (moveTarget & MOVE_TARGET_x10) - gMultiUsePlayerCursor = gActiveBank; + gMultiUsePlayerCursor = gActiveBattler; else - gMultiUsePlayerCursor = GetBankByPosition((GetBankPosition(gActiveBank) & BIT_SIDE) ^ BIT_SIDE); + gMultiUsePlayerCursor = GetBattlerAtPosition((GetBattlerPosition(gActiveBattler) & BIT_SIDE) ^ BIT_SIDE); - if (!gBattleBufferA[gActiveBank][1]) // not a double battle + if (!gBattleBufferA[gActiveBattler][1]) // not a double battle { - if (moveTarget & MOVE_TARGET_USER && !gBattleBufferA[gActiveBank][2]) + if (moveTarget & MOVE_TARGET_USER && !gBattleBufferA[gActiveBattler][2]) canSelectTarget++; } else // double battle @@ -557,32 +557,32 @@ static void HandleInputChooseMove(void) if (!(moveTarget & (MOVE_TARGET_RANDOM | MOVE_TARGET_BOTH | MOVE_TARGET_DEPENDS | MOVE_TARGET_FOES_AND_ALLY | MOVE_TARGET_OPPONENTS_FIELD | MOVE_TARGET_x10))) canSelectTarget++; // either selected or user - if (moveInfo->currentPp[gMoveSelectionCursor[gActiveBank]] == 0) + if (moveInfo->currentPp[gMoveSelectionCursor[gActiveBattler]] == 0) { canSelectTarget = FALSE; } else if (!(moveTarget & (MOVE_TARGET_x10 | MOVE_TARGET_USER)) && CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) <= 1) { - gMultiUsePlayerCursor = GetDefaultMoveTarget(gActiveBank); + gMultiUsePlayerCursor = GetDefaultMoveTarget(gActiveBattler); canSelectTarget = FALSE; } } if (!canSelectTarget) { - EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBank] | (gMultiUsePlayerCursor << 8)); + EmitTwoReturnValues(1, 10, gMoveSelectionCursor[gActiveBattler] | (gMultiUsePlayerCursor << 8)); PlayerBufferExecCompleted(); } else { - gBattleBankFunc[gActiveBank] = HandleInputChooseTarget; + gBattlerFuncs[gActiveBattler] = HandleInputChooseTarget; if (moveTarget & (MOVE_TARGET_x10 | MOVE_TARGET_USER)) - gMultiUsePlayerCursor = gActiveBank; - else if (gAbsentBankFlags & gBitTable[GetBankByPosition(B_POSITION_OPPONENT_LEFT)]) - gMultiUsePlayerCursor = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + gMultiUsePlayerCursor = gActiveBattler; + else if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)]) + gMultiUsePlayerCursor = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); else - gMultiUsePlayerCursor = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + gMultiUsePlayerCursor = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); gSprites[gBankSpriteIds[gMultiUsePlayerCursor]].callback = sub_8039AD8; } @@ -595,50 +595,50 @@ static void HandleInputChooseMove(void) } else if (gMain.newKeys & DPAD_LEFT) { - if (gMoveSelectionCursor[gActiveBank] & 1) + if (gMoveSelectionCursor[gActiveBattler] & 1) { - MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBank]); - gMoveSelectionCursor[gActiveBank] ^= 1; + MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); + gMoveSelectionCursor[gActiveBattler] ^= 1; PlaySE(SE_SELECT); - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 0); + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); MoveSelectionDisplayPpNumber(); MoveSelectionDisplayMoveType(); } } else if (gMain.newKeys & DPAD_RIGHT) { - if (!(gMoveSelectionCursor[gActiveBank] & 1) - && (gMoveSelectionCursor[gActiveBank] ^ 1) < gNumberOfMovesToChoose) + if (!(gMoveSelectionCursor[gActiveBattler] & 1) + && (gMoveSelectionCursor[gActiveBattler] ^ 1) < gNumberOfMovesToChoose) { - MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBank]); - gMoveSelectionCursor[gActiveBank] ^= 1; + MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); + gMoveSelectionCursor[gActiveBattler] ^= 1; PlaySE(SE_SELECT); - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 0); + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); MoveSelectionDisplayPpNumber(); MoveSelectionDisplayMoveType(); } } else if (gMain.newKeys & DPAD_UP) { - if (gMoveSelectionCursor[gActiveBank] & 2) + if (gMoveSelectionCursor[gActiveBattler] & 2) { - MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBank]); - gMoveSelectionCursor[gActiveBank] ^= 2; + MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); + gMoveSelectionCursor[gActiveBattler] ^= 2; PlaySE(SE_SELECT); - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 0); + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); MoveSelectionDisplayPpNumber(); MoveSelectionDisplayMoveType(); } } else if (gMain.newKeys & DPAD_DOWN) { - if (!(gMoveSelectionCursor[gActiveBank] & 2) - && (gMoveSelectionCursor[gActiveBank] ^ 2) < gNumberOfMovesToChoose) + if (!(gMoveSelectionCursor[gActiveBattler] & 2) + && (gMoveSelectionCursor[gActiveBattler] ^ 2) < gNumberOfMovesToChoose) { - MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBank]); - gMoveSelectionCursor[gActiveBank] ^= 2; + MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); + gMoveSelectionCursor[gActiveBattler] ^= 2; PlaySE(SE_SELECT); - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 0); + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); MoveSelectionDisplayPpNumber(); MoveSelectionDisplayMoveType(); } @@ -647,16 +647,16 @@ static void HandleInputChooseMove(void) { if (gNumberOfMovesToChoose > 1 && !(gBattleTypeFlags & BATTLE_TYPE_LINK)) { - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 29); + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 29); - if (gMoveSelectionCursor[gActiveBank] != 0) + if (gMoveSelectionCursor[gActiveBattler] != 0) gMultiUsePlayerCursor = 0; else - gMultiUsePlayerCursor = gMoveSelectionCursor[gActiveBank] + 1; + gMultiUsePlayerCursor = gMoveSelectionCursor[gActiveBattler] + 1; MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27); BattleHandleAddTextPrinter(gText_BattleSwitchWhich, 0xB); - gBattleBankFunc[gActiveBank] = HandleMoveSwitchting; + gBattlerFuncs[gActiveBattler] = HandleMoveSwitchting; } } } @@ -677,35 +677,35 @@ u32 sub_8057FBC(void) // unused gBattle_BG0_Y = 0x140; var = 0xFF; } - if (gMain.newKeys & DPAD_LEFT && gMoveSelectionCursor[gActiveBank] & 1) + if (gMain.newKeys & DPAD_LEFT && gMoveSelectionCursor[gActiveBattler] & 1) { - MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBank]); - gMoveSelectionCursor[gActiveBank] ^= 1; + MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); + gMoveSelectionCursor[gActiveBattler] ^= 1; PlaySE(SE_SELECT); - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 0); + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); } - if (gMain.newKeys & DPAD_RIGHT && !(gMoveSelectionCursor[gActiveBank] & 1) - && (gMoveSelectionCursor[gActiveBank] ^ 1) < gNumberOfMovesToChoose) + if (gMain.newKeys & DPAD_RIGHT && !(gMoveSelectionCursor[gActiveBattler] & 1) + && (gMoveSelectionCursor[gActiveBattler] ^ 1) < gNumberOfMovesToChoose) { - MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBank]); - gMoveSelectionCursor[gActiveBank] ^= 1; + MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); + gMoveSelectionCursor[gActiveBattler] ^= 1; PlaySE(SE_SELECT); - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 0); + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); } - if (gMain.newKeys & DPAD_UP && gMoveSelectionCursor[gActiveBank] & 2) + if (gMain.newKeys & DPAD_UP && gMoveSelectionCursor[gActiveBattler] & 2) { - MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBank]); - gMoveSelectionCursor[gActiveBank] ^= 2; + MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); + gMoveSelectionCursor[gActiveBattler] ^= 2; PlaySE(SE_SELECT); - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 0); + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); } - if (gMain.newKeys & DPAD_DOWN && !(gMoveSelectionCursor[gActiveBank] & 2) - && (gMoveSelectionCursor[gActiveBank] ^ 2) < gNumberOfMovesToChoose) + if (gMain.newKeys & DPAD_DOWN && !(gMoveSelectionCursor[gActiveBattler] & 2) + && (gMoveSelectionCursor[gActiveBattler] ^ 2) < gNumberOfMovesToChoose) { - MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBank]); - gMoveSelectionCursor[gActiveBank] ^= 2; + MoveSelectionDestroyCursorAt(gMoveSelectionCursor[gActiveBattler]); + gMoveSelectionCursor[gActiveBattler] ^= 2; PlaySE(SE_SELECT); - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 0); + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); } return var; @@ -721,73 +721,73 @@ static void HandleMoveSwitchting(void) { PlaySE(SE_SELECT); - if (gMoveSelectionCursor[gActiveBank] != gMultiUsePlayerCursor) + if (gMoveSelectionCursor[gActiveBattler] != gMultiUsePlayerCursor) { - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); s32 i; // swap moves and pp - i = moveInfo->moves[gMoveSelectionCursor[gActiveBank]]; - moveInfo->moves[gMoveSelectionCursor[gActiveBank]] = moveInfo->moves[gMultiUsePlayerCursor]; + i = moveInfo->moves[gMoveSelectionCursor[gActiveBattler]]; + moveInfo->moves[gMoveSelectionCursor[gActiveBattler]] = moveInfo->moves[gMultiUsePlayerCursor]; moveInfo->moves[gMultiUsePlayerCursor] = i; - i = moveInfo->currentPp[gMoveSelectionCursor[gActiveBank]]; - moveInfo->currentPp[gMoveSelectionCursor[gActiveBank]] = moveInfo->currentPp[gMultiUsePlayerCursor]; + i = moveInfo->currentPp[gMoveSelectionCursor[gActiveBattler]]; + moveInfo->currentPp[gMoveSelectionCursor[gActiveBattler]] = moveInfo->currentPp[gMultiUsePlayerCursor]; moveInfo->currentPp[gMultiUsePlayerCursor] = i; - i = moveInfo->maxPp[gMoveSelectionCursor[gActiveBank]]; - moveInfo->maxPp[gMoveSelectionCursor[gActiveBank]] = moveInfo->maxPp[gMultiUsePlayerCursor]; + i = moveInfo->maxPp[gMoveSelectionCursor[gActiveBattler]]; + moveInfo->maxPp[gMoveSelectionCursor[gActiveBattler]] = moveInfo->maxPp[gMultiUsePlayerCursor]; moveInfo->maxPp[gMultiUsePlayerCursor] = i; - if (gDisableStructs[gActiveBank].unk18_b & gBitTable[gMoveSelectionCursor[gActiveBank]]) + if (gDisableStructs[gActiveBattler].unk18_b & gBitTable[gMoveSelectionCursor[gActiveBattler]]) { - gDisableStructs[gActiveBank].unk18_b &= (~gBitTable[gMoveSelectionCursor[gActiveBank]]); - gDisableStructs[gActiveBank].unk18_b |= gBitTable[gMultiUsePlayerCursor]; + gDisableStructs[gActiveBattler].unk18_b &= (~gBitTable[gMoveSelectionCursor[gActiveBattler]]); + gDisableStructs[gActiveBattler].unk18_b |= gBitTable[gMultiUsePlayerCursor]; } MoveSelectionDisplayMoveNames(); for (i = 0; i < 4; i++) - perMovePPBonuses[i] = (gBattleMons[gActiveBank].ppBonuses & (3 << (i * 2))) >> (i * 2); + perMovePPBonuses[i] = (gBattleMons[gActiveBattler].ppBonuses & (3 << (i * 2))) >> (i * 2); - totalPPBonuses = perMovePPBonuses[gMoveSelectionCursor[gActiveBank]]; - perMovePPBonuses[gMoveSelectionCursor[gActiveBank]] = perMovePPBonuses[gMultiUsePlayerCursor]; + totalPPBonuses = perMovePPBonuses[gMoveSelectionCursor[gActiveBattler]]; + perMovePPBonuses[gMoveSelectionCursor[gActiveBattler]] = perMovePPBonuses[gMultiUsePlayerCursor]; perMovePPBonuses[gMultiUsePlayerCursor] = totalPPBonuses; totalPPBonuses = 0; for (i = 0; i < 4; i++) totalPPBonuses |= perMovePPBonuses[i] << (i * 2); - gBattleMons[gActiveBank].ppBonuses = totalPPBonuses; + gBattleMons[gActiveBattler].ppBonuses = totalPPBonuses; for (i = 0; i < 4; i++) { - gBattleMons[gActiveBank].moves[i] = moveInfo->moves[i]; - gBattleMons[gActiveBank].pp[i] = moveInfo->currentPp[i]; + gBattleMons[gActiveBattler].moves[i] = moveInfo->moves[i]; + gBattleMons[gActiveBattler].pp[i] = moveInfo->currentPp[i]; } - if (!(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) + if (!(gBattleMons[gActiveBattler].status2 & STATUS2_TRANSFORMED)) { for (i = 0; i < 4; i++) { - moveStruct.moves[i] = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MOVE1 + i); - moveStruct.currentPp[i] = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_PP1 + i); + moveStruct.moves[i] = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MOVE1 + i); + moveStruct.currentPp[i] = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_PP1 + i); } - totalPPBonuses = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_PP_BONUSES); + totalPPBonuses = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_PP_BONUSES); for (i = 0; i < 4; i++) perMovePPBonuses[i] = (totalPPBonuses & (3 << (i * 2))) >> (i * 2); - i = moveStruct.moves[gMoveSelectionCursor[gActiveBank]]; - moveStruct.moves[gMoveSelectionCursor[gActiveBank]] = moveStruct.moves[gMultiUsePlayerCursor]; + i = moveStruct.moves[gMoveSelectionCursor[gActiveBattler]]; + moveStruct.moves[gMoveSelectionCursor[gActiveBattler]] = moveStruct.moves[gMultiUsePlayerCursor]; moveStruct.moves[gMultiUsePlayerCursor] = i; - i = moveStruct.currentPp[gMoveSelectionCursor[gActiveBank]]; - moveStruct.currentPp[gMoveSelectionCursor[gActiveBank]] = moveStruct.currentPp[gMultiUsePlayerCursor]; + i = moveStruct.currentPp[gMoveSelectionCursor[gActiveBattler]]; + moveStruct.currentPp[gMoveSelectionCursor[gActiveBattler]] = moveStruct.currentPp[gMultiUsePlayerCursor]; moveStruct.currentPp[gMultiUsePlayerCursor] = i; - totalPPBonuses = perMovePPBonuses[gMoveSelectionCursor[gActiveBank]]; - perMovePPBonuses[gMoveSelectionCursor[gActiveBank]] = perMovePPBonuses[gMultiUsePlayerCursor]; + totalPPBonuses = perMovePPBonuses[gMoveSelectionCursor[gActiveBattler]]; + perMovePPBonuses[gMoveSelectionCursor[gActiveBattler]] = perMovePPBonuses[gMultiUsePlayerCursor]; perMovePPBonuses[gMultiUsePlayerCursor] = totalPPBonuses; totalPPBonuses = 0; @@ -796,17 +796,17 @@ static void HandleMoveSwitchting(void) for (i = 0; i < 4; i++) { - SetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MOVE1 + i, &moveStruct.moves[i]); - SetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_PP1 + i, &moveStruct.currentPp[i]); + SetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MOVE1 + i, &moveStruct.moves[i]); + SetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_PP1 + i, &moveStruct.currentPp[i]); } - SetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_PP_BONUSES, &totalPPBonuses); + SetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_PP_BONUSES, &totalPPBonuses); } } - gBattleBankFunc[gActiveBank] = HandleInputChooseMove; - gMoveSelectionCursor[gActiveBank] = gMultiUsePlayerCursor; - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 0); + gBattlerFuncs[gActiveBattler] = HandleInputChooseMove; + gMoveSelectionCursor[gActiveBattler] = gMultiUsePlayerCursor; + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); MoveSelectionDisplayPpString(); MoveSelectionDisplayPpNumber(); MoveSelectionDisplayMoveType(); @@ -815,8 +815,8 @@ static void HandleMoveSwitchting(void) { PlaySE(SE_SELECT); MoveSelectionDestroyCursorAt(gMultiUsePlayerCursor); - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 0); - gBattleBankFunc[gActiveBank] = HandleInputChooseMove; + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); + gBattlerFuncs[gActiveBattler] = HandleInputChooseMove; MoveSelectionDisplayPpString(); MoveSelectionDisplayPpNumber(); MoveSelectionDisplayMoveType(); @@ -825,15 +825,15 @@ static void HandleMoveSwitchting(void) { if (gMultiUsePlayerCursor & 1) { - if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBank]) - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 29); + if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler]) + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 29); else MoveSelectionDestroyCursorAt(gMultiUsePlayerCursor); gMultiUsePlayerCursor ^= 1; PlaySE(SE_SELECT); - if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBank]) + if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler]) MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 0); else MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27); @@ -843,15 +843,15 @@ static void HandleMoveSwitchting(void) { if (!(gMultiUsePlayerCursor & 1) && (gMultiUsePlayerCursor ^ 1) < gNumberOfMovesToChoose) { - if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBank]) - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 29); + if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler]) + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 29); else MoveSelectionDestroyCursorAt(gMultiUsePlayerCursor); gMultiUsePlayerCursor ^= 1; PlaySE(SE_SELECT); - if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBank]) + if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler]) MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 0); else MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27); @@ -861,15 +861,15 @@ static void HandleMoveSwitchting(void) { if (gMultiUsePlayerCursor & 2) { - if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBank]) - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 29); + if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler]) + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 29); else MoveSelectionDestroyCursorAt(gMultiUsePlayerCursor); gMultiUsePlayerCursor ^= 2; PlaySE(SE_SELECT); - if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBank]) + if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler]) MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 0); else MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27); @@ -879,15 +879,15 @@ static void HandleMoveSwitchting(void) { if (!(gMultiUsePlayerCursor & 2) && (gMultiUsePlayerCursor ^ 2) < gNumberOfMovesToChoose) { - if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBank]) - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 29); + if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler]) + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 29); else MoveSelectionDestroyCursorAt(gMultiUsePlayerCursor); gMultiUsePlayerCursor ^= 2; PlaySE(SE_SELECT); - if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBank]) + if (gMultiUsePlayerCursor == gMoveSelectionCursor[gActiveBattler]) MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 0); else MoveSelectionCreateCursorAt(gMultiUsePlayerCursor, 27); @@ -938,7 +938,7 @@ void sub_80587B0(void) else sub_800ADF8(); - gBattleBankFunc[gActiveBank] = sub_80586F8; + gBattlerFuncs[gActiveBattler] = sub_80586F8; } } else @@ -953,32 +953,32 @@ void sub_80587B0(void) static void CompleteOnBankSpriteCallbackDummy(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) PlayerBufferExecCompleted(); } static void CompleteOnBankSpriteCallbackDummy2(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) PlayerBufferExecCompleted(); } static void sub_80588B4(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { nullsub_25(gSaveBlock2Ptr->playerGender); - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); PlayerBufferExecCompleted(); } } static void sub_8058924(void) { - if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 == 0xFF) + if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; PlayerBufferExecCompleted(); } } @@ -989,33 +989,33 @@ static void sub_805896C(void) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) var = TRUE; } else { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gHealthBoxesIds[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) var = TRUE; } - if (var && gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 - && gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1) + if (var && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); if (IsDoubleBattle()) - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], gActiveBank ^ BIT_MON); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3; - gBattleBankFunc[gActiveBank] = sub_8058924; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; + gBattlerFuncs[gActiveBattler] = sub_8058924; } } @@ -1024,58 +1024,58 @@ static void sub_8058B40(void) bool32 r9 = FALSE; bool32 r8 = FALSE; - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) - sub_8172EF0(gActiveBank, &gPlayerParty[gBattlePartyID[gActiveBank]]); - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive) - sub_8172EF0(gActiveBank ^ BIT_MON, &gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]]); + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) + sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) + sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]]); - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank ^ BIT_MON], &gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], HEALTHBOX_ALL); - sub_8076918(gActiveBank ^ BIT_MON); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank ^ BIT_MON]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler ^ BIT_FLANK); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); } - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; } - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x40 - && gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x40 + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40 && !IsCryPlayingOrClearCrySongs()) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) m4aMPlayContinue(&gMPlayInfo_BGM); else m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1; r9 = TRUE; } if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { r8 = TRUE; } } else { - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gUnknown_03005D7C[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) { r8 = TRUE; } @@ -1084,63 +1084,63 @@ static void sub_8058B40(void) if (r9 && r8) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank ^ BIT_MON]]); - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); gBattleSpritesDataPtr->animationData->field_9_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; - gBattleBankFunc[gActiveBank] = sub_805896C; + gBattlerFuncs[gActiveBattler] = sub_805896C; } } static void sub_8058EDC(void) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy - && gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - CopyBattleSpriteInvisibility(gActiveBank); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + CopyBattleSpriteInvisibility(gActiveBattler); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleBankFunc[gActiveBank] = sub_8058FC0; + gBattlerFuncs[gActiveBattler] = sub_8058FC0; } } static void sub_8058FC0(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs()) { m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); PlayerBufferExecCompleted(); } } static void sub_805902C(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - sub_8172EF0(gActiveBank, &gPlayerParty[gBattlePartyID[gActiveBank]]); + sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); } - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); - gBattleBankFunc[gActiveBank] = sub_8058EDC; + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); + gBattlerFuncs[gActiveBattler] = sub_8058EDC; } } @@ -1155,17 +1155,17 @@ void c3_0802FDF4(u8 taskId) static void CompleteOnHealthbarDone(void) { - s16 hpValue = sub_8074AA0(gActiveBank, gHealthBoxesIds[gActiveBank], HEALTH_BAR, 0); + s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); if (hpValue != -1) { - UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBank], hpValue, HP_CURRENT); + UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); } else { - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); PlayerBufferExecCompleted(); } } @@ -1202,13 +1202,13 @@ static void Task_GiveExpToMon(u8 taskId) SetMonData(mon, MON_DATA_EXP, &nextLvlExp); CalculateMonStats(mon); gainedExp -= nextLvlExp - currExp; - savedActiveBank = gActiveBank; - gActiveBank = bank; + savedActiveBank = gActiveBattler; + gActiveBattler = bank; EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp); - gActiveBank = savedActiveBank; + gActiveBattler = savedActiveBank; if (IsDoubleBattle() == TRUE - && ((u16)(monId) == gBattlePartyID[bank] || (u16)(monId) == gBattlePartyID[bank ^ BIT_MON])) + && ((u16)(monId) == gBattlePartyID[bank] || (u16)(monId) == gBattlePartyID[bank ^ BIT_FLANK])) gTasks[taskId].func = sub_8059544; else gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter; @@ -1217,7 +1217,7 @@ static void Task_GiveExpToMon(u8 taskId) { currExp += gainedExp; SetMonData(mon, MON_DATA_EXP, &currExp); - gBattleBankFunc[bank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[bank] = CompleteOnInactiveTextPrinter; DestroyTask(taskId); } } @@ -1281,17 +1281,17 @@ static void sub_8059400(u8 taskId) SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &expOnNextLvl); CalculateMonStats(&gPlayerParty[monId]); gainedExp -= expOnNextLvl - currExp; - savedActiveBank = gActiveBank; - gActiveBank = bank; + savedActiveBank = gActiveBattler; + gActiveBattler = bank; EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp); - gActiveBank = savedActiveBank; + gActiveBattler = savedActiveBank; gTasks[taskId].func = sub_8059544; } else { currExp += gainedExp; SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp); - gBattleBankFunc[bank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[bank] = CompleteOnInactiveTextPrinter; DestroyTask(taskId); } } @@ -1303,8 +1303,8 @@ static void sub_8059544(u8 taskId) u8 bank = gTasks[taskId].tExpTask_bank; u8 monIndex = gTasks[taskId].tExpTask_monId; - if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON]) - bank ^= BIT_MON; + if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_FLANK]) + bank ^= BIT_FLANK; InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP); gTasks[taskId].func = sub_80595A4; @@ -1320,8 +1320,8 @@ static void sub_80595A4(u8 taskId) GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value - if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON]) - UpdateHealthboxAttribute(gHealthBoxesIds[bank ^ BIT_MON], &gPlayerParty[monIndex], HEALTHBOX_ALL); + if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_FLANK]) + UpdateHealthboxAttribute(gHealthBoxesIds[bank ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL); else UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gPlayerParty[monIndex], HEALTHBOX_ALL); @@ -1337,31 +1337,31 @@ static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId) monIndex = gTasks[taskId].tExpTask_monId; GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value bank = gTasks[taskId].tExpTask_bank; - gBattleBankFunc[bank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[bank] = CompleteOnInactiveTextPrinter; DestroyTask(taskId); } static void sub_80596A8(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].pos1.y + gSprites[gBankSpriteIds[gActiveBank]].pos2.y > DISPLAY_HEIGHT) + if (gSprites[gBankSpriteIds[gActiveBattler]].pos1.y + gSprites[gBankSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT) { - u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); nullsub_24(species); - FreeOamMatrix(gSprites[gBankSpriteIds[gActiveBank]].oam.matrixNum); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeOamMatrix(gSprites[gBankSpriteIds[gActiveBattler]].oam.matrixNum); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); PlayerBufferExecCompleted(); } } static void sub_8059744(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); PlayerBufferExecCompleted(); } } @@ -1378,9 +1378,9 @@ static void sub_80597CC(void) { u8 r4; - gBattleBankFunc[gActiveBank] = sub_8059828; - r4 = gTasks[gUnknown_03005D7C[gActiveBank]].data[0]; - DestroyTask(gUnknown_03005D7C[gActiveBank]); + gBattlerFuncs[gActiveBattler] = sub_8059828; + r4 = gTasks[gUnknown_03005D7C[gActiveBattler]].data[0]; + DestroyTask(gUnknown_03005D7C[gActiveBattler]); FreeAllWindowBuffers(); sub_81B89AC(r4); } @@ -1395,7 +1395,7 @@ static void sub_8059828(void) else EmitChosenMonReturnValue(1, 6, NULL); - if ((gBattleBufferA[gActiveBank][1] & 0xF) == 1) + if ((gBattleBufferA[gActiveBattler][1] & 0xF) == 1) PrintLinkStandbyMsg(); PlayerBufferExecCompleted(); @@ -1406,7 +1406,7 @@ static void OpenBagAndChooseItem(void) { if (!gPaletteFade.active) { - gBattleBankFunc[gActiveBank] = CompleteWhenChoseItem; + gBattlerFuncs[gActiveBattler] = CompleteWhenChoseItem; nullsub_35(); FreeAllWindowBuffers(); sub_81AABB0(); @@ -1424,13 +1424,13 @@ static void CompleteWhenChoseItem(void) static void CompleteOnSpecialAnimDone(void) { - if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) PlayerBufferExecCompleted(); } static void DoHitAnimBlinkSpriteEffect(void) { - u8 spriteId = gBankSpriteIds[gActiveBank]; + u8 spriteId = gBankSpriteIds[gActiveBattler]; if (gSprites[spriteId].data[1] == 32) { @@ -1486,7 +1486,7 @@ static void PlayerHandleUnknownYesNoInput(void) static void MoveSelectionDisplayMoveNames(void) { s32 i; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); gNumberOfMovesToChoose = 0; for (i = 0; i < 4; i++) @@ -1510,15 +1510,15 @@ static void MoveSelectionDisplayPpNumber(void) u8 *txtPtr; struct ChooseMoveStruct *moveInfo; - if (gBattleBufferA[gActiveBank][2] == TRUE) // check if we didn't want to display pp number + if (gBattleBufferA[gActiveBattler][2] == TRUE) // check if we didn't want to display pp number return; SetPpNumbersPaletteInMoveSelection(); - moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); - txtPtr = ConvertIntToDecimalStringN(gDisplayedStringBattle, moveInfo->currentPp[gMoveSelectionCursor[gActiveBank]], STR_CONV_MODE_RIGHT_ALIGN, 2); + moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); + txtPtr = ConvertIntToDecimalStringN(gDisplayedStringBattle, moveInfo->currentPp[gMoveSelectionCursor[gActiveBattler]], STR_CONV_MODE_RIGHT_ALIGN, 2); txtPtr[0] = CHAR_SLASH; txtPtr++; - ConvertIntToDecimalStringN(txtPtr, moveInfo->maxPp[gMoveSelectionCursor[gActiveBank]], STR_CONV_MODE_RIGHT_ALIGN, 2); + ConvertIntToDecimalStringN(txtPtr, moveInfo->maxPp[gMoveSelectionCursor[gActiveBattler]], STR_CONV_MODE_RIGHT_ALIGN, 2); BattleHandleAddTextPrinter(gDisplayedStringBattle, 9); } @@ -1526,7 +1526,7 @@ static void MoveSelectionDisplayPpNumber(void) static void MoveSelectionDisplayMoveType(void) { u8 *txtPtr; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); txtPtr = StringCopy(gDisplayedStringBattle, gText_MoveInterfaceType); txtPtr[0] = EXT_CTRL_CODE_BEGIN; @@ -1536,7 +1536,7 @@ static void MoveSelectionDisplayMoveType(void) txtPtr[0] = 1; txtPtr++; - StringCopy(txtPtr, gTypeNames[gBattleMoves[moveInfo->moves[gMoveSelectionCursor[gActiveBank]]].type]); + StringCopy(txtPtr, gTypeNames[gBattleMoves[moveInfo->moves[gMoveSelectionCursor[gActiveBattler]]].type]); BattleHandleAddTextPrinter(gDisplayedStringBattle, 10); } @@ -1592,13 +1592,13 @@ void SetCB2ToReshowScreenAfterMenu2(void) static void CompleteOnFinishedStatusAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) PlayerBufferExecCompleted(); } static void CompleteOnFinishedBattleAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive) PlayerBufferExecCompleted(); } @@ -1619,13 +1619,13 @@ static void PlayerHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - size += CopyPlayerMonData(gBattlePartyID[gActiveBank], monData); + size += CopyPlayerMonData(gBattlePartyID[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -1647,7 +1647,7 @@ static u32 CopyPlayerMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); @@ -1713,7 +1713,7 @@ static u32 CopyPlayerMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -1728,7 +1728,7 @@ static u32 CopyPlayerMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -1946,14 +1946,14 @@ static u32 CopyPlayerMonData(u8 monId, u8 *dst) void PlayerHandleGetRawMonData(void) { struct BattlePokemon battleMon; - u8 *src = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; - u8 *dst = (u8 *)&battleMon + gBattleBufferA[gActiveBank][1]; + u8 *src = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; + u8 *dst = (u8 *)&battleMon + gBattleBufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) + for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) dst[i] = src[i]; - EmitDataTransfer(1, gBattleBufferA[gActiveBank][2], dst); + EmitDataTransfer(1, gBattleBufferA[gActiveBattler][2], dst); PlayerBufferExecCompleted(); } @@ -1962,13 +1962,13 @@ static void PlayerHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - SetPlayerMonData(gBattlePartyID[gActiveBank]); + SetPlayerMonData(gBattlePartyID[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -1981,11 +1981,11 @@ static void PlayerHandleSetMonData(void) static void SetPlayerMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBank][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -2026,10 +2026,10 @@ static void SetPlayerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < 4; i++) @@ -2043,187 +2043,187 @@ static void SetPlayerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBank][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][7]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][8]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; } - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); } static void PlayerHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; + u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) - dst[i] = gBattleBufferA[gActiveBank][3 + i]; + for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) + dst[i] = gBattleBufferA[gActiveBattler][3 + i]; PlayerBufferExecCompleted(); } static void PlayerHandleLoadMonSprite(void) { - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - gBattleBankFunc[gActiveBank] = CompleteOnBankSpritePosX_0; + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpritePosX_0; } static void PlayerHandleSwitchInAnim(void) { - ClearTemporarySpeciesSpriteData(gActiveBank, gBattleBufferA[gActiveBank][2]); - gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1]; - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - gActionSelectionCursor[gActiveBank] = 0; - gMoveSelectionCursor[gActiveBank] = 0; - sub_805B258(gActiveBank, gBattleBufferA[gActiveBank][2]); - gBattleBankFunc[gActiveBank] = sub_805902C; + ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + gActionSelectionCursor[gActiveBattler] = 0; + gMoveSelectionCursor[gActiveBattler] = 0; + sub_805B258(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlerFuncs[gActiveBattler] = sub_805902C; } static void sub_805B258(u8 bank, bool8 dontClearSubstituteBit) @@ -2234,7 +2234,7 @@ static void sub_805B258(u8 bank, bool8 dontClearSubstituteBit) gBattlePartyID[bank] = gBattleBufferA[bank][1]; species = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); - sub_806A068(species, GetBankPosition(bank)); + sub_806A068(species, GetBattlerPosition(bank)); gBankSpriteIds[bank] = CreateSprite( &gUnknown_0202499C, @@ -2259,36 +2259,36 @@ static void sub_805B258(u8 bank, bool8 dontClearSubstituteBit) static void PlayerHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBank][1] == 0) + if (gBattleBufferA[gActiveBattler][1] == 0) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = DoSwitchOutAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; } else { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); PlayerBufferExecCompleted(); } } static void DoSwitchOutAnimation(void) { - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); - gBattleBankFunc[gActiveBank] = sub_8059744; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); + gBattlerFuncs[gActiveBattler] = sub_8059744; } break; } @@ -2326,7 +2326,7 @@ static void PlayerHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((GetBankPosition(gActiveBank) & BIT_MON) != 0) // second mon + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon xPos = 90; else // first mon xPos = 32; @@ -2352,32 +2352,32 @@ static void PlayerHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && gPartnerTrainerId != STEVEN_PARTNER_ID) { trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender); - DecompressTrainerFrontPic(trainerPicId, gActiveBank); - sub_806A1C0(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBank)); + DecompressTrainerFrontPic(trainerPicId, gActiveBattler); + sub_806A1C0(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 240; - gSprites[gBankSpriteIds[gActiveBank]].pos2.y = 48; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; - gSprites[gBankSpriteIds[gActiveBank]].oam.affineMode = 0; - gSprites[gBankSpriteIds[gActiveBank]].hFlip = 1; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.y = 48; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].oam.affineMode = 0; + gSprites[gBankSpriteIds[gActiveBattler]].hFlip = 1; } // use the back pic in any other scenario else { - DecompressTrainerBackPic(trainerPicId, gActiveBank); - sub_806A12C(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBank)); + DecompressTrainerBackPic(trainerPicId, gActiveBattler); + sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; } - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; } static void PlayerHandleTrainerSlide(void) @@ -2406,49 +2406,49 @@ static void PlayerHandleTrainerSlide(void) trainerPicId = gSaveBlock2Ptr->playerGender; } - DecompressTrainerBackPic(trainerPicId, gActiveBank); - sub_806A12C(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, 80, (8 - gTrainerBackPicCoords[trainerPicId].coords) * 4 + 80, 30); + DecompressTrainerBackPic(trainerPicId, gActiveBattler); + sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, 80, (8 - gTrainerBackPicCoords[trainerPicId].coords) * 4 + 80, 30); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -96; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 2; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -96; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 2; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy2; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; } static void PlayerHandleTrainerSlideBack(void) { - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 50; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = -40; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], SpriteCallbackDummy); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 1); - gBattleBankFunc[gActiveBank] = sub_80588B4; + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 50; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 1); + gBattlerFuncs[gActiveBattler] = sub_80588B4; } static void PlayerHandleFaintAnimation(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } else { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER); - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = 5; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_8039C00; - gBattleBankFunc[gActiveBank] = sub_80596A8; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 5; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039C00; + gBattlerFuncs[gActiveBattler] = sub_80596A8; } } } @@ -2463,23 +2463,23 @@ static void PlayerHandleSuccessBallThrowAnim(void) { gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW); - gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW); + gBattlerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone; } static void PlayerHandleBallThrowAnim(void) { - u8 ballThrowCaseId = gBattleBufferA[gActiveBank][1]; + u8 ballThrowCaseId = gBattleBufferA[gActiveBattler][1]; gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW); - gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW); + gBattlerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone; } static void PlayerHandlePause(void) { - u8 var = gBattleBufferA[gActiveBank][1]; + u8 var = gBattleBufferA[gActiveBattler][1]; // WTF is this?? while (var != 0) @@ -2490,25 +2490,25 @@ static void PlayerHandlePause(void) static void PlayerHandleMoveAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBank][3]; - gAnimMovePower = gBattleBufferA[gActiveBank][4] | (gBattleBufferA[gActiveBank][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBank][6] | (gBattleBufferA[gActiveBank][7] << 8) | (gBattleBufferA[gActiveBank][8] << 16) | (gBattleBufferA[gActiveBank][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBank][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBank][12] | (gBattleBufferA[gActiveBank][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBank][16]; - gTransformedPersonalities[gActiveBank] = gAnimDisableStructPtr->transformedMonPersonality; + gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; + gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleBufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { PlayerBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = PlayerDoMoveAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = PlayerDoMoveAnimation; sub_817E0FC(move, gWeatherMoveAnim, gAnimDisableStructPtr); } } @@ -2516,26 +2516,26 @@ static void PlayerHandleMoveAnimation(void) static void PlayerDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); - u8 multihit = gBattleBufferA[gActiveBank][11]; + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleBufferA[gActiveBattler][11]; - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { sub_805EB9C(0); DoMoveAnim(move); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 2; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; } break; case 2: @@ -2543,20 +2543,20 @@ static void PlayerDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) { - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } break; case 3: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; PlayerBufferExecCompleted(); } break; @@ -2569,17 +2569,17 @@ static void PlayerHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBank][2]); + stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); - gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter2; + gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2; sub_817C95C(*stringId); - sub_81A57E4(gActiveBank, *stringId); + sub_81A57E4(gActiveBattler, *stringId); } static void PlayerHandlePrintSelectionString(void) { - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) PlayerHandlePrintString(); else PlayerBufferExecCompleted(); @@ -2591,7 +2591,7 @@ static void HandleChooseActionAfterDma3(void) { gBattle_BG0_X = 0; gBattle_BG0_Y = 160; - gBattleBankFunc[gActiveBank] = HandleInputChooseAction; + gBattlerFuncs[gActiveBattler] = HandleInputChooseAction; } } @@ -2599,27 +2599,27 @@ static void PlayerHandleChooseAction(void) { s32 i; - gBattleBankFunc[gActiveBank] = HandleChooseActionAfterDma3; + gBattlerFuncs[gActiveBattler] = HandleChooseActionAfterDma3; sub_817F2A8(); BattleHandleAddTextPrinter(gText_BattleMenu, 2); for (i = 0; i < 4; i++) ActionSelectionDestroyCursorAt(i); - ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0); + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo); BattleHandleAddTextPrinter(gDisplayedStringBattle, 1); } static void PlayerHandleUnknownYesNoBox(void) { - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { HandleBattleWindow(0x18, 8, 0x1D, 0xD, 0); BattleHandleAddTextPrinter(gText_BattleYesNoChoice, 12); gMultiUsePlayerCursor = 1; BattleCreateYesNoCursorAt(1); - gBattleBankFunc[gActiveBank] = PlayerHandleUnknownYesNoInput; + gBattlerFuncs[gActiveBattler] = PlayerHandleUnknownYesNoInput; } else { @@ -2633,13 +2633,13 @@ static void HandleChooseMoveAfterDma3(void) { gBattle_BG0_X = 0; gBattle_BG0_Y = 320; - gBattleBankFunc[gActiveBank] = HandleInputChooseMove; + gBattlerFuncs[gActiveBattler] = HandleInputChooseMove; } } static void PlayerChooseMoveInBattlePalace(void) { - if (--*(gBattleStruct->field_298 + gActiveBank) == 0) + if (--*(gBattleStruct->field_298 + gActiveBattler) == 0) { gBattlePalaceMoveSelectionRngValue = gRngValue; EmitTwoReturnValues(1, 10, ChooseMoveAndTargetInBattlePalace()); @@ -2651,13 +2651,13 @@ static void PlayerHandleChooseMove(void) { if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - *(gBattleStruct->field_298 + gActiveBank) = 8; - gBattleBankFunc[gActiveBank] = PlayerChooseMoveInBattlePalace; + *(gBattleStruct->field_298 + gActiveBattler) = 8; + gBattlerFuncs[gActiveBattler] = PlayerChooseMoveInBattlePalace; } else { InitMoveSelectionsVarsAndStrings(); - gBattleBankFunc[gActiveBank] = HandleChooseMoveAfterDma3; + gBattlerFuncs[gActiveBattler] = HandleChooseMoveAfterDma3; } } @@ -2665,7 +2665,7 @@ void InitMoveSelectionsVarsAndStrings(void) { MoveSelectionDisplayMoveNames(); gMultiUsePlayerCursor = 0xFF; - MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBank], 0); + MoveSelectionCreateCursorAt(gMoveSelectionCursor[gActiveBattler], 0); MoveSelectionDisplayPpString(); MoveSelectionDisplayPpNumber(); MoveSelectionDisplayMoveType(); @@ -2676,11 +2676,11 @@ static void PlayerHandleChooseItem(void) s32 i; BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - gBattleBankFunc[gActiveBank] = OpenBagAndChooseItem; - gBankInMenu = gActiveBank; + gBattlerFuncs[gActiveBattler] = OpenBagAndChooseItem; + gBankInMenu = gActiveBattler; for (i = 0; i < 3; i++) - gUnknown_0203CF00[i] = gBattleBufferA[gActiveBank][1 + i]; + gUnknown_0203CF00[i] = gBattleBufferA[gActiveBattler][1 + i]; } static void PlayerHandleChoosePokemon(void) @@ -2688,23 +2688,23 @@ static void PlayerHandleChoosePokemon(void) s32 i; for (i = 0; i < 3; i++) - gUnknown_0203CF00[i] = gBattleBufferA[gActiveBank][4 + i]; + gUnknown_0203CF00[i] = gBattleBufferA[gActiveBattler][4 + i]; - if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleBufferA[gActiveBank][1] & 0xF) != 2) + if (gBattleTypeFlags & BATTLE_TYPE_ARENA && (gBattleBufferA[gActiveBattler][1] & 0xF) != 2) { - EmitChosenMonReturnValue(1, gBattlePartyID[gActiveBank] + 1, gUnknown_0203CF00); + EmitChosenMonReturnValue(1, gBattlePartyID[gActiveBattler] + 1, gUnknown_0203CF00); PlayerBufferExecCompleted(); } else { - gUnknown_03005D7C[gActiveBank] = CreateTask(TaskDummy, 0xFF); - gTasks[gUnknown_03005D7C[gActiveBank]].data[0] = gBattleBufferA[gActiveBank][1] & 0xF; - *(&gBattleStruct->field_49) = gBattleBufferA[gActiveBank][1] >> 4; - *(&gBattleStruct->field_8B) = gBattleBufferA[gActiveBank][2]; - *(&gBattleStruct->field_B0) = gBattleBufferA[gActiveBank][3]; + gUnknown_03005D7C[gActiveBattler] = CreateTask(TaskDummy, 0xFF); + gTasks[gUnknown_03005D7C[gActiveBattler]].data[0] = gBattleBufferA[gActiveBattler][1] & 0xF; + *(&gBattleStruct->field_49) = gBattleBufferA[gActiveBattler][1] >> 4; + *(&gBattleStruct->field_8B) = gBattleBufferA[gActiveBattler][2]; + *(&gBattleStruct->field_B0) = gBattleBufferA[gActiveBattler][3]; BeginNormalPaletteFade(-1, 0, 0, 16, 0); - gBattleBankFunc[gActiveBank] = sub_80597CC; - gBankInMenu = gActiveBank; + gBattlerFuncs[gActiveBattler] = sub_80597CC; + gBankInMenu = gActiveBattler; } } @@ -2720,32 +2720,32 @@ static void PlayerHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); if (hpVal > 0) gUnknown_0203CD70 += hpVal; if (hpVal != INSTANT_HP_BAR_DROP) { - u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); - u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); + u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, curHP, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); } else { - u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, 0, hpVal); - UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBank], 0, HP_CURRENT); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); + UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], 0, HP_CURRENT); } - gBattleBankFunc[gActiveBank] = CompleteOnHealthbarDone; + gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } static void PlayerHandleExpUpdate(void) { - u8 monId = gBattleBufferA[gActiveBank][1]; + u8 monId = gBattleBufferA[gActiveBattler][1]; if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_MON_LEVEL) { @@ -2758,12 +2758,12 @@ static void PlayerHandleExpUpdate(void) LoadBattleBarGfx(1); GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); // unused return value - expPointsToGive = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + expPointsToGive = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); taskId = CreateTask(Task_GiveExpToMon, 10); gTasks[taskId].tExpTask_monId = monId; gTasks[taskId].tExpTask_gainedExp = expPointsToGive; - gTasks[taskId].tExpTask_bank = gActiveBank; - gBattleBankFunc[gActiveBank] = nullsub_21; + gTasks[taskId].tExpTask_bank = gActiveBattler; + gBattlerFuncs[gActiveBattler] = nullsub_21; } } @@ -2774,32 +2774,32 @@ static void PlayerHandleExpUpdate(void) static void PlayerHandleStatusIconUpdate(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { u8 bank; - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_STATUS_ICON); - bank = gActiveBank; + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); + bank = gActiveBattler; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } static void PlayerHandleStatusAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], - gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], + gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } static void PlayerHandleStatusXor(void) { - u8 val = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_STATUS) ^ gBattleBufferA[gActiveBank][1]; + u8 val = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_STATUS) ^ gBattleBufferA[gActiveBattler][1]; - SetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_STATUS, &val); + SetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_STATUS, &val); PlayerBufferExecCompleted(); } @@ -2810,13 +2810,13 @@ static void PlayerHandleDataTransfer(void) static void PlayerHandleDMA3Transfer(void) { - u32 dstArg = gBattleBufferA[gActiveBank][1] - | (gBattleBufferA[gActiveBank][2] << 8) - | (gBattleBufferA[gActiveBank][3] << 16) - | (gBattleBufferA[gActiveBank][4] << 24); - u16 sizeArg = gBattleBufferA[gActiveBank][5] | (gBattleBufferA[gActiveBank][6] << 8); + u32 dstArg = gBattleBufferA[gActiveBattler][1] + | (gBattleBufferA[gActiveBattler][2] << 8) + | (gBattleBufferA[gActiveBattler][3] << 16) + | (gBattleBufferA[gActiveBattler][4] << 24); + u16 sizeArg = gBattleBufferA[gActiveBattler][5] | (gBattleBufferA[gActiveBattler][6] << 8); - const u8 *src = &gBattleBufferA[gActiveBank][7]; + const u8 *src = &gBattleBufferA[gActiveBattler][7]; u8 *dst = (u8*)(dstArg); u32 size = sizeArg; @@ -2837,7 +2837,7 @@ static void PlayerHandleDMA3Transfer(void) static void PlayerHandlePlayBGM(void) { - PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); PlayerBufferExecCompleted(); } @@ -2878,7 +2878,7 @@ static void PlayerHandleCmd37(void) static void PlayerHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBank][1]; + gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; PlayerBufferExecCompleted(); } @@ -2896,16 +2896,16 @@ static void PlayerHandleCmd40(void) static void PlayerHandleHitAnimation(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].invisible == TRUE) + if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) { PlayerBufferExecCompleted(); } else { gDoingBattleAnim = TRUE; - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - DoHitAnimHealthboxEffect(gActiveBank); - gBattleBankFunc[gActiveBank] = DoHitAnimBlinkSpriteEffect; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + DoHitAnimHealthboxEffect(gActiveBattler); + gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; } } @@ -2918,25 +2918,25 @@ static void PlayerHandlePlaySE(void) { s8 pan; - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) pan = PAN_SIDE_PLAYER; else pan = PAN_SIDE_OPPONENT; - PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan); + PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); PlayerBufferExecCompleted(); } static void PlayerHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBank][3]) + if (gBattleBufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } PlayerBufferExecCompleted(); @@ -2944,7 +2944,7 @@ static void PlayerHandlePlayFanfareOrBGM(void) static void PlayerHandleFaintingCry(void) { - u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); PlayCry3(species, -25, 5); PlayerBufferExecCompleted(); @@ -2952,7 +2952,7 @@ static void PlayerHandleFaintingCry(void) static void PlayerHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBank][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gUnknown_020243FC |= 1; PlayerBufferExecCompleted(); } @@ -2962,29 +2962,29 @@ static void PlayerHandleIntroTrainerBallThrow(void) u8 paletteNum; u8 taskId; - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 50; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = -40; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - gSprites[gBankSpriteIds[gActiveBank]].data[5] = gActiveBank; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 50; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + gSprites[gBankSpriteIds[gActiveBattler]].data[5] = gActiveBattler; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], sub_805CC00); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 1); + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_805CC00); + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 1); paletteNum = AllocSpritePalette(0xD6F8); LoadCompressedPalette(gTrainerBackPicPaletteTable[gSaveBlock2Ptr->playerGender].data, 0x100 + paletteNum * 16, 32); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = paletteNum; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; taskId = CreateTask(task05_08033660, 5); - gTasks[taskId].data[0] = gActiveBank; + gTasks[taskId].data[0] = gActiveBattler; - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gBattleSpritesDataPtr->animationData->field_9_x1 = 1; - gBattleBankFunc[gActiveBank] = nullsub_21; + gBattlerFuncs[gActiveBattler] = nullsub_21; } void sub_805CC00(struct Sprite *sprite) @@ -3006,93 +3006,93 @@ static void task05_08033660(u8 taskId) } else { - u8 savedActiveBank = gActiveBank; + u8 savedActiveBank = gActiveBattler; - gActiveBank = gTasks[taskId].data[0]; + gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_805B258(gActiveBank, FALSE); + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_805B258(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_805B258(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - sub_805B258(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_805B258(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + sub_805B258(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; } - gBattleBankFunc[gActiveBank] = sub_8058B40; - gActiveBank = savedActiveBank; + gBattlerFuncs[gActiveBattler] = sub_8058B40; + gActiveBattler = savedActiveBank; DestroyTask(taskId); } } static void PlayerHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == SIDE_PLAYER) + if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { PlayerBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1 = 1; - gUnknown_020244B4[gActiveBank] = CreatePartyStatusSummarySprites(gActiveBank, (struct HpAndStatus *)&gBattleBufferA[gActiveBank][4], gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1 = 1; + gUnknown_020244B4[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBank][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0x5D; + if (gBattleBufferA[gActiveBattler][2] != 0) + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; - gBattleBankFunc[gActiveBank] = sub_805CE38; + gBattlerFuncs[gActiveBattler] = sub_805CE38; } } static void sub_805CE38(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5++ > 0x5C) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; PlayerBufferExecCompleted(); } } static void PlayerHandleCmd49(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; PlayerBufferExecCompleted(); } static void PlayerHandleCmd50(void) { - dp11b_obj_free(gActiveBank, 1); - dp11b_obj_free(gActiveBank, 0); + dp11b_obj_free(gActiveBattler, 1); + dp11b_obj_free(gActiveBattler, 0); PlayerBufferExecCompleted(); } static void PlayerHandleSpriteInvisibility(void) { - if (IsBankSpritePresent(gActiveBank)) + if (IsBankSpritePresent(gActiveBattler)) { - gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; - CopyBattleSpriteInvisibility(gActiveBank); + gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + CopyBattleSpriteInvisibility(gActiveBattler); } PlayerBufferExecCompleted(); } static void PlayerHandleBattleAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBank][1]; - u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + u8 animationId = gBattleBufferA[gActiveBattler][1]; + u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) PlayerBufferExecCompleted(); else - gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; sub_817E32C(animationId); } @@ -3100,15 +3100,15 @@ static void PlayerHandleBattleAnimation(void) static void PlayerHandleLinkStandbyMsg(void) { - sub_81851A8(&gBattleBufferA[gActiveBank][2]); - switch (gBattleBufferA[gActiveBank][1]) + sub_81851A8(&gBattleBufferA[gActiveBattler][2]); + switch (gBattleBufferA[gActiveBattler][1]) { case 0: PrintLinkStandbyMsg(); // fall through case 1: - dp11b_obj_free(gActiveBank, 1); - dp11b_obj_free(gActiveBank, 0); + dp11b_obj_free(gActiveBattler, 1); + dp11b_obj_free(gActiveBattler, 0); break; case 2: PrintLinkStandbyMsg(); @@ -3119,17 +3119,17 @@ static void PlayerHandleLinkStandbyMsg(void) static void PlayerHandleResetActionMoveSelection(void) { - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case RESET_ACTION_MOVE_SELECTION: - gActionSelectionCursor[gActiveBank] = 0; - gMoveSelectionCursor[gActiveBank] = 0; + gActionSelectionCursor[gActiveBattler] = 0; + gMoveSelectionCursor[gActiveBattler] = 0; break; case RESET_ACTION_SELECTION: - gActionSelectionCursor[gActiveBank] = 0; + gActionSelectionCursor[gActiveBattler] = 0; break; case RESET_MOVE_SELECTION: - gMoveSelectionCursor[gActiveBank] = 0; + gMoveSelectionCursor[gActiveBattler] = 0; break; } PlayerBufferExecCompleted(); @@ -3137,13 +3137,13 @@ static void PlayerHandleResetActionMoveSelection(void) static void PlayerHandleCmd55(void) { - sub_81851A8(&gBattleBufferA[gActiveBank][4]); - gBattleOutcome = gBattleBufferA[gActiveBank][1]; - gSaveBlock2Ptr->field_CA9_b = gBattleBufferA[gActiveBank][2]; + sub_81851A8(&gBattleBufferA[gActiveBattler][4]); + gBattleOutcome = gBattleBufferA[gActiveBattler][1]; + gSaveBlock2Ptr->field_CA9_b = gBattleBufferA[gActiveBattler][2]; FadeOutMapMusic(5); BeginFastPaletteFade(3); PlayerBufferExecCompleted(); - gBattleBankFunc[gActiveBank] = sub_80587B0; + gBattlerFuncs[gActiveBattler] = sub_80587B0; } static void nullsub_22(void) diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 1da8ee04c..2b21dab94 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -24,33 +24,33 @@ #include "data2.h" extern u32 gBattleExecBuffer; -extern u8 gActiveBank; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; -extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gBattleBanksCount; +extern u8 gActiveBattler; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; +extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gBattlersCount; extern bool8 gDoingBattleAnim; -extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); +extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gPreBattleCallback1)(void); -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct SpriteTemplate gUnknown_0202499C; extern u16 gSpecialVar_ItemId; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gBattleOutcome; extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; extern u8 gBankInMenu; extern u16 gUnknown_020243FC; -extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; -extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; +extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; +extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBankDefender; -extern u8 gAbsentBankFlags; +extern u8 gBattleDefender; +extern u8 gAbsentBattlerFlags; extern u8 gUnknown_020244B4[]; -extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; +extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern struct UnusedControllerStruct gUnknown_02022D0C; extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[]; @@ -213,15 +213,15 @@ static void nullsub_77(void) void SetControllerToPlayerPartner(void) { - gBattleBankFunc[gActiveBank] = PlayerPartnerBufferRunCommand; + gBattlerFuncs[gActiveBattler] = PlayerPartnerBufferRunCommand; } static void PlayerPartnerBufferRunCommand(void) { - if (gBattleExecBuffer & gBitTable[gActiveBank]) + if (gBattleExecBuffer & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(sPlayerPartnerBufferCommands)) - sPlayerPartnerBufferCommands[gBattleBufferA[gActiveBank][0]](); + if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sPlayerPartnerBufferCommands)) + sPlayerPartnerBufferCommands[gBattleBufferA[gActiveBattler][0]](); else PlayerPartnerBufferExecCompleted(); } @@ -229,26 +229,26 @@ static void PlayerPartnerBufferRunCommand(void) static void CompleteOnBankSpriteCallbackDummy(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) PlayerPartnerBufferExecCompleted(); } static void sub_81BAE98(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { nullsub_25(0); - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); PlayerPartnerBufferExecCompleted(); } } static void sub_81BAF00(void) { - if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 == 0xFF) + if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; PlayerPartnerBufferExecCompleted(); } } @@ -259,13 +259,13 @@ static void sub_81BAF48(void) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) r6 = TRUE; } else { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gHealthBoxesIds[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) { r6 = TRUE; } @@ -276,59 +276,59 @@ static void sub_81BAF48(void) if (r6) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3; - gBattleBankFunc[gActiveBank] = sub_81BAF00; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; + gBattlerFuncs[gActiveBattler] = sub_81BAF00; } } static void sub_81BB02C(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive - && gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy - && ++gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 != 1) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive + && gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy + && ++gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 != 1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank ^ BIT_MON]]); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank ^ BIT_MON], &gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], HEALTHBOX_ALL); - sub_8076918(gActiveBank ^ BIT_MON); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank ^ BIT_MON]); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler ^ BIT_FLANK); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); } - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); gBattleSpritesDataPtr->animationData->field_9_x1 = 0; - gBattleBankFunc[gActiveBank] = sub_81BAF48; + gBattlerFuncs[gActiveBattler] = sub_81BAF48; } } static void sub_81BB1D4(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].animEnded && gSprites[gBankSpriteIds[gActiveBank]].pos2.x == 0) + if (gSprites[gBankSpriteIds[gActiveBattler]].animEnded && gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0) PlayerPartnerBufferExecCompleted(); } static void CompleteOnHealthbarDone(void) { - s16 hpValue = sub_8074AA0(gActiveBank, gHealthBoxesIds[gActiveBank], HEALTH_BAR, 0); + s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); if (hpValue != -1) { - UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBank], hpValue, HP_CURRENT); + UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); } else { - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); PlayerPartnerBufferExecCompleted(); } } @@ -366,13 +366,13 @@ static void Task_GiveExpToMon(u8 taskId) SetMonData(mon, MON_DATA_EXP, &nextLvlExp); CalculateMonStats(mon); gainedExp -= nextLvlExp - currExp; - savedActiveBank = gActiveBank; - gActiveBank = bank; + savedActiveBank = gActiveBattler; + gActiveBattler = bank; EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp); - gActiveBank = savedActiveBank; + gActiveBattler = savedActiveBank; if (IsDoubleBattle() == TRUE - && ((u16)(monId) == gBattlePartyID[bank] || (u16)(monId) == gBattlePartyID[bank ^ BIT_MON])) + && ((u16)(monId) == gBattlePartyID[bank] || (u16)(monId) == gBattlePartyID[bank ^ BIT_FLANK])) gTasks[taskId].func = sub_81BB628; else gTasks[taskId].func = DestroyExpTaskAndCompleteOnInactiveTextPrinter; @@ -381,7 +381,7 @@ static void Task_GiveExpToMon(u8 taskId) { currExp += gainedExp; SetMonData(mon, MON_DATA_EXP, &currExp); - gBattleBankFunc[bank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[bank] = CompleteOnInactiveTextPrinter; DestroyTask(taskId); } } @@ -445,17 +445,17 @@ static void sub_81BB4E4(u8 taskId) SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &expOnNextLvl); CalculateMonStats(&gPlayerParty[monId]); gainedExp -= expOnNextLvl - currExp; - savedActiveBank = gActiveBank; - gActiveBank = bank; + savedActiveBank = gActiveBattler; + gActiveBattler = bank; EmitTwoReturnValues(1, RET_VALUE_LEVELLED_UP, gainedExp); - gActiveBank = savedActiveBank; + gActiveBattler = savedActiveBank; gTasks[taskId].func = sub_81BB628; } else { currExp += gainedExp; SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &currExp); - gBattleBankFunc[bank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[bank] = CompleteOnInactiveTextPrinter; DestroyTask(taskId); } } @@ -467,8 +467,8 @@ static void sub_81BB628(u8 taskId) u8 bank = gTasks[taskId].tExpTask_bank; u8 monIndex = gTasks[taskId].tExpTask_monId; - if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON]) - bank ^= BIT_MON; + if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_FLANK]) + bank ^= BIT_FLANK; InitAndLaunchSpecialAnimation(bank, bank, bank, B_ANIM_LVL_UP); gTasks[taskId].func = sub_81BB688; @@ -484,8 +484,8 @@ static void sub_81BB688(u8 taskId) GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value - if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_MON]) - UpdateHealthboxAttribute(gHealthBoxesIds[bank ^ BIT_MON], &gPlayerParty[monIndex], HEALTHBOX_ALL); + if (IsDoubleBattle() == TRUE && monIndex == gBattlePartyID[bank ^ BIT_FLANK]) + UpdateHealthboxAttribute(gHealthBoxesIds[bank ^ BIT_FLANK], &gPlayerParty[monIndex], HEALTHBOX_ALL); else UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gPlayerParty[monIndex], HEALTHBOX_ALL); @@ -501,31 +501,31 @@ static void DestroyExpTaskAndCompleteOnInactiveTextPrinter(u8 taskId) monIndex = gTasks[taskId].tExpTask_monId; GetMonData(&gPlayerParty[monIndex], MON_DATA_LEVEL); // Unused return value bank = gTasks[taskId].tExpTask_bank; - gBattleBankFunc[bank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[bank] = CompleteOnInactiveTextPrinter; DestroyTask(taskId); } static void sub_81BB78C(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].pos1.y + gSprites[gBankSpriteIds[gActiveBank]].pos2.y > DISPLAY_HEIGHT) + if (gSprites[gBankSpriteIds[gActiveBattler]].pos1.y + gSprites[gBankSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT) { - u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); nullsub_24(species); - FreeOamMatrix(gSprites[gBankSpriteIds[gActiveBank]].oam.matrixNum); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeOamMatrix(gSprites[gBankSpriteIds[gActiveBattler]].oam.matrixNum); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); PlayerPartnerBufferExecCompleted(); } } static void sub_81BB828(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); PlayerPartnerBufferExecCompleted(); } } @@ -538,7 +538,7 @@ static void CompleteOnInactiveTextPrinter2(void) static void DoHitAnimBlinkSpriteEffect(void) { - u8 spriteId = gBankSpriteIds[gActiveBank]; + u8 spriteId = gBankSpriteIds[gActiveBattler]; if (gSprites[spriteId].data[1] == 32) { @@ -557,20 +557,20 @@ static void DoHitAnimBlinkSpriteEffect(void) static void sub_81BB92C(void) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) { - CopyBattleSpriteInvisibility(gActiveBank); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + CopyBattleSpriteInvisibility(gActiveBattler); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleBankFunc[gActiveBank] = sub_81BB9A0; + gBattlerFuncs[gActiveBattler] = sub_81BB9A0; } } static void sub_81BB9A0(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { PlayerPartnerBufferExecCompleted(); } @@ -578,66 +578,66 @@ static void sub_81BB9A0(void) static void sub_81BB9F4(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); CreateTask(c3_0802FDF4, 10); - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); - gBattleBankFunc[gActiveBank] = sub_81BB92C; + gBattlerFuncs[gActiveBattler] = sub_81BB92C; } } static void sub_81BBAE8(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - sub_8172EF0(gActiveBank, &gPlayerParty[gBattlePartyID[gActiveBank]]); + sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); } - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - gBattleBankFunc[gActiveBank] = sub_81BB9F4; + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + gBattlerFuncs[gActiveBattler] = sub_81BB9F4; } } static void PlayerPartnerBufferExecCompleted(void) { - gBattleBankFunc[gActiveBank] = PlayerPartnerBufferRunCommand; + gBattlerFuncs[gActiveBattler] = PlayerPartnerBufferRunCommand; if (gBattleTypeFlags & BATTLE_TYPE_LINK) { u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBank][0] = CONTROLLER_TERMINATOR_NOP; + gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { - gBattleExecBuffer &= ~gBitTable[gActiveBank]; + gBattleExecBuffer &= ~gBitTable[gActiveBattler]; } } static void CompleteOnFinishedStatusAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) PlayerPartnerBufferExecCompleted(); } static void CompleteOnFinishedBattleAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive) PlayerPartnerBufferExecCompleted(); } @@ -648,13 +648,13 @@ static void PlayerPartnerHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - size += CopyPlayerPartnerMonData(gBattlePartyID[gActiveBank], monData); + size += CopyPlayerPartnerMonData(gBattlePartyID[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -676,7 +676,7 @@ static u32 CopyPlayerPartnerMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); @@ -742,7 +742,7 @@ static u32 CopyPlayerPartnerMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -757,7 +757,7 @@ static u32 CopyPlayerPartnerMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -982,13 +982,13 @@ static void PlayerPartnerHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - SetPlayerPartnerMonData(gBattlePartyID[gActiveBank]); + SetPlayerPartnerMonData(gBattlePartyID[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -1001,11 +1001,11 @@ static void PlayerPartnerHandleSetMonData(void) static void SetPlayerPartnerMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBank][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -1046,10 +1046,10 @@ static void SetPlayerPartnerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < 4; i++) @@ -1063,167 +1063,167 @@ static void SetPlayerPartnerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBank][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][7]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][8]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; } - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); } static void PlayerPartnerHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; + u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) - dst[i] = gBattleBufferA[gActiveBank][3 + i]; + for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) + dst[i] = gBattleBufferA[gActiveBattler][3 + i]; PlayerPartnerBufferExecCompleted(); } @@ -1232,28 +1232,28 @@ static void PlayerPartnerHandleLoadMonSprite(void) { u16 species; - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); - sub_806A068(species, GetBankPosition(gActiveBank)); + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); + sub_806A068(species, GetBattlerPosition(gActiveBattler)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, - GetBankCoord(gActiveBank, 2), - GetBankSpriteDefault_Y(gActiveBank), - sub_80A82E4(gActiveBank)); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], gBattleMonForms[gActiveBank]); - gBattleBankFunc[gActiveBank] = sub_81BB1D4; + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, + GetBankCoord(gActiveBattler, 2), + GetBankSpriteDefault_Y(gActiveBattler), + sub_80A82E4(gActiveBattler)); + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); + gBattlerFuncs[gActiveBattler] = sub_81BB1D4; } static void PlayerPartnerHandleSwitchInAnim(void) { - ClearTemporarySpeciesSpriteData(gActiveBank, gBattleBufferA[gActiveBank][2]); - gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1]; - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - sub_81BD0E4(gActiveBank, gBattleBufferA[gActiveBank][2]); - gBattleBankFunc[gActiveBank] = sub_81BBAE8; + ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + sub_81BD0E4(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlerFuncs[gActiveBattler] = sub_81BBAE8; } static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit) @@ -1264,7 +1264,7 @@ static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit) gBattlePartyID[bank] = gBattleBufferA[bank][1]; species = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); - sub_806A068(species, GetBankPosition(bank)); + sub_806A068(species, GetBattlerPosition(bank)); gBankSpriteIds[bank] = CreateSprite( &gUnknown_0202499C, @@ -1289,36 +1289,36 @@ static void sub_81BD0E4(u8 bank, bool8 dontClearSubstituteBit) static void PlayerPartnerHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBank][1] == 0) + if (gBattleBufferA[gActiveBattler][1] == 0) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = DoSwitchOutAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; } else { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); PlayerPartnerBufferExecCompleted(); } } static void DoSwitchOutAnimation(void) { - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); - gBattleBankFunc[gActiveBank] = sub_81BB828; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); + gBattlerFuncs[gActiveBattler] = sub_81BB828; } break; } @@ -1348,31 +1348,31 @@ static void PlayerPartnerHandleDrawTrainerPic(void) // Use back pic only if the partner is Steven if (gPartnerTrainerId == STEVEN_PARTNER_ID) { - DecompressTrainerBackPic(trainerPicId, gActiveBank); - sub_806A12C(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBank)); + DecompressTrainerBackPic(trainerPicId, gActiveBattler); + sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; } else // otherwise use front sprite { - DecompressTrainerFrontPic(trainerPicId, gActiveBank); - sub_806A1C0(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBank)); + DecompressTrainerFrontPic(trainerPicId, gActiveBattler); + sub_806A1C0(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 240; - gSprites[gBankSpriteIds[gActiveBank]].pos2.y = 48; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; - gSprites[gBankSpriteIds[gActiveBank]].oam.affineMode = 0; - gSprites[gBankSpriteIds[gActiveBank]].hFlip = 1; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.y = 48; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].oam.affineMode = 0; + gSprites[gBankSpriteIds[gActiveBattler]].hFlip = 1; } - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; } static void PlayerPartnerHandleTrainerSlide(void) @@ -1382,34 +1382,34 @@ static void PlayerPartnerHandleTrainerSlide(void) static void PlayerPartnerHandleTrainerSlideBack(void) { - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 35; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = -40; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], SpriteCallbackDummy); - gBattleBankFunc[gActiveBank] = sub_81BAE98; + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); + gBattlerFuncs[gActiveBattler] = sub_81BAE98; } static void PlayerPartnerHandleFaintAnimation(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } else { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_PLAYER); - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = 5; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_8039C00; - gBattleBankFunc[gActiveBank] = sub_81BB78C; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 5; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039C00; + gBattlerFuncs[gActiveBattler] = sub_81BB78C; } } } @@ -1436,51 +1436,51 @@ static void PlayerPartnerHandlePause(void) static void PlayerPartnerHandleMoveAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBank][3]; - gAnimMovePower = gBattleBufferA[gActiveBank][4] | (gBattleBufferA[gActiveBank][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBank][6] | (gBattleBufferA[gActiveBank][7] << 8) | (gBattleBufferA[gActiveBank][8] << 16) | (gBattleBufferA[gActiveBank][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBank][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBank][12] | (gBattleBufferA[gActiveBank][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBank][16]; - gTransformedPersonalities[gActiveBank] = gAnimDisableStructPtr->transformedMonPersonality; + gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; + gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleBufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { PlayerPartnerBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = PlayerPartnerDoMoveAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = PlayerPartnerDoMoveAnimation; } } } static void PlayerPartnerDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); - u8 multihit = gBattleBufferA[gActiveBank][11]; + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleBufferA[gActiveBattler][11]; - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { sub_805EB9C(0); DoMoveAnim(move); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 2; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; } break; case 2: @@ -1488,20 +1488,20 @@ static void PlayerPartnerDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) { - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } break; case 3: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; PlayerPartnerBufferExecCompleted(); } break; @@ -1514,10 +1514,10 @@ static void PlayerPartnerHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBank][2]); + stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); - gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter2; + gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter2; } static void PlayerPartnerHandlePrintSelectionString(void) @@ -1539,21 +1539,21 @@ static void PlayerPartnerHandleUnknownYesNoBox(void) static void PlayerPartnerHandleChooseMove(void) { u8 chosenMoveId; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); BattleAI_SetupAIData(0xF); chosenMoveId = BattleAI_ChooseMoveOrAction(); if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_x10 | MOVE_TARGET_USER)) - gBankDefender = gActiveBank; + gBattleDefender = gActiveBattler; if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH) { - gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_LEFT); - if (gAbsentBankFlags & gBitTable[gBankDefender]) - gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + if (gAbsentBattlerFlags & gBitTable[gBattleDefender]) + gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); } - EmitTwoReturnValues(1, 10, chosenMoveId | (gBankDefender << 8)); + EmitTwoReturnValues(1, 10, chosenMoveId | (gBattleDefender << 8)); PlayerPartnerBufferExecCompleted(); } @@ -1568,8 +1568,8 @@ static void PlayerPartnerHandleChoosePokemon(void) if (chosenMonId == 6) // just switch to the next mon { - u8 playerMonIdentity = GetBankByPosition(B_POSITION_PLAYER_LEFT); - u8 selfIdentity = GetBankByPosition(B_POSITION_PLAYER_RIGHT); + u8 playerMonIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + u8 selfIdentity = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); for (chosenMonId = 3; chosenMonId < 6; chosenMonId++) { @@ -1582,7 +1582,7 @@ static void PlayerPartnerHandleChoosePokemon(void) } } - *(gBattleStruct->monToSwitchIntoId + gActiveBank) = chosenMonId; + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = chosenMonId; EmitChosenMonReturnValue(1, chosenMonId, NULL); PlayerPartnerBufferExecCompleted(); } @@ -1597,28 +1597,28 @@ static void PlayerPartnerHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { - u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); - u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); + u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, curHP, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); } else { - u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, 0, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); } - gBattleBankFunc[gActiveBank] = CompleteOnHealthbarDone; + gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } static void PlayerPartnerHandleExpUpdate(void) { - u8 monId = gBattleBufferA[gActiveBank][1]; + u8 monId = gBattleBufferA[gActiveBattler][1]; if (GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL) >= MAX_MON_LEVEL) { @@ -1631,12 +1631,12 @@ static void PlayerPartnerHandleExpUpdate(void) LoadBattleBarGfx(1); GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); // unused return value - expPointsToGive = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + expPointsToGive = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); taskId = CreateTask(Task_GiveExpToMon, 10); gTasks[taskId].tExpTask_monId = monId; gTasks[taskId].tExpTask_gainedExp = expPointsToGive; - gTasks[taskId].tExpTask_bank = gActiveBank; - gBattleBankFunc[gActiveBank] = nullsub_21; + gTasks[taskId].tExpTask_bank = gActiveBattler; + gBattlerFuncs[gActiveBattler] = nullsub_21; } } @@ -1647,24 +1647,24 @@ static void PlayerPartnerHandleExpUpdate(void) static void PlayerPartnerHandleStatusIconUpdate(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { u8 bank; - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_STATUS_ICON); - bank = gActiveBank; + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); + bank = gActiveBattler; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } static void PlayerPartnerHandleStatusAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], - gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], + gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1721,7 +1721,7 @@ static void PlayerPartnerHandleCmd37(void) static void PlayerPartnerHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBank][1]; + gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; PlayerPartnerBufferExecCompleted(); } @@ -1739,16 +1739,16 @@ static void PlayerPartnerHandleCmd40(void) static void PlayerPartnerHandleHitAnimation(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].invisible == TRUE) + if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) { PlayerPartnerBufferExecCompleted(); } else { gDoingBattleAnim = TRUE; - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - DoHitAnimHealthboxEffect(gActiveBank); - gBattleBankFunc[gActiveBank] = DoHitAnimBlinkSpriteEffect; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + DoHitAnimHealthboxEffect(gActiveBattler); + gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; } } @@ -1761,25 +1761,25 @@ static void PlayerPartnerHandlePlaySE(void) { s8 pan; - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) pan = PAN_SIDE_PLAYER; else pan = PAN_SIDE_OPPONENT; - PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan); + PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); PlayerPartnerBufferExecCompleted(); } static void PlayerPartnerHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBank][3]) + if (gBattleBufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } PlayerPartnerBufferExecCompleted(); @@ -1787,7 +1787,7 @@ static void PlayerPartnerHandlePlayFanfareOrBGM(void) static void PlayerPartnerHandleFaintingCry(void) { - u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); PlayCry3(species, -25, 5); PlayerPartnerBufferExecCompleted(); @@ -1795,7 +1795,7 @@ static void PlayerPartnerHandleFaintingCry(void) static void PlayerPartnerHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBank][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gUnknown_020243FC |= 1; PlayerPartnerBufferExecCompleted(); } @@ -1805,16 +1805,16 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void) u8 paletteNum; u8 taskId; - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 50; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = -40; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - gSprites[gBankSpriteIds[gActiveBank]].data[5] = gActiveBank; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 50; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + gSprites[gBankSpriteIds[gActiveBattler]].data[5] = gActiveBattler; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], sub_805CC00); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 1); + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_805CC00); + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 1); paletteNum = AllocSpritePalette(0xD6F9); if (gPartnerTrainerId == STEVEN_PARTNER_ID) @@ -1829,16 +1829,16 @@ static void PlayerPartnerHandleIntroTrainerBallThrow(void) } - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = paletteNum; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; taskId = CreateTask(sub_81BE2C8, 5); - gTasks[taskId].data[0] = gActiveBank; + gTasks[taskId].data[0] = gActiveBattler; - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gBattleSpritesDataPtr->animationData->field_9_x1 = 1; - gBattleBankFunc[gActiveBank] = nullsub_77; + gBattlerFuncs[gActiveBattler] = nullsub_77; } static void sub_81BE2C8(u8 taskId) @@ -1849,62 +1849,62 @@ static void sub_81BE2C8(u8 taskId) } else { - u8 savedActiveBank = gActiveBank; + u8 savedActiveBank = gActiveBattler; - gActiveBank = gTasks[taskId].data[0]; + gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_81BD0E4(gActiveBank, FALSE); + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_81BD0E4(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_81BD0E4(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - sub_81BD0E4(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_81BD0E4(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + sub_81BD0E4(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; } - gBattleBankFunc[gActiveBank] = sub_81BB02C; - gActiveBank = savedActiveBank; + gBattlerFuncs[gActiveBattler] = sub_81BB02C; + gActiveBattler = savedActiveBank; DestroyTask(taskId); } } static void PlayerPartnerHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == SIDE_PLAYER) + if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { PlayerPartnerBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1 = 1; - gUnknown_020244B4[gActiveBank] = CreatePartyStatusSummarySprites(gActiveBank, (struct HpAndStatus *)&gBattleBufferA[gActiveBank][4], gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1 = 1; + gUnknown_020244B4[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBank][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0x5D; + if (gBattleBufferA[gActiveBattler][2] != 0) + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; - gBattleBankFunc[gActiveBank] = sub_81BE498; + gBattlerFuncs[gActiveBattler] = sub_81BE498; } } static void sub_81BE498(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5++ > 0x5C) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; PlayerPartnerBufferExecCompleted(); } } static void PlayerPartnerHandleCmd49(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; PlayerPartnerBufferExecCompleted(); } @@ -1915,25 +1915,25 @@ static void PlayerPartnerHandleCmd50(void) static void PlayerPartnerHandleSpriteInvisibility(void) { - if (IsBankSpritePresent(gActiveBank)) + if (IsBankSpritePresent(gActiveBattler)) { - gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; - CopyBattleSpriteInvisibility(gActiveBank); + gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + CopyBattleSpriteInvisibility(gActiveBattler); } PlayerPartnerBufferExecCompleted(); } static void PlayerPartnerHandleBattleAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBank][1]; - u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + u8 animationId = gBattleBufferA[gActiveBattler][1]; + u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) PlayerPartnerBufferExecCompleted(); else - gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; } } @@ -1949,11 +1949,11 @@ static void PlayerPartnerHandleResetActionMoveSelection(void) static void PlayerPartnerHandleCmd55(void) { - gBattleOutcome = gBattleBufferA[gActiveBank][1]; + gBattleOutcome = gBattleBufferA[gActiveBattler][1]; FadeOutMapMusic(5); BeginFastPaletteFade(3); PlayerPartnerBufferExecCompleted(); - gBattleBankFunc[gActiveBank] = sub_80587B0; + gBattlerFuncs[gActiveBattler] = sub_80587B0; } static void nullsub_128(void) diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index e970c5f58..290eee61b 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -26,32 +26,32 @@ #include "data2.h" extern u32 gBattleExecBuffer; -extern u8 gActiveBank; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; -extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gBattleBanksCount; +extern u8 gActiveBattler; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; +extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gBattlersCount; extern bool8 gDoingBattleAnim; -extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); +extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gPreBattleCallback1)(void); -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct SpriteTemplate gUnknown_0202499C; extern u16 gSpecialVar_ItemId; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gBattleOutcome; extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; extern u16 gUnknown_020243FC; -extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; -extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; +extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; +extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBankDefender; -extern u8 gAbsentBankFlags; +extern u8 gBattleDefender; +extern u8 gAbsentBattlerFlags; extern u8 gUnknown_020244B4[]; -extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; +extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern struct UnusedControllerStruct gUnknown_02022D0C; extern u16 gTrainerBattleOpponent_A; @@ -202,15 +202,15 @@ static void nullsub_70(void) void SetControllerToRecordedOpponent(void) { - gBattleBankFunc[gActiveBank] = RecordedOpponentBufferRunCommand; + gBattlerFuncs[gActiveBattler] = RecordedOpponentBufferRunCommand; } static void RecordedOpponentBufferRunCommand(void) { - if (gBattleExecBuffer & gBitTable[gActiveBank]) + if (gBattleExecBuffer & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(sRecordedOpponentBufferCommands)) - sRecordedOpponentBufferCommands[gBattleBufferA[gActiveBank][0]](); + if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedOpponentBufferCommands)) + sRecordedOpponentBufferCommands[gBattleBufferA[gActiveBattler][0]](); else RecordedOpponentBufferExecCompleted(); } @@ -218,32 +218,32 @@ static void RecordedOpponentBufferRunCommand(void) static void CompleteOnBankSpriteCallbackDummy(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) RecordedOpponentBufferExecCompleted(); } static void CompleteOnBankSpriteCallbackDummy2(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) RecordedOpponentBufferExecCompleted(); } static void sub_81865C8(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - FreeTrainerFrontPicPalette(gSprites[gBankSpriteIds[gActiveBank]].oam.affineParam); - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); + FreeTrainerFrontPicPalette(gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); RecordedOpponentBufferExecCompleted(); } } static void sub_8186630(void) { - if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 == 0xFF) + if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; RecordedOpponentBufferExecCompleted(); } } @@ -254,8 +254,8 @@ static void sub_8186678(void) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].animEnded) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].animEnded) { var = TRUE; } @@ -263,10 +263,10 @@ static void sub_8186678(void) } else { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gHealthBoxesIds[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].animEnded - && gSprites[gBankSpriteIds[gActiveBank ^ BIT_MON]].animEnded) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].animEnded + && gSprites[gBankSpriteIds[gActiveBattler ^ BIT_FLANK]].animEnded) { var = TRUE; } @@ -274,23 +274,23 @@ static void sub_8186678(void) if (var) { - if (GetBankPosition(gActiveBank) == B_POSITION_OPPONENT_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) return; - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) return; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3; - gBattleBankFunc[gActiveBank] = sub_8186630; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; + gBattlerFuncs[gActiveBattler] = sub_8186630; } } @@ -299,38 +299,38 @@ static void sub_818686C(void) bool32 r9 = FALSE; bool32 r8 = FALSE; - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) - sub_8172EF0(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive) - sub_8172EF0(gActiveBank ^ BIT_MON, &gEnemyParty[gBattlePartyID[gActiveBank ^ BIT_MON]]); + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) + sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) + sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]]); - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank ^ BIT_MON], &gEnemyParty[gBattlePartyID[gActiveBank ^ BIT_MON]], HEALTHBOX_ALL); - sub_8076918(gActiveBank ^ BIT_MON); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank ^ BIT_MON]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler ^ BIT_FLANK); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); } - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gEnemyParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; } - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x40 - && gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x40 + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40 && !IsCryPlayingOrClearCrySongs()) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) { - if (GetBankPosition(gActiveBank) == B_POSITION_OPPONENT_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT) m4aMPlayContinue(&gMPlayInfo_BGM); } else @@ -338,24 +338,24 @@ static void sub_818686C(void) m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); } } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1; r9 = TRUE; } if (!IsDoubleBattle()) { - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { r8 = TRUE; } } else { - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gUnknown_03005D7C[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) { r8 = TRUE; } @@ -365,36 +365,36 @@ static void sub_818686C(void) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank ^ BIT_MON]]); - SetBankEnemyShadowSpriteCallback(gActiveBank ^ BIT_MON, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank ^ BIT_MON]], MON_DATA_SPECIES)); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); + SetBankEnemyShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES)); } - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - SetBankEnemyShadowSpriteCallback(gActiveBank, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); gBattleSpritesDataPtr->animationData->field_9_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; - gBattleBankFunc[gActiveBank] = sub_8186678; + gBattlerFuncs[gActiveBattler] = sub_8186678; } } static void sub_8186C48(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].pos2.x == 0) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80) { - sub_8172EF0(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); + sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); } else { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); RecordedOpponentBufferExecCompleted(); @@ -405,13 +405,13 @@ static void sub_8186C48(void) static void CompleteOnHealthbarDone(void) { - s16 hpValue = sub_8074AA0(gActiveBank, gHealthBoxesIds[gActiveBank], HEALTH_BAR, 0); + s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); if (hpValue != -1) { - UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBank], hpValue, HP_CURRENT); + UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); } else { @@ -421,21 +421,21 @@ static void CompleteOnHealthbarDone(void) static void sub_8186D58(void) { - if (!gSprites[gBankSpriteIds[gActiveBank]].inUse) + if (!gSprites[gBankSpriteIds[gActiveBattler]].inUse) { - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); RecordedOpponentBufferExecCompleted(); } } static void sub_8186D9C(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - EnemyShadowCallbackToSetInvisible(gActiveBank); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + EnemyShadowCallbackToSetInvisible(gActiveBattler); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); RecordedOpponentBufferExecCompleted(); } } @@ -448,7 +448,7 @@ static void CompleteOnInactiveTextPrinter(void) static void DoHitAnimBlinkSpriteEffect(void) { - u8 spriteId = gBankSpriteIds[gActiveBank]; + u8 spriteId = gBankSpriteIds[gActiveBattler]; if (gSprites[spriteId].data[1] == 32) { @@ -467,22 +467,22 @@ static void DoHitAnimBlinkSpriteEffect(void) static void sub_8186EA4(void) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleBankFunc[gActiveBank] = sub_8186F14; + gBattlerFuncs[gActiveBattler] = sub_8186F14; } } static void sub_8186F14(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive && !IsCryPlayingOrClearCrySongs()) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy - || gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy_2) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy + || gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy_2) { m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); RecordedOpponentBufferExecCompleted(); @@ -492,67 +492,67 @@ static void sub_8186F14(void) static void sub_8186F94(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gEnemyParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); - CopyBattleSpriteInvisibility(gActiveBank); - gBattleBankFunc[gActiveBank] = sub_8186EA4; + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); + CopyBattleSpriteInvisibility(gActiveBattler); + gBattlerFuncs[gActiveBattler] = sub_8186EA4; } } static void sub_8187084(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80) { - sub_8172EF0(gActiveBank, &gEnemyParty[gBattlePartyID[gActiveBank]]); + sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlePartyID[gActiveBattler]]); } - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - SetBankEnemyShadowSpriteCallback(gActiveBank, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); - gBattleBankFunc[gActiveBank] = sub_8186F94; + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); + gBattlerFuncs[gActiveBattler] = sub_8186F94; } } static void CompleteOnFinishedStatusAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) RecordedOpponentBufferExecCompleted(); } static void CompleteOnFinishedBattleAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive) RecordedOpponentBufferExecCompleted(); } static void RecordedOpponentBufferExecCompleted(void) { - gBattleBankFunc[gActiveBank] = RecordedOpponentBufferRunCommand; + gBattlerFuncs[gActiveBattler] = RecordedOpponentBufferRunCommand; if (gBattleTypeFlags & BATTLE_TYPE_LINK) { u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBank][0] = CONTROLLER_TERMINATOR_NOP; + gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { - gBattleExecBuffer &= ~gBitTable[gActiveBank]; + gBattleExecBuffer &= ~gBitTable[gActiveBattler]; } } @@ -563,13 +563,13 @@ static void RecordedOpponentHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - size += CopyRecordedOpponentMonData(gBattlePartyID[gActiveBank], monData); + size += CopyRecordedOpponentMonData(gBattlePartyID[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -591,7 +591,7 @@ static u32 CopyRecordedOpponentMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES); @@ -657,7 +657,7 @@ static u32 CopyRecordedOpponentMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -672,7 +672,7 @@ static u32 CopyRecordedOpponentMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -897,13 +897,13 @@ static void RecordedOpponentHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - SetRecordedOpponentMonData(gBattlePartyID[gActiveBank]); + SetRecordedOpponentMonData(gBattlePartyID[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -916,11 +916,11 @@ static void RecordedOpponentHandleSetMonData(void) static void SetRecordedOpponentMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBank][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -961,10 +961,10 @@ static void SetRecordedOpponentMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < 4; i++) @@ -978,198 +978,198 @@ static void SetRecordedOpponentMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBank][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][7]); - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][8]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gEnemyParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; } } static void RecordedOpponentHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; + u8 *dst = (u8 *)&gEnemyParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) - dst[i] = gBattleBufferA[gActiveBank][3 + i]; + for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) + dst[i] = gBattleBufferA[gActiveBattler][3 + i]; RecordedOpponentBufferExecCompleted(); } static void RecordedOpponentHandleLoadMonSprite(void) { - u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); - BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[gActiveBank]], gActiveBank); - sub_806A068(species, GetBankPosition(gActiveBank)); + BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + sub_806A068(species, GetBattlerPosition(gActiveBattler)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, - GetBankCoord(gActiveBank, 2), - GetBankSpriteDefault_Y(gActiveBank), - sub_80A82E4(gActiveBank)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, + GetBankCoord(gActiveBattler, 2), + GetBankSpriteDefault_Y(gActiveBattler), + sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], gBattleMonForms[gActiveBank]); + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); - SetBankEnemyShadowSpriteCallback(gActiveBank, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES)); + SetBankEnemyShadowSpriteCallback(gActiveBattler, GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES)); - gBattleBankFunc[gActiveBank] = sub_8186C48; + gBattlerFuncs[gActiveBattler] = sub_8186C48; } static void RecordedOpponentHandleSwitchInAnim(void) { - gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1]; - sub_81885D8(gActiveBank, gBattleBufferA[gActiveBank][2]); - gBattleBankFunc[gActiveBank] = sub_8187084; + gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; + sub_81885D8(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlerFuncs[gActiveBattler] = sub_8187084; } static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit) @@ -1181,7 +1181,7 @@ static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit) species = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); - sub_806A068(species, GetBankPosition(bank)); + sub_806A068(species, GetBattlerPosition(bank)); gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBankCoord(bank, 2), @@ -1205,37 +1205,37 @@ static void sub_81885D8(u8 bank, bool8 dontClearSubstituteBit) static void RecordedOpponentHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBank][1] == 0) + if (gBattleBufferA[gActiveBattler][1] == 0) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = DoSwitchOutAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; } else { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - EnemyShadowCallbackToSetInvisible(gActiveBank); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + EnemyShadowCallbackToSetInvisible(gActiveBattler); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); RecordedOpponentBufferExecCompleted(); } } static void DoSwitchOutAnimation(void) { - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_OPPONENT_MON); - gBattleBankFunc[gActiveBank] = sub_8186D9C; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_OPPONENT_MON); + gBattlerFuncs[gActiveBattler] = sub_8186D9C; } break; } @@ -1248,14 +1248,14 @@ static void RecordedOpponentHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((GetBankPosition(gActiveBank) & BIT_MON) != 0) // second mon + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon xPos = 152; else // first mon xPos = 200; if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) { - if (gActiveBank == 1) + if (gActiveBattler == 1) trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_A); else trainerPicId = GetFrontierTrainerFrontSpriteId(gTrainerBattleOpponent_B); @@ -1278,20 +1278,20 @@ static void RecordedOpponentHandleDrawTrainerPic(void) } } - DecompressTrainerFrontPic(trainerPicId, gActiveBank); - sub_806A12C(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, + DecompressTrainerFrontPic(trainerPicId, gActiveBattler); + sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, (8 - gTrainerFrontPicCoords[trainerPicId].coords) * 4 + 40, - sub_80A82E4(gActiveBank)); + sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 2; - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); - gSprites[gBankSpriteIds[gActiveBank]].oam.affineParam = trainerPicId; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 2; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); + gSprites[gBankSpriteIds[gActiveBattler]].oam.affineParam = trainerPicId; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; } static void RecordedOpponentHandleTrainerSlide(void) @@ -1301,31 +1301,31 @@ static void RecordedOpponentHandleTrainerSlide(void) static void RecordedOpponentHandleTrainerSlideBack(void) { - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 35; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = 280; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], SpriteCallbackDummy); - gBattleBankFunc[gActiveBank] = sub_81865C8; + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); + gBattlerFuncs[gActiveBattler] = sub_81865C8; } static void RecordedOpponentHandleFaintAnimation(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } else { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; PlaySE12WithPanning(SE_POKE_DEAD, PAN_SIDE_OPPONENT); - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_8039934; - gBattleBankFunc[gActiveBank] = sub_8186D58; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039934; + gBattlerFuncs[gActiveBattler] = sub_8186D58; } } } @@ -1352,51 +1352,51 @@ static void RecordedOpponentHandlePause(void) static void RecordedOpponentHandleMoveAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBank][3]; - gAnimMovePower = gBattleBufferA[gActiveBank][4] | (gBattleBufferA[gActiveBank][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBank][6] | (gBattleBufferA[gActiveBank][7] << 8) | (gBattleBufferA[gActiveBank][8] << 16) | (gBattleBufferA[gActiveBank][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBank][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBank][12] | (gBattleBufferA[gActiveBank][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBank][16]; - gTransformedPersonalities[gActiveBank] = gAnimDisableStructPtr->transformedMonPersonality; + gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; + gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleBufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { RecordedOpponentBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = RecordedOpponentDoMoveAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = RecordedOpponentDoMoveAnimation; } } } static void RecordedOpponentDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); - u8 multihit = gBattleBufferA[gActiveBank][11]; + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleBufferA[gActiveBattler][11]; - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { sub_805EB9C(0); DoMoveAnim(move); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 2; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; } break; case 2: @@ -1404,20 +1404,20 @@ static void RecordedOpponentDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) { - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } break; case 3: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; RecordedOpponentBufferExecCompleted(); } break; @@ -1430,10 +1430,10 @@ static void RecordedOpponentHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBank][2]); + stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); - gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; } static void RecordedOpponentHandlePrintSelectionString(void) @@ -1443,7 +1443,7 @@ static void RecordedOpponentHandlePrintSelectionString(void) static void RecordedOpponentHandleChooseAction(void) { - EmitTwoReturnValues(1, RecordedBattle_ReadBankAction(gActiveBank), 0); + EmitTwoReturnValues(1, RecordedBattle_ReadBankAction(gActiveBattler), 0); RecordedOpponentBufferExecCompleted(); } @@ -1460,8 +1460,8 @@ static void RecordedOpponentHandleChooseMove(void) } else { - u8 moveId = RecordedBattle_ReadBankAction(gActiveBank); - u8 target = RecordedBattle_ReadBankAction(gActiveBank); + u8 moveId = RecordedBattle_ReadBankAction(gActiveBattler); + u8 target = RecordedBattle_ReadBankAction(gActiveBattler); EmitTwoReturnValues(1, 10, moveId | (target << 8)); } @@ -1475,8 +1475,8 @@ static void RecordedOpponentHandleChooseItem(void) static void RecordedOpponentHandleChoosePokemon(void) { - *(gBattleStruct->monToSwitchIntoId + gActiveBank) = RecordedBattle_ReadBankAction(gActiveBank); - EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBank), NULL); + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_ReadBankAction(gActiveBattler); + EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); RecordedOpponentBufferExecCompleted(); } @@ -1490,23 +1490,23 @@ static void RecordedOpponentHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { - u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); - u32 curHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); + u32 curHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, curHP, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); } else { - u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 maxHP = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, 0, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); } - gBattleBankFunc[gActiveBank] = CompleteOnHealthbarDone; + gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } static void RecordedOpponentHandleExpUpdate(void) @@ -1516,24 +1516,24 @@ static void RecordedOpponentHandleExpUpdate(void) static void RecordedOpponentHandleStatusIconUpdate(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { u8 bank; - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gEnemyParty[gBattlePartyID[gActiveBank]], HEALTHBOX_STATUS_ICON); - bank = gActiveBank; + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gEnemyParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); + bank = gActiveBattler; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } static void RecordedOpponentHandleStatusAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], - gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], + gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1590,7 +1590,7 @@ static void RecordedOpponentHandleCmd37(void) static void RecordedOpponentHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBank][1]; + gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; RecordedOpponentBufferExecCompleted(); } @@ -1608,16 +1608,16 @@ static void RecordedOpponentHandleCmd40(void) static void RecordedOpponentHandleHitAnimation(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].invisible == TRUE) + if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) { RecordedOpponentBufferExecCompleted(); } else { gDoingBattleAnim = TRUE; - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - DoHitAnimHealthboxEffect(gActiveBank); - gBattleBankFunc[gActiveBank] = DoHitAnimBlinkSpriteEffect; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + DoHitAnimHealthboxEffect(gActiveBattler); + gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; } } @@ -1630,25 +1630,25 @@ static void RecordedOpponentHandlePlaySE(void) { s8 pan; - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) pan = PAN_SIDE_PLAYER; else pan = PAN_SIDE_OPPONENT; - PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan); + PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); RecordedOpponentBufferExecCompleted(); } static void RecordedOpponentHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBank][3]) + if (gBattleBufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } RecordedOpponentBufferExecCompleted(); @@ -1656,7 +1656,7 @@ static void RecordedOpponentHandlePlayFanfareOrBGM(void) static void RecordedOpponentHandleFaintingCry(void) { - u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); PlayCry3(species, 25, 5); RecordedOpponentBufferExecCompleted(); @@ -1664,7 +1664,7 @@ static void RecordedOpponentHandleFaintingCry(void) static void RecordedOpponentHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBank][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gUnknown_020243FC |= 1; RecordedOpponentBufferExecCompleted(); } @@ -1674,46 +1674,46 @@ static void RecordedOpponentHandleIntroTrainerBallThrow(void) u8 paletteNum; u8 taskId; - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 35; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = 280; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 280; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], sub_818962C); + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_818962C); taskId = CreateTask(sub_8189548, 5); - gTasks[taskId].data[0] = gActiveBank; + gTasks[taskId].data[0] = gActiveBattler; - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gBattleSpritesDataPtr->animationData->field_9_x1 = 1; - gBattleBankFunc[gActiveBank] = nullsub_70; + gBattlerFuncs[gActiveBattler] = nullsub_70; } static void sub_8189548(u8 taskId) { - u8 savedActiveBank = gActiveBank; + u8 savedActiveBank = gActiveBattler; - gActiveBank = gTasks[taskId].data[0]; + gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_81885D8(gActiveBank, FALSE); + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_81885D8(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_81885D8(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_81885D8(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_81885D8(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_81885D8(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; } - gBattleBankFunc[gActiveBank] = sub_818686C; - gActiveBank = savedActiveBank; + gBattlerFuncs[gActiveBattler] = sub_818686C; + gActiveBattler = savedActiveBank; DestroyTask(taskId); } @@ -1726,50 +1726,50 @@ static void sub_818962C(struct Sprite *sprite) static void RecordedOpponentHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == SIDE_PLAYER) + if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { RecordedOpponentBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1 = 1; - if (gBattleBufferA[gActiveBank][2] != 0) + if (gBattleBufferA[gActiveBattler][2] != 0) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E < 2) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E < 2) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E++; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E++; return; } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1E = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1E = 0; } } - gUnknown_020244B4[gActiveBank] = CreatePartyStatusSummarySprites(gActiveBank, (struct HpAndStatus *)&gBattleBufferA[gActiveBank][4], gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gUnknown_020244B4[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBank][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0x5D; + if (gBattleBufferA[gActiveBattler][2] != 0) + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; - gBattleBankFunc[gActiveBank] = sub_818975C; + gBattlerFuncs[gActiveBattler] = sub_818975C; } } static void sub_818975C(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5++ > 0x5C) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; RecordedOpponentBufferExecCompleted(); } } static void RecordedOpponentHandleCmd49(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; RecordedOpponentBufferExecCompleted(); } @@ -1780,25 +1780,25 @@ static void RecordedOpponentHandleCmd50(void) static void RecordedOpponentHandleSpriteInvisibility(void) { - if (IsBankSpritePresent(gActiveBank)) + if (IsBankSpritePresent(gActiveBattler)) { - gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; - CopyBattleSpriteInvisibility(gActiveBank); + gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + CopyBattleSpriteInvisibility(gActiveBattler); } RecordedOpponentBufferExecCompleted(); } static void RecordedOpponentHandleBattleAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBank][1]; - u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + u8 animationId = gBattleBufferA[gActiveBattler][1]; + u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) RecordedOpponentBufferExecCompleted(); else - gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; } } @@ -1814,15 +1814,15 @@ static void RecordedOpponentHandleResetActionMoveSelection(void) static void RecordedOpponentHandleCmd55(void) { - if (gBattleBufferA[gActiveBank][1] == B_OUTCOME_DREW) - gBattleOutcome = gBattleBufferA[gActiveBank][1]; + if (gBattleBufferA[gActiveBattler][1] == B_OUTCOME_DREW) + gBattleOutcome = gBattleBufferA[gActiveBattler][1]; else - gBattleOutcome = gBattleBufferA[gActiveBank][1] ^ B_OUTCOME_DREW; + gBattleOutcome = gBattleBufferA[gActiveBattler][1] ^ B_OUTCOME_DREW; FadeOutMapMusic(5); BeginFastPaletteFade(3); RecordedOpponentBufferExecCompleted(); - gBattleBankFunc[gActiveBank] = sub_80587B0; + gBattlerFuncs[gActiveBattler] = sub_80587B0; } static void nullsub_119(void) diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 775ea3e7c..ad8cb3a05 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -25,33 +25,33 @@ #include "data2.h" extern u32 gBattleExecBuffer; -extern u8 gActiveBank; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; -extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gBattleBanksCount; +extern u8 gActiveBattler; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; +extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gBattlersCount; extern bool8 gDoingBattleAnim; -extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); +extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gPreBattleCallback1)(void); -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct SpriteTemplate gUnknown_0202499C; extern u16 gSpecialVar_ItemId; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gBattleOutcome; extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; extern u8 gBankInMenu; extern u16 gUnknown_020243FC; -extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; -extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; +extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; +extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBankDefender; -extern u8 gAbsentBankFlags; +extern u8 gBattleDefender; +extern u8 gAbsentBattlerFlags; extern u8 gUnknown_020244B4[]; -extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; +extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u8 gBattleCommunication[]; extern u8 gUnknown_0203C7B4; extern struct MusicPlayerInfo gMPlayInfo_BGM; @@ -201,15 +201,15 @@ static void nullsub_120(void) void SetControllerToRecordedPlayer(void) { - gBattleBankFunc[gActiveBank] = RecordedPlayerBufferRunCommand; + gBattlerFuncs[gActiveBattler] = RecordedPlayerBufferRunCommand; } static void RecordedPlayerBufferRunCommand(void) { - if (gBattleExecBuffer & gBitTable[gActiveBank]) + if (gBattleExecBuffer & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(sRecordedPlayerBufferCommands)) - sRecordedPlayerBufferCommands[gBattleBufferA[gActiveBank][0]](); + if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sRecordedPlayerBufferCommands)) + sRecordedPlayerBufferCommands[gBattleBufferA[gActiveBattler][0]](); else RecordedPlayerBufferExecCompleted(); } @@ -217,26 +217,26 @@ static void RecordedPlayerBufferRunCommand(void) static void CompleteOnBankSpriteCallbackDummy(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) RecordedPlayerBufferExecCompleted(); } static void sub_81899F0(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { nullsub_25(0); - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); RecordedPlayerBufferExecCompleted(); } } static void sub_8189A58(void) { - if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 == 0xFF) + if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; RecordedPlayerBufferExecCompleted(); } } @@ -245,53 +245,53 @@ static void sub_8189AA0(void) { bool32 r6 = FALSE; - if (GetBankPosition(gActiveBank) == B_POSITION_PLAYER_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT) { if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) r6 = TRUE; } else { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gHealthBoxesIds[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) { r6 = TRUE; } } - if (r6 && gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 - && gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1) + if (r6 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); if (IsDoubleBattle()) - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], gActiveBank ^ BIT_MON); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], gActiveBattler ^ BIT_FLANK); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3; - gBattleBankFunc[gActiveBank] = sub_8189A58; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; + gBattlerFuncs[gActiveBattler] = sub_8189A58; } } else { if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) r6 = TRUE; } else { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gHealthBoxesIds[gActiveBank ^ BIT_MON]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) { r6 = TRUE; } @@ -302,8 +302,8 @@ static void sub_8189AA0(void) if (r6) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_9 = 3; - gBattleBankFunc[gActiveBank] = sub_8189A58; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 3; + gBattlerFuncs[gActiveBattler] = sub_8189A58; } } } @@ -312,48 +312,48 @@ static void sub_8189D40(void) { bool32 r10 = FALSE; - if (GetBankPosition(gActiveBank) == B_POSITION_PLAYER_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - sub_8172EF0(gActiveBank, &gPlayerParty[gBattlePartyID[gActiveBank]]); + sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); } - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) { - sub_8172EF0(gActiveBank ^ BIT_MON, &gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]]); + sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]]); } } - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank ^ BIT_MON], &gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], HEALTHBOX_ALL); - sub_8076918(gActiveBank ^ BIT_MON); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank ^ BIT_MON]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler ^ BIT_FLANK); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); } - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 1; } - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x40 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x40 + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40 && !IsCryPlayingOrClearCrySongs()) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) { if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - if (GetBankPosition(gActiveBank) == B_POSITION_PLAYER_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT) m4aMPlayContinue(&gMPlayInfo_BGM); } else @@ -362,68 +362,68 @@ static void sub_8189D40(void) } } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20 = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 1; r10 = TRUE; } - if (r10 && gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (r10 && gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank ^ BIT_MON]]); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); gBattleSpritesDataPtr->animationData->field_9_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x20 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x80 = 0; - gBattleBankFunc[gActiveBank] = sub_8189AA0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 = 0; + gBattlerFuncs[gActiveBattler] = sub_8189AA0; } } static void sub_818A064(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].animEnded && gSprites[gBankSpriteIds[gActiveBank]].pos2.x == 0) + if (gSprites[gBankSpriteIds[gActiveBattler]].animEnded && gSprites[gBankSpriteIds[gActiveBattler]].pos2.x == 0) RecordedPlayerBufferExecCompleted(); } static void CompleteOnHealthbarDone(void) { - s16 hpValue = sub_8074AA0(gActiveBank, gHealthBoxesIds[gActiveBank], HEALTH_BAR, 0); + s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); if (hpValue != -1) { - UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBank], hpValue, HP_CURRENT); + UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); } else { - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); RecordedPlayerBufferExecCompleted(); } } static void sub_818A114(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].pos1.y + gSprites[gBankSpriteIds[gActiveBank]].pos2.y > DISPLAY_HEIGHT) + if (gSprites[gBankSpriteIds[gActiveBattler]].pos1.y + gSprites[gBankSpriteIds[gActiveBattler]].pos2.y > DISPLAY_HEIGHT) { - u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); nullsub_24(species); - FreeOamMatrix(gSprites[gBankSpriteIds[gActiveBank]].oam.matrixNum); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeOamMatrix(gSprites[gBankSpriteIds[gActiveBattler]].oam.matrixNum); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); RecordedPlayerBufferExecCompleted(); } } static void sub_818A1B0(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); RecordedPlayerBufferExecCompleted(); } } @@ -436,7 +436,7 @@ static void CompleteOnInactiveTextPrinter(void) static void DoHitAnimBlinkSpriteEffect(void) { - u8 spriteId = gBankSpriteIds[gActiveBank]; + u8 spriteId = gBankSpriteIds[gActiveBattler]; if (gSprites[spriteId].data[1] == 32) { @@ -455,20 +455,20 @@ static void DoHitAnimBlinkSpriteEffect(void) static void sub_818A2B4(void) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) { - CopyBattleSpriteInvisibility(gActiveBank); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + CopyBattleSpriteInvisibility(gActiveBattler); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleBankFunc[gActiveBank] = sub_818A328; + gBattlerFuncs[gActiveBattler] = sub_818A328; } } static void sub_818A328(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { RecordedPlayerBufferExecCompleted(); } @@ -476,66 +476,66 @@ static void sub_818A328(void) static void sub_818A37C(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); CreateTask(c3_0802FDF4, 10); - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 0); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 0); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); - gBattleBankFunc[gActiveBank] = sub_818A2B4; + gBattlerFuncs[gActiveBattler] = sub_818A2B4; } } static void sub_818A470(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - sub_8172EF0(gActiveBank, &gPlayerParty[gBattlePartyID[gActiveBank]]); + sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); } - if (gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) + if (gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - gBattleBankFunc[gActiveBank] = sub_818A37C; + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + gBattlerFuncs[gActiveBattler] = sub_818A37C; } } static void RecordedPlayerBufferExecCompleted(void) { - gBattleBankFunc[gActiveBank] = RecordedPlayerBufferRunCommand; + gBattlerFuncs[gActiveBattler] = RecordedPlayerBufferRunCommand; if (gBattleTypeFlags & BATTLE_TYPE_LINK) { u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBank][0] = CONTROLLER_TERMINATOR_NOP; + gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { - gBattleExecBuffer &= ~gBitTable[gActiveBank]; + gBattleExecBuffer &= ~gBitTable[gActiveBattler]; } } static void CompleteOnFinishedStatusAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) RecordedPlayerBufferExecCompleted(); } static void CompleteOnFinishedBattleAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive) RecordedPlayerBufferExecCompleted(); } @@ -546,13 +546,13 @@ static void RecordedPlayerHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - size += CopyRecordedPlayerMonData(gBattlePartyID[gActiveBank], monData); + size += CopyRecordedPlayerMonData(gBattlePartyID[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -574,7 +574,7 @@ static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); @@ -640,7 +640,7 @@ static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -655,7 +655,7 @@ static u32 CopyRecordedPlayerMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -880,13 +880,13 @@ static void RecordedPlayerHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - SetRecordedPlayerMonData(gBattlePartyID[gActiveBank]); + SetRecordedPlayerMonData(gBattlePartyID[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -899,11 +899,11 @@ static void RecordedPlayerHandleSetMonData(void) static void SetRecordedPlayerMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBank][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -944,10 +944,10 @@ static void SetRecordedPlayerMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < 4; i++) @@ -961,167 +961,167 @@ static void SetRecordedPlayerMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBank][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][7]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][8]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; } - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); } static void RecordedPlayerHandleSetRawMonData(void) { - u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBank]] + gBattleBufferA[gActiveBank][1]; + u8 *dst = (u8 *)&gPlayerParty[gBattlePartyID[gActiveBattler]] + gBattleBufferA[gActiveBattler][1]; u8 i; - for (i = 0; i < gBattleBufferA[gActiveBank][2]; i++) - dst[i] = gBattleBufferA[gActiveBank][3 + i]; + for (i = 0; i < gBattleBufferA[gActiveBattler][2]; i++) + dst[i] = gBattleBufferA[gActiveBattler][3 + i]; RecordedPlayerBufferExecCompleted(); } @@ -1130,28 +1130,28 @@ static void RecordedPlayerHandleLoadMonSprite(void) { u16 species; - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); - sub_806A068(species, GetBankPosition(gActiveBank)); + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); + sub_806A068(species, GetBattlerPosition(gActiveBattler)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, - GetBankCoord(gActiveBank, 2), - GetBankSpriteDefault_Y(gActiveBank), - sub_80A82E4(gActiveBank)); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], gBattleMonForms[gActiveBank]); - gBattleBankFunc[gActiveBank] = sub_818A064; + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, + GetBankCoord(gActiveBattler, 2), + GetBankSpriteDefault_Y(gActiveBattler), + sub_80A82E4(gActiveBattler)); + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], gBattleMonForms[gActiveBattler]); + gBattlerFuncs[gActiveBattler] = sub_818A064; } static void RecordedPlayerHandleSwitchInAnim(void) { - ClearTemporarySpeciesSpriteData(gActiveBank, gBattleBufferA[gActiveBank][2]); - gBattlePartyID[gActiveBank] = gBattleBufferA[gActiveBank][1]; - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - sub_818BA6C(gActiveBank, gBattleBufferA[gActiveBank][2]); - gBattleBankFunc[gActiveBank] = sub_818A470; + ClearTemporarySpeciesSpriteData(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlePartyID[gActiveBattler] = gBattleBufferA[gActiveBattler][1]; + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + sub_818BA6C(gActiveBattler, gBattleBufferA[gActiveBattler][2]); + gBattlerFuncs[gActiveBattler] = sub_818A470; } static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit) @@ -1162,7 +1162,7 @@ static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit) gBattlePartyID[bank] = gBattleBufferA[bank][1]; species = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); - sub_806A068(species, GetBankPosition(bank)); + sub_806A068(species, GetBattlerPosition(bank)); gBankSpriteIds[bank] = CreateSprite( &gUnknown_0202499C, @@ -1187,36 +1187,36 @@ static void sub_818BA6C(u8 bank, bool8 dontClearSubstituteBit) static void RecordedPlayerHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBank][1] == 0) + if (gBattleBufferA[gActiveBattler][1] == 0) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = DoSwitchOutAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = DoSwitchOutAnimation; } else { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); RecordedPlayerBufferExecCompleted(); } } static void DoSwitchOutAnimation(void) { - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); - gBattleBankFunc[gActiveBank] = sub_818A1B0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); + gBattlerFuncs[gActiveBattler] = sub_818A1B0; } break; } @@ -1241,7 +1241,7 @@ static void RecordedPlayerHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if ((GetBankPosition(gActiveBank) & BIT_MON) != 0) // second mon + if ((GetBattlerPosition(gActiveBattler) & BIT_FLANK) != 0) // second mon xPos = 90; else // first mon xPos = 32; @@ -1266,31 +1266,31 @@ static void RecordedPlayerHandleDrawTrainerPic(void) if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) { trainerPicId = PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender); - DecompressTrainerFrontPic(trainerPicId, gActiveBank); - sub_806A1C0(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBank)); + DecompressTrainerFrontPic(trainerPicId, gActiveBattler); + sub_806A1C0(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 240; - gSprites[gBankSpriteIds[gActiveBank]].pos2.y = 48; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; - gSprites[gBankSpriteIds[gActiveBank]].oam.affineMode = 0; - gSprites[gBankSpriteIds[gActiveBank]].hFlip = 1; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = IndexOfSpritePaletteTag(gTrainerFrontPicPaletteTable[trainerPicId].tag); + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.y = 48; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].oam.affineMode = 0; + gSprites[gBankSpriteIds[gActiveBattler]].hFlip = 1; } else { - DecompressTrainerBackPic(trainerPicId, gActiveBank); - sub_806A12C(trainerPicId, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBank)); + DecompressTrainerBackPic(trainerPicId, gActiveBattler); + sub_806A12C(trainerPicId, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, xPos, yPos, sub_80A82E4(gActiveBattler)); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; } - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; } static void RecordedPlayerHandleTrainerSlide(void) @@ -1300,34 +1300,34 @@ static void RecordedPlayerHandleTrainerSlide(void) static void RecordedPlayerHandleTrainerSlideBack(void) { - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 35; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = -40; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], SpriteCallbackDummy); - gBattleBankFunc[gActiveBank] = sub_81899F0; + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 35; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], SpriteCallbackDummy); + gBattlerFuncs[gActiveBattler] = sub_81899F0; } static void RecordedPlayerHandleFaintAnimation(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState == 0) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState++; + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } else { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); PlaySE12WithPanning(SE_POKE_DEAD, -64); - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = 5; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_8039C00; - gBattleBankFunc[gActiveBank] = sub_818A114; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = 5; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_8039C00; + gBattlerFuncs[gActiveBattler] = sub_818A114; } } } @@ -1354,51 +1354,51 @@ static void RecordedPlayerHandlePause(void) static void RecordedPlayerHandleMoveAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBank][3]; - gAnimMovePower = gBattleBufferA[gActiveBank][4] | (gBattleBufferA[gActiveBank][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBank][6] | (gBattleBufferA[gActiveBank][7] << 8) | (gBattleBufferA[gActiveBank][8] << 16) | (gBattleBufferA[gActiveBank][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBank][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBank][12] | (gBattleBufferA[gActiveBank][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBank][16]; - gTransformedPersonalities[gActiveBank] = gAnimDisableStructPtr->transformedMonPersonality; + gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; + gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleBufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { RecordedPlayerBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = RecordedPlayerDoMoveAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = RecordedPlayerDoMoveAnimation; } } } static void RecordedPlayerDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); - u8 multihit = gBattleBufferA[gActiveBank][11]; + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); + u8 multihit = gBattleBufferA[gActiveBattler][11]; - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 1; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { sub_805EB9C(0); DoMoveAnim(move); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 2; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; } break; case 2: @@ -1406,20 +1406,20 @@ static void RecordedPlayerDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) { - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBank].flag_x8 = 0; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); + gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } break; case 3: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; RecordedPlayerBufferExecCompleted(); } break; @@ -1432,10 +1432,10 @@ static void RecordedPlayerHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBank][2]); + stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); - gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; } static void RecordedPlayerHandlePrintSelectionString(void) @@ -1445,9 +1445,9 @@ static void RecordedPlayerHandlePrintSelectionString(void) static void ChooseActionInBattlePalace(void) { - if (gBattleCommunication[4] >= gBattleBanksCount / 2) + if (gBattleCommunication[4] >= gBattlersCount / 2) { - EmitTwoReturnValues(1, RecordedBattle_ReadBankAction(gActiveBank), 0); + EmitTwoReturnValues(1, RecordedBattle_ReadBankAction(gActiveBattler), 0); RecordedPlayerBufferExecCompleted(); } } @@ -1456,11 +1456,11 @@ static void RecordedPlayerHandleChooseAction(void) { if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gBattleBankFunc[gActiveBank] = ChooseActionInBattlePalace; + gBattlerFuncs[gActiveBattler] = ChooseActionInBattlePalace; } else { - EmitTwoReturnValues(1, RecordedBattle_ReadBankAction(gActiveBank), 0); + EmitTwoReturnValues(1, RecordedBattle_ReadBankAction(gActiveBattler), 0); RecordedPlayerBufferExecCompleted(); } } @@ -1478,8 +1478,8 @@ static void RecordedPlayerHandleChooseMove(void) } else { - u8 moveId = RecordedBattle_ReadBankAction(gActiveBank); - u8 target = RecordedBattle_ReadBankAction(gActiveBank); + u8 moveId = RecordedBattle_ReadBankAction(gActiveBattler); + u8 target = RecordedBattle_ReadBankAction(gActiveBattler); EmitTwoReturnValues(1, 10, moveId | (target << 8)); } @@ -1493,8 +1493,8 @@ static void RecordedPlayerHandleChooseItem(void) static void RecordedPlayerHandleChoosePokemon(void) { - *(gBattleStruct->monToSwitchIntoId + gActiveBank) = RecordedBattle_ReadBankAction(gActiveBank); - EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBank), NULL); + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_ReadBankAction(gActiveBattler); + EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); RecordedPlayerBufferExecCompleted(); } @@ -1508,24 +1508,24 @@ static void RecordedPlayerHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { - u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); - u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); + u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, curHP, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); } else { - u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, 0, hpVal); - UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBank], 0, HP_CURRENT); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); + UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], 0, HP_CURRENT); } - gBattleBankFunc[gActiveBank] = CompleteOnHealthbarDone; + gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } static void RecordedPlayerHandleExpUpdate(void) @@ -1535,24 +1535,24 @@ static void RecordedPlayerHandleExpUpdate(void) static void RecordedPlayerHandleStatusIconUpdate(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { u8 bank; - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_STATUS_ICON); - bank = gActiveBank; + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_STATUS_ICON); + bank = gActiveBattler; gBattleSpritesDataPtr->healthBoxesData[bank].statusAnimActive = 0; - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } static void RecordedPlayerHandleStatusAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBank][1], - gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8) | (gBattleBufferA[gActiveBank][4] << 16) | (gBattleBufferA[gActiveBank][5] << 24)); - gBattleBankFunc[gActiveBank] = CompleteOnFinishedStatusAnimation; + InitAndLaunchChosenStatusAnimation(gBattleBufferA[gActiveBattler][1], + gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8) | (gBattleBufferA[gActiveBattler][4] << 16) | (gBattleBufferA[gActiveBattler][5] << 24)); + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedStatusAnimation; } } @@ -1609,7 +1609,7 @@ static void RecordedPlayerHandleCmd37(void) static void RecordedPlayerHandleCmd38(void) { - gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBank][1]; + gUnknown_02022D0C.field_0 = gBattleBufferA[gActiveBattler][1]; RecordedPlayerBufferExecCompleted(); } @@ -1627,16 +1627,16 @@ static void RecordedPlayerHandleCmd40(void) static void RecordedPlayerHandleHitAnimation(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].invisible == TRUE) + if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) { RecordedPlayerBufferExecCompleted(); } else { gDoingBattleAnim = TRUE; - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - DoHitAnimHealthboxEffect(gActiveBank); - gBattleBankFunc[gActiveBank] = DoHitAnimBlinkSpriteEffect; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + DoHitAnimHealthboxEffect(gActiveBattler); + gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; } } @@ -1649,25 +1649,25 @@ static void RecordedPlayerHandlePlaySE(void) { s8 pan; - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) pan = PAN_SIDE_PLAYER; else pan = PAN_SIDE_OPPONENT; - PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan); + PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); RecordedPlayerBufferExecCompleted(); } static void RecordedPlayerHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBank][3]) + if (gBattleBufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } RecordedPlayerBufferExecCompleted(); @@ -1675,7 +1675,7 @@ static void RecordedPlayerHandlePlayFanfareOrBGM(void) static void RecordedPlayerHandleFaintingCry(void) { - u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); PlayCry3(species, -25, 5); RecordedPlayerBufferExecCompleted(); @@ -1683,7 +1683,7 @@ static void RecordedPlayerHandleFaintingCry(void) static void RecordedPlayerHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBank][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gUnknown_020243FC |= 1; RecordedPlayerBufferExecCompleted(); } @@ -1694,35 +1694,35 @@ static void RecordedPlayerHandleIntroTrainerBallThrow(void) u8 taskId; u32 trainerPicId; - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 50; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = -40; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - gSprites[gBankSpriteIds[gActiveBank]].data[5] = gActiveBank; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 50; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + gSprites[gBankSpriteIds[gActiveBattler]].data[5] = gActiveBattler; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], sub_805CC00); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 1); + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_805CC00); + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 1); paletteNum = AllocSpritePalette(0xD6F9); if (gBattleTypeFlags & BATTLE_TYPE_x2000000) - trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBank)].gender; + trainerPicId = gLinkPlayers[GetBankMultiplayerId(gActiveBattler)].gender; else trainerPicId = gSaveBlock2Ptr->playerGender; LoadCompressedPalette(gTrainerBackPicPaletteTable[trainerPicId].data, 0x100 + paletteNum * 16, 32); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = paletteNum; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; taskId = CreateTask(sub_818CC24, 5); - gTasks[taskId].data[0] = gActiveBank; + gTasks[taskId].data[0] = gActiveBattler; - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gBattleSpritesDataPtr->animationData->field_9_x1 = 1; - gBattleBankFunc[gActiveBank] = nullsub_120; + gBattlerFuncs[gActiveBattler] = nullsub_120; } static void sub_818CC24(u8 taskId) @@ -1733,62 +1733,62 @@ static void sub_818CC24(u8 taskId) } else { - u8 savedActiveBank = gActiveBank; + u8 savedActiveBank = gActiveBattler; - gActiveBank = gTasks[taskId].data[0]; + gActiveBattler = gTasks[taskId].data[0]; if (!IsDoubleBattle() || (gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_818BA6C(gActiveBank, FALSE); + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_818BA6C(gActiveBattler, FALSE); } else { - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_818BA6C(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); - sub_818BA6C(gActiveBank, FALSE); - gActiveBank ^= BIT_MON; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_818BA6C(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); + sub_818BA6C(gActiveBattler, FALSE); + gActiveBattler ^= BIT_FLANK; } - gBattleBankFunc[gActiveBank] = sub_8189D40; - gActiveBank = savedActiveBank; + gBattlerFuncs[gActiveBattler] = sub_8189D40; + gActiveBattler = savedActiveBank; DestroyTask(taskId); } } static void RecordedPlayerHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == SIDE_PLAYER) + if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { RecordedPlayerBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1 = 1; - gUnknown_020244B4[gActiveBank] = CreatePartyStatusSummarySprites(gActiveBank, (struct HpAndStatus *)&gBattleBufferA[gActiveBank][4], gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2]); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1 = 1; + gUnknown_020244B4[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; - if (gBattleBufferA[gActiveBank][2] != 0) - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0x5D; + if (gBattleBufferA[gActiveBattler][2] != 0) + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0x5D; - gBattleBankFunc[gActiveBank] = sub_818CDF4; + gBattlerFuncs[gActiveBattler] = sub_818CDF4; } } static void sub_818CDF4(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5++ > 0x5C) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5++ > 0x5C) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_5 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_5 = 0; RecordedPlayerBufferExecCompleted(); } } static void RecordedPlayerHandleCmd49(void) { - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; RecordedPlayerBufferExecCompleted(); } @@ -1799,25 +1799,25 @@ static void RecordedPlayerHandleCmd50(void) static void RecordedPlayerHandleSpriteInvisibility(void) { - if (IsBankSpritePresent(gActiveBank)) + if (IsBankSpritePresent(gActiveBattler)) { - gSprites[gBankSpriteIds[gActiveBank]].invisible = gBattleBufferA[gActiveBank][1]; - CopyBattleSpriteInvisibility(gActiveBank); + gSprites[gBankSpriteIds[gActiveBattler]].invisible = gBattleBufferA[gActiveBattler][1]; + CopyBattleSpriteInvisibility(gActiveBattler); } RecordedPlayerBufferExecCompleted(); } static void RecordedPlayerHandleBattleAnimation(void) { - if (!mplay_80342A4(gActiveBank)) + if (!mplay_80342A4(gActiveBattler)) { - u8 animationId = gBattleBufferA[gActiveBank][1]; - u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + u8 animationId = gBattleBufferA[gActiveBattler][1]; + u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) RecordedPlayerBufferExecCompleted(); else - gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; } } @@ -1833,11 +1833,11 @@ static void RecordedPlayerHandleResetActionMoveSelection(void) static void RecordedPlayerHandleCmd55(void) { - gBattleOutcome = gBattleBufferA[gActiveBank][1]; + gBattleOutcome = gBattleBufferA[gActiveBattler][1]; FadeOutMapMusic(5); BeginFastPaletteFade(3); RecordedPlayerBufferExecCompleted(); - gBattleBankFunc[gActiveBank] = sub_80587B0; + gBattlerFuncs[gActiveBattler] = sub_80587B0; } static void nullsub_121(void) diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index a605e4cb8..9e90d660c 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -23,20 +23,20 @@ #include "pokeblock.h" extern u32 gBattleExecBuffer; -extern u8 gActiveBank; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; -extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gBattleBanksCount; +extern u8 gActiveBattler; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; +extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gBattlersCount; extern bool8 gDoingBattleAnim; -extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); +extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); extern void (*gPreBattleCallback1)(void); -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct SpriteTemplate gUnknown_0202499C; extern u16 gSpecialVar_ItemId; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gBattleOutcome; extern u16 gBattle_BG0_X; extern u16 gBattle_BG0_Y; @@ -180,15 +180,15 @@ static void nullsub_114(void) void SetControllerToSafari(void) { - gBattleBankFunc[gActiveBank] = SafariBufferRunCommand; + gBattlerFuncs[gActiveBattler] = SafariBufferRunCommand; } static void SafariBufferRunCommand(void) { - if (gBattleExecBuffer & gBitTable[gActiveBank]) + if (gBattleExecBuffer & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(sSafariBufferCommands)) - sSafariBufferCommands[gBattleBufferA[gActiveBank][0]](); + if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sSafariBufferCommands)) + sSafariBufferCommands[gBattleBufferA[gActiveBattler][0]](); else SafariBufferExecCompleted(); } @@ -200,7 +200,7 @@ static void HandleInputChooseAction(void) { PlaySE(SE_SELECT); - switch (gActionSelectionCursor[gActiveBank]) + switch (gActionSelectionCursor[gActiveBattler]) { case 0: EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_BALL, 0); @@ -219,49 +219,49 @@ static void HandleInputChooseAction(void) } else if (gMain.newKeys & DPAD_LEFT) { - if (gActionSelectionCursor[gActiveBank] & 1) + if (gActionSelectionCursor[gActiveBattler] & 1) { PlaySE(SE_SELECT); - ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]); - gActionSelectionCursor[gActiveBank] ^= 1; - ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0); + ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); + gActionSelectionCursor[gActiveBattler] ^= 1; + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } else if (gMain.newKeys & DPAD_RIGHT) { - if (!(gActionSelectionCursor[gActiveBank] & 1)) + if (!(gActionSelectionCursor[gActiveBattler] & 1)) { PlaySE(SE_SELECT); - ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]); - gActionSelectionCursor[gActiveBank] ^= 1; - ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0); + ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); + gActionSelectionCursor[gActiveBattler] ^= 1; + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } else if (gMain.newKeys & DPAD_UP) { - if (gActionSelectionCursor[gActiveBank] & 2) + if (gActionSelectionCursor[gActiveBattler] & 2) { PlaySE(SE_SELECT); - ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]); - gActionSelectionCursor[gActiveBank] ^= 2; - ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0); + ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); + gActionSelectionCursor[gActiveBattler] ^= 2; + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } else if (gMain.newKeys & DPAD_DOWN) { - if (!(gActionSelectionCursor[gActiveBank] & 2)) + if (!(gActionSelectionCursor[gActiveBattler] & 2)) { PlaySE(SE_SELECT); - ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBank]); - gActionSelectionCursor[gActiveBank] ^= 2; - ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0); + ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); + gActionSelectionCursor[gActiveBattler] ^= 2; + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); } } } static void CompleteOnBankSpriteCallbackDummy(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) SafariBufferExecCompleted(); } @@ -273,7 +273,7 @@ static void CompleteOnInactiveTextPrinter(void) static void CompleteOnHealthboxSpriteCallbackDummy(void) { - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) SafariBufferExecCompleted(); } @@ -289,7 +289,7 @@ static void sub_81595E4(void) static void CompleteOnSpecialAnimDone(void) { - if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gDoingBattleAnim || !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) SafariBufferExecCompleted(); } @@ -297,7 +297,7 @@ static void SafariOpenPokeblockCase(void) { if (!gPaletteFade.active) { - gBattleBankFunc[gActiveBank] = CompleteWhenChosePokeblock; + gBattlerFuncs[gActiveBattler] = CompleteWhenChosePokeblock; FreeAllWindowBuffers(); OpenPokeblockCaseInBattle(); } @@ -314,29 +314,29 @@ static void CompleteWhenChosePokeblock(void) static void CompleteOnFinishedBattleAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive) SafariBufferExecCompleted(); } static void SafariBufferExecCompleted(void) { - gBattleBankFunc[gActiveBank] = SafariBufferRunCommand; + gBattlerFuncs[gActiveBattler] = SafariBufferRunCommand; if (gBattleTypeFlags & BATTLE_TYPE_LINK) { u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBank][0] = CONTROLLER_TERMINATOR_NOP; + gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { - gBattleExecBuffer &= ~gBitTable[gActiveBank]; + gBattleExecBuffer &= ~gBitTable[gActiveBattler]; } } static void CompleteOnFinishedStatusAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) SafariBufferExecCompleted(); } @@ -377,18 +377,18 @@ static void SafariHandleReturnMonToBall(void) static void SafariHandleDrawTrainerPic(void) { - DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBank); - sub_806A12C(gSaveBlock2Ptr->playerGender, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite( + DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, gActiveBattler); + sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite( &gUnknown_0202499C, 80, (8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80, 30); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; } static void SafariHandleTrainerSlide(void) @@ -415,18 +415,18 @@ static void SafariHandleSuccessBallThrowAnim(void) { gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); - gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); + gBattlerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone; } static void SafariHandleBallThrowAnim(void) { - u8 ballThrowCaseId = gBattleBufferA[gActiveBank][1]; + u8 ballThrowCaseId = gBattleBufferA[gActiveBattler][1]; gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); - gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); + gBattlerFuncs[gActiveBattler] = CompleteOnSpecialAnimDone; } static void SafariHandlePause(void) @@ -445,15 +445,15 @@ static void SafariHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBank][2]); + stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); - gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; } static void SafariHandlePrintSelectionString(void) { - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) SafariHandlePrintString(); else SafariBufferExecCompleted(); @@ -465,7 +465,7 @@ static void HandleChooseActionAfterDma3(void) { gBattle_BG0_X = 0; gBattle_BG0_Y = 160; - gBattleBankFunc[gActiveBank] = HandleInputChooseAction; + gBattlerFuncs[gActiveBattler] = HandleInputChooseAction; } } @@ -473,13 +473,13 @@ static void SafariHandleChooseAction(void) { s32 i; - gBattleBankFunc[gActiveBank] = HandleChooseActionAfterDma3; + gBattlerFuncs[gActiveBattler] = HandleChooseActionAfterDma3; BattleHandleAddTextPrinter(gText_SafariZoneMenu, 2); for (i = 0; i < 4; i++) ActionSelectionDestroyCursorAt(i); - ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0); + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillPkmnDo2); BattleHandleAddTextPrinter(gDisplayedStringBattle, 1); } @@ -499,8 +499,8 @@ static void SafariHandleChooseItem(void) s32 i; BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - gBattleBankFunc[gActiveBank] = SafariOpenPokeblockCase; - gBankInMenu = gActiveBank; + gBattlerFuncs[gActiveBattler] = SafariOpenPokeblockCase; + gBankInMenu = gActiveBattler; } static void SafariHandleChoosePokemon(void) @@ -525,7 +525,7 @@ static void SafariHandleExpUpdate(void) static void SafariHandleStatusIconUpdate(void) { - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_SAFARI_BALLS_TEXT); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_SAFARI_BALLS_TEXT); SafariBufferExecCompleted(); } @@ -613,25 +613,25 @@ static void SafariHandlePlaySE(void) { s8 pan; - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) pan = PAN_SIDE_PLAYER; else pan = PAN_SIDE_OPPONENT; - PlaySE12WithPanning(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8), pan); + PlaySE12WithPanning(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8), pan); SafariBufferExecCompleted(); } static void SafariHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBank][3]) + if (gBattleBufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } SafariBufferExecCompleted(); @@ -639,7 +639,7 @@ static void SafariHandlePlayFanfareOrBGM(void) static void SafariHandleFaintingCry(void) { - u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); PlayCry1(species, 25); SafariBufferExecCompleted(); @@ -647,17 +647,17 @@ static void SafariHandleFaintingCry(void) static void SafariHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBank][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gUnknown_020243FC |= 1; SafariBufferExecCompleted(); } static void SafariHandleIntroTrainerBallThrow(void) { - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_SAFARI_ALL_TEXT); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); - gBattleBankFunc[gActiveBank] = CompleteOnHealthboxSpriteCallbackDummy; + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_SAFARI_ALL_TEXT); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); + gBattlerFuncs[gActiveBattler] = CompleteOnHealthboxSpriteCallbackDummy; } static void SafariHandleDrawPartyStatusSummary(void) @@ -682,13 +682,13 @@ static void SafariHandleSpriteInvisibility(void) static void SafariHandleBattleAnimation(void) { - u8 animationId = gBattleBufferA[gActiveBank][1]; - u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + u8 animationId = gBattleBufferA[gActiveBattler][1]; + u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) SafariBufferExecCompleted(); else - gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; } static void SafariHandleLinkStandbyMsg(void) @@ -703,12 +703,12 @@ static void SafariHandleResetActionMoveSelection(void) static void SafariHandleCmd55(void) { - gBattleOutcome = gBattleBufferA[gActiveBank][1]; + gBattleOutcome = gBattleBufferA[gActiveBattler][1]; FadeOutMapMusic(5); BeginFastPaletteFade(3); SafariBufferExecCompleted(); if ((gBattleTypeFlags & BATTLE_TYPE_LINK) && !(gBattleTypeFlags & BATTLE_TYPE_WILD)) - gBattleBankFunc[gActiveBank] = sub_81595E4; + gBattlerFuncs[gActiveBattler] = sub_81595E4; } static void nullsub_115(void) diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 11fb0074f..d12a0a907 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -29,26 +29,26 @@ #include "party_menu.h" extern u32 gBattleExecBuffer; -extern u8 gActiveBank; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; -extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gAbsentBankFlags; -extern u8 gBattleBanksCount; +extern u8 gActiveBattler; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; +extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gAbsentBattlerFlags; +extern u8 gBattlersCount; extern bool8 gDoingBattleAnim; -extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; +extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gMultiUsePlayerCursor; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern u16 gPartnerTrainerId; extern struct SpriteTemplate gUnknown_0202499C; -extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; +extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gSpecialVar_ItemId; -extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern u8 gBattleOutcome; extern u8 gNumberOfMovesToChoose; extern u16 gBattle_BG0_X; @@ -56,7 +56,7 @@ extern u16 gBattle_BG0_Y; extern s32 gUnknown_0203CD70; extern u8 gBankInMenu; extern u32 gBattlePalaceMoveSelectionRngValue; -extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; +extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern u8 gUnknown_020244B4[]; extern u16 gUnknown_020243FC; extern struct UnusedControllerStruct gUnknown_02022D0C; @@ -204,7 +204,7 @@ static void nullsub_117(void) void SetControllerToWally(void) { - gBattleBankFunc[gActiveBank] = WallyBufferRunCommand; + gBattlerFuncs[gActiveBattler] = WallyBufferRunCommand; gBattleStruct->wallyBattleState = 0; gBattleStruct->wallyMovesState = 0; gBattleStruct->wallyWaitFrames = 0; @@ -213,10 +213,10 @@ void SetControllerToWally(void) static void WallyBufferRunCommand(void) { - if (gBattleExecBuffer & gBitTable[gActiveBank]) + if (gBattleExecBuffer & gBitTable[gActiveBattler]) { - if (gBattleBufferA[gActiveBank][0] < ARRAY_COUNT(sWallyBufferCommands)) - sWallyBufferCommands[gBattleBufferA[gActiveBank][0]](); + if (gBattleBufferA[gActiveBattler][0] < ARRAY_COUNT(sWallyBufferCommands)) + sWallyBufferCommands[gBattleBufferA[gActiveBattler][0]](); else WallyBufferExecCompleted(); } @@ -284,7 +284,7 @@ static void WallyHandleActions(void) static void CompleteOnBankSpriteCallbackDummy(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) WallyBufferExecCompleted(); } @@ -304,7 +304,7 @@ static void OpenBagAfterPaletteFade(void) { if (!gPaletteFade.active) { - gBattleBankFunc[gActiveBank] = CompleteOnChosenItem; + gBattlerFuncs[gActiveBattler] = CompleteOnChosenItem; nullsub_35(); FreeAllWindowBuffers(); DoWallyTutorialBagMenu(); @@ -322,30 +322,30 @@ static void CompleteOnChosenItem(void) static void sub_816864C(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive) - sub_8172EF0(gActiveBank, &gPlayerParty[gBattlePartyID[gActiveBank]]); - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive) - sub_8172EF0(gActiveBank ^ BIT_MON, &gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]]); + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive) + sub_8172EF0(gActiveBattler, &gPlayerParty[gBattlePartyID[gActiveBattler]]); + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) + sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]]); - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].ballAnimActive - && gSprites[gUnknown_03005D7C[gActiveBank]].callback == SpriteCallbackDummy - && gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive + && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive + && gSprites[gUnknown_03005D7C[gActiveBattler]].callback == SpriteCallbackDummy + && gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank ^ BIT_MON]]); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank ^ BIT_MON], &gPlayerParty[gBattlePartyID[gActiveBank ^ BIT_MON]], HEALTHBOX_ALL); - sub_8076918(gActiveBank ^ BIT_MON); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank ^ BIT_MON]); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK], &gPlayerParty[gBattlePartyID[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler ^ BIT_FLANK); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler ^ BIT_FLANK]); } - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBank]]); - UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBank], &gPlayerParty[gBattlePartyID[gActiveBank]], HEALTHBOX_ALL); - sub_8076918(gActiveBank); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler]]); + UpdateHealthboxAttribute(gHealthBoxesIds[gActiveBattler], &gPlayerParty[gBattlePartyID[gActiveBattler]], HEALTHBOX_ALL); + sub_8076918(gActiveBattler); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); gBattleSpritesDataPtr->animationData->field_9_x1 = 0; - gBattleBankFunc[gActiveBank] = sub_8168818; + gBattlerFuncs[gActiveBattler] = sub_8168818; } } @@ -354,23 +354,23 @@ static void sub_8168818(void) { bool32 r4 = FALSE; - if (gSprites[gHealthBoxesIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gHealthBoxesIds[gActiveBattler]].callback == SpriteCallbackDummy) r4 = TRUE; - if (r4 && gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 - && gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1) + if (r4 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 + && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].flag_x80 = 0; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank ^ BIT_MON].field_1_x1 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); CreateTask(c3_0802FDF4, 10); - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); WallyBufferExecCompleted(); } @@ -378,24 +378,24 @@ static void sub_8168818(void) static void CompleteOnHealthbarDone(void) { - s16 hpValue = sub_8074AA0(gActiveBank, gHealthBoxesIds[gActiveBank], HEALTH_BAR, 0); + s16 hpValue = sub_8074AA0(gActiveBattler, gHealthBoxesIds[gActiveBattler], HEALTH_BAR, 0); - SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBank]); + SetHealthboxSpriteVisible(gHealthBoxesIds[gActiveBattler]); if (hpValue != -1) { - UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBank], hpValue, HP_CURRENT); + UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], hpValue, HP_CURRENT); } else { - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); WallyBufferExecCompleted(); } } static void DoHitAnimBlinkSpriteEffect(void) { - u8 spriteId = gBankSpriteIds[gActiveBank]; + u8 spriteId = gBankSpriteIds[gActiveBattler]; if (gSprites[spriteId].data[1] == 32) { @@ -414,46 +414,46 @@ static void DoHitAnimBlinkSpriteEffect(void) static void sub_8168A20(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); WallyBufferExecCompleted(); } } static void CompleteOnBankSpriteCallbackDummy2(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].callback == SpriteCallbackDummy) + if (gSprites[gBankSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) WallyBufferExecCompleted(); } static void CompleteOnFinishedBattleAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animFromTableActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animFromTableActive) WallyBufferExecCompleted(); } static void WallyBufferExecCompleted(void) { - gBattleBankFunc[gActiveBank] = WallyBufferRunCommand; + gBattlerFuncs[gActiveBattler] = WallyBufferRunCommand; if (gBattleTypeFlags & BATTLE_TYPE_LINK) { u8 playerId = GetMultiplayerId(); PrepareBufferDataTransferLink(2, 4, &playerId); - gBattleBufferA[gActiveBank][0] = CONTROLLER_TERMINATOR_NOP; + gBattleBufferA[gActiveBattler][0] = CONTROLLER_TERMINATOR_NOP; } else { - gBattleExecBuffer &= ~gBitTable[gActiveBank]; + gBattleExecBuffer &= ~gBitTable[gActiveBattler]; } } static void CompleteOnFinishedStatusAnimation(void) { - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive) WallyBufferExecCompleted(); } @@ -464,13 +464,13 @@ static void WallyHandleGetMonData(void) u8 monToCheck; s32 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - size += CopyWallyMonData(gBattlePartyID[gActiveBank], monData); + size += CopyWallyMonData(gBattlePartyID[gActiveBattler], monData); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -492,7 +492,7 @@ static u32 CopyWallyMonData(u8 monId, u8 *dst) u32 data32; s32 size = 0; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: battleMon.species = GetMonData(&gPlayerParty[monId], MON_DATA_SPECIES); @@ -558,7 +558,7 @@ static u32 CopyWallyMonData(u8 monId, u8 *dst) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE); + data16 = GetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE); dst[0] = data16; dst[1] = data16 >> 8; size = 2; @@ -573,7 +573,7 @@ static u32 CopyWallyMonData(u8 monId, u8 *dst) case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE); + dst[0] = GetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE); size = 1; break; case REQUEST_OTID_BATTLE: @@ -798,13 +798,13 @@ static void WallyHandleSetMonData(void) u8 monToCheck; u8 i; - if (gBattleBufferA[gActiveBank][2] == 0) + if (gBattleBufferA[gActiveBattler][2] == 0) { - SetWallyMonData(gBattlePartyID[gActiveBank]); + SetWallyMonData(gBattlePartyID[gActiveBattler]); } else { - monToCheck = gBattleBufferA[gActiveBank][2]; + monToCheck = gBattleBufferA[gActiveBattler][2]; for (i = 0; i < 6; i++) { if (monToCheck & 1) @@ -817,11 +817,11 @@ static void WallyHandleSetMonData(void) static void SetWallyMonData(u8 monId) { - struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBank][3]; - struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBank][3]; + struct BattlePokemon *battlePokemon = (struct BattlePokemon *)&gBattleBufferA[gActiveBattler][3]; + struct MovePpInfo *moveData = (struct MovePpInfo *)&gBattleBufferA[gActiveBattler][3]; s32 i; - switch (gBattleBufferA[gActiveBank][1]) + switch (gBattleBufferA[gActiveBattler][1]) { case REQUEST_ALL_BATTLE: { @@ -862,10 +862,10 @@ static void SetWallyMonData(u8 monId) } break; case REQUEST_SPECIES_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPECIES, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HELDITEM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HELD_ITEM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MOVES_PP_BATTLE: for (i = 0; i < 4; i++) @@ -879,158 +879,158 @@ static void SetWallyMonData(u8 monId) case REQUEST_MOVE2_BATTLE: case REQUEST_MOVE3_BATTLE: case REQUEST_MOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBank][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MOVE1 + gBattleBufferA[gActiveBattler][1] - REQUEST_MOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PP_DATA_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBank][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP2, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP3, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP4, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP_BONUSES, &gBattleBufferA[gActiveBattler][7]); break; case REQUEST_PPMOVE1_BATTLE: case REQUEST_PPMOVE2_BATTLE: case REQUEST_PPMOVE3_BATTLE: case REQUEST_PPMOVE4_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBank][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PP1 + gBattleBufferA[gActiveBattler][1] - REQUEST_PPMOVE1_BATTLE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_OTID_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_OT_ID, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_EXP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_EXP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_EV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_EV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_FRIENDSHIP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_FRIENDSHIP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKERUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKERUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LOCATION_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LOCATION, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MET_GAME_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MET_GAME, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_POKEBALL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_POKEBALL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ALL_IVS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][4]); - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][5]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][6]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][7]); - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][8]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][4]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][5]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][6]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][7]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][8]); break; case REQUEST_HP_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_IV_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF_IV, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_PERSONALITY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_PERSONALITY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CHECKSUM_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CHECKSUM, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_STATUS_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_STATUS, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_LEVEL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_LEVEL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_MAX_HP_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_MAX_HP, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_ATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_ATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_DEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_DEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPEED_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPEED, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPATK_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPATK, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SPDEF_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SPDEF, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SHEEN_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SHEEN, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_COOL_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_COOL_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_BEAUTY_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_BEAUTY_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_CUTE_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_CUTE_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_SMART_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_SMART_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; case REQUEST_TOUGH_RIBBON_BATTLE: - SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBank][3]); + SetMonData(&gPlayerParty[monId], MON_DATA_TOUGH_RIBBON, &gBattleBufferA[gActiveBattler][3]); break; } - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); } static void WallyHandleSetRawMonData(void) @@ -1050,48 +1050,48 @@ static void WallyHandleSwitchInAnim(void) static void WallyHandleReturnMonToBall(void) { - if (gBattleBufferA[gActiveBank][1] == 0) + if (gBattleBufferA[gActiveBattler][1] == 0) { - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SWITCH_OUT_PLAYER_MON); - gBattleBankFunc[gActiveBank] = sub_8168A20; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SWITCH_OUT_PLAYER_MON); + gBattlerFuncs[gActiveBattler] = sub_8168A20; } else { - FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBank]]); - DestroySprite(&gSprites[gBankSpriteIds[gActiveBank]]); - SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBank]); + FreeSpriteOamMatrix(&gSprites[gBankSpriteIds[gActiveBattler]]); + DestroySprite(&gSprites[gBankSpriteIds[gActiveBattler]]); + SetHealthboxSpriteInvisible(gHealthBoxesIds[gActiveBattler]); WallyBufferExecCompleted(); } } static void WallyHandleDrawTrainerPic(void) { - DecompressTrainerBackPic(BACK_PIC_WALLY, gActiveBank); - sub_806A12C(BACK_PIC_WALLY, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, + DecompressTrainerBackPic(BACK_PIC_WALLY, gActiveBattler); + sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, 80, 80 + 4 * (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords), 30); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = 240; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = -2; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = 240; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = -2; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy; } static void WallyHandleTrainerSlide(void) { - DecompressTrainerBackPic(BACK_PIC_WALLY, gActiveBank); - sub_806A12C(BACK_PIC_WALLY, GetBankPosition(gActiveBank)); - gBankSpriteIds[gActiveBank] = CreateSprite(&gUnknown_0202499C, + DecompressTrainerBackPic(BACK_PIC_WALLY, gActiveBattler); + sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(gActiveBattler)); + gBankSpriteIds[gActiveBattler] = CreateSprite(&gUnknown_0202499C, 80, 80 + 4 * (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords), 30); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = gActiveBank; - gSprites[gBankSpriteIds[gActiveBank]].pos2.x = -96; - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 2; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_805D7AC; - gBattleBankFunc[gActiveBank] = CompleteOnBankSpriteCallbackDummy2; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = gActiveBattler; + gSprites[gBankSpriteIds[gActiveBattler]].pos2.x = -96; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 2; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_805D7AC; + gBattlerFuncs[gActiveBattler] = CompleteOnBankSpriteCallbackDummy2; } static void WallyHandleTrainerSlideBack(void) @@ -1113,18 +1113,18 @@ static void WallyHandleSuccessBallThrowAnim(void) { gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); - gBattleBankFunc[gActiveBank] = CompleteOnFinishedAnimation; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedAnimation; } static void WallyHandleBallThrowAnim(void) { - u8 ballThrowCaseId = gBattleBufferA[gActiveBank][1]; + u8 ballThrowCaseId = gBattleBufferA[gActiveBattler][1]; gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); - gBattleBankFunc[gActiveBank] = CompleteOnFinishedAnimation; + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedAnimation; } static void WallyHandlePause(void) @@ -1134,46 +1134,46 @@ static void WallyHandlePause(void) static void WallyHandleMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - gAnimMoveTurn = gBattleBufferA[gActiveBank][3]; - gAnimMovePower = gBattleBufferA[gActiveBank][4] | (gBattleBufferA[gActiveBank][5] << 8); - gAnimMoveDmg = gBattleBufferA[gActiveBank][6] | (gBattleBufferA[gActiveBank][7] << 8) | (gBattleBufferA[gActiveBank][8] << 16) | (gBattleBufferA[gActiveBank][9] << 24); - gAnimFriendship = gBattleBufferA[gActiveBank][10]; - gWeatherMoveAnim = gBattleBufferA[gActiveBank][12] | (gBattleBufferA[gActiveBank][13] << 8); - gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBank][16]; - gTransformedPersonalities[gActiveBank] = gAnimDisableStructPtr->transformedMonPersonality; + gAnimMoveTurn = gBattleBufferA[gActiveBattler][3]; + gAnimMovePower = gBattleBufferA[gActiveBattler][4] | (gBattleBufferA[gActiveBattler][5] << 8); + gAnimMoveDmg = gBattleBufferA[gActiveBattler][6] | (gBattleBufferA[gActiveBattler][7] << 8) | (gBattleBufferA[gActiveBattler][8] << 16) | (gBattleBufferA[gActiveBattler][9] << 24); + gAnimFriendship = gBattleBufferA[gActiveBattler][10]; + gWeatherMoveAnim = gBattleBufferA[gActiveBattler][12] | (gBattleBufferA[gActiveBattler][13] << 8); + gAnimDisableStructPtr = (struct DisableStruct *)&gBattleBufferA[gActiveBattler][16]; + gTransformedPersonalities[gActiveBattler] = gAnimDisableStructPtr->transformedMonPersonality; if (IsMoveWithoutAnimation(move, gAnimMoveTurn)) // always returns FALSE { WallyBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; - gBattleBankFunc[gActiveBank] = WallyDoMoveAnimation; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; + gBattlerFuncs[gActiveBattler] = WallyDoMoveAnimation; } } static void WallyDoMoveAnimation(void) { - u16 move = gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8); + u16 move = gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8); - switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState) + switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) { - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_SUBSTITUTE_TO_MON); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; break; case 1: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { sub_805EB9C(0); DoMoveAnim(move); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 2; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 2; } break; case 2: @@ -1181,19 +1181,19 @@ static void WallyDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBank].behindSubstitute) + if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) { - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, gActiveBank, B_ANIM_MON_TO_SUBSTITUTE); + InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); } - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 3; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } break; case 3: - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBank].specialAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].specialAnimActive) { CopyAllBattleSpritesInvisibilities(); - TrySetBehindSubstituteSpriteBit(gActiveBank, gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].animationState = 0; + TrySetBehindSubstituteSpriteBit(gActiveBattler, gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 0; WallyBufferExecCompleted(); } break; @@ -1206,15 +1206,15 @@ static void WallyHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - stringId = (u16*)(&gBattleBufferA[gActiveBank][2]); + stringId = (u16*)(&gBattleBufferA[gActiveBattler][2]); BufferStringBattle(*stringId); BattleHandleAddTextPrinter(gDisplayedStringBattle, 0); - gBattleBankFunc[gActiveBank] = CompleteOnInactiveTextPrinter; + gBattlerFuncs[gActiveBattler] = CompleteOnInactiveTextPrinter; } static void WallyHandlePrintSelectionString(void) { - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) WallyHandlePrintString(); else WallyBufferExecCompleted(); @@ -1226,7 +1226,7 @@ static void HandleChooseActionAfterDma3(void) { gBattle_BG0_X = 0; gBattle_BG0_Y = 160; - gBattleBankFunc[gActiveBank] = WallyHandleActions; + gBattlerFuncs[gActiveBattler] = WallyHandleActions; } } @@ -1234,13 +1234,13 @@ static void WallyHandleChooseAction(void) { s32 i; - gBattleBankFunc[gActiveBank] = HandleChooseActionAfterDma3; + gBattlerFuncs[gActiveBattler] = HandleChooseActionAfterDma3; BattleHandleAddTextPrinter(gText_BattleMenu, 2); for (i = 0; i < 4; i++) ActionSelectionDestroyCursorAt(i); - ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBank], 0); + ActionSelectionCreateCursorAt(gActionSelectionCursor[gActiveBattler], 0); BattleStringExpandPlaceholdersToDisplayedString(gText_WhatWillWallyDo); BattleHandleAddTextPrinter(gDisplayedStringBattle, 1); } @@ -1281,8 +1281,8 @@ static void WallyHandleChooseMove(void) static void WallyHandleChooseItem(void) { BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); - gBattleBankFunc[gActiveBank] = OpenBagAfterPaletteFade; - gBankInMenu = gActiveBank; + gBattlerFuncs[gActiveBattler] = OpenBagAfterPaletteFade; + gBankInMenu = gActiveBattler; } static void WallyHandleChoosePokemon(void) @@ -1300,24 +1300,24 @@ static void WallyHandleHealthBarUpdate(void) s16 hpVal; LoadBattleBarGfx(0); - hpVal = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + hpVal = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); if (hpVal != INSTANT_HP_BAR_DROP) { - u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); - u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_HP); + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); + u32 curHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, curHP, hpVal); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, curHP, hpVal); } else { - u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_MAX_HP); + u32 maxHP = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_MAX_HP); - SetBattleBarStruct(gActiveBank, gHealthBoxesIds[gActiveBank], maxHP, 0, hpVal); - UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBank], 0, HP_CURRENT); + SetBattleBarStruct(gActiveBattler, gHealthBoxesIds[gActiveBattler], maxHP, 0, hpVal); + UpdateHpTextInHealthbox(gHealthBoxesIds[gActiveBattler], 0, HP_CURRENT); } - gBattleBankFunc[gActiveBank] = CompleteOnHealthbarDone; + gBattlerFuncs[gActiveBattler] = CompleteOnHealthbarDone; } static void WallyHandleExpUpdate(void) @@ -1402,16 +1402,16 @@ static void WallyHandleCmd40(void) static void WallyHandleHitAnimation(void) { - if (gSprites[gBankSpriteIds[gActiveBank]].invisible == TRUE) + if (gSprites[gBankSpriteIds[gActiveBattler]].invisible == TRUE) { WallyBufferExecCompleted(); } else { gDoingBattleAnim = TRUE; - gSprites[gBankSpriteIds[gActiveBank]].data[1] = 0; - DoHitAnimHealthboxEffect(gActiveBank); - gBattleBankFunc[gActiveBank] = DoHitAnimBlinkSpriteEffect; + gSprites[gBankSpriteIds[gActiveBattler]].data[1] = 0; + DoHitAnimHealthboxEffect(gActiveBattler); + gBattlerFuncs[gActiveBattler] = DoHitAnimBlinkSpriteEffect; } } @@ -1422,20 +1422,20 @@ static void WallyHandleCmd42(void) static void WallyHandlePlaySE(void) { - PlaySE(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlaySE(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); WallyBufferExecCompleted(); } static void WallyHandlePlayFanfareOrBGM(void) { - if (gBattleBufferA[gActiveBank][3]) + if (gBattleBufferA[gActiveBattler][3]) { BattleStopLowHpSound(); - PlayBGM(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayBGM(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } else { - PlayFanfare(gBattleBufferA[gActiveBank][1] | (gBattleBufferA[gActiveBank][2] << 8)); + PlayFanfare(gBattleBufferA[gActiveBattler][1] | (gBattleBufferA[gActiveBattler][2] << 8)); } WallyBufferExecCompleted(); @@ -1443,7 +1443,7 @@ static void WallyHandlePlayFanfareOrBGM(void) static void WallyHandleFaintingCry(void) { - u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES); + u16 species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES); PlayCry1(species, 25); WallyBufferExecCompleted(); @@ -1451,7 +1451,7 @@ static void WallyHandleFaintingCry(void) static void WallyHandleIntroSlide(void) { - HandleIntroSlide(gBattleBufferA[gActiveBank][1]); + HandleIntroSlide(gBattleBufferA[gActiveBattler][1]); gUnknown_020243FC |= 1; WallyBufferExecCompleted(); } @@ -1461,29 +1461,29 @@ static void WallyHandleIntroTrainerBallThrow(void) u8 paletteNum; u8 taskId; - oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBank]]); + oamt_add_pos2_onto_pos1(&gSprites[gBankSpriteIds[gActiveBattler]]); - gSprites[gBankSpriteIds[gActiveBank]].data[0] = 50; - gSprites[gBankSpriteIds[gActiveBank]].data[2] = -40; - gSprites[gBankSpriteIds[gActiveBank]].data[4] = gSprites[gBankSpriteIds[gActiveBank]].pos1.y; - gSprites[gBankSpriteIds[gActiveBank]].callback = sub_80A6EEC; - gSprites[gBankSpriteIds[gActiveBank]].data[5] = gActiveBank; + gSprites[gBankSpriteIds[gActiveBattler]].data[0] = 50; + gSprites[gBankSpriteIds[gActiveBattler]].data[2] = -40; + gSprites[gBankSpriteIds[gActiveBattler]].data[4] = gSprites[gBankSpriteIds[gActiveBattler]].pos1.y; + gSprites[gBankSpriteIds[gActiveBattler]].callback = sub_80A6EEC; + gSprites[gBankSpriteIds[gActiveBattler]].data[5] = gActiveBattler; - StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBank]], sub_805CC00); - StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBank]], 1); + StoreSpriteCallbackInData6(&gSprites[gBankSpriteIds[gActiveBattler]], sub_805CC00); + StartSpriteAnim(&gSprites[gBankSpriteIds[gActiveBattler]], 1); paletteNum = AllocSpritePalette(0xD6F8); LoadCompressedPalette(gTrainerBackPicPaletteTable[BACK_PIC_WALLY].data, 0x100 + paletteNum * 16, 32); - gSprites[gBankSpriteIds[gActiveBank]].oam.paletteNum = paletteNum; + gSprites[gBankSpriteIds[gActiveBattler]].oam.paletteNum = paletteNum; taskId = CreateTask(sub_816AC04, 5); - gTasks[taskId].data[0] = gActiveBank; + gTasks[taskId].data[0] = gActiveBattler; - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1) - gTasks[gUnknown_020244B4[gActiveBank]].func = sub_8073C30; + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1) + gTasks[gUnknown_020244B4[gActiveBattler]].func = sub_8073C30; gBattleSpritesDataPtr->animationData->field_9_x1 = 1; - gBattleBankFunc[gActiveBank] = nullsub_21; + gBattlerFuncs[gActiveBattler] = nullsub_21; } static void sub_816AA80(u8 bank) @@ -1494,7 +1494,7 @@ static void sub_816AA80(u8 bank) gBattlePartyID[bank] = gBattleBufferA[bank][1]; species = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); - sub_806A068(species, GetBankPosition(bank)); + sub_806A068(species, GetBattlerPosition(bank)); gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBankCoord(bank, 2), GetBankSpriteDefault_Y(bank), @@ -1521,27 +1521,27 @@ static void sub_816AC04(u8 taskId) } else { - u8 savedActiveBank = gActiveBank; + u8 savedActiveBank = gActiveBattler; - gActiveBank = gTasks[taskId].data[0]; - gBattleBufferA[gActiveBank][1] = gBattlePartyID[gActiveBank]; - sub_816AA80(gActiveBank); - gBattleBankFunc[gActiveBank] = sub_816864C; - gActiveBank = savedActiveBank; + gActiveBattler = gTasks[taskId].data[0]; + gBattleBufferA[gActiveBattler][1] = gBattlePartyID[gActiveBattler]; + sub_816AA80(gActiveBattler); + gBattlerFuncs[gActiveBattler] = sub_816864C; + gActiveBattler = savedActiveBank; DestroyTask(taskId); } } static void WallyHandleDrawPartyStatusSummary(void) { - if (gBattleBufferA[gActiveBank][1] != 0 && GetBankSide(gActiveBank) == SIDE_PLAYER) + if (gBattleBufferA[gActiveBattler][1] != 0 && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { WallyBufferExecCompleted(); } else { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].flag_x1 = 1; - gUnknown_020244B4[gActiveBank] = CreatePartyStatusSummarySprites(gActiveBank, (struct HpAndStatus *)&gBattleBufferA[gActiveBank][4], gBattleBufferA[gActiveBank][1], gBattleBufferA[gActiveBank][2]); + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].flag_x1 = 1; + gUnknown_020244B4[gActiveBattler] = CreatePartyStatusSummarySprites(gActiveBattler, (struct HpAndStatus *)&gBattleBufferA[gActiveBattler][4], gBattleBufferA[gActiveBattler][1], gBattleBufferA[gActiveBattler][2]); WallyBufferExecCompleted(); } } @@ -1563,13 +1563,13 @@ static void WallyHandleSpriteInvisibility(void) static void WallyHandleBattleAnimation(void) { - u8 animationId = gBattleBufferA[gActiveBank][1]; - u16 argument = gBattleBufferA[gActiveBank][2] | (gBattleBufferA[gActiveBank][3] << 8); + u8 animationId = gBattleBufferA[gActiveBattler][1]; + u16 argument = gBattleBufferA[gActiveBattler][2] | (gBattleBufferA[gActiveBattler][3] << 8); - if (TryHandleLaunchBattleTableAnimation(gActiveBank, gActiveBank, gActiveBank, animationId, argument)) + if (TryHandleLaunchBattleTableAnimation(gActiveBattler, gActiveBattler, gActiveBattler, animationId, argument)) WallyBufferExecCompleted(); else - gBattleBankFunc[gActiveBank] = CompleteOnFinishedBattleAnimation; + gBattlerFuncs[gActiveBattler] = CompleteOnFinishedBattleAnimation; } static void WallyHandleLinkStandbyMsg(void) @@ -1584,13 +1584,13 @@ static void WallyHandleResetActionMoveSelection(void) static void WallyHandleCmd55(void) { - gBattleOutcome = gBattleBufferA[gActiveBank][1]; + gBattleOutcome = gBattleBufferA[gActiveBattler][1]; FadeOutMapMusic(5); BeginFastPaletteFade(3); WallyBufferExecCompleted(); if (!(gBattleTypeFlags & BATTLE_TYPE_WILD) && gBattleTypeFlags & BATTLE_TYPE_LINK) - gBattleBankFunc[gActiveBank] = sub_80587B0; + gBattlerFuncs[gActiveBattler] = sub_80587B0; } static void nullsub_118(void) diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 499d816be..aafc106aa 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -15,28 +15,28 @@ extern u32 gBattleTypeFlags; extern u32 gBattleExecBuffer; extern void (*gBattleMainFunc)(void); -extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); -extern u8 gBankPositions[BATTLE_BANKS_COUNT]; -extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gBattleBanksCount; -extern u8 gActiveBank; +extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); +extern u8 gBattlerPositions[MAX_BATTLERS_COUNT]; +extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gBattlersCount; +extern u8 gActiveBattler; extern u8 gUnknown_0202428C; extern u32 gUnknown_02022FF4; extern u8 gUnknown_0203C7B4; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBuffersTransferData[0x100]; extern u8 gUnknown_02022D08; extern u8 gUnknown_02022D09; extern u8 gUnknown_02022D0A; -extern u8 gBankAttacker; -extern u8 gBankDefender; -extern u8 gAbsentBankFlags; +extern u8 gBattleAttacker; +extern u8 gBattleDefender; +extern u8 gAbsentBattlerFlags; extern u8 gEffectBank; extern u16 gBattleWeather; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern u16 gCurrentMove; extern u16 gChosenMove; extern u16 gLastUsedItem; @@ -76,10 +76,10 @@ void SetUpBattleVarsAndBirchZigzagoon(void) gBattleMainFunc = nullsub_20; - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { - gBattleBankFunc[i] = nullsub_21; - gBankPositions[i] = 0xFF; + gBattlerFuncs[i] = nullsub_21; + gBattlerPositions[i] = 0xFF; gActionSelectionCursor[i] = 0; gMoveSelectionCursor[i] = 0; } @@ -124,7 +124,7 @@ void sub_8032768(void) if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) sub_81B8D64(i, 0); } @@ -145,34 +145,34 @@ static void SetControllersVariables(void) if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { - gBattleBankFunc[0] = SetControllerToRecordedPlayer; - gBankPositions[0] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[0] = SetControllerToRecordedPlayer; + gBattlerPositions[0] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[1] = SetControllerToOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - gBattleBankFunc[2] = SetControllerToPlayerPartner; - gBankPositions[2] = B_POSITION_PLAYER_RIGHT; + gBattlerFuncs[2] = SetControllerToPlayerPartner; + gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT; - gBattleBankFunc[3] = SetControllerToOpponent; - gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; + gBattlerFuncs[3] = SetControllerToOpponent; + gBattlerPositions[3] = B_POSITION_OPPONENT_RIGHT; } else { - gBattleBankFunc[0] = SetControllerToPlayer; - gBankPositions[0] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[0] = SetControllerToPlayer; + gBattlerPositions[0] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[1] = SetControllerToOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - gBattleBankFunc[2] = SetControllerToPlayerPartner; - gBankPositions[2] = B_POSITION_PLAYER_RIGHT; + gBattlerFuncs[2] = SetControllerToPlayerPartner; + gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT; - gBattleBankFunc[3] = SetControllerToOpponent; - gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; + gBattlerFuncs[3] = SetControllerToOpponent; + gBattlerPositions[3] = B_POSITION_OPPONENT_RIGHT; } - gBattleBanksCount = 4; + gBattlersCount = 4; sub_81B8D64(0, 0); sub_81B8D64(1, 0); @@ -189,18 +189,18 @@ static void SetControllersVariables(void) gBattleMainFunc = BeginBattleIntro; if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) - gBattleBankFunc[0] = SetControllerToSafari; + gBattlerFuncs[0] = SetControllerToSafari; else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) - gBattleBankFunc[0] = SetControllerToWally; + gBattlerFuncs[0] = SetControllerToWally; else - gBattleBankFunc[0] = SetControllerToPlayer; + gBattlerFuncs[0] = SetControllerToPlayer; - gBankPositions[0] = B_POSITION_PLAYER_LEFT; + gBattlerPositions[0] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[1] = SetControllerToOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - gBattleBanksCount = 2; + gBattlersCount = 2; if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { @@ -210,32 +210,32 @@ static void SetControllersVariables(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetControllerToRecordedPlayer; - gBankPositions[0] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[0] = SetControllerToRecordedPlayer; + gBattlerPositions[0] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[1] = SetControllerToRecordedOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToRecordedOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - gBattleBanksCount = 2; + gBattlersCount = 2; } else // see how the banks are switched { - gBattleBankFunc[1] = SetControllerToRecordedPlayer; - gBankPositions[1] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[1] = SetControllerToRecordedPlayer; + gBattlerPositions[1] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[0] = SetControllerToRecordedOpponent; - gBankPositions[0] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[0] = SetControllerToRecordedOpponent; + gBattlerPositions[0] = B_POSITION_OPPONENT_LEFT; - gBattleBanksCount = 2; + gBattlersCount = 2; } } else { - gBattleBankFunc[0] = SetControllerToRecordedPlayer; - gBankPositions[0] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[0] = SetControllerToRecordedPlayer; + gBattlerPositions[0] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[1] = SetControllerToOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; } } } @@ -243,19 +243,19 @@ static void SetControllersVariables(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetControllerToPlayer; - gBankPositions[0] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[0] = SetControllerToPlayer; + gBattlerPositions[0] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[1] = SetControllerToOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - gBattleBankFunc[2] = SetControllerToPlayer; - gBankPositions[2] = B_POSITION_PLAYER_RIGHT; + gBattlerFuncs[2] = SetControllerToPlayer; + gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT; - gBattleBankFunc[3] = SetControllerToOpponent; - gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; + gBattlerFuncs[3] = SetControllerToOpponent; + gBattlerPositions[3] = B_POSITION_OPPONENT_RIGHT; - gBattleBanksCount = 4; + gBattlersCount = 4; if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { @@ -263,19 +263,19 @@ static void SetControllersVariables(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetControllerToRecordedPlayer; - gBankPositions[0] = 0; + gBattlerFuncs[0] = SetControllerToRecordedPlayer; + gBattlerPositions[0] = 0; - gBattleBankFunc[1] = SetControllerToOpponent; - gBankPositions[1] = 1; + gBattlerFuncs[1] = SetControllerToOpponent; + gBattlerPositions[1] = 1; - gBattleBankFunc[2] = SetControllerToRecordedPlayer; - gBankPositions[2] = 2; + gBattlerFuncs[2] = SetControllerToRecordedPlayer; + gBattlerPositions[2] = 2; - gBattleBankFunc[3] = SetControllerToOpponent; - gBankPositions[3] = 3; + gBattlerFuncs[3] = SetControllerToOpponent; + gBattlerPositions[3] = 3; - gBattleBanksCount = 4; + gBattlersCount = 4; sub_81B8D64(0, 0); sub_81B8D64(1, 0); @@ -291,7 +291,7 @@ static void SetControllersVariables(void) { u8 var; // multiplayer Id in a recorded battle? - for (var = gUnknown_0203C7B4, i = 0; i < BATTLE_BANKS_COUNT; i++) + for (var = gUnknown_0203C7B4, i = 0; i < MAX_BATTLERS_COUNT; i++) { switch (gLinkPlayers[i].lp_field_18) { @@ -307,17 +307,17 @@ static void SetControllersVariables(void) if (i == var) { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToRecordedPlayer; + gBattlerFuncs[gLinkPlayers[i].lp_field_18] = SetControllerToRecordedPlayer; switch (gLinkPlayers[i].lp_field_18) { case 0: case 3: - gBankPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_PLAYER_LEFT; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_PLAYER_LEFT; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; break; case 1: case 2: - gBankPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_PLAYER_RIGHT; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_PLAYER_RIGHT; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; break; } @@ -325,34 +325,34 @@ static void SetControllersVariables(void) else if ((!(gLinkPlayers[i].lp_field_18 & 1) && !(gLinkPlayers[var].lp_field_18 & 1)) || ((gLinkPlayers[i].lp_field_18 & 1) && (gLinkPlayers[var].lp_field_18 & 1))) { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToRecordedPlayer; + gBattlerFuncs[gLinkPlayers[i].lp_field_18] = SetControllerToRecordedPlayer; switch (gLinkPlayers[i].lp_field_18) { case 0: case 3: - gBankPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_PLAYER_LEFT; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_PLAYER_LEFT; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; break; case 1: case 2: - gBankPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_PLAYER_RIGHT; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_PLAYER_RIGHT; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; break; } } else { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToRecordedOpponent; + gBattlerFuncs[gLinkPlayers[i].lp_field_18] = SetControllerToRecordedOpponent; switch (gLinkPlayers[i].lp_field_18) { case 0: case 3: - gBankPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_OPPONENT_LEFT; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_OPPONENT_LEFT; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; break; case 1: case 2: - gBankPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_OPPONENT_RIGHT; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = B_POSITION_OPPONENT_RIGHT; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; break; } @@ -361,52 +361,52 @@ static void SetControllersVariables(void) } else if (gBattleTypeFlags & BATTLE_TYPE_WILD) { - gBattleBankFunc[0] = SetControllerToRecordedPlayer; - gBankPositions[0] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[0] = SetControllerToRecordedPlayer; + gBattlerPositions[0] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[2] = SetControllerToRecordedPlayer; - gBankPositions[2] = B_POSITION_PLAYER_RIGHT; + gBattlerFuncs[2] = SetControllerToRecordedPlayer; + gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT; if (gBattleTypeFlags & BATTLE_TYPE_x2000000) { - gBattleBankFunc[1] = SetControllerToRecordedOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToRecordedOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - gBattleBankFunc[3] = SetControllerToRecordedOpponent; - gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; + gBattlerFuncs[3] = SetControllerToRecordedOpponent; + gBattlerPositions[3] = B_POSITION_OPPONENT_RIGHT; } else { - gBattleBankFunc[1] = SetControllerToOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - gBattleBankFunc[3] = SetControllerToOpponent; - gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; + gBattlerFuncs[3] = SetControllerToOpponent; + gBattlerPositions[3] = B_POSITION_OPPONENT_RIGHT; } } else { - gBattleBankFunc[1] = SetControllerToRecordedPlayer; - gBankPositions[1] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[1] = SetControllerToRecordedPlayer; + gBattlerPositions[1] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[3] = SetControllerToRecordedPlayer; - gBankPositions[3] = B_POSITION_PLAYER_RIGHT; + gBattlerFuncs[3] = SetControllerToRecordedPlayer; + gBattlerPositions[3] = B_POSITION_PLAYER_RIGHT; if (gBattleTypeFlags & BATTLE_TYPE_x2000000) { - gBattleBankFunc[0] = SetControllerToRecordedOpponent; - gBankPositions[0] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[0] = SetControllerToRecordedOpponent; + gBattlerPositions[0] = B_POSITION_OPPONENT_LEFT; - gBattleBankFunc[2] = SetControllerToRecordedOpponent; - gBankPositions[2] = B_POSITION_OPPONENT_RIGHT; + gBattlerFuncs[2] = SetControllerToRecordedOpponent; + gBattlerPositions[2] = B_POSITION_OPPONENT_RIGHT; } else { - gBattleBankFunc[0] = SetControllerToOpponent; - gBankPositions[0] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[0] = SetControllerToOpponent; + gBattlerPositions[0] = B_POSITION_OPPONENT_LEFT; - gBattleBankFunc[2] = SetControllerToOpponent; - gBankPositions[2] = B_POSITION_OPPONENT_RIGHT; + gBattlerFuncs[2] = SetControllerToOpponent; + gBattlerPositions[2] = B_POSITION_OPPONENT_RIGHT; } } } @@ -424,23 +424,23 @@ static void SetControllersVariablesInLinkBattle(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetControllerToPlayer; - gBankPositions[0] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[0] = SetControllerToPlayer; + gBattlerPositions[0] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[1] = SetControllerToLinkOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToLinkOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - gBattleBanksCount = 2; + gBattlersCount = 2; } else { - gBattleBankFunc[1] = SetControllerToPlayer; - gBankPositions[1] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[1] = SetControllerToPlayer; + gBattlerPositions[1] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[0] = SetControllerToLinkOpponent; - gBankPositions[0] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[0] = SetControllerToLinkOpponent; + gBattlerPositions[0] = B_POSITION_OPPONENT_LEFT; - gBattleBanksCount = 2; + gBattlersCount = 2; } } else if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && gBattleTypeFlags & BATTLE_TYPE_DOUBLE) @@ -449,35 +449,35 @@ static void SetControllersVariablesInLinkBattle(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetControllerToPlayer; - gBankPositions[0] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[0] = SetControllerToPlayer; + gBattlerPositions[0] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[1] = SetControllerToLinkOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToLinkOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - gBattleBankFunc[2] = SetControllerToPlayer; - gBankPositions[2] = B_POSITION_PLAYER_RIGHT; + gBattlerFuncs[2] = SetControllerToPlayer; + gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT; - gBattleBankFunc[3] = SetControllerToLinkOpponent; - gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; + gBattlerFuncs[3] = SetControllerToLinkOpponent; + gBattlerPositions[3] = B_POSITION_OPPONENT_RIGHT; - gBattleBanksCount = 4; + gBattlersCount = 4; } else { - gBattleBankFunc[1] = SetControllerToPlayer; - gBankPositions[1] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[1] = SetControllerToPlayer; + gBattlerPositions[1] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[0] = SetControllerToLinkOpponent; - gBankPositions[0] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[0] = SetControllerToLinkOpponent; + gBattlerPositions[0] = B_POSITION_OPPONENT_LEFT; - gBattleBankFunc[3] = SetControllerToPlayer; - gBankPositions[3] = B_POSITION_PLAYER_RIGHT; + gBattlerFuncs[3] = SetControllerToPlayer; + gBattlerPositions[3] = B_POSITION_PLAYER_RIGHT; - gBattleBankFunc[2] = SetControllerToLinkOpponent; - gBankPositions[2] = B_POSITION_OPPONENT_RIGHT; + gBattlerFuncs[2] = SetControllerToLinkOpponent; + gBattlerPositions[2] = B_POSITION_OPPONENT_RIGHT; - gBattleBanksCount = 4; + gBattlersCount = 4; } } else if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) @@ -486,35 +486,35 @@ static void SetControllersVariablesInLinkBattle(void) { gBattleMainFunc = BeginBattleIntro; - gBattleBankFunc[0] = SetControllerToPlayer; - gBankPositions[0] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[0] = SetControllerToPlayer; + gBattlerPositions[0] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[1] = SetControllerToOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - gBattleBankFunc[2] = SetControllerToLinkPartner; - gBankPositions[2] = B_POSITION_PLAYER_RIGHT; + gBattlerFuncs[2] = SetControllerToLinkPartner; + gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT; - gBattleBankFunc[3] = SetControllerToOpponent; - gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; + gBattlerFuncs[3] = SetControllerToOpponent; + gBattlerPositions[3] = B_POSITION_OPPONENT_RIGHT; - gBattleBanksCount = 4; + gBattlersCount = 4; } else { - gBattleBankFunc[0] = SetControllerToLinkPartner; - gBankPositions[0] = B_POSITION_PLAYER_LEFT; + gBattlerFuncs[0] = SetControllerToLinkPartner; + gBattlerPositions[0] = B_POSITION_PLAYER_LEFT; - gBattleBankFunc[1] = SetControllerToLinkOpponent; - gBankPositions[1] = B_POSITION_OPPONENT_LEFT; + gBattlerFuncs[1] = SetControllerToLinkOpponent; + gBattlerPositions[1] = B_POSITION_OPPONENT_LEFT; - gBattleBankFunc[2] = SetControllerToPlayer; - gBankPositions[2] = B_POSITION_PLAYER_RIGHT; + gBattlerFuncs[2] = SetControllerToPlayer; + gBattlerPositions[2] = B_POSITION_PLAYER_RIGHT; - gBattleBankFunc[3] = SetControllerToLinkOpponent; - gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; + gBattlerFuncs[3] = SetControllerToLinkOpponent; + gBattlerPositions[3] = B_POSITION_OPPONENT_RIGHT; - gBattleBanksCount = 4; + gBattlersCount = 4; } sub_81B8D64(0, 0); @@ -533,7 +533,7 @@ static void SetControllersVariablesInLinkBattle(void) if (gBattleTypeFlags & BATTLE_TYPE_WILD) gBattleMainFunc = BeginBattleIntro; - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { switch (gLinkPlayers[i].lp_field_18) { @@ -549,17 +549,17 @@ static void SetControllersVariablesInLinkBattle(void) if (i == multiplayerId) { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToPlayer; + gBattlerFuncs[gLinkPlayers[i].lp_field_18] = SetControllerToPlayer; switch (gLinkPlayers[i].lp_field_18) { case 0: case 3: - gBankPositions[gLinkPlayers[i].lp_field_18] = 0; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = 0; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; break; case 1: case 2: - gBankPositions[gLinkPlayers[i].lp_field_18] = 2; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = 2; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; break; } @@ -569,34 +569,34 @@ static void SetControllersVariablesInLinkBattle(void) if ((!(gLinkPlayers[i].lp_field_18 & 1) && !(gLinkPlayers[multiplayerId].lp_field_18 & 1)) || ((gLinkPlayers[i].lp_field_18 & 1) && (gLinkPlayers[multiplayerId].lp_field_18 & 1))) { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToLinkPartner; + gBattlerFuncs[gLinkPlayers[i].lp_field_18] = SetControllerToLinkPartner; switch (gLinkPlayers[i].lp_field_18) { case 0: case 3: - gBankPositions[gLinkPlayers[i].lp_field_18] = 0; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = 0; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; break; case 1: case 2: - gBankPositions[gLinkPlayers[i].lp_field_18] = 2; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = 2; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; break; } } else { - gBattleBankFunc[gLinkPlayers[i].lp_field_18] = SetControllerToLinkOpponent; + gBattlerFuncs[gLinkPlayers[i].lp_field_18] = SetControllerToLinkOpponent; switch (gLinkPlayers[i].lp_field_18) { case 0: case 3: - gBankPositions[gLinkPlayers[i].lp_field_18] = 1; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = 1; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 0; break; case 1: case 2: - gBankPositions[gLinkPlayers[i].lp_field_18] = 3; + gBattlerPositions[gLinkPlayers[i].lp_field_18] = 3; gBattlePartyID[gLinkPlayers[i].lp_field_18] = 3; break; } @@ -604,7 +604,7 @@ static void SetControllersVariablesInLinkBattle(void) } } - gBattleBanksCount = 4; + gBattlersCount = 4; } } @@ -614,13 +614,13 @@ static void SetBattlePartyIds(void) if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { for (j = 0; j < 6; j++) { if (i < 2) { - if (GET_BANK_SIDE2(i) == SIDE_PLAYER) + if (GET_BATTLER_SIDE2(i) == B_SIDE_PLAYER) { if (GetMonData(&gPlayerParty[j], MON_DATA_HP) != 0 && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES2) != SPECIES_NONE @@ -645,7 +645,7 @@ static void SetBattlePartyIds(void) } else { - if (GET_BANK_SIDE2(i) == SIDE_PLAYER) + if (GET_BATTLER_SIDE2(i) == B_SIDE_PLAYER) { if (GetMonData(&gPlayerParty[j], MON_DATA_HP) != 0 && GetMonData(&gPlayerParty[j], MON_DATA_SPECIES) != SPECIES_NONE // Probably a typo by Game Freak. The rest use SPECIES2. @@ -693,14 +693,14 @@ static void PrepareBufferDataTransfer(u8 bufferId, u8 *data, u16 size) case 0: for (i = 0; i < size; i++) { - gBattleBufferA[gActiveBank][i] = *data; + gBattleBufferA[gActiveBattler][i] = *data; data++; } break; case 1: for (i = 0; i < size; i++) { - gBattleBufferB[gActiveBank][i] = *data; + gBattleBufferB[gActiveBattler][i] = *data; data++; } break; @@ -751,12 +751,12 @@ void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data) gTasks[gUnknown_02022D08].data[14] = 0; } gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_BUFFER_ID] = bufferId; - gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ACTIVE_BANK] = gActiveBank; - gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ATTACKER] = gBankAttacker; - gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_TARGET] = gBankDefender; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ACTIVE_BANK] = gActiveBattler; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ATTACKER] = gBattleAttacker; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_TARGET] = gBattleDefender; 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_ABSENT_BANK_FLAGS] = gAbsentBankFlags; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ABSENT_BANK_FLAGS] = gAbsentBattlerFlags; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_EFFECT_BANK] = gEffectBank; for (i = 0; i < size; i++) @@ -920,9 +920,9 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId) if (!(gBattleTypeFlags & BATTLE_TYPE_WILD)) { - gBankAttacker = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 2]; - gBankDefender = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 3]; - gAbsentBankFlags = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 6]; + gBattleAttacker = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 2]; + gBattleDefender = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 3]; + gAbsentBattlerFlags = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 6]; gEffectBank = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 7]; } break; @@ -1123,13 +1123,13 @@ void EmitPrintString(u8 bufferId, u16 stringID) stringInfo->originallyUsedMove = gChosenMove; stringInfo->lastItem = gLastUsedItem; stringInfo->lastAbility = gLastUsedAbility; - stringInfo->scrActive = gBattleScripting.bank; + stringInfo->scrActive = gBattleScripting.battler; stringInfo->unk1605E = gBattleStruct->field_52; stringInfo->hpScale = gBattleStruct->hpScale; stringInfo->StringBank = gStringBank; stringInfo->moveType = gBattleMoves[gCurrentMove].type; - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) stringInfo->abilities[i] = gBattleMons[i].ability; for (i = 0; i < TEXT_BUFF_ARRAY_COUNT; i++) { @@ -1155,10 +1155,10 @@ void EmitPrintSelectionString(u8 bufferId, u16 stringID) stringInfo->originallyUsedMove = gChosenMove; stringInfo->lastItem = gLastUsedItem; stringInfo->lastAbility = gLastUsedAbility; - stringInfo->scrActive = gBattleScripting.bank; + stringInfo->scrActive = gBattleScripting.battler; stringInfo->unk1605E = gBattleStruct->field_52; - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) stringInfo->abilities[i] = gBattleMons[i].ability; for (i = 0; i < TEXT_BUFF_ARRAY_COUNT; i++) { diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 4bfbebf98..a6b6f7a09 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -23,17 +23,17 @@ #include "contest.h" #include "constants/songs.h" -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gActiveBank; -extern u8 gBattleBanksCount; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gActiveBattler; +extern u8 gBattlersCount; extern u16 gUnknown_020243FC; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; -extern u8 gBankPositions[BATTLE_BANKS_COUNT]; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; -extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; -extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; +extern u8 gBattlerPositions[MAX_BATTLERS_COUNT]; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; +extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; +extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; extern struct MusicPlayerInfo gMPlayInfo_SE1; extern struct MusicPlayerInfo gMPlayInfo_SE2; extern struct MusicPlayerInfo gMPlayInfo_BGM; @@ -109,7 +109,7 @@ static const struct CompressedSpriteSheet gUnknown_0832C100 = gUnknown_08C1F8E8, 0x1000, TAG_HEALTHBOX_SAFARI_TILE }; -static const struct CompressedSpriteSheet gUnknown_0832C108[BATTLE_BANKS_COUNT] = +static const struct CompressedSpriteSheet gUnknown_0832C108[MAX_BATTLERS_COUNT] = { {gBlankGfxCompressed, 0x0100, 0xd704}, {gBlankGfxCompressed, 0x0120, 0xd705}, @@ -127,10 +127,10 @@ static const struct SpritePalette gUnknown_0832C128[2] = void AllocateBattleSpritesData(void) { gBattleSpritesDataPtr = AllocZeroed(sizeof(struct BattleSpriteData)); - gBattleSpritesDataPtr->bankData = AllocZeroed(sizeof(struct BattleSpriteInfo) * BATTLE_BANKS_COUNT); - gBattleSpritesDataPtr->healthBoxesData = AllocZeroed(sizeof(struct BattleHealthboxInfo) * BATTLE_BANKS_COUNT); + gBattleSpritesDataPtr->bankData = AllocZeroed(sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT); + gBattleSpritesDataPtr->healthBoxesData = AllocZeroed(sizeof(struct BattleHealthboxInfo) * MAX_BATTLERS_COUNT); gBattleSpritesDataPtr->animationData = AllocZeroed(sizeof(struct BattleAnimationInfo)); - gBattleSpritesDataPtr->battleBars = AllocZeroed(sizeof(struct BattleBarInfo) * BATTLE_BANKS_COUNT); + gBattleSpritesDataPtr->battleBars = AllocZeroed(sizeof(struct BattleBarInfo) * MAX_BATTLERS_COUNT); } void FreeBattleSpritesData(void) @@ -149,17 +149,17 @@ u16 ChooseMoveAndTargetInBattlePalace(void) { s32 i, var1, var2; s32 chosenMoveId = -1; - struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); - u8 unusableMovesBits = CheckMoveLimitations(gActiveBank, 0, 0xFF); + struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); + u8 unusableMovesBits = CheckMoveLimitations(gActiveBattler, 0, 0xFF); s32 percent = Random() % 100; - i = (gBattleStruct->field_92 & gBitTable[gActiveBank]) ? 2 : 0; + i = (gBattleStruct->field_92 & gBitTable[gActiveBattler]) ? 2 : 0; var2 = i; var1 = i + 2; for (; i < var1; i++) { - if (gUnknown_0831C494[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)][i] > percent) + if (gUnknown_0831C494[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)][i] > percent) break; } @@ -234,13 +234,13 @@ u16 ChooseMoveAndTargetInBattlePalace(void) if (Random() % 100 > 49) { - gProtectStructs[gActiveBank].flag_x10 = 1; + gProtectStructs[gActiveBattler].flag_x10 = 1; return 0; } } else { - gProtectStructs[gActiveBank].flag_x10 = 1; + gProtectStructs[gActiveBattler].flag_x10 = 1; return 0; } } @@ -258,11 +258,11 @@ u16 ChooseMoveAndTargetInBattlePalace(void) } if (var1 & MOVE_TARGET_x10) - chosenMoveId |= (gActiveBank << 8); + chosenMoveId |= (gActiveBattler << 8); else if (var1 == MOVE_TARGET_SELECTED) chosenMoveId |= (BattlePalaceGetTargetRetValue()); else - chosenMoveId |= (GetBankByPosition((GetBankPosition(gActiveBank) & BIT_SIDE) ^ BIT_SIDE) << 8); + chosenMoveId |= (GetBattlerAtPosition((GetBattlerPosition(gActiveBattler) & BIT_SIDE) ^ BIT_SIDE) << 8); return chosenMoveId; } @@ -297,21 +297,21 @@ static u16 BattlePalaceGetTargetRetValue(void) { u8 opposing1, opposing2; - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { - opposing1 = GetBankByPosition(B_POSITION_OPPONENT_LEFT); - opposing2 = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + opposing1 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + opposing2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); } else { - opposing1 = GetBankByPosition(B_POSITION_PLAYER_LEFT); - opposing2 = GetBankByPosition(B_POSITION_PLAYER_RIGHT); + opposing1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + opposing2 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); } if (gBattleMons[opposing1].hp == gBattleMons[opposing2].hp) - return (((gActiveBank & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8; + return (((gActiveBattler & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8; - switch (gUnknown_0831C604[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)]) + switch (gUnknown_0831C604[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)]) { case 0: if (gBattleMons[opposing1].hp > gBattleMons[opposing2].hp) @@ -324,11 +324,11 @@ static u16 BattlePalaceGetTargetRetValue(void) else return opposing2 << 8; case 2: - return (((gActiveBank & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8; + return (((gActiveBattler & BIT_SIDE) ^ BIT_SIDE) + (Random() & 2)) << 8; } } - return (gActiveBank ^ BIT_SIDE) << 8; + return (gActiveBattler ^ BIT_SIDE) << 8; } void sub_805D714(struct Sprite *sprite) @@ -388,36 +388,36 @@ static void sub_805D7EC(struct Sprite *sprite) void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status) { - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 1; if (!isStatus2) { if (status == STATUS1_FREEZE) - LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_FRZ); + LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_FRZ); else if (status == STATUS1_POISON || status & STATUS1_TOXIC_POISON) - LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_PSN); + LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_PSN); else if (status == STATUS1_BURN) - LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_BRN); + LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_BRN); else if (status & STATUS1_SLEEP) - LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_SLP); + LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_SLP); else if (status == STATUS1_PARALYSIS) - LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_PRZ); + LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_PRZ); else // no animation - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 0; } else { if (status & STATUS2_INFATUATION) - LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_INFATUATION); + LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_INFATUATION); else if (status & STATUS2_CONFUSION) - LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_CONFUSION); + LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_CONFUSION); else if (status & STATUS2_CURSED) - LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_CURSED); + LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_CURSED); else if (status & STATUS2_NIGHTMARE) - LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_NIGHTMARE); + LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_NIGHTMARE); else if (status & STATUS2_WRAPPED) - LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_WRAPPED); // this animation doesn't actually exist + LaunchStatusAnimation(gActiveBattler, B_ANIM_STATUS_WRAPPED); // this animation doesn't actually exist else // no animation - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 0; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].statusAnimActive = 0; } } @@ -524,7 +524,7 @@ bool8 mplay_80342A4(u8 bank) if (IsSEPlaying()) { gBattleSpritesDataPtr->healthBoxesData[bank].field_8++; - if (gBattleSpritesDataPtr->healthBoxesData[gActiveBank].field_8 < 30) + if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_8 < 30) return TRUE; m4aMPlayStop(&gMPlayInfo_SE1); @@ -561,7 +561,7 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank) } otId = GetMonData(mon, MON_DATA_OT_ID); - position = GetBankPosition(bank); + position = GetBattlerPosition(bank); HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[position], species, currentPersonality); @@ -614,7 +614,7 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank) } otId = GetMonData(mon, MON_DATA_OT_ID); - position = GetBankPosition(bank); + position = GetBattlerPosition(bank); if (sub_80688F8(1, bank) == 1 || gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) { @@ -665,7 +665,7 @@ void nullsub_24(u16 species) void DecompressTrainerFrontPic(u16 frontPicId, u8 bank) { - u8 position = GetBankPosition(bank); + u8 position = GetBattlerPosition(bank); DecompressPicFromTable_2(&gTrainerFrontPicTable[frontPicId], gMonSpritesGfxPtr->sprites[position], SPECIES_NONE); @@ -674,7 +674,7 @@ void DecompressTrainerFrontPic(u16 frontPicId, u8 bank) void DecompressTrainerBackPic(u16 backPicId, u8 bank) { - u8 position = GetBankPosition(bank); + u8 position = GetBattlerPosition(bank); DecompressPicFromTable_2(&gTrainerBackPicTable[backPicId], gMonSpritesGfxPtr->sprites[position], SPECIES_NONE); @@ -713,7 +713,7 @@ void sub_805DFFC(void) numberOfBanks = 4; } for (i = 0; i < numberOfBanks; i++) - LoadCompressedObjectPic(&gUnknown_0832C108[gBankPositions[i]]); + LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[i]]); } bool8 BattleLoadAllHealthBoxesGfx(u8 state) @@ -739,9 +739,9 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state) else if (state == 3) LoadCompressedObjectPic(&gUnknown_0832C0D8); else if (state == 4) - LoadCompressedObjectPic(&gUnknown_0832C108[gBankPositions[0]]); + LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[0]]); else if (state == 5) - LoadCompressedObjectPic(&gUnknown_0832C108[gBankPositions[1]]); + LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[1]]); else retVal = TRUE; } @@ -756,13 +756,13 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state) else if (state == 5) LoadCompressedObjectPic(&gUnknown_0832C0F0[1]); else if (state == 6) - LoadCompressedObjectPic(&gUnknown_0832C108[gBankPositions[0]]); + LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[0]]); else if (state == 7) - LoadCompressedObjectPic(&gUnknown_0832C108[gBankPositions[1]]); + LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[1]]); else if (state == 8) - LoadCompressedObjectPic(&gUnknown_0832C108[gBankPositions[2]]); + LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[2]]); else if (state == 9) - LoadCompressedObjectPic(&gUnknown_0832C108[gBankPositions[3]]); + LoadCompressedObjectPic(&gUnknown_0832C108[gBattlerPositions[3]]); else retVal = TRUE; } @@ -807,7 +807,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank) gHealthBoxesIds[*bank] = CreateBankHealthboxSprites(*bank); (*bank)++; - if (*bank == gBattleBanksCount) + if (*bank == gBattlersCount) { *bank = 0; (*state1)++; @@ -815,20 +815,20 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank) break; case 4: SetBankHealthboxSpritePos(*bank); - if (gBankPositions[*bank] <= 1) + if (gBattlerPositions[*bank] <= 1) DummyBattleInterfaceFunc(gHealthBoxesIds[*bank], FALSE); else DummyBattleInterfaceFunc(gHealthBoxesIds[*bank], TRUE); (*bank)++; - if (*bank == gBattleBanksCount) + if (*bank == gBattlersCount) { *bank = 0; (*state1)++; } break; case 5: - if (GetBankSide(*bank) == SIDE_PLAYER) + if (GetBattlerSide(*bank) == B_SIDE_PLAYER) { if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) UpdateHealthboxAttribute(gHealthBoxesIds[*bank], &gPlayerParty[gBattlePartyID[*bank]], HEALTHBOX_ALL); @@ -839,7 +839,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank) } SetHealthboxSpriteInvisible(gHealthBoxesIds[*bank]); (*bank)++; - if (*bank == gBattleBanksCount) + if (*bank == gBattlersCount) { *bank = 0; (*state1)++; @@ -857,21 +857,21 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank) void ClearSpritesHealthboxAnimData(void) { - memset(gBattleSpritesDataPtr->healthBoxesData, 0, sizeof(struct BattleHealthboxInfo) * BATTLE_BANKS_COUNT); + memset(gBattleSpritesDataPtr->healthBoxesData, 0, sizeof(struct BattleHealthboxInfo) * MAX_BATTLERS_COUNT); memset(gBattleSpritesDataPtr->animationData, 0, sizeof(struct BattleAnimationInfo)); } static void ClearSpritesBankHealthboxAnimData(void) { ClearSpritesHealthboxAnimData(); - memset(gBattleSpritesDataPtr->bankData, 0, sizeof(struct BattleSpriteInfo) * BATTLE_BANKS_COUNT); + memset(gBattleSpritesDataPtr->bankData, 0, sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT); } void CopyAllBattleSpritesInvisibilities(void) { s32 i; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) gBattleSpritesDataPtr->bankData[i].invisible = gSprites[gBankSpriteIds[i]].invisible; } @@ -921,14 +921,14 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform) } else { - position = GetBankPosition(bankAtk); + position = GetBattlerPosition(bankAtk); - if (GetBankSide(bankDef) == SIDE_OPPONENT) + if (GetBattlerSide(bankDef) == B_SIDE_OPPONENT) targetSpecies = GetMonData(&gEnemyParty[gBattlePartyID[bankDef]], MON_DATA_SPECIES); else targetSpecies = GetMonData(&gPlayerParty[gBattlePartyID[bankDef]], MON_DATA_SPECIES); - if (GetBankSide(bankAtk) == SIDE_PLAYER) + if (GetBattlerSide(bankAtk) == B_SIDE_PLAYER) { personalityValue = GetMonData(&gPlayerParty[gBattlePartyID[bankAtk]], MON_DATA_PERSONALITY); otId = GetMonData(&gPlayerParty[gBattlePartyID[bankAtk]], MON_DATA_OT_ID); @@ -991,11 +991,11 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 bank, bool8 loadMonSprite) if (IsContest()) position = 0; else - position = GetBankPosition(bank); + position = GetBattlerPosition(bank); if (IsContest()) LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[position]); - else if (GetBankSide(bank) != SIDE_PLAYER) + else if (GetBattlerSide(bank) != B_SIDE_PLAYER) LZDecompressVram(gSubstituteDollGfx, gMonSpritesGfxPtr->sprites[position]); else LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[position]); @@ -1018,7 +1018,7 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 bank, bool8 loadMonSprite) { if (!IsContest()) { - if (GetBankSide(bank) != SIDE_PLAYER) + if (GetBattlerSide(bank) != B_SIDE_PLAYER) BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); else BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlePartyID[bank]], bank); @@ -1057,7 +1057,7 @@ void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank) { if (!gBattleSpritesDataPtr->bankData[bank].lowHpSong) { - if (!gBattleSpritesDataPtr->bankData[bank ^ BIT_MON].lowHpSong) + if (!gBattleSpritesDataPtr->bankData[bank ^ BIT_FLANK].lowHpSong) PlaySE(SE_HINSI); gBattleSpritesDataPtr->bankData[bank].lowHpSong = 1; } @@ -1070,7 +1070,7 @@ void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank) m4aSongNumStop(SE_HINSI); return; } - if (IsDoubleBattle() && !gBattleSpritesDataPtr->bankData[bank ^ BIT_MON].lowHpSong) + if (IsDoubleBattle() && !gBattleSpritesDataPtr->bankData[bank ^ BIT_FLANK].lowHpSong) { m4aSongNumStop(SE_HINSI); return; @@ -1080,11 +1080,11 @@ void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank) void BattleStopLowHpSound(void) { - u8 playerBank = GetBankByPosition(B_POSITION_PLAYER_LEFT); + u8 playerBank = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); gBattleSpritesDataPtr->bankData[playerBank].lowHpSong = 0; if (IsDoubleBattle()) - gBattleSpritesDataPtr->bankData[playerBank ^ BIT_MON].lowHpSong = 0; + gBattleSpritesDataPtr->bankData[playerBank ^ BIT_FLANK].lowHpSong = 0; m4aSongNumStop(SE_HINSI); } @@ -1101,8 +1101,8 @@ void sub_805EAE8(void) { if (gMain.inBattle) { - u8 playerBank1 = GetBankByPosition(B_POSITION_PLAYER_LEFT); - u8 playerBank2 = GetBankByPosition(B_POSITION_PLAYER_RIGHT); + u8 playerBank1 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + u8 playerBank2 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); u8 bank1PartyId = pokemon_order_func(gBattlePartyID[playerBank1]); u8 bank2PartyId = pokemon_order_func(gBattlePartyID[playerBank2]); @@ -1117,7 +1117,7 @@ void sub_805EB9C(u8 affineMode) { s32 i; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (IsBankSpritePresent(i)) { @@ -1143,13 +1143,13 @@ void LoadAndCreateEnemyShadowSprites(void) LoadCompressedObjectPic(&gSpriteSheet_EnemyShadow); - bank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + bank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBankCoord(bank, 0), GetBankCoord(bank, 1) + 29, 0xC8); gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank; if (IsDoubleBattle()) { - bank = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + bank = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBankCoord(bank, 0), GetBankCoord(bank, 1) + 29, 0xC8); gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank; } @@ -1189,7 +1189,7 @@ void SpriteCB_SetInvisible(struct Sprite *sprite) void SetBankEnemyShadowSpriteCallback(u8 bank, u16 species) { - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(bank) == B_SIDE_PLAYER) return; if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) @@ -1245,7 +1245,7 @@ void AllocateMonSpritesGfx(void) gMonSpritesGfxPtr = AllocZeroed(sizeof(*gMonSpritesGfxPtr)); gMonSpritesGfxPtr->firstDecompressed = AllocZeroed(0x8000); - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { gMonSpritesGfxPtr->sprites[i] = gMonSpritesGfxPtr->firstDecompressed + (i * 0x2000); *(gMonSpritesGfxPtr->templates + i) = gUnknown_08329D98[i]; diff --git a/src/battle_interface.c b/src/battle_interface.c index f7b585ca4..b006a9d31 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -153,10 +153,10 @@ enum HEALTHBOX_GFX_117, }; -extern u8 gBankPositions[BATTLE_BANKS_COUNT]; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleBanksCount; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u8 gBattlerPositions[MAX_BATTLERS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattlersCount; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern const u8 * const gNatureNamePointers[]; extern const u8 gSpeciesNames[][POKEMON_NAME_LENGTH + 1]; @@ -907,7 +907,7 @@ u8 CreateBankHealthboxSprites(u8 bank) if (!IsDoubleBattle()) { - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(bank) == B_SIDE_PLAYER) { healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[0], 240, 160, 1); healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[0], 240, 160, 1); @@ -932,10 +932,10 @@ u8 CreateBankHealthboxSprites(u8 bank) } else { - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(bank) == B_SIDE_PLAYER) { - healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[GetBankPosition(bank) / 2], 240, 160, 1); - healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[GetBankPosition(bank) / 2], 240, 160, 1); + healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); + healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); gSprites[healthboxSpriteId_1].oam.affineParam = healthboxSpriteId_2; @@ -947,8 +947,8 @@ u8 CreateBankHealthboxSprites(u8 bank) } else { - healthboxSpriteId_1 = CreateSprite(&sHealthboxOpponentSpriteTemplates[GetBankPosition(bank) / 2], 240, 160, 1); - healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[GetBankPosition(bank) / 2], 240, 160, 1); + healthboxSpriteId_1 = CreateSprite(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); + healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); gSprites[healthboxSpriteId_1].oam.affineParam = healthboxSpriteId_2; @@ -960,9 +960,9 @@ u8 CreateBankHealthboxSprites(u8 bank) } } - unkSpriteId = CreateSpriteAtEnd(&sUnknown_0832C1C0[gBankPositions[bank]], 140, 60, 0); + unkSpriteId = CreateSpriteAtEnd(&sUnknown_0832C1C0[gBattlerPositions[bank]], 140, 60, 0); unkSpritePtr = &gSprites[unkSpriteId]; - SetSubspriteTables(unkSpritePtr, &sUnknown_0832C28C[GetBankSide(bank)]); + SetSubspriteTables(unkSpritePtr, &sUnknown_0832C28C[GetBattlerSide(bank)]); unkSpritePtr->subspriteMode = 2; unkSpritePtr->oam.priority = 1; @@ -1087,7 +1087,7 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority) { s32 i; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { u8 healthboxSpriteId_1 = gHealthBoxesIds[i]; u8 healthboxSpriteId_2 = gSprites[gHealthBoxesIds[i]].oam.affineParam; @@ -1105,14 +1105,14 @@ void SetBankHealthboxSpritePos(u8 bank) if (!IsDoubleBattle()) { - if (GetBankSide(bank) != SIDE_PLAYER) + if (GetBattlerSide(bank) != B_SIDE_PLAYER) x = 44, y = 30; else x = 158, y = 88; } else { - switch (GetBankPosition(bank)) + switch (GetBattlerPosition(bank)) { case B_POSITION_PLAYER_LEFT: x = 159, y = 76; @@ -1156,7 +1156,7 @@ static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl) windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(text, xPos, 3, 2, &windowId); spriteTileNum = gSprites[healthboxSpriteId].oam.tileNum * 32; - if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == SIDE_PLAYER) + if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER) { objVram = (void*)(OBJ_VRAM0); if (!IsDoubleBattle()) @@ -1180,7 +1180,7 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent) u8 text[32]; void *objVram; - if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == SIDE_PLAYER && !IsDoubleBattle()) + if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER && !IsDoubleBattle()) { spriteTileNum = gSprites[healthboxSpriteId].oam.tileNum * 32; if (maxOrCurrent != HP_CURRENT) // singles, max @@ -1214,7 +1214,7 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent) memcpy(text, sUnknown_0832C3C4, sizeof(sUnknown_0832C3C4)); bank = gSprites[healthboxSpriteId].data[6]; - if (IsDoubleBattle() == TRUE || GetBankSide(bank) == SIDE_OPPONENT) + if (IsDoubleBattle() == TRUE || GetBattlerSide(bank) == B_SIDE_OPPONENT) { UpdateHpTextInHealthboxInDoubles(healthboxSpriteId, value, maxOrCurrent); } @@ -1223,7 +1223,7 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent) u32 var; u8 i; - if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == SIDE_PLAYER) + if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER) { if (maxOrCurrent == HP_CURRENT) var = 29; @@ -1258,7 +1258,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8 u8 text[32]; void *objVram; - if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == 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 { @@ -1335,7 +1335,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8 } else { - if (GetBankSide(bank) == SIDE_PLAYER) // impossible to reach part, because the bank is from the opponent's side + if (GetBattlerSide(bank) == B_SIDE_PLAYER) // impossible to reach part, because the bank is from the opponent's side { CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_116), (void*)(OBJ_VRAM0) + ((gSprites[healthboxSpriteId].oam.tileNum + 52) * 32), @@ -1354,7 +1354,7 @@ static void sub_80730D4(u8 healthboxSpriteId, struct Pokemon *mon) u8 i, var, nature, healthboxSpriteId_2; memcpy(text, sUnknown_0832C3C4, sizeof(sUnknown_0832C3C4)); - barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (GetBankPosition(gSprites[healthboxSpriteId].data[6]) * 384)]; + barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (GetBattlerPosition(gSprites[healthboxSpriteId].data[6]) * 384)]; var = 5; nature = GetNature(mon); StringCopy(text + 6, gNatureNamePointers[nature]); @@ -1415,17 +1415,17 @@ void SwapHpBarsWithHpText(void) s32 i; u8 spriteId; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gSprites[gHealthBoxesIds[i]].callback == SpriteCallbackDummy - && GetBankSide(i) != SIDE_OPPONENT - && (IsDoubleBattle() || GetBankSide(i) != SIDE_PLAYER)) + && GetBattlerSide(i) != B_SIDE_OPPONENT + && (IsDoubleBattle() || GetBattlerSide(i) != B_SIDE_PLAYER)) { bool8 noBars; gBattleSpritesDataPtr->bankData[i].hpNumbersNoBars ^= 1; noBars = gBattleSpritesDataPtr->bankData[i].hpNumbersNoBars; - if (GetBankSide(i) == SIDE_PLAYER) + if (GetBattlerSide(i) == B_SIDE_PLAYER) { if (!IsDoubleBattle()) continue; @@ -1486,9 +1486,9 @@ u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 ar u8 ballIconSpritesIds[6]; u8 taskId; - if (!arg2 || GetBankPosition(bank) != B_POSITION_OPPONENT_RIGHT) + if (!arg2 || GetBattlerPosition(bank) != B_POSITION_OPPONENT_RIGHT) { - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(bank) == B_SIDE_PLAYER) { isOpponent = FALSE; bar_X = 136, bar_Y = 96; @@ -1567,7 +1567,7 @@ u8 CreatePartyStatusSummarySprites(u8 bank, struct HpAndStatus *partyInfo, u8 ar gSprites[ballIconSpritesIds[i]].data[2] = isOpponent; } - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(bank) == B_SIDE_PLAYER) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { @@ -1712,7 +1712,7 @@ void sub_8073C30(u8 taskId) { for (i = 0; i < 6; i++) { - if (GetBankSide(bank) != SIDE_PLAYER) + if (GetBattlerSide(bank) != B_SIDE_PLAYER) { gSprites[sp[5 - i]].data[1] = 7 * i; gSprites[sp[5 - i]].data[3] = 0; @@ -1964,7 +1964,7 @@ static void UpdateNickInHealthbox(u8 healthboxSpriteId, struct Pokemon *mon) spriteTileNum = gSprites[healthboxSpriteId].oam.tileNum * 32; - if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == SIDE_PLAYER) + if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER) { sub_8075198((void*)(0x6010040 + spriteTileNum), windowTileData, 6); ptr = (void*)(OBJ_VRAM0); @@ -1992,7 +1992,7 @@ static void TryAddPokeballIconToHealthbox(u8 healthboxSpriteId, bool8 noStatus) return; bank = gSprites[healthboxSpriteId].data[6]; - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(bank) == B_SIDE_PLAYER) return; if (!GetSetPokedexFlag(SpeciesToNationalPokedexNum(GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES)), FLAG_GET_CAUGHT)) return; @@ -2016,7 +2016,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId) bank = gSprites[healthboxSpriteId].data[6]; healthboxSpriteId_2 = gSprites[healthboxSpriteId].data[5]; - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(bank) == B_SIDE_PLAYER) { status = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_STATUS); if (!IsDoubleBattle()) @@ -2075,7 +2075,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId) FillPalette(sStatusIconColors[statusPalId], pltAdder + 0x100, 2); CpuCopy16(gPlttBufferUnfaded + 0x100 + pltAdder, (void*)(OBJ_PLTT + pltAdder * 2), 2); CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder) * 32), 96); - if (IsDoubleBattle() == TRUE || GetBankSide(bank) == SIDE_OPPONENT) + if (IsDoubleBattle() == TRUE || GetBattlerSide(bank) == B_SIDE_OPPONENT) { if (!gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars) { @@ -2181,9 +2181,9 @@ void UpdateHealthboxAttribute(u8 healthboxSpriteId, struct Pokemon *mon, u8 elem u8 bank = gSprites[healthboxSpriteId].data[6]; if (elementId == HEALTHBOX_ALL && !IsDoubleBattle()) - GetBankSide(bank); // pointless function call + GetBattlerSide(bank); // pointless function call - if (GetBankSide(gSprites[healthboxSpriteId].data[6]) == SIDE_PLAYER) + if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER) { u8 isDoubles; diff --git a/src/battle_main.c b/src/battle_main.c index 9027b1d14..a0f89f019 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -77,7 +77,7 @@ extern u16 gBattle_WIN1H; extern u16 gBattle_WIN1V; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; -extern struct BattleEnigmaBerry gEnigmaBerries[BATTLE_BANKS_COUNT]; +extern struct BattleEnigmaBerry gEnigmaBerries[MAX_BATTLERS_COUNT]; extern void (*gPreBattleCallback1)(void); extern void (*gBattleMainFunc)(void); extern void (*gCB2_AfterEvolution)(void); @@ -87,54 +87,54 @@ extern struct MusicPlayerInfo gMPlayInfo_SE1; extern struct MusicPlayerInfo gMPlayInfo_SE2; extern u8 gDecompressionBuffer[]; extern u16 gUnknown_020243FC; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; -extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; +extern void (*gBattlerFuncs[MAX_BATTLERS_COUNT])(void); +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u8 gStringBank; extern u32 gUnknown_02022F88; extern u32 gHitMarker; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; extern u16 gPaydayMoney; extern u16 gBattleWeather; extern u16 gPauseCounterBattle; extern u16 gRandomTurnNumber; -extern u8 gActiveBank; -extern u8 gBattleBanksCount; -extern u8 gBankAttacker; -extern u8 gBankDefender; +extern u8 gActiveBattler; +extern u8 gBattlersCount; +extern u8 gBattleAttacker; +extern u8 gBattleDefender; extern u8 gLeveledUpInBattle; -extern u8 gAbsentBankFlags; +extern u8 gAbsentBattlerFlags; extern u32 gBattleExecBuffer; extern u8 gMultiHitCounter; extern u8 gMoveResultFlags; extern s32 gBattleMoveDamage; -extern const u8* gPalaceSelectionBattleScripts[BATTLE_BANKS_COUNT]; -extern u16 gLastPrintedMoves[BATTLE_BANKS_COUNT]; -extern u16 gLastMoves[BATTLE_BANKS_COUNT]; -extern u16 gLastLandedMoves[BATTLE_BANKS_COUNT]; -extern u16 gLastHitByType[BATTLE_BANKS_COUNT]; -extern u16 gLastResultingMoves[BATTLE_BANKS_COUNT]; -extern u16 gLockedMoves[BATTLE_BANKS_COUNT]; -extern u8 gLastHitBy[BATTLE_BANKS_COUNT]; -extern u8 gUnknown_02024284[BATTLE_BANKS_COUNT]; -extern u32 gStatuses3[BATTLE_BANKS_COUNT]; +extern const u8* gPalaceSelectionBattleScripts[MAX_BATTLERS_COUNT]; +extern u16 gLastPrintedMoves[MAX_BATTLERS_COUNT]; +extern u16 gLastMoves[MAX_BATTLERS_COUNT]; +extern u16 gLastLandedMoves[MAX_BATTLERS_COUNT]; +extern u16 gLastHitByType[MAX_BATTLERS_COUNT]; +extern u16 gLastResultingMoves[MAX_BATTLERS_COUNT]; +extern u16 gLockedMoves[MAX_BATTLERS_COUNT]; +extern u8 gLastHitBy[MAX_BATTLERS_COUNT]; +extern u8 gUnknown_02024284[MAX_BATTLERS_COUNT]; +extern u32 gStatuses3[MAX_BATTLERS_COUNT]; extern u16 gSideStatuses[2]; extern u16 gCurrentMove; -extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; -extern u8 gBanksByTurnOrder[BATTLE_BANKS_COUNT]; -extern u8 gActionForBanks[BATTLE_BANKS_COUNT]; -extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT]; +extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; +extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; +extern u8 gBattleTurnOrder[MAX_BATTLERS_COUNT]; +extern u8 gActionForBanks[MAX_BATTLERS_COUNT]; +extern u16 gChosenMovesByBanks[MAX_BATTLERS_COUNT]; extern u8 gCurrentActionFuncId; extern u8 gLastUsedAbility; extern u8 gUnknown_0203CF00[]; -extern const u8* gSelectionBattleScripts[BATTLE_BANKS_COUNT]; +extern const u8* gSelectionBattleScripts[MAX_BATTLERS_COUNT]; extern const u8* gBattlescriptCurrInstr; -extern u8 gActionsByTurnOrder[BATTLE_BANKS_COUNT]; +extern u8 gActionsByTurnOrder[MAX_BATTLERS_COUNT]; extern u8 gCurrentTurnActionNumber; extern u16 gDynamicBasePower; extern u8 gCritMultiplier; @@ -2506,7 +2506,7 @@ static void sub_8039A48(struct Sprite *sprite) } else { - u8 *dst = (u8 *)gMonSpritesGfxPtr->sprites[GetBankPosition(sprite->tBank)] + (gBattleMonForms[sprite->tBank] << 11) + (sprite->data[3] << 8); + u8 *dst = (u8 *)gMonSpritesGfxPtr->sprites[GetBattlerPosition(sprite->tBank)] + (gBattleMonForms[sprite->tBank] << 11) + (sprite->data[3] << 8); for (i = 0; i < 0x100; i++) *(dst++) = 0; @@ -2709,8 +2709,8 @@ static void BattleMainCB1(void) { gBattleMainFunc(); - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) - gBattleBankFunc[gActiveBank](); + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) + gBattlerFuncs[gActiveBattler](); } static void BattleStartClearSetData(void) @@ -2722,7 +2722,7 @@ static void BattleStartClearSetData(void) TurnValuesCleanUp(FALSE); SpecialStatusesClear(); - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { gStatuses3[i] = 0; @@ -2752,8 +2752,8 @@ static void BattleStartClearSetData(void) dataPtr[j] = 0; } - gBankAttacker = 0; - gBankDefender = 0; + gBattleAttacker = 0; + gBattleDefender = 0; gBattleWeather = 0; dataPtr = (u8 *)&gWishFutureKnock; @@ -2788,7 +2788,7 @@ static void BattleStartClearSetData(void) gBattleScripting.animTurn = 0; gBattleScripting.animTargetsHit = 0; gLeveledUpInBattle = 0; - gAbsentBankFlags = 0; + gAbsentBattlerFlags = 0; gBattleStruct->runTries = 0; gBattleStruct->field_79 = 0; gBattleStruct->field_7A = 0; @@ -2809,7 +2809,7 @@ static void BattleStartClearSetData(void) *(i + 3 * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; } - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { *(gBattleStruct->AI_monToSwitchIntoId + i) = 6; } @@ -2831,19 +2831,19 @@ static void BattleStartClearSetData(void) void SwitchInClearSetData(void) { - struct DisableStruct disableStructCopy = gDisableStructs[gActiveBank]; + struct DisableStruct disableStructCopy = gDisableStructs[gActiveBattler]; s32 i; u8 *ptr; if (gBattleMoves[gCurrentMove].effect != EFFECT_BATON_PASS) { for (i = 0; i < BATTLE_STATS_NO; i++) - gBattleMons[gActiveBank].statStages[i] = 6; - for (i = 0; i < gBattleBanksCount; i++) + gBattleMons[gActiveBattler].statStages[i] = 6; + for (i = 0; i < gBattlersCount; i++) { - if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].bankPreventingEscape == gActiveBank) + if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].bankPreventingEscape == gActiveBattler) gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; - if ((gStatuses3[i] & STATUS3_ALWAYS_HITS) && gDisableStructs[i].bankWithSureHit == gActiveBank) + if ((gStatuses3[i] & STATUS3_ALWAYS_HITS) && gDisableStructs[i].bankWithSureHit == gActiveBattler) { gStatuses3[i] &= ~STATUS3_ALWAYS_HITS; gDisableStructs[i].bankWithSureHit = 0; @@ -2852,14 +2852,14 @@ void SwitchInClearSetData(void) } if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) { - gBattleMons[gActiveBank].status2 &= (STATUS2_CONFUSION | STATUS2_FOCUS_ENERGY | STATUS2_SUBSTITUTE | STATUS2_ESCAPE_PREVENTION | STATUS2_CURSED); - gStatuses3[gActiveBank] &= (STATUS3_LEECHSEED_BANK | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED | STATUS3_MUDSPORT | STATUS3_WATERSPORT); + gBattleMons[gActiveBattler].status2 &= (STATUS2_CONFUSION | STATUS2_FOCUS_ENERGY | STATUS2_SUBSTITUTE | STATUS2_ESCAPE_PREVENTION | STATUS2_CURSED); + gStatuses3[gActiveBattler] &= (STATUS3_LEECHSEED_BANK | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED | STATUS3_MUDSPORT | STATUS3_WATERSPORT); - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (GetBankSide(gActiveBank) != GetBankSide(i) + if (GetBattlerSide(gActiveBattler) != GetBattlerSide(i) && (gStatuses3[i] & STATUS3_ALWAYS_HITS) != 0 - && (gDisableStructs[i].bankWithSureHit == gActiveBank)) + && (gDisableStructs[i].bankWithSureHit == gActiveBattler)) { gStatuses3[i] &= ~(STATUS3_ALWAYS_HITS); gStatuses3[i] |= 0x10; @@ -2868,77 +2868,77 @@ void SwitchInClearSetData(void) } else { - gBattleMons[gActiveBank].status2 = 0; - gStatuses3[gActiveBank] = 0; + gBattleMons[gActiveBattler].status2 = 0; + gStatuses3[gActiveBattler] = 0; } - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBank)) - gBattleMons[i].status2 &= ~(STATUS2_INFATUATED_WITH(gActiveBank)); - if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == gActiveBank) + if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBattler)) + gBattleMons[i].status2 &= ~(STATUS2_INFATUATED_WITH(gActiveBattler)); + if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == gActiveBattler) gBattleMons[i].status2 &= ~(STATUS2_WRAPPED); } - gActionSelectionCursor[gActiveBank] = 0; - gMoveSelectionCursor[gActiveBank] = 0; + gActionSelectionCursor[gActiveBattler] = 0; + gMoveSelectionCursor[gActiveBattler] = 0; - ptr = (u8 *)&gDisableStructs[gActiveBank]; + ptr = (u8 *)&gDisableStructs[gActiveBattler]; for (i = 0; i < sizeof(struct DisableStruct); i++) ptr[i] = 0; if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) { - gDisableStructs[gActiveBank].substituteHP = disableStructCopy.substituteHP; - gDisableStructs[gActiveBank].bankWithSureHit = disableStructCopy.bankWithSureHit; - gDisableStructs[gActiveBank].perishSongTimer1 = disableStructCopy.perishSongTimer1; - gDisableStructs[gActiveBank].perishSongTimer2 = disableStructCopy.perishSongTimer2; - gDisableStructs[gActiveBank].bankPreventingEscape = disableStructCopy.bankPreventingEscape; + gDisableStructs[gActiveBattler].substituteHP = disableStructCopy.substituteHP; + gDisableStructs[gActiveBattler].bankWithSureHit = disableStructCopy.bankWithSureHit; + gDisableStructs[gActiveBattler].perishSongTimer1 = disableStructCopy.perishSongTimer1; + gDisableStructs[gActiveBattler].perishSongTimer2 = disableStructCopy.perishSongTimer2; + gDisableStructs[gActiveBattler].bankPreventingEscape = disableStructCopy.bankPreventingEscape; } gMoveResultFlags = 0; - gDisableStructs[gActiveBank].isFirstTurn = 2; - gDisableStructs[gActiveBank].truantUnknownBit = disableStructCopy.truantUnknownBit; - gLastMoves[gActiveBank] = 0; - gLastLandedMoves[gActiveBank] = 0; - gLastHitByType[gActiveBank] = 0; - gLastResultingMoves[gActiveBank] = 0; - gLastPrintedMoves[gActiveBank] = 0; - gLastHitBy[gActiveBank] = 0xFF; + gDisableStructs[gActiveBattler].isFirstTurn = 2; + gDisableStructs[gActiveBattler].truantUnknownBit = disableStructCopy.truantUnknownBit; + gLastMoves[gActiveBattler] = 0; + gLastLandedMoves[gActiveBattler] = 0; + gLastHitByType[gActiveBattler] = 0; + gLastResultingMoves[gActiveBattler] = 0; + gLastPrintedMoves[gActiveBattler] = 0; + gLastHitBy[gActiveBattler] = 0xFF; - *(gBattleStruct->mirrorMoves + gActiveBank * 2 + 0) = 0; - *(gBattleStruct->mirrorMoves + gActiveBank * 2 + 1) = 0; - *(0 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; - *(0 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; - *(1 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; - *(1 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; - *(2 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; - *(2 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; - *(3 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; - *(3 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(gBattleStruct->mirrorMoves + gActiveBattler * 2 + 0) = 0; + *(gBattleStruct->mirrorMoves + gActiveBattler * 2 + 1) = 0; + *(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; - gBattleStruct->field_92 &= ~(gBitTable[gActiveBank]); + gBattleStruct->field_92 &= ~(gBitTable[gActiveBattler]); - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (i != gActiveBank && GetBankSide(i) != GetBankSide(gActiveBank)) + if (i != gActiveBattler && GetBattlerSide(i) != GetBattlerSide(gActiveBattler)) { *(gBattleStruct->mirrorMoves + i * 2 + 0) = 0; *(gBattleStruct->mirrorMoves + i * 2 + 1) = 0; } - *(i * 8 + gActiveBank * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; - *(i * 8 + gActiveBank * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; } - *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 0) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 1) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 1) = 0; - gBattleResources->flags->flags[gActiveBank] = 0; + gBattleResources->flags->flags[gActiveBattler] = 0; gCurrentMove = 0; gBattleStruct->field_DA = 0xFF; - ClearBankMoveHistory(gActiveBank); - ClearBankAbilityHistory(gActiveBank); + ClearBankMoveHistory(gActiveBattler); + ClearBankAbilityHistory(gActiveBattler); } void FaintClearSetData(void) @@ -2947,91 +2947,91 @@ void FaintClearSetData(void) u8 *ptr; for (i = 0; i < BATTLE_STATS_NO; i++) - gBattleMons[gActiveBank].statStages[i] = 6; + gBattleMons[gActiveBattler].statStages[i] = 6; - gBattleMons[gActiveBank].status2 = 0; - gStatuses3[gActiveBank] = 0; + gBattleMons[gActiveBattler].status2 = 0; + gStatuses3[gActiveBattler] = 0; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].bankPreventingEscape == gActiveBank) + if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].bankPreventingEscape == gActiveBattler) gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; - if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBank)) - gBattleMons[i].status2 &= ~(STATUS2_INFATUATED_WITH(gActiveBank)); - if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == gActiveBank) + if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBattler)) + gBattleMons[i].status2 &= ~(STATUS2_INFATUATED_WITH(gActiveBattler)); + if ((gBattleMons[i].status2 & STATUS2_WRAPPED) && *(gBattleStruct->wrappedBy + i) == gActiveBattler) gBattleMons[i].status2 &= ~(STATUS2_WRAPPED); } - gActionSelectionCursor[gActiveBank] = 0; - gMoveSelectionCursor[gActiveBank] = 0; + gActionSelectionCursor[gActiveBattler] = 0; + gMoveSelectionCursor[gActiveBattler] = 0; - ptr = (u8 *)&gDisableStructs[gActiveBank]; + ptr = (u8 *)&gDisableStructs[gActiveBattler]; for (i = 0; i < sizeof(struct DisableStruct); i++) ptr[i] = 0; - gProtectStructs[gActiveBank].protected = 0; - gProtectStructs[gActiveBank].endured = 0; - gProtectStructs[gActiveBank].onlyStruggle = 0; - gProtectStructs[gActiveBank].helpingHand = 0; - gProtectStructs[gActiveBank].bounceMove = 0; - gProtectStructs[gActiveBank].stealMove = 0; - gProtectStructs[gActiveBank].flag0Unknown = 0; - gProtectStructs[gActiveBank].prlzImmobility = 0; - gProtectStructs[gActiveBank].confusionSelfDmg = 0; - gProtectStructs[gActiveBank].targetNotAffected = 0; - gProtectStructs[gActiveBank].chargingTurn = 0; - gProtectStructs[gActiveBank].fleeFlag = 0; - gProtectStructs[gActiveBank].usedImprisionedMove = 0; - gProtectStructs[gActiveBank].loveImmobility = 0; - gProtectStructs[gActiveBank].usedDisabledMove = 0; - gProtectStructs[gActiveBank].usedTauntedMove = 0; - gProtectStructs[gActiveBank].flag2Unknown = 0; - gProtectStructs[gActiveBank].flinchImmobility = 0; - gProtectStructs[gActiveBank].notFirstStrike = 0; + gProtectStructs[gActiveBattler].protected = 0; + gProtectStructs[gActiveBattler].endured = 0; + gProtectStructs[gActiveBattler].onlyStruggle = 0; + gProtectStructs[gActiveBattler].helpingHand = 0; + gProtectStructs[gActiveBattler].bounceMove = 0; + gProtectStructs[gActiveBattler].stealMove = 0; + gProtectStructs[gActiveBattler].flag0Unknown = 0; + gProtectStructs[gActiveBattler].prlzImmobility = 0; + gProtectStructs[gActiveBattler].confusionSelfDmg = 0; + gProtectStructs[gActiveBattler].targetNotAffected = 0; + gProtectStructs[gActiveBattler].chargingTurn = 0; + gProtectStructs[gActiveBattler].fleeFlag = 0; + gProtectStructs[gActiveBattler].usedImprisionedMove = 0; + gProtectStructs[gActiveBattler].loveImmobility = 0; + gProtectStructs[gActiveBattler].usedDisabledMove = 0; + gProtectStructs[gActiveBattler].usedTauntedMove = 0; + gProtectStructs[gActiveBattler].flag2Unknown = 0; + gProtectStructs[gActiveBattler].flinchImmobility = 0; + gProtectStructs[gActiveBattler].notFirstStrike = 0; - gDisableStructs[gActiveBank].isFirstTurn = 2; + gDisableStructs[gActiveBattler].isFirstTurn = 2; - gLastMoves[gActiveBank] = 0; - gLastLandedMoves[gActiveBank] = 0; - gLastHitByType[gActiveBank] = 0; - gLastResultingMoves[gActiveBank] = 0; - gLastPrintedMoves[gActiveBank] = 0; - gLastHitBy[gActiveBank] = 0xFF; + gLastMoves[gActiveBattler] = 0; + gLastLandedMoves[gActiveBattler] = 0; + gLastHitByType[gActiveBattler] = 0; + gLastResultingMoves[gActiveBattler] = 0; + gLastPrintedMoves[gActiveBattler] = 0; + gLastHitBy[gActiveBattler] = 0xFF; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 0) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBank]) + 1) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 1) = 0; - *(gBattleStruct->mirrorMoves + gActiveBank * 2 + 0) = 0; - *(gBattleStruct->mirrorMoves + gActiveBank * 2 + 1) = 0; - *(0 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; - *(0 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; - *(1 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; - *(1 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; - *(2 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; - *(2 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; - *(3 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; - *(3 * 2 + gActiveBank * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(gBattleStruct->mirrorMoves + gActiveBattler * 2 + 0) = 0; + *(gBattleStruct->mirrorMoves + gActiveBattler * 2 + 1) = 0; + *(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(0 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(1 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(2 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(3 * 2 + gActiveBattler * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; - gBattleStruct->field_92 &= ~(gBitTable[gActiveBank]); + gBattleStruct->field_92 &= ~(gBitTable[gActiveBattler]); - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (i != gActiveBank && GetBankSide(i) != GetBankSide(gActiveBank)) + if (i != gActiveBattler && GetBattlerSide(i) != GetBattlerSide(gActiveBattler)) { *(gBattleStruct->mirrorMoves + i * 2 + 0) = 0; *(gBattleStruct->mirrorMoves + i * 2 + 1) = 0; } - *(i * 8 + gActiveBank * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; - *(i * 8 + gActiveBank * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; + *(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = 0; + *(i * 8 + gActiveBattler * 2 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = 0; } - gBattleResources->flags->flags[gActiveBank] = 0; + gBattleResources->flags->flags[gActiveBattler] = 0; - gBattleMons[gActiveBank].type1 = gBaseStats[gBattleMons[gActiveBank].species].type1; - gBattleMons[gActiveBank].type2 = gBaseStats[gBattleMons[gActiveBank].species].type2; + gBattleMons[gActiveBattler].type1 = gBaseStats[gBattleMons[gActiveBattler].species].type1; + gBattleMons[gActiveBattler].type2 = gBaseStats[gBattleMons[gActiveBattler].species].type2; - ClearBankMoveHistory(gActiveBank); - ClearBankAbilityHistory(gActiveBank); + ClearBankMoveHistory(gActiveBattler); + ClearBankAbilityHistory(gActiveBattler); } static void BattleIntroGetMonsData(void) @@ -3039,16 +3039,16 @@ static void BattleIntroGetMonsData(void) switch (gBattleCommunication[MULTIUSE_STATE]) { case 0: - gActiveBank = gBattleCommunication[1]; + gActiveBattler = gBattleCommunication[1]; EmitGetMonData(0, 0, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattleCommunication[MULTIUSE_STATE]++; break; case 1: if (gBattleExecBuffer == 0) { gBattleCommunication[1]++; - if (gBattleCommunication[1] == gBattleBanksCount) + if (gBattleCommunication[1] == gBattlersCount) gBattleMainFunc = BattleIntroPrepareBackgroundSlide; else gBattleCommunication[MULTIUSE_STATE] = 0; @@ -3061,9 +3061,9 @@ static void BattleIntroPrepareBackgroundSlide(void) { if (gBattleExecBuffer == 0) { - gActiveBank = GetBankByPosition(0); + gActiveBattler = GetBattlerAtPosition(0); EmitIntroSlide(0, gBattleTerrain); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattleMainFunc = BattleIntroDrawTrainersOrMonsSprites; gBattleCommunication[0] = 0; gBattleCommunication[1] = 0; @@ -3078,12 +3078,12 @@ static void BattleIntroDrawTrainersOrMonsSprites(void) if (gBattleExecBuffer) return; - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) - && GetBankSide(gActiveBank) == SIDE_PLAYER) + && GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { - ptr = (u8 *)&gBattleMons[gActiveBank]; + ptr = (u8 *)&gBattleMons[gActiveBattler]; for (i = 0; i < sizeof(struct BattlePokemon); i++) ptr[i] = 0; } @@ -3091,46 +3091,46 @@ static void BattleIntroDrawTrainersOrMonsSprites(void) { u16* hpOnSwitchout; - ptr = (u8 *)&gBattleMons[gActiveBank]; + ptr = (u8 *)&gBattleMons[gActiveBattler]; for (i = 0; i < sizeof(struct BattlePokemon); i++) - ptr[i] = gBattleBufferB[gActiveBank][4 + i]; + ptr[i] = gBattleBufferB[gActiveBattler][4 + i]; - gBattleMons[gActiveBank].type1 = gBaseStats[gBattleMons[gActiveBank].species].type1; - gBattleMons[gActiveBank].type2 = gBaseStats[gBattleMons[gActiveBank].species].type2; - gBattleMons[gActiveBank].ability = GetAbilityBySpecies(gBattleMons[gActiveBank].species, gBattleMons[gActiveBank].altAbility); - hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBankSide(gActiveBank)]; - *hpOnSwitchout = gBattleMons[gActiveBank].hp; + gBattleMons[gActiveBattler].type1 = gBaseStats[gBattleMons[gActiveBattler].species].type1; + gBattleMons[gActiveBattler].type2 = gBaseStats[gBattleMons[gActiveBattler].species].type2; + gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].altAbility); + hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(gActiveBattler)]; + *hpOnSwitchout = gBattleMons[gActiveBattler].hp; for (i = 0; i < BATTLE_STATS_NO; i++) - gBattleMons[gActiveBank].statStages[i] = 6; - gBattleMons[gActiveBank].status2 = 0; + gBattleMons[gActiveBattler].statStages[i] = 6; + gBattleMons[gActiveBattler].status2 = 0; } - if (GetBankPosition(gActiveBank) == B_POSITION_PLAYER_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_LEFT) { EmitDrawTrainerPic(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { - if (GetBankPosition(gActiveBank) == B_POSITION_OPPONENT_LEFT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_LEFT) { EmitDrawTrainerPic(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } - if (GetBankSide(gActiveBank) == SIDE_OPPONENT + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_x4000000))) { - HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBank].species), FLAG_SET_SEEN, gBattleMons[gActiveBank].personality); + HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBattler].species), FLAG_SET_SEEN, gBattleMons[gActiveBattler].personality); } } else { - if (GetBankSide(gActiveBank) == SIDE_OPPONENT) + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) { if (!(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER @@ -3138,28 +3138,28 @@ static void BattleIntroDrawTrainersOrMonsSprites(void) | BATTLE_TYPE_x2000000 | BATTLE_TYPE_x4000000))) { - HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBank].species), FLAG_SET_SEEN, gBattleMons[gActiveBank].personality); + HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBattler].species), FLAG_SET_SEEN, gBattleMons[gActiveBattler].personality); } EmitLoadMonSprite(0); - MarkBufferBankForExecution(gActiveBank); - gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES, NULL); + MarkBufferBankForExecution(gActiveBattler); + gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES, NULL); } } if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if (GetBankPosition(gActiveBank) == B_POSITION_PLAYER_RIGHT - || GetBankPosition(gActiveBank) == B_POSITION_OPPONENT_RIGHT) + if (GetBattlerPosition(gActiveBattler) == B_POSITION_PLAYER_RIGHT + || GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) { EmitDrawTrainerPic(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } } - if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && GetBankPosition(gActiveBank) == B_POSITION_OPPONENT_RIGHT) + if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && GetBattlerPosition(gActiveBattler) == B_POSITION_OPPONENT_RIGHT) { EmitDrawTrainerPic(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } if (gBattleTypeFlags & BATTLE_TYPE_ARENA) @@ -3192,9 +3192,9 @@ static void BattleIntroDrawPartySummaryScreens(void) hpStatus[i].status = GetMonData(&gEnemyParty[i], MON_DATA_STATUS); } } - gActiveBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + gActiveBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); EmitDrawPartyStatusSummary(0, hpStatus, 0x80); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); for (i = 0; i < PARTY_SIZE; i++) { @@ -3210,9 +3210,9 @@ static void BattleIntroDrawPartySummaryScreens(void) hpStatus[i].status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); } } - gActiveBank = GetBankByPosition(B_POSITION_PLAYER_LEFT); + gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); EmitDrawPartyStatusSummary(0, hpStatus, 0x80); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattleMainFunc = BattleIntroPrintTrainerWantsToBattle; } @@ -3246,8 +3246,8 @@ static void BattleIntroPrintTrainerWantsToBattle(void) { if (gBattleExecBuffer == 0) { - gActiveBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); - PrepareStringBattle(STRINGID_INTROMSG, gActiveBank); + gActiveBattler = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + PrepareStringBattle(STRINGID_INTROMSG, gActiveBattler); gBattleMainFunc = BattleIntroPrintOpponentSendsOut; } } @@ -3280,7 +3280,7 @@ static void BattleIntroPrintOpponentSendsOut(void) else position = B_POSITION_OPPONENT_LEFT; - PrepareStringBattle(STRINGID_INTROSENDOUT, GetBankByPosition(position)); + PrepareStringBattle(STRINGID_INTROSENDOUT, GetBattlerAtPosition(position)); gBattleMainFunc = BattleIntroOpponent1SendsOutMonAnimation; } @@ -3300,12 +3300,12 @@ static void BattleIntroOpponent2SendsOutMonAnimation(void) else position = B_POSITION_OPPONENT_RIGHT; - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (GetBankPosition(gActiveBank) == position) + if (GetBattlerPosition(gActiveBattler) == position) { EmitIntroTrainerBallThrow(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } } @@ -3332,12 +3332,12 @@ static void BattleIntroOpponent1SendsOutMonAnimation(void) if (gBattleExecBuffer) return; - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (GetBankPosition(gActiveBank) == position) + if (GetBattlerPosition(gActiveBattler) == position) { EmitIntroTrainerBallThrow(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); if (gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_TWO_OPPONENTS)) { gBattleMainFunc = BattleIntroOpponent2SendsOutMonAnimation; @@ -3387,9 +3387,9 @@ _0803B29A:\n\ ldr r2, [r0]\n\ cmp r2, 0\n\ bne _0803B2F2\n\ - ldr r0, =gActiveBank\n\ + ldr r0, =gActiveBattler\n\ strb r2, [r0]\n\ - ldr r1, =gBattleBanksCount\n\ + ldr r1, =gBattlersCount\n\ adds r4, r0, 0\n\ ldrb r1, [r1]\n\ cmp r2, r1\n\ @@ -3397,7 +3397,7 @@ _0803B29A:\n\ adds r6, r4, 0\n\ _0803B2B2:\n\ ldrb r0, [r4]\n\ - bl GetBankPosition\n\ + bl GetBattlerPosition\n\ lsls r0, 24\n\ lsrs r0, 24\n\ cmp r0, r5\n\ @@ -3416,10 +3416,10 @@ _0803B2D8:\n\ ldrb r0, [r6]\n\ adds r0, 0x1\n\ strb r0, [r6]\n\ - ldr r1, =gBattleBanksCount\n\ + ldr r1, =gBattlersCount\n\ lsls r0, 24\n\ lsrs r0, 24\n\ - ldr r4, =gActiveBank\n\ + ldr r4, =gActiveBattler\n\ ldrb r1, [r1]\n\ cmp r0, r1\n\ bcc _0803B2B2\n\ @@ -3442,16 +3442,16 @@ static void BattleIntroRecordMonsToDex(void) { if (gBattleExecBuffer == 0) { - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (GetBankSide(gActiveBank) == SIDE_OPPONENT + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_x4000000))) { - HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBank].species), FLAG_SET_SEEN, gBattleMons[gActiveBank].personality); + HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBattler].species), FLAG_SET_SEEN, gBattleMons[gActiveBattler].personality); } } gBattleMainFunc = BattleIntroPrintPlayerSendsOut; @@ -3483,7 +3483,7 @@ static void BattleIntroPrintPlayerSendsOut(void) position = B_POSITION_PLAYER_LEFT; if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) - PrepareStringBattle(STRINGID_INTROSENDOUT, GetBankByPosition(position)); + PrepareStringBattle(STRINGID_INTROSENDOUT, GetBattlerAtPosition(position)); gBattleMainFunc = BattleIntroPlayer1SendsOutMonAnimation; } @@ -3505,12 +3505,12 @@ static void BattleIntroPlayer2SendsOutMonAnimation(void) else position = B_POSITION_PLAYER_RIGHT; - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (GetBankPosition(gActiveBank) == position) + if (GetBattlerPosition(gActiveBattler) == position) { EmitIntroTrainerBallThrow(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } } @@ -3540,12 +3540,12 @@ static void BattleIntroPlayer1SendsOutMonAnimation(void) if (gBattleExecBuffer) return; - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (GetBankPosition(gActiveBank) == position) + if (GetBattlerPosition(gActiveBattler) == position) { EmitIntroTrainerBallThrow(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); if (gBattleTypeFlags & (BATTLE_TYPE_MULTI)) { gBattleMainFunc = BattleIntroPlayer2SendsOutMonAnimation; @@ -3565,12 +3565,12 @@ void sub_803B598(void) // unused { if (gBattleExecBuffer == 0) { - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { - EmitSwitchInAnim(0, gBattlePartyID[gActiveBank], FALSE); - MarkBufferBankForExecution(gActiveBank); + EmitSwitchInAnim(0, gBattlePartyID[gActiveBattler], FALSE); + MarkBufferBankForExecution(gActiveBattler); } } @@ -3593,13 +3593,13 @@ static void TryDoEventsBeforeFirstTurn(void) if (gBattleStruct->switchInAbilitiesCounter == 0) { - for (i = 0; i < gBattleBanksCount; i++) - gBanksByTurnOrder[i] = i; - for (i = 0; i < gBattleBanksCount - 1; i++) + for (i = 0; i < gBattlersCount; i++) + gBattleTurnOrder[i] = i; + for (i = 0; i < gBattlersCount - 1; i++) { - for (j = i + 1; j < gBattleBanksCount; j++) + for (j = i + 1; j < gBattlersCount; j++) { - if (GetWhoStrikesFirst(gBanksByTurnOrder[i], gBanksByTurnOrder[j], TRUE) != 0) + if (GetWhoStrikesFirst(gBattleTurnOrder[i], gBattleTurnOrder[j], TRUE) != 0) SwapTurnOrder(i, j); } } @@ -3611,9 +3611,9 @@ static void TryDoEventsBeforeFirstTurn(void) return; } // check all switch in abilities happening from the fastest mon to slowest - while (gBattleStruct->switchInAbilitiesCounter < gBattleBanksCount) + while (gBattleStruct->switchInAbilitiesCounter < gBattlersCount) { - if (AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gBanksByTurnOrder[gBattleStruct->switchInAbilitiesCounter], 0, 0, 0) != 0) + if (AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gBattleTurnOrder[gBattleStruct->switchInAbilitiesCounter], 0, 0, 0) != 0) effect++; gBattleStruct->switchInAbilitiesCounter++; @@ -3626,9 +3626,9 @@ static void TryDoEventsBeforeFirstTurn(void) if (AbilityBattleEffects(ABILITYEFFECT_TRACE, 0, 0, 0, 0) != 0) return; // check all switch in items having effect from the fastest mon to slowest - while (gBattleStruct->switchInItemsCounter < gBattleBanksCount) + while (gBattleStruct->switchInItemsCounter < gBattlersCount) { - if (ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, gBanksByTurnOrder[gBattleStruct->switchInItemsCounter], 0) != 0) + if (ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, gBattleTurnOrder[gBattleStruct->switchInItemsCounter], 0) != 0) effect++; gBattleStruct->switchInItemsCounter++; @@ -3636,7 +3636,7 @@ static void TryDoEventsBeforeFirstTurn(void) if (effect) return; } - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { *(gBattleStruct->monToSwitchIntoId + i) = 6; gActionForBanks[i] = ACTION_INIT_VALUE; @@ -3644,7 +3644,7 @@ static void TryDoEventsBeforeFirstTurn(void) } TurnValuesCleanUp(FALSE); SpecialStatusesClear(); - *(&gBattleStruct->field_91) = gAbsentBankFlags; + *(&gBattleStruct->field_91) = gAbsentBattlerFlags; BattleHandleAddTextPrinter(gText_EmptyString3, 0); gBattleMainFunc = HandleTurnActionSelectionState; ResetSentPokesToOpponentValue(); @@ -3652,7 +3652,7 @@ static void TryDoEventsBeforeFirstTurn(void) for (i = 0; i < BATTLE_COMMUNICATION_ENTRIES_COUNT; i++) gBattleCommunication[i] = 0; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) gBattleMons[i].status2 &= ~(STATUS2_FLINCHED); *(&gBattleStruct->turnEffectsTracker) = 0; @@ -3682,7 +3682,7 @@ static void HandleEndTurn_ContinueBattle(void) gBattleMainFunc = BattleTurnPassed; for (i = 0; i < BATTLE_COMMUNICATION_ENTRIES_COUNT; i++) gBattleCommunication[i] = 0; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { gBattleMons[i].status2 &= ~(STATUS2_FLINCHED); if ((gBattleMons[i].status1 & STATUS1_SLEEP) && (gBattleMons[i].status2 & STATUS2_MULTIPLETURNS)) @@ -3742,7 +3742,7 @@ void BattleTurnPassed(void) gBattleStruct->field_DA++; } - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { gActionForBanks[i] = ACTION_INIT_VALUE; gChosenMovesByBanks[i] = MOVE_NONE; @@ -3751,7 +3751,7 @@ void BattleTurnPassed(void) for (i = 0; i < 4; i++) *(gBattleStruct->monToSwitchIntoId + i) = 6; - *(&gBattleStruct->field_91) = gAbsentBankFlags; + *(&gBattleStruct->field_91) = gAbsentBattlerFlags; BattleHandleAddTextPrinter(gText_EmptyString3, 0); gBattleMainFunc = HandleTurnActionSelectionState; gRandomTurnNumber = Random(); @@ -3768,54 +3768,54 @@ u8 IsRunningFromBattleImpossible(void) u8 side; s32 i; - if (gBattleMons[gActiveBank].item == ITEM_ENIGMA_BERRY) - holdEffect = gEnigmaBerries[gActiveBank].holdEffect; + if (gBattleMons[gActiveBattler].item == ITEM_ENIGMA_BERRY) + holdEffect = gEnigmaBerries[gActiveBattler].holdEffect; else - holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBank].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item); - gStringBank = gActiveBank; + gStringBank = gActiveBattler; if (holdEffect == HOLD_EFFECT_CAN_ALWAYS_RUN) return 0; if (gBattleTypeFlags & BATTLE_TYPE_LINK) return 0; - if (gBattleMons[gActiveBank].ability == ABILITY_RUN_AWAY) + if (gBattleMons[gActiveBattler].ability == ABILITY_RUN_AWAY) return 0; - side = GetBankSide(gActiveBank); + side = GetBattlerSide(gActiveBattler); - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (side != GetBankSide(i) + if (side != GetBattlerSide(i) && gBattleMons[i].ability == ABILITY_SHADOW_TAG) { - gBattleScripting.bank = i; + gBattleScripting.battler = i; gLastUsedAbility = gBattleMons[i].ability; gBattleCommunication[MULTISTRING_CHOOSER] = 2; return 2; } - if (side != GetBankSide(i) - && gBattleMons[gActiveBank].ability != ABILITY_LEVITATE - && gBattleMons[gActiveBank].type1 != TYPE_FLYING - && gBattleMons[gActiveBank].type2 != TYPE_FLYING + if (side != GetBattlerSide(i) + && gBattleMons[gActiveBattler].ability != ABILITY_LEVITATE + && gBattleMons[gActiveBattler].type1 != TYPE_FLYING + && gBattleMons[gActiveBattler].type2 != TYPE_FLYING && gBattleMons[i].ability == ABILITY_ARENA_TRAP) { - gBattleScripting.bank = i; + gBattleScripting.battler = i; gLastUsedAbility = gBattleMons[i].ability; gBattleCommunication[MULTISTRING_CHOOSER] = 2; return 2; } } - i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBank, ABILITY_MAGNET_PULL, 0, 0); - if (i != 0 && (gBattleMons[gActiveBank].type1 == TYPE_STEEL || gBattleMons[gActiveBank].type2 == TYPE_STEEL)) + i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBattler, ABILITY_MAGNET_PULL, 0, 0); + if (i != 0 && (gBattleMons[gActiveBattler].type1 == TYPE_STEEL || gBattleMons[gActiveBattler].type2 == TYPE_STEEL)) { - gBattleScripting.bank = i - 1; + gBattleScripting.battler = i - 1; gLastUsedAbility = gBattleMons[i - 1].ability; gBattleCommunication[MULTISTRING_CHOOSER] = 2; return 2; } - if ((gBattleMons[gActiveBank].status2 & (STATUS2_ESCAPE_PREVENTION | STATUS2_WRAPPED)) - || (gStatuses3[gActiveBank] & STATUS3_ROOTED)) + if ((gBattleMons[gActiveBattler].status2 & (STATUS2_ESCAPE_PREVENTION | STATUS2_WRAPPED)) + || (gStatuses3[gActiveBattler] & STATUS3_ROOTED)) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; return 1; @@ -3848,7 +3848,7 @@ void sub_803BDA0(u8 bank) for (i = 0; i < 3; i++) { *(bank * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; - *((bank ^ BIT_MON) * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + *((bank ^ BIT_FLANK) * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; } } else @@ -3878,91 +3878,91 @@ static void HandleTurnActionSelectionState(void) s32 i; gBattleCommunication[ACTIONS_CONFIRMED_COUNT] = 0; - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - u8 position = GetBankPosition(gActiveBank); - switch (gBattleCommunication[gActiveBank]) + u8 position = GetBattlerPosition(gActiveBattler); + switch (gBattleCommunication[gActiveBattler]) { case STATE_TURN_START_RECORD: // recorded battle related on start of every turn RecordedBattle_CopyBankMoves(); - gBattleCommunication[gActiveBank] = STATE_BEFORE_ACTION_CHOSEN; + gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; break; case STATE_BEFORE_ACTION_CHOSEN: // choose an action - *(gBattleStruct->monToSwitchIntoId + gActiveBank) = 6; + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6; if (gBattleTypeFlags & BATTLE_TYPE_MULTI - || !(position & BIT_MON) - || gBattleStruct->field_91 & gBitTable[GetBankByPosition(position ^ BIT_MON)] - || gBattleCommunication[GetBankByPosition(position ^ BIT_MON)] == 5) + || !(position & BIT_FLANK) + || gBattleStruct->field_91 & gBitTable[GetBattlerAtPosition(position ^ BIT_FLANK)] + || gBattleCommunication[GetBattlerAtPosition(position ^ BIT_FLANK)] == 5) { - if (gBattleStruct->field_91 & gBitTable[gActiveBank]) + if (gBattleStruct->field_91 & gBitTable[gActiveBattler]) { - gActionForBanks[gActiveBank] = ACTION_NOTHING_FAINTED; + gActionForBanks[gActiveBattler] = ACTION_NOTHING_FAINTED; if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) - gBattleCommunication[gActiveBank] = STATE_WAIT_ACTION_CONFIRMED; + gBattleCommunication[gActiveBattler] = STATE_WAIT_ACTION_CONFIRMED; else - gBattleCommunication[gActiveBank] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; + gBattleCommunication[gActiveBattler] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; } else { - if (gBattleMons[gActiveBank].status2 & STATUS2_MULTIPLETURNS - || gBattleMons[gActiveBank].status2 & STATUS2_RECHARGE) + if (gBattleMons[gActiveBattler].status2 & STATUS2_MULTIPLETURNS + || gBattleMons[gActiveBattler].status2 & STATUS2_RECHARGE) { - gActionForBanks[gActiveBank] = ACTION_USE_MOVE; - gBattleCommunication[gActiveBank] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; + gActionForBanks[gActiveBattler] = ACTION_USE_MOVE; + gBattleCommunication[gActiveBattler] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; } else { EmitChooseAction(0, gActionForBanks[0], gBattleBufferB[0][1] | (gBattleBufferB[0][2] << 8)); - MarkBufferBankForExecution(gActiveBank); - gBattleCommunication[gActiveBank]++; + MarkBufferBankForExecution(gActiveBattler); + gBattleCommunication[gActiveBattler]++; } } } break; case STATE_WAIT_ACTION_CHOSEN: // try to perform an action - if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + if (!(gBattleExecBuffer & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { - RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][1]); - gActionForBanks[gActiveBank] = gBattleBufferB[gActiveBank][1]; + RecordedBattle_SetBankAction(gActiveBattler, gBattleBufferB[gActiveBattler][1]); + gActionForBanks[gActiveBattler] = gBattleBufferB[gActiveBattler][1]; - switch (gBattleBufferB[gActiveBank][1]) + switch (gBattleBufferB[gActiveBattler][1]) { case ACTION_USE_MOVE: if (AreAllMovesUnusable()) { - gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT; - *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; - *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_WAIT_ACTION_CONFIRMED_STANDBY; - *(gBattleStruct->moveTarget + gActiveBank) = gBattleBufferB[gActiveBank][3]; + gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; + *(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE; + *(gBattleStruct->stateIdAfterSelScript + gActiveBattler) = STATE_WAIT_ACTION_CONFIRMED_STANDBY; + *(gBattleStruct->moveTarget + gActiveBattler) = gBattleBufferB[gActiveBattler][3]; return; } - else if (gDisableStructs[gActiveBank].encoredMove != 0) + else if (gDisableStructs[gActiveBattler].encoredMove != 0) { - gChosenMovesByBanks[gActiveBank] = gDisableStructs[gActiveBank].encoredMove; - *(gBattleStruct->chosenMovePositions + gActiveBank) = gDisableStructs[gActiveBank].encoredMovePos; - gBattleCommunication[gActiveBank] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; + gChosenMovesByBanks[gActiveBattler] = gDisableStructs[gActiveBattler].encoredMove; + *(gBattleStruct->chosenMovePositions + gActiveBattler) = gDisableStructs[gActiveBattler].encoredMovePos; + gBattleCommunication[gActiveBattler] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; return; } else { struct ChooseMoveStruct moveInfo; - moveInfo.species = gBattleMons[gActiveBank].species; - moveInfo.monType1 = gBattleMons[gActiveBank].type1; - moveInfo.monType2 = gBattleMons[gActiveBank].type2; + moveInfo.species = gBattleMons[gActiveBattler].species; + moveInfo.monType1 = gBattleMons[gActiveBattler].type1; + moveInfo.monType2 = gBattleMons[gActiveBattler].type2; for (i = 0; i < 4; i++) { - moveInfo.moves[i] = gBattleMons[gActiveBank].moves[i]; - moveInfo.currentPp[i] = gBattleMons[gActiveBank].pp[i]; + moveInfo.moves[i] = gBattleMons[gActiveBattler].moves[i]; + moveInfo.currentPp[i] = gBattleMons[gActiveBattler].pp[i]; moveInfo.maxPp[i] = CalculatePPWithBonus( - gBattleMons[gActiveBank].moves[i], - gBattleMons[gActiveBank].ppBonuses, + gBattleMons[gActiveBattler].moves[i], + gBattleMons[gActiveBattler].ppBonuses, i); } EmitChooseMove(0, (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) != 0, FALSE, &moveInfo); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } break; case ACTION_USE_ITEM: @@ -3971,142 +3971,142 @@ static void HandleTurnActionSelectionState(void) | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_x2000000)) { - RecordedBattle_ClearBankAction(gActiveBank, 1); - gSelectionBattleScripts[gActiveBank] = BattleScript_ActionSelectionItemsCantBeUsed; - gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT; - *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; - *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN; + RecordedBattle_ClearBankAction(gActiveBattler, 1); + gSelectionBattleScripts[gActiveBattler] = BattleScript_ActionSelectionItemsCantBeUsed; + gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; + *(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE; + *(gBattleStruct->stateIdAfterSelScript + gActiveBattler) = STATE_BEFORE_ACTION_CHOSEN; return; } else { - EmitChooseItem(0, gBattleStruct->field_60[gActiveBank]); - MarkBufferBankForExecution(gActiveBank); + EmitChooseItem(0, gBattleStruct->field_60[gActiveBattler]); + MarkBufferBankForExecution(gActiveBattler); } break; case ACTION_SWITCH: - *(gBattleStruct->field_58 + gActiveBank) = gBattlePartyID[gActiveBank]; - if (gBattleMons[gActiveBank].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION) + *(gBattleStruct->field_58 + gActiveBattler) = gBattlePartyID[gActiveBattler]; + if (gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION) || gBattleTypeFlags & BATTLE_TYPE_ARENA - || gStatuses3[gActiveBank] & STATUS3_ROOTED) + || gStatuses3[gActiveBattler] & STATUS3_ROOTED) { - EmitChoosePokemon(0, 2, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); + EmitChoosePokemon(0, 2, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); } - else if ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_SHADOW_TAG, 0, 0)) - || ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBank, ABILITY_ARENA_TRAP, 0, 0)) - && gBattleMons[gActiveBank].type1 != TYPE_FLYING - && gBattleMons[gActiveBank].type2 != TYPE_FLYING - && gBattleMons[gActiveBank].ability != ABILITY_LEVITATE) - || ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBank, ABILITY_MAGNET_PULL, 0, 0)) - && (gBattleMons[gActiveBank].type1 == TYPE_STEEL - || gBattleMons[gActiveBank].type2 == TYPE_STEEL))) + else if ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_SHADOW_TAG, 0, 0)) + || ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gActiveBattler, ABILITY_ARENA_TRAP, 0, 0)) + && gBattleMons[gActiveBattler].type1 != TYPE_FLYING + && gBattleMons[gActiveBattler].type2 != TYPE_FLYING + && gBattleMons[gActiveBattler].ability != ABILITY_LEVITATE) + || ((i = AbilityBattleEffects(ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK, gActiveBattler, ABILITY_MAGNET_PULL, 0, 0)) + && (gBattleMons[gActiveBattler].type1 == TYPE_STEEL + || gBattleMons[gActiveBattler].type2 == TYPE_STEEL))) { - EmitChoosePokemon(0, ((i - 1) << 4) | 4, 6, gLastUsedAbility, gBattleStruct->field_60[gActiveBank]); + EmitChoosePokemon(0, ((i - 1) << 4) | 4, 6, gLastUsedAbility, gBattleStruct->field_60[gActiveBattler]); } else { - if (gActiveBank == 2 && gActionForBanks[0] == ACTION_SWITCH) - EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); - else if (gActiveBank == 3 && gActionForBanks[1] == ACTION_SWITCH) - EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); + if (gActiveBattler == 2 && gActionForBanks[0] == ACTION_SWITCH) + EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); + else if (gActiveBattler == 3 && gActionForBanks[1] == ACTION_SWITCH) + EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); else - EmitChoosePokemon(0, 0, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBank]); + EmitChoosePokemon(0, 0, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); } - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); break; case ACTION_SAFARI_ZONE_BALL: if (IsPlayerPartyAndPokemonStorageFull()) { - gSelectionBattleScripts[gActiveBank] = BattleScript_PrintFullBox; - gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT; - *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; - *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN; + gSelectionBattleScripts[gActiveBattler] = BattleScript_PrintFullBox; + gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; + *(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE; + *(gBattleStruct->stateIdAfterSelScript + gActiveBattler) = STATE_BEFORE_ACTION_CHOSEN; return; } break; case ACTION_POKEBLOCK_CASE: - EmitChooseItem(0, gBattleStruct->field_60[gActiveBank]); - MarkBufferBankForExecution(gActiveBank); + EmitChooseItem(0, gBattleStruct->field_60[gActiveBattler]); + MarkBufferBankForExecution(gActiveBattler); break; case ACTION_CANCEL_PARTNER: - gBattleCommunication[gActiveBank] = 7; - gBattleCommunication[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)] = 1; - RecordedBattle_ClearBankAction(gActiveBank, 1); - if (gBattleMons[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)].status2 & STATUS2_MULTIPLETURNS - || gBattleMons[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)].status2 & STATUS2_RECHARGE) + gBattleCommunication[gActiveBattler] = 7; + gBattleCommunication[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)] = 1; + RecordedBattle_ClearBankAction(gActiveBattler, 1); + if (gBattleMons[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)].status2 & STATUS2_MULTIPLETURNS + || gBattleMons[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)].status2 & STATUS2_RECHARGE) { EmitCmd50(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); return; } - else if (gActionForBanks[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_SWITCH) + else if (gActionForBanks[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)] == ACTION_SWITCH) { - RecordedBattle_ClearBankAction(GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON), 2); + RecordedBattle_ClearBankAction(GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK), 2); } - else if (gActionForBanks[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_RUN) + else if (gActionForBanks[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)] == ACTION_RUN) { - RecordedBattle_ClearBankAction(GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON), 1); + RecordedBattle_ClearBankAction(GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK), 1); } - else if (gActionForBanks[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_USE_MOVE - && (gProtectStructs[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)].onlyStruggle - || gDisableStructs[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)].encoredMove)) + else if (gActionForBanks[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)] == ACTION_USE_MOVE + && (gProtectStructs[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)].onlyStruggle + || gDisableStructs[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)].encoredMove)) { - RecordedBattle_ClearBankAction(GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON), 1); + RecordedBattle_ClearBankAction(GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK), 1); } else if (gBattleTypeFlags & BATTLE_TYPE_PALACE - && gActionForBanks[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_USE_MOVE) + && gActionForBanks[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)] == ACTION_USE_MOVE) { gRngValue = gBattlePalaceMoveSelectionRngValue; - RecordedBattle_ClearBankAction(GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON), 1); + RecordedBattle_ClearBankAction(GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK), 1); } else { - RecordedBattle_ClearBankAction(GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON), 3); + RecordedBattle_ClearBankAction(GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK), 3); } EmitCmd50(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); return; } if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000) - && gBattleBufferB[gActiveBank][1] == ACTION_RUN) + && gBattleBufferB[gActiveBattler][1] == ACTION_RUN) { - gSelectionBattleScripts[gActiveBank] = BattleScript_AskIfWantsToForfeitMatch; - gBattleCommunication[gActiveBank] = 8; - *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; - *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN; + gSelectionBattleScripts[gActiveBattler] = BattleScript_AskIfWantsToForfeitMatch; + gBattleCommunication[gActiveBattler] = 8; + *(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE; + *(gBattleStruct->stateIdAfterSelScript + gActiveBattler) = STATE_BEFORE_ACTION_CHOSEN; return; } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) - && gBattleBufferB[gActiveBank][1] == ACTION_RUN) + && gBattleBufferB[gActiveBattler][1] == ACTION_RUN) { BattleScriptExecute(BattleScript_PrintCantRunFromTrainer); - gBattleCommunication[gActiveBank] = 1; + gBattleCommunication[gActiveBattler] = 1; } else if (IsRunningFromBattleImpossible() - && gBattleBufferB[gActiveBank][1] == ACTION_RUN) + && gBattleBufferB[gActiveBattler][1] == ACTION_RUN) { - gSelectionBattleScripts[gActiveBank] = BattleScript_PrintCantEscapeFromBattle; - gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT; - *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; - *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_BEFORE_ACTION_CHOSEN; + gSelectionBattleScripts[gActiveBattler] = BattleScript_PrintCantEscapeFromBattle; + gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; + *(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE; + *(gBattleStruct->stateIdAfterSelScript + gActiveBattler) = STATE_BEFORE_ACTION_CHOSEN; return; } else { - gBattleCommunication[gActiveBank]++; + gBattleCommunication[gActiveBattler]++; } } break; case STATE_WAIT_ACTION_CASE_CHOSEN: - if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + if (!(gBattleExecBuffer & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { - switch (gActionForBanks[gActiveBank]) + switch (gActionForBanks[gActiveBattler]) { case ACTION_USE_MOVE: - switch (gBattleBufferB[gActiveBank][1]) + switch (gBattleBufferB[gActiveBattler][1]) { case 3: case 4: @@ -4115,107 +4115,107 @@ static void HandleTurnActionSelectionState(void) case 7: case 8: case 9: - gActionForBanks[gActiveBank] = gBattleBufferB[gActiveBank][1]; + gActionForBanks[gActiveBattler] = gBattleBufferB[gActiveBattler][1]; return; case 15: - gActionForBanks[gActiveBank] = ACTION_SWITCH; + gActionForBanks[gActiveBattler] = ACTION_SWITCH; sub_803CDF8(); return; default: sub_818603C(2); - if ((gBattleBufferB[gActiveBank][2] | (gBattleBufferB[gActiveBank][3] << 8)) == 0xFFFF) + if ((gBattleBufferB[gActiveBattler][2] | (gBattleBufferB[gActiveBattler][3] << 8)) == 0xFFFF) { - gBattleCommunication[gActiveBank] = 1; - RecordedBattle_ClearBankAction(gActiveBank, 1); + gBattleCommunication[gActiveBattler] = 1; + RecordedBattle_ClearBankAction(gActiveBattler, 1); } else if (TrySetCantSelectMoveBattleScript()) { - RecordedBattle_ClearBankAction(gActiveBank, 1); - gBattleCommunication[gActiveBank] = STATE_SELECTION_SCRIPT; - *(gBattleStruct->selectionScriptFinished + gActiveBank) = FALSE; - gBattleBufferB[gActiveBank][1] = 0; - *(gBattleStruct->stateIdAfterSelScript + gActiveBank) = STATE_WAIT_ACTION_CHOSEN; + RecordedBattle_ClearBankAction(gActiveBattler, 1); + gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; + *(gBattleStruct->selectionScriptFinished + gActiveBattler) = FALSE; + gBattleBufferB[gActiveBattler][1] = 0; + *(gBattleStruct->stateIdAfterSelScript + gActiveBattler) = STATE_WAIT_ACTION_CHOSEN; return; } else { if (!(gBattleTypeFlags & BATTLE_TYPE_PALACE)) { - RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][2]); - RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][3]); + RecordedBattle_SetBankAction(gActiveBattler, gBattleBufferB[gActiveBattler][2]); + RecordedBattle_SetBankAction(gActiveBattler, gBattleBufferB[gActiveBattler][3]); } - *(gBattleStruct->chosenMovePositions + gActiveBank) = gBattleBufferB[gActiveBank][2]; - gChosenMovesByBanks[gActiveBank] = gBattleMons[gActiveBank].moves[*(gBattleStruct->chosenMovePositions + gActiveBank)]; - *(gBattleStruct->moveTarget + gActiveBank) = gBattleBufferB[gActiveBank][3]; - gBattleCommunication[gActiveBank]++; + *(gBattleStruct->chosenMovePositions + gActiveBattler) = gBattleBufferB[gActiveBattler][2]; + gChosenMovesByBanks[gActiveBattler] = gBattleMons[gActiveBattler].moves[*(gBattleStruct->chosenMovePositions + gActiveBattler)]; + *(gBattleStruct->moveTarget + gActiveBattler) = gBattleBufferB[gActiveBattler][3]; + gBattleCommunication[gActiveBattler]++; } break; } break; case ACTION_USE_ITEM: - if ((gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8)) == 0) + if ((gBattleBufferB[gActiveBattler][1] | (gBattleBufferB[gActiveBattler][2] << 8)) == 0) { - gBattleCommunication[gActiveBank] = 1; + gBattleCommunication[gActiveBattler] = 1; } else { - gLastUsedItem = (gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8)); - gBattleCommunication[gActiveBank]++; + gLastUsedItem = (gBattleBufferB[gActiveBattler][1] | (gBattleBufferB[gActiveBattler][2] << 8)); + gBattleCommunication[gActiveBattler]++; } break; case ACTION_SWITCH: - if (gBattleBufferB[gActiveBank][1] == 6) + if (gBattleBufferB[gActiveBattler][1] == 6) { - gBattleCommunication[gActiveBank] = 1; - RecordedBattle_ClearBankAction(gActiveBank, 1); + gBattleCommunication[gActiveBattler] = 1; + RecordedBattle_ClearBankAction(gActiveBattler, 1); } else { sub_803CDF8(); - gBattleCommunication[gActiveBank]++; + gBattleCommunication[gActiveBattler]++; } break; case ACTION_RUN: gHitMarker |= HITMARKER_RUN; - gBattleCommunication[gActiveBank]++; + gBattleCommunication[gActiveBattler]++; break; case ACTION_WATCHES_CAREFULLY: - gBattleCommunication[gActiveBank]++; + gBattleCommunication[gActiveBattler]++; break; case ACTION_SAFARI_ZONE_BALL: - gBattleCommunication[gActiveBank]++; + gBattleCommunication[gActiveBattler]++; break; case ACTION_POKEBLOCK_CASE: - if ((gBattleBufferB[gActiveBank][1] | (gBattleBufferB[gActiveBank][2] << 8)) != 0) + if ((gBattleBufferB[gActiveBattler][1] | (gBattleBufferB[gActiveBattler][2] << 8)) != 0) { - gBattleCommunication[gActiveBank]++; + gBattleCommunication[gActiveBattler]++; } else { - gBattleCommunication[gActiveBank] = STATE_BEFORE_ACTION_CHOSEN; + gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; } break; case ACTION_GO_NEAR: - gBattleCommunication[gActiveBank]++; + gBattleCommunication[gActiveBattler]++; break; case ACTION_SAFARI_ZONE_RUN: gHitMarker |= HITMARKER_RUN; - gBattleCommunication[gActiveBank]++; + gBattleCommunication[gActiveBattler]++; break; case ACTION_9: - gBattleCommunication[gActiveBank]++; + gBattleCommunication[gActiveBattler]++; break; } } break; case STATE_WAIT_ACTION_CONFIRMED_STANDBY: - if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + if (!(gBattleExecBuffer & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { i = (sub_803CDB8() != 0); if (((gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_DOUBLE)) != BATTLE_TYPE_DOUBLE) - || (position & BIT_MON) - || (*(&gBattleStruct->field_91) & gBitTable[GetBankByPosition(position ^ BIT_MON)])) + || (position & BIT_FLANK) + || (*(&gBattleStruct->field_91) & gBitTable[GetBattlerAtPosition(position ^ BIT_FLANK)])) { EmitLinkStandbyMsg(0, 0, i); } @@ -4223,76 +4223,76 @@ static void HandleTurnActionSelectionState(void) { EmitLinkStandbyMsg(0, 1, i); } - MarkBufferBankForExecution(gActiveBank); - gBattleCommunication[gActiveBank]++; + MarkBufferBankForExecution(gActiveBattler); + gBattleCommunication[gActiveBattler]++; } break; case STATE_WAIT_ACTION_CONFIRMED: - if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + if (!(gBattleExecBuffer & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { gBattleCommunication[ACTIONS_CONFIRMED_COUNT]++; } break; case STATE_SELECTION_SCRIPT: - if (*(gBattleStruct->selectionScriptFinished + gActiveBank)) + if (*(gBattleStruct->selectionScriptFinished + gActiveBattler)) { - gBattleCommunication[gActiveBank] = *(gBattleStruct->stateIdAfterSelScript + gActiveBank); + gBattleCommunication[gActiveBattler] = *(gBattleStruct->stateIdAfterSelScript + gActiveBattler); } else { - gBankAttacker = gActiveBank; - gBattlescriptCurrInstr = gSelectionBattleScripts[gActiveBank]; - if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + gBattleAttacker = gActiveBattler; + gBattlescriptCurrInstr = gSelectionBattleScripts[gActiveBattler]; + if (!(gBattleExecBuffer & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]](); } - gSelectionBattleScripts[gActiveBank] = gBattlescriptCurrInstr; + gSelectionBattleScripts[gActiveBattler] = gBattlescriptCurrInstr; } break; case STATE_WAIT_SET_BEFORE_ACTION: - if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + if (!(gBattleExecBuffer & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { - gBattleCommunication[gActiveBank] = 1; + gBattleCommunication[gActiveBattler] = 1; } break; case STATE_SELECTION_SCRIPT_MAY_RUN: - if (*(gBattleStruct->selectionScriptFinished + gActiveBank)) + if (*(gBattleStruct->selectionScriptFinished + gActiveBattler)) { - if (gBattleBufferB[gActiveBank][1] == 13) + if (gBattleBufferB[gActiveBattler][1] == 13) { gHitMarker |= HITMARKER_RUN; - gActionForBanks[gActiveBank] = ACTION_RUN; - gBattleCommunication[gActiveBank] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; + gActionForBanks[gActiveBattler] = ACTION_RUN; + gBattleCommunication[gActiveBattler] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; } else { - RecordedBattle_ClearBankAction(gActiveBank, 1); - gBattleCommunication[gActiveBank] = *(gBattleStruct->stateIdAfterSelScript + gActiveBank); + RecordedBattle_ClearBankAction(gActiveBattler, 1); + gBattleCommunication[gActiveBattler] = *(gBattleStruct->stateIdAfterSelScript + gActiveBattler); } } else { - gBankAttacker = gActiveBank; - gBattlescriptCurrInstr = gSelectionBattleScripts[gActiveBank]; - if (!(gBattleExecBuffer & ((gBitTable[gActiveBank]) | (0xF0000000) | (gBitTable[gActiveBank] << 4) | (gBitTable[gActiveBank] << 8) | (gBitTable[gActiveBank] << 0xC)))) + gBattleAttacker = gActiveBattler; + gBattlescriptCurrInstr = gSelectionBattleScripts[gActiveBattler]; + if (!(gBattleExecBuffer & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { gBattleScriptingCommandsTable[gBattlescriptCurrInstr[0]](); } - gSelectionBattleScripts[gActiveBank] = gBattlescriptCurrInstr; + gSelectionBattleScripts[gActiveBattler] = gBattlescriptCurrInstr; } break; } } // check if everyone chose actions - if (gBattleCommunication[ACTIONS_CONFIRMED_COUNT] == gBattleBanksCount) + if (gBattleCommunication[ACTIONS_CONFIRMED_COUNT] == gBattlersCount) { sub_818603C(1); gBattleMainFunc = SetActionsAndBanksTurnOrder; if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) { - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gActionForBanks[i] == ACTION_SWITCH) sub_80571DC(i, *(gBattleStruct->monToSwitchIntoId + i)); @@ -4305,13 +4305,13 @@ static bool8 sub_803CDB8(void) { s32 i, var; - for (var = 0, i = 0; i < gBattleBanksCount; i++) + for (var = 0, i = 0; i < gBattlersCount; i++) { if (gBattleCommunication[i] == 5) var++; } - if (var + 1 == gBattleBanksCount) + if (var + 1 == gBattlersCount) return TRUE; else return FALSE; @@ -4319,18 +4319,18 @@ static bool8 sub_803CDB8(void) static void sub_803CDF8(void) { - *(gBattleStruct->monToSwitchIntoId + gActiveBank) = gBattleBufferB[gActiveBank][1]; - RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][1]); + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = gBattleBufferB[gActiveBattler][1]; + RecordedBattle_SetBankAction(gActiveBattler, gBattleBufferB[gActiveBattler][1]); if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI) { - *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 0) &= 0xF; - *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBank][2] & 0xF0); - *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 1) = gBattleBufferB[gActiveBank][3]; + *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 0) &= 0xF; + *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBattler][2] & 0xF0); + *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 1) = gBattleBufferB[gActiveBattler][3]; - *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 0) &= (0xF0); - *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBank][2] & 0xF0) >> 4; - *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleBufferB[gActiveBank][3]; + *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 0) &= (0xF0); + *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBattler][2] & 0xF0) >> 4; + *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleBufferB[gActiveBattler][3]; } } @@ -4340,9 +4340,9 @@ void SwapTurnOrder(u8 id1, u8 id2) gActionsByTurnOrder[id1] = gActionsByTurnOrder[id2]; gActionsByTurnOrder[id2] = temp; - temp = gBanksByTurnOrder[id1]; - gBanksByTurnOrder[id1] = gBanksByTurnOrder[id2]; - gBanksByTurnOrder[id2] = temp; + temp = gBattleTurnOrder[id1]; + gBattleTurnOrder[id1] = gBattleTurnOrder[id2]; + gBattleTurnOrder[id2] = temp; } u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves) @@ -4392,7 +4392,7 @@ u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves) // badge boost if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER)) && FlagGet(FLAG_BADGE03_GET) - && GetBankSide(bank1) == SIDE_PLAYER) + && GetBattlerSide(bank1) == B_SIDE_PLAYER) { speedBank1 = (speedBank1 * 110) / 100; } @@ -4426,7 +4426,7 @@ u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves) // badge boost if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER)) && FlagGet(FLAG_BADGE03_GET) - && GetBankSide(bank2) == SIDE_PLAYER) + && GetBattlerSide(bank2) == B_SIDE_PLAYER) { speedBank2 = (speedBank2 * 110) / 100; } @@ -4507,10 +4507,10 @@ static void SetActionsAndBanksTurnOrder(void) if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) { - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - gActionsByTurnOrder[var] = gActionForBanks[gActiveBank]; - gBanksByTurnOrder[var] = gActiveBank; + gActionsByTurnOrder[var] = gActionForBanks[gActiveBattler]; + gBattleTurnOrder[var] = gActiveBattler; var++; } } @@ -4518,9 +4518,9 @@ static void SetActionsAndBanksTurnOrder(void) { if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (gActionForBanks[gActiveBank] == ACTION_RUN) + if (gActionForBanks[gActiveBattler] == ACTION_RUN) { var = 5; break; @@ -4531,27 +4531,27 @@ static void SetActionsAndBanksTurnOrder(void) { if (gActionForBanks[0] == ACTION_RUN) { - gActiveBank = 0; + gActiveBattler = 0; var = 5; } if (gActionForBanks[2] == ACTION_RUN) { - gActiveBank = 2; + gActiveBattler = 2; var = 5; } } if (var == 5) { - gActionsByTurnOrder[0] = gActionForBanks[gActiveBank]; - gBanksByTurnOrder[0] = gActiveBank; + gActionsByTurnOrder[0] = gActionForBanks[gActiveBattler]; + gBattleTurnOrder[0] = gActiveBattler; var = 1; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (i != gActiveBank) + if (i != gActiveBattler) { gActionsByTurnOrder[var] = gActionForBanks[i]; - gBanksByTurnOrder[var] = i; + gBattleTurnOrder[var] = i; var++; } } @@ -4561,30 +4561,30 @@ static void SetActionsAndBanksTurnOrder(void) } else { - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (gActionForBanks[gActiveBank] == ACTION_USE_ITEM || gActionForBanks[gActiveBank] == ACTION_SWITCH) + if (gActionForBanks[gActiveBattler] == ACTION_USE_ITEM || gActionForBanks[gActiveBattler] == ACTION_SWITCH) { - gActionsByTurnOrder[var] = gActionForBanks[gActiveBank]; - gBanksByTurnOrder[var] = gActiveBank; + gActionsByTurnOrder[var] = gActionForBanks[gActiveBattler]; + gBattleTurnOrder[var] = gActiveBattler; var++; } } - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (gActionForBanks[gActiveBank] != ACTION_USE_ITEM && gActionForBanks[gActiveBank] != ACTION_SWITCH) + if (gActionForBanks[gActiveBattler] != ACTION_USE_ITEM && gActionForBanks[gActiveBattler] != ACTION_SWITCH) { - gActionsByTurnOrder[var] = gActionForBanks[gActiveBank]; - gBanksByTurnOrder[var] = gActiveBank; + gActionsByTurnOrder[var] = gActionForBanks[gActiveBattler]; + gBattleTurnOrder[var] = gActiveBattler; var++; } } - for (i = 0; i < gBattleBanksCount - 1; i++) + for (i = 0; i < gBattlersCount - 1; i++) { - for (j = i + 1; j < gBattleBanksCount; j++) + for (j = i + 1; j < gBattlersCount; j++) { - u8 bank1 = gBanksByTurnOrder[i]; - u8 bank2 = gBanksByTurnOrder[j]; + u8 bank1 = gBattleTurnOrder[i]; + u8 bank2 = gBattleTurnOrder[j]; if (gActionsByTurnOrder[i] != ACTION_USE_ITEM && gActionsByTurnOrder[j] != ACTION_USE_ITEM && gActionsByTurnOrder[i] != ACTION_SWITCH @@ -4606,32 +4606,32 @@ static void TurnValuesCleanUp(bool8 var0) s32 i; u8 *dataPtr; - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { if (var0) { - gProtectStructs[gActiveBank].protected = 0; - gProtectStructs[gActiveBank].endured = 0; + gProtectStructs[gActiveBattler].protected = 0; + gProtectStructs[gActiveBattler].endured = 0; } else { - dataPtr = (u8*)(&gProtectStructs[gActiveBank]); + dataPtr = (u8*)(&gProtectStructs[gActiveBattler]); for (i = 0; i < sizeof(struct ProtectStruct); i++) dataPtr[i] = 0; - if (gDisableStructs[gActiveBank].isFirstTurn) - gDisableStructs[gActiveBank].isFirstTurn--; + if (gDisableStructs[gActiveBattler].isFirstTurn) + gDisableStructs[gActiveBattler].isFirstTurn--; - if (gDisableStructs[gActiveBank].rechargeCounter) + if (gDisableStructs[gActiveBattler].rechargeCounter) { - gDisableStructs[gActiveBank].rechargeCounter--; - if (gDisableStructs[gActiveBank].rechargeCounter == 0) - gBattleMons[gActiveBank].status2 &= ~(STATUS2_RECHARGE); + gDisableStructs[gActiveBattler].rechargeCounter--; + if (gDisableStructs[gActiveBattler].rechargeCounter == 0) + gBattleMons[gActiveBattler].status2 &= ~(STATUS2_RECHARGE); } } - if (gDisableStructs[gActiveBank].substituteHP == 0) - gBattleMons[gActiveBank].status2 &= ~(STATUS2_SUBSTITUTE); + if (gDisableStructs[gActiveBattler].substituteHP == 0) + gBattleMons[gActiveBattler].status2 &= ~(STATUS2_SUBSTITUTE); } gSideTimers[0].followmeTimer = 0; @@ -4640,10 +4640,10 @@ static void TurnValuesCleanUp(bool8 var0) static void SpecialStatusesClear(void) { - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { s32 i; - u8 *dataPtr = (u8*)(&gSpecialStatuses[gActiveBank]); + u8 *dataPtr = (u8*)(&gSpecialStatuses[gActiveBattler]); for (i = 0; i < sizeof(struct SpecialStatus); i++) dataPtr[i] = 0; @@ -4654,14 +4654,14 @@ static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void) { if (!(gHitMarker & HITMARKER_RUN)) { - while (gBattleStruct->focusPunchBank < gBattleBanksCount) + while (gBattleStruct->focusPunchBank < gBattlersCount) { - gActiveBank = gBankAttacker = gBattleStruct->focusPunchBank; + gActiveBattler = gBattleAttacker = gBattleStruct->focusPunchBank; gBattleStruct->focusPunchBank++; - if (gChosenMovesByBanks[gActiveBank] == MOVE_FOCUS_PUNCH - && !(gBattleMons[gActiveBank].status1 & STATUS1_SLEEP) - && !(gDisableStructs[gBankAttacker].truantCounter) - && !(gProtectStructs[gActiveBank].onlyStruggle)) + if (gChosenMovesByBanks[gActiveBattler] == MOVE_FOCUS_PUNCH + && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) + && !(gDisableStructs[gBattleAttacker].truantCounter) + && !(gProtectStructs[gActiveBattler].onlyStruggle)) { BattleScriptExecute(BattleScript_FocusPunchSetUp); return; @@ -4693,7 +4693,7 @@ static void RunTurnActionsFunctions(void) *(&gBattleStruct->savedTurnActionNumber) = gCurrentTurnActionNumber; sTurnActionsFuncsTable[gCurrentActionFuncId](); - if (gCurrentTurnActionNumber >= gBattleBanksCount) // everyone did their actions, turn finished + if (gCurrentTurnActionNumber >= gBattlersCount) // everyone did their actions, turn finished { gHitMarker &= ~(HITMARKER_x100000); gBattleMainFunc = sEndTurnFuncsTable[gBattleOutcome & 0x7F]; @@ -4716,7 +4716,7 @@ static void HandleEndTurn_BattleWon(void) { gSpecialVar_Result = gBattleOutcome; gBattleTextBuff1[0] = gBattleOutcome; - gBankAttacker = GetBankByPosition(B_POSITION_PLAYER_LEFT); + gBattleAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); gBattlescriptCurrInstr = BattleScript_LinkBattleWonOrLost; gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN); } @@ -4789,7 +4789,7 @@ static void HandleEndTurn_BattleLost(void) else { gBattleTextBuff1[0] = gBattleOutcome; - gBankAttacker = GetBankByPosition(B_POSITION_PLAYER_LEFT); + gBattleAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); gBattlescriptCurrInstr = BattleScript_LinkBattleWonOrLost; gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN); } @@ -4819,7 +4819,7 @@ static void HandleEndTurn_RanFromBattle(void) } else { - switch (gProtectStructs[gBankAttacker].fleeFlag) + switch (gProtectStructs[gBattleAttacker].fleeFlag) { default: gBattlescriptCurrInstr = BattleScript_GotAwaySafely; @@ -4840,7 +4840,7 @@ static void HandleEndTurn_MonFled(void) { gCurrentActionFuncId = 0; - PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBankAttacker, gBattlePartyID[gBankAttacker]); + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattleAttacker, gBattlePartyID[gBattleAttacker]); gBattlescriptCurrInstr = BattleScript_WildMonFled; gBattleMainFunc = HandleEndTurn_FinishBattle; @@ -4858,19 +4858,19 @@ static void HandleEndTurn_FinishBattle(void) | BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_FRONTIER))) { - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { if (gBattleResults.playerMon1Species == SPECIES_NONE) { - gBattleResults.playerMon1Species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES, NULL); - GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_NICKNAME, gBattleResults.playerMon1Name); + gBattleResults.playerMon1Species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES, NULL); + GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_NICKNAME, gBattleResults.playerMon1Name); } else { - gBattleResults.playerMon2Species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES, NULL); - GetMonData(&gPlayerParty[gBattlePartyID[gActiveBank]], MON_DATA_NICKNAME, gBattleResults.playerMon2Name); + gBattleResults.playerMon2Species = GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES, NULL); + GetMonData(&gPlayerParty[gBattlePartyID[gActiveBattler]], MON_DATA_NICKNAME, gBattleResults.playerMon2Name); } } } @@ -5017,9 +5017,9 @@ static void HandleAction_UseMove(void) u8 side; u8 var = 4; - gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattleAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; - if (*(&gBattleStruct->field_91) & gBitTable[gBankAttacker]) + if (*(&gBattleStruct->field_91) & gBitTable[gBattleAttacker]) { gCurrentActionFuncId = ACTION_FINISHED; return; @@ -5031,186 +5031,186 @@ static void HandleAction_UseMove(void) gMoveResultFlags = 0; gMultiHitCounter = 0; gBattleCommunication[6] = 0; - gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBankAttacker); + gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBattleAttacker); // choose move - if (gProtectStructs[gBankAttacker].onlyStruggle) + if (gProtectStructs[gBattleAttacker].onlyStruggle) { - gProtectStructs[gBankAttacker].onlyStruggle = 0; + gProtectStructs[gBattleAttacker].onlyStruggle = 0; gCurrentMove = gChosenMove = MOVE_STRUGGLE; gHitMarker |= HITMARKER_NO_PPDEDUCT; - *(gBattleStruct->moveTarget + gBankAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0); + *(gBattleStruct->moveTarget + gBattleAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0); } - else if (gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS || gBattleMons[gBankAttacker].status2 & STATUS2_RECHARGE) + else if (gBattleMons[gBattleAttacker].status2 & STATUS2_MULTIPLETURNS || gBattleMons[gBattleAttacker].status2 & STATUS2_RECHARGE) { - gCurrentMove = gChosenMove = gLockedMoves[gBankAttacker]; + gCurrentMove = gChosenMove = gLockedMoves[gBattleAttacker]; } // encore forces you to use the same move - else if (gDisableStructs[gBankAttacker].encoredMove != MOVE_NONE - && gDisableStructs[gBankAttacker].encoredMove == gBattleMons[gBankAttacker].moves[gDisableStructs[gBankAttacker].encoredMovePos]) + else if (gDisableStructs[gBattleAttacker].encoredMove != MOVE_NONE + && gDisableStructs[gBattleAttacker].encoredMove == gBattleMons[gBattleAttacker].moves[gDisableStructs[gBattleAttacker].encoredMovePos]) { - gCurrentMove = gChosenMove = gDisableStructs[gBankAttacker].encoredMove; - gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBankAttacker].encoredMovePos; - *(gBattleStruct->moveTarget + gBankAttacker) = GetMoveTarget(gCurrentMove, 0); + gCurrentMove = gChosenMove = gDisableStructs[gBattleAttacker].encoredMove; + gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBattleAttacker].encoredMovePos; + *(gBattleStruct->moveTarget + gBattleAttacker) = GetMoveTarget(gCurrentMove, 0); } // check if the encored move wasn't overwritten - else if (gDisableStructs[gBankAttacker].encoredMove != MOVE_NONE - && gDisableStructs[gBankAttacker].encoredMove != gBattleMons[gBankAttacker].moves[gDisableStructs[gBankAttacker].encoredMovePos]) + else if (gDisableStructs[gBattleAttacker].encoredMove != MOVE_NONE + && gDisableStructs[gBattleAttacker].encoredMove != gBattleMons[gBattleAttacker].moves[gDisableStructs[gBattleAttacker].encoredMovePos]) { - gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBankAttacker].encoredMovePos; - gCurrentMove = gChosenMove = gBattleMons[gBankAttacker].moves[gCurrMovePos]; - gDisableStructs[gBankAttacker].encoredMove = MOVE_NONE; - gDisableStructs[gBankAttacker].encoredMovePos = 0; - gDisableStructs[gBankAttacker].encoreTimer1 = 0; - *(gBattleStruct->moveTarget + gBankAttacker) = GetMoveTarget(gCurrentMove, 0); + gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBattleAttacker].encoredMovePos; + gCurrentMove = gChosenMove = gBattleMons[gBattleAttacker].moves[gCurrMovePos]; + gDisableStructs[gBattleAttacker].encoredMove = MOVE_NONE; + gDisableStructs[gBattleAttacker].encoredMovePos = 0; + gDisableStructs[gBattleAttacker].encoreTimer1 = 0; + *(gBattleStruct->moveTarget + gBattleAttacker) = GetMoveTarget(gCurrentMove, 0); } - else if (gBattleMons[gBankAttacker].moves[gCurrMovePos] != gChosenMovesByBanks[gBankAttacker]) + else if (gBattleMons[gBattleAttacker].moves[gCurrMovePos] != gChosenMovesByBanks[gBattleAttacker]) { - gCurrentMove = gChosenMove = gBattleMons[gBankAttacker].moves[gCurrMovePos]; - *(gBattleStruct->moveTarget + gBankAttacker) = GetMoveTarget(gCurrentMove, 0); + gCurrentMove = gChosenMove = gBattleMons[gBattleAttacker].moves[gCurrMovePos]; + *(gBattleStruct->moveTarget + gBattleAttacker) = GetMoveTarget(gCurrentMove, 0); } else { - gCurrentMove = gChosenMove = gBattleMons[gBankAttacker].moves[gCurrMovePos]; + gCurrentMove = gChosenMove = gBattleMons[gBattleAttacker].moves[gCurrMovePos]; } - if (gBattleMons[gBankAttacker].hp != 0) + if (gBattleMons[gBattleAttacker].hp != 0) { - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) gBattleResults.lastUsedMovePlayer = gCurrentMove; else gBattleResults.lastUsedMoveOpponent = gCurrentMove; } // choose target - side = GetBankSide(gBankAttacker) ^ BIT_SIDE; + side = GetBattlerSide(gBattleAttacker) ^ BIT_SIDE; if (gSideTimers[side].followmeTimer != 0 && gBattleMoves[gCurrentMove].target == MOVE_TARGET_SELECTED - && GetBankSide(gBankAttacker) != GetBankSide(gSideTimers[side].followmeTarget) + && GetBattlerSide(gBattleAttacker) != GetBattlerSide(gSideTimers[side].followmeTarget) && gBattleMons[gSideTimers[side].followmeTarget].hp != 0) { - gBankDefender = gSideTimers[side].followmeTarget; + gBattleDefender = gSideTimers[side].followmeTarget; } else if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gSideTimers[side].followmeTimer == 0 && (gBattleMoves[gCurrentMove].power != 0 || gBattleMoves[gCurrentMove].target != MOVE_TARGET_x10) - && gBattleMons[*(gBattleStruct->moveTarget + gBankAttacker)].ability != ABILITY_LIGHTNING_ROD + && gBattleMons[*(gBattleStruct->moveTarget + gBattleAttacker)].ability != ABILITY_LIGHTNING_ROD && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) { - side = GetBankSide(gBankAttacker); - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + side = GetBattlerSide(gBattleAttacker); + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (side != GetBankSide(gActiveBank) - && *(gBattleStruct->moveTarget + gBankAttacker) != gActiveBank - && gBattleMons[gActiveBank].ability == ABILITY_LIGHTNING_ROD - && BankGetTurnOrder(gActiveBank) < var) + if (side != GetBattlerSide(gActiveBattler) + && *(gBattleStruct->moveTarget + gBattleAttacker) != gActiveBattler + && gBattleMons[gActiveBattler].ability == ABILITY_LIGHTNING_ROD + && BankGetTurnOrder(gActiveBattler) < var) { - var = BankGetTurnOrder(gActiveBank); + var = BankGetTurnOrder(gActiveBattler); } } if (var == 4) { if (gBattleMoves[gChosenMove].target & MOVE_TARGET_RANDOM) { - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) { if (Random() & 1) - gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); else - gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); } else { if (Random() & 1) - gBankDefender = GetBankByPosition(B_POSITION_PLAYER_LEFT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); else - gBankDefender = GetBankByPosition(B_POSITION_PLAYER_RIGHT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); } } else { - gBankDefender = *(gBattleStruct->moveTarget + gBankAttacker); + gBattleDefender = *(gBattleStruct->moveTarget + gBattleAttacker); } - if (gAbsentBankFlags & gBitTable[gBankDefender]) + if (gAbsentBattlerFlags & gBitTable[gBattleDefender]) { - if (GetBankSide(gBankAttacker) != GetBankSide(gBankDefender)) + if (GetBattlerSide(gBattleAttacker) != GetBattlerSide(gBattleDefender)) { - gBankDefender = GetBankByPosition(GetBankPosition(gBankDefender) ^ BIT_MON); + gBattleDefender = GetBattlerAtPosition(GetBattlerPosition(gBattleDefender) ^ BIT_FLANK); } else { - gBankDefender = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_SIDE); - if (gAbsentBankFlags & gBitTable[gBankDefender]) - gBankDefender = GetBankByPosition(GetBankPosition(gBankDefender) ^ BIT_MON); + gBattleDefender = GetBattlerAtPosition(GetBattlerPosition(gBattleAttacker) ^ BIT_SIDE); + if (gAbsentBattlerFlags & gBitTable[gBattleDefender]) + gBattleDefender = GetBattlerAtPosition(GetBattlerPosition(gBattleDefender) ^ BIT_FLANK); } } } else { - gActiveBank = gBanksByTurnOrder[var]; - RecordAbilityBattle(gActiveBank, gBattleMons[gActiveBank].ability); - gSpecialStatuses[gActiveBank].lightningRodRedirected = 1; - gBankDefender = gActiveBank; + gActiveBattler = gBattleTurnOrder[var]; + RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability); + gSpecialStatuses[gActiveBattler].lightningRodRedirected = 1; + gBattleDefender = gActiveBattler; } } else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && gBattleMoves[gChosenMove].target & MOVE_TARGET_RANDOM) { - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) { if (Random() & 1) - gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); else - gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); } else { if (Random() & 1) - gBankDefender = GetBankByPosition(B_POSITION_PLAYER_LEFT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); else - gBankDefender = GetBankByPosition(B_POSITION_PLAYER_RIGHT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); } - if (gAbsentBankFlags & gBitTable[gBankDefender] - && GetBankSide(gBankAttacker) != GetBankSide(gBankDefender)) + if (gAbsentBattlerFlags & gBitTable[gBattleDefender] + && GetBattlerSide(gBattleAttacker) != GetBattlerSide(gBattleDefender)) { - gBankDefender = GetBankByPosition(GetBankPosition(gBankDefender) ^ BIT_MON); + gBattleDefender = GetBattlerAtPosition(GetBattlerPosition(gBattleDefender) ^ BIT_FLANK); } } else { - gBankDefender = *(gBattleStruct->moveTarget + gBankAttacker); - if (gAbsentBankFlags & gBitTable[gBankDefender]) + gBattleDefender = *(gBattleStruct->moveTarget + gBattleAttacker); + if (gAbsentBattlerFlags & gBitTable[gBattleDefender]) { - if (GetBankSide(gBankAttacker) != GetBankSide(gBankDefender)) + if (GetBattlerSide(gBattleAttacker) != GetBattlerSide(gBattleDefender)) { - gBankDefender = GetBankByPosition(GetBankPosition(gBankDefender) ^ BIT_MON); + gBattleDefender = GetBattlerAtPosition(GetBattlerPosition(gBattleDefender) ^ BIT_FLANK); } else { - gBankDefender = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_SIDE); - if (gAbsentBankFlags & gBitTable[gBankDefender]) - gBankDefender = GetBankByPosition(GetBankPosition(gBankDefender) ^ BIT_MON); + gBattleDefender = GetBattlerAtPosition(GetBattlerPosition(gBattleAttacker) ^ BIT_SIDE); + if (gAbsentBattlerFlags & gBitTable[gBattleDefender]) + gBattleDefender = GetBattlerAtPosition(GetBattlerPosition(gBattleDefender) ^ BIT_FLANK); } } } // choose battlescript if (gBattleTypeFlags & BATTLE_TYPE_PALACE - && gProtectStructs[gBankAttacker].flag_x10) + && gProtectStructs[gBattleAttacker].flag_x10) { - if (gBattleMons[gBankAttacker].hp == 0) + if (gBattleMons[gBattleAttacker].hp == 0) { gCurrentActionFuncId = 12; return; } - else if (gPalaceSelectionBattleScripts[gBankAttacker] != NULL) + else if (gPalaceSelectionBattleScripts[gBattleAttacker] != NULL) { gBattleCommunication[MULTISTRING_CHOOSER] = 4; - gBattlescriptCurrInstr = gPalaceSelectionBattleScripts[gBankAttacker]; - gPalaceSelectionBattleScripts[gBankAttacker] = NULL; + gBattlescriptCurrInstr = gPalaceSelectionBattleScripts[gBattleAttacker]; + gPalaceSelectionBattleScripts[gBattleAttacker] = NULL; } else { @@ -5224,22 +5224,22 @@ static void HandleAction_UseMove(void) } if (gBattleTypeFlags & BATTLE_TYPE_ARENA) - sub_81A56E8(gBankAttacker); + sub_81A56E8(gBattleAttacker); gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; } static void HandleAction_Switch(void) { - gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattleAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - gActionSelectionCursor[gBankAttacker] = 0; - gMoveSelectionCursor[gBankAttacker] = 0; + gActionSelectionCursor[gBattleAttacker] = 0; + gMoveSelectionCursor[gBattleAttacker] = 0; - PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBankAttacker, *(gBattleStruct->field_58 + gBankAttacker)) + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattleAttacker, *(gBattleStruct->field_58 + gBattleAttacker)) - gBattleScripting.bank = gBankAttacker; + gBattleScripting.battler = gBattleAttacker; gBattlescriptCurrInstr = BattleScript_ActionSwitch; gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; @@ -5249,11 +5249,11 @@ static void HandleAction_Switch(void) static void HandleAction_UseItem(void) { - gBankAttacker = gBankDefender = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattleAttacker = gBattleDefender = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - ClearFuryCutterDestinyBondGrudge(gBankAttacker); - gLastUsedItem = gBattleBufferB[gBankAttacker][1] | (gBattleBufferB[gBankAttacker][2] << 8); + ClearFuryCutterDestinyBondGrudge(gBattleAttacker); + gLastUsedItem = gBattleBufferB[gBattleAttacker][1] | (gBattleBufferB[gBattleAttacker][2] << 8); if (gLastUsedItem <= ITEM_PREMIER_BALL) // is ball { @@ -5263,38 +5263,38 @@ static void HandleAction_UseItem(void) { gBattlescriptCurrInstr = gBattlescriptsForRunningByItem[0]; } - else if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + else if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) { gBattlescriptCurrInstr = gBattlescriptsForUsingItem[0]; } else { - gBattleScripting.bank = gBankAttacker; + gBattleScripting.battler = gBattleAttacker; - switch (*(gBattleStruct->AI_itemType + (gBankAttacker >> 1))) + switch (*(gBattleStruct->AI_itemType + (gBattleAttacker >> 1))) { case AI_ITEM_FULL_RESTORE: case AI_ITEM_HEAL_HP: break; case AI_ITEM_CURE_CONDITION: gBattleCommunication[MULTISTRING_CHOOSER] = 0; - if (*(gBattleStruct->AI_itemFlags + gBankAttacker / 2) & 1) + if (*(gBattleStruct->AI_itemFlags + gBattleAttacker / 2) & 1) { - if (*(gBattleStruct->AI_itemFlags + gBankAttacker / 2) & 0x3E) + if (*(gBattleStruct->AI_itemFlags + gBattleAttacker / 2) & 0x3E) gBattleCommunication[MULTISTRING_CHOOSER] = 5; } else { - while (!(*(gBattleStruct->AI_itemFlags + gBankAttacker / 2) & 1)) + while (!(*(gBattleStruct->AI_itemFlags + gBattleAttacker / 2) & 1)) { - *(gBattleStruct->AI_itemFlags + gBankAttacker / 2) >>= 1; + *(gBattleStruct->AI_itemFlags + gBattleAttacker / 2) >>= 1; gBattleCommunication[MULTISTRING_CHOOSER]++; } } break; case AI_ITEM_X_STAT: gBattleCommunication[MULTISTRING_CHOOSER] = 4; - if (*(gBattleStruct->AI_itemFlags + (gBankAttacker >> 1)) & 0x80) + if (*(gBattleStruct->AI_itemFlags + (gBattleAttacker >> 1)) & 0x80) { gBattleCommunication[MULTISTRING_CHOOSER] = 5; } @@ -5303,9 +5303,9 @@ static void HandleAction_UseItem(void) PREPARE_STAT_BUFFER(gBattleTextBuff1, STAT_ATK) PREPARE_STRING_BUFFER(gBattleTextBuff2, 0xD2) - while (!((*(gBattleStruct->AI_itemFlags + (gBankAttacker >> 1))) & 1)) + while (!((*(gBattleStruct->AI_itemFlags + (gBattleAttacker >> 1))) & 1)) { - *(gBattleStruct->AI_itemFlags + gBankAttacker / 2) >>= 1; + *(gBattleStruct->AI_itemFlags + gBattleAttacker / 2) >>= 1; gBattleTextBuff1[2]++; } @@ -5321,7 +5321,7 @@ static void HandleAction_UseItem(void) break; } - gBattlescriptCurrInstr = gBattlescriptsForUsingItem[*(gBattleStruct->AI_itemType + gBankAttacker / 2)]; + gBattlescriptCurrInstr = gBattlescriptsForUsingItem[*(gBattleStruct->AI_itemType + gBattleAttacker / 2)]; } gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; } @@ -5399,7 +5399,7 @@ bool8 TryRunFromBattle(u8 bank) if (effect) { - gCurrentTurnActionNumber = gBattleBanksCount; + gCurrentTurnActionNumber = gBattlersCount; gBattleOutcome = B_OUTCOME_RAN; } @@ -5408,22 +5408,22 @@ bool8 TryRunFromBattle(u8 bank) static void HandleAction_Run(void) { - gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattleAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) { - gCurrentTurnActionNumber = gBattleBanksCount; + gCurrentTurnActionNumber = gBattlersCount; - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { - if (gActionForBanks[gActiveBank] == ACTION_RUN) + if (gActionForBanks[gActiveBattler] == ACTION_RUN) gBattleOutcome |= B_OUTCOME_LOST; } else { - if (gActionForBanks[gActiveBank] == ACTION_RUN) + if (gActionForBanks[gActiveBattler] == ACTION_RUN) gBattleOutcome |= B_OUTCOME_WON; } } @@ -5433,11 +5433,11 @@ static void HandleAction_Run(void) } else { - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) { - if (!TryRunFromBattle(gBankAttacker)) // failed to run away + if (!TryRunFromBattle(gBattleAttacker)) // failed to run away { - ClearFuryCutterDestinyBondGrudge(gBankAttacker); + ClearFuryCutterDestinyBondGrudge(gBattleAttacker); gBattleCommunication[MULTISTRING_CHOOSER] = 3; gBattlescriptCurrInstr = BattleScript_PrintFailedToRunString; gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; @@ -5445,7 +5445,7 @@ static void HandleAction_Run(void) } else { - if (gBattleMons[gBankAttacker].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) + if (gBattleMons[gBattleAttacker].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) { gBattleCommunication[MULTISTRING_CHOOSER] = 4; gBattlescriptCurrInstr = BattleScript_PrintFailedToRunString; @@ -5453,7 +5453,7 @@ static void HandleAction_Run(void) } else { - gCurrentTurnActionNumber = gBattleBanksCount; + gCurrentTurnActionNumber = gBattlersCount; gBattleOutcome = B_OUTCOME_POKE_FLED; } } @@ -5462,7 +5462,7 @@ static void HandleAction_Run(void) static void HandleAction_WatchesCarefully(void) { - gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattleAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; gBattlescriptCurrInstr = gBattlescriptsForSafariActions[0]; @@ -5471,7 +5471,7 @@ static void HandleAction_WatchesCarefully(void) static void HandleAction_SafariZoneBallThrow(void) { - gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattleAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; gNumSafariBalls--; @@ -5482,11 +5482,11 @@ static void HandleAction_SafariZoneBallThrow(void) static void HandleAction_ThrowPokeblock(void) { - gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattleAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - gBattleCommunication[MULTISTRING_CHOOSER] = gBattleBufferB[gBankAttacker][1] - 1; - gLastUsedItem = gBattleBufferB[gBankAttacker][2]; + gBattleCommunication[MULTISTRING_CHOOSER] = gBattleBufferB[gBattleAttacker][1] - 1; + gLastUsedItem = gBattleBufferB[gBattleAttacker][2]; if (gBattleResults.field_1F < 0xFF) gBattleResults.field_1F++; @@ -5506,7 +5506,7 @@ static void HandleAction_ThrowPokeblock(void) static void HandleAction_GoNear(void) { - gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattleAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; @@ -5533,19 +5533,19 @@ static void HandleAction_GoNear(void) static void HandleAction_SafriZoneRun(void) { - gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattleAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; PlaySE(SE_NIGERU); - gCurrentTurnActionNumber = gBattleBanksCount; + gCurrentTurnActionNumber = gBattlersCount; gBattleOutcome = B_OUTCOME_RAN; } static void HandleAction_Action9(void) { - gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBattleAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBankAttacker, gBattlePartyID[gBankAttacker]) + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattleAttacker, gBattlePartyID[gBattleAttacker]) gBattlescriptCurrInstr = gBattlescriptsForSafariActions[3]; gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; @@ -5574,7 +5574,7 @@ static void HandleAction_NothingIsFainted(void) static void HandleAction_ActionFinished(void) { - *(gBattleStruct->monToSwitchIntoId + gBanksByTurnOrder[gCurrentTurnActionNumber]) = 6; + *(gBattleStruct->monToSwitchIntoId + gBattleTurnOrder[gCurrentTurnActionNumber]) = 6; gCurrentTurnActionNumber++; gCurrentActionFuncId = gActionsByTurnOrder[gCurrentTurnActionNumber]; SpecialStatusesClear(); @@ -5589,8 +5589,8 @@ static void HandleAction_ActionFinished(void) gMoveResultFlags = 0; gBattleScripting.animTurn = 0; gBattleScripting.animTargetsHit = 0; - gLastLandedMoves[gBankAttacker] = 0; - gLastHitByType[gBankAttacker] = 0; + gLastLandedMoves[gBattleAttacker] = 0; + gLastHitByType[gBattleAttacker] = 0; gBattleStruct->dynamicMoveType = 0; gDynamicBasePower = 0; gBattleScripting.atk49_state = 0; diff --git a/src/battle_message.c b/src/battle_message.c index 7ab6fcef3..3bfa5b48d 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -16,20 +16,20 @@ extern u16 gLastUsedItem; extern u8 gLastUsedAbility; -extern u8 gActiveBank; -extern u8 gBankAttacker; -extern u8 gBankDefender; +extern u8 gActiveBattler; +extern u8 gBattleAttacker; +extern u8 gBattleDefender; extern u8 gStringBank; extern u8 gEffectBank; -extern u8 gAbilitiesPerBank[BATTLE_BANKS_COUNT]; +extern u8 gAbilitiesPerBank[MAX_BATTLERS_COUNT]; extern u32 gBattleTypeFlags; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; extern u16 gPartnerTrainerId; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern struct BattleEnigmaBerry gEnigmaBerries[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; -extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern struct BattleEnigmaBerry gEnigmaBerries[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; +extern u8 gMoveSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gUnknown_0203C7B4; extern struct StringInfoBattle *gStringInfo; @@ -1430,16 +1430,16 @@ void BufferStringBattle(u16 stringID) s32 i; const u8* stringPtr = NULL; - gStringInfo = (struct StringInfoBattle*)(&gBattleBufferA[gActiveBank][4]); + gStringInfo = (struct StringInfoBattle*)(&gBattleBufferA[gActiveBattler][4]); gLastUsedItem = gStringInfo->lastItem; gLastUsedAbility = gStringInfo->lastAbility; - gBattleScripting.bank = gStringInfo->scrActive; + gBattleScripting.battler = gStringInfo->scrActive; *(&gBattleStruct->field_52) = gStringInfo->unk1605E; *(&gBattleStruct->hpScale) = gStringInfo->hpScale; gStringBank = gStringInfo->StringBank; *(&gBattleStruct->stringMoveType) = gStringInfo->moveType; - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { gAbilitiesPerBank[i] = gStringInfo->abilities[i]; } @@ -1501,7 +1501,7 @@ void BufferStringBattle(u16 stringID) } break; case STRINGID_INTROSENDOUT: // poke first send-out - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { @@ -1546,7 +1546,7 @@ void BufferStringBattle(u16 stringID) } break; case STRINGID_RETURNMON: // sending poke to ball msg - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { if (*(&gBattleStruct->hpScale) == 0) stringPtr = gText_PkmnThatsEnough; @@ -1573,7 +1573,7 @@ void BufferStringBattle(u16 stringID) } break; case STRINGID_SWITCHINMON: // switch-in msg - if (GetBankSide(gBattleScripting.bank) == SIDE_PLAYER) + if (GetBattlerSide(gBattleScripting.battler) == B_SIDE_PLAYER) { if (*(&gBattleStruct->hpScale) == 0 || gBattleTypeFlags & BATTLE_TYPE_DOUBLE) stringPtr = gText_GoPkmn2; @@ -1590,7 +1590,7 @@ void BufferStringBattle(u16 stringID) { if (gBattleTypeFlags & BATTLE_TYPE_x800000) { - if (gBattleScripting.bank == 1) + if (gBattleScripting.battler == 1) stringPtr = gText_Trainer1SentOutPkmn2; else stringPtr = gText_Trainer2SentOutPkmn; @@ -1609,7 +1609,7 @@ void BufferStringBattle(u16 stringID) { if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) { - if (gBattleScripting.bank == 1) + if (gBattleScripting.battler == 1) stringPtr = gText_Trainer1SentOutPkmn2; else stringPtr = gText_Trainer2SentOutPkmn; @@ -1636,7 +1636,7 @@ void BufferStringBattle(u16 stringID) if (gBattleTextBuff1[0] & B_OUTCOME_LINK_BATTLE_RAN) { gBattleTextBuff1[0] &= ~(B_OUTCOME_LINK_BATTLE_RAN); - if (GetBankSide(gActiveBank) == SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW) + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW) gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON); if (gBattleTextBuff1[0] == B_OUTCOME_LOST || gBattleTextBuff1[0] == B_OUTCOME_DREW) @@ -1648,7 +1648,7 @@ void BufferStringBattle(u16 stringID) } else { - if (GetBankSide(gActiveBank) == SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW) + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW) gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON); if (gBattleTypeFlags & BATTLE_TYPE_MULTI) @@ -1754,7 +1754,7 @@ static const u8* TryGetStatusString(u8* src) } #define HANDLE_NICKNAME_STRING_CASE(bank, monIndex) \ - if (GetBankSide(bank) != SIDE_PLAYER) \ + if (GetBattlerSide(bank) != B_SIDE_PLAYER) \ { \ if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) \ toCpy = gText_FoePkmnPrefix; \ @@ -1836,25 +1836,25 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = gStringVar3; break; case B_TXT_PLAYER_MON1_NAME: // first player poke name - GetMonData(&gPlayerParty[gBattlePartyID[GetBankByPosition(B_POSITION_PLAYER_LEFT)]], + GetMonData(&gPlayerParty[gBattlePartyID[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; break; case B_TXT_OPPONENT_MON1_NAME: // first enemy poke name - GetMonData(&gEnemyParty[gBattlePartyID[GetBankByPosition(B_POSITION_OPPONENT_LEFT)]], + GetMonData(&gEnemyParty[gBattlePartyID[GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; break; case B_TXT_PLAYER_MON2_NAME: // second player poke name - GetMonData(&gPlayerParty[gBattlePartyID[GetBankByPosition(B_POSITION_PLAYER_RIGHT)]], + GetMonData(&gPlayerParty[gBattlePartyID[GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; break; case B_TXT_OPPONENT_MON2_NAME: // second enemy poke name - GetMonData(&gEnemyParty[gBattlePartyID[GetBankByPosition(B_POSITION_OPPONENT_RIGHT)]], + GetMonData(&gEnemyParty[gBattlePartyID[GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT)]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; @@ -1884,32 +1884,32 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = text; break; case B_TXT_ATK_NAME_WITH_PREFIX_MON1: // attacker name with prefix, only bank 0/1 - HANDLE_NICKNAME_STRING_CASE(gBankAttacker, - gBattlePartyID[GetBankByPosition(GET_BANK_SIDE(gBankAttacker))]) + HANDLE_NICKNAME_STRING_CASE(gBattleAttacker, + gBattlePartyID[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleAttacker))]) break; case B_TXT_ATK_PARTNER_NAME: // attacker partner name - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) - GetMonData(&gPlayerParty[gBattlePartyID[GetBankByPosition(GET_BANK_SIDE(gBankAttacker)) + 2]], MON_DATA_NICKNAME, text); + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) + GetMonData(&gPlayerParty[gBattlePartyID[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleAttacker)) + 2]], MON_DATA_NICKNAME, text); else - GetMonData(&gEnemyParty[gBattlePartyID[GetBankByPosition(GET_BANK_SIDE(gBankAttacker)) + 2]], MON_DATA_NICKNAME, text); + GetMonData(&gEnemyParty[gBattlePartyID[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleAttacker)) + 2]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; break; case B_TXT_ATK_NAME_WITH_PREFIX: // attacker name with prefix - HANDLE_NICKNAME_STRING_CASE(gBankAttacker, gBattlePartyID[gBankAttacker]) + HANDLE_NICKNAME_STRING_CASE(gBattleAttacker, gBattlePartyID[gBattleAttacker]) break; case B_TXT_DEF_NAME_WITH_PREFIX: // target name with prefix - HANDLE_NICKNAME_STRING_CASE(gBankDefender, gBattlePartyID[gBankDefender]) + HANDLE_NICKNAME_STRING_CASE(gBattleDefender, gBattlePartyID[gBattleDefender]) break; case B_TXT_EFF_NAME_WITH_PREFIX: // effect bank name with prefix HANDLE_NICKNAME_STRING_CASE(gEffectBank, gBattlePartyID[gEffectBank]) break; case B_TXT_ACTIVE_NAME_WITH_PREFIX: // active bank name with prefix - HANDLE_NICKNAME_STRING_CASE(gActiveBank, gBattlePartyID[gActiveBank]) + HANDLE_NICKNAME_STRING_CASE(gActiveBattler, gBattlePartyID[gActiveBattler]) break; case B_TXT_SCR_ACTIVE_NAME_WITH_PREFIX: // scripting active bank name with prefix - HANDLE_NICKNAME_STRING_CASE(gBattleScripting.bank, gBattlePartyID[gBattleScripting.bank]) + HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler, gBattlePartyID[gBattleScripting.battler]) break; case B_TXT_CURRENT_MOVE: // current move name if (gStringInfo->currentMove > LAST_MOVE_INDEX) @@ -1970,13 +1970,13 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = gAbilityNames[gLastUsedAbility]; break; case B_TXT_ATK_ABILITY: // attacker ability - toCpy = gAbilityNames[gAbilitiesPerBank[gBankAttacker]]; + toCpy = gAbilityNames[gAbilitiesPerBank[gBattleAttacker]]; break; case B_TXT_DEF_ABILITY: // target ability - toCpy = gAbilityNames[gAbilitiesPerBank[gBankDefender]]; + toCpy = gAbilityNames[gAbilitiesPerBank[gBattleDefender]]; break; case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability - toCpy = gAbilityNames[gAbilitiesPerBank[gBattleScripting.bank]]; + toCpy = gAbilityNames[gAbilitiesPerBank[gBattleScripting.battler]]; break; case B_TXT_EFF_ABILITY: // effect bank ability toCpy = gAbilityNames[gAbilitiesPerBank[gEffectBank]]; @@ -2048,7 +2048,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = gLinkPlayers[GetBankMultiplayerId(3 ^ gLinkPlayers[multiplayerID].lp_field_18)].name; break; case B_TXT_22: // link scripting active name - toCpy = gLinkPlayers[GetBankMultiplayerId(gBattleScripting.bank)].name; + toCpy = gLinkPlayers[GetBankMultiplayerId(gBattleScripting.battler)].name; break; case B_TXT_PLAYER_NAME: // player name if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) @@ -2085,7 +2085,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) } break; case B_TXT_26: // ? - HANDLE_NICKNAME_STRING_CASE(gBattleScripting.bank, *(&gBattleStruct->field_52)) + HANDLE_NICKNAME_STRING_CASE(gBattleScripting.battler, *(&gBattleStruct->field_52)) break; case B_TXT_PC_CREATOR_NAME: // lanette pc if (FlagGet(FLAG_SYS_PC_LANETTE)) @@ -2094,37 +2094,37 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = gText_Someones; break; case B_TXT_ATK_PREFIX2: - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix2; else toCpy = gText_FoePkmnPrefix3; break; case B_TXT_DEF_PREFIX2: - if (GetBankSide(gBankDefender) == SIDE_PLAYER) + if (GetBattlerSide(gBattleDefender) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix2; else toCpy = gText_FoePkmnPrefix3; break; case B_TXT_ATK_PREFIX1: - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix; else toCpy = gText_FoePkmnPrefix2; break; case B_TXT_DEF_PREFIX1: - if (GetBankSide(gBankDefender) == SIDE_PLAYER) + if (GetBattlerSide(gBattleDefender) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix; else toCpy = gText_FoePkmnPrefix2; break; case B_TXT_ATK_PREFIX3: - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix3; else toCpy = gText_FoePkmnPrefix4; break; case B_TXT_DEF_PREFIX3: - if (GetBankSide(gBankDefender) == SIDE_PLAYER) + if (GetBattlerSide(gBattleDefender) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix3; else toCpy = gText_FoePkmnPrefix4; @@ -2266,7 +2266,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst) srcID += 2; break; case B_BUFF_MON_NICK_WITH_PREFIX: // poke nick with prefix - if (GetBankSide(src[srcID + 1]) == SIDE_PLAYER) + if (GetBattlerSide(src[srcID + 1]) == B_SIDE_PLAYER) { GetMonData(&gPlayerParty[src[srcID + 2]], MON_DATA_NICKNAME, text); } @@ -2292,7 +2292,7 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst) srcID += 3; break; case B_BUFF_MON_NICK: // poke nick without prefix - if (GetBankSide(src[srcID + 1]) == SIDE_PLAYER) + if (GetBattlerSide(src[srcID + 1]) == B_SIDE_PLAYER) GetMonData(&gPlayerParty[src[srcID + 2]], MON_DATA_NICKNAME, dst); else GetMonData(&gEnemyParty[src[srcID + 2]], MON_DATA_NICKNAME, dst); @@ -2490,10 +2490,10 @@ void BattleHandleAddTextPrinter(const u8 *text, u8 arg1) void SetPpNumbersPaletteInMoveSelection(void) { - struct ChooseMoveStruct *chooseMoveStruct = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBank][4]); + struct ChooseMoveStruct *chooseMoveStruct = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); const u16 *palPtr = gUnknown_08D85620; - u8 var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[gActiveBank]], - chooseMoveStruct->maxPp[gMoveSelectionCursor[gActiveBank]]); + u8 var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[gActiveBattler]], + chooseMoveStruct->maxPp[gMoveSelectionCursor[gActiveBattler]]); gPlttBufferUnfaded[92] = palPtr[(var * 2) + 0]; gPlttBufferUnfaded[91] = palPtr[(var * 2) + 1]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index be20305fa..8f3036028 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -44,26 +44,26 @@ extern u8 gCritMultiplier; extern s32 gBattleMoveDamage; -extern struct BattleEnigmaBerry gEnigmaBerries[BATTLE_BANKS_COUNT]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; -extern u8 gActiveBank; +extern struct BattleEnigmaBerry gEnigmaBerries[MAX_BATTLERS_COUNT]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; +extern u8 gActiveBattler; extern u32 gBattleExecBuffer; -extern u8 gBattleBanksCount; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBanksByTurnOrder[BATTLE_BANKS_COUNT]; -extern u8 gActionsByTurnOrder[BATTLE_BANKS_COUNT]; +extern u8 gBattlersCount; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattleTurnOrder[MAX_BATTLERS_COUNT]; +extern u8 gActionsByTurnOrder[MAX_BATTLERS_COUNT]; extern u16 gCurrentMove; extern u8 gLastUsedAbility; extern u8 gStringBank; extern u8 gEffectBank; -extern u8 gAbsentBankFlags; +extern u8 gAbsentBattlerFlags; extern u8 gMultiHitCounter; -extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT]; +extern u16 gChosenMovesByBanks[MAX_BATTLERS_COUNT]; extern u16 gPauseCounterBattle; extern u16 gPaydayMoney; extern u16 gRandomTurnNumber; -extern u8 gBankAttacker; -extern u8 gBankDefender; +extern u8 gBattleAttacker; +extern u8 gBattleDefender; extern const u8* gBattlescriptCurrInstr; extern u8 gCurrMovePos; extern u8 gCurrentActionFuncId; @@ -78,8 +78,8 @@ extern u16 gDynamicBasePower; extern u16 gLastUsedItem; extern u16 gBattleMovePower; extern s32 gHpDealt; -extern s32 gTakenDmg[BATTLE_BANKS_COUNT]; -extern u8 gTakenDmgBanks[BATTLE_BANKS_COUNT]; +extern s32 gTakenDmg[MAX_BATTLERS_COUNT]; +extern u8 gTakenDmgBanks[MAX_BATTLERS_COUNT]; extern u8 gSentPokesToOpponent[2]; extern u8 gBank1; extern u16 gExpShareExp; @@ -89,14 +89,14 @@ extern u8 gPlayerPartyCount; extern u16 gMoveToLearn; extern u16 gRandomMove; extern u8 gBankInMenu; -extern u8 gActionForBanks[BATTLE_BANKS_COUNT]; +extern u8 gActionForBanks[MAX_BATTLERS_COUNT]; extern u8 gCurrentTurnActionNumber; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; -extern u16 gLockedMoves[BATTLE_BANKS_COUNT]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; +extern u16 gLockedMoves[MAX_BATTLERS_COUNT]; extern u16 gPartnerTrainerId; extern u16 gChosenMove; -extern u16 gLastPrintedMoves[BATTLE_BANKS_COUNT]; -extern u16 gLastMoves[BATTLE_BANKS_COUNT]; +extern u16 gLastPrintedMoves[MAX_BATTLERS_COUNT]; +extern u16 gLastMoves[MAX_BATTLERS_COUNT]; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; extern u8 gUnknown_020241E9; @@ -155,10 +155,10 @@ extern const u8 gText_BattleYesNoChoice[]; #define BS2ScriptRead16(ptr) ((ptr)[0] + ((ptr)[1] << 8)) #define BS2ScriptReadPtr(ptr) ((void *)BS2ScriptRead32(ptr)) -#define DEFENDER_IS_PROTECTED ((gProtectStructs[gBankDefender].protected) && (gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED)) +#define DEFENDER_IS_PROTECTED ((gProtectStructs[gBattleDefender].protected) && (gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED)) -#define TARGET_TURN_DAMAGED (gSpecialStatuses[gBankDefender].moveturnLostHP_physical != 0 \ - || gSpecialStatuses[gBankDefender].moveturnLostHP_special != 0) +#define TARGET_TURN_DAMAGED (gSpecialStatuses[gBattleDefender].moveturnLostHP_physical != 0 \ + || gSpecialStatuses[gBattleDefender].moveturnLostHP_special != 0) // this file's functions static bool8 IsTwoTurnsMove(u16 move); @@ -1027,7 +1027,7 @@ static void atk00_attackcanceler(void) gCurrentActionFuncId = ACTION_FINISHED; return; } - if (gBattleMons[gBankAttacker].hp == 0 && !(gHitMarker & HITMARKER_NO_ATTACKSTRING)) + if (gBattleMons[gBattleAttacker].hp == 0 && !(gHitMarker & HITMARKER_NO_ATTACKSTRING)) { gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gBattlescriptCurrInstr = BattleScript_MoveEnd; @@ -1035,10 +1035,10 @@ static void atk00_attackcanceler(void) } if (AtkCanceller_UnableToUseMove()) return; - if (AbilityBattleEffects(ABILITYEFFECT_MOVES_BLOCK, gBankDefender, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_MOVES_BLOCK, gBattleDefender, 0, 0, 0)) return; - if (!gBattleMons[gBankAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE && !(gHitMarker & 0x800200) - && !(gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS)) + if (!gBattleMons[gBattleAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE && !(gHitMarker & 0x800200) + && !(gBattleMons[gBattleAttacker].status2 & STATUS2_MULTIPLETURNS)) { gBattlescriptCurrInstr = BattleScript_NoPPForMove; gMoveResultFlags |= MOVE_RESULT_MISSED; @@ -1047,7 +1047,7 @@ static void atk00_attackcanceler(void) gHitMarker &= ~(HITMARKER_x800000); - if (!(gHitMarker & HITMARKER_OBEYS) && !(gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS)) + if (!(gHitMarker & HITMARKER_OBEYS) && !(gBattleMons[gBattleAttacker].status2 & STATUS2_MULTIPLETURNS)) { i = IsMonDisobedient(); // why use the 'i' variable...? switch (i) @@ -1065,44 +1065,44 @@ static void atk00_attackcanceler(void) gHitMarker |= HITMARKER_OBEYS; - if (gProtectStructs[gBankDefender].bounceMove && gBattleMoves[gCurrentMove].flags & FLAG_MAGICCOAT_AFFECTED) + if (gProtectStructs[gBattleDefender].bounceMove && gBattleMoves[gCurrentMove].flags & FLAG_MAGICCOAT_AFFECTED) { - PressurePPLose(gBankAttacker, gBankDefender, MOVE_MAGIC_COAT); - gProtectStructs[gBankDefender].bounceMove = 0; + PressurePPLose(gBattleAttacker, gBattleDefender, MOVE_MAGIC_COAT); + gProtectStructs[gBattleDefender].bounceMove = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MagicCoatBounce; return; } - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if ((gProtectStructs[gBanksByTurnOrder[i]].stealMove) && gBattleMoves[gCurrentMove].flags & FLAG_SNATCH_AFFECTED) + if ((gProtectStructs[gBattleTurnOrder[i]].stealMove) && gBattleMoves[gCurrentMove].flags & FLAG_SNATCH_AFFECTED) { - PressurePPLose(gBankAttacker, gBanksByTurnOrder[i], MOVE_SNATCH); - gProtectStructs[gBanksByTurnOrder[i]].stealMove = 0; - gBattleScripting.bank = gBanksByTurnOrder[i]; + PressurePPLose(gBattleAttacker, gBattleTurnOrder[i], MOVE_SNATCH); + gProtectStructs[gBattleTurnOrder[i]].stealMove = 0; + gBattleScripting.battler = gBattleTurnOrder[i]; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SnatchedMove; return; } } - if (gSpecialStatuses[gBankDefender].lightningRodRedirected) + if (gSpecialStatuses[gBattleDefender].lightningRodRedirected) { - gSpecialStatuses[gBankDefender].lightningRodRedirected = 0; + gSpecialStatuses[gBattleDefender].lightningRodRedirected = 0; gLastUsedAbility = ABILITY_LIGHTNING_ROD; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_TookAttack; - RecordAbilityBattle(gBankDefender, gLastUsedAbility); + RecordAbilityBattle(gBattleDefender, gLastUsedAbility); } else if (DEFENDER_IS_PROTECTED - && (gCurrentMove != MOVE_CURSE || (gBattleMons[gBankAttacker].type1 == TYPE_GHOST || gBattleMons[gBankAttacker].type2 == TYPE_GHOST)) - && ((!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS)))) + && (gCurrentMove != MOVE_CURSE || (gBattleMons[gBattleAttacker].type1 == TYPE_GHOST || gBattleMons[gBattleAttacker].type2 == TYPE_GHOST)) + && ((!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattleAttacker].status2 & STATUS2_MULTIPLETURNS)))) { - CancelMultiTurnMoves(gBankAttacker); + CancelMultiTurnMoves(gBattleAttacker); gMoveResultFlags |= MOVE_RESULT_MISSED; - gLastLandedMoves[gBankDefender] = 0; - gLastHitByType[gBankDefender] = 0; + gLastLandedMoves[gBattleDefender] = 0; + gLastHitByType[gBattleDefender] = 0; gBattleCommunication[6] = 1; gBattlescriptCurrInstr++; } @@ -1117,14 +1117,14 @@ static void JumpIfMoveFailed(u8 adder, u16 move) const u8 *BS_ptr = gBattlescriptCurrInstr + adder; if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { - gLastLandedMoves[gBankDefender] = 0; - gLastHitByType[gBankDefender] = 0; + gLastLandedMoves[gBattleDefender] = 0; + gLastHitByType[gBattleDefender] = 0; BS_ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { TrySetDestinyBondToHappen(); - if (AbilityBattleEffects(ABILITYEFFECT_ABSORBING, gBankDefender, 0, 0, move)) + if (AbilityBattleEffects(ABILITYEFFECT_ABSORBING, gBattleDefender, 0, 0, move)) return; } gBattlescriptCurrInstr = BS_ptr; @@ -1159,13 +1159,13 @@ bool8 JumpIfMoveAffectedByProtect(u16 move) static bool8 AccuracyCalcHelper(u16 move) { - if (gStatuses3[gBankDefender] & STATUS3_ALWAYS_HITS && gDisableStructs[gBankDefender].bankWithSureHit == gBankAttacker) + if (gStatuses3[gBattleDefender] & STATUS3_ALWAYS_HITS && gDisableStructs[gBattleDefender].bankWithSureHit == gBattleAttacker) { JumpIfMoveFailed(7, move); return TRUE; } - if (!(gHitMarker & HITMARKER_IGNORE_ON_AIR) && gStatuses3[gBankDefender] & STATUS3_ON_AIR) + if (!(gHitMarker & HITMARKER_IGNORE_ON_AIR) && gStatuses3[gBattleDefender] & STATUS3_ON_AIR) { gMoveResultFlags |= MOVE_RESULT_MISSED; JumpIfMoveFailed(7, move); @@ -1174,7 +1174,7 @@ static bool8 AccuracyCalcHelper(u16 move) gHitMarker &= ~HITMARKER_IGNORE_ON_AIR; - if (!(gHitMarker & HITMARKER_IGNORE_UNDERGROUND) && gStatuses3[gBankDefender] & STATUS3_UNDERGROUND) + if (!(gHitMarker & HITMARKER_IGNORE_UNDERGROUND) && gStatuses3[gBattleDefender] & STATUS3_UNDERGROUND) { gMoveResultFlags |= MOVE_RESULT_MISSED; JumpIfMoveFailed(7, move); @@ -1183,7 +1183,7 @@ static bool8 AccuracyCalcHelper(u16 move) gHitMarker &= ~HITMARKER_IGNORE_UNDERGROUND; - if (!(gHitMarker & HITMARKER_IGNORE_UNDERWATER) && gStatuses3[gBankDefender] & STATUS3_UNDERWATER) + if (!(gHitMarker & HITMARKER_IGNORE_UNDERWATER) && gStatuses3[gBattleDefender] & STATUS3_UNDERWATER) { gMoveResultFlags |= MOVE_RESULT_MISSED; JumpIfMoveFailed(7, move); @@ -1208,9 +1208,9 @@ static void atk01_accuracycheck(void) if (move == 0xFFFE || move == 0xFFFF) { - if (gStatuses3[gBankDefender] & STATUS3_ALWAYS_HITS && move == 0xFFFF && gDisableStructs[gBankDefender].bankWithSureHit == gBankAttacker) + if (gStatuses3[gBattleDefender] & STATUS3_ALWAYS_HITS && move == 0xFFFF && gDisableStructs[gBattleDefender].bankWithSureHit == gBattleAttacker) gBattlescriptCurrInstr += 7; - else if (gStatuses3[gBankDefender] & (STATUS3_ON_AIR | STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) + else if (gStatuses3[gBattleDefender] & (STATUS3_ON_AIR | STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); else if (!JumpIfMoveAffectedByProtect(0)) gBattlescriptCurrInstr += 7; @@ -1231,15 +1231,15 @@ static void atk01_accuracycheck(void) if (AccuracyCalcHelper(move)) return; - if (gBattleMons[gBankDefender].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBattleDefender].status2 & STATUS2_FORESIGHT) { - u8 acc = gBattleMons[gBankAttacker].statStages[STAT_STAGE_ACC]; + u8 acc = gBattleMons[gBattleAttacker].statStages[STAT_STAGE_ACC]; buff = acc; } else { - u8 acc = gBattleMons[gBankAttacker].statStages[STAT_STAGE_ACC]; - buff = acc + 6 - gBattleMons[gBankDefender].statStages[STAT_STAGE_EVASION]; + u8 acc = gBattleMons[gBattleAttacker].statStages[STAT_STAGE_ACC]; + buff = acc + 6 - gBattleMons[gBattleDefender].statStages[STAT_STAGE_EVASION]; } if (buff < 0) @@ -1255,25 +1255,25 @@ static void atk01_accuracycheck(void) calc = sAccuracyStageRatios[buff].dividend * moveAcc; calc /= sAccuracyStageRatios[buff].divisor; - if (gBattleMons[gBankAttacker].ability == ABILITY_COMPOUND_EYES) + if (gBattleMons[gBattleAttacker].ability == ABILITY_COMPOUND_EYES) calc = (calc * 130) / 100; // 1.3 compound eyes boost - if (WEATHER_HAS_EFFECT && gBattleMons[gBankDefender].ability == ABILITY_SAND_VEIL && gBattleWeather & WEATHER_SANDSTORM_ANY) + if (WEATHER_HAS_EFFECT && gBattleMons[gBattleDefender].ability == ABILITY_SAND_VEIL && gBattleWeather & WEATHER_SANDSTORM_ANY) calc = (calc * 80) / 100; // 1.2 sand veil loss - if (gBattleMons[gBankAttacker].ability == ABILITY_HUSTLE && type < 9) + if (gBattleMons[gBattleAttacker].ability == ABILITY_HUSTLE && type < 9) calc = (calc * 80) / 100; // 1.2 hustle loss - if (gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBattleDefender].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBankDefender].holdEffect; - quality = gEnigmaBerries[gBankDefender].holdEffectParam; + holdEffect = gEnigmaBerries[gBattleDefender].holdEffect; + quality = gEnigmaBerries[gBattleDefender].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankDefender].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBankDefender].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattleDefender].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBattleDefender].item); } - gStringBank = gBankDefender; + gStringBank = gBattleDefender; if (holdEffect == HOLD_EFFECT_EVASION_UP) calc = (calc * (100 - quality)) / 100; @@ -1300,7 +1300,7 @@ static void atk02_attackstring(void) return; if (!(gHitMarker & (HITMARKER_NO_ATTACKSTRING | HITMARKER_ATTACKSTRING_PRINTED))) { - PrepareStringBattle(STRINGID_USEDMOVE, gBankAttacker); + PrepareStringBattle(STRINGID_USEDMOVE, gBattleAttacker); gHitMarker |= HITMARKER_ATTACKSTRING_PRINTED; } gBattlescriptCurrInstr++; @@ -1314,39 +1314,39 @@ static void atk03_ppreduce(void) if (gBattleExecBuffer) return; - if (!gSpecialStatuses[gBankAttacker].flag20) + if (!gSpecialStatuses[gBattleAttacker].flag20) { switch (gBattleMoves[gCurrentMove].target) { case MOVE_TARGET_FOES_AND_ALLY: - ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_ON_FIELD, gBankAttacker, ABILITY_PRESSURE, 0, 0); + ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_ON_FIELD, gBattleAttacker, ABILITY_PRESSURE, 0, 0); break; case MOVE_TARGET_BOTH: case MOVE_TARGET_OPPONENTS_FIELD: - ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBankAttacker, ABILITY_PRESSURE, 0, 0); + ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBattleAttacker, ABILITY_PRESSURE, 0, 0); break; default: - if (gBankAttacker != gBankDefender && gBattleMons[gBankDefender].ability == ABILITY_PRESSURE) + if (gBattleAttacker != gBattleDefender && gBattleMons[gBattleDefender].ability == ABILITY_PRESSURE) ppToDeduct++; break; } } - if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBankAttacker].pp[gCurrMovePos]) + if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattleAttacker].pp[gCurrMovePos]) { - gProtectStructs[gBankAttacker].notFirstStrike = 1; + gProtectStructs[gBattleAttacker].notFirstStrike = 1; - if (gBattleMons[gBankAttacker].pp[gCurrMovePos] > ppToDeduct) - gBattleMons[gBankAttacker].pp[gCurrMovePos] -= ppToDeduct; + if (gBattleMons[gBattleAttacker].pp[gCurrMovePos] > ppToDeduct) + gBattleMons[gBattleAttacker].pp[gCurrMovePos] -= ppToDeduct; else - gBattleMons[gBankAttacker].pp[gCurrMovePos] = 0; + gBattleMons[gBattleAttacker].pp[gCurrMovePos] = 0; - if (!(gBattleMons[gBankAttacker].status2 & STATUS2_TRANSFORMED) - && !((gDisableStructs[gBankAttacker].unk18_b) & gBitTable[gCurrMovePos])) + if (!(gBattleMons[gBattleAttacker].status2 & STATUS2_TRANSFORMED) + && !((gDisableStructs[gBattleAttacker].unk18_b) & gBitTable[gCurrMovePos])) { - gActiveBank = gBankAttacker; - EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + gCurrMovePos, 0, 1, &gBattleMons[gBankAttacker].pp[gCurrMovePos]); - MarkBufferBankForExecution(gBankAttacker); + gActiveBattler = gBattleAttacker; + EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + gCurrMovePos, 0, 1, &gBattleMons[gBattleAttacker].pp[gCurrMovePos]); + MarkBufferBankForExecution(gBattleAttacker); } } @@ -1359,29 +1359,29 @@ static void atk04_critcalc(void) u8 holdEffect; u16 item, critChance; - item = gBattleMons[gBankAttacker].item; + item = gBattleMons[gBattleAttacker].item; if (item == ITEM_ENIGMA_BERRY) - holdEffect = gEnigmaBerries[gBankAttacker].holdEffect; + holdEffect = gEnigmaBerries[gBattleAttacker].holdEffect; else holdEffect = ItemId_GetHoldEffect(item); - gStringBank = gBankAttacker; + gStringBank = gBattleAttacker; - critChance = 2 * ((gBattleMons[gBankAttacker].status2 & STATUS2_FOCUS_ENERGY) != 0) + critChance = 2 * ((gBattleMons[gBattleAttacker].status2 & STATUS2_FOCUS_ENERGY) != 0) + (gBattleMoves[gCurrentMove].effect == EFFECT_HIGH_CRITICAL) + (gBattleMoves[gCurrentMove].effect == EFFECT_SKY_ATTACK) + (gBattleMoves[gCurrentMove].effect == EFFECT_BLAZE_KICK) + (gBattleMoves[gCurrentMove].effect == EFFECT_POISON_TAIL) + (holdEffect == HOLD_EFFECT_SCOPE_LENS) - + 2 * (holdEffect == HOLD_EFFECT_LUCKY_PUNCH && gBattleMons[gBankAttacker].species == SPECIES_CHANSEY) - + 2 * (holdEffect == HOLD_EFFECT_STICK && gBattleMons[gBankAttacker].species == SPECIES_FARFETCHD); + + 2 * (holdEffect == HOLD_EFFECT_LUCKY_PUNCH && gBattleMons[gBattleAttacker].species == SPECIES_CHANSEY) + + 2 * (holdEffect == HOLD_EFFECT_STICK && gBattleMons[gBattleAttacker].species == SPECIES_FARFETCHD); if (critChance > 4) critChance = 4; - if ((gBattleMons[gBankDefender].ability != ABILITY_BATTLE_ARMOR && gBattleMons[gBankDefender].ability != ABILITY_SHELL_ARMOR) - && !(gStatuses3[gBankAttacker] & STATUS3_CANT_SCORE_A_CRIT) + if ((gBattleMons[gBattleDefender].ability != ABILITY_BATTLE_ARMOR && gBattleMons[gBattleDefender].ability != ABILITY_SHELL_ARMOR) + && !(gStatuses3[gBattleAttacker] & STATUS3_CANT_SCORE_A_CRIT) && !(gBattleTypeFlags & (BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_FIRST_BATTLE)) && !(Random() % sCriticalHitChance[critChance])) gCritMultiplier = 2; @@ -1393,32 +1393,32 @@ static void atk04_critcalc(void) static void atk05_damagecalc(void) { - u16 sideStatus = gSideStatuses[GET_BANK_SIDE(gBankDefender)]; - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankDefender], gCurrentMove, + u16 sideStatus = gSideStatuses[GET_BATTLER_SIDE(gBattleDefender)]; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattleAttacker], &gBattleMons[gBattleDefender], gCurrentMove, sideStatus, gDynamicBasePower, - gBattleStruct->dynamicMoveType, gBankAttacker, gBankDefender); + gBattleStruct->dynamicMoveType, gBattleAttacker, gBattleDefender); gBattleMoveDamage = gBattleMoveDamage * gCritMultiplier * gBattleScripting.dmgMultiplier; - if (gStatuses3[gBankAttacker] & STATUS3_CHARGED_UP && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) + if (gStatuses3[gBattleAttacker] & STATUS3_CHARGED_UP && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) gBattleMoveDamage *= 2; - if (gProtectStructs[gBankAttacker].helpingHand) + if (gProtectStructs[gBattleAttacker].helpingHand) gBattleMoveDamage = gBattleMoveDamage * 15 / 10; gBattlescriptCurrInstr++; } -void AI_CalcDmg(u8 bankAtk, u8 bankDef) +void AI_CalcDmg(u8 attacker, u8 defender) { - u16 sideStatus = gSideStatuses[GET_BANK_SIDE(bankDef)]; - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[bankAtk], &gBattleMons[bankDef], gCurrentMove, + u16 sideStatus = gSideStatuses[GET_BATTLER_SIDE(defender)]; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[attacker], &gBattleMons[defender], gCurrentMove, sideStatus, gDynamicBasePower, - gBattleStruct->dynamicMoveType, bankAtk, bankDef); + gBattleStruct->dynamicMoveType, attacker, defender); gDynamicBasePower = 0; gBattleMoveDamage = gBattleMoveDamage * gCritMultiplier * gBattleScripting.dmgMultiplier; - if (gStatuses3[bankAtk] & STATUS3_CHARGED_UP && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) + if (gStatuses3[attacker] & STATUS3_CHARGED_UP && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) gBattleMoveDamage *= 2; - if (gProtectStructs[bankAtk].helpingHand) + if (gProtectStructs[attacker].helpingHand) gBattleMoveDamage = gBattleMoveDamage * 15 / 10; } @@ -1470,20 +1470,20 @@ static void atk06_typecalc(void) GET_MOVE_TYPE(gCurrentMove, moveType); // check stab - if (gBattleMons[gBankAttacker].type1 == moveType || gBattleMons[gBankAttacker].type2 == moveType) + if (gBattleMons[gBattleAttacker].type1 == moveType || gBattleMons[gBattleAttacker].type2 == moveType) { gBattleMoveDamage = gBattleMoveDamage * 15; gBattleMoveDamage = gBattleMoveDamage / 10; } - if (gBattleMons[gBankDefender].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) + if (gBattleMons[gBattleDefender].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { - gLastUsedAbility = gBattleMons[gBankDefender].ability; + gLastUsedAbility = gBattleMons[gBattleDefender].ability; gMoveResultFlags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE); - gLastLandedMoves[gBankDefender] = 0; - gLastHitByType[gBankDefender] = 0; + gLastLandedMoves[gBattleDefender] = 0; + gLastHitByType[gBattleDefender] = 0; gBattleCommunication[6] = moveType; - RecordAbilityBattle(gBankDefender, gLastUsedAbility); + RecordAbilityBattle(gBattleDefender, gLastUsedAbility); } else { @@ -1491,7 +1491,7 @@ static void atk06_typecalc(void) { if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) { - if (gBattleMons[gBankDefender].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBattleDefender].status2 & STATUS2_FORESIGHT) break; i += 3; continue; @@ -1499,30 +1499,30 @@ static void atk06_typecalc(void) else if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type1) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type1) ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i)); // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 && - gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type2 && + gBattleMons[gBattleDefender].type1 != gBattleMons[gBattleDefender].type2) ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i)); } i += 3; } } - if (gBattleMons[gBankDefender].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBankAttacker, gCurrentMove) == 2 + if (gBattleMons[gBattleDefender].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBattleAttacker, gCurrentMove) == 2 && (!(gMoveResultFlags & MOVE_RESULT_SUPER_EFFECTIVE) || ((gMoveResultFlags & (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)) == (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE))) && gBattleMoves[gCurrentMove].power) { gLastUsedAbility = ABILITY_WONDER_GUARD; gMoveResultFlags |= MOVE_RESULT_MISSED; - gLastLandedMoves[gBankDefender] = 0; - gLastHitByType[gBankDefender] = 0; + gLastLandedMoves[gBattleDefender] = 0; + gLastHitByType[gBattleDefender] = 0; gBattleCommunication[6] = 3; - RecordAbilityBattle(gBankDefender, gLastUsedAbility); + RecordAbilityBattle(gBattleDefender, gLastUsedAbility); } if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) - gProtectStructs[gBankAttacker].targetNotAffected = 1; + gProtectStructs[gBattleAttacker].targetNotAffected = 1; gBattlescriptCurrInstr++; } @@ -1538,11 +1538,11 @@ static void CheckWonderGuardAndLevitate(void) GET_MOVE_TYPE(gCurrentMove, moveType); - if (gBattleMons[gBankDefender].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) + if (gBattleMons[gBattleDefender].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { gLastUsedAbility = ABILITY_LEVITATE; gBattleCommunication[6] = moveType; - RecordAbilityBattle(gBankDefender, ABILITY_LEVITATE); + RecordAbilityBattle(gBattleDefender, ABILITY_LEVITATE); return; } @@ -1550,7 +1550,7 @@ static void CheckWonderGuardAndLevitate(void) { if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) { - if (gBattleMons[gBankDefender].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBattleDefender].status2 & STATUS2_FORESIGHT) break; i += 3; continue; @@ -1558,46 +1558,46 @@ static void CheckWonderGuardAndLevitate(void) if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check no effect - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type1 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type1 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; - gProtectStructs[gBankAttacker].targetNotAffected = 1; + gProtectStructs[gBattleAttacker].targetNotAffected = 1; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 && - gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 && + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type2 && + gBattleMons[gBattleDefender].type1 != gBattleMons[gBattleDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; - gProtectStructs[gBankAttacker].targetNotAffected = 1; + gProtectStructs[gBattleAttacker].targetNotAffected = 1; } // check super effective - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20) flags |= 1; - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 - && gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type2 + && gBattleMons[gBattleDefender].type1 != gBattleMons[gBattleDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) flags |= 1; // check not very effective - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5) flags |= 2; - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 - && gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type2 + && gBattleMons[gBattleDefender].type1 != gBattleMons[gBattleDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) flags |= 2; } i += 3; } - if (gBattleMons[gBankDefender].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBankAttacker, gCurrentMove) == 2) + if (gBattleMons[gBattleDefender].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBattleAttacker, gCurrentMove) == 2) { if (((flags & 2) || !(flags & 1)) && gBattleMoves[gCurrentMove].power) { gLastUsedAbility = ABILITY_WONDER_GUARD; gBattleCommunication[6] = 3; - RecordAbilityBattle(gBankDefender, ABILITY_WONDER_GUARD); + RecordAbilityBattle(gBattleDefender, ABILITY_WONDER_GUARD); } } } @@ -1636,7 +1636,7 @@ static void ModulateDmgByType2(u8 multiplier, u16 move, u8* flags) // same as Mo } } -u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef) +u8 TypeCalc(u16 move, u8 attacker, u8 defender) { s32 i = 0; u8 flags = 0; @@ -1648,13 +1648,13 @@ u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef) moveType = gBattleMoves[move].type; // check stab - if (gBattleMons[bankAtk].type1 == moveType || gBattleMons[bankAtk].type2 == moveType) + if (gBattleMons[attacker].type1 == moveType || gBattleMons[attacker].type2 == moveType) { gBattleMoveDamage = gBattleMoveDamage * 15; gBattleMoveDamage = gBattleMoveDamage / 10; } - if (gBattleMons[bankDef].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) + if (gBattleMons[defender].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { flags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE); } @@ -1664,7 +1664,7 @@ u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef) { if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) { - if (gBattleMons[bankDef].status2 & STATUS2_FORESIGHT) + if (gBattleMons[defender].status2 & STATUS2_FORESIGHT) break; i += 3; continue; @@ -1673,19 +1673,19 @@ u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef) else if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[bankDef].type1) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].type1) ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags); // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[bankDef].type2 && - gBattleMons[bankDef].type1 != gBattleMons[bankDef].type2) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[defender].type2 && + gBattleMons[defender].type1 != gBattleMons[defender].type2) ModulateDmgByType2(TYPE_EFFECT_MULTIPLIER(i), move, &flags); } i += 3; } } - if (gBattleMons[bankDef].ability == ABILITY_WONDER_GUARD && !(flags & MOVE_RESULT_MISSED) - && AttacksThisTurn(bankAtk, move) == 2 + if (gBattleMons[defender].ability == ABILITY_WONDER_GUARD && !(flags & MOVE_RESULT_MISSED) + && AttacksThisTurn(attacker, move) == 2 && (!(flags & MOVE_RESULT_SUPER_EFFECTIVE) || ((flags & (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)) == (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE))) && gBattleMoves[move].power) { @@ -1764,42 +1764,42 @@ static void atk07_adjustnormaldamage(void) ApplyRandomDmgMultiplier(); - if (gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBattleDefender].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBankDefender].holdEffect, quality = gEnigmaBerries[gBankDefender].holdEffectParam; + holdEffect = gEnigmaBerries[gBattleDefender].holdEffect, quality = gEnigmaBerries[gBattleDefender].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankDefender].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBankDefender].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattleDefender].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBattleDefender].item); } - gStringBank = gBankDefender; + gStringBank = gBattleDefender; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < quality) { - RecordItemEffectBattle(gBankDefender, holdEffect); - gSpecialStatuses[gBankDefender].focusBanded = 1; + RecordItemEffectBattle(gBattleDefender, holdEffect); + gSpecialStatuses[gBattleDefender].focusBanded = 1; } - if (gBattleMons[gBankDefender].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBattleDefender].status2 & STATUS2_SUBSTITUTE) goto END; - if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBankDefender].endured - && !gSpecialStatuses[gBankDefender].focusBanded) + if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBattleDefender].endured + && !gSpecialStatuses[gBattleDefender].focusBanded) goto END; - if (gBattleMons[gBankDefender].hp > gBattleMoveDamage) + if (gBattleMons[gBattleDefender].hp > gBattleMoveDamage) goto END; - gBattleMoveDamage = gBattleMons[gBankDefender].hp - 1; + gBattleMoveDamage = gBattleMons[gBattleDefender].hp - 1; - if (gProtectStructs[gBankDefender].endured) + if (gProtectStructs[gBattleDefender].endured) { gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBankDefender].focusBanded) + else if (gSpecialStatuses[gBattleDefender].focusBanded) { gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; - gLastUsedItem = gBattleMons[gBankDefender].item; + gLastUsedItem = gBattleMons[gBattleDefender].item; } END: @@ -1812,40 +1812,40 @@ static void atk08_adjustnormaldamage2(void) // The same as 0x7 except it doesn't ApplyRandomDmgMultiplier(); - if (gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBattleDefender].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBankDefender].holdEffect, quality = gEnigmaBerries[gBankDefender].holdEffectParam; + holdEffect = gEnigmaBerries[gBattleDefender].holdEffect, quality = gEnigmaBerries[gBattleDefender].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankDefender].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBankDefender].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattleDefender].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBattleDefender].item); } - gStringBank = gBankDefender; + gStringBank = gBattleDefender; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < quality) { - RecordItemEffectBattle(gBankDefender, holdEffect); - gSpecialStatuses[gBankDefender].focusBanded = 1; + RecordItemEffectBattle(gBattleDefender, holdEffect); + gSpecialStatuses[gBattleDefender].focusBanded = 1; } - if (gBattleMons[gBankDefender].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBattleDefender].status2 & STATUS2_SUBSTITUTE) goto END; - if (!gProtectStructs[gBankDefender].endured && !gSpecialStatuses[gBankDefender].focusBanded) + if (!gProtectStructs[gBattleDefender].endured && !gSpecialStatuses[gBattleDefender].focusBanded) goto END; - if (gBattleMons[gBankDefender].hp > gBattleMoveDamage) + if (gBattleMons[gBattleDefender].hp > gBattleMoveDamage) goto END; - gBattleMoveDamage = gBattleMons[gBankDefender].hp - 1; + gBattleMoveDamage = gBattleMons[gBattleDefender].hp - 1; - if (gProtectStructs[gBankDefender].endured) + if (gProtectStructs[gBattleDefender].endured) { gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBankDefender].focusBanded) + else if (gSpecialStatuses[gBattleDefender].focusBanded) { gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; - gLastUsedItem = gBattleMons[gBankDefender].item; + gLastUsedItem = gBattleMons[gBattleDefender].item; } END: @@ -1878,13 +1878,13 @@ static void atk09_attackanimation(void) { u8 multihit; - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; - if (gBattleMons[gBankDefender].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBattleDefender].status2 & STATUS2_SUBSTITUTE) multihit = gMultiHitCounter; else if (gMultiHitCounter != 0 && gMultiHitCounter != 1) { - if (gBattleMons[gBankDefender].hp <= gBattleMoveDamage) + if (gBattleMons[gBattleDefender].hp <= gBattleMoveDamage) multihit = 1; else multihit = gMultiHitCounter; @@ -1892,10 +1892,10 @@ static void atk09_attackanimation(void) else multihit = gMultiHitCounter; - EmitMoveAnimation(0, gCurrentMove, gBattleScripting.animTurn, gBattleMovePower, gBattleMoveDamage, gBattleMons[gBankAttacker].friendship, &gDisableStructs[gBankAttacker], multihit); + EmitMoveAnimation(0, gCurrentMove, gBattleScripting.animTurn, gBattleMovePower, gBattleMoveDamage, gBattleMons[gBattleAttacker].friendship, &gDisableStructs[gBattleAttacker], multihit); gBattleScripting.animTurn += 1; gBattleScripting.animTargetsHit += 1; - MarkBufferBankForExecution(gBankAttacker); + MarkBufferBankForExecution(gBattleAttacker); gBattlescriptCurrInstr++; } else @@ -1919,11 +1919,11 @@ static void atk0B_healthbarupdate(void) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); - if (gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE && gDisableStructs[gActiveBank].substituteHP && !(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE)) + if (gBattleMons[gActiveBattler].status2 & STATUS2_SUBSTITUTE && gDisableStructs[gActiveBattler].substituteHP && !(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE)) { - PrepareStringBattle(STRINGID_SUBSTITUTEDAMAGED, gActiveBank); + PrepareStringBattle(STRINGID_SUBSTITUTEDAMAGED, gActiveBattler); } else { @@ -1938,9 +1938,9 @@ static void atk0B_healthbarupdate(void) healthValue = maxPossibleDmgValue; EmitHealthBarUpdate(0, healthValue); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); - if (GetBankSide(gActiveBank) == SIDE_PLAYER && gBattleMoveDamage > 0) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER && gBattleMoveDamage > 0) gBattleResults.unk5_0 = 1; } } @@ -1964,25 +1964,25 @@ static void atk0C_datahpupdate(void) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - if (gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE && gDisableStructs[gActiveBank].substituteHP && !(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE)) + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); + if (gBattleMons[gActiveBattler].status2 & STATUS2_SUBSTITUTE && gDisableStructs[gActiveBattler].substituteHP && !(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE)) { - if (gDisableStructs[gActiveBank].substituteHP >= gBattleMoveDamage) + if (gDisableStructs[gActiveBattler].substituteHP >= gBattleMoveDamage) { - if (gSpecialStatuses[gActiveBank].moveturnLostHP == 0) - gSpecialStatuses[gActiveBank].moveturnLostHP = gBattleMoveDamage; - gDisableStructs[gActiveBank].substituteHP -= gBattleMoveDamage; + if (gSpecialStatuses[gActiveBattler].moveturnLostHP == 0) + gSpecialStatuses[gActiveBattler].moveturnLostHP = gBattleMoveDamage; + gDisableStructs[gActiveBattler].substituteHP -= gBattleMoveDamage; gHpDealt = gBattleMoveDamage; } else { - if (gSpecialStatuses[gActiveBank].moveturnLostHP == 0) - gSpecialStatuses[gActiveBank].moveturnLostHP = gDisableStructs[gActiveBank].substituteHP; - gHpDealt = gDisableStructs[gActiveBank].substituteHP; - gDisableStructs[gActiveBank].substituteHP = 0; + if (gSpecialStatuses[gActiveBattler].moveturnLostHP == 0) + gSpecialStatuses[gActiveBattler].moveturnLostHP = gDisableStructs[gActiveBattler].substituteHP; + gHpDealt = gDisableStructs[gActiveBattler].substituteHP; + gDisableStructs[gActiveBattler].substituteHP = 0; } // check substitute fading - if (gDisableStructs[gActiveBank].substituteHP == 0) + if (gDisableStructs[gActiveBattler].substituteHP == 0) { gBattlescriptCurrInstr += 2; BattleScriptPushCursor(); @@ -1995,9 +1995,9 @@ static void atk0C_datahpupdate(void) gHitMarker &= ~(HITMARKER_IGNORE_SUBSTITUTE); if (gBattleMoveDamage < 0) // hp goes up { - gBattleMons[gActiveBank].hp -= gBattleMoveDamage; - if (gBattleMons[gActiveBank].hp > gBattleMons[gActiveBank].maxHP) - gBattleMons[gActiveBank].hp = gBattleMons[gActiveBank].maxHP; + gBattleMons[gActiveBattler].hp -= gBattleMoveDamage; + if (gBattleMons[gActiveBattler].hp > gBattleMons[gActiveBattler].maxHP) + gBattleMons[gActiveBattler].hp = gBattleMons[gActiveBattler].maxHP; } else // hp goes down @@ -2008,68 +2008,68 @@ static void atk0C_datahpupdate(void) } else { - gTakenDmg[gActiveBank] += gBattleMoveDamage; + gTakenDmg[gActiveBattler] += gBattleMoveDamage; if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) - gTakenDmgBanks[gActiveBank] = gBankAttacker; + gTakenDmgBanks[gActiveBattler] = gBattleAttacker; else - gTakenDmgBanks[gActiveBank] = gBankDefender; + gTakenDmgBanks[gActiveBattler] = gBattleDefender; } - if (gBattleMons[gActiveBank].hp > gBattleMoveDamage) + if (gBattleMons[gActiveBattler].hp > gBattleMoveDamage) { - gBattleMons[gActiveBank].hp -= gBattleMoveDamage; + gBattleMons[gActiveBattler].hp -= gBattleMoveDamage; gHpDealt = gBattleMoveDamage; } else { - gHpDealt = gBattleMons[gActiveBank].hp; - gBattleMons[gActiveBank].hp = 0; + gHpDealt = gBattleMons[gActiveBattler].hp; + gBattleMons[gActiveBattler].hp = 0; } - if (!gSpecialStatuses[gActiveBank].moveturnLostHP && !(gHitMarker & HITMARKER_x100000)) - gSpecialStatuses[gActiveBank].moveturnLostHP = gHpDealt; + if (!gSpecialStatuses[gActiveBattler].moveturnLostHP && !(gHitMarker & HITMARKER_x100000)) + gSpecialStatuses[gActiveBattler].moveturnLostHP = gHpDealt; if (moveType <= 8 && !(gHitMarker & HITMARKER_x100000) && gCurrentMove != MOVE_PAIN_SPLIT) { - gProtectStructs[gActiveBank].physicalDmg = gHpDealt; - gSpecialStatuses[gActiveBank].moveturnLostHP_physical = gHpDealt; + gProtectStructs[gActiveBattler].physicalDmg = gHpDealt; + gSpecialStatuses[gActiveBattler].moveturnLostHP_physical = gHpDealt; if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) { - gProtectStructs[gActiveBank].physicalBank = gBankAttacker; - gSpecialStatuses[gActiveBank].moveturnPhysicalBank = gBankAttacker; + gProtectStructs[gActiveBattler].physicalBank = gBattleAttacker; + gSpecialStatuses[gActiveBattler].moveturnPhysicalBank = gBattleAttacker; } else { - gProtectStructs[gActiveBank].physicalBank = gBankDefender; - gSpecialStatuses[gActiveBank].moveturnPhysicalBank = gBankDefender; + gProtectStructs[gActiveBattler].physicalBank = gBattleDefender; + gSpecialStatuses[gActiveBattler].moveturnPhysicalBank = gBattleDefender; } } else if (moveType > 8 && !(gHitMarker & HITMARKER_x100000)) { - gProtectStructs[gActiveBank].specialDmg = gHpDealt; - gSpecialStatuses[gActiveBank].moveturnLostHP_special = gHpDealt; + gProtectStructs[gActiveBattler].specialDmg = gHpDealt; + gSpecialStatuses[gActiveBattler].moveturnLostHP_special = gHpDealt; if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) { - gProtectStructs[gActiveBank].specialBank = gBankAttacker; - gSpecialStatuses[gActiveBank].moveturnSpecialBank = gBankAttacker; + gProtectStructs[gActiveBattler].specialBank = gBattleAttacker; + gSpecialStatuses[gActiveBattler].moveturnSpecialBank = gBattleAttacker; } else { - gProtectStructs[gActiveBank].specialBank = gBankDefender; - gSpecialStatuses[gActiveBank].moveturnSpecialBank = gBankDefender; + gProtectStructs[gActiveBattler].specialBank = gBattleDefender; + gSpecialStatuses[gActiveBattler].moveturnSpecialBank = gBattleDefender; } } } gHitMarker &= ~(HITMARKER_x100000); - EmitSetMonData(0, REQUEST_HP_BATTLE, 0, 2, &gBattleMons[gActiveBank].hp); - MarkBufferBankForExecution(gActiveBank); + EmitSetMonData(0, REQUEST_HP_BATTLE, 0, 2, &gBattleMons[gActiveBattler].hp); + MarkBufferBankForExecution(gActiveBattler); } } else { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - if (gSpecialStatuses[gActiveBank].moveturnLostHP == 0) - gSpecialStatuses[gActiveBank].moveturnLostHP = 0xFFFF; + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); + if (gSpecialStatuses[gActiveBattler].moveturnLostHP == 0) + gSpecialStatuses[gActiveBattler].moveturnLostHP = 0xFFFF; } gBattlescriptCurrInstr += 2; } @@ -2080,7 +2080,7 @@ static void atk0D_critmessage(void) { if (gCritMultiplier == 2 && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { - PrepareStringBattle(STRINGID_CRITICALHIT, gBankAttacker); + PrepareStringBattle(STRINGID_CRITICALHIT, gBattleAttacker); gBattleCommunication[MSG_DISPLAY] = 1; } gBattlescriptCurrInstr++; @@ -2092,18 +2092,18 @@ static void atk0E_effectivenesssound(void) if (gBattleExecBuffer) return; - gActiveBank = gBankDefender; + gActiveBattler = gBattleDefender; if (!(gMoveResultFlags & MOVE_RESULT_MISSED)) { switch (gMoveResultFlags & (u8)(~(MOVE_RESULT_MISSED))) { case MOVE_RESULT_SUPER_EFFECTIVE: EmitPlaySE(0, SE_KOUKA_H); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); break; case MOVE_RESULT_NOT_VERY_EFFECTIVE: EmitPlaySE(0, SE_KOUKA_L); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); break; case MOVE_RESULT_DOESNT_AFFECT_FOE: case MOVE_RESULT_FAILED: @@ -2116,17 +2116,17 @@ static void atk0E_effectivenesssound(void) if (gMoveResultFlags & MOVE_RESULT_SUPER_EFFECTIVE) { EmitPlaySE(0, SE_KOUKA_H); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } else if (gMoveResultFlags & MOVE_RESULT_NOT_VERY_EFFECTIVE) { EmitPlaySE(0, SE_KOUKA_L); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } else if (!(gMoveResultFlags & (MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED))) { EmitPlaySE(0, SE_KOUKA_M); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } break; } @@ -2170,8 +2170,8 @@ static void atk0F_resultmessage(void) stringId = STRINGID_ITDOESNTAFFECT; break; case MOVE_RESULT_FOE_HUNG_ON: - gLastUsedItem = gBattleMons[gBankDefender].item; - gStringBank = gBankDefender; + gLastUsedItem = gBattleMons[gBattleDefender].item; + gStringBank = gBattleDefender; gMoveResultFlags &= ~(MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_HangedOnMsg; @@ -2199,8 +2199,8 @@ static void atk0F_resultmessage(void) } else if (gMoveResultFlags & MOVE_RESULT_FOE_HUNG_ON) { - gLastUsedItem = gBattleMons[gBankDefender].item; - gStringBank = gBankDefender; + gLastUsedItem = gBattleMons[gBattleDefender].item; + gStringBank = gBattleDefender; gMoveResultFlags &= ~(MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_HangedOnMsg; @@ -2218,7 +2218,7 @@ static void atk0F_resultmessage(void) } if (stringId) - PrepareStringBattle(stringId, gBankAttacker); + PrepareStringBattle(stringId, gBattleAttacker); gBattlescriptCurrInstr++; } @@ -2228,7 +2228,7 @@ static void atk10_printstring(void) if (gBattleExecBuffer == 0) { u16 var = BS2ScriptRead16(gBattlescriptCurrInstr + 1); - PrepareStringBattle(var, gBankAttacker); + PrepareStringBattle(var, gBattleAttacker); gBattlescriptCurrInstr += 3; gBattleCommunication[MSG_DISPLAY] = 1; } @@ -2236,10 +2236,10 @@ static void atk10_printstring(void) static void atk11_printselectionstring(void) { - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; EmitPrintSelectionString(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1)); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 3; gBattleCommunication[MSG_DISPLAY] = 1; @@ -2273,7 +2273,7 @@ static void atk13_printfromtable(void) const u16 *ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); ptr += gBattleCommunication[MULTISTRING_CHOOSER]; - PrepareStringBattle(*ptr, gBankAttacker); + PrepareStringBattle(*ptr, gBattleAttacker); gBattlescriptCurrInstr += 5; gBattleCommunication[MSG_DISPLAY] = 1; @@ -2287,9 +2287,9 @@ static void atk14_printselectionstringfromtable(void) const u16 *ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); ptr += gBattleCommunication[MULTISTRING_CHOOSER]; - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; EmitPrintSelectionString(0, *ptr); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 5; gBattleCommunication[MSG_DISPLAY] = 1; @@ -2299,9 +2299,9 @@ static void atk14_printselectionstringfromtable(void) u8 BankGetTurnOrder(u8 bank) { s32 i; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (gBanksByTurnOrder[i] == bank) + if (gBattleTurnOrder[i] == bank) break; } return i; @@ -2328,22 +2328,22 @@ void SetMoveEffect(bool8 primary, u8 certain) if (gBattleCommunication[MOVE_EFFECT_BYTE] & MOVE_EFFECT_AFFECTS_USER) { - gEffectBank = gBankAttacker; // bank that effects get applied on + gEffectBank = gBattleAttacker; // bank that effects get applied on gBattleCommunication[MOVE_EFFECT_BYTE] &= ~(MOVE_EFFECT_AFFECTS_USER); affectsUser = MOVE_EFFECT_AFFECTS_USER; - gBattleScripting.bank = gBankDefender; // theoretically the attacker + gBattleScripting.battler = gBattleDefender; // theoretically the attacker } else { - gEffectBank = gBankDefender; - gBattleScripting.bank = gBankAttacker; + gEffectBank = gBattleDefender; + gBattleScripting.battler = gBattleAttacker; } if (gBattleMons[gEffectBank].ability == ABILITY_SHIELD_DUST && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) && !primary && gBattleCommunication[MOVE_EFFECT_BYTE] <= 9) INCREMENT_RESET_RETURN - if (gSideStatuses[GET_BANK_SIDE(gEffectBank)] & SIDE_STATUS_SAFEGUARD && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + if (gSideStatuses[GET_BATTLER_SIDE(gEffectBank)] & SIDE_STATUS_SAFEGUARD && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) && !primary && gBattleCommunication[MOVE_EFFECT_BYTE] <= 7) INCREMENT_RESET_RETURN @@ -2363,17 +2363,17 @@ void SetMoveEffect(bool8 primary, u8 certain) // check active uproar if (gBattleMons[gEffectBank].ability != ABILITY_SOUNDPROOF) { - for (gActiveBank = 0; - gActiveBank < gBattleBanksCount && !(gBattleMons[gActiveBank].status2 & STATUS2_UPROAR); - gActiveBank++) + for (gActiveBattler = 0; + gActiveBattler < gBattlersCount && !(gBattleMons[gActiveBattler].status2 & STATUS2_UPROAR); + gActiveBattler++) {} } else - gActiveBank = gBattleBanksCount; + gActiveBattler = gBattlersCount; if (gBattleMons[gEffectBank].status1) break; - if (gActiveBank != gBattleBanksCount) + if (gActiveBattler != gBattlersCount) break; if (gBattleMons[gEffectBank].ability == ABILITY_VITAL_SPIRIT) break; @@ -2583,9 +2583,9 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; - gActiveBank = gEffectBank; + gActiveBattler = gEffectBank; EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gEffectBank].status1); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); if (gHitMarker & HITMARKER_IGNORE_SAFEGUARD) { @@ -2681,10 +2681,10 @@ void SetMoveEffect(bool8 primary, u8 certain) } break; case MOVE_EFFECT_PAYDAY: - if (GET_BANK_SIDE(gBankAttacker) == SIDE_PLAYER) + if (GET_BATTLER_SIDE(gBattleAttacker) == B_SIDE_PLAYER) { u16 PayDay = gPaydayMoney; - gPaydayMoney += (gBattleMons[gBankAttacker].level * 5); + gPaydayMoney += (gBattleMons[gBattleAttacker].level * 5); if (PayDay > gPaydayMoney) gPaydayMoney = 0xFFFF; } @@ -2719,7 +2719,7 @@ void SetMoveEffect(bool8 primary, u8 certain) *(gBattleStruct->wrappedMove + gEffectBank * 2 + 0) = gCurrentMove; *(gBattleStruct->wrappedMove + gEffectBank * 2 + 1) = gCurrentMove >> 8; - *(gBattleStruct->wrappedBy + gEffectBank) = gBankAttacker; + *(gBattleStruct->wrappedBy + gEffectBank) = gBattleAttacker; BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; @@ -2832,7 +2832,7 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattlescriptCurrInstr++; break; case MOVE_EFFECT_RAGE: - gBattleMons[gBankAttacker].status2 |= STATUS2_RAGE; + gBattleMons[gBattleAttacker].status2 |= STATUS2_RAGE; gBattlescriptCurrInstr++; break; case MOVE_EFFECT_STEAL_ITEM: @@ -2843,8 +2843,8 @@ void SetMoveEffect(bool8 primary, u8 certain) break; } - side = GetBankSide(gBankAttacker); - if (GetBankSide(gBankAttacker) == SIDE_OPPONENT + side = GetBattlerSide(gBattleAttacker); + if (GetBattlerSide(gBattleAttacker) == B_SIDE_OPPONENT && !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER @@ -2860,56 +2860,56 @@ void SetMoveEffect(bool8 primary, u8 certain) | BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_SECRET_BASE)) - && (gWishFutureKnock.knockedOffPokes[side] & gBitTable[gBattlePartyID[gBankAttacker]])) + && (gWishFutureKnock.knockedOffPokes[side] & gBitTable[gBattlePartyID[gBattleAttacker]])) { gBattlescriptCurrInstr++; } - else if (gBattleMons[gBankDefender].item - && gBattleMons[gBankDefender].ability == ABILITY_STICKY_HOLD) + else if (gBattleMons[gBattleDefender].item + && gBattleMons[gBattleDefender].ability == ABILITY_STICKY_HOLD) { BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_NoItemSteal; - gLastUsedAbility = gBattleMons[gBankDefender].ability; - RecordAbilityBattle(gBankDefender, gLastUsedAbility); + gLastUsedAbility = gBattleMons[gBattleDefender].ability; + RecordAbilityBattle(gBattleDefender, gLastUsedAbility); } - else if (gBattleMons[gBankAttacker].item != 0 - || gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY - || IS_ITEM_MAIL(gBattleMons[gBankDefender].item) - || gBattleMons[gBankDefender].item == 0) + else if (gBattleMons[gBattleAttacker].item != 0 + || gBattleMons[gBattleDefender].item == ITEM_ENIGMA_BERRY + || IS_ITEM_MAIL(gBattleMons[gBattleDefender].item) + || gBattleMons[gBattleDefender].item == 0) { gBattlescriptCurrInstr++; } else { - u16* changedItem = &gBattleStruct->changedItems[gBankAttacker]; - gLastUsedItem = *changedItem = gBattleMons[gBankDefender].item; - gBattleMons[gBankDefender].item = 0; + u16* changedItem = &gBattleStruct->changedItems[gBattleAttacker]; + gLastUsedItem = *changedItem = gBattleMons[gBattleDefender].item; + gBattleMons[gBattleDefender].item = 0; - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem); - MarkBufferBankForExecution(gBankAttacker); + MarkBufferBankForExecution(gBattleAttacker); - gActiveBank = gBankDefender; - EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBankDefender].item); - MarkBufferBankForExecution(gBankDefender); + gActiveBattler = gBattleDefender; + EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBattleDefender].item); + MarkBufferBankForExecution(gBattleDefender); BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_ItemSteal; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankDefender]) + 0) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankDefender]) + 1) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleDefender]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleDefender]) + 1) = 0; } } break; case MOVE_EFFECT_PREVENT_ESCAPE: - gBattleMons[gBankDefender].status2 |= STATUS2_ESCAPE_PREVENTION; - gDisableStructs[gBankDefender].bankPreventingEscape = gBankAttacker; + gBattleMons[gBattleDefender].status2 |= STATUS2_ESCAPE_PREVENTION; + gDisableStructs[gBattleDefender].bankPreventingEscape = gBattleAttacker; gBattlescriptCurrInstr++; break; case MOVE_EFFECT_NIGHTMARE: - gBattleMons[gBankDefender].status2 |= STATUS2_NIGHTMARE; + gBattleMons[gBattleDefender].status2 |= STATUS2_NIGHTMARE; gBattlescriptCurrInstr++; break; case MOVE_EFFECT_ALL_STATS_UP: @@ -2921,17 +2921,17 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattlescriptCurrInstr = BattleScript_RapidSpinAway; break; case MOVE_EFFECT_REMOVE_PARALYSIS: // Smelling salts - if (!(gBattleMons[gBankDefender].status1 & STATUS1_PARALYSIS)) + if (!(gBattleMons[gBattleDefender].status1 & STATUS1_PARALYSIS)) { gBattlescriptCurrInstr++; } else { - gBattleMons[gBankDefender].status1 &= ~(STATUS1_PARALYSIS); + gBattleMons[gBattleDefender].status1 &= ~(STATUS1_PARALYSIS); - gActiveBank = gBankDefender; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = gBattleDefender; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_TargetPRLZHeal; @@ -2978,7 +2978,7 @@ void SetMoveEffect(bool8 primary, u8 certain) } if (gBattleMons[gEffectBank].item) { - side = GetBankSide(gEffectBank); + side = GetBattlerSide(gEffectBank); gLastUsedItem = gBattleMons[gEffectBank].item; gBattleMons[gEffectBank].item = 0; @@ -3010,7 +3010,7 @@ static void atk15_seteffectwithchance(void) { u32 percentChance; - if (gBattleMons[gBankAttacker].ability == ABILITY_SERENE_GRACE) + if (gBattleMons[gBattleAttacker].ability == ABILITY_SERENE_GRACE) percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance * 2; else percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance; @@ -3051,12 +3051,12 @@ static void atk17_seteffectsecondary(void) static void atk18_clearstatusfromeffect(void) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); if (gBattleCommunication[MOVE_EFFECT_BYTE] <= MOVE_EFFECT_TOXIC) - gBattleMons[gActiveBank].status1 &= (~sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]); + gBattleMons[gActiveBattler].status1 &= (~sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]); else - gBattleMons[gActiveBank].status2 &= (~sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]); + gBattleMons[gActiveBattler].status2 &= (~sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]); gBattleCommunication[MOVE_EFFECT_BYTE] = 0; gBattlescriptCurrInstr += 2; @@ -3069,14 +3069,14 @@ static void atk19_tryfaintmon(void) if (gBattlescriptCurrInstr[2] != 0) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - if (gHitMarker & HITMARKER_FAINTED(gActiveBank)) + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); + if (gHitMarker & HITMARKER_FAINTED(gActiveBattler)) { BS_ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 3); BattleScriptPop(); gBattlescriptCurrInstr = BS_ptr; - gSideStatuses[GetBankSide(gActiveBank)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); + gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); } else { @@ -3089,58 +3089,58 @@ static void atk19_tryfaintmon(void) if (gBattlescriptCurrInstr[1] == BS_GET_ATTACKER) { - gActiveBank = gBankAttacker; - bank = gBankDefender; + gActiveBattler = gBattleAttacker; + bank = gBattleDefender; BS_ptr = BattleScript_FaintAttacker; } else { - gActiveBank = gBankDefender; - bank = gBankAttacker; + gActiveBattler = gBattleDefender; + bank = gBattleAttacker; BS_ptr = BattleScript_FaintTarget; } - if (!(gAbsentBankFlags & gBitTable[gActiveBank]) - && gBattleMons[gActiveBank].hp == 0) + if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler]) + && gBattleMons[gActiveBattler].hp == 0) { - gHitMarker |= HITMARKER_FAINTED(gActiveBank); + gHitMarker |= HITMARKER_FAINTED(gActiveBattler); BattleScriptPush(gBattlescriptCurrInstr + 7); gBattlescriptCurrInstr = BS_ptr; - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { gHitMarker |= HITMARKER_x400000; if (gBattleResults.playerFaintCounter < 0xFF) gBattleResults.playerFaintCounter++; - AdjustFriendshipOnBattleFaint(gActiveBank); + AdjustFriendshipOnBattleFaint(gActiveBattler); } else { if (gBattleResults.opponentFaintCounter < 0xFF) gBattleResults.opponentFaintCounter++; - gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBank]], MON_DATA_SPECIES, NULL); + gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlePartyID[gActiveBattler]], MON_DATA_SPECIES, NULL); } - if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBankAttacker].hp != 0) + if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBattleAttacker].hp != 0) { gHitMarker &= ~(HITMARKER_DESTINYBOND); BattleScriptPush(gBattlescriptCurrInstr); gBattleMoveDamage = gBattleMons[bank].hp; gBattlescriptCurrInstr = BattleScript_DestinyBondTakesLife; } - if ((gStatuses3[gBankDefender] & STATUS3_GRUDGE) + if ((gStatuses3[gBattleDefender] & STATUS3_GRUDGE) && !(gHitMarker & HITMARKER_GRUDGE) - && GetBankSide(gBankAttacker) != GetBankSide(gBankDefender) - && gBattleMons[gBankAttacker].hp != 0 + && GetBattlerSide(gBattleAttacker) != GetBattlerSide(gBattleDefender) + && gBattleMons[gBattleAttacker].hp != 0 && gCurrentMove != MOVE_STRUGGLE) { - u8 moveIndex = *(gBattleStruct->chosenMovePositions + gBankAttacker); + u8 moveIndex = *(gBattleStruct->chosenMovePositions + gBattleAttacker); - gBattleMons[gBankAttacker].pp[moveIndex] = 0; + gBattleMons[gBattleAttacker].pp[moveIndex] = 0; BattleScriptPush(gBattlescriptCurrInstr); gBattlescriptCurrInstr = BattleScript_GrudgeTakesPp; - gActiveBank = gBankAttacker; - EmitSetMonData(0, moveIndex + REQUEST_PPMOVE1_BATTLE, 0, 1, &gBattleMons[gActiveBank].pp[moveIndex]); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = gBattleAttacker; + EmitSetMonData(0, moveIndex + REQUEST_PPMOVE1_BATTLE, 0, 1, &gBattleMons[gActiveBattler].pp[moveIndex]); + MarkBufferBankForExecution(gActiveBattler); - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBankAttacker].moves[moveIndex]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBattleAttacker].moves[moveIndex]) } } else @@ -3154,9 +3154,9 @@ static void atk1A_dofaintanimation(void) { if (gBattleExecBuffer == 0) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); EmitFaintAnimation(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } } @@ -3165,13 +3165,13 @@ static void atk1B_cleareffectsonfaint(void) { if (gBattleExecBuffer == 0) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); - if (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || gBattleMons[gActiveBank].hp == 0) + if (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || gBattleMons[gActiveBattler].hp == 0) { - gBattleMons[gActiveBank].status1 = 0; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 0x4, &gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); + gBattleMons[gActiveBattler].status1 = 0; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 0x4, &gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); } FaintClearSetData(); // Effects like attractions, trapping, etc. @@ -3211,7 +3211,7 @@ static void atk1E_jumpifability(void) if (gBattlescriptCurrInstr[1] == BS_GET_ATTACKER_SIDE) { - bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_BANK_SIDE, gBankAttacker, ability, 0, 0); + bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_BANK_SIDE, gBattleAttacker, ability, 0, 0); if (bank) { gLastUsedAbility = ability; @@ -3224,7 +3224,7 @@ static void atk1E_jumpifability(void) } else if (gBattlescriptCurrInstr[1] == BS_GET_NOT_ATTACKER_SIDE) { - bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gBankAttacker, ability, 0, 0); + bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gBattleAttacker, ability, 0, 0); if (bank) { gLastUsedAbility = ability; @@ -3257,9 +3257,9 @@ static void atk1F_jumpifsideaffecting(void) const u8* jumpPtr; if (gBattlescriptCurrInstr[1] == BS_GET_ATTACKER) - side = GET_BANK_SIDE(gBankAttacker); + side = GET_BATTLER_SIDE(gBattleAttacker); else - side = GET_BANK_SIDE(gBankDefender); + side = GET_BATTLER_SIDE(gBattleDefender); flags = BS2ScriptRead16(gBattlescriptCurrInstr + 2); jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 4); @@ -3315,20 +3315,20 @@ static void atk21_jumpifstatus3condition(void) u32 flags; const u8 *jumpPtr; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); flags = BS2ScriptRead32(gBattlescriptCurrInstr + 2); jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 7); if (gBattlescriptCurrInstr[6]) { - if ((gStatuses3[gActiveBank] & flags) != 0) + if ((gStatuses3[gActiveBattler] & flags) != 0) gBattlescriptCurrInstr += 11; else gBattlescriptCurrInstr = jumpPtr; } else { - if ((gStatuses3[gActiveBank] & flags) != 0) + if ((gStatuses3[gActiveBattler] & flags) != 0) gBattlescriptCurrInstr = jumpPtr; else gBattlescriptCurrInstr += 11; @@ -3363,7 +3363,7 @@ static void atk23_getexp(void) switch (gBattleScripting.atk23_state) { case 0: // check if should receive exp at all - if (GetBankSide(gBank1) != SIDE_OPPONENT || (gBattleTypeFlags & + if (GetBattlerSide(gBank1) != B_SIDE_OPPONENT || (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000 | BATTLE_TYPE_x4000000 @@ -3495,11 +3495,11 @@ static void atk23_getexp(void) // get exp getter bank if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - if (!(gBattlePartyID[2] != gBattleStruct->expGetterId) && !(gAbsentBankFlags & gBitTable[2])) + if (!(gBattlePartyID[2] != gBattleStruct->expGetterId) && !(gAbsentBattlerFlags & gBitTable[2])) gBattleStruct->expGetterBank = 2; else { - if (!(gAbsentBankFlags & gBitTable[0])) + if (!(gAbsentBattlerFlags & gBitTable[0])) gBattleStruct->expGetterBank = 0; else gBattleStruct->expGetterBank = 2; @@ -3536,9 +3536,9 @@ static void atk23_getexp(void) BATTLE_LVLUP_STATS->spAtk = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPATK); BATTLE_LVLUP_STATS->spDef = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPDEF); - gActiveBank = gBattleStruct->expGetterBank; + gActiveBattler = gBattleStruct->expGetterBank; EmitExpUpdate(0, gBattleStruct->expGetterId, gBattleMoveDamage); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } gBattleScripting.atk23_state++; } @@ -3546,20 +3546,20 @@ static void atk23_getexp(void) case 4: // lvl up if necessary if (gBattleExecBuffer == 0) { - gActiveBank = gBattleStruct->expGetterBank; - if (gBattleBufferB[gActiveBank][0] == CONTROLLER_TWORETURNVALUES && gBattleBufferB[gActiveBank][1] == RET_VALUE_LEVELLED_UP) + gActiveBattler = gBattleStruct->expGetterBank; + if (gBattleBufferB[gActiveBattler][0] == CONTROLLER_TWORETURNVALUES && gBattleBufferB[gActiveBattler][1] == RET_VALUE_LEVELLED_UP) { - if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId) - HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBank]], gActiveBank); + if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattlePartyID[gActiveBattler] == gBattleStruct->expGetterId) + HandleLowHpMusicChange(&gPlayerParty[gBattlePartyID[gActiveBattler]], gActiveBattler); - PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBank, gBattleStruct->expGetterId) + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBattler, gBattleStruct->expGetterId) PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff2, 3, GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_LEVEL)) BattleScriptPushCursor(); gLeveledUpInBattle |= gBitTable[gBattleStruct->expGetterId]; gBattlescriptCurrInstr = BattleScript_LevelUp; - gBattleMoveDamage = (gBattleBufferB[gActiveBank][2] | (gBattleBufferB[gActiveBank][3] << 8)); + gBattleMoveDamage = (gBattleBufferB[gActiveBattler][2] | (gBattleBufferB[gActiveBattler][3] << 8)); AdjustFriendship(&gPlayerParty[gBattleStruct->expGetterId], 0); // update battle mon structure after level up @@ -3674,13 +3674,13 @@ static void atk24(void) s32 foundOpponent; // Impossible to decompile loops. - for (foundPlayer = 0, i = 0; i < gBattleBanksCount; i += 2) + for (foundPlayer = 0, i = 0; i < gBattlersCount; i += 2) { if (HITMARKER_UNK(i) & gHitMarker && !gSpecialStatuses[i].flag40) foundPlayer++; } - for (foundOpponent = 0, i = 1; i < gBattleBanksCount; i += 2) + for (foundOpponent = 0, i = 1; i < gBattlersCount; i += 2) { if (HITMARKER_UNK(i) & gHitMarker && !gSpecialStatuses[i].flag40) foundOpponent++; @@ -3889,7 +3889,7 @@ static void atk24(void) beq _0804AF1A\n\ movs r3, 0\n\ movs r5, 0\n\ - ldr r0, =gBattleBanksCount\n\ + ldr r0, =gBattlersCount\n\ ldrb r1, [r0]\n\ mov r12, r0\n\ ldr r7, =gBattlescriptCurrInstr\n\ @@ -4323,12 +4323,12 @@ static void atk3A_waitstate(void) static void atk3B_healthbar_update(void) { if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) - gActiveBank = gBankDefender; + gActiveBattler = gBattleDefender; else - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; EmitHealthBarUpdate(0, gBattleMoveDamage); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } @@ -4340,16 +4340,16 @@ static void atk3C_return(void) static void atk3D_end(void) { if (gBattleTypeFlags & BATTLE_TYPE_ARENA) - sub_81A5718(gBankAttacker); + sub_81A5718(gBattleAttacker); gMoveResultFlags = 0; - gActiveBank = 0; + gActiveBattler = 0; gCurrentActionFuncId = 0xB; } static void atk3E_end2(void) { - gActiveBank = 0; + gActiveBattler = 0; gCurrentActionFuncId = 0xB; } @@ -4387,14 +4387,14 @@ static void atk43_jumpifabilitypresent(void) static void atk44_endselectionscript(void) { - *(gBankAttacker + gBattleStruct->selectionScriptFinished) = TRUE; + *(gBattleAttacker + gBattleStruct->selectionScriptFinished) = TRUE; } static void atk45_playanimation(void) { const u16* argumentPtr; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); argumentPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 3); if (gBattlescriptCurrInstr[2] == B_ANIM_STATS_CHANGE @@ -4402,7 +4402,7 @@ static void atk45_playanimation(void) || gBattlescriptCurrInstr[2] == B_ANIM_SUBSTITUTE_FADE) { EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 7; } else if (gHitMarker & HITMARKER_NO_ANIMATIONS) @@ -4416,17 +4416,17 @@ static void atk45_playanimation(void) || gBattlescriptCurrInstr[2] == B_ANIM_HAIL_CONTINUES) { EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 7; } - else if (gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) + else if (gStatuses3[gActiveBattler] & STATUS3_SEMI_INVULNERABLE) { gBattlescriptCurrInstr += 7; } else { EmitBattleAnimation(0, gBattlescriptCurrInstr[2], *argumentPtr); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 7; } } @@ -4436,7 +4436,7 @@ static void atk46_playanimation2(void) // animation Id is stored in the first po const u16* argumentPtr; const u8* animationIdPtr; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); animationIdPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 2); argumentPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 6); @@ -4445,7 +4445,7 @@ static void atk46_playanimation2(void) // animation Id is stored in the first po || *animationIdPtr == B_ANIM_SUBSTITUTE_FADE) { EmitBattleAnimation(0, *animationIdPtr, *argumentPtr); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 10; } else if (gHitMarker & HITMARKER_NO_ANIMATIONS) @@ -4458,17 +4458,17 @@ static void atk46_playanimation2(void) // animation Id is stored in the first po || *animationIdPtr == B_ANIM_HAIL_CONTINUES) { EmitBattleAnimation(0, *animationIdPtr, *argumentPtr); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 10; } - else if (gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) + else if (gStatuses3[gActiveBattler] & STATUS3_SEMI_INVULNERABLE) { gBattlescriptCurrInstr += 10; } else { EmitBattleAnimation(0, *animationIdPtr, *argumentPtr); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 10; } } @@ -4505,7 +4505,7 @@ static void atk48_playstatchangeanimation(void) s32 changeableStats = 0; u32 statsToCheck = 0; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); statsToCheck = gBattlescriptCurrInstr[2]; if (gBattlescriptCurrInstr[3] & ATK48_STAT_NEGATIVE) // goes down @@ -4517,19 +4517,19 @@ static void atk48_playstatchangeanimation(void) { if (!(gBattlescriptCurrInstr[3] & ATK48_LOWER_FAIL_CHECK)) { - if (gBattleMons[gActiveBank].statStages[currStat] > 0) + if (gBattleMons[gActiveBattler].statStages[currStat] > 0) { statAnimId = checkingStatAnimId; changeableStats++; } } - else if (!gSideTimers[GET_BANK_SIDE(gActiveBank)].mistTimer - && gBattleMons[gActiveBank].ability != ABILITY_CLEAR_BODY - && gBattleMons[gActiveBank].ability != ABILITY_WHITE_SMOKE - && !(gBattleMons[gActiveBank].ability == ABILITY_KEEN_EYE && currStat == STAT_STAGE_ACC) - && !(gBattleMons[gActiveBank].ability == ABILITY_HYPER_CUTTER && currStat == STAT_STAGE_ATK)) + else if (!gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].mistTimer + && gBattleMons[gActiveBattler].ability != ABILITY_CLEAR_BODY + && gBattleMons[gActiveBattler].ability != ABILITY_WHITE_SMOKE + && !(gBattleMons[gActiveBattler].ability == ABILITY_KEEN_EYE && currStat == STAT_STAGE_ACC) + && !(gBattleMons[gActiveBattler].ability == ABILITY_HYPER_CUTTER && currStat == STAT_STAGE_ATK)) { - if (gBattleMons[gActiveBank].statStages[currStat] > 0) + if (gBattleMons[gActiveBattler].statStages[currStat] > 0) { statAnimId = checkingStatAnimId; changeableStats++; @@ -4552,7 +4552,7 @@ static void atk48_playstatchangeanimation(void) checkingStatAnimId = (gBattlescriptCurrInstr[3] & ATK48_STAT_BY_TWO) ? 0x26 : 0xE; while (statsToCheck != 0) { - if (statsToCheck & 1 && gBattleMons[gActiveBank].statStages[currStat] < 0xC) + if (statsToCheck & 1 && gBattleMons[gActiveBattler].statStages[currStat] < 0xC) { statAnimId = checkingStatAnimId; changeableStats++; @@ -4576,7 +4576,7 @@ static void atk48_playstatchangeanimation(void) else if (changeableStats != 0 && gBattleScripting.field_1B == 0) { EmitBattleAnimation(0, B_ANIM_STATS_CHANGE, statAnimId); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); if (gBattlescriptCurrInstr[3] & ATK48_BIT_x4 && changeableStats > 1) gBattleScripting.field_1B = 1; gBattlescriptCurrInstr += 4; @@ -4607,7 +4607,7 @@ static void atk48_playstatchangeanimation(void) ldrb r0, [r0, 0x1]\n\ str r3, [sp]\n\ bl GetBattleBank\n\ - ldr r2, =gActiveBank\n\ + ldr r2, =gActiveBattler\n\ strb r0, [r2]\n\ ldr r0, [r5]\n\ ldrb r4, [r0, 0x2]\n\ @@ -4644,7 +4644,7 @@ _0804BA26:\n\ ands r0, r1\n\ cmp r0, 0\n\ beq _0804BA58\n\ - ldr r0, =gActiveBank\n\ + ldr r0, =gActiveBattler\n\ ldrb r1, [r0]\n\ movs r0, 0x58\n\ muls r0, r1\n\ @@ -4652,10 +4652,10 @@ _0804BA26:\n\ b _0804BAA0\n\ .pool\n\ _0804BA58:\n\ - ldr r6, =gActiveBank\n\ + ldr r6, =gActiveBattler\n\ ldrb r0, [r6]\n\ str r3, [sp]\n\ - bl GetBankPosition\n\ + bl GetBattlerPosition\n\ mov r1, r10\n\ ands r1, r0\n\ lsls r0, r1, 1\n\ @@ -4804,7 +4804,7 @@ _0804BB6C:\n\ mov r2, r8\n\ str r3, [sp]\n\ bl EmitBattleAnimation\n\ - ldr r0, =gActiveBank\n\ + ldr r0, =gActiveBattler\n\ ldrb r0, [r0]\n\ bl MarkBufferBankForExecution\n\ ldr r0, =gBattlescriptCurrInstr\n\ @@ -4864,12 +4864,12 @@ static void atk49_moveend(void) arg1 = gBattlescriptCurrInstr[1]; arg2 = gBattlescriptCurrInstr[2]; - if (gBattleMons[gBankAttacker].item == ITEM_ENIGMA_BERRY) - holdEffectAtk = gEnigmaBerries[gBankAttacker].holdEffect; + if (gBattleMons[gBattleAttacker].item == ITEM_ENIGMA_BERRY) + holdEffectAtk = gEnigmaBerries[gBattleAttacker].holdEffect; else - holdEffectAtk = ItemId_GetHoldEffect(gBattleMons[gBankAttacker].item); + holdEffectAtk = ItemId_GetHoldEffect(gBattleMons[gBattleAttacker].item); - choicedMoveAtk = &gBattleStruct->choicedMove[gBankAttacker]; + choicedMoveAtk = &gBattleStruct->choicedMove[gBattleAttacker]; GET_MOVE_TYPE(gCurrentMove, moveType); @@ -4878,13 +4878,13 @@ static void atk49_moveend(void) switch (gBattleScripting.atk49_state) { case 0: // rage check - if (gBattleMons[gBankDefender].status2 & STATUS2_RAGE - && gBattleMons[gBankDefender].hp != 0 && gBankAttacker != gBankDefender - && GetBankSide(gBankAttacker) != GetBankSide(gBankDefender) + if (gBattleMons[gBattleDefender].status2 & STATUS2_RAGE + && gBattleMons[gBattleDefender].hp != 0 && gBattleAttacker != gBattleDefender + && GetBattlerSide(gBattleAttacker) != GetBattlerSide(gBattleDefender) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && TARGET_TURN_DAMAGED - && gBattleMoves[gCurrentMove].power && gBattleMons[gBankDefender].statStages[STAT_STAGE_ATK] <= 0xB) + && gBattleMoves[gCurrentMove].power && gBattleMons[gBattleDefender].statStages[STAT_STAGE_ATK] <= 0xB) { - gBattleMons[gBankDefender].statStages[STAT_STAGE_ATK]++; + gBattleMons[gBattleDefender].statStages[STAT_STAGE_ATK]++; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_RageIsBuilding; effect = TRUE; @@ -4892,15 +4892,15 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case 1: // defrosting check - if (gBattleMons[gBankDefender].status1 & STATUS1_FREEZE - && gBattleMons[gBankDefender].hp != 0 && gBankAttacker != gBankDefender - && gSpecialStatuses[gBankDefender].moveturnLostHP_special + if (gBattleMons[gBattleDefender].status1 & STATUS1_FREEZE + && gBattleMons[gBattleDefender].hp != 0 && gBattleAttacker != gBattleDefender + && gSpecialStatuses[gBattleDefender].moveturnLostHP_special && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && moveType == TYPE_FIRE) { - gBattleMons[gBankDefender].status1 &= ~(STATUS1_FREEZE); - gActiveBank = gBankDefender; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBankDefender].status1); - MarkBufferBankForExecution(gActiveBank); + gBattleMons[gBattleDefender].status1 &= ~(STATUS1_FREEZE); + gActiveBattler = gBattleDefender; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBattleDefender].status1); + MarkBufferBankForExecution(gActiveBattler); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_DefrostedViaFireMove; effect = TRUE; @@ -4908,12 +4908,12 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case 2: // target synchronize - if (AbilityBattleEffects(ABILITYEFFECT_SYNCHRONIZE, gBankDefender, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_SYNCHRONIZE, gBattleDefender, 0, 0, 0)) effect = TRUE; gBattleScripting.atk49_state++; break; case 3: // contact abilities - if (AbilityBattleEffects(ABILITYEFFECT_CONTACT, gBankDefender, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_CONTACT, gBattleDefender, 0, 0, 0)) effect = TRUE; gBattleScripting.atk49_state++; break; @@ -4924,7 +4924,7 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case 5: // attacker synchronize - if (AbilityBattleEffects(ABILITYEFFECT_ATK_SYNCHRONIZE, gBankAttacker, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_ATK_SYNCHRONIZE, gBattleAttacker, 0, 0, 0)) effect = TRUE; gBattleScripting.atk49_state++; break; @@ -4942,7 +4942,7 @@ static void atk49_moveend(void) { for (i = 0; i < 4; i++) { - if (gBattleMons[gBankAttacker].moves[i] == *choicedMoveAtk) + if (gBattleMons[gBattleAttacker].moves[i] == *choicedMoveAtk) break; } if (i == 4) @@ -4952,7 +4952,7 @@ static void atk49_moveend(void) } break; case 7: // changed held items - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { u16* changedItem = &gBattleStruct->changedItems[i]; if (*changedItem != 0) @@ -4975,12 +4975,12 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case 8: // make attacker sprite invisible - if (gStatuses3[gBankAttacker] & (STATUS3_SEMI_INVULNERABLE) + if (gStatuses3[gBattleAttacker] & (STATUS3_SEMI_INVULNERABLE) && gHitMarker & HITMARKER_NO_ANIMATIONS) { - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; EmitSpriteInvisibility(0, TRUE); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattleScripting.atk49_state++; return; } @@ -4988,34 +4988,34 @@ static void atk49_moveend(void) break; case 9: // make attacker sprite visible if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT - || !(gStatuses3[gBankAttacker] & (STATUS3_SEMI_INVULNERABLE)) - || WasUnableToUseMove(gBankAttacker)) + || !(gStatuses3[gBattleAttacker] & (STATUS3_SEMI_INVULNERABLE)) + || WasUnableToUseMove(gBattleAttacker)) { - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; EmitSpriteInvisibility(0, FALSE); - MarkBufferBankForExecution(gActiveBank); - gStatuses3[gBankAttacker] &= ~(STATUS3_SEMI_INVULNERABLE); - gSpecialStatuses[gBankAttacker].restoredBankSprite = 1; + MarkBufferBankForExecution(gActiveBattler); + gStatuses3[gBattleAttacker] &= ~(STATUS3_SEMI_INVULNERABLE); + gSpecialStatuses[gBattleAttacker].restoredBankSprite = 1; gBattleScripting.atk49_state++; return; } gBattleScripting.atk49_state++; break; case 10: // make target sprite visible - if (!gSpecialStatuses[gBankDefender].restoredBankSprite && gBankDefender < gBattleBanksCount - && !(gStatuses3[gBankDefender] & STATUS3_SEMI_INVULNERABLE)) + if (!gSpecialStatuses[gBattleDefender].restoredBankSprite && gBattleDefender < gBattlersCount + && !(gStatuses3[gBattleDefender] & STATUS3_SEMI_INVULNERABLE)) { - gActiveBank = gBankDefender; + gActiveBattler = gBattleDefender; EmitSpriteInvisibility(0, FALSE); - MarkBufferBankForExecution(gActiveBank); - gStatuses3[gBankDefender] &= ~(STATUS3_SEMI_INVULNERABLE); + MarkBufferBankForExecution(gActiveBattler); + gStatuses3[gBattleDefender] &= ~(STATUS3_SEMI_INVULNERABLE); gBattleScripting.atk49_state++; return; } gBattleScripting.atk49_state++; break; case 13: // update substitute - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gDisableStructs[i].substituteHP == 0) gBattleMons[i].status2 &= ~(STATUS2_SUBSTITUTE); @@ -5025,82 +5025,82 @@ static void atk49_moveend(void) case 14: // This case looks interesting, although I am not certain what it does. Probably fine tunes edge cases. if (gHitMarker & HITMARKER_PURSUIT_TRAP) { - gActiveBank = gBankAttacker; - gBankAttacker = gBankDefender; - gBankDefender = gActiveBank; + gActiveBattler = gBattleAttacker; + gBattleAttacker = gBattleDefender; + gBattleDefender = gActiveBattler; gHitMarker &= ~(HITMARKER_PURSUIT_TRAP); } if (gHitMarker & HITMARKER_ATTACKSTRING_PRINTED) { - gLastPrintedMoves[gBankAttacker] = gChosenMove; + gLastPrintedMoves[gBattleAttacker] = gChosenMove; } - if (!(gAbsentBankFlags & gBitTable[gBankAttacker]) - && !(gBattleStruct->field_91 & gBitTable[gBankAttacker]) + if (!(gAbsentBattlerFlags & gBitTable[gBattleAttacker]) + && !(gBattleStruct->field_91 & gBitTable[gBattleAttacker]) && gBattleMoves[originallyUsedMove].effect != EFFECT_BATON_PASS) { if (gHitMarker & HITMARKER_OBEYS) { - gLastMoves[gBankAttacker] = gChosenMove; - gLastResultingMoves[gBankAttacker] = gCurrentMove; + gLastMoves[gBattleAttacker] = gChosenMove; + gLastResultingMoves[gBattleAttacker] = gCurrentMove; } else { - gLastMoves[gBankAttacker] = 0xFFFF; - gLastResultingMoves[gBankAttacker] = 0xFFFF; + gLastMoves[gBattleAttacker] = 0xFFFF; + gLastResultingMoves[gBattleAttacker] = 0xFFFF; } - if (!(gHitMarker & HITMARKER_FAINTED(gBankDefender))) - gLastHitBy[gBankDefender] = gBankAttacker; + if (!(gHitMarker & HITMARKER_FAINTED(gBattleDefender))) + gLastHitBy[gBattleDefender] = gBattleAttacker; if (gHitMarker & HITMARKER_OBEYS && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { if (gChosenMove == 0xFFFF) { - gLastLandedMoves[gBankDefender] = gChosenMove; + gLastLandedMoves[gBattleDefender] = gChosenMove; } else { - gLastLandedMoves[gBankDefender] = gCurrentMove; - GET_MOVE_TYPE(gCurrentMove, gLastHitByType[gBankDefender]); + gLastLandedMoves[gBattleDefender] = gCurrentMove; + GET_MOVE_TYPE(gCurrentMove, gLastHitByType[gBattleDefender]); } } else { - gLastLandedMoves[gBankDefender] = 0xFFFF; + gLastLandedMoves[gBattleDefender] = 0xFFFF; } } gBattleScripting.atk49_state++; break; case 15: // mirror move - if (!(gAbsentBankFlags & gBitTable[gBankAttacker]) && !(gBattleStruct->field_91 & gBitTable[gBankAttacker]) + if (!(gAbsentBattlerFlags & gBitTable[gBattleAttacker]) && !(gBattleStruct->field_91 & gBitTable[gBattleAttacker]) && gBattleMoves[originallyUsedMove].flags & FLAG_MIRROR_MOVE_AFFECTED && gHitMarker & HITMARKER_OBEYS - && gBankAttacker != gBankDefender && !(gHitMarker & HITMARKER_FAINTED(gBankDefender)) + && gBattleAttacker != gBattleDefender && !(gHitMarker & HITMARKER_FAINTED(gBattleDefender)) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { u8 target, attacker; - *(gBattleStruct->mirrorMoves + gBankDefender * 2 + 0) = gChosenMove; - *(gBattleStruct->mirrorMoves + gBankDefender * 2 + 1) = gChosenMove >> 8; + *(gBattleStruct->mirrorMoves + gBattleDefender * 2 + 0) = gChosenMove; + *(gBattleStruct->mirrorMoves + gBattleDefender * 2 + 1) = gChosenMove >> 8; - target = gBankDefender; - attacker = gBankAttacker; + target = gBattleDefender; + attacker = gBattleAttacker; *(attacker * 2 + target * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = gChosenMove; - target = gBankDefender; - attacker = gBankAttacker; + target = gBattleDefender; + attacker = gBattleAttacker; *(attacker * 2 + target * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = gChosenMove >> 8; } gBattleScripting.atk49_state++; break; case 16: // if (!(gHitMarker & HITMARKER_UNABLE_TO_USE_MOVE) && gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && !gProtectStructs[gBankAttacker].chargingTurn && gBattleMoves[gCurrentMove].target == MOVE_TARGET_BOTH + && !gProtectStructs[gBattleAttacker].chargingTurn && gBattleMoves[gCurrentMove].target == MOVE_TARGET_BOTH && !(gHitMarker & HITMARKER_NO_ATTACKSTRING)) { - u8 bank = GetBankByPosition(B_POSITION_PARTNER(GetBankPosition(gBankDefender))); + u8 bank = GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gBattleDefender))); if (gBattleMons[bank].hp != 0) { - gBankDefender = bank; + gBattleDefender = bank; gHitMarker |= HITMARKER_NO_ATTACKSTRING; gBattleScripting.atk49_state = 0; MoveValuesCleanUp(); @@ -5136,13 +5136,13 @@ static void atk4A_typecalc2(void) s32 i = 0; u8 moveType = gBattleMoves[gCurrentMove].type; - if (gBattleMons[gBankDefender].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) + if (gBattleMons[gBattleDefender].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { - gLastUsedAbility = gBattleMons[gBankDefender].ability; + gLastUsedAbility = gBattleMons[gBattleDefender].ability; gMoveResultFlags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE); - gLastLandedMoves[gBankDefender] = 0; + gLastLandedMoves[gBattleDefender] = 0; gBattleCommunication[6] = moveType; - RecordAbilityBattle(gBankDefender, gLastUsedAbility); + RecordAbilityBattle(gBattleDefender, gLastUsedAbility); } else { @@ -5150,7 +5150,7 @@ static void atk4A_typecalc2(void) { if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) { - if (gBattleMons[gBankDefender].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBattleDefender].status2 & STATUS2_FORESIGHT) { break; } @@ -5164,7 +5164,7 @@ static void atk4A_typecalc2(void) if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type1) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type1) { if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { @@ -5181,22 +5181,22 @@ static void atk4A_typecalc2(void) } } // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type2) { - if (gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 + if (gBattleMons[gBattleDefender].type1 != gBattleMons[gBattleDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; break; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 - && gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type2 + && gBattleMons[gBattleDefender].type1 != gBattleMons[gBattleDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) { flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 - && gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleDefender].type2 + && gBattleMons[gBattleDefender].type1 != gBattleMons[gBattleDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) { flags |= MOVE_RESULT_SUPER_EFFECTIVE; @@ -5207,31 +5207,31 @@ static void atk4A_typecalc2(void) } } - if (gBattleMons[gBankDefender].ability == ABILITY_WONDER_GUARD + if (gBattleMons[gBattleDefender].ability == ABILITY_WONDER_GUARD && !(flags & MOVE_RESULT_NO_EFFECT) - && AttacksThisTurn(gBankAttacker, gCurrentMove) == 2 + && AttacksThisTurn(gBattleAttacker, gCurrentMove) == 2 && (!(flags & MOVE_RESULT_SUPER_EFFECTIVE) || ((flags & (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)) == (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE))) && gBattleMoves[gCurrentMove].power) { gLastUsedAbility = ABILITY_WONDER_GUARD; gMoveResultFlags |= MOVE_RESULT_MISSED; - gLastLandedMoves[gBankDefender] = 0; + gLastLandedMoves[gBattleDefender] = 0; gBattleCommunication[6] = 3; - RecordAbilityBattle(gBankDefender, gLastUsedAbility); + RecordAbilityBattle(gBattleDefender, gLastUsedAbility); } if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) - gProtectStructs[gBankAttacker].targetNotAffected = 1; + gProtectStructs[gBattleAttacker].targetNotAffected = 1; gBattlescriptCurrInstr++; } static void atk4B_returnatktoball(void) { - gActiveBank = gBankAttacker; - if (!(gHitMarker & HITMARKER_FAINTED(gActiveBank))) + gActiveBattler = gBattleAttacker; + if (!(gHitMarker & HITMARKER_FAINTED(gActiveBattler))) { EmitReturnMonToBall(0, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } gBattlescriptCurrInstr++; } @@ -5241,12 +5241,12 @@ static void atk4C_getswitchedmondata(void) if (gBattleExecBuffer) return; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); - gBattlePartyID[gActiveBank] = *(gBattleStruct->monToSwitchIntoId + gActiveBank); + gBattlePartyID[gActiveBattler] = *(gBattleStruct->monToSwitchIntoId + gActiveBattler); - EmitGetMonData(0, REQUEST_ALL_BATTLE, gBitTable[gBattlePartyID[gActiveBank]]); - MarkBufferBankForExecution(gActiveBank); + EmitGetMonData(0, REQUEST_ALL_BATTLE, gBitTable[gBattlePartyID[gActiveBattler]]); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } @@ -5260,46 +5260,46 @@ static void atk4D_switchindataupdate(void) if (gBattleExecBuffer) return; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - oldData = gBattleMons[gActiveBank]; - monData = (u8*)(&gBattleMons[gActiveBank]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); + oldData = gBattleMons[gActiveBattler]; + monData = (u8*)(&gBattleMons[gActiveBattler]); for (i = 0; i < sizeof(struct BattlePokemon); i++) { - monData[i] = gBattleBufferB[gActiveBank][4 + i]; + monData[i] = gBattleBufferB[gActiveBattler][4 + i]; } - gBattleMons[gActiveBank].type1 = gBaseStats[gBattleMons[gActiveBank].species].type1; - gBattleMons[gActiveBank].type2 = gBaseStats[gBattleMons[gActiveBank].species].type2; - gBattleMons[gActiveBank].ability = GetAbilityBySpecies(gBattleMons[gActiveBank].species, gBattleMons[gActiveBank].altAbility); + gBattleMons[gActiveBattler].type1 = gBaseStats[gBattleMons[gActiveBattler].species].type1; + gBattleMons[gActiveBattler].type2 = gBaseStats[gBattleMons[gActiveBattler].species].type2; + gBattleMons[gActiveBattler].ability = GetAbilityBySpecies(gBattleMons[gActiveBattler].species, gBattleMons[gActiveBattler].altAbility); // check knocked off item - i = GetBankSide(gActiveBank); - if (gWishFutureKnock.knockedOffPokes[i] & gBitTable[gBattlePartyID[gActiveBank]]) + i = GetBattlerSide(gActiveBattler); + if (gWishFutureKnock.knockedOffPokes[i] & gBitTable[gBattlePartyID[gActiveBattler]]) { - gBattleMons[gActiveBank].item = 0; + gBattleMons[gActiveBattler].item = 0; } if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) { for (i = 0; i < BATTLE_STATS_NO; i++) { - gBattleMons[gActiveBank].statStages[i] = oldData.statStages[i]; + gBattleMons[gActiveBattler].statStages[i] = oldData.statStages[i]; } - gBattleMons[gActiveBank].status2 = oldData.status2; + gBattleMons[gActiveBattler].status2 = oldData.status2; } SwitchInClearSetData(); - if (gBattleTypeFlags & BATTLE_TYPE_PALACE && gBattleMons[gActiveBank].maxHP / 2 >= gBattleMons[gActiveBank].hp - && gBattleMons[gActiveBank].hp != 0 && !(gBattleMons[gActiveBank].status1 & STATUS1_SLEEP)) + if (gBattleTypeFlags & BATTLE_TYPE_PALACE && gBattleMons[gActiveBattler].maxHP / 2 >= gBattleMons[gActiveBattler].hp + && gBattleMons[gActiveBattler].hp != 0 && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)) { - gBattleStruct->field_92 |= gBitTable[gActiveBank]; + gBattleStruct->field_92 |= gBitTable[gActiveBattler]; } - gBattleScripting.bank = gActiveBank; + gBattleScripting.battler = gActiveBattler; - PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gActiveBank, gBattlePartyID[gActiveBank]); + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gActiveBattler, gBattlePartyID[gActiveBattler]); gBattlescriptCurrInstr += 2; } @@ -5309,20 +5309,20 @@ static void atk4E_switchinanim(void) if (gBattleExecBuffer) return; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); - if (GetBankSide(gActiveBank) == SIDE_OPPONENT + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_x2000000 | BATTLE_TYPE_x4000000 | BATTLE_TYPE_FRONTIER))) - HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBank].species), FLAG_SET_SEEN, gBattleMons[gActiveBank].personality); + HandleSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gActiveBattler].species), FLAG_SET_SEEN, gBattleMons[gActiveBattler].personality); - gAbsentBankFlags &= ~(gBitTable[gActiveBank]); + gAbsentBattlerFlags &= ~(gBitTable[gActiveBattler]); - EmitSwitchInAnim(0, gBattlePartyID[gActiveBank], gBattlescriptCurrInstr[2]); - MarkBufferBankForExecution(gActiveBank); + EmitSwitchInAnim(0, gBattlePartyID[gActiveBattler], gBattlescriptCurrInstr[2]); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 3; @@ -5337,11 +5337,11 @@ static void atk4F_jumpifcantswitch(void) struct Pokemon *party = NULL; s32 r7 = 0; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1] & ~(ATK4F_DONT_CHECK_STATUSES)); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1] & ~(ATK4F_DONT_CHECK_STATUSES)); if (!(gBattlescriptCurrInstr[1] & ATK4F_DONT_CHECK_STATUSES) - && ((gBattleMons[gActiveBank].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) - || (gStatuses3[gActiveBank] & STATUS3_ROOTED))) + && ((gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) + || (gStatuses3[gActiveBattler] & STATUS3_ROOTED))) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); } @@ -5350,13 +5350,13 @@ static void atk4F_jumpifcantswitch(void) #ifndef NONMATCHING asm("":::"r5"); #endif // NONMATCHING - if (GetBankSide(gActiveBank) == SIDE_OPPONENT) + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) party = gEnemyParty; else party = gPlayerParty; val = 0; - if (2 & gActiveBank) + if (2 & gActiveBattler) val = 3; for (compareVar = val + 3; val < compareVar; val++) @@ -5364,7 +5364,7 @@ static void atk4F_jumpifcantswitch(void) if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE && !GetMonData(&party[val], MON_DATA_IS_EGG) && GetMonData(&party[val], MON_DATA_HP) != 0 - && gBattlePartyID[gActiveBank] != val) + && gBattlePartyID[gActiveBattler] != val) break; } @@ -5377,19 +5377,19 @@ static void atk4F_jumpifcantswitch(void) { if (gBattleTypeFlags & BATTLE_TYPE_x800000) { - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { party = gPlayerParty; val = 0; - if (sub_806D82C(GetBankMultiplayerId(gActiveBank)) == TRUE) + if (sub_806D82C(GetBankMultiplayerId(gActiveBattler)) == TRUE) val = 3; } else { party = gEnemyParty; - if (gActiveBank == 1) + if (gActiveBattler == 1) val = 0; else val = 3; @@ -5397,14 +5397,14 @@ static void atk4F_jumpifcantswitch(void) } else { - if (GetBankSide(gActiveBank) == SIDE_OPPONENT) + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) party = gEnemyParty; else party = gPlayerParty; val = 0; - if (sub_806D82C(GetBankMultiplayerId(gActiveBank)) == TRUE) + if (sub_806D82C(GetBankMultiplayerId(gActiveBattler)) == TRUE) val = 3; } @@ -5413,7 +5413,7 @@ static void atk4F_jumpifcantswitch(void) if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE && !GetMonData(&party[val], MON_DATA_IS_EGG) && GetMonData(&party[val], MON_DATA_HP) != 0 - && gBattlePartyID[gActiveBank] != val) + && gBattlePartyID[gActiveBattler] != val) break; } @@ -5422,12 +5422,12 @@ static void atk4F_jumpifcantswitch(void) else gBattlescriptCurrInstr += 6; } - else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && GetBankSide(gActiveBank) == SIDE_OPPONENT) + else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS && GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) { party = gEnemyParty; val = 0; - if (gActiveBank == 3) + if (gActiveBattler == 3) val = 3; for (compareVar = val + 3; val < compareVar; val++) @@ -5435,7 +5435,7 @@ static void atk4F_jumpifcantswitch(void) if (GetMonData(&party[val], MON_DATA_SPECIES) != SPECIES_NONE && !GetMonData(&party[val], MON_DATA_IS_EGG) && GetMonData(&party[val], MON_DATA_HP) != 0 - && gBattlePartyID[gActiveBank] != val) + && gBattlePartyID[gActiveBattler] != val) break; } @@ -5446,12 +5446,12 @@ static void atk4F_jumpifcantswitch(void) } else { - if (GetBankSide(gActiveBank) == SIDE_OPPONENT) + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) { - r7 = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + r7 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - compareVar = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + compareVar = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); else compareVar = r7; @@ -5459,10 +5459,10 @@ static void atk4F_jumpifcantswitch(void) } else { - r7 = GetBankByPosition(B_POSITION_PLAYER_LEFT); + r7 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - compareVar = GetBankByPosition(B_POSITION_PLAYER_RIGHT); + compareVar = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); else compareVar = r7; @@ -5486,12 +5486,12 @@ static void atk4F_jumpifcantswitch(void) static void sub_804CF10(u8 arg0) { - *(gBattleStruct->field_58 + gActiveBank) = gBattlePartyID[gActiveBank]; - *(gBattleStruct->monToSwitchIntoId + gActiveBank) = 6; - gBattleStruct->field_93 &= ~(gBitTable[gActiveBank]); + *(gBattleStruct->field_58 + gActiveBattler) = gBattlePartyID[gActiveBattler]; + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6; + gBattleStruct->field_93 &= ~(gBitTable[gActiveBattler]); - EmitChoosePokemon(0, 1, arg0, 0, gBattleStruct->field_60[gActiveBank]); - MarkBufferBankForExecution(gActiveBank); + EmitChoosePokemon(0, 1, arg0, 0, gBattleStruct->field_60[gActiveBattler]); + MarkBufferBankForExecution(gActiveBattler); } static void atk50_openpartyscreen(void) @@ -5509,27 +5509,27 @@ static void atk50_openpartyscreen(void) { if ((gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_MULTI)) != BATTLE_TYPE_DOUBLE) { - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (gHitMarker & HITMARKER_FAINTED(gActiveBank)) + if (gHitMarker & HITMARKER_FAINTED(gActiveBattler)) { - if (sub_80423F4(gActiveBank, 6, 6)) + if (sub_80423F4(gActiveBattler, 6, 6)) { - gAbsentBankFlags |= gBitTable[gActiveBank]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + gAbsentBattlerFlags |= gBitTable[gActiveBattler]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); EmitLinkStandbyMsg(0, 2, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } - else if (!gSpecialStatuses[gActiveBank].flag40) + else if (!gSpecialStatuses[gActiveBattler].flag40) { sub_804CF10(6); - gSpecialStatuses[gActiveBank].flag40 = 1; + gSpecialStatuses[gActiveBattler].flag40 = 1; } } else { EmitLinkStandbyMsg(0, 2, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } } } @@ -5541,88 +5541,88 @@ static void atk50_openpartyscreen(void) if (gBitTable[0] & hitmarkerFaintBits) { - gActiveBank = 0; + gActiveBattler = 0; if (sub_80423F4(0, 6, 6)) { - gAbsentBankFlags |= gBitTable[gActiveBank]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + gAbsentBattlerFlags |= gBitTable[gActiveBattler]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); EmitCmd42(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } - else if (!gSpecialStatuses[gActiveBank].flag40) + else if (!gSpecialStatuses[gActiveBattler].flag40) { sub_804CF10(gBattleStruct->monToSwitchIntoId[2]); - gSpecialStatuses[gActiveBank].flag40 = 1; + gSpecialStatuses[gActiveBattler].flag40 = 1; } else { EmitLinkStandbyMsg(0, 2, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); flags |= 1; } } if (gBitTable[2] & hitmarkerFaintBits && !(gBitTable[0] & hitmarkerFaintBits)) { - gActiveBank = 2; + gActiveBattler = 2; if (sub_80423F4(2, 6, 6)) { - gAbsentBankFlags |= gBitTable[gActiveBank]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + gAbsentBattlerFlags |= gBitTable[gActiveBattler]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); EmitCmd42(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } - else if (!gSpecialStatuses[gActiveBank].flag40) + else if (!gSpecialStatuses[gActiveBattler].flag40) { sub_804CF10(gBattleStruct->monToSwitchIntoId[0]); - gSpecialStatuses[gActiveBank].flag40 = 1; + gSpecialStatuses[gActiveBattler].flag40 = 1; } else if (!(flags & 1)) { EmitLinkStandbyMsg(0, 2, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } } if (gBitTable[1] & hitmarkerFaintBits) { - gActiveBank = 1; + gActiveBattler = 1; if (sub_80423F4(1, 6, 6)) { - gAbsentBankFlags |= gBitTable[gActiveBank]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + gAbsentBattlerFlags |= gBitTable[gActiveBattler]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); EmitCmd42(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } - else if (!gSpecialStatuses[gActiveBank].flag40) + else if (!gSpecialStatuses[gActiveBattler].flag40) { sub_804CF10(gBattleStruct->monToSwitchIntoId[3]); - gSpecialStatuses[gActiveBank].flag40 = 1; + gSpecialStatuses[gActiveBattler].flag40 = 1; } else { EmitLinkStandbyMsg(0, 2, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); flags |= 2; } } if (gBitTable[3] & hitmarkerFaintBits && !(gBitTable[1] & hitmarkerFaintBits)) { - gActiveBank = 3; + gActiveBattler = 3; if (sub_80423F4(3, 6, 6)) { - gAbsentBankFlags |= gBitTable[gActiveBank]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + gAbsentBattlerFlags |= gBitTable[gActiveBattler]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); EmitCmd42(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } - else if (!gSpecialStatuses[gActiveBank].flag40) + else if (!gSpecialStatuses[gActiveBattler].flag40) { sub_804CF10(gBattleStruct->monToSwitchIntoId[1]); - gSpecialStatuses[gActiveBank].flag40 = 1; + gSpecialStatuses[gActiveBattler].flag40 = 1; } else if (!(flags & 2)) { EmitLinkStandbyMsg(0, 2, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } } @@ -5632,13 +5632,13 @@ static void atk50_openpartyscreen(void) flag40_2 = gSpecialStatuses[2].flag40; if (!flag40_2 && hitmarkerFaintBits != 0) { - if (gAbsentBankFlags & gBitTable[0]) - gActiveBank = 2; + if (gAbsentBattlerFlags & gBitTable[0]) + gActiveBattler = 2; else - gActiveBank = 0; + gActiveBattler = 0; EmitLinkStandbyMsg(0, 2, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } } @@ -5648,13 +5648,13 @@ static void atk50_openpartyscreen(void) flag40_3 = gSpecialStatuses[3].flag40; if (!flag40_3 && hitmarkerFaintBits != 0) { - if (gAbsentBankFlags & gBitTable[1]) - gActiveBank = 3; + if (gAbsentBattlerFlags & gBitTable[1]) + gActiveBattler = 3; else - gActiveBank = 1; + gActiveBattler = 1; EmitLinkStandbyMsg(0, 2, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } } } @@ -5669,34 +5669,34 @@ static void atk50_openpartyscreen(void) hitmarkerFaintBits = gHitMarker >> 0x1C; if (gBitTable[2] & hitmarkerFaintBits && gBitTable[0] & hitmarkerFaintBits) { - gActiveBank = 2; + gActiveBattler = 2; if (sub_80423F4(2, gBattleBufferB[0][1], 6)) { - gAbsentBankFlags |= gBitTable[gActiveBank]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + gAbsentBattlerFlags |= gBitTable[gActiveBattler]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); EmitCmd42(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } - else if (!gSpecialStatuses[gActiveBank].flag40) + else if (!gSpecialStatuses[gActiveBattler].flag40) { sub_804CF10(gBattleStruct->monToSwitchIntoId[0]); - gSpecialStatuses[gActiveBank].flag40 = 1; + gSpecialStatuses[gActiveBattler].flag40 = 1; } } if (gBitTable[3] & hitmarkerFaintBits && hitmarkerFaintBits & gBitTable[1]) { - gActiveBank = 3; + gActiveBattler = 3; if (sub_80423F4(3, gBattleBufferB[1][1], 6)) { - gAbsentBankFlags |= gBitTable[gActiveBank]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + gAbsentBattlerFlags |= gBitTable[gActiveBattler]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); EmitCmd42(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } - else if (!gSpecialStatuses[gActiveBank].flag40) + else if (!gSpecialStatuses[gActiveBattler].flag40) { sub_804CF10(gBattleStruct->monToSwitchIntoId[1]); - gSpecialStatuses[gActiveBank].flag40 = 1; + gSpecialStatuses[gActiveBattler].flag40 = 1; } } gBattlescriptCurrInstr += 6; @@ -5718,12 +5718,12 @@ static void atk50_openpartyscreen(void) { if (gBitTable[gBank1] & hitmarkerFaintBits) break; - if (gBank1 >= gBattleBanksCount) + if (gBank1 >= gBattlersCount) break; gBank1++; } - if (gBank1 == gBattleBanksCount) + if (gBank1 == gBattlersCount) gBattlescriptCurrInstr = jumpPtr; } else @@ -5740,45 +5740,45 @@ static void atk50_openpartyscreen(void) } else if (sub_80423F4(bank, 6, 6)) { - gActiveBank = bank; - gAbsentBankFlags |= gBitTable[gActiveBank]; - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); + gActiveBattler = bank; + gAbsentBattlerFlags |= gBitTable[gActiveBattler]; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); gBattlescriptCurrInstr = jumpPtr; } else { - gActiveBank = bank; - *(gBattleStruct->field_58 + gActiveBank) = gBattlePartyID[gActiveBank]; - *(gBattleStruct->monToSwitchIntoId + gActiveBank) = 6; - gBattleStruct->field_93 &= ~(gBitTable[gActiveBank]); + gActiveBattler = bank; + *(gBattleStruct->field_58 + gActiveBattler) = gBattlePartyID[gActiveBattler]; + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6; + gBattleStruct->field_93 &= ~(gBitTable[gActiveBattler]); - EmitChoosePokemon(0, hitmarkerFaintBits, *(gBattleStruct->monToSwitchIntoId + (gActiveBank ^ 2)), 0, gBattleStruct->field_60[gActiveBank]); - MarkBufferBankForExecution(gActiveBank); + EmitChoosePokemon(0, hitmarkerFaintBits, *(gBattleStruct->monToSwitchIntoId + (gActiveBattler ^ 2)), 0, gBattleStruct->field_60[gActiveBattler]); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 6; - if (GetBankPosition(gActiveBank) == 0 && gBattleResults.playerSwitchesCounter < 0xFF) + if (GetBattlerPosition(gActiveBattler) == 0 && gBattleResults.playerSwitchesCounter < 0xFF) gBattleResults.playerSwitchesCounter++; if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) + for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (gActiveBank != bank) + if (gActiveBattler != bank) { EmitLinkStandbyMsg(0, 2, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } } } else { - gActiveBank = GetBankByPosition(GetBankPosition(bank) ^ BIT_SIDE); - if (gAbsentBankFlags & gBitTable[gActiveBank]) - gActiveBank ^= BIT_MON; + gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(bank) ^ BIT_SIDE); + if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) + gActiveBattler ^= BIT_FLANK; EmitLinkStandbyMsg(0, 2, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } } } @@ -5790,12 +5790,12 @@ static void atk51_switchhandleorder(void) if (gBattleExecBuffer) return; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); switch (gBattlescriptCurrInstr[2]) { case 0: - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gBattleBufferB[i][0] == 0x22) { @@ -5810,40 +5810,40 @@ static void atk51_switchhandleorder(void) break; case 1: if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) - sub_803BDA0(gActiveBank); + sub_803BDA0(gActiveBattler); break; case 2: - if (!(gBattleStruct->field_93 & gBitTable[gActiveBank])) + if (!(gBattleStruct->field_93 & gBitTable[gActiveBattler])) { - RecordedBattle_SetBankAction(gActiveBank, gBattleBufferB[gActiveBank][1]); - gBattleStruct->field_93 |= gBitTable[gActiveBank]; + RecordedBattle_SetBankAction(gActiveBattler, gBattleBufferB[gActiveBattler][1]); + gBattleStruct->field_93 |= gBitTable[gActiveBattler]; } // fall through case 3: - gBattleCommunication[0] = gBattleBufferB[gActiveBank][1]; - *(gBattleStruct->monToSwitchIntoId + gActiveBank) = gBattleBufferB[gActiveBank][1]; + gBattleCommunication[0] = gBattleBufferB[gActiveBattler][1]; + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = gBattleBufferB[gActiveBattler][1]; if (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI) { - *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 0) &= 0xF; - *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBank][2] & 0xF0); - *(gActiveBank * 3 + (u8*)(gBattleStruct->field_60) + 1) = gBattleBufferB[gActiveBank][3]; + *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 0) &= 0xF; + *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBattler][2] & 0xF0); + *(gActiveBattler * 3 + (u8*)(gBattleStruct->field_60) + 1) = gBattleBufferB[gActiveBattler][3]; - *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 0) &= (0xF0); - *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBank][2] & 0xF0) >> 4; - *((gActiveBank ^ BIT_MON) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleBufferB[gActiveBank][3]; + *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 0) &= (0xF0); + *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 0) |= (gBattleBufferB[gActiveBattler][2] & 0xF0) >> 4; + *((gActiveBattler ^ BIT_FLANK) * 3 + (u8*)(gBattleStruct->field_60) + 2) = gBattleBufferB[gActiveBattler][3]; } else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) { - sub_80571DC(gActiveBank, *(gBattleStruct->monToSwitchIntoId + gActiveBank)); + sub_80571DC(gActiveBattler, *(gBattleStruct->monToSwitchIntoId + gActiveBattler)); } else { - sub_803BDA0(gActiveBank); + sub_803BDA0(gActiveBattler); } - PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBankAttacker].species) - PREPARE_MON_NICK_BUFFER(gBattleTextBuff2, gActiveBank, gBattleBufferB[gActiveBank][1]) + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattleAttacker].species) + PREPARE_MON_NICK_BUFFER(gBattleTextBuff2, gActiveBattler, gBattleBufferB[gActiveBattler][1]) break; } @@ -5855,31 +5855,31 @@ static void atk52_switchineffects(void) { s32 i; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - sub_803FA70(gActiveBank); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); + sub_803FA70(gActiveBattler); - gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); - gSpecialStatuses[gActiveBank].flag40 = 0; + gHitMarker &= ~(HITMARKER_FAINTED(gActiveBattler)); + gSpecialStatuses[gActiveBattler].flag40 = 0; - if (!(gSideStatuses[GetBankSide(gActiveBank)] & SIDE_STATUS_SPIKES_DAMAGED) - && (gSideStatuses[GetBankSide(gActiveBank)] & SIDE_STATUS_SPIKES) - && gBattleMons[gActiveBank].type1 != TYPE_FLYING - && gBattleMons[gActiveBank].type2 != TYPE_FLYING - && gBattleMons[gActiveBank].ability != ABILITY_LEVITATE) + if (!(gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES_DAMAGED) + && (gSideStatuses[GetBattlerSide(gActiveBattler)] & SIDE_STATUS_SPIKES) + && gBattleMons[gActiveBattler].type1 != TYPE_FLYING + && gBattleMons[gActiveBattler].type2 != TYPE_FLYING + && gBattleMons[gActiveBattler].ability != ABILITY_LEVITATE) { u8 spikesDmg; - gSideStatuses[GetBankSide(gActiveBank)] |= SIDE_STATUS_SPIKES_DAMAGED; + gSideStatuses[GetBattlerSide(gActiveBattler)] |= SIDE_STATUS_SPIKES_DAMAGED; - gBattleMons[gActiveBank].status2 &= ~(STATUS2_DESTINY_BOND); + gBattleMons[gActiveBattler].status2 &= ~(STATUS2_DESTINY_BOND); gHitMarker &= ~(HITMARKER_DESTINYBOND); - spikesDmg = (5 - gSideTimers[GetBankSide(gActiveBank)].spikesAmount) * 2; - gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / (spikesDmg); + spikesDmg = (5 - gSideTimers[GetBattlerSide(gActiveBattler)].spikesAmount) * 2; + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / (spikesDmg); if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - gBattleScripting.bank = gActiveBank; + gBattleScripting.battler = gActiveBattler; BattleScriptPushCursor(); if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) @@ -5891,25 +5891,25 @@ static void atk52_switchineffects(void) } else { - if (gBattleMons[gActiveBank].ability == ABILITY_TRUANT && !gDisableStructs[gActiveBank].truantUnknownBit) - gDisableStructs[gActiveBank].truantCounter = 1; + if (gBattleMons[gActiveBattler].ability == ABILITY_TRUANT && !gDisableStructs[gActiveBattler].truantUnknownBit) + gDisableStructs[gActiveBattler].truantCounter = 1; - gDisableStructs[gActiveBank].truantUnknownBit = 0; + gDisableStructs[gActiveBattler].truantUnknownBit = 0; - if (AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gActiveBank, 0, 0, 0) == 0 && - ItemBattleEffects(0, gActiveBank, 0) == 0) + if (AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gActiveBattler, 0, 0, 0) == 0 && + ItemBattleEffects(0, gActiveBattler, 0) == 0) { - gSideStatuses[GetBankSide(gActiveBank)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); + gSideStatuses[GetBattlerSide(gActiveBattler)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (gBanksByTurnOrder[i] == gActiveBank) + if (gBattleTurnOrder[i] == gActiveBattler) gActionsByTurnOrder[i] = ACTION_CANCEL_PARTNER; } - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - u16* hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBankSide(i)]; + u16* hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(i)]; *hpOnSwitchout = gBattleMons[i].hp; } @@ -5920,9 +5920,9 @@ static void atk52_switchineffects(void) gBank1++; while (1) { - if (hitmarkerFaintBits & gBitTable[gBank1] && !(gAbsentBankFlags & gBitTable[gBank1])) + if (hitmarkerFaintBits & gBitTable[gBank1] && !(gAbsentBattlerFlags & gBitTable[gBank1])) break; - if (gBank1 >= gBattleBanksCount) + if (gBank1 >= gBattlersCount) break; gBank1++; } @@ -5934,54 +5934,54 @@ static void atk52_switchineffects(void) static void atk53_trainerslidein(void) { - gActiveBank = GetBankByPosition(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattlerAtPosition(gBattlescriptCurrInstr[1]); EmitTrainerSlide(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } static void atk54_playse(void) { - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; EmitPlaySE(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1)); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 3; } static void atk55_fanfare(void) { - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; EmitPlayFanfareOrBGM(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1), FALSE); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 3; } static void atk56_playfaintcry(void) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); EmitFaintingCry(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } static void atk57(void) { - gActiveBank = GetBankByPosition(B_POSITION_PLAYER_LEFT); + gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); EmitCmd55(0, gBattleOutcome); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 1; } static void atk58_returntoball(void) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); EmitReturnMonToBall(0, 1); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } @@ -6005,20 +6005,20 @@ static void atk59_handlelearnnewmove(void) } else { - gActiveBank = GetBankByPosition(B_POSITION_PLAYER_LEFT); + gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); - if (gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId - && !(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) + if (gBattlePartyID[gActiveBattler] == gBattleStruct->expGetterId + && !(gBattleMons[gActiveBattler].status2 & STATUS2_TRANSFORMED)) { - GiveMoveToBattleMon(&gBattleMons[gActiveBank], ret); + GiveMoveToBattleMon(&gBattleMons[gActiveBattler], ret); } if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - gActiveBank = GetBankByPosition(B_POSITION_PLAYER_RIGHT); - if (gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId - && !(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) + gActiveBattler = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); + if (gBattlePartyID[gActiveBattler] == gBattleStruct->expGetterId + && !(gBattleMons[gActiveBattler].status2 & STATUS2_TRANSFORMED)) { - GiveMoveToBattleMon(&gBattleMons[gActiveBank], ret); + GiveMoveToBattleMon(&gBattleMons[gActiveBattler], ret); } } @@ -6028,7 +6028,7 @@ static void atk59_handlelearnnewmove(void) static void atk5A_yesnoboxlearnmove(void) { - gActiveBank = 0; + gActiveBattler = 0; switch (gBattleScripting.learnMoveState) { @@ -6101,7 +6101,7 @@ static void atk5A_yesnoboxlearnmove(void) u16 moveId = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_MOVE1 + movePosition); if (IsHMMove2(moveId)) { - PrepareStringBattle(STRINGID_HMMOVESCANTBEFORGOTTEN, gActiveBank); + PrepareStringBattle(STRINGID_HMMOVESCANTBEFORGOTTEN, gActiveBattler); gBattleScripting.learnMoveState = 6; } else @@ -6194,16 +6194,16 @@ static void atk5B_yesnoboxstoplearningmove(void) static void atk5C_hitanimation(void) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { gBattlescriptCurrInstr += 2; } - else if (!(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE) || !(gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE) || gDisableStructs[gActiveBank].substituteHP == 0) + else if (!(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE) || !(gBattleMons[gActiveBattler].status2 & STATUS2_SUBSTITUTE) || gDisableStructs[gActiveBattler].substituteHP == 0) { EmitHitAnimation(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } else @@ -6284,24 +6284,24 @@ static void atk5D_getmoneyreward(void) static void atk5E(void) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); switch (gBattleCommunication[0]) { case 0: EmitGetMonData(0, REQUEST_ALL_BATTLE, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattleCommunication[0]++; break; case 1: if (gBattleExecBuffer == 0) { s32 i; - struct BattlePokemon* bufferPoke = (struct BattlePokemon*) &gBattleBufferB[gActiveBank][4]; + struct BattlePokemon* bufferPoke = (struct BattlePokemon*) &gBattleBufferB[gActiveBattler][4]; for (i = 0; i < 4; i++) { - gBattleMons[gActiveBank].moves[i] = bufferPoke->moves[i]; - gBattleMons[gActiveBank].pp[i] = bufferPoke->pp[i]; + gBattleMons[gActiveBattler].moves[i] = bufferPoke->moves[i]; + gBattleMons[gActiveBattler].pp[i] = bufferPoke->pp[i]; } gBattlescriptCurrInstr += 2; } @@ -6311,9 +6311,9 @@ static void atk5E(void) static void atk5F(void) { - gActiveBank = gBankAttacker; - gBankAttacker = gBankDefender; - gBankDefender = gActiveBank; + gActiveBattler = gBattleAttacker; + gBattleAttacker = gBattleDefender; + gBattleDefender = gActiveBattler; if (gHitMarker & HITMARKER_PURSUIT_TRAP) gHitMarker &= ~(HITMARKER_PURSUIT_TRAP); @@ -6325,7 +6325,7 @@ static void atk5F(void) static void atk60_incrementgamestat(void) { - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) IncrementGameStat(gBattlescriptCurrInstr[1]); gBattlescriptCurrInstr += 2; @@ -6340,9 +6340,9 @@ static void atk61_drawpartystatussummary(void) if (gBattleExecBuffer) return; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -6363,16 +6363,16 @@ static void atk61_drawpartystatussummary(void) } EmitDrawPartyStatusSummary(0, hpStatuses, 1); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } static void atk62(void) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); EmitCmd49(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } @@ -6391,13 +6391,13 @@ static void atk64_statusanimation(void) { if (gBattleExecBuffer == 0) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - if (!(gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) - && gDisableStructs[gActiveBank].substituteHP == 0 + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); + if (!(gStatuses3[gActiveBattler] & STATUS3_SEMI_INVULNERABLE) + && gDisableStructs[gActiveBattler].substituteHP == 0 && !(gHitMarker & HITMARKER_NO_ANIMATIONS)) { - EmitStatusAnimation(0, FALSE, gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); + EmitStatusAnimation(0, FALSE, gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); } gBattlescriptCurrInstr += 2; } @@ -6409,14 +6409,14 @@ static void atk65_status2animation(void) if (gBattleExecBuffer == 0) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); wantedToAnimate = BSScriptRead32(gBattlescriptCurrInstr + 2); - if (!(gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) - && gDisableStructs[gActiveBank].substituteHP == 0 + if (!(gStatuses3[gActiveBattler] & STATUS3_SEMI_INVULNERABLE) + && gDisableStructs[gActiveBattler].substituteHP == 0 && !(gHitMarker & HITMARKER_NO_ANIMATIONS)) { - EmitStatusAnimation(0, TRUE, gBattleMons[gActiveBank].status2 & wantedToAnimate); - MarkBufferBankForExecution(gActiveBank); + EmitStatusAnimation(0, TRUE, gBattleMons[gActiveBattler].status2 & wantedToAnimate); + MarkBufferBankForExecution(gActiveBattler); } gBattlescriptCurrInstr += 6; } @@ -6428,14 +6428,14 @@ static void atk66_chosenstatusanimation(void) if (gBattleExecBuffer == 0) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); wantedStatus = BSScriptRead32(gBattlescriptCurrInstr + 3); - if (!(gStatuses3[gActiveBank] & STATUS3_SEMI_INVULNERABLE) - && gDisableStructs[gActiveBank].substituteHP == 0 + if (!(gStatuses3[gActiveBattler] & STATUS3_SEMI_INVULNERABLE) + && gDisableStructs[gActiveBattler].substituteHP == 0 && !(gHitMarker & HITMARKER_NO_ANIMATIONS)) { EmitStatusAnimation(0, gBattlescriptCurrInstr[2], wantedStatus); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } gBattlescriptCurrInstr += 7; } @@ -6488,7 +6488,7 @@ static void atk68_cancelallactions(void) { s32 i; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) gActionsByTurnOrder[i] = ACTION_CANCEL_PARTNER; gBattlescriptCurrInstr++; @@ -6498,42 +6498,42 @@ static void atk69_adjustsetdamage(void) // The same as 0x7, except there's no ra { u8 holdEffect, quality; - if (gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBattleDefender].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBankDefender].holdEffect, quality = gEnigmaBerries[gBankDefender].holdEffectParam; + holdEffect = gEnigmaBerries[gBattleDefender].holdEffect, quality = gEnigmaBerries[gBattleDefender].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankDefender].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBankDefender].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattleDefender].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBattleDefender].item); } - gStringBank = gBankDefender; + gStringBank = gBattleDefender; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < quality) { - RecordItemEffectBattle(gBankDefender, holdEffect); - gSpecialStatuses[gBankDefender].focusBanded = 1; + RecordItemEffectBattle(gBattleDefender, holdEffect); + gSpecialStatuses[gBattleDefender].focusBanded = 1; } - if (gBattleMons[gBankDefender].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBattleDefender].status2 & STATUS2_SUBSTITUTE) goto END; - if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBankDefender].endured - && !gSpecialStatuses[gBankDefender].focusBanded) + if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBattleDefender].endured + && !gSpecialStatuses[gBattleDefender].focusBanded) goto END; - if (gBattleMons[gBankDefender].hp > gBattleMoveDamage) + if (gBattleMons[gBattleDefender].hp > gBattleMoveDamage) goto END; - gBattleMoveDamage = gBattleMons[gBankDefender].hp - 1; + gBattleMoveDamage = gBattleMons[gBattleDefender].hp - 1; - if (gProtectStructs[gBankDefender].endured) + if (gProtectStructs[gBattleDefender].endured) { gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBankDefender].focusBanded) + else if (gSpecialStatuses[gBattleDefender].focusBanded) { gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; - gLastUsedItem = gBattleMons[gBankDefender].item; + gLastUsedItem = gBattleMons[gBattleDefender].item; } END: @@ -6544,21 +6544,21 @@ static void atk6A_removeitem(void) { u16* usedHeldItem; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); - usedHeldItem = &gBattleStruct->usedHeldItems[gActiveBank]; - *usedHeldItem = gBattleMons[gActiveBank].item; - gBattleMons[gActiveBank].item = 0; + usedHeldItem = &gBattleStruct->usedHeldItems[gActiveBattler]; + *usedHeldItem = gBattleMons[gActiveBattler].item; + gBattleMons[gActiveBattler].item = 0; - EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBank].item); - MarkBufferBankForExecution(gActiveBank); + EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBattler].item); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } static void atk6B_atknameinbuff1(void) { - PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBankAttacker, gBattlePartyID[gBankAttacker]) + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattleAttacker, gBattlePartyID[gBattleAttacker]) gBattlescriptCurrInstr++; } @@ -6845,23 +6845,23 @@ static void atk6D_resetsentmonsvalue(void) static void atk6E_setatktoplayer0(void) { - gBankAttacker = GetBankByPosition(B_POSITION_PLAYER_LEFT); + gBattleAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); gBattlescriptCurrInstr++; } static void atk6F_makevisible(void) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); EmitSpriteInvisibility(0, FALSE); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } static void atk70_recordlastability(void) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - RecordAbilityBattle(gActiveBank, gLastUsedAbility); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); + RecordAbilityBattle(gActiveBattler, gLastUsedAbility); gBattlescriptCurrInstr += 1; // UB: Should be + 2, one byte for command and one byte for bank argument. } @@ -6891,8 +6891,8 @@ static void atk73_hpthresholds(void) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - opposingBank = gActiveBank ^ BIT_SIDE; + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); + opposingBank = gActiveBattler ^ BIT_SIDE; result = gBattleMons[opposingBank].hp * 100 / gBattleMons[opposingBank].maxHP; if (result == 0) @@ -6919,9 +6919,9 @@ static void atk74_hpthresholds2(void) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - opposingBank = gActiveBank ^ BIT_SIDE; - hpSwitchout = *(gBattleStruct->hpOnSwitchout + GetBankSide(opposingBank)); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); + opposingBank = gActiveBattler ^ BIT_SIDE; + hpSwitchout = *(gBattleStruct->hpOnSwitchout + GetBattlerSide(opposingBank)); result = (hpSwitchout - gBattleMons[opposingBank].hp) * 100 / hpSwitchout; if (gBattleMons[opposingBank].hp >= hpSwitchout) @@ -6939,8 +6939,8 @@ static void atk74_hpthresholds2(void) static void atk75_useitemonopponent(void) { - gBankInMenu = gBankAttacker; - ExecuteTableBasedItemEffect(&gEnemyParty[gBattlePartyID[gBankAttacker]], gLastUsedItem, gBattlePartyID[gBankAttacker], 0, 1); + gBankInMenu = gBattleAttacker; + ExecuteTableBasedItemEffect(&gEnemyParty[gBattlePartyID[gBattleAttacker]], gLastUsedItem, gBattlePartyID[gBattleAttacker], 0, 1); gBattlescriptCurrInstr += 1; } @@ -6950,36 +6950,36 @@ static void atk76_various(void) u8 side; s32 i; - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); switch (gBattlescriptCurrInstr[2]) { case VARIOUS_CANCEL_MULTI_TURN_MOVES: - CancelMultiTurnMoves(gActiveBank); + CancelMultiTurnMoves(gActiveBattler); break; case VARIOUS_SET_MAGIC_COAT_TARGET: - gBankAttacker = gBankDefender; - side = GetBankSide(gBankAttacker) ^ BIT_SIDE; + gBattleAttacker = gBattleDefender; + side = GetBattlerSide(gBattleAttacker) ^ BIT_SIDE; if (gSideTimers[side].followmeTimer != 0 && gBattleMons[gSideTimers[side].followmeTarget].hp != 0) - gBankDefender = gSideTimers[side].followmeTarget; + gBattleDefender = gSideTimers[side].followmeTarget; else - gBankDefender = gActiveBank; + gBattleDefender = gActiveBattler; break; case VARIOUS_IS_RUNNING_IMPOSSIBLE: gBattleCommunication[0] = IsRunningFromBattleImpossible(); break; case VARIOUS_GET_MOVE_TARGET: - gBankDefender = GetMoveTarget(gCurrentMove, 0); + gBattleDefender = GetMoveTarget(gCurrentMove, 0); break; case 4: - if (gHitMarker & HITMARKER_FAINTED(gActiveBank)) + if (gHitMarker & HITMARKER_FAINTED(gActiveBattler)) gBattleCommunication[0] = 1; else gBattleCommunication[0] = 0; break; case VARIOUS_RESET_INTIMIDATE_TRACE_BITS: - gSpecialStatuses[gActiveBank].intimidatedPoke = 0; - gSpecialStatuses[gActiveBank].traced = 0; + gSpecialStatuses[gActiveBattler].intimidatedPoke = 0; + gSpecialStatuses[gActiveBattler].traced = 0; break; case VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP: if (gBattlePartyID[0] == gBattleStruct->expGetterId || gBattlePartyID[2] == gBattleStruct->expGetterId) @@ -6987,15 +6987,15 @@ static void atk76_various(void) u16 *choicedMove; if (gBattlePartyID[0] == gBattleStruct->expGetterId) - gActiveBank = 0; + gActiveBattler = 0; else - gActiveBank = 2; + gActiveBattler = 2; - choicedMove = &gBattleStruct->choicedMove[gActiveBank]; + choicedMove = &gBattleStruct->choicedMove[gActiveBattler]; for (i = 0; i < 4; i++) { - if (gBattleMons[gActiveBank].moves[i] == *choicedMove) + if (gBattleMons[gActiveBattler].moves[i] == *choicedMove) break; } if (i == 4) @@ -7013,15 +7013,15 @@ static void atk76_various(void) break; case 8: gBattleCommunication[0] = 0; - gBattleScripting.bank = gActiveBank = gBattleCommunication[1]; - if (!(gBattleStruct->field_92 & gBitTable[gActiveBank]) - && gBattleMons[gActiveBank].maxHP / 2 >= gBattleMons[gActiveBank].hp - && gBattleMons[gActiveBank].hp != 0 - && !(gBattleMons[gActiveBank].status1 & STATUS1_SLEEP)) + gBattleScripting.battler = gActiveBattler = gBattleCommunication[1]; + if (!(gBattleStruct->field_92 & gBitTable[gActiveBattler]) + && gBattleMons[gActiveBattler].maxHP / 2 >= gBattleMons[gActiveBattler].hp + && gBattleMons[gActiveBattler].hp != 0 + && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP)) { - gBattleStruct->field_92 |= gBitTable[gActiveBank]; + gBattleStruct->field_92 |= gBitTable[gActiveBattler]; gBattleCommunication[0] = 1; - gBattleCommunication[MULTISTRING_CHOOSER] = sUnknown_0831C4F8[GetNatureFromPersonality(gBattleMons[gActiveBank].personality)]; + gBattleCommunication[MULTISTRING_CHOOSER] = sUnknown_0831C4F8[GetNatureFromPersonality(gBattleMons[gActiveBattler].personality)]; } break; case 9: @@ -7057,7 +7057,7 @@ static void atk76_various(void) break; case VARIOUS_EMIT_YESNOBOX: EmitUnknownYesNoBox(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); break; case 14: sub_81A5BF8(); @@ -7078,21 +7078,21 @@ static void atk76_various(void) return; break; case VARIOUS_RETURN_OPPONENT_MON1: - gActiveBank = 1; - if (gBattleMons[gActiveBank].hp != 0) + gActiveBattler = 1; + if (gBattleMons[gActiveBattler].hp != 0) { EmitReturnMonToBall(0, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } break; case VARIOUS_RETURN_OPPONENT_MON2: - if (gBattleBanksCount > 3) + if (gBattlersCount > 3) { - gActiveBank = 3; - if (gBattleMons[gActiveBank].hp != 0) + gActiveBattler = 3; + if (gBattleMons[gActiveBattler].hp != 0) { EmitReturnMonToBall(0, 0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } } break; @@ -7103,21 +7103,21 @@ static void atk76_various(void) m4aMPlayVolumeControl(&gMPlayInfo_BGM, 0xFFFF, 0x100); break; case 23: - gBattleStruct->field_2A2 |= gBitTable[gActiveBank]; + gBattleStruct->field_2A2 |= gBitTable[gActiveBattler]; break; case 24: - if (sub_805725C(gActiveBank)) + if (sub_805725C(gActiveBattler)) return; break; case VARIOUS_SET_TELEPORT_OUTCOME: - if (GetBankSide(gActiveBank) == SIDE_PLAYER) + if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; else gBattleOutcome = B_OUTCOME_POKE_TELEPORTED; break; case VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC: EmitPlayFanfareOrBGM(0, MUS_KACHI1, TRUE); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); break; } @@ -7127,31 +7127,31 @@ static void atk76_various(void) static void atk77_setprotectlike(void) // protect and endure { bool8 notLastTurn = TRUE; - u16 lastMove = gLastResultingMoves[gBankAttacker]; + u16 lastMove = gLastResultingMoves[gBattleAttacker]; if (lastMove != MOVE_PROTECT && lastMove != MOVE_DETECT && lastMove != MOVE_ENDURE) - gDisableStructs[gBankAttacker].protectUses = 0; + gDisableStructs[gBattleAttacker].protectUses = 0; - if (gCurrentTurnActionNumber == (gBattleBanksCount - 1)) + if (gCurrentTurnActionNumber == (gBattlersCount - 1)) notLastTurn = FALSE; - if (sProtectSuccessRates[gDisableStructs[gBankAttacker].protectUses] >= Random() && notLastTurn) + if (sProtectSuccessRates[gDisableStructs[gBattleAttacker].protectUses] >= Random() && notLastTurn) { if (gBattleMoves[gCurrentMove].effect == EFFECT_PROTECT) { - gProtectStructs[gBankAttacker].protected = 1; + gProtectStructs[gBattleAttacker].protected = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } if (gBattleMoves[gCurrentMove].effect == EFFECT_ENDURE) { - gProtectStructs[gBankAttacker].endured = 1; + gProtectStructs[gBattleAttacker].endured = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } - gDisableStructs[gBankAttacker].protectUses++; + gDisableStructs[gBattleAttacker].protectUses++; } else { - gDisableStructs[gBankAttacker].protectUses = 0; + gDisableStructs[gBattleAttacker].protectUses = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 2; gMoveResultFlags |= MOVE_RESULT_MISSED; } @@ -7164,32 +7164,32 @@ static void atk78_faintifabilitynotdamp(void) if (gBattleExecBuffer) return; - for (gBankDefender = 0; gBankDefender < gBattleBanksCount; gBankDefender++) + for (gBattleDefender = 0; gBattleDefender < gBattlersCount; gBattleDefender++) { - if (gBattleMons[gBankDefender].ability == ABILITY_DAMP) + if (gBattleMons[gBattleDefender].ability == ABILITY_DAMP) break; } - if (gBankDefender == gBattleBanksCount) + if (gBattleDefender == gBattlersCount) { - gActiveBank = gBankAttacker; - gBattleMoveDamage = gBattleMons[gActiveBank].hp; + gActiveBattler = gBattleAttacker; + gBattleMoveDamage = gBattleMons[gActiveBattler].hp; EmitHealthBarUpdate(0, INSTANT_HP_BAR_DROP); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr++; - for (gBankDefender = 0; gBankDefender < gBattleBanksCount; gBankDefender++) + for (gBattleDefender = 0; gBattleDefender < gBattlersCount; gBattleDefender++) { - if (gBankDefender == gBankAttacker) + if (gBattleDefender == gBattleAttacker) continue; - if (!(gAbsentBankFlags & gBitTable[gBankDefender])) + if (!(gAbsentBattlerFlags & gBitTable[gBattleDefender])) break; } } else { gLastUsedAbility = ABILITY_DAMP; - RecordAbilityBattle(gBankDefender, gBattleMons[gBankDefender].ability); + RecordAbilityBattle(gBattleDefender, gBattleMons[gBattleDefender].ability); gBattlescriptCurrInstr = BattleScript_DampStopsExplosion; } } @@ -7199,10 +7199,10 @@ static void atk79_setatkhptozero(void) if (gBattleExecBuffer) return; - gActiveBank = gBankAttacker; - gBattleMons[gActiveBank].hp = 0; - EmitSetMonData(0, REQUEST_HP_BATTLE, 0, 2, &gBattleMons[gActiveBank].hp); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = gBattleAttacker; + gBattleMons[gActiveBattler].hp = 0; + EmitSetMonData(0, REQUEST_HP_BATTLE, 0, 2, &gBattleMons[gActiveBattler].hp); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr++; } @@ -7213,15 +7213,15 @@ static void atk7A_jumpifnexttargetvalid(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - for (gBankDefender++; ; gBankDefender++) + for (gBattleDefender++; ; gBattleDefender++) { - if (gBankDefender == gBankAttacker) + if (gBattleDefender == gBattleAttacker) continue; - if (!(gAbsentBankFlags & gBitTable[gBankDefender])) + if (!(gAbsentBattlerFlags & gBitTable[gBattleDefender])) break; } - if (gBankDefender >= gBattleBanksCount) + if (gBattleDefender >= gBattlersCount) gBattlescriptCurrInstr += 5; else gBattlescriptCurrInstr = jumpPtr; @@ -7237,14 +7237,14 @@ static void atk7B_tryhealhalfhealth(void) const u8* failPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); if (gBattlescriptCurrInstr[5] == BS_GET_ATTACKER) - gBankDefender = gBankAttacker; + gBattleDefender = gBattleAttacker; - gBattleMoveDamage = gBattleMons[gBankDefender].maxHP / 2; + gBattleMoveDamage = gBattleMons[gBattleDefender].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - if (gBattleMons[gBankDefender].hp == gBattleMons[gBankDefender].maxHP) + if (gBattleMons[gBattleDefender].hp == gBattleMons[gBattleDefender].maxHP) gBattlescriptCurrInstr = failPtr; else gBattlescriptCurrInstr += 6; @@ -7260,12 +7260,12 @@ static void atk7C_trymirrormove(void) for (i = 0; i < 3; i++) movesArray[i] = 0; - for (validMovesCount = 0, i = 0; i < gBattleBanksCount; i++) + for (validMovesCount = 0, i = 0; i < gBattlersCount; i++) { - if (i != gBankAttacker) + if (i != gBattleAttacker) { - move = *(i * 2 + gBankAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) - | (*(i * 2 + gBankAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) << 8); + move = *(i * 2 + gBattleAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) + | (*(i * 2 + gBattleAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) << 8); if (move != 0 && move != 0xFFFF) { @@ -7275,14 +7275,14 @@ static void atk7C_trymirrormove(void) } } - move = *(gBattleStruct->mirrorMoves + gBankAttacker * 2 + 0) - | (*(gBattleStruct->mirrorMoves + gBankAttacker * 2 + 1) << 8); + move = *(gBattleStruct->mirrorMoves + gBattleAttacker * 2 + 0) + | (*(gBattleStruct->mirrorMoves + gBattleAttacker * 2 + 1) << 8); if (move != 0 && move != 0xFFFF) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = move; - gBankDefender = GetMoveTarget(gCurrentMove, 0); + gBattleDefender = GetMoveTarget(gCurrentMove, 0); gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; } else if (validMovesCount) @@ -7290,12 +7290,12 @@ static void atk7C_trymirrormove(void) gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); i = Random() % validMovesCount; gCurrentMove = movesArray[i]; - gBankDefender = GetMoveTarget(gCurrentMove, 0); + gBattleDefender = GetMoveTarget(gCurrentMove, 0); gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; } else { - gSpecialStatuses[gBankAttacker].flag20 = 1; + gSpecialStatuses[gBattleAttacker].flag20 = 1; gBattlescriptCurrInstr++; } } @@ -7318,16 +7318,16 @@ static void atk7D_setrain(void) static void atk7E_setreflect(void) { - if (gSideStatuses[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_REFLECT) + if (gSideStatuses[GET_BATTLER_SIDE(gBattleAttacker)] & SIDE_STATUS_REFLECT) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } else { - gSideStatuses[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_REFLECT; - gSideTimers[GET_BANK_SIDE(gBankAttacker)].reflectTimer = 5; - gSideTimers[GET_BANK_SIDE(gBankAttacker)].reflectBank = gBankAttacker; + gSideStatuses[GET_BATTLER_SIDE(gBattleAttacker)] |= SIDE_STATUS_REFLECT; + gSideTimers[GET_BATTLER_SIDE(gBattleAttacker)].reflectTimer = 5; + gSideTimers[GET_BATTLER_SIDE(gBattleAttacker)].reflectBank = gBattleAttacker; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && CountAliveMonsInBattle(BATTLE_ALIVE_ATK_SIDE) == 2) gBattleCommunication[MULTISTRING_CHOOSER] = 2; @@ -7339,20 +7339,20 @@ static void atk7E_setreflect(void) static void atk7F_setseeded(void) { - if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT || gStatuses3[gBankDefender] & STATUS3_LEECHSEED) + if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT || gStatuses3[gBattleDefender] & STATUS3_LEECHSEED) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } - else if (gBattleMons[gBankDefender].type1 == TYPE_GRASS || gBattleMons[gBankDefender].type2 == TYPE_GRASS) + else if (gBattleMons[gBattleDefender].type1 == TYPE_GRASS || gBattleMons[gBattleDefender].type2 == TYPE_GRASS) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 2; } else { - gStatuses3[gBankDefender] |= gBankAttacker; - gStatuses3[gBankDefender] |= STATUS3_LEECHSEED; + gStatuses3[gBattleDefender] |= gBattleAttacker; + gStatuses3[gBattleDefender] |= STATUS3_LEECHSEED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } @@ -7370,8 +7370,8 @@ static void atk80_manipulatedamage(void) gBattleMoveDamage /= 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - if ((gBattleMons[gBankDefender].maxHP / 2) < gBattleMoveDamage) - gBattleMoveDamage = gBattleMons[gBankDefender].maxHP / 2; + if ((gBattleMons[gBattleDefender].maxHP / 2) < gBattleMoveDamage) + gBattleMoveDamage = gBattleMons[gBattleDefender].maxHP / 2; break; case ATK80_DMG_DOUBLED: gBattleMoveDamage *= 2; @@ -7384,23 +7384,23 @@ static void atk80_manipulatedamage(void) static void atk81_trysetrest(void) { const u8 *failJump = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - gActiveBank = gBankDefender = gBankAttacker; - gBattleMoveDamage = gBattleMons[gBankDefender].maxHP * (-1); + gActiveBattler = gBattleDefender = gBattleAttacker; + gBattleMoveDamage = gBattleMons[gBattleDefender].maxHP * (-1); - if (gBattleMons[gBankDefender].hp == gBattleMons[gBankDefender].maxHP) + if (gBattleMons[gBattleDefender].hp == gBattleMons[gBattleDefender].maxHP) { gBattlescriptCurrInstr = failJump; } else { - if (gBattleMons[gBankDefender].status1 & ((u8)(~STATUS1_SLEEP))) + if (gBattleMons[gBattleDefender].status1 & ((u8)(~STATUS1_SLEEP))) gBattleCommunication[MULTISTRING_CHOOSER] = 1; else gBattleCommunication[MULTISTRING_CHOOSER] = 0; - gBattleMons[gBankDefender].status1 = 3; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); + gBattleMons[gBattleDefender].status1 = 3; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 5; } } @@ -7409,7 +7409,7 @@ static void atk82_jumpifnotfirstturn(void) { const u8* failJump = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - if (gDisableStructs[gBankAttacker].isFirstTurn) + if (gDisableStructs[gBattleAttacker].isFirstTurn) gBattlescriptCurrInstr += 5; else gBattlescriptCurrInstr = failJump; @@ -7424,16 +7424,16 @@ bool8 UproarWakeUpCheck(u8 bank) { s32 i; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (!(gBattleMons[i].status2 & STATUS2_UPROAR) || gBattleMons[bank].ability == ABILITY_SOUNDPROOF) continue; - gBattleScripting.bank = i; + gBattleScripting.battler = i; - if (gBankDefender == 0xFF) - gBankDefender = i; - else if (gBankDefender == i) + if (gBattleDefender == 0xFF) + gBattleDefender = i; + else if (gBattleDefender == i) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -7441,7 +7441,7 @@ bool8 UproarWakeUpCheck(u8 bank) break; } - if (i == gBattleBanksCount) + if (i == gBattlersCount) return FALSE; else return TRUE; @@ -7451,17 +7451,17 @@ static void atk84_jumpifcantmakeasleep(void) { const u8 *jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - if (UproarWakeUpCheck(gBankDefender)) + if (UproarWakeUpCheck(gBattleDefender)) { gBattlescriptCurrInstr = jumpPtr; } - else if (gBattleMons[gBankDefender].ability == ABILITY_INSOMNIA - || gBattleMons[gBankDefender].ability == ABILITY_VITAL_SPIRIT) + else if (gBattleMons[gBattleDefender].ability == ABILITY_INSOMNIA + || gBattleMons[gBattleDefender].ability == ABILITY_VITAL_SPIRIT) { - gLastUsedAbility = gBattleMons[gBankDefender].ability; + gLastUsedAbility = gBattleMons[gBattleDefender].ability; gBattleCommunication[MULTISTRING_CHOOSER] = 2; gBattlescriptCurrInstr = jumpPtr; - RecordAbilityBattle(gBankDefender, gLastUsedAbility); + RecordAbilityBattle(gBattleDefender, gLastUsedAbility); } else { @@ -7471,16 +7471,16 @@ static void atk84_jumpifcantmakeasleep(void) static void atk85_stockpile(void) { - if (gDisableStructs[gBankAttacker].stockpileCounter == 3) + if (gDisableStructs[gBattleAttacker].stockpileCounter == 3) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else { - gDisableStructs[gBankAttacker].stockpileCounter++; + gDisableStructs[gBattleAttacker].stockpileCounter++; - PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gBankAttacker].stockpileCounter) + PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gBattleAttacker].stockpileCounter) gBattleCommunication[MULTISTRING_CHOOSER] = 0; } @@ -7490,7 +7490,7 @@ static void atk85_stockpile(void) static void atk86_stockpiletobasedamage(void) { const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - if (gDisableStructs[gBankAttacker].stockpileCounter == 0) + if (gDisableStructs[gBattleAttacker].stockpileCounter == 0) { gBattlescriptCurrInstr = jumpPtr; } @@ -7498,17 +7498,17 @@ static void atk86_stockpiletobasedamage(void) { if (gBattleCommunication[6] != 1) { - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankDefender], gCurrentMove, - gSideStatuses[GET_BANK_SIDE(gBankDefender)], 0, - 0, gBankAttacker, gBankDefender) - * gDisableStructs[gBankAttacker].stockpileCounter; - gBattleScripting.animTurn = gDisableStructs[gBankAttacker].stockpileCounter; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattleAttacker], &gBattleMons[gBattleDefender], gCurrentMove, + gSideStatuses[GET_BATTLER_SIDE(gBattleDefender)], 0, + 0, gBattleAttacker, gBattleDefender) + * gDisableStructs[gBattleAttacker].stockpileCounter; + gBattleScripting.animTurn = gDisableStructs[gBattleAttacker].stockpileCounter; - if (gProtectStructs[gBankAttacker].helpingHand) + if (gProtectStructs[gBattleAttacker].helpingHand) gBattleMoveDamage = gBattleMoveDamage * 15 / 10; } - gDisableStructs[gBankAttacker].stockpileCounter = 0; + gDisableStructs[gBattleAttacker].stockpileCounter = 0; gBattlescriptCurrInstr += 5; } } @@ -7517,30 +7517,30 @@ static void atk87_stockpiletohpheal(void) { const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - if (gDisableStructs[gBankAttacker].stockpileCounter == 0) + if (gDisableStructs[gBattleAttacker].stockpileCounter == 0) { gBattlescriptCurrInstr = jumpPtr; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } - else if (gBattleMons[gBankAttacker].maxHP == gBattleMons[gBankAttacker].hp) + else if (gBattleMons[gBattleAttacker].maxHP == gBattleMons[gBattleAttacker].hp) { - gDisableStructs[gBankAttacker].stockpileCounter = 0; + gDisableStructs[gBattleAttacker].stockpileCounter = 0; gBattlescriptCurrInstr = jumpPtr; - gBankDefender = gBankAttacker; + gBattleDefender = gBattleAttacker; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else { - gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / (1 << (3 - gDisableStructs[gBankAttacker].stockpileCounter)); + gBattleMoveDamage = gBattleMons[gBattleAttacker].maxHP / (1 << (3 - gDisableStructs[gBattleAttacker].stockpileCounter)); if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - gBattleScripting.animTurn = gDisableStructs[gBankAttacker].stockpileCounter; - gDisableStructs[gBankAttacker].stockpileCounter = 0; + gBattleScripting.animTurn = gDisableStructs[gBattleAttacker].stockpileCounter; + gDisableStructs[gBattleAttacker].stockpileCounter = 0; gBattlescriptCurrInstr += 5; - gBankDefender = gBankAttacker; + gBattleDefender = gBattleAttacker; } } @@ -7560,9 +7560,9 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) u32 index; if (flags & MOVE_EFFECT_AFFECTS_USER) - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; else - gActiveBank = gBankDefender; + gActiveBattler = gBattleDefender; flags &= ~(MOVE_EFFECT_AFFECTS_USER); @@ -7578,21 +7578,21 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) if ((statValue << 0x18) < 0) // stat decrease { - if (gSideTimers[GET_BANK_SIDE(gActiveBank)].mistTimer + if (gSideTimers[GET_BATTLER_SIDE(gActiveBattler)].mistTimer && !certain && gCurrentMove != MOVE_CURSE) { if (flags == STAT_CHANGE_BS_PTR) { - if (gSpecialStatuses[gActiveBank].statLowered) + if (gSpecialStatuses[gActiveBattler].statLowered) { gBattlescriptCurrInstr = BS_ptr; } else { BattleScriptPush(BS_ptr); - gBattleScripting.bank = gActiveBank; + gBattleScripting.battler = gActiveBattler; gBattlescriptCurrInstr = BattleScript_MistProtected; - gSpecialStatuses[gActiveBank].statLowered = 1; + gSpecialStatuses[gActiveBattler].statLowered = 1; } } return STAT_CHANGE_DIDNT_WORK; @@ -7603,55 +7603,55 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) gBattlescriptCurrInstr = BattleScript_ButItFailed; return STAT_CHANGE_DIDNT_WORK; } - else if ((gBattleMons[gActiveBank].ability == ABILITY_CLEAR_BODY - || gBattleMons[gActiveBank].ability == ABILITY_WHITE_SMOKE) + else if ((gBattleMons[gActiveBattler].ability == ABILITY_CLEAR_BODY + || gBattleMons[gActiveBattler].ability == ABILITY_WHITE_SMOKE) && !certain && gCurrentMove != MOVE_CURSE) { if (flags == STAT_CHANGE_BS_PTR) { - if (gSpecialStatuses[gActiveBank].statLowered) + if (gSpecialStatuses[gActiveBattler].statLowered) { gBattlescriptCurrInstr = BS_ptr; } else { BattleScriptPush(BS_ptr); - gBattleScripting.bank = gActiveBank; + gBattleScripting.battler = gActiveBattler; gBattlescriptCurrInstr = BattleScript_AbilityNoStatLoss; - gLastUsedAbility = gBattleMons[gActiveBank].ability; - RecordAbilityBattle(gActiveBank, gLastUsedAbility); - gSpecialStatuses[gActiveBank].statLowered = 1; + gLastUsedAbility = gBattleMons[gActiveBattler].ability; + RecordAbilityBattle(gActiveBattler, gLastUsedAbility); + gSpecialStatuses[gActiveBattler].statLowered = 1; } } return STAT_CHANGE_DIDNT_WORK; } - else if (gBattleMons[gActiveBank].ability == ABILITY_KEEN_EYE + else if (gBattleMons[gActiveBattler].ability == ABILITY_KEEN_EYE && !certain && statId == STAT_STAGE_ACC) { if (flags == STAT_CHANGE_BS_PTR) { BattleScriptPush(BS_ptr); - gBattleScripting.bank = gActiveBank; + gBattleScripting.battler = gActiveBattler; gBattlescriptCurrInstr = BattleScript_AbilityNoSpecificStatLoss; - gLastUsedAbility = gBattleMons[gActiveBank].ability; - RecordAbilityBattle(gActiveBank, gLastUsedAbility); + gLastUsedAbility = gBattleMons[gActiveBattler].ability; + RecordAbilityBattle(gActiveBattler, gLastUsedAbility); } return STAT_CHANGE_DIDNT_WORK; } - else if (gBattleMons[gActiveBank].ability == ABILITY_HYPER_CUTTER + else if (gBattleMons[gActiveBattler].ability == ABILITY_HYPER_CUTTER && !certain && statId == STAT_STAGE_ATK) { if (flags == STAT_CHANGE_BS_PTR) { BattleScriptPush(BS_ptr); - gBattleScripting.bank = gActiveBank; + gBattleScripting.battler = gActiveBattler; gBattlescriptCurrInstr = BattleScript_AbilityNoSpecificStatLoss; - gLastUsedAbility = gBattleMons[gActiveBank].ability; - RecordAbilityBattle(gActiveBank, gLastUsedAbility); + gLastUsedAbility = gBattleMons[gActiveBattler].ability; + RecordAbilityBattle(gActiveBattler, gLastUsedAbility); } return STAT_CHANGE_DIDNT_WORK; } - else if (gBattleMons[gActiveBank].ability == ABILITY_SHIELD_DUST && flags == 0) + else if (gBattleMons[gActiveBattler].ability == ABILITY_SHIELD_DUST && flags == 0) { return STAT_CHANGE_DIDNT_WORK; } @@ -7675,10 +7675,10 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) index++; gBattleTextBuff2[index] = B_BUFF_EOS; - if (gBattleMons[gActiveBank].statStages[statId] == 0) + if (gBattleMons[gActiveBattler].statStages[statId] == 0) gBattleCommunication[MULTISTRING_CHOOSER] = 2; else - gBattleCommunication[MULTISTRING_CHOOSER] = (gBankDefender == gActiveBank); + gBattleCommunication[MULTISTRING_CHOOSER] = (gBattleDefender == gActiveBattler); } } @@ -7702,17 +7702,17 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) index++; gBattleTextBuff2[index] = B_BUFF_EOS; - if (gBattleMons[gActiveBank].statStages[statId] == 0xC) + if (gBattleMons[gActiveBattler].statStages[statId] == 0xC) gBattleCommunication[MULTISTRING_CHOOSER] = 2; else - gBattleCommunication[MULTISTRING_CHOOSER] = (gBankDefender == gActiveBank); + gBattleCommunication[MULTISTRING_CHOOSER] = (gBattleDefender == gActiveBattler); } - gBattleMons[gActiveBank].statStages[statId] += statValue; - if (gBattleMons[gActiveBank].statStages[statId] < 0) - gBattleMons[gActiveBank].statStages[statId] = 0; - if (gBattleMons[gActiveBank].statStages[statId] > 0xC) - gBattleMons[gActiveBank].statStages[statId] = 0xC; + gBattleMons[gActiveBattler].statStages[statId] += statValue; + if (gBattleMons[gActiveBattler].statStages[statId] < 0) + gBattleMons[gActiveBattler].statStages[statId] = 0; + if (gBattleMons[gActiveBattler].statStages[statId] > 0xC) + gBattleMons[gActiveBattler].statStages[statId] = 0xC; if (gBattleCommunication[MULTISTRING_CHOOSER] == 2 && flags & STAT_CHANGE_BS_PTR) gMoveResultFlags |= MOVE_RESULT_MISSED; @@ -7734,7 +7734,7 @@ static void atk8A_normalisebuffs(void) // haze { s32 i, j; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { for (j = 0; j < BATTLE_STATS_NO; j++) gBattleMons[i].statStages[j] = 6; @@ -7745,17 +7745,17 @@ static void atk8A_normalisebuffs(void) // haze static void atk8B_setbide(void) { - gBattleMons[gBankAttacker].status2 |= STATUS2_MULTIPLETURNS; - gLockedMoves[gBankAttacker] = gCurrentMove; - gTakenDmg[gBankAttacker] = 0; - gBattleMons[gBankAttacker].status2 |= (STATUS2_BIDE - 0x100); // 2 turns + gBattleMons[gBattleAttacker].status2 |= STATUS2_MULTIPLETURNS; + gLockedMoves[gBattleAttacker] = gCurrentMove; + gTakenDmg[gBattleAttacker] = 0; + gBattleMons[gBattleAttacker].status2 |= (STATUS2_BIDE - 0x100); // 2 turns gBattlescriptCurrInstr++; } static void atk8C_confuseifrepeatingattackends(void) { - if (!(gBattleMons[gBankAttacker].status2 & STATUS2_LOCK_CONFUSE)) + if (!(gBattleMons[gBattleAttacker].status2 & STATUS2_LOCK_CONFUSE)) gBattleCommunication[MOVE_EFFECT_BYTE] = (MOVE_EFFECT_THRASH | MOVE_EFFECT_AFFECTS_USER); gBattlescriptCurrInstr++; @@ -7788,19 +7788,19 @@ static void atk8E_initmultihitstring(void) static bool8 TryDoForceSwitchOut(void) { - if (gBattleMons[gBankAttacker].level >= gBattleMons[gBankDefender].level) + if (gBattleMons[gBattleAttacker].level >= gBattleMons[gBattleDefender].level) { - *(gBattleStruct->field_58 + gBankDefender) = gBattlePartyID[gBankDefender]; + *(gBattleStruct->field_58 + gBattleDefender) = gBattlePartyID[gBattleDefender]; } else { u16 random = Random() & 0xFF; - if ((u32)((random * (gBattleMons[gBankAttacker].level + gBattleMons[gBankDefender].level) >> 8) + 1) <= (gBattleMons[gBankDefender].level / 4)) + if ((u32)((random * (gBattleMons[gBattleAttacker].level + gBattleMons[gBattleDefender].level) >> 8) + 1) <= (gBattleMons[gBattleDefender].level / 4)) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); return FALSE; } - *(gBattleStruct->field_58 + gBankDefender) = gBattlePartyID[gBankDefender]; + *(gBattleStruct->field_58 + gBattleDefender) = gBattlePartyID[gBattleDefender]; } gBattlescriptCurrInstr = BattleScript_SuccessForceOut; @@ -7827,7 +7827,7 @@ static void atk8F_forcerandomswitch(void) if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER)) { - if (GetBankSide(gBankDefender) == SIDE_PLAYER) + if (GetBattlerSide(gBattleDefender) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -7836,7 +7836,7 @@ static void atk8F_forcerandomswitch(void) || (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER && gBattleTypeFlags & BATTLE_TYPE_x2000000) || (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)) { - if ((gBankDefender & BIT_MON) != 0) + if ((gBattleDefender & BIT_FLANK) != 0) { firstMonId = 3; lastMonId = 6; @@ -7848,13 +7848,13 @@ static void atk8F_forcerandomswitch(void) } monsCount = 3; minNeeded = 1; - bank2PartyId = gBattlePartyID[gBankDefender]; - bank1PartyId = gBattlePartyID[gBankDefender ^ BIT_MON]; + bank2PartyId = gBattlePartyID[gBattleDefender]; + bank1PartyId = gBattlePartyID[gBattleDefender ^ BIT_FLANK]; } else if ((gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) || (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_x2000000)) { - if (sub_806D82C(GetBankMultiplayerId(gBankDefender)) == 1) + if (sub_806D82C(GetBankMultiplayerId(gBattleDefender)) == 1) { firstMonId = 3; lastMonId = 6; @@ -7866,12 +7866,12 @@ static void atk8F_forcerandomswitch(void) } monsCount = 3; minNeeded = 1; - bank2PartyId = gBattlePartyID[gBankDefender]; - bank1PartyId = gBattlePartyID[gBankDefender ^ BIT_MON]; + bank2PartyId = gBattlePartyID[gBattleDefender]; + bank1PartyId = gBattlePartyID[gBattleDefender ^ BIT_FLANK]; } else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) { - if (GetBankSide(gBankDefender) == SIDE_PLAYER) + if (GetBattlerSide(gBattleDefender) == B_SIDE_PLAYER) { firstMonId = 0; lastMonId = 6; @@ -7880,7 +7880,7 @@ static void atk8F_forcerandomswitch(void) } else { - if ((gBankDefender & BIT_MON) != 0) + if ((gBattleDefender & BIT_FLANK) != 0) { firstMonId = 3; lastMonId = 6; @@ -7893,8 +7893,8 @@ static void atk8F_forcerandomswitch(void) monsCount = 3; minNeeded = 1; } - bank2PartyId = gBattlePartyID[gBankDefender]; - bank1PartyId = gBattlePartyID[gBankDefender ^ BIT_MON]; + bank2PartyId = gBattlePartyID[gBattleDefender]; + bank1PartyId = gBattlePartyID[gBattleDefender ^ BIT_FLANK]; } else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { @@ -7902,8 +7902,8 @@ static void atk8F_forcerandomswitch(void) lastMonId = 6; monsCount = 6; minNeeded = 2; - bank2PartyId = gBattlePartyID[gBankDefender]; - bank1PartyId = gBattlePartyID[gBankDefender ^ BIT_MON]; + bank2PartyId = gBattlePartyID[gBattleDefender]; + bank1PartyId = gBattlePartyID[gBattleDefender ^ BIT_FLANK]; } else { @@ -7911,8 +7911,8 @@ static void atk8F_forcerandomswitch(void) lastMonId = 6; monsCount = 6; minNeeded = 1; - bank2PartyId = gBattlePartyID[gBankDefender]; // there is only one pokemon out in single battles - bank1PartyId = gBattlePartyID[gBankDefender]; + bank2PartyId = gBattlePartyID[gBattleDefender]; // there is only one pokemon out in single battles + bank1PartyId = gBattlePartyID[gBattleDefender]; } for (i = firstMonId; i < lastMonId; i++) @@ -7944,22 +7944,22 @@ static void atk8F_forcerandomswitch(void) || GetMonData(&party[i], MON_DATA_IS_EGG) == TRUE || GetMonData(&party[i], MON_DATA_HP) == 0); } - *(gBattleStruct->monToSwitchIntoId + gBankDefender) = i; + *(gBattleStruct->monToSwitchIntoId + gBattleDefender) = i; if (!sub_81B1250()) - sub_803BDA0(gBankDefender); + sub_803BDA0(gBattleDefender); if ((gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) || (gBattleTypeFlags & BATTLE_TYPE_LINK && gBattleTypeFlags & BATTLE_TYPE_MULTI) || (gBattleTypeFlags & BATTLE_TYPE_x2000000 && gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) || (gBattleTypeFlags & BATTLE_TYPE_x2000000 && gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - sub_81B8E80(gBankDefender, i, 0); - sub_81B8E80(gBankDefender ^ BIT_MON, i, 1); + sub_81B8E80(gBattleDefender, i, 0); + sub_81B8E80(gBattleDefender ^ BIT_FLANK, i, 1); } if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) - sub_80571DC(gBankDefender, i); + sub_80571DC(gBattleDefender, i); } } else @@ -7976,7 +7976,7 @@ static void atk90_tryconversiontypechange(void) // randomly changes user's type while (validMoves < 4) { - if (gBattleMons[gBankAttacker].moves[validMoves] == 0) + if (gBattleMons[gBattleAttacker].moves[validMoves] == 0) break; validMoves++; @@ -7984,17 +7984,17 @@ static void atk90_tryconversiontypechange(void) // randomly changes user's type for (moveChecked = 0; moveChecked < validMoves; moveChecked++) { - moveType = gBattleMoves[gBattleMons[gBankAttacker].moves[moveChecked]].type; + moveType = gBattleMoves[gBattleMons[gBattleAttacker].moves[moveChecked]].type; if (moveType == TYPE_MYSTERY) { - if (gBattleMons[gBankAttacker].type1 == TYPE_GHOST || gBattleMons[gBankAttacker].type2 == TYPE_GHOST) + if (gBattleMons[gBattleAttacker].type1 == TYPE_GHOST || gBattleMons[gBattleAttacker].type2 == TYPE_GHOST) moveType = TYPE_GHOST; else moveType = TYPE_NORMAL; } - if (moveType != gBattleMons[gBankAttacker].type1 - && moveType != gBattleMons[gBankAttacker].type2) + if (moveType != gBattleMons[gBattleAttacker].type1 + && moveType != gBattleMons[gBattleAttacker].type2) { break; } @@ -8011,20 +8011,20 @@ static void atk90_tryconversiontypechange(void) // randomly changes user's type while ((moveChecked = Random() & 3) >= validMoves); - moveType = gBattleMoves[gBattleMons[gBankAttacker].moves[moveChecked]].type; + moveType = gBattleMoves[gBattleMons[gBattleAttacker].moves[moveChecked]].type; if (moveType == TYPE_MYSTERY) { - if (gBattleMons[gBankAttacker].type1 == TYPE_GHOST || gBattleMons[gBankAttacker].type2 == TYPE_GHOST) + if (gBattleMons[gBattleAttacker].type1 == TYPE_GHOST || gBattleMons[gBattleAttacker].type2 == TYPE_GHOST) moveType = TYPE_GHOST; else moveType = TYPE_NORMAL; } } - while (moveType == gBattleMons[gBankAttacker].type1 || moveType == gBattleMons[gBankAttacker].type2); + while (moveType == gBattleMons[gBattleAttacker].type1 || moveType == gBattleMons[gBattleAttacker].type2); - gBattleMons[gBankAttacker].type1 = moveType; - gBattleMons[gBankAttacker].type2 = moveType; + gBattleMons[gBattleAttacker].type1 = moveType; + gBattleMons[gBattleAttacker].type2 = moveType; PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType) @@ -8052,16 +8052,16 @@ static void atk91_givepaydaymoney(void) static void atk92_setlightscreen(void) { - if (gSideStatuses[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_LIGHTSCREEN) + if (gSideStatuses[GET_BATTLER_SIDE(gBattleAttacker)] & SIDE_STATUS_LIGHTSCREEN) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } else { - gSideStatuses[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_LIGHTSCREEN; - gSideTimers[GET_BANK_SIDE(gBankAttacker)].lightscreenTimer = 5; - gSideTimers[GET_BANK_SIDE(gBankAttacker)].lightscreenBank = gBankAttacker; + gSideStatuses[GET_BATTLER_SIDE(gBattleAttacker)] |= SIDE_STATUS_LIGHTSCREEN; + gSideTimers[GET_BATTLER_SIDE(gBattleAttacker)].lightscreenTimer = 5; + gSideTimers[GET_BATTLER_SIDE(gBattleAttacker)].lightscreenBank = gBattleAttacker; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && CountAliveMonsInBattle(BATTLE_ALIVE_ATK_SIDE) == 2) gBattleCommunication[MULTISTRING_CHOOSER] = 4; @@ -8076,72 +8076,72 @@ static void atk93_tryKO(void) { u8 holdEffect, param; - if (gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBattleDefender].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBankDefender].holdEffect; - param = gEnigmaBerries[gBankDefender].holdEffectParam; + holdEffect = gEnigmaBerries[gBattleDefender].holdEffect; + param = gEnigmaBerries[gBattleDefender].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankDefender].item); - param = ItemId_GetHoldEffectParam(gBattleMons[gBankDefender].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattleDefender].item); + param = ItemId_GetHoldEffectParam(gBattleMons[gBattleDefender].item); } - gStringBank = gBankDefender; + gStringBank = gBattleDefender; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param) { - RecordItemEffectBattle(gBankDefender, HOLD_EFFECT_FOCUS_BAND); - gSpecialStatuses[gBankDefender].focusBanded = 1; + RecordItemEffectBattle(gBattleDefender, HOLD_EFFECT_FOCUS_BAND); + gSpecialStatuses[gBattleDefender].focusBanded = 1; } - if (gBattleMons[gBankDefender].ability == ABILITY_STURDY) + if (gBattleMons[gBattleDefender].ability == ABILITY_STURDY) { gMoveResultFlags |= MOVE_RESULT_MISSED; gLastUsedAbility = ABILITY_STURDY; gBattlescriptCurrInstr = BattleScript_SturdyPreventsOHKO; - RecordAbilityBattle(gBankDefender, ABILITY_STURDY); + RecordAbilityBattle(gBattleDefender, ABILITY_STURDY); } else { u16 chance; - if (!(gStatuses3[gBankDefender] & STATUS3_ALWAYS_HITS)) + if (!(gStatuses3[gBattleDefender] & STATUS3_ALWAYS_HITS)) { - chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBankAttacker].level - gBattleMons[gBankDefender].level); - if (Random() % 100 + 1 < chance && gBattleMons[gBankAttacker].level >= gBattleMons[gBankDefender].level) + chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBattleAttacker].level - gBattleMons[gBattleDefender].level); + if (Random() % 100 + 1 < chance && gBattleMons[gBattleAttacker].level >= gBattleMons[gBattleDefender].level) chance = TRUE; else chance = FALSE; } - else if (gDisableStructs[gBankDefender].bankWithSureHit == gBankAttacker - && gBattleMons[gBankAttacker].level >= gBattleMons[gBankDefender].level) + else if (gDisableStructs[gBattleDefender].bankWithSureHit == gBattleAttacker + && gBattleMons[gBattleAttacker].level >= gBattleMons[gBattleDefender].level) { chance = TRUE; } else { - chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBankAttacker].level - gBattleMons[gBankDefender].level); - if (Random() % 100 + 1 < chance && gBattleMons[gBankAttacker].level >= gBattleMons[gBankDefender].level) + chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBattleAttacker].level - gBattleMons[gBattleDefender].level); + if (Random() % 100 + 1 < chance && gBattleMons[gBattleAttacker].level >= gBattleMons[gBattleDefender].level) chance = TRUE; else chance = FALSE; } if (chance) { - if (gProtectStructs[gBankDefender].endured) + if (gProtectStructs[gBattleDefender].endured) { - gBattleMoveDamage = gBattleMons[gBankDefender].hp - 1; + gBattleMoveDamage = gBattleMons[gBattleDefender].hp - 1; gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBankDefender].focusBanded) + else if (gSpecialStatuses[gBattleDefender].focusBanded) { - gBattleMoveDamage = gBattleMons[gBankDefender].hp - 1; + gBattleMoveDamage = gBattleMons[gBattleDefender].hp - 1; gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; - gLastUsedItem = gBattleMons[gBankDefender].item; + gLastUsedItem = gBattleMons[gBattleDefender].item; } else { - gBattleMoveDamage = gBattleMons[gBankDefender].hp; + gBattleMoveDamage = gBattleMons[gBattleDefender].hp; gMoveResultFlags |= MOVE_RESULT_ONE_HIT_KO; } gBattlescriptCurrInstr += 5; @@ -8149,7 +8149,7 @@ static void atk93_tryKO(void) else { gMoveResultFlags |= MOVE_RESULT_MISSED; - if (gBattleMons[gBankAttacker].level >= gBattleMons[gBankDefender].level) + if (gBattleMons[gBattleAttacker].level >= gBattleMons[gBattleDefender].level) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -8160,7 +8160,7 @@ static void atk93_tryKO(void) static void atk94_damagetohalftargethp(void) // super fang { - gBattleMoveDamage = gBattleMons[gBankDefender].hp / 2; + gBattleMoveDamage = gBattleMons[gBattleDefender].hp / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -8189,17 +8189,17 @@ static void atk96_weatherdamage(void) { if (gBattleWeather & WEATHER_SANDSTORM_ANY) { - if (gBattleMons[gBankAttacker].type1 != TYPE_ROCK - && gBattleMons[gBankAttacker].type1 != TYPE_STEEL - && gBattleMons[gBankAttacker].type1 != TYPE_GROUND - && gBattleMons[gBankAttacker].type2 != TYPE_ROCK - && gBattleMons[gBankAttacker].type2 != TYPE_STEEL - && gBattleMons[gBankAttacker].type2 != TYPE_GROUND - && gBattleMons[gBankAttacker].ability != ABILITY_SAND_VEIL - && !(gStatuses3[gBankAttacker] & STATUS3_UNDERGROUND) - && !(gStatuses3[gBankAttacker] & STATUS3_UNDERWATER)) + if (gBattleMons[gBattleAttacker].type1 != TYPE_ROCK + && gBattleMons[gBattleAttacker].type1 != TYPE_STEEL + && gBattleMons[gBattleAttacker].type1 != TYPE_GROUND + && gBattleMons[gBattleAttacker].type2 != TYPE_ROCK + && gBattleMons[gBattleAttacker].type2 != TYPE_STEEL + && gBattleMons[gBattleAttacker].type2 != TYPE_GROUND + && gBattleMons[gBattleAttacker].ability != ABILITY_SAND_VEIL + && !(gStatuses3[gBattleAttacker] & STATUS3_UNDERGROUND) + && !(gStatuses3[gBattleAttacker] & STATUS3_UNDERWATER)) { - gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 16; + gBattleMoveDamage = gBattleMons[gBattleAttacker].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; } @@ -8210,12 +8210,12 @@ static void atk96_weatherdamage(void) } if (gBattleWeather & WEATHER_HAIL) { - if (gBattleMons[gBankAttacker].type1 != TYPE_ICE - && gBattleMons[gBankAttacker].type2 != TYPE_ICE - && !(gStatuses3[gBankAttacker] & STATUS3_UNDERGROUND) - && !(gStatuses3[gBankAttacker] & STATUS3_UNDERWATER)) + if (gBattleMons[gBattleAttacker].type1 != TYPE_ICE + && gBattleMons[gBattleAttacker].type2 != TYPE_ICE + && !(gStatuses3[gBattleAttacker] & STATUS3_UNDERGROUND) + && !(gStatuses3[gBattleAttacker] & STATUS3_UNDERWATER)) { - gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 16; + gBattleMoveDamage = gBattleMons[gBattleAttacker].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; } @@ -8230,7 +8230,7 @@ static void atk96_weatherdamage(void) gBattleMoveDamage = 0; } - if (gAbsentBankFlags & gBitTable[gBankAttacker]) + if (gAbsentBattlerFlags & gBitTable[gBattleAttacker]) gBattleMoveDamage = 0; gBattlescriptCurrInstr++; @@ -8242,15 +8242,15 @@ static void atk97_tryinfatuating(void) u16 speciesAttacker, speciesTarget; u32 personalityAttacker, personalityTarget; - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) - monAttacker = &gPlayerParty[gBattlePartyID[gBankAttacker]]; + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) + monAttacker = &gPlayerParty[gBattlePartyID[gBattleAttacker]]; else - monAttacker = &gEnemyParty[gBattlePartyID[gBankAttacker]]; + monAttacker = &gEnemyParty[gBattlePartyID[gBattleAttacker]]; - if (GetBankSide(gBankDefender) == SIDE_PLAYER) - monTarget = &gPlayerParty[gBattlePartyID[gBankDefender]]; + if (GetBattlerSide(gBattleDefender) == B_SIDE_PLAYER) + monTarget = &gPlayerParty[gBattlePartyID[gBattleDefender]]; else - monTarget = &gEnemyParty[gBattlePartyID[gBankDefender]]; + monTarget = &gEnemyParty[gBattlePartyID[gBattleDefender]]; speciesAttacker = GetMonData(monAttacker, MON_DATA_SPECIES); personalityAttacker = GetMonData(monAttacker, MON_DATA_PERSONALITY); @@ -8258,16 +8258,16 @@ static void atk97_tryinfatuating(void) speciesTarget = GetMonData(monTarget, MON_DATA_SPECIES); personalityTarget = GetMonData(monTarget, MON_DATA_PERSONALITY); - if (gBattleMons[gBankDefender].ability == ABILITY_OBLIVIOUS) + if (gBattleMons[gBattleDefender].ability == ABILITY_OBLIVIOUS) { gBattlescriptCurrInstr = BattleScript_ObliviousPreventsAttraction; gLastUsedAbility = ABILITY_OBLIVIOUS; - RecordAbilityBattle(gBankDefender, ABILITY_OBLIVIOUS); + RecordAbilityBattle(gBattleDefender, ABILITY_OBLIVIOUS); } else { if (GetGenderFromSpeciesAndPersonality(speciesAttacker, personalityAttacker) == GetGenderFromSpeciesAndPersonality(speciesTarget, personalityTarget) - || gBattleMons[gBankDefender].status2 & STATUS2_INFATUATION + || gBattleMons[gBattleDefender].status2 & STATUS2_INFATUATION || GetGenderFromSpeciesAndPersonality(speciesAttacker, personalityAttacker) == MON_GENDERLESS || GetGenderFromSpeciesAndPersonality(speciesTarget, personalityTarget) == MON_GENDERLESS) { @@ -8275,7 +8275,7 @@ static void atk97_tryinfatuating(void) } else { - gBattleMons[gBankDefender].status2 |= STATUS2_INFATUATED_WITH(gBankAttacker); + gBattleMons[gBattleDefender].status2 |= STATUS2_INFATUATED_WITH(gBattleAttacker); gBattlescriptCurrInstr += 5; } } @@ -8288,26 +8288,26 @@ static void atk98_updatestatusicon(void) if (gBattlescriptCurrInstr[1] != BS_ATTACKER_WITH_PARTNER) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - EmitStatusIconUpdate(0, gBattleMons[gActiveBank].status1, gBattleMons[gActiveBank].status2); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); + EmitStatusIconUpdate(0, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } else { - gActiveBank = gBankAttacker; - if (!(gAbsentBankFlags & gBitTable[gActiveBank])) + gActiveBattler = gBattleAttacker; + if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { - EmitStatusIconUpdate(0, gBattleMons[gActiveBank].status1, gBattleMons[gActiveBank].status2); - MarkBufferBankForExecution(gActiveBank); + EmitStatusIconUpdate(0, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); + MarkBufferBankForExecution(gActiveBattler); } if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - gActiveBank = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_MON); - if (!(gAbsentBankFlags & gBitTable[gActiveBank])) + gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattleAttacker) ^ BIT_FLANK); + if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { - EmitStatusIconUpdate(0, gBattleMons[gActiveBank].status1, gBattleMons[gActiveBank].status2); - MarkBufferBankForExecution(gActiveBank); + EmitStatusIconUpdate(0, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); + MarkBufferBankForExecution(gActiveBattler); } } gBattlescriptCurrInstr += 2; @@ -8316,16 +8316,16 @@ static void atk98_updatestatusicon(void) static void atk99_setmist(void) { - if (gSideTimers[GET_BANK_SIDE(gBankAttacker)].mistTimer) + if (gSideTimers[GET_BATTLER_SIDE(gBattleAttacker)].mistTimer) { gMoveResultFlags |= MOVE_RESULT_FAILED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else { - gSideTimers[GET_BANK_SIDE(gBankAttacker)].mistTimer = 5; - gSideTimers[GET_BANK_SIDE(gBankAttacker)].mistBank = gBankAttacker; - gSideStatuses[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_MIST; + gSideTimers[GET_BATTLER_SIDE(gBattleAttacker)].mistTimer = 5; + gSideTimers[GET_BATTLER_SIDE(gBattleAttacker)].mistBank = gBattleAttacker; + gSideStatuses[GET_BATTLER_SIDE(gBattleAttacker)] |= SIDE_STATUS_MIST; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } gBattlescriptCurrInstr++; @@ -8333,14 +8333,14 @@ static void atk99_setmist(void) static void atk9A_setfocusenergy(void) { - if (gBattleMons[gBankAttacker].status2 & STATUS2_FOCUS_ENERGY) + if (gBattleMons[gBattleAttacker].status2 & STATUS2_FOCUS_ENERGY) { gMoveResultFlags |= MOVE_RESULT_FAILED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else { - gBattleMons[gBankAttacker].status2 |= STATUS2_FOCUS_ENERGY; + gBattleMons[gBattleAttacker].status2 |= STATUS2_FOCUS_ENERGY; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } gBattlescriptCurrInstr++; @@ -8350,8 +8350,8 @@ static void atk9B_transformdataexecution(void) { gChosenMove = 0xFFFF; gBattlescriptCurrInstr++; - if (gBattleMons[gBankDefender].status2 & STATUS2_TRANSFORMED - || gStatuses3[gBankDefender] & STATUS3_SEMI_INVULNERABLE) + if (gBattleMons[gBattleDefender].status2 & STATUS2_TRANSFORMED + || gStatuses3[gBattleDefender] & STATUS3_SEMI_INVULNERABLE) { gMoveResultFlags |= MOVE_RESULT_FAILED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -8361,55 +8361,55 @@ static void atk9B_transformdataexecution(void) s32 i; u8 *battleMonAttacker, *battleMonTarget; - gBattleMons[gBankAttacker].status2 |= STATUS2_TRANSFORMED; - gDisableStructs[gBankAttacker].disabledMove = 0; - gDisableStructs[gBankAttacker].disableTimer1 = 0; - gDisableStructs[gBankAttacker].transformedMonPersonality = gBattleMons[gBankDefender].personality; - gDisableStructs[gBankAttacker].unk18_b = 0; + gBattleMons[gBattleAttacker].status2 |= STATUS2_TRANSFORMED; + gDisableStructs[gBattleAttacker].disabledMove = 0; + gDisableStructs[gBattleAttacker].disableTimer1 = 0; + gDisableStructs[gBattleAttacker].transformedMonPersonality = gBattleMons[gBattleDefender].personality; + gDisableStructs[gBattleAttacker].unk18_b = 0; - PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBankDefender].species) + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattleDefender].species) - battleMonAttacker = (u8*)(&gBattleMons[gBankAttacker]); - battleMonTarget = (u8*)(&gBattleMons[gBankDefender]); + battleMonAttacker = (u8*)(&gBattleMons[gBattleAttacker]); + battleMonTarget = (u8*)(&gBattleMons[gBattleDefender]); for (i = 0; i < offsetof(struct BattlePokemon, pp); i++) battleMonAttacker[i] = battleMonTarget[i]; for (i = 0; i < 4; i++) { - if (gBattleMoves[gBattleMons[gBankAttacker].moves[i]].pp < 5) - gBattleMons[gBankAttacker].pp[i] = gBattleMoves[gBattleMons[gBankAttacker].moves[i]].pp; + if (gBattleMoves[gBattleMons[gBattleAttacker].moves[i]].pp < 5) + gBattleMons[gBattleAttacker].pp[i] = gBattleMoves[gBattleMons[gBattleAttacker].moves[i]].pp; else - gBattleMons[gBankAttacker].pp[i] = 5; + gBattleMons[gBattleAttacker].pp[i] = 5; } - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; EmitResetActionMoveSelection(0, RESET_MOVE_SELECTION); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattleCommunication[MULTISTRING_CHOOSER] = 0; } } static void atk9C_setsubstitute(void) { - u32 hp = gBattleMons[gBankAttacker].maxHP / 4; - if (gBattleMons[gBankAttacker].maxHP / 4 == 0) + u32 hp = gBattleMons[gBattleAttacker].maxHP / 4; + if (gBattleMons[gBattleAttacker].maxHP / 4 == 0) hp = 1; - if (gBattleMons[gBankAttacker].hp <= hp) + if (gBattleMons[gBattleAttacker].hp <= hp) { gBattleMoveDamage = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else { - gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 4; // one bit value will only work for pokemon which max hp can go to 1020(which is more than possible in games) + gBattleMoveDamage = gBattleMons[gBattleAttacker].maxHP / 4; // one bit value will only work for pokemon which max hp can go to 1020(which is more than possible in games) if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - gBattleMons[gBankAttacker].status2 |= STATUS2_SUBSTITUTE; - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_WRAPPED); - gDisableStructs[gBankAttacker].substituteHP = gBattleMoveDamage; + gBattleMons[gBattleAttacker].status2 |= STATUS2_SUBSTITUTE; + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_WRAPPED); + gDisableStructs[gBattleAttacker].substituteHP = gBattleMoveDamage; gBattleCommunication[MULTISTRING_CHOOSER] = 0; gHitMarker |= HITMARKER_IGNORE_SUBSTITUTE; } @@ -8430,10 +8430,10 @@ static void atk9D_mimicattackcopy(void) { gChosenMove = 0xFFFF; - if (IsMoveUncopyableByMimic(gLastMoves[gBankDefender]) - || gBattleMons[gBankAttacker].status2 & STATUS2_TRANSFORMED - || gLastMoves[gBankDefender] == 0 - || gLastMoves[gBankDefender] == 0xFFFF) + if (IsMoveUncopyableByMimic(gLastMoves[gBattleDefender]) + || gBattleMons[gBattleAttacker].status2 & STATUS2_TRANSFORMED + || gLastMoves[gBattleDefender] == 0 + || gLastMoves[gBattleDefender] == 0xFFFF) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -8443,22 +8443,22 @@ static void atk9D_mimicattackcopy(void) for (i = 0; i < 4; i++) { - if (gBattleMons[gBankAttacker].moves[i] == gLastMoves[gBankDefender]) + if (gBattleMons[gBattleAttacker].moves[i] == gLastMoves[gBattleDefender]) break; } if (i == 4) { - gBattleMons[gBankAttacker].moves[gCurrMovePos] = gLastMoves[gBankDefender]; - if (gBattleMoves[gLastMoves[gBankDefender]].pp < 5) - gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gLastMoves[gBankDefender]].pp; + gBattleMons[gBattleAttacker].moves[gCurrMovePos] = gLastMoves[gBattleDefender]; + if (gBattleMoves[gLastMoves[gBattleDefender]].pp < 5) + gBattleMons[gBattleAttacker].pp[gCurrMovePos] = gBattleMoves[gLastMoves[gBattleDefender]].pp; else - gBattleMons[gBankAttacker].pp[gCurrMovePos] = 5; + gBattleMons[gBattleAttacker].pp[gCurrMovePos] = 5; - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBankDefender]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBattleDefender]) - gDisableStructs[gBankAttacker].unk18_b |= gBitTable[gCurrMovePos]; + gDisableStructs[gBattleAttacker].unk18_b |= gBitTable[gCurrMovePos]; gBattlescriptCurrInstr += 5; } else @@ -8494,7 +8494,7 @@ static void atk9E_metronome(void) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; - gBankDefender = GetMoveTarget(gCurrentMove, 0); + gBattleDefender = GetMoveTarget(gCurrentMove, 0); return; } } @@ -8502,7 +8502,7 @@ static void atk9E_metronome(void) static void atk9F_dmgtolevel(void) { - gBattleMoveDamage = gBattleMons[gBankAttacker].level; + gBattleMoveDamage = gBattleMons[gBattleAttacker].level; gBattlescriptCurrInstr++; } @@ -8513,54 +8513,54 @@ static void atkA0_psywavedamageeffect(void) while ((randDamage = (Random() & 0xF)) > 10); randDamage *= 10; - gBattleMoveDamage = gBattleMons[gBankAttacker].level * (randDamage + 50) / 100; + gBattleMoveDamage = gBattleMons[gBattleAttacker].level * (randDamage + 50) / 100; gBattlescriptCurrInstr++; } static void atkA1_counterdamagecalculator(void) { - u8 sideAttacker = GetBankSide(gBankAttacker); - u8 sideTarget = GetBankSide(gProtectStructs[gBankAttacker].physicalBank); + u8 sideAttacker = GetBattlerSide(gBattleAttacker); + u8 sideTarget = GetBattlerSide(gProtectStructs[gBattleAttacker].physicalBank); - if (gProtectStructs[gBankAttacker].physicalDmg + if (gProtectStructs[gBattleAttacker].physicalDmg && sideAttacker != sideTarget - && gBattleMons[gProtectStructs[gBankAttacker].physicalBank].hp) + && gBattleMons[gProtectStructs[gBattleAttacker].physicalBank].hp) { - gBattleMoveDamage = gProtectStructs[gBankAttacker].physicalDmg * 2; + gBattleMoveDamage = gProtectStructs[gBattleAttacker].physicalDmg * 2; if (gSideTimers[sideTarget].followmeTimer && gBattleMons[gSideTimers[sideTarget].followmeTarget].hp) - gBankDefender = gSideTimers[sideTarget].followmeTarget; + gBattleDefender = gSideTimers[sideTarget].followmeTarget; else - gBankDefender = gProtectStructs[gBankAttacker].physicalBank; + gBattleDefender = gProtectStructs[gBattleAttacker].physicalBank; gBattlescriptCurrInstr += 5; } else { - gSpecialStatuses[gBankAttacker].flag20 = 1; + gSpecialStatuses[gBattleAttacker].flag20 = 1; gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } } static void atkA2_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the physical -> special field changes { - u8 sideAttacker = GetBankSide(gBankAttacker); - u8 sideTarget = GetBankSide(gProtectStructs[gBankAttacker].specialBank); + u8 sideAttacker = GetBattlerSide(gBattleAttacker); + u8 sideTarget = GetBattlerSide(gProtectStructs[gBattleAttacker].specialBank); - if (gProtectStructs[gBankAttacker].specialDmg && sideAttacker != sideTarget && gBattleMons[gProtectStructs[gBankAttacker].specialBank].hp) + if (gProtectStructs[gBattleAttacker].specialDmg && sideAttacker != sideTarget && gBattleMons[gProtectStructs[gBattleAttacker].specialBank].hp) { - gBattleMoveDamage = gProtectStructs[gBankAttacker].specialDmg * 2; + gBattleMoveDamage = gProtectStructs[gBattleAttacker].specialDmg * 2; if (gSideTimers[sideTarget].followmeTimer && gBattleMons[gSideTimers[sideTarget].followmeTarget].hp) - gBankDefender = gSideTimers[sideTarget].followmeTarget; + gBattleDefender = gSideTimers[sideTarget].followmeTarget; else - gBankDefender = gProtectStructs[gBankAttacker].specialBank; + gBattleDefender = gProtectStructs[gBattleAttacker].specialBank; gBattlescriptCurrInstr += 5; } else { - gSpecialStatuses[gBankAttacker].flag20 = 1; + gSpecialStatuses[gBattleAttacker].flag20 = 1; gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } } @@ -8571,17 +8571,17 @@ static void atkA3_disablelastusedattack(void) for (i = 0; i < 4; i++) { - if (gBattleMons[gBankDefender].moves[i] == gLastMoves[gBankDefender]) + if (gBattleMons[gBattleDefender].moves[i] == gLastMoves[gBattleDefender]) break; } - if (gDisableStructs[gBankDefender].disabledMove == 0 - && i != 4 && gBattleMons[gBankDefender].pp[i] != 0) + if (gDisableStructs[gBattleDefender].disabledMove == 0 + && i != 4 && gBattleMons[gBattleDefender].pp[i] != 0) { - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBankDefender].moves[i]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBattleDefender].moves[i]) - gDisableStructs[gBankDefender].disabledMove = gBattleMons[gBankDefender].moves[i]; - gDisableStructs[gBankDefender].disableTimer1 = (Random() & 3) + 2; - gDisableStructs[gBankDefender].disableTimer2 = gDisableStructs[gBankDefender].disableTimer1; // used to save the random amount of turns? + gDisableStructs[gBattleDefender].disabledMove = gBattleMons[gBattleDefender].moves[i]; + gDisableStructs[gBattleDefender].disableTimer1 = (Random() & 3) + 2; + gDisableStructs[gBattleDefender].disableTimer2 = gDisableStructs[gBattleDefender].disableTimer1; // used to save the random amount of turns? gBattlescriptCurrInstr += 5; } else @@ -8596,24 +8596,24 @@ static void atkA4_trysetencore(void) for (i = 0; i < 4; i++) { - if (gBattleMons[gBankDefender].moves[i] == gLastMoves[gBankDefender]) + if (gBattleMons[gBattleDefender].moves[i] == gLastMoves[gBattleDefender]) break; } - if (gLastMoves[gBankDefender] == MOVE_STRUGGLE - || gLastMoves[gBankDefender] == MOVE_ENCORE - || gLastMoves[gBankDefender] == MOVE_MIRROR_MOVE) + if (gLastMoves[gBattleDefender] == MOVE_STRUGGLE + || gLastMoves[gBattleDefender] == MOVE_ENCORE + || gLastMoves[gBattleDefender] == MOVE_MIRROR_MOVE) { i = 4; } - if (gDisableStructs[gBankDefender].encoredMove == 0 - && i != 4 && gBattleMons[gBankDefender].pp[i] != 0) + if (gDisableStructs[gBattleDefender].encoredMove == 0 + && i != 4 && gBattleMons[gBattleDefender].pp[i] != 0) { - gDisableStructs[gBankDefender].encoredMove = gBattleMons[gBankDefender].moves[i]; - gDisableStructs[gBankDefender].encoredMovePos = i; - gDisableStructs[gBankDefender].encoreTimer1 = (Random() & 3) + 3; - gDisableStructs[gBankDefender].encoreTimer2 = gDisableStructs[gBankDefender].encoreTimer1; + gDisableStructs[gBattleDefender].encoredMove = gBattleMons[gBattleDefender].moves[i]; + gDisableStructs[gBattleDefender].encoredMovePos = i; + gDisableStructs[gBattleDefender].encoreTimer1 = (Random() & 3) + 3; + gDisableStructs[gBattleDefender].encoreTimer2 = gDisableStructs[gBattleDefender].encoreTimer1; gBattlescriptCurrInstr += 5; } else @@ -8624,10 +8624,10 @@ static void atkA4_trysetencore(void) static void atkA5_painsplitdmgcalc(void) { - if (!(gBattleMons[gBankDefender].status2 & STATUS2_SUBSTITUTE)) + if (!(gBattleMons[gBattleDefender].status2 & STATUS2_SUBSTITUTE)) { - s32 hpDiff = (gBattleMons[gBankAttacker].hp + gBattleMons[gBankDefender].hp) / 2; - s32 painSplitHp = gBattleMoveDamage = gBattleMons[gBankDefender].hp - hpDiff; + s32 hpDiff = (gBattleMons[gBattleAttacker].hp + gBattleMons[gBattleDefender].hp) / 2; + s32 painSplitHp = gBattleMoveDamage = gBattleMons[gBattleDefender].hp - hpDiff; u8* storeLoc = (void*)(&gBattleScripting.painSplitHp); storeLoc[0] = (painSplitHp); @@ -8635,8 +8635,8 @@ static void atkA5_painsplitdmgcalc(void) storeLoc[2] = (painSplitHp & 0x00FF0000) >> 16; storeLoc[3] = (painSplitHp & 0xFF000000) >> 24; - gBattleMoveDamage = gBattleMons[gBankAttacker].hp - hpDiff; - gSpecialStatuses[gBankDefender].moveturnLostHP = 0xFFFF; + gBattleMoveDamage = gBattleMons[gBattleAttacker].hp - hpDiff; + gSpecialStatuses[gBattleDefender].moveturnLostHP = 0xFFFF; gBattlescriptCurrInstr += 5; } @@ -8648,13 +8648,13 @@ static void atkA5_painsplitdmgcalc(void) static void atkA6_settypetorandomresistance(void) // conversion 2 { - if (gLastLandedMoves[gBankAttacker] == 0 - || gLastLandedMoves[gBankAttacker] == 0xFFFF) + if (gLastLandedMoves[gBattleAttacker] == 0 + || gLastLandedMoves[gBattleAttacker] == 0xFFFF) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } - else if (IsTwoTurnsMove(gLastLandedMoves[gBankAttacker]) - && gBattleMons[gLastHitBy[gBankAttacker]].status2 & STATUS2_MULTIPLETURNS) + else if (IsTwoTurnsMove(gLastLandedMoves[gBattleAttacker]) + && gBattleMons[gLastHitBy[gBattleAttacker]].status2 & STATUS2_MULTIPLETURNS) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -8668,13 +8668,13 @@ static void atkA6_settypetorandomresistance(void) // conversion 2 i *= 3; - if (TYPE_EFFECT_ATK_TYPE(i) == gLastHitByType[gBankAttacker] + if (TYPE_EFFECT_ATK_TYPE(i) == gLastHitByType[gBattleAttacker] && TYPE_EFFECT_MULTIPLIER(i) <= TYPE_MUL_NOT_EFFECTIVE - && gBattleMons[gBankAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i) - && gBattleMons[gBankAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i)) + && gBattleMons[gBattleAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i) + && gBattleMons[gBattleAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i)) { - gBattleMons[gBankAttacker].type1 = TYPE_EFFECT_DEF_TYPE(i); - gBattleMons[gBankAttacker].type2 = TYPE_EFFECT_DEF_TYPE(i); + gBattleMons[gBattleAttacker].type1 = TYPE_EFFECT_DEF_TYPE(i); + gBattleMons[gBattleAttacker].type2 = TYPE_EFFECT_DEF_TYPE(i); PREPARE_TYPE_BUFFER(gBattleTextBuff1, TYPE_EFFECT_DEF_TYPE(i)) @@ -8691,13 +8691,13 @@ static void atkA6_settypetorandomresistance(void) // conversion 2 case TYPE_FORESIGHT: break; default: - if (TYPE_EFFECT_ATK_TYPE(j) == gLastHitByType[gBankAttacker] + if (TYPE_EFFECT_ATK_TYPE(j) == gLastHitByType[gBattleAttacker] && TYPE_EFFECT_MULTIPLIER(j) <= 5 - && gBattleMons[gBankAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i) - && gBattleMons[gBankAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i)) + && gBattleMons[gBattleAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i) + && gBattleMons[gBattleAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i)) { - gBattleMons[gBankAttacker].type1 = TYPE_EFFECT_DEF_TYPE(rands); - gBattleMons[gBankAttacker].type2 = TYPE_EFFECT_DEF_TYPE(rands); + gBattleMons[gBattleAttacker].type1 = TYPE_EFFECT_DEF_TYPE(rands); + gBattleMons[gBattleAttacker].type2 = TYPE_EFFECT_DEF_TYPE(rands); PREPARE_TYPE_BUFFER(gBattleTextBuff1, TYPE_EFFECT_DEF_TYPE(rands)) @@ -8714,9 +8714,9 @@ static void atkA6_settypetorandomresistance(void) // conversion 2 static void atkA7_setalwayshitflag(void) { - gStatuses3[gBankDefender] &= ~(STATUS3_ALWAYS_HITS); - gStatuses3[gBankDefender] |= 0x10; - gDisableStructs[gBankDefender].bankWithSureHit = gBankAttacker; + gStatuses3[gBattleDefender] &= ~(STATUS3_ALWAYS_HITS); + gStatuses3[gBattleDefender] |= 0x10; + gDisableStructs[gBattleDefender].bankWithSureHit = gBattleAttacker; gBattlescriptCurrInstr++; } @@ -8724,19 +8724,19 @@ static void atkA8_copymovepermanently(void) // sketch { gChosenMove = 0xFFFF; - if (!(gBattleMons[gBankAttacker].status2 & STATUS2_TRANSFORMED) - && gLastPrintedMoves[gBankDefender] != MOVE_STRUGGLE - && gLastPrintedMoves[gBankDefender] != 0 - && gLastPrintedMoves[gBankDefender] != 0xFFFF - && gLastPrintedMoves[gBankDefender] != MOVE_SKETCH) + if (!(gBattleMons[gBattleAttacker].status2 & STATUS2_TRANSFORMED) + && gLastPrintedMoves[gBattleDefender] != MOVE_STRUGGLE + && gLastPrintedMoves[gBattleDefender] != 0 + && gLastPrintedMoves[gBattleDefender] != 0xFFFF + && gLastPrintedMoves[gBattleDefender] != MOVE_SKETCH) { s32 i; for (i = 0; i < 4; i++) { - if (gBattleMons[gBankAttacker].moves[i] == MOVE_SKETCH) + if (gBattleMons[gBattleAttacker].moves[i] == MOVE_SKETCH) continue; - if (gBattleMons[gBankAttacker].moves[i] == gLastPrintedMoves[gBankDefender]) + if (gBattleMons[gBattleAttacker].moves[i] == gLastPrintedMoves[gBattleDefender]) break; } @@ -8748,21 +8748,21 @@ static void atkA8_copymovepermanently(void) // sketch { struct MovePpInfo movePpData; - gBattleMons[gBankAttacker].moves[gCurrMovePos] = gLastPrintedMoves[gBankDefender]; - gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gLastPrintedMoves[gBankDefender]].pp; - gActiveBank = gBankAttacker; + gBattleMons[gBattleAttacker].moves[gCurrMovePos] = gLastPrintedMoves[gBattleDefender]; + gBattleMons[gBattleAttacker].pp[gCurrMovePos] = gBattleMoves[gLastPrintedMoves[gBattleDefender]].pp; + gActiveBattler = gBattleAttacker; for (i = 0; i < 4; i++) { - movePpData.moves[i] = gBattleMons[gBankAttacker].moves[i]; - movePpData.pp[i] = gBattleMons[gBankAttacker].pp[i]; + movePpData.moves[i] = gBattleMons[gBattleAttacker].moves[i]; + movePpData.pp[i] = gBattleMons[gBattleAttacker].pp[i]; } - movePpData.ppBonuses = gBattleMons[gBankAttacker].ppBonuses; + movePpData.ppBonuses = gBattleMons[gBattleAttacker].ppBonuses; EmitSetMonData(0, REQUEST_MOVES_PP_BATTLE, 0, sizeof(struct MovePpInfo), &movePpData); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastPrintedMoves[gBankDefender]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastPrintedMoves[gBattleDefender]) gBattlescriptCurrInstr += 5; } @@ -8822,17 +8822,17 @@ static void atkA9_trychoosesleeptalkmove(void) for (i = 0; i < 4; i++) { - if (IsInvalidForSleepTalkOrAssist(gBattleMons[gBankAttacker].moves[i]) - || gBattleMons[gBankAttacker].moves[i] == MOVE_FOCUS_PUNCH - || gBattleMons[gBankAttacker].moves[i] == MOVE_UPROAR - || IsTwoTurnsMove(gBattleMons[gBankAttacker].moves[i])) + if (IsInvalidForSleepTalkOrAssist(gBattleMons[gBattleAttacker].moves[i]) + || gBattleMons[gBattleAttacker].moves[i] == MOVE_FOCUS_PUNCH + || gBattleMons[gBattleAttacker].moves[i] == MOVE_UPROAR + || IsTwoTurnsMove(gBattleMons[gBattleAttacker].moves[i])) { unusableMovesBits |= gBitTable[i]; } } - unusableMovesBits = CheckMoveLimitations(gBankAttacker, unusableMovesBits, ~(MOVE_LIMITATION_PP)); + unusableMovesBits = CheckMoveLimitations(gBattleAttacker, unusableMovesBits, ~(MOVE_LIMITATION_PP)); if (unusableMovesBits == 0xF) // all 4 moves cannot be chosen { gBattlescriptCurrInstr += 5; @@ -8846,25 +8846,25 @@ static void atkA9_trychoosesleeptalkmove(void) movePosition = Random() & 3; } while ((gBitTable[movePosition] & unusableMovesBits)); - gRandomMove = gBattleMons[gBankAttacker].moves[movePosition]; + gRandomMove = gBattleMons[gBattleAttacker].moves[movePosition]; gCurrMovePos = movePosition; gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); - gBankDefender = GetMoveTarget(gRandomMove, 0); + gBattleDefender = GetMoveTarget(gRandomMove, 0); gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } } static void atkAA_setdestinybond(void) { - gBattleMons[gBankAttacker].status2 |= STATUS2_DESTINY_BOND; + gBattleMons[gBattleAttacker].status2 |= STATUS2_DESTINY_BOND; gBattlescriptCurrInstr++; } static void TrySetDestinyBondToHappen(void) { - u8 sideAttacker = GetBankSide(gBankAttacker); - u8 sideTarget = GetBankSide(gBankDefender); - if (gBattleMons[gBankDefender].status2 & STATUS2_DESTINY_BOND + u8 sideAttacker = GetBattlerSide(gBattleAttacker); + u8 sideTarget = GetBattlerSide(gBattleDefender); + if (gBattleMons[gBattleDefender].status2 & STATUS2_DESTINY_BOND && sideAttacker != sideTarget && !(gHitMarker & HITMARKER_GRUDGE)) { @@ -8881,7 +8881,7 @@ static void atkAB_trysetdestinybondtohappen(void) static void atkAC_remaininghptopower(void) { s32 i; - s32 hpFraction = GetScaledHPFraction(gBattleMons[gBankAttacker].hp, gBattleMons[gBankAttacker].maxHP, 48); + s32 hpFraction = GetScaledHPFraction(gBattleMons[gBattleAttacker].hp, gBattleMons[gBattleAttacker].maxHP, 48); for (i = 0; i < (s32) sizeof(sFlailHpScaleToPowerTable); i += 2) { @@ -8895,43 +8895,43 @@ static void atkAC_remaininghptopower(void) static void atkAD_tryspiteppreduce(void) { - if (gLastMoves[gBankDefender] != 0 - && gLastMoves[gBankDefender] != 0xFFFF) + if (gLastMoves[gBattleDefender] != 0 + && gLastMoves[gBattleDefender] != 0xFFFF) { s32 i; for (i = 0; i < 4; i++) { - if (gLastMoves[gBankDefender] == gBattleMons[gBankDefender].moves[i]) + if (gLastMoves[gBattleDefender] == gBattleMons[gBattleDefender].moves[i]) break; } - if (i != 4 && gBattleMons[gBankDefender].pp[i] > 1) + if (i != 4 && gBattleMons[gBattleDefender].pp[i] > 1) { s32 ppToDeduct = (Random() & 3) + 2; - if (gBattleMons[gBankDefender].pp[i] < ppToDeduct) - ppToDeduct = gBattleMons[gBankDefender].pp[i]; + if (gBattleMons[gBattleDefender].pp[i] < ppToDeduct) + ppToDeduct = gBattleMons[gBattleDefender].pp[i]; - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBankDefender]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBattleDefender]) ConvertIntToDecimalStringN(gBattleTextBuff2, ppToDeduct, 0, 1); PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff2, 1, ppToDeduct) - gBattleMons[gBankDefender].pp[i] -= ppToDeduct; - gActiveBank = gBankDefender; + gBattleMons[gBattleDefender].pp[i] -= ppToDeduct; + gActiveBattler = gBattleDefender; - if (!(gDisableStructs[gActiveBank].unk18_b & gBitTable[i]) - && !(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) + if (!(gDisableStructs[gActiveBattler].unk18_b & gBitTable[i]) + && !(gBattleMons[gActiveBattler].status2 & STATUS2_TRANSFORMED)) { - EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + i, 0, 1, &gBattleMons[gActiveBank].pp[i]); - MarkBufferBankForExecution(gActiveBank); + EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + i, 0, 1, &gBattleMons[gActiveBattler].pp[i]); + MarkBufferBankForExecution(gActiveBattler); } gBattlescriptCurrInstr += 5; - if (gBattleMons[gBankDefender].pp[i] == 0) - CancelMultiTurnMoves(gBankDefender); + if (gBattleMons[gBattleDefender].pp[i] == 0) + CancelMultiTurnMoves(gBattleDefender); } else { @@ -8956,35 +8956,35 @@ static void atkAE_healpartystatus(void) gBattleCommunication[MULTISTRING_CHOOSER] = 0; - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; - if (gBattleMons[gBankAttacker].ability != ABILITY_SOUNDPROOF) + if (gBattleMons[gBattleAttacker].ability != ABILITY_SOUNDPROOF) { - gBattleMons[gBankAttacker].status1 = 0; - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattleAttacker].status1 = 0; + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_NIGHTMARE); } else { - RecordAbilityBattle(gBankAttacker, gBattleMons[gBankAttacker].ability); + RecordAbilityBattle(gBattleAttacker, gBattleMons[gBattleAttacker].ability); gBattleCommunication[MULTISTRING_CHOOSER] |= 1; } - gActiveBank = gBattleScripting.bank = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_MON); + gActiveBattler = gBattleScripting.battler = GetBattlerAtPosition(GetBattlerPosition(gBattleAttacker) ^ BIT_FLANK); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && !(gAbsentBankFlags & gBitTable[gActiveBank])) + && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { - if (gBattleMons[gActiveBank].ability != ABILITY_SOUNDPROOF) + if (gBattleMons[gActiveBattler].ability != ABILITY_SOUNDPROOF) { - gBattleMons[gActiveBank].status1 = 0; - gBattleMons[gActiveBank].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gActiveBattler].status1 = 0; + gBattleMons[gActiveBattler].status2 &= ~(STATUS2_NIGHTMARE); } else { - RecordAbilityBattle(gActiveBank, gBattleMons[gActiveBank].ability); + RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability); gBattleCommunication[MULTISTRING_CHOOSER] |= 2; } } @@ -8998,12 +8998,12 @@ static void atkAE_healpartystatus(void) { u8 ability; - if (gBattlePartyID[gBankAttacker] == i) - ability = gBattleMons[gBankAttacker].ability; + if (gBattlePartyID[gBattleAttacker] == i) + ability = gBattleMons[gBattleAttacker].ability; else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && gBattlePartyID[gActiveBank] == i - && !(gAbsentBankFlags & gBitTable[gActiveBank])) - ability = gBattleMons[gActiveBank].ability; + && gBattlePartyID[gActiveBattler] == i + && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) + ability = gBattleMons[gActiveBattler].ability; else ability = GetAbilityBySpecies(species, abilityBit); @@ -9017,24 +9017,24 @@ static void atkAE_healpartystatus(void) gBattleCommunication[MULTISTRING_CHOOSER] = 4; toHeal = 0x3F; - gBattleMons[gBankAttacker].status1 = 0; - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattleAttacker].status1 = 0; + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_NIGHTMARE); - gActiveBank = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_MON); + gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattleAttacker) ^ BIT_FLANK); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && !(gAbsentBankFlags & gBitTable[gActiveBank])) + && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { - gBattleMons[gActiveBank].status1 = 0; - gBattleMons[gActiveBank].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gActiveBattler].status1 = 0; + gBattleMons[gActiveBattler].status2 &= ~(STATUS2_NIGHTMARE); } } if (toHeal) { - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; EmitSetMonData(0, REQUEST_STATUS_BATTLE, toHeal, 4, &zero); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } gBattlescriptCurrInstr++; @@ -9042,14 +9042,14 @@ static void atkAE_healpartystatus(void) static void atkAF_cursetarget(void) { - if (gBattleMons[gBankDefender].status2 & STATUS2_CURSED) + if (gBattleMons[gBattleDefender].status2 & STATUS2_CURSED) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gBattleMons[gBankDefender].status2 |= STATUS2_CURSED; - gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 2; + gBattleMons[gBattleDefender].status2 |= STATUS2_CURSED; + gBattleMoveDamage = gBattleMons[gBattleAttacker].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -9059,11 +9059,11 @@ static void atkAF_cursetarget(void) static void atkB0_trysetspikes(void) { - u8 targetSide = GetBankSide(gBankAttacker) ^ BIT_SIDE; + u8 targetSide = GetBattlerSide(gBattleAttacker) ^ BIT_SIDE; if (gSideTimers[targetSide].spikesAmount == 3) { - gSpecialStatuses[gBankAttacker].flag20 = 1; + gSpecialStatuses[gBattleAttacker].flag20 = 1; gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else @@ -9076,7 +9076,7 @@ static void atkB0_trysetspikes(void) static void atkB1_setforesight(void) { - gBattleMons[gBankDefender].status2 |= STATUS2_FORESIGHT; + gBattleMons[gBattleDefender].status2 |= STATUS2_FORESIGHT; gBattlescriptCurrInstr++; } @@ -9085,7 +9085,7 @@ static void atkB2_trysetperishsong(void) s32 i; s32 notAffectedCount = 0; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gStatuses3[i] & STATUS3_PERISH_SONG || gBattleMons[i].ability == ABILITY_SOUNDPROOF) @@ -9100,9 +9100,9 @@ static void atkB2_trysetperishsong(void) } } - PressurePPLoseOnUsingPerishSong(gBankAttacker); + PressurePPLoseOnUsingPerishSong(gBattleAttacker); - if (notAffectedCount == gBattleBanksCount) + if (notAffectedCount == gBattlersCount) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); else gBattlescriptCurrInstr += 5; @@ -9112,31 +9112,31 @@ static void atkB3_rolloutdamagecalculation(void) { if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { - CancelMultiTurnMoves(gBankAttacker); + CancelMultiTurnMoves(gBattleAttacker); gBattlescriptCurrInstr = BattleScript_MoveMissedPause; } else { s32 i; - if (!(gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS)) // first hit + if (!(gBattleMons[gBattleAttacker].status2 & STATUS2_MULTIPLETURNS)) // first hit { - gDisableStructs[gBankAttacker].rolloutCounter1 = 5; - gDisableStructs[gBankAttacker].rolloutCounter2 = 5; - gBattleMons[gBankAttacker].status2 |= STATUS2_MULTIPLETURNS; - gLockedMoves[gBankAttacker] = gCurrentMove; + gDisableStructs[gBattleAttacker].rolloutCounter1 = 5; + gDisableStructs[gBattleAttacker].rolloutCounter2 = 5; + gBattleMons[gBattleAttacker].status2 |= STATUS2_MULTIPLETURNS; + gLockedMoves[gBattleAttacker] = gCurrentMove; } - if (--gDisableStructs[gBankAttacker].rolloutCounter1 == 0) // last hit + if (--gDisableStructs[gBattleAttacker].rolloutCounter1 == 0) // last hit { - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); } gDynamicBasePower = gBattleMoves[gCurrentMove].power; - for (i = 1; i < (5 - gDisableStructs[gBankAttacker].rolloutCounter1); i++) + for (i = 1; i < (5 - gDisableStructs[gBattleAttacker].rolloutCounter1); i++) gDynamicBasePower *= 2; - if (gBattleMons[gBankAttacker].status2 & STATUS2_DEFENSE_CURL) + if (gBattleMons[gBattleAttacker].status2 & STATUS2_DEFENSE_CURL) gDynamicBasePower *= 2; gBattlescriptCurrInstr++; @@ -9145,8 +9145,8 @@ static void atkB3_rolloutdamagecalculation(void) static void atkB4_jumpifconfusedandstatmaxed(void) { - if (gBattleMons[gBankDefender].status2 & STATUS2_CONFUSION - && gBattleMons[gBankDefender].statStages[gBattlescriptCurrInstr[1]] == 0xC) + if (gBattleMons[gBattleDefender].status2 & STATUS2_CONFUSION + && gBattleMons[gBattleDefender].statStages[gBattlescriptCurrInstr[1]] == 0xC) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); else gBattlescriptCurrInstr += 6; @@ -9156,19 +9156,19 @@ static void atkB5_furycuttercalc(void) { if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { - gDisableStructs[gBankAttacker].furyCutterCounter = 0; + gDisableStructs[gBattleAttacker].furyCutterCounter = 0; gBattlescriptCurrInstr = BattleScript_MoveMissedPause; } else { s32 i; - if (gDisableStructs[gBankAttacker].furyCutterCounter != 5) - gDisableStructs[gBankAttacker].furyCutterCounter++; + if (gDisableStructs[gBattleAttacker].furyCutterCounter != 5) + gDisableStructs[gBattleAttacker].furyCutterCounter++; gDynamicBasePower = gBattleMoves[gCurrentMove].power; - for (i = 1; i < gDisableStructs[gBankAttacker].furyCutterCounter; i++) + for (i = 1; i < gDisableStructs[gBattleAttacker].furyCutterCounter; i++) gDynamicBasePower *= 2; gBattlescriptCurrInstr++; @@ -9178,9 +9178,9 @@ static void atkB5_furycuttercalc(void) static void atkB6_happinesstodamagecalculation(void) { if (gBattleMoves[gCurrentMove].effect == EFFECT_RETURN) - gDynamicBasePower = 10 * (gBattleMons[gBankAttacker].friendship) / 25; + gDynamicBasePower = 10 * (gBattleMons[gBattleAttacker].friendship) / 25; else // EFFECT_FRUSTRATION - gDynamicBasePower = 10 * (255 - gBattleMons[gBankAttacker].friendship) / 25; + gDynamicBasePower = 10 * (255 - gBattleMons[gBattleAttacker].friendship) / 25; gBattlescriptCurrInstr++; } @@ -9197,14 +9197,14 @@ static void atkB7_presentdamagecalculation(void) gDynamicBasePower = 120; else { - gBattleMoveDamage = gBattleMons[gBankDefender].maxHP / 4; + gBattleMoveDamage = gBattleMons[gBattleDefender].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; } if (rand < 204) gBattlescriptCurrInstr = BattleScript_HitFromCritCalc; - else if (gBattleMons[gBankDefender].maxHP == gBattleMons[gBankDefender].hp) + else if (gBattleMons[gBattleDefender].maxHP == gBattleMons[gBattleDefender].hp) gBattlescriptCurrInstr = BattleScript_AlreadyAtFullHp; else { @@ -9215,16 +9215,16 @@ static void atkB7_presentdamagecalculation(void) static void atkB8_setsafeguard(void) { - if (gSideStatuses[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_SAFEGUARD) + if (gSideStatuses[GET_BATTLER_SIDE(gBattleAttacker)] & SIDE_STATUS_SAFEGUARD) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } else { - gSideStatuses[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_SAFEGUARD; - gSideTimers[GET_BANK_SIDE(gBankAttacker)].safeguardTimer = 5; - gSideTimers[GET_BANK_SIDE(gBankAttacker)].safeguardBank = gBankAttacker; + gSideStatuses[GET_BATTLER_SIDE(gBattleAttacker)] |= SIDE_STATUS_SAFEGUARD; + gSideTimers[GET_BATTLER_SIDE(gBattleAttacker)].safeguardTimer = 5; + gSideTimers[GET_BATTLER_SIDE(gBattleAttacker)].safeguardBank = gBattleAttacker; gBattleCommunication[MULTISTRING_CHOOSER] = 5; } @@ -9274,11 +9274,11 @@ static void atkB9_magnitudedamagecalculation(void) PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 2, magnitude) - for (gBankDefender = 0; gBankDefender < gBattleBanksCount; gBankDefender++) + for (gBattleDefender = 0; gBattleDefender < gBattlersCount; gBattleDefender++) { - if (gBankDefender == gBankAttacker) + if (gBattleDefender == gBattleAttacker) continue; - if (!(gAbsentBankFlags & gBitTable[gBankDefender])) // a valid target was found + if (!(gAbsentBattlerFlags & gBitTable[gBattleDefender])) // a valid target was found break; } @@ -9289,36 +9289,36 @@ static void atkBA_jumpifnopursuitswitchdmg(void) { if (gMultiHitCounter == 1) { - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) - gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) + gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); else - gBankDefender = GetBankByPosition(B_POSITION_PLAYER_LEFT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); } else { - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) - gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) + gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); else - gBankDefender = GetBankByPosition(B_POSITION_PLAYER_RIGHT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); } - if (gActionForBanks[gBankDefender] == ACTION_USE_MOVE - && gBankAttacker == *(gBattleStruct->moveTarget + gBankDefender) - && !(gBattleMons[gBankDefender].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) - && gBattleMons[gBankAttacker].hp - && !gDisableStructs[gBankDefender].truantCounter - && gChosenMovesByBanks[gBankDefender] == MOVE_PURSUIT) + if (gActionForBanks[gBattleDefender] == ACTION_USE_MOVE + && gBattleAttacker == *(gBattleStruct->moveTarget + gBattleDefender) + && !(gBattleMons[gBattleDefender].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) + && gBattleMons[gBattleAttacker].hp + && !gDisableStructs[gBattleDefender].truantCounter + && gChosenMovesByBanks[gBattleDefender] == MOVE_PURSUIT) { s32 i; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (gBanksByTurnOrder[i] == gBankDefender) + if (gBattleTurnOrder[i] == gBattleDefender) gActionsByTurnOrder[i] = 11; } gCurrentMove = MOVE_PURSUIT; - gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBankDefender); + gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBattleDefender); gBattlescriptCurrInstr += 5; gBattleScripting.animTurn = 1; gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); @@ -9348,16 +9348,16 @@ static void atkBB_setsunny(void) static void atkBC_maxattackhalvehp(void) // belly drum { - u32 halfHp = gBattleMons[gBankAttacker].maxHP / 2; + u32 halfHp = gBattleMons[gBattleAttacker].maxHP / 2; - if (!(gBattleMons[gBankAttacker].maxHP / 2)) + if (!(gBattleMons[gBattleAttacker].maxHP / 2)) halfHp = 1; - if (gBattleMons[gBankAttacker].statStages[STAT_STAGE_ATK] < 12 - && gBattleMons[gBankAttacker].hp > halfHp) + if (gBattleMons[gBattleAttacker].statStages[STAT_STAGE_ATK] < 12 + && gBattleMons[gBattleAttacker].hp > halfHp) { - gBattleMons[gBankAttacker].statStages[STAT_STAGE_ATK] = 12; - gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 2; + gBattleMons[gBattleAttacker].statStages[STAT_STAGE_ATK] = 12; + gBattleMoveDamage = gBattleMons[gBattleAttacker].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -9375,7 +9375,7 @@ static void atkBD_copyfoestats(void) // psych up for (i = 0; i < BATTLE_STATS_NO; i++) { - gBattleMons[gBankAttacker].statStages[i] = gBattleMons[gBankDefender].statStages[i]; + gBattleMons[gBattleAttacker].statStages[i] = gBattleMons[gBattleDefender].statStages[i]; } gBattlescriptCurrInstr += 5; // Has an unused jump ptr(possibly for a failed attempt) parameter. @@ -9383,32 +9383,32 @@ static void atkBD_copyfoestats(void) // psych up static void atkBE_rapidspinfree(void) { - if (gBattleMons[gBankAttacker].status2 & STATUS2_WRAPPED) + if (gBattleMons[gBattleAttacker].status2 & STATUS2_WRAPPED) { - gBattleScripting.bank = gBankDefender; - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_WRAPPED); - gBankDefender = *(gBattleStruct->wrappedBy + gBankAttacker); + gBattleScripting.battler = gBattleDefender; + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_WRAPPED); + gBattleDefender = *(gBattleStruct->wrappedBy + gBattleAttacker); gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN; gBattleTextBuff1[1] = B_BUFF_MOVE; - gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gBankAttacker * 2 + 0); - gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gBankAttacker * 2 + 1); + gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gBattleAttacker * 2 + 0); + gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gBattleAttacker * 2 + 1); gBattleTextBuff1[4] = B_BUFF_EOS; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_WrapFree; } - else if (gStatuses3[gBankAttacker] & STATUS3_LEECHSEED) + else if (gStatuses3[gBattleAttacker] & STATUS3_LEECHSEED) { - gStatuses3[gBankAttacker] &= ~(STATUS3_LEECHSEED); - gStatuses3[gBankAttacker] &= ~(STATUS3_LEECHSEED_BANK); + gStatuses3[gBattleAttacker] &= ~(STATUS3_LEECHSEED); + gStatuses3[gBattleAttacker] &= ~(STATUS3_LEECHSEED_BANK); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_LeechSeedFree; } - else if (gSideStatuses[GetBankSide(gBankAttacker)] & SIDE_STATUS_SPIKES) + else if (gSideStatuses[GetBattlerSide(gBattleAttacker)] & SIDE_STATUS_SPIKES) { - gSideStatuses[GetBankSide(gBankAttacker)] &= ~(SIDE_STATUS_SPIKES); - gSideTimers[GetBankSide(gBankAttacker)].spikesAmount = 0; + gSideStatuses[GetBattlerSide(gBattleAttacker)] &= ~(SIDE_STATUS_SPIKES); + gSideTimers[GetBattlerSide(gBattleAttacker)].spikesAmount = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SpikesFree; } @@ -9420,22 +9420,22 @@ static void atkBE_rapidspinfree(void) static void atkBF_setdefensecurlbit(void) { - gBattleMons[gBankAttacker].status2 |= STATUS2_DEFENSE_CURL; + gBattleMons[gBattleAttacker].status2 |= STATUS2_DEFENSE_CURL; gBattlescriptCurrInstr++; } static void atkC0_recoverbasedonsunlight(void) { - gBankDefender = gBankAttacker; + gBattleDefender = gBattleAttacker; - if (gBattleMons[gBankAttacker].hp != gBattleMons[gBankAttacker].maxHP) + if (gBattleMons[gBattleAttacker].hp != gBattleMons[gBattleAttacker].maxHP) { if (gBattleWeather == 0 || !WEATHER_HAS_EFFECT) - gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 2; + gBattleMoveDamage = gBattleMons[gBattleAttacker].maxHP / 2; else if (gBattleWeather & WEATHER_SUN_ANY) - gBattleMoveDamage = 20 * gBattleMons[gBankAttacker].maxHP / 30; + gBattleMoveDamage = 20 * gBattleMons[gBattleAttacker].maxHP / 30; else // not sunny weather - gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 4; + gBattleMoveDamage = gBattleMons[gBattleAttacker].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -9455,19 +9455,19 @@ static void atkC1_hiddenpowercalc(void) u32 powerBits = 0; u32 typeBits = 0; - powerBits |= ((gBattleMons[gBankAttacker].hpIV & 2) >> 1); - powerBits |= ((gBattleMons[gBankAttacker].attackIV & 2) << 0); - powerBits |= ((gBattleMons[gBankAttacker].defenseIV & 2) << 1); - powerBits |= ((gBattleMons[gBankAttacker].speedIV & 2) << 2); - powerBits |= ((gBattleMons[gBankAttacker].spAttackIV & 2) << 3); - powerBits |= ((gBattleMons[gBankAttacker].spDefenseIV & 2) << 4); + powerBits |= ((gBattleMons[gBattleAttacker].hpIV & 2) >> 1); + powerBits |= ((gBattleMons[gBattleAttacker].attackIV & 2) << 0); + powerBits |= ((gBattleMons[gBattleAttacker].defenseIV & 2) << 1); + powerBits |= ((gBattleMons[gBattleAttacker].speedIV & 2) << 2); + powerBits |= ((gBattleMons[gBattleAttacker].spAttackIV & 2) << 3); + powerBits |= ((gBattleMons[gBattleAttacker].spDefenseIV & 2) << 4); - typeBits |= ((gBattleMons[gBankAttacker].hpIV & 1) << 0); - typeBits |= ((gBattleMons[gBankAttacker].attackIV & 1) << 1); - typeBits |= ((gBattleMons[gBankAttacker].defenseIV & 1) << 2); - typeBits |= ((gBattleMons[gBankAttacker].speedIV & 1) << 3); - typeBits |= ((gBattleMons[gBankAttacker].spAttackIV & 1) << 4); - typeBits |= ((gBattleMons[gBankAttacker].spDefenseIV & 1) << 5); + typeBits |= ((gBattleMons[gBattleAttacker].hpIV & 1) << 0); + typeBits |= ((gBattleMons[gBattleAttacker].attackIV & 1) << 1); + typeBits |= ((gBattleMons[gBattleAttacker].defenseIV & 1) << 2); + typeBits |= ((gBattleMons[gBattleAttacker].speedIV & 1) << 3); + typeBits |= ((gBattleMons[gBattleAttacker].spAttackIV & 1) << 4); + typeBits |= ((gBattleMons[gBattleAttacker].spDefenseIV & 1) << 5); gDynamicBasePower = (40 * powerBits) / 63 + 30; @@ -9490,7 +9490,7 @@ static void atkC1_hiddenpowercalc(void) mov r5, r8\n\ push {r5-r7}\n\ ldr r2, =gBattleMons\n\ - ldr r0, =gBankAttacker\n\ + ldr r0, =gBattleAttacker\n\ ldrb r1, [r0]\n\ movs r0, 0x58\n\ adds r4, r1, 0\n\ @@ -9626,11 +9626,11 @@ _080544F0:\n\ static void atkC2_selectfirstvalidtarget(void) { - for (gBankDefender = 0; gBankDefender < gBattleBanksCount; gBankDefender++) + for (gBattleDefender = 0; gBattleDefender < gBattlersCount; gBattleDefender++) { - if (gBankDefender == gBankAttacker) + if (gBattleDefender == gBattleAttacker) continue; - if (!(gAbsentBankFlags & gBitTable[gBankDefender])) + if (!(gAbsentBattlerFlags & gBitTable[gBattleDefender])) break; } gBattlescriptCurrInstr++; @@ -9638,22 +9638,22 @@ static void atkC2_selectfirstvalidtarget(void) static void atkC3_trysetfutureattack(void) { - if (gWishFutureKnock.futureSightCounter[gBankDefender] != 0) + if (gWishFutureKnock.futureSightCounter[gBattleDefender] != 0) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gSideStatuses[GET_BANK_SIDE(gBankDefender)] |= SIDE_STATUS_FUTUREATTACK; - gWishFutureKnock.futureSightMove[gBankDefender] = gCurrentMove; - gWishFutureKnock.futureSightAttacker[gBankDefender] = gBankAttacker; - gWishFutureKnock.futureSightCounter[gBankDefender] = 3; - gWishFutureKnock.futureSightDmg[gBankDefender] = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankDefender], gCurrentMove, - gSideStatuses[GET_BANK_SIDE(gBankDefender)], 0, - 0, gBankAttacker, gBankDefender); + gSideStatuses[GET_BATTLER_SIDE(gBattleDefender)] |= SIDE_STATUS_FUTUREATTACK; + gWishFutureKnock.futureSightMove[gBattleDefender] = gCurrentMove; + gWishFutureKnock.futureSightAttacker[gBattleDefender] = gBattleAttacker; + gWishFutureKnock.futureSightCounter[gBattleDefender] = 3; + gWishFutureKnock.futureSightDmg[gBattleDefender] = CalculateBaseDamage(&gBattleMons[gBattleAttacker], &gBattleMons[gBattleDefender], gCurrentMove, + gSideStatuses[GET_BATTLER_SIDE(gBattleDefender)], 0, + 0, gBattleAttacker, gBattleDefender); - if (gProtectStructs[gBankAttacker].helpingHand) - gWishFutureKnock.futureSightDmg[gBankDefender] = gWishFutureKnock.futureSightDmg[gBankDefender] * 15 / 10; + if (gProtectStructs[gBattleAttacker].helpingHand) + gWishFutureKnock.futureSightDmg[gBattleDefender] = gWishFutureKnock.futureSightDmg[gBattleDefender] * 15 / 10; if (gCurrentMove == MOVE_DOOM_DESIRE) gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -9668,12 +9668,12 @@ static void atkC4_trydobeatup(void) { struct Pokemon *party; - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; - if (gBattleMons[gBankDefender].hp == 0) + if (gBattleMons[gBattleDefender].hp == 0) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -9690,16 +9690,16 @@ static void atkC4_trydobeatup(void) } if (gBattleCommunication[0] < 6) { - PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBankAttacker, gBattleCommunication[0]) + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBattleAttacker, gBattleCommunication[0]) gBattlescriptCurrInstr += 9; gBattleMoveDamage = gBaseStats[GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES)].baseAttack; gBattleMoveDamage *= gBattleMoves[gCurrentMove].power; gBattleMoveDamage *= (GetMonData(&party[gBattleCommunication[0]], MON_DATA_LEVEL) * 2 / 5 + 2); - gBattleMoveDamage /= gBaseStats[gBattleMons[gBankDefender].species].baseDefense; + gBattleMoveDamage /= gBaseStats[gBattleMons[gBattleDefender].species].baseDefense; gBattleMoveDamage = (gBattleMoveDamage / 50) + 2; - if (gProtectStructs[gBankAttacker].helpingHand) + if (gProtectStructs[gBattleAttacker].helpingHand) gBattleMoveDamage = gBattleMoveDamage * 15 / 10; gBattleCommunication[0]++; @@ -9717,13 +9717,13 @@ static void atkC5_setsemiinvulnerablebit(void) { case MOVE_FLY: case MOVE_BOUNCE: - gStatuses3[gBankAttacker] |= STATUS3_ON_AIR; + gStatuses3[gBattleAttacker] |= STATUS3_ON_AIR; break; case MOVE_DIG: - gStatuses3[gBankAttacker] |= STATUS3_UNDERGROUND; + gStatuses3[gBattleAttacker] |= STATUS3_UNDERGROUND; break; case MOVE_DIVE: - gStatuses3[gBankAttacker] |= STATUS3_UNDERWATER; + gStatuses3[gBattleAttacker] |= STATUS3_UNDERWATER; break; } @@ -9736,13 +9736,13 @@ static void atkC6_clearsemiinvulnerablebit(void) { case MOVE_FLY: case MOVE_BOUNCE: - gStatuses3[gBankAttacker] &= ~STATUS3_ON_AIR; + gStatuses3[gBattleAttacker] &= ~STATUS3_ON_AIR; break; case MOVE_DIG: - gStatuses3[gBankAttacker] &= ~STATUS3_UNDERGROUND; + gStatuses3[gBattleAttacker] &= ~STATUS3_UNDERGROUND; break; case MOVE_DIVE: - gStatuses3[gBankAttacker] &= ~STATUS3_UNDERWATER; + gStatuses3[gBattleAttacker] &= ~STATUS3_UNDERWATER; break; } @@ -9752,7 +9752,7 @@ static void atkC6_clearsemiinvulnerablebit(void) static void atkC7_setminimize(void) { if (gHitMarker & HITMARKER_OBEYS) - gStatuses3[gBankAttacker] |= STATUS3_MINIMIZED; + gStatuses3[gBattleAttacker] |= STATUS3_MINIMIZED; gBattlescriptCurrInstr++; } @@ -9776,34 +9776,34 @@ static void atkC8_sethail(void) static void atkC9_jumpifattackandspecialattackcannotfall(void) // memento { - if (gBattleMons[gBankDefender].statStages[STAT_STAGE_ATK] == 0 - && gBattleMons[gBankDefender].statStages[STAT_STAGE_SPATK] == 0 + if (gBattleMons[gBattleDefender].statStages[STAT_STAGE_ATK] == 0 + && gBattleMons[gBattleDefender].statStages[STAT_STAGE_SPATK] == 0 && gBattleCommunication[6] != 1) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gActiveBank = gBankAttacker; - gBattleMoveDamage = gBattleMons[gActiveBank].hp; + gActiveBattler = gBattleAttacker; + gBattleMoveDamage = gBattleMons[gActiveBattler].hp; EmitHealthBarUpdate(0, INSTANT_HP_BAR_DROP); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 5; } } static void atkCA_setforcedtarget(void) // follow me { - gSideTimers[GetBankSide(gBankAttacker)].followmeTimer = 1; - gSideTimers[GetBankSide(gBankAttacker)].followmeTarget = gBankAttacker; + gSideTimers[GetBattlerSide(gBattleAttacker)].followmeTimer = 1; + gSideTimers[GetBattlerSide(gBattleAttacker)].followmeTarget = gBattleAttacker; gBattlescriptCurrInstr++; } static void atkCB_setcharge(void) { - gStatuses3[gBankAttacker] |= STATUS3_CHARGED_UP; - gDisableStructs[gBankAttacker].chargeTimer1 = 2; - gDisableStructs[gBankAttacker].chargeTimer2 = 2; + gStatuses3[gBattleAttacker] |= STATUS3_CHARGED_UP; + gDisableStructs[gBattleAttacker].chargeTimer1 = 2; + gDisableStructs[gBattleAttacker].chargeTimer2 = 2; gBattlescriptCurrInstr++; } @@ -9811,20 +9811,20 @@ static void atkCC_callterrainattack(void) // nature power { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = sNaturePowerMoves[gBattleTerrain]; - gBankDefender = GetMoveTarget(gCurrentMove, 0); + gBattleDefender = GetMoveTarget(gCurrentMove, 0); BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]); gBattlescriptCurrInstr++; } static void atkCD_cureifburnedparalysedorpoisoned(void) // refresh { - if (gBattleMons[gBankAttacker].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)) + if (gBattleMons[gBattleAttacker].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)) { - gBattleMons[gBankAttacker].status1 = 0; + gBattleMons[gBattleAttacker].status1 = 0; gBattlescriptCurrInstr += 5; - gActiveBank = gBankAttacker; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = gBattleAttacker; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); } else { @@ -9834,20 +9834,20 @@ static void atkCD_cureifburnedparalysedorpoisoned(void) // refresh static void atkCE_settorment(void) { - if (gBattleMons[gBankDefender].status2 & STATUS2_TORMENT) + if (gBattleMons[gBattleDefender].status2 & STATUS2_TORMENT) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gBattleMons[gBankDefender].status2 |= STATUS2_TORMENT; + gBattleMons[gBattleDefender].status2 |= STATUS2_TORMENT; gBattlescriptCurrInstr += 5; } } static void atkCF_jumpifnodamage(void) { - if (gProtectStructs[gBankAttacker].physicalDmg || gProtectStructs[gBankAttacker].specialDmg) + if (gProtectStructs[gBattleAttacker].physicalDmg || gProtectStructs[gBattleAttacker].specialDmg) gBattlescriptCurrInstr += 5; else gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); @@ -9855,10 +9855,10 @@ static void atkCF_jumpifnodamage(void) static void atkD0_settaunt(void) { - if (gDisableStructs[gBankDefender].tauntTimer1 == 0) + if (gDisableStructs[gBattleDefender].tauntTimer1 == 0) { - gDisableStructs[gBankDefender].tauntTimer1 = 2; - gDisableStructs[gBankDefender].tauntTimer2 = 2; + gDisableStructs[gBattleDefender].tauntTimer1 = 2; + gDisableStructs[gBattleDefender].tauntTimer2 = 2; gBattlescriptCurrInstr += 5; } else @@ -9869,14 +9869,14 @@ static void atkD0_settaunt(void) static void atkD1_trysethelpinghand(void) { - gBankDefender = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_MON); + gBattleDefender = GetBattlerAtPosition(GetBattlerPosition(gBattleAttacker) ^ BIT_FLANK); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && !(gAbsentBankFlags & gBitTable[gBankDefender]) - && !gProtectStructs[gBankAttacker].helpingHand - && !gProtectStructs[gBankDefender].helpingHand) + && !(gAbsentBattlerFlags & gBitTable[gBattleDefender]) + && !gProtectStructs[gBattleAttacker].helpingHand + && !gProtectStructs[gBattleDefender].helpingHand) { - gProtectStructs[gBankDefender].helpingHand = 1; + gProtectStructs[gBattleDefender].helpingHand = 1; gBattlescriptCurrInstr += 5; } else @@ -9889,7 +9889,7 @@ static void atkD2_tryswapitems(void) // trick { // opponent can't swap items with player in regular battles if (gBattleTypeFlags & BATTLE_TYPE_x4000000 - || (GetBankSide(gBankAttacker) == SIDE_OPPONENT + || (GetBattlerSide(gBattleAttacker) == B_SIDE_OPPONENT && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_FRONTIER @@ -9900,8 +9900,8 @@ static void atkD2_tryswapitems(void) // trick } else { - u8 sideAttacker = GetBankSide(gBankAttacker); - u8 sideTarget = GetBankSide(gBankDefender); + u8 sideAttacker = GetBattlerSide(gBattleAttacker); + u8 sideTarget = GetBattlerSide(gBattleDefender); // you can't swap items if they were knocked off in regular battles if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK @@ -9909,53 +9909,53 @@ static void atkD2_tryswapitems(void) // trick | BATTLE_TYPE_FRONTIER | BATTLE_TYPE_SECRET_BASE | BATTLE_TYPE_x2000000)) - && (gWishFutureKnock.knockedOffPokes[sideAttacker] & gBitTable[gBattlePartyID[gBankAttacker]] - || gWishFutureKnock.knockedOffPokes[sideTarget] & gBitTable[gBattlePartyID[gBankDefender]])) + && (gWishFutureKnock.knockedOffPokes[sideAttacker] & gBitTable[gBattlePartyID[gBattleAttacker]] + || gWishFutureKnock.knockedOffPokes[sideTarget] & gBitTable[gBattlePartyID[gBattleDefender]])) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } // can't swap if two pokemon don't have an item // or if either of them is an enigma berry or a mail - else if ((gBattleMons[gBankAttacker].item == 0 && gBattleMons[gBankDefender].item == 0) - || gBattleMons[gBankAttacker].item == ITEM_ENIGMA_BERRY - || gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY - || IS_ITEM_MAIL(gBattleMons[gBankAttacker].item) - || IS_ITEM_MAIL(gBattleMons[gBankDefender].item)) + else if ((gBattleMons[gBattleAttacker].item == 0 && gBattleMons[gBattleDefender].item == 0) + || gBattleMons[gBattleAttacker].item == ITEM_ENIGMA_BERRY + || gBattleMons[gBattleDefender].item == ITEM_ENIGMA_BERRY + || IS_ITEM_MAIL(gBattleMons[gBattleAttacker].item) + || IS_ITEM_MAIL(gBattleMons[gBattleDefender].item)) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } // check if ability prevents swapping - else if (gBattleMons[gBankDefender].ability == ABILITY_STICKY_HOLD) + else if (gBattleMons[gBattleDefender].ability == ABILITY_STICKY_HOLD) { gBattlescriptCurrInstr = BattleScript_StickyHoldActivates; - gLastUsedAbility = gBattleMons[gBankDefender].ability; - RecordAbilityBattle(gBankDefender, gLastUsedAbility); + gLastUsedAbility = gBattleMons[gBattleDefender].ability; + RecordAbilityBattle(gBattleDefender, gLastUsedAbility); } // took a while, but all checks passed and items can be safely swapped else { u16 oldItemAtk, *newItemAtk; - newItemAtk = &gBattleStruct->changedItems[gBankAttacker]; - oldItemAtk = gBattleMons[gBankAttacker].item; - *newItemAtk = gBattleMons[gBankDefender].item; + newItemAtk = &gBattleStruct->changedItems[gBattleAttacker]; + oldItemAtk = gBattleMons[gBattleAttacker].item; + *newItemAtk = gBattleMons[gBattleDefender].item; - gBattleMons[gBankAttacker].item = 0; - gBattleMons[gBankDefender].item = oldItemAtk; + gBattleMons[gBattleAttacker].item = 0; + gBattleMons[gBattleDefender].item = oldItemAtk; - gActiveBank = gBankAttacker; + gActiveBattler = gBattleAttacker; EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, newItemAtk); - MarkBufferBankForExecution(gBankAttacker); + MarkBufferBankForExecution(gBattleAttacker); - gActiveBank = gBankDefender; - EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBankDefender].item); - MarkBufferBankForExecution(gBankDefender); + gActiveBattler = gBattleDefender; + EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBattleDefender].item); + MarkBufferBankForExecution(gBattleDefender); - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankDefender]) + 0) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankDefender]) + 1) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleDefender]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleDefender]) + 1) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankAttacker]) + 0) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankAttacker]) + 1) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleAttacker]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleAttacker]) + 1) = 0; gBattlescriptCurrInstr += 5; @@ -9974,11 +9974,11 @@ static void atkD2_tryswapitems(void) // trick static void atkD3_trycopyability(void) // role play { - if (gBattleMons[gBankDefender].ability != 0 - && gBattleMons[gBankDefender].ability != ABILITY_WONDER_GUARD) + if (gBattleMons[gBattleDefender].ability != 0 + && gBattleMons[gBattleDefender].ability != ABILITY_WONDER_GUARD) { - gBattleMons[gBankAttacker].ability = gBattleMons[gBankDefender].ability; - gLastUsedAbility = gBattleMons[gBankDefender].ability; + gBattleMons[gBattleAttacker].ability = gBattleMons[gBattleDefender].ability; + gLastUsedAbility = gBattleMons[gBattleDefender].ability; gBattlescriptCurrInstr += 5; } else @@ -9992,10 +9992,10 @@ static void atkD4_trywish(void) switch (gBattlescriptCurrInstr[1]) { case 0: // use wish - if (gWishFutureKnock.wishCounter[gBankAttacker] == 0) + if (gWishFutureKnock.wishCounter[gBattleAttacker] == 0) { - gWishFutureKnock.wishCounter[gBankAttacker] = 2; - gWishFutureKnock.wishUserID[gBankAttacker] = gBattlePartyID[gBankAttacker]; + gWishFutureKnock.wishCounter[gBattleAttacker] = 2; + gWishFutureKnock.wishUserID[gBattleAttacker] = gBattlePartyID[gBattleAttacker]; gBattlescriptCurrInstr += 6; } else @@ -10004,14 +10004,14 @@ static void atkD4_trywish(void) } break; case 1: // heal effect - PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBankDefender, gWishFutureKnock.wishUserID[gBankDefender]) + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBattleDefender, gWishFutureKnock.wishUserID[gBattleDefender]) - gBattleMoveDamage = gBattleMons[gBankDefender].maxHP / 2; + gBattleMoveDamage = gBattleMons[gBattleDefender].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - if (gBattleMons[gBankDefender].hp == gBattleMons[gBankDefender].maxHP) + if (gBattleMons[gBattleDefender].hp == gBattleMons[gBattleDefender].maxHP) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); else gBattlescriptCurrInstr += 6; @@ -10022,23 +10022,23 @@ static void atkD4_trywish(void) static void atkD5_trysetroots(void) // ingrain { - if (gStatuses3[gBankAttacker] & STATUS3_ROOTED) + if (gStatuses3[gBattleAttacker] & STATUS3_ROOTED) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gStatuses3[gBankAttacker] |= STATUS3_ROOTED; + gStatuses3[gBattleAttacker] |= STATUS3_ROOTED; gBattlescriptCurrInstr += 5; } } static void atkD6_doubledamagedealtifdamaged(void) { - if ((gProtectStructs[gBankAttacker].physicalDmg - && gProtectStructs[gBankAttacker].physicalBank == gBankDefender) - || (gProtectStructs[gBankAttacker].specialDmg - && gProtectStructs[gBankAttacker].specialBank == gBankDefender)) + if ((gProtectStructs[gBattleAttacker].physicalDmg + && gProtectStructs[gBattleAttacker].physicalBank == gBattleDefender) + || (gProtectStructs[gBattleAttacker].specialDmg + && gProtectStructs[gBattleAttacker].specialBank == gBattleDefender)) { gBattleScripting.dmgMultiplier = 2; } @@ -10048,27 +10048,27 @@ static void atkD6_doubledamagedealtifdamaged(void) static void atkD7_setyawn(void) { - if (gStatuses3[gBankDefender] & STATUS3_YAWN - || gBattleMons[gBankDefender].status1 & STATUS1_ANY) + if (gStatuses3[gBattleDefender] & STATUS3_YAWN + || gBattleMons[gBattleDefender].status1 & STATUS1_ANY) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gStatuses3[gBankDefender] |= 0x1000; + gStatuses3[gBattleDefender] |= 0x1000; gBattlescriptCurrInstr += 5; } } static void atkD8_setdamagetohealthdifference(void) { - if (gBattleMons[gBankDefender].hp <= gBattleMons[gBankAttacker].hp) + if (gBattleMons[gBattleDefender].hp <= gBattleMons[gBattleAttacker].hp) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gBattleMoveDamage = gBattleMons[gBankDefender].hp - gBattleMons[gBankAttacker].hp; + gBattleMoveDamage = gBattleMons[gBattleDefender].hp - gBattleMons[gBattleAttacker].hp; gBattlescriptCurrInstr += 5; } } @@ -10078,7 +10078,7 @@ static void atkD9_scaledamagebyhealthratio(void) if (gDynamicBasePower == 0) { u8 power = gBattleMoves[gCurrentMove].power; - gDynamicBasePower = gBattleMons[gBankAttacker].hp * power / gBattleMons[gBankAttacker].maxHP; + gDynamicBasePower = gBattleMons[gBattleAttacker].hp * power / gBattleMons[gBattleAttacker].maxHP; if (gDynamicBasePower == 0) gDynamicBasePower = 1; } @@ -10087,19 +10087,19 @@ static void atkD9_scaledamagebyhealthratio(void) static void atkDA_tryswapabilities(void) // skill swap { - if ((gBattleMons[gBankAttacker].ability == 0 - && gBattleMons[gBankDefender].ability == 0) - || gBattleMons[gBankAttacker].ability == ABILITY_WONDER_GUARD - || gBattleMons[gBankDefender].ability == ABILITY_WONDER_GUARD + if ((gBattleMons[gBattleAttacker].ability == 0 + && gBattleMons[gBattleDefender].ability == 0) + || gBattleMons[gBattleAttacker].ability == ABILITY_WONDER_GUARD + || gBattleMons[gBattleDefender].ability == ABILITY_WONDER_GUARD || gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - u8 abilityAtk = gBattleMons[gBankAttacker].ability; - gBattleMons[gBankAttacker].ability = gBattleMons[gBankDefender].ability; - gBattleMons[gBankDefender].ability = abilityAtk; + u8 abilityAtk = gBattleMons[gBattleAttacker].ability; + gBattleMons[gBattleAttacker].ability = gBattleMons[gBattleDefender].ability; + gBattleMons[gBattleDefender].ability = abilityAtk; gBattlescriptCurrInstr += 5; } @@ -10107,7 +10107,7 @@ static void atkDA_tryswapabilities(void) // skill swap static void atkDB_tryimprision(void) { - if ((gStatuses3[gBankAttacker] & STATUS3_IMPRISONED_OTHERS)) + if ((gStatuses3[gBattleAttacker] & STATUS3_IMPRISONED_OTHERS)) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -10115,11 +10115,11 @@ static void atkDB_tryimprision(void) { u8 bank, sideAttacker; - sideAttacker = GetBankSide(gBankAttacker); - PressurePPLoseOnUsingImprision(gBankAttacker); - for (bank = 0; bank < gBattleBanksCount; bank++) + sideAttacker = GetBattlerSide(gBattleAttacker); + PressurePPLoseOnUsingImprision(gBattleAttacker); + for (bank = 0; bank < gBattlersCount; bank++) { - if (sideAttacker != GetBankSide(bank)) + if (sideAttacker != GetBattlerSide(bank)) { s32 attackerMoveId; for (attackerMoveId = 0; attackerMoveId < 4; attackerMoveId++) @@ -10127,8 +10127,8 @@ static void atkDB_tryimprision(void) s32 i; for (i = 0; i < 4; i++) { - if (gBattleMons[gBankAttacker].moves[attackerMoveId] == gBattleMons[bank].moves[i] - && gBattleMons[gBankAttacker].moves[attackerMoveId] != MOVE_NONE) + if (gBattleMons[gBattleAttacker].moves[attackerMoveId] == gBattleMons[bank].moves[i] + && gBattleMons[gBattleAttacker].moves[attackerMoveId] != MOVE_NONE) break; } if (i != 4) @@ -10136,26 +10136,26 @@ static void atkDB_tryimprision(void) } if (attackerMoveId != 4) { - gStatuses3[gBankAttacker] |= STATUS3_IMPRISONED_OTHERS; + gStatuses3[gBattleAttacker] |= STATUS3_IMPRISONED_OTHERS; gBattlescriptCurrInstr += 5; break; } } } - if (bank == gBattleBanksCount) // In Generation 3 games, Imprison fails if the user doesn't share any moves with any of the foes + if (bank == gBattlersCount) // In Generation 3 games, Imprison fails if the user doesn't share any moves with any of the foes gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } } static void atkDC_trysetgrudge(void) { - if (gStatuses3[gBankAttacker] & STATUS3_GRUDGE) + if (gStatuses3[gBattleAttacker] & STATUS3_GRUDGE) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gStatuses3[gBankAttacker] |= STATUS3_GRUDGE; + gStatuses3[gBattleAttacker] |= STATUS3_GRUDGE; gBattlescriptCurrInstr += 5; } } @@ -10165,7 +10165,7 @@ static void atkDD_weightdamagecalculation(void) s32 i; for (i = 0; sWeightToDamageTable[i] != 0xFFFF; i += 2) { - if (sWeightToDamageTable[i] > GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBankDefender].species), 1)) + if (sWeightToDamageTable[i] > GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBattleDefender].species), 1)) break; } @@ -10184,14 +10184,14 @@ static void atkDE_asistattackselect(void) s32 monId, moveId; u16* movesArray = gBattleStruct->assistPossibleMoves; - if (GET_BANK_SIDE(gBankAttacker) != SIDE_PLAYER) + if (GET_BATTLER_SIDE(gBattleAttacker) != B_SIDE_PLAYER) party = gEnemyParty; else party = gPlayerParty; for (monId = 0; monId < 6; monId++) { - if (monId == gBattlePartyID[gBankAttacker]) + if (monId == gBattlePartyID[gBattleAttacker]) continue; if (GetMonData(&party[monId], MON_DATA_SPECIES2) == SPECIES_NONE) continue; @@ -10221,7 +10221,7 @@ static void atkDE_asistattackselect(void) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gRandomMove = movesArray[((Random() & 0xFF) * chooseableMovesNo) >> 8]; - gBankDefender = GetMoveTarget(gRandomMove, 0); + gBattleDefender = GetMoveTarget(gRandomMove, 0); gBattlescriptCurrInstr += 5; } else @@ -10232,29 +10232,29 @@ static void atkDE_asistattackselect(void) static void atkDF_trysetmagiccoat(void) { - gBankDefender = gBankAttacker; - gSpecialStatuses[gBankAttacker].flag20 = 1; - if (gCurrentTurnActionNumber == gBattleBanksCount - 1) // moves last turn + gBattleDefender = gBattleAttacker; + gSpecialStatuses[gBattleAttacker].flag20 = 1; + if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gProtectStructs[gBankAttacker].bounceMove = 1; + gProtectStructs[gBattleAttacker].bounceMove = 1; gBattlescriptCurrInstr += 5; } } static void atkE0_trysetsnatch(void) // snatch { - gSpecialStatuses[gBankAttacker].flag20 = 1; - if (gCurrentTurnActionNumber == gBattleBanksCount - 1) // moves last turn + gSpecialStatuses[gBattleAttacker].flag20 = 1; + if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gProtectStructs[gBankAttacker].stealMove = 1; + gProtectStructs[gBattleAttacker].stealMove = 1; gBattlescriptCurrInstr += 5; } } @@ -10263,20 +10263,20 @@ static void atkE1_trygetintimidatetarget(void) { u8 side; - gBattleScripting.bank = gBattleStruct->intimidateBank; - side = GetBankSide(gBattleScripting.bank); + gBattleScripting.battler = gBattleStruct->intimidateBank; + side = GetBattlerSide(gBattleScripting.battler); - PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gBattleMons[gBattleScripting.bank].ability) + PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gBattleMons[gBattleScripting.battler].ability) - for (;gBankDefender < gBattleBanksCount; gBankDefender++) + for (;gBattleDefender < gBattlersCount; gBattleDefender++) { - if (GetBankSide(gBankDefender) == side) + if (GetBattlerSide(gBattleDefender) == side) continue; - if (!(gAbsentBankFlags & gBitTable[gBankDefender])) + if (!(gAbsentBattlerFlags & gBitTable[gBattleDefender])) break; } - if (gBankDefender >= gBattleBanksCount) + if (gBattleDefender >= gBattlersCount) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); else gBattlescriptCurrInstr += 5; @@ -10284,14 +10284,14 @@ static void atkE1_trygetintimidatetarget(void) static void atkE2_switchoutabilities(void) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); - switch (gBattleMons[gActiveBank].ability) + switch (gBattleMons[gActiveBattler].ability) { case ABILITY_NATURAL_CURE: - gBattleMons[gActiveBank].status1 = 0; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, gBitTable[*(gBattleStruct->field_58 + gActiveBank)], 4, &gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); + gBattleMons[gActiveBattler].status1 = 0; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, gBitTable[*(gBattleStruct->field_58 + gActiveBattler)], 4, &gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); break; } @@ -10300,9 +10300,9 @@ static void atkE2_switchoutabilities(void) static void atkE3_jumpifhasnohp(void) { - gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattleBank(gBattlescriptCurrInstr[1]); - if (gBattleMons[gActiveBank].hp == 0) + if (gBattleMons[gActiveBattler].hp == 0) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); else gBattlescriptCurrInstr += 6; @@ -10421,13 +10421,13 @@ static void atkE5_pickup(void) static void atkE6_docastformchangeanimation(void) { - gActiveBank = gBattleScripting.bank; + gActiveBattler = gBattleScripting.battler; - if (gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gActiveBattler].status2 & STATUS2_SUBSTITUTE) *(&gBattleStruct->formToChangeInto) |= 0x80; EmitBattleAnimation(0, B_ANIM_CASTFORM_CHANGE, gBattleStruct->formToChangeInto); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr++; } @@ -10437,7 +10437,7 @@ static void atkE7_trycastformdatachange(void) u8 form; gBattlescriptCurrInstr++; - form = CastformDataTypeChange(gBattleScripting.bank); + form = CastformDataTypeChange(gBattleScripting.battler); if (form) { BattleScriptPushCursorAndCallback(BattleScript_CastformChange); @@ -10451,18 +10451,18 @@ static void atkE8_settypebasedhalvers(void) // water and mud sport if (gBattleMoves[gCurrentMove].effect == EFFECT_MUD_SPORT) { - if (!(gStatuses3[gBankAttacker] & STATUS3_MUDSPORT)) + if (!(gStatuses3[gBattleAttacker] & STATUS3_MUDSPORT)) { - gStatuses3[gBankAttacker] |= STATUS3_MUDSPORT; + gStatuses3[gBattleAttacker] |= STATUS3_MUDSPORT; gBattleCommunication[MULTISTRING_CHOOSER] = 0; worked = TRUE; } } else // water sport { - if (!(gStatuses3[gBankAttacker] & STATUS3_WATERSPORT)) + if (!(gStatuses3[gBattleAttacker] & STATUS3_WATERSPORT)) { - gStatuses3[gBankAttacker] |= STATUS3_WATERSPORT; + gStatuses3[gBattleAttacker] |= STATUS3_WATERSPORT; gBattleCommunication[MULTISTRING_CHOOSER] = 1; worked = TRUE; } @@ -10499,16 +10499,16 @@ static void atkEA_tryrecycleitem(void) { u16 *usedHeldItem; - gActiveBank = gBankAttacker; - usedHeldItem = &gBattleStruct->usedHeldItems[gActiveBank]; - if (*usedHeldItem != 0 && gBattleMons[gActiveBank].item == 0) + gActiveBattler = gBattleAttacker; + usedHeldItem = &gBattleStruct->usedHeldItems[gActiveBattler]; + if (*usedHeldItem != 0 && gBattleMons[gActiveBattler].item == 0) { gLastUsedItem = *usedHeldItem; *usedHeldItem = 0; - gBattleMons[gActiveBank].item = gLastUsedItem; + gBattleMons[gActiveBattler].item = gLastUsedItem; - EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBank].item); - MarkBufferBankForExecution(gActiveBank); + EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gActiveBattler].item); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 5; } @@ -10520,11 +10520,11 @@ static void atkEA_tryrecycleitem(void) static void atkEB_settypetoterrain(void) { - if (gBattleMons[gBankAttacker].type1 != sTerrainToType[gBattleTerrain] - && gBattleMons[gBankAttacker].type2 != sTerrainToType[gBattleTerrain]) + if (gBattleMons[gBattleAttacker].type1 != sTerrainToType[gBattleTerrain] + && gBattleMons[gBattleAttacker].type2 != sTerrainToType[gBattleTerrain]) { - gBattleMons[gBankAttacker].type1 = sTerrainToType[gBattleTerrain]; - gBattleMons[gBankAttacker].type2 = sTerrainToType[gBattleTerrain]; + gBattleMons[gBattleAttacker].type1 = sTerrainToType[gBattleTerrain]; + gBattleMons[gBattleAttacker].type2 = sTerrainToType[gBattleTerrain]; PREPARE_TYPE_BUFFER(gBattleTextBuff1, sTerrainToType[gBattleTerrain]) @@ -10538,19 +10538,19 @@ static void atkEB_settypetoterrain(void) static void atkEC_pursuitrelated(void) { - gActiveBank = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_MON); + gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattleAttacker) ^ BIT_FLANK); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && !(gAbsentBankFlags & gBitTable[gActiveBank]) - && gActionForBanks[gActiveBank] == 0 - && gChosenMovesByBanks[gActiveBank] == MOVE_PURSUIT) + && !(gAbsentBattlerFlags & gBitTable[gActiveBattler]) + && gActionForBanks[gActiveBattler] == 0 + && gChosenMovesByBanks[gActiveBattler] == MOVE_PURSUIT) { - gActionsByTurnOrder[gActiveBank] = 11; + gActionsByTurnOrder[gActiveBattler] = 11; gCurrentMove = MOVE_PURSUIT; gBattlescriptCurrInstr += 5; gBattleScripting.animTurn = 1; - gBattleScripting.field_20 = gBankAttacker; - gBankAttacker = gActiveBank; + gBattleScripting.field_20 = gBattleAttacker; + gBattleAttacker = gActiveBattler; } else { @@ -10560,20 +10560,20 @@ static void atkEC_pursuitrelated(void) static void atkEF_snatchsetbanks(void) { - gEffectBank = gBankAttacker; + gEffectBank = gBattleAttacker; - if (gBankAttacker == gBankDefender) - gBankAttacker = gBankDefender = gBattleScripting.bank; + if (gBattleAttacker == gBattleDefender) + gBattleAttacker = gBattleDefender = gBattleScripting.battler; else - gBankDefender = gBattleScripting.bank; + gBattleDefender = gBattleScripting.battler; - gBattleScripting.bank = gEffectBank; + gBattleScripting.battler = gEffectBank; gBattlescriptCurrInstr++; } static void atkEE_removelightscreenreflect(void) // brick break { - u8 opposingSide = GetBankSide(gBankAttacker) ^ BIT_SIDE; + u8 opposingSide = GetBattlerSide(gBattleAttacker) ^ BIT_SIDE; if (gSideTimers[opposingSide].reflectTimer || gSideTimers[opposingSide].lightscreenTimer) { @@ -10600,19 +10600,19 @@ static void atkEF_handleballthrow(void) if (gBattleExecBuffer) return; - gActiveBank = gBankAttacker; - gBankDefender = gBankAttacker ^ BIT_SIDE; + gActiveBattler = gBattleAttacker; + gBattleDefender = gBattleAttacker ^ BIT_SIDE; if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { EmitBallThrowAnim(0, BALL_TRAINER_BLOCK); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr = BattleScript_TrainerBallBlock; } else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL) { EmitBallThrowAnim(0, BALL_3_SHAKES_SUCCESS); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr = BattleScript_WallyBallThrow; } else @@ -10623,17 +10623,17 @@ static void atkEF_handleballthrow(void) if (gLastUsedItem == ITEM_SAFARI_BALL) catchRate = gBattleStruct->field_7C * 1275 / 100; else - catchRate = gBaseStats[gBattleMons[gBankDefender].species].catchRate; + catchRate = gBaseStats[gBattleMons[gBattleDefender].species].catchRate; if (gLastUsedItem > ITEM_SAFARI_BALL) { switch (gLastUsedItem) { case ITEM_NET_BALL: - if (gBattleMons[gBankDefender].type1 == TYPE_WATER - || gBattleMons[gBankDefender].type2 == TYPE_WATER - || gBattleMons[gBankDefender].type1 == TYPE_BUG - || gBattleMons[gBankDefender].type2 == TYPE_BUG) + if (gBattleMons[gBattleDefender].type1 == TYPE_WATER + || gBattleMons[gBattleDefender].type2 == TYPE_WATER + || gBattleMons[gBattleDefender].type1 == TYPE_BUG + || gBattleMons[gBattleDefender].type2 == TYPE_BUG) ballMultiplier = 30; else ballMultiplier = 10; @@ -10645,9 +10645,9 @@ static void atkEF_handleballthrow(void) ballMultiplier = 10; break; case ITEM_NEST_BALL: - if (gBattleMons[gBankDefender].level < 40) + if (gBattleMons[gBattleDefender].level < 40) { - ballMultiplier = 40 - gBattleMons[gBankDefender].level; + ballMultiplier = 40 - gBattleMons[gBattleDefender].level; if (ballMultiplier <= 9) ballMultiplier = 10; } @@ -10657,7 +10657,7 @@ static void atkEF_handleballthrow(void) } break; case ITEM_REPEAT_BALL: - if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBankDefender].species), FLAG_GET_CAUGHT)) + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBattleDefender].species), FLAG_GET_CAUGHT)) ballMultiplier = 30; else ballMultiplier = 10; @@ -10677,12 +10677,12 @@ static void atkEF_handleballthrow(void) ballMultiplier = sBallCatchBonuses[gLastUsedItem - 2]; odds = (catchRate * ballMultiplier / 10) - * (gBattleMons[gBankDefender].maxHP * 3 - gBattleMons[gBankDefender].hp * 2) - / (3 * gBattleMons[gBankDefender].maxHP); + * (gBattleMons[gBattleDefender].maxHP * 3 - gBattleMons[gBattleDefender].hp * 2) + / (3 * gBattleMons[gBattleDefender].maxHP); - if (gBattleMons[gBankDefender].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) + if (gBattleMons[gBattleDefender].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) odds *= 2; - if (gBattleMons[gBankDefender].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)) + if (gBattleMons[gBattleDefender].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)) odds = (odds * 15) / 10; if (gLastUsedItem != ITEM_SAFARI_BALL) @@ -10701,9 +10701,9 @@ static void atkEF_handleballthrow(void) if (odds > 254) // mon caught { EmitBallThrowAnim(0, BALL_3_SHAKES_SUCCESS); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; - SetMonData(&gEnemyParty[gBattlePartyID[gBankDefender]], MON_DATA_POKEBALL, &gLastUsedItem); + SetMonData(&gEnemyParty[gBattlePartyID[gBattleDefender]], MON_DATA_POKEBALL, &gLastUsedItem); if (CalculatePlayerPartyCount() == 6) gBattleCommunication[MULTISTRING_CHOOSER] = 0; @@ -10723,12 +10723,12 @@ static void atkEF_handleballthrow(void) shakes = BALL_3_SHAKES_SUCCESS; // why calculate the shakes before that check? EmitBallThrowAnim(0, shakes); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); if (shakes == BALL_3_SHAKES_SUCCESS) // mon caught, copy of the code above { gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; - SetMonData(&gEnemyParty[gBattlePartyID[gBankDefender]], MON_DATA_POKEBALL, &gLastUsedItem); + SetMonData(&gEnemyParty[gBattlePartyID[gBattleDefender]], MON_DATA_POKEBALL, &gLastUsedItem); if (CalculatePlayerPartyCount() == 6) gBattleCommunication[MULTISTRING_CHOOSER] = 0; @@ -10746,18 +10746,18 @@ static void atkEF_handleballthrow(void) static void atkF0_givecaughtmon(void) { - if (GiveMonToPlayer(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]]) != MON_GIVEN_TO_PARTY) + if (GiveMonToPlayer(&gEnemyParty[gBattlePartyID[gBattleAttacker ^ BIT_SIDE]]) != MON_GIVEN_TO_PARTY) { if (!sub_813B21C()) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN))); - GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2); + GetMonData(&gEnemyParty[gBattlePartyID[gBattleAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2); } else { StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN))); - GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2); + GetMonData(&gEnemyParty[gBattlePartyID[gBattleAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2); StringCopy(gStringVar3, GetBoxNamePtr(get_unknown_box_id())); gBattleCommunication[MULTISTRING_CHOOSER] = 2; } @@ -10766,9 +10766,9 @@ static void atkF0_givecaughtmon(void) gBattleCommunication[MULTISTRING_CHOOSER]++; } - gBattleResults.caughtMonSpecies = GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_SPECIES, NULL); - GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleResults.caughtMonNick); - gBattleResults.caughtMonBall = GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_POKEBALL, NULL); + gBattleResults.caughtMonSpecies = GetMonData(&gEnemyParty[gBattlePartyID[gBattleAttacker ^ BIT_SIDE]], MON_DATA_SPECIES, NULL); + GetMonData(&gEnemyParty[gBattlePartyID[gBattleAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleResults.caughtMonNick); + gBattleResults.caughtMonBall = GetMonData(&gEnemyParty[gBattlePartyID[gBattleAttacker ^ BIT_SIDE]], MON_DATA_POKEBALL, NULL); gBattlescriptCurrInstr++; } @@ -10804,8 +10804,8 @@ static void atkF2_displaydexinfo(void) { FreeAllWindowBuffers(); gBattleCommunication[TASK_ID] = CreateDexDisplayMonDataTask(SpeciesToNationalPokedexNum(species), - gBattleMons[gBankDefender].otId, - gBattleMons[gBankDefender].personality); + gBattleMons[gBattleDefender].otId, + gBattleMons[gBattleDefender].personality); gBattleCommunication[0]++; } break; @@ -10956,13 +10956,13 @@ static void atkF3_trygivecaughtmonnick(void) case 2: if (!gPaletteFade.active) { - GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick); + GetMonData(&gEnemyParty[gBattlePartyID[gBattleAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick); FreeAllWindowBuffers(); DoNamingScreen(NAMING_SCREEN_CAUGHT_MON, gBattleStruct->caughtMonNick, - GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_SPECIES), - GetMonGender(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]]), - GetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_PERSONALITY, NULL), + GetMonData(&gEnemyParty[gBattlePartyID[gBattleAttacker ^ BIT_SIDE]], MON_DATA_SPECIES), + GetMonGender(&gEnemyParty[gBattlePartyID[gBattleAttacker ^ BIT_SIDE]]), + GetMonData(&gEnemyParty[gBattlePartyID[gBattleAttacker ^ BIT_SIDE]], MON_DATA_PERSONALITY, NULL), BattleMainCB2); gBattleCommunication[MULTIUSE_STATE]++; @@ -10971,7 +10971,7 @@ static void atkF3_trygivecaughtmonnick(void) case 3: if (gMain.callback2 == BattleMainCB2 && !gPaletteFade.active ) { - SetMonData(&gEnemyParty[gBattlePartyID[gBankAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick); + SetMonData(&gEnemyParty[gBattlePartyID[gBattleAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick); gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } break; @@ -10986,13 +10986,13 @@ static void atkF3_trygivecaughtmonnick(void) static void atkF4_subattackerhpbydmg(void) { - gBattleMons[gBankAttacker].hp -= gBattleMoveDamage; + gBattleMons[gBattleAttacker].hp -= gBattleMoveDamage; gBattlescriptCurrInstr++; } static void atkF5_removeattackerstatus1(void) { - gBattleMons[gBankAttacker].status1 = 0; + gBattleMons[gBattleAttacker].status1 = 0; gBattlescriptCurrInstr++; } @@ -11004,14 +11004,14 @@ static void atkF6_finishaction(void) static void atkF7_finishturn(void) { gCurrentActionFuncId = ACTION_FINISHED; - gCurrentTurnActionNumber = gBattleBanksCount; + gCurrentTurnActionNumber = gBattlersCount; } static void atkF8_trainerslideout(void) { - gActiveBank = GetBankByPosition(gBattlescriptCurrInstr[1]); + gActiveBattler = GetBattlerAtPosition(gBattlescriptCurrInstr[1]); EmitTrainerSlideBack(0); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); gBattlescriptCurrInstr += 2; } diff --git a/src/battle_util.c b/src/battle_util.c index 250976347..135f4f7f2 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -24,36 +24,36 @@ #include "berry.h" extern const u8* gBattlescriptCurrInstr; -extern const u8* gSelectionBattleScripts[BATTLE_BANKS_COUNT]; -extern const u8* gPalaceSelectionBattleScripts[BATTLE_BANKS_COUNT]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; -extern u8 gActiveBank; +extern const u8* gSelectionBattleScripts[MAX_BATTLERS_COUNT]; +extern const u8* gPalaceSelectionBattleScripts[MAX_BATTLERS_COUNT]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; +extern u8 gActiveBattler; extern u8 gStringBank; extern u16 gCurrentMove; extern u16 gLastUsedItem; -extern u8 gBattleBanksCount; -extern u32 gStatuses3[BATTLE_BANKS_COUNT]; -extern u8 gBankAttacker; -extern u8 gBankDefender; -extern u8 gAbsentBankFlags; +extern u8 gBattlersCount; +extern u32 gStatuses3[MAX_BATTLERS_COUNT]; +extern u8 gBattleAttacker; +extern u8 gBattleDefender; +extern u8 gAbsentBattlerFlags; extern u16 gBattleWeather; -extern u8 gBanksByTurnOrder[BATTLE_BANKS_COUNT]; +extern u8 gBattleTurnOrder[MAX_BATTLERS_COUNT]; extern u16 gSideStatuses[2]; extern u8 gBattleCommunication[]; extern void (*gBattleMainFunc)(void); extern s32 gBattleMoveDamage; -extern struct BattleEnigmaBerry gEnigmaBerries[BATTLE_BANKS_COUNT]; -extern u8 gBattleBufferB[BATTLE_BANKS_COUNT][0x200]; +extern struct BattleEnigmaBerry gEnigmaBerries[MAX_BATTLERS_COUNT]; +extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u32 gBattleTypeFlags; -extern u16 gLastMoves[BATTLE_BANKS_COUNT]; +extern u16 gLastMoves[MAX_BATTLERS_COUNT]; extern u32 gHitMarker; extern u8 gEffectBank; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u8 gBank1; -extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT]; +extern u16 gChosenMovesByBanks[MAX_BATTLERS_COUNT]; extern u8 gMoveResultFlags; -extern s32 gTakenDmg[BATTLE_BANKS_COUNT]; -extern u8 gTakenDmgBanks[BATTLE_BANKS_COUNT]; +extern s32 gTakenDmg[MAX_BATTLERS_COUNT]; +extern u8 gTakenDmgBanks[MAX_BATTLERS_COUNT]; extern u8 gLastUsedAbility; extern u8 gCurrentActionFuncId; extern u32 gBattleExecBuffer; @@ -79,10 +79,10 @@ u8 GetBattleBank(u8 caseId) switch (caseId) { case BS_GET_TARGET: - ret = gBankDefender; + ret = gBattleDefender; break; case BS_GET_ATTACKER: - ret = gBankAttacker; + ret = gBattleAttacker; break; case BS_GET_EFFECT_BANK: ret = gEffectBank; @@ -91,7 +91,7 @@ u8 GetBattleBank(u8 caseId) ret = 0; break; case BS_GET_SCRIPTING_BANK: - ret = gBattleScripting.bank; + ret = gBattleScripting.battler; break; case BS_GET_gBank1: ret = gBank1; @@ -104,113 +104,113 @@ u8 GetBattleBank(u8 caseId) case 8: case 9: case BS_GET_PLAYER1: - ret = GetBankByPosition(B_POSITION_PLAYER_LEFT); + ret = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); break; case BS_GET_OPPONENT1: - ret = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + ret = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); break; case BS_GET_PLAYER2: - ret = GetBankByPosition(B_POSITION_PLAYER_RIGHT); + ret = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); break; case BS_GET_OPPONENT2: - ret = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + ret = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); break; } return ret; } -void PressurePPLose(u8 bankDef, u8 bankAtk, u16 move) +void PressurePPLose(u8 defender, u8 attacker, u16 move) { s32 i; - if (gBattleMons[bankDef].ability != ABILITY_PRESSURE) + if (gBattleMons[defender].ability != ABILITY_PRESSURE) return; for (i = 0; i < 4; i++) { - if (gBattleMons[bankAtk].moves[i] == move) + if (gBattleMons[attacker].moves[i] == move) break; } if (i == 4) // mons don't share any moves return; - if (gBattleMons[bankAtk].pp[i] != 0) - gBattleMons[bankAtk].pp[i]--; + if (gBattleMons[attacker].pp[i] != 0) + gBattleMons[attacker].pp[i]--; - if (!(gBattleMons[bankAtk].status2 & STATUS2_TRANSFORMED) - && !(gDisableStructs[bankAtk].unk18_b & gBitTable[i])) + if (!(gBattleMons[attacker].status2 & STATUS2_TRANSFORMED) + && !(gDisableStructs[attacker].unk18_b & gBitTable[i])) { - gActiveBank = bankAtk; - EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + i, 0, 1, &gBattleMons[gActiveBank].pp[i]); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = attacker; + EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + i, 0, 1, &gBattleMons[gActiveBattler].pp[i]); + MarkBufferBankForExecution(gActiveBattler); } } -void PressurePPLoseOnUsingImprision(u8 bankAtk) +void PressurePPLoseOnUsingImprision(u8 attacker) { s32 i, j; s32 imprisionPos = 4; - u8 atkSide = GetBankSide(bankAtk); + u8 atkSide = GetBattlerSide(attacker); - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (atkSide != GetBankSide(i) && gBattleMons[i].ability == ABILITY_PRESSURE) + if (atkSide != GetBattlerSide(i) && gBattleMons[i].ability == ABILITY_PRESSURE) { for (j = 0; j < 4; j++) { - if (gBattleMons[bankAtk].moves[j] == MOVE_IMPRISON) + if (gBattleMons[attacker].moves[j] == MOVE_IMPRISON) break; } if (j != 4) { imprisionPos = j; - if (gBattleMons[bankAtk].pp[j] != 0) - gBattleMons[bankAtk].pp[j]--; + if (gBattleMons[attacker].pp[j] != 0) + gBattleMons[attacker].pp[j]--; } } } if (imprisionPos != 4 - && !(gBattleMons[bankAtk].status2 & STATUS2_TRANSFORMED) - && !(gDisableStructs[bankAtk].unk18_b & gBitTable[imprisionPos])) + && !(gBattleMons[attacker].status2 & STATUS2_TRANSFORMED) + && !(gDisableStructs[attacker].unk18_b & gBitTable[imprisionPos])) { - gActiveBank = bankAtk; - EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + imprisionPos, 0, 1, &gBattleMons[gActiveBank].pp[imprisionPos]); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = attacker; + EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + imprisionPos, 0, 1, &gBattleMons[gActiveBattler].pp[imprisionPos]); + MarkBufferBankForExecution(gActiveBattler); } } -void PressurePPLoseOnUsingPerishSong(u8 bankAtk) +void PressurePPLoseOnUsingPerishSong(u8 attacker) { s32 i, j; s32 perishSongPos = 4; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (gBattleMons[i].ability == ABILITY_PRESSURE && i != bankAtk) + if (gBattleMons[i].ability == ABILITY_PRESSURE && i != attacker) { for (j = 0; j < 4; j++) { - if (gBattleMons[bankAtk].moves[j] == MOVE_PERISH_SONG) + if (gBattleMons[attacker].moves[j] == MOVE_PERISH_SONG) break; } if (j != 4) { perishSongPos = j; - if (gBattleMons[bankAtk].pp[j] != 0) - gBattleMons[bankAtk].pp[j]--; + if (gBattleMons[attacker].pp[j] != 0) + gBattleMons[attacker].pp[j]--; } } } if (perishSongPos != 4 - && !(gBattleMons[bankAtk].status2 & STATUS2_TRANSFORMED) - && !(gDisableStructs[bankAtk].unk18_b & gBitTable[perishSongPos])) + && !(gBattleMons[attacker].status2 & STATUS2_TRANSFORMED) + && !(gDisableStructs[attacker].unk18_b & gBitTable[perishSongPos])) { - gActiveBank = bankAtk; - EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + perishSongPos, 0, 1, &gBattleMons[gActiveBank].pp[perishSongPos]); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = attacker; + EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + perishSongPos, 0, 1, &gBattleMons[gActiveBattler].pp[perishSongPos]); + MarkBufferBankForExecution(gActiveBattler); } } @@ -220,25 +220,25 @@ void MarkAllBufferBanksForExecution(void) // unused if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) gBattleExecBuffer |= gBitTable[i] << 0x1C; } else { - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) gBattleExecBuffer |= gBitTable[i]; } } -void MarkBufferBankForExecution(u8 bank) +void MarkBufferBankForExecution(u8 battler) { if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - gBattleExecBuffer |= gBitTable[bank] << 0x1C; + gBattleExecBuffer |= gBitTable[battler] << 0x1C; } else { - gBattleExecBuffer |= gBitTable[bank]; + gBattleExecBuffer |= gBitTable[battler]; } } @@ -252,40 +252,40 @@ void sub_803F850(u8 arg0) gBattleExecBuffer &= ~(0x10000000 << arg0); } -void CancelMultiTurnMoves(u8 bank) +void CancelMultiTurnMoves(u8 battler) { - gBattleMons[bank].status2 &= ~(STATUS2_MULTIPLETURNS); - gBattleMons[bank].status2 &= ~(STATUS2_LOCK_CONFUSE); - gBattleMons[bank].status2 &= ~(STATUS2_UPROAR); - gBattleMons[bank].status2 &= ~(STATUS2_BIDE); + gBattleMons[battler].status2 &= ~(STATUS2_MULTIPLETURNS); + gBattleMons[battler].status2 &= ~(STATUS2_LOCK_CONFUSE); + gBattleMons[battler].status2 &= ~(STATUS2_UPROAR); + gBattleMons[battler].status2 &= ~(STATUS2_BIDE); - gStatuses3[bank] &= ~(STATUS3_SEMI_INVULNERABLE); + gStatuses3[battler] &= ~(STATUS3_SEMI_INVULNERABLE); - gDisableStructs[bank].rolloutCounter1 = 0; - gDisableStructs[bank].furyCutterCounter = 0; + gDisableStructs[battler].rolloutCounter1 = 0; + gDisableStructs[battler].furyCutterCounter = 0; } -bool8 WasUnableToUseMove(u8 bank) +bool8 WasUnableToUseMove(u8 battler) { - if (gProtectStructs[bank].prlzImmobility - || gProtectStructs[bank].targetNotAffected - || gProtectStructs[bank].usedImprisionedMove - || gProtectStructs[bank].loveImmobility - || gProtectStructs[bank].usedDisabledMove - || gProtectStructs[bank].usedTauntedMove - || gProtectStructs[bank].flag2Unknown - || gProtectStructs[bank].flinchImmobility - || gProtectStructs[bank].confusionSelfDmg) + if (gProtectStructs[battler].prlzImmobility + || gProtectStructs[battler].targetNotAffected + || gProtectStructs[battler].usedImprisionedMove + || gProtectStructs[battler].loveImmobility + || gProtectStructs[battler].usedDisabledMove + || gProtectStructs[battler].usedTauntedMove + || gProtectStructs[battler].flag2Unknown + || gProtectStructs[battler].flinchImmobility + || gProtectStructs[battler].confusionSelfDmg) return TRUE; else return FALSE; } -void PrepareStringBattle(u16 stringId, u8 bank) +void PrepareStringBattle(u16 stringId, u8 battler) { - gActiveBank = bank; + gActiveBattler = battler; EmitPrintString(0, stringId); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); } void ResetSentPokesToOpponentValue(void) @@ -296,44 +296,44 @@ void ResetSentPokesToOpponentValue(void) gSentPokesToOpponent[0] = 0; gSentPokesToOpponent[1] = 0; - for (i = 0; i < gBattleBanksCount; i += 2) + for (i = 0; i < gBattlersCount; i += 2) bits |= gBitTable[gBattlePartyID[i]]; - for (i = 1; i < gBattleBanksCount; i += 2) - gSentPokesToOpponent[(i & BIT_MON) >> 1] = bits; + for (i = 1; i < gBattlersCount; i += 2) + gSentPokesToOpponent[(i & BIT_FLANK) >> 1] = bits; } -void sub_803F9EC(u8 bank) +void sub_803F9EC(u8 battler) { s32 i = 0; u32 bits = 0; - if (GetBankSide(bank) == SIDE_OPPONENT) + if (GetBattlerSide(battler) == B_SIDE_OPPONENT) { - u8 id = ((bank & BIT_MON) >> 1); - gSentPokesToOpponent[id] = 0; + u8 flank = ((battler & BIT_FLANK) >> 1); + gSentPokesToOpponent[flank] = 0; - for (i = 0; i < gBattleBanksCount; i += 2) + for (i = 0; i < gBattlersCount; i += 2) { - if (!(gAbsentBankFlags & gBitTable[i])) + if (!(gAbsentBattlerFlags & gBitTable[i])) bits |= gBitTable[gBattlePartyID[i]]; } - gSentPokesToOpponent[id] = bits; + gSentPokesToOpponent[flank] = bits; } } -void sub_803FA70(u8 bank) +void sub_803FA70(u8 battler) { - if (GetBankSide(bank) == SIDE_OPPONENT) + if (GetBattlerSide(battler) == B_SIDE_OPPONENT) { - sub_803F9EC(bank); + sub_803F9EC(battler); } else { s32 i; - for (i = 1; i < gBattleBanksCount; i++) - gSentPokesToOpponent[(i & BIT_MON) >> 1] |= gBitTable[gBattlePartyID[bank]]; + for (i = 1; i < gBattlersCount; i++) + gSentPokesToOpponent[(i & BIT_FLANK) >> 1] |= gBitTable[gBattlePartyID[battler]]; } } @@ -355,102 +355,102 @@ void BattleScriptPop(void) u8 TrySetCantSelectMoveBattleScript(void) { u8 limitations = 0; - u16 move = gBattleMons[gActiveBank].moves[gBattleBufferB[gActiveBank][2]]; + u16 move = gBattleMons[gActiveBattler].moves[gBattleBufferB[gActiveBattler][2]]; u8 holdEffect; - u16* choicedMove = &gBattleStruct->choicedMove[gActiveBank]; + u16* choicedMove = &gBattleStruct->choicedMove[gActiveBattler]; - if (gDisableStructs[gActiveBank].disabledMove == move && move != 0) + if (gDisableStructs[gActiveBattler].disabledMove == move && move != 0) { - gBattleScripting.bank = gActiveBank; + gBattleScripting.battler = gActiveBattler; gCurrentMove = move; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gPalaceSelectionBattleScripts[gActiveBank] = BattleScript_SelectingDisabledMoveInPalace; - gProtectStructs[gActiveBank].flag_x10 = 1; + gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingDisabledMoveInPalace; + gProtectStructs[gActiveBattler].flag_x10 = 1; } else { - gSelectionBattleScripts[gActiveBank] = BattleScript_SelectingDisabledMove; + gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingDisabledMove; limitations = 1; } } - if (move == gLastMoves[gActiveBank] && move != MOVE_STRUGGLE && (gBattleMons[gActiveBank].status2 & STATUS2_TORMENT)) + if (move == gLastMoves[gActiveBattler] && move != MOVE_STRUGGLE && (gBattleMons[gActiveBattler].status2 & STATUS2_TORMENT)) { - CancelMultiTurnMoves(gActiveBank); + CancelMultiTurnMoves(gActiveBattler); if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gPalaceSelectionBattleScripts[gActiveBank] = BattleScript_SelectingTormentedMoveInPalace; - gProtectStructs[gActiveBank].flag_x10 = 1; + gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingTormentedMoveInPalace; + gProtectStructs[gActiveBattler].flag_x10 = 1; } else { - gSelectionBattleScripts[gActiveBank] = BattleScript_SelectingTormentedMove; + gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingTormentedMove; limitations++; } } - if (gDisableStructs[gActiveBank].tauntTimer1 != 0 && gBattleMoves[move].power == 0) + if (gDisableStructs[gActiveBattler].tauntTimer1 != 0 && gBattleMoves[move].power == 0) { gCurrentMove = move; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gPalaceSelectionBattleScripts[gActiveBank] = BattleScript_SelectingNotAllowedMoveTauntInPalace; - gProtectStructs[gActiveBank].flag_x10 = 1; + gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveTauntInPalace; + gProtectStructs[gActiveBattler].flag_x10 = 1; } else { - gSelectionBattleScripts[gActiveBank] = BattleScript_SelectingNotAllowedMoveTaunt; + gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveTaunt; limitations++; } } - if (GetImprisonedMovesCount(gActiveBank, move)) + if (GetImprisonedMovesCount(gActiveBattler, move)) { gCurrentMove = move; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gPalaceSelectionBattleScripts[gActiveBank] = BattleScript_SelectingImprisionedMoveInPalace; - gProtectStructs[gActiveBank].flag_x10 = 1; + gPalaceSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisionedMoveInPalace; + gProtectStructs[gActiveBattler].flag_x10 = 1; } else { - gSelectionBattleScripts[gActiveBank] = BattleScript_SelectingImprisionedMove; + gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingImprisionedMove; limitations++; } } - if (gBattleMons[gActiveBank].item == ITEM_ENIGMA_BERRY) - holdEffect = gEnigmaBerries[gActiveBank].holdEffect; + if (gBattleMons[gActiveBattler].item == ITEM_ENIGMA_BERRY) + holdEffect = gEnigmaBerries[gActiveBattler].holdEffect; else - holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBank].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item); - gStringBank = gActiveBank; + gStringBank = gActiveBattler; if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != move) { gCurrentMove = *choicedMove; - gLastUsedItem = gBattleMons[gActiveBank].item; + gLastUsedItem = gBattleMons[gActiveBattler].item; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gProtectStructs[gActiveBank].flag_x10 = 1; + gProtectStructs[gActiveBattler].flag_x10 = 1; } else { - gSelectionBattleScripts[gActiveBank] = BattleScript_SelectingNotAllowedMoveChoiceItem; + gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingNotAllowedMoveChoiceItem; limitations++; } } - if (gBattleMons[gActiveBank].pp[gBattleBufferB[gActiveBank][2]] == 0) + if (gBattleMons[gActiveBattler].pp[gBattleBufferB[gActiveBattler][2]] == 0) { if (gBattleTypeFlags & BATTLE_TYPE_PALACE) { - gProtectStructs[gActiveBank].flag_x10 = 1; + gProtectStructs[gActiveBattler].flag_x10 = 1; } else { - gSelectionBattleScripts[gActiveBank] = BattleScript_SelectingMoveWithNoPP; + gSelectionBattleScripts[gActiveBattler] = BattleScript_SelectingMoveWithNoPP; limitations++; } } @@ -471,7 +471,7 @@ u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check) gStringBank = bank; - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { if (gBattleMons[bank].moves[i] == 0 && check & MOVE_LIMITATION_ZEROMOVE) unusableMoves |= gBitTable[i]; @@ -496,16 +496,16 @@ u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check) bool8 AreAllMovesUnusable(void) { u8 unusable; - unusable = CheckMoveLimitations(gActiveBank, 0, 0xFF); + unusable = CheckMoveLimitations(gActiveBattler, 0, 0xFF); if (unusable == 0xF) // all moves are unusable { - gProtectStructs[gActiveBank].onlyStruggle = 1; - gSelectionBattleScripts[gActiveBank] = BattleScript_NoMovesLeft; + gProtectStructs[gActiveBattler].onlyStruggle = 1; + gSelectionBattleScripts[gActiveBattler] = BattleScript_NoMovesLeft; } else { - gProtectStructs[gActiveBank].onlyStruggle = 0; + gProtectStructs[gActiveBattler].onlyStruggle = 0; } return (unusable == 0xF); @@ -515,11 +515,11 @@ u8 GetImprisonedMovesCount(u8 bank, u16 move) { s32 i; u8 imprisionedMoves = 0; - u8 bankSide = GetBankSide(bank); + u8 bankSide = GetBattlerSide(bank); - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (bankSide != GetBankSide(i) && gStatuses3[i] & STATUS3_IMPRISONED_OTHERS) + if (bankSide != GetBattlerSide(i) && gStatuses3[i] & STATUS3_IMPRISONED_OTHERS) { s32 j; for (j = 0; j < 4; j++) @@ -540,10 +540,10 @@ u8 UpdateTurnCounters(void) u8 effect = 0; s32 i; - for (gBankAttacker = 0; gBankAttacker < gBattleBanksCount && gAbsentBankFlags & gBitTable[gBankAttacker]; gBankAttacker++) + for (gBattleAttacker = 0; gBattleAttacker < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattleAttacker]; gBattleAttacker++) { } - for (gBankDefender = 0; gBankDefender < gBattleBanksCount && gAbsentBankFlags & gBitTable[gBankDefender]; gBankDefender++) + for (gBattleDefender = 0; gBattleDefender < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattleDefender]; gBattleDefender++) { } @@ -554,16 +554,16 @@ u8 UpdateTurnCounters(void) switch (gBattleStruct->turncountersTracker) { case 0: - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - gBanksByTurnOrder[i] = i; + gBattleTurnOrder[i] = i; } - for (i = 0; i < gBattleBanksCount - 1; i++) + for (i = 0; i < gBattlersCount - 1; i++) { s32 j; - for (j = i + 1; j < gBattleBanksCount; j++) + for (j = i + 1; j < gBattlersCount; j++) { - if (GetWhoStrikesFirst(gBanksByTurnOrder[i], gBanksByTurnOrder[j], 0)) + if (GetWhoStrikesFirst(gBattleTurnOrder[i], gBattleTurnOrder[j], 0)) SwapTurnOrder(i, j); } } @@ -579,7 +579,7 @@ u8 UpdateTurnCounters(void) while (gBattleStruct->turnSideTracker < 2) { sideBank = gBattleStruct->turnSideTracker; - gActiveBank = gBankAttacker = gSideTimers[sideBank].reflectBank; + gActiveBattler = gBattleAttacker = gSideTimers[sideBank].reflectBank; if (gSideStatuses[sideBank] & SIDE_STATUS_REFLECT) { if (--gSideTimers[sideBank].reflectTimer == 0) @@ -604,7 +604,7 @@ u8 UpdateTurnCounters(void) while (gBattleStruct->turnSideTracker < 2) { sideBank = gBattleStruct->turnSideTracker; - gActiveBank = gBankAttacker = gSideTimers[sideBank].lightscreenBank; + gActiveBattler = gBattleAttacker = gSideTimers[sideBank].lightscreenBank; if (gSideStatuses[sideBank] & SIDE_STATUS_LIGHTSCREEN) { if (--gSideTimers[sideBank].lightscreenTimer == 0) @@ -630,7 +630,7 @@ u8 UpdateTurnCounters(void) while (gBattleStruct->turnSideTracker < 2) { sideBank = gBattleStruct->turnSideTracker; - gActiveBank = gBankAttacker = gSideTimers[sideBank].mistBank; + gActiveBattler = gBattleAttacker = gSideTimers[sideBank].mistBank; if (gSideTimers[sideBank].mistTimer != 0 && --gSideTimers[sideBank].mistTimer == 0) { @@ -654,7 +654,7 @@ u8 UpdateTurnCounters(void) while (gBattleStruct->turnSideTracker < 2) { sideBank = gBattleStruct->turnSideTracker; - gActiveBank = gBankAttacker = gSideTimers[sideBank].safeguardBank; + gActiveBattler = gBattleAttacker = gSideTimers[sideBank].safeguardBank; if (gSideStatuses[sideBank] & SIDE_STATUS_SAFEGUARD) { if (--gSideTimers[sideBank].safeguardTimer == 0) @@ -675,14 +675,14 @@ u8 UpdateTurnCounters(void) } break; case 5: - while (gBattleStruct->turnSideTracker < gBattleBanksCount) + while (gBattleStruct->turnSideTracker < gBattlersCount) { - gActiveBank = gBanksByTurnOrder[gBattleStruct->turnSideTracker]; - if (gWishFutureKnock.wishCounter[gActiveBank] != 0 - && --gWishFutureKnock.wishCounter[gActiveBank] == 0 - && gBattleMons[gActiveBank].hp != 0) + gActiveBattler = gBattleTurnOrder[gBattleStruct->turnSideTracker]; + if (gWishFutureKnock.wishCounter[gActiveBattler] != 0 + && --gWishFutureKnock.wishCounter[gActiveBattler] == 0 + && gBattleMons[gActiveBattler].hp != 0) { - gBankDefender = gActiveBank; + gBattleDefender = gActiveBattler; BattleScriptExecute(BattleScript_WishComesTrue); effect++; } @@ -798,10 +798,10 @@ u8 TurnBasedEffects(void) u8 effect = 0; gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_x20); - while (gBattleStruct->turnEffectsBank < gBattleBanksCount && gBattleStruct->turnEffectsTracker <= TURNBASED_MAX_CASE) + while (gBattleStruct->turnEffectsBank < gBattlersCount && gBattleStruct->turnEffectsTracker <= TURNBASED_MAX_CASE) { - gActiveBank = gBankAttacker = gBanksByTurnOrder[gBattleStruct->turnEffectsBank]; - if (gAbsentBankFlags & gBitTable[gActiveBank]) + gActiveBattler = gBattleAttacker = gBattleTurnOrder[gBattleStruct->turnEffectsBank]; + if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) { gBattleStruct->turnEffectsBank++; } @@ -810,11 +810,11 @@ u8 TurnBasedEffects(void) switch (gBattleStruct->turnEffectsTracker) { case 0: // ingrain - if ((gStatuses3[gActiveBank] & STATUS3_ROOTED) - && gBattleMons[gActiveBank].hp != gBattleMons[gActiveBank].maxHP - && gBattleMons[gActiveBank].hp != 0) + if ((gStatuses3[gActiveBattler] & STATUS3_ROOTED) + && gBattleMons[gActiveBattler].hp != gBattleMons[gActiveBattler].maxHP + && gBattleMons[gActiveBattler].hp != 0) { - gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 16; + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; @@ -824,40 +824,40 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 1: // end turn abilities - if (AbilityBattleEffects(ABILITYEFFECT_ENDTURN, gActiveBank, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_ENDTURN, gActiveBattler, 0, 0, 0)) effect++; gBattleStruct->turnEffectsTracker++; break; case 2: // item effects - if (ItemBattleEffects(1, gActiveBank, 0)) + if (ItemBattleEffects(1, gActiveBattler, 0)) effect++; gBattleStruct->turnEffectsTracker++; break; case 18: // item effects again - if (ItemBattleEffects(1, gActiveBank, 1)) + if (ItemBattleEffects(1, gActiveBattler, 1)) effect++; gBattleStruct->turnEffectsTracker++; break; case 3: // leech seed - if ((gStatuses3[gActiveBank] & STATUS3_LEECHSEED) - && gBattleMons[gStatuses3[gActiveBank] & STATUS3_LEECHSEED_BANK].hp != 0 - && gBattleMons[gActiveBank].hp != 0) + if ((gStatuses3[gActiveBattler] & STATUS3_LEECHSEED) + && gBattleMons[gStatuses3[gActiveBattler] & STATUS3_LEECHSEED_BANK].hp != 0 + && gBattleMons[gActiveBattler].hp != 0) { - gBankDefender = gStatuses3[gActiveBank] & STATUS3_LEECHSEED_BANK; //funny how the 'target' is actually the bank that receives HP - gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; + gBattleDefender = gStatuses3[gActiveBattler] & STATUS3_LEECHSEED_BANK; //funny how the 'target' is actually the bank that receives HP + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - gBattleScripting.animArg1 = gBankDefender; - gBattleScripting.animArg2 = gBankAttacker; + gBattleScripting.animArg1 = gBattleDefender; + gBattleScripting.animArg2 = gBattleAttacker; BattleScriptExecute(BattleScript_LeechSeedTurnDrain); effect++; } gBattleStruct->turnEffectsTracker++; break; case 4: // poison - if ((gBattleMons[gActiveBank].status1 & STATUS1_POISON) && gBattleMons[gActiveBank].hp != 0) + if ((gBattleMons[gActiveBattler].status1 & STATUS1_POISON) && gBattleMons[gActiveBattler].hp != 0) { - gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; BattleScriptExecute(BattleScript_PoisonTurnDmg); @@ -866,23 +866,23 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 5: // toxic poison - if ((gBattleMons[gActiveBank].status1 & STATUS1_TOXIC_POISON) && gBattleMons[gActiveBank].hp != 0) + if ((gBattleMons[gActiveBattler].status1 & STATUS1_TOXIC_POISON) && gBattleMons[gActiveBattler].hp != 0) { - gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 16; + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - if ((gBattleMons[gActiveBank].status1 & 0xF00) != 0xF00) // not 16 turns - gBattleMons[gActiveBank].status1 += 0x100; - gBattleMoveDamage *= (gBattleMons[gActiveBank].status1 & 0xF00) >> 8; + if ((gBattleMons[gActiveBattler].status1 & 0xF00) != 0xF00) // not 16 turns + gBattleMons[gActiveBattler].status1 += 0x100; + gBattleMoveDamage *= (gBattleMons[gActiveBattler].status1 & 0xF00) >> 8; BattleScriptExecute(BattleScript_PoisonTurnDmg); effect++; } gBattleStruct->turnEffectsTracker++; break; case 6: // burn - if ((gBattleMons[gActiveBank].status1 & STATUS1_BURN) && gBattleMons[gActiveBank].hp != 0) + if ((gBattleMons[gActiveBattler].status1 & STATUS1_BURN) && gBattleMons[gActiveBattler].hp != 0) { - gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; BattleScriptExecute(BattleScript_BurnTurnDmg); @@ -891,13 +891,13 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 7: // spooky nightmares - if ((gBattleMons[gActiveBank].status2 & STATUS2_NIGHTMARE) && gBattleMons[gActiveBank].hp != 0) + if ((gBattleMons[gActiveBattler].status2 & STATUS2_NIGHTMARE) && gBattleMons[gActiveBattler].hp != 0) { // R/S does not perform this sleep check, which causes the nighmare effect to // persist even after the affected Pokemon has been awakened by Shed Skin - if (gBattleMons[gActiveBank].status1 & STATUS1_SLEEP) + if (gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) { - gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 4; + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; BattleScriptExecute(BattleScript_NightmareTurnDmg); @@ -905,15 +905,15 @@ u8 TurnBasedEffects(void) } else { - gBattleMons[gActiveBank].status2 &= ~STATUS2_NIGHTMARE; + gBattleMons[gActiveBattler].status2 &= ~STATUS2_NIGHTMARE; } } gBattleStruct->turnEffectsTracker++; break; case 8: // curse - if ((gBattleMons[gActiveBank].status2 & STATUS2_CURSED) && gBattleMons[gActiveBank].hp != 0) + if ((gBattleMons[gActiveBattler].status2 & STATUS2_CURSED) && gBattleMons[gActiveBattler].hp != 0) { - gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 4; + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; BattleScriptExecute(BattleScript_CurseTurnDmg); @@ -922,21 +922,21 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 9: // wrap - if ((gBattleMons[gActiveBank].status2 & STATUS2_WRAPPED) && gBattleMons[gActiveBank].hp != 0) + if ((gBattleMons[gActiveBattler].status2 & STATUS2_WRAPPED) && gBattleMons[gActiveBattler].hp != 0) { - gBattleMons[gActiveBank].status2 -= 0x2000; - if (gBattleMons[gActiveBank].status2 & STATUS2_WRAPPED) // damaged by wrap + gBattleMons[gActiveBattler].status2 -= 0x2000; + if (gBattleMons[gActiveBattler].status2 & STATUS2_WRAPPED) // damaged by wrap { // This is the only way I could get this array access to match. - gBattleScripting.animArg1 = *(gBattleStruct->wrappedMove + gActiveBank * 2 + 0); - gBattleScripting.animArg2 = *(gBattleStruct->wrappedMove + gActiveBank * 2 + 1); + gBattleScripting.animArg1 = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 0); + gBattleScripting.animArg2 = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 1); gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN; gBattleTextBuff1[1] = B_BUFF_MOVE; - gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gActiveBank * 2 + 0); - gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gActiveBank * 2 + 1); + gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 0); + gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 1); gBattleTextBuff1[4] = EOS; gBattlescriptCurrInstr = BattleScript_WrapTurnDmg; - gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 16; + gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; } @@ -944,8 +944,8 @@ u8 TurnBasedEffects(void) { gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN; gBattleTextBuff1[1] = B_BUFF_MOVE; - gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gActiveBank * 2 + 0); - gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gActiveBank * 2 + 1); + gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 0); + gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gActiveBattler * 2 + 1); gBattleTextBuff1[4] = EOS; gBattlescriptCurrInstr = BattleScript_WrapEnds; } @@ -955,46 +955,46 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 10: // uproar - if (gBattleMons[gActiveBank].status2 & STATUS2_UPROAR) + if (gBattleMons[gActiveBattler].status2 & STATUS2_UPROAR) { - for (gBankAttacker = 0; gBankAttacker < gBattleBanksCount; gBankAttacker++) + for (gBattleAttacker = 0; gBattleAttacker < gBattlersCount; gBattleAttacker++) { - if ((gBattleMons[gBankAttacker].status1 & STATUS1_SLEEP) - && gBattleMons[gBankAttacker].ability != ABILITY_SOUNDPROOF) + if ((gBattleMons[gBattleAttacker].status1 & STATUS1_SLEEP) + && gBattleMons[gBattleAttacker].ability != ABILITY_SOUNDPROOF) { - gBattleMons[gBankAttacker].status1 &= ~(STATUS1_SLEEP); - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattleAttacker].status1 &= ~(STATUS1_SLEEP); + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_NIGHTMARE); gBattleCommunication[MULTISTRING_CHOOSER] = 1; BattleScriptExecute(BattleScript_MonWokeUpInUproar); - gActiveBank = gBankAttacker; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = gBattleAttacker; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); break; } } - if (gBankAttacker != gBattleBanksCount) + if (gBattleAttacker != gBattlersCount) { effect = 2; // a pokemon was awaken break; } else { - gBankAttacker = gActiveBank; - gBattleMons[gActiveBank].status2 -= 0x10; // uproar timer goes down - if (WasUnableToUseMove(gActiveBank)) + gBattleAttacker = gActiveBattler; + gBattleMons[gActiveBattler].status2 -= 0x10; // uproar timer goes down + if (WasUnableToUseMove(gActiveBattler)) { - CancelMultiTurnMoves(gActiveBank); + CancelMultiTurnMoves(gActiveBattler); gBattleCommunication[MULTISTRING_CHOOSER] = 1; } - else if (gBattleMons[gActiveBank].status2 & STATUS2_UPROAR) + else if (gBattleMons[gActiveBattler].status2 & STATUS2_UPROAR) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; - gBattleMons[gActiveBank].status2 |= STATUS2_MULTIPLETURNS; + gBattleMons[gActiveBattler].status2 |= STATUS2_MULTIPLETURNS; } else { gBattleCommunication[MULTISTRING_CHOOSER] = 1; - CancelMultiTurnMoves(gActiveBank); + CancelMultiTurnMoves(gActiveBattler); } BattleScriptExecute(BattleScript_PrintUproarOverTurns); effect = 1; @@ -1004,20 +1004,20 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 11: // thrash - if (gBattleMons[gActiveBank].status2 & STATUS2_LOCK_CONFUSE) + if (gBattleMons[gActiveBattler].status2 & STATUS2_LOCK_CONFUSE) { - gBattleMons[gActiveBank].status2 -= 0x400; - if (WasUnableToUseMove(gActiveBank)) - CancelMultiTurnMoves(gActiveBank); - else if (!(gBattleMons[gActiveBank].status2 & STATUS2_LOCK_CONFUSE) - && (gBattleMons[gActiveBank].status2 & STATUS2_MULTIPLETURNS)) + gBattleMons[gActiveBattler].status2 -= 0x400; + if (WasUnableToUseMove(gActiveBattler)) + CancelMultiTurnMoves(gActiveBattler); + else if (!(gBattleMons[gActiveBattler].status2 & STATUS2_LOCK_CONFUSE) + && (gBattleMons[gActiveBattler].status2 & STATUS2_MULTIPLETURNS)) { - gBattleMons[gActiveBank].status2 &= ~(STATUS2_MULTIPLETURNS); - if (!(gBattleMons[gActiveBank].status2 & STATUS2_CONFUSION)) + gBattleMons[gActiveBattler].status2 &= ~(STATUS2_MULTIPLETURNS); + if (!(gBattleMons[gActiveBattler].status2 & STATUS2_CONFUSION)) { gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_CONFUSION | MOVE_EFFECT_AFFECTS_USER; SetMoveEffect(1, 0); - if (gBattleMons[gActiveBank].status2 & STATUS2_CONFUSION) + if (gBattleMons[gActiveBattler].status2 & STATUS2_CONFUSION) BattleScriptExecute(BattleScript_ThrashConfuses); effect++; } @@ -1026,22 +1026,22 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 12: // disable - if (gDisableStructs[gActiveBank].disableTimer1 != 0) + if (gDisableStructs[gActiveBattler].disableTimer1 != 0) { int i; for (i = 0; i < 4; i++) { - if (gDisableStructs[gActiveBank].disabledMove == gBattleMons[gActiveBank].moves[i]) + if (gDisableStructs[gActiveBattler].disabledMove == gBattleMons[gActiveBattler].moves[i]) break; } if (i == 4) // pokemon does not have the disabled move anymore { - gDisableStructs[gActiveBank].disabledMove = 0; - gDisableStructs[gActiveBank].disableTimer1 = 0; + gDisableStructs[gActiveBattler].disabledMove = 0; + gDisableStructs[gActiveBattler].disableTimer1 = 0; } - else if (--gDisableStructs[gActiveBank].disableTimer1 == 0) // disable ends + else if (--gDisableStructs[gActiveBattler].disableTimer1 == 0) // disable ends { - gDisableStructs[gActiveBank].disabledMove = 0; + gDisableStructs[gActiveBattler].disabledMove = 0; BattleScriptExecute(BattleScript_DisabledNoMore); effect++; } @@ -1049,18 +1049,18 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 13: // encore - if (gDisableStructs[gActiveBank].encoreTimer1 != 0) + if (gDisableStructs[gActiveBattler].encoreTimer1 != 0) { - if (gBattleMons[gActiveBank].moves[gDisableStructs[gActiveBank].encoredMovePos] != gDisableStructs[gActiveBank].encoredMove) // pokemon does not have the encored move anymore + if (gBattleMons[gActiveBattler].moves[gDisableStructs[gActiveBattler].encoredMovePos] != gDisableStructs[gActiveBattler].encoredMove) // pokemon does not have the encored move anymore { - gDisableStructs[gActiveBank].encoredMove = 0; - gDisableStructs[gActiveBank].encoreTimer1 = 0; + gDisableStructs[gActiveBattler].encoredMove = 0; + gDisableStructs[gActiveBattler].encoreTimer1 = 0; } - else if (--gDisableStructs[gActiveBank].encoreTimer1 == 0 - || gBattleMons[gActiveBank].pp[gDisableStructs[gActiveBank].encoredMovePos] == 0) + else if (--gDisableStructs[gActiveBattler].encoreTimer1 == 0 + || gBattleMons[gActiveBattler].pp[gDisableStructs[gActiveBattler].encoredMovePos] == 0) { - gDisableStructs[gActiveBank].encoredMove = 0; - gDisableStructs[gActiveBank].encoreTimer1 = 0; + gDisableStructs[gActiveBattler].encoredMove = 0; + gDisableStructs[gActiveBattler].encoreTimer1 = 0; BattleScriptExecute(BattleScript_EncoredNoMore); effect++; } @@ -1068,33 +1068,33 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 14: // lock-on decrement - if (gStatuses3[gActiveBank] & STATUS3_ALWAYS_HITS) - gStatuses3[gActiveBank] -= 0x8; + if (gStatuses3[gActiveBattler] & STATUS3_ALWAYS_HITS) + gStatuses3[gActiveBattler] -= 0x8; gBattleStruct->turnEffectsTracker++; break; case 15: // charge - if (gDisableStructs[gActiveBank].chargeTimer1 && --gDisableStructs[gActiveBank].chargeTimer1 == 0) - gStatuses3[gActiveBank] &= ~STATUS3_CHARGED_UP; + if (gDisableStructs[gActiveBattler].chargeTimer1 && --gDisableStructs[gActiveBattler].chargeTimer1 == 0) + gStatuses3[gActiveBattler] &= ~STATUS3_CHARGED_UP; gBattleStruct->turnEffectsTracker++; break; case 16: // taunt - if (gDisableStructs[gActiveBank].tauntTimer1) - gDisableStructs[gActiveBank].tauntTimer1--; + if (gDisableStructs[gActiveBattler].tauntTimer1) + gDisableStructs[gActiveBattler].tauntTimer1--; gBattleStruct->turnEffectsTracker++; break; case 17: // yawn - if (gStatuses3[gActiveBank] & STATUS3_YAWN) + if (gStatuses3[gActiveBattler] & STATUS3_YAWN) { - gStatuses3[gActiveBank] -= 0x800; - if (!(gStatuses3[gActiveBank] & STATUS3_YAWN) && !(gBattleMons[gActiveBank].status1 & STATUS1_ANY) - && gBattleMons[gActiveBank].ability != ABILITY_VITAL_SPIRIT - && gBattleMons[gActiveBank].ability != ABILITY_INSOMNIA && !UproarWakeUpCheck(gActiveBank)) + gStatuses3[gActiveBattler] -= 0x800; + if (!(gStatuses3[gActiveBattler] & STATUS3_YAWN) && !(gBattleMons[gActiveBattler].status1 & STATUS1_ANY) + && gBattleMons[gActiveBattler].ability != ABILITY_VITAL_SPIRIT + && gBattleMons[gActiveBattler].ability != ABILITY_INSOMNIA && !UproarWakeUpCheck(gActiveBattler)) { - CancelMultiTurnMoves(gActiveBank); - gBattleMons[gActiveBank].status1 |= (Random() & 3) + 2; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); - gEffectBank = gActiveBank; + CancelMultiTurnMoves(gActiveBattler); + gBattleMons[gActiveBattler].status1 |= (Random() & 3) + 2; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); + gEffectBank = gActiveBattler; BattleScriptExecute(BattleScript_YawnMakesAsleep); effect++; } @@ -1121,37 +1121,37 @@ bool8 HandleWishPerishSongOnTurnEnd(void) switch (gBattleStruct->wishPerishSongState) { case 0: - while (gBattleStruct->wishPerishSongBank < gBattleBanksCount) + while (gBattleStruct->wishPerishSongBank < gBattlersCount) { - gActiveBank = gBattleStruct->wishPerishSongBank; - if (gAbsentBankFlags & gBitTable[gActiveBank]) + gActiveBattler = gBattleStruct->wishPerishSongBank; + if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) { gBattleStruct->wishPerishSongBank++; continue; } gBattleStruct->wishPerishSongBank++; - if (gWishFutureKnock.futureSightCounter[gActiveBank] != 0 - && --gWishFutureKnock.futureSightCounter[gActiveBank] == 0 - && gBattleMons[gActiveBank].hp != 0) + if (gWishFutureKnock.futureSightCounter[gActiveBattler] != 0 + && --gWishFutureKnock.futureSightCounter[gActiveBattler] == 0 + && gBattleMons[gActiveBattler].hp != 0) { - if (gWishFutureKnock.futureSightMove[gActiveBank] == MOVE_FUTURE_SIGHT) + if (gWishFutureKnock.futureSightMove[gActiveBattler] == MOVE_FUTURE_SIGHT) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gWishFutureKnock.futureSightMove[gActiveBank]); + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gWishFutureKnock.futureSightMove[gActiveBattler]); - gBankDefender = gActiveBank; - gBankAttacker = gWishFutureKnock.futureSightAttacker[gActiveBank]; - gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBank]; - gSpecialStatuses[gBankDefender].moveturnLostHP = 0xFFFF; + gBattleDefender = gActiveBattler; + gBattleAttacker = gWishFutureKnock.futureSightAttacker[gActiveBattler]; + gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBattler]; + gSpecialStatuses[gBattleDefender].moveturnLostHP = 0xFFFF; BattleScriptExecute(BattleScript_MonTookFutureAttack); - if (gWishFutureKnock.futureSightCounter[gActiveBank] == 0 - && gWishFutureKnock.futureSightCounter[gActiveBank ^ BIT_MON] == 0) + if (gWishFutureKnock.futureSightCounter[gActiveBattler] == 0 + && gWishFutureKnock.futureSightCounter[gActiveBattler ^ BIT_FLANK] == 0) { - gSideStatuses[GET_BANK_SIDE(gBankDefender)] &= ~(SIDE_STATUS_FUTUREATTACK); + gSideStatuses[GET_BATTLER_SIDE(gBattleDefender)] &= ~(SIDE_STATUS_FUTUREATTACK); } return TRUE; } @@ -1164,27 +1164,27 @@ bool8 HandleWishPerishSongOnTurnEnd(void) } // fall through case 1: - while (gBattleStruct->wishPerishSongBank < gBattleBanksCount) + while (gBattleStruct->wishPerishSongBank < gBattlersCount) { - gActiveBank = gBankAttacker = gBanksByTurnOrder[gBattleStruct->wishPerishSongBank]; - if (gAbsentBankFlags & gBitTable[gActiveBank]) + gActiveBattler = gBattleAttacker = gBattleTurnOrder[gBattleStruct->wishPerishSongBank]; + if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) { gBattleStruct->wishPerishSongBank++; continue; } gBattleStruct->wishPerishSongBank++; - if (gStatuses3[gActiveBank] & STATUS3_PERISH_SONG) + if (gStatuses3[gActiveBattler] & STATUS3_PERISH_SONG) { - PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gActiveBank].perishSongTimer1); - if (gDisableStructs[gActiveBank].perishSongTimer1 == 0) + PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gActiveBattler].perishSongTimer1); + if (gDisableStructs[gActiveBattler].perishSongTimer1 == 0) { - gStatuses3[gActiveBank] &= ~STATUS3_PERISH_SONG; - gBattleMoveDamage = gBattleMons[gActiveBank].hp; + gStatuses3[gActiveBattler] &= ~STATUS3_PERISH_SONG; + gBattleMoveDamage = gBattleMons[gActiveBattler].hp; gBattlescriptCurrInstr = BattleScript_PerishSongTakesLife; } else { - gDisableStructs[gActiveBank].perishSongTimer1--; + gDisableStructs[gActiveBattler].perishSongTimer1--; gBattlescriptCurrInstr = BattleScript_PerishSongCountGoesDown; } BattleScriptExecute(gBattlescriptCurrInstr); @@ -1235,30 +1235,30 @@ bool8 HandleFaintedMonActions(void) case 0: gBattleStruct->faintedActionsBank = 0; gBattleStruct->faintedActionsState++; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (gAbsentBankFlags & gBitTable[i] && !sub_80423F4(i, 6, 6)) - gAbsentBankFlags &= ~(gBitTable[i]); + if (gAbsentBattlerFlags & gBitTable[i] && !sub_80423F4(i, 6, 6)) + gAbsentBattlerFlags &= ~(gBitTable[i]); } // fall through case 1: do { - gBank1 = gBankDefender = gBattleStruct->faintedActionsBank; + gBank1 = gBattleDefender = gBattleStruct->faintedActionsBank; if (gBattleMons[gBattleStruct->faintedActionsBank].hp == 0 && !(gBattleStruct->field_DF & gBitTable[gBattlePartyID[gBattleStruct->faintedActionsBank]]) - && !(gAbsentBankFlags & gBitTable[gBattleStruct->faintedActionsBank])) + && !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBank])) { BattleScriptExecute(BattleScript_GiveExp); gBattleStruct->faintedActionsState = 2; return TRUE; } - } while (++gBattleStruct->faintedActionsBank != gBattleBanksCount); + } while (++gBattleStruct->faintedActionsBank != gBattlersCount); gBattleStruct->faintedActionsState = 3; break; case 2: sub_803F9EC(gBank1); - if (++gBattleStruct->faintedActionsBank == gBattleBanksCount) + if (++gBattleStruct->faintedActionsBank == gBattlersCount) gBattleStruct->faintedActionsState = 3; else gBattleStruct->faintedActionsState = 1; @@ -1270,19 +1270,19 @@ bool8 HandleFaintedMonActions(void) case 4: do { - gBank1 = gBankDefender = gBattleStruct->faintedActionsBank; + gBank1 = gBattleDefender = gBattleStruct->faintedActionsBank; if (gBattleMons[gBattleStruct->faintedActionsBank].hp == 0 - && !(gAbsentBankFlags & gBitTable[gBattleStruct->faintedActionsBank])) + && !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBank])) { BattleScriptExecute(BattleScript_HandleFaintedMon); gBattleStruct->faintedActionsState = 5; return TRUE; } - } while (++gBattleStruct->faintedActionsBank != gBattleBanksCount); + } while (++gBattleStruct->faintedActionsBank != gBattlersCount); gBattleStruct->faintedActionsState = 6; break; case 5: - if (++gBattleStruct->faintedActionsBank == gBattleBanksCount) + if (++gBattleStruct->faintedActionsBank == gBattlersCount) gBattleStruct->faintedActionsState = 6; else gBattleStruct->faintedActionsState = 4; @@ -1302,7 +1302,7 @@ bool8 HandleFaintedMonActions(void) void TryClearRageStatuses(void) { int i; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if ((gBattleMons[i].status2 & STATUS2_RAGE) && gChosenMovesByBanks[i] != MOVE_RAGE) gBattleMons[i].status2 &= ~(STATUS2_RAGE); @@ -1320,17 +1320,17 @@ u8 AtkCanceller_UnableToUseMove(void) switch (gBattleStruct->atkCancellerTracker) { case 0: // flags clear - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_DESTINY_BOND); - gStatuses3[gBankAttacker] &= ~(STATUS3_GRUDGE); + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_DESTINY_BOND); + gStatuses3[gBattleAttacker] &= ~(STATUS3_GRUDGE); gBattleStruct->atkCancellerTracker++; break; case 1: // check being asleep - if (gBattleMons[gBankAttacker].status1 & STATUS1_SLEEP) + if (gBattleMons[gBattleAttacker].status1 & STATUS1_SLEEP) { - if (UproarWakeUpCheck(gBankAttacker)) + if (UproarWakeUpCheck(gBattleAttacker)) { - gBattleMons[gBankAttacker].status1 &= ~(STATUS1_SLEEP); - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattleAttacker].status1 &= ~(STATUS1_SLEEP); + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_NIGHTMARE); BattleScriptPushCursor(); gBattleCommunication[MULTISTRING_CHOOSER] = 1; gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp; @@ -1339,15 +1339,15 @@ u8 AtkCanceller_UnableToUseMove(void) else { u8 toSub; - if (gBattleMons[gBankAttacker].ability == ABILITY_EARLY_BIRD) + if (gBattleMons[gBattleAttacker].ability == ABILITY_EARLY_BIRD) toSub = 2; else toSub = 1; - if ((gBattleMons[gBankAttacker].status1 & STATUS1_SLEEP) < toSub) - gBattleMons[gBankAttacker].status1 &= ~(STATUS1_SLEEP); + if ((gBattleMons[gBattleAttacker].status1 & STATUS1_SLEEP) < toSub) + gBattleMons[gBattleAttacker].status1 &= ~(STATUS1_SLEEP); else - gBattleMons[gBankAttacker].status1 -= toSub; - if (gBattleMons[gBankAttacker].status1 & STATUS1_SLEEP) + gBattleMons[gBattleAttacker].status1 -= toSub; + if (gBattleMons[gBattleAttacker].status1 & STATUS1_SLEEP) { if (gCurrentMove != MOVE_SNORE && gCurrentMove != MOVE_SLEEP_TALK) { @@ -1358,7 +1358,7 @@ u8 AtkCanceller_UnableToUseMove(void) } else { - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_NIGHTMARE); BattleScriptPushCursor(); gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp; @@ -1369,7 +1369,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 2: // check being frozen - if (gBattleMons[gBankAttacker].status1 & STATUS1_FREEZE) + if (gBattleMons[gBattleAttacker].status1 & STATUS1_FREEZE) { if (Random() % 5) { @@ -1386,7 +1386,7 @@ u8 AtkCanceller_UnableToUseMove(void) } else // unfreeze { - gBattleMons[gBankAttacker].status1 &= ~(STATUS1_FREEZE); + gBattleMons[gBattleAttacker].status1 &= ~(STATUS1_FREEZE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; gBattleCommunication[MULTISTRING_CHOOSER] = 0; @@ -1396,9 +1396,9 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 3: // truant - if (gBattleMons[gBankAttacker].ability == ABILITY_TRUANT && gDisableStructs[gBankAttacker].truantCounter) + if (gBattleMons[gBattleAttacker].ability == ABILITY_TRUANT && gDisableStructs[gBattleAttacker].truantCounter) { - CancelMultiTurnMoves(gBankAttacker); + CancelMultiTurnMoves(gBattleAttacker); gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround; @@ -1408,11 +1408,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 4: // recharge - if (gBattleMons[gBankAttacker].status2 & STATUS2_RECHARGE) + if (gBattleMons[gBattleAttacker].status2 & STATUS2_RECHARGE) { - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_RECHARGE); - gDisableStructs[gBankAttacker].rechargeCounter = 0; - CancelMultiTurnMoves(gBankAttacker); + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_RECHARGE); + gDisableStructs[gBattleAttacker].rechargeCounter = 0; + CancelMultiTurnMoves(gBattleAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedMustRecharge; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1420,11 +1420,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 5: // flinch - if (gBattleMons[gBankAttacker].status2 & STATUS2_FLINCHED) + if (gBattleMons[gBattleAttacker].status2 & STATUS2_FLINCHED) { - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_FLINCHED); - gProtectStructs[gBankAttacker].flinchImmobility = 1; - CancelMultiTurnMoves(gBankAttacker); + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_FLINCHED); + gProtectStructs[gBattleAttacker].flinchImmobility = 1; + CancelMultiTurnMoves(gBattleAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedFlinched; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1432,11 +1432,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 6: // disabled move - if (gDisableStructs[gBankAttacker].disabledMove == gCurrentMove && gDisableStructs[gBankAttacker].disabledMove != 0) + if (gDisableStructs[gBattleAttacker].disabledMove == gCurrentMove && gDisableStructs[gBattleAttacker].disabledMove != 0) { - gProtectStructs[gBankAttacker].usedDisabledMove = 1; - gBattleScripting.bank = gBankAttacker; - CancelMultiTurnMoves(gBankAttacker); + gProtectStructs[gBattleAttacker].usedDisabledMove = 1; + gBattleScripting.battler = gBattleAttacker; + CancelMultiTurnMoves(gBattleAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsDisabled; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1444,10 +1444,10 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 7: // taunt - if (gDisableStructs[gBankAttacker].tauntTimer1 && gBattleMoves[gCurrentMove].power == 0) + if (gDisableStructs[gBattleAttacker].tauntTimer1 && gBattleMoves[gCurrentMove].power == 0) { - gProtectStructs[gBankAttacker].usedTauntedMove = 1; - CancelMultiTurnMoves(gBankAttacker); + gProtectStructs[gBattleAttacker].usedTauntedMove = 1; + CancelMultiTurnMoves(gBattleAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsTaunted; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1455,10 +1455,10 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 8: // imprisoned - if (GetImprisonedMovesCount(gBankAttacker, gCurrentMove)) + if (GetImprisonedMovesCount(gBattleAttacker, gCurrentMove)) { - gProtectStructs[gBankAttacker].usedImprisionedMove = 1; - CancelMultiTurnMoves(gBankAttacker); + gProtectStructs[gBattleAttacker].usedImprisionedMove = 1; + CancelMultiTurnMoves(gBattleAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsImprisoned; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1466,10 +1466,10 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 9: // confusion - if (gBattleMons[gBankAttacker].status2 & STATUS2_CONFUSION) + if (gBattleMons[gBattleAttacker].status2 & STATUS2_CONFUSION) { - gBattleMons[gBankAttacker].status2--; - if (gBattleMons[gBankAttacker].status2 & STATUS2_CONFUSION) + gBattleMons[gBattleAttacker].status2--; + if (gBattleMons[gBattleAttacker].status2 & STATUS2_CONFUSION) { if (Random() & 1) { @@ -1479,9 +1479,9 @@ u8 AtkCanceller_UnableToUseMove(void) else // confusion dmg { gBattleCommunication[MULTISTRING_CHOOSER] = 1; - gBankDefender = gBankAttacker; - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankAttacker], MOVE_POUND, 0, 40, 0, gBankAttacker, gBankAttacker); - gProtectStructs[gBankAttacker].confusionSelfDmg = 1; + gBattleDefender = gBattleAttacker; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattleAttacker], &gBattleMons[gBattleAttacker], MOVE_POUND, 0, 40, 0, gBattleAttacker, gBattleAttacker); + gProtectStructs[gBattleAttacker].confusionSelfDmg = 1; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; } gBattlescriptCurrInstr = BattleScript_MoveUsedIsConfused; @@ -1496,11 +1496,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 10: // paralysis - if ((gBattleMons[gBankAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0) + if ((gBattleMons[gBattleAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0) { - gProtectStructs[gBankAttacker].prlzImmobility = 1; + gProtectStructs[gBattleAttacker].prlzImmobility = 1; // This is removed in Emerald for some reason - //CancelMultiTurnMoves(gBankAttacker); + //CancelMultiTurnMoves(gBattleAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1508,17 +1508,17 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 11: // infatuation - if (gBattleMons[gBankAttacker].status2 & STATUS2_INFATUATION) + if (gBattleMons[gBattleAttacker].status2 & STATUS2_INFATUATION) { - gBattleScripting.bank = CountTrailingZeroBits((gBattleMons[gBankAttacker].status2 & STATUS2_INFATUATION) >> 0x10); + gBattleScripting.battler = CountTrailingZeroBits((gBattleMons[gBattleAttacker].status2 & STATUS2_INFATUATION) >> 0x10); if (Random() & 1) BattleScriptPushCursor(); else { BattleScriptPush(BattleScript_MoveUsedIsParalyzedCantAttack); gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; - gProtectStructs[gBankAttacker].loveImmobility = 1; - CancelMultiTurnMoves(gBankAttacker); + gProtectStructs[gBattleAttacker].loveImmobility = 1; + CancelMultiTurnMoves(gBattleAttacker); } gBattlescriptCurrInstr = BattleScript_MoveUsedIsInLove; effect = 1; @@ -1526,22 +1526,22 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 12: // bide - if (gBattleMons[gBankAttacker].status2 & STATUS2_BIDE) + if (gBattleMons[gBattleAttacker].status2 & STATUS2_BIDE) { - gBattleMons[gBankAttacker].status2 -= 0x100; - if (gBattleMons[gBankAttacker].status2 & STATUS2_BIDE) + gBattleMons[gBattleAttacker].status2 -= 0x100; + if (gBattleMons[gBattleAttacker].status2 & STATUS2_BIDE) gBattlescriptCurrInstr = BattleScript_BideStoringEnergy; else { // This is removed in Emerald for some reason - //gBattleMons[gBankAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); - if (gTakenDmg[gBankAttacker]) + //gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); + if (gTakenDmg[gBattleAttacker]) { gCurrentMove = MOVE_BIDE; - *bideDmg = gTakenDmg[gBankAttacker] * 2; - gBankDefender = gTakenDmgBanks[gBankAttacker]; - if (gAbsentBankFlags & gBitTable[gBankDefender]) - gBankDefender = GetMoveTarget(MOVE_BIDE, 1); + *bideDmg = gTakenDmg[gBattleAttacker] * 2; + gBattleDefender = gTakenDmgBanks[gBattleAttacker]; + if (gAbsentBattlerFlags & gBitTable[gBattleDefender]) + gBattleDefender = GetMoveTarget(MOVE_BIDE, 1); gBattlescriptCurrInstr = BattleScript_BideAttack; } else @@ -1552,11 +1552,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 13: // move thawing - if (gBattleMons[gBankAttacker].status1 & STATUS1_FREEZE) + if (gBattleMons[gBattleAttacker].status1 & STATUS1_FREEZE) { if (gBattleMoves[gCurrentMove].effect == EFFECT_THAW_HIT) { - gBattleMons[gBankAttacker].status1 &= ~(STATUS1_FREEZE); + gBattleMons[gBattleAttacker].status1 &= ~(STATUS1_FREEZE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -1573,14 +1573,14 @@ u8 AtkCanceller_UnableToUseMove(void) if (effect == 2) { - gActiveBank = gBankAttacker; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = gBattleAttacker; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); } return effect; } -bool8 sub_80423F4(u8 bank, u8 r1, u8 r2) +bool8 sub_80423F4(u8 battler, u8 r1, u8 r2) { struct Pokemon* party; u8 r7; @@ -1590,11 +1590,11 @@ bool8 sub_80423F4(u8 bank, u8 r1, u8 r2) return FALSE; if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) { - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(battler) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; - r6 = ((bank & 2) / 2); + r6 = ((battler & 2) / 2); for (i = r6 * 3; i < r6 * 3 + 3; i++) { if (GetMonData(&party[i], MON_DATA_HP) != 0 @@ -1608,10 +1608,10 @@ bool8 sub_80423F4(u8 bank, u8 r1, u8 r2) { if (gBattleTypeFlags & BATTLE_TYPE_x800000) { - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(battler) == B_SIDE_PLAYER) { party = gPlayerParty; - r7 = GetBankMultiplayerId(bank); + r7 = GetBankMultiplayerId(battler); r6 = sub_806D82C(r7); } else @@ -1624,14 +1624,14 @@ bool8 sub_80423F4(u8 bank, u8 r1, u8 r2) #endif // NONMATCHING party = gEnemyParty; - var = bank ^ 1; + var = battler ^ 1; r6 = (var != 0) ? 1 : 0; } } else { - r7 = GetBankMultiplayerId(bank); - if (GetBankSide(bank) == SIDE_PLAYER) + r7 = GetBankMultiplayerId(battler); + if (GetBattlerSide(battler) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -1646,11 +1646,11 @@ bool8 sub_80423F4(u8 bank, u8 r1, u8 r2) } return (i == r6 * 3 + 3); } - else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) && GetBankSide(bank) == SIDE_OPPONENT) + else if ((gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) && GetBattlerSide(battler) == B_SIDE_OPPONENT) { party = gEnemyParty; - if (bank == 1) + if (battler == 1) r6 = 0; else r6 = 3; @@ -1665,16 +1665,16 @@ bool8 sub_80423F4(u8 bank, u8 r1, u8 r2) } else { - if (GetBankSide(bank) == SIDE_OPPONENT) + if (GetBattlerSide(battler) == B_SIDE_OPPONENT) { - r7 = GetBankByPosition(B_POSITION_OPPONENT_LEFT); - r6 = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + r7 = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + r6 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); party = gEnemyParty; } else { - r7 = GetBankByPosition(B_POSITION_PLAYER_LEFT); - r6 = GetBankByPosition(B_POSITION_PLAYER_RIGHT); + r7 = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + r6 = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); party = gPlayerParty; } if (r1 == 6) @@ -1703,48 +1703,48 @@ enum CASTFORM_TO_ICE, //4 }; -u8 CastformDataTypeChange(u8 bank) +u8 CastformDataTypeChange(u8 battler) { u8 formChange = 0; - if (gBattleMons[bank].species != SPECIES_CASTFORM || gBattleMons[bank].ability != ABILITY_FORECAST || gBattleMons[bank].hp == 0) + if (gBattleMons[battler].species != SPECIES_CASTFORM || gBattleMons[battler].ability != ABILITY_FORECAST || gBattleMons[battler].hp == 0) return CASTFORM_NO_CHANGE; - if (!WEATHER_HAS_EFFECT && gBattleMons[bank].type1 != TYPE_NORMAL && gBattleMons[bank].type2 != TYPE_NORMAL) + if (!WEATHER_HAS_EFFECT && gBattleMons[battler].type1 != TYPE_NORMAL && gBattleMons[battler].type2 != TYPE_NORMAL) { - gBattleMons[bank].type1 = TYPE_NORMAL; - gBattleMons[bank].type2 = TYPE_NORMAL; + gBattleMons[battler].type1 = TYPE_NORMAL; + gBattleMons[battler].type2 = TYPE_NORMAL; return CASTFORM_TO_NORMAL; } if (!WEATHER_HAS_EFFECT) return CASTFORM_NO_CHANGE; - if (!(gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SUN_ANY | WEATHER_HAIL)) && gBattleMons[bank].type1 != TYPE_NORMAL && gBattleMons[bank].type2 != TYPE_NORMAL) + if (!(gBattleWeather & (WEATHER_RAIN_ANY | WEATHER_SUN_ANY | WEATHER_HAIL)) && gBattleMons[battler].type1 != TYPE_NORMAL && gBattleMons[battler].type2 != TYPE_NORMAL) { - gBattleMons[bank].type1 = TYPE_NORMAL; - gBattleMons[bank].type2 = TYPE_NORMAL; + gBattleMons[battler].type1 = TYPE_NORMAL; + gBattleMons[battler].type2 = TYPE_NORMAL; formChange = CASTFORM_TO_NORMAL; } - if (gBattleWeather & WEATHER_SUN_ANY && gBattleMons[bank].type1 != TYPE_FIRE && gBattleMons[bank].type2 != TYPE_FIRE) + if (gBattleWeather & WEATHER_SUN_ANY && gBattleMons[battler].type1 != TYPE_FIRE && gBattleMons[battler].type2 != TYPE_FIRE) { - gBattleMons[bank].type1 = TYPE_FIRE; - gBattleMons[bank].type2 = TYPE_FIRE; + gBattleMons[battler].type1 = TYPE_FIRE; + gBattleMons[battler].type2 = TYPE_FIRE; formChange = CASTFORM_TO_FIRE; } - if (gBattleWeather & WEATHER_RAIN_ANY && gBattleMons[bank].type1 != TYPE_WATER && gBattleMons[bank].type2 != TYPE_WATER) + if (gBattleWeather & WEATHER_RAIN_ANY && gBattleMons[battler].type1 != TYPE_WATER && gBattleMons[battler].type2 != TYPE_WATER) { - gBattleMons[bank].type1 = TYPE_WATER; - gBattleMons[bank].type2 = TYPE_WATER; + gBattleMons[battler].type1 = TYPE_WATER; + gBattleMons[battler].type2 = TYPE_WATER; formChange = CASTFORM_TO_WATER; } - if (gBattleWeather & WEATHER_HAIL && gBattleMons[bank].type1 != TYPE_ICE && gBattleMons[bank].type2 != TYPE_ICE) + if (gBattleWeather & WEATHER_HAIL && gBattleMons[battler].type1 != TYPE_ICE && gBattleMons[battler].type2 != TYPE_ICE) { - gBattleMons[bank].type1 = TYPE_ICE; - gBattleMons[bank].type2 = TYPE_ICE; + gBattleMons[battler].type1 = TYPE_ICE; + gBattleMons[battler].type2 = TYPE_ICE; formChange = CASTFORM_TO_ICE; } return formChange; } // The largest function in the game, but even it could not save itself from decompiling. -u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) +u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveArg) { u8 effect = 0; struct Pokemon *pokeAtk; @@ -1754,19 +1754,19 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) u32 pidAtk; u32 pidDef; - if (gBankAttacker >= gBattleBanksCount) - gBankAttacker = bank; - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) - pokeAtk = &gPlayerParty[gBattlePartyID[gBankAttacker]]; + if (gBattleAttacker >= gBattlersCount) + gBattleAttacker = battler; + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) + pokeAtk = &gPlayerParty[gBattlePartyID[gBattleAttacker]]; else - pokeAtk = &gEnemyParty[gBattlePartyID[gBankAttacker]]; + pokeAtk = &gEnemyParty[gBattlePartyID[gBattleAttacker]]; - if (gBankDefender >= gBattleBanksCount) - gBankDefender = bank; - if (GetBankSide(gBankDefender) == SIDE_PLAYER) - pokeDef = &gPlayerParty[gBattlePartyID[gBankDefender]]; + if (gBattleDefender >= gBattlersCount) + gBattleDefender = battler; + if (GetBattlerSide(gBattleDefender) == B_SIDE_PLAYER) + pokeDef = &gPlayerParty[gBattlePartyID[gBattleDefender]]; else - pokeDef = &gEnemyParty[gBattlePartyID[gBankDefender]]; + pokeDef = &gEnemyParty[gBattlePartyID[gBattleDefender]]; speciesAtk = GetMonData(pokeAtk, MON_DATA_SPECIES); pidAtk = GetMonData(pokeAtk, MON_DATA_PERSONALITY); @@ -1785,7 +1785,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (special) gLastUsedAbility = special; else - gLastUsedAbility = gBattleMons[bank].ability; + gLastUsedAbility = gBattleMons[battler].ability; if (moveArg) move = moveArg; @@ -1797,8 +1797,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) switch (caseID) { case ABILITYEFFECT_ON_SWITCHIN: // 0 - if (gBankAttacker >= gBattleBanksCount) - gBankAttacker = bank; + if (gBattleAttacker >= gBattlersCount) + gBattleAttacker = battler; switch (gLastUsedAbility) { case ABILITYEFFECT_SWITCH_IN_WEATHER: @@ -1813,7 +1813,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleWeather = (WEATHER_RAIN_TEMPORARY | WEATHER_RAIN_PERMANENT); gBattleScripting.animArg1 = B_ANIM_RAIN_CONTINUES; - gBattleScripting.bank = bank; + gBattleScripting.battler = battler; effect++; } break; @@ -1822,7 +1822,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleWeather = (WEATHER_SANDSTORM_PERMANENT | WEATHER_SANDSTORM_TEMPORARY); gBattleScripting.animArg1 = B_ANIM_SANDSTORM_CONTINUES; - gBattleScripting.bank = bank; + gBattleScripting.battler = battler; effect++; } break; @@ -1831,7 +1831,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleWeather = (WEATHER_SUN_PERMANENT | WEATHER_SUN_TEMPORARY); gBattleScripting.animArg1 = B_ANIM_SUN_CONTINUES; - gBattleScripting.bank = bank; + gBattleScripting.battler = battler; effect++; } break; @@ -1848,7 +1848,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleWeather = (WEATHER_RAIN_PERMANENT | WEATHER_RAIN_TEMPORARY); BattleScriptPushCursorAndCallback(BattleScript_DrizzleActivates); - gBattleScripting.bank = bank; + gBattleScripting.battler = battler; effect++; } break; @@ -1857,7 +1857,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleWeather = (WEATHER_SANDSTORM_PERMANENT | WEATHER_SANDSTORM_TEMPORARY); BattleScriptPushCursorAndCallback(BattleScript_SandstreamActivates); - gBattleScripting.bank = bank; + gBattleScripting.battler = battler; effect++; } break; @@ -1866,44 +1866,44 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { gBattleWeather = (WEATHER_SUN_PERMANENT | WEATHER_SUN_TEMPORARY); BattleScriptPushCursorAndCallback(BattleScript_DroughtActivates); - gBattleScripting.bank = bank; + gBattleScripting.battler = battler; effect++; } break; case ABILITY_INTIMIDATE: - if (!(gSpecialStatuses[bank].intimidatedPoke)) + if (!(gSpecialStatuses[battler].intimidatedPoke)) { - gStatuses3[bank] |= STATUS3_INTIMIDATE_POKES; - gSpecialStatuses[bank].intimidatedPoke = 1; + gStatuses3[battler] |= STATUS3_INTIMIDATE_POKES; + gSpecialStatuses[battler].intimidatedPoke = 1; } break; case ABILITY_FORECAST: - effect = CastformDataTypeChange(bank); + effect = CastformDataTypeChange(battler); if (effect != 0) { BattleScriptPushCursorAndCallback(BattleScript_CastformChange); - gBattleScripting.bank = bank; + gBattleScripting.battler = battler; *(&gBattleStruct->formToChangeInto) = effect - 1; } break; case ABILITY_TRACE: - if (!(gSpecialStatuses[bank].traced)) + if (!(gSpecialStatuses[battler].traced)) { - gStatuses3[bank] |= STATUS3_TRACE; - gSpecialStatuses[bank].traced = 1; + gStatuses3[battler] |= STATUS3_TRACE; + gSpecialStatuses[battler].traced = 1; } break; case ABILITY_CLOUD_NINE: case ABILITY_AIR_LOCK: { - // that's a weird choice for a variable, why not use i or bank? - for (target1 = 0; target1 < gBattleBanksCount; target1++) + // that's a weird choice for a variable, why not use i or battler? + for (target1 = 0; target1 < gBattlersCount; target1++) { effect = CastformDataTypeChange(target1); if (effect != 0) { BattleScriptPushCursorAndCallback(BattleScript_CastformChange); - gBattleScripting.bank = target1; + gBattleScripting.battler = target1; *(&gBattleStruct->formToChangeInto) = effect - 1; break; } @@ -1913,18 +1913,18 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_ENDTURN: // 1 - if (gBattleMons[bank].hp != 0) + if (gBattleMons[battler].hp != 0) { - gBankAttacker = bank; + gBattleAttacker = battler; switch (gLastUsedAbility) { case ABILITY_RAIN_DISH: if (WEATHER_HAS_EFFECT && (gBattleWeather & WEATHER_RAIN_ANY) - && gBattleMons[bank].maxHP > gBattleMons[bank].hp) + && gBattleMons[battler].maxHP > gBattleMons[battler].hp) { gLastUsedAbility = ABILITY_RAIN_DISH; // why BattleScriptPushCursorAndCallback(BattleScript_RainDishActivates); - gBattleMoveDamage = gBattleMons[bank].maxHP / 16; + gBattleMoveDamage = gBattleMons[battler].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; @@ -1932,40 +1932,40 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_SHED_SKIN: - if ((gBattleMons[bank].status1 & STATUS1_ANY) && (Random() % 3) == 0) + if ((gBattleMons[battler].status1 & STATUS1_ANY) && (Random() % 3) == 0) { - if (gBattleMons[bank].status1 & (STATUS1_POISON | STATUS1_TOXIC_POISON)) + if (gBattleMons[battler].status1 & (STATUS1_POISON | STATUS1_TOXIC_POISON)) StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); - if (gBattleMons[bank].status1 & STATUS1_SLEEP) + if (gBattleMons[battler].status1 & STATUS1_SLEEP) StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn); - if (gBattleMons[bank].status1 & STATUS1_PARALYSIS) + if (gBattleMons[battler].status1 & STATUS1_PARALYSIS) StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn); - if (gBattleMons[bank].status1 & STATUS1_BURN) + if (gBattleMons[battler].status1 & STATUS1_BURN) StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn); - if (gBattleMons[bank].status1 & STATUS1_FREEZE) + if (gBattleMons[battler].status1 & STATUS1_FREEZE) StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn); - gBattleMons[bank].status1 = 0; - gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); // fix nightmare glitch - gBattleScripting.bank = gActiveBank = bank; + gBattleMons[battler].status1 = 0; + gBattleMons[battler].status2 &= ~(STATUS2_NIGHTMARE); // fix nightmare glitch + gBattleScripting.battler = gActiveBattler = battler; BattleScriptPushCursorAndCallback(BattleScript_ShedSkinActivates); - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[bank].status1); - MarkBufferBankForExecution(gActiveBank); + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[battler].status1); + MarkBufferBankForExecution(gActiveBattler); effect++; } break; case ABILITY_SPEED_BOOST: - if (gBattleMons[bank].statStages[STAT_STAGE_SPEED] < 0xC && gDisableStructs[bank].isFirstTurn != 2) + if (gBattleMons[battler].statStages[STAT_STAGE_SPEED] < 0xC && gDisableStructs[battler].isFirstTurn != 2) { - gBattleMons[bank].statStages[STAT_STAGE_SPEED]++; + gBattleMons[battler].statStages[STAT_STAGE_SPEED]++; gBattleScripting.animArg1 = 0x11; gBattleScripting.animArg2 = 0; BattleScriptPushCursorAndCallback(BattleScript_SpeedBoostActivates); - gBattleScripting.bank = bank; + gBattleScripting.battler = battler; effect++; } break; case ABILITY_TRUANT: - gDisableStructs[gBankAttacker].truantCounter ^= 1; + gDisableStructs[gBattleAttacker].truantCounter ^= 1; break; } } @@ -1980,7 +1980,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } if (sSoundMovesTable[i] != 0xFFFF) { - if (gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS) + if (gBattleMons[gBattleAttacker].status2 & STATUS2_MULTIPLETURNS) gHitMarker |= HITMARKER_NO_PPDEDUCT; gBattlescriptCurrInstr = BattleScript_SoundproofProtected; effect = 1; @@ -1995,7 +1995,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) case ABILITY_VOLT_ABSORB: if (moveType == TYPE_ELECTRIC && gBattleMoves[move].power != 0) { - if (gProtectStructs[gBankAttacker].notFirstStrike) + if (gProtectStructs[gBattleAttacker].notFirstStrike) gBattlescriptCurrInstr = BattleScript_MoveHPDrain; else gBattlescriptCurrInstr = BattleScript_MoveHPDrain_PPLoss; @@ -2006,7 +2006,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) case ABILITY_WATER_ABSORB: if (moveType == TYPE_WATER && gBattleMoves[move].power != 0) { - if (gProtectStructs[gBankAttacker].notFirstStrike) + if (gProtectStructs[gBattleAttacker].notFirstStrike) gBattlescriptCurrInstr = BattleScript_MoveHPDrain; else gBattlescriptCurrInstr = BattleScript_MoveHPDrain_PPLoss; @@ -2015,23 +2015,23 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_FLASH_FIRE: - if (moveType == TYPE_FIRE && !(gBattleMons[bank].status1 & STATUS1_FREEZE)) + if (moveType == TYPE_FIRE && !(gBattleMons[battler].status1 & STATUS1_FREEZE)) { - if (!(gBattleResources->flags->flags[bank] & UNKNOWN_FLAG_FLASH_FIRE)) + if (!(gBattleResources->flags->flags[battler] & UNKNOWN_FLAG_FLASH_FIRE)) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; - if (gProtectStructs[gBankAttacker].notFirstStrike) + if (gProtectStructs[gBattleAttacker].notFirstStrike) gBattlescriptCurrInstr = BattleScript_FlashFireBoost; else gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss; - gBattleResources->flags->flags[bank] |= UNKNOWN_FLAG_FLASH_FIRE; + gBattleResources->flags->flags[battler] |= UNKNOWN_FLAG_FLASH_FIRE; effect = 2; } else { gBattleCommunication[MULTISTRING_CHOOSER] = 1; - if (gProtectStructs[gBankAttacker].notFirstStrike) + if (gProtectStructs[gBattleAttacker].notFirstStrike) gBattlescriptCurrInstr = BattleScript_FlashFireBoost; else gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss; @@ -2043,16 +2043,16 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } if (effect == 1) { - if (gBattleMons[bank].maxHP == gBattleMons[bank].hp) + if (gBattleMons[battler].maxHP == gBattleMons[battler].hp) { - if ((gProtectStructs[gBankAttacker].notFirstStrike)) + if ((gProtectStructs[gBattleAttacker].notFirstStrike)) gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless; else gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless_PPLoss; } else { - gBattleMoveDamage = gBattleMons[bank].maxHP / 4; + gBattleMoveDamage = gBattleMons[battler].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; @@ -2067,13 +2067,13 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && move != MOVE_STRUGGLE && gBattleMoves[move].power != 0 - && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) - && gBattleMons[bank].type1 != moveType - && gBattleMons[bank].type2 != moveType - && gBattleMons[bank].hp != 0) + && (gSpecialStatuses[gBattleDefender].moveturnLostHP_physical || gSpecialStatuses[gBattleDefender].moveturnLostHP_special) + && gBattleMons[battler].type1 != moveType + && gBattleMons[battler].type2 != moveType + && gBattleMons[battler].hp != 0) { - gBattleMons[bank].type1 = moveType; - gBattleMons[bank].type2 = moveType; + gBattleMons[battler].type1 = moveType; + gBattleMons[battler].type2 = moveType; PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType) BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_ColorChangeActivates; @@ -2082,12 +2082,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITY_ROUGH_SKIN: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBankAttacker].hp != 0 - && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) + && gBattleMons[gBattleAttacker].hp != 0 + && !gProtectStructs[gBattleAttacker].confusionSelfDmg + && (gSpecialStatuses[gBattleDefender].moveturnLostHP_physical || gSpecialStatuses[gBattleDefender].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)) { - gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 16; + gBattleMoveDamage = gBattleMons[gBattleAttacker].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; BattleScriptPushCursor(); @@ -2097,9 +2097,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITY_EFFECT_SPORE: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBankAttacker].hp != 0 - && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) + && gBattleMons[gBattleAttacker].hp != 0 + && !gProtectStructs[gBattleAttacker].confusionSelfDmg + && (gSpecialStatuses[gBattleDefender].moveturnLostHP_physical || gSpecialStatuses[gBattleDefender].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (Random() % 10) == 0) { @@ -2120,9 +2120,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITY_POISON_POINT: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBankAttacker].hp != 0 - && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) + && gBattleMons[gBattleAttacker].hp != 0 + && !gProtectStructs[gBattleAttacker].confusionSelfDmg + && (gSpecialStatuses[gBattleDefender].moveturnLostHP_physical || gSpecialStatuses[gBattleDefender].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (Random() % 3) == 0) { @@ -2135,9 +2135,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITY_STATIC: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBankAttacker].hp != 0 - && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) + && gBattleMons[gBattleAttacker].hp != 0 + && !gProtectStructs[gBattleAttacker].confusionSelfDmg + && (gSpecialStatuses[gBattleDefender].moveturnLostHP_physical || gSpecialStatuses[gBattleDefender].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (Random() % 3) == 0) { @@ -2150,10 +2150,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITY_FLAME_BODY: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBankAttacker].hp != 0 - && !gProtectStructs[gBankAttacker].confusionSelfDmg + && gBattleMons[gBattleAttacker].hp != 0 + && !gProtectStructs[gBattleAttacker].confusionSelfDmg && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) - && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) + && (gSpecialStatuses[gBattleDefender].moveturnLostHP_physical || gSpecialStatuses[gBattleDefender].moveturnLostHP_special) && (Random() % 3) == 0) { gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_BURN; @@ -2165,19 +2165,19 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITY_CUTE_CHARM: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBankAttacker].hp != 0 - && !gProtectStructs[gBankAttacker].confusionSelfDmg + && gBattleMons[gBattleAttacker].hp != 0 + && !gProtectStructs[gBattleAttacker].confusionSelfDmg && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) - && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) - && gBattleMons[gBankDefender].hp != 0 + && (gSpecialStatuses[gBattleDefender].moveturnLostHP_physical || gSpecialStatuses[gBattleDefender].moveturnLostHP_special) + && gBattleMons[gBattleDefender].hp != 0 && (Random() % 3) == 0 - && gBattleMons[gBankAttacker].ability != ABILITY_OBLIVIOUS + && gBattleMons[gBattleAttacker].ability != ABILITY_OBLIVIOUS && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) - && !(gBattleMons[gBankAttacker].status2 & STATUS2_INFATUATION) + && !(gBattleMons[gBattleAttacker].status2 & STATUS2_INFATUATION) && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != MON_GENDERLESS && GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) != MON_GENDERLESS) { - gBattleMons[gBankAttacker].status2 |= STATUS2_INFATUATED_WITH(gBankDefender); + gBattleMons[gBattleAttacker].status2 |= STATUS2_INFATUATED_WITH(gBattleDefender); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_CuteCharmActivates; effect++; @@ -2186,26 +2186,26 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_IMMUNITY: // 5 - for (bank = 0; bank < gBattleBanksCount; bank++) + for (battler = 0; battler < gBattlersCount; battler++) { - switch (gBattleMons[bank].ability) + switch (gBattleMons[battler].ability) { case ABILITY_IMMUNITY: - if (gBattleMons[bank].status1 & (STATUS1_POISON | STATUS1_TOXIC_POISON | STATUS1_TOXIC_COUNTER)) + if (gBattleMons[battler].status1 & (STATUS1_POISON | STATUS1_TOXIC_POISON | STATUS1_TOXIC_COUNTER)) { StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); effect = 1; } break; case ABILITY_OWN_TEMPO: - if (gBattleMons[bank].status2 & STATUS2_CONFUSION) + if (gBattleMons[battler].status2 & STATUS2_CONFUSION) { StringCopy(gBattleTextBuff1, gStatusConditionString_ConfusionJpn); effect = 2; } break; case ABILITY_LIMBER: - if (gBattleMons[bank].status1 & STATUS1_PARALYSIS) + if (gBattleMons[battler].status1 & STATUS1_PARALYSIS) { StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn); effect = 1; @@ -2213,29 +2213,29 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITY_INSOMNIA: case ABILITY_VITAL_SPIRIT: - if (gBattleMons[bank].status1 & STATUS1_SLEEP) + if (gBattleMons[battler].status1 & STATUS1_SLEEP) { - gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[battler].status2 &= ~(STATUS2_NIGHTMARE); StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn); effect = 1; } break; case ABILITY_WATER_VEIL: - if (gBattleMons[bank].status1 & STATUS1_BURN) + if (gBattleMons[battler].status1 & STATUS1_BURN) { StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn); effect = 1; } break; case ABILITY_MAGMA_ARMOR: - if (gBattleMons[bank].status1 & STATUS1_FREEZE) + if (gBattleMons[battler].status1 & STATUS1_FREEZE) { StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn); effect = 1; } break; case ABILITY_OBLIVIOUS: - if (gBattleMons[bank].status2 & STATUS2_INFATUATION) + if (gBattleMons[battler].status2 & STATUS2_INFATUATION) { StringCopy(gBattleTextBuff1, gStatusConditionString_LoveJpn); effect = 3; @@ -2247,36 +2247,36 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) switch (effect) { case 1: // status cleared - gBattleMons[bank].status1 = 0; + gBattleMons[battler].status1 = 0; break; case 2: // get rid of confusion - gBattleMons[bank].status2 &= ~(STATUS2_CONFUSION); + gBattleMons[battler].status2 &= ~(STATUS2_CONFUSION); break; case 3: // get rid of infatuation - gBattleMons[bank].status2 &= ~(STATUS2_INFATUATION); + gBattleMons[battler].status2 &= ~(STATUS2_INFATUATION); break; } BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_AbilityCuredStatus; - gBattleScripting.bank = bank; - gActiveBank = bank; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); + gBattleScripting.battler = battler; + gActiveBattler = battler; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); return effect; } } break; case ABILITYEFFECT_FORECAST: // 6 - for (bank = 0; bank < gBattleBanksCount; bank++) + for (battler = 0; battler < gBattlersCount; battler++) { - if (gBattleMons[bank].ability == ABILITY_FORECAST) + if (gBattleMons[battler].ability == ABILITY_FORECAST) { - effect = CastformDataTypeChange(bank); + effect = CastformDataTypeChange(battler); if (effect) { BattleScriptPushCursorAndCallback(BattleScript_CastformChange); - gBattleScripting.bank = bank; + gBattleScripting.battler = battler; *(&gBattleStruct->formToChangeInto) = effect - 1; return effect; } @@ -2292,7 +2292,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON; gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleStruct->synchronizeMoveEffect + MOVE_EFFECT_AFFECTS_USER; - gBattleScripting.bank = gBankDefender; + gBattleScripting.battler = gBattleDefender; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; @@ -2308,7 +2308,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON; gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleStruct->synchronizeMoveEffect; - gBattleScripting.bank = gBankAttacker; + gBattleScripting.battler = gBattleAttacker; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; @@ -2316,7 +2316,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_INTIMIDATE1: // 9 - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gBattleMons[i].ability == ABILITY_INTIMIDATE && gStatuses3[i] & STATUS3_INTIMIDATE_POKES) { @@ -2330,42 +2330,42 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_TRACE: // 11 - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gBattleMons[i].ability == ABILITY_TRACE && (gStatuses3[i] & STATUS3_TRACE)) { u8 target2; - side = (GetBankPosition(i) ^ BIT_SIDE) & BIT_SIDE; // side of the opposing pokemon - target1 = GetBankByPosition(side); - target2 = GetBankByPosition(side + BIT_MON); + side = (GetBattlerPosition(i) ^ BIT_SIDE) & BIT_SIDE; // side of the opposing pokemon + target1 = GetBattlerAtPosition(side); + target2 = GetBattlerAtPosition(side + BIT_FLANK); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { if (gBattleMons[target1].ability != 0 && gBattleMons[target1].hp != 0 && gBattleMons[target2].ability != 0 && gBattleMons[target2].hp != 0) { - gActiveBank = GetBankByPosition(((Random() & 1) * 2) | side); - gBattleMons[i].ability = gBattleMons[gActiveBank].ability; - gLastUsedAbility = gBattleMons[gActiveBank].ability; + gActiveBattler = GetBattlerAtPosition(((Random() & 1) * 2) | side); + gBattleMons[i].ability = gBattleMons[gActiveBattler].ability; + gLastUsedAbility = gBattleMons[gActiveBattler].ability; effect++; } else if (gBattleMons[target1].ability != 0 && gBattleMons[target1].hp != 0) { - gActiveBank = target1; - gBattleMons[i].ability = gBattleMons[gActiveBank].ability; - gLastUsedAbility = gBattleMons[gActiveBank].ability; + gActiveBattler = target1; + gBattleMons[i].ability = gBattleMons[gActiveBattler].ability; + gLastUsedAbility = gBattleMons[gActiveBattler].ability; effect++; } else if (gBattleMons[target2].ability != 0 && gBattleMons[target2].hp != 0) { - gActiveBank = target2; - gBattleMons[i].ability = gBattleMons[gActiveBank].ability; - gLastUsedAbility = gBattleMons[gActiveBank].ability; + gActiveBattler = target2; + gBattleMons[i].ability = gBattleMons[gActiveBattler].ability; + gLastUsedAbility = gBattleMons[gActiveBattler].ability; effect++; } } else { - gActiveBank = target1; + gActiveBattler = target1; if (gBattleMons[target1].ability && gBattleMons[target1].hp) { gBattleMons[i].ability = gBattleMons[target1].ability; @@ -2377,9 +2377,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) { BattleScriptPushCursorAndCallback(BattleScript_TraceActivates); gStatuses3[i] &= ~(STATUS3_TRACE); - gBattleScripting.bank = i; + gBattleScripting.battler = i; - PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBank, gBattlePartyID[gActiveBank]) + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gActiveBattler, gBattlePartyID[gActiveBattler]) PREPARE_ABILITY_BUFFER(gBattleTextBuff2, gLastUsedAbility) break; } @@ -2387,7 +2387,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_INTIMIDATE2: // 10 - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gBattleMons[i].ability == ABILITY_INTIMIDATE && (gStatuses3[i] & STATUS3_INTIMIDATE_POKES)) { @@ -2402,10 +2402,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_CHECK_OTHER_SIDE: // 12 - side = GetBankSide(bank); - for (i = 0; i < gBattleBanksCount; i++) + side = GetBattlerSide(battler); + for (i = 0; i < gBattlersCount; i++) { - if (GetBankSide(i) != side && gBattleMons[i].ability == ability) + if (GetBattlerSide(i) != side && gBattleMons[i].ability == ability) { gLastUsedAbility = ability; effect = i + 1; @@ -2413,10 +2413,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_CHECK_BANK_SIDE: // 13 - side = GetBankSide(bank); - for (i = 0; i < gBattleBanksCount; i++) + side = GetBattlerSide(battler); + for (i = 0; i < gBattlersCount; i++) { - if (GetBankSide(i) == side && gBattleMons[i].ability == ability) + if (GetBattlerSide(i) == side && gBattleMons[i].ability == ability) { gLastUsedAbility = ability; effect = i + 1; @@ -2427,21 +2427,21 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) switch (gLastUsedAbility) { case 0xFD: - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gStatuses3[i] & STATUS3_MUDSPORT) effect = i + 1; } break; case 0xFE: - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gStatuses3[i] & STATUS3_WATERSPORT) effect = i + 1; } break; default: - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gBattleMons[i].ability == ability) { @@ -2453,7 +2453,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_CHECK_ON_FIELD: // 19 - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gBattleMons[i].ability == ability && gBattleMons[i].hp != 0) { @@ -2463,9 +2463,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK: // 15 - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (gBattleMons[i].ability == ability && i != bank) + if (gBattleMons[i].ability == ability && i != battler) { gLastUsedAbility = ability; effect = i + 1; @@ -2473,10 +2473,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_COUNT_OTHER_SIDE: // 16 - side = GetBankSide(bank); - for (i = 0; i < gBattleBanksCount; i++) + side = GetBattlerSide(battler); + for (i = 0; i < gBattlersCount; i++) { - if (GetBankSide(i) != side && gBattleMons[i].ability == ability) + if (GetBattlerSide(i) != side && gBattleMons[i].ability == ability) { gLastUsedAbility = ability; effect++; @@ -2484,10 +2484,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_COUNT_BANK_SIDE: // 17 - side = GetBankSide(bank); - for (i = 0; i < gBattleBanksCount; i++) + side = GetBattlerSide(battler); + for (i = 0; i < gBattlersCount; i++) { - if (GetBankSide(i) == side && gBattleMons[i].ability == ability) + if (GetBattlerSide(i) == side && gBattleMons[i].ability == ability) { gLastUsedAbility = ability; effect++; @@ -2495,9 +2495,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_COUNT_ON_FIELD: // 18 - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { - if (gBattleMons[i].ability == ability && i != bank) + if (gBattleMons[i].ability == ability && i != battler) { gLastUsedAbility = ability; effect++; @@ -2507,7 +2507,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } if (effect && caseID < ABILITYEFFECT_CHECK_OTHER_SIDE && gLastUsedAbility != 0xFF) - RecordAbilityBattle(bank, gLastUsedAbility); + RecordAbilityBattle(battler, gLastUsedAbility); } return effect; @@ -2560,11 +2560,11 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) bankQuality = ItemId_GetHoldEffectParam(gLastUsedItem); } - atkItem = gBattleMons[gBankAttacker].item; + atkItem = gBattleMons[gBattleAttacker].item; if (atkItem == ITEM_ENIGMA_BERRY) { - atkHoldEffect = gEnigmaBerries[gBankAttacker].holdEffect; - atkQuality = gEnigmaBerries[gBankAttacker].holdEffectParam; + atkHoldEffect = gEnigmaBerries[gBattleAttacker].holdEffect; + atkQuality = gEnigmaBerries[gBattleAttacker].holdEffectParam; } else { @@ -2573,11 +2573,11 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } // def variables are unused - defItem = gBattleMons[gBankDefender].item; + defItem = gBattleMons[gBattleDefender].item; if (defItem == ITEM_ENIGMA_BERRY) { - defHoldEffect = gEnigmaBerries[gBankDefender].holdEffect; - defQuality = gEnigmaBerries[gBankDefender].holdEffectParam; + defHoldEffect = gEnigmaBerries[gBattleDefender].holdEffect; + defQuality = gEnigmaBerries[gBattleDefender].holdEffectParam; } else { @@ -2591,7 +2591,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) switch (bankHoldEffect) { case HOLD_EFFECT_DOUBLE_PRIZE: - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(bank) == B_SIDE_PLAYER) gBattleStruct->moneyMultiplier = 2; break; case HOLD_EFFECT_RESTORE_STATS: @@ -2605,9 +2605,9 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } if (effect) { - gBattleScripting.bank = bank; + gBattleScripting.battler = bank; gStringBank = bank; - gActiveBank = gBankAttacker = bank; + gActiveBattler = gBattleAttacker = bank; BattleScriptExecute(BattleScript_WhiteHerbEnd2); } break; @@ -2636,7 +2636,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) u8 ppBonuses; u16 move; - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(bank) == B_SIDE_PLAYER) mon = &gPlayerParty[gBattlePartyID[bank]]; else mon = &gEnemyParty[gBattlePartyID[bank]]; @@ -2660,7 +2660,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) BattleScriptExecute(BattleScript_BerryPPHealEnd2); EmitSetMonData(0, i + REQUEST_PPMOVE1_BATTLE, 0, 1, &changedPP); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); effect = ITEM_PP_CHANGE; } } @@ -2676,9 +2676,9 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } if (effect) { - gBattleScripting.bank = bank; + gBattleScripting.battler = bank; gStringBank = bank; - gActiveBank = gBankAttacker = bank; + gActiveBattler = gBattleAttacker = bank; BattleScriptExecute(BattleScript_WhiteHerbEnd2); } break; @@ -3004,14 +3004,14 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } if (effect) { - gBattleScripting.bank = bank; + gBattleScripting.battler = bank; gStringBank = bank; - gActiveBank = gBankAttacker = bank; + gActiveBattler = gBattleAttacker = bank; switch (effect) { case ITEM_STATUS_CHANGE: EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[bank].status1); - MarkBufferBankForExecution(gActiveBank); + MarkBufferBankForExecution(gActiveBattler); break; case ITEM_PP_CHANGE: if (!(gBattleMons[bank].status2 & STATUS2_TRANSFORMED) && !(gDisableStructs[bank].unk18_b & gBitTable[i])) @@ -3024,7 +3024,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) case 2: break; case 3: - for (bank = 0; bank < gBattleBanksCount; bank++) + for (bank = 0; bank < gBattlersCount; bank++) { gLastUsedItem = gBattleMons[bank].item; if (gBattleMons[bank].item == ITEM_ENIGMA_BERRY) @@ -3152,7 +3152,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } if (effect) { - gBattleScripting.bank = bank; + gBattleScripting.battler = bank; gStringBank = bank; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_WhiteHerbRet; @@ -3162,11 +3162,11 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } if (effect) { - gBattleScripting.bank = bank; + gBattleScripting.battler = bank; gStringBank = bank; - gActiveBank = bank; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = bank; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); break; } } @@ -3178,10 +3178,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) { case HOLD_EFFECT_FLINCH: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) + && (gSpecialStatuses[gBattleDefender].moveturnLostHP_physical || gSpecialStatuses[gBattleDefender].moveturnLostHP_special) && (Random() % 100) < atkQuality && gBattleMoves[gCurrentMove].flags & FLAG_KINGSROCK_AFFECTED - && gBattleMons[gBankDefender].hp) + && gBattleMons[gBattleDefender].hp) { gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_FLINCH; BattleScriptPushCursor(); @@ -3191,19 +3191,19 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) break; case HOLD_EFFECT_SHELL_BELL: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gSpecialStatuses[gBankDefender].moveturnLostHP != 0 - && gSpecialStatuses[gBankDefender].moveturnLostHP != 0xFFFF - && gBankAttacker != gBankDefender - && gBattleMons[gBankAttacker].hp != gBattleMons[gBankAttacker].maxHP - && gBattleMons[gBankAttacker].hp != 0) + && gSpecialStatuses[gBattleDefender].moveturnLostHP != 0 + && gSpecialStatuses[gBattleDefender].moveturnLostHP != 0xFFFF + && gBattleAttacker != gBattleDefender + && gBattleMons[gBattleAttacker].hp != gBattleMons[gBattleAttacker].maxHP + && gBattleMons[gBattleAttacker].hp != 0) { gLastUsedItem = atkItem; - gStringBank = gBankAttacker; - gBattleScripting.bank = gBankAttacker; - gBattleMoveDamage = (gSpecialStatuses[gBankDefender].moveturnLostHP / atkQuality) * -1; + gStringBank = gBattleAttacker; + gBattleScripting.battler = gBattleAttacker; + gBattleMoveDamage = (gSpecialStatuses[gBattleDefender].moveturnLostHP / atkQuality) * -1; if (gBattleMoveDamage == 0) gBattleMoveDamage = -1; - gSpecialStatuses[gBankDefender].moveturnLostHP = 0; + gSpecialStatuses[gBattleDefender].moveturnLostHP = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret; effect++; @@ -3244,21 +3244,21 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) switch (moveTarget) { case MOVE_TARGET_SELECTED: - side = GetBankSide(gBankAttacker) ^ BIT_SIDE; + side = GetBattlerSide(gBattleAttacker) ^ BIT_SIDE; if (gSideTimers[side].followmeTimer && gBattleMons[gSideTimers[side].followmeTarget].hp) targetBank = gSideTimers[side].followmeTarget; else { - side = GetBankSide(gBankAttacker); + side = GetBattlerSide(gBattleAttacker); do { - targetBank = Random() % gBattleBanksCount; - } while (targetBank == gBankAttacker || side == GetBankSide(targetBank) || gAbsentBankFlags & gBitTable[targetBank]); + targetBank = Random() % gBattlersCount; + } while (targetBank == gBattleAttacker || side == GetBattlerSide(targetBank) || gAbsentBattlerFlags & gBitTable[targetBank]); if (gBattleMoves[move].type == TYPE_ELECTRIC - && AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBankAttacker, ABILITY_LIGHTNING_ROD, 0, 0) + && AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBattleAttacker, ABILITY_LIGHTNING_ROD, 0, 0) && gBattleMons[targetBank].ability != ABILITY_LIGHTNING_ROD) { - targetBank ^= BIT_MON; + targetBank ^= BIT_FLANK; RecordAbilityBattle(targetBank, gBattleMons[targetBank].ability); gSpecialStatuses[targetBank].lightningRodRedirected = 1; } @@ -3268,50 +3268,50 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) case MOVE_TARGET_BOTH: case MOVE_TARGET_FOES_AND_ALLY: case MOVE_TARGET_OPPONENTS_FIELD: - targetBank = GetBankByPosition((GetBankPosition(gBankAttacker) & BIT_SIDE) ^ BIT_SIDE); - if (gAbsentBankFlags & gBitTable[targetBank]) - targetBank ^= BIT_MON; + targetBank = GetBattlerAtPosition((GetBattlerPosition(gBattleAttacker) & BIT_SIDE) ^ BIT_SIDE); + if (gAbsentBattlerFlags & gBitTable[targetBank]) + targetBank ^= BIT_FLANK; break; case MOVE_TARGET_RANDOM: - side = GetBankSide(gBankAttacker) ^ BIT_SIDE; + side = GetBattlerSide(gBattleAttacker) ^ BIT_SIDE; if (gSideTimers[side].followmeTimer && gBattleMons[gSideTimers[side].followmeTarget].hp) targetBank = gSideTimers[side].followmeTarget; else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && moveTarget & MOVE_TARGET_RANDOM) { - if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_PLAYER) { if (Random() & 1) - targetBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + targetBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); else - targetBank = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + targetBank = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); } else { if (Random() & 1) - targetBank = GetBankByPosition(B_POSITION_PLAYER_LEFT); + targetBank = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); else - targetBank = GetBankByPosition(B_POSITION_PLAYER_RIGHT); + targetBank = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); } - if (gAbsentBankFlags & gBitTable[targetBank]) - targetBank ^= BIT_MON; + if (gAbsentBattlerFlags & gBitTable[targetBank]) + targetBank ^= BIT_FLANK; } else - targetBank = GetBankByPosition((GetBankPosition(gBankAttacker) & BIT_SIDE) ^ BIT_SIDE); + targetBank = GetBattlerAtPosition((GetBattlerPosition(gBattleAttacker) & BIT_SIDE) ^ BIT_SIDE); break; case MOVE_TARGET_USER: case MOVE_TARGET_x10: - targetBank = gBankAttacker; + targetBank = gBattleAttacker; break; } - *(gBattleStruct->moveTarget + gBankAttacker) = targetBank; + *(gBattleStruct->moveTarget + gBattleAttacker) = targetBank; return targetBank; } static bool32 HasObedientBitSet(u8 bank) { - if (GetBankSide(bank) == SIDE_OPPONENT) + if (GetBattlerSide(bank) == B_SIDE_OPPONENT) return TRUE; if (GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES, NULL) != SPECIES_DEOXYS && GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES, NULL) != SPECIES_MEW) @@ -3327,18 +3327,18 @@ u8 IsMonDisobedient(void) if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) return 0; - if (GetBankSide(gBankAttacker) == SIDE_OPPONENT) + if (GetBattlerSide(gBattleAttacker) == B_SIDE_OPPONENT) return 0; - if (HasObedientBitSet(gBankAttacker)) // only if species is Mew or Deoxys + if (HasObedientBitSet(gBattleAttacker)) // only if species is Mew or Deoxys { - if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBankPosition(gBankAttacker) == 2) + if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattleAttacker) == 2) return 0; if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) return 0; if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) return 0; - if (!IsOtherTrainer(gBattleMons[gBankAttacker].otId, gBattleMons[gBankAttacker].otName)) + if (!IsOtherTrainer(gBattleMons[gBattleAttacker].otId, gBattleMons[gBattleAttacker].otName)) return 0; if (FlagGet(FLAG_BADGE08_GET)) return 0; @@ -3353,27 +3353,27 @@ u8 IsMonDisobedient(void) obedienceLevel = 70; } - if (gBattleMons[gBankAttacker].level <= obedienceLevel) + if (gBattleMons[gBattleAttacker].level <= obedienceLevel) return 0; rnd = (Random() & 255); - calc = (gBattleMons[gBankAttacker].level + obedienceLevel) * rnd >> 8; + calc = (gBattleMons[gBattleAttacker].level + obedienceLevel) * rnd >> 8; if (calc < obedienceLevel) return 0; // is not obedient if (gCurrentMove == MOVE_RAGE) - gBattleMons[gBankAttacker].status2 &= ~(STATUS2_RAGE); - if (gBattleMons[gBankAttacker].status1 & STATUS1_SLEEP && (gCurrentMove == MOVE_SNORE || gCurrentMove == MOVE_SLEEP_TALK)) + gBattleMons[gBattleAttacker].status2 &= ~(STATUS2_RAGE); + if (gBattleMons[gBattleAttacker].status1 & STATUS1_SLEEP && (gCurrentMove == MOVE_SNORE || gCurrentMove == MOVE_SLEEP_TALK)) { gBattlescriptCurrInstr = BattleScript_82DB695; return 1; } rnd = (Random() & 255); - calc = (gBattleMons[gBankAttacker].level + obedienceLevel) * rnd >> 8; + calc = (gBattleMons[gBattleAttacker].level + obedienceLevel) * rnd >> 8; if (calc < obedienceLevel) { - calc = CheckMoveLimitations(gBankAttacker, gBitTable[gCurrMovePos], 0xFF); + calc = CheckMoveLimitations(gBattleAttacker, gBitTable[gCurrMovePos], 0xFF); if (calc == 0xF) // all moves cannot be used { gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3; @@ -3387,28 +3387,28 @@ u8 IsMonDisobedient(void) gCurrMovePos = gUnknown_020241E9 = Random() & 3; } while (gBitTable[gCurrMovePos] & calc); - gRandomMove = gBattleMons[gBankAttacker].moves[gCurrMovePos]; + gRandomMove = gBattleMons[gBattleAttacker].moves[gCurrMovePos]; gBattlescriptCurrInstr = BattleScript_IgnoresAndUsesRandomMove; - gBankDefender = GetMoveTarget(gRandomMove, 0); + gBattleDefender = GetMoveTarget(gRandomMove, 0); gHitMarker |= HITMARKER_x200000; return 2; } } else { - obedienceLevel = gBattleMons[gBankAttacker].level - obedienceLevel; + obedienceLevel = gBattleMons[gBattleAttacker].level - obedienceLevel; calc = (Random() & 255); - if (calc < obedienceLevel && !(gBattleMons[gBankAttacker].status1 & STATUS1_ANY) && gBattleMons[gBankAttacker].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gBankAttacker].ability != ABILITY_INSOMNIA) + if (calc < obedienceLevel && !(gBattleMons[gBattleAttacker].status1 & STATUS1_ANY) && gBattleMons[gBattleAttacker].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gBattleAttacker].ability != ABILITY_INSOMNIA) { // try putting asleep int i; - for (i = 0; i < gBattleBanksCount; i++) + for (i = 0; i < gBattlersCount; i++) { if (gBattleMons[i].status2 & STATUS2_UPROAR) break; } - if (i == gBattleBanksCount) + if (i == gBattlersCount) { gBattlescriptCurrInstr = BattleScript_IgnoresAndFallsAsleep; return 1; @@ -3417,8 +3417,8 @@ u8 IsMonDisobedient(void) calc -= obedienceLevel; if (calc < obedienceLevel) { - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankAttacker], MOVE_POUND, 0, 40, 0, gBankAttacker, gBankAttacker); - gBankDefender = gBankAttacker; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattleAttacker], &gBattleMons[gBattleAttacker], MOVE_POUND, 0, 40, 0, gBattleAttacker, gBattleAttacker); + gBattleDefender = gBattleAttacker; gBattlescriptCurrInstr = BattleScript_82DB6F0; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; return 2; diff --git a/src/battle_util2.c b/src/battle_util2.c index fb01865a4..5c7434aa0 100644 --- a/src/battle_util2.c +++ b/src/battle_util2.c @@ -8,12 +8,12 @@ #include "random.h" #include "battle_scripts.h" -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; extern u8 gUnknown_0203CF00[]; extern const u8 *gBattlescriptCurrInstr; extern u8 gBattleCommunication[]; -extern u8 gActiveBank; +extern u8 gActiveBattler; extern void sub_81D55D0(void); extern void sub_81D5694(void); @@ -87,15 +87,15 @@ void AdjustFriendshipOnBattleFaint(u8 bank) { u8 opposingBank2; - opposingBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); - opposingBank2 = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + opposingBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + opposingBank2 = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); if (gBattleMons[opposingBank2].level > gBattleMons[opposingBank].level) opposingBank = opposingBank2; } else { - opposingBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + opposingBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); } if (gBattleMons[opposingBank].level > gBattleMons[bank].level) @@ -113,7 +113,7 @@ void AdjustFriendshipOnBattleFaint(u8 bank) void sub_80571DC(u8 bank, u8 arg1) { - if (GetBankSide(bank) != SIDE_OPPONENT) + if (GetBattlerSide(bank) != B_SIDE_OPPONENT) { s32 i; @@ -206,9 +206,9 @@ u32 sub_805725C(u8 bank) if (effect == 2) { - gActiveBank = bank; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); - MarkBufferBankForExecution(gActiveBank); + gActiveBattler = bank; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); + MarkBufferBankForExecution(gActiveBattler); } return effect; diff --git a/src/pokeball.c b/src/pokeball.c index f16096429..424ecb0eb 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -16,8 +16,8 @@ #include "graphics.h" extern bool8 gDoingBattleAnim; -extern u8 gActiveBank; -extern u8 gBankDefender; +extern u8 gActiveBattler; +extern u8 gBattleDefender; extern u16 gBattlePartyID[]; extern u8 gBankSpriteIds[]; extern u8 gHealthBoxesIds[]; @@ -334,12 +334,12 @@ u8 DoPokeballSendOutAnimation(s16 pan, u8 kindOfThrow) u8 taskId; gDoingBattleAnim = TRUE; - gBattleSpritesDataPtr->healthBoxesData[gActiveBank].ballAnimActive = 1; + gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive = 1; taskId = CreateTask(Task_DoPokeballSendOutAnim, 5); gTasks[taskId].tPan = pan; gTasks[taskId].tThrowId = kindOfThrow; - gTasks[taskId].tBank = gActiveBank; + gTasks[taskId].tBank = gActiveBattler; return 0; } @@ -363,7 +363,7 @@ static void Task_DoPokeballSendOutAnim(u8 taskId) throwCaseId = gTasks[taskId].tThrowId; bank = gTasks[taskId].tBank; - if (GetBankSide(bank) != SIDE_PLAYER) + if (GetBattlerSide(bank) != B_SIDE_PLAYER) itemId = GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_POKEBALL); else itemId = GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_POKEBALL); @@ -378,7 +378,7 @@ static void Task_DoPokeballSendOutAnim(u8 taskId) switch (throwCaseId) { case POKEBALL_PLAYER_SENDOUT: - gBankDefender = bank; + gBattleDefender = bank; gSprites[ballSpriteId].pos1.x = 24; gSprites[ballSpriteId].pos1.y = 68; gSprites[ballSpriteId].callback = SpriteCB_PlayerMonSendOut_1; @@ -386,17 +386,17 @@ static void Task_DoPokeballSendOutAnim(u8 taskId) case POKEBALL_OPPONENT_SENDOUT: gSprites[ballSpriteId].pos1.x = GetBankCoord(bank, BANK_X_POS); gSprites[ballSpriteId].pos1.y = GetBankCoord(bank, BANK_Y_POS) + 24; - gBankDefender = bank; + gBattleDefender = bank; gSprites[ballSpriteId].data[0] = 0; gSprites[ballSpriteId].callback = SpriteCB_OpponentMonSendOut; break; default: - gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + gBattleDefender = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); notSendOut = TRUE; break; } - gSprites[ballSpriteId].sBank = gBankDefender; + gSprites[ballSpriteId].sBank = gBattleDefender; if (!notSendOut) { DestroyTask(taskId); @@ -405,12 +405,12 @@ static void Task_DoPokeballSendOutAnim(u8 taskId) // this will perform an unused ball throw animation gSprites[ballSpriteId].data[0] = 0x22; - gSprites[ballSpriteId].data[2] = GetBankCoord(gBankDefender, BANK_X_POS); - gSprites[ballSpriteId].data[4] = GetBankCoord(gBankDefender, BANK_Y_POS) - 16; + gSprites[ballSpriteId].data[2] = GetBankCoord(gBattleDefender, BANK_X_POS); + gSprites[ballSpriteId].data[4] = GetBankCoord(gBattleDefender, BANK_Y_POS) - 16; gSprites[ballSpriteId].data[5] = -40; sub_80A68D4(&gSprites[ballSpriteId]); gSprites[ballSpriteId].oam.affineParam = taskId; - gTasks[taskId].tOpponentBank = gBankDefender; + gTasks[taskId].tOpponentBank = gBattleDefender; gTasks[taskId].func = TaskDummy; PlaySE(SE_NAGERU); } @@ -755,7 +755,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite) u16 wantedCryCase; u8 taskId; - if (GetBankSide(bank) != SIDE_PLAYER) + if (GetBattlerSide(bank) != B_SIDE_PLAYER) { mon = &gEnemyParty[gBattlePartyID[bank]]; pan = 25; @@ -767,7 +767,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite) } species = GetMonData(mon, MON_DATA_SPECIES); - if ((bank == GetBankByPosition(B_POSITION_PLAYER_LEFT) || bank == GetBankByPosition(B_POSITION_OPPONENT_LEFT)) + if ((bank == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || bank == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)) && IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) @@ -783,7 +783,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite) if (!IsDoubleBattle() || !gBattleSpritesDataPtr->animationData->field_9_x1) wantedCryCase = 0; - else if (bank == GetBankByPosition(B_POSITION_PLAYER_LEFT) || bank == GetBankByPosition(B_POSITION_OPPONENT_LEFT)) + else if (bank == GetBattlerAtPosition(B_POSITION_PLAYER_LEFT) || bank == GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT)) wantedCryCase = 1; else wantedCryCase = 2; @@ -803,7 +803,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite) StartSpriteAffineAnim(&gSprites[gBankSpriteIds[sprite->sBank]], 1); - if (GetBankSide(sprite->sBank) == SIDE_OPPONENT) + if (GetBattlerSide(sprite->sBank) == B_SIDE_OPPONENT) gSprites[gBankSpriteIds[sprite->sBank]].callback = sub_8039B58; else gSprites[gBankSpriteIds[sprite->sBank]].callback = sub_8039E44; @@ -859,12 +859,12 @@ static void HandleBallAnimEnd(struct Sprite *sprite) FreeSpriteOamMatrix(sprite); DestroySprite(sprite); - for (doneBanks = 0, i = 0; i < BATTLE_BANKS_COUNT; i++) + for (doneBanks = 0, i = 0; i < MAX_BATTLERS_COUNT; i++) { if (gBattleSpritesDataPtr->healthBoxesData[i].ballAnimActive == 0) doneBanks++; } - if (doneBanks == BATTLE_BANKS_COUNT) + if (doneBanks == MAX_BATTLERS_COUNT) { for (i = 0; i < POKEBALL_COUNT; i++) FreeBallGfx(i); @@ -956,7 +956,7 @@ static void SpriteCB_PlayerMonSendOut_2(struct Sprite *sprite) sprite->data[0] = 0; if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1 - && sprite->sBank == GetBankByPosition(B_POSITION_PLAYER_RIGHT)) + && sprite->sBank == GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT)) sprite->callback = SpriteCB_ReleaseMon2FromBall; else sprite->callback = SpriteCB_ReleaseMonFromBall; @@ -982,7 +982,7 @@ static void SpriteCB_OpponentMonSendOut(struct Sprite *sprite) { sprite->data[0] = 0; if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1 - && sprite->sBank == GetBankByPosition(B_POSITION_OPPONENT_RIGHT)) + && sprite->sBank == GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT)) sprite->callback = SpriteCB_ReleaseMon2FromBall; else sprite->callback = SpriteCB_ReleaseMonFromBall; @@ -1190,7 +1190,7 @@ void sub_8076918(u8 bank) healthboxSprite->pos2.x = 0x73; healthboxSprite->pos2.y = 0; healthboxSprite->callback = sub_80769CC; - if (GetBankSide(bank) != SIDE_PLAYER) + if (GetBattlerSide(bank) != B_SIDE_PLAYER) { healthboxSprite->data[0] = -healthboxSprite->data[0]; healthboxSprite->data[1] = -healthboxSprite->data[1]; @@ -1198,7 +1198,7 @@ void sub_8076918(u8 bank) healthboxSprite->pos2.y = -healthboxSprite->pos2.y; } gSprites[healthboxSprite->data[5]].callback(&gSprites[healthboxSprite->data[5]]); - if (GetBankPosition(bank) == B_POSITION_PLAYER_RIGHT) + if (GetBattlerPosition(bank) == B_POSITION_PLAYER_RIGHT) healthboxSprite->callback = sub_80769A8; } @@ -1275,7 +1275,7 @@ void FreeBallGfx(u8 ballId) static u16 GetBankPokeballItemId(u8 bank) { - if (GetBankSide(bank) == SIDE_PLAYER) + if (GetBattlerSide(bank) == B_SIDE_PLAYER) return GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_POKEBALL); else return GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_POKEBALL); diff --git a/src/pokemon_2.c b/src/pokemon_2.c index f05453c52..d4ccd5ca1 100644 --- a/src/pokemon_2.c +++ b/src/pokemon_2.c @@ -14,10 +14,10 @@ struct Unknown_020249B4 struct SpriteTemplate* templates; }; -extern u8 gAbsentBankFlags; -extern u8 gActiveBank; -extern u8 gBankAttacker; -extern u8 gBankDefender; +extern u8 gAbsentBattlerFlags; +extern u8 gActiveBattler; +extern u8 gBattleAttacker; +extern u8 gBattleDefender; extern u8 gLastUsedAbility; extern u16 gTrainerBattleOpponent_A; extern u32 gBattleTypeFlags; @@ -34,9 +34,9 @@ extern const union AnimCmd* const * const gUnknown_0830536C[]; extern const u8 gText_BadEgg[]; extern const u8 gText_EggNickname[]; -extern u8 GetBankSide(u8 bank); -extern u8 GetBankByPosition(u8 bank); -extern u8 GetBankPosition(u8 bank); +extern u8 GetBattlerSide(u8 bank); +extern u8 GetBattlerAtPosition(u8 bank); +extern u8 GetBattlerPosition(u8 bank); u8 CountAliveMonsInBattle(u8 caseId) { @@ -48,21 +48,21 @@ u8 CountAliveMonsInBattle(u8 caseId) case BATTLE_ALIVE_EXCEPT_ACTIVE: for (i = 0; i < 4; i++) { - if (i != gActiveBank && !(gAbsentBankFlags & gBitTable[i])) + if (i != gActiveBattler && !(gAbsentBattlerFlags & gBitTable[i])) retVal++; } break; case BATTLE_ALIVE_ATK_SIDE: for (i = 0; i < 4; i++) { - if (GetBankSide(i) == GetBankSide(gBankAttacker) && !(gAbsentBankFlags & gBitTable[i])) + if (GetBattlerSide(i) == GetBattlerSide(gBattleAttacker) && !(gAbsentBattlerFlags & gBitTable[i])) retVal++; } break; case BATTLE_ALIVE_DEF_SIDE: for (i = 0; i < 4; i++) { - if (GetBankSide(i) == GetBankSide(gBankDefender) && !(gAbsentBankFlags & gBitTable[i])) + if (GetBattlerSide(i) == GetBattlerSide(gBattleDefender) && !(gAbsentBattlerFlags & gBitTable[i])) retVal++; } break; @@ -75,7 +75,7 @@ bool8 ShouldGetStatBadgeBoost(u16 badgeFlag, u8 bank) { if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_EREADER_TRAINER | BATTLE_TYPE_x2000000 | BATTLE_TYPE_FRONTIER)) return FALSE; - if (GetBankSide(bank) != SIDE_PLAYER) + if (GetBattlerSide(bank) != B_SIDE_PLAYER) return FALSE; if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gTrainerBattleOpponent_A == SECRET_BASE_OPPONENT) return FALSE; @@ -86,11 +86,11 @@ bool8 ShouldGetStatBadgeBoost(u16 badgeFlag, u8 bank) u8 GetDefaultMoveTarget(u8 bank) { - u8 status = GetBankPosition(bank) & 1; + u8 status = GetBattlerPosition(bank) & 1; status ^= 1; if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) - return GetBankByPosition(status); + return GetBattlerAtPosition(status); if (CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) > 1) { u8 val; @@ -99,14 +99,14 @@ u8 GetDefaultMoveTarget(u8 bank) val = status ^ 2; else val = status; - return GetBankByPosition(val); + return GetBattlerAtPosition(val); } else { - if ((gAbsentBankFlags & gBitTable[status])) - return GetBankByPosition(status ^ 2); + if ((gAbsentBattlerFlags & gBitTable[status])) + return GetBattlerAtPosition(status ^ 2); else - return GetBankByPosition(status); + return GetBattlerAtPosition(status); } } @@ -1353,7 +1353,7 @@ void CopyPlayerPartyMonToBattleData(u8 bank, u8 partyIndex) StringCopy10(gBattleMons[bank].nickname, nickname); GetMonData(&gPlayerParty[partyIndex], MON_DATA_OT_NAME, gBattleMons[bank].otName); - hpSwitchout = &gBattleStruct->hpOnSwitchout[GetBankSide(bank)]; + hpSwitchout = &gBattleStruct->hpOnSwitchout[GetBattlerSide(bank)]; *hpSwitchout = gBattleMons[bank].hp; for (i = 0; i < 8; i++) diff --git a/src/pokemon_3.c b/src/pokemon_3.c index 57b12501e..d6413c455 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -25,10 +25,10 @@ extern struct BattlePokemon gBattleMons[4]; extern struct BattleEnigmaBerry gEnigmaBerries[4]; -extern u8 gActiveBank; +extern u8 gActiveBattler; extern u8 gBankInMenu; -extern u8 gBankDefender; -extern u8 gBankAttacker; +extern u8 gBattleDefender; +extern u8 gBattleAttacker; extern u8 gStringBank; extern u16 gTrainerBattleOpponent_A; extern u32 gBattleTypeFlags; @@ -113,7 +113,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit) if (itemId == ITEM_ENIGMA_BERRY) { - temp = gEnigmaBerries[gActiveBank].itemEffect; + temp = gEnigmaBerries[gActiveBattler].itemEffect; } itemEffect = temp; @@ -210,7 +210,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit) void sub_806CF24(s32 stat) { - gBankDefender = gBankInMenu; + gBattleDefender = gBankInMenu; StringCopy(gBattleTextBuff1, gStatNamesTable[gUnknown_08329EC8[stat]]); StringCopy(gBattleTextBuff2, gText_StatRose); BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnsStatChanged2); @@ -247,7 +247,7 @@ u8 *sub_806CF78(u16 itemId) } else { - gBankAttacker = gBankInMenu; + gBattleAttacker = gBankInMenu; BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnGettingPumped); } } @@ -255,7 +255,7 @@ u8 *sub_806CF78(u16 itemId) if (itemEffect[3] & 0x80) { - gBankAttacker = gBankInMenu; + gBattleAttacker = gBankInMenu; BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnShroudedInMist); } @@ -1366,7 +1366,7 @@ void sub_806E994(void) gBattleTextBuff1[2] = gBattleStruct->field_49; gBattleTextBuff1[4] = B_BUFF_EOS; - if (!GetBankSide(gBattleStruct->field_49)) + if (!GetBattlerSide(gBattleStruct->field_49)) gBattleTextBuff1[3] = pokemon_order_func(gBattlePartyID[gBattleStruct->field_49]); else gBattleTextBuff1[3] = gBattlePartyID[gBattleStruct->field_49]; diff --git a/src/recorded_battle.c b/src/recorded_battle.c index b785d1ea1..cd54495fc 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -25,11 +25,11 @@ extern u32 gBattleTypeFlags; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; extern u16 gPartnerTrainerId; -extern u8 gActiveBank; -extern u8 gBattleBanksCount; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; -extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT]; +extern u8 gActiveBattler; +extern u8 gBattlersCount; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; +extern u16 gChosenMovesByBanks[MAX_BATTLERS_COUNT]; extern u8 gUnknown_03001278; extern u8 gUnknown_03001279; @@ -52,13 +52,13 @@ struct RecordedBattleSave { struct Pokemon playerParty[PARTY_SIZE]; struct Pokemon opponentParty[PARTY_SIZE]; - u8 playersName[BATTLE_BANKS_COUNT][PLAYER_NAME_LENGTH]; - u8 playersGender[BATTLE_BANKS_COUNT]; - u32 playersTrainerId[BATTLE_BANKS_COUNT]; - u8 playersLanguage[BATTLE_BANKS_COUNT]; + u8 playersName[MAX_BATTLERS_COUNT][PLAYER_NAME_LENGTH]; + u8 playersGender[MAX_BATTLERS_COUNT]; + u32 playersTrainerId[MAX_BATTLERS_COUNT]; + u8 playersLanguage[MAX_BATTLERS_COUNT]; u32 rngSeed; u32 battleFlags; - u8 playersBank[BATTLE_BANKS_COUNT]; + u8 playersBank[MAX_BATTLERS_COUNT]; u16 opponentA; u16 opponentB; u16 partnerId; @@ -75,14 +75,14 @@ struct RecordedBattleSave u16 field_50E[6]; u8 field_51A; u8 field_51B; - u8 battleRecord[BATTLE_BANKS_COUNT][BANK_RECORD_SIZE]; + u8 battleRecord[MAX_BATTLERS_COUNT][BANK_RECORD_SIZE]; u32 checksum; }; EWRAM_DATA u32 gRecordedBattleRngSeed = 0; EWRAM_DATA u32 gBattlePalaceMoveSelectionRngValue = 0; -EWRAM_DATA static u8 sBattleRecords[BATTLE_BANKS_COUNT][BANK_RECORD_SIZE] = {0}; -EWRAM_DATA static u16 sRecordedBytesNo[BATTLE_BANKS_COUNT] = {0}; +EWRAM_DATA static u8 sBattleRecords[MAX_BATTLERS_COUNT][BANK_RECORD_SIZE] = {0}; +EWRAM_DATA static u16 sRecordedBytesNo[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA static u16 sUnknown_0203C79C[4] = {0}; EWRAM_DATA static u16 sUnknown_0203C7A4[4] = {0}; EWRAM_DATA static u8 sUnknown_0203C7AC = 0; @@ -99,7 +99,7 @@ EWRAM_DATA static u32 sRecordedBattle_AI_Scripts = 0; EWRAM_DATA static struct Pokemon sSavedPlayerParty[PARTY_SIZE] = {0}; EWRAM_DATA static struct Pokemon sSavedOpponentParty[PARTY_SIZE] = {0}; EWRAM_DATA static u16 sRecordedBattle_PlayerMonMoves[2][4] = {0}; -EWRAM_DATA static struct PlayerInfo sRecordedBattle_Players[BATTLE_BANKS_COUNT] = {0}; +EWRAM_DATA static struct PlayerInfo sRecordedBattle_Players[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA static u8 sUnknown_0203CCD0 = 0; EWRAM_DATA static u8 sUnknown_0203CCD1[8] = {0}; EWRAM_DATA static u8 sUnknown_0203CCD9 = 0; @@ -123,7 +123,7 @@ void sub_8184DA4(u8 arg0) sUnknown_0203C7AC = arg0; sUnknown_0203CCD0 = 0; - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { sRecordedBytesNo[i] = 0; sUnknown_0203C79C[i] = 0; @@ -164,7 +164,7 @@ void sub_8184E58(void) gUnknown_0203C7B4 = GetMultiplayerId(); linkPlayersCount = GetLinkPlayerCount(); - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { sRecordedBattle_Players[i].trainerId = gLinkPlayers[i].trainerId; sRecordedBattle_Players[i].gender = gLinkPlayers[i].gender; @@ -248,7 +248,7 @@ u8 sub_81850DC(u8 *arg0) u8 i, j; u8 ret = 0; - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { if (sRecordedBytesNo[i] != sUnknown_0203C79C[i]) { @@ -350,7 +350,7 @@ u32 MoveRecordedBattleToSaveData(void) battleSave->opponentParty[i] = sSavedOpponentParty[i]; } - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { for (j = 0; j < PLAYER_NAME_LENGTH; j++) { @@ -1339,7 +1339,7 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src) gEnemyParty[i] = src->opponentParty[i]; } - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { for (var = FALSE, j = 0; j < PLAYER_NAME_LENGTH; j++) { @@ -1386,7 +1386,7 @@ static void SetRecordedBattleVarsFromSave(struct RecordedBattleSave *src) gSaveBlock2Ptr->frontierChosenLvl = src->field_4FC; - for (i = 0; i < BATTLE_BANKS_COUNT; i++) + for (i = 0; i < MAX_BATTLERS_COUNT; i++) { for (j = 0; j < BANK_RECORD_SIZE; j++) { @@ -1462,7 +1462,7 @@ u8 GetActiveBankLinkPlayerGender(void) for (i = 0; i < MAX_LINK_PLAYERS; i++) { - if (gLinkPlayers[i].lp_field_18 == gActiveBank) + if (gLinkPlayers[i].lp_field_18 == gActiveBattler) break; } @@ -1501,7 +1501,7 @@ void RecordedBattle_CopyBankMoves(void) { s32 i; - if (GetBankSide(gActiveBank) == SIDE_OPPONENT) + if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT) return; if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) return; @@ -1510,7 +1510,7 @@ void RecordedBattle_CopyBankMoves(void) for (i = 0; i < 4; i++) { - sRecordedBattle_PlayerMonMoves[gActiveBank / 2][i] = gBattleMons[gActiveBank].moves[i]; + sRecordedBattle_PlayerMonMoves[gActiveBattler / 2][i] = gBattleMons[gActiveBattler].moves[i]; } } @@ -1523,9 +1523,9 @@ void sub_818603C(u8 arg0) if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) return; - for (bank = 0; bank < gBattleBanksCount; bank++) + for (bank = 0; bank < gBattlersCount; bank++) { - if (GetBankSide(bank) != SIDE_OPPONENT) // player's side only + if (GetBattlerSide(bank) != B_SIDE_OPPONENT) // player's side only { if (arg0 == 1) { diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index 93d69b840..92a9c4074 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -22,14 +22,14 @@ extern u16 gBattle_BG2_Y; extern u16 gBattle_BG3_X; extern u16 gBattle_BG3_Y; extern u8 gReservedSpritePaletteCount; -extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; +extern u8 gActionSelectionCursor[MAX_BATTLERS_COUNT]; extern u8 gBankInMenu; -extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gBattleBanksCount; +extern u16 gBattlePartyID[MAX_BATTLERS_COUNT]; +extern u8 gBattlersCount; extern u32 gBattleTypeFlags; -extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; -extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; -extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; +extern u8 gBankSpriteIds[MAX_BATTLERS_COUNT]; +extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; +extern u8 gHealthBoxesIds[MAX_BATTLERS_COUNT]; extern struct SpriteTemplate gUnknown_0202499C; extern const union AnimCmd * const * const gMonAnimationsSpriteAnimsPtrTable[]; @@ -164,13 +164,13 @@ static void CB2_ReshowBattleScreenAfterMenu(void) LoadAndCreateEnemyShadowSprites(); - opponentBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + opponentBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); species = GetMonData(&gEnemyParty[gBattlePartyID[opponentBank]], MON_DATA_SPECIES); SetBankEnemyShadowSpriteCallback(opponentBank, species); if (IsDoubleBattle()) { - opponentBank = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); + opponentBank = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); species = GetMonData(&gEnemyParty[gBattlePartyID[opponentBank]], MON_DATA_SPECIES); SetBankEnemyShadowSpriteCallback(opponentBank, species); } @@ -210,9 +210,9 @@ static void sub_80A95F4(void) static bool8 LoadBankSpriteGfx(u8 bank) { - if (bank < gBattleBanksCount) + if (bank < gBattlersCount) { - if (GetBankSide(bank) != SIDE_PLAYER) + if (GetBattlerSide(bank) != B_SIDE_PLAYER) { if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute) BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlePartyID[bank]], bank); @@ -245,7 +245,7 @@ extern const struct MonCoords gTrainerBackPicCoords[]; static void CreateBankSprite(u8 bank) { - if (bank < gBattleBanksCount) + if (bank < gBattlersCount) { u8 posY; @@ -254,12 +254,12 @@ static void CreateBankSprite(u8 bank) else posY = GetBankSpriteDefault_Y(bank); - if (GetBankSide(bank) != SIDE_PLAYER) + if (GetBattlerSide(bank) != B_SIDE_PLAYER) { if (GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_HP) == 0) return; - sub_806A068(GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES), GetBankPosition(bank)); + sub_806A068(GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBankCoord(bank, 2), posY, sub_80A82E4(bank)); gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; @@ -272,7 +272,7 @@ static void CreateBankSprite(u8 bank) } else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) { - sub_806A12C(gSaveBlock2Ptr->playerGender, GetBankPosition(B_POSITION_PLAYER_LEFT)); + sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT)); gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50, (8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80, sub_80A82E4(0)); @@ -282,7 +282,7 @@ static void CreateBankSprite(u8 bank) } else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) { - sub_806A12C(BACK_PIC_WALLY, GetBankPosition(0)); + sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(0)); gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50, (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords) * 4 + 80, sub_80A82E4(0)); @@ -295,7 +295,7 @@ static void CreateBankSprite(u8 bank) if (GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_HP) == 0) return; - sub_806A068(GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES), GetBankPosition(bank)); + sub_806A068(GetMonData(&gPlayerParty[gBattlePartyID[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); gBankSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBankCoord(bank, 2), posY, sub_80A82E4(bank)); gSprites[gBankSpriteIds[bank]].oam.paletteNum = bank; gSprites[gBankSpriteIds[bank]].callback = SpriteCallbackDummy; @@ -313,7 +313,7 @@ static void CreateBankSprite(u8 bank) static void CreateHealthboxSprite(u8 bank) { - if (bank < gBattleBanksCount) + if (bank < gBattlersCount) { u8 healthboxSpriteId; @@ -328,19 +328,19 @@ static void CreateHealthboxSprite(u8 bank) SetBankHealthboxSpritePos(bank); SetHealthboxSpriteVisible(healthboxSpriteId); - if (GetBankSide(bank) != SIDE_PLAYER) + if (GetBattlerSide(bank) != B_SIDE_PLAYER) UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gEnemyParty[gBattlePartyID[bank]], HEALTHBOX_ALL); else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gPlayerParty[gBattlePartyID[bank]], HEALTHBOX_SAFARI_ALL_TEXT); else UpdateHealthboxAttribute(gHealthBoxesIds[bank], &gPlayerParty[gBattlePartyID[bank]], HEALTHBOX_ALL); - if (GetBankPosition(bank) == B_POSITION_OPPONENT_RIGHT || GetBankPosition(bank) == B_POSITION_PLAYER_RIGHT) + if (GetBattlerPosition(bank) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(bank) == B_POSITION_PLAYER_RIGHT) DummyBattleInterfaceFunc(gHealthBoxesIds[bank], TRUE); else DummyBattleInterfaceFunc(gHealthBoxesIds[bank], FALSE); - if (GetBankSide(bank) != SIDE_PLAYER) + if (GetBattlerSide(bank) != B_SIDE_PLAYER) { if (GetMonData(&gEnemyParty[gBattlePartyID[bank]], MON_DATA_HP) == 0) SetHealthboxSpriteInvisible(healthboxSpriteId); diff --git a/sym_common.txt b/sym_common.txt index 4918ca425..d724a46d5 100644 --- a/sym_common.txt +++ b/sym_common.txt @@ -215,7 +215,7 @@ gBattleResults: @ 3005D10 gLeveledUpInBattle: @ 3005D54 .space 0xC -gBattleBankFunc: @ 3005D60 +gBattlerFuncs: @ 3005D60 .space 0x10 gHealthBoxesIds: @ 3005D70 diff --git a/sym_ewram.txt b/sym_ewram.txt index a33a09a7c..ca117d1e5 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -270,25 +270,25 @@ gBattleBufferA: @ 2023064 gBattleBufferB: @ 2023864 .space 0x800 -gActiveBank: @ 2024064 +gActiveBattler: @ 2024064 .space 0x4 gBattleExecBuffer: @ 2024068 .space 0x4 -gBattleBanksCount: @ 202406C +gBattlersCount: @ 202406C .space 0x2 gBattlePartyID: @ 202406E .space 0x8 -gBankPositions: @ 2024076 +gBattlerPositions: @ 2024076 .space 0x4 gActionsByTurnOrder: @ 202407A .space 0x4 -gBanksByTurnOrder: @ 202407E +gBattleTurnOrder: @ 202407E .space 0x4 gCurrentTurnActionNumber: @ 2024082 @@ -333,10 +333,10 @@ gLastUsedItem: @ 2024208 gLastUsedAbility: @ 202420A .space 0x1 -gBankAttacker: @ 202420B +gBattleAttacker: @ 202420B .space 0x1 -gBankDefender: @ 202420C +gBattleDefender: @ 202420C .space 0x1 gBank1: @ 202420D @@ -348,7 +348,7 @@ gEffectBank: @ 202420E gStringBank: @ 202420F .space 0x1 -gAbsentBankFlags: @ 2024210 +gAbsentBattlerFlags: @ 2024210 .space 0x1 gCritMultiplier: @ 2024211