From c3dc14ba66b31c8f2556e9a19b6be7a5e860a376 Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Tue, 6 Feb 2018 16:09:39 -0600 Subject: [PATCH] more renaming --- asm/battle_anim_80FE840.s | 12 +- asm/battle_link_817C95C.s | 134 +- asm/contest.s | 12 +- asm/pokemon_item_effect.s | 2 +- data/battle_scripts_1.s | 26 +- include/battle.h | 68 +- include/battle_ai_script_commands.h | 4 +- include/battle_interface.h | 2 +- include/recorded_battle.h | 2 +- src/battle_ai_script_commands.c | 252 +-- src/battle_ai_switch_items.c | 32 +- src/battle_anim.c | 10 +- src/battle_controller_link_opponent.c | 54 +- src/battle_controller_link_partner.c | 18 +- src/battle_controller_opponent.c | 34 +- src/battle_controller_player.c | 36 +- src/battle_controller_player_partner.c | 28 +- src/battle_controller_recorded_opponent.c | 38 +- src/battle_controller_recorded_player.c | 28 +- src/battle_controller_safari.c | 8 +- src/battle_controller_wally.c | 12 +- src/battle_controllers.c | 16 +- src/battle_gfx_sfx_util.c | 68 +- src/battle_interface.c | 48 +- src/battle_main.c | 574 +++---- src/battle_message.c | 60 +- src/battle_script_commands.c | 1844 ++++++++++----------- src/battle_util.c | 392 ++--- src/pokeball.c | 16 +- src/pokemon_2.c | 8 +- src/pokemon_3.c | 14 +- src/recorded_battle.c | 10 +- src/reshow_battle_screen.c | 154 +- sym_ewram.txt | 12 +- 34 files changed, 2014 insertions(+), 2014 deletions(-) diff --git a/asm/battle_anim_80FE840.s b/asm/battle_anim_80FE840.s index 1aee34601..3e3be2100 100644 --- a/asm/battle_anim_80FE840.s +++ b/asm/battle_anim_80FE840.s @@ -29520,7 +29520,7 @@ sub_810D608: @ 810D608 ldrsh r0, [r0, r1] cmp r0, 0 bne _0810D664 - ldr r4, =gBattleMoveAttacker + ldr r4, =gBattlerAttacker ldrb r0, [r4] movs r1, 0x2 bl GetBattlerSpriteCoord @@ -29808,7 +29808,7 @@ sub_810D874: @ 810D874 ldrsh r0, [r0, r1] cmp r0, 0 bne _0810D8B8 - ldr r4, =gBattleMoveAttacker + ldr r4, =gBattlerAttacker ldrb r0, [r4] movs r1, 0x2 bl GetBattlerSpriteCoord @@ -40918,7 +40918,7 @@ sub_8113250: @ 8113250 ldr r0, =gBattleAnimArgs ldrh r0, [r0] strh r0, [r6, 0x3A] - ldr r4, =gBattleMoveAttacker + ldr r4, =gBattlerAttacker ldrb r0, [r4] movs r1, 0 bl sub_80A861C @@ -50065,7 +50065,7 @@ sub_8117E94: @ 8117E94 lsls r0, 24 lsrs r0, 24 ldr r2, =gBattleAnimAttacker - ldr r1, =gBattleMoveTarget + ldr r1, =gBattlerTarget ldrb r1, [r1] strb r1, [r2] ldr r2, =gBattleAnimTarget @@ -50117,7 +50117,7 @@ sub_8117F10: @ 8117F10 lsls r0, 24 lsrs r0, 24 ldr r2, =gBattleAnimTarget - ldr r1, =gBattleMoveTarget + ldr r1, =gBattlerTarget ldrb r1, [r1] strb r1, [r2] bl DestroyAnimVisualTask @@ -50132,7 +50132,7 @@ sub_8117F30: @ 8117F30 lsls r0, 24 lsrs r0, 24 ldr r2, =gBattleAnimAttacker - ldr r1, =gBattleMoveAttacker + ldr r1, =gBattlerAttacker ldrb r1, [r1] strb r1, [r2] ldr r2, =gBattleAnimTarget diff --git a/asm/battle_link_817C95C.s b/asm/battle_link_817C95C.s index 61e303417..dcfd89132 100644 --- a/asm/battle_link_817C95C.s +++ b/asm/battle_link_817C95C.s @@ -34,12 +34,12 @@ _0817C988: movs r1, 0x81 lsls r1, 2 adds r7, r0, r1 - ldr r5, =gBattleMoveAttacker + ldr r5, =gBattlerAttacker ldrb r0, [r5] bl GetBattlerSide lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gBattleMoveTarget + ldr r0, =gBattlerTarget ldrb r0, [r0] bl GetBattlerSide lsls r0, 24 @@ -83,7 +83,7 @@ _0817CA10: str r1, [sp, 0x8] cmp r6, 0 bne _0817CA3C - ldr r0, =gBattleMoveTarget + ldr r0, =gBattlerTarget ldrb r0, [r0] lsls r0, 1 adds r0, r2 @@ -94,7 +94,7 @@ _0817CA10: b _0817CA4C .pool _0817CA3C: - ldr r0, =gBattleMoveTarget + ldr r0, =gBattlerTarget ldrb r0, [r0] lsls r0, 1 adds r0, r2 @@ -105,7 +105,7 @@ _0817CA3C: _0817CA4C: adds r1, r0 str r1, [sp, 0xC] - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] ldr r1, =gStringInfo ldr r1, [r1] @@ -134,13 +134,13 @@ _0817CA4C: bl _0817E0A2 .pool _0817CA9C: - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] bl GetBattlerPosition lsls r0, 24 lsrs r0, 25 mov r8, r0 - ldr r0, =gBattleMoveTarget + ldr r0, =gBattlerTarget ldrb r0, [r0] bl GetBattlerPosition lsls r0, 24 @@ -572,7 +572,7 @@ _0817D0DC: lsls r3, 2 adds r3, r7, r3 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -602,7 +602,7 @@ _0817D124: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -635,7 +635,7 @@ _0817D16C: lsls r0, 2 adds r5, r7, r0 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -716,7 +716,7 @@ _0817D216: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -776,7 +776,7 @@ _0817D296: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -834,7 +834,7 @@ _0817D314: adds r3, r0 adds r3, r7, r3 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -940,8 +940,8 @@ _0817D3F2: bne _0817D3FE bl _0817E0A6 _0817D3FE: - ldr r0, =gBattleMoveAttacker - ldr r1, =gBattleMoveTarget + ldr r0, =gBattlerAttacker + ldr r1, =gBattlerTarget ldrb r0, [r0] ldrb r1, [r1] cmp r0, r1 @@ -1015,7 +1015,7 @@ _0817D498: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1092,7 +1092,7 @@ _0817D53C: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1162,7 +1162,7 @@ _0817D5CE: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1227,7 +1227,7 @@ _0817D65E: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker 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, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r5 @@ -1354,7 +1354,7 @@ _0817D76C: bl _0817E0A6 _0817D77E: ldr r6, =gBattlerPartyIndexes - ldr r5, =gBattleMoveAttacker + ldr r5, =gBattlerAttacker 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, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker 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, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r5 @@ -1498,7 +1498,7 @@ _0817D8A4: _0817D8B6: ldr r2, =gBattlerPartyIndexes mov r8, r2 - ldr r6, =gBattleMoveAttacker + ldr r6, =gBattlerAttacker ldrb r0, [r6] lsls r0, 1 add r0, r8 @@ -1574,7 +1574,7 @@ _0817D94C: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker 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, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r5 @@ -1672,7 +1672,7 @@ _0817D9C2: .pool _0817DA24: ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker 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, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r5 @@ -1748,7 +1748,7 @@ _0817DA68: .pool _0817DACC: ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker 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, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r5 @@ -1839,7 +1839,7 @@ _0817DB76: .pool _0817DB90: ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1876,7 +1876,7 @@ _0817DBD4: adds r3, r0 adds r3, r7, r3 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -1944,7 +1944,7 @@ _0817DC62: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2022,7 +2022,7 @@ _0817DCFC: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2050,7 +2050,7 @@ _0817DD38: adds r2, r0 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2122,7 +2122,7 @@ _0817DDC8: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2155,7 +2155,7 @@ _0817DE10: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2254,7 +2254,7 @@ _0817DEDC: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2332,7 +2332,7 @@ _0817DF70: lsls r2, 2 adds r2, r7, r2 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2414,7 +2414,7 @@ _0817DFE6: ands r0, r2 strb r0, [r1] ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -2557,14 +2557,14 @@ _0817E122: lsls r1, 2 adds r1, r0, r1 str r1, [sp, 0x8] - ldr r2, =gBattleMoveAttacker + ldr r2, =gBattlerAttacker mov r10, r2 ldrb r0, [r2] bl GetBattlerSide lsls r0, 24 lsrs r0, 24 mov r9, r0 - ldr r0, =gBattleMoveTarget + ldr r0, =gBattlerTarget ldrb r0, [r0] bl GetBattlerSide lsls r0, 24 @@ -2812,7 +2812,7 @@ sub_817E32C: @ 817E32C movs r1, 0x81 lsls r1, 2 adds r4, r0, r1 - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] bl GetBattlerSide lsls r0, 24 @@ -3244,12 +3244,12 @@ sub_817E684: @ 817E684 movs r2, 0x81 lsls r2, 2 adds r7, r0, r2 - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] bl GetBattlerSide lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gBattleMoveTarget + ldr r0, =gBattlerTarget ldrb r0, [r0] bl GetBattlerSide lsls r0, 24 @@ -3298,7 +3298,7 @@ _0817E6F0: .4byte _0817E760 _0817E760: ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker 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, =gBattleMoveAttacker + ldr r3, =gBattlerAttacker ldrh r0, [r1] cmp r6, r0 bne _0817E7E0 @@ -3708,13 +3708,13 @@ sub_817EA80: @ 817EA80 movs r1, 0x81 lsls r1, 2 adds r5, r0, r1 - ldr r3, =gBattleMoveAttacker + ldr r3, =gBattlerAttacker mov r8, r3 ldrb r0, [r3] bl GetBattlerSide lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gBattleMoveTarget + ldr r0, =gBattlerTarget ldrb r0, [r0] bl GetBattlerSide lsls r0, 24 @@ -4006,7 +4006,7 @@ _0817ECCC: lsrs r0, 5 subs r6, r0, 0x1 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -4165,7 +4165,7 @@ _0817EE1C: bne _0817EEBC adds r2, r4, 0 ldr r1, =gBattlerPartyIndexes - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] lsls r0, 1 adds r0, r1 @@ -4269,7 +4269,7 @@ sub_817EECC: @ 817EECC beq _0817EEE6 b _0817F1FA _0817EEE6: - ldr r4, =gBattleMoveAttacker + ldr r4, =gBattlerAttacker ldrb r0, [r4] bl GetBattlerSide lsls r0, 24 @@ -4291,7 +4291,7 @@ _0817EEF8: bgt _0817EF10 b _0817F1FA _0817EF10: - ldr r0, =gBattleMoveTarget + ldr r0, =gBattlerTarget ldrb r0, [r0] muls r0, r1 adds r0, r5 @@ -4367,7 +4367,7 @@ _0817EF8A: beq _0817EF98 b _0817F1FA _0817EF98: - ldr r2, =gBattleMoveAttacker + ldr r2, =gBattlerAttacker 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, =gBattleMoveTarget + ldr r4, =gBattlerTarget mov r9, r4 _0817EFC2: lsls r1, r5, 1 - ldr r6, =gBattleMoveAttacker + ldr r6, =gBattlerAttacker ldrb r0, [r6] movs r2, 0x58 muls r0, r2 @@ -4420,7 +4420,7 @@ _0817EFC2: lsls r1, 1 adds r1, r4 ldrh r3, [r1] - ldr r2, =gBattleMoveAttacker + ldr r2, =gBattlerAttacker 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, =gBattleMoveAttacker + ldr r6, =gBattlerAttacker 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, =gBattleMoveAttacker + ldr r2, =gBattlerAttacker ldrb r0, [r2] lsls r0, 2 adds r0, r1 @@ -4472,7 +4472,7 @@ _0817EFC2: str r0, [r4] _0817F06A: ldr r0, =gProtectStructs - ldr r6, =gBattleMoveAttacker + ldr r6, =gBattlerAttacker ldrb r1, [r6] lsls r1, 4 adds r1, r0 @@ -4513,7 +4513,7 @@ _0817F0B4: cmp r5, 0x3 ble _0817EFC2 movs r5, 0 - ldr r3, =gBattleMoveAttacker + ldr r3, =gBattlerAttacker ldr r6, =gMoveSelectionCursor ldr r4, =gBattlerPartyIndexes mov r8, r4 @@ -4545,9 +4545,9 @@ _0817F0D8: movs r7, 0 _0817F0F6: movs r5, 0 - ldr r4, =gBattleMoveTarget + ldr r4, =gBattlerTarget ldr r6, =gEnemyParty - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker 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, =gBattleMoveAttacker + ldr r2, =gBattlerAttacker 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, =gBattleMoveAttacker + ldr r4, =gBattlerAttacker ldrb r3, [r4] mov r2, r10 adds r0, r3, r2 @@ -4625,7 +4625,7 @@ _0817F1D4: _0817F1DC: ldr r2, =gBattleMoveDamage ldr r1, =gMoveSelectionCursor - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] adds r0, r1 ldrb r0, [r0] @@ -4695,7 +4695,7 @@ _0817F270: cmp r2, 0x95 bne _0817F294 ldr r2, =gBattleMons - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r1, [r0] movs r0, 0x58 muls r0, r1 diff --git a/asm/contest.s b/asm/contest.s index 8f5ff780e..87abc1d06 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -1058,9 +1058,9 @@ _080D8004: strb r2, [r1, 0x3] ldr r0, =gBattleTypeFlags str r4, [r0] - ldr r4, =gBattleMoveAttacker + ldr r4, =gBattlerAttacker strb r2, [r4] - ldr r0, =gBattleMoveTarget + ldr r0, =gBattlerTarget strb r3, [r0] bl sub_80DB0C4 ldr r2, =gBattlerSpriteIds @@ -2548,7 +2548,7 @@ _080D8DD0: adds r4, r0 strh r5, [r4, 0xC] ldr r1, =gBattlerSpriteIds - ldr r0, =gBattleMoveAttacker + ldr r0, =gBattlerAttacker ldrb r0, [r0] adds r0, r1 strb r5, [r0] @@ -13798,7 +13798,7 @@ sub_80DEA20: @ 80DEA20 bl CreateInvisibleSpriteWithCallback ldr r1, =gBattlerSpriteIds strb r0, [r1, 0x3] - ldr r0, =gBattleMoveTarget + ldr r0, =gBattlerTarget ldrb r0, [r0] adds r0, r1 ldrb r1, [r0] @@ -13905,12 +13905,12 @@ _080DEAD0: .4byte _080DEB60 .4byte _080DEB60 _080DEB54: - ldr r1, =gBattleMoveTarget + ldr r1, =gBattlerTarget movs r0, 0x2 b _080DEB64 .pool _080DEB60: - ldr r1, =gBattleMoveTarget + ldr r1, =gBattlerTarget movs r0, 0x3 _080DEB64: strb r0, [r1] diff --git a/asm/pokemon_item_effect.s b/asm/pokemon_item_effect.s index 928eb5550..be7d3be49 100644 --- a/asm/pokemon_item_effect.s +++ b/asm/pokemon_item_effect.s @@ -100,7 +100,7 @@ _0806BDBC: lsrs r0, 24 _0806BDC4: str r0, [sp, 0x34] - ldr r1, =gStringBank + ldr r1, =gStringBattler ldr r0, =gBankInMenu ldrb r2, [r0] strb r2, [r1] diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 8eb3deaf2..4d8b22186 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, gBattleMoveTarget + copybyte gEffectBank, gBattlerTarget setbyte cMULTISTRING_CHOOSER, 0x0 call BattleScript_PSNPrevention goto BattleScript_MoveEnd @@ -1055,7 +1055,7 @@ BattleScript_AlreadyParalyzed:: goto BattleScript_MoveEnd BattleScript_LimberProtected:: - copybyte gEffectBank, gBattleMoveTarget + copybyte gEffectBank, gBattlerTarget 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 gBattleMoveTarget, gBattleMoveAttacker + copybyte gBattlerTarget, gBattlerAttacker setbyte sANIM_TURN, 0x1 attackanimation waitanimation @@ -1534,7 +1534,7 @@ BattleScript_CurseTryDefence:: BattleScript_CurseEnd:: goto BattleScript_MoveEnd BattleScript_GhostCurse:: - jumpifbytenotequal gBattleMoveAttacker, gBattleMoveTarget, BattleScript_DoGhostCurse + jumpifbytenotequal gBattlerAttacker, gBattlerTarget, BattleScript_DoGhostCurse getmovetarget ATTACKER BattleScript_DoGhostCurse:: attackcanceler @@ -2217,7 +2217,7 @@ BattleScript_EffectWillOWisp:: goto BattleScript_MoveEnd BattleScript_WaterVeilPrevents:: - copybyte gEffectBank, gBattleMoveTarget + copybyte gEffectBank, gBattlerTarget setbyte cMULTISTRING_CHOOSER, 0x0 call BattleScript_BRNPrevention goto BattleScript_MoveEnd @@ -2598,11 +2598,11 @@ BattleScript_EffectTeeterDance:: attackcanceler attackstring ppreduce - setbyte gBattleMoveTarget, 0x0 + setbyte gBattlerTarget, 0x0 BattleScript_TeeterDanceLoop:: movevaluescleanup setmoveeffect EFFECT_CONFUSION - jumpifbyteequal gBattleMoveAttacker, gBattleMoveTarget, BattleScript_TeeterDanceLoopIncrement + jumpifbyteequal gBattlerAttacker, gBattlerTarget, 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 gBattleMoveTarget, 0x1 - jumpifbytenotequal gBattleMoveTarget, gBattlersCount, BattleScript_TeeterDanceLoop + addbyte gBattlerTarget, 0x1 + jumpifbytenotequal gBattlerTarget, gBattlersCount, BattleScript_TeeterDanceLoop end BattleScript_TeeterDanceOwnTempoPrevents:: @@ -3228,7 +3228,7 @@ BattleScript_DamagingWeatherContinues:: playanimation2 ATTACKER, sANIM_ARG1, NULL setbyte gBattleCommunication, 0x0 BattleScript_DamagingWeatherLoop:: - copyarraywithindex gBattleMoveAttacker, gBattleTurnOrder, gBattleCommunication, 0x1 + copyarraywithindex gBattlerAttacker, gBattleTurnOrder, gBattleCommunication, 0x1 weatherdamage jumpifword EQUAL, gBattleMoveDamage, 0x0, BattleScript_DamagingWeatherLoopIncrement printfromtable gSandStormHailDmgStringIds @@ -3521,7 +3521,7 @@ BattleScript_RapidSpinAway:: BattleScript_WrapFree:: printstring STRINGID_PKMNGOTFREE waitmessage 0x40 - copybyte gBattleMoveTarget, sBANK + copybyte gBattlerTarget, sBANK return BattleScript_LeechSeedFree:: @@ -4053,7 +4053,7 @@ BattleScript_82DB4B8:: BattleScript_82DB4BE:: pause 0x20 BattleScript_82DB4C1:: - setbyte gBattleMoveTarget, 0x0 + setbyte gBattlerTarget, 0x0 setstatchanger ATK, 1, TRUE BattleScript_82DB4CD:: trygetintimidatetarget BattleScript_82DB51B @@ -4068,7 +4068,7 @@ BattleScript_82DB4CD:: printstring STRINGID_PKMNCUTSATTACKWITH waitmessage 0x40 BattleScript_82DB510:: - addbyte gBattleMoveTarget, 0x1 + addbyte gBattlerTarget, 0x1 goto BattleScript_82DB4CD BattleScript_82DB51B:: return diff --git a/include/battle.h b/include/battle.h index eafa72098..81c1d341d 100644 --- a/include/battle.h +++ b/include/battle.h @@ -13,17 +13,18 @@ /* * 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 battler number is usually the same - * as the position, except in the case of link battles. + * The second bit determines what flank the battler is on, either the left or right. + * Note that the opponent's flanks are drawn corresponding to their perspective, so + * their right mon appears on the left, and their left mon appears on the right. + * The battler ID is usually the same as the position, except in the case of link battles. * * + ------------------------- + - * | Opponent's side | + * | Opponent's side | + * | Right Left | * | 3 1 | * | | - * | | * | Player's side | + * | Left Right | * | 0 2 | * ----------------------------+ * | | @@ -38,12 +39,16 @@ #define B_POSITION_PLAYER_RIGHT 2 #define B_POSITION_OPPONENT_RIGHT 3 -#define B_POSITION_PARTNER(position) ((position) ^ 2) -#define B_POSITION_OPPOSITE(position) ((position) ^ 1) +// These macros can be used with either battler ID or positions to get the partner or the opposite mon +#define BATTLE_OPPOSITE(id) ((id) ^ 1) +#define BATTLE_PARTNER(id) ((id) ^ 2) #define B_SIDE_PLAYER 0 #define B_SIDE_OPPONENT 1 +#define B_FLANK_LEFT 0 +#define B_FLANK_RIGHT 1 + #define BIT_SIDE 1 #define BIT_FLANK 2 @@ -170,7 +175,7 @@ extern u8 gBattleOutcome; extern u32 gStatuses3[MAX_BATTLERS_COUNT]; -// +// Not really sure what a "hitmarker" is. #define HITMARKER_x10 0x00000010 #define HITMARKER_x20 0x00000020 @@ -214,21 +219,24 @@ extern u32 gHitMarker; extern u16 gSideStatuses[2]; -#define ACTION_USE_MOVE 0 -#define ACTION_USE_ITEM 1 -#define ACTION_SWITCH 2 -#define ACTION_RUN 3 -#define ACTION_WATCHES_CAREFULLY 4 -#define ACTION_SAFARI_ZONE_BALL 5 -#define ACTION_POKEBLOCK_CASE 6 -#define ACTION_GO_NEAR 7 -#define ACTION_SAFARI_ZONE_RUN 8 -#define ACTION_9 9 -#define ACTION_RUN_BATTLESCRIPT 10 // when executing an action -#define ACTION_CANCEL_PARTNER 12 // when choosing an action -#define ACTION_FINISHED 12 // when executing an action -#define ACTION_NOTHING_FAINTED 13 // when choosing an action -#define ACTION_INIT_VALUE 0xFF +// Battle Actions +// These determine what each battler will do in a turn +#define B_ACTION_USE_MOVE 0 +#define B_ACTION_USE_ITEM 1 +#define B_ACTION_SWITCH 2 +#define B_ACTION_RUN 3 +#define B_ACTION_SAFARI_WATCH_CAREFULLY 4 +#define B_ACTION_SAFARI_BALL 5 +#define B_ACTION_SAFARI_POKEBLOCK 6 +#define B_ACTION_SAFARI_GO_NEAR 7 +#define B_ACTION_SAFARI_RUN 8 +// The exact purposes of these are unclear +#define B_ACTION_UNKNOWN9 9 +#define B_ACTION_EXEC_SCRIPT 10 // when executing an action +#define B_ACTION_CANCEL_PARTNER 12 // when choosing an action +#define B_ACTION_FINISHED 12 // when executing an action +#define B_ACTION_NOTHING_FAINTED 13 // when choosing an action +#define B_ACTION_NONE 0xFF #define MOVE_RESULT_MISSED (1 << 0) #define MOVE_RESULT_SUPER_EFFECTIVE (1 << 1) @@ -421,8 +429,8 @@ struct DisableStruct /*0x12*/ u8 chargeTimer2 : 4; /*0x13*/ u8 tauntTimer1:4; /*0x13*/ u8 tauntTimer2:4; - /*0x14*/ u8 bankPreventingEscape; - /*0x15*/ u8 bankWithSureHit; + /*0x14*/ u8 battlerPreventingEscape; + /*0x15*/ u8 battlerWithSureHit; /*0x16*/ u8 isFirstTurn; /*0x17*/ u8 unk17; /*0x18*/ u8 truantCounter : 1; @@ -594,10 +602,6 @@ struct BattleResources extern struct BattleResources* gBattleResources; -#define BATTLESCRIPTS_STACK (gBattleResources->battleScriptsStack) -#define BATTLE_CALLBACKS_STACK (gBattleResources->battleCallbackStack) -#define BATTLE_LVLUP_STATS (gBattleResources->statsBeforeLvlUp) - struct BattleResults { u8 playerFaintCounter; // 0x0 @@ -836,7 +840,7 @@ struct BattleScripting u8 animArg2; u16 tripleKickPower; u8 atk49_state; - u8 bankWithAbility; + u8 battlerWithAbility; u8 multihitMoveEffect; u8 battler; u8 animTurn; @@ -946,7 +950,7 @@ struct BattleBarInfo struct BattleSpriteData { - struct BattleSpriteInfo *bankData; + struct BattleSpriteInfo *battlerData; struct BattleHealthboxInfo *healthBoxesData; struct BattleAnimationInfo *animationData; struct BattleBarInfo *battleBars; diff --git a/include/battle_ai_script_commands.h b/include/battle_ai_script_commands.h index 5fb422b41..316f76de6 100644 --- a/include/battle_ai_script_commands.h +++ b/include/battle_ai_script_commands.h @@ -4,9 +4,9 @@ void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves); void BattleAI_SetupAIData(u8 defaultScoreMoves); u8 BattleAI_ChooseMoveOrAction(void); -void ClearBankMoveHistory(u8 bank); +void ClearBattlerMoveHistory(u8 bank); void RecordAbilityBattle(u8 bank, u8 abilityId); -void ClearBankAbilityHistory(u8 bank); +void ClearBattlerAbilityHistory(u8 bank); void RecordItemEffectBattle(u8 bank, u8 itemEffect); void ClearBankItemEffectHistory(u8 bank); diff --git a/include/battle_interface.h b/include/battle_interface.h index 5ccec56ca..fe8c03f70 100644 --- a/include/battle_interface.h +++ b/include/battle_interface.h @@ -54,7 +54,7 @@ enum HEALTHBOX_SAFARI_BALLS_TEXT }; -u8 CreateHealthboxSprites(u8 bank); +u8 CreateBattlerHealthboxSprites(u8 bank); u8 CreateSafariPlayerHealthboxSprites(void); void SetBattleBarStruct(u8 bank, u8 healthboxSpriteId, s32 maxVal, s32 currVal, s32 receivedValue); void SetHealthboxSpriteInvisible(u8 healthboxSpriteId); diff --git a/include/recorded_battle.h b/include/recorded_battle.h index 5c7bdc983..296245a24 100644 --- a/include/recorded_battle.h +++ b/include/recorded_battle.h @@ -9,7 +9,7 @@ void sub_8184DA4(u8 arg0); void sub_8184E58(void); void RecordedBattle_SetBattlerAction(u8 bank, u8 action); void RecordedBattle_ClearBattlerAction(u8 bank, u8 bytesToClear); -u8 RecordedBattle_GetBankAction(u8 bank); +u8 RecordedBattle_GetBattlerAction(u8 bank); u8 sub_81850D0(void); u8 sub_81850DC(u8 *arg0); void sub_81851A8(u8 *arg0); diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 3e8d8d40e..355d81d2c 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -48,7 +48,7 @@ extern u32 gBattleTypeFlags; extern u8 gActiveBattler; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; extern u16 gCurrentMove; -extern u8 gBattleMoveTarget; +extern u8 gBattlerTarget; extern u8 gAbsentBattlerFlags; extern u16 gLastMoves[MAX_BATTLERS_COUNT]; extern u16 gTrainerBattleOpponent_A; @@ -179,7 +179,7 @@ static void BattleAICmd_if_holds_item(void); // ewram EWRAM_DATA const u8 *gAIScriptPtr = NULL; -EWRAM_DATA static u8 sBank_AI = 0; +EWRAM_DATA static u8 sBattler_AI = 0; // const rom data @@ -363,18 +363,18 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves) AI_THINKING_STRUCT->simulatedRNG[i] = 100 - (Random() % 16); } gBattleResources->AI_ScriptsStack->size = 0; - sBank_AI = gActiveBattler; + sBattler_AI = gActiveBattler; // decide a random target bank in doubles if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - gBattleMoveTarget = (Random() & BIT_FLANK) + (GetBattlerSide(gActiveBattler) ^ BIT_SIDE); - if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) - gBattleMoveTarget ^= BIT_FLANK; + gBattlerTarget = (Random() & BIT_FLANK) + (GetBattlerSide(gActiveBattler) ^ BIT_SIDE); + if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) + gBattlerTarget ^= BIT_FLANK; } // in singles there's only one choice else { - gBattleMoveTarget = sBank_AI ^ BIT_SIDE; + gBattlerTarget = sBattler_AI ^ BIT_SIDE; } if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) @@ -444,7 +444,7 @@ static u8 BattleAI_ChooseMoveOrAction_Singles(void) for (i = 1; i < 4; i++) { - if (gBattleMons[sBank_AI].moves[i] != 0) // emerald adds an extra move ID check for some reason. + if (gBattleMons[sBattler_AI].moves[i] != 0) // emerald adds an extra move ID check for some reason. { // in ruby, the order of these if statements are reversed. if (currentMoveArray[0] == AI_THINKING_STRUCT->score[i]) @@ -479,7 +479,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void) for (i = 0; i < 4; i++) { - if (i == sBank_AI || gBattleMons[i].hp == 0) + if (i == sBattler_AI || gBattleMons[i].hp == 0) { actionOrMoveIndex[i] = -1; bestMovePointsForTarget[i] = -1; @@ -491,9 +491,9 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void) else BattleAI_SetupAIData(0xF); - gBattleMoveTarget = i; + gBattlerTarget = i; - if ((i & BIT_SIDE) != (sBank_AI & BIT_SIDE)) + if ((i & BIT_SIDE) != (sBattler_AI & BIT_SIDE)) RecordLastUsedMoveByTarget(); AI_THINKING_STRUCT->aiLogicId = 0; @@ -521,7 +521,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void) mostViableMovesNo = 1; for (j = 1; j < 4; j++) { - if (gBattleMons[sBank_AI].moves[j] != 0) + if (gBattleMons[sBattler_AI].moves[j] != 0) { if (mostViableMovesScores[0] == AI_THINKING_STRUCT->score[j]) { @@ -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_FLANK) && bestMovePointsForTarget[i] < 100) + if (i == (sBattler_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) } } - gBattleMoveTarget = mostViableTargetsArray[Random() % mostViableTargetsNo]; - return actionOrMoveIndex[gBattleMoveTarget]; + gBattlerTarget = mostViableTargetsArray[Random() % mostViableTargetsNo]; + return actionOrMoveIndex[gBattlerTarget]; } static void BattleAI_DoAIProcessing(void) @@ -587,13 +587,13 @@ static void BattleAI_DoAIProcessing(void) break; case AIState_SettingUp: gAIScriptPtr = gBattleAI_ScriptsTable[AI_THINKING_STRUCT->aiLogicId]; // set AI ptr to logic ID. - if (gBattleMons[sBank_AI].pp[AI_THINKING_STRUCT->movesetIndex] == 0) + if (gBattleMons[sBattler_AI].pp[AI_THINKING_STRUCT->movesetIndex] == 0) { AI_THINKING_STRUCT->moveConsidered = 0; } else { - AI_THINKING_STRUCT->moveConsidered = gBattleMons[sBank_AI].moves[AI_THINKING_STRUCT->movesetIndex]; + AI_THINKING_STRUCT->moveConsidered = gBattleMons[sBattler_AI].moves[AI_THINKING_STRUCT->movesetIndex]; } AI_THINKING_STRUCT->aiState++; break; @@ -627,18 +627,18 @@ static void RecordLastUsedMoveByTarget(void) for (i = 0; i < 4; i++) { - if (gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] == gLastMoves[gBattleMoveTarget]) + if (gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] == gLastMoves[gBattlerTarget]) break; - if (gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] != gLastMoves[gBattleMoveTarget] // HACK: This redundant condition is a hack to make the asm match. - && gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] == 0) + if (gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] != gLastMoves[gBattlerTarget] // HACK: This redundant condition is a hack to make the asm match. + && gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] == 0) { - gBattleResources->battleHistory->usedMoves[gBattleMoveTarget].moves[i] = gLastMoves[gBattleMoveTarget]; + gBattleResources->battleHistory->usedMoves[gBattlerTarget].moves[i] = gLastMoves[gBattlerTarget]; break; } } } -void ClearBankMoveHistory(u8 bank) +void ClearBattlerMoveHistory(u8 bank) { s32 i; @@ -651,7 +651,7 @@ void RecordAbilityBattle(u8 bank, u8 abilityId) gBattleResources->battleHistory->abilities[bank] = abilityId; } -void ClearBankAbilityHistory(u8 bank) +void ClearBattlerAbilityHistory(u8 bank) { gBattleResources->battleHistory->abilities[bank] = 0; } @@ -721,9 +721,9 @@ static void BattleAICmd_if_hp_less_than(void) u16 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -736,9 +736,9 @@ static void BattleAICmd_if_hp_more_than(void) u16 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -751,9 +751,9 @@ static void BattleAICmd_if_hp_equal(void) u16 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -766,9 +766,9 @@ static void BattleAICmd_if_hp_not_equal(void) u16 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -782,9 +782,9 @@ static void BattleAICmd_if_status(void) u32 status; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; status = AIScriptRead32(gAIScriptPtr + 2); @@ -800,9 +800,9 @@ static void BattleAICmd_if_not_status(void) u32 status; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; status = AIScriptRead32(gAIScriptPtr + 2); @@ -818,9 +818,9 @@ static void BattleAICmd_if_status2(void) u32 status; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; status = AIScriptRead32(gAIScriptPtr + 2); @@ -836,9 +836,9 @@ static void BattleAICmd_if_not_status2(void) u32 status; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; status = AIScriptRead32(gAIScriptPtr + 2); @@ -854,9 +854,9 @@ static void BattleAICmd_if_status3(void) u32 status; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; status = AIScriptRead32(gAIScriptPtr + 2); @@ -872,9 +872,9 @@ static void BattleAICmd_if_not_status3(void) u32 status; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; status = AIScriptRead32(gAIScriptPtr + 2); @@ -890,9 +890,9 @@ static void BattleAICmd_if_side_affecting(void) u32 side, status; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; side = GET_BATTLER_SIDE(bank); status = AIScriptRead32(gAIScriptPtr + 2); @@ -909,9 +909,9 @@ static void BattleAICmd_if_not_side_affecting(void) u32 side, status; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; side = GET_BATTLER_SIDE(bank); status = AIScriptRead32(gAIScriptPtr + 2); @@ -1084,8 +1084,8 @@ static void BattleAICmd_if_user_has_attacking_move(void) for (i = 0; i < 4; i++) { - if (gBattleMons[sBank_AI].moves[i] != 0 - && gBattleMoves[gBattleMons[sBank_AI].moves[i]].power != 0) + if (gBattleMons[sBattler_AI].moves[i] != 0 + && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].power != 0) break; } if (i == 4) @@ -1100,8 +1100,8 @@ static void BattleAICmd_if_user_has_no_attacking_moves(void) for (i = 0; i < 4; i++) { - if (gBattleMons[sBank_AI].moves[i] != 0 - && gBattleMoves[gBattleMons[sBank_AI].moves[i]].power != 0) + if (gBattleMons[sBattler_AI].moves[i] != 0 + && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].power != 0) break; } if (i != 4) @@ -1123,16 +1123,16 @@ static void BattleAICmd_get_type(void) switch (typeVar) { case AI_TYPE1_USER: // AI user primary type - AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type1; + AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type1; break; case AI_TYPE1_TARGET: // target primary type - AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleMoveTarget].type1; + AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type1; break; case AI_TYPE2_USER: // AI user secondary type - AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type2; + AI_THINKING_STRUCT->funcResult = gBattleMons[sBattler_AI].type2; break; case AI_TYPE2_TARGET: // target secondary type - AI_THINKING_STRUCT->funcResult = gBattleMons[gBattleMoveTarget].type2; + AI_THINKING_STRUCT->funcResult = gBattleMons[gBattlerTarget].type2; break; case AI_TYPE_MOVE: // type of move being pointed to AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type; @@ -1146,14 +1146,14 @@ static u8 BattleAI_GetWantedBank(u8 bank) switch (bank) { case AI_USER: - return sBank_AI; + return sBattler_AI; case AI_TARGET: default: - return gBattleMoveTarget; + return gBattlerTarget; case AI_USER_PARTNER: - return sBank_AI ^ BIT_FLANK; + return sBattler_AI ^ BIT_FLANK; case AI_TARGET_PARTNER: - return gBattleMoveTarget ^ BIT_FLANK; + return gBattlerTarget ^ BIT_FLANK; } } @@ -1203,17 +1203,17 @@ static void BattleAICmd_get_how_powerful_move_is(void) { for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++) { - if (gBattleMoves[gBattleMons[sBank_AI].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i]) + if (gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i]) break; } - if (gBattleMons[sBank_AI].moves[checkedMove] != MOVE_NONE + if (gBattleMons[sBattler_AI].moves[checkedMove] != MOVE_NONE && sDiscouragedPowerfulMoveEffects[i] == 0xFFFF - && gBattleMoves[gBattleMons[sBank_AI].moves[checkedMove]].power > 1) + && gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].power > 1) { - gCurrentMove = gBattleMons[sBank_AI].moves[checkedMove]; - AI_CalcDmg(sBank_AI, gBattleMoveTarget); - TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget); + gCurrentMove = gBattleMons[sBattler_AI].moves[checkedMove]; + AI_CalcDmg(sBattler_AI, gBattlerTarget); + TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); moveDmgs[checkedMove] = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[checkedMove] / 100; if (moveDmgs[checkedMove] == 0) moveDmgs[checkedMove] = 1; @@ -1246,9 +1246,9 @@ static void BattleAICmd_get_how_powerful_move_is(void) static void BattleAICmd_get_last_used_bank_move(void) { if (gAIScriptPtr[1] == AI_USER) - AI_THINKING_STRUCT->funcResult = gLastMoves[sBank_AI]; + AI_THINKING_STRUCT->funcResult = gLastMoves[sBattler_AI]; else - AI_THINKING_STRUCT->funcResult = gLastMoves[gBattleMoveTarget]; + AI_THINKING_STRUCT->funcResult = gLastMoves[gBattlerTarget]; 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, gBattleMoveTarget, TRUE) == gAIScriptPtr[1]) + if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, 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, gBattleMoveTarget, TRUE) != gAIScriptPtr[1]) + if (GetWhoStrikesFirst(sBattler_AI, gBattlerTarget, TRUE) != gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -1303,9 +1303,9 @@ static void BattleAICmd_count_usable_party_mons(void) AI_THINKING_STRUCT->funcResult = 0; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; if (GetBattlerSide(bank) == B_SIDE_PLAYER) party = gPlayerParty; @@ -1356,9 +1356,9 @@ static void BattleAICmd_get_ability(void) u8 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; if (gActiveBattler != bank) { @@ -1489,11 +1489,11 @@ static void BattleAICmd_get_highest_type_effectiveness(void) for (i = 0; i < 4; i++) { gBattleMoveDamage = AI_EFFECTIVENESS_x1; - gCurrentMove = gBattleMons[sBank_AI].moves[i]; + gCurrentMove = gBattleMons[sBattler_AI].moves[i]; if (gCurrentMove) { - TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget); + TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); // 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, gBattleMoveTarget); + TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); if (gBattleMoveDamage == 120) gBattleMoveDamage = AI_EFFECTIVENESS_x2; @@ -1569,10 +1569,10 @@ static void BattleAICmd_if_status_in_party(void) switch(gAIScriptPtr[1]) { case AI_USER: - bank = sBank_AI; + bank = sBattler_AI; break; default: - bank = gBattleMoveTarget; + bank = gBattlerTarget; break; } @@ -1606,10 +1606,10 @@ static void BattleAICmd_if_status_not_in_party(void) switch(gAIScriptPtr[1]) { case 1: - bank = sBank_AI; + bank = sBattler_AI; break; default: - bank = gBattleMoveTarget; + bank = gBattlerTarget; break; } @@ -1667,9 +1667,9 @@ static void BattleAICmd_if_stat_level_less_than(void) u32 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; if (gBattleMons[bank].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); @@ -1682,9 +1682,9 @@ static void BattleAICmd_if_stat_level_more_than(void) u32 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; if (gBattleMons[bank].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); @@ -1697,9 +1697,9 @@ static void BattleAICmd_if_stat_level_equal(void) u32 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; if (gBattleMons[bank].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); @@ -1712,9 +1712,9 @@ static void BattleAICmd_if_stat_level_not_equal(void) u32 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; 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, gBattleMoveTarget); - TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget); + AI_CalcDmg(sBattler_AI, gBattlerTarget); + TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); 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[gBattleMoveTarget].hp <= gBattleMoveDamage) + if (gBattleMons[gBattlerTarget].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, gBattleMoveTarget); - TypeCalc(gCurrentMove, sBank_AI, gBattleMoveTarget); + AI_CalcDmg(sBattler_AI, gBattlerTarget); + TypeCalc(gCurrentMove, sBattler_AI, gBattlerTarget); gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100; // this macro is missing the damage 0 = 1 assumption. - if (gBattleMons[gBattleMoveTarget].hp > gBattleMoveDamage) + if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1788,7 +1788,7 @@ static void BattleAICmd_if_has_move(void) case AI_USER: for (i = 0; i < 4; i++) { - if (gBattleMons[sBank_AI].moves[i] == *movePtr) + if (gBattleMons[sBattler_AI].moves[i] == *movePtr) break; } if (i == 4) @@ -1802,7 +1802,7 @@ static void BattleAICmd_if_has_move(void) return; } case AI_USER_PARTNER: - if (gBattleMons[sBank_AI ^ BIT_FLANK].hp == 0) + if (gBattleMons[sBattler_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_FLANK].moves[i] == *movePtr) + if (gBattleMons[sBattler_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[gBattleMoveTarget].moves[i] == *movePtr) + if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == *movePtr) break; } if (i == 4) @@ -1856,7 +1856,7 @@ static void BattleAICmd_if_doesnt_have_move(void) case AI_USER_PARTNER: // UB: no separate check for user partner for (i = 0; i < 4; i++) { - if (gBattleMons[sBank_AI].moves[i] == *movePtr) + if (gBattleMons[sBattler_AI].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[gBattleMoveTarget].moves[i] == *movePtr) + if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == *movePtr) break; } if (i != 4) @@ -1899,7 +1899,7 @@ static void BattleAICmd_if_has_move_with_effect(void) case AI_USER_PARTNER: for (i = 0; i < 4; i++) { - if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBank_AI].moves[i]].effect == gAIScriptPtr[2]) + if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].effect == gAIScriptPtr[2]) break; } 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 gBattleMoveTarget - if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i]].effect == gAIScriptPtr[2]) + // UB: checks sBattler_AI instead of gBattlerTarget + if (gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i]].effect == gAIScriptPtr[2]) break; } if (i == 4) @@ -1933,7 +1933,7 @@ static void BattleAICmd_if_doesnt_have_move_with_effect(void) case AI_USER_PARTNER: for (i = 0; i < 4; i++) { - if(gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBank_AI].moves[i]].effect == gAIScriptPtr[2]) + if(gBattleMons[sBattler_AI].moves[i] != 0 && gBattleMoves[gBattleMons[sBattler_AI].moves[i]].effect == gAIScriptPtr[2]) break; } 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[gBattleMoveTarget].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattleMoveTarget].moves[i]].effect == gAIScriptPtr[2]) + if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i]].effect == gAIScriptPtr[2]) break; } if (i != 4) @@ -1961,9 +1961,9 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void) u8 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; if (gAIScriptPtr[2] == 0) { @@ -2039,9 +2039,9 @@ static void BattleAICmd_get_hold_effect(void) u8 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; if (gActiveBattler != bank) AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]); @@ -2057,7 +2057,7 @@ static void BattleAICmd_if_holds_item(void) u16 item; u8 var1, var2; - if ((bank & BIT_SIDE) == (sBank_AI & BIT_SIDE)) + if ((bank & BIT_SIDE) == (sBattler_AI & BIT_SIDE)) item = gBattleMons[bank].item; else item = BATTLE_HISTORY->itemEffects[bank]; @@ -2077,9 +2077,9 @@ static void BattleAICmd_get_gender(void) u8 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[bank].species, gBattleMons[bank].personality); @@ -2091,9 +2091,9 @@ static void BattleAICmd_is_first_turn_for(void) u8 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].isFirstTurn; @@ -2105,9 +2105,9 @@ static void BattleAICmd_get_stockpile_count(void) u8 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].stockpileCounter; @@ -2126,9 +2126,9 @@ static void BattleAICmd_get_used_held_item(void) u8 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; // This is likely a leftover from Ruby's code and its ugly ewram access #ifdef NONMATCHING @@ -2166,9 +2166,9 @@ static void BattleAICmd_get_protect_count(void) u8 bank; if (gAIScriptPtr[1] == AI_USER) - bank = sBank_AI; + bank = sBattler_AI; else - bank = gBattleMoveTarget; + bank = gBattlerTarget; 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[gBattleMoveTarget].level) + if (gBattleMons[sBattler_AI].level > gBattleMons[gBattlerTarget].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[gBattleMoveTarget].level) + if (gBattleMons[sBattler_AI].level < gBattleMons[gBattlerTarget].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[gBattleMoveTarget].level) + if (gBattleMons[sBattler_AI].level == gBattleMons[gBattlerTarget].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[gBattleMoveTarget].tauntTimer1 != 0) + if (gDisableStructs[gBattlerTarget].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[gBattleMoveTarget].tauntTimer1 == 0) + if (gDisableStructs[gBattlerTarget].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) == (gBattleMoveTarget & BIT_SIDE)) + if ((sBattler_AI & BIT_SIDE) == (gBattlerTarget & 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 1671fad7e..23d223308 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -39,7 +39,7 @@ static bool8 ShouldSwitchIfPerishSong(void) && gDisableStructs[gActiveBattler].perishSongTimer1 == 0) { *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; - BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); return TRUE; } @@ -60,7 +60,7 @@ static bool8 ShouldSwitchIfWonderGuard(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) return FALSE; - opposingPosition = B_POSITION_OPPOSITE(GetBattlerPosition(gActiveBattler)); + opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler)); if (gBattleMons[GetBattlerAtPosition(opposingPosition)].ability != ABILITY_WONDER_GUARD) return FALSE; @@ -121,7 +121,7 @@ static bool8 ShouldSwitchIfWonderGuard(void) { // we found a mon *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; - BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); return TRUE; } } @@ -151,10 +151,10 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { bankIn1 = gActiveBattler; - if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler)))]) + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) bankIn2 = gActiveBattler; else - bankIn2 = GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler))); + bankIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); } else { @@ -221,7 +221,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) { // we found a mon *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; - BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); return TRUE; } } @@ -241,13 +241,13 @@ static bool8 ShouldSwitchIfNaturalCure(void) if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1) { *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; - BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); return TRUE; } else if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0 && Random() & 1) { *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; - BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); return TRUE; } @@ -258,7 +258,7 @@ static bool8 ShouldSwitchIfNaturalCure(void) if (Random() & 1) { *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = 6; - BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); return TRUE; } @@ -273,7 +273,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng) u8 moveFlags; u16 move; - opposingPosition = B_POSITION_OPPOSITE(GetBattlerPosition(gActiveBattler)); + opposingPosition = BATTLE_OPPOSITE(GetBattlerPosition(gActiveBattler)); opposingBank = GetBattlerAtPosition(opposingPosition); if (!(gAbsentBattlerFlags & gBitTable[opposingBank])) @@ -297,7 +297,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) return FALSE; - opposingBank = GetBattlerAtPosition(B_POSITION_PARTNER(opposingPosition)); + opposingBank = GetBattlerAtPosition(BATTLE_PARTNER(opposingPosition)); if (!(gAbsentBattlerFlags & gBitTable[opposingBank])) { @@ -357,10 +357,10 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { bankIn1 = gActiveBattler; - if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler)))]) + if (gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))]) bankIn2 = gActiveBattler; else - bankIn2 = GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gActiveBattler))); + bankIn2 = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))); } else { @@ -426,7 +426,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0) { *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = i; - BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); return TRUE; } } @@ -611,7 +611,7 @@ void AI_TrySwitchOrUseItem(void) } } - BtlController_EmitTwoReturnValues(1, ACTION_USE_MOVE, (gActiveBattler ^ BIT_SIDE) << 8); + BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, (gActiveBattler ^ BIT_SIDE) << 8); } static void ModulateByTypeEffectiveness(u8 atkType, u8 defType1, u8 defType2, u8 *var) @@ -937,7 +937,7 @@ static bool8 ShouldUseItem(void) if (shouldUse) { - BtlController_EmitTwoReturnValues(1, ACTION_USE_ITEM, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_USE_ITEM, 0); *(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 ab9569dcf..34b7a7476 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -25,8 +25,8 @@ #define ANIM_SPRITE_INDEX_COUNT 8 -extern u8 gBattleMoveAttacker; -extern u8 gBattleMoveTarget; +extern u8 gBattlerAttacker; +extern u8 gBattlerTarget; extern u16 gBattle_WIN0H; extern u16 gBattle_WIN0V; extern u16 gBattle_WIN1H; @@ -221,8 +221,8 @@ void ClearBattleAnimationVars(void) void DoMoveAnim(u16 move) { - gBattleAnimAttacker = gBattleMoveAttacker; - gBattleAnimTarget = gBattleMoveTarget; + gBattleAnimAttacker = gBattlerAttacker; + gBattleAnimTarget = gBattlerTarget; LaunchBattleAnimation(gBattleAnims_Moves, move, TRUE); } @@ -665,7 +665,7 @@ bool8 IsBattlerSpriteVisible(u8 bank) return FALSE; if (IsContest()) return TRUE; // this line wont ever be reached. - if (!gBattleSpritesDataPtr->bankData[bank].invisible || !gSprites[gBattlerSpriteIds[bank]].invisible) + if (!gBattleSpritesDataPtr->battlerData[bank].invisible || !gSprites[gBattlerSpriteIds[bank]].invisible) return TRUE; return FALSE; diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index 2ce9d8712..3775cf1fb 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBattleMoveTarget; +extern u8 gBattlerTarget; extern u8 gAbsentBattlerFlags; extern u8 gUnknown_020244B4[]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; @@ -262,7 +262,7 @@ static void sub_8064520(void) else { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy - && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy) + && gSprites[gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]].callback == SpriteCallbackDummy) { r8 = TRUE; } @@ -271,18 +271,18 @@ static void sub_8064520(void) if (r8) { - if (r4 || !IsBattlerSpriteVisible(gActiveBattler ^ BIT_FLANK)) + if (r4 || !IsBattlerSpriteVisible(BATTLE_PARTNER(gActiveBattler))) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x1) return; - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) + if (!gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].field_1_x1) return; 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; + gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].flag_x80 = 0; + gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].field_1_x1 = 0; FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); @@ -318,23 +318,23 @@ static void sub_8064734(void) sub_8172EF0(gActiveBattler, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]]); } if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].flag_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x1) + && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive + && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].flag_x80 + && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].field_1_x1) { - sub_8172EF0(gActiveBattler ^ BIT_FLANK, &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]]); + sub_8172EF0(BATTLE_PARTNER(gActiveBattler), &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]]); } - if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].ballAnimActive) + if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].ballAnimActive && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].ballAnimActive) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80) { if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], HEALTHBOX_ALL); - sub_8076918(gActiveBattler ^ BIT_FLANK); - SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]); + UpdateHealthboxAttribute(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)], &gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], HEALTHBOX_ALL); + sub_8076918(BATTLE_PARTNER(gActiveBattler)); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[BATTLE_PARTNER(gActiveBattler)]); } UpdateHealthboxAttribute(gHealthboxSpriteIds[gActiveBattler], &gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], HEALTHBOX_ALL); sub_8076918(gActiveBattler); @@ -345,7 +345,7 @@ static void sub_8064734(void) if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x40 && gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x80 - && !gBattleSpritesDataPtr->healthBoxesData[gActiveBattler ^ BIT_FLANK].field_1_x40 + && !gBattleSpritesDataPtr->healthBoxesData[BATTLE_PARTNER(gActiveBattler)].field_1_x40 && !IsCryPlayingOrClearCrySongs()) { if (!gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_1_x20) @@ -379,8 +379,8 @@ static void sub_8064734(void) if (IsDoubleBattle() && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - DestroySprite(&gSprites[gUnknown_03005D7C[gActiveBattler ^ BIT_FLANK]]); - SetBattlerShadowSpriteCallback(gActiveBattler ^ BIT_FLANK, GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler ^ BIT_FLANK]], MON_DATA_SPECIES)); + DestroySprite(&gSprites[gUnknown_03005D7C[BATTLE_PARTNER(gActiveBattler)]]); + SetBattlerShadowSpriteCallback(BATTLE_PARTNER(gActiveBattler), GetMonData(&gEnemyParty[gBattlerPartyIndexes[BATTLE_PARTNER(gActiveBattler)]], MON_DATA_SPECIES)); } @@ -485,7 +485,7 @@ static void sub_8064D60(void) { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); gBattlerControllerFuncs[gActiveBattler] = sub_8064DD0; @@ -1239,7 +1239,7 @@ static void DoSwitchOutAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1382,7 +1382,7 @@ static void LinkOpponentHandleFaintAnimation(void) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } @@ -1452,10 +1452,10 @@ static void LinkOpponentDoMoveAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1; InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1473,10 +1473,10 @@ static void LinkOpponentDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } @@ -1763,10 +1763,10 @@ static void sub_8067618(u8 taskId) { gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_8066494(gActiveBattler, FALSE); - gActiveBattler ^= BIT_FLANK; + gActiveBattler = BATTLE_PARTNER(gActiveBattler); gBattleBufferA[gActiveBattler][1] = gBattlerPartyIndexes[gActiveBattler]; sub_8066494(gActiveBattler, FALSE); - gActiveBattler ^= BIT_FLANK; + gActiveBattler = BATTLE_PARTNER(gActiveBattler); } gBattlerControllerFuncs[gActiveBattler] = sub_8064734; gActiveBattler = savedActiveBank; diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 26f808620..340a2b566 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBattleMoveTarget; +extern u8 gBattlerTarget; extern u8 gAbsentBattlerFlags; extern u8 gUnknown_020244B4[]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; @@ -373,7 +373,7 @@ static void sub_814B4E0(void) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { CopyBattleSpriteInvisibility(gActiveBattler); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); gBattlerControllerFuncs[gActiveBattler] = sub_814B554; @@ -1121,7 +1121,7 @@ static void DoSwitchOutAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1201,7 +1201,7 @@ static void LinkPartnerHandleFaintAnimation(void) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } @@ -1274,10 +1274,10 @@ static void LinkPartnerDoMoveAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1; InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1295,10 +1295,10 @@ static void LinkPartnerDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index 2ce339732..760205d90 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -30,7 +30,7 @@ extern u32 gBattleControllerExecFlags; extern u8 gActiveBattler; -extern u8 gBattleMoveTarget; +extern u8 gBattlerTarget; extern u8 gAbsentBattlerFlags; extern bool8 gDoingBattleAnim; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT]; @@ -473,7 +473,7 @@ static void sub_805FC10(void) { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); gBattlerControllerFuncs[gActiveBattler] = sub_805FC80; } @@ -1229,7 +1229,7 @@ static void DoSwitchOutAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1415,7 +1415,7 @@ static void OpponentHandleFaintAnimation(void) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } @@ -1484,10 +1484,10 @@ static void OpponentDoMoveAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1; InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1505,10 +1505,10 @@ static void OpponentDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } @@ -1575,24 +1575,24 @@ static void OpponentHandleChooseMove(void) switch (chosenMoveId) { case 5: - BtlController_EmitTwoReturnValues(1, ACTION_WATCHES_CAREFULLY, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_WATCH_CAREFULLY, 0); break; case 4: - BtlController_EmitTwoReturnValues(1, ACTION_RUN, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_RUN, 0); break; case 6: - BtlController_EmitTwoReturnValues(1, 15, gBattleMoveTarget); + BtlController_EmitTwoReturnValues(1, 15, gBattlerTarget); break; default: if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_x10)) - gBattleMoveTarget = gActiveBattler; + gBattlerTarget = gActiveBattler; if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH) { - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); - if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); } - BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (gBattleMoveTarget << 8)); + BtlController_EmitTwoReturnValues(1, 10, (chosenMoveId) | (gBattlerTarget << 8)); break; } OpponentBufferExecCompleted(); diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index 7a7f87e55..08af2e902 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -300,23 +300,23 @@ static void HandleInputChooseAction(void) switch (gActionSelectionCursor[gActiveBattler]) { case 0: - BtlController_EmitTwoReturnValues(1, ACTION_USE_MOVE, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, 0); break; case 1: - BtlController_EmitTwoReturnValues(1, ACTION_USE_ITEM, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_USE_ITEM, 0); break; case 2: - BtlController_EmitTwoReturnValues(1, ACTION_SWITCH, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); break; case 3: - BtlController_EmitTwoReturnValues(1, ACTION_RUN, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_RUN, 0); break; } PlayerBufferExecCompleted(); } else if (gMain.newKeys & DPAD_LEFT) { - if (gActionSelectionCursor[gActiveBattler] & 1) // if is ACTION_USE_ITEM or ACTION_RUN + if (gActionSelectionCursor[gActiveBattler] & 1) // if is B_ACTION_USE_ITEM or B_ACTION_RUN { PlaySE(SE_SELECT); ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); @@ -326,7 +326,7 @@ static void HandleInputChooseAction(void) } else if (gMain.newKeys & DPAD_RIGHT) { - if (!(gActionSelectionCursor[gActiveBattler] & 1)) // if is ACTION_USE_MOVE or ACTION_SWITCH + if (!(gActionSelectionCursor[gActiveBattler] & 1)) // if is B_ACTION_USE_MOVE or B_ACTION_SWITCH { PlaySE(SE_SELECT); ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); @@ -336,7 +336,7 @@ static void HandleInputChooseAction(void) } else if (gMain.newKeys & DPAD_UP) { - if (gActionSelectionCursor[gActiveBattler] & 2) // if is ACTION_SWITCH or ACTION_RUN + if (gActionSelectionCursor[gActiveBattler] & 2) // if is B_ACTION_SWITCH or B_ACTION_RUN { PlaySE(SE_SELECT); ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); @@ -346,7 +346,7 @@ static void HandleInputChooseAction(void) } else if (gMain.newKeys & DPAD_DOWN) { - if (!(gActionSelectionCursor[gActiveBattler] & 2)) // if is ACTION_USE_MOVE or ACTION_USE_ITEM + if (!(gActionSelectionCursor[gActiveBattler] & 2)) // if is B_ACTION_USE_MOVE or B_ACTION_USE_ITEM { PlaySE(SE_SELECT); ActionSelectionDestroyCursorAt(gActionSelectionCursor[gActiveBattler]); @@ -361,7 +361,7 @@ static void HandleInputChooseAction(void) && !(gAbsentBattlerFlags & gBitTable[GetBattlerAtPosition(B_POSITION_PLAYER_LEFT)]) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - if (gBattleBufferA[gActiveBattler][1] == ACTION_USE_ITEM) + if (gBattleBufferA[gActiveBattler][1] == B_ACTION_USE_ITEM) { // Add item to bag if it is a ball if (itemId <= ITEM_PREMIER_BALL) @@ -370,7 +370,7 @@ static void HandleInputChooseAction(void) return; } PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(1, ACTION_CANCEL_PARTNER, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_CANCEL_PARTNER, 0); PlayerBufferExecCompleted(); } } @@ -1107,7 +1107,7 @@ static void sub_8058EDC(void) FreeSpriteTilesByTag(0x27F9); FreeSpritePaletteByTag(0x27F9); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); gBattlerControllerFuncs[gActiveBattler] = sub_8058FC0; @@ -2278,7 +2278,7 @@ static void DoSwitchOutAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -2434,7 +2434,7 @@ static void PlayerHandleFaintAnimation(void) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } @@ -2522,10 +2522,10 @@ static void PlayerDoMoveAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1; InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -2543,10 +2543,10 @@ static void PlayerDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index c44a8d31e..b2b6baa0a 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBattleMoveTarget; +extern u8 gBattlerTarget; extern u8 gAbsentBattlerFlags; extern u8 gUnknown_020244B4[]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; @@ -560,7 +560,7 @@ static void sub_81BB92C(void) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { CopyBattleSpriteInvisibility(gActiveBattler); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); gBattlerControllerFuncs[gActiveBattler] = sub_81BB9A0; @@ -1308,7 +1308,7 @@ static void DoSwitchOutAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1395,7 +1395,7 @@ static void PlayerPartnerHandleFaintAnimation(void) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } @@ -1467,10 +1467,10 @@ static void PlayerPartnerDoMoveAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1; InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1488,10 +1488,10 @@ static void PlayerPartnerDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } @@ -1545,15 +1545,15 @@ static void PlayerPartnerHandleChooseMove(void) chosenMoveId = BattleAI_ChooseMoveOrAction(); if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_x10 | MOVE_TARGET_USER)) - gBattleMoveTarget = gActiveBattler; + gBattlerTarget = gActiveBattler; if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH) { - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); - if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) + gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); } - BtlController_EmitTwoReturnValues(1, 10, chosenMoveId | (gBattleMoveTarget << 8)); + BtlController_EmitTwoReturnValues(1, 10, chosenMoveId | (gBattlerTarget << 8)); PlayerPartnerBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index 22cd63fb3..8078d0af2 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -48,7 +48,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBattleMoveTarget; +extern u8 gBattlerTarget; extern u8 gAbsentBattlerFlags; extern u8 gUnknown_020244B4[]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; @@ -255,21 +255,17 @@ static void sub_8186678(void) if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & BATTLE_TYPE_MULTI))) { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy - && gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded) - { + && gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded) var = TRUE; - } } else { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy - && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy - && gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded - && gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].animEnded) - { + && gSprites[gHealthboxSpriteIds[gActiveBattler ^ BIT_FLANK]].callback == SpriteCallbackDummy + && gSprites[gBattlerSpriteIds[gActiveBattler]].animEnded + && gSprites[gBattlerSpriteIds[gActiveBattler ^ BIT_FLANK]].animEnded) var = TRUE; - } } if (var) @@ -469,7 +465,7 @@ static void sub_8186EA4(void) { if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); gBattlerControllerFuncs[gActiveBattler] = sub_8186F14; @@ -1225,7 +1221,7 @@ static void DoSwitchOutAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1314,7 +1310,7 @@ static void RecordedOpponentHandleFaintAnimation(void) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } @@ -1383,10 +1379,10 @@ static void RecordedOpponentDoMoveAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1; InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1404,10 +1400,10 @@ static void RecordedOpponentDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } @@ -1443,7 +1439,7 @@ static void RecordedOpponentHandlePrintSelectionString(void) static void RecordedOpponentHandleChooseAction(void) { - BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBankAction(gActiveBattler), 0); + BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBattlerAction(gActiveBattler), 0); RecordedOpponentBufferExecCompleted(); } @@ -1460,8 +1456,8 @@ static void RecordedOpponentHandleChooseMove(void) } else { - u8 moveId = RecordedBattle_GetBankAction(gActiveBattler); - u8 target = RecordedBattle_GetBankAction(gActiveBattler); + u8 moveId = RecordedBattle_GetBattlerAction(gActiveBattler); + u8 target = RecordedBattle_GetBattlerAction(gActiveBattler); BtlController_EmitTwoReturnValues(1, 10, moveId | (target << 8)); } @@ -1475,7 +1471,7 @@ static void RecordedOpponentHandleChooseItem(void) static void RecordedOpponentHandleChoosePokemon(void) { - *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBankAction(gActiveBattler); + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBattlerAction(gActiveBattler); BtlController_EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); RecordedOpponentBufferExecCompleted(); } diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 109d71733..953f989e9 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -48,7 +48,7 @@ extern u8 gUnknown_03005D7C[MAX_BATTLERS_COUNT]; extern u8 gBattleMonForms[MAX_BATTLERS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBattleMoveTarget; +extern u8 gBattlerTarget; extern u8 gAbsentBattlerFlags; extern u8 gUnknown_020244B4[]; extern u32 gTransformedPersonalities[MAX_BATTLERS_COUNT]; @@ -458,7 +458,7 @@ static void sub_818A2B4(void) if (gSprites[gHealthboxSpriteIds[gActiveBattler]].callback == SpriteCallbackDummy) { CopyBattleSpriteInvisibility(gActiveBattler); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); gBattlerControllerFuncs[gActiveBattler] = sub_818A328; @@ -1206,7 +1206,7 @@ static void DoSwitchOutAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1313,7 +1313,7 @@ static void RecordedPlayerHandleFaintAnimation(void) { if (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState == 0) { - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState++; } @@ -1385,10 +1385,10 @@ static void RecordedPlayerDoMoveAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute - && !gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute + && !gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8) { - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 1; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 1; InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 1; @@ -1406,10 +1406,10 @@ static void RecordedPlayerDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute && multihit < 2) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute && multihit < 2) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); - gBattleSpritesDataPtr->bankData[gActiveBattler].flag_x8 = 0; + gBattleSpritesDataPtr->battlerData[gActiveBattler].flag_x8 = 0; } gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState = 3; } @@ -1447,7 +1447,7 @@ static void ChooseActionInBattlePalace(void) { if (gBattleCommunication[4] >= gBattlersCount / 2) { - BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBankAction(gActiveBattler), 0); + BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBattlerAction(gActiveBattler), 0); RecordedPlayerBufferExecCompleted(); } } @@ -1460,7 +1460,7 @@ static void RecordedPlayerHandleChooseAction(void) } else { - BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBankAction(gActiveBattler), 0); + BtlController_EmitTwoReturnValues(1, RecordedBattle_GetBattlerAction(gActiveBattler), 0); RecordedPlayerBufferExecCompleted(); } } @@ -1478,8 +1478,8 @@ static void RecordedPlayerHandleChooseMove(void) } else { - u8 moveId = RecordedBattle_GetBankAction(gActiveBattler); - u8 target = RecordedBattle_GetBankAction(gActiveBattler); + u8 moveId = RecordedBattle_GetBattlerAction(gActiveBattler); + u8 target = RecordedBattle_GetBattlerAction(gActiveBattler); BtlController_EmitTwoReturnValues(1, 10, moveId | (target << 8)); } @@ -1493,7 +1493,7 @@ static void RecordedPlayerHandleChooseItem(void) static void RecordedPlayerHandleChoosePokemon(void) { - *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBankAction(gActiveBattler); + *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = RecordedBattle_GetBattlerAction(gActiveBattler); BtlController_EmitChosenMonReturnValue(1, *(gBattleStruct->monToSwitchIntoId + gActiveBattler), NULL); RecordedPlayerBufferExecCompleted(); } diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index 814ee8076..608d59418 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -203,16 +203,16 @@ static void HandleInputChooseAction(void) switch (gActionSelectionCursor[gActiveBattler]) { case 0: - BtlController_EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_BALL, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_BALL, 0); break; case 1: - BtlController_EmitTwoReturnValues(1, ACTION_POKEBLOCK_CASE, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_POKEBLOCK, 0); break; case 2: - BtlController_EmitTwoReturnValues(1, ACTION_GO_NEAR, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_GO_NEAR, 0); break; case 3: - BtlController_EmitTwoReturnValues(1, ACTION_SAFARI_ZONE_RUN, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_SAFARI_RUN, 0); break; } SafariBufferExecCompleted(); diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 7f5108b9b..dd01e5996 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -233,7 +233,7 @@ static void WallyHandleActions(void) if (--gBattleStruct->wallyWaitFrames == 0) { PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(1, ACTION_USE_MOVE, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, 0); WallyBufferExecCompleted(); gBattleStruct->wallyBattleState++; gBattleStruct->wallyMovesState = 0; @@ -244,7 +244,7 @@ static void WallyHandleActions(void) if (--gBattleStruct->wallyWaitFrames == 0) { PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(1, ACTION_USE_MOVE, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_USE_MOVE, 0); WallyBufferExecCompleted(); gBattleStruct->wallyBattleState++; gBattleStruct->wallyMovesState = 0; @@ -275,7 +275,7 @@ static void WallyHandleActions(void) if (--gBattleStruct->wallyWaitFrames == 0) { PlaySE(SE_SELECT); - BtlController_EmitTwoReturnValues(1, ACTION_USE_ITEM, 0); + BtlController_EmitTwoReturnValues(1, B_ACTION_USE_ITEM, 0); WallyBufferExecCompleted(); } break; @@ -1162,7 +1162,7 @@ static void WallyDoMoveAnimation(void) switch (gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].animationState) { case 0: - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_SUBSTITUTE_TO_MON); } @@ -1181,7 +1181,7 @@ static void WallyDoMoveAnimation(void) if (!gAnimScriptActive) { sub_805EB9C(1); - if (gBattleSpritesDataPtr->bankData[gActiveBattler].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[gActiveBattler].behindSubstitute) { InitAndLaunchSpecialAnimation(gActiveBattler, gActiveBattler, gActiveBattler, B_ANIM_MON_TO_SUBSTITUTE); } @@ -1490,7 +1490,7 @@ static void sub_816AA80(u8 bank) { u16 species; - gBattleSpritesDataPtr->bankData[bank].transformSpecies = 0; + gBattleSpritesDataPtr->battlerData[bank].transformSpecies = 0; gBattlerPartyIndexes[bank] = gBattleBufferA[bank][1]; species = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES); gUnknown_03005D7C[bank] = CreateInvisibleSpriteWithCallback(sub_805D714); diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 4d8b63c65..4f523cfa0 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -31,8 +31,8 @@ extern u8 gBattleBuffersTransferData[0x100]; extern u8 gUnknown_02022D08; extern u8 gUnknown_02022D09; extern u8 gUnknown_02022D0A; -extern u8 gBattleMoveAttacker; -extern u8 gBattleMoveTarget; +extern u8 gBattlerAttacker; +extern u8 gBattlerTarget; extern u8 gAbsentBattlerFlags; extern u8 gEffectBank; extern u16 gBattleWeather; @@ -42,7 +42,7 @@ extern u16 gChosenMove; extern u16 gLastUsedItem; extern u8 gBattleOutcome; extern u8 gLastUsedAbility; -extern u8 gStringBank; +extern u8 gStringBattler; extern const struct BattleMove gBattleMoves[]; @@ -752,8 +752,8 @@ void PrepareBufferDataTransferLink(u8 bufferId, u16 size, u8 *data) } gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_BUFFER_ID] = bufferId; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ACTIVE_BANK] = gActiveBattler; - gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ATTACKER] = gBattleMoveAttacker; - gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_TARGET] = gBattleMoveTarget; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ATTACKER] = gBattlerAttacker; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_TARGET] = gBattlerTarget; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_SIZE_LO] = alignedSize; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_SIZE_HI] = (alignedSize & 0x0000FF00) >> 8; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ABSENT_BANK_FLAGS] = gAbsentBattlerFlags; @@ -920,8 +920,8 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId) if (!(gBattleTypeFlags & BATTLE_TYPE_WILD)) { - gBattleMoveAttacker = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 2]; - gBattleMoveTarget = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 3]; + gBattlerAttacker = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 2]; + gBattlerTarget = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 3]; gAbsentBattlerFlags = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 6]; gEffectBank = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 7]; } @@ -1126,7 +1126,7 @@ void BtlController_EmitPrintString(u8 bufferId, u16 stringID) stringInfo->scrActive = gBattleScripting.battler; stringInfo->unk1605E = gBattleStruct->field_52; stringInfo->hpScale = gBattleStruct->hpScale; - stringInfo->StringBank = gStringBank; + stringInfo->StringBank = gStringBattler; stringInfo->moveType = gBattleMoves[gCurrentMove].type; for (i = 0; i < MAX_BATTLERS_COUNT; i++) diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index d7806aee0..7958d07b3 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -127,7 +127,7 @@ static const struct SpritePalette gUnknown_0832C128[2] = void AllocateBattleSpritesData(void) { gBattleSpritesDataPtr = AllocZeroed(sizeof(struct BattleSpriteData)); - gBattleSpritesDataPtr->bankData = AllocZeroed(sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT); + gBattleSpritesDataPtr->battlerData = AllocZeroed(sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT); gBattleSpritesDataPtr->healthBoxesData = AllocZeroed(sizeof(struct BattleHealthboxInfo) * MAX_BATTLERS_COUNT); gBattleSpritesDataPtr->animationData = AllocZeroed(sizeof(struct BattleAnimationInfo)); gBattleSpritesDataPtr->battleBars = AllocZeroed(sizeof(struct BattleBarInfo) * MAX_BATTLERS_COUNT); @@ -141,7 +141,7 @@ void FreeBattleSpritesData(void) FREE_AND_SET_NULL(gBattleSpritesDataPtr->battleBars); FREE_AND_SET_NULL(gBattleSpritesDataPtr->animationData); FREE_AND_SET_NULL(gBattleSpritesDataPtr->healthBoxesData); - FREE_AND_SET_NULL(gBattleSpritesDataPtr->bankData); + FREE_AND_SET_NULL(gBattleSpritesDataPtr->battlerData); FREE_AND_SET_NULL(gBattleSpritesDataPtr); } @@ -432,12 +432,12 @@ bool8 TryHandleLaunchBattleTableAnimation(u8 activeBank, u8 atkBank, u8 defBank, gBattleMonForms[activeBank] = (argument & ~(0x80)); return TRUE; } - if (gBattleSpritesDataPtr->bankData[activeBank].behindSubstitute + if (gBattleSpritesDataPtr->battlerData[activeBank].behindSubstitute && !ShouldAnimBeDoneRegardlessOfSubsitute(tableId)) { return TRUE; } - if (gBattleSpritesDataPtr->bankData[activeBank].behindSubstitute + if (gBattleSpritesDataPtr->battlerData[activeBank].behindSubstitute && tableId == B_ANIM_SUBSTITUTE_FADE && gSprites[gBattlerSpriteIds[activeBank]].invisible) { @@ -549,14 +549,14 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank) monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY); - if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) + if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE) { species = GetMonData(mon, MON_DATA_SPECIES); currentPersonality = monsPersonality; } else { - species = gBattleSpritesDataPtr->bankData[bank].transformSpecies; + species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies; currentPersonality = gTransformedPersonalities[bank]; } @@ -568,7 +568,7 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank) paletteOffset = 0x100 + bank * 16; - if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) + if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE) lzPaletteData = GetMonFrontSpritePal(mon); else lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality); @@ -585,7 +585,7 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 bank) } // transform's pink color - if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) + if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE) { BlendPalette(paletteOffset, 16, 6, 0x7FFF); CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); @@ -602,21 +602,21 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank) monsPersonality = GetMonData(mon, MON_DATA_PERSONALITY); - if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) + if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE) { species = GetMonData(mon, MON_DATA_SPECIES); currentPersonality = monsPersonality; } else { - species = gBattleSpritesDataPtr->bankData[bank].transformSpecies; + species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies; currentPersonality = gTransformedPersonalities[bank]; } otId = GetMonData(mon, MON_DATA_OT_ID); position = GetBattlerPosition(bank); - if (sub_80688F8(1, bank) == 1 || gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) + if (sub_80688F8(1, bank) == 1 || gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE) { HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species], gMonSpritesGfxPtr->sprites[position], @@ -631,7 +631,7 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank) paletteOffset = 0x100 + bank * 16; - if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_NONE) + if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies == SPECIES_NONE) lzPaletteData = GetMonFrontSpritePal(mon); else lzPaletteData = GetFrontSpritePalFromSpeciesAndPersonality(species, otId, monsPersonality); @@ -648,7 +648,7 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 bank) } // transform's pink color - if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) + if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE) { BlendPalette(paletteOffset, 16, 6, 0x7FFF); CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); @@ -804,7 +804,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank) if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && *bank == 0) gHealthboxSpriteIds[*bank] = CreateSafariPlayerHealthboxSprites(); else - gHealthboxSpriteIds[*bank] = CreateHealthboxSprites(*bank); + gHealthboxSpriteIds[*bank] = CreateBattlerHealthboxSprites(*bank); (*bank)++; if (*bank == gBattlersCount) @@ -864,7 +864,7 @@ void ClearSpritesHealthboxAnimData(void) static void ClearSpritesBankHealthboxAnimData(void) { ClearSpritesHealthboxAnimData(); - memset(gBattleSpritesDataPtr->bankData, 0, sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT); + memset(gBattleSpritesDataPtr->battlerData, 0, sizeof(struct BattleSpriteInfo) * MAX_BATTLERS_COUNT); } void CopyAllBattleSpritesInvisibilities(void) @@ -872,12 +872,12 @@ void CopyAllBattleSpritesInvisibilities(void) s32 i; for (i = 0; i < gBattlersCount; i++) - gBattleSpritesDataPtr->bankData[i].invisible = gSprites[gBattlerSpriteIds[i]].invisible; + gBattleSpritesDataPtr->battlerData[i].invisible = gSprites[gBattlerSpriteIds[i]].invisible; } void CopyBattleSpriteInvisibility(u8 bank) { - gBattleSpritesDataPtr->bankData[bank].invisible = gSprites[gBattlerSpriteIds[bank]].invisible; + gBattleSpritesDataPtr->battlerData[bank].invisible = gSprites[gBattlerSpriteIds[bank]].invisible; } void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform) @@ -894,7 +894,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform) paletteOffset = 0x100 + bankAtk * 16; LoadPalette(gBattleStruct->castformPalette[gBattleSpritesDataPtr->animationData->animArg], paletteOffset, 32); gBattleMonForms[bankAtk] = gBattleSpritesDataPtr->animationData->animArg; - if (gBattleSpritesDataPtr->bankData[bankAtk].transformSpecies != SPECIES_NONE) + if (gBattleSpritesDataPtr->battlerData[bankAtk].transformSpecies != SPECIES_NONE) { BlendPalette(paletteOffset, 16, 6, 0x7FFF); CpuCopy32(gPlttBufferFaded + paletteOffset, gPlttBufferUnfaded + paletteOffset, 32); @@ -970,7 +970,7 @@ void HandleSpeciesGfxDataChange(u8 bankAtk, u8 bankDef, bool8 notTransform) if (!IsContest()) { - gBattleSpritesDataPtr->bankData[bankAtk].transformSpecies = targetSpecies; + gBattleSpritesDataPtr->battlerData[bankAtk].transformSpecies = targetSpecies; gBattleMonForms[bankAtk] = gBattleMonForms[bankDef]; } @@ -1040,12 +1040,12 @@ void LoadBattleMonGfxAndAnimate(u8 bank, bool8 loadMonSprite, u8 spriteId) void TrySetBehindSubstituteSpriteBit(u8 bank, u16 move) { if (move == MOVE_SUBSTITUTE) - gBattleSpritesDataPtr->bankData[bank].behindSubstitute = 1; + gBattleSpritesDataPtr->battlerData[bank].behindSubstitute = 1; } void ClearBehindSubstituteBit(u8 bank) { - gBattleSpritesDataPtr->bankData[bank].behindSubstitute = 0; + gBattleSpritesDataPtr->battlerData[bank].behindSubstitute = 0; } void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank) @@ -1055,22 +1055,22 @@ void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank) if (GetHPBarLevel(hp, maxHP) == HP_BAR_RED) { - if (!gBattleSpritesDataPtr->bankData[bank].lowHpSong) + if (!gBattleSpritesDataPtr->battlerData[bank].lowHpSong) { - if (!gBattleSpritesDataPtr->bankData[bank ^ BIT_FLANK].lowHpSong) + if (!gBattleSpritesDataPtr->battlerData[bank ^ BIT_FLANK].lowHpSong) PlaySE(SE_HINSI); - gBattleSpritesDataPtr->bankData[bank].lowHpSong = 1; + gBattleSpritesDataPtr->battlerData[bank].lowHpSong = 1; } } else { - gBattleSpritesDataPtr->bankData[bank].lowHpSong = 0; + gBattleSpritesDataPtr->battlerData[bank].lowHpSong = 0; if (!IsDoubleBattle()) { m4aSongNumStop(SE_HINSI); return; } - if (IsDoubleBattle() && !gBattleSpritesDataPtr->bankData[bank ^ BIT_FLANK].lowHpSong) + if (IsDoubleBattle() && !gBattleSpritesDataPtr->battlerData[bank ^ BIT_FLANK].lowHpSong) { m4aSongNumStop(SE_HINSI); return; @@ -1082,9 +1082,9 @@ void BattleStopLowHpSound(void) { u8 playerBank = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); - gBattleSpritesDataPtr->bankData[playerBank].lowHpSong = 0; + gBattleSpritesDataPtr->battlerData[playerBank].lowHpSong = 0; if (IsDoubleBattle()) - gBattleSpritesDataPtr->bankData[playerBank ^ BIT_FLANK].lowHpSong = 0; + gBattleSpritesDataPtr->battlerData[playerBank ^ BIT_FLANK].lowHpSong = 0; m4aSongNumStop(SE_HINSI); } @@ -1168,11 +1168,11 @@ void SpriteCB_EnemyShadow(struct Sprite *shadowSprite) } if (gAnimScriptActive || bankSprite->invisible) invisible = TRUE; - else if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE - && gEnemyMonElevation[gBattleSpritesDataPtr->bankData[bank].transformSpecies] == 0) + else if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE + && gEnemyMonElevation[gBattleSpritesDataPtr->battlerData[bank].transformSpecies] == 0) invisible = TRUE; - if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute) + if (gBattleSpritesDataPtr->battlerData[bank].behindSubstitute) invisible = TRUE; shadowSprite->pos1.x = bankSprite->pos1.x; @@ -1193,8 +1193,8 @@ void SetBattlerShadowSpriteCallback(u8 bank, u16 species) if (GetBattlerSide(bank) == B_SIDE_PLAYER) return; - if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != SPECIES_NONE) - species = gBattleSpritesDataPtr->bankData[bank].transformSpecies; + if (gBattleSpritesDataPtr->battlerData[bank].transformSpecies != SPECIES_NONE) + species = gBattleSpritesDataPtr->battlerData[bank].transformSpecies; if (gEnemyMonElevation[species] != 0) gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].callback = SpriteCB_EnemyShadow; @@ -1232,7 +1232,7 @@ void sub_805EF14(void) void ClearTemporarySpeciesSpriteData(u8 bank, bool8 dontClearSubstitute) { - gBattleSpritesDataPtr->bankData[bank].transformSpecies = SPECIES_NONE; + gBattleSpritesDataPtr->battlerData[bank].transformSpecies = SPECIES_NONE; gBattleMonForms[bank] = 0; if (!dontClearSubstitute) ClearBehindSubstituteBit(bank); diff --git a/src/battle_interface.c b/src/battle_interface.c index 941fd20d5..debbc8eb7 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -898,7 +898,7 @@ void sub_80724A8(s16 arg0, s16 arg1, u16 *arg2) // healthboxSpriteId_2 refers to the other part // there's also one other sprite that appears to be a black square? dont fully understand its role -u8 CreateHealthboxSprites(u8 bank) +u8 CreateBattlerHealthboxSprites(u8 battler) { s16 data6 = 0; u8 healthboxSpriteId_1, healthboxSpriteId_2; @@ -907,7 +907,7 @@ u8 CreateHealthboxSprites(u8 bank) if (!IsDoubleBattle()) { - if (GetBattlerSide(bank) == B_SIDE_PLAYER) + if (GetBattlerSide(battler) == B_SIDE_PLAYER) { healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[0], 240, 160, 1); healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[0], 240, 160, 1); @@ -932,10 +932,10 @@ u8 CreateHealthboxSprites(u8 bank) } else { - if (GetBattlerSide(bank) == B_SIDE_PLAYER) + if (GetBattlerSide(battler) == B_SIDE_PLAYER) { - healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); - healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); + healthboxSpriteId_1 = CreateSprite(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1); + healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxPlayerSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1); gSprites[healthboxSpriteId_1].oam.affineParam = healthboxSpriteId_2; @@ -947,8 +947,8 @@ u8 CreateHealthboxSprites(u8 bank) } else { - healthboxSpriteId_1 = CreateSprite(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); - healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(bank) / 2], 240, 160, 1); + healthboxSpriteId_1 = CreateSprite(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1); + healthboxSpriteId_2 = CreateSpriteAtEnd(&sHealthboxOpponentSpriteTemplates[GetBattlerPosition(battler) / 2], 240, 160, 1); gSprites[healthboxSpriteId_1].oam.affineParam = healthboxSpriteId_2; @@ -960,16 +960,16 @@ u8 CreateHealthboxSprites(u8 bank) } } - unkSpriteId = CreateSpriteAtEnd(&sUnknown_0832C1C0[gBattlerPositions[bank]], 140, 60, 0); + unkSpriteId = CreateSpriteAtEnd(&sUnknown_0832C1C0[gBattlerPositions[battler]], 140, 60, 0); unkSpritePtr = &gSprites[unkSpriteId]; - SetSubspriteTables(unkSpritePtr, &sUnknown_0832C28C[GetBattlerSide(bank)]); + SetSubspriteTables(unkSpritePtr, &sUnknown_0832C28C[GetBattlerSide(battler)]); unkSpritePtr->subspriteMode = 2; unkSpritePtr->oam.priority = 1; CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_1), (void*)(OBJ_VRAM0 + unkSpritePtr->oam.tileNum * 32), 64); gSprites[healthboxSpriteId_1].data[5] = unkSpriteId; - gSprites[healthboxSpriteId_1].data[6] = bank; + gSprites[healthboxSpriteId_1].data[6] = battler; gSprites[healthboxSpriteId_1].invisible = 1; gSprites[healthboxSpriteId_2].invisible = 1; @@ -1099,20 +1099,20 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority) } } -void InitBattlerHealthboxCoords(u8 bank) +void InitBattlerHealthboxCoords(u8 battler) { s16 x = 0, y = 0; if (!IsDoubleBattle()) { - if (GetBattlerSide(bank) != B_SIDE_PLAYER) + if (GetBattlerSide(battler) != B_SIDE_PLAYER) x = 44, y = 30; else x = 158, y = 88; } else { - switch (GetBattlerPosition(bank)) + switch (GetBattlerPosition(battler)) { case B_POSITION_PLAYER_LEFT: x = 159, y = 76; @@ -1129,7 +1129,7 @@ void InitBattlerHealthboxCoords(u8 bank) } } - UpdateSpritePos(gHealthboxSpriteIds[bank], x, y); + UpdateSpritePos(gHealthboxSpriteIds[battler], x, y); } static void UpdateLvlInHealthbox(u8 healthboxSpriteId, u8 lvl) @@ -1210,11 +1210,11 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent) } else { - u8 bank; + u8 battler; memcpy(text, sUnknown_0832C3C4, sizeof(sUnknown_0832C3C4)); - bank = gSprites[healthboxSpriteId].data[6]; - if (IsDoubleBattle() == TRUE || GetBattlerSide(bank) == B_SIDE_OPPONENT) + battler = gSprites[healthboxSpriteId].data[6]; + if (IsDoubleBattle() == TRUE || GetBattlerSide(battler) == B_SIDE_OPPONENT) { UpdateHpTextInHealthboxInDoubles(healthboxSpriteId, value, maxOrCurrent); } @@ -1260,7 +1260,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8 if (GetBattlerSide(gSprites[healthboxSpriteId].data[6]) == B_SIDE_PLAYER) { - if (gBattleSpritesDataPtr->bankData[gSprites[healthboxSpriteId].data[6]].hpNumbersNoBars) // don't print text if only bars are visible + if (gBattleSpritesDataPtr->battlerData[gSprites[healthboxSpriteId].data[6]].hpNumbersNoBars) // don't print text if only bars are visible { spriteTileNum = gSprites[gSprites[healthboxSpriteId].data[5]].oam.tileNum * 32; objVram = (void*)(OBJ_VRAM0) + spriteTileNum; @@ -1294,7 +1294,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8 memcpy(text, sUnknown_0832C3D8, sizeof(sUnknown_0832C3D8)); bank = gSprites[healthboxSpriteId].data[6]; - if (gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars) // don't print text if only bars are visible + if (gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars) // don't print text if only bars are visible { u8 var = 4; u8 r7; @@ -1423,8 +1423,8 @@ void SwapHpBarsWithHpText(void) { bool8 noBars; - gBattleSpritesDataPtr->bankData[i].hpNumbersNoBars ^= 1; - noBars = gBattleSpritesDataPtr->bankData[i].hpNumbersNoBars; + gBattleSpritesDataPtr->battlerData[i].hpNumbersNoBars ^= 1; + noBars = gBattleSpritesDataPtr->battlerData[i].hpNumbersNoBars; if (GetBattlerSide(i) == B_SIDE_PLAYER) { if (!IsDoubleBattle()) @@ -2062,7 +2062,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId) for (i = 0; i < 3; i++) CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder + i) * 32), 32); - if (!gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars) + if (!gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars) CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_1), (void *)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 64); TryAddPokeballIconToHealthbox(healthboxSpriteId, TRUE); @@ -2077,7 +2077,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId) CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder) * 32), 96); if (IsDoubleBattle() == TRUE || GetBattlerSide(bank) == B_SIDE_OPPONENT) { - if (!gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars) + if (!gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars) { CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_0), (void*)(OBJ_VRAM0 + gSprites[healthboxSpriteId_2].oam.tileNum * 32), 32); CpuCopy32(GetHealthboxElementGfxPtr(HEALTHBOX_GFX_65), (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId_2].oam.tileNum + 1) * 32), 32); @@ -2275,7 +2275,7 @@ s32 sub_8074AA0(u8 bank, u8 healthboxSpriteId, u8 whichBar, u8 arg3) 8, expFraction); } - if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->bankData[bank].hpNumbersNoBars)) + if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->battlerData[bank].hpNumbersNoBars)) sub_8074B9C(bank, whichBar); if (var == -1) diff --git a/src/battle_main.c b/src/battle_main.c index df3fc9378..3704ff3b4 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -91,7 +91,7 @@ extern u8 gHealthboxSpriteIds[MAX_BATTLERS_COUNT]; extern void (*gBattlerControllerFuncs[MAX_BATTLERS_COUNT])(void); extern u8 gBattleBufferA[MAX_BATTLERS_COUNT][0x200]; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; -extern u8 gStringBank; +extern u8 gStringBattler; extern u32 gUnknown_02022F88; extern u32 gHitMarker; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT]; @@ -103,8 +103,8 @@ extern u16 gPauseCounterBattle; extern u16 gRandomTurnNumber; extern u8 gActiveBattler; extern u8 gBattlersCount; -extern u8 gBattleMoveAttacker; -extern u8 gBattleMoveTarget; +extern u8 gBattlerAttacker; +extern u8 gBattlerTarget; extern u8 gLeveledUpInBattle; extern u8 gAbsentBattlerFlags; extern u32 gBattleControllerExecFlags; @@ -127,8 +127,8 @@ 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 gChosenActionByBattler[MAX_BATTLERS_COUNT]; +extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT]; extern u8 gCurrentActionFuncId; extern u8 gLastUsedAbility; extern u8 gUnknown_0203CF00[]; @@ -264,20 +264,20 @@ static void HandleAction_ActionFinished(void); // rom const data static void (* const sTurnActionsFuncsTable[])(void) = { - HandleAction_UseMove, // ACTION_USE_MOVE - HandleAction_UseItem, // ACTION_USE_ITEM - HandleAction_Switch, // ACTION_SWITCH - HandleAction_Run, // ACTION_RUN - HandleAction_WatchesCarefully, // ACTION_WATCHES_CAREFULLY - HandleAction_SafariZoneBallThrow, // ACTION_SAFARI_ZONE_BALL - HandleAction_ThrowPokeblock, // ACTION_POKEBLOCK_CASE - HandleAction_GoNear, // ACTION_GO_NEAR - HandleAction_SafriZoneRun, // ACTION_SAFARI_ZONE_RUN - HandleAction_Action9, // ACTION_9 - HandleAction_RunBattleScript, // ACTION_RUN_BATTLESCRIPT + HandleAction_UseMove, // B_ACTION_USE_MOVE + HandleAction_UseItem, // B_ACTION_USE_ITEM + HandleAction_Switch, // B_ACTION_SWITCH + HandleAction_Run, // B_ACTION_RUN + HandleAction_WatchesCarefully, // B_ACTION_SAFARI_WATCH_CAREFULLY + HandleAction_SafariZoneBallThrow, // B_ACTION_SAFARI_BALL + HandleAction_ThrowPokeblock, // B_ACTION_SAFARI_POKEBLOCK + HandleAction_GoNear, // B_ACTION_SAFARI_GO_NEAR + HandleAction_SafriZoneRun, // B_ACTION_SAFARI_RUN + HandleAction_Action9, // B_ACTION_UNKNOWN9 + HandleAction_RunBattleScript, // B_ACTION_EXEC_SCRIPT HandleAction_Action11, // not sure about this one - HandleAction_ActionFinished, // ACTION_FINISHED - HandleAction_NothingIsFainted, // ACTION_NOTHING_FAINTED + HandleAction_ActionFinished, // B_ACTION_FINISHED + HandleAction_NothingIsFainted, // B_ACTION_NOTHING_FAINTED }; static void (* const sEndTurnFuncsTable[])(void) = @@ -2371,8 +2371,8 @@ u32 sub_80397C4(u32 setId, u32 tableId) return gUnknown_0831ABA0[setId][tableId].width * 8; } -#define tBank data[0] -#define tSpeciesId data[2] +#define sBattler data[0] +#define sSpeciesId data[2] void oac_poke_opponent(struct Sprite *sprite) { @@ -2397,8 +2397,8 @@ static void sub_8039838(struct Sprite *sprite) { if (sprite->animEnded) { - sub_8076918(sprite->tBank); - SetHealthboxSpriteVisible(gHealthboxSpriteIds[sprite->tBank]); + sub_8076918(sprite->sBattler); + SetHealthboxSpriteVisible(gHealthboxSpriteIds[sprite->sBattler]); sprite->callback = sub_8039894; StartSpriteAnimIfDifferent(sprite, 0); BeginNormalPaletteFade(0x20000, 0, 10, 0, 0x2108); @@ -2409,7 +2409,7 @@ static void sub_8039894(struct Sprite *sprite) { if (!gPaletteFade.active) { - BattleAnimateFrontSprite(sprite, sprite->tSpeciesId, FALSE, 1); + BattleAnimateFrontSprite(sprite, sprite->sSpeciesId, FALSE, 1); } } @@ -2447,20 +2447,20 @@ extern const struct MonCoords gCastformFrontSpriteCoords[]; void sub_8039934(struct Sprite *sprite) { - u8 bank = sprite->tBank; + u8 battler = sprite->sBattler; u16 species; u8 yOffset; - if (gBattleSpritesDataPtr->bankData[bank].transformSpecies != 0) - species = gBattleSpritesDataPtr->bankData[bank].transformSpecies; + if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies != 0) + species = gBattleSpritesDataPtr->battlerData[battler].transformSpecies; else - species = sprite->tSpeciesId; + species = sprite->sSpeciesId; - GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_PERSONALITY); // Unused return value + GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_PERSONALITY); // Unused return value if (species == SPECIES_UNOWN) { - u32 personalityValue = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_PERSONALITY); + u32 personalityValue = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_PERSONALITY); u16 unownForm = ((((personalityValue & 0x3000000) >> 18) | ((personalityValue & 0x30000) >> 12) | ((personalityValue & 0x300) >> 6) | (personalityValue & 3)) % 0x1C); u16 unownSpecies; @@ -2473,7 +2473,7 @@ void sub_8039934(struct Sprite *sprite) } else if (species == SPECIES_CASTFORM) { - yOffset = gCastformFrontSpriteCoords[gBattleMonForms[bank]].y_offset; + yOffset = gCastformFrontSpriteCoords[gBattleMonForms[battler]].y_offset; } else if (species > NUM_SPECIES) { @@ -2506,12 +2506,12 @@ static void sub_8039A48(struct Sprite *sprite) } else { - u8 *dst = (u8 *)gMonSpritesGfxPtr->sprites[GetBattlerPosition(sprite->tBank)] + (gBattleMonForms[sprite->tBank] << 11) + (sprite->data[3] << 8); + u8 *dst = (u8 *)gMonSpritesGfxPtr->sprites[GetBattlerPosition(sprite->sBattler)] + (gBattleMonForms[sprite->sBattler] << 11) + (sprite->data[3] << 8); for (i = 0; i < 0x100; i++) *(dst++) = 0; - StartSpriteAnim(sprite, gBattleMonForms[sprite->tBank]); + StartSpriteAnim(sprite, gBattleMonForms[sprite->sBattler]); } } } @@ -2546,10 +2546,10 @@ void sub_8039B58(struct Sprite *sprite) { if (!(gHitMarker & HITMARKER_NO_ANIMATIONS) || gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) { - if (HasTwoFramesAnimation(sprite->tSpeciesId)) + if (HasTwoFramesAnimation(sprite->sSpeciesId)) StartSpriteAnim(sprite, 1); } - BattleAnimateFrontSprite(sprite, sprite->tSpeciesId, TRUE, 1); + BattleAnimateFrontSprite(sprite, sprite->sSpeciesId, TRUE, 1); } } @@ -2589,35 +2589,35 @@ void sub_8039C00(struct Sprite *sprite) } } -void dp11b_obj_instanciate(u8 bank, u8 b, s8 c, s8 d) +void dp11b_obj_instanciate(u8 battler, u8 b, s8 c, s8 d) { u8 bounceHealthBoxSpriteId; u8 spriteId2; if (b) { - if (gBattleSpritesDataPtr->healthBoxesData[bank].flag_x2) + if (gBattleSpritesDataPtr->healthBoxesData[battler].flag_x2) return; } else { - if (gBattleSpritesDataPtr->healthBoxesData[bank].flag_x4) + if (gBattleSpritesDataPtr->healthBoxesData[battler].flag_x4) return; } bounceHealthBoxSpriteId = CreateInvisibleSpriteWithCallback(SpriteCB_HealthBoxBounce); if (b == TRUE) { - spriteId2 = gHealthboxSpriteIds[bank]; - gBattleSpritesDataPtr->healthBoxesData[bank].field_2 = bounceHealthBoxSpriteId; - gBattleSpritesDataPtr->healthBoxesData[bank].flag_x2 = 1; + spriteId2 = gHealthboxSpriteIds[battler]; + gBattleSpritesDataPtr->healthBoxesData[battler].field_2 = bounceHealthBoxSpriteId; + gBattleSpritesDataPtr->healthBoxesData[battler].flag_x2 = 1; gSprites[bounceHealthBoxSpriteId].data[0] = 0x80; } else { - spriteId2 = gBattlerSpriteIds[bank]; - gBattleSpritesDataPtr->healthBoxesData[bank].field_3 = bounceHealthBoxSpriteId; - gBattleSpritesDataPtr->healthBoxesData[bank].flag_x4 = 1; + spriteId2 = gBattlerSpriteIds[battler]; + gBattleSpritesDataPtr->healthBoxesData[battler].field_3 = bounceHealthBoxSpriteId; + gBattleSpritesDataPtr->healthBoxesData[battler].flag_x4 = 1; gSprites[bounceHealthBoxSpriteId].data[0] = 0xC0; } gSprites[bounceHealthBoxSpriteId].data[1] = c; @@ -2628,27 +2628,27 @@ void dp11b_obj_instanciate(u8 bank, u8 b, s8 c, s8 d) gSprites[spriteId2].pos2.y = 0; } -void dp11b_obj_free(u8 bank, bool8 b) +void dp11b_obj_free(u8 battler, bool8 b) { u8 r4; if (b == TRUE) { - if (!gBattleSpritesDataPtr->healthBoxesData[bank].flag_x2) + if (!gBattleSpritesDataPtr->healthBoxesData[battler].flag_x2) return; - r4 = gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].field_2].data[3]; - DestroySprite(&gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].field_2]); - gBattleSpritesDataPtr->healthBoxesData[bank].flag_x2 = 0; + r4 = gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].field_2].data[3]; + DestroySprite(&gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].field_2]); + gBattleSpritesDataPtr->healthBoxesData[battler].flag_x2 = 0; } else { - if (!gBattleSpritesDataPtr->healthBoxesData[bank].flag_x4) + if (!gBattleSpritesDataPtr->healthBoxesData[battler].flag_x4) return; - r4 = gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].field_3].data[3]; - DestroySprite(&gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].field_3]); - gBattleSpritesDataPtr->healthBoxesData[bank].flag_x4 = 0; + r4 = gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].field_3].data[3]; + DestroySprite(&gSprites[gBattleSpritesDataPtr->healthBoxesData[battler].field_3]); + gBattleSpritesDataPtr->healthBoxesData[battler].flag_x4 = 0; } gSprites[r4].pos2.x = 0; gSprites[r4].pos2.y = 0; @@ -2671,7 +2671,7 @@ static void SpriteCB_HealthBoxBounce(struct Sprite *sprite) void sub_8039E44(struct Sprite *sprite) { if (sprite->affineAnimEnded) - BattleAnimateBackSprite(sprite, sprite->tSpeciesId); + BattleAnimateBackSprite(sprite, sprite->sSpeciesId); } void sub_8039E60(struct Sprite *sprite) @@ -2752,8 +2752,8 @@ static void BattleStartClearSetData(void) dataPtr[j] = 0; } - gBattleMoveAttacker = 0; - gBattleMoveTarget = 0; + gBattlerAttacker = 0; + gBattlerTarget = 0; gBattleWeather = 0; dataPtr = (u8 *)&gWishFutureKnock; @@ -2841,12 +2841,12 @@ void SwitchInClearSetData(void) gBattleMons[gActiveBattler].statStages[i] = 6; for (i = 0; i < gBattlersCount; i++) { - if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].bankPreventingEscape == gActiveBattler) + if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].battlerPreventingEscape == gActiveBattler) gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; - if ((gStatuses3[i] & STATUS3_ALWAYS_HITS) && gDisableStructs[i].bankWithSureHit == gActiveBattler) + if ((gStatuses3[i] & STATUS3_ALWAYS_HITS) && gDisableStructs[i].battlerWithSureHit == gActiveBattler) { gStatuses3[i] &= ~STATUS3_ALWAYS_HITS; - gDisableStructs[i].bankWithSureHit = 0; + gDisableStructs[i].battlerWithSureHit = 0; } } } @@ -2859,7 +2859,7 @@ void SwitchInClearSetData(void) { if (GetBattlerSide(gActiveBattler) != GetBattlerSide(i) && (gStatuses3[i] & STATUS3_ALWAYS_HITS) != 0 - && (gDisableStructs[i].bankWithSureHit == gActiveBattler)) + && (gDisableStructs[i].battlerWithSureHit == gActiveBattler)) { gStatuses3[i] &= ~(STATUS3_ALWAYS_HITS); gStatuses3[i] |= 0x10; @@ -2890,10 +2890,10 @@ void SwitchInClearSetData(void) if (gBattleMoves[gCurrentMove].effect == EFFECT_BATON_PASS) { gDisableStructs[gActiveBattler].substituteHP = disableStructCopy.substituteHP; - gDisableStructs[gActiveBattler].bankWithSureHit = disableStructCopy.bankWithSureHit; + gDisableStructs[gActiveBattler].battlerWithSureHit = disableStructCopy.battlerWithSureHit; gDisableStructs[gActiveBattler].perishSongTimer1 = disableStructCopy.perishSongTimer1; gDisableStructs[gActiveBattler].perishSongTimer2 = disableStructCopy.perishSongTimer2; - gDisableStructs[gActiveBattler].bankPreventingEscape = disableStructCopy.bankPreventingEscape; + gDisableStructs[gActiveBattler].battlerPreventingEscape = disableStructCopy.battlerPreventingEscape; } gMoveResultFlags = 0; @@ -2937,8 +2937,8 @@ void SwitchInClearSetData(void) gCurrentMove = 0; gBattleStruct->field_DA = 0xFF; - ClearBankMoveHistory(gActiveBattler); - ClearBankAbilityHistory(gActiveBattler); + ClearBattlerMoveHistory(gActiveBattler); + ClearBattlerAbilityHistory(gActiveBattler); } void FaintClearSetData(void) @@ -2954,7 +2954,7 @@ void FaintClearSetData(void) for (i = 0; i < gBattlersCount; i++) { - if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].bankPreventingEscape == gActiveBattler) + if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].battlerPreventingEscape == gActiveBattler) gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBattler)) gBattleMons[i].status2 &= ~(STATUS2_INFATUATED_WITH(gActiveBattler)); @@ -3030,8 +3030,8 @@ void FaintClearSetData(void) gBattleMons[gActiveBattler].type1 = gBaseStats[gBattleMons[gActiveBattler].species].type1; gBattleMons[gActiveBattler].type2 = gBaseStats[gBattleMons[gActiveBattler].species].type2; - ClearBankMoveHistory(gActiveBattler); - ClearBankAbilityHistory(gActiveBattler); + ClearBattlerMoveHistory(gActiveBattler); + ClearBattlerAbilityHistory(gActiveBattler); } static void BattleIntroGetMonsData(void) @@ -3639,8 +3639,8 @@ static void TryDoEventsBeforeFirstTurn(void) for (i = 0; i < MAX_BATTLERS_COUNT; i++) { *(gBattleStruct->monToSwitchIntoId + i) = 6; - gActionForBanks[i] = ACTION_INIT_VALUE; - gChosenMovesByBanks[i] = MOVE_NONE; + gChosenActionByBattler[i] = B_ACTION_NONE; + gChosenMoveByBattler[i] = MOVE_NONE; } TurnValuesCleanUp(FALSE); SpecialStatusesClear(); @@ -3744,8 +3744,8 @@ void BattleTurnPassed(void) for (i = 0; i < gBattlersCount; i++) { - gActionForBanks[i] = ACTION_INIT_VALUE; - gChosenMovesByBanks[i] = MOVE_NONE; + gChosenActionByBattler[i] = B_ACTION_NONE; + gChosenMoveByBattler[i] = MOVE_NONE; } for (i = 0; i < 4; i++) @@ -3773,7 +3773,7 @@ u8 IsRunningFromBattleImpossible(void) else holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item); - gStringBank = gActiveBattler; + gStringBattler = gActiveBattler; if (holdEffect == HOLD_EFFECT_CAN_ALWAYS_RUN) return 0; @@ -3828,34 +3828,34 @@ u8 IsRunningFromBattleImpossible(void) return 0; } -void sub_803BDA0(u8 bank) +void sub_803BDA0(u8 battler) { s32 i; u8 r4; u8 r1; - // gBattleStruct->field_60[bank][i] + // gBattleStruct->field_60[battler][i] for (i = 0; i < 3; i++) - gUnknown_0203CF00[i] = *(bank * 3 + i + (u8*)(gBattleStruct->field_60)); + gUnknown_0203CF00[i] = *(battler * 3 + i + (u8*)(gBattleStruct->field_60)); - r4 = pokemon_order_func(gBattlerPartyIndexes[bank]); - r1 = pokemon_order_func(*(gBattleStruct->monToSwitchIntoId + bank)); + r4 = pokemon_order_func(gBattlerPartyIndexes[battler]); + r1 = pokemon_order_func(*(gBattleStruct->monToSwitchIntoId + battler)); sub_81B8FB0(r4, r1); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { for (i = 0; i < 3; i++) { - *(bank * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; - *((bank ^ BIT_FLANK) * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + *(battler * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + *(BATTLE_PARTNER(battler) * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; } } else { for (i = 0; i < 3; i++) { - *(bank * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; + *(battler * 3 + i + (u8*)(gBattleStruct->field_60)) = gUnknown_0203CF00[i]; } } } @@ -3891,12 +3891,12 @@ static void HandleTurnActionSelectionState(void) *(gBattleStruct->monToSwitchIntoId + gActiveBattler) = 6; if (gBattleTypeFlags & BATTLE_TYPE_MULTI || !(position & BIT_FLANK) - || gBattleStruct->field_91 & gBitTable[GetBattlerAtPosition(position ^ BIT_FLANK)] - || gBattleCommunication[GetBattlerAtPosition(position ^ BIT_FLANK)] == 5) + || gBattleStruct->field_91 & gBitTable[GetBattlerAtPosition(BATTLE_PARTNER(position))] + || gBattleCommunication[GetBattlerAtPosition(BATTLE_PARTNER(position))] == 5) { if (gBattleStruct->field_91 & gBitTable[gActiveBattler]) { - gActionForBanks[gActiveBattler] = ACTION_NOTHING_FAINTED; + gChosenActionByBattler[gActiveBattler] = B_ACTION_NOTHING_FAINTED; if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) gBattleCommunication[gActiveBattler] = STATE_WAIT_ACTION_CONFIRMED; else @@ -3907,12 +3907,12 @@ static void HandleTurnActionSelectionState(void) if (gBattleMons[gActiveBattler].status2 & STATUS2_MULTIPLETURNS || gBattleMons[gActiveBattler].status2 & STATUS2_RECHARGE) { - gActionForBanks[gActiveBattler] = ACTION_USE_MOVE; + gChosenActionByBattler[gActiveBattler] = B_ACTION_USE_MOVE; gBattleCommunication[gActiveBattler] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; } else { - BtlController_EmitChooseAction(0, gActionForBanks[0], gBattleBufferB[0][1] | (gBattleBufferB[0][2] << 8)); + BtlController_EmitChooseAction(0, gChosenActionByBattler[0], gBattleBufferB[0][1] | (gBattleBufferB[0][2] << 8)); MarkBattlerForControllerExec(gActiveBattler); gBattleCommunication[gActiveBattler]++; } @@ -3923,11 +3923,11 @@ static void HandleTurnActionSelectionState(void) if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { RecordedBattle_SetBattlerAction(gActiveBattler, gBattleBufferB[gActiveBattler][1]); - gActionForBanks[gActiveBattler] = gBattleBufferB[gActiveBattler][1]; + gChosenActionByBattler[gActiveBattler] = gBattleBufferB[gActiveBattler][1]; switch (gBattleBufferB[gActiveBattler][1]) { - case ACTION_USE_MOVE: + case B_ACTION_USE_MOVE: if (AreAllMovesUnusable()) { gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; @@ -3938,7 +3938,7 @@ static void HandleTurnActionSelectionState(void) } else if (gDisableStructs[gActiveBattler].encoredMove != 0) { - gChosenMovesByBanks[gActiveBattler] = gDisableStructs[gActiveBattler].encoredMove; + gChosenMoveByBattler[gActiveBattler] = gDisableStructs[gActiveBattler].encoredMove; *(gBattleStruct->chosenMovePositions + gActiveBattler) = gDisableStructs[gActiveBattler].encoredMovePos; gBattleCommunication[gActiveBattler] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; return; @@ -3965,7 +3965,7 @@ static void HandleTurnActionSelectionState(void) MarkBattlerForControllerExec(gActiveBattler); } break; - case ACTION_USE_ITEM: + case B_ACTION_USE_ITEM: if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_FRONTIER_NO_PYRAMID | BATTLE_TYPE_EREADER_TRAINER @@ -3984,7 +3984,7 @@ static void HandleTurnActionSelectionState(void) MarkBattlerForControllerExec(gActiveBattler); } break; - case ACTION_SWITCH: + case B_ACTION_SWITCH: *(gBattleStruct->field_58 + gActiveBattler) = gBattlerPartyIndexes[gActiveBattler]; if (gBattleMons[gActiveBattler].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION) || gBattleTypeFlags & BATTLE_TYPE_ARENA @@ -4005,16 +4005,16 @@ static void HandleTurnActionSelectionState(void) } else { - if (gActiveBattler == 2 && gActionForBanks[0] == ACTION_SWITCH) + if (gActiveBattler == 2 && gChosenActionByBattler[0] == B_ACTION_SWITCH) BtlController_EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 0), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); - else if (gActiveBattler == 3 && gActionForBanks[1] == ACTION_SWITCH) + else if (gActiveBattler == 3 && gChosenActionByBattler[1] == B_ACTION_SWITCH) BtlController_EmitChoosePokemon(0, 0, *(gBattleStruct->monToSwitchIntoId + 1), ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); else BtlController_EmitChoosePokemon(0, 0, 6, ABILITY_NONE, gBattleStruct->field_60[gActiveBattler]); } MarkBattlerForControllerExec(gActiveBattler); break; - case ACTION_SAFARI_ZONE_BALL: + case B_ACTION_SAFARI_BALL: if (IsPlayerPartyAndPokemonStorageFull()) { gSelectionBattleScripts[gActiveBattler] = BattleScript_PrintFullBox; @@ -4024,44 +4024,44 @@ static void HandleTurnActionSelectionState(void) return; } break; - case ACTION_POKEBLOCK_CASE: + case B_ACTION_SAFARI_POKEBLOCK: BtlController_EmitChooseItem(0, gBattleStruct->field_60[gActiveBattler]); MarkBattlerForControllerExec(gActiveBattler); break; - case ACTION_CANCEL_PARTNER: + case B_ACTION_CANCEL_PARTNER: gBattleCommunication[gActiveBattler] = 7; - gBattleCommunication[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)] = 1; + gBattleCommunication[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] = 1; RecordedBattle_ClearBattlerAction(gActiveBattler, 1); - if (gBattleMons[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)].status2 & STATUS2_MULTIPLETURNS - || gBattleMons[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)].status2 & STATUS2_RECHARGE) + if (gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].status2 & STATUS2_MULTIPLETURNS + || gBattleMons[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].status2 & STATUS2_RECHARGE) { BtlController_EmitCmd50(0); MarkBattlerForControllerExec(gActiveBattler); return; } - else if (gActionForBanks[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)] == ACTION_SWITCH) + else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_SWITCH) { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK), 2); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 2); } - else if (gActionForBanks[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)] == ACTION_RUN) + else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_RUN) { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK), 1); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 1); } - 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)) + else if (gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_USE_MOVE + && (gProtectStructs[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].onlyStruggle + || gDisableStructs[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))].encoredMove)) { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK), 1); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 1); } else if (gBattleTypeFlags & BATTLE_TYPE_PALACE - && gActionForBanks[GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK)] == ACTION_USE_MOVE) + && gChosenActionByBattler[GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler)))] == B_ACTION_USE_MOVE) { gRngValue = gBattlePalaceMoveSelectionRngValue; - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK), 1); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 1); } else { - RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(GetBattlerPosition(gActiveBattler) ^ BIT_FLANK), 3); + RecordedBattle_ClearBattlerAction(GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gActiveBattler))), 3); } BtlController_EmitCmd50(0); MarkBattlerForControllerExec(gActiveBattler); @@ -4070,7 +4070,7 @@ static void HandleTurnActionSelectionState(void) if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000) - && gBattleBufferB[gActiveBattler][1] == ACTION_RUN) + && gBattleBufferB[gActiveBattler][1] == B_ACTION_RUN) { gSelectionBattleScripts[gActiveBattler] = BattleScript_AskIfWantsToForfeitMatch; gBattleCommunication[gActiveBattler] = 8; @@ -4080,13 +4080,13 @@ static void HandleTurnActionSelectionState(void) } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && !(gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) - && gBattleBufferB[gActiveBattler][1] == ACTION_RUN) + && gBattleBufferB[gActiveBattler][1] == B_ACTION_RUN) { BattleScriptExecute(BattleScript_PrintCantRunFromTrainer); gBattleCommunication[gActiveBattler] = 1; } else if (IsRunningFromBattleImpossible() - && gBattleBufferB[gActiveBattler][1] == ACTION_RUN) + && gBattleBufferB[gActiveBattler][1] == B_ACTION_RUN) { gSelectionBattleScripts[gActiveBattler] = BattleScript_PrintCantEscapeFromBattle; gBattleCommunication[gActiveBattler] = STATE_SELECTION_SCRIPT; @@ -4103,9 +4103,9 @@ static void HandleTurnActionSelectionState(void) case STATE_WAIT_ACTION_CASE_CHOSEN: if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { - switch (gActionForBanks[gActiveBattler]) + switch (gChosenActionByBattler[gActiveBattler]) { - case ACTION_USE_MOVE: + case B_ACTION_USE_MOVE: switch (gBattleBufferB[gActiveBattler][1]) { case 3: @@ -4115,10 +4115,10 @@ static void HandleTurnActionSelectionState(void) case 7: case 8: case 9: - gActionForBanks[gActiveBattler] = gBattleBufferB[gActiveBattler][1]; + gChosenActionByBattler[gActiveBattler] = gBattleBufferB[gActiveBattler][1]; return; case 15: - gActionForBanks[gActiveBattler] = ACTION_SWITCH; + gChosenActionByBattler[gActiveBattler] = B_ACTION_SWITCH; sub_803CDF8(); return; default: @@ -4145,14 +4145,14 @@ static void HandleTurnActionSelectionState(void) RecordedBattle_SetBattlerAction(gActiveBattler, gBattleBufferB[gActiveBattler][3]); } *(gBattleStruct->chosenMovePositions + gActiveBattler) = gBattleBufferB[gActiveBattler][2]; - gChosenMovesByBanks[gActiveBattler] = gBattleMons[gActiveBattler].moves[*(gBattleStruct->chosenMovePositions + gActiveBattler)]; + gChosenMoveByBattler[gActiveBattler] = gBattleMons[gActiveBattler].moves[*(gBattleStruct->chosenMovePositions + gActiveBattler)]; *(gBattleStruct->moveTarget + gActiveBattler) = gBattleBufferB[gActiveBattler][3]; gBattleCommunication[gActiveBattler]++; } break; } break; - case ACTION_USE_ITEM: + case B_ACTION_USE_ITEM: if ((gBattleBufferB[gActiveBattler][1] | (gBattleBufferB[gActiveBattler][2] << 8)) == 0) { gBattleCommunication[gActiveBattler] = 1; @@ -4163,7 +4163,7 @@ static void HandleTurnActionSelectionState(void) gBattleCommunication[gActiveBattler]++; } break; - case ACTION_SWITCH: + case B_ACTION_SWITCH: if (gBattleBufferB[gActiveBattler][1] == 6) { gBattleCommunication[gActiveBattler] = 1; @@ -4175,17 +4175,17 @@ static void HandleTurnActionSelectionState(void) gBattleCommunication[gActiveBattler]++; } break; - case ACTION_RUN: + case B_ACTION_RUN: gHitMarker |= HITMARKER_RUN; gBattleCommunication[gActiveBattler]++; break; - case ACTION_WATCHES_CAREFULLY: + case B_ACTION_SAFARI_WATCH_CAREFULLY: gBattleCommunication[gActiveBattler]++; break; - case ACTION_SAFARI_ZONE_BALL: + case B_ACTION_SAFARI_BALL: gBattleCommunication[gActiveBattler]++; break; - case ACTION_POKEBLOCK_CASE: + case B_ACTION_SAFARI_POKEBLOCK: if ((gBattleBufferB[gActiveBattler][1] | (gBattleBufferB[gActiveBattler][2] << 8)) != 0) { gBattleCommunication[gActiveBattler]++; @@ -4195,14 +4195,14 @@ static void HandleTurnActionSelectionState(void) gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; } break; - case ACTION_GO_NEAR: + case B_ACTION_SAFARI_GO_NEAR: gBattleCommunication[gActiveBattler]++; break; - case ACTION_SAFARI_ZONE_RUN: + case B_ACTION_SAFARI_RUN: gHitMarker |= HITMARKER_RUN; gBattleCommunication[gActiveBattler]++; break; - case ACTION_9: + case B_ACTION_UNKNOWN9: gBattleCommunication[gActiveBattler]++; break; } @@ -4240,7 +4240,7 @@ static void HandleTurnActionSelectionState(void) } else { - gBattleMoveAttacker = gActiveBattler; + gBattlerAttacker = gActiveBattler; gBattlescriptCurrInstr = gSelectionBattleScripts[gActiveBattler]; if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { @@ -4261,7 +4261,7 @@ static void HandleTurnActionSelectionState(void) if (gBattleBufferB[gActiveBattler][1] == 13) { gHitMarker |= HITMARKER_RUN; - gActionForBanks[gActiveBattler] = ACTION_RUN; + gChosenActionByBattler[gActiveBattler] = B_ACTION_RUN; gBattleCommunication[gActiveBattler] = STATE_WAIT_ACTION_CONFIRMED_STANDBY; } else @@ -4272,7 +4272,7 @@ static void HandleTurnActionSelectionState(void) } else { - gBattleMoveAttacker = gActiveBattler; + gBattlerAttacker = gActiveBattler; gBattlescriptCurrInstr = gSelectionBattleScripts[gActiveBattler]; if (!(gBattleControllerExecFlags & ((gBitTable[gActiveBattler]) | (0xF0000000) | (gBitTable[gActiveBattler] << 4) | (gBitTable[gActiveBattler] << 8) | (gBitTable[gActiveBattler] << 0xC)))) { @@ -4294,7 +4294,7 @@ static void HandleTurnActionSelectionState(void) { for (i = 0; i < gBattlersCount; i++) { - if (gActionForBanks[i] == ACTION_SWITCH) + if (gChosenActionByBattler[i] == B_ACTION_SWITCH) sub_80571DC(i, *(gBattleStruct->monToSwitchIntoId + i)); } } @@ -4447,7 +4447,7 @@ u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves) } else { - if (gActionForBanks[bank1] == ACTION_USE_MOVE) + if (gChosenActionByBattler[bank1] == B_ACTION_USE_MOVE) { if (gProtectStructs[bank1].onlyStruggle) moveBank1 = MOVE_STRUGGLE; @@ -4457,7 +4457,7 @@ u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves) else moveBank1 = MOVE_NONE; - if (gActionForBanks[bank2] == ACTION_USE_MOVE) + if (gChosenActionByBattler[bank2] == B_ACTION_USE_MOVE) { if (gProtectStructs[bank2].onlyStruggle) moveBank2 = MOVE_STRUGGLE; @@ -4509,7 +4509,7 @@ static void SetActionsAndBanksTurnOrder(void) { for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - gActionsByTurnOrder[var] = gActionForBanks[gActiveBattler]; + gActionsByTurnOrder[var] = gChosenActionByBattler[gActiveBattler]; gBattleTurnOrder[var] = gActiveBattler; var++; } @@ -4520,7 +4520,7 @@ static void SetActionsAndBanksTurnOrder(void) { for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (gActionForBanks[gActiveBattler] == ACTION_RUN) + if (gChosenActionByBattler[gActiveBattler] == B_ACTION_RUN) { var = 5; break; @@ -4529,12 +4529,12 @@ static void SetActionsAndBanksTurnOrder(void) } else { - if (gActionForBanks[0] == ACTION_RUN) + if (gChosenActionByBattler[0] == B_ACTION_RUN) { gActiveBattler = 0; var = 5; } - if (gActionForBanks[2] == ACTION_RUN) + if (gChosenActionByBattler[2] == B_ACTION_RUN) { gActiveBattler = 2; var = 5; @@ -4543,14 +4543,14 @@ static void SetActionsAndBanksTurnOrder(void) if (var == 5) { - gActionsByTurnOrder[0] = gActionForBanks[gActiveBattler]; + gActionsByTurnOrder[0] = gChosenActionByBattler[gActiveBattler]; gBattleTurnOrder[0] = gActiveBattler; var = 1; for (i = 0; i < gBattlersCount; i++) { if (i != gActiveBattler) { - gActionsByTurnOrder[var] = gActionForBanks[i]; + gActionsByTurnOrder[var] = gChosenActionByBattler[i]; gBattleTurnOrder[var] = i; var++; } @@ -4563,18 +4563,18 @@ static void SetActionsAndBanksTurnOrder(void) { for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (gActionForBanks[gActiveBattler] == ACTION_USE_ITEM || gActionForBanks[gActiveBattler] == ACTION_SWITCH) + if (gChosenActionByBattler[gActiveBattler] == B_ACTION_USE_ITEM || gChosenActionByBattler[gActiveBattler] == B_ACTION_SWITCH) { - gActionsByTurnOrder[var] = gActionForBanks[gActiveBattler]; + gActionsByTurnOrder[var] = gChosenActionByBattler[gActiveBattler]; gBattleTurnOrder[var] = gActiveBattler; var++; } } for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { - if (gActionForBanks[gActiveBattler] != ACTION_USE_ITEM && gActionForBanks[gActiveBattler] != ACTION_SWITCH) + if (gChosenActionByBattler[gActiveBattler] != B_ACTION_USE_ITEM && gChosenActionByBattler[gActiveBattler] != B_ACTION_SWITCH) { - gActionsByTurnOrder[var] = gActionForBanks[gActiveBattler]; + gActionsByTurnOrder[var] = gChosenActionByBattler[gActiveBattler]; gBattleTurnOrder[var] = gActiveBattler; var++; } @@ -4585,10 +4585,10 @@ static void SetActionsAndBanksTurnOrder(void) { u8 bank1 = gBattleTurnOrder[i]; u8 bank2 = gBattleTurnOrder[j]; - if (gActionsByTurnOrder[i] != ACTION_USE_ITEM - && gActionsByTurnOrder[j] != ACTION_USE_ITEM - && gActionsByTurnOrder[i] != ACTION_SWITCH - && gActionsByTurnOrder[j] != ACTION_SWITCH) + if (gActionsByTurnOrder[i] != B_ACTION_USE_ITEM + && gActionsByTurnOrder[j] != B_ACTION_USE_ITEM + && gActionsByTurnOrder[i] != B_ACTION_SWITCH + && gActionsByTurnOrder[j] != B_ACTION_SWITCH) { if (GetWhoStrikesFirst(bank1, bank2, FALSE)) SwapTurnOrder(i, j); @@ -4656,11 +4656,11 @@ static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void) { while (gBattleStruct->focusPunchBank < gBattlersCount) { - gActiveBattler = gBattleMoveAttacker = gBattleStruct->focusPunchBank; + gActiveBattler = gBattlerAttacker = gBattleStruct->focusPunchBank; gBattleStruct->focusPunchBank++; - if (gChosenMovesByBanks[gActiveBattler] == MOVE_FOCUS_PUNCH + if (gChosenMoveByBattler[gActiveBattler] == MOVE_FOCUS_PUNCH && !(gBattleMons[gActiveBattler].status1 & STATUS1_SLEEP) - && !(gDisableStructs[gBattleMoveAttacker].truantCounter) + && !(gDisableStructs[gBattlerAttacker].truantCounter) && !(gProtectStructs[gActiveBattler].onlyStruggle)) { BattleScriptExecute(BattleScript_FocusPunchSetUp); @@ -4716,7 +4716,7 @@ static void HandleEndTurn_BattleWon(void) { gSpecialVar_Result = gBattleOutcome; gBattleTextBuff1[0] = gBattleOutcome; - gBattleMoveAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + gBattlerAttacker = 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; - gBattleMoveAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + gBattlerAttacker = 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[gBattleMoveAttacker].fleeFlag) + switch (gProtectStructs[gBattlerAttacker].fleeFlag) { default: gBattlescriptCurrInstr = BattleScript_GotAwaySafely; @@ -4840,7 +4840,7 @@ static void HandleEndTurn_MonFled(void) { gCurrentActionFuncId = 0; - PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattleMoveAttacker, gBattlerPartyIndexes[gBattleMoveAttacker]); + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattlerAttacker, gBattlerPartyIndexes[gBattlerAttacker]); gBattlescriptCurrInstr = BattleScript_WildMonFled; gBattleMainFunc = HandleEndTurn_FinishBattle; @@ -4995,9 +4995,9 @@ void RunBattleScriptCommands_PopCallbacksStack(void) { if (gCurrentActionFuncId == 0xB || gCurrentActionFuncId == 0xC) { - if (BATTLE_CALLBACKS_STACK->size != 0) - BATTLE_CALLBACKS_STACK->size--; - gBattleMainFunc = BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size]; + if (gBattleResources->battleCallbackStack->size != 0) + gBattleResources->battleCallbackStack->size--; + gBattleMainFunc = gBattleResources->battleCallbackStack->function[gBattleResources->battleCallbackStack->size]; } else { @@ -5017,11 +5017,11 @@ static void HandleAction_UseMove(void) u8 side; u8 var = 4; - gBattleMoveAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; + gBattlerAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; - if (*(&gBattleStruct->field_91) & gBitTable[gBattleMoveAttacker]) + if (*(&gBattleStruct->field_91) & gBitTable[gBattlerAttacker]) { - gCurrentActionFuncId = ACTION_FINISHED; + gCurrentActionFuncId = B_ACTION_FINISHED; return; } @@ -5031,78 +5031,78 @@ static void HandleAction_UseMove(void) gMoveResultFlags = 0; gMultiHitCounter = 0; gBattleCommunication[6] = 0; - gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBattleMoveAttacker); + gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBattlerAttacker); // choose move - if (gProtectStructs[gBattleMoveAttacker].onlyStruggle) + if (gProtectStructs[gBattlerAttacker].onlyStruggle) { - gProtectStructs[gBattleMoveAttacker].onlyStruggle = 0; + gProtectStructs[gBattlerAttacker].onlyStruggle = 0; gCurrentMove = gChosenMove = MOVE_STRUGGLE; gHitMarker |= HITMARKER_NO_PPDEDUCT; - *(gBattleStruct->moveTarget + gBattleMoveAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0); + *(gBattleStruct->moveTarget + gBattlerAttacker) = GetMoveTarget(MOVE_STRUGGLE, 0); } - else if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_MULTIPLETURNS || gBattleMons[gBattleMoveAttacker].status2 & STATUS2_RECHARGE) + else if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS || gBattleMons[gBattlerAttacker].status2 & STATUS2_RECHARGE) { - gCurrentMove = gChosenMove = gLockedMoves[gBattleMoveAttacker]; + gCurrentMove = gChosenMove = gLockedMoves[gBattlerAttacker]; } // encore forces you to use the same move - else if (gDisableStructs[gBattleMoveAttacker].encoredMove != MOVE_NONE - && gDisableStructs[gBattleMoveAttacker].encoredMove == gBattleMons[gBattleMoveAttacker].moves[gDisableStructs[gBattleMoveAttacker].encoredMovePos]) + else if (gDisableStructs[gBattlerAttacker].encoredMove != MOVE_NONE + && gDisableStructs[gBattlerAttacker].encoredMove == gBattleMons[gBattlerAttacker].moves[gDisableStructs[gBattlerAttacker].encoredMovePos]) { - gCurrentMove = gChosenMove = gDisableStructs[gBattleMoveAttacker].encoredMove; - gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBattleMoveAttacker].encoredMovePos; - *(gBattleStruct->moveTarget + gBattleMoveAttacker) = GetMoveTarget(gCurrentMove, 0); + gCurrentMove = gChosenMove = gDisableStructs[gBattlerAttacker].encoredMove; + gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBattlerAttacker].encoredMovePos; + *(gBattleStruct->moveTarget + gBattlerAttacker) = GetMoveTarget(gCurrentMove, 0); } // check if the encored move wasn't overwritten - else if (gDisableStructs[gBattleMoveAttacker].encoredMove != MOVE_NONE - && gDisableStructs[gBattleMoveAttacker].encoredMove != gBattleMons[gBattleMoveAttacker].moves[gDisableStructs[gBattleMoveAttacker].encoredMovePos]) + else if (gDisableStructs[gBattlerAttacker].encoredMove != MOVE_NONE + && gDisableStructs[gBattlerAttacker].encoredMove != gBattleMons[gBattlerAttacker].moves[gDisableStructs[gBattlerAttacker].encoredMovePos]) { - gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBattleMoveAttacker].encoredMovePos; - gCurrentMove = gChosenMove = gBattleMons[gBattleMoveAttacker].moves[gCurrMovePos]; - gDisableStructs[gBattleMoveAttacker].encoredMove = MOVE_NONE; - gDisableStructs[gBattleMoveAttacker].encoredMovePos = 0; - gDisableStructs[gBattleMoveAttacker].encoreTimer1 = 0; - *(gBattleStruct->moveTarget + gBattleMoveAttacker) = GetMoveTarget(gCurrentMove, 0); + gCurrMovePos = gUnknown_020241E9 = gDisableStructs[gBattlerAttacker].encoredMovePos; + gCurrentMove = gChosenMove = gBattleMons[gBattlerAttacker].moves[gCurrMovePos]; + gDisableStructs[gBattlerAttacker].encoredMove = MOVE_NONE; + gDisableStructs[gBattlerAttacker].encoredMovePos = 0; + gDisableStructs[gBattlerAttacker].encoreTimer1 = 0; + *(gBattleStruct->moveTarget + gBattlerAttacker) = GetMoveTarget(gCurrentMove, 0); } - else if (gBattleMons[gBattleMoveAttacker].moves[gCurrMovePos] != gChosenMovesByBanks[gBattleMoveAttacker]) + else if (gBattleMons[gBattlerAttacker].moves[gCurrMovePos] != gChosenMoveByBattler[gBattlerAttacker]) { - gCurrentMove = gChosenMove = gBattleMons[gBattleMoveAttacker].moves[gCurrMovePos]; - *(gBattleStruct->moveTarget + gBattleMoveAttacker) = GetMoveTarget(gCurrentMove, 0); + gCurrentMove = gChosenMove = gBattleMons[gBattlerAttacker].moves[gCurrMovePos]; + *(gBattleStruct->moveTarget + gBattlerAttacker) = GetMoveTarget(gCurrentMove, 0); } else { - gCurrentMove = gChosenMove = gBattleMons[gBattleMoveAttacker].moves[gCurrMovePos]; + gCurrentMove = gChosenMove = gBattleMons[gBattlerAttacker].moves[gCurrMovePos]; } - if (gBattleMons[gBattleMoveAttacker].hp != 0) + if (gBattleMons[gBattlerAttacker].hp != 0) { - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) gBattleResults.lastUsedMovePlayer = gCurrentMove; else gBattleResults.lastUsedMoveOpponent = gCurrentMove; } // choose target - side = GetBattlerSide(gBattleMoveAttacker) ^ BIT_SIDE; + side = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE; if (gSideTimers[side].followmeTimer != 0 && gBattleMoves[gCurrentMove].target == MOVE_TARGET_SELECTED - && GetBattlerSide(gBattleMoveAttacker) != GetBattlerSide(gSideTimers[side].followmeTarget) + && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gSideTimers[side].followmeTarget) && gBattleMons[gSideTimers[side].followmeTarget].hp != 0) { - gBattleMoveTarget = gSideTimers[side].followmeTarget; + gBattlerTarget = 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 + gBattleMoveAttacker)].ability != ABILITY_LIGHTNING_ROD + && gBattleMons[*(gBattleStruct->moveTarget + gBattlerAttacker)].ability != ABILITY_LIGHTNING_ROD && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) { - side = GetBattlerSide(gBattleMoveAttacker); + side = GetBattlerSide(gBattlerAttacker); for (gActiveBattler = 0; gActiveBattler < gBattlersCount; gActiveBattler++) { if (side != GetBattlerSide(gActiveBattler) - && *(gBattleStruct->moveTarget + gBattleMoveAttacker) != gActiveBattler + && *(gBattleStruct->moveTarget + gBattlerAttacker) != gActiveBattler && gBattleMons[gActiveBattler].ability == ABILITY_LIGHTNING_ROD && GetBattlerTurnOrderNum(gActiveBattler) < var) { @@ -5113,37 +5113,37 @@ static void HandleAction_UseMove(void) { if (gBattleMoves[gChosenMove].target & MOVE_TARGET_RANDOM) { - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) { if (Random() & 1) - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); else - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); } else { if (Random() & 1) - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); else - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); } } else { - gBattleMoveTarget = *(gBattleStruct->moveTarget + gBattleMoveAttacker); + gBattlerTarget = *(gBattleStruct->moveTarget + gBattlerAttacker); } - if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) + if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) { - if (GetBattlerSide(gBattleMoveAttacker) != GetBattlerSide(gBattleMoveTarget)) + if (GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) { - gBattleMoveTarget = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveTarget) ^ BIT_FLANK); + gBattlerTarget = GetBattlerAtPosition(GetBattlerPosition(gBattlerTarget) ^ BIT_FLANK); } else { - gBattleMoveTarget = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveAttacker) ^ BIT_SIDE); - if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) - gBattleMoveTarget = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveTarget) ^ BIT_FLANK); + gBattlerTarget = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_SIDE); + if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) + gBattlerTarget = GetBattlerAtPosition(GetBattlerPosition(gBattlerTarget) ^ BIT_FLANK); } } } @@ -5152,65 +5152,65 @@ static void HandleAction_UseMove(void) gActiveBattler = gBattleTurnOrder[var]; RecordAbilityBattle(gActiveBattler, gBattleMons[gActiveBattler].ability); gSpecialStatuses[gActiveBattler].lightningRodRedirected = 1; - gBattleMoveTarget = gActiveBattler; + gBattlerTarget = gActiveBattler; } } else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && gBattleMoves[gChosenMove].target & MOVE_TARGET_RANDOM) { - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) { if (Random() & 1) - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); else - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); } else { if (Random() & 1) - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); else - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); } - if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget] - && GetBattlerSide(gBattleMoveAttacker) != GetBattlerSide(gBattleMoveTarget)) + if (gAbsentBattlerFlags & gBitTable[gBattlerTarget] + && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) { - gBattleMoveTarget = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveTarget) ^ BIT_FLANK); + gBattlerTarget = GetBattlerAtPosition(GetBattlerPosition(gBattlerTarget) ^ BIT_FLANK); } } else { - gBattleMoveTarget = *(gBattleStruct->moveTarget + gBattleMoveAttacker); - if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) + gBattlerTarget = *(gBattleStruct->moveTarget + gBattlerAttacker); + if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) { - if (GetBattlerSide(gBattleMoveAttacker) != GetBattlerSide(gBattleMoveTarget)) + if (GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget)) { - gBattleMoveTarget = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveTarget) ^ BIT_FLANK); + gBattlerTarget = GetBattlerAtPosition(GetBattlerPosition(gBattlerTarget) ^ BIT_FLANK); } else { - gBattleMoveTarget = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveAttacker) ^ BIT_SIDE); - if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) - gBattleMoveTarget = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveTarget) ^ BIT_FLANK); + gBattlerTarget = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_SIDE); + if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) + gBattlerTarget = GetBattlerAtPosition(GetBattlerPosition(gBattlerTarget) ^ BIT_FLANK); } } } // choose battlescript if (gBattleTypeFlags & BATTLE_TYPE_PALACE - && gProtectStructs[gBattleMoveAttacker].flag_x10) + && gProtectStructs[gBattlerAttacker].flag_x10) { - if (gBattleMons[gBattleMoveAttacker].hp == 0) + if (gBattleMons[gBattlerAttacker].hp == 0) { - gCurrentActionFuncId = 12; + gCurrentActionFuncId = B_ACTION_FINISHED; return; } - else if (gPalaceSelectionBattleScripts[gBattleMoveAttacker] != NULL) + else if (gPalaceSelectionBattleScripts[gBattlerAttacker] != NULL) { gBattleCommunication[MULTISTRING_CHOOSER] = 4; - gBattlescriptCurrInstr = gPalaceSelectionBattleScripts[gBattleMoveAttacker]; - gPalaceSelectionBattleScripts[gBattleMoveAttacker] = NULL; + gBattlescriptCurrInstr = gPalaceSelectionBattleScripts[gBattlerAttacker]; + gPalaceSelectionBattleScripts[gBattlerAttacker] = NULL; } else { @@ -5224,24 +5224,24 @@ static void HandleAction_UseMove(void) } if (gBattleTypeFlags & BATTLE_TYPE_ARENA) - sub_81A56E8(gBattleMoveAttacker); + sub_81A56E8(gBattlerAttacker); - gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; } static void HandleAction_Switch(void) { - gBattleMoveAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; + gBattlerAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - gActionSelectionCursor[gBattleMoveAttacker] = 0; - gMoveSelectionCursor[gBattleMoveAttacker] = 0; + gActionSelectionCursor[gBattlerAttacker] = 0; + gMoveSelectionCursor[gBattlerAttacker] = 0; - PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattleMoveAttacker, *(gBattleStruct->field_58 + gBattleMoveAttacker)) + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattlerAttacker, *(gBattleStruct->field_58 + gBattlerAttacker)) - gBattleScripting.battler = gBattleMoveAttacker; + gBattleScripting.battler = gBattlerAttacker; gBattlescriptCurrInstr = BattleScript_ActionSwitch; - gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; if (gBattleResults.playerSwitchesCounter < 255) gBattleResults.playerSwitchesCounter++; @@ -5249,11 +5249,11 @@ static void HandleAction_Switch(void) static void HandleAction_UseItem(void) { - gBattleMoveAttacker = gBattleMoveTarget = gBattleTurnOrder[gCurrentTurnActionNumber]; + gBattlerAttacker = gBattlerTarget = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - ClearFuryCutterDestinyBondGrudge(gBattleMoveAttacker); - gLastUsedItem = gBattleBufferB[gBattleMoveAttacker][1] | (gBattleBufferB[gBattleMoveAttacker][2] << 8); + ClearFuryCutterDestinyBondGrudge(gBattlerAttacker); + gLastUsedItem = gBattleBufferB[gBattlerAttacker][1] | (gBattleBufferB[gBattlerAttacker][2] << 8); if (gLastUsedItem <= ITEM_PREMIER_BALL) // is ball { @@ -5263,38 +5263,38 @@ static void HandleAction_UseItem(void) { gBattlescriptCurrInstr = gBattlescriptsForRunningByItem[0]; } - else if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + else if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) { gBattlescriptCurrInstr = gBattlescriptsForUsingItem[0]; } else { - gBattleScripting.battler = gBattleMoveAttacker; + gBattleScripting.battler = gBattlerAttacker; - switch (*(gBattleStruct->AI_itemType + (gBattleMoveAttacker >> 1))) + switch (*(gBattleStruct->AI_itemType + (gBattlerAttacker >> 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 + gBattleMoveAttacker / 2) & 1) + if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & 1) { - if (*(gBattleStruct->AI_itemFlags + gBattleMoveAttacker / 2) & 0x3E) + if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & 0x3E) gBattleCommunication[MULTISTRING_CHOOSER] = 5; } else { - while (!(*(gBattleStruct->AI_itemFlags + gBattleMoveAttacker / 2) & 1)) + while (!(*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & 1)) { - *(gBattleStruct->AI_itemFlags + gBattleMoveAttacker / 2) >>= 1; + *(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) >>= 1; gBattleCommunication[MULTISTRING_CHOOSER]++; } } break; case AI_ITEM_X_STAT: gBattleCommunication[MULTISTRING_CHOOSER] = 4; - if (*(gBattleStruct->AI_itemFlags + (gBattleMoveAttacker >> 1)) & 0x80) + if (*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 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 + (gBattleMoveAttacker >> 1))) & 1)) + while (!((*(gBattleStruct->AI_itemFlags + (gBattlerAttacker >> 1))) & 1)) { - *(gBattleStruct->AI_itemFlags + gBattleMoveAttacker / 2) >>= 1; + *(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) >>= 1; gBattleTextBuff1[2]++; } @@ -5321,49 +5321,49 @@ static void HandleAction_UseItem(void) break; } - gBattlescriptCurrInstr = gBattlescriptsForUsingItem[*(gBattleStruct->AI_itemType + gBattleMoveAttacker / 2)]; + gBattlescriptCurrInstr = gBattlescriptsForUsingItem[*(gBattleStruct->AI_itemType + gBattlerAttacker / 2)]; } - gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; } -bool8 TryRunFromBattle(u8 bank) +bool8 TryRunFromBattle(u8 battler) { bool8 effect = FALSE; u8 holdEffect; u8 pyramidMultiplier; u8 speedVar; - if (gBattleMons[bank].item == ITEM_ENIGMA_BERRY) - holdEffect = gEnigmaBerries[bank].holdEffect; + if (gBattleMons[battler].item == ITEM_ENIGMA_BERRY) + holdEffect = gEnigmaBerries[battler].holdEffect; else - holdEffect = ItemId_GetHoldEffect(gBattleMons[bank].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[battler].item); - gStringBank = bank; + gStringBattler = battler; if (holdEffect == HOLD_EFFECT_CAN_ALWAYS_RUN) { - gLastUsedItem = gBattleMons[bank].item ; - gProtectStructs[bank].fleeFlag = 1; + gLastUsedItem = gBattleMons[battler].item ; + gProtectStructs[battler].fleeFlag = 1; effect++; } - else if (gBattleMons[bank].ability == ABILITY_RUN_AWAY) + else if (gBattleMons[battler].ability == ABILITY_RUN_AWAY) { if (InBattlePyramid()) { gBattleStruct->runTries++; pyramidMultiplier = sub_81A9E28(); - speedVar = (gBattleMons[bank].speed * pyramidMultiplier) / (gBattleMons[bank ^ BIT_SIDE].speed) + (gBattleStruct->runTries * 30); + speedVar = (gBattleMons[battler].speed * pyramidMultiplier) / (gBattleMons[BATTLE_OPPOSITE(battler)].speed) + (gBattleStruct->runTries * 30); if (speedVar > (Random() & 0xFF)) { gLastUsedAbility = ABILITY_RUN_AWAY; - gProtectStructs[bank].fleeFlag = 2; + gProtectStructs[battler].fleeFlag = 2; effect++; } } else { gLastUsedAbility = ABILITY_RUN_AWAY; - gProtectStructs[bank].fleeFlag = 2; + gProtectStructs[battler].fleeFlag = 2; effect++; } } @@ -5378,13 +5378,13 @@ bool8 TryRunFromBattle(u8 bank) if (InBattlePyramid()) { pyramidMultiplier = sub_81A9E28(); - speedVar = (gBattleMons[bank].speed * pyramidMultiplier) / (gBattleMons[bank ^ BIT_SIDE].speed) + (gBattleStruct->runTries * 30); + speedVar = (gBattleMons[battler].speed * pyramidMultiplier) / (gBattleMons[BATTLE_OPPOSITE(battler)].speed) + (gBattleStruct->runTries * 30); if (speedVar > (Random() & 0xFF)) effect++; } - else if (gBattleMons[bank].speed < gBattleMons[bank ^ BIT_SIDE].speed) + else if (gBattleMons[battler].speed < gBattleMons[BATTLE_OPPOSITE(battler)].speed) { - speedVar = (gBattleMons[bank].speed * 128) / (gBattleMons[bank ^ BIT_SIDE].speed) + (gBattleStruct->runTries * 30); + speedVar = (gBattleMons[battler].speed * 128) / (gBattleMons[BATTLE_OPPOSITE(battler)].speed) + (gBattleStruct->runTries * 30); if (speedVar > (Random() & 0xFF)) effect++; } @@ -5408,7 +5408,7 @@ bool8 TryRunFromBattle(u8 bank) static void HandleAction_Run(void) { - gBattleMoveAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; + gBattlerAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) { @@ -5418,12 +5418,12 @@ static void HandleAction_Run(void) { if (GetBattlerSide(gActiveBattler) == B_SIDE_PLAYER) { - if (gActionForBanks[gActiveBattler] == ACTION_RUN) + if (gChosenActionByBattler[gActiveBattler] == B_ACTION_RUN) gBattleOutcome |= B_OUTCOME_LOST; } else { - if (gActionForBanks[gActiveBattler] == ACTION_RUN) + if (gChosenActionByBattler[gActiveBattler] == B_ACTION_RUN) gBattleOutcome |= B_OUTCOME_WON; } } @@ -5433,23 +5433,23 @@ static void HandleAction_Run(void) } else { - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) { - if (!TryRunFromBattle(gBattleMoveAttacker)) // failed to run away + if (!TryRunFromBattle(gBattlerAttacker)) // failed to run away { - ClearFuryCutterDestinyBondGrudge(gBattleMoveAttacker); + ClearFuryCutterDestinyBondGrudge(gBattlerAttacker); gBattleCommunication[MULTISTRING_CHOOSER] = 3; gBattlescriptCurrInstr = BattleScript_PrintFailedToRunString; - gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; } } else { - if (gBattleMons[gBattleMoveAttacker].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) + if (gBattleMons[gBattlerAttacker].status2 & (STATUS2_WRAPPED | STATUS2_ESCAPE_PREVENTION)) { gBattleCommunication[MULTISTRING_CHOOSER] = 4; gBattlescriptCurrInstr = BattleScript_PrintFailedToRunString; - gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; } else { @@ -5462,31 +5462,31 @@ static void HandleAction_Run(void) static void HandleAction_WatchesCarefully(void) { - gBattleMoveAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; + gBattlerAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; gBattlescriptCurrInstr = gBattlescriptsForSafariActions[0]; - gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; } static void HandleAction_SafariZoneBallThrow(void) { - gBattleMoveAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; + gBattlerAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; gNumSafariBalls--; gLastUsedItem = ITEM_SAFARI_BALL; gBattlescriptCurrInstr = gBattlescriptsForBallThrow[ITEM_SAFARI_BALL]; - gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; } static void HandleAction_ThrowPokeblock(void) { - gBattleMoveAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; + gBattlerAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - gBattleCommunication[MULTISTRING_CHOOSER] = gBattleBufferB[gBattleMoveAttacker][1] - 1; - gLastUsedItem = gBattleBufferB[gBattleMoveAttacker][2]; + gBattleCommunication[MULTISTRING_CHOOSER] = gBattleBufferB[gBattlerAttacker][1] - 1; + gLastUsedItem = gBattleBufferB[gBattlerAttacker][2]; if (gBattleResults.field_1F < 0xFF) gBattleResults.field_1F++; @@ -5501,12 +5501,12 @@ static void HandleAction_ThrowPokeblock(void) } gBattlescriptCurrInstr = gBattlescriptsForSafariActions[2]; - gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; } static void HandleAction_GoNear(void) { - gBattleMoveAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; + gBattlerAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; @@ -5528,12 +5528,12 @@ static void HandleAction_GoNear(void) gBattleCommunication[MULTISTRING_CHOOSER] = 1; } gBattlescriptCurrInstr = gBattlescriptsForSafariActions[1]; - gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; + gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; } static void HandleAction_SafriZoneRun(void) { - gBattleMoveAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; + gBattlerAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; PlaySE(SE_NIGERU); gCurrentTurnActionNumber = gBattlersCount; gBattleOutcome = B_OUTCOME_RAN; @@ -5541,15 +5541,15 @@ static void HandleAction_SafriZoneRun(void) static void HandleAction_Action9(void) { - gBattleMoveAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; + gBattlerAttacker = gBattleTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattleMoveAttacker, gBattlerPartyIndexes[gBattleMoveAttacker]) + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattlerAttacker, gBattlerPartyIndexes[gBattlerAttacker]) gBattlescriptCurrInstr = gBattlescriptsForSafariActions[3]; - gCurrentActionFuncId = ACTION_RUN_BATTLESCRIPT; - gActionsByTurnOrder[1] = ACTION_FINISHED; + gCurrentActionFuncId = B_ACTION_EXEC_SCRIPT; + gActionsByTurnOrder[1] = B_ACTION_FINISHED; } static void HandleAction_Action11(void) @@ -5557,7 +5557,7 @@ static void HandleAction_Action11(void) if (!HandleFaintedMonActions()) { gBattleStruct->faintedActionsState = 0; - gCurrentActionFuncId = ACTION_FINISHED; + gCurrentActionFuncId = B_ACTION_FINISHED; } } @@ -5589,8 +5589,8 @@ static void HandleAction_ActionFinished(void) gMoveResultFlags = 0; gBattleScripting.animTurn = 0; gBattleScripting.animTargetsHit = 0; - gLastLandedMoves[gBattleMoveAttacker] = 0; - gLastHitByType[gBattleMoveAttacker] = 0; + gLastLandedMoves[gBattlerAttacker] = 0; + gLastHitByType[gBattlerAttacker] = 0; gBattleStruct->dynamicMoveType = 0; gDynamicBasePower = 0; gBattleScripting.atk49_state = 0; diff --git a/src/battle_message.c b/src/battle_message.c index 07e5b2d60..88d11163d 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -17,11 +17,11 @@ extern u16 gLastUsedItem; extern u8 gLastUsedAbility; extern u8 gActiveBattler; -extern u8 gBattleMoveAttacker; -extern u8 gBattleMoveTarget; -extern u8 gStringBank; +extern u8 gBattlerAttacker; +extern u8 gBattlerTarget; +extern u8 gStringBattler; extern u8 gEffectBank; -extern u8 gAbilitiesPerBank[MAX_BATTLERS_COUNT]; +extern u8 gBattlerAbilities[MAX_BATTLERS_COUNT]; extern u32 gBattleTypeFlags; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; @@ -1436,12 +1436,12 @@ void BufferStringBattle(u16 stringID) gBattleScripting.battler = gStringInfo->scrActive; *(&gBattleStruct->field_52) = gStringInfo->unk1605E; *(&gBattleStruct->hpScale) = gStringInfo->hpScale; - gStringBank = gStringInfo->StringBank; + gStringBattler = gStringInfo->StringBank; *(&gBattleStruct->stringMoveType) = gStringInfo->moveType; for (i = 0; i < MAX_BATTLERS_COUNT; i++) { - gAbilitiesPerBank[i] = gStringInfo->abilities[i]; + gBattlerAbilities[i] = gStringInfo->abilities[i]; } for (i = 0; i < TEXT_BUFF_ARRAY_COUNT; i++) { @@ -1884,23 +1884,23 @@ 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(gBattleMoveAttacker, - gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleMoveAttacker))]) + HANDLE_NICKNAME_STRING_CASE(gBattlerAttacker, + gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattlerAttacker))]) break; case B_TXT_ATK_PARTNER_NAME: // attacker partner name - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) - GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleMoveAttacker)) + 2]], MON_DATA_NICKNAME, text); + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) + GetMonData(&gPlayerParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattlerAttacker)) + 2]], MON_DATA_NICKNAME, text); else - GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattleMoveAttacker)) + 2]], MON_DATA_NICKNAME, text); + GetMonData(&gEnemyParty[gBattlerPartyIndexes[GetBattlerAtPosition(GET_BATTLER_SIDE(gBattlerAttacker)) + 2]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; break; case B_TXT_ATK_NAME_WITH_PREFIX: // attacker name with prefix - HANDLE_NICKNAME_STRING_CASE(gBattleMoveAttacker, gBattlerPartyIndexes[gBattleMoveAttacker]) + HANDLE_NICKNAME_STRING_CASE(gBattlerAttacker, gBattlerPartyIndexes[gBattlerAttacker]) break; case B_TXT_DEF_NAME_WITH_PREFIX: // target name with prefix - HANDLE_NICKNAME_STRING_CASE(gBattleMoveTarget, gBattlerPartyIndexes[gBattleMoveTarget]) + HANDLE_NICKNAME_STRING_CASE(gBattlerTarget, gBattlerPartyIndexes[gBattlerTarget]) break; case B_TXT_EFF_NAME_WITH_PREFIX: // effect bank name with prefix HANDLE_NICKNAME_STRING_CASE(gEffectBank, gBattlerPartyIndexes[gEffectBank]) @@ -1930,10 +1930,10 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) { if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - if ((gBattleScripting.multiplayerId != 0 && (gStringBank & BIT_SIDE)) - || (gBattleScripting.multiplayerId == 0 && !(gStringBank & BIT_SIDE))) + if ((gBattleScripting.multiplayerId != 0 && (gStringBattler & BIT_SIDE)) + || (gBattleScripting.multiplayerId == 0 && !(gStringBattler & BIT_SIDE))) { - StringCopy(text, gEnigmaBerries[gStringBank].name); + StringCopy(text, gEnigmaBerries[gStringBattler].name); StringAppend(text, gText_BerrySuffix); toCpy = text; } @@ -1944,9 +1944,9 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) } else { - if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBank) + if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBattler) { - StringCopy(text, gEnigmaBerries[gStringBank].name); + StringCopy(text, gEnigmaBerries[gStringBattler].name); StringAppend(text, gText_BerrySuffix); toCpy = text; } @@ -1970,16 +1970,16 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = gAbilityNames[gLastUsedAbility]; break; case B_TXT_ATK_ABILITY: // attacker ability - toCpy = gAbilityNames[gAbilitiesPerBank[gBattleMoveAttacker]]; + toCpy = gAbilityNames[gBattlerAbilities[gBattlerAttacker]]; break; case B_TXT_DEF_ABILITY: // target ability - toCpy = gAbilityNames[gAbilitiesPerBank[gBattleMoveTarget]]; + toCpy = gAbilityNames[gBattlerAbilities[gBattlerTarget]]; break; case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability - toCpy = gAbilityNames[gAbilitiesPerBank[gBattleScripting.battler]]; + toCpy = gAbilityNames[gBattlerAbilities[gBattleScripting.battler]]; break; case B_TXT_EFF_ABILITY: // effect bank ability - toCpy = gAbilityNames[gAbilitiesPerBank[gEffectBank]]; + toCpy = gAbilityNames[gBattlerAbilities[gEffectBank]]; break; case B_TXT_TRAINER1_CLASS: // trainer class name if (gBattleTypeFlags & BATTLE_TYPE_SECRET_BASE) @@ -2094,37 +2094,37 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = gText_Someones; break; case B_TXT_ATK_PREFIX2: - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix2; else toCpy = gText_FoePkmnPrefix3; break; case B_TXT_DEF_PREFIX2: - if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix2; else toCpy = gText_FoePkmnPrefix3; break; case B_TXT_ATK_PREFIX1: - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix; else toCpy = gText_FoePkmnPrefix2; break; case B_TXT_DEF_PREFIX1: - if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix; else toCpy = gText_FoePkmnPrefix2; break; case B_TXT_ATK_PREFIX3: - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix3; else toCpy = gText_FoePkmnPrefix4; break; case B_TXT_DEF_PREFIX3: - if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix3; else toCpy = gText_FoePkmnPrefix4; @@ -2313,9 +2313,9 @@ static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst) { if (hword == ITEM_ENIGMA_BERRY) { - if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBank) + if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 == gStringBattler) { - StringCopy(dst, gEnigmaBerries[gStringBank].name); + StringCopy(dst, gEnigmaBerries[gStringBattler].name); StringAppend(dst, gText_BerrySuffix); } else diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index c443c5449..a751cf5e7 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -54,16 +54,16 @@ extern u8 gBattleTurnOrder[MAX_BATTLERS_COUNT]; extern u8 gActionsByTurnOrder[MAX_BATTLERS_COUNT]; extern u16 gCurrentMove; extern u8 gLastUsedAbility; -extern u8 gStringBank; +extern u8 gStringBattler; extern u8 gEffectBank; extern u8 gAbsentBattlerFlags; extern u8 gMultiHitCounter; -extern u16 gChosenMovesByBanks[MAX_BATTLERS_COUNT]; +extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT]; extern u16 gPauseCounterBattle; extern u16 gPaydayMoney; extern u16 gRandomTurnNumber; -extern u8 gBattleMoveAttacker; -extern u8 gBattleMoveTarget; +extern u8 gBattlerAttacker; +extern u8 gBattlerTarget; extern const u8* gBattlescriptCurrInstr; extern u8 gCurrMovePos; extern u8 gCurrentActionFuncId; @@ -73,7 +73,7 @@ extern u16 gLastLandedMoves[4]; extern u16 gLastHitByType[4]; extern u16 gLastResultingMoves[4]; extern u8 gLastHitBy[4]; -extern u8 gStringBank; +extern u8 gStringBattler; extern u16 gDynamicBasePower; extern u16 gLastUsedItem; extern u16 gBattleMovePower; @@ -89,7 +89,7 @@ extern u8 gPlayerPartyCount; extern u16 gMoveToLearn; extern u16 gRandomMove; extern u8 gBankInMenu; -extern u8 gActionForBanks[MAX_BATTLERS_COUNT]; +extern u8 gChosenActionByBattler[MAX_BATTLERS_COUNT]; extern u8 gCurrentTurnActionNumber; extern u8 gBattleBufferB[MAX_BATTLERS_COUNT][0x200]; extern u16 gLockedMoves[MAX_BATTLERS_COUNT]; @@ -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[gBattleMoveTarget].protected) && (gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED)) +#define DEFENDER_IS_PROTECTED ((gProtectStructs[gBattlerTarget].protected) && (gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED)) -#define TARGET_TURN_DAMAGED (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical != 0 \ - || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special != 0) +#define TARGET_TURN_DAMAGED (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical != 0 \ + || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special != 0) // this file's functions static bool8 IsTwoTurnsMove(u16 move); @@ -1024,10 +1024,10 @@ static void atk00_attackcanceler(void) if (gBattleOutcome != 0) { - gCurrentActionFuncId = ACTION_FINISHED; + gCurrentActionFuncId = B_ACTION_FINISHED; return; } - if (gBattleMons[gBattleMoveAttacker].hp == 0 && !(gHitMarker & HITMARKER_NO_ATTACKSTRING)) + if (gBattleMons[gBattlerAttacker].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, gBattleMoveTarget, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_MOVES_BLOCK, gBattlerTarget, 0, 0, 0)) return; - if (!gBattleMons[gBattleMoveAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE && !(gHitMarker & 0x800200) - && !(gBattleMons[gBattleMoveAttacker].status2 & STATUS2_MULTIPLETURNS)) + if (!gBattleMons[gBattlerAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE && !(gHitMarker & 0x800200) + && !(gBattleMons[gBattlerAttacker].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[gBattleMoveAttacker].status2 & STATUS2_MULTIPLETURNS)) + if (!(gHitMarker & HITMARKER_OBEYS) && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) { i = IsMonDisobedient(); // why use the 'i' variable...? switch (i) @@ -1065,10 +1065,10 @@ static void atk00_attackcanceler(void) gHitMarker |= HITMARKER_OBEYS; - if (gProtectStructs[gBattleMoveTarget].bounceMove && gBattleMoves[gCurrentMove].flags & FLAG_MAGICCOAT_AFFECTED) + if (gProtectStructs[gBattlerTarget].bounceMove && gBattleMoves[gCurrentMove].flags & FLAG_MAGICCOAT_AFFECTED) { - PressurePPLose(gBattleMoveAttacker, gBattleMoveTarget, MOVE_MAGIC_COAT); - gProtectStructs[gBattleMoveTarget].bounceMove = 0; + PressurePPLose(gBattlerAttacker, gBattlerTarget, MOVE_MAGIC_COAT); + gProtectStructs[gBattlerTarget].bounceMove = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MagicCoatBounce; return; @@ -1078,7 +1078,7 @@ static void atk00_attackcanceler(void) { if ((gProtectStructs[gBattleTurnOrder[i]].stealMove) && gBattleMoves[gCurrentMove].flags & FLAG_SNATCH_AFFECTED) { - PressurePPLose(gBattleMoveAttacker, gBattleTurnOrder[i], MOVE_SNATCH); + PressurePPLose(gBattlerAttacker, gBattleTurnOrder[i], MOVE_SNATCH); gProtectStructs[gBattleTurnOrder[i]].stealMove = 0; gBattleScripting.battler = gBattleTurnOrder[i]; BattleScriptPushCursor(); @@ -1087,22 +1087,22 @@ static void atk00_attackcanceler(void) } } - if (gSpecialStatuses[gBattleMoveTarget].lightningRodRedirected) + if (gSpecialStatuses[gBattlerTarget].lightningRodRedirected) { - gSpecialStatuses[gBattleMoveTarget].lightningRodRedirected = 0; + gSpecialStatuses[gBattlerTarget].lightningRodRedirected = 0; gLastUsedAbility = ABILITY_LIGHTNING_ROD; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_TookAttack; - RecordAbilityBattle(gBattleMoveTarget, gLastUsedAbility); + RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } else if (DEFENDER_IS_PROTECTED - && (gCurrentMove != MOVE_CURSE || (gBattleMons[gBattleMoveAttacker].type1 == TYPE_GHOST || gBattleMons[gBattleMoveAttacker].type2 == TYPE_GHOST)) - && ((!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_MULTIPLETURNS)))) + && (gCurrentMove != MOVE_CURSE || (gBattleMons[gBattlerAttacker].type1 == TYPE_GHOST || gBattleMons[gBattlerAttacker].type2 == TYPE_GHOST)) + && ((!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)))) { - CancelMultiTurnMoves(gBattleMoveAttacker); + CancelMultiTurnMoves(gBattlerAttacker); gMoveResultFlags |= MOVE_RESULT_MISSED; - gLastLandedMoves[gBattleMoveTarget] = 0; - gLastHitByType[gBattleMoveTarget] = 0; + gLastLandedMoves[gBattlerTarget] = 0; + gLastHitByType[gBattlerTarget] = 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[gBattleMoveTarget] = 0; - gLastHitByType[gBattleMoveTarget] = 0; + gLastLandedMoves[gBattlerTarget] = 0; + gLastHitByType[gBattlerTarget] = 0; BS_ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { TrySetDestinyBondToHappen(); - if (AbilityBattleEffects(ABILITYEFFECT_ABSORBING, gBattleMoveTarget, 0, 0, move)) + if (AbilityBattleEffects(ABILITYEFFECT_ABSORBING, gBattlerTarget, 0, 0, move)) return; } gBattlescriptCurrInstr = BS_ptr; @@ -1159,13 +1159,13 @@ bool8 JumpIfMoveAffectedByProtect(u16 move) static bool8 AccuracyCalcHelper(u16 move) { - if (gStatuses3[gBattleMoveTarget] & STATUS3_ALWAYS_HITS && gDisableStructs[gBattleMoveTarget].bankWithSureHit == gBattleMoveAttacker) + if (gStatuses3[gBattlerTarget] & STATUS3_ALWAYS_HITS && gDisableStructs[gBattlerTarget].battlerWithSureHit == gBattlerAttacker) { JumpIfMoveFailed(7, move); return TRUE; } - if (!(gHitMarker & HITMARKER_IGNORE_ON_AIR) && gStatuses3[gBattleMoveTarget] & STATUS3_ON_AIR) + if (!(gHitMarker & HITMARKER_IGNORE_ON_AIR) && gStatuses3[gBattlerTarget] & 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[gBattleMoveTarget] & STATUS3_UNDERGROUND) + if (!(gHitMarker & HITMARKER_IGNORE_UNDERGROUND) && gStatuses3[gBattlerTarget] & 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[gBattleMoveTarget] & STATUS3_UNDERWATER) + if (!(gHitMarker & HITMARKER_IGNORE_UNDERWATER) && gStatuses3[gBattlerTarget] & 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[gBattleMoveTarget] & STATUS3_ALWAYS_HITS && move == 0xFFFF && gDisableStructs[gBattleMoveTarget].bankWithSureHit == gBattleMoveAttacker) + if (gStatuses3[gBattlerTarget] & STATUS3_ALWAYS_HITS && move == 0xFFFF && gDisableStructs[gBattlerTarget].battlerWithSureHit == gBattlerAttacker) gBattlescriptCurrInstr += 7; - else if (gStatuses3[gBattleMoveTarget] & (STATUS3_ON_AIR | STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) + else if (gStatuses3[gBattlerTarget] & (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[gBattleMoveTarget].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBattlerTarget].status2 & STATUS2_FORESIGHT) { - u8 acc = gBattleMons[gBattleMoveAttacker].statStages[STAT_STAGE_ACC]; + u8 acc = gBattleMons[gBattlerAttacker].statStages[STAT_STAGE_ACC]; buff = acc; } else { - u8 acc = gBattleMons[gBattleMoveAttacker].statStages[STAT_STAGE_ACC]; - buff = acc + 6 - gBattleMons[gBattleMoveTarget].statStages[STAT_STAGE_EVASION]; + u8 acc = gBattleMons[gBattlerAttacker].statStages[STAT_STAGE_ACC]; + buff = acc + 6 - gBattleMons[gBattlerTarget].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[gBattleMoveAttacker].ability == ABILITY_COMPOUND_EYES) + if (gBattleMons[gBattlerAttacker].ability == ABILITY_COMPOUND_EYES) calc = (calc * 130) / 100; // 1.3 compound eyes boost - if (WEATHER_HAS_EFFECT && gBattleMons[gBattleMoveTarget].ability == ABILITY_SAND_VEIL && gBattleWeather & WEATHER_SANDSTORM_ANY) + if (WEATHER_HAS_EFFECT && gBattleMons[gBattlerTarget].ability == ABILITY_SAND_VEIL && gBattleWeather & WEATHER_SANDSTORM_ANY) calc = (calc * 80) / 100; // 1.2 sand veil loss - if (gBattleMons[gBattleMoveAttacker].ability == ABILITY_HUSTLE && type < 9) + if (gBattleMons[gBattlerAttacker].ability == ABILITY_HUSTLE && type < 9) calc = (calc * 80) / 100; // 1.2 hustle loss - if (gBattleMons[gBattleMoveTarget].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBattleMoveTarget].holdEffect; - quality = gEnigmaBerries[gBattleMoveTarget].holdEffectParam; + holdEffect = gEnigmaBerries[gBattlerTarget].holdEffect; + quality = gEnigmaBerries[gBattlerTarget].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattleMoveTarget].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBattleMoveTarget].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattlerTarget].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item); } - gStringBank = gBattleMoveTarget; + gStringBattler = gBattlerTarget; 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, gBattleMoveAttacker); + PrepareStringBattle(STRINGID_USEDMOVE, gBattlerAttacker); gHitMarker |= HITMARKER_ATTACKSTRING_PRINTED; } gBattlescriptCurrInstr++; @@ -1314,39 +1314,39 @@ static void atk03_ppreduce(void) if (gBattleControllerExecFlags) return; - if (!gSpecialStatuses[gBattleMoveAttacker].flag20) + if (!gSpecialStatuses[gBattlerAttacker].flag20) { switch (gBattleMoves[gCurrentMove].target) { case MOVE_TARGET_FOES_AND_ALLY: - ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_ON_FIELD, gBattleMoveAttacker, ABILITY_PRESSURE, 0, 0); + ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_ON_FIELD, gBattlerAttacker, ABILITY_PRESSURE, 0, 0); break; case MOVE_TARGET_BOTH: case MOVE_TARGET_OPPONENTS_FIELD: - ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBattleMoveAttacker, ABILITY_PRESSURE, 0, 0); + ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBattlerAttacker, ABILITY_PRESSURE, 0, 0); break; default: - if (gBattleMoveAttacker != gBattleMoveTarget && gBattleMons[gBattleMoveTarget].ability == ABILITY_PRESSURE) + if (gBattlerAttacker != gBattlerTarget && gBattleMons[gBattlerTarget].ability == ABILITY_PRESSURE) ppToDeduct++; break; } } - if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattleMoveAttacker].pp[gCurrMovePos]) + if (!(gHitMarker & (HITMARKER_NO_PPDEDUCT | HITMARKER_NO_ATTACKSTRING)) && gBattleMons[gBattlerAttacker].pp[gCurrMovePos]) { - gProtectStructs[gBattleMoveAttacker].notFirstStrike = 1; + gProtectStructs[gBattlerAttacker].notFirstStrike = 1; - if (gBattleMons[gBattleMoveAttacker].pp[gCurrMovePos] > ppToDeduct) - gBattleMons[gBattleMoveAttacker].pp[gCurrMovePos] -= ppToDeduct; + if (gBattleMons[gBattlerAttacker].pp[gCurrMovePos] > ppToDeduct) + gBattleMons[gBattlerAttacker].pp[gCurrMovePos] -= ppToDeduct; else - gBattleMons[gBattleMoveAttacker].pp[gCurrMovePos] = 0; + gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = 0; - if (!(gBattleMons[gBattleMoveAttacker].status2 & STATUS2_TRANSFORMED) - && !((gDisableStructs[gBattleMoveAttacker].unk18_b) & gBitTable[gCurrMovePos])) + if (!(gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED) + && !((gDisableStructs[gBattlerAttacker].unk18_b) & gBitTable[gCurrMovePos])) { - gActiveBattler = gBattleMoveAttacker; - BtlController_EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + gCurrMovePos, 0, 1, &gBattleMons[gBattleMoveAttacker].pp[gCurrMovePos]); - MarkBattlerForControllerExec(gBattleMoveAttacker); + gActiveBattler = gBattlerAttacker; + BtlController_EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + gCurrMovePos, 0, 1, &gBattleMons[gBattlerAttacker].pp[gCurrMovePos]); + MarkBattlerForControllerExec(gBattlerAttacker); } } @@ -1359,29 +1359,29 @@ static void atk04_critcalc(void) u8 holdEffect; u16 item, critChance; - item = gBattleMons[gBattleMoveAttacker].item; + item = gBattleMons[gBattlerAttacker].item; if (item == ITEM_ENIGMA_BERRY) - holdEffect = gEnigmaBerries[gBattleMoveAttacker].holdEffect; + holdEffect = gEnigmaBerries[gBattlerAttacker].holdEffect; else holdEffect = ItemId_GetHoldEffect(item); - gStringBank = gBattleMoveAttacker; + gStringBattler = gBattlerAttacker; - critChance = 2 * ((gBattleMons[gBattleMoveAttacker].status2 & STATUS2_FOCUS_ENERGY) != 0) + critChance = 2 * ((gBattleMons[gBattlerAttacker].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[gBattleMoveAttacker].species == SPECIES_CHANSEY) - + 2 * (holdEffect == HOLD_EFFECT_STICK && gBattleMons[gBattleMoveAttacker].species == SPECIES_FARFETCHD); + + 2 * (holdEffect == HOLD_EFFECT_LUCKY_PUNCH && gBattleMons[gBattlerAttacker].species == SPECIES_CHANSEY) + + 2 * (holdEffect == HOLD_EFFECT_STICK && gBattleMons[gBattlerAttacker].species == SPECIES_FARFETCHD); if (critChance > 4) critChance = 4; - if ((gBattleMons[gBattleMoveTarget].ability != ABILITY_BATTLE_ARMOR && gBattleMons[gBattleMoveTarget].ability != ABILITY_SHELL_ARMOR) - && !(gStatuses3[gBattleMoveAttacker] & STATUS3_CANT_SCORE_A_CRIT) + if ((gBattleMons[gBattlerTarget].ability != ABILITY_BATTLE_ARMOR && gBattleMons[gBattlerTarget].ability != ABILITY_SHELL_ARMOR) + && !(gStatuses3[gBattlerAttacker] & STATUS3_CANT_SCORE_A_CRIT) && !(gBattleTypeFlags & (BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_FIRST_BATTLE)) && !(Random() % sCriticalHitChance[critChance])) gCritMultiplier = 2; @@ -1393,15 +1393,15 @@ static void atk04_critcalc(void) static void atk05_damagecalc(void) { - u16 sideStatus = gSideStatuses[GET_BATTLER_SIDE(gBattleMoveTarget)]; - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattleMoveAttacker], &gBattleMons[gBattleMoveTarget], gCurrentMove, + u16 sideStatus = gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)]; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerTarget], gCurrentMove, sideStatus, gDynamicBasePower, - gBattleStruct->dynamicMoveType, gBattleMoveAttacker, gBattleMoveTarget); + gBattleStruct->dynamicMoveType, gBattlerAttacker, gBattlerTarget); gBattleMoveDamage = gBattleMoveDamage * gCritMultiplier * gBattleScripting.dmgMultiplier; - if (gStatuses3[gBattleMoveAttacker] & STATUS3_CHARGED_UP && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) + if (gStatuses3[gBattlerAttacker] & STATUS3_CHARGED_UP && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) gBattleMoveDamage *= 2; - if (gProtectStructs[gBattleMoveAttacker].helpingHand) + if (gProtectStructs[gBattlerAttacker].helpingHand) gBattleMoveDamage = gBattleMoveDamage * 15 / 10; gBattlescriptCurrInstr++; @@ -1470,20 +1470,20 @@ static void atk06_typecalc(void) GET_MOVE_TYPE(gCurrentMove, moveType); // check stab - if (gBattleMons[gBattleMoveAttacker].type1 == moveType || gBattleMons[gBattleMoveAttacker].type2 == moveType) + if (gBattleMons[gBattlerAttacker].type1 == moveType || gBattleMons[gBattlerAttacker].type2 == moveType) { gBattleMoveDamage = gBattleMoveDamage * 15; gBattleMoveDamage = gBattleMoveDamage / 10; } - if (gBattleMons[gBattleMoveTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) + if (gBattleMons[gBattlerTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { - gLastUsedAbility = gBattleMons[gBattleMoveTarget].ability; + gLastUsedAbility = gBattleMons[gBattlerTarget].ability; gMoveResultFlags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE); - gLastLandedMoves[gBattleMoveTarget] = 0; - gLastHitByType[gBattleMoveTarget] = 0; + gLastLandedMoves[gBattlerTarget] = 0; + gLastHitByType[gBattlerTarget] = 0; gBattleCommunication[6] = moveType; - RecordAbilityBattle(gBattleMoveTarget, gLastUsedAbility); + RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } else { @@ -1491,7 +1491,7 @@ static void atk06_typecalc(void) { if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) { - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBattlerTarget].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[gBattleMoveTarget].type1) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1) ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i)); // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleMoveTarget].type2 && - gBattleMons[gBattleMoveTarget].type1 != gBattleMons[gBattleMoveTarget].type2) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 && + gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2) ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i)); } i += 3; } } - if (gBattleMons[gBattleMoveTarget].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBattleMoveAttacker, gCurrentMove) == 2 + if (gBattleMons[gBattlerTarget].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBattlerAttacker, 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[gBattleMoveTarget] = 0; - gLastHitByType[gBattleMoveTarget] = 0; + gLastLandedMoves[gBattlerTarget] = 0; + gLastHitByType[gBattlerTarget] = 0; gBattleCommunication[6] = 3; - RecordAbilityBattle(gBattleMoveTarget, gLastUsedAbility); + RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) - gProtectStructs[gBattleMoveAttacker].targetNotAffected = 1; + gProtectStructs[gBattlerAttacker].targetNotAffected = 1; gBattlescriptCurrInstr++; } @@ -1538,11 +1538,11 @@ static void CheckWonderGuardAndLevitate(void) GET_MOVE_TYPE(gCurrentMove, moveType); - if (gBattleMons[gBattleMoveTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) + if (gBattleMons[gBattlerTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { gLastUsedAbility = ABILITY_LEVITATE; gBattleCommunication[6] = moveType; - RecordAbilityBattle(gBattleMoveTarget, ABILITY_LEVITATE); + RecordAbilityBattle(gBattlerTarget, ABILITY_LEVITATE); return; } @@ -1550,7 +1550,7 @@ static void CheckWonderGuardAndLevitate(void) { if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) { - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBattlerTarget].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[gBattleMoveTarget].type1 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; - gProtectStructs[gBattleMoveAttacker].targetNotAffected = 1; + gProtectStructs[gBattlerAttacker].targetNotAffected = 1; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleMoveTarget].type2 && - gBattleMons[gBattleMoveTarget].type1 != gBattleMons[gBattleMoveTarget].type2 && + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 && + gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; - gProtectStructs[gBattleMoveAttacker].targetNotAffected = 1; + gProtectStructs[gBattlerAttacker].targetNotAffected = 1; } // check super effective - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleMoveTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20) flags |= 1; - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleMoveTarget].type2 - && gBattleMons[gBattleMoveTarget].type1 != gBattleMons[gBattleMoveTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 + && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) flags |= 1; // check not very effective - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleMoveTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5) flags |= 2; - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleMoveTarget].type2 - && gBattleMons[gBattleMoveTarget].type1 != gBattleMons[gBattleMoveTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 + && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) flags |= 2; } i += 3; } - if (gBattleMons[gBattleMoveTarget].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBattleMoveAttacker, gCurrentMove) == 2) + if (gBattleMons[gBattlerTarget].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBattlerAttacker, gCurrentMove) == 2) { if (((flags & 2) || !(flags & 1)) && gBattleMoves[gCurrentMove].power) { gLastUsedAbility = ABILITY_WONDER_GUARD; gBattleCommunication[6] = 3; - RecordAbilityBattle(gBattleMoveTarget, ABILITY_WONDER_GUARD); + RecordAbilityBattle(gBattlerTarget, ABILITY_WONDER_GUARD); } } } @@ -1764,42 +1764,42 @@ static void atk07_adjustnormaldamage(void) ApplyRandomDmgMultiplier(); - if (gBattleMons[gBattleMoveTarget].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBattleMoveTarget].holdEffect, quality = gEnigmaBerries[gBattleMoveTarget].holdEffectParam; + holdEffect = gEnigmaBerries[gBattlerTarget].holdEffect, quality = gEnigmaBerries[gBattlerTarget].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattleMoveTarget].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBattleMoveTarget].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattlerTarget].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item); } - gStringBank = gBattleMoveTarget; + gStringBattler = gBattlerTarget; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < quality) { - RecordItemEffectBattle(gBattleMoveTarget, holdEffect); - gSpecialStatuses[gBattleMoveTarget].focusBanded = 1; + RecordItemEffectBattle(gBattlerTarget, holdEffect); + gSpecialStatuses[gBattlerTarget].focusBanded = 1; } - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE) goto END; - if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBattleMoveTarget].endured - && !gSpecialStatuses[gBattleMoveTarget].focusBanded) + if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBattlerTarget].endured + && !gSpecialStatuses[gBattlerTarget].focusBanded) goto END; - if (gBattleMons[gBattleMoveTarget].hp > gBattleMoveDamage) + if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage) goto END; - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].hp - 1; + gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1; - if (gProtectStructs[gBattleMoveTarget].endured) + if (gProtectStructs[gBattlerTarget].endured) { gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBattleMoveTarget].focusBanded) + else if (gSpecialStatuses[gBattlerTarget].focusBanded) { gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; - gLastUsedItem = gBattleMons[gBattleMoveTarget].item; + gLastUsedItem = gBattleMons[gBattlerTarget].item; } END: @@ -1812,40 +1812,40 @@ static void atk08_adjustnormaldamage2(void) // The same as 0x7 except it doesn't ApplyRandomDmgMultiplier(); - if (gBattleMons[gBattleMoveTarget].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBattleMoveTarget].holdEffect, quality = gEnigmaBerries[gBattleMoveTarget].holdEffectParam; + holdEffect = gEnigmaBerries[gBattlerTarget].holdEffect, quality = gEnigmaBerries[gBattlerTarget].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattleMoveTarget].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBattleMoveTarget].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattlerTarget].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item); } - gStringBank = gBattleMoveTarget; + gStringBattler = gBattlerTarget; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < quality) { - RecordItemEffectBattle(gBattleMoveTarget, holdEffect); - gSpecialStatuses[gBattleMoveTarget].focusBanded = 1; + RecordItemEffectBattle(gBattlerTarget, holdEffect); + gSpecialStatuses[gBattlerTarget].focusBanded = 1; } - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE) goto END; - if (!gProtectStructs[gBattleMoveTarget].endured && !gSpecialStatuses[gBattleMoveTarget].focusBanded) + if (!gProtectStructs[gBattlerTarget].endured && !gSpecialStatuses[gBattlerTarget].focusBanded) goto END; - if (gBattleMons[gBattleMoveTarget].hp > gBattleMoveDamage) + if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage) goto END; - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].hp - 1; + gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1; - if (gProtectStructs[gBattleMoveTarget].endured) + if (gProtectStructs[gBattlerTarget].endured) { gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBattleMoveTarget].focusBanded) + else if (gSpecialStatuses[gBattlerTarget].focusBanded) { gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; - gLastUsedItem = gBattleMons[gBattleMoveTarget].item; + gLastUsedItem = gBattleMons[gBattlerTarget].item; } END: @@ -1878,13 +1878,13 @@ static void atk09_attackanimation(void) { u8 multihit; - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE) multihit = gMultiHitCounter; else if (gMultiHitCounter != 0 && gMultiHitCounter != 1) { - if (gBattleMons[gBattleMoveTarget].hp <= gBattleMoveDamage) + if (gBattleMons[gBattlerTarget].hp <= gBattleMoveDamage) multihit = 1; else multihit = gMultiHitCounter; @@ -1892,10 +1892,10 @@ static void atk09_attackanimation(void) else multihit = gMultiHitCounter; - BtlController_EmitMoveAnimation(0, gCurrentMove, gBattleScripting.animTurn, gBattleMovePower, gBattleMoveDamage, gBattleMons[gBattleMoveAttacker].friendship, &gDisableStructs[gBattleMoveAttacker], multihit); + BtlController_EmitMoveAnimation(0, gCurrentMove, gBattleScripting.animTurn, gBattleMovePower, gBattleMoveDamage, gBattleMons[gBattlerAttacker].friendship, &gDisableStructs[gBattlerAttacker], multihit); gBattleScripting.animTurn += 1; gBattleScripting.animTargetsHit += 1; - MarkBattlerForControllerExec(gBattleMoveAttacker); + MarkBattlerForControllerExec(gBattlerAttacker); gBattlescriptCurrInstr++; } else @@ -2010,9 +2010,9 @@ static void atk0C_datahpupdate(void) { gTakenDmg[gActiveBattler] += gBattleMoveDamage; if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) - gTakenDmgBanks[gActiveBattler] = gBattleMoveAttacker; + gTakenDmgBanks[gActiveBattler] = gBattlerAttacker; else - gTakenDmgBanks[gActiveBattler] = gBattleMoveTarget; + gTakenDmgBanks[gActiveBattler] = gBattlerTarget; } if (gBattleMons[gActiveBattler].hp > gBattleMoveDamage) @@ -2035,13 +2035,13 @@ static void atk0C_datahpupdate(void) gSpecialStatuses[gActiveBattler].moveturnLostHP_physical = gHpDealt; if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) { - gProtectStructs[gActiveBattler].physicalBank = gBattleMoveAttacker; - gSpecialStatuses[gActiveBattler].moveturnPhysicalBank = gBattleMoveAttacker; + gProtectStructs[gActiveBattler].physicalBank = gBattlerAttacker; + gSpecialStatuses[gActiveBattler].moveturnPhysicalBank = gBattlerAttacker; } else { - gProtectStructs[gActiveBattler].physicalBank = gBattleMoveTarget; - gSpecialStatuses[gActiveBattler].moveturnPhysicalBank = gBattleMoveTarget; + gProtectStructs[gActiveBattler].physicalBank = gBattlerTarget; + gSpecialStatuses[gActiveBattler].moveturnPhysicalBank = gBattlerTarget; } } else if (moveType > 8 && !(gHitMarker & HITMARKER_x100000)) @@ -2050,13 +2050,13 @@ static void atk0C_datahpupdate(void) gSpecialStatuses[gActiveBattler].moveturnLostHP_special = gHpDealt; if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) { - gProtectStructs[gActiveBattler].specialBank = gBattleMoveAttacker; - gSpecialStatuses[gActiveBattler].moveturnSpecialBank = gBattleMoveAttacker; + gProtectStructs[gActiveBattler].specialBank = gBattlerAttacker; + gSpecialStatuses[gActiveBattler].moveturnSpecialBank = gBattlerAttacker; } else { - gProtectStructs[gActiveBattler].specialBank = gBattleMoveTarget; - gSpecialStatuses[gActiveBattler].moveturnSpecialBank = gBattleMoveTarget; + gProtectStructs[gActiveBattler].specialBank = gBattlerTarget; + gSpecialStatuses[gActiveBattler].moveturnSpecialBank = gBattlerTarget; } } } @@ -2080,7 +2080,7 @@ static void atk0D_critmessage(void) { if (gCritMultiplier == 2 && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { - PrepareStringBattle(STRINGID_CRITICALHIT, gBattleMoveAttacker); + PrepareStringBattle(STRINGID_CRITICALHIT, gBattlerAttacker); gBattleCommunication[MSG_DISPLAY] = 1; } gBattlescriptCurrInstr++; @@ -2092,7 +2092,7 @@ static void atk0E_effectivenesssound(void) if (gBattleControllerExecFlags) return; - gActiveBattler = gBattleMoveTarget; + gActiveBattler = gBattlerTarget; if (!(gMoveResultFlags & MOVE_RESULT_MISSED)) { switch (gMoveResultFlags & (u8)(~(MOVE_RESULT_MISSED))) @@ -2170,8 +2170,8 @@ static void atk0F_resultmessage(void) stringId = STRINGID_ITDOESNTAFFECT; break; case MOVE_RESULT_FOE_HUNG_ON: - gLastUsedItem = gBattleMons[gBattleMoveTarget].item; - gStringBank = gBattleMoveTarget; + gLastUsedItem = gBattleMons[gBattlerTarget].item; + gStringBattler = gBattlerTarget; 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[gBattleMoveTarget].item; - gStringBank = gBattleMoveTarget; + gLastUsedItem = gBattleMons[gBattlerTarget].item; + gStringBattler = gBattlerTarget; 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, gBattleMoveAttacker); + PrepareStringBattle(stringId, gBattlerAttacker); gBattlescriptCurrInstr++; } @@ -2228,7 +2228,7 @@ static void atk10_printstring(void) if (gBattleControllerExecFlags == 0) { u16 var = BS2ScriptRead16(gBattlescriptCurrInstr + 1); - PrepareStringBattle(var, gBattleMoveAttacker); + PrepareStringBattle(var, gBattlerAttacker); gBattlescriptCurrInstr += 3; gBattleCommunication[MSG_DISPLAY] = 1; } @@ -2236,7 +2236,7 @@ static void atk10_printstring(void) static void atk11_printselectionstring(void) { - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitPrintSelectionString(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1)); MarkBattlerForControllerExec(gActiveBattler); @@ -2273,7 +2273,7 @@ static void atk13_printfromtable(void) const u16 *ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); ptr += gBattleCommunication[MULTISTRING_CHOOSER]; - PrepareStringBattle(*ptr, gBattleMoveAttacker); + PrepareStringBattle(*ptr, gBattlerAttacker); gBattlescriptCurrInstr += 5; gBattleCommunication[MSG_DISPLAY] = 1; @@ -2287,7 +2287,7 @@ static void atk14_printselectionstringfromtable(void) const u16 *ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); ptr += gBattleCommunication[MULTISTRING_CHOOSER]; - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitPrintSelectionString(0, *ptr); MarkBattlerForControllerExec(gActiveBattler); @@ -2328,15 +2328,15 @@ void SetMoveEffect(bool8 primary, u8 certain) if (gBattleCommunication[MOVE_EFFECT_BYTE] & MOVE_EFFECT_AFFECTS_USER) { - gEffectBank = gBattleMoveAttacker; // bank that effects get applied on + gEffectBank = gBattlerAttacker; // bank that effects get applied on gBattleCommunication[MOVE_EFFECT_BYTE] &= ~(MOVE_EFFECT_AFFECTS_USER); affectsUser = MOVE_EFFECT_AFFECTS_USER; - gBattleScripting.battler = gBattleMoveTarget; // theoretically the attacker + gBattleScripting.battler = gBattlerTarget; // theoretically the attacker } else { - gEffectBank = gBattleMoveTarget; - gBattleScripting.battler = gBattleMoveAttacker; + gEffectBank = gBattlerTarget; + gBattleScripting.battler = gBattlerAttacker; } if (gBattleMons[gEffectBank].ability == ABILITY_SHIELD_DUST && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) @@ -2681,10 +2681,10 @@ void SetMoveEffect(bool8 primary, u8 certain) } break; case MOVE_EFFECT_PAYDAY: - if (GET_BATTLER_SIDE(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GET_BATTLER_SIDE(gBattlerAttacker) == B_SIDE_PLAYER) { u16 PayDay = gPaydayMoney; - gPaydayMoney += (gBattleMons[gBattleMoveAttacker].level * 5); + gPaydayMoney += (gBattleMons[gBattlerAttacker].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) = gBattleMoveAttacker; + *(gBattleStruct->wrappedBy + gEffectBank) = gBattlerAttacker; 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[gBattleMoveAttacker].status2 |= STATUS2_RAGE; + gBattleMons[gBattlerAttacker].status2 |= STATUS2_RAGE; gBattlescriptCurrInstr++; break; case MOVE_EFFECT_STEAL_ITEM: @@ -2843,8 +2843,8 @@ void SetMoveEffect(bool8 primary, u8 certain) break; } - side = GetBattlerSide(gBattleMoveAttacker); - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_OPPONENT + side = GetBattlerSide(gBattlerAttacker); + if (GetBattlerSide(gBattlerAttacker) == 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[gBattlerPartyIndexes[gBattleMoveAttacker]])) + && (gWishFutureKnock.knockedOffPokes[side] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]])) { gBattlescriptCurrInstr++; } - else if (gBattleMons[gBattleMoveTarget].item - && gBattleMons[gBattleMoveTarget].ability == ABILITY_STICKY_HOLD) + else if (gBattleMons[gBattlerTarget].item + && gBattleMons[gBattlerTarget].ability == ABILITY_STICKY_HOLD) { BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_NoItemSteal; - gLastUsedAbility = gBattleMons[gBattleMoveTarget].ability; - RecordAbilityBattle(gBattleMoveTarget, gLastUsedAbility); + gLastUsedAbility = gBattleMons[gBattlerTarget].ability; + RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } - else if (gBattleMons[gBattleMoveAttacker].item != 0 - || gBattleMons[gBattleMoveTarget].item == ITEM_ENIGMA_BERRY - || IS_ITEM_MAIL(gBattleMons[gBattleMoveTarget].item) - || gBattleMons[gBattleMoveTarget].item == 0) + else if (gBattleMons[gBattlerAttacker].item != 0 + || gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY + || IS_ITEM_MAIL(gBattleMons[gBattlerTarget].item) + || gBattleMons[gBattlerTarget].item == 0) { gBattlescriptCurrInstr++; } else { - u16* changedItem = &gBattleStruct->changedItems[gBattleMoveAttacker]; - gLastUsedItem = *changedItem = gBattleMons[gBattleMoveTarget].item; - gBattleMons[gBattleMoveTarget].item = 0; + u16* changedItem = &gBattleStruct->changedItems[gBattlerAttacker]; + gLastUsedItem = *changedItem = gBattleMons[gBattlerTarget].item; + gBattleMons[gBattlerTarget].item = 0; - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem); - MarkBattlerForControllerExec(gBattleMoveAttacker); + MarkBattlerForControllerExec(gBattlerAttacker); - gActiveBattler = gBattleMoveTarget; - BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBattleMoveTarget].item); - MarkBattlerForControllerExec(gBattleMoveTarget); + gActiveBattler = gBattlerTarget; + BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBattlerTarget].item); + MarkBattlerForControllerExec(gBattlerTarget); BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_ItemSteal; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleMoveTarget]) + 0) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleMoveTarget]) + 1) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerTarget]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerTarget]) + 1) = 0; } } break; case MOVE_EFFECT_PREVENT_ESCAPE: - gBattleMons[gBattleMoveTarget].status2 |= STATUS2_ESCAPE_PREVENTION; - gDisableStructs[gBattleMoveTarget].bankPreventingEscape = gBattleMoveAttacker; + gBattleMons[gBattlerTarget].status2 |= STATUS2_ESCAPE_PREVENTION; + gDisableStructs[gBattlerTarget].battlerPreventingEscape = gBattlerAttacker; gBattlescriptCurrInstr++; break; case MOVE_EFFECT_NIGHTMARE: - gBattleMons[gBattleMoveTarget].status2 |= STATUS2_NIGHTMARE; + gBattleMons[gBattlerTarget].status2 |= STATUS2_NIGHTMARE; gBattlescriptCurrInstr++; break; case MOVE_EFFECT_ALL_STATS_UP: @@ -2921,15 +2921,15 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattlescriptCurrInstr = BattleScript_RapidSpinAway; break; case MOVE_EFFECT_REMOVE_PARALYSIS: // Smelling salts - if (!(gBattleMons[gBattleMoveTarget].status1 & STATUS1_PARALYSIS)) + if (!(gBattleMons[gBattlerTarget].status1 & STATUS1_PARALYSIS)) { gBattlescriptCurrInstr++; } else { - gBattleMons[gBattleMoveTarget].status1 &= ~(STATUS1_PARALYSIS); + gBattleMons[gBattlerTarget].status1 &= ~(STATUS1_PARALYSIS); - gActiveBattler = gBattleMoveTarget; + gActiveBattler = gBattlerTarget; BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); @@ -3010,7 +3010,7 @@ static void atk15_seteffectwithchance(void) { u32 percentChance; - if (gBattleMons[gBattleMoveAttacker].ability == ABILITY_SERENE_GRACE) + if (gBattleMons[gBattlerAttacker].ability == ABILITY_SERENE_GRACE) percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance * 2; else percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance; @@ -3089,14 +3089,14 @@ static void atk19_tryfaintmon(void) if (gBattlescriptCurrInstr[1] == BS_GET_ATTACKER) { - gActiveBattler = gBattleMoveAttacker; - bank = gBattleMoveTarget; + gActiveBattler = gBattlerAttacker; + bank = gBattlerTarget; BS_ptr = BattleScript_FaintAttacker; } else { - gActiveBattler = gBattleMoveTarget; - bank = gBattleMoveAttacker; + gActiveBattler = gBattlerTarget; + bank = gBattlerAttacker; BS_ptr = BattleScript_FaintTarget; } if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler]) @@ -3118,29 +3118,29 @@ static void atk19_tryfaintmon(void) gBattleResults.opponentFaintCounter++; gBattleResults.lastOpponentSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gActiveBattler]], MON_DATA_SPECIES, NULL); } - if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBattleMoveAttacker].hp != 0) + if ((gHitMarker & HITMARKER_DESTINYBOND) && gBattleMons[gBattlerAttacker].hp != 0) { gHitMarker &= ~(HITMARKER_DESTINYBOND); BattleScriptPush(gBattlescriptCurrInstr); gBattleMoveDamage = gBattleMons[bank].hp; gBattlescriptCurrInstr = BattleScript_DestinyBondTakesLife; } - if ((gStatuses3[gBattleMoveTarget] & STATUS3_GRUDGE) + if ((gStatuses3[gBattlerTarget] & STATUS3_GRUDGE) && !(gHitMarker & HITMARKER_GRUDGE) - && GetBattlerSide(gBattleMoveAttacker) != GetBattlerSide(gBattleMoveTarget) - && gBattleMons[gBattleMoveAttacker].hp != 0 + && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget) + && gBattleMons[gBattlerAttacker].hp != 0 && gCurrentMove != MOVE_STRUGGLE) { - u8 moveIndex = *(gBattleStruct->chosenMovePositions + gBattleMoveAttacker); + u8 moveIndex = *(gBattleStruct->chosenMovePositions + gBattlerAttacker); - gBattleMons[gBattleMoveAttacker].pp[moveIndex] = 0; + gBattleMons[gBattlerAttacker].pp[moveIndex] = 0; BattleScriptPush(gBattlescriptCurrInstr); gBattlescriptCurrInstr = BattleScript_GrudgeTakesPp; - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitSetMonData(0, moveIndex + REQUEST_PPMOVE1_BATTLE, 0, 1, &gBattleMons[gActiveBattler].pp[moveIndex]); MarkBattlerForControllerExec(gActiveBattler); - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBattleMoveAttacker].moves[moveIndex]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].moves[moveIndex]) } } else @@ -3211,26 +3211,26 @@ static void atk1E_jumpifability(void) if (gBattlescriptCurrInstr[1] == BS_GET_ATTACKER_SIDE) { - bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_BANK_SIDE, gBattleMoveAttacker, ability, 0, 0); + bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_BANK_SIDE, gBattlerAttacker, ability, 0, 0); if (bank) { gLastUsedAbility = ability; gBattlescriptCurrInstr = jumpPtr; RecordAbilityBattle(bank - 1, gLastUsedAbility); - gBattleScripting.bankWithAbility = bank - 1; + gBattleScripting.battlerWithAbility = bank - 1; } else gBattlescriptCurrInstr += 7; } else if (gBattlescriptCurrInstr[1] == BS_GET_NOT_ATTACKER_SIDE) { - bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gBattleMoveAttacker, ability, 0, 0); + bank = AbilityBattleEffects(ABILITYEFFECT_CHECK_OTHER_SIDE, gBattlerAttacker, ability, 0, 0); if (bank) { gLastUsedAbility = ability; gBattlescriptCurrInstr = jumpPtr; RecordAbilityBattle(bank - 1, gLastUsedAbility); - gBattleScripting.bankWithAbility = bank - 1; + gBattleScripting.battlerWithAbility = bank - 1; } else gBattlescriptCurrInstr += 7; @@ -3243,7 +3243,7 @@ static void atk1E_jumpifability(void) gLastUsedAbility = ability; gBattlescriptCurrInstr = jumpPtr; RecordAbilityBattle(bank, gLastUsedAbility); - gBattleScripting.bankWithAbility = bank; + gBattleScripting.battlerWithAbility = bank; } else gBattlescriptCurrInstr += 7; @@ -3257,9 +3257,9 @@ static void atk1F_jumpifsideaffecting(void) const u8* jumpPtr; if (gBattlescriptCurrInstr[1] == BS_GET_ATTACKER) - side = GET_BATTLER_SIDE(gBattleMoveAttacker); + side = GET_BATTLER_SIDE(gBattlerAttacker); else - side = GET_BATTLER_SIDE(gBattleMoveTarget); + side = GET_BATTLER_SIDE(gBattlerTarget); flags = BS2ScriptRead16(gBattlescriptCurrInstr + 2); jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 4); @@ -3529,12 +3529,12 @@ static void atk23_getexp(void) gBattleBufferB[gBattleStruct->expGetterBank][0] = 0; if (GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_HP) && GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_LEVEL) != MAX_MON_LEVEL) { - BATTLE_LVLUP_STATS->hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_MAX_HP); - BATTLE_LVLUP_STATS->atk = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_ATK); - BATTLE_LVLUP_STATS->def = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_DEF); - BATTLE_LVLUP_STATS->spd = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPEED); - BATTLE_LVLUP_STATS->spAtk = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPATK); - BATTLE_LVLUP_STATS->spDef = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPDEF); + gBattleResources->statsBeforeLvlUp->hp = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_MAX_HP); + gBattleResources->statsBeforeLvlUp->atk = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_ATK); + gBattleResources->statsBeforeLvlUp->def = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_DEF); + gBattleResources->statsBeforeLvlUp->spd = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPEED); + gBattleResources->statsBeforeLvlUp->spAtk = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPATK); + gBattleResources->statsBeforeLvlUp->spDef = GetMonData(&gPlayerParty[gBattleStruct->expGetterId], MON_DATA_SPDEF); gActiveBattler = gBattleStruct->expGetterBank; BtlController_EmitExpUpdate(0, gBattleStruct->expGetterId, gBattleMoveDamage); @@ -3646,7 +3646,7 @@ static void atk24(void) for (i = 0; i < 6; i++) { if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) && !GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG) - && (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->field_2A0 & gBitTable[i]))) + && (!(gBattleTypeFlags & BATTLE_TYPE_ARENA) || !(gBattleStruct->field_2A0 & gBitTable[i]))) { HP_count += GetMonData(&gPlayerParty[i], MON_DATA_HP); } @@ -4323,9 +4323,9 @@ static void atk3A_waitstate(void) static void atk3B_healthbar_update(void) { if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) - gActiveBattler = gBattleMoveTarget; + gActiveBattler = gBattlerTarget; else - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitHealthBarUpdate(0, gBattleMoveDamage); MarkBattlerForControllerExec(gActiveBattler); @@ -4340,7 +4340,7 @@ static void atk3C_return(void) static void atk3D_end(void) { if (gBattleTypeFlags & BATTLE_TYPE_ARENA) - sub_81A5718(gBattleMoveAttacker); + sub_81A5718(gBattlerAttacker); gMoveResultFlags = 0; gActiveBattler = 0; @@ -4356,9 +4356,9 @@ static void atk3E_end2(void) static void atk3F_end3(void) // pops the main function stack { BattleScriptPop(); - if (BATTLE_CALLBACKS_STACK->size) - BATTLE_CALLBACKS_STACK->size--; - gBattleMainFunc = BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size]; + if (gBattleResources->battleCallbackStack->size != 0) + gBattleResources->battleCallbackStack->size--; + gBattleMainFunc = gBattleResources->battleCallbackStack->function[gBattleResources->battleCallbackStack->size]; } static void atk41_call(void) @@ -4387,7 +4387,7 @@ static void atk43_jumpifabilitypresent(void) static void atk44_endselectionscript(void) { - *(gBattleMoveAttacker + gBattleStruct->selectionScriptFinished) = TRUE; + *(gBattlerAttacker + gBattleStruct->selectionScriptFinished) = TRUE; } static void atk45_playanimation(void) @@ -4864,12 +4864,12 @@ static void atk49_moveend(void) arg1 = gBattlescriptCurrInstr[1]; arg2 = gBattlescriptCurrInstr[2]; - if (gBattleMons[gBattleMoveAttacker].item == ITEM_ENIGMA_BERRY) - holdEffectAtk = gEnigmaBerries[gBattleMoveAttacker].holdEffect; + if (gBattleMons[gBattlerAttacker].item == ITEM_ENIGMA_BERRY) + holdEffectAtk = gEnigmaBerries[gBattlerAttacker].holdEffect; else - holdEffectAtk = ItemId_GetHoldEffect(gBattleMons[gBattleMoveAttacker].item); + holdEffectAtk = ItemId_GetHoldEffect(gBattleMons[gBattlerAttacker].item); - choicedMoveAtk = &gBattleStruct->choicedMove[gBattleMoveAttacker]; + choicedMoveAtk = &gBattleStruct->choicedMove[gBattlerAttacker]; GET_MOVE_TYPE(gCurrentMove, moveType); @@ -4878,13 +4878,13 @@ static void atk49_moveend(void) switch (gBattleScripting.atk49_state) { case 0: // rage check - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_RAGE - && gBattleMons[gBattleMoveTarget].hp != 0 && gBattleMoveAttacker != gBattleMoveTarget - && GetBattlerSide(gBattleMoveAttacker) != GetBattlerSide(gBattleMoveTarget) + if (gBattleMons[gBattlerTarget].status2 & STATUS2_RAGE + && gBattleMons[gBattlerTarget].hp != 0 && gBattlerAttacker != gBattlerTarget + && GetBattlerSide(gBattlerAttacker) != GetBattlerSide(gBattlerTarget) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && TARGET_TURN_DAMAGED - && gBattleMoves[gCurrentMove].power && gBattleMons[gBattleMoveTarget].statStages[STAT_STAGE_ATK] <= 0xB) + && gBattleMoves[gCurrentMove].power && gBattleMons[gBattlerTarget].statStages[STAT_STAGE_ATK] <= 0xB) { - gBattleMons[gBattleMoveTarget].statStages[STAT_STAGE_ATK]++; + gBattleMons[gBattlerTarget].statStages[STAT_STAGE_ATK]++; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_RageIsBuilding; effect = TRUE; @@ -4892,14 +4892,14 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case 1: // defrosting check - if (gBattleMons[gBattleMoveTarget].status1 & STATUS1_FREEZE - && gBattleMons[gBattleMoveTarget].hp != 0 && gBattleMoveAttacker != gBattleMoveTarget - && gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special + if (gBattleMons[gBattlerTarget].status1 & STATUS1_FREEZE + && gBattleMons[gBattlerTarget].hp != 0 && gBattlerAttacker != gBattlerTarget + && gSpecialStatuses[gBattlerTarget].moveturnLostHP_special && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && moveType == TYPE_FIRE) { - gBattleMons[gBattleMoveTarget].status1 &= ~(STATUS1_FREEZE); - gActiveBattler = gBattleMoveTarget; - BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBattleMoveTarget].status1); + gBattleMons[gBattlerTarget].status1 &= ~(STATUS1_FREEZE); + gActiveBattler = gBattlerTarget; + BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBattlerTarget].status1); MarkBattlerForControllerExec(gActiveBattler); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_DefrostedViaFireMove; @@ -4908,12 +4908,12 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case 2: // target synchronize - if (AbilityBattleEffects(ABILITYEFFECT_SYNCHRONIZE, gBattleMoveTarget, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_SYNCHRONIZE, gBattlerTarget, 0, 0, 0)) effect = TRUE; gBattleScripting.atk49_state++; break; case 3: // contact abilities - if (AbilityBattleEffects(ABILITYEFFECT_CONTACT, gBattleMoveTarget, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_CONTACT, gBattlerTarget, 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, gBattleMoveAttacker, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_ATK_SYNCHRONIZE, gBattlerAttacker, 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[gBattleMoveAttacker].moves[i] == *choicedMoveAtk) + if (gBattleMons[gBattlerAttacker].moves[i] == *choicedMoveAtk) break; } if (i == 4) @@ -4975,10 +4975,10 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case 8: // make attacker sprite invisible - if (gStatuses3[gBattleMoveAttacker] & (STATUS3_SEMI_INVULNERABLE) + if (gStatuses3[gBattlerAttacker] & (STATUS3_SEMI_INVULNERABLE) && gHitMarker & HITMARKER_NO_ANIMATIONS) { - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitSpriteInvisibility(0, TRUE); MarkBattlerForControllerExec(gActiveBattler); gBattleScripting.atk49_state++; @@ -4988,27 +4988,27 @@ static void atk49_moveend(void) break; case 9: // make attacker sprite visible if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT - || !(gStatuses3[gBattleMoveAttacker] & (STATUS3_SEMI_INVULNERABLE)) - || WasUnableToUseMove(gBattleMoveAttacker)) + || !(gStatuses3[gBattlerAttacker] & (STATUS3_SEMI_INVULNERABLE)) + || WasUnableToUseMove(gBattlerAttacker)) { - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitSpriteInvisibility(0, FALSE); MarkBattlerForControllerExec(gActiveBattler); - gStatuses3[gBattleMoveAttacker] &= ~(STATUS3_SEMI_INVULNERABLE); - gSpecialStatuses[gBattleMoveAttacker].restoredBankSprite = 1; + gStatuses3[gBattlerAttacker] &= ~(STATUS3_SEMI_INVULNERABLE); + gSpecialStatuses[gBattlerAttacker].restoredBankSprite = 1; gBattleScripting.atk49_state++; return; } gBattleScripting.atk49_state++; break; case 10: // make target sprite visible - if (!gSpecialStatuses[gBattleMoveTarget].restoredBankSprite && gBattleMoveTarget < gBattlersCount - && !(gStatuses3[gBattleMoveTarget] & STATUS3_SEMI_INVULNERABLE)) + if (!gSpecialStatuses[gBattlerTarget].restoredBankSprite && gBattlerTarget < gBattlersCount + && !(gStatuses3[gBattlerTarget] & STATUS3_SEMI_INVULNERABLE)) { - gActiveBattler = gBattleMoveTarget; + gActiveBattler = gBattlerTarget; BtlController_EmitSpriteInvisibility(0, FALSE); MarkBattlerForControllerExec(gActiveBattler); - gStatuses3[gBattleMoveTarget] &= ~(STATUS3_SEMI_INVULNERABLE); + gStatuses3[gBattlerTarget] &= ~(STATUS3_SEMI_INVULNERABLE); gBattleScripting.atk49_state++; return; } @@ -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) { - gActiveBattler = gBattleMoveAttacker; - gBattleMoveAttacker = gBattleMoveTarget; - gBattleMoveTarget = gActiveBattler; + gActiveBattler = gBattlerAttacker; + gBattlerAttacker = gBattlerTarget; + gBattlerTarget = gActiveBattler; gHitMarker &= ~(HITMARKER_PURSUIT_TRAP); } if (gHitMarker & HITMARKER_ATTACKSTRING_PRINTED) { - gLastPrintedMoves[gBattleMoveAttacker] = gChosenMove; + gLastPrintedMoves[gBattlerAttacker] = gChosenMove; } - if (!(gAbsentBattlerFlags & gBitTable[gBattleMoveAttacker]) - && !(gBattleStruct->field_91 & gBitTable[gBattleMoveAttacker]) + if (!(gAbsentBattlerFlags & gBitTable[gBattlerAttacker]) + && !(gBattleStruct->field_91 & gBitTable[gBattlerAttacker]) && gBattleMoves[originallyUsedMove].effect != EFFECT_BATON_PASS) { if (gHitMarker & HITMARKER_OBEYS) { - gLastMoves[gBattleMoveAttacker] = gChosenMove; - gLastResultingMoves[gBattleMoveAttacker] = gCurrentMove; + gLastMoves[gBattlerAttacker] = gChosenMove; + gLastResultingMoves[gBattlerAttacker] = gCurrentMove; } else { - gLastMoves[gBattleMoveAttacker] = 0xFFFF; - gLastResultingMoves[gBattleMoveAttacker] = 0xFFFF; + gLastMoves[gBattlerAttacker] = 0xFFFF; + gLastResultingMoves[gBattlerAttacker] = 0xFFFF; } - if (!(gHitMarker & HITMARKER_FAINTED(gBattleMoveTarget))) - gLastHitBy[gBattleMoveTarget] = gBattleMoveAttacker; + if (!(gHitMarker & HITMARKER_FAINTED(gBattlerTarget))) + gLastHitBy[gBattlerTarget] = gBattlerAttacker; if (gHitMarker & HITMARKER_OBEYS && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { if (gChosenMove == 0xFFFF) { - gLastLandedMoves[gBattleMoveTarget] = gChosenMove; + gLastLandedMoves[gBattlerTarget] = gChosenMove; } else { - gLastLandedMoves[gBattleMoveTarget] = gCurrentMove; - GET_MOVE_TYPE(gCurrentMove, gLastHitByType[gBattleMoveTarget]); + gLastLandedMoves[gBattlerTarget] = gCurrentMove; + GET_MOVE_TYPE(gCurrentMove, gLastHitByType[gBattlerTarget]); } } else { - gLastLandedMoves[gBattleMoveTarget] = 0xFFFF; + gLastLandedMoves[gBattlerTarget] = 0xFFFF; } } gBattleScripting.atk49_state++; break; case 15: // mirror move - if (!(gAbsentBattlerFlags & gBitTable[gBattleMoveAttacker]) && !(gBattleStruct->field_91 & gBitTable[gBattleMoveAttacker]) + if (!(gAbsentBattlerFlags & gBitTable[gBattlerAttacker]) && !(gBattleStruct->field_91 & gBitTable[gBattlerAttacker]) && gBattleMoves[originallyUsedMove].flags & FLAG_MIRROR_MOVE_AFFECTED && gHitMarker & HITMARKER_OBEYS - && gBattleMoveAttacker != gBattleMoveTarget && !(gHitMarker & HITMARKER_FAINTED(gBattleMoveTarget)) + && gBattlerAttacker != gBattlerTarget && !(gHitMarker & HITMARKER_FAINTED(gBattlerTarget)) && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { u8 target, attacker; - *(gBattleStruct->mirrorMoves + gBattleMoveTarget * 2 + 0) = gChosenMove; - *(gBattleStruct->mirrorMoves + gBattleMoveTarget * 2 + 1) = gChosenMove >> 8; + *(gBattleStruct->mirrorMoves + gBattlerTarget * 2 + 0) = gChosenMove; + *(gBattleStruct->mirrorMoves + gBattlerTarget * 2 + 1) = gChosenMove >> 8; - target = gBattleMoveTarget; - attacker = gBattleMoveAttacker; + target = gBattlerTarget; + attacker = gBattlerAttacker; *(attacker * 2 + target * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = gChosenMove; - target = gBattleMoveTarget; - attacker = gBattleMoveAttacker; + target = gBattlerTarget; + attacker = gBattlerAttacker; *(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[gBattleMoveAttacker].chargingTurn && gBattleMoves[gCurrentMove].target == MOVE_TARGET_BOTH + && !gProtectStructs[gBattlerAttacker].chargingTurn && gBattleMoves[gCurrentMove].target == MOVE_TARGET_BOTH && !(gHitMarker & HITMARKER_NO_ATTACKSTRING)) { - u8 bank = GetBattlerAtPosition(B_POSITION_PARTNER(GetBattlerPosition(gBattleMoveTarget))); + u8 bank = GetBattlerAtPosition(BATTLE_PARTNER(GetBattlerPosition(gBattlerTarget))); if (gBattleMons[bank].hp != 0) { - gBattleMoveTarget = bank; + gBattlerTarget = 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[gBattleMoveTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) + if (gBattleMons[gBattlerTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { - gLastUsedAbility = gBattleMons[gBattleMoveTarget].ability; + gLastUsedAbility = gBattleMons[gBattlerTarget].ability; gMoveResultFlags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE); - gLastLandedMoves[gBattleMoveTarget] = 0; + gLastLandedMoves[gBattlerTarget] = 0; gBattleCommunication[6] = moveType; - RecordAbilityBattle(gBattleMoveTarget, gLastUsedAbility); + RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } else { @@ -5150,7 +5150,7 @@ static void atk4A_typecalc2(void) { if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) { - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBattlerTarget].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[gBattleMoveTarget].type1) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].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[gBattleMoveTarget].type2) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2) { - if (gBattleMons[gBattleMoveTarget].type1 != gBattleMons[gBattleMoveTarget].type2 + if (gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; break; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleMoveTarget].type2 - && gBattleMons[gBattleMoveTarget].type1 != gBattleMons[gBattleMoveTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 + && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) { flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattleMoveTarget].type2 - && gBattleMons[gBattleMoveTarget].type1 != gBattleMons[gBattleMoveTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBattlerTarget].type2 + && gBattleMons[gBattlerTarget].type1 != gBattleMons[gBattlerTarget].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) { flags |= MOVE_RESULT_SUPER_EFFECTIVE; @@ -5207,27 +5207,27 @@ static void atk4A_typecalc2(void) } } - if (gBattleMons[gBattleMoveTarget].ability == ABILITY_WONDER_GUARD + if (gBattleMons[gBattlerTarget].ability == ABILITY_WONDER_GUARD && !(flags & MOVE_RESULT_NO_EFFECT) - && AttacksThisTurn(gBattleMoveAttacker, gCurrentMove) == 2 + && AttacksThisTurn(gBattlerAttacker, 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[gBattleMoveTarget] = 0; + gLastLandedMoves[gBattlerTarget] = 0; gBattleCommunication[6] = 3; - RecordAbilityBattle(gBattleMoveTarget, gLastUsedAbility); + RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) - gProtectStructs[gBattleMoveAttacker].targetNotAffected = 1; + gProtectStructs[gBattlerAttacker].targetNotAffected = 1; gBattlescriptCurrInstr++; } static void atk4B_returnatktoball(void) { - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; if (!(gHitMarker & HITMARKER_FAINTED(gActiveBattler))) { BtlController_EmitReturnMonToBall(0, 0); @@ -5842,7 +5842,7 @@ static void atk51_switchhandleorder(void) sub_803BDA0(gActiveBattler); } - PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattleMoveAttacker].species) + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerAttacker].species) PREPARE_MON_NICK_BUFFER(gBattleTextBuff2, gActiveBattler, gBattleBufferB[gActiveBattler][1]) break; @@ -5904,7 +5904,7 @@ static void atk52_switchineffects(void) for (i = 0; i < gBattlersCount; i++) { if (gBattleTurnOrder[i] == gActiveBattler) - gActionsByTurnOrder[i] = ACTION_CANCEL_PARTNER; + gActionsByTurnOrder[i] = B_ACTION_CANCEL_PARTNER; } for (i = 0; i < gBattlersCount; i++) @@ -5943,7 +5943,7 @@ static void atk53_trainerslidein(void) static void atk54_playse(void) { - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitPlaySE(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1)); MarkBattlerForControllerExec(gActiveBattler); @@ -5952,7 +5952,7 @@ static void atk54_playse(void) static void atk55_fanfare(void) { - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitPlayFanfareOrBGM(0, BS2ScriptRead16(gBattlescriptCurrInstr + 1), FALSE); MarkBattlerForControllerExec(gActiveBattler); @@ -6311,9 +6311,9 @@ static void atk5E(void) static void atk5F(void) { - gActiveBattler = gBattleMoveAttacker; - gBattleMoveAttacker = gBattleMoveTarget; - gBattleMoveTarget = gActiveBattler; + gActiveBattler = gBattlerAttacker; + gBattlerAttacker = gBattlerTarget; + gBattlerTarget = gActiveBattler; if (gHitMarker & HITMARKER_PURSUIT_TRAP) gHitMarker &= ~(HITMARKER_PURSUIT_TRAP); @@ -6325,7 +6325,7 @@ static void atk5F(void) static void atk60_incrementgamestat(void) { - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) IncrementGameStat(gBattlescriptCurrInstr[1]); gBattlescriptCurrInstr += 2; @@ -6489,7 +6489,7 @@ static void atk68_cancelallactions(void) s32 i; for (i = 0; i < gBattlersCount; i++) - gActionsByTurnOrder[i] = ACTION_CANCEL_PARTNER; + gActionsByTurnOrder[i] = B_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[gBattleMoveTarget].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBattleMoveTarget].holdEffect, quality = gEnigmaBerries[gBattleMoveTarget].holdEffectParam; + holdEffect = gEnigmaBerries[gBattlerTarget].holdEffect, quality = gEnigmaBerries[gBattlerTarget].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattleMoveTarget].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBattleMoveTarget].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattlerTarget].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item); } - gStringBank = gBattleMoveTarget; + gStringBattler = gBattlerTarget; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < quality) { - RecordItemEffectBattle(gBattleMoveTarget, holdEffect); - gSpecialStatuses[gBattleMoveTarget].focusBanded = 1; + RecordItemEffectBattle(gBattlerTarget, holdEffect); + gSpecialStatuses[gBattlerTarget].focusBanded = 1; } - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE) goto END; - if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBattleMoveTarget].endured - && !gSpecialStatuses[gBattleMoveTarget].focusBanded) + if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBattlerTarget].endured + && !gSpecialStatuses[gBattlerTarget].focusBanded) goto END; - if (gBattleMons[gBattleMoveTarget].hp > gBattleMoveDamage) + if (gBattleMons[gBattlerTarget].hp > gBattleMoveDamage) goto END; - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].hp - 1; + gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1; - if (gProtectStructs[gBattleMoveTarget].endured) + if (gProtectStructs[gBattlerTarget].endured) { gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBattleMoveTarget].focusBanded) + else if (gSpecialStatuses[gBattlerTarget].focusBanded) { gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; - gLastUsedItem = gBattleMons[gBattleMoveTarget].item; + gLastUsedItem = gBattleMons[gBattlerTarget].item; } END: @@ -6558,7 +6558,7 @@ static void atk6A_removeitem(void) static void atk6B_atknameinbuff1(void) { - PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattleMoveAttacker, gBattlerPartyIndexes[gBattleMoveAttacker]) + PREPARE_MON_NICK_BUFFER(gBattleTextBuff1, gBattlerAttacker, gBattlerPartyIndexes[gBattlerAttacker]) gBattlescriptCurrInstr++; } @@ -6845,7 +6845,7 @@ static void atk6D_resetsentmonsvalue(void) static void atk6E_setatktoplayer0(void) { - gBattleMoveAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + gBattlerAttacker = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); gBattlescriptCurrInstr++; } @@ -6939,8 +6939,8 @@ static void atk74_hpthresholds2(void) static void atk75_useitemonopponent(void) { - gBankInMenu = gBattleMoveAttacker; - ExecuteTableBasedItemEffect(&gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker]], gLastUsedItem, gBattlerPartyIndexes[gBattleMoveAttacker], 0, 1); + gBankInMenu = gBattlerAttacker; + ExecuteTableBasedItemEffect(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]], gLastUsedItem, gBattlerPartyIndexes[gBattlerAttacker], 0, 1); gBattlescriptCurrInstr += 1; } @@ -6958,18 +6958,18 @@ static void atk76_various(void) CancelMultiTurnMoves(gActiveBattler); break; case VARIOUS_SET_MAGIC_COAT_TARGET: - gBattleMoveAttacker = gBattleMoveTarget; - side = GetBattlerSide(gBattleMoveAttacker) ^ BIT_SIDE; + gBattlerAttacker = gBattlerTarget; + side = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE; if (gSideTimers[side].followmeTimer != 0 && gBattleMons[gSideTimers[side].followmeTarget].hp != 0) - gBattleMoveTarget = gSideTimers[side].followmeTarget; + gBattlerTarget = gSideTimers[side].followmeTarget; else - gBattleMoveTarget = gActiveBattler; + gBattlerTarget = gActiveBattler; break; case VARIOUS_IS_RUNNING_IMPOSSIBLE: gBattleCommunication[0] = IsRunningFromBattleImpossible(); break; case VARIOUS_GET_MOVE_TARGET: - gBattleMoveTarget = GetMoveTarget(gCurrentMove, 0); + gBattlerTarget = GetMoveTarget(gCurrentMove, 0); break; case 4: if (gHitMarker & HITMARKER_FAINTED(gActiveBattler)) @@ -7127,31 +7127,31 @@ static void atk76_various(void) static void atk77_setprotectlike(void) // protect and endure { bool8 notLastTurn = TRUE; - u16 lastMove = gLastResultingMoves[gBattleMoveAttacker]; + u16 lastMove = gLastResultingMoves[gBattlerAttacker]; if (lastMove != MOVE_PROTECT && lastMove != MOVE_DETECT && lastMove != MOVE_ENDURE) - gDisableStructs[gBattleMoveAttacker].protectUses = 0; + gDisableStructs[gBattlerAttacker].protectUses = 0; if (gCurrentTurnActionNumber == (gBattlersCount - 1)) notLastTurn = FALSE; - if (sProtectSuccessRates[gDisableStructs[gBattleMoveAttacker].protectUses] >= Random() && notLastTurn) + if (sProtectSuccessRates[gDisableStructs[gBattlerAttacker].protectUses] >= Random() && notLastTurn) { if (gBattleMoves[gCurrentMove].effect == EFFECT_PROTECT) { - gProtectStructs[gBattleMoveAttacker].protected = 1; + gProtectStructs[gBattlerAttacker].protected = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } if (gBattleMoves[gCurrentMove].effect == EFFECT_ENDURE) { - gProtectStructs[gBattleMoveAttacker].endured = 1; + gProtectStructs[gBattlerAttacker].endured = 1; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } - gDisableStructs[gBattleMoveAttacker].protectUses++; + gDisableStructs[gBattlerAttacker].protectUses++; } else { - gDisableStructs[gBattleMoveAttacker].protectUses = 0; + gDisableStructs[gBattlerAttacker].protectUses = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 2; gMoveResultFlags |= MOVE_RESULT_MISSED; } @@ -7164,32 +7164,32 @@ static void atk78_faintifabilitynotdamp(void) if (gBattleControllerExecFlags) return; - for (gBattleMoveTarget = 0; gBattleMoveTarget < gBattlersCount; gBattleMoveTarget++) + for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) { - if (gBattleMons[gBattleMoveTarget].ability == ABILITY_DAMP) + if (gBattleMons[gBattlerTarget].ability == ABILITY_DAMP) break; } - if (gBattleMoveTarget == gBattlersCount) + if (gBattlerTarget == gBattlersCount) { - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; gBattleMoveDamage = gBattleMons[gActiveBattler].hp; BtlController_EmitHealthBarUpdate(0, INSTANT_HP_BAR_DROP); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr++; - for (gBattleMoveTarget = 0; gBattleMoveTarget < gBattlersCount; gBattleMoveTarget++) + for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) { - if (gBattleMoveTarget == gBattleMoveAttacker) + if (gBattlerTarget == gBattlerAttacker) continue; - if (!(gAbsentBattlerFlags & gBitTable[gBattleMoveTarget])) + if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget])) break; } } else { gLastUsedAbility = ABILITY_DAMP; - RecordAbilityBattle(gBattleMoveTarget, gBattleMons[gBattleMoveTarget].ability); + RecordAbilityBattle(gBattlerTarget, gBattleMons[gBattlerTarget].ability); gBattlescriptCurrInstr = BattleScript_DampStopsExplosion; } } @@ -7199,7 +7199,7 @@ static void atk79_setatkhptozero(void) if (gBattleControllerExecFlags) return; - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; gBattleMons[gActiveBattler].hp = 0; BtlController_EmitSetMonData(0, REQUEST_HP_BATTLE, 0, 2, &gBattleMons[gActiveBattler].hp); MarkBattlerForControllerExec(gActiveBattler); @@ -7213,15 +7213,15 @@ static void atk7A_jumpifnexttargetvalid(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - for (gBattleMoveTarget++; ; gBattleMoveTarget++) + for (gBattlerTarget++; ; gBattlerTarget++) { - if (gBattleMoveTarget == gBattleMoveAttacker) + if (gBattlerTarget == gBattlerAttacker) continue; - if (!(gAbsentBattlerFlags & gBitTable[gBattleMoveTarget])) + if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget])) break; } - if (gBattleMoveTarget >= gBattlersCount) + if (gBattlerTarget >= 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) - gBattleMoveTarget = gBattleMoveAttacker; + gBattlerTarget = gBattlerAttacker; - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].maxHP / 2; + gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - if (gBattleMons[gBattleMoveTarget].hp == gBattleMons[gBattleMoveTarget].maxHP) + if (gBattleMons[gBattlerTarget].hp == gBattleMons[gBattlerTarget].maxHP) gBattlescriptCurrInstr = failPtr; else gBattlescriptCurrInstr += 6; @@ -7262,10 +7262,10 @@ static void atk7C_trymirrormove(void) for (validMovesCount = 0, i = 0; i < gBattlersCount; i++) { - if (i != gBattleMoveAttacker) + if (i != gBattlerAttacker) { - move = *(i * 2 + gBattleMoveAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) - | (*(i * 2 + gBattleMoveAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) << 8); + move = *(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) + | (*(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) << 8); if (move != 0 && move != 0xFFFF) { @@ -7275,14 +7275,14 @@ static void atk7C_trymirrormove(void) } } - move = *(gBattleStruct->mirrorMoves + gBattleMoveAttacker * 2 + 0) - | (*(gBattleStruct->mirrorMoves + gBattleMoveAttacker * 2 + 1) << 8); + move = *(gBattleStruct->mirrorMoves + gBattlerAttacker * 2 + 0) + | (*(gBattleStruct->mirrorMoves + gBattlerAttacker * 2 + 1) << 8); if (move != 0 && move != 0xFFFF) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = move; - gBattleMoveTarget = GetMoveTarget(gCurrentMove, 0); + gBattlerTarget = 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]; - gBattleMoveTarget = GetMoveTarget(gCurrentMove, 0); + gBattlerTarget = GetMoveTarget(gCurrentMove, 0); gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; } else { - gSpecialStatuses[gBattleMoveAttacker].flag20 = 1; + gSpecialStatuses[gBattlerAttacker].flag20 = 1; gBattlescriptCurrInstr++; } } @@ -7318,16 +7318,16 @@ static void atk7D_setrain(void) static void atk7E_setreflect(void) { - if (gSideStatuses[GET_BATTLER_SIDE(gBattleMoveAttacker)] & SIDE_STATUS_REFLECT) + if (gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] & SIDE_STATUS_REFLECT) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } else { - gSideStatuses[GET_BATTLER_SIDE(gBattleMoveAttacker)] |= SIDE_STATUS_REFLECT; - gSideTimers[GET_BATTLER_SIDE(gBattleMoveAttacker)].reflectTimer = 5; - gSideTimers[GET_BATTLER_SIDE(gBattleMoveAttacker)].reflectBank = gBattleMoveAttacker; + gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] |= SIDE_STATUS_REFLECT; + gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].reflectTimer = 5; + gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].reflectBank = gBattlerAttacker; 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[gBattleMoveTarget] & STATUS3_LEECHSEED) + if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT || gStatuses3[gBattlerTarget] & STATUS3_LEECHSEED) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } - else if (gBattleMons[gBattleMoveTarget].type1 == TYPE_GRASS || gBattleMons[gBattleMoveTarget].type2 == TYPE_GRASS) + else if (gBattleMons[gBattlerTarget].type1 == TYPE_GRASS || gBattleMons[gBattlerTarget].type2 == TYPE_GRASS) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 2; } else { - gStatuses3[gBattleMoveTarget] |= gBattleMoveAttacker; - gStatuses3[gBattleMoveTarget] |= STATUS3_LEECHSEED; + gStatuses3[gBattlerTarget] |= gBattlerAttacker; + gStatuses3[gBattlerTarget] |= STATUS3_LEECHSEED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } @@ -7370,8 +7370,8 @@ static void atk80_manipulatedamage(void) gBattleMoveDamage /= 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - if ((gBattleMons[gBattleMoveTarget].maxHP / 2) < gBattleMoveDamage) - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].maxHP / 2; + if ((gBattleMons[gBattlerTarget].maxHP / 2) < gBattleMoveDamage) + gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 2; break; case ATK80_DMG_DOUBLED: gBattleMoveDamage *= 2; @@ -7384,21 +7384,21 @@ static void atk80_manipulatedamage(void) static void atk81_trysetrest(void) { const u8 *failJump = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - gActiveBattler = gBattleMoveTarget = gBattleMoveAttacker; - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].maxHP * (-1); + gActiveBattler = gBattlerTarget = gBattlerAttacker; + gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP * (-1); - if (gBattleMons[gBattleMoveTarget].hp == gBattleMons[gBattleMoveTarget].maxHP) + if (gBattleMons[gBattlerTarget].hp == gBattleMons[gBattlerTarget].maxHP) { gBattlescriptCurrInstr = failJump; } else { - if (gBattleMons[gBattleMoveTarget].status1 & ((u8)(~STATUS1_SLEEP))) + if (gBattleMons[gBattlerTarget].status1 & ((u8)(~STATUS1_SLEEP))) gBattleCommunication[MULTISTRING_CHOOSER] = 1; else gBattleCommunication[MULTISTRING_CHOOSER] = 0; - gBattleMons[gBattleMoveTarget].status1 = 3; + gBattleMons[gBattlerTarget].status1 = 3; BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr += 5; @@ -7409,7 +7409,7 @@ static void atk82_jumpifnotfirstturn(void) { const u8* failJump = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - if (gDisableStructs[gBattleMoveAttacker].isFirstTurn) + if (gDisableStructs[gBattlerAttacker].isFirstTurn) gBattlescriptCurrInstr += 5; else gBattlescriptCurrInstr = failJump; @@ -7431,9 +7431,9 @@ bool8 UproarWakeUpCheck(u8 bank) gBattleScripting.battler = i; - if (gBattleMoveTarget == 0xFF) - gBattleMoveTarget = i; - else if (gBattleMoveTarget == i) + if (gBattlerTarget == 0xFF) + gBattlerTarget = i; + else if (gBattlerTarget == i) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -7451,17 +7451,17 @@ static void atk84_jumpifcantmakeasleep(void) { const u8 *jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - if (UproarWakeUpCheck(gBattleMoveTarget)) + if (UproarWakeUpCheck(gBattlerTarget)) { gBattlescriptCurrInstr = jumpPtr; } - else if (gBattleMons[gBattleMoveTarget].ability == ABILITY_INSOMNIA - || gBattleMons[gBattleMoveTarget].ability == ABILITY_VITAL_SPIRIT) + else if (gBattleMons[gBattlerTarget].ability == ABILITY_INSOMNIA + || gBattleMons[gBattlerTarget].ability == ABILITY_VITAL_SPIRIT) { - gLastUsedAbility = gBattleMons[gBattleMoveTarget].ability; + gLastUsedAbility = gBattleMons[gBattlerTarget].ability; gBattleCommunication[MULTISTRING_CHOOSER] = 2; gBattlescriptCurrInstr = jumpPtr; - RecordAbilityBattle(gBattleMoveTarget, gLastUsedAbility); + RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } else { @@ -7471,16 +7471,16 @@ static void atk84_jumpifcantmakeasleep(void) static void atk85_stockpile(void) { - if (gDisableStructs[gBattleMoveAttacker].stockpileCounter == 3) + if (gDisableStructs[gBattlerAttacker].stockpileCounter == 3) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else { - gDisableStructs[gBattleMoveAttacker].stockpileCounter++; + gDisableStructs[gBattlerAttacker].stockpileCounter++; - PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gBattleMoveAttacker].stockpileCounter) + PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 1, gDisableStructs[gBattlerAttacker].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[gBattleMoveAttacker].stockpileCounter == 0) + if (gDisableStructs[gBattlerAttacker].stockpileCounter == 0) { gBattlescriptCurrInstr = jumpPtr; } @@ -7498,17 +7498,17 @@ static void atk86_stockpiletobasedamage(void) { if (gBattleCommunication[6] != 1) { - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattleMoveAttacker], &gBattleMons[gBattleMoveTarget], gCurrentMove, - gSideStatuses[GET_BATTLER_SIDE(gBattleMoveTarget)], 0, - 0, gBattleMoveAttacker, gBattleMoveTarget) - * gDisableStructs[gBattleMoveAttacker].stockpileCounter; - gBattleScripting.animTurn = gDisableStructs[gBattleMoveAttacker].stockpileCounter; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerTarget], gCurrentMove, + gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)], 0, + 0, gBattlerAttacker, gBattlerTarget) + * gDisableStructs[gBattlerAttacker].stockpileCounter; + gBattleScripting.animTurn = gDisableStructs[gBattlerAttacker].stockpileCounter; - if (gProtectStructs[gBattleMoveAttacker].helpingHand) + if (gProtectStructs[gBattlerAttacker].helpingHand) gBattleMoveDamage = gBattleMoveDamage * 15 / 10; } - gDisableStructs[gBattleMoveAttacker].stockpileCounter = 0; + gDisableStructs[gBattlerAttacker].stockpileCounter = 0; gBattlescriptCurrInstr += 5; } } @@ -7517,30 +7517,30 @@ static void atk87_stockpiletohpheal(void) { const u8* jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - if (gDisableStructs[gBattleMoveAttacker].stockpileCounter == 0) + if (gDisableStructs[gBattlerAttacker].stockpileCounter == 0) { gBattlescriptCurrInstr = jumpPtr; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } - else if (gBattleMons[gBattleMoveAttacker].maxHP == gBattleMons[gBattleMoveAttacker].hp) + else if (gBattleMons[gBattlerAttacker].maxHP == gBattleMons[gBattlerAttacker].hp) { - gDisableStructs[gBattleMoveAttacker].stockpileCounter = 0; + gDisableStructs[gBattlerAttacker].stockpileCounter = 0; gBattlescriptCurrInstr = jumpPtr; - gBattleMoveTarget = gBattleMoveAttacker; + gBattlerTarget = gBattlerAttacker; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else { - gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].maxHP / (1 << (3 - gDisableStructs[gBattleMoveAttacker].stockpileCounter)); + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / (1 << (3 - gDisableStructs[gBattlerAttacker].stockpileCounter)); if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - gBattleScripting.animTurn = gDisableStructs[gBattleMoveAttacker].stockpileCounter; - gDisableStructs[gBattleMoveAttacker].stockpileCounter = 0; + gBattleScripting.animTurn = gDisableStructs[gBattlerAttacker].stockpileCounter; + gDisableStructs[gBattlerAttacker].stockpileCounter = 0; gBattlescriptCurrInstr += 5; - gBattleMoveTarget = gBattleMoveAttacker; + gBattlerTarget = gBattlerAttacker; } } @@ -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) - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; else - gActiveBattler = gBattleMoveTarget; + gActiveBattler = gBattlerTarget; flags &= ~(MOVE_EFFECT_AFFECTS_USER); @@ -7678,7 +7678,7 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) if (gBattleMons[gActiveBattler].statStages[statId] == 0) gBattleCommunication[MULTISTRING_CHOOSER] = 2; else - gBattleCommunication[MULTISTRING_CHOOSER] = (gBattleMoveTarget == gActiveBattler); + gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); } } @@ -7705,7 +7705,7 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) if (gBattleMons[gActiveBattler].statStages[statId] == 0xC) gBattleCommunication[MULTISTRING_CHOOSER] = 2; else - gBattleCommunication[MULTISTRING_CHOOSER] = (gBattleMoveTarget == gActiveBattler); + gBattleCommunication[MULTISTRING_CHOOSER] = (gBattlerTarget == gActiveBattler); } gBattleMons[gActiveBattler].statStages[statId] += statValue; @@ -7745,17 +7745,17 @@ static void atk8A_normalisebuffs(void) // haze static void atk8B_setbide(void) { - gBattleMons[gBattleMoveAttacker].status2 |= STATUS2_MULTIPLETURNS; - gLockedMoves[gBattleMoveAttacker] = gCurrentMove; - gTakenDmg[gBattleMoveAttacker] = 0; - gBattleMons[gBattleMoveAttacker].status2 |= (STATUS2_BIDE - 0x100); // 2 turns + gBattleMons[gBattlerAttacker].status2 |= STATUS2_MULTIPLETURNS; + gLockedMoves[gBattlerAttacker] = gCurrentMove; + gTakenDmg[gBattlerAttacker] = 0; + gBattleMons[gBattlerAttacker].status2 |= (STATUS2_BIDE - 0x100); // 2 turns gBattlescriptCurrInstr++; } static void atk8C_confuseifrepeatingattackends(void) { - if (!(gBattleMons[gBattleMoveAttacker].status2 & STATUS2_LOCK_CONFUSE)) + if (!(gBattleMons[gBattlerAttacker].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[gBattleMoveAttacker].level >= gBattleMons[gBattleMoveTarget].level) + if (gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level) { - *(gBattleStruct->field_58 + gBattleMoveTarget) = gBattlerPartyIndexes[gBattleMoveTarget]; + *(gBattleStruct->field_58 + gBattlerTarget) = gBattlerPartyIndexes[gBattlerTarget]; } else { u16 random = Random() & 0xFF; - if ((u32)((random * (gBattleMons[gBattleMoveAttacker].level + gBattleMons[gBattleMoveTarget].level) >> 8) + 1) <= (gBattleMons[gBattleMoveTarget].level / 4)) + if ((u32)((random * (gBattleMons[gBattlerAttacker].level + gBattleMons[gBattlerTarget].level) >> 8) + 1) <= (gBattleMons[gBattlerTarget].level / 4)) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); return FALSE; } - *(gBattleStruct->field_58 + gBattleMoveTarget) = gBattlerPartyIndexes[gBattleMoveTarget]; + *(gBattleStruct->field_58 + gBattlerTarget) = gBattlerPartyIndexes[gBattlerTarget]; } gBattlescriptCurrInstr = BattleScript_SuccessForceOut; @@ -7827,7 +7827,7 @@ static void atk8F_forcerandomswitch(void) if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER)) { - if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerTarget) == 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 ((gBattleMoveTarget & BIT_FLANK) != 0) + if ((gBattlerTarget & BIT_FLANK) != 0) { firstMonId = 3; lastMonId = 6; @@ -7848,13 +7848,13 @@ static void atk8F_forcerandomswitch(void) } monsCount = 3; minNeeded = 1; - bank2PartyId = gBattlerPartyIndexes[gBattleMoveTarget]; - bank1PartyId = gBattlerPartyIndexes[gBattleMoveTarget ^ BIT_FLANK]; + bank2PartyId = gBattlerPartyIndexes[gBattlerTarget]; + bank1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK]; } else if ((gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) || (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_x2000000)) { - if (sub_806D82C(GetBattlerMultiplayerId(gBattleMoveTarget)) == 1) + if (sub_806D82C(GetBattlerMultiplayerId(gBattlerTarget)) == 1) { firstMonId = 3; lastMonId = 6; @@ -7866,12 +7866,12 @@ static void atk8F_forcerandomswitch(void) } monsCount = 3; minNeeded = 1; - bank2PartyId = gBattlerPartyIndexes[gBattleMoveTarget]; - bank1PartyId = gBattlerPartyIndexes[gBattleMoveTarget ^ BIT_FLANK]; + bank2PartyId = gBattlerPartyIndexes[gBattlerTarget]; + bank1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK]; } else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) { - if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER) { firstMonId = 0; lastMonId = 6; @@ -7880,7 +7880,7 @@ static void atk8F_forcerandomswitch(void) } else { - if ((gBattleMoveTarget & BIT_FLANK) != 0) + if ((gBattlerTarget & BIT_FLANK) != 0) { firstMonId = 3; lastMonId = 6; @@ -7893,8 +7893,8 @@ static void atk8F_forcerandomswitch(void) monsCount = 3; minNeeded = 1; } - bank2PartyId = gBattlerPartyIndexes[gBattleMoveTarget]; - bank1PartyId = gBattlerPartyIndexes[gBattleMoveTarget ^ BIT_FLANK]; + bank2PartyId = gBattlerPartyIndexes[gBattlerTarget]; + bank1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK]; } else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { @@ -7902,8 +7902,8 @@ static void atk8F_forcerandomswitch(void) lastMonId = 6; monsCount = 6; minNeeded = 2; - bank2PartyId = gBattlerPartyIndexes[gBattleMoveTarget]; - bank1PartyId = gBattlerPartyIndexes[gBattleMoveTarget ^ BIT_FLANK]; + bank2PartyId = gBattlerPartyIndexes[gBattlerTarget]; + bank1PartyId = gBattlerPartyIndexes[gBattlerTarget ^ BIT_FLANK]; } else { @@ -7911,8 +7911,8 @@ static void atk8F_forcerandomswitch(void) lastMonId = 6; monsCount = 6; minNeeded = 1; - bank2PartyId = gBattlerPartyIndexes[gBattleMoveTarget]; // there is only one pokemon out in single battles - bank1PartyId = gBattlerPartyIndexes[gBattleMoveTarget]; + bank2PartyId = gBattlerPartyIndexes[gBattlerTarget]; // there is only one pokemon out in single battles + bank1PartyId = gBattlerPartyIndexes[gBattlerTarget]; } 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 + gBattleMoveTarget) = i; + *(gBattleStruct->monToSwitchIntoId + gBattlerTarget) = i; if (!sub_81B1250()) - sub_803BDA0(gBattleMoveTarget); + sub_803BDA0(gBattlerTarget); 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(gBattleMoveTarget, i, 0); - sub_81B8E80(gBattleMoveTarget ^ BIT_FLANK, i, 1); + sub_81B8E80(gBattlerTarget, i, 0); + sub_81B8E80(gBattlerTarget ^ BIT_FLANK, i, 1); } if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) - sub_80571DC(gBattleMoveTarget, i); + sub_80571DC(gBattlerTarget, i); } } else @@ -7976,7 +7976,7 @@ static void atk90_tryconversiontypechange(void) // randomly changes user's type while (validMoves < 4) { - if (gBattleMons[gBattleMoveAttacker].moves[validMoves] == 0) + if (gBattleMons[gBattlerAttacker].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[gBattleMoveAttacker].moves[moveChecked]].type; + moveType = gBattleMoves[gBattleMons[gBattlerAttacker].moves[moveChecked]].type; if (moveType == TYPE_MYSTERY) { - if (gBattleMons[gBattleMoveAttacker].type1 == TYPE_GHOST || gBattleMons[gBattleMoveAttacker].type2 == TYPE_GHOST) + if (gBattleMons[gBattlerAttacker].type1 == TYPE_GHOST || gBattleMons[gBattlerAttacker].type2 == TYPE_GHOST) moveType = TYPE_GHOST; else moveType = TYPE_NORMAL; } - if (moveType != gBattleMons[gBattleMoveAttacker].type1 - && moveType != gBattleMons[gBattleMoveAttacker].type2) + if (moveType != gBattleMons[gBattlerAttacker].type1 + && moveType != gBattleMons[gBattlerAttacker].type2) { break; } @@ -8011,20 +8011,20 @@ static void atk90_tryconversiontypechange(void) // randomly changes user's type while ((moveChecked = Random() & 3) >= validMoves); - moveType = gBattleMoves[gBattleMons[gBattleMoveAttacker].moves[moveChecked]].type; + moveType = gBattleMoves[gBattleMons[gBattlerAttacker].moves[moveChecked]].type; if (moveType == TYPE_MYSTERY) { - if (gBattleMons[gBattleMoveAttacker].type1 == TYPE_GHOST || gBattleMons[gBattleMoveAttacker].type2 == TYPE_GHOST) + if (gBattleMons[gBattlerAttacker].type1 == TYPE_GHOST || gBattleMons[gBattlerAttacker].type2 == TYPE_GHOST) moveType = TYPE_GHOST; else moveType = TYPE_NORMAL; } } - while (moveType == gBattleMons[gBattleMoveAttacker].type1 || moveType == gBattleMons[gBattleMoveAttacker].type2); + while (moveType == gBattleMons[gBattlerAttacker].type1 || moveType == gBattleMons[gBattlerAttacker].type2); - gBattleMons[gBattleMoveAttacker].type1 = moveType; - gBattleMons[gBattleMoveAttacker].type2 = moveType; + gBattleMons[gBattlerAttacker].type1 = moveType; + gBattleMons[gBattlerAttacker].type2 = moveType; PREPARE_TYPE_BUFFER(gBattleTextBuff1, moveType) @@ -8052,16 +8052,16 @@ static void atk91_givepaydaymoney(void) static void atk92_setlightscreen(void) { - if (gSideStatuses[GET_BATTLER_SIDE(gBattleMoveAttacker)] & SIDE_STATUS_LIGHTSCREEN) + if (gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] & SIDE_STATUS_LIGHTSCREEN) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } else { - gSideStatuses[GET_BATTLER_SIDE(gBattleMoveAttacker)] |= SIDE_STATUS_LIGHTSCREEN; - gSideTimers[GET_BATTLER_SIDE(gBattleMoveAttacker)].lightscreenTimer = 5; - gSideTimers[GET_BATTLER_SIDE(gBattleMoveAttacker)].lightscreenBank = gBattleMoveAttacker; + gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] |= SIDE_STATUS_LIGHTSCREEN; + gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].lightscreenTimer = 5; + gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].lightscreenBank = gBattlerAttacker; 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[gBattleMoveTarget].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBattleMoveTarget].holdEffect; - param = gEnigmaBerries[gBattleMoveTarget].holdEffectParam; + holdEffect = gEnigmaBerries[gBattlerTarget].holdEffect; + param = gEnigmaBerries[gBattlerTarget].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattleMoveTarget].item); - param = ItemId_GetHoldEffectParam(gBattleMons[gBattleMoveTarget].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBattlerTarget].item); + param = ItemId_GetHoldEffectParam(gBattleMons[gBattlerTarget].item); } - gStringBank = gBattleMoveTarget; + gStringBattler = gBattlerTarget; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param) { - RecordItemEffectBattle(gBattleMoveTarget, HOLD_EFFECT_FOCUS_BAND); - gSpecialStatuses[gBattleMoveTarget].focusBanded = 1; + RecordItemEffectBattle(gBattlerTarget, HOLD_EFFECT_FOCUS_BAND); + gSpecialStatuses[gBattlerTarget].focusBanded = 1; } - if (gBattleMons[gBattleMoveTarget].ability == ABILITY_STURDY) + if (gBattleMons[gBattlerTarget].ability == ABILITY_STURDY) { gMoveResultFlags |= MOVE_RESULT_MISSED; gLastUsedAbility = ABILITY_STURDY; gBattlescriptCurrInstr = BattleScript_SturdyPreventsOHKO; - RecordAbilityBattle(gBattleMoveTarget, ABILITY_STURDY); + RecordAbilityBattle(gBattlerTarget, ABILITY_STURDY); } else { u16 chance; - if (!(gStatuses3[gBattleMoveTarget] & STATUS3_ALWAYS_HITS)) + if (!(gStatuses3[gBattlerTarget] & STATUS3_ALWAYS_HITS)) { - chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBattleMoveAttacker].level - gBattleMons[gBattleMoveTarget].level); - if (Random() % 100 + 1 < chance && gBattleMons[gBattleMoveAttacker].level >= gBattleMons[gBattleMoveTarget].level) + chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBattlerAttacker].level - gBattleMons[gBattlerTarget].level); + if (Random() % 100 + 1 < chance && gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level) chance = TRUE; else chance = FALSE; } - else if (gDisableStructs[gBattleMoveTarget].bankWithSureHit == gBattleMoveAttacker - && gBattleMons[gBattleMoveAttacker].level >= gBattleMons[gBattleMoveTarget].level) + else if (gDisableStructs[gBattlerTarget].battlerWithSureHit == gBattlerAttacker + && gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level) { chance = TRUE; } else { - chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBattleMoveAttacker].level - gBattleMons[gBattleMoveTarget].level); - if (Random() % 100 + 1 < chance && gBattleMons[gBattleMoveAttacker].level >= gBattleMons[gBattleMoveTarget].level) + chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBattlerAttacker].level - gBattleMons[gBattlerTarget].level); + if (Random() % 100 + 1 < chance && gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].level) chance = TRUE; else chance = FALSE; } if (chance) { - if (gProtectStructs[gBattleMoveTarget].endured) + if (gProtectStructs[gBattlerTarget].endured) { - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].hp - 1; + gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1; gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBattleMoveTarget].focusBanded) + else if (gSpecialStatuses[gBattlerTarget].focusBanded) { - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].hp - 1; + gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - 1; gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; - gLastUsedItem = gBattleMons[gBattleMoveTarget].item; + gLastUsedItem = gBattleMons[gBattlerTarget].item; } else { - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].hp; + gBattleMoveDamage = gBattleMons[gBattlerTarget].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[gBattleMoveAttacker].level >= gBattleMons[gBattleMoveTarget].level) + if (gBattleMons[gBattlerAttacker].level >= gBattleMons[gBattlerTarget].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[gBattleMoveTarget].hp / 2; + gBattleMoveDamage = gBattleMons[gBattlerTarget].hp / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -8189,17 +8189,17 @@ static void atk96_weatherdamage(void) { if (gBattleWeather & WEATHER_SANDSTORM_ANY) { - if (gBattleMons[gBattleMoveAttacker].type1 != TYPE_ROCK - && gBattleMons[gBattleMoveAttacker].type1 != TYPE_STEEL - && gBattleMons[gBattleMoveAttacker].type1 != TYPE_GROUND - && gBattleMons[gBattleMoveAttacker].type2 != TYPE_ROCK - && gBattleMons[gBattleMoveAttacker].type2 != TYPE_STEEL - && gBattleMons[gBattleMoveAttacker].type2 != TYPE_GROUND - && gBattleMons[gBattleMoveAttacker].ability != ABILITY_SAND_VEIL - && !(gStatuses3[gBattleMoveAttacker] & STATUS3_UNDERGROUND) - && !(gStatuses3[gBattleMoveAttacker] & STATUS3_UNDERWATER)) + if (gBattleMons[gBattlerAttacker].type1 != TYPE_ROCK + && gBattleMons[gBattlerAttacker].type1 != TYPE_STEEL + && gBattleMons[gBattlerAttacker].type1 != TYPE_GROUND + && gBattleMons[gBattlerAttacker].type2 != TYPE_ROCK + && gBattleMons[gBattlerAttacker].type2 != TYPE_STEEL + && gBattleMons[gBattlerAttacker].type2 != TYPE_GROUND + && gBattleMons[gBattlerAttacker].ability != ABILITY_SAND_VEIL + && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) + && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)) { - gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].maxHP / 16; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; } @@ -8210,12 +8210,12 @@ static void atk96_weatherdamage(void) } if (gBattleWeather & WEATHER_HAIL) { - if (gBattleMons[gBattleMoveAttacker].type1 != TYPE_ICE - && gBattleMons[gBattleMoveAttacker].type2 != TYPE_ICE - && !(gStatuses3[gBattleMoveAttacker] & STATUS3_UNDERGROUND) - && !(gStatuses3[gBattleMoveAttacker] & STATUS3_UNDERWATER)) + if (gBattleMons[gBattlerAttacker].type1 != TYPE_ICE + && gBattleMons[gBattlerAttacker].type2 != TYPE_ICE + && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERGROUND) + && !(gStatuses3[gBattlerAttacker] & STATUS3_UNDERWATER)) { - gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].maxHP / 16; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; } @@ -8230,7 +8230,7 @@ static void atk96_weatherdamage(void) gBattleMoveDamage = 0; } - if (gAbsentBattlerFlags & gBitTable[gBattleMoveAttacker]) + if (gAbsentBattlerFlags & gBitTable[gBattlerAttacker]) gBattleMoveDamage = 0; gBattlescriptCurrInstr++; @@ -8242,15 +8242,15 @@ static void atk97_tryinfatuating(void) u16 speciesAttacker, speciesTarget; u32 personalityAttacker, personalityTarget; - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) - monAttacker = &gPlayerParty[gBattlerPartyIndexes[gBattleMoveAttacker]]; + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) + monAttacker = &gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]; else - monAttacker = &gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker]]; + monAttacker = &gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]]; - if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER) - monTarget = &gPlayerParty[gBattlerPartyIndexes[gBattleMoveTarget]]; + if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER) + monTarget = &gPlayerParty[gBattlerPartyIndexes[gBattlerTarget]]; else - monTarget = &gEnemyParty[gBattlerPartyIndexes[gBattleMoveTarget]]; + monTarget = &gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]; 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[gBattleMoveTarget].ability == ABILITY_OBLIVIOUS) + if (gBattleMons[gBattlerTarget].ability == ABILITY_OBLIVIOUS) { gBattlescriptCurrInstr = BattleScript_ObliviousPreventsAttraction; gLastUsedAbility = ABILITY_OBLIVIOUS; - RecordAbilityBattle(gBattleMoveTarget, ABILITY_OBLIVIOUS); + RecordAbilityBattle(gBattlerTarget, ABILITY_OBLIVIOUS); } else { if (GetGenderFromSpeciesAndPersonality(speciesAttacker, personalityAttacker) == GetGenderFromSpeciesAndPersonality(speciesTarget, personalityTarget) - || gBattleMons[gBattleMoveTarget].status2 & STATUS2_INFATUATION + || gBattleMons[gBattlerTarget].status2 & STATUS2_INFATUATION || GetGenderFromSpeciesAndPersonality(speciesAttacker, personalityAttacker) == MON_GENDERLESS || GetGenderFromSpeciesAndPersonality(speciesTarget, personalityTarget) == MON_GENDERLESS) { @@ -8275,7 +8275,7 @@ static void atk97_tryinfatuating(void) } else { - gBattleMons[gBattleMoveTarget].status2 |= STATUS2_INFATUATED_WITH(gBattleMoveAttacker); + gBattleMons[gBattlerTarget].status2 |= STATUS2_INFATUATED_WITH(gBattlerAttacker); gBattlescriptCurrInstr += 5; } } @@ -8295,7 +8295,7 @@ static void atk98_updatestatusicon(void) } else { - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { BtlController_EmitStatusIconUpdate(0, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); @@ -8303,7 +8303,7 @@ static void atk98_updatestatusicon(void) } if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveAttacker) ^ BIT_FLANK); + gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_FLANK); if (!(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { BtlController_EmitStatusIconUpdate(0, gBattleMons[gActiveBattler].status1, gBattleMons[gActiveBattler].status2); @@ -8316,16 +8316,16 @@ static void atk98_updatestatusicon(void) static void atk99_setmist(void) { - if (gSideTimers[GET_BATTLER_SIDE(gBattleMoveAttacker)].mistTimer) + if (gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].mistTimer) { gMoveResultFlags |= MOVE_RESULT_FAILED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else { - gSideTimers[GET_BATTLER_SIDE(gBattleMoveAttacker)].mistTimer = 5; - gSideTimers[GET_BATTLER_SIDE(gBattleMoveAttacker)].mistBank = gBattleMoveAttacker; - gSideStatuses[GET_BATTLER_SIDE(gBattleMoveAttacker)] |= SIDE_STATUS_MIST; + gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].mistTimer = 5; + gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].mistBank = gBattlerAttacker; + gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] |= SIDE_STATUS_MIST; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } gBattlescriptCurrInstr++; @@ -8333,14 +8333,14 @@ static void atk99_setmist(void) static void atk9A_setfocusenergy(void) { - if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_FOCUS_ENERGY) + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_FOCUS_ENERGY) { gMoveResultFlags |= MOVE_RESULT_FAILED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else { - gBattleMons[gBattleMoveAttacker].status2 |= STATUS2_FOCUS_ENERGY; + gBattleMons[gBattlerAttacker].status2 |= STATUS2_FOCUS_ENERGY; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } gBattlescriptCurrInstr++; @@ -8350,8 +8350,8 @@ static void atk9B_transformdataexecution(void) { gChosenMove = 0xFFFF; gBattlescriptCurrInstr++; - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_TRANSFORMED - || gStatuses3[gBattleMoveTarget] & STATUS3_SEMI_INVULNERABLE) + if (gBattleMons[gBattlerTarget].status2 & STATUS2_TRANSFORMED + || gStatuses3[gBattlerTarget] & STATUS3_SEMI_INVULNERABLE) { gMoveResultFlags |= MOVE_RESULT_FAILED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -8361,29 +8361,29 @@ static void atk9B_transformdataexecution(void) s32 i; u8 *battleMonAttacker, *battleMonTarget; - gBattleMons[gBattleMoveAttacker].status2 |= STATUS2_TRANSFORMED; - gDisableStructs[gBattleMoveAttacker].disabledMove = 0; - gDisableStructs[gBattleMoveAttacker].disableTimer1 = 0; - gDisableStructs[gBattleMoveAttacker].transformedMonPersonality = gBattleMons[gBattleMoveTarget].personality; - gDisableStructs[gBattleMoveAttacker].unk18_b = 0; + gBattleMons[gBattlerAttacker].status2 |= STATUS2_TRANSFORMED; + gDisableStructs[gBattlerAttacker].disabledMove = 0; + gDisableStructs[gBattlerAttacker].disableTimer1 = 0; + gDisableStructs[gBattlerAttacker].transformedMonPersonality = gBattleMons[gBattlerTarget].personality; + gDisableStructs[gBattlerAttacker].unk18_b = 0; - PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattleMoveTarget].species) + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerTarget].species) - battleMonAttacker = (u8*)(&gBattleMons[gBattleMoveAttacker]); - battleMonTarget = (u8*)(&gBattleMons[gBattleMoveTarget]); + battleMonAttacker = (u8*)(&gBattleMons[gBattlerAttacker]); + battleMonTarget = (u8*)(&gBattleMons[gBattlerTarget]); for (i = 0; i < offsetof(struct BattlePokemon, pp); i++) battleMonAttacker[i] = battleMonTarget[i]; for (i = 0; i < 4; i++) { - if (gBattleMoves[gBattleMons[gBattleMoveAttacker].moves[i]].pp < 5) - gBattleMons[gBattleMoveAttacker].pp[i] = gBattleMoves[gBattleMons[gBattleMoveAttacker].moves[i]].pp; + if (gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].pp < 5) + gBattleMons[gBattlerAttacker].pp[i] = gBattleMoves[gBattleMons[gBattlerAttacker].moves[i]].pp; else - gBattleMons[gBattleMoveAttacker].pp[i] = 5; + gBattleMons[gBattlerAttacker].pp[i] = 5; } - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitResetActionMoveSelection(0, RESET_MOVE_SELECTION); MarkBattlerForControllerExec(gActiveBattler); gBattleCommunication[MULTISTRING_CHOOSER] = 0; @@ -8392,24 +8392,24 @@ static void atk9B_transformdataexecution(void) static void atk9C_setsubstitute(void) { - u32 hp = gBattleMons[gBattleMoveAttacker].maxHP / 4; - if (gBattleMons[gBattleMoveAttacker].maxHP / 4 == 0) + u32 hp = gBattleMons[gBattlerAttacker].maxHP / 4; + if (gBattleMons[gBattlerAttacker].maxHP / 4 == 0) hp = 1; - if (gBattleMons[gBattleMoveAttacker].hp <= hp) + if (gBattleMons[gBattlerAttacker].hp <= hp) { gBattleMoveDamage = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else { - gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].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[gBattlerAttacker].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[gBattleMoveAttacker].status2 |= STATUS2_SUBSTITUTE; - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_WRAPPED); - gDisableStructs[gBattleMoveAttacker].substituteHP = gBattleMoveDamage; + gBattleMons[gBattlerAttacker].status2 |= STATUS2_SUBSTITUTE; + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_WRAPPED); + gDisableStructs[gBattlerAttacker].substituteHP = gBattleMoveDamage; gBattleCommunication[MULTISTRING_CHOOSER] = 0; gHitMarker |= HITMARKER_IGNORE_SUBSTITUTE; } @@ -8430,10 +8430,10 @@ static void atk9D_mimicattackcopy(void) { gChosenMove = 0xFFFF; - if (IsMoveUncopyableByMimic(gLastMoves[gBattleMoveTarget]) - || gBattleMons[gBattleMoveAttacker].status2 & STATUS2_TRANSFORMED - || gLastMoves[gBattleMoveTarget] == 0 - || gLastMoves[gBattleMoveTarget] == 0xFFFF) + if (IsMoveUncopyableByMimic(gLastMoves[gBattlerTarget]) + || gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED + || gLastMoves[gBattlerTarget] == 0 + || gLastMoves[gBattlerTarget] == 0xFFFF) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -8443,22 +8443,22 @@ static void atk9D_mimicattackcopy(void) for (i = 0; i < 4; i++) { - if (gBattleMons[gBattleMoveAttacker].moves[i] == gLastMoves[gBattleMoveTarget]) + if (gBattleMons[gBattlerAttacker].moves[i] == gLastMoves[gBattlerTarget]) break; } if (i == 4) { - gBattleMons[gBattleMoveAttacker].moves[gCurrMovePos] = gLastMoves[gBattleMoveTarget]; - if (gBattleMoves[gLastMoves[gBattleMoveTarget]].pp < 5) - gBattleMons[gBattleMoveAttacker].pp[gCurrMovePos] = gBattleMoves[gLastMoves[gBattleMoveTarget]].pp; + gBattleMons[gBattlerAttacker].moves[gCurrMovePos] = gLastMoves[gBattlerTarget]; + if (gBattleMoves[gLastMoves[gBattlerTarget]].pp < 5) + gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = gBattleMoves[gLastMoves[gBattlerTarget]].pp; else - gBattleMons[gBattleMoveAttacker].pp[gCurrMovePos] = 5; + gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = 5; - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBattleMoveTarget]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBattlerTarget]) - gDisableStructs[gBattleMoveAttacker].unk18_b |= gBitTable[gCurrMovePos]; + gDisableStructs[gBattlerAttacker].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]; - gBattleMoveTarget = GetMoveTarget(gCurrentMove, 0); + gBattlerTarget = GetMoveTarget(gCurrentMove, 0); return; } } @@ -8502,7 +8502,7 @@ static void atk9E_metronome(void) static void atk9F_dmgtolevel(void) { - gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].level; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].level; gBattlescriptCurrInstr++; } @@ -8513,54 +8513,54 @@ static void atkA0_psywavedamageeffect(void) while ((randDamage = (Random() & 0xF)) > 10); randDamage *= 10; - gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].level * (randDamage + 50) / 100; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].level * (randDamage + 50) / 100; gBattlescriptCurrInstr++; } static void atkA1_counterdamagecalculator(void) { - u8 sideAttacker = GetBattlerSide(gBattleMoveAttacker); - u8 sideTarget = GetBattlerSide(gProtectStructs[gBattleMoveAttacker].physicalBank); + u8 sideAttacker = GetBattlerSide(gBattlerAttacker); + u8 sideTarget = GetBattlerSide(gProtectStructs[gBattlerAttacker].physicalBank); - if (gProtectStructs[gBattleMoveAttacker].physicalDmg + if (gProtectStructs[gBattlerAttacker].physicalDmg && sideAttacker != sideTarget - && gBattleMons[gProtectStructs[gBattleMoveAttacker].physicalBank].hp) + && gBattleMons[gProtectStructs[gBattlerAttacker].physicalBank].hp) { - gBattleMoveDamage = gProtectStructs[gBattleMoveAttacker].physicalDmg * 2; + gBattleMoveDamage = gProtectStructs[gBattlerAttacker].physicalDmg * 2; if (gSideTimers[sideTarget].followmeTimer && gBattleMons[gSideTimers[sideTarget].followmeTarget].hp) - gBattleMoveTarget = gSideTimers[sideTarget].followmeTarget; + gBattlerTarget = gSideTimers[sideTarget].followmeTarget; else - gBattleMoveTarget = gProtectStructs[gBattleMoveAttacker].physicalBank; + gBattlerTarget = gProtectStructs[gBattlerAttacker].physicalBank; gBattlescriptCurrInstr += 5; } else { - gSpecialStatuses[gBattleMoveAttacker].flag20 = 1; + gSpecialStatuses[gBattlerAttacker].flag20 = 1; gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } } static void atkA2_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the physical -> special field changes { - u8 sideAttacker = GetBattlerSide(gBattleMoveAttacker); - u8 sideTarget = GetBattlerSide(gProtectStructs[gBattleMoveAttacker].specialBank); + u8 sideAttacker = GetBattlerSide(gBattlerAttacker); + u8 sideTarget = GetBattlerSide(gProtectStructs[gBattlerAttacker].specialBank); - if (gProtectStructs[gBattleMoveAttacker].specialDmg && sideAttacker != sideTarget && gBattleMons[gProtectStructs[gBattleMoveAttacker].specialBank].hp) + if (gProtectStructs[gBattlerAttacker].specialDmg && sideAttacker != sideTarget && gBattleMons[gProtectStructs[gBattlerAttacker].specialBank].hp) { - gBattleMoveDamage = gProtectStructs[gBattleMoveAttacker].specialDmg * 2; + gBattleMoveDamage = gProtectStructs[gBattlerAttacker].specialDmg * 2; if (gSideTimers[sideTarget].followmeTimer && gBattleMons[gSideTimers[sideTarget].followmeTarget].hp) - gBattleMoveTarget = gSideTimers[sideTarget].followmeTarget; + gBattlerTarget = gSideTimers[sideTarget].followmeTarget; else - gBattleMoveTarget = gProtectStructs[gBattleMoveAttacker].specialBank; + gBattlerTarget = gProtectStructs[gBattlerAttacker].specialBank; gBattlescriptCurrInstr += 5; } else { - gSpecialStatuses[gBattleMoveAttacker].flag20 = 1; + gSpecialStatuses[gBattlerAttacker].flag20 = 1; gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } } @@ -8571,17 +8571,17 @@ static void atkA3_disablelastusedattack(void) for (i = 0; i < 4; i++) { - if (gBattleMons[gBattleMoveTarget].moves[i] == gLastMoves[gBattleMoveTarget]) + if (gBattleMons[gBattlerTarget].moves[i] == gLastMoves[gBattlerTarget]) break; } - if (gDisableStructs[gBattleMoveTarget].disabledMove == 0 - && i != 4 && gBattleMons[gBattleMoveTarget].pp[i] != 0) + if (gDisableStructs[gBattlerTarget].disabledMove == 0 + && i != 4 && gBattleMons[gBattlerTarget].pp[i] != 0) { - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBattleMoveTarget].moves[i]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBattlerTarget].moves[i]) - gDisableStructs[gBattleMoveTarget].disabledMove = gBattleMons[gBattleMoveTarget].moves[i]; - gDisableStructs[gBattleMoveTarget].disableTimer1 = (Random() & 3) + 2; - gDisableStructs[gBattleMoveTarget].disableTimer2 = gDisableStructs[gBattleMoveTarget].disableTimer1; // used to save the random amount of turns? + gDisableStructs[gBattlerTarget].disabledMove = gBattleMons[gBattlerTarget].moves[i]; + gDisableStructs[gBattlerTarget].disableTimer1 = (Random() & 3) + 2; + gDisableStructs[gBattlerTarget].disableTimer2 = gDisableStructs[gBattlerTarget].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[gBattleMoveTarget].moves[i] == gLastMoves[gBattleMoveTarget]) + if (gBattleMons[gBattlerTarget].moves[i] == gLastMoves[gBattlerTarget]) break; } - if (gLastMoves[gBattleMoveTarget] == MOVE_STRUGGLE - || gLastMoves[gBattleMoveTarget] == MOVE_ENCORE - || gLastMoves[gBattleMoveTarget] == MOVE_MIRROR_MOVE) + if (gLastMoves[gBattlerTarget] == MOVE_STRUGGLE + || gLastMoves[gBattlerTarget] == MOVE_ENCORE + || gLastMoves[gBattlerTarget] == MOVE_MIRROR_MOVE) { i = 4; } - if (gDisableStructs[gBattleMoveTarget].encoredMove == 0 - && i != 4 && gBattleMons[gBattleMoveTarget].pp[i] != 0) + if (gDisableStructs[gBattlerTarget].encoredMove == 0 + && i != 4 && gBattleMons[gBattlerTarget].pp[i] != 0) { - gDisableStructs[gBattleMoveTarget].encoredMove = gBattleMons[gBattleMoveTarget].moves[i]; - gDisableStructs[gBattleMoveTarget].encoredMovePos = i; - gDisableStructs[gBattleMoveTarget].encoreTimer1 = (Random() & 3) + 3; - gDisableStructs[gBattleMoveTarget].encoreTimer2 = gDisableStructs[gBattleMoveTarget].encoreTimer1; + gDisableStructs[gBattlerTarget].encoredMove = gBattleMons[gBattlerTarget].moves[i]; + gDisableStructs[gBattlerTarget].encoredMovePos = i; + gDisableStructs[gBattlerTarget].encoreTimer1 = (Random() & 3) + 3; + gDisableStructs[gBattlerTarget].encoreTimer2 = gDisableStructs[gBattlerTarget].encoreTimer1; gBattlescriptCurrInstr += 5; } else @@ -8624,10 +8624,10 @@ static void atkA4_trysetencore(void) static void atkA5_painsplitdmgcalc(void) { - if (!(gBattleMons[gBattleMoveTarget].status2 & STATUS2_SUBSTITUTE)) + if (!(gBattleMons[gBattlerTarget].status2 & STATUS2_SUBSTITUTE)) { - s32 hpDiff = (gBattleMons[gBattleMoveAttacker].hp + gBattleMons[gBattleMoveTarget].hp) / 2; - s32 painSplitHp = gBattleMoveDamage = gBattleMons[gBattleMoveTarget].hp - hpDiff; + s32 hpDiff = (gBattleMons[gBattlerAttacker].hp + gBattleMons[gBattlerTarget].hp) / 2; + s32 painSplitHp = gBattleMoveDamage = gBattleMons[gBattlerTarget].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[gBattleMoveAttacker].hp - hpDiff; - gSpecialStatuses[gBattleMoveTarget].moveturnLostHP = 0xFFFF; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].hp - hpDiff; + gSpecialStatuses[gBattlerTarget].moveturnLostHP = 0xFFFF; gBattlescriptCurrInstr += 5; } @@ -8648,13 +8648,13 @@ static void atkA5_painsplitdmgcalc(void) static void atkA6_settypetorandomresistance(void) // conversion 2 { - if (gLastLandedMoves[gBattleMoveAttacker] == 0 - || gLastLandedMoves[gBattleMoveAttacker] == 0xFFFF) + if (gLastLandedMoves[gBattlerAttacker] == 0 + || gLastLandedMoves[gBattlerAttacker] == 0xFFFF) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } - else if (IsTwoTurnsMove(gLastLandedMoves[gBattleMoveAttacker]) - && gBattleMons[gLastHitBy[gBattleMoveAttacker]].status2 & STATUS2_MULTIPLETURNS) + else if (IsTwoTurnsMove(gLastLandedMoves[gBattlerAttacker]) + && gBattleMons[gLastHitBy[gBattlerAttacker]].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[gBattleMoveAttacker] + if (TYPE_EFFECT_ATK_TYPE(i) == gLastHitByType[gBattlerAttacker] && TYPE_EFFECT_MULTIPLIER(i) <= TYPE_MUL_NOT_EFFECTIVE - && gBattleMons[gBattleMoveAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i) - && gBattleMons[gBattleMoveAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i)) + && gBattleMons[gBattlerAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i) + && gBattleMons[gBattlerAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i)) { - gBattleMons[gBattleMoveAttacker].type1 = TYPE_EFFECT_DEF_TYPE(i); - gBattleMons[gBattleMoveAttacker].type2 = TYPE_EFFECT_DEF_TYPE(i); + gBattleMons[gBattlerAttacker].type1 = TYPE_EFFECT_DEF_TYPE(i); + gBattleMons[gBattlerAttacker].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[gBattleMoveAttacker] - && TYPE_EFFECT_MULTIPLIER(j) <= 5 - && gBattleMons[gBattleMoveAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i) - && gBattleMons[gBattleMoveAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i)) + if (TYPE_EFFECT_ATK_TYPE(j) == gLastHitByType[gBattlerAttacker] + && TYPE_EFFECT_MULTIPLIER(j) <= 5 + && gBattleMons[gBattlerAttacker].type1 != TYPE_EFFECT_DEF_TYPE(i) + && gBattleMons[gBattlerAttacker].type2 != TYPE_EFFECT_DEF_TYPE(i)) { - gBattleMons[gBattleMoveAttacker].type1 = TYPE_EFFECT_DEF_TYPE(rands); - gBattleMons[gBattleMoveAttacker].type2 = TYPE_EFFECT_DEF_TYPE(rands); + gBattleMons[gBattlerAttacker].type1 = TYPE_EFFECT_DEF_TYPE(rands); + gBattleMons[gBattlerAttacker].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[gBattleMoveTarget] &= ~(STATUS3_ALWAYS_HITS); - gStatuses3[gBattleMoveTarget] |= 0x10; - gDisableStructs[gBattleMoveTarget].bankWithSureHit = gBattleMoveAttacker; + gStatuses3[gBattlerTarget] &= ~(STATUS3_ALWAYS_HITS); + gStatuses3[gBattlerTarget] |= 0x10; + gDisableStructs[gBattlerTarget].battlerWithSureHit = gBattlerAttacker; gBattlescriptCurrInstr++; } @@ -8724,19 +8724,19 @@ static void atkA8_copymovepermanently(void) // sketch { gChosenMove = 0xFFFF; - if (!(gBattleMons[gBattleMoveAttacker].status2 & STATUS2_TRANSFORMED) - && gLastPrintedMoves[gBattleMoveTarget] != MOVE_STRUGGLE - && gLastPrintedMoves[gBattleMoveTarget] != 0 - && gLastPrintedMoves[gBattleMoveTarget] != 0xFFFF - && gLastPrintedMoves[gBattleMoveTarget] != MOVE_SKETCH) + if (!(gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED) + && gLastPrintedMoves[gBattlerTarget] != MOVE_STRUGGLE + && gLastPrintedMoves[gBattlerTarget] != 0 + && gLastPrintedMoves[gBattlerTarget] != 0xFFFF + && gLastPrintedMoves[gBattlerTarget] != MOVE_SKETCH) { s32 i; for (i = 0; i < 4; i++) { - if (gBattleMons[gBattleMoveAttacker].moves[i] == MOVE_SKETCH) + if (gBattleMons[gBattlerAttacker].moves[i] == MOVE_SKETCH) continue; - if (gBattleMons[gBattleMoveAttacker].moves[i] == gLastPrintedMoves[gBattleMoveTarget]) + if (gBattleMons[gBattlerAttacker].moves[i] == gLastPrintedMoves[gBattlerTarget]) break; } @@ -8748,21 +8748,21 @@ static void atkA8_copymovepermanently(void) // sketch { struct MovePpInfo movePpData; - gBattleMons[gBattleMoveAttacker].moves[gCurrMovePos] = gLastPrintedMoves[gBattleMoveTarget]; - gBattleMons[gBattleMoveAttacker].pp[gCurrMovePos] = gBattleMoves[gLastPrintedMoves[gBattleMoveTarget]].pp; - gActiveBattler = gBattleMoveAttacker; + gBattleMons[gBattlerAttacker].moves[gCurrMovePos] = gLastPrintedMoves[gBattlerTarget]; + gBattleMons[gBattlerAttacker].pp[gCurrMovePos] = gBattleMoves[gLastPrintedMoves[gBattlerTarget]].pp; + gActiveBattler = gBattlerAttacker; for (i = 0; i < 4; i++) { - movePpData.moves[i] = gBattleMons[gBattleMoveAttacker].moves[i]; - movePpData.pp[i] = gBattleMons[gBattleMoveAttacker].pp[i]; + movePpData.moves[i] = gBattleMons[gBattlerAttacker].moves[i]; + movePpData.pp[i] = gBattleMons[gBattlerAttacker].pp[i]; } - movePpData.ppBonuses = gBattleMons[gBattleMoveAttacker].ppBonuses; + movePpData.ppBonuses = gBattleMons[gBattlerAttacker].ppBonuses; BtlController_EmitSetMonData(0, REQUEST_MOVES_PP_BATTLE, 0, sizeof(struct MovePpInfo), &movePpData); MarkBattlerForControllerExec(gActiveBattler); - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastPrintedMoves[gBattleMoveTarget]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastPrintedMoves[gBattlerTarget]) gBattlescriptCurrInstr += 5; } @@ -8822,17 +8822,17 @@ static void atkA9_trychoosesleeptalkmove(void) for (i = 0; i < 4; i++) { - if (IsInvalidForSleepTalkOrAssist(gBattleMons[gBattleMoveAttacker].moves[i]) - || gBattleMons[gBattleMoveAttacker].moves[i] == MOVE_FOCUS_PUNCH - || gBattleMons[gBattleMoveAttacker].moves[i] == MOVE_UPROAR - || IsTwoTurnsMove(gBattleMons[gBattleMoveAttacker].moves[i])) + if (IsInvalidForSleepTalkOrAssist(gBattleMons[gBattlerAttacker].moves[i]) + || gBattleMons[gBattlerAttacker].moves[i] == MOVE_FOCUS_PUNCH + || gBattleMons[gBattlerAttacker].moves[i] == MOVE_UPROAR + || IsTwoTurnsMove(gBattleMons[gBattlerAttacker].moves[i])) { unusableMovesBits |= gBitTable[i]; } } - unusableMovesBits = CheckMoveLimitations(gBattleMoveAttacker, unusableMovesBits, ~(MOVE_LIMITATION_PP)); + unusableMovesBits = CheckMoveLimitations(gBattlerAttacker, 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[gBattleMoveAttacker].moves[movePosition]; + gRandomMove = gBattleMons[gBattlerAttacker].moves[movePosition]; gCurrMovePos = movePosition; gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); - gBattleMoveTarget = GetMoveTarget(gRandomMove, 0); + gBattlerTarget = GetMoveTarget(gRandomMove, 0); gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } } static void atkAA_setdestinybond(void) { - gBattleMons[gBattleMoveAttacker].status2 |= STATUS2_DESTINY_BOND; + gBattleMons[gBattlerAttacker].status2 |= STATUS2_DESTINY_BOND; gBattlescriptCurrInstr++; } static void TrySetDestinyBondToHappen(void) { - u8 sideAttacker = GetBattlerSide(gBattleMoveAttacker); - u8 sideTarget = GetBattlerSide(gBattleMoveTarget); - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_DESTINY_BOND + u8 sideAttacker = GetBattlerSide(gBattlerAttacker); + u8 sideTarget = GetBattlerSide(gBattlerTarget); + if (gBattleMons[gBattlerTarget].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[gBattleMoveAttacker].hp, gBattleMons[gBattleMoveAttacker].maxHP, 48); + s32 hpFraction = GetScaledHPFraction(gBattleMons[gBattlerAttacker].hp, gBattleMons[gBattlerAttacker].maxHP, 48); for (i = 0; i < (s32) sizeof(sFlailHpScaleToPowerTable); i += 2) { @@ -8895,31 +8895,31 @@ static void atkAC_remaininghptopower(void) static void atkAD_tryspiteppreduce(void) { - if (gLastMoves[gBattleMoveTarget] != 0 - && gLastMoves[gBattleMoveTarget] != 0xFFFF) + if (gLastMoves[gBattlerTarget] != 0 + && gLastMoves[gBattlerTarget] != 0xFFFF) { s32 i; for (i = 0; i < 4; i++) { - if (gLastMoves[gBattleMoveTarget] == gBattleMons[gBattleMoveTarget].moves[i]) + if (gLastMoves[gBattlerTarget] == gBattleMons[gBattlerTarget].moves[i]) break; } - if (i != 4 && gBattleMons[gBattleMoveTarget].pp[i] > 1) + if (i != 4 && gBattleMons[gBattlerTarget].pp[i] > 1) { s32 ppToDeduct = (Random() & 3) + 2; - if (gBattleMons[gBattleMoveTarget].pp[i] < ppToDeduct) - ppToDeduct = gBattleMons[gBattleMoveTarget].pp[i]; + if (gBattleMons[gBattlerTarget].pp[i] < ppToDeduct) + ppToDeduct = gBattleMons[gBattlerTarget].pp[i]; - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBattleMoveTarget]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBattlerTarget]) ConvertIntToDecimalStringN(gBattleTextBuff2, ppToDeduct, 0, 1); PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff2, 1, ppToDeduct) - gBattleMons[gBattleMoveTarget].pp[i] -= ppToDeduct; - gActiveBattler = gBattleMoveTarget; + gBattleMons[gBattlerTarget].pp[i] -= ppToDeduct; + gActiveBattler = gBattlerTarget; if (!(gDisableStructs[gActiveBattler].unk18_b & gBitTable[i]) && !(gBattleMons[gActiveBattler].status2 & STATUS2_TRANSFORMED)) @@ -8930,8 +8930,8 @@ static void atkAD_tryspiteppreduce(void) gBattlescriptCurrInstr += 5; - if (gBattleMons[gBattleMoveTarget].pp[i] == 0) - CancelMultiTurnMoves(gBattleMoveTarget); + if (gBattleMons[gBattlerTarget].pp[i] == 0) + CancelMultiTurnMoves(gBattlerTarget); } else { @@ -8956,23 +8956,23 @@ static void atkAE_healpartystatus(void) gBattleCommunication[MULTISTRING_CHOOSER] = 0; - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; - if (gBattleMons[gBattleMoveAttacker].ability != ABILITY_SOUNDPROOF) + if (gBattleMons[gBattlerAttacker].ability != ABILITY_SOUNDPROOF) { - gBattleMons[gBattleMoveAttacker].status1 = 0; - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattlerAttacker].status1 = 0; + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_NIGHTMARE); } else { - RecordAbilityBattle(gBattleMoveAttacker, gBattleMons[gBattleMoveAttacker].ability); + RecordAbilityBattle(gBattlerAttacker, gBattleMons[gBattlerAttacker].ability); gBattleCommunication[MULTISTRING_CHOOSER] |= 1; } - gActiveBattler = gBattleScripting.battler = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveAttacker) ^ BIT_FLANK); + gActiveBattler = gBattleScripting.battler = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_FLANK); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) @@ -8998,8 +8998,8 @@ static void atkAE_healpartystatus(void) { u8 ability; - if (gBattlerPartyIndexes[gBattleMoveAttacker] == i) - ability = gBattleMons[gBattleMoveAttacker].ability; + if (gBattlerPartyIndexes[gBattlerAttacker] == i) + ability = gBattleMons[gBattlerAttacker].ability; else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && gBattlerPartyIndexes[gActiveBattler] == i && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) @@ -9017,10 +9017,10 @@ static void atkAE_healpartystatus(void) gBattleCommunication[MULTISTRING_CHOOSER] = 4; toHeal = 0x3F; - gBattleMons[gBattleMoveAttacker].status1 = 0; - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattlerAttacker].status1 = 0; + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_NIGHTMARE); - gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveAttacker) ^ BIT_FLANK); + gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_FLANK); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler])) { @@ -9032,7 +9032,7 @@ static void atkAE_healpartystatus(void) if (toHeal) { - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, toHeal, 4, &zero); MarkBattlerForControllerExec(gActiveBattler); } @@ -9042,14 +9042,14 @@ static void atkAE_healpartystatus(void) static void atkAF_cursetarget(void) { - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_CURSED) + if (gBattleMons[gBattlerTarget].status2 & STATUS2_CURSED) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gBattleMons[gBattleMoveTarget].status2 |= STATUS2_CURSED; - gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].maxHP / 2; + gBattleMons[gBattlerTarget].status2 |= STATUS2_CURSED; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -9059,11 +9059,11 @@ static void atkAF_cursetarget(void) static void atkB0_trysetspikes(void) { - u8 targetSide = GetBattlerSide(gBattleMoveAttacker) ^ BIT_SIDE; + u8 targetSide = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE; if (gSideTimers[targetSide].spikesAmount == 3) { - gSpecialStatuses[gBattleMoveAttacker].flag20 = 1; + gSpecialStatuses[gBattlerAttacker].flag20 = 1; gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else @@ -9076,7 +9076,7 @@ static void atkB0_trysetspikes(void) static void atkB1_setforesight(void) { - gBattleMons[gBattleMoveTarget].status2 |= STATUS2_FORESIGHT; + gBattleMons[gBattlerTarget].status2 |= STATUS2_FORESIGHT; gBattlescriptCurrInstr++; } @@ -9100,7 +9100,7 @@ static void atkB2_trysetperishsong(void) } } - PressurePPLoseOnUsingPerishSong(gBattleMoveAttacker); + PressurePPLoseOnUsingPerishSong(gBattlerAttacker); if (notAffectedCount == gBattlersCount) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); @@ -9112,31 +9112,31 @@ static void atkB3_rolloutdamagecalculation(void) { if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { - CancelMultiTurnMoves(gBattleMoveAttacker); + CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveMissedPause; } else { s32 i; - if (!(gBattleMons[gBattleMoveAttacker].status2 & STATUS2_MULTIPLETURNS)) // first hit + if (!(gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)) // first hit { - gDisableStructs[gBattleMoveAttacker].rolloutCounter1 = 5; - gDisableStructs[gBattleMoveAttacker].rolloutCounter2 = 5; - gBattleMons[gBattleMoveAttacker].status2 |= STATUS2_MULTIPLETURNS; - gLockedMoves[gBattleMoveAttacker] = gCurrentMove; + gDisableStructs[gBattlerAttacker].rolloutCounter1 = 5; + gDisableStructs[gBattlerAttacker].rolloutCounter2 = 5; + gBattleMons[gBattlerAttacker].status2 |= STATUS2_MULTIPLETURNS; + gLockedMoves[gBattlerAttacker] = gCurrentMove; } - if (--gDisableStructs[gBattleMoveAttacker].rolloutCounter1 == 0) // last hit + if (--gDisableStructs[gBattlerAttacker].rolloutCounter1 == 0) // last hit { - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); } gDynamicBasePower = gBattleMoves[gCurrentMove].power; - for (i = 1; i < (5 - gDisableStructs[gBattleMoveAttacker].rolloutCounter1); i++) + for (i = 1; i < (5 - gDisableStructs[gBattlerAttacker].rolloutCounter1); i++) gDynamicBasePower *= 2; - if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_DEFENSE_CURL) + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_DEFENSE_CURL) gDynamicBasePower *= 2; gBattlescriptCurrInstr++; @@ -9145,8 +9145,8 @@ static void atkB3_rolloutdamagecalculation(void) static void atkB4_jumpifconfusedandstatmaxed(void) { - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_CONFUSION - && gBattleMons[gBattleMoveTarget].statStages[gBattlescriptCurrInstr[1]] == 0xC) + if (gBattleMons[gBattlerTarget].status2 & STATUS2_CONFUSION + && gBattleMons[gBattlerTarget].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[gBattleMoveAttacker].furyCutterCounter = 0; + gDisableStructs[gBattlerAttacker].furyCutterCounter = 0; gBattlescriptCurrInstr = BattleScript_MoveMissedPause; } else { s32 i; - if (gDisableStructs[gBattleMoveAttacker].furyCutterCounter != 5) - gDisableStructs[gBattleMoveAttacker].furyCutterCounter++; + if (gDisableStructs[gBattlerAttacker].furyCutterCounter != 5) + gDisableStructs[gBattlerAttacker].furyCutterCounter++; gDynamicBasePower = gBattleMoves[gCurrentMove].power; - for (i = 1; i < gDisableStructs[gBattleMoveAttacker].furyCutterCounter; i++) + for (i = 1; i < gDisableStructs[gBattlerAttacker].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[gBattleMoveAttacker].friendship) / 25; + gDynamicBasePower = 10 * (gBattleMons[gBattlerAttacker].friendship) / 25; else // EFFECT_FRUSTRATION - gDynamicBasePower = 10 * (255 - gBattleMons[gBattleMoveAttacker].friendship) / 25; + gDynamicBasePower = 10 * (255 - gBattleMons[gBattlerAttacker].friendship) / 25; gBattlescriptCurrInstr++; } @@ -9197,14 +9197,14 @@ static void atkB7_presentdamagecalculation(void) gDynamicBasePower = 120; else { - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].maxHP / 4; + gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; } if (rand < 204) gBattlescriptCurrInstr = BattleScript_HitFromCritCalc; - else if (gBattleMons[gBattleMoveTarget].maxHP == gBattleMons[gBattleMoveTarget].hp) + else if (gBattleMons[gBattlerTarget].maxHP == gBattleMons[gBattlerTarget].hp) gBattlescriptCurrInstr = BattleScript_AlreadyAtFullHp; else { @@ -9215,16 +9215,16 @@ static void atkB7_presentdamagecalculation(void) static void atkB8_setsafeguard(void) { - if (gSideStatuses[GET_BATTLER_SIDE(gBattleMoveAttacker)] & SIDE_STATUS_SAFEGUARD) + if (gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] & SIDE_STATUS_SAFEGUARD) { gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } else { - gSideStatuses[GET_BATTLER_SIDE(gBattleMoveAttacker)] |= SIDE_STATUS_SAFEGUARD; - gSideTimers[GET_BATTLER_SIDE(gBattleMoveAttacker)].safeguardTimer = 5; - gSideTimers[GET_BATTLER_SIDE(gBattleMoveAttacker)].safeguardBank = gBattleMoveAttacker; + gSideStatuses[GET_BATTLER_SIDE(gBattlerAttacker)] |= SIDE_STATUS_SAFEGUARD; + gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].safeguardTimer = 5; + gSideTimers[GET_BATTLER_SIDE(gBattlerAttacker)].safeguardBank = gBattlerAttacker; gBattleCommunication[MULTISTRING_CHOOSER] = 5; } @@ -9274,11 +9274,11 @@ static void atkB9_magnitudedamagecalculation(void) PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 2, magnitude) - for (gBattleMoveTarget = 0; gBattleMoveTarget < gBattlersCount; gBattleMoveTarget++) + for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) { - if (gBattleMoveTarget == gBattleMoveAttacker) + if (gBattlerTarget == gBattlerAttacker) continue; - if (!(gAbsentBattlerFlags & gBitTable[gBattleMoveTarget])) // a valid target was found + if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget])) // a valid target was found break; } @@ -9289,36 +9289,36 @@ static void atkBA_jumpifnopursuitswitchdmg(void) { if (gMultiHitCounter == 1) { - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) + gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); else - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_LEFT); } else { - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) + gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_RIGHT); else - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_PLAYER_RIGHT); } - if (gActionForBanks[gBattleMoveTarget] == ACTION_USE_MOVE - && gBattleMoveAttacker == *(gBattleStruct->moveTarget + gBattleMoveTarget) - && !(gBattleMons[gBattleMoveTarget].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) - && gBattleMons[gBattleMoveAttacker].hp - && !gDisableStructs[gBattleMoveTarget].truantCounter - && gChosenMovesByBanks[gBattleMoveTarget] == MOVE_PURSUIT) + if (gChosenActionByBattler[gBattlerTarget] == B_ACTION_USE_MOVE + && gBattlerAttacker == *(gBattleStruct->moveTarget + gBattlerTarget) + && !(gBattleMons[gBattlerTarget].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) + && gBattleMons[gBattlerAttacker].hp + && !gDisableStructs[gBattlerTarget].truantCounter + && gChosenMoveByBattler[gBattlerTarget] == MOVE_PURSUIT) { s32 i; for (i = 0; i < gBattlersCount; i++) { - if (gBattleTurnOrder[i] == gBattleMoveTarget) + if (gBattleTurnOrder[i] == gBattlerTarget) gActionsByTurnOrder[i] = 11; } gCurrentMove = MOVE_PURSUIT; - gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBattleMoveTarget); + gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBattlerTarget); 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[gBattleMoveAttacker].maxHP / 2; + u32 halfHp = gBattleMons[gBattlerAttacker].maxHP / 2; - if (!(gBattleMons[gBattleMoveAttacker].maxHP / 2)) + if (!(gBattleMons[gBattlerAttacker].maxHP / 2)) halfHp = 1; - if (gBattleMons[gBattleMoveAttacker].statStages[STAT_STAGE_ATK] < 12 - && gBattleMons[gBattleMoveAttacker].hp > halfHp) + if (gBattleMons[gBattlerAttacker].statStages[STAT_STAGE_ATK] < 12 + && gBattleMons[gBattlerAttacker].hp > halfHp) { - gBattleMons[gBattleMoveAttacker].statStages[STAT_STAGE_ATK] = 12; - gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].maxHP / 2; + gBattleMons[gBattlerAttacker].statStages[STAT_STAGE_ATK] = 12; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].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[gBattleMoveAttacker].statStages[i] = gBattleMons[gBattleMoveTarget].statStages[i]; + gBattleMons[gBattlerAttacker].statStages[i] = gBattleMons[gBattlerTarget].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[gBattleMoveAttacker].status2 & STATUS2_WRAPPED) + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_WRAPPED) { - gBattleScripting.battler = gBattleMoveTarget; - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_WRAPPED); - gBattleMoveTarget = *(gBattleStruct->wrappedBy + gBattleMoveAttacker); + gBattleScripting.battler = gBattlerTarget; + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_WRAPPED); + gBattlerTarget = *(gBattleStruct->wrappedBy + gBattlerAttacker); gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN; gBattleTextBuff1[1] = B_BUFF_MOVE; - gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gBattleMoveAttacker * 2 + 0); - gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gBattleMoveAttacker * 2 + 1); + gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gBattlerAttacker * 2 + 0); + gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gBattlerAttacker * 2 + 1); gBattleTextBuff1[4] = B_BUFF_EOS; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_WrapFree; } - else if (gStatuses3[gBattleMoveAttacker] & STATUS3_LEECHSEED) + else if (gStatuses3[gBattlerAttacker] & STATUS3_LEECHSEED) { - gStatuses3[gBattleMoveAttacker] &= ~(STATUS3_LEECHSEED); - gStatuses3[gBattleMoveAttacker] &= ~(STATUS3_LEECHSEED_BANK); + gStatuses3[gBattlerAttacker] &= ~(STATUS3_LEECHSEED); + gStatuses3[gBattlerAttacker] &= ~(STATUS3_LEECHSEED_BANK); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_LeechSeedFree; } - else if (gSideStatuses[GetBattlerSide(gBattleMoveAttacker)] & SIDE_STATUS_SPIKES) + else if (gSideStatuses[GetBattlerSide(gBattlerAttacker)] & SIDE_STATUS_SPIKES) { - gSideStatuses[GetBattlerSide(gBattleMoveAttacker)] &= ~(SIDE_STATUS_SPIKES); - gSideTimers[GetBattlerSide(gBattleMoveAttacker)].spikesAmount = 0; + gSideStatuses[GetBattlerSide(gBattlerAttacker)] &= ~(SIDE_STATUS_SPIKES); + gSideTimers[GetBattlerSide(gBattlerAttacker)].spikesAmount = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SpikesFree; } @@ -9420,22 +9420,22 @@ static void atkBE_rapidspinfree(void) static void atkBF_setdefensecurlbit(void) { - gBattleMons[gBattleMoveAttacker].status2 |= STATUS2_DEFENSE_CURL; + gBattleMons[gBattlerAttacker].status2 |= STATUS2_DEFENSE_CURL; gBattlescriptCurrInstr++; } static void atkC0_recoverbasedonsunlight(void) { - gBattleMoveTarget = gBattleMoveAttacker; + gBattlerTarget = gBattlerAttacker; - if (gBattleMons[gBattleMoveAttacker].hp != gBattleMons[gBattleMoveAttacker].maxHP) + if (gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP) { if (gBattleWeather == 0 || !WEATHER_HAS_EFFECT) - gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].maxHP / 2; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 2; else if (gBattleWeather & WEATHER_SUN_ANY) - gBattleMoveDamage = 20 * gBattleMons[gBattleMoveAttacker].maxHP / 30; + gBattleMoveDamage = 20 * gBattleMons[gBattlerAttacker].maxHP / 30; else // not sunny weather - gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].maxHP / 4; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -9455,19 +9455,19 @@ static void atkC1_hiddenpowercalc(void) u32 powerBits = 0; u32 typeBits = 0; - powerBits |= ((gBattleMons[gBattleMoveAttacker].hpIV & 2) >> 1); - powerBits |= ((gBattleMons[gBattleMoveAttacker].attackIV & 2) << 0); - powerBits |= ((gBattleMons[gBattleMoveAttacker].defenseIV & 2) << 1); - powerBits |= ((gBattleMons[gBattleMoveAttacker].speedIV & 2) << 2); - powerBits |= ((gBattleMons[gBattleMoveAttacker].spAttackIV & 2) << 3); - powerBits |= ((gBattleMons[gBattleMoveAttacker].spDefenseIV & 2) << 4); + powerBits |= ((gBattleMons[gBattlerAttacker].hpIV & 2) >> 1); + powerBits |= ((gBattleMons[gBattlerAttacker].attackIV & 2) << 0); + powerBits |= ((gBattleMons[gBattlerAttacker].defenseIV & 2) << 1); + powerBits |= ((gBattleMons[gBattlerAttacker].speedIV & 2) << 2); + powerBits |= ((gBattleMons[gBattlerAttacker].spAttackIV & 2) << 3); + powerBits |= ((gBattleMons[gBattlerAttacker].spDefenseIV & 2) << 4); - typeBits |= ((gBattleMons[gBattleMoveAttacker].hpIV & 1) << 0); - typeBits |= ((gBattleMons[gBattleMoveAttacker].attackIV & 1) << 1); - typeBits |= ((gBattleMons[gBattleMoveAttacker].defenseIV & 1) << 2); - typeBits |= ((gBattleMons[gBattleMoveAttacker].speedIV & 1) << 3); - typeBits |= ((gBattleMons[gBattleMoveAttacker].spAttackIV & 1) << 4); - typeBits |= ((gBattleMons[gBattleMoveAttacker].spDefenseIV & 1) << 5); + typeBits |= ((gBattleMons[gBattlerAttacker].hpIV & 1) << 0); + typeBits |= ((gBattleMons[gBattlerAttacker].attackIV & 1) << 1); + typeBits |= ((gBattleMons[gBattlerAttacker].defenseIV & 1) << 2); + typeBits |= ((gBattleMons[gBattlerAttacker].speedIV & 1) << 3); + typeBits |= ((gBattleMons[gBattlerAttacker].spAttackIV & 1) << 4); + typeBits |= ((gBattleMons[gBattlerAttacker].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, =gBattleMoveAttacker\n\ + ldr r0, =gBattlerAttacker\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 (gBattleMoveTarget = 0; gBattleMoveTarget < gBattlersCount; gBattleMoveTarget++) + for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount; gBattlerTarget++) { - if (gBattleMoveTarget == gBattleMoveAttacker) + if (gBattlerTarget == gBattlerAttacker) continue; - if (!(gAbsentBattlerFlags & gBitTable[gBattleMoveTarget])) + if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget])) break; } gBattlescriptCurrInstr++; @@ -9638,22 +9638,22 @@ static void atkC2_selectfirstvalidtarget(void) static void atkC3_trysetfutureattack(void) { - if (gWishFutureKnock.futureSightCounter[gBattleMoveTarget] != 0) + if (gWishFutureKnock.futureSightCounter[gBattlerTarget] != 0) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gSideStatuses[GET_BATTLER_SIDE(gBattleMoveTarget)] |= SIDE_STATUS_FUTUREATTACK; - gWishFutureKnock.futureSightMove[gBattleMoveTarget] = gCurrentMove; - gWishFutureKnock.futureSightAttacker[gBattleMoveTarget] = gBattleMoveAttacker; - gWishFutureKnock.futureSightCounter[gBattleMoveTarget] = 3; - gWishFutureKnock.futureSightDmg[gBattleMoveTarget] = CalculateBaseDamage(&gBattleMons[gBattleMoveAttacker], &gBattleMons[gBattleMoveTarget], gCurrentMove, - gSideStatuses[GET_BATTLER_SIDE(gBattleMoveTarget)], 0, - 0, gBattleMoveAttacker, gBattleMoveTarget); + gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)] |= SIDE_STATUS_FUTUREATTACK; + gWishFutureKnock.futureSightMove[gBattlerTarget] = gCurrentMove; + gWishFutureKnock.futureSightAttacker[gBattlerTarget] = gBattlerAttacker; + gWishFutureKnock.futureSightCounter[gBattlerTarget] = 3; + gWishFutureKnock.futureSightDmg[gBattlerTarget] = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerTarget], gCurrentMove, + gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)], 0, + 0, gBattlerAttacker, gBattlerTarget); - if (gProtectStructs[gBattleMoveAttacker].helpingHand) - gWishFutureKnock.futureSightDmg[gBattleMoveTarget] = gWishFutureKnock.futureSightDmg[gBattleMoveTarget] * 15 / 10; + if (gProtectStructs[gBattlerAttacker].helpingHand) + gWishFutureKnock.futureSightDmg[gBattlerTarget] = gWishFutureKnock.futureSightDmg[gBattlerTarget] * 15 / 10; if (gCurrentMove == MOVE_DOOM_DESIRE) gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -9668,12 +9668,12 @@ static void atkC4_trydobeatup(void) { struct Pokemon *party; - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; - if (gBattleMons[gBattleMoveTarget].hp == 0) + if (gBattleMons[gBattlerTarget].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, gBattleMoveAttacker, gBattleCommunication[0]) + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBattlerAttacker, 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[gBattleMoveTarget].species].baseDefense; + gBattleMoveDamage /= gBaseStats[gBattleMons[gBattlerTarget].species].baseDefense; gBattleMoveDamage = (gBattleMoveDamage / 50) + 2; - if (gProtectStructs[gBattleMoveAttacker].helpingHand) + if (gProtectStructs[gBattlerAttacker].helpingHand) gBattleMoveDamage = gBattleMoveDamage * 15 / 10; gBattleCommunication[0]++; @@ -9717,13 +9717,13 @@ static void atkC5_setsemiinvulnerablebit(void) { case MOVE_FLY: case MOVE_BOUNCE: - gStatuses3[gBattleMoveAttacker] |= STATUS3_ON_AIR; + gStatuses3[gBattlerAttacker] |= STATUS3_ON_AIR; break; case MOVE_DIG: - gStatuses3[gBattleMoveAttacker] |= STATUS3_UNDERGROUND; + gStatuses3[gBattlerAttacker] |= STATUS3_UNDERGROUND; break; case MOVE_DIVE: - gStatuses3[gBattleMoveAttacker] |= STATUS3_UNDERWATER; + gStatuses3[gBattlerAttacker] |= STATUS3_UNDERWATER; break; } @@ -9736,13 +9736,13 @@ static void atkC6_clearsemiinvulnerablebit(void) { case MOVE_FLY: case MOVE_BOUNCE: - gStatuses3[gBattleMoveAttacker] &= ~STATUS3_ON_AIR; + gStatuses3[gBattlerAttacker] &= ~STATUS3_ON_AIR; break; case MOVE_DIG: - gStatuses3[gBattleMoveAttacker] &= ~STATUS3_UNDERGROUND; + gStatuses3[gBattlerAttacker] &= ~STATUS3_UNDERGROUND; break; case MOVE_DIVE: - gStatuses3[gBattleMoveAttacker] &= ~STATUS3_UNDERWATER; + gStatuses3[gBattlerAttacker] &= ~STATUS3_UNDERWATER; break; } @@ -9752,7 +9752,7 @@ static void atkC6_clearsemiinvulnerablebit(void) static void atkC7_setminimize(void) { if (gHitMarker & HITMARKER_OBEYS) - gStatuses3[gBattleMoveAttacker] |= STATUS3_MINIMIZED; + gStatuses3[gBattlerAttacker] |= STATUS3_MINIMIZED; gBattlescriptCurrInstr++; } @@ -9776,15 +9776,15 @@ static void atkC8_sethail(void) static void atkC9_jumpifattackandspecialattackcannotfall(void) // memento { - if (gBattleMons[gBattleMoveTarget].statStages[STAT_STAGE_ATK] == 0 - && gBattleMons[gBattleMoveTarget].statStages[STAT_STAGE_SPATK] == 0 + if (gBattleMons[gBattlerTarget].statStages[STAT_STAGE_ATK] == 0 + && gBattleMons[gBattlerTarget].statStages[STAT_STAGE_SPATK] == 0 && gBattleCommunication[6] != 1) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; gBattleMoveDamage = gBattleMons[gActiveBattler].hp; BtlController_EmitHealthBarUpdate(0, INSTANT_HP_BAR_DROP); MarkBattlerForControllerExec(gActiveBattler); @@ -9794,16 +9794,16 @@ static void atkC9_jumpifattackandspecialattackcannotfall(void) // memento static void atkCA_setforcedtarget(void) // follow me { - gSideTimers[GetBattlerSide(gBattleMoveAttacker)].followmeTimer = 1; - gSideTimers[GetBattlerSide(gBattleMoveAttacker)].followmeTarget = gBattleMoveAttacker; + gSideTimers[GetBattlerSide(gBattlerAttacker)].followmeTimer = 1; + gSideTimers[GetBattlerSide(gBattlerAttacker)].followmeTarget = gBattlerAttacker; gBattlescriptCurrInstr++; } static void atkCB_setcharge(void) { - gStatuses3[gBattleMoveAttacker] |= STATUS3_CHARGED_UP; - gDisableStructs[gBattleMoveAttacker].chargeTimer1 = 2; - gDisableStructs[gBattleMoveAttacker].chargeTimer2 = 2; + gStatuses3[gBattlerAttacker] |= STATUS3_CHARGED_UP; + gDisableStructs[gBattlerAttacker].chargeTimer1 = 2; + gDisableStructs[gBattlerAttacker].chargeTimer2 = 2; gBattlescriptCurrInstr++; } @@ -9811,18 +9811,18 @@ static void atkCC_callterrainattack(void) // nature power { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = sNaturePowerMoves[gBattleTerrain]; - gBattleMoveTarget = GetMoveTarget(gCurrentMove, 0); + gBattlerTarget = GetMoveTarget(gCurrentMove, 0); BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]); gBattlescriptCurrInstr++; } static void atkCD_cureifburnedparalysedorpoisoned(void) // refresh { - if (gBattleMons[gBattleMoveAttacker].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)) + if (gBattleMons[gBattlerAttacker].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)) { - gBattleMons[gBattleMoveAttacker].status1 = 0; + gBattleMons[gBattlerAttacker].status1 = 0; gBattlescriptCurrInstr += 5; - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); } @@ -9834,20 +9834,20 @@ static void atkCD_cureifburnedparalysedorpoisoned(void) // refresh static void atkCE_settorment(void) { - if (gBattleMons[gBattleMoveTarget].status2 & STATUS2_TORMENT) + if (gBattleMons[gBattlerTarget].status2 & STATUS2_TORMENT) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gBattleMons[gBattleMoveTarget].status2 |= STATUS2_TORMENT; + gBattleMons[gBattlerTarget].status2 |= STATUS2_TORMENT; gBattlescriptCurrInstr += 5; } } static void atkCF_jumpifnodamage(void) { - if (gProtectStructs[gBattleMoveAttacker].physicalDmg || gProtectStructs[gBattleMoveAttacker].specialDmg) + if (gProtectStructs[gBattlerAttacker].physicalDmg || gProtectStructs[gBattlerAttacker].specialDmg) gBattlescriptCurrInstr += 5; else gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); @@ -9855,10 +9855,10 @@ static void atkCF_jumpifnodamage(void) static void atkD0_settaunt(void) { - if (gDisableStructs[gBattleMoveTarget].tauntTimer1 == 0) + if (gDisableStructs[gBattlerTarget].tauntTimer1 == 0) { - gDisableStructs[gBattleMoveTarget].tauntTimer1 = 2; - gDisableStructs[gBattleMoveTarget].tauntTimer2 = 2; + gDisableStructs[gBattlerTarget].tauntTimer1 = 2; + gDisableStructs[gBattlerTarget].tauntTimer2 = 2; gBattlescriptCurrInstr += 5; } else @@ -9869,14 +9869,14 @@ static void atkD0_settaunt(void) static void atkD1_trysethelpinghand(void) { - gBattleMoveTarget = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveAttacker) ^ BIT_FLANK); + gBattlerTarget = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_FLANK); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && !(gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) - && !gProtectStructs[gBattleMoveAttacker].helpingHand - && !gProtectStructs[gBattleMoveTarget].helpingHand) + && !(gAbsentBattlerFlags & gBitTable[gBattlerTarget]) + && !gProtectStructs[gBattlerAttacker].helpingHand + && !gProtectStructs[gBattlerTarget].helpingHand) { - gProtectStructs[gBattleMoveTarget].helpingHand = 1; + gProtectStructs[gBattlerTarget].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 - || (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_OPPONENT + || (GetBattlerSide(gBattlerAttacker) == 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 = GetBattlerSide(gBattleMoveAttacker); - u8 sideTarget = GetBattlerSide(gBattleMoveTarget); + u8 sideAttacker = GetBattlerSide(gBattlerAttacker); + u8 sideTarget = GetBattlerSide(gBattlerTarget); // 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[gBattlerPartyIndexes[gBattleMoveAttacker]] - || gWishFutureKnock.knockedOffPokes[sideTarget] & gBitTable[gBattlerPartyIndexes[gBattleMoveTarget]])) + && (gWishFutureKnock.knockedOffPokes[sideAttacker] & gBitTable[gBattlerPartyIndexes[gBattlerAttacker]] + || gWishFutureKnock.knockedOffPokes[sideTarget] & gBitTable[gBattlerPartyIndexes[gBattlerTarget]])) { 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[gBattleMoveAttacker].item == 0 && gBattleMons[gBattleMoveTarget].item == 0) - || gBattleMons[gBattleMoveAttacker].item == ITEM_ENIGMA_BERRY - || gBattleMons[gBattleMoveTarget].item == ITEM_ENIGMA_BERRY - || IS_ITEM_MAIL(gBattleMons[gBattleMoveAttacker].item) - || IS_ITEM_MAIL(gBattleMons[gBattleMoveTarget].item)) + else if ((gBattleMons[gBattlerAttacker].item == 0 && gBattleMons[gBattlerTarget].item == 0) + || gBattleMons[gBattlerAttacker].item == ITEM_ENIGMA_BERRY + || gBattleMons[gBattlerTarget].item == ITEM_ENIGMA_BERRY + || IS_ITEM_MAIL(gBattleMons[gBattlerAttacker].item) + || IS_ITEM_MAIL(gBattleMons[gBattlerTarget].item)) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } // check if ability prevents swapping - else if (gBattleMons[gBattleMoveTarget].ability == ABILITY_STICKY_HOLD) + else if (gBattleMons[gBattlerTarget].ability == ABILITY_STICKY_HOLD) { gBattlescriptCurrInstr = BattleScript_StickyHoldActivates; - gLastUsedAbility = gBattleMons[gBattleMoveTarget].ability; - RecordAbilityBattle(gBattleMoveTarget, gLastUsedAbility); + gLastUsedAbility = gBattleMons[gBattlerTarget].ability; + RecordAbilityBattle(gBattlerTarget, gLastUsedAbility); } // took a while, but all checks passed and items can be safely swapped else { u16 oldItemAtk, *newItemAtk; - newItemAtk = &gBattleStruct->changedItems[gBattleMoveAttacker]; - oldItemAtk = gBattleMons[gBattleMoveAttacker].item; - *newItemAtk = gBattleMons[gBattleMoveTarget].item; + newItemAtk = &gBattleStruct->changedItems[gBattlerAttacker]; + oldItemAtk = gBattleMons[gBattlerAttacker].item; + *newItemAtk = gBattleMons[gBattlerTarget].item; - gBattleMons[gBattleMoveAttacker].item = 0; - gBattleMons[gBattleMoveTarget].item = oldItemAtk; + gBattleMons[gBattlerAttacker].item = 0; + gBattleMons[gBattlerTarget].item = oldItemAtk; - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, newItemAtk); - MarkBattlerForControllerExec(gBattleMoveAttacker); + MarkBattlerForControllerExec(gBattlerAttacker); - gActiveBattler = gBattleMoveTarget; - BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBattleMoveTarget].item); - MarkBattlerForControllerExec(gBattleMoveTarget); + gActiveBattler = gBattlerTarget; + BtlController_EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBattlerTarget].item); + MarkBattlerForControllerExec(gBattlerTarget); - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleMoveTarget]) + 0) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleMoveTarget]) + 1) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerTarget]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerTarget]) + 1) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleMoveAttacker]) + 0) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattleMoveAttacker]) + 1) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerAttacker]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBattlerAttacker]) + 1) = 0; gBattlescriptCurrInstr += 5; @@ -9974,11 +9974,11 @@ static void atkD2_tryswapitems(void) // trick static void atkD3_trycopyability(void) // role play { - if (gBattleMons[gBattleMoveTarget].ability != 0 - && gBattleMons[gBattleMoveTarget].ability != ABILITY_WONDER_GUARD) + if (gBattleMons[gBattlerTarget].ability != 0 + && gBattleMons[gBattlerTarget].ability != ABILITY_WONDER_GUARD) { - gBattleMons[gBattleMoveAttacker].ability = gBattleMons[gBattleMoveTarget].ability; - gLastUsedAbility = gBattleMons[gBattleMoveTarget].ability; + gBattleMons[gBattlerAttacker].ability = gBattleMons[gBattlerTarget].ability; + gLastUsedAbility = gBattleMons[gBattlerTarget].ability; gBattlescriptCurrInstr += 5; } else @@ -9992,10 +9992,10 @@ static void atkD4_trywish(void) switch (gBattlescriptCurrInstr[1]) { case 0: // use wish - if (gWishFutureKnock.wishCounter[gBattleMoveAttacker] == 0) + if (gWishFutureKnock.wishCounter[gBattlerAttacker] == 0) { - gWishFutureKnock.wishCounter[gBattleMoveAttacker] = 2; - gWishFutureKnock.wishUserID[gBattleMoveAttacker] = gBattlerPartyIndexes[gBattleMoveAttacker]; + gWishFutureKnock.wishCounter[gBattlerAttacker] = 2; + gWishFutureKnock.wishUserID[gBattlerAttacker] = gBattlerPartyIndexes[gBattlerAttacker]; gBattlescriptCurrInstr += 6; } else @@ -10004,14 +10004,14 @@ static void atkD4_trywish(void) } break; case 1: // heal effect - PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBattleMoveTarget, gWishFutureKnock.wishUserID[gBattleMoveTarget]) + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBattlerTarget, gWishFutureKnock.wishUserID[gBattlerTarget]) - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].maxHP / 2; + gBattleMoveDamage = gBattleMons[gBattlerTarget].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - if (gBattleMons[gBattleMoveTarget].hp == gBattleMons[gBattleMoveTarget].maxHP) + if (gBattleMons[gBattlerTarget].hp == gBattleMons[gBattlerTarget].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[gBattleMoveAttacker] & STATUS3_ROOTED) + if (gStatuses3[gBattlerAttacker] & STATUS3_ROOTED) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gStatuses3[gBattleMoveAttacker] |= STATUS3_ROOTED; + gStatuses3[gBattlerAttacker] |= STATUS3_ROOTED; gBattlescriptCurrInstr += 5; } } static void atkD6_doubledamagedealtifdamaged(void) { - if ((gProtectStructs[gBattleMoveAttacker].physicalDmg - && gProtectStructs[gBattleMoveAttacker].physicalBank == gBattleMoveTarget) - || (gProtectStructs[gBattleMoveAttacker].specialDmg - && gProtectStructs[gBattleMoveAttacker].specialBank == gBattleMoveTarget)) + if ((gProtectStructs[gBattlerAttacker].physicalDmg + && gProtectStructs[gBattlerAttacker].physicalBank == gBattlerTarget) + || (gProtectStructs[gBattlerAttacker].specialDmg + && gProtectStructs[gBattlerAttacker].specialBank == gBattlerTarget)) { gBattleScripting.dmgMultiplier = 2; } @@ -10048,27 +10048,27 @@ static void atkD6_doubledamagedealtifdamaged(void) static void atkD7_setyawn(void) { - if (gStatuses3[gBattleMoveTarget] & STATUS3_YAWN - || gBattleMons[gBattleMoveTarget].status1 & STATUS1_ANY) + if (gStatuses3[gBattlerTarget] & STATUS3_YAWN + || gBattleMons[gBattlerTarget].status1 & STATUS1_ANY) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gStatuses3[gBattleMoveTarget] |= 0x1000; + gStatuses3[gBattlerTarget] |= 0x1000; gBattlescriptCurrInstr += 5; } } static void atkD8_setdamagetohealthdifference(void) { - if (gBattleMons[gBattleMoveTarget].hp <= gBattleMons[gBattleMoveAttacker].hp) + if (gBattleMons[gBattlerTarget].hp <= gBattleMons[gBattlerAttacker].hp) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gBattleMoveDamage = gBattleMons[gBattleMoveTarget].hp - gBattleMons[gBattleMoveAttacker].hp; + gBattleMoveDamage = gBattleMons[gBattlerTarget].hp - gBattleMons[gBattlerAttacker].hp; gBattlescriptCurrInstr += 5; } } @@ -10078,7 +10078,7 @@ static void atkD9_scaledamagebyhealthratio(void) if (gDynamicBasePower == 0) { u8 power = gBattleMoves[gCurrentMove].power; - gDynamicBasePower = gBattleMons[gBattleMoveAttacker].hp * power / gBattleMons[gBattleMoveAttacker].maxHP; + gDynamicBasePower = gBattleMons[gBattlerAttacker].hp * power / gBattleMons[gBattlerAttacker].maxHP; if (gDynamicBasePower == 0) gDynamicBasePower = 1; } @@ -10087,19 +10087,19 @@ static void atkD9_scaledamagebyhealthratio(void) static void atkDA_tryswapabilities(void) // skill swap { - if ((gBattleMons[gBattleMoveAttacker].ability == 0 - && gBattleMons[gBattleMoveTarget].ability == 0) - || gBattleMons[gBattleMoveAttacker].ability == ABILITY_WONDER_GUARD - || gBattleMons[gBattleMoveTarget].ability == ABILITY_WONDER_GUARD + if ((gBattleMons[gBattlerAttacker].ability == 0 + && gBattleMons[gBattlerTarget].ability == 0) + || gBattleMons[gBattlerAttacker].ability == ABILITY_WONDER_GUARD + || gBattleMons[gBattlerTarget].ability == ABILITY_WONDER_GUARD || gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - u8 abilityAtk = gBattleMons[gBattleMoveAttacker].ability; - gBattleMons[gBattleMoveAttacker].ability = gBattleMons[gBattleMoveTarget].ability; - gBattleMons[gBattleMoveTarget].ability = abilityAtk; + u8 abilityAtk = gBattleMons[gBattlerAttacker].ability; + gBattleMons[gBattlerAttacker].ability = gBattleMons[gBattlerTarget].ability; + gBattleMons[gBattlerTarget].ability = abilityAtk; gBattlescriptCurrInstr += 5; } @@ -10107,7 +10107,7 @@ static void atkDA_tryswapabilities(void) // skill swap static void atkDB_tryimprision(void) { - if ((gStatuses3[gBattleMoveAttacker] & STATUS3_IMPRISONED_OTHERS)) + if ((gStatuses3[gBattlerAttacker] & STATUS3_IMPRISONED_OTHERS)) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -10115,8 +10115,8 @@ static void atkDB_tryimprision(void) { u8 bank, sideAttacker; - sideAttacker = GetBattlerSide(gBattleMoveAttacker); - PressurePPLoseOnUsingImprision(gBattleMoveAttacker); + sideAttacker = GetBattlerSide(gBattlerAttacker); + PressurePPLoseOnUsingImprision(gBattlerAttacker); for (bank = 0; bank < gBattlersCount; bank++) { if (sideAttacker != GetBattlerSide(bank)) @@ -10127,8 +10127,8 @@ static void atkDB_tryimprision(void) s32 i; for (i = 0; i < 4; i++) { - if (gBattleMons[gBattleMoveAttacker].moves[attackerMoveId] == gBattleMons[bank].moves[i] - && gBattleMons[gBattleMoveAttacker].moves[attackerMoveId] != MOVE_NONE) + if (gBattleMons[gBattlerAttacker].moves[attackerMoveId] == gBattleMons[bank].moves[i] + && gBattleMons[gBattlerAttacker].moves[attackerMoveId] != MOVE_NONE) break; } if (i != 4) @@ -10136,7 +10136,7 @@ static void atkDB_tryimprision(void) } if (attackerMoveId != 4) { - gStatuses3[gBattleMoveAttacker] |= STATUS3_IMPRISONED_OTHERS; + gStatuses3[gBattlerAttacker] |= STATUS3_IMPRISONED_OTHERS; gBattlescriptCurrInstr += 5; break; } @@ -10149,13 +10149,13 @@ static void atkDB_tryimprision(void) static void atkDC_trysetgrudge(void) { - if (gStatuses3[gBattleMoveAttacker] & STATUS3_GRUDGE) + if (gStatuses3[gBattlerAttacker] & STATUS3_GRUDGE) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gStatuses3[gBattleMoveAttacker] |= STATUS3_GRUDGE; + gStatuses3[gBattlerAttacker] |= 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[gBattleMoveTarget].species), 1)) + if (sWeightToDamageTable[i] > GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), 1)) break; } @@ -10184,14 +10184,14 @@ static void atkDE_asistattackselect(void) s32 monId, moveId; u16* movesArray = gBattleStruct->assistPossibleMoves; - if (GET_BATTLER_SIDE(gBattleMoveAttacker) != B_SIDE_PLAYER) + if (GET_BATTLER_SIDE(gBattlerAttacker) != B_SIDE_PLAYER) party = gEnemyParty; else party = gPlayerParty; for (monId = 0; monId < 6; monId++) { - if (monId == gBattlerPartyIndexes[gBattleMoveAttacker]) + if (monId == gBattlerPartyIndexes[gBattlerAttacker]) 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]; - gBattleMoveTarget = GetMoveTarget(gRandomMove, 0); + gBattlerTarget = GetMoveTarget(gRandomMove, 0); gBattlescriptCurrInstr += 5; } else @@ -10232,29 +10232,29 @@ static void atkDE_asistattackselect(void) static void atkDF_trysetmagiccoat(void) { - gBattleMoveTarget = gBattleMoveAttacker; - gSpecialStatuses[gBattleMoveAttacker].flag20 = 1; + gBattlerTarget = gBattlerAttacker; + gSpecialStatuses[gBattlerAttacker].flag20 = 1; if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gProtectStructs[gBattleMoveAttacker].bounceMove = 1; + gProtectStructs[gBattlerAttacker].bounceMove = 1; gBattlescriptCurrInstr += 5; } } static void atkE0_trysetsnatch(void) // snatch { - gSpecialStatuses[gBattleMoveAttacker].flag20 = 1; + gSpecialStatuses[gBattlerAttacker].flag20 = 1; if (gCurrentTurnActionNumber == gBattlersCount - 1) // moves last turn { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gProtectStructs[gBattleMoveAttacker].stealMove = 1; + gProtectStructs[gBattlerAttacker].stealMove = 1; gBattlescriptCurrInstr += 5; } } @@ -10268,15 +10268,15 @@ static void atkE1_trygetintimidatetarget(void) PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gBattleMons[gBattleScripting.battler].ability) - for (;gBattleMoveTarget < gBattlersCount; gBattleMoveTarget++) + for (;gBattlerTarget < gBattlersCount; gBattlerTarget++) { - if (GetBattlerSide(gBattleMoveTarget) == side) + if (GetBattlerSide(gBattlerTarget) == side) continue; - if (!(gAbsentBattlerFlags & gBitTable[gBattleMoveTarget])) + if (!(gAbsentBattlerFlags & gBitTable[gBattlerTarget])) break; } - if (gBattleMoveTarget >= gBattlersCount) + if (gBattlerTarget >= gBattlersCount) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); else gBattlescriptCurrInstr += 5; @@ -10451,18 +10451,18 @@ static void atkE8_settypebasedhalvers(void) // water and mud sport if (gBattleMoves[gCurrentMove].effect == EFFECT_MUD_SPORT) { - if (!(gStatuses3[gBattleMoveAttacker] & STATUS3_MUDSPORT)) + if (!(gStatuses3[gBattlerAttacker] & STATUS3_MUDSPORT)) { - gStatuses3[gBattleMoveAttacker] |= STATUS3_MUDSPORT; + gStatuses3[gBattlerAttacker] |= STATUS3_MUDSPORT; gBattleCommunication[MULTISTRING_CHOOSER] = 0; worked = TRUE; } } else // water sport { - if (!(gStatuses3[gBattleMoveAttacker] & STATUS3_WATERSPORT)) + if (!(gStatuses3[gBattlerAttacker] & STATUS3_WATERSPORT)) { - gStatuses3[gBattleMoveAttacker] |= STATUS3_WATERSPORT; + gStatuses3[gBattlerAttacker] |= STATUS3_WATERSPORT; gBattleCommunication[MULTISTRING_CHOOSER] = 1; worked = TRUE; } @@ -10499,7 +10499,7 @@ static void atkEA_tryrecycleitem(void) { u16 *usedHeldItem; - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; usedHeldItem = &gBattleStruct->usedHeldItems[gActiveBattler]; if (*usedHeldItem != 0 && gBattleMons[gActiveBattler].item == 0) { @@ -10520,11 +10520,11 @@ static void atkEA_tryrecycleitem(void) static void atkEB_settypetoterrain(void) { - if (gBattleMons[gBattleMoveAttacker].type1 != sTerrainToType[gBattleTerrain] - && gBattleMons[gBattleMoveAttacker].type2 != sTerrainToType[gBattleTerrain]) + if (gBattleMons[gBattlerAttacker].type1 != sTerrainToType[gBattleTerrain] + && gBattleMons[gBattlerAttacker].type2 != sTerrainToType[gBattleTerrain]) { - gBattleMons[gBattleMoveAttacker].type1 = sTerrainToType[gBattleTerrain]; - gBattleMons[gBattleMoveAttacker].type2 = sTerrainToType[gBattleTerrain]; + gBattleMons[gBattlerAttacker].type1 = sTerrainToType[gBattleTerrain]; + gBattleMons[gBattlerAttacker].type2 = sTerrainToType[gBattleTerrain]; PREPARE_TYPE_BUFFER(gBattleTextBuff1, sTerrainToType[gBattleTerrain]) @@ -10538,19 +10538,19 @@ static void atkEB_settypetoterrain(void) static void atkEC_pursuitrelated(void) { - gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattleMoveAttacker) ^ BIT_FLANK); + gActiveBattler = GetBattlerAtPosition(GetBattlerPosition(gBattlerAttacker) ^ BIT_FLANK); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBattlerFlags & gBitTable[gActiveBattler]) - && gActionForBanks[gActiveBattler] == 0 - && gChosenMovesByBanks[gActiveBattler] == MOVE_PURSUIT) + && gChosenActionByBattler[gActiveBattler] == 0 + && gChosenMoveByBattler[gActiveBattler] == MOVE_PURSUIT) { gActionsByTurnOrder[gActiveBattler] = 11; gCurrentMove = MOVE_PURSUIT; gBattlescriptCurrInstr += 5; gBattleScripting.animTurn = 1; - gBattleScripting.field_20 = gBattleMoveAttacker; - gBattleMoveAttacker = gActiveBattler; + gBattleScripting.field_20 = gBattlerAttacker; + gBattlerAttacker = gActiveBattler; } else { @@ -10560,12 +10560,12 @@ static void atkEC_pursuitrelated(void) static void atkEF_snatchsetbanks(void) { - gEffectBank = gBattleMoveAttacker; + gEffectBank = gBattlerAttacker; - if (gBattleMoveAttacker == gBattleMoveTarget) - gBattleMoveAttacker = gBattleMoveTarget = gBattleScripting.battler; + if (gBattlerAttacker == gBattlerTarget) + gBattlerAttacker = gBattlerTarget = gBattleScripting.battler; else - gBattleMoveTarget = gBattleScripting.battler; + gBattlerTarget = gBattleScripting.battler; gBattleScripting.battler = gEffectBank; gBattlescriptCurrInstr++; @@ -10573,7 +10573,7 @@ static void atkEF_snatchsetbanks(void) static void atkEE_removelightscreenreflect(void) // brick break { - u8 opposingSide = GetBattlerSide(gBattleMoveAttacker) ^ BIT_SIDE; + u8 opposingSide = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE; if (gSideTimers[opposingSide].reflectTimer || gSideTimers[opposingSide].lightscreenTimer) { @@ -10600,8 +10600,8 @@ static void atkEF_handleballthrow(void) if (gBattleControllerExecFlags) return; - gActiveBattler = gBattleMoveAttacker; - gBattleMoveTarget = gBattleMoveAttacker ^ BIT_SIDE; + gActiveBattler = gBattlerAttacker; + gBattlerTarget = gBattlerAttacker ^ BIT_SIDE; if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { @@ -10623,17 +10623,17 @@ static void atkEF_handleballthrow(void) if (gLastUsedItem == ITEM_SAFARI_BALL) catchRate = gBattleStruct->field_7C * 1275 / 100; else - catchRate = gBaseStats[gBattleMons[gBattleMoveTarget].species].catchRate; + catchRate = gBaseStats[gBattleMons[gBattlerTarget].species].catchRate; if (gLastUsedItem > ITEM_SAFARI_BALL) { switch (gLastUsedItem) { case ITEM_NET_BALL: - if (gBattleMons[gBattleMoveTarget].type1 == TYPE_WATER - || gBattleMons[gBattleMoveTarget].type2 == TYPE_WATER - || gBattleMons[gBattleMoveTarget].type1 == TYPE_BUG - || gBattleMons[gBattleMoveTarget].type2 == TYPE_BUG) + if (gBattleMons[gBattlerTarget].type1 == TYPE_WATER + || gBattleMons[gBattlerTarget].type2 == TYPE_WATER + || gBattleMons[gBattlerTarget].type1 == TYPE_BUG + || gBattleMons[gBattlerTarget].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[gBattleMoveTarget].level < 40) + if (gBattleMons[gBattlerTarget].level < 40) { - ballMultiplier = 40 - gBattleMons[gBattleMoveTarget].level; + ballMultiplier = 40 - gBattleMons[gBattlerTarget].level; if (ballMultiplier <= 9) ballMultiplier = 10; } @@ -10657,7 +10657,7 @@ static void atkEF_handleballthrow(void) } break; case ITEM_REPEAT_BALL: - if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBattleMoveTarget].species), FLAG_GET_CAUGHT)) + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].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[gBattleMoveTarget].maxHP * 3 - gBattleMons[gBattleMoveTarget].hp * 2) - / (3 * gBattleMons[gBattleMoveTarget].maxHP); + * (gBattleMons[gBattlerTarget].maxHP * 3 - gBattleMons[gBattlerTarget].hp * 2) + / (3 * gBattleMons[gBattlerTarget].maxHP); - if (gBattleMons[gBattleMoveTarget].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) + if (gBattleMons[gBattlerTarget].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) odds *= 2; - if (gBattleMons[gBattleMoveTarget].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)) + if (gBattleMons[gBattlerTarget].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)) odds = (odds * 15) / 10; if (gLastUsedItem != ITEM_SAFARI_BALL) @@ -10703,7 +10703,7 @@ static void atkEF_handleballthrow(void) BtlController_EmitBallThrowAnim(0, BALL_3_SHAKES_SUCCESS); MarkBattlerForControllerExec(gActiveBattler); gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; - SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleMoveTarget]], MON_DATA_POKEBALL, &gLastUsedItem); + SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], MON_DATA_POKEBALL, &gLastUsedItem); if (CalculatePlayerPartyCount() == 6) gBattleCommunication[MULTISTRING_CHOOSER] = 0; @@ -10728,7 +10728,7 @@ static void atkEF_handleballthrow(void) if (shakes == BALL_3_SHAKES_SUCCESS) // mon caught, copy of the code above { gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; - SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleMoveTarget]], MON_DATA_POKEBALL, &gLastUsedItem); + SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]], 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[gBattlerPartyIndexes[gBattleMoveAttacker ^ BIT_SIDE]]) != MON_GIVEN_TO_PARTY) + if (GiveMonToPlayer(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]]) != MON_GIVEN_TO_PARTY) { if (!sub_813B21C()) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN))); - GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2); + GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2); } else { StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN))); - GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gStringVar2); + GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ 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[gBattlerPartyIndexes[gBattleMoveAttacker ^ BIT_SIDE]], MON_DATA_SPECIES, NULL); - GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleResults.caughtMonNick); - gBattleResults.caughtMonBall = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker ^ BIT_SIDE]], MON_DATA_POKEBALL, NULL); + gBattleResults.caughtMonSpecies = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_SPECIES, NULL); + GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleResults.caughtMonNick); + gBattleResults.caughtMonBall = GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_POKEBALL, NULL); gBattlescriptCurrInstr++; } @@ -10804,8 +10804,8 @@ static void atkF2_displaydexinfo(void) { FreeAllWindowBuffers(); gBattleCommunication[TASK_ID] = CreateDexDisplayMonDataTask(SpeciesToNationalPokedexNum(species), - gBattleMons[gBattleMoveTarget].otId, - gBattleMons[gBattleMoveTarget].personality); + gBattleMons[gBattlerTarget].otId, + gBattleMons[gBattlerTarget].personality); gBattleCommunication[0]++; } break; @@ -10956,13 +10956,13 @@ static void atkF3_trygivecaughtmonnick(void) case 2: if (!gPaletteFade.active) { - GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick); + GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick); FreeAllWindowBuffers(); DoNamingScreen(NAMING_SCREEN_CAUGHT_MON, gBattleStruct->caughtMonNick, - GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker ^ BIT_SIDE]], MON_DATA_SPECIES), - GetMonGender(&gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker ^ BIT_SIDE]]), - GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker ^ BIT_SIDE]], MON_DATA_PERSONALITY, NULL), + GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_SPECIES), + GetMonGender(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]]), + GetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ 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[gBattlerPartyIndexes[gBattleMoveAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick); + SetMonData(&gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker ^ BIT_SIDE]], MON_DATA_NICKNAME, gBattleStruct->caughtMonNick); gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } break; @@ -10986,24 +10986,24 @@ static void atkF3_trygivecaughtmonnick(void) static void atkF4_subattackerhpbydmg(void) { - gBattleMons[gBattleMoveAttacker].hp -= gBattleMoveDamage; + gBattleMons[gBattlerAttacker].hp -= gBattleMoveDamage; gBattlescriptCurrInstr++; } static void atkF5_removeattackerstatus1(void) { - gBattleMons[gBattleMoveAttacker].status1 = 0; + gBattleMons[gBattlerAttacker].status1 = 0; gBattlescriptCurrInstr++; } static void atkF6_finishaction(void) { - gCurrentActionFuncId = ACTION_FINISHED; + gCurrentActionFuncId = B_ACTION_FINISHED; } static void atkF7_finishturn(void) { - gCurrentActionFuncId = ACTION_FINISHED; + gCurrentActionFuncId = B_ACTION_FINISHED; gCurrentTurnActionNumber = gBattlersCount; } diff --git a/src/battle_util.c b/src/battle_util.c index 228727585..bbb4bf41d 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -28,13 +28,13 @@ 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 u8 gStringBattler; extern u16 gCurrentMove; extern u16 gLastUsedItem; extern u8 gBattlersCount; extern u32 gStatuses3[MAX_BATTLERS_COUNT]; -extern u8 gBattleMoveAttacker; -extern u8 gBattleMoveTarget; +extern u8 gBattlerAttacker; +extern u8 gBattlerTarget; extern u8 gAbsentBattlerFlags; extern u16 gBattleWeather; extern u8 gBattleTurnOrder[MAX_BATTLERS_COUNT]; @@ -50,7 +50,7 @@ extern u32 gHitMarker; extern u8 gEffectBank; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT]; extern u8 gBank1; -extern u16 gChosenMovesByBanks[MAX_BATTLERS_COUNT]; +extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT]; extern u8 gMoveResultFlags; extern s32 gTakenDmg[MAX_BATTLERS_COUNT]; extern u8 gTakenDmgBanks[MAX_BATTLERS_COUNT]; @@ -79,10 +79,10 @@ u8 GetBattleBank(u8 caseId) switch (caseId) { case BS_GET_TARGET: - ret = gBattleMoveTarget; + ret = gBattlerTarget; break; case BS_GET_ATTACKER: - ret = gBattleMoveAttacker; + ret = gBattlerAttacker; break; case BS_GET_EFFECT_BANK: ret = gEffectBank; @@ -335,17 +335,17 @@ void sub_803FA70(u8 battler) void BattleScriptPush(const u8* bsPtr) { - BATTLESCRIPTS_STACK->ptr[BATTLESCRIPTS_STACK->size++] = bsPtr; + gBattleResources->battleScriptsStack->ptr[gBattleResources->battleScriptsStack->size++] = bsPtr; } void BattleScriptPushCursor(void) { - BATTLESCRIPTS_STACK->ptr[BATTLESCRIPTS_STACK->size++] = gBattlescriptCurrInstr; + gBattleResources->battleScriptsStack->ptr[gBattleResources->battleScriptsStack->size++] = gBattlescriptCurrInstr; } void BattleScriptPop(void) { - gBattlescriptCurrInstr = BATTLESCRIPTS_STACK->ptr[--BATTLESCRIPTS_STACK->size]; + gBattlescriptCurrInstr = gBattleResources->battleScriptsStack->ptr[--gBattleResources->battleScriptsStack->size]; } u8 TrySetCantSelectMoveBattleScript(void) @@ -421,7 +421,7 @@ u8 TrySetCantSelectMoveBattleScript(void) else holdEffect = ItemId_GetHoldEffect(gBattleMons[gActiveBattler].item); - gStringBank = gActiveBattler; + gStringBattler = gActiveBattler; if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != move) { @@ -465,7 +465,7 @@ u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check) else holdEffect = ItemId_GetHoldEffect(gBattleMons[bank].item); - gStringBank = bank; + gStringBattler = bank; for (i = 0; i < MAX_BATTLERS_COUNT; i++) { @@ -536,10 +536,10 @@ u8 UpdateTurnCounters(void) u8 effect = 0; s32 i; - for (gBattleMoveAttacker = 0; gBattleMoveAttacker < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattleMoveAttacker]; gBattleMoveAttacker++) + for (gBattlerAttacker = 0; gBattlerAttacker < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattlerAttacker]; gBattlerAttacker++) { } - for (gBattleMoveTarget = 0; gBattleMoveTarget < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]; gBattleMoveTarget++) + for (gBattlerTarget = 0; gBattlerTarget < gBattlersCount && gAbsentBattlerFlags & gBitTable[gBattlerTarget]; gBattlerTarget++) { } @@ -575,7 +575,7 @@ u8 UpdateTurnCounters(void) while (gBattleStruct->turnSideTracker < 2) { sideBank = gBattleStruct->turnSideTracker; - gActiveBattler = gBattleMoveAttacker = gSideTimers[sideBank].reflectBank; + gActiveBattler = gBattlerAttacker = gSideTimers[sideBank].reflectBank; if (gSideStatuses[sideBank] & SIDE_STATUS_REFLECT) { if (--gSideTimers[sideBank].reflectTimer == 0) @@ -600,7 +600,7 @@ u8 UpdateTurnCounters(void) while (gBattleStruct->turnSideTracker < 2) { sideBank = gBattleStruct->turnSideTracker; - gActiveBattler = gBattleMoveAttacker = gSideTimers[sideBank].lightscreenBank; + gActiveBattler = gBattlerAttacker = gSideTimers[sideBank].lightscreenBank; if (gSideStatuses[sideBank] & SIDE_STATUS_LIGHTSCREEN) { if (--gSideTimers[sideBank].lightscreenTimer == 0) @@ -626,7 +626,7 @@ u8 UpdateTurnCounters(void) while (gBattleStruct->turnSideTracker < 2) { sideBank = gBattleStruct->turnSideTracker; - gActiveBattler = gBattleMoveAttacker = gSideTimers[sideBank].mistBank; + gActiveBattler = gBattlerAttacker = gSideTimers[sideBank].mistBank; if (gSideTimers[sideBank].mistTimer != 0 && --gSideTimers[sideBank].mistTimer == 0) { @@ -650,7 +650,7 @@ u8 UpdateTurnCounters(void) while (gBattleStruct->turnSideTracker < 2) { sideBank = gBattleStruct->turnSideTracker; - gActiveBattler = gBattleMoveAttacker = gSideTimers[sideBank].safeguardBank; + gActiveBattler = gBattlerAttacker = gSideTimers[sideBank].safeguardBank; if (gSideStatuses[sideBank] & SIDE_STATUS_SAFEGUARD) { if (--gSideTimers[sideBank].safeguardTimer == 0) @@ -678,7 +678,7 @@ u8 UpdateTurnCounters(void) && --gWishFutureKnock.wishCounter[gActiveBattler] == 0 && gBattleMons[gActiveBattler].hp != 0) { - gBattleMoveTarget = gActiveBattler; + gBattlerTarget = gActiveBattler; BattleScriptExecute(BattleScript_WishComesTrue); effect++; } @@ -796,7 +796,7 @@ u8 TurnBasedEffects(void) gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_x20); while (gBattleStruct->turnEffectsBank < gBattlersCount && gBattleStruct->turnEffectsTracker <= TURNBASED_MAX_CASE) { - gActiveBattler = gBattleMoveAttacker = gBattleTurnOrder[gBattleStruct->turnEffectsBank]; + gActiveBattler = gBattlerAttacker = gBattleTurnOrder[gBattleStruct->turnEffectsBank]; if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) { gBattleStruct->turnEffectsBank++; @@ -839,12 +839,12 @@ u8 TurnBasedEffects(void) && gBattleMons[gStatuses3[gActiveBattler] & STATUS3_LEECHSEED_BANK].hp != 0 && gBattleMons[gActiveBattler].hp != 0) { - gBattleMoveTarget = gStatuses3[gActiveBattler] & STATUS3_LEECHSEED_BANK; //funny how the 'target' is actually the bank that receives HP + gBattlerTarget = gStatuses3[gActiveBattler] & STATUS3_LEECHSEED_BANK; //funny how the 'target' is actually the bank that receives HP gBattleMoveDamage = gBattleMons[gActiveBattler].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - gBattleScripting.animArg1 = gBattleMoveTarget; - gBattleScripting.animArg2 = gBattleMoveAttacker; + gBattleScripting.animArg1 = gBattlerTarget; + gBattleScripting.animArg2 = gBattlerAttacker; BattleScriptExecute(BattleScript_LeechSeedTurnDrain); effect++; } @@ -953,29 +953,29 @@ u8 TurnBasedEffects(void) case 10: // uproar if (gBattleMons[gActiveBattler].status2 & STATUS2_UPROAR) { - for (gBattleMoveAttacker = 0; gBattleMoveAttacker < gBattlersCount; gBattleMoveAttacker++) + for (gBattlerAttacker = 0; gBattlerAttacker < gBattlersCount; gBattlerAttacker++) { - if ((gBattleMons[gBattleMoveAttacker].status1 & STATUS1_SLEEP) - && gBattleMons[gBattleMoveAttacker].ability != ABILITY_SOUNDPROOF) + if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) + && gBattleMons[gBattlerAttacker].ability != ABILITY_SOUNDPROOF) { - gBattleMons[gBattleMoveAttacker].status1 &= ~(STATUS1_SLEEP); - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattlerAttacker].status1 &= ~(STATUS1_SLEEP); + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_NIGHTMARE); gBattleCommunication[MULTISTRING_CHOOSER] = 1; BattleScriptExecute(BattleScript_MonWokeUpInUproar); - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); break; } } - if (gBattleMoveAttacker != gBattlersCount) + if (gBattlerAttacker != gBattlersCount) { effect = 2; // a pokemon was awaken break; } else { - gBattleMoveAttacker = gActiveBattler; + gBattlerAttacker = gActiveBattler; gBattleMons[gActiveBattler].status2 -= 0x10; // uproar timer goes down if (WasUnableToUseMove(gActiveBattler)) { @@ -1138,16 +1138,16 @@ bool8 HandleWishPerishSongOnTurnEnd(void) PREPARE_MOVE_BUFFER(gBattleTextBuff1, gWishFutureKnock.futureSightMove[gActiveBattler]); - gBattleMoveTarget = gActiveBattler; - gBattleMoveAttacker = gWishFutureKnock.futureSightAttacker[gActiveBattler]; + gBattlerTarget = gActiveBattler; + gBattlerAttacker = gWishFutureKnock.futureSightAttacker[gActiveBattler]; gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBattler]; - gSpecialStatuses[gBattleMoveTarget].moveturnLostHP = 0xFFFF; + gSpecialStatuses[gBattlerTarget].moveturnLostHP = 0xFFFF; BattleScriptExecute(BattleScript_MonTookFutureAttack); if (gWishFutureKnock.futureSightCounter[gActiveBattler] == 0 && gWishFutureKnock.futureSightCounter[gActiveBattler ^ BIT_FLANK] == 0) { - gSideStatuses[GET_BATTLER_SIDE(gBattleMoveTarget)] &= ~(SIDE_STATUS_FUTUREATTACK); + gSideStatuses[GET_BATTLER_SIDE(gBattlerTarget)] &= ~(SIDE_STATUS_FUTUREATTACK); } return TRUE; } @@ -1162,7 +1162,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void) case 1: while (gBattleStruct->wishPerishSongBank < gBattlersCount) { - gActiveBattler = gBattleMoveAttacker = gBattleTurnOrder[gBattleStruct->wishPerishSongBank]; + gActiveBattler = gBattlerAttacker = gBattleTurnOrder[gBattleStruct->wishPerishSongBank]; if (gAbsentBattlerFlags & gBitTable[gActiveBattler]) { gBattleStruct->wishPerishSongBank++; @@ -1240,7 +1240,7 @@ bool8 HandleFaintedMonActions(void) case 1: do { - gBank1 = gBattleMoveTarget = gBattleStruct->faintedActionsBank; + gBank1 = gBattlerTarget = gBattleStruct->faintedActionsBank; if (gBattleMons[gBattleStruct->faintedActionsBank].hp == 0 && !(gBattleStruct->field_DF & gBitTable[gBattlerPartyIndexes[gBattleStruct->faintedActionsBank]]) && !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBank])) @@ -1266,7 +1266,7 @@ bool8 HandleFaintedMonActions(void) case 4: do { - gBank1 = gBattleMoveTarget = gBattleStruct->faintedActionsBank; + gBank1 = gBattlerTarget = gBattleStruct->faintedActionsBank; if (gBattleMons[gBattleStruct->faintedActionsBank].hp == 0 && !(gAbsentBattlerFlags & gBitTable[gBattleStruct->faintedActionsBank])) { @@ -1300,7 +1300,7 @@ void TryClearRageStatuses(void) int i; for (i = 0; i < gBattlersCount; i++) { - if ((gBattleMons[i].status2 & STATUS2_RAGE) && gChosenMovesByBanks[i] != MOVE_RAGE) + if ((gBattleMons[i].status2 & STATUS2_RAGE) && gChosenMoveByBattler[i] != MOVE_RAGE) gBattleMons[i].status2 &= ~(STATUS2_RAGE); } } @@ -1316,17 +1316,17 @@ u8 AtkCanceller_UnableToUseMove(void) switch (gBattleStruct->atkCancellerTracker) { case 0: // flags clear - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_DESTINY_BOND); - gStatuses3[gBattleMoveAttacker] &= ~(STATUS3_GRUDGE); + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_DESTINY_BOND); + gStatuses3[gBattlerAttacker] &= ~(STATUS3_GRUDGE); gBattleStruct->atkCancellerTracker++; break; case 1: // check being asleep - if (gBattleMons[gBattleMoveAttacker].status1 & STATUS1_SLEEP) + if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) { - if (UproarWakeUpCheck(gBattleMoveAttacker)) + if (UproarWakeUpCheck(gBattlerAttacker)) { - gBattleMons[gBattleMoveAttacker].status1 &= ~(STATUS1_SLEEP); - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattlerAttacker].status1 &= ~(STATUS1_SLEEP); + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_NIGHTMARE); BattleScriptPushCursor(); gBattleCommunication[MULTISTRING_CHOOSER] = 1; gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp; @@ -1335,15 +1335,15 @@ u8 AtkCanceller_UnableToUseMove(void) else { u8 toSub; - if (gBattleMons[gBattleMoveAttacker].ability == ABILITY_EARLY_BIRD) + if (gBattleMons[gBattlerAttacker].ability == ABILITY_EARLY_BIRD) toSub = 2; else toSub = 1; - if ((gBattleMons[gBattleMoveAttacker].status1 & STATUS1_SLEEP) < toSub) - gBattleMons[gBattleMoveAttacker].status1 &= ~(STATUS1_SLEEP); + if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) < toSub) + gBattleMons[gBattlerAttacker].status1 &= ~(STATUS1_SLEEP); else - gBattleMons[gBattleMoveAttacker].status1 -= toSub; - if (gBattleMons[gBattleMoveAttacker].status1 & STATUS1_SLEEP) + gBattleMons[gBattlerAttacker].status1 -= toSub; + if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP) { if (gCurrentMove != MOVE_SNORE && gCurrentMove != MOVE_SLEEP_TALK) { @@ -1354,7 +1354,7 @@ u8 AtkCanceller_UnableToUseMove(void) } else { - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_NIGHTMARE); + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_NIGHTMARE); BattleScriptPushCursor(); gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattlescriptCurrInstr = BattleScript_MoveUsedWokeUp; @@ -1365,7 +1365,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 2: // check being frozen - if (gBattleMons[gBattleMoveAttacker].status1 & STATUS1_FREEZE) + if (gBattleMons[gBattlerAttacker].status1 & STATUS1_FREEZE) { if (Random() % 5) { @@ -1382,7 +1382,7 @@ u8 AtkCanceller_UnableToUseMove(void) } else // unfreeze { - gBattleMons[gBattleMoveAttacker].status1 &= ~(STATUS1_FREEZE); + gBattleMons[gBattlerAttacker].status1 &= ~(STATUS1_FREEZE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; gBattleCommunication[MULTISTRING_CHOOSER] = 0; @@ -1392,9 +1392,9 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 3: // truant - if (gBattleMons[gBattleMoveAttacker].ability == ABILITY_TRUANT && gDisableStructs[gBattleMoveAttacker].truantCounter) + if (gBattleMons[gBattlerAttacker].ability == ABILITY_TRUANT && gDisableStructs[gBattlerAttacker].truantCounter) { - CancelMultiTurnMoves(gBattleMoveAttacker); + CancelMultiTurnMoves(gBattlerAttacker); gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround; @@ -1404,11 +1404,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 4: // recharge - if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_RECHARGE) + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_RECHARGE) { - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_RECHARGE); - gDisableStructs[gBattleMoveAttacker].rechargeCounter = 0; - CancelMultiTurnMoves(gBattleMoveAttacker); + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_RECHARGE); + gDisableStructs[gBattlerAttacker].rechargeCounter = 0; + CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedMustRecharge; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1416,11 +1416,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 5: // flinch - if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_FLINCHED) + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_FLINCHED) { - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_FLINCHED); - gProtectStructs[gBattleMoveAttacker].flinchImmobility = 1; - CancelMultiTurnMoves(gBattleMoveAttacker); + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_FLINCHED); + gProtectStructs[gBattlerAttacker].flinchImmobility = 1; + CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedFlinched; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1428,11 +1428,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 6: // disabled move - if (gDisableStructs[gBattleMoveAttacker].disabledMove == gCurrentMove && gDisableStructs[gBattleMoveAttacker].disabledMove != 0) + if (gDisableStructs[gBattlerAttacker].disabledMove == gCurrentMove && gDisableStructs[gBattlerAttacker].disabledMove != 0) { - gProtectStructs[gBattleMoveAttacker].usedDisabledMove = 1; - gBattleScripting.battler = gBattleMoveAttacker; - CancelMultiTurnMoves(gBattleMoveAttacker); + gProtectStructs[gBattlerAttacker].usedDisabledMove = 1; + gBattleScripting.battler = gBattlerAttacker; + CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsDisabled; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1440,10 +1440,10 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 7: // taunt - if (gDisableStructs[gBattleMoveAttacker].tauntTimer1 && gBattleMoves[gCurrentMove].power == 0) + if (gDisableStructs[gBattlerAttacker].tauntTimer1 && gBattleMoves[gCurrentMove].power == 0) { - gProtectStructs[gBattleMoveAttacker].usedTauntedMove = 1; - CancelMultiTurnMoves(gBattleMoveAttacker); + gProtectStructs[gBattlerAttacker].usedTauntedMove = 1; + CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsTaunted; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1451,10 +1451,10 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 8: // imprisoned - if (GetImprisonedMovesCount(gBattleMoveAttacker, gCurrentMove)) + if (GetImprisonedMovesCount(gBattlerAttacker, gCurrentMove)) { - gProtectStructs[gBattleMoveAttacker].usedImprisionedMove = 1; - CancelMultiTurnMoves(gBattleMoveAttacker); + gProtectStructs[gBattlerAttacker].usedImprisionedMove = 1; + CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsImprisoned; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1462,10 +1462,10 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 9: // confusion - if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_CONFUSION) + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_CONFUSION) { - gBattleMons[gBattleMoveAttacker].status2--; - if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_CONFUSION) + gBattleMons[gBattlerAttacker].status2--; + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_CONFUSION) { if (Random() & 1) { @@ -1475,9 +1475,9 @@ u8 AtkCanceller_UnableToUseMove(void) else // confusion dmg { gBattleCommunication[MULTISTRING_CHOOSER] = 1; - gBattleMoveTarget = gBattleMoveAttacker; - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattleMoveAttacker], &gBattleMons[gBattleMoveAttacker], MOVE_POUND, 0, 40, 0, gBattleMoveAttacker, gBattleMoveAttacker); - gProtectStructs[gBattleMoveAttacker].confusionSelfDmg = 1; + gBattlerTarget = gBattlerAttacker; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerAttacker], MOVE_POUND, 0, 40, 0, gBattlerAttacker, gBattlerAttacker); + gProtectStructs[gBattlerAttacker].confusionSelfDmg = 1; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; } gBattlescriptCurrInstr = BattleScript_MoveUsedIsConfused; @@ -1492,11 +1492,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 10: // paralysis - if ((gBattleMons[gBattleMoveAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0) + if ((gBattleMons[gBattlerAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0) { - gProtectStructs[gBattleMoveAttacker].prlzImmobility = 1; + gProtectStructs[gBattlerAttacker].prlzImmobility = 1; // This is removed in Emerald for some reason - //CancelMultiTurnMoves(gBattleMoveAttacker); + //CancelMultiTurnMoves(gBattlerAttacker); gBattlescriptCurrInstr = BattleScript_MoveUsedIsParalyzed; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; effect = 1; @@ -1504,17 +1504,17 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 11: // infatuation - if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_INFATUATION) + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_INFATUATION) { - gBattleScripting.battler = CountTrailingZeroBits((gBattleMons[gBattleMoveAttacker].status2 & STATUS2_INFATUATION) >> 0x10); + gBattleScripting.battler = CountTrailingZeroBits((gBattleMons[gBattlerAttacker].status2 & STATUS2_INFATUATION) >> 0x10); if (Random() & 1) BattleScriptPushCursor(); else { BattleScriptPush(BattleScript_MoveUsedIsParalyzedCantAttack); gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; - gProtectStructs[gBattleMoveAttacker].loveImmobility = 1; - CancelMultiTurnMoves(gBattleMoveAttacker); + gProtectStructs[gBattlerAttacker].loveImmobility = 1; + CancelMultiTurnMoves(gBattlerAttacker); } gBattlescriptCurrInstr = BattleScript_MoveUsedIsInLove; effect = 1; @@ -1522,22 +1522,22 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 12: // bide - if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_BIDE) + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_BIDE) { - gBattleMons[gBattleMoveAttacker].status2 -= 0x100; - if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_BIDE) + gBattleMons[gBattlerAttacker].status2 -= 0x100; + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_BIDE) gBattlescriptCurrInstr = BattleScript_BideStoringEnergy; else { // This is removed in Emerald for some reason - //gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); - if (gTakenDmg[gBattleMoveAttacker]) + //gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); + if (gTakenDmg[gBattlerAttacker]) { gCurrentMove = MOVE_BIDE; - *bideDmg = gTakenDmg[gBattleMoveAttacker] * 2; - gBattleMoveTarget = gTakenDmgBanks[gBattleMoveAttacker]; - if (gAbsentBattlerFlags & gBitTable[gBattleMoveTarget]) - gBattleMoveTarget = GetMoveTarget(MOVE_BIDE, 1); + *bideDmg = gTakenDmg[gBattlerAttacker] * 2; + gBattlerTarget = gTakenDmgBanks[gBattlerAttacker]; + if (gAbsentBattlerFlags & gBitTable[gBattlerTarget]) + gBattlerTarget = GetMoveTarget(MOVE_BIDE, 1); gBattlescriptCurrInstr = BattleScript_BideAttack; } else @@ -1548,11 +1548,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 13: // move thawing - if (gBattleMons[gBattleMoveAttacker].status1 & STATUS1_FREEZE) + if (gBattleMons[gBattlerAttacker].status1 & STATUS1_FREEZE) { if (gBattleMoves[gCurrentMove].effect == EFFECT_THAW_HIT) { - gBattleMons[gBattleMoveAttacker].status1 &= ~(STATUS1_FREEZE); + gBattleMons[gBattlerAttacker].status1 &= ~(STATUS1_FREEZE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -1569,7 +1569,7 @@ u8 AtkCanceller_UnableToUseMove(void) if (effect == 2) { - gActiveBattler = gBattleMoveAttacker; + gActiveBattler = gBattlerAttacker; BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); } @@ -1750,19 +1750,19 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA u32 pidAtk; u32 pidDef; - if (gBattleMoveAttacker >= gBattlersCount) - gBattleMoveAttacker = battler; - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) - pokeAtk = &gPlayerParty[gBattlerPartyIndexes[gBattleMoveAttacker]]; + if (gBattlerAttacker >= gBattlersCount) + gBattlerAttacker = battler; + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) + pokeAtk = &gPlayerParty[gBattlerPartyIndexes[gBattlerAttacker]]; else - pokeAtk = &gEnemyParty[gBattlerPartyIndexes[gBattleMoveAttacker]]; + pokeAtk = &gEnemyParty[gBattlerPartyIndexes[gBattlerAttacker]]; - if (gBattleMoveTarget >= gBattlersCount) - gBattleMoveTarget = battler; - if (GetBattlerSide(gBattleMoveTarget) == B_SIDE_PLAYER) - pokeDef = &gPlayerParty[gBattlerPartyIndexes[gBattleMoveTarget]]; + if (gBattlerTarget >= gBattlersCount) + gBattlerTarget = battler; + if (GetBattlerSide(gBattlerTarget) == B_SIDE_PLAYER) + pokeDef = &gPlayerParty[gBattlerPartyIndexes[gBattlerTarget]]; else - pokeDef = &gEnemyParty[gBattlerPartyIndexes[gBattleMoveTarget]]; + pokeDef = &gEnemyParty[gBattlerPartyIndexes[gBattlerTarget]]; speciesAtk = GetMonData(pokeAtk, MON_DATA_SPECIES); pidAtk = GetMonData(pokeAtk, MON_DATA_PERSONALITY); @@ -1793,8 +1793,8 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA switch (caseID) { case ABILITYEFFECT_ON_SWITCHIN: // 0 - if (gBattleMoveAttacker >= gBattlersCount) - gBattleMoveAttacker = battler; + if (gBattlerAttacker >= gBattlersCount) + gBattlerAttacker = battler; switch (gLastUsedAbility) { case ABILITYEFFECT_SWITCH_IN_WEATHER: @@ -1911,7 +1911,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA case ABILITYEFFECT_ENDTURN: // 1 if (gBattleMons[battler].hp != 0) { - gBattleMoveAttacker = battler; + gBattlerAttacker = battler; switch (gLastUsedAbility) { case ABILITY_RAIN_DISH: @@ -1961,7 +1961,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA } break; case ABILITY_TRUANT: - gDisableStructs[gBattleMoveAttacker].truantCounter ^= 1; + gDisableStructs[gBattlerAttacker].truantCounter ^= 1; break; } } @@ -1976,7 +1976,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA } if (sSoundMovesTable[i] != 0xFFFF) { - if (gBattleMons[gBattleMoveAttacker].status2 & STATUS2_MULTIPLETURNS) + if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) gHitMarker |= HITMARKER_NO_PPDEDUCT; gBattlescriptCurrInstr = BattleScript_SoundproofProtected; effect = 1; @@ -1991,7 +1991,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA case ABILITY_VOLT_ABSORB: if (moveType == TYPE_ELECTRIC && gBattleMoves[move].power != 0) { - if (gProtectStructs[gBattleMoveAttacker].notFirstStrike) + if (gProtectStructs[gBattlerAttacker].notFirstStrike) gBattlescriptCurrInstr = BattleScript_MoveHPDrain; else gBattlescriptCurrInstr = BattleScript_MoveHPDrain_PPLoss; @@ -2002,7 +2002,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA case ABILITY_WATER_ABSORB: if (moveType == TYPE_WATER && gBattleMoves[move].power != 0) { - if (gProtectStructs[gBattleMoveAttacker].notFirstStrike) + if (gProtectStructs[gBattlerAttacker].notFirstStrike) gBattlescriptCurrInstr = BattleScript_MoveHPDrain; else gBattlescriptCurrInstr = BattleScript_MoveHPDrain_PPLoss; @@ -2016,7 +2016,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA if (!(gBattleResources->flags->flags[battler] & UNKNOWN_FLAG_FLASH_FIRE)) { gBattleCommunication[MULTISTRING_CHOOSER] = 0; - if (gProtectStructs[gBattleMoveAttacker].notFirstStrike) + if (gProtectStructs[gBattlerAttacker].notFirstStrike) gBattlescriptCurrInstr = BattleScript_FlashFireBoost; else gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss; @@ -2027,7 +2027,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA else { gBattleCommunication[MULTISTRING_CHOOSER] = 1; - if (gProtectStructs[gBattleMoveAttacker].notFirstStrike) + if (gProtectStructs[gBattlerAttacker].notFirstStrike) gBattlescriptCurrInstr = BattleScript_FlashFireBoost; else gBattlescriptCurrInstr = BattleScript_FlashFireBoost_PPLoss; @@ -2041,7 +2041,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA { if (gBattleMons[battler].maxHP == gBattleMons[battler].hp) { - if ((gProtectStructs[gBattleMoveAttacker].notFirstStrike)) + if ((gProtectStructs[gBattlerAttacker].notFirstStrike)) gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless; else gBattlescriptCurrInstr = BattleScript_MonMadeMoveUseless_PPLoss; @@ -2063,7 +2063,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && move != MOVE_STRUGGLE && gBattleMoves[move].power != 0 - && (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) + && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special) && gBattleMons[battler].type1 != moveType && gBattleMons[battler].type2 != moveType && gBattleMons[battler].hp != 0) @@ -2078,12 +2078,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA break; case ABILITY_ROUGH_SKIN: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBattleMoveAttacker].hp != 0 - && !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg - && (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) + && gBattleMons[gBattlerAttacker].hp != 0 + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)) { - gBattleMoveDamage = gBattleMons[gBattleMoveAttacker].maxHP / 16; + gBattleMoveDamage = gBattleMons[gBattlerAttacker].maxHP / 16; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; BattleScriptPushCursor(); @@ -2093,9 +2093,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA break; case ABILITY_EFFECT_SPORE: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBattleMoveAttacker].hp != 0 - && !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg - && (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) + && gBattleMons[gBattlerAttacker].hp != 0 + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (Random() % 10) == 0) { @@ -2116,9 +2116,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA break; case ABILITY_POISON_POINT: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBattleMoveAttacker].hp != 0 - && !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg - && (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) + && gBattleMons[gBattlerAttacker].hp != 0 + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (Random() % 3) == 0) { @@ -2131,9 +2131,9 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA break; case ABILITY_STATIC: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBattleMoveAttacker].hp != 0 - && !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg - && (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) + && gBattleMons[gBattlerAttacker].hp != 0 + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg + && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (Random() % 3) == 0) { @@ -2146,10 +2146,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA break; case ABILITY_FLAME_BODY: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBattleMoveAttacker].hp != 0 - && !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg + && gBattleMons[gBattlerAttacker].hp != 0 + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) - && (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) + && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special) && (Random() % 3) == 0) { gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_BURN; @@ -2161,19 +2161,19 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA break; case ABILITY_CUTE_CHARM: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gBattleMons[gBattleMoveAttacker].hp != 0 - && !gProtectStructs[gBattleMoveAttacker].confusionSelfDmg + && gBattleMons[gBattlerAttacker].hp != 0 + && !gProtectStructs[gBattlerAttacker].confusionSelfDmg && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) - && (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) - && gBattleMons[gBattleMoveTarget].hp != 0 + && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special) + && gBattleMons[gBattlerTarget].hp != 0 && (Random() % 3) == 0 - && gBattleMons[gBattleMoveAttacker].ability != ABILITY_OBLIVIOUS + && gBattleMons[gBattlerAttacker].ability != ABILITY_OBLIVIOUS && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) - && !(gBattleMons[gBattleMoveAttacker].status2 & STATUS2_INFATUATION) + && !(gBattleMons[gBattlerAttacker].status2 & STATUS2_INFATUATION) && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != MON_GENDERLESS && GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) != MON_GENDERLESS) { - gBattleMons[gBattleMoveAttacker].status2 |= STATUS2_INFATUATED_WITH(gBattleMoveTarget); + gBattleMons[gBattlerAttacker].status2 |= STATUS2_INFATUATED_WITH(gBattlerTarget); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_CuteCharmActivates; effect++; @@ -2288,7 +2288,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON; gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleStruct->synchronizeMoveEffect + MOVE_EFFECT_AFFECTS_USER; - gBattleScripting.battler = gBattleMoveTarget; + gBattleScripting.battler = gBattlerTarget; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; @@ -2304,7 +2304,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON; gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleStruct->synchronizeMoveEffect; - gBattleScripting.battler = gBattleMoveAttacker; + gBattleScripting.battler = gBattlerAttacker; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; @@ -2512,7 +2512,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA void BattleScriptExecute(const u8 *BS_ptr) { gBattlescriptCurrInstr = BS_ptr; - BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size++] = gBattleMainFunc; + gBattleResources->battleCallbackStack->function[gBattleResources->battleCallbackStack->size++] = gBattleMainFunc; gBattleMainFunc = RunBattleScriptCommands_PopCallbacksStack; gCurrentActionFuncId = 0; } @@ -2521,7 +2521,7 @@ void BattleScriptPushCursorAndCallback(const u8 *BS_ptr) { BattleScriptPushCursor(); gBattlescriptCurrInstr = BS_ptr; - BATTLE_CALLBACKS_STACK->function[BATTLE_CALLBACKS_STACK->size++] = gBattleMainFunc; + gBattleResources->battleCallbackStack->function[gBattleResources->battleCallbackStack->size++] = gBattleMainFunc; gBattleMainFunc = RunBattleScriptCommands; } @@ -2556,11 +2556,11 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) bankQuality = ItemId_GetHoldEffectParam(gLastUsedItem); } - atkItem = gBattleMons[gBattleMoveAttacker].item; + atkItem = gBattleMons[gBattlerAttacker].item; if (atkItem == ITEM_ENIGMA_BERRY) { - atkHoldEffect = gEnigmaBerries[gBattleMoveAttacker].holdEffect; - atkQuality = gEnigmaBerries[gBattleMoveAttacker].holdEffectParam; + atkHoldEffect = gEnigmaBerries[gBattlerAttacker].holdEffect; + atkQuality = gEnigmaBerries[gBattlerAttacker].holdEffectParam; } else { @@ -2569,11 +2569,11 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } // def variables are unused - defItem = gBattleMons[gBattleMoveTarget].item; + defItem = gBattleMons[gBattlerTarget].item; if (defItem == ITEM_ENIGMA_BERRY) { - defHoldEffect = gEnigmaBerries[gBattleMoveTarget].holdEffect; - defQuality = gEnigmaBerries[gBattleMoveTarget].holdEffectParam; + defHoldEffect = gEnigmaBerries[gBattlerTarget].holdEffect; + defQuality = gEnigmaBerries[gBattlerTarget].holdEffectParam; } else { @@ -2602,8 +2602,8 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (effect) { gBattleScripting.battler = bank; - gStringBank = bank; - gActiveBattler = gBattleMoveAttacker = bank; + gStringBattler = bank; + gActiveBattler = gBattlerAttacker = bank; BattleScriptExecute(BattleScript_WhiteHerbEnd2); } break; @@ -2673,8 +2673,8 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (effect) { gBattleScripting.battler = bank; - gStringBank = bank; - gActiveBattler = gBattleMoveAttacker = bank; + gStringBattler = bank; + gActiveBattler = gBattlerAttacker = bank; BattleScriptExecute(BattleScript_WhiteHerbEnd2); } break; @@ -3001,8 +3001,8 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (effect) { gBattleScripting.battler = bank; - gStringBank = bank; - gActiveBattler = gBattleMoveAttacker = bank; + gStringBattler = bank; + gActiveBattler = gBattlerAttacker = bank; switch (effect) { case ITEM_STATUS_CHANGE: @@ -3149,7 +3149,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (effect) { gBattleScripting.battler = bank; - gStringBank = bank; + gStringBattler = bank; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_WhiteHerbRet; return effect; // unnecessary return @@ -3159,7 +3159,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) if (effect) { gBattleScripting.battler = bank; - gStringBank = bank; + gStringBattler = bank; gActiveBattler = bank; BtlController_EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBattler].status1); MarkBattlerForControllerExec(gActiveBattler); @@ -3174,10 +3174,10 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) { case HOLD_EFFECT_FLINCH: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_physical || gSpecialStatuses[gBattleMoveTarget].moveturnLostHP_special) + && (gSpecialStatuses[gBattlerTarget].moveturnLostHP_physical || gSpecialStatuses[gBattlerTarget].moveturnLostHP_special) && (Random() % 100) < atkQuality && gBattleMoves[gCurrentMove].flags & FLAG_KINGSROCK_AFFECTED - && gBattleMons[gBattleMoveTarget].hp) + && gBattleMons[gBattlerTarget].hp) { gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_FLINCH; BattleScriptPushCursor(); @@ -3187,19 +3187,19 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) break; case HOLD_EFFECT_SHELL_BELL: if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) - && gSpecialStatuses[gBattleMoveTarget].moveturnLostHP != 0 - && gSpecialStatuses[gBattleMoveTarget].moveturnLostHP != 0xFFFF - && gBattleMoveAttacker != gBattleMoveTarget - && gBattleMons[gBattleMoveAttacker].hp != gBattleMons[gBattleMoveAttacker].maxHP - && gBattleMons[gBattleMoveAttacker].hp != 0) + && gSpecialStatuses[gBattlerTarget].moveturnLostHP != 0 + && gSpecialStatuses[gBattlerTarget].moveturnLostHP != 0xFFFF + && gBattlerAttacker != gBattlerTarget + && gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP + && gBattleMons[gBattlerAttacker].hp != 0) { gLastUsedItem = atkItem; - gStringBank = gBattleMoveAttacker; - gBattleScripting.battler = gBattleMoveAttacker; - gBattleMoveDamage = (gSpecialStatuses[gBattleMoveTarget].moveturnLostHP / atkQuality) * -1; + gStringBattler = gBattlerAttacker; + gBattleScripting.battler = gBattlerAttacker; + gBattleMoveDamage = (gSpecialStatuses[gBattlerTarget].moveturnLostHP / atkQuality) * -1; if (gBattleMoveDamage == 0) gBattleMoveDamage = -1; - gSpecialStatuses[gBattleMoveTarget].moveturnLostHP = 0; + gSpecialStatuses[gBattlerTarget].moveturnLostHP = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret; effect++; @@ -3240,18 +3240,18 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) switch (moveTarget) { case MOVE_TARGET_SELECTED: - side = GetBattlerSide(gBattleMoveAttacker) ^ BIT_SIDE; + side = GetBattlerSide(gBattlerAttacker) ^ BIT_SIDE; if (gSideTimers[side].followmeTimer && gBattleMons[gSideTimers[side].followmeTarget].hp) targetBank = gSideTimers[side].followmeTarget; else { - side = GetBattlerSide(gBattleMoveAttacker); + side = GetBattlerSide(gBattlerAttacker); do { targetBank = Random() % gBattlersCount; - } while (targetBank == gBattleMoveAttacker || side == GetBattlerSide(targetBank) || gAbsentBattlerFlags & gBitTable[targetBank]); + } while (targetBank == gBattlerAttacker || side == GetBattlerSide(targetBank) || gAbsentBattlerFlags & gBitTable[targetBank]); if (gBattleMoves[move].type == TYPE_ELECTRIC - && AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBattleMoveAttacker, ABILITY_LIGHTNING_ROD, 0, 0) + && AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBattlerAttacker, ABILITY_LIGHTNING_ROD, 0, 0) && gBattleMons[targetBank].ability != ABILITY_LIGHTNING_ROD) { targetBank ^= BIT_FLANK; @@ -3264,17 +3264,17 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) case MOVE_TARGET_BOTH: case MOVE_TARGET_FOES_AND_ALLY: case MOVE_TARGET_OPPONENTS_FIELD: - targetBank = GetBattlerAtPosition((GetBattlerPosition(gBattleMoveAttacker) & BIT_SIDE) ^ BIT_SIDE); + targetBank = GetBattlerAtPosition((GetBattlerPosition(gBattlerAttacker) & BIT_SIDE) ^ BIT_SIDE); if (gAbsentBattlerFlags & gBitTable[targetBank]) targetBank ^= BIT_FLANK; break; case MOVE_TARGET_RANDOM: - side = GetBattlerSide(gBattleMoveAttacker) ^ BIT_SIDE; + side = GetBattlerSide(gBattlerAttacker) ^ 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 (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_PLAYER) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_PLAYER) { if (Random() & 1) targetBank = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); @@ -3292,15 +3292,15 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) targetBank ^= BIT_FLANK; } else - targetBank = GetBattlerAtPosition((GetBattlerPosition(gBattleMoveAttacker) & BIT_SIDE) ^ BIT_SIDE); + targetBank = GetBattlerAtPosition((GetBattlerPosition(gBattlerAttacker) & BIT_SIDE) ^ BIT_SIDE); break; case MOVE_TARGET_USER: case MOVE_TARGET_x10: - targetBank = gBattleMoveAttacker; + targetBank = gBattlerAttacker; break; } - *(gBattleStruct->moveTarget + gBattleMoveAttacker) = targetBank; + *(gBattleStruct->moveTarget + gBattlerAttacker) = targetBank; return targetBank; } @@ -3323,18 +3323,18 @@ u8 IsMonDisobedient(void) if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) return 0; - if (GetBattlerSide(gBattleMoveAttacker) == B_SIDE_OPPONENT) + if (GetBattlerSide(gBattlerAttacker) == B_SIDE_OPPONENT) return 0; - if (HasObedientBitSet(gBattleMoveAttacker)) // only if species is Mew or Deoxys + if (HasObedientBitSet(gBattlerAttacker)) // only if species is Mew or Deoxys { - if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattleMoveAttacker) == 2) + if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER && GetBattlerPosition(gBattlerAttacker) == 2) return 0; if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) return 0; if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) return 0; - if (!IsOtherTrainer(gBattleMons[gBattleMoveAttacker].otId, gBattleMons[gBattleMoveAttacker].otName)) + if (!IsOtherTrainer(gBattleMons[gBattlerAttacker].otId, gBattleMons[gBattlerAttacker].otName)) return 0; if (FlagGet(FLAG_BADGE08_GET)) return 0; @@ -3349,27 +3349,27 @@ u8 IsMonDisobedient(void) obedienceLevel = 70; } - if (gBattleMons[gBattleMoveAttacker].level <= obedienceLevel) + if (gBattleMons[gBattlerAttacker].level <= obedienceLevel) return 0; rnd = (Random() & 255); - calc = (gBattleMons[gBattleMoveAttacker].level + obedienceLevel) * rnd >> 8; + calc = (gBattleMons[gBattlerAttacker].level + obedienceLevel) * rnd >> 8; if (calc < obedienceLevel) return 0; // is not obedient if (gCurrentMove == MOVE_RAGE) - gBattleMons[gBattleMoveAttacker].status2 &= ~(STATUS2_RAGE); - if (gBattleMons[gBattleMoveAttacker].status1 & STATUS1_SLEEP && (gCurrentMove == MOVE_SNORE || gCurrentMove == MOVE_SLEEP_TALK)) + gBattleMons[gBattlerAttacker].status2 &= ~(STATUS2_RAGE); + if (gBattleMons[gBattlerAttacker].status1 & STATUS1_SLEEP && (gCurrentMove == MOVE_SNORE || gCurrentMove == MOVE_SLEEP_TALK)) { gBattlescriptCurrInstr = BattleScript_82DB695; return 1; } rnd = (Random() & 255); - calc = (gBattleMons[gBattleMoveAttacker].level + obedienceLevel) * rnd >> 8; + calc = (gBattleMons[gBattlerAttacker].level + obedienceLevel) * rnd >> 8; if (calc < obedienceLevel) { - calc = CheckMoveLimitations(gBattleMoveAttacker, gBitTable[gCurrMovePos], 0xFF); + calc = CheckMoveLimitations(gBattlerAttacker, gBitTable[gCurrMovePos], 0xFF); if (calc == 0xF) // all moves cannot be used { gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3; @@ -3383,19 +3383,19 @@ u8 IsMonDisobedient(void) gCurrMovePos = gUnknown_020241E9 = Random() & 3; } while (gBitTable[gCurrMovePos] & calc); - gRandomMove = gBattleMons[gBattleMoveAttacker].moves[gCurrMovePos]; + gRandomMove = gBattleMons[gBattlerAttacker].moves[gCurrMovePos]; gBattlescriptCurrInstr = BattleScript_IgnoresAndUsesRandomMove; - gBattleMoveTarget = GetMoveTarget(gRandomMove, 0); + gBattlerTarget = GetMoveTarget(gRandomMove, 0); gHitMarker |= HITMARKER_x200000; return 2; } } else { - obedienceLevel = gBattleMons[gBattleMoveAttacker].level - obedienceLevel; + obedienceLevel = gBattleMons[gBattlerAttacker].level - obedienceLevel; calc = (Random() & 255); - if (calc < obedienceLevel && !(gBattleMons[gBattleMoveAttacker].status1 & STATUS1_ANY) && gBattleMons[gBattleMoveAttacker].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gBattleMoveAttacker].ability != ABILITY_INSOMNIA) + if (calc < obedienceLevel && !(gBattleMons[gBattlerAttacker].status1 & STATUS1_ANY) && gBattleMons[gBattlerAttacker].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gBattlerAttacker].ability != ABILITY_INSOMNIA) { // try putting asleep int i; @@ -3413,8 +3413,8 @@ u8 IsMonDisobedient(void) calc -= obedienceLevel; if (calc < obedienceLevel) { - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattleMoveAttacker], &gBattleMons[gBattleMoveAttacker], MOVE_POUND, 0, 40, 0, gBattleMoveAttacker, gBattleMoveAttacker); - gBattleMoveTarget = gBattleMoveAttacker; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBattlerAttacker], &gBattleMons[gBattlerAttacker], MOVE_POUND, 0, 40, 0, gBattlerAttacker, gBattlerAttacker); + gBattlerTarget = gBattlerAttacker; gBattlescriptCurrInstr = BattleScript_82DB6F0; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; return 2; diff --git a/src/pokeball.c b/src/pokeball.c index 87802d6ba..ada0258db 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -17,7 +17,7 @@ extern bool8 gDoingBattleAnim; extern u8 gActiveBattler; -extern u8 gBattleMoveTarget; +extern u8 gBattlerTarget; extern u16 gBattlerPartyIndexes[]; extern u8 gBattlerSpriteIds[]; extern u8 gHealthboxSpriteIds[]; @@ -378,7 +378,7 @@ static void Task_DoPokeballSendOutAnim(u8 taskId) switch (throwCaseId) { case POKEBALL_PLAYER_SENDOUT: - gBattleMoveTarget = bank; + gBattlerTarget = 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 = GetBattlerSpriteCoord(bank, BANK_X_POS); gSprites[ballSpriteId].pos1.y = GetBattlerSpriteCoord(bank, BANK_Y_POS) + 24; - gBattleMoveTarget = bank; + gBattlerTarget = bank; gSprites[ballSpriteId].data[0] = 0; gSprites[ballSpriteId].callback = SpriteCB_OpponentMonSendOut; break; default: - gBattleMoveTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); + gBattlerTarget = GetBattlerAtPosition(B_POSITION_OPPONENT_LEFT); notSendOut = TRUE; break; } - gSprites[ballSpriteId].sBank = gBattleMoveTarget; + gSprites[ballSpriteId].sBank = gBattlerTarget; 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] = GetBattlerSpriteCoord(gBattleMoveTarget, BANK_X_POS); - gSprites[ballSpriteId].data[4] = GetBattlerSpriteCoord(gBattleMoveTarget, BANK_Y_POS) - 16; + gSprites[ballSpriteId].data[2] = GetBattlerSpriteCoord(gBattlerTarget, BANK_X_POS); + gSprites[ballSpriteId].data[4] = GetBattlerSpriteCoord(gBattlerTarget, BANK_Y_POS) - 16; gSprites[ballSpriteId].data[5] = -40; sub_80A68D4(&gSprites[ballSpriteId]); gSprites[ballSpriteId].oam.affineParam = taskId; - gTasks[taskId].tOpponentBank = gBattleMoveTarget; + gTasks[taskId].tOpponentBank = gBattlerTarget; gTasks[taskId].func = TaskDummy; PlaySE(SE_NAGERU); } diff --git a/src/pokemon_2.c b/src/pokemon_2.c index 4e3364486..e484b21a4 100644 --- a/src/pokemon_2.c +++ b/src/pokemon_2.c @@ -16,8 +16,8 @@ struct Unknown_020249B4 extern u8 gAbsentBattlerFlags; extern u8 gActiveBattler; -extern u8 gBattleMoveAttacker; -extern u8 gBattleMoveTarget; +extern u8 gBattlerAttacker; +extern u8 gBattlerTarget; extern u8 gLastUsedAbility; extern u16 gTrainerBattleOpponent_A; extern u32 gBattleTypeFlags; @@ -55,14 +55,14 @@ u8 CountAliveMonsInBattle(u8 caseId) case BATTLE_ALIVE_ATK_SIDE: for (i = 0; i < 4; i++) { - if (GetBattlerSide(i) == GetBattlerSide(gBattleMoveAttacker) && !(gAbsentBattlerFlags & gBitTable[i])) + if (GetBattlerSide(i) == GetBattlerSide(gBattlerAttacker) && !(gAbsentBattlerFlags & gBitTable[i])) retVal++; } break; case BATTLE_ALIVE_DEF_SIDE: for (i = 0; i < 4; i++) { - if (GetBattlerSide(i) == GetBattlerSide(gBattleMoveTarget) && !(gAbsentBattlerFlags & gBitTable[i])) + if (GetBattlerSide(i) == GetBattlerSide(gBattlerTarget) && !(gAbsentBattlerFlags & gBitTable[i])) retVal++; } break; diff --git a/src/pokemon_3.c b/src/pokemon_3.c index e11afa91e..6442679a6 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -27,9 +27,9 @@ extern struct BattlePokemon gBattleMons[4]; extern struct BattleEnigmaBerry gEnigmaBerries[4]; extern u8 gActiveBattler; extern u8 gBankInMenu; -extern u8 gBattleMoveTarget; -extern u8 gBattleMoveAttacker; -extern u8 gStringBank; +extern u8 gBattlerTarget; +extern u8 gBattlerAttacker; +extern u8 gStringBattler; extern u16 gTrainerBattleOpponent_A; extern u32 gBattleTypeFlags; extern u8 gBattleMonForms[4]; @@ -210,7 +210,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit) void sub_806CF24(s32 stat) { - gBattleMoveTarget = gBankInMenu; + gBattlerTarget = gBankInMenu; StringCopy(gBattleTextBuff1, gStatNamesTable[gUnknown_08329EC8[stat]]); StringCopy(gBattleTextBuff2, gText_StatRose); BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnsStatChanged2); @@ -233,7 +233,7 @@ u8 *sub_806CF78(u16 itemId) itemEffect = gItemEffectTable[itemId - 13]; } - gStringBank = gBankInMenu; + gStringBattler = gBankInMenu; for (i = 0; i < 3; i++) { @@ -247,7 +247,7 @@ u8 *sub_806CF78(u16 itemId) } else { - gBattleMoveAttacker = gBankInMenu; + gBattlerAttacker = gBankInMenu; BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnGettingPumped); } } @@ -255,7 +255,7 @@ u8 *sub_806CF78(u16 itemId) if (itemEffect[3] & 0x80) { - gBattleMoveAttacker = gBankInMenu; + gBattlerAttacker = gBankInMenu; BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnShroudedInMist); } diff --git a/src/recorded_battle.c b/src/recorded_battle.c index 34611b509..fc576462b 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -29,7 +29,7 @@ extern u8 gActiveBattler; extern u8 gBattlersCount; extern u16 gBattlerPartyIndexes[MAX_BATTLERS_COUNT]; extern struct BattlePokemon gBattleMons[MAX_BATTLERS_COUNT]; -extern u16 gChosenMovesByBanks[MAX_BATTLERS_COUNT]; +extern u16 gChosenMoveByBattler[MAX_BATTLERS_COUNT]; extern u8 gUnknown_03001278; extern u8 gUnknown_03001279; @@ -221,7 +221,7 @@ void RecordedBattle_ClearBattlerAction(u8 bank, u8 bytesToClear) } } -u8 RecordedBattle_GetBankAction(u8 bank) +u8 RecordedBattle_GetBattlerAction(u8 bank) { // trying to read past array or invalid action byte, battle is over if (sRecordedBytesNo[bank] >= BANK_RECORD_SIZE || sBattleRecords[bank][sRecordedBytesNo[bank]] == 0xFF) @@ -1561,14 +1561,14 @@ void sub_818603C(u8 arg0) u8 array3[8]; u8 var; - RecordedBattle_GetBankAction(bank); + RecordedBattle_GetBattlerAction(bank); for (j = 0; j < 4; j++) { ppBonuses[j] = ((gBattleMons[bank].ppBonuses & ((3 << (j << 1)))) >> (j << 1)); } for (j = 0; j < 4; j++) { - array1[j] = RecordedBattle_GetBankAction(bank); + array1[j] = RecordedBattle_GetBattlerAction(bank); movePp.moves[j] = gBattleMons[bank].moves[array1[j]]; movePp.pp[j] = gBattleMons[bank].pp[array1[j]]; array3[j] = ppBonuses[array1[j]]; @@ -1612,7 +1612,7 @@ void sub_818603C(u8 arg0) SetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_PP_BONUSES, &var); } - gChosenMovesByBanks[bank] = gBattleMons[bank].moves[*(gBattleStruct->chosenMovePositions + bank)]; + gChosenMoveByBattler[bank] = gBattleMons[bank].moves[*(gBattleStruct->chosenMovePositions + bank)]; } } } diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index c1e37a9ac..925b65de5 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -46,8 +46,8 @@ extern u8 GetBattlerSpriteCoord(u8 bank, u8 caseId); // this file's functions static void CB2_ReshowBattleScreenAfterMenu(void); -static bool8 LoadBankSpriteGfx(u8 bank); -static void CreateBankSprite(u8 bank); +static bool8 LoadBattlerSpriteGfx(u8 bank); +static void CreateBattlerSprite(u8 bank); static void CreateHealthboxSprite(u8 bank); static void sub_80A95F4(void); @@ -118,32 +118,32 @@ static void CB2_ReshowBattleScreenAfterMenu(void) } break; case 7: - if (!LoadBankSpriteGfx(0)) + if (!LoadBattlerSpriteGfx(0)) gBattleScripting.reshowMainState--; break; case 8: - if (!LoadBankSpriteGfx(1)) + if (!LoadBattlerSpriteGfx(1)) gBattleScripting.reshowMainState--; break; case 9: - if (!LoadBankSpriteGfx(2)) + if (!LoadBattlerSpriteGfx(2)) gBattleScripting.reshowMainState--; break; case 10: - if (!LoadBankSpriteGfx(3)) + if (!LoadBattlerSpriteGfx(3)) gBattleScripting.reshowMainState--; break; case 11: - CreateBankSprite(0); + CreateBattlerSprite(0); break; case 12: - CreateBankSprite(1); + CreateBattlerSprite(1); break; case 13: - CreateBankSprite(2); + CreateBattlerSprite(2); break; case 14: - CreateBankSprite(3); + CreateBattlerSprite(3); break; case 15: CreateHealthboxSprite(0); @@ -208,25 +208,25 @@ static void sub_80A95F4(void) regBgcnt2->charBaseBlock = 0; } -static bool8 LoadBankSpriteGfx(u8 bank) +static bool8 LoadBattlerSpriteGfx(u8 battler) { - if (bank < gBattlersCount) + if (battler < gBattlersCount) { - if (GetBattlerSide(bank) != B_SIDE_PLAYER) + if (GetBattlerSide(battler) != B_SIDE_PLAYER) { - if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute) - BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[bank]], bank); + if (!gBattleSpritesDataPtr->battlerData[battler].behindSubstitute) + BattleLoadOpponentMonSpriteGfx(&gEnemyParty[gBattlerPartyIndexes[battler]], battler); else - BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE); + BattleLoadSubstituteOrMonSpriteGfx(battler, FALSE); } - else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) - DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, bank); - else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) - DecompressTrainerBackPic(BACK_PIC_WALLY, bank); - else if (!gBattleSpritesDataPtr->bankData[bank].behindSubstitute) - BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[bank]], bank); + else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0) + DecompressTrainerBackPic(gSaveBlock2Ptr->playerGender, battler); + else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0) + DecompressTrainerBackPic(BACK_PIC_WALLY, battler); + else if (!gBattleSpritesDataPtr->battlerData[battler].behindSubstitute) + BattleLoadPlayerMonSpriteGfx(&gPlayerParty[gBattlerPartyIndexes[battler]], battler); else - BattleLoadSubstituteOrMonSpriteGfx(bank, FALSE); + BattleLoadSubstituteOrMonSpriteGfx(battler, FALSE); gBattleScripting.reshowHelperState = 0; } @@ -243,111 +243,111 @@ struct MonCoords }; extern const struct MonCoords gTrainerBackPicCoords[]; -static void CreateBankSprite(u8 bank) +static void CreateBattlerSprite(u8 battler) { - if (bank < gBattlersCount) + if (battler < gBattlersCount) { u8 posY; - if (gBattleSpritesDataPtr->bankData[bank].behindSubstitute) - posY = GetSubstituteSpriteDefault_Y(bank); + if (gBattleSpritesDataPtr->battlerData[battler].behindSubstitute) + posY = GetSubstituteSpriteDefault_Y(battler); else - posY = GetBattlerSpriteDefault_Y(bank); + posY = GetBattlerSpriteDefault_Y(battler); - if (GetBattlerSide(bank) != B_SIDE_PLAYER) + if (GetBattlerSide(battler) != B_SIDE_PLAYER) { - if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) + if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0) return; - sub_806A068(GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); - gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(bank, 2), posY, sub_80A82E4(bank)); - gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; - gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; - gSprites[gBattlerSpriteIds[bank]].data[0] = bank; - gSprites[gBattlerSpriteIds[bank]].data[2] = GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES); + sub_806A068(GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler)); + gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(battler, 2), posY, sub_80A82E4(battler)); + gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler; + gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy; + gSprites[gBattlerSpriteIds[battler]].data[0] = battler; + gSprites[gBattlerSpriteIds[battler]].data[2] = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES); - StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]); - if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_CASTFORM) - gSprites[gBattlerSpriteIds[bank]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM]; + StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], gBattleMonForms[battler]); + if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies == SPECIES_CASTFORM) + gSprites[gBattlerSpriteIds[battler]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM]; } - else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) + else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0) { sub_806A12C(gSaveBlock2Ptr->playerGender, GetBattlerPosition(B_POSITION_PLAYER_LEFT)); - gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50, + gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, 0x50, (8 - gTrainerBackPicCoords[gSaveBlock2Ptr->playerGender].coords) * 4 + 80, sub_80A82E4(0)); - gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; - gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; - gSprites[gBattlerSpriteIds[bank]].data[0] = bank; + gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler; + gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy; + gSprites[gBattlerSpriteIds[battler]].data[0] = battler; } - else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) + else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0) { sub_806A12C(BACK_PIC_WALLY, GetBattlerPosition(0)); - gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, 0x50, + gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, 0x50, (8 - gTrainerBackPicCoords[BACK_PIC_WALLY].coords) * 4 + 80, sub_80A82E4(0)); - gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; - gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; - gSprites[gBattlerSpriteIds[bank]].data[0] = bank; + gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler; + gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy; + gSprites[gBattlerSpriteIds[battler]].data[0] = battler; } else { - if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) + if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0) return; - sub_806A068(GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES), GetBattlerPosition(bank)); - gBattlerSpriteIds[bank] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(bank, 2), posY, sub_80A82E4(bank)); - gSprites[gBattlerSpriteIds[bank]].oam.paletteNum = bank; - gSprites[gBattlerSpriteIds[bank]].callback = SpriteCallbackDummy; - gSprites[gBattlerSpriteIds[bank]].data[0] = bank; - gSprites[gBattlerSpriteIds[bank]].data[2] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_SPECIES); + sub_806A068(GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES), GetBattlerPosition(battler)); + gBattlerSpriteIds[battler] = CreateSprite(&gUnknown_0202499C, GetBattlerSpriteCoord(battler, 2), posY, sub_80A82E4(battler)); + gSprites[gBattlerSpriteIds[battler]].oam.paletteNum = battler; + gSprites[gBattlerSpriteIds[battler]].callback = SpriteCallbackDummy; + gSprites[gBattlerSpriteIds[battler]].data[0] = battler; + gSprites[gBattlerSpriteIds[battler]].data[2] = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_SPECIES); - StartSpriteAnim(&gSprites[gBattlerSpriteIds[bank]], gBattleMonForms[bank]); - if (gBattleSpritesDataPtr->bankData[bank].transformSpecies == SPECIES_CASTFORM) - gSprites[gBattlerSpriteIds[bank]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM]; + StartSpriteAnim(&gSprites[gBattlerSpriteIds[battler]], gBattleMonForms[battler]); + if (gBattleSpritesDataPtr->battlerData[battler].transformSpecies == SPECIES_CASTFORM) + gSprites[gBattlerSpriteIds[battler]].anims = gMonAnimationsSpriteAnimsPtrTable[SPECIES_CASTFORM]; } - gSprites[gBattlerSpriteIds[bank]].invisible = gBattleSpritesDataPtr->bankData[bank].invisible; + gSprites[gBattlerSpriteIds[battler]].invisible = gBattleSpritesDataPtr->battlerData[battler].invisible; } } -static void CreateHealthboxSprite(u8 bank) +static void CreateHealthboxSprite(u8 battler) { - if (bank < gBattlersCount) + if (battler < gBattlersCount) { u8 healthboxSpriteId; - if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && bank == 0) + if (gBattleTypeFlags & BATTLE_TYPE_SAFARI && battler == 0) healthboxSpriteId = CreateSafariPlayerHealthboxSprites(); - else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && bank == 0) + else if (gBattleTypeFlags & BATTLE_TYPE_WALLY_TUTORIAL && battler == 0) return; else - healthboxSpriteId = CreateHealthboxSprites(bank); + healthboxSpriteId = CreateBattlerHealthboxSprites(battler); - gHealthboxSpriteIds[bank] = healthboxSpriteId; - InitBattlerHealthboxCoords(bank); + gHealthboxSpriteIds[battler] = healthboxSpriteId; + InitBattlerHealthboxCoords(battler); SetHealthboxSpriteVisible(healthboxSpriteId); - if (GetBattlerSide(bank) != B_SIDE_PLAYER) - UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gEnemyParty[gBattlerPartyIndexes[bank]], HEALTHBOX_ALL); + if (GetBattlerSide(battler) != B_SIDE_PLAYER) + UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gEnemyParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL); else if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) - UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[gBattlerPartyIndexes[bank]], HEALTHBOX_SAFARI_ALL_TEXT); + UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_SAFARI_ALL_TEXT); else - UpdateHealthboxAttribute(gHealthboxSpriteIds[bank], &gPlayerParty[gBattlerPartyIndexes[bank]], HEALTHBOX_ALL); + UpdateHealthboxAttribute(gHealthboxSpriteIds[battler], &gPlayerParty[gBattlerPartyIndexes[battler]], HEALTHBOX_ALL); - if (GetBattlerPosition(bank) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(bank) == B_POSITION_PLAYER_RIGHT) - DummyBattleInterfaceFunc(gHealthboxSpriteIds[bank], TRUE); + if (GetBattlerPosition(battler) == B_POSITION_OPPONENT_RIGHT || GetBattlerPosition(battler) == B_POSITION_PLAYER_RIGHT) + DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], TRUE); else - DummyBattleInterfaceFunc(gHealthboxSpriteIds[bank], FALSE); + DummyBattleInterfaceFunc(gHealthboxSpriteIds[battler], FALSE); - if (GetBattlerSide(bank) != B_SIDE_PLAYER) + if (GetBattlerSide(battler) != B_SIDE_PLAYER) { - if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) + if (GetMonData(&gEnemyParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0) SetHealthboxSpriteInvisible(healthboxSpriteId); } else if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) { - if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[bank]], MON_DATA_HP) == 0) + if (GetMonData(&gPlayerParty[gBattlerPartyIndexes[battler]], MON_DATA_HP) == 0) SetHealthboxSpriteInvisible(healthboxSpriteId); } } diff --git a/sym_ewram.txt b/sym_ewram.txt index a35bd4bf0..d42ec2ad4 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -333,10 +333,10 @@ gLastUsedItem: @ 2024208 gLastUsedAbility: @ 202420A .space 0x1 -gBattleMoveAttacker: @ 202420B +gBattlerAttacker: @ 202420B .space 0x1 -gBattleMoveTarget: @ 202420C +gBattlerTarget: @ 202420C .space 0x1 gBank1: @ 202420D @@ -345,7 +345,7 @@ gBank1: @ 202420D gEffectBank: @ 202420E .space 0x1 -gStringBank: @ 202420F +gStringBattler: @ 202420F .space 0x1 gAbsentBattlerFlags: @ 2024210 @@ -360,7 +360,7 @@ gMultiHitCounter: @ 2024212 gBattlescriptCurrInstr: @ 2024214 .space 0x8 -gActionForBanks: @ 202421C +gChosenActionByBattler: @ 202421C .space 0x4 gSelectionBattleScripts: @ 2024220 @@ -390,7 +390,7 @@ gLockedMoves: @ 2024268 gLastHitBy: @ 2024270 .space 0x4 -gChosenMovesByBanks: @ 2024274 +gChosenMoveByBattler: @ 2024274 .space 0x8 gMoveResultFlags: @ 202427C @@ -1165,7 +1165,7 @@ gUnknown_0203AB98: @ 203AB98 .include "src/coins.o" .include "src/battle_transition.o" -gAbilitiesPerBank: @ 203ABA4 +gBattlerAbilities: @ 203ABA4 .space 0x4 gStringInfo: @ 203ABA8