From c3c13d0acfa46a54bd05d1c7dcea2955103ac3ad Mon Sep 17 00:00:00 2001 From: camthesaxman Date: Tue, 16 Jan 2018 15:12:38 -0600 Subject: [PATCH] more renaming --- asm/battle_anim_80A5C6C.s | 30 +- asm/battle_anim_80D51AC.s | 2 +- asm/battle_anim_80FE840.s | 32 +- asm/battle_anim_8170478.s | 20 +- asm/battle_frontier_2.s | 2 +- asm/battle_link_817C95C.s | 24 +- asm/contest.s | 8 +- asm/macros/battle_script.inc | 2 +- asm/party_menu.s | 14 +- asm/pokemon_item_effect.s | 4 +- constants/battle_constants.inc | 33 +- data/battle_ai_scripts.s | 52 +- data/battle_scripts_1.s | 136 +- include/battle.h | 158 ++- src/battle_2.c | 286 ++--- src/battle_ai_script_commands.c | 158 +-- src/battle_ai_switch_items.c | 78 +- src/battle_anim.c | 4 +- src/battle_bg.c | 6 +- src/battle_controller_link_opponent.c | 8 +- src/battle_controller_link_partner.c | 4 +- src/battle_controller_opponent.c | 24 +- src/battle_controller_player.c | 32 +- src/battle_controller_player_partner.c | 18 +- src/battle_controller_recorded_opponent.c | 8 +- src/battle_controller_recorded_player.c | 6 +- src/battle_controller_safari.c | 6 +- src/battle_controller_wally.c | 6 +- src/battle_controllers.c | 38 +- src/battle_gfx_sfx_util.c | 44 +- src/battle_interface.c | 16 +- src/battle_message.c | 58 +- src/battle_script_commands.c | 1412 ++++++++++----------- src/battle_setup.c | 14 +- src/battle_util.c | 378 +++--- src/battle_util2.c | 20 +- src/calculate_base_damage.c | 2 +- src/field_poison.c | 2 +- src/pokeball.c | 24 +- src/pokemon_2.c | 14 +- src/pokemon_3.c | 4 +- src/recorded_battle.c | 6 +- src/reshow_battle_screen.c | 12 +- src/safari_zone.c | 6 +- src/tv.c | 20 +- sym_ewram.txt | 8 +- 46 files changed, 1630 insertions(+), 1609 deletions(-) diff --git a/asm/battle_anim_80A5C6C.s b/asm/battle_anim_80A5C6C.s index 1c19805a0..b543a5ec2 100644 --- a/asm/battle_anim_80A5C6C.s +++ b/asm/battle_anim_80A5C6C.s @@ -1830,13 +1830,13 @@ GetBankPosition: @ 80A6A44 .pool thumb_func_end GetBankPosition - thumb_func_start GetBankByIdentity -GetBankByIdentity: @ 80A6A54 + thumb_func_start GetBankByPosition +GetBankByPosition: @ 80A6A54 push {r4,lr} lsls r0, 24 lsrs r3, r0, 24 movs r1, 0 - ldr r0, =gNoOfAllBanks + ldr r0, =gBattleBanksCount ldrb r2, [r0] cmp r1, r2 bcs _080A6A7E @@ -1860,7 +1860,7 @@ _080A6A7E: pop {r1} bx r1 .pool - thumb_func_end GetBankByIdentity + thumb_func_end GetBankByPosition thumb_func_start IsBankSpritePresent IsBankSpritePresent: @ 80A6A90 @@ -3496,7 +3496,7 @@ _080A76F2: cmp r5, 0 beq _080A771A movs r0, 0 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 bl IsAnimBankSpriteVisible @@ -3504,7 +3504,7 @@ _080A76F2: cmp r0, 0 beq _080A771A movs r0, 0 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 adds r0, 0x10 @@ -3514,7 +3514,7 @@ _080A771A: cmp r6, 0 beq _080A7746 movs r0, 0x2 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 bl IsAnimBankSpriteVisible @@ -3522,7 +3522,7 @@ _080A771A: cmp r0, 0 beq _080A7746 movs r0, 0x2 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 adds r1, r0, 0 @@ -3534,7 +3534,7 @@ _080A7746: cmp r7, 0 beq _080A7772 movs r0, 0x1 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 bl IsAnimBankSpriteVisible @@ -3542,7 +3542,7 @@ _080A7746: cmp r0, 0 beq _080A7772 movs r0, 0x1 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 adds r1, r0, 0 @@ -3555,7 +3555,7 @@ _080A7772: cmp r0, 0 beq _080A77A0 movs r0, 0x3 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 bl IsAnimBankSpriteVisible @@ -3563,7 +3563,7 @@ _080A7772: cmp r0, 0 beq _080A77A0 movs r0, 0x3 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 adds r1, r0, 0 @@ -3592,7 +3592,7 @@ sub_80A77B4: @ 80A77B4 push {lr} lsls r0, 24 lsrs r0, 24 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 pop {r1} @@ -4959,7 +4959,7 @@ _080A825C: sub_80A8278: @ 80A8278 push {r4-r6,lr} movs r5, 0 - ldr r0, =gNoOfAllBanks + ldr r0, =gBattleBanksCount ldrb r0, [r0] cmp r5, r0 bge _080A82D2 @@ -4998,7 +4998,7 @@ _080A8286: strb r2, [r0, 0x5] _080A82C8: adds r5, 0x1 - ldr r0, =gNoOfAllBanks + ldr r0, =gBattleBanksCount ldrb r0, [r0] cmp r5, r0 blt _080A8286 diff --git a/asm/battle_anim_80D51AC.s b/asm/battle_anim_80D51AC.s index 3ee1786ad..3b1e9dcce 100755 --- a/asm/battle_anim_80D51AC.s +++ b/asm/battle_anim_80D51AC.s @@ -200,7 +200,7 @@ _080D5320: _080D5324: movs r0, 0x3 _080D5326: - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r4, r0, 24 adds r0, r4, 0 diff --git a/asm/battle_anim_80FE840.s b/asm/battle_anim_80FE840.s index c94826f40..c63918719 100644 --- a/asm/battle_anim_80FE840.s +++ b/asm/battle_anim_80FE840.s @@ -7539,7 +7539,7 @@ sub_8102434: @ 8102434 lsls r0, 24 lsrs r7, r0, 24 movs r4, 0 - ldr r0, =gNoOfAllBanks + ldr r0, =gBattleBanksCount ldrb r0, [r0] cmp r4, r0 bcs _08102490 @@ -7576,7 +7576,7 @@ _08102482: adds r0, r4, 0x1 lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gNoOfAllBanks + ldr r0, =gBattleBanksCount ldrb r0, [r0] cmp r4, r0 bcc _08102448 @@ -7605,7 +7605,7 @@ _081024B2: lsls r0, 24 lsrs r4, r0, 24 _081024C2: - ldr r0, =gNoOfAllBanks + ldr r0, =gBattleBanksCount ldrb r0, [r0] cmp r4, r0 bcc _081024B2 @@ -21049,14 +21049,14 @@ sub_8109198: @ 8109198 cmp r4, r0 bne _081091DE movs r0, 0x2 - bl GetBankByIdentity + bl GetBankByPosition ldrb r1, [r5] lsls r0, 24 lsrs r0, 24 cmp r1, r0 beq _081091D6 movs r0, 0x3 - bl GetBankByIdentity + bl GetBankByPosition ldrb r1, [r5] lsls r0, 24 lsrs r0, 24 @@ -28050,7 +28050,7 @@ sub_810C9E4: @ 810C9E4 ldrh r0, [r4, 0x2] lsls r0, 20 lsrs r0, 24 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r5, r0, 24 adds r0, r5, 0 @@ -33064,7 +33064,7 @@ _0810F212: bne _0810F2B8 _0810F22E: movs r0, 0x1 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r4, r0, 24 adds r7, r4, 0 @@ -33193,7 +33193,7 @@ sub_810F340: @ 810F340 push {r4,r5,lr} adds r5, r0, 0 movs r0, 0x1 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r4, r0, 24 movs r1, 0x3C @@ -33370,7 +33370,7 @@ sub_810F46C: @ 810F46C cmp r0, 0 bne _0810F502 movs r0, 0x1 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r4, r0, 24 adds r6, r4, 0 @@ -33441,7 +33441,7 @@ sub_810F524: @ 810F524 cmp r0, 0 bne _0810F57C movs r0, 0x1 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 adds r4, r0, 0 @@ -43586,7 +43586,7 @@ _08114902: beq _0811492E _08114908: adds r0, r4, 0 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r4, r0, 24 adds r0, r4, 0 @@ -45846,7 +45846,7 @@ sub_8115B0C: @ 8115B0C strh r1, [r0, 0x12] strh r5, [r0, 0x18] movs r4, 0 - ldr r0, =gNoOfAllBanks + ldr r0, =gBattleBanksCount ldrb r1, [r0] mov r9, r3 mov r8, r2 @@ -46650,7 +46650,7 @@ _0811618A: cmp r0, 0x1 bhi _081161DC movs r4, 0 - ldr r5, =gNoOfAllBanks + ldr r5, =gBattleBanksCount ldrb r0, [r5] cmp r4, r0 bcs _081161DC @@ -50065,7 +50065,7 @@ sub_8117E94: @ 8117E94 lsls r0, 24 lsrs r0, 24 ldr r2, =gAnimBankAttacker - ldr r1, =gBankTarget + ldr r1, =gBankDefender ldrb r1, [r1] strb r1, [r2] ldr r2, =gAnimBankTarget @@ -50117,7 +50117,7 @@ sub_8117F10: @ 8117F10 lsls r0, 24 lsrs r0, 24 ldr r2, =gAnimBankTarget - ldr r1, =gBankTarget + ldr r1, =gBankDefender ldrb r1, [r1] strb r1, [r2] bl DestroyAnimVisualTask @@ -52078,7 +52078,7 @@ sub_8118FBC: @ 8118FBC lsls r5, 16 lsrs r5, 16 adds r0, r4, 0 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 ldr r1, =gMonSpritesGfxPtr diff --git a/asm/battle_anim_8170478.s b/asm/battle_anim_8170478.s index a7893ee94..956b30186 100644 --- a/asm/battle_anim_8170478.s +++ b/asm/battle_anim_8170478.s @@ -1283,7 +1283,7 @@ _08170F54: lsls r4, 24 lsrs r4, 24 movs r0, 0x1 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 bl sub_80A82E4 @@ -1335,7 +1335,7 @@ _08170F54: ldr r0, =SpriteCallbackDummy str r0, [r4] movs r0, 0 - bl GetBankByIdentity + bl GetBankByPosition ldr r1, =gBankSpriteIds lsls r0, 24 lsrs r0, 24 @@ -1371,7 +1371,7 @@ sub_8171030: @ 8171030 lsrs r5, r0, 24 ldr r6, =gSprites movs r0, 0 - bl GetBankByIdentity + bl GetBankByPosition ldr r1, =gBankSpriteIds lsls r0, 24 lsrs r0, 24 @@ -1422,7 +1422,7 @@ sub_81710A8: @ 81710A8 lsrs r5, r0, 24 ldr r6, =gSprites movs r0, 0 - bl GetBankByIdentity + bl GetBankByPosition ldr r4, =gBankSpriteIds lsls r0, 24 lsrs r0, 24 @@ -1438,7 +1438,7 @@ sub_81710A8: @ 81710A8 cmp r0, 0 bge _081710F4 movs r0, 0 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 adds r0, r4 @@ -5575,7 +5575,7 @@ sub_817330C: @ 817330C movs r0, 0x1E strh r0, [r4, 0x2E] movs r0, 0x1 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 movs r1, 0 @@ -5587,7 +5587,7 @@ sub_817330C: @ 817330C adds r0, r1 strh r0, [r4, 0x32] movs r0, 0x1 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r0, 24 movs r1, 0x1 @@ -5732,7 +5732,7 @@ sub_817345C: @ 817345C .pool _08173478: movs r0, 0 - bl GetBankByIdentity + bl GetBankByPosition ldr r1, =gAnimBankAttacker strb r0, [r1] movs r0, 0x1 @@ -5740,12 +5740,12 @@ _08173478: .pool _0817348C: movs r0, 0x1 - bl GetBankByIdentity + bl GetBankByPosition ldr r1, =gAnimBankAttacker strb r0, [r1] movs r0, 0 _08173498: - bl GetBankByIdentity + bl GetBankByPosition ldr r1, =gAnimBankTarget strb r0, [r1] _081734A0: diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index 23f870d4d..899b6f5d3 100755 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -21034,7 +21034,7 @@ sub_81A5718: @ 81A5718 b _081A57D8 .pool _081A576C: - ldr r0, =gBattleMoveFlags + ldr r0, =gMoveResultFlags ldrb r1, [r0] movs r0, 0x29 ands r0, r1 diff --git a/asm/battle_link_817C95C.s b/asm/battle_link_817C95C.s index d656946b4..f1a398ad6 100644 --- a/asm/battle_link_817C95C.s +++ b/asm/battle_link_817C95C.s @@ -39,7 +39,7 @@ _0817C988: bl GetBankSide lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gBankTarget + ldr r0, =gBankDefender ldrb r0, [r0] bl GetBankSide lsls r0, 24 @@ -83,7 +83,7 @@ _0817CA10: str r1, [sp, 0x8] cmp r6, 0 bne _0817CA3C - ldr r0, =gBankTarget + ldr r0, =gBankDefender ldrb r0, [r0] lsls r0, 1 adds r0, r2 @@ -94,7 +94,7 @@ _0817CA10: b _0817CA4C .pool _0817CA3C: - ldr r0, =gBankTarget + ldr r0, =gBankDefender ldrb r0, [r0] lsls r0, 1 adds r0, r2 @@ -140,7 +140,7 @@ _0817CA9C: lsls r0, 24 lsrs r0, 25 mov r8, r0 - ldr r0, =gBankTarget + ldr r0, =gBankDefender ldrb r0, [r0] bl GetBankPosition lsls r0, 24 @@ -941,7 +941,7 @@ _0817D3F2: bl _0817E0A6 _0817D3FE: ldr r0, =gBankAttacker - ldr r1, =gBankTarget + ldr r1, =gBankDefender ldrb r0, [r0] ldrb r1, [r1] cmp r0, r1 @@ -2564,7 +2564,7 @@ _0817E122: lsls r0, 24 lsrs r0, 24 mov r9, r0 - ldr r0, =gBankTarget + ldr r0, =gBankDefender ldrb r0, [r0] bl GetBankSide lsls r0, 24 @@ -3249,7 +3249,7 @@ sub_817E684: @ 817E684 bl GetBankSide lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gBankTarget + ldr r0, =gBankDefender ldrb r0, [r0] bl GetBankSide lsls r0, 24 @@ -3714,7 +3714,7 @@ sub_817EA80: @ 817EA80 bl GetBankSide lsls r0, 24 lsrs r4, r0, 24 - ldr r0, =gBankTarget + ldr r0, =gBankDefender ldrb r0, [r0] bl GetBankSide lsls r0, 24 @@ -4291,7 +4291,7 @@ _0817EEF8: bgt _0817EF10 b _0817F1FA _0817EF10: - ldr r0, =gBankTarget + ldr r0, =gBankDefender ldrb r0, [r0] muls r0, r1 adds r0, r5 @@ -4386,7 +4386,7 @@ _0817EF98: mov r10, r3 mov r8, r0 add r7, sp, 0x10 - ldr r4, =gBankTarget + ldr r4, =gBankDefender mov r9, r4 _0817EFC2: lsls r1, r5, 1 @@ -4411,7 +4411,7 @@ _0817EFC2: lsls r0, 24 cmp r0, 0 beq _0817F0B4 - ldr r4, =gSideAffecting + ldr r4, =gSideStatuses mov r1, r9 ldrb r0, [r1] bl GetBankPosition @@ -4545,7 +4545,7 @@ _0817F0D8: movs r7, 0 _0817F0F6: movs r5, 0 - ldr r4, =gBankTarget + ldr r4, =gBankDefender ldr r6, =gEnemyParty ldr r0, =gBankAttacker ldrb r0, [r0] diff --git a/asm/contest.s b/asm/contest.s index c35a29733..48766fb68 100644 --- a/asm/contest.s +++ b/asm/contest.s @@ -1060,7 +1060,7 @@ _080D8004: str r4, [r0] ldr r4, =gBankAttacker strb r2, [r4] - ldr r0, =gBankTarget + ldr r0, =gBankDefender strb r3, [r0] bl sub_80DB0C4 ldr r2, =gBankSpriteIds @@ -13798,7 +13798,7 @@ sub_80DEA20: @ 80DEA20 bl CreateInvisibleSpriteWithCallback ldr r1, =gBankSpriteIds strb r0, [r1, 0x3] - ldr r0, =gBankTarget + ldr r0, =gBankDefender ldrb r0, [r0] adds r0, r1 ldrb r1, [r0] @@ -13905,12 +13905,12 @@ _080DEAD0: .4byte _080DEB60 .4byte _080DEB60 _080DEB54: - ldr r1, =gBankTarget + ldr r1, =gBankDefender movs r0, 0x2 b _080DEB64 .pool _080DEB60: - ldr r1, =gBankTarget + ldr r1, =gBankDefender movs r0, 0x3 _080DEB64: strb r0, [r1] diff --git a/asm/macros/battle_script.inc b/asm/macros/battle_script.inc index a16b59366..c5ffb5abc 100644 --- a/asm/macros/battle_script.inc +++ b/asm/macros/battle_script.inc @@ -1389,7 +1389,7 @@ .endm .macro jumpifmovehadnoeffect jumpptr - jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED, \jumpptr + jumpifbyte COMMON_BITS, gMoveResultFlags, MOVE_RESULT_NO_EFFECT, \jumpptr .endm .macro jumpifbattletype flags, jumpptr diff --git a/asm/party_menu.s b/asm/party_menu.s index 844043a95..5a371d387 100755 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -16060,7 +16060,7 @@ _081B8B1E: lsls r0, 24 lsrs r4, r0, 24 _081B8B24: - ldr r0, =gNoOfAllBanks + ldr r0, =gBattleBanksCount ldrb r0, [r0] cmp r4, r0 bcc _081B8AFC @@ -16228,7 +16228,7 @@ _081B8CBE: bne _081B8CFC movs r5, 0x1 movs r0, 0 - bl GetBankByIdentity + bl GetBankByPosition mov r2, sp ldr r1, =gBattlePartyID lsls r0, 24 @@ -16255,7 +16255,7 @@ _081B8CF0: _081B8CFC: movs r5, 0x2 movs r0, 0 - bl GetBankByIdentity + bl GetBankByPosition mov r1, sp ldr r4, =gBattlePartyID lsls r0, 24 @@ -16264,7 +16264,7 @@ _081B8CFC: ldrh r0, [r0] strb r0, [r1] movs r0, 0x2 - bl GetBankByIdentity + bl GetBankByPosition mov r1, sp lsls r0, 24 lsrs r0, 23 @@ -16344,19 +16344,19 @@ sub_81B8D88: @ 81B8D88 cmp r0, 0 bne _081B8DB0 movs r0, 0 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r4, r0, 24 movs r0, 0x2 b _081B8DBC _081B8DB0: movs r0, 0x1 - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r4, r0, 24 movs r0, 0x3 _081B8DBC: - bl GetBankByIdentity + bl GetBankByPosition lsls r0, 24 lsrs r6, r0, 24 bl sub_81B1250 diff --git a/asm/pokemon_item_effect.s b/asm/pokemon_item_effect.s index 49b205967..fb8ea0d3c 100644 --- a/asm/pokemon_item_effect.s +++ b/asm/pokemon_item_effect.s @@ -124,7 +124,7 @@ _0806BDC4: orrs r1, r0 lsrs r1, 31 str r1, [sp, 0x1C] - ldr r0, =gNoOfAllBanks + ldr r0, =gBattleBanksCount ldr r4, [sp, 0xC] subs r4, 0xD ldrb r0, [r0] @@ -148,7 +148,7 @@ _0806BE3C: ldr r1, [sp, 0x1C] adds r1, 0x2 str r1, [sp, 0x1C] - ldr r0, =gNoOfAllBanks + ldr r0, =gBattleBanksCount ldrb r0, [r0] cmp r1, r0 bge _0806BE70 diff --git a/constants/battle_constants.inc b/constants/battle_constants.inc index c48ff0203..0a5dd1094 100644 --- a/constants/battle_constants.inc +++ b/constants/battle_constants.inc @@ -51,15 +51,15 @@ .set B_POSITION_OPPONENT_RIGHT, 3 @ status 1 - .set STATUS_SLEEP, 0x7 - .set STATUS_POISON, 0x8 - .set STATUS_BURN, 0x10 - .set STATUS_FREEZE, 0x20 - .set STATUS_PARALYSIS, 0x40 - .set STATUS_TOXIC_POISON, 0x80 - .set STATUS_TOXIC_COUNTER, 0xF00 + .set STATUS1_SLEEP, 0x7 + .set STATUS1_POISON, 0x8 + .set STATUS1_BURN, 0x10 + .set STATUS1_FREEZE, 0x20 + .set STATUS1_PARALYSIS, 0x40 + .set STATUS1_TOXIC_POISON, 0x80 + .set STATUS1_TOXIC_COUNTER, 0xF00 - .set STATUS_ANY, STATUS_SLEEP | STATUS_POISON | STATUS_BURN | STATUS_FREEZE | STATUS_PARALYSIS | STATUS_TOXIC_POISON + .set STATUS1_ANY, STATUS1_SLEEP | STATUS1_POISON | STATUS1_BURN | STATUS1_FREEZE | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON @ status 2 .set STATUS2_CONFUSION, 0x00000007 @@ -160,11 +160,12 @@ .set HITMARKER_x8000000, 0x08000000 @ move flags - .set MOVESTATUS_MISSED, 0x1 - .set MOVESTATUS_SUPEREFFECTIVE, 0x2 - .set MOVESTATUS_NOTVERYEFFECTIVE, 0x4 - .set MOVESTATUS_NOTAFFECTED, 0x8 - .set MOVESTATUS_ONEHITKO, 0x10 - .set MOVESTATUS_FAILED, 0x20 - .set MOVESTATUS_ENDURED, 0x40 - .set MOVESTATUS_HUNGON, 0x80 + .set MOVE_RESULT_MISSED, 0x1 + .set MOVE_RESULT_SUPER_EFFECTIVE, 0x2 + .set MOVE_RESULT_NOT_VERY_EFFECTIVE, 0x4 + .set MOVE_RESULT_DOESNT_AFFECT_FOE, 0x8 + .set MOVE_RESULT_ONE_HIT_KO, 0x10 + .set MOVE_RESULT_FAILED, 0x20 + .set MOVE_RESULT_FOE_ENDURED, 0x40 + .set MOVE_RESULT_FOE_HUNG_ON, 0x80 + .set MOVE_RESULT_NO_EFFECT, (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED) diff --git a/data/battle_ai_scripts.s b/data/battle_ai_scripts.s index 2b9b6864b..afe365231 100644 --- a/data/battle_ai_scripts.s +++ b/data/battle_ai_scripts.s @@ -218,7 +218,7 @@ BattleAIScript_82DC2D4: get_ability AI_TARGET if_equal ABILITY_INSOMNIA, Score_Minus10 if_equal ABILITY_VITAL_SPIRIT, Score_Minus10 - if_status AI_TARGET, STATUS_ANY, Score_Minus10 + if_status AI_TARGET, STATUS1_ANY, Score_Minus10 if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 end @@ -237,11 +237,11 @@ BattleAIScript_82DC31A: BattleAIScript_82DC31B: if_status2 AI_TARGET, STATUS2_NIGHTMARE, Score_Minus10 - if_not_status AI_TARGET, STATUS_SLEEP, Score_Minus8 + if_not_status AI_TARGET, STATUS1_SLEEP, Score_Minus8 end BattleAIScript_82DC330: - if_not_status AI_TARGET, STATUS_SLEEP, Score_Minus8 + if_not_status AI_TARGET, STATUS1_SLEEP, Score_Minus8 if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 end @@ -350,7 +350,7 @@ BattleAIScript_82DC48C: if_equal TYPE_POISON, Score_Minus10 get_ability AI_TARGET if_equal ABILITY_IMMUNITY, Score_Minus10 - if_status AI_TARGET, STATUS_ANY, Score_Minus10 + if_status AI_TARGET, STATUS1_ANY, Score_Minus10 if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 end @@ -402,7 +402,7 @@ BattleAIScript_82DC545: if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 get_ability AI_TARGET if_equal ABILITY_LIMBER, Score_Minus10 - if_status AI_TARGET, STATUS_ANY, Score_Minus10 + if_status AI_TARGET, STATUS1_ANY, Score_Minus10 if_side_affecting AI_TARGET, SIDE_STATUS_SAFEGUARD, Score_Minus10 end @@ -428,7 +428,7 @@ BattleAIScript_82DC59D: end BattleAIScript_82DC5A5: - if_not_status AI_USER, STATUS_SLEEP, Score_Minus8 + if_not_status AI_USER, STATUS1_SLEEP, Score_Minus8 end BattleAIScript_82DC5B0: @@ -536,7 +536,7 @@ BattleAIScript_82DC6A9: BattleAIScript_82DC6B4: get_ability AI_TARGET if_equal ABILITY_WATER_VEIL, Score_Minus10 - if_status AI_TARGET, STATUS_ANY, Score_Minus10 + if_status AI_TARGET, STATUS1_ANY, Score_Minus10 if_type_effectiveness AI_EFFECTIVENESS_x0, Score_Minus10 if_type_effectiveness AI_EFFECTIVENESS_x0_5, Score_Minus10 if_type_effectiveness AI_EFFECTIVENESS_x0_25, Score_Minus10 @@ -566,7 +566,7 @@ BattleAIScript_82DC708: end BattleAIScript_82DC713: - if_not_status AI_USER, STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON, Score_Minus10 + if_not_status AI_USER, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, Score_Minus10 end BattleAIScript_82DC71E: @@ -1076,7 +1076,7 @@ BattleAIScript_82DCD3D: score -1 BattleAIScript_82DCD4D: - if_not_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DCD6C + if_not_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DCD6C if_hp_more_than AI_USER, 50, BattleAIScript_82DCD64 if_random_less_than 80, BattleAIScript_82DCD6C @@ -1263,7 +1263,7 @@ BattleAIScript_82DCF22: score -2 BattleAIScript_82DCF32: - if_not_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DCF44 + if_not_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DCF44 if_random_less_than 70, BattleAIScript_82DCF44 score +2 @@ -1520,7 +1520,7 @@ BattleAIScript_82DD228: end BattleAIScript_82DD229: - if_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DD256 + if_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DD256 if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DD256 if_status3 AI_TARGET, STATUS3_PERISH_SONG, BattleAIScript_82DD256 if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD256 @@ -1673,7 +1673,7 @@ BattleAIScript_82DD381: goto BattleAIScript_82DD3E9 BattleAIScript_82DD3B9: - if_not_status AI_TARGET, STATUS_ANY, BattleAIScript_82DD3E1 + if_not_status AI_TARGET, STATUS1_ANY, BattleAIScript_82DD3E1 goto BattleAIScript_82DD3E9 BattleAIScript_82DD3C8: @@ -1722,7 +1722,7 @@ BattleAIScript_82DD430: end BattleAIScript_82DD431: - if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DD4D6 + if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DD4D6 if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD4D6 if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DD4D6 if_hp_more_than AI_USER, 30, BattleAIScript_82DD45E @@ -1901,7 +1901,7 @@ BattleAIScript_82DD582: end BattleAIScript_82DD583: - if_status AI_USER, STATUS_SLEEP, Score_Plus10 + if_status AI_USER, STATUS1_SLEEP, Score_Plus10 score -5 end @@ -1952,8 +1952,8 @@ BattleAIScript_82DD60A: end BattleAIScript_82DD60B: - if_status AI_TARGET, STATUS_ANY, BattleAIScript_82DD621 - if_status_in_party AI_TARGET, STATUS_ANY, BattleAIScript_82DD621 + if_status AI_TARGET, STATUS1_ANY, BattleAIScript_82DD621 + if_status_in_party AI_TARGET, STATUS1_ANY, BattleAIScript_82DD621 score -5 BattleAIScript_82DD621: @@ -2012,7 +2012,7 @@ BattleAIScript_82DD693: BattleAIScript_82DD694: get_protect_count AI_USER if_more_than 1, BattleAIScript_82DD75A - if_status AI_USER, STATUS_TOXIC_POISON, BattleAIScript_82DD751 + if_status AI_USER, STATUS1_TOXIC_POISON, BattleAIScript_82DD751 if_status2 AI_USER, STATUS2_CURSED, BattleAIScript_82DD751 if_status3 AI_USER, STATUS3_PERISH_SONG, BattleAIScript_82DD751 if_status2 AI_USER, STATUS2_INFATUATION, BattleAIScript_82DD751 @@ -2020,7 +2020,7 @@ BattleAIScript_82DD694: if_status3 AI_USER, STATUS3_YAWN, BattleAIScript_82DD751 if_has_move_with_effect AI_TARGET, EFFECT_RESTORE_HP, BattleAIScript_82DD751 if_has_move_with_effect AI_TARGET, EFFECT_DEFENSE_CURL, BattleAIScript_82DD751 - if_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DD730 + if_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DD730 if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DD730 if_status3 AI_TARGET, STATUS3_PERISH_SONG, BattleAIScript_82DD730 if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD730 @@ -2238,7 +2238,7 @@ BattleAIScript_82DD959: end BattleAIScript_82DD95A: - if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DD9FF + if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DD9FF if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DD9FF if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DD9FF if_hp_more_than AI_USER, 30, BattleAIScript_82DD987 @@ -2323,7 +2323,7 @@ BattleAIScript_82DDA2F: goto BattleAIScript_82DDAB4 BattleAIScript_82DDA3D: - if_status AI_TARGET, STATUS_TOXIC_POISON, BattleAIScript_82DDAAC + if_status AI_TARGET, STATUS1_TOXIC_POISON, BattleAIScript_82DDAAC if_status2 AI_TARGET, STATUS2_CURSED, BattleAIScript_82DDAAC if_status3 AI_TARGET, STATUS3_LEECHSEED, BattleAIScript_82DDAAC get_weather @@ -2396,7 +2396,7 @@ BattleAIScript_82DDAF5: end BattleAIScript_82DDAF6: - if_not_status AI_TARGET, STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON, BattleAIScript_82DDB02 + if_not_status AI_TARGET, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, BattleAIScript_82DDB02 score +1 BattleAIScript_82DDB02: @@ -2405,7 +2405,7 @@ BattleAIScript_82DDB02: BattleAIScript_82DDB03: if_type_effectiveness AI_EFFECTIVENESS_x0_25, BattleAIScript_82DDB42 if_type_effectiveness AI_EFFECTIVENESS_x0_5, BattleAIScript_82DDB42 - if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DDB59 + if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DDB59 if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DDB49 if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DDB49 is_first_turn_for AI_USER @@ -2429,7 +2429,7 @@ BattleAIScript_82DDB5B: end BattleAIScript_82DDB5C: - if_status AI_TARGET, STATUS_PARALYSIS, BattleAIScript_82DDB6B + if_status AI_TARGET, STATUS1_PARALYSIS, BattleAIScript_82DDB6B goto BattleAIScript_82DDB6D BattleAIScript_82DDB6B: @@ -2571,7 +2571,7 @@ sItemsTable_82DDC6E: .byte -1 BattleAIScript_82DDC72: - if_status AI_TARGET, STATUS_SLEEP, BattleAIScript_82DDC9D + if_status AI_TARGET, STATUS1_SLEEP, BattleAIScript_82DDC9D if_status2 AI_TARGET, STATUS2_INFATUATION, BattleAIScript_82DDC9D if_status2 AI_TARGET, STATUS2_CONFUSION, BattleAIScript_82DDC9D if_random_less_than 180, BattleAIScript_82DDC9D @@ -2960,7 +2960,7 @@ BattleAIScript_82DDFED: end BattleAIScript_82DDFF5: - if_status AI_USER, STATUS_ANY, BattleAIScript_82DE000 + if_status AI_USER, STATUS1_ANY, BattleAIScript_82DE000 end BattleAIScript_82DE000: @@ -3060,7 +3060,7 @@ BattleAIScript_82DE14A: BattleAIScript_82DE14F: get_ability AI_TARGET if_not_equal ABILITY_GUTS, Score_Minus30_ - if_status AI_TARGET, STATUS_ANY, Score_Minus30_ + if_status AI_TARGET, STATUS1_ANY, Score_Minus30_ if_hp_less_than AI_USER, 91, Score_Minus30_ goto Score_Plus5 diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index c3750bd88..8ab5ea2f1 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -286,7 +286,7 @@ BattleScript_MoveEnd:: end BattleScript_MakeMoveMissed:: - orbyte gBattleMoveFlags, MOVESTATUS_MISSED + orbyte gMoveResultFlags, MOVE_RESULT_MISSED BattleScript_PrintMoveMissed:: attackstring ppreduce @@ -303,9 +303,9 @@ BattleScript_EffectSleep:: attackstring ppreduce jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed - jumpifstatus TARGET, STATUS_SLEEP, BattleScript_AlreadyAsleep + jumpifstatus TARGET, STATUS1_SLEEP, BattleScript_AlreadyAsleep jumpifcantmakeasleep BattleScript_CantMakeAsleep - jumpifstatus TARGET, STATUS_ANY, BattleScript_ButItFailed + jumpifstatus TARGET, STATUS1_ANY, BattleScript_ButItFailed accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE jumpifsideaffecting TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected attackanimation @@ -397,7 +397,7 @@ BattleScript_EffectExplosion:: faintifabilitynotdamp setatkhptozero waitstate - jumpifbyte NO_COMMON_BITS, gBattleMoveFlags, MOVESTATUS_MISSED, BattleScript_82D8B94 + jumpifbyte NO_COMMON_BITS, gMoveResultFlags, MOVE_RESULT_MISSED, BattleScript_82D8B94 call BattleScript_82D8BEA goto BattleScript_82D8B96 BattleScript_82D8B94:: @@ -436,16 +436,16 @@ BattleScript_82D8BCF:: end BattleScript_82D8BEA:: - bicbyte gBattleMoveFlags, MOVESTATUS_MISSED + bicbyte gMoveResultFlags, MOVE_RESULT_MISSED attackanimation waitanimation - orbyte gBattleMoveFlags, MOVESTATUS_MISSED + orbyte gMoveResultFlags, MOVE_RESULT_MISSED return BattleScript_EffectDreamEater:: attackcanceler jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_82D8C0E - jumpifstatus TARGET, STATUS_SLEEP, BattleScript_82D8C18 + jumpifstatus TARGET, STATUS1_SLEEP, BattleScript_82D8C18 BattleScript_82D8C0E:: attackstring ppreduce @@ -487,7 +487,7 @@ BattleScript_EffectMirrorMove:: pause 0x40 trymirrormove ppreduce - orbyte gBattleMoveFlags, MOVESTATUS_FAILED + orbyte gMoveResultFlags, MOVE_RESULT_FAILED printstring STRINGID_MIRRORMOVEFAILED waitmessage 0x40 goto BattleScript_MoveEnd @@ -633,7 +633,7 @@ BattleScript_MultiHitLoop:: jumpifhasnohp ATTACKER, BattleScript_MultiHitEnd jumpifhasnohp TARGET, BattleScript_MultiHitPrintStrings jumpifhalfword EQUAL, gChosenMove, MOVE_SLEEP_TALK, BattleScript_DoMultiHit - jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_MultiHitPrintStrings + jumpifstatus ATTACKER, STATUS1_SLEEP, BattleScript_MultiHitPrintStrings BattleScript_DoMultiHit:: movevaluescleanup copybyte cEFFECT_CHOOSER, sMULTIHIT_EFFECT @@ -656,7 +656,7 @@ BattleScript_DoMultiHit:: addbyte sMULTIHIT_STRING + 4, 0x1 setbyte sMOVEEND_STATE, 0x0 moveend 0x2, 0x10 - jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_ENDURED, BattleScript_MultiHitPrintStrings + jumpifbyte COMMON_BITS, gMoveResultFlags, MOVE_RESULT_FOE_ENDURED, BattleScript_MultiHitPrintStrings decrementmultihit BattleScript_MultiHitLoop goto BattleScript_MultiHitPrintStrings BattleScript_MultiHitNoMoreHits:: @@ -712,9 +712,9 @@ BattleScript_EffectToxic:: ppreduce jumpifability TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed - jumpifstatus TARGET, STATUS_POISON, BattleScript_AlreadyPoisoned - jumpifstatus TARGET, STATUS_TOXIC_POISON, BattleScript_AlreadyPoisoned - jumpifstatus TARGET, STATUS_ANY, BattleScript_ButItFailed + jumpifstatus TARGET, STATUS1_POISON, BattleScript_AlreadyPoisoned + jumpifstatus TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned + jumpifstatus TARGET, STATUS1_ANY, BattleScript_ButItFailed jumpiftype TARGET, TYPE_POISON, BattleScript_NotAffected jumpiftype TARGET, TYPE_STEEL, BattleScript_NotAffected accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE @@ -735,7 +735,7 @@ BattleScript_AlreadyPoisoned:: goto BattleScript_MoveEnd BattleScript_ImmunityProtected:: - copybyte gEffectBank, gBankTarget + copybyte gEffectBank, gBankDefender setbyte cMULTISTRING_CHOOSER, 0x0 call BattleScript_PSNPrevention goto BattleScript_MoveEnd @@ -759,7 +759,7 @@ BattleScript_EffectRest:: attackcanceler attackstring ppreduce - jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_RestIsAlreadyAsleep + jumpifstatus ATTACKER, STATUS1_SLEEP, BattleScript_RestIsAlreadyAsleep jumpifcantmakeasleep BattleScript_RestCantSleep trysetrest BattleScript_AlreadyAtFullHp pause 0x20 @@ -835,7 +835,7 @@ BattleScript_EffectSuperFang:: attackstring ppreduce typecalc - bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE + bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE damagetohalftargethp goto BattleScript_HitFromAtkAnimation @@ -845,7 +845,7 @@ BattleScript_EffectDragonRage:: attackstring ppreduce typecalc - bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE + bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE setword gBattleMoveDamage, 40 adjustsetdamage goto BattleScript_HitFromAtkAnimation @@ -879,19 +879,19 @@ BattleScript_MoveMissedDoDamage:: pause 0x40 resultmessage waitmessage 0x40 - jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_NOTAFFECTED, BattleScript_MoveEnd + jumpifbyte COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_MoveEnd printstring STRINGID_PKMNCRASHED waitmessage 0x40 damagecalc typecalc adjustnormaldamage manipulatedamage ATK80_DMG_HALF_BY_TWO_NOT_MORE_THAN_HALF_MAX_HP - bicbyte gBattleMoveFlags, MOVESTATUS_MISSED + bicbyte gMoveResultFlags, MOVE_RESULT_MISSED orword gHitMarker, HITMARKER_IGNORE_SUBSTITUTE healthbarupdate ATTACKER datahpupdate ATTACKER tryfaintmon ATTACKER, FALSE, NULL - orbyte gBattleMoveFlags, MOVESTATUS_MISSED + orbyte gMoveResultFlags, MOVE_RESULT_MISSED goto BattleScript_MoveEnd BattleScript_EffectMist:: @@ -1012,11 +1012,11 @@ BattleScript_EffectPoison:: ppreduce jumpifability TARGET, ABILITY_IMMUNITY, BattleScript_ImmunityProtected jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed - jumpifstatus TARGET, STATUS_POISON, BattleScript_AlreadyPoisoned - jumpifstatus TARGET, STATUS_TOXIC_POISON, BattleScript_AlreadyPoisoned + jumpifstatus TARGET, STATUS1_POISON, BattleScript_AlreadyPoisoned + jumpifstatus TARGET, STATUS1_TOXIC_POISON, BattleScript_AlreadyPoisoned jumpiftype TARGET, TYPE_POISON, BattleScript_NotAffected jumpiftype TARGET, TYPE_STEEL, BattleScript_NotAffected - jumpifstatus TARGET, STATUS_ANY, BattleScript_ButItFailed + jumpifstatus TARGET, STATUS1_ANY, BattleScript_ButItFailed accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE jumpifsideaffecting TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected attackanimation @@ -1035,8 +1035,8 @@ BattleScript_EffectParalyze:: jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed typecalc jumpifmovehadnoeffect BattleScript_ButItFailed - jumpifstatus TARGET, STATUS_PARALYSIS, BattleScript_AlreadyParalyzed - jumpifstatus TARGET, STATUS_ANY, BattleScript_ButItFailed + jumpifstatus TARGET, STATUS1_PARALYSIS, BattleScript_AlreadyParalyzed + jumpifstatus TARGET, STATUS1_ANY, BattleScript_ButItFailed accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE jumpifsideaffecting TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected attackanimation @@ -1055,7 +1055,7 @@ BattleScript_AlreadyParalyzed:: goto BattleScript_MoveEnd BattleScript_LimberProtected:: - copybyte gEffectBank, gBankTarget + copybyte gEffectBank, gBankDefender setbyte cMULTISTRING_CHOOSER, 0x0 call BattleScript_PRLZPrevention goto BattleScript_MoveEnd @@ -1221,7 +1221,7 @@ BattleScript_EffectLevelDamage:: attackstring ppreduce typecalc - bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE + bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE dmgtolevel adjustsetdamage goto BattleScript_HitFromAtkAnimation @@ -1232,7 +1232,7 @@ BattleScript_EffectPsywave:: attackstring ppreduce typecalc - bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE + bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE psywavedamageeffect adjustsetdamage goto BattleScript_HitFromAtkAnimation @@ -1279,7 +1279,7 @@ BattleScript_EffectPainSplit:: BattleScript_EffectSnore:: attackcanceler - jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_SnoreIsAsleep + jumpifstatus ATTACKER, STATUS1_SLEEP, BattleScript_SnoreIsAsleep attackstring ppreduce goto BattleScript_ButItFailed @@ -1333,7 +1333,7 @@ BattleScript_EffectSketch:: BattleScript_EffectSleepTalk:: attackcanceler - jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_SleepTalkIsAsleep + jumpifstatus ATTACKER, STATUS1_SLEEP, BattleScript_SleepTalkIsAsleep attackstring ppreduce goto BattleScript_ButItFailed @@ -1415,7 +1415,7 @@ BattleScript_TripleKickLoop:: jumpifhasnohp ATTACKER, BattleScript_TripleKickEnd jumpifhasnohp TARGET, BattleScript_TripleKickNoMoreHits jumpifhalfword EQUAL, gChosenMove, MOVE_SLEEP_TALK, BattleScript_DoTripleKickAttack - jumpifstatus ATTACKER, STATUS_SLEEP, BattleScript_TripleKickNoMoreHits + jumpifstatus ATTACKER, STATUS1_SLEEP, BattleScript_TripleKickNoMoreHits BattleScript_DoTripleKickAttack:: accuracycheck BattleScript_TripleKickNoMoreHits, ACC_CURR_MOVE movevaluescleanup @@ -1440,18 +1440,18 @@ BattleScript_DoTripleKickAttack:: waitmessage 0x1 setbyte sMOVEEND_STATE, 0x0 moveend 0x2, 0x10 - jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_ENDURED, BattleScript_TripleKickPrintStrings + jumpifbyte COMMON_BITS, gMoveResultFlags, MOVE_RESULT_FOE_ENDURED, BattleScript_TripleKickPrintStrings decrementmultihit BattleScript_TripleKickLoop goto BattleScript_TripleKickPrintStrings BattleScript_TripleKickNoMoreHits:: pause 0x20 jumpifbyte EQUAL, sMULTIHIT_STRING + 4, 0x0, BattleScript_TripleKickPrintStrings - bicbyte gBattleMoveFlags, MOVESTATUS_MISSED + bicbyte gMoveResultFlags, MOVE_RESULT_MISSED BattleScript_TripleKickPrintStrings:: resultmessage waitmessage 0x40 jumpifbyte EQUAL, sMULTIHIT_STRING + 4, 0x0, BattleScript_TripleKickEnd - jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_NOTAFFECTED, BattleScript_TripleKickEnd + jumpifbyte COMMON_BITS, gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE, BattleScript_TripleKickEnd copyarray gBattleTextBuff1, sMULTIHIT_STRING, 0x6 printstring STRINGID_HITXTIMES waitmessage 0x40 @@ -1487,7 +1487,7 @@ BattleScript_EffectNightmare:: ppreduce jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed jumpifstatus2 TARGET, STATUS2_NIGHTMARE, BattleScript_ButItFailed - jumpifstatus TARGET, STATUS_SLEEP, BattleScript_NightmareWorked + jumpifstatus TARGET, STATUS1_SLEEP, BattleScript_NightmareWorked goto BattleScript_ButItFailed BattleScript_NightmareWorked:: attackanimation @@ -1513,7 +1513,7 @@ BattleScript_EffectCurse:: jumpifstat ATTACKER, NOT_EQUAL, ATK, 0xC, BattleScript_CurseTrySpeed jumpifstat ATTACKER, EQUAL, DEF, 0xC, BattleScript_ButItFailed BattleScript_CurseTrySpeed:: - copybyte gBankTarget, gBankAttacker + copybyte gBankDefender, gBankAttacker setbyte sANIM_TURN, 0x1 attackanimation waitanimation @@ -1534,7 +1534,7 @@ BattleScript_CurseTryDefence:: BattleScript_CurseEnd:: goto BattleScript_MoveEnd BattleScript_GhostCurse:: - jumpifbytenotequal gBankAttacker, gBankTarget, BattleScript_DoGhostCurse + jumpifbytenotequal gBankAttacker, gBankDefender, BattleScript_DoGhostCurse getmovetarget ATTACKER BattleScript_DoGhostCurse:: attackcanceler @@ -1603,7 +1603,7 @@ BattleScript_PerishSongLoop:: jumpifability SCRIPTING_BANK, ABILITY_SOUNDPROOF, BattleScript_PerishSongNotAffected BattleScript_PerishSongLoopIncrement:: addbyte sBANK, 0x1 - jumpifbytenotequal sBANK, gNoOfAllBanks, BattleScript_PerishSongLoop + jumpifbytenotequal sBANK, gBattleBanksCount, BattleScript_PerishSongLoop goto BattleScript_MoveEnd BattleScript_PerishSongNotAffected:: @@ -1748,7 +1748,7 @@ BattleScript_EffectSonicboom:: attackstring ppreduce typecalc - bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE + bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE setword gBattleMoveDamage, 20 adjustsetdamage goto BattleScript_HitFromAtkAnimation @@ -2085,14 +2085,14 @@ BattleScript_ButItFailedPpReduce:: ppreduce BattleScript_ButItFailed:: pause 0x20 - orbyte gBattleMoveFlags, MOVESTATUS_FAILED + orbyte gMoveResultFlags, MOVE_RESULT_FAILED resultmessage waitmessage 0x40 goto BattleScript_MoveEnd BattleScript_NotAffected:: pause 0x20 - orbyte gBattleMoveFlags, MOVESTATUS_NOTAFFECTED + orbyte gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE resultmessage waitmessage 0x40 goto BattleScript_MoveEnd @@ -2204,10 +2204,10 @@ BattleScript_EffectWillOWisp:: attackstring ppreduce jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_ButItFailed - jumpifstatus TARGET, STATUS_BURN, BattleScript_AlreadyBurned + jumpifstatus TARGET, STATUS1_BURN, BattleScript_AlreadyBurned jumpiftype TARGET, TYPE_FIRE, BattleScript_NotAffected jumpifability TARGET, ABILITY_WATER_VEIL, BattleScript_WaterVeilPrevents - jumpifstatus TARGET, STATUS_ANY, BattleScript_ButItFailed + jumpifstatus TARGET, STATUS1_ANY, BattleScript_ButItFailed accuracycheck BattleScript_ButItFailed, ACC_CURR_MOVE jumpifsideaffecting TARGET, SIDE_STATUS_SAFEGUARD, BattleScript_SafeguardProtected attackanimation @@ -2217,7 +2217,7 @@ BattleScript_EffectWillOWisp:: goto BattleScript_MoveEnd BattleScript_WaterVeilPrevents:: - copybyte gEffectBank, gBankTarget + copybyte gEffectBank, gBankDefender setbyte cMULTISTRING_CHOOSER, 0x0 call BattleScript_BRNPrevention goto BattleScript_MoveEnd @@ -2275,7 +2275,7 @@ BattleScript_82DA15A:: goto BattleScript_MoveEnd BattleScript_EffectFacade:: - jumpifstatus ATTACKER, STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON, BattleScript_FacadeDoubleDmg + jumpifstatus ATTACKER, STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON, BattleScript_FacadeDoubleDmg goto BattleScript_EffectHit BattleScript_FacadeDoubleDmg:: @@ -2293,7 +2293,7 @@ BattleScript_EffectFocusPunch:: BattleScript_EffectSmellingsalt:: jumpifstatus2 TARGET, STATUS2_SUBSTITUTE, BattleScript_EffectHit setmoveeffect EFFECT_REMOVE_PARALYSIS | CERTAIN - jumpifstatus TARGET, STATUS_PARALYSIS, BattleScript_SmellingsaltDoubleDmg + jumpifstatus TARGET, STATUS1_PARALYSIS, BattleScript_SmellingsaltDoubleDmg goto BattleScript_EffectHit BattleScript_SmellingsaltDoubleDmg:: @@ -2452,7 +2452,7 @@ BattleScript_EffectBrickBreak:: typecalc adjustnormaldamage jumpifbyte EQUAL, sANIM_TURN, 0x0, BattleScript_BrickBreakAnim - bicbyte gBattleMoveFlags, MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED + bicbyte gMoveResultFlags, MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE BattleScript_BrickBreakAnim:: attackanimation waitanimation @@ -2511,7 +2511,7 @@ BattleScript_EffectEndeavor:: accuracycheck BattleScript_MoveMissedPause, ACC_CURR_MOVE typecalc jumpifmovehadnoeffect BattleScript_HitFromAtkAnimation - bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE + bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE copyword gBattleMoveDamage, gHpDealt adjustsetdamage goto BattleScript_HitFromAtkAnimation @@ -2598,11 +2598,11 @@ BattleScript_EffectTeeterDance:: attackcanceler attackstring ppreduce - setbyte gBankTarget, 0x0 + setbyte gBankDefender, 0x0 BattleScript_TeeterDanceLoop:: movevaluescleanup setmoveeffect EFFECT_CONFUSION - jumpifbyteequal gBankAttacker, gBankTarget, BattleScript_TeeterDanceLoopIncrement + jumpifbyteequal gBankAttacker, gBankDefender, 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 gBankTarget, 0x1 - jumpifbytenotequal gBankTarget, gNoOfAllBanks, BattleScript_TeeterDanceLoop + addbyte gBankDefender, 0x1 + jumpifbytenotequal gBankDefender, gBattleBanksCount, BattleScript_TeeterDanceLoop end BattleScript_TeeterDanceOwnTempoPrevents:: @@ -2706,7 +2706,7 @@ BattleScript_TickleEnd:: BattleScript_CantLowerMultipleStats:: pause 0x20 - orbyte gBattleMoveFlags, MOVESTATUS_FAILED + orbyte gMoveResultFlags, MOVE_RESULT_FAILED printstring STRINGID_STATSWONTDECREASE2 waitmessage 0x40 goto BattleScript_MoveEnd @@ -2792,7 +2792,7 @@ BattleScript_CalmMindEnd:: BattleScript_CantRaiseMultipleStats:: pause 0x20 - orbyte gBattleMoveFlags, MOVESTATUS_FAILED + orbyte gMoveResultFlags, MOVE_RESULT_FAILED printstring STRINGID_STATSWONTINCREASE2 waitmessage 0x40 goto BattleScript_MoveEnd @@ -2935,7 +2935,7 @@ BattleScript_82DA908:: switchinanim GBANK_1, FALSE waitstate switchineffects 5 - jumpifbytenotequal gBank1, gNoOfAllBanks, BattleScript_82DA908 + jumpifbytenotequal gBank1, gBattleBanksCount, BattleScript_82DA908 BattleScript_82DA92C:: end2 @@ -3243,7 +3243,7 @@ BattleScript_DamagingWeatherLoop:: BattleScript_DamagingWeatherLoopIncrement:: jumpifbyte NOT_EQUAL, gBattleOutcome, 0, BattleScript_DamagingWeatherContinuesEnd addbyte gBattleCommunication, 0x1 - jumpifbytenotequal gBattleCommunication, gNoOfAllBanks, BattleScript_DamagingWeatherLoop + jumpifbytenotequal gBattleCommunication, gBattleBanksCount, BattleScript_DamagingWeatherLoop BattleScript_DamagingWeatherContinuesEnd:: bicword gHitMarker, HITMARKER_x20 | HITMARKER_IGNORE_SUBSTITUTE | HITMARKER_x100000 | HITMARKER_GRUDGE end2 @@ -3322,7 +3322,7 @@ BattleScript_BideAttack:: waitmessage 0x40 accuracycheck BattleScript_MoveMissed, ACC_CURR_MOVE typecalc - bicbyte gBattleMoveFlags, MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE + bicbyte gMoveResultFlags, MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE copyword gBattleMoveDamage, sBIDE_DMG adjustsetdamage setbyte sANIM_TURN, 0x1 @@ -3521,7 +3521,7 @@ BattleScript_RapidSpinAway:: BattleScript_WrapFree:: printstring STRINGID_PKMNGOTFREE waitmessage 0x40 - copybyte gBankTarget, sBANK + copybyte gBankDefender, sBANK return BattleScript_LeechSeedFree:: @@ -3564,16 +3564,16 @@ BattleScript_FutureAttackEnd:: moveend 0x1, 0x0 setbyte sMOVEEND_STATE, 0xB moveend 0x2, 0xE - setbyte gBattleMoveFlags, 0 + setbyte gMoveResultFlags, 0 end2 BattleScript_FutureAttackMiss:: pause 0x20 - setbyte gBattleMoveFlags, 0 - orbyte gBattleMoveFlags, MOVESTATUS_FAILED + setbyte gMoveResultFlags, 0 + orbyte gMoveResultFlags, MOVE_RESULT_FAILED resultmessage waitmessage 0x40 - setbyte gBattleMoveFlags, 0 + setbyte gMoveResultFlags, 0 end2 BattleScript_NoMovesLeft:: @@ -4032,7 +4032,7 @@ BattleScript_WeatherFormChanges:: BattleScript_WeatherFormChangesLoop:: trycastformdatachange addbyte sBANK, 0x1 - jumpifbytenotequal sBANK, gNoOfAllBanks, BattleScript_WeatherFormChangesLoop + jumpifbytenotequal sBANK, gBattleBanksCount, BattleScript_WeatherFormChangesLoop return BattleScript_CastformChange:: @@ -4053,7 +4053,7 @@ BattleScript_82DB4B8:: BattleScript_82DB4BE:: pause 0x20 BattleScript_82DB4C1:: - setbyte gBankTarget, 0x0 + setbyte gBankDefender, 0x0 setstatchanger ATK, 1, TRUE BattleScript_82DB4CD:: trygetintimidatetarget BattleScript_82DB51B @@ -4068,7 +4068,7 @@ BattleScript_82DB4CD:: printstring STRINGID_PKMNCUTSATTACKWITH waitmessage 0x40 BattleScript_82DB510:: - addbyte gBankTarget, 0x1 + addbyte gBankDefender, 0x1 goto BattleScript_82DB4CD BattleScript_82DB51B:: return @@ -4117,7 +4117,7 @@ BattleScript_MoveHPDrain:: datahpupdate TARGET printstring STRINGID_PKMNRESTOREDHPUSING waitmessage 0x40 - orbyte gBattleMoveFlags, MOVESTATUS_NOTAFFECTED + orbyte gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE goto BattleScript_MoveEnd BattleScript_MonMadeMoveUseless_PPLoss:: @@ -4127,7 +4127,7 @@ BattleScript_MonMadeMoveUseless:: pause 0x20 printstring STRINGID_PKMNSXMADEYUSELESS waitmessage 0x40 - orbyte gBattleMoveFlags, MOVESTATUS_NOTAFFECTED + orbyte gMoveResultFlags, MOVE_RESULT_DOESNT_AFFECT_FOE goto BattleScript_MoveEnd BattleScript_FlashFireBoost_PPLoss:: @@ -4474,7 +4474,7 @@ BattleScript_82DB887:: waitmessage 0x40 BattleScript_82DB89D:: addbyte gBattleCommunication + 1, 0x1 - jumpifbytenotequal gBattleCommunication + 1, gNoOfAllBanks, BattleScript_82DB887 + jumpifbytenotequal gBattleCommunication + 1, gBattleBanksCount, BattleScript_82DB887 setbyte gBattleCommunication, 0x0 setbyte gBattleCommunication + 1, 0x0 end2 diff --git a/include/battle.h b/include/battle.h index 7b9d8b461..71a25eaa7 100644 --- a/include/battle.h +++ b/include/battle.h @@ -39,15 +39,20 @@ #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) + #define SIDE_PLAYER 0x0 #define SIDE_OPPONENT 0x1 #define BIT_SIDE 0x1 #define BIT_MON 0x2 -#define GET_BANK_POSITION(bank)((gBankPositions[bank])) -#define GET_BANK_SIDE(bank)((GetBankPosition(bank) & BIT_SIDE)) -#define GET_BANK_SIDE2(bank)((GET_BANK_POSITION(bank) & BIT_SIDE)) +#define GET_BANK_POSITION(bank) (gBankPositions[bank]) +#define GET_BANK_SIDE(bank) (GetBankPosition(bank) & BIT_SIDE) +#define GET_BANK_SIDE2(bank) (GET_BANK_POSITION(bank) & BIT_SIDE) + +// Battle Type Flags #define BATTLE_TYPE_DOUBLE 0x0001 #define BATTLE_TYPE_LINK 0x0002 @@ -84,59 +89,66 @@ #define BATTLE_TYPE_FRONTIER (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE | BATTLE_TYPE_PYRAMID) #define BATTLE_TYPE_FRONTIER_NO_PYRAMID (BATTLE_TYPE_BATTLE_TOWER | BATTLE_TYPE_DOME | BATTLE_TYPE_PALACE | BATTLE_TYPE_ARENA | BATTLE_TYPE_FACTORY | BATTLE_TYPE_PIKE) +extern u32 gBattleTypeFlags; + #define TRAINER_OPPONENT_3FE 0x3FE #define TRAINER_OPPONENT_C00 0xC00 #define TRAINER_OPPONENT_800 0x800 #define STEVEN_PARTNER_ID 0xC03 #define SECRET_BASE_OPPONENT 0x400 -#define BATTLE_WON 0x1 -#define BATTLE_LOST 0x2 -#define BATTLE_DREW 0x3 -#define BATTLE_RAN 0x4 -#define BATTLE_PLAYER_TELEPORTED 0x5 -#define BATTLE_POKE_FLED 0x6 -#define BATTLE_CAUGHT 0x7 -#define BATTLE_SAFARI_OUT_OF_BALLS 0x8 -#define BATTLE_FORFEITED 0x9 -#define BATTLE_OPPONENT_TELEPORTED 0xA +#define B_OUTCOME_WON 0x1 +#define B_OUTCOME_LOST 0x2 +#define B_OUTCOME_DREW 0x3 +#define B_OUTCOME_RAN 0x4 +#define B_OUTCOME_PLAYER_TELEPORTED 0x5 +#define B_OUTCOME_POKE_FLED 0x6 +#define B_OUTCOME_CAUGHT_POKE 0x7 +#define B_OUTCOME_NO_SAFARI_BALLS 0x8 +#define B_OUTCOME_FORFEITED 0x9 +#define B_OUTCOME_POKE_TELEPORTED 0xA +#define B_OUTCOME_LINK_BATTLE_RAN 0x80 -#define OUTCOME_LINK_BATTLE_RUN 0x80 +extern u8 gBattleOutcome; -#define STATUS_NONE 0x0 -#define STATUS_SLEEP 0x7 -#define STATUS_POISON 0x8 -#define STATUS_BURN 0x10 -#define STATUS_FREEZE 0x20 -#define STATUS_PARALYSIS 0x40 -#define STATUS_TOXIC_POISON 0x80 -#define STATUS_TOXIC_COUNTER 0xF00 +// Non-volatile status conditions +// These persist remain outside of battle and after switching out +#define STATUS1_NONE 0x0 +#define STATUS1_SLEEP 0x7 +#define STATUS1_POISON 0x8 +#define STATUS1_BURN 0x10 +#define STATUS1_FREEZE 0x20 +#define STATUS1_PARALYSIS 0x40 +#define STATUS1_TOXIC_POISON 0x80 +#define STATUS1_TOXIC_COUNTER 0xF00 +#define STATUS1_PSN_ANY (STATUS1_POISON | STATUS1_TOXIC_POISON) +#define STATUS1_ANY (STATUS1_SLEEP | STATUS1_POISON | STATUS1_BURN | STATUS1_FREEZE | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON) -#define STATUS_PSN_ANY ((STATUS_POISON | STATUS_TOXIC_POISON)) -#define STATUS_ANY ((STATUS_SLEEP | STATUS_POISON | STATUS_BURN | STATUS_FREEZE | STATUS_PARALYSIS | STATUS_TOXIC_POISON)) - -#define STATUS2_CONFUSION 0x00000007 -#define STATUS2_FLINCHED 0x00000008 -#define STATUS2_UPROAR 0x00000070 -#define STATUS2_BIDE 0x00000300 // two bits 0x100, 0x200 -#define STATUS2_LOCK_CONFUSE 0x00000C00 -#define STATUS2_MULTIPLETURNS 0x00001000 -#define STATUS2_WRAPPED 0x0000E000 -#define STATUS2_INFATUATION 0x000F0000 // 4 bits, one for every bank -#define STATUS2_INFATUATED_WITH(bank)((gBitTable[bank] << 16)) -#define STATUS2_FOCUS_ENERGY 0x00100000 -#define STATUS2_TRANSFORMED 0x00200000 -#define STATUS2_RECHARGE 0x00400000 -#define STATUS2_RAGE 0x00800000 -#define STATUS2_SUBSTITUTE 0x01000000 -#define STATUS2_DESTINY_BOND 0x02000000 -#define STATUS2_ESCAPE_PREVENTION 0x04000000 -#define STATUS2_NIGHTMARE 0x08000000 -#define STATUS2_CURSED 0x10000000 -#define STATUS2_FORESIGHT 0x20000000 -#define STATUS2_DEFENSE_CURL 0x40000000 -#define STATUS2_TORMENT 0x80000000 +// Volatile status ailments +// These are removed after exiting the battle or switching out +#define STATUS2_CONFUSION 0x00000007 +#define STATUS2_FLINCHED 0x00000008 +#define STATUS2_UPROAR 0x00000070 +#define STATUS2_BIDE 0x00000300 // two bits 0x100, 0x200 +#define STATUS2_LOCK_CONFUSE 0x00000C00 +#define STATUS2_MULTIPLETURNS 0x00001000 +#define STATUS2_WRAPPED 0x0000E000 +#define STATUS2_INFATUATION 0x000F0000 // 4 bits, one for every bank +#define STATUS2_INFATUATED_WITH(bank) (gBitTable[bank] << 16) +#define STATUS2_FOCUS_ENERGY 0x00100000 +#define STATUS2_TRANSFORMED 0x00200000 +#define STATUS2_RECHARGE 0x00400000 +#define STATUS2_RAGE 0x00800000 +#define STATUS2_SUBSTITUTE 0x01000000 +#define STATUS2_DESTINY_BOND 0x02000000 +#define STATUS2_ESCAPE_PREVENTION 0x04000000 +#define STATUS2_NIGHTMARE 0x08000000 +#define STATUS2_CURSED 0x10000000 +#define STATUS2_FORESIGHT 0x20000000 +#define STATUS2_DEFENSE_CURL 0x40000000 +#define STATUS2_TORMENT 0x80000000 +// Seems like per-bank statuses. Not quite sure how to categorize these #define STATUS3_LEECHSEED_BANK 0x3 #define STATUS3_LEECHSEED 0x4 #define STATUS3_ALWAYS_HITS 0x18 // two bits @@ -155,8 +167,11 @@ #define STATUS3_UNDERWATER 0x40000 #define STATUS3_INTIMIDATE_POKES 0x80000 #define STATUS3_TRACE 0x100000 +#define STATUS3_SEMI_INVULNERABLE (STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER) -#define STATUS3_SEMI_INVULNERABLE ((STATUS3_UNDERGROUND | STATUS3_ON_AIR | STATUS3_UNDERWATER)) +extern u32 gStatuses3[BATTLE_BANKS_COUNT]; + +// #define HITMARKER_x10 0x00000010 #define HITMARKER_x20 0x00000020 @@ -182,8 +197,12 @@ #define HITMARKER_OBEYS 0x02000000 #define HITMARKER_x4000000 0x04000000 #define HITMARKER_x8000000 0x08000000 -#define HITMARKER_FAINTED(bank) ((gBitTable[bank] << 0x1C)) -#define HITMARKER_UNK(bank) ((0x10000000 << bank)) +#define HITMARKER_FAINTED(bank) (gBitTable[bank] << 0x1C) +#define HITMARKER_UNK(bank) (0x10000000 << bank) + +extern u32 gHitMarker; + +// Per-side statuses that affect an entire party #define SIDE_STATUS_REFLECT (1 << 0) #define SIDE_STATUS_LIGHTSCREEN (1 << 1) @@ -194,6 +213,8 @@ #define SIDE_STATUS_MIST (1 << 8) #define SIDE_STATUS_SPIKES_DAMAGED (1 << 9) +extern u16 gSideStatuses[2]; + #define ACTION_USE_MOVE 0 #define ACTION_USE_ITEM 1 #define ACTION_SWITCH 2 @@ -210,33 +231,36 @@ #define ACTION_NOTHING_FAINTED 13 // when choosing an action #define ACTION_INIT_VALUE 0xFF -#define MOVESTATUS_MISSED (1 << 0) -#define MOVESTATUS_SUPEREFFECTIVE (1 << 1) -#define MOVESTATUS_NOTVERYEFFECTIVE (1 << 2) -#define MOVESTATUS_NOTAFFECTED (1 << 3) -#define MOVESTATUS_ONEHITKO (1 << 4) -#define MOVESTATUS_FAILED (1 << 5) -#define MOVESTATUS_ENDURED (1 << 6) -#define MOVESTATUS_HUNGON (1 << 7) - -#define MOVESTATUS_NOEFFECT ((MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED)) +#define MOVE_RESULT_MISSED (1 << 0) +#define MOVE_RESULT_SUPER_EFFECTIVE (1 << 1) +#define MOVE_RESULT_NOT_VERY_EFFECTIVE (1 << 2) +#define MOVE_RESULT_DOESNT_AFFECT_FOE (1 << 3) +#define MOVE_RESULT_ONE_HIT_KO (1 << 4) +#define MOVE_RESULT_FAILED (1 << 5) +#define MOVE_RESULT_FOE_ENDURED (1 << 6) +#define MOVE_RESULT_FOE_HUNG_ON (1 << 7) +#define MOVE_RESULT_NO_EFFECT (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED) #define MAX_TRAINER_ITEMS 4 #define MAX_MON_MOVES 4 +// Battle Weather flags + #define WEATHER_RAIN_TEMPORARY (1 << 0) -#define WEATHER_RAIN_DOWNPOUR (1 << 1) +#define WEATHER_RAIN_DOWNPOUR (1 << 1) // unused #define WEATHER_RAIN_PERMANENT (1 << 2) -#define WEATHER_RAIN_ANY ((WEATHER_RAIN_TEMPORARY | WEATHER_RAIN_DOWNPOUR | WEATHER_RAIN_PERMANENT)) +#define WEATHER_RAIN_ANY (WEATHER_RAIN_TEMPORARY | WEATHER_RAIN_DOWNPOUR | WEATHER_RAIN_PERMANENT) #define WEATHER_SANDSTORM_TEMPORARY (1 << 3) #define WEATHER_SANDSTORM_PERMANENT (1 << 4) -#define WEATHER_SANDSTORM_ANY ((WEATHER_SANDSTORM_TEMPORARY | WEATHER_SANDSTORM_PERMANENT)) +#define WEATHER_SANDSTORM_ANY (WEATHER_SANDSTORM_TEMPORARY | WEATHER_SANDSTORM_PERMANENT) #define WEATHER_SUN_TEMPORARY (1 << 5) #define WEATHER_SUN_PERMANENT (1 << 6) -#define WEATHER_SUN_ANY ((WEATHER_SUN_TEMPORARY | WEATHER_SUN_PERMANENT)) +#define WEATHER_SUN_ANY (WEATHER_SUN_TEMPORARY | WEATHER_SUN_PERMANENT) #define WEATHER_HAIL (1 << 7) -#define WEATHER_HAIL_ANY ((WEATHER_HAIL)) -#define WEATHER_ANY ((WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_SUN_ANY | WEATHER_HAIL_ANY)) +#define WEATHER_HAIL_ANY (WEATHER_HAIL) +#define WEATHER_ANY (WEATHER_RAIN_ANY | WEATHER_SANDSTORM_ANY | WEATHER_SUN_ANY | WEATHER_HAIL_ANY) + +extern u16 gBattleWeather; #define BATTLE_TERRAIN_GRASS 0 #define BATTLE_TERRAIN_LONG_GRASS 1 @@ -249,6 +273,8 @@ #define BATTLE_TERRAIN_BUILDING 8 #define BATTLE_TERRAIN_PLAIN 9 +extern u8 gBattleTerrain; + // array entries for battle communication #define MULTIUSE_STATE 0x0 #define CURSOR_POSITION 0x1 @@ -847,7 +873,7 @@ enum // rom_80A5C6C u8 GetBankSide(u8 bank); u8 GetBankPosition(u8 bank); -u8 GetBankByIdentity(u8 bank); +u8 GetBankByPosition(u8 bank); struct BattleSpriteInfo { diff --git a/src/battle_2.c b/src/battle_2.c index 78f577fda..b19dcace1 100644 --- a/src/battle_2.c +++ b/src/battle_2.c @@ -111,14 +111,14 @@ extern u16 gBattleWeather; extern u16 gPauseCounterBattle; extern u16 gRandomTurnNumber; extern u8 gActiveBank; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern u8 gBankAttacker; -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gLeveledUpInBattle; extern u8 gAbsentBankFlags; extern u32 gBattleExecBuffer; extern u8 gMultiHitCounter; -extern u8 gBattleMoveFlags; +extern u8 gMoveResultFlags; extern s32 gBattleMoveDamage; extern const u8* gPalaceSelectionBattleScripts[BATTLE_BANKS_COUNT]; extern u16 gLastPrintedMoves[BATTLE_BANKS_COUNT]; @@ -130,7 +130,7 @@ extern u16 gLockedMoves[BATTLE_BANKS_COUNT]; extern u8 gLastHitBy[BATTLE_BANKS_COUNT]; extern u8 gUnknown_02024284[BATTLE_BANKS_COUNT]; extern u32 gStatuses3[BATTLE_BANKS_COUNT]; -extern u16 gSideAffecting[2]; +extern u16 gSideStatuses[2]; extern u16 gCurrentMove; extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT]; @@ -291,16 +291,16 @@ static void (* const sTurnActionsFuncsTable[])(void) = static void (* const sEndTurnFuncsTable[])(void) = { HandleEndTurn_ContinueBattle, // battle outcome 0 - HandleEndTurn_BattleWon, // BATTLE_WON - HandleEndTurn_BattleLost, // BATTLE_LOST - HandleEndTurn_BattleLost, // BATTLE_DREW - HandleEndTurn_RanFromBattle, // BATTLE_RAN - HandleEndTurn_FinishBattle, // BATTLE_PLAYER_TELEPORTED - HandleEndTurn_MonFled, // BATTLE_POKE_FLED - HandleEndTurn_FinishBattle, // BATTLE_CAUGHT + HandleEndTurn_BattleWon, // B_OUTCOME_WON + HandleEndTurn_BattleLost, // B_OUTCOME_LOST + HandleEndTurn_BattleLost, // B_OUTCOME_DREW + HandleEndTurn_RanFromBattle, // B_OUTCOME_RAN + HandleEndTurn_FinishBattle, // B_OUTCOME_PLAYER_TELEPORTED + HandleEndTurn_MonFled, // B_OUTCOME_POKE_FLED + HandleEndTurn_FinishBattle, // B_OUTCOME_CAUGHT_POKE HandleEndTurn_FinishBattle, // battle outcome 8 - HandleEndTurn_FinishBattle, // BATTLE_FORFEITED - HandleEndTurn_FinishBattle, // BATTLE_OPPONENT_TELEPORTED + HandleEndTurn_FinishBattle, // B_OUTCOME_FORFEITED + HandleEndTurn_FinishBattle, // B_OUTCOME_POKE_TELEPORTED }; const u8 gStatusConditionString_PoisonJpn[8] = _("どく$$$$$"); @@ -1586,7 +1586,7 @@ void BattleMainCB2(void) if (gMain.heldKeys & B_BUTTON && gBattleTypeFlags & BATTLE_TYPE_RECORDED && sub_8186450()) { - gSpecialVar_Result = gBattleOutcome = BATTLE_PLAYER_TELEPORTED; + gSpecialVar_Result = gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; ResetPaletteFadeControl(); BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); SetMainCallback2(CB2_QuitRecordedBattle); @@ -2720,7 +2720,7 @@ static void BattleMainCB1(void) { gBattleMainFunc(); - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) gBattleBankFunc[gActiveBank](); } @@ -2756,7 +2756,7 @@ static void BattleStartClearSetData(void) for (i = 0; i < 2; i++) { - gSideAffecting[i] = 0; + gSideStatuses[i] = 0; dataPtr = (u8 *)&gSideTimers[i]; for (j = 0; j < sizeof(struct SideTimer); j++) @@ -2764,7 +2764,7 @@ static void BattleStartClearSetData(void) } gBankAttacker = 0; - gBankTarget = 0; + gBankDefender = 0; gBattleWeather = 0; dataPtr = (u8 *)&gWishFutureKnock; @@ -2850,7 +2850,7 @@ void SwitchInClearSetData(void) { for (i = 0; i < BATTLE_STATS_NO; i++) gBattleMons[gActiveBank].statStages[i] = 6; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].bankPreventingEscape == gActiveBank) gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; @@ -2866,7 +2866,7 @@ void SwitchInClearSetData(void) gBattleMons[gActiveBank].status2 &= (STATUS2_CONFUSION | STATUS2_FOCUS_ENERGY | STATUS2_SUBSTITUTE | STATUS2_ESCAPE_PREVENTION | STATUS2_CURSED); gStatuses3[gActiveBank] &= (STATUS3_LEECHSEED_BANK | STATUS3_LEECHSEED | STATUS3_ALWAYS_HITS | STATUS3_PERISH_SONG | STATUS3_ROOTED | STATUS3_MUDSPORT | STATUS3_WATERSPORT); - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (GetBankSide(gActiveBank) != GetBankSide(i) && (gStatuses3[i] & STATUS3_ALWAYS_HITS) != 0 @@ -2883,7 +2883,7 @@ void SwitchInClearSetData(void) gStatuses3[gActiveBank] = 0; } - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBattleMons[i].status2 & STATUS2_INFATUATED_WITH(gActiveBank)) gBattleMons[i].status2 &= ~(STATUS2_INFATUATED_WITH(gActiveBank)); @@ -2907,7 +2907,7 @@ void SwitchInClearSetData(void) gDisableStructs[gActiveBank].bankPreventingEscape = disableStructCopy.bankPreventingEscape; } - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gDisableStructs[gActiveBank].isFirstTurn = 2; gDisableStructs[gActiveBank].truantUnknownBit = disableStructCopy.truantUnknownBit; gLastMoves[gActiveBank] = 0; @@ -2930,7 +2930,7 @@ void SwitchInClearSetData(void) gBattleStruct->field_92 &= ~(gBitTable[gActiveBank]); - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (i != gActiveBank && GetBankSide(i) != GetBankSide(gActiveBank)) { @@ -2963,7 +2963,7 @@ void FaintClearSetData(void) gBattleMons[gActiveBank].status2 = 0; gStatuses3[gActiveBank] = 0; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if ((gBattleMons[i].status2 & STATUS2_ESCAPE_PREVENTION) && gDisableStructs[i].bankPreventingEscape == gActiveBank) gBattleMons[i].status2 &= ~STATUS2_ESCAPE_PREVENTION; @@ -3025,7 +3025,7 @@ void FaintClearSetData(void) gBattleStruct->field_92 &= ~(gBitTable[gActiveBank]); - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (i != gActiveBank && GetBankSide(i) != GetBankSide(gActiveBank)) { @@ -3059,7 +3059,7 @@ static void BattleIntroGetMonsData(void) if (gBattleExecBuffer == 0) { gBattleCommunication[1]++; - if (gBattleCommunication[1] == gNoOfAllBanks) + if (gBattleCommunication[1] == gBattleBanksCount) gBattleMainFunc = BattleIntroPrepareBackgroundSlide; else gBattleCommunication[MULTIUSE_STATE] = 0; @@ -3072,7 +3072,7 @@ static void BattleIntroPrepareBackgroundSlide(void) { if (gBattleExecBuffer == 0) { - gActiveBank = GetBankByIdentity(0); + gActiveBank = GetBankByPosition(0); EmitIntroSlide(0, gBattleTerrain); MarkBufferBankForExecution(gActiveBank); gBattleMainFunc = BattleIntroDrawTrainersOrMonsSprites; @@ -3089,7 +3089,7 @@ static void BattleIntroDrawTrainersOrMonsSprites(void) if (gBattleExecBuffer) return; - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if ((gBattleTypeFlags & BATTLE_TYPE_SAFARI) && GetBankSide(gActiveBank) == SIDE_PLAYER) @@ -3203,7 +3203,7 @@ static void BattleIntroDrawPartySummaryScreens(void) hpStatus[i].status = GetMonData(&gEnemyParty[i], MON_DATA_STATUS); } } - gActiveBank = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + gActiveBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); EmitDrawPartyStatusSummary(0, hpStatus, 0x80); MarkBufferBankForExecution(gActiveBank); @@ -3221,7 +3221,7 @@ static void BattleIntroDrawPartySummaryScreens(void) hpStatus[i].status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); } } - gActiveBank = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + gActiveBank = GetBankByPosition(B_POSITION_PLAYER_LEFT); EmitDrawPartyStatusSummary(0, hpStatus, 0x80); MarkBufferBankForExecution(gActiveBank); @@ -3257,7 +3257,7 @@ static void BattleIntroPrintTrainerWantsToBattle(void) { if (gBattleExecBuffer == 0) { - gActiveBank = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + gActiveBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); PrepareStringBattle(STRINGID_INTROMSG, gActiveBank); gBattleMainFunc = BattleIntroPrintOpponentSendsOut; } @@ -3291,7 +3291,7 @@ static void BattleIntroPrintOpponentSendsOut(void) else identity = B_POSITION_OPPONENT_LEFT; - PrepareStringBattle(STRINGID_INTROSENDOUT, GetBankByIdentity(identity)); + PrepareStringBattle(STRINGID_INTROSENDOUT, GetBankByPosition(identity)); gBattleMainFunc = BattleIntroOpponent1SendsOutMonAnimation; } @@ -3311,7 +3311,7 @@ static void BattleIntroOpponent2SendsOutMonAnimation(void) else identity = B_POSITION_OPPONENT_RIGHT; - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (GetBankPosition(gActiveBank) == identity) { @@ -3343,7 +3343,7 @@ static void BattleIntroOpponent1SendsOutMonAnimation(void) if (gBattleExecBuffer) return; - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (GetBankPosition(gActiveBank) == identity) { @@ -3400,7 +3400,7 @@ _0803B29A:\n\ bne _0803B2F2\n\ ldr r0, =gActiveBank\n\ strb r2, [r0]\n\ - ldr r1, =gNoOfAllBanks\n\ + ldr r1, =gBattleBanksCount\n\ adds r4, r0, 0\n\ ldrb r1, [r1]\n\ cmp r2, r1\n\ @@ -3427,7 +3427,7 @@ _0803B2D8:\n\ ldrb r0, [r6]\n\ adds r0, 0x1\n\ strb r0, [r6]\n\ - ldr r1, =gNoOfAllBanks\n\ + ldr r1, =gBattleBanksCount\n\ lsls r0, 24\n\ lsrs r0, 24\n\ ldr r4, =gActiveBank\n\ @@ -3453,7 +3453,7 @@ static void BattleIntroRecordMonsToDex(void) { if (gBattleExecBuffer == 0) { - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (GetBankSide(gActiveBank) == SIDE_OPPONENT && !(gBattleTypeFlags & (BATTLE_TYPE_EREADER_TRAINER @@ -3494,7 +3494,7 @@ static void BattleIntroPrintPlayerSendsOut(void) identity = B_POSITION_PLAYER_LEFT; if (!(gBattleTypeFlags & BATTLE_TYPE_SAFARI)) - PrepareStringBattle(STRINGID_INTROSENDOUT, GetBankByIdentity(identity)); + PrepareStringBattle(STRINGID_INTROSENDOUT, GetBankByPosition(identity)); gBattleMainFunc = BattleIntroPlayer1SendsOutMonAnimation; } @@ -3516,7 +3516,7 @@ static void BattleIntroPlayer2SendsOutMonAnimation(void) else identity = B_POSITION_PLAYER_RIGHT; - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (GetBankPosition(gActiveBank) == identity) { @@ -3551,7 +3551,7 @@ static void BattleIntroPlayer1SendsOutMonAnimation(void) if (gBattleExecBuffer) return; - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (GetBankPosition(gActiveBank) == identity) { @@ -3576,7 +3576,7 @@ void sub_803B598(void) // unused { if (gBattleExecBuffer == 0) { - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (GetBankSide(gActiveBank) == SIDE_PLAYER) { @@ -3604,11 +3604,11 @@ static void TryDoEventsBeforeFirstTurn(void) if (gBattleStruct->switchInAbilitiesCounter == 0) { - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) gBanksByTurnOrder[i] = i; - for (i = 0; i < gNoOfAllBanks - 1; i++) + for (i = 0; i < gBattleBanksCount - 1; i++) { - for (j = i + 1; j < gNoOfAllBanks; j++) + for (j = i + 1; j < gBattleBanksCount; j++) { if (GetWhoStrikesFirst(gBanksByTurnOrder[i], gBanksByTurnOrder[j], TRUE) != 0) SwapTurnOrder(i, j); @@ -3622,7 +3622,7 @@ static void TryDoEventsBeforeFirstTurn(void) return; } // check all switch in abilities happening from the fastest mon to slowest - while (gBattleStruct->switchInAbilitiesCounter < gNoOfAllBanks) + while (gBattleStruct->switchInAbilitiesCounter < gBattleBanksCount) { if (AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gBanksByTurnOrder[gBattleStruct->switchInAbilitiesCounter], 0, 0, 0) != 0) effect++; @@ -3637,7 +3637,7 @@ static void TryDoEventsBeforeFirstTurn(void) if (AbilityBattleEffects(ABILITYEFFECT_TRACE, 0, 0, 0, 0) != 0) return; // check all switch in items having effect from the fastest mon to slowest - while (gBattleStruct->switchInItemsCounter < gNoOfAllBanks) + while (gBattleStruct->switchInItemsCounter < gBattleBanksCount) { if (ItemBattleEffects(ITEMEFFECT_ON_SWITCH_IN, gBanksByTurnOrder[gBattleStruct->switchInItemsCounter], 0) != 0) effect++; @@ -3663,7 +3663,7 @@ static void TryDoEventsBeforeFirstTurn(void) for (i = 0; i < BATTLE_COMMUNICATION_ENTRIES_COUNT; i++) gBattleCommunication[i] = 0; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) gBattleMons[i].status2 &= ~(STATUS2_FLINCHED); *(&gBattleStruct->turnEffectsTracker) = 0; @@ -3673,7 +3673,7 @@ static void TryDoEventsBeforeFirstTurn(void) gBattleScripting.atk49_state = 0; gBattleStruct->faintedActionsState = 0; gBattleStruct->turncountersTracker = 0; - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gRandomTurnNumber = Random(); @@ -3693,10 +3693,10 @@ static void HandleEndTurn_ContinueBattle(void) gBattleMainFunc = BattleTurnPassed; for (i = 0; i < BATTLE_COMMUNICATION_ENTRIES_COUNT; i++) gBattleCommunication[i] = 0; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { gBattleMons[i].status2 &= ~(STATUS2_FLINCHED); - if ((gBattleMons[i].status1 & STATUS_SLEEP) && (gBattleMons[i].status2 & STATUS2_MULTIPLETURNS)) + if ((gBattleMons[i].status1 & STATUS1_SLEEP) && (gBattleMons[i].status2 & STATUS2_MULTIPLETURNS)) CancelMultiTurnMoves(i); } gBattleStruct->turnEffectsTracker = 0; @@ -3704,7 +3704,7 @@ static void HandleEndTurn_ContinueBattle(void) gBattleStruct->wishPerishSongState = 0; gBattleStruct->wishPerishSongBank = 0; gBattleStruct->turncountersTracker = 0; - gBattleMoveFlags = 0; + gMoveResultFlags = 0; } } @@ -3735,7 +3735,7 @@ void BattleTurnPassed(void) gBattleScripting.animTargetsHit = 0; gBattleScripting.atk49_state = 0; gBattleMoveDamage = 0; - gBattleMoveFlags = 0; + gMoveResultFlags = 0; for (i = 0; i < 5; i++) gBattleCommunication[i] = 0; @@ -3753,7 +3753,7 @@ void BattleTurnPassed(void) gBattleStruct->field_DA++; } - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { gActionForBanks[i] = ACTION_INIT_VALUE; gChosenMovesByBanks[i] = MOVE_NONE; @@ -3795,7 +3795,7 @@ u8 IsRunningFromBattleImpossible(void) side = GetBankSide(gActiveBank); - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (side != GetBankSide(i) && gBattleMons[i].ability == ABILITY_SHADOW_TAG) @@ -3889,7 +3889,7 @@ static void HandleTurnActionSelectionState(void) s32 i; gBattleCommunication[ACTIONS_CONFIRMED_COUNT] = 0; - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { u8 identity = GetBankPosition(gActiveBank); switch (gBattleCommunication[gActiveBank]) @@ -3902,8 +3902,8 @@ static void HandleTurnActionSelectionState(void) *(gBattleStruct->monToSwitchIntoId + gActiveBank) = 6; if (gBattleTypeFlags & BATTLE_TYPE_MULTI || !(identity & BIT_MON) - || gBattleStruct->field_91 & gBitTable[GetBankByIdentity(identity ^ BIT_MON)] - || gBattleCommunication[GetBankByIdentity(identity ^ BIT_MON)] == 5) + || gBattleStruct->field_91 & gBitTable[GetBankByPosition(identity ^ BIT_MON)] + || gBattleCommunication[GetBankByPosition(identity ^ BIT_MON)] == 5) { if (gBattleStruct->field_91 & gBitTable[gActiveBank]) { @@ -4041,38 +4041,38 @@ static void HandleTurnActionSelectionState(void) break; case ACTION_CANCEL_PARTNER: gBattleCommunication[gActiveBank] = 7; - gBattleCommunication[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)] = 1; + gBattleCommunication[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)] = 1; RecordedBattle_ClearBankAction(gActiveBank, 1); - if (gBattleMons[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)].status2 & STATUS2_MULTIPLETURNS - || gBattleMons[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)].status2 & STATUS2_RECHARGE) + if (gBattleMons[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)].status2 & STATUS2_MULTIPLETURNS + || gBattleMons[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)].status2 & STATUS2_RECHARGE) { EmitCmd50(0); MarkBufferBankForExecution(gActiveBank); return; } - else if (gActionForBanks[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_SWITCH) + else if (gActionForBanks[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_SWITCH) { - RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON), 2); + RecordedBattle_ClearBankAction(GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON), 2); } - else if (gActionForBanks[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_RUN) + else if (gActionForBanks[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_RUN) { - RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON), 1); + RecordedBattle_ClearBankAction(GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON), 1); } - else if (gActionForBanks[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_USE_MOVE - && (gProtectStructs[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)].onlyStruggle - || gDisableStructs[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)].encoredMove)) + else if (gActionForBanks[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_USE_MOVE + && (gProtectStructs[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)].onlyStruggle + || gDisableStructs[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)].encoredMove)) { - RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON), 1); + RecordedBattle_ClearBankAction(GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON), 1); } else if (gBattleTypeFlags & BATTLE_TYPE_PALACE - && gActionForBanks[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_USE_MOVE) + && gActionForBanks[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)] == ACTION_USE_MOVE) { gRngValue = gBattlePalaceMoveSelectionRngValue; - RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON), 1); + RecordedBattle_ClearBankAction(GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON), 1); } else { - RecordedBattle_ClearBankAction(GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON), 3); + RecordedBattle_ClearBankAction(GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON), 3); } EmitCmd50(0); MarkBufferBankForExecution(gActiveBank); @@ -4226,7 +4226,7 @@ static void HandleTurnActionSelectionState(void) if (((gBattleTypeFlags & (BATTLE_TYPE_MULTI | BATTLE_TYPE_DOUBLE)) != BATTLE_TYPE_DOUBLE) || (identity & BIT_MON) - || (*(&gBattleStruct->field_91) & gBitTable[GetBankByIdentity(identity ^ BIT_MON)])) + || (*(&gBattleStruct->field_91) & gBitTable[GetBankByPosition(identity ^ BIT_MON)])) { EmitLinkStandbyMsg(0, 0, i); } @@ -4296,14 +4296,14 @@ static void HandleTurnActionSelectionState(void) } // check if everyone chose actions - if (gBattleCommunication[ACTIONS_CONFIRMED_COUNT] == gNoOfAllBanks) + if (gBattleCommunication[ACTIONS_CONFIRMED_COUNT] == gBattleBanksCount) { sub_818603C(1); gBattleMainFunc = SetActionsAndBanksTurnOrder; if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) { - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gActionForBanks[i] == ACTION_SWITCH) sub_80571DC(i, *(gBattleStruct->monToSwitchIntoId + i)); @@ -4316,13 +4316,13 @@ static bool8 sub_803CDB8(void) { s32 i, var; - for (var = 0, i = 0; i < gNoOfAllBanks; i++) + for (var = 0, i = 0; i < gBattleBanksCount; i++) { if (gBattleCommunication[i] == 5) var++; } - if (var + 1 == gNoOfAllBanks) + if (var + 1 == gBattleBanksCount) return TRUE; else return FALSE; @@ -4411,7 +4411,7 @@ u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves) if (holdEffect == HOLD_EFFECT_MACHO_BRACE) speedBank1 /= 2; - if (gBattleMons[bank1].status1 & STATUS_PARALYSIS) + if (gBattleMons[bank1].status1 & STATUS1_PARALYSIS) speedBank1 /= 4; if (holdEffect == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * holdEffectParam) / 100) @@ -4445,7 +4445,7 @@ u8 GetWhoStrikesFirst(u8 bank1, u8 bank2, bool8 ignoreChosenMoves) if (holdEffect == HOLD_EFFECT_MACHO_BRACE) speedBank2 /= 2; - if (gBattleMons[bank2].status1 & STATUS_PARALYSIS) + if (gBattleMons[bank2].status1 & STATUS1_PARALYSIS) speedBank2 /= 4; if (holdEffect == HOLD_EFFECT_QUICK_CLAW && gRandomTurnNumber < (0xFFFF * holdEffectParam) / 100) @@ -4518,7 +4518,7 @@ static void SetActionsAndBanksTurnOrder(void) if (gBattleTypeFlags & BATTLE_TYPE_SAFARI) { - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { gActionsByTurnOrder[var] = gActionForBanks[gActiveBank]; gBanksByTurnOrder[var] = gActiveBank; @@ -4529,7 +4529,7 @@ static void SetActionsAndBanksTurnOrder(void) { if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (gActionForBanks[gActiveBank] == ACTION_RUN) { @@ -4557,7 +4557,7 @@ static void SetActionsAndBanksTurnOrder(void) gActionsByTurnOrder[0] = gActionForBanks[gActiveBank]; gBanksByTurnOrder[0] = gActiveBank; var = 1; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (i != gActiveBank) { @@ -4572,7 +4572,7 @@ static void SetActionsAndBanksTurnOrder(void) } else { - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (gActionForBanks[gActiveBank] == ACTION_USE_ITEM || gActionForBanks[gActiveBank] == ACTION_SWITCH) { @@ -4581,7 +4581,7 @@ static void SetActionsAndBanksTurnOrder(void) var++; } } - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (gActionForBanks[gActiveBank] != ACTION_USE_ITEM && gActionForBanks[gActiveBank] != ACTION_SWITCH) { @@ -4590,9 +4590,9 @@ static void SetActionsAndBanksTurnOrder(void) var++; } } - for (i = 0; i < gNoOfAllBanks - 1; i++) + for (i = 0; i < gBattleBanksCount - 1; i++) { - for (j = i + 1; j < gNoOfAllBanks; j++) + for (j = i + 1; j < gBattleBanksCount; j++) { u8 bank1 = gBanksByTurnOrder[i]; u8 bank2 = gBanksByTurnOrder[j]; @@ -4617,7 +4617,7 @@ static void TurnValuesCleanUp(bool8 var0) s32 i; u8 *dataPtr; - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (var0) { @@ -4651,7 +4651,7 @@ static void TurnValuesCleanUp(bool8 var0) static void SpecialStatusesClear(void) { - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { s32 i; u8 *dataPtr = (u8*)(&gSpecialStatuses[gActiveBank]); @@ -4665,12 +4665,12 @@ static void CheckFocusPunch_ClearVarsBeforeTurnStarts(void) { if (!(gHitMarker & HITMARKER_RUN)) { - while (gBattleStruct->focusPunchBank < gNoOfAllBanks) + while (gBattleStruct->focusPunchBank < gBattleBanksCount) { gActiveBank = gBankAttacker = gBattleStruct->focusPunchBank; gBattleStruct->focusPunchBank++; if (gChosenMovesByBanks[gActiveBank] == MOVE_FOCUS_PUNCH - && !(gBattleMons[gActiveBank].status1 & STATUS_SLEEP) + && !(gBattleMons[gActiveBank].status1 & STATUS1_SLEEP) && !(gDisableStructs[gBankAttacker].truantCounter) && !(gProtectStructs[gActiveBank].onlyStruggle)) { @@ -4704,7 +4704,7 @@ static void RunTurnActionsFunctions(void) *(&gBattleStruct->savedTurnActionNumber) = gCurrentTurnActionNumber; sTurnActionsFuncsTable[gCurrentActionFuncId](); - if (gCurrentTurnActionNumber >= gNoOfAllBanks) // everyone did their actions, turn finished + if (gCurrentTurnActionNumber >= gBattleBanksCount) // everyone did their actions, turn finished { gHitMarker &= ~(HITMARKER_x100000); gBattleMainFunc = sEndTurnFuncsTable[gBattleOutcome & 0x7F]; @@ -4727,9 +4727,9 @@ static void HandleEndTurn_BattleWon(void) { gSpecialVar_Result = gBattleOutcome; gBattleTextBuff1[0] = gBattleOutcome; - gBankAttacker = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + gBankAttacker = GetBankByPosition(B_POSITION_PLAYER_LEFT); gBattlescriptCurrInstr = BattleScript_LinkBattleWonOrLost; - gBattleOutcome &= ~(OUTCOME_LINK_BATTLE_RUN); + gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN); } else if (gBattleTypeFlags & BATTLE_TYPE_TRAINER && gBattleTypeFlags & (BATTLE_TYPE_FRONTIER | BATTLE_TYPE_x4000000 | BATTLE_TYPE_EREADER_TRAINER)) @@ -4785,24 +4785,24 @@ static void HandleEndTurn_BattleLost(void) { if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER) { - if (gBattleOutcome & OUTCOME_LINK_BATTLE_RUN) + if (gBattleOutcome & B_OUTCOME_LINK_BATTLE_RAN) { gBattlescriptCurrInstr = BattleScript_PrintPlayerForfeitedLinkBattle; - gBattleOutcome &= ~(OUTCOME_LINK_BATTLE_RUN); + gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN); gSaveBlock2Ptr->field_CA9_b = 1; } else { gBattlescriptCurrInstr = BattleScript_82DAA0B; - gBattleOutcome &= ~(OUTCOME_LINK_BATTLE_RUN); + gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN); } } else { gBattleTextBuff1[0] = gBattleOutcome; - gBankAttacker = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + gBankAttacker = GetBankByPosition(B_POSITION_PLAYER_LEFT); gBattlescriptCurrInstr = BattleScript_LinkBattleWonOrLost; - gBattleOutcome &= ~(OUTCOME_LINK_BATTLE_RUN); + gBattleOutcome &= ~(B_OUTCOME_LINK_BATTLE_RAN); } } else @@ -4820,13 +4820,13 @@ static void HandleEndTurn_RanFromBattle(void) if (gBattleTypeFlags & BATTLE_TYPE_FRONTIER && gBattleTypeFlags & BATTLE_TYPE_TRAINER) { gBattlescriptCurrInstr = BattleScript_PrintPlayerForfeited; - gBattleOutcome = BATTLE_FORFEITED; + gBattleOutcome = B_OUTCOME_FORFEITED; gSaveBlock2Ptr->field_CA9_b = 1; } else if (gBattleTypeFlags & BATTLE_TYPE_x4000000) { gBattlescriptCurrInstr = BattleScript_PrintPlayerForfeited; - gBattleOutcome = BATTLE_FORFEITED; + gBattleOutcome = B_OUTCOME_FORFEITED; } else { @@ -4869,7 +4869,7 @@ static void HandleEndTurn_FinishBattle(void) | BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_FRONTIER))) { - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (GetBankSide(gActiveBank) == SIDE_PLAYER) { @@ -4919,7 +4919,7 @@ static void FreeResetData_ReturnToOvOrDoEvolutions(void) if (!gPaletteFade.active) { ResetSpriteData(); - if (gLeveledUpInBattle == 0 || gBattleOutcome != BATTLE_WON) + if (gLeveledUpInBattle == 0 || gBattleOutcome != B_OUTCOME_WON) { gBattleMainFunc = ReturnFromBattleToOverworld; return; @@ -4994,7 +4994,7 @@ static void ReturnFromBattleToOverworld(void) if (gBattleTypeFlags & BATTLE_TYPE_ROAMER) { UpdateRoamerHPStatus(&gEnemyParty[0]); - if ((gBattleOutcome & BATTLE_WON) || gBattleOutcome == BATTLE_CAUGHT) + if ((gBattleOutcome & B_OUTCOME_WON) || gBattleOutcome == B_OUTCOME_CAUGHT_POKE) SetRoamerInactive(); } @@ -5039,7 +5039,7 @@ static void HandleAction_UseMove(void) gCritMultiplier = 1; gBattleScripting.dmgMultiplier = 1; gBattleStruct->atkCancellerTracker = 0; - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gMultiHitCounter = 0; gBattleCommunication[6] = 0; gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBankAttacker); @@ -5100,7 +5100,7 @@ static void HandleAction_UseMove(void) && GetBankSide(gBankAttacker) != GetBankSide(gSideTimers[side].followmeTarget) && gBattleMons[gSideTimers[side].followmeTarget].hp != 0) { - gBankTarget = gSideTimers[side].followmeTarget; + gBankDefender = gSideTimers[side].followmeTarget; } else if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && gSideTimers[side].followmeTimer == 0 @@ -5110,7 +5110,7 @@ static void HandleAction_UseMove(void) && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) { side = GetBankSide(gBankAttacker); - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (side != GetBankSide(gActiveBank) && *(gBattleStruct->moveTarget + gBankAttacker) != gActiveBank @@ -5127,34 +5127,34 @@ static void HandleAction_UseMove(void) if (GetBankSide(gBankAttacker) == SIDE_PLAYER) { if (Random() & 1) - gBankTarget = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_LEFT); else - gBankTarget = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); } else { if (Random() & 1) - gBankTarget = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + gBankDefender = GetBankByPosition(B_POSITION_PLAYER_LEFT); else - gBankTarget = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + gBankDefender = GetBankByPosition(B_POSITION_PLAYER_RIGHT); } } else { - gBankTarget = *(gBattleStruct->moveTarget + gBankAttacker); + gBankDefender = *(gBattleStruct->moveTarget + gBankAttacker); } - if (gAbsentBankFlags & gBitTable[gBankTarget]) + if (gAbsentBankFlags & gBitTable[gBankDefender]) { - if (GetBankSide(gBankAttacker) != GetBankSide(gBankTarget)) + if (GetBankSide(gBankAttacker) != GetBankSide(gBankDefender)) { - gBankTarget = GetBankByIdentity(GetBankPosition(gBankTarget) ^ BIT_MON); + gBankDefender = GetBankByPosition(GetBankPosition(gBankDefender) ^ BIT_MON); } else { - gBankTarget = GetBankByIdentity(GetBankPosition(gBankAttacker) ^ BIT_SIDE); - if (gAbsentBankFlags & gBitTable[gBankTarget]) - gBankTarget = GetBankByIdentity(GetBankPosition(gBankTarget) ^ BIT_MON); + gBankDefender = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_SIDE); + if (gAbsentBankFlags & gBitTable[gBankDefender]) + gBankDefender = GetBankByPosition(GetBankPosition(gBankDefender) ^ BIT_MON); } } } @@ -5163,7 +5163,7 @@ static void HandleAction_UseMove(void) gActiveBank = gBanksByTurnOrder[var]; RecordAbilityBattle(gActiveBank, gBattleMons[gActiveBank].ability); gSpecialStatuses[gActiveBank].lightningRodRedirected = 1; - gBankTarget = gActiveBank; + gBankDefender = gActiveBank; } } else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE @@ -5172,38 +5172,38 @@ static void HandleAction_UseMove(void) if (GetBankSide(gBankAttacker) == SIDE_PLAYER) { if (Random() & 1) - gBankTarget = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_LEFT); else - gBankTarget = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); } else { if (Random() & 1) - gBankTarget = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + gBankDefender = GetBankByPosition(B_POSITION_PLAYER_LEFT); else - gBankTarget = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + gBankDefender = GetBankByPosition(B_POSITION_PLAYER_RIGHT); } - if (gAbsentBankFlags & gBitTable[gBankTarget] - && GetBankSide(gBankAttacker) != GetBankSide(gBankTarget)) + if (gAbsentBankFlags & gBitTable[gBankDefender] + && GetBankSide(gBankAttacker) != GetBankSide(gBankDefender)) { - gBankTarget = GetBankByIdentity(GetBankPosition(gBankTarget) ^ BIT_MON); + gBankDefender = GetBankByPosition(GetBankPosition(gBankDefender) ^ BIT_MON); } } else { - gBankTarget = *(gBattleStruct->moveTarget + gBankAttacker); - if (gAbsentBankFlags & gBitTable[gBankTarget]) + gBankDefender = *(gBattleStruct->moveTarget + gBankAttacker); + if (gAbsentBankFlags & gBitTable[gBankDefender]) { - if (GetBankSide(gBankAttacker) != GetBankSide(gBankTarget)) + if (GetBankSide(gBankAttacker) != GetBankSide(gBankDefender)) { - gBankTarget = GetBankByIdentity(GetBankPosition(gBankTarget) ^ BIT_MON); + gBankDefender = GetBankByPosition(GetBankPosition(gBankDefender) ^ BIT_MON); } else { - gBankTarget = GetBankByIdentity(GetBankPosition(gBankAttacker) ^ BIT_SIDE); - if (gAbsentBankFlags & gBitTable[gBankTarget]) - gBankTarget = GetBankByIdentity(GetBankPosition(gBankTarget) ^ BIT_MON); + gBankDefender = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_SIDE); + if (gAbsentBankFlags & gBitTable[gBankDefender]) + gBankDefender = GetBankByPosition(GetBankPosition(gBankDefender) ^ BIT_MON); } } } @@ -5260,7 +5260,7 @@ static void HandleAction_Switch(void) static void HandleAction_UseItem(void) { - gBankAttacker = gBankTarget = gBanksByTurnOrder[gCurrentTurnActionNumber]; + gBankAttacker = gBankDefender = gBanksByTurnOrder[gCurrentTurnActionNumber]; gBattle_BG0_X = 0; gBattle_BG0_Y = 0; ClearFuryCutterDestinyBondGrudge(gBankAttacker); @@ -5410,8 +5410,8 @@ bool8 TryRunFromBattle(u8 bank) if (effect) { - gCurrentTurnActionNumber = gNoOfAllBanks; - gBattleOutcome = BATTLE_RAN; + gCurrentTurnActionNumber = gBattleBanksCount; + gBattleOutcome = B_OUTCOME_RAN; } return effect; @@ -5423,23 +5423,23 @@ static void HandleAction_Run(void) if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) { - gCurrentTurnActionNumber = gNoOfAllBanks; + gCurrentTurnActionNumber = gBattleBanksCount; - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (GetBankSide(gActiveBank) == SIDE_PLAYER) { if (gActionForBanks[gActiveBank] == ACTION_RUN) - gBattleOutcome |= BATTLE_LOST; + gBattleOutcome |= B_OUTCOME_LOST; } else { if (gActionForBanks[gActiveBank] == ACTION_RUN) - gBattleOutcome |= BATTLE_WON; + gBattleOutcome |= B_OUTCOME_WON; } } - gBattleOutcome |= OUTCOME_LINK_BATTLE_RUN; + gBattleOutcome |= B_OUTCOME_LINK_BATTLE_RAN; gSaveBlock2Ptr->field_CA9_b = 1; } else @@ -5464,8 +5464,8 @@ static void HandleAction_Run(void) } else { - gCurrentTurnActionNumber = gNoOfAllBanks; - gBattleOutcome = BATTLE_POKE_FLED; + gCurrentTurnActionNumber = gBattleBanksCount; + gBattleOutcome = B_OUTCOME_POKE_FLED; } } } @@ -5546,8 +5546,8 @@ static void HandleAction_SafriZoneRun(void) { gBankAttacker = gBanksByTurnOrder[gCurrentTurnActionNumber]; PlaySE(SE_NIGERU); - gCurrentTurnActionNumber = gNoOfAllBanks; - gBattleOutcome = BATTLE_RAN; + gCurrentTurnActionNumber = gBattleBanksCount; + gBattleOutcome = B_OUTCOME_RAN; } static void HandleAction_Action9(void) @@ -5597,7 +5597,7 @@ static void HandleAction_ActionFinished(void) gCurrentMove = 0; gBattleMoveDamage = 0; - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gBattleScripting.animTurn = 0; gBattleScripting.animTargetsHit = 0; gLastLandedMoves[gBankAttacker] = 0; diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index a10dab976..07bedb113 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -48,16 +48,16 @@ extern u32 gBattleTypeFlags; extern u8 gActiveBank; extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; extern u16 gCurrentMove; -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gAbsentBankFlags; extern u16 gLastMoves[BATTLE_BANKS_COUNT]; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; extern u32 gStatuses3[BATTLE_BANKS_COUNT]; -extern u16 gSideAffecting[2]; +extern u16 gSideStatuses[2]; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; extern u16 gDynamicBasePower; -extern u8 gBattleMoveFlags; +extern u8 gMoveResultFlags; extern s32 gBattleMoveDamage; extern u8 gCritMultiplier; extern u16 gBattleWeather; @@ -367,14 +367,14 @@ void BattleAI_SetupAIData(u8 defaultScoreMoves) // decide a random target bank in doubles if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - gBankTarget = (Random() & BIT_MON) + (GetBankSide(gActiveBank) ^ BIT_SIDE); - if (gAbsentBankFlags & gBitTable[gBankTarget]) - gBankTarget ^= BIT_MON; + gBankDefender = (Random() & BIT_MON) + (GetBankSide(gActiveBank) ^ BIT_SIDE); + if (gAbsentBankFlags & gBitTable[gBankDefender]) + gBankDefender ^= BIT_MON; } // in singles there's only one choice else { - gBankTarget = sBank_AI ^ BIT_SIDE; + gBankDefender = sBank_AI ^ BIT_SIDE; } if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) @@ -491,7 +491,7 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void) else BattleAI_SetupAIData(0xF); - gBankTarget = i; + gBankDefender = i; if ((i & BIT_SIDE) != (sBank_AI & BIT_SIDE)) RecordLastUsedMoveByTarget(); @@ -573,8 +573,8 @@ static u8 BattleAI_ChooseMoveOrAction_Doubles(void) } } - gBankTarget = mostViableTargetsArray[Random() % mostViableTargetsNo]; - return actionOrMoveIndex[gBankTarget]; + gBankDefender = mostViableTargetsArray[Random() % mostViableTargetsNo]; + return actionOrMoveIndex[gBankDefender]; } static void BattleAI_DoAIProcessing(void) @@ -627,12 +627,12 @@ static void RecordLastUsedMoveByTarget(void) for (i = 0; i < 4; i++) { - if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == gLastMoves[gBankTarget]) + if (gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] == gLastMoves[gBankDefender]) break; - if (gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] != gLastMoves[gBankTarget] // HACK: This redundant condition is a hack to make the asm match. - && gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] == 0) + if (gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] != gLastMoves[gBankDefender] // HACK: This redundant condition is a hack to make the asm match. + && gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] == 0) { - gBattleResources->battleHistory->usedMoves[gBankTarget].moves[i] = gLastMoves[gBankTarget]; + gBattleResources->battleHistory->usedMoves[gBankDefender].moves[i] = gLastMoves[gBankDefender]; break; } } @@ -723,7 +723,7 @@ static void BattleAICmd_if_hp_less_than(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) < gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -738,7 +738,7 @@ static void BattleAICmd_if_hp_more_than(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) > gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -753,7 +753,7 @@ static void BattleAICmd_if_hp_equal(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) == gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -768,7 +768,7 @@ static void BattleAICmd_if_hp_not_equal(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if ((u32)(100 * gBattleMons[bank].hp / gBattleMons[bank].maxHP) != gAIScriptPtr[2]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 3); @@ -784,7 +784,7 @@ static void BattleAICmd_if_status(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -802,7 +802,7 @@ static void BattleAICmd_if_not_status(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -820,7 +820,7 @@ static void BattleAICmd_if_status2(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -838,7 +838,7 @@ static void BattleAICmd_if_not_status2(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -856,7 +856,7 @@ static void BattleAICmd_if_status3(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -874,7 +874,7 @@ static void BattleAICmd_if_not_status3(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; status = AIScriptRead32(gAIScriptPtr + 2); @@ -892,12 +892,12 @@ static void BattleAICmd_if_side_affecting(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; side = GET_BANK_SIDE(bank); status = AIScriptRead32(gAIScriptPtr + 2); - if ((gSideAffecting[side] & status) != 0) + if ((gSideStatuses[side] & status) != 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); else gAIScriptPtr += 10; @@ -911,12 +911,12 @@ static void BattleAICmd_if_not_side_affecting(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; side = GET_BANK_SIDE(bank); status = AIScriptRead32(gAIScriptPtr + 2); - if ((gSideAffecting[side] & status) == 0) + if ((gSideStatuses[side] & status) == 0) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 6); else gAIScriptPtr += 10; @@ -1126,13 +1126,13 @@ static void BattleAICmd_get_type(void) AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type1; break; case AI_TYPE1_TARGET: // target primary type - AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type1; + AI_THINKING_STRUCT->funcResult = gBattleMons[gBankDefender].type1; break; case AI_TYPE2_USER: // AI user secondary type AI_THINKING_STRUCT->funcResult = gBattleMons[sBank_AI].type2; break; case AI_TYPE2_TARGET: // target secondary type - AI_THINKING_STRUCT->funcResult = gBattleMons[gBankTarget].type2; + AI_THINKING_STRUCT->funcResult = gBattleMons[gBankDefender].type2; break; case AI_TYPE_MOVE: // type of move being pointed to AI_THINKING_STRUCT->funcResult = gBattleMoves[AI_THINKING_STRUCT->moveConsidered].type; @@ -1149,11 +1149,11 @@ static u8 BattleAI_GetWantedBank(u8 bank) return sBank_AI; case AI_TARGET: default: - return gBankTarget; + return gBankDefender; case AI_USER_PARTNER: return sBank_AI ^ BIT_MON; case AI_TARGET_PARTNER: - return gBankTarget ^ BIT_MON; + return gBankDefender ^ BIT_MON; } } @@ -1196,7 +1196,7 @@ static void BattleAICmd_get_how_powerful_move_is(void) gDynamicBasePower = 0; *(&gBattleStruct->dynamicMoveType) = 0; gBattleScripting.dmgMultiplier = 1; - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gCritMultiplier = 1; for (checkedMove = 0; checkedMove < 4; checkedMove++) @@ -1212,8 +1212,8 @@ static void BattleAICmd_get_how_powerful_move_is(void) && gBattleMoves[gBattleMons[sBank_AI].moves[checkedMove]].power > 1) { gCurrentMove = gBattleMons[sBank_AI].moves[checkedMove]; - AI_CalcDmg(sBank_AI, gBankTarget); - TypeCalc(gCurrentMove, sBank_AI, gBankTarget); + AI_CalcDmg(sBank_AI, gBankDefender); + TypeCalc(gCurrentMove, sBank_AI, gBankDefender); moveDmgs[checkedMove] = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[checkedMove] / 100; if (moveDmgs[checkedMove] == 0) moveDmgs[checkedMove] = 1; @@ -1248,7 +1248,7 @@ static void BattleAICmd_get_last_used_bank_move(void) if (gAIScriptPtr[1] == AI_USER) AI_THINKING_STRUCT->funcResult = gLastMoves[sBank_AI]; else - AI_THINKING_STRUCT->funcResult = gLastMoves[gBankTarget]; + AI_THINKING_STRUCT->funcResult = gLastMoves[gBankDefender]; 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, gBankTarget, TRUE) == gAIScriptPtr[1]) + if (GetWhoStrikesFirst(sBank_AI, gBankDefender, 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, gBankTarget, TRUE) != gAIScriptPtr[1]) + if (GetWhoStrikesFirst(sBank_AI, gBankDefender, TRUE) != gAIScriptPtr[1]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 2); else gAIScriptPtr += 6; @@ -1305,7 +1305,7 @@ static void BattleAICmd_count_usable_party_mons(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if (GetBankSide(bank) == SIDE_PLAYER) party = gPlayerParty; @@ -1317,7 +1317,7 @@ static void BattleAICmd_count_usable_party_mons(void) u32 identity; bankOnField1 = gBattlePartyID[bank]; identity = GetBankPosition(bank) ^ BIT_MON; - bankOnField2 = gBattlePartyID[GetBankByIdentity(identity)]; + bankOnField2 = gBattlePartyID[GetBankByPosition(identity)]; } else // in singles there's only one bank by side { @@ -1358,7 +1358,7 @@ static void BattleAICmd_get_ability(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if (gActiveBank != bank) { @@ -1482,7 +1482,7 @@ static void BattleAICmd_get_highest_type_effectiveness(void) dynamicMoveType = &gBattleStruct->dynamicMoveType; *dynamicMoveType = 0; gBattleScripting.dmgMultiplier = 1; - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gCritMultiplier = 1; AI_THINKING_STRUCT->funcResult = 0; @@ -1493,7 +1493,7 @@ static void BattleAICmd_get_highest_type_effectiveness(void) if (gCurrentMove) { - TypeCalc(gCurrentMove, sBank_AI, gBankTarget); + TypeCalc(gCurrentMove, sBank_AI, gBankDefender); // reduce by 1/3. if (gBattleMoveDamage == 120) @@ -1505,7 +1505,7 @@ static void BattleAICmd_get_highest_type_effectiveness(void) if (gBattleMoveDamage == 15) gBattleMoveDamage = AI_EFFECTIVENESS_x0_25; - if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) + if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) gBattleMoveDamage = AI_EFFECTIVENESS_x0; if (AI_THINKING_STRUCT->funcResult < gBattleMoveDamage) @@ -1522,13 +1522,13 @@ static void BattleAICmd_if_type_effectiveness(void) gDynamicBasePower = 0; gBattleStruct->dynamicMoveType = 0; gBattleScripting.dmgMultiplier = 1; - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gCritMultiplier = 1; gBattleMoveDamage = AI_EFFECTIVENESS_x1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; - TypeCalc(gCurrentMove, sBank_AI, gBankTarget); + TypeCalc(gCurrentMove, sBank_AI, gBankDefender); if (gBattleMoveDamage == 120) gBattleMoveDamage = AI_EFFECTIVENESS_x2; @@ -1539,7 +1539,7 @@ static void BattleAICmd_if_type_effectiveness(void) if (gBattleMoveDamage == 15) gBattleMoveDamage = AI_EFFECTIVENESS_x0_25; - if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) + if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) gBattleMoveDamage = AI_EFFECTIVENESS_x0; // store gBattleMoveDamage in a u8 variable because gAIScriptPtr[1] is a u8. @@ -1572,7 +1572,7 @@ static void BattleAICmd_if_status_in_party(void) bank = sBank_AI; break; default: - bank = gBankTarget; + bank = gBankDefender; break; } @@ -1609,7 +1609,7 @@ static void BattleAICmd_if_status_not_in_party(void) bank = sBank_AI; break; default: - bank = gBankTarget; + bank = gBankDefender; break; } @@ -1669,7 +1669,7 @@ static void BattleAICmd_if_stat_level_less_than(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if (gBattleMons[bank].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); @@ -1684,7 +1684,7 @@ static void BattleAICmd_if_stat_level_more_than(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if (gBattleMons[bank].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); @@ -1699,7 +1699,7 @@ static void BattleAICmd_if_stat_level_equal(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if (gBattleMons[bank].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); @@ -1714,7 +1714,7 @@ static void BattleAICmd_if_stat_level_not_equal(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if (gBattleMons[bank].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); @@ -1733,11 +1733,11 @@ static void BattleAICmd_if_can_faint(void) gDynamicBasePower = 0; gBattleStruct->dynamicMoveType = 0; gBattleScripting.dmgMultiplier = 1; - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gCritMultiplier = 1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; - AI_CalcDmg(sBank_AI, gBankTarget); - TypeCalc(gCurrentMove, sBank_AI, gBankTarget); + AI_CalcDmg(sBank_AI, gBankDefender); + TypeCalc(gCurrentMove, sBank_AI, gBankDefender); 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[gBankTarget].hp <= gBattleMoveDamage) + if (gBattleMons[gBankDefender].hp <= gBattleMoveDamage) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -1762,17 +1762,17 @@ static void BattleAICmd_if_cant_faint(void) gDynamicBasePower = 0; gBattleStruct->dynamicMoveType = 0; gBattleScripting.dmgMultiplier = 1; - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gCritMultiplier = 1; gCurrentMove = AI_THINKING_STRUCT->moveConsidered; - AI_CalcDmg(sBank_AI, gBankTarget); - TypeCalc(gCurrentMove, sBank_AI, gBankTarget); + AI_CalcDmg(sBank_AI, gBankDefender); + TypeCalc(gCurrentMove, sBank_AI, gBankDefender); gBattleMoveDamage = gBattleMoveDamage * AI_THINKING_STRUCT->simulatedRNG[AI_THINKING_STRUCT->movesetIndex] / 100; // this macro is missing the damage 0 = 1 assumption. - if (gBattleMons[gBankTarget].hp > gBattleMoveDamage) + if (gBattleMons[gBankDefender].hp > gBattleMoveDamage) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); else gAIScriptPtr += 5; @@ -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[gBankTarget].moves[i] == *movePtr) + if (BATTLE_HISTORY->usedMoves[gBankDefender].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[gBankTarget].moves[i] == *movePtr) + if (BATTLE_HISTORY->usedMoves[gBankDefender].moves[i] == *movePtr) break; } if (i != 4) @@ -1911,8 +1911,8 @@ static void BattleAICmd_if_has_move_with_effect(void) case AI_TARGET_PARTNER: for (i = 0; i < 4; i++) { - // UB: checks sBank_AI instead of gBankTarget - if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankTarget].moves[i]].effect == gAIScriptPtr[2]) + // UB: checks sBank_AI instead of gBankDefender + if (gBattleMons[sBank_AI].moves[i] != 0 && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankDefender].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[gBankTarget].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankTarget].moves[i]].effect == gAIScriptPtr[2]) + if (BATTLE_HISTORY->usedMoves[gBankDefender].moves[i] && gBattleMoves[BATTLE_HISTORY->usedMoves[gBankDefender].moves[i]].effect == gAIScriptPtr[2]) break; } if (i != 4) @@ -1963,7 +1963,7 @@ static void BattleAICmd_if_any_move_disabled_or_encored(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if (gAIScriptPtr[2] == 0) { @@ -2041,7 +2041,7 @@ static void BattleAICmd_get_hold_effect(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; if (gActiveBank != bank) AI_THINKING_STRUCT->funcResult = ItemId_GetHoldEffect(BATTLE_HISTORY->itemEffects[bank]); @@ -2079,7 +2079,7 @@ static void BattleAICmd_get_gender(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; AI_THINKING_STRUCT->funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[bank].species, gBattleMons[bank].personality); @@ -2093,7 +2093,7 @@ static void BattleAICmd_is_first_turn_for(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].isFirstTurn; @@ -2107,7 +2107,7 @@ static void BattleAICmd_get_stockpile_count(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; AI_THINKING_STRUCT->funcResult = gDisableStructs[bank].stockpileCounter; @@ -2128,7 +2128,7 @@ static void BattleAICmd_get_used_held_item(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; // This is likely a leftover from Ruby's code and its ugly ewram access #ifdef NONMATCHING @@ -2168,7 +2168,7 @@ static void BattleAICmd_get_protect_count(void) if (gAIScriptPtr[1] == AI_USER) bank = sBank_AI; else - bank = gBankTarget; + bank = gBankDefender; 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[gBankTarget].level) + if (gBattleMons[sBank_AI].level > gBattleMons[gBankDefender].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[gBankTarget].level) + if (gBattleMons[sBank_AI].level < gBattleMons[gBankDefender].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[gBankTarget].level) + if (gBattleMons[sBank_AI].level == gBattleMons[gBankDefender].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[gBankTarget].tauntTimer1 != 0) + if (gDisableStructs[gBankDefender].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[gBankTarget].tauntTimer1 == 0) + if (gDisableStructs[gBankDefender].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) == (gBankTarget & BIT_SIDE)) + if ((sBank_AI & BIT_SIDE) == (gBankDefender & 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 092d4a7c7..60212f849 100644 --- a/src/battle_ai_switch_items.c +++ b/src/battle_ai_switch_items.c @@ -19,7 +19,7 @@ extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; extern u16 gLastLandedMoves[BATTLE_BANKS_COUNT]; extern u8 gLastHitBy[BATTLE_BANKS_COUNT]; extern u16 gDynamicBasePower; -extern u8 gBattleMoveFlags; +extern u8 gMoveResultFlags; extern u8 gCritMultiplier; extern s32 gBattleMoveDamage; @@ -48,7 +48,7 @@ static bool8 ShouldSwitchIfPerishSong(void) static bool8 ShouldSwitchIfWonderGuard(void) { - u8 opposingIdentity; + u8 opposingPosition; u8 opposingBank; u8 moveFlags; s32 i, j; @@ -60,20 +60,20 @@ static bool8 ShouldSwitchIfWonderGuard(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) return FALSE; - opposingIdentity = GetBankPosition(gActiveBank) ^ BIT_SIDE; + opposingPosition = B_POSITION_OPPOSITE(GetBankPosition(gActiveBank)); - if (gBattleMons[GetBankByIdentity(opposingIdentity)].ability != ABILITY_WONDER_GUARD) + if (gBattleMons[GetBankByPosition(opposingPosition)].ability != ABILITY_WONDER_GUARD) return FALSE; // check if pokemon has a super effective move - for (opposingBank = GetBankByIdentity(opposingIdentity), i = 0; i < 4; i++) + for (opposingBank = GetBankByPosition(opposingPosition), i = 0; i < 4; i++) { move = gBattleMons[gActiveBank].moves[i]; if (move == MOVE_NONE) continue; moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability); - if (moveFlags & MOVESTATUS_SUPEREFFECTIVE) + if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE) return FALSE; } @@ -110,14 +110,14 @@ static bool8 ShouldSwitchIfWonderGuard(void) GetMonData(&party[i], MON_DATA_SPECIES); // unused return value GetMonData(&party[i], MON_DATA_ALT_ABILITY); // unused return value - for (opposingBank = GetBankByIdentity(opposingIdentity), j = 0; j < 4; j++) + for (opposingBank = GetBankByPosition(opposingPosition), j = 0; j < 4; j++) { move = GetMonData(&party[i], MON_DATA_MOVE1 + j); if (move == MOVE_NONE) continue; moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability); - if (moveFlags & MOVESTATUS_SUPEREFFECTIVE && Random() % 3 < 2) + if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % 3 < 2) { // we found a mon *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i; @@ -151,10 +151,10 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { bankIn1 = gActiveBank; - if (gAbsentBankFlags & gBitTable[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)]) + if (gAbsentBankFlags & gBitTable[GetBankByPosition(B_POSITION_PARTNER(GetBankPosition(gActiveBank)))]) bankIn2 = gActiveBank; else - bankIn2 = GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON); + bankIn2 = GetBankByPosition(B_POSITION_PARTNER(GetBankPosition(gActiveBank))); } else { @@ -231,7 +231,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void) static bool8 ShouldSwitchIfNaturalCure(void) { - if (!(gBattleMons[gActiveBank].status1 & STATUS_SLEEP)) + if (!(gBattleMons[gActiveBank].status1 & STATUS1_SLEEP)) return FALSE; if (gBattleMons[gActiveBank].ability != ABILITY_NATURAL_CURE) return FALSE; @@ -251,9 +251,9 @@ static bool8 ShouldSwitchIfNaturalCure(void) return TRUE; } - if (FindMonWithFlagsAndSuperEffective(MOVESTATUS_NOTAFFECTED, 1)) + if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_DOESNT_AFFECT_FOE, 1)) return TRUE; - if (FindMonWithFlagsAndSuperEffective(MOVESTATUS_NOTVERYEFFECTIVE, 1)) + if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 1)) return TRUE; if (Random() & 1) { @@ -267,14 +267,14 @@ static bool8 ShouldSwitchIfNaturalCure(void) static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng) { - u8 opposingIdentity; + u8 opposingPosition; u8 opposingBank; s32 i; u8 moveFlags; u16 move; - opposingIdentity = GetBankPosition(gActiveBank) ^ BIT_SIDE; - opposingBank = GetBankByIdentity(opposingIdentity); + opposingPosition = B_POSITION_OPPOSITE(GetBankPosition(gActiveBank)); + opposingBank = GetBankByPosition(opposingPosition); if (!(gAbsentBankFlags & gBitTable[opposingBank])) { @@ -285,7 +285,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng) continue; moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability); - if (moveFlags & MOVESTATUS_SUPEREFFECTIVE) + if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE) { if (noRng) return TRUE; @@ -297,7 +297,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) return FALSE; - opposingBank = GetBankByIdentity(opposingIdentity ^ BIT_MON); + opposingBank = GetBankByPosition(B_POSITION_PARTNER(opposingPosition)); if (!(gAbsentBankFlags & gBitTable[opposingBank])) { @@ -308,7 +308,7 @@ static bool8 HasSuperEffectiveMoveAgainstOpponents(bool8 noRng) continue; moveFlags = AI_TypeCalc(move, gBattleMons[opposingBank].species, gBattleMons[opposingBank].ability); - if (moveFlags & MOVESTATUS_SUPEREFFECTIVE) + if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE) { if (noRng) return TRUE; @@ -357,10 +357,10 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { bankIn1 = gActiveBank; - if (gAbsentBankFlags & gBitTable[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)]) + if (gAbsentBankFlags & gBitTable[GetBankByPosition(B_POSITION_PARTNER(GetBankPosition(gActiveBank)))]) bankIn2 = gActiveBank; else - bankIn2 = GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON); + bankIn2 = GetBankByPosition(B_POSITION_PARTNER(GetBankPosition(gActiveBank))); } else { @@ -423,7 +423,7 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent) continue; moveFlags = AI_TypeCalc(move, gBattleMons[bankIn1].species, gBattleMons[bankIn1].ability); - if (moveFlags & MOVESTATUS_SUPEREFFECTIVE && Random() % moduloPercent == 0) + if (moveFlags & MOVE_RESULT_SUPER_EFFECTIVE && Random() % moduloPercent == 0) { *(gBattleStruct->AI_monToSwitchIntoId + gActiveBank) = i; EmitTwoReturnValues(1, ACTION_SWITCH, 0); @@ -468,10 +468,10 @@ static bool8 ShouldSwitch(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { bankIn1 = *activeBankPtr; - if (gAbsentBankFlags & gBitTable[GetBankByIdentity(GetBankPosition(*activeBankPtr) ^ BIT_MON)]) + if (gAbsentBankFlags & gBitTable[GetBankByPosition(GetBankPosition(*activeBankPtr) ^ BIT_MON)]) bankIn2 = *activeBankPtr; else - bankIn2 = GetBankByIdentity(GetBankPosition(*activeBankPtr) ^ BIT_MON); + bankIn2 = GetBankByPosition(GetBankPosition(*activeBankPtr) ^ BIT_MON); } else { @@ -530,8 +530,8 @@ static bool8 ShouldSwitch(void) return FALSE; if (AreStatsRaised()) return FALSE; - if (FindMonWithFlagsAndSuperEffective(MOVESTATUS_NOTAFFECTED, 2) - || FindMonWithFlagsAndSuperEffective(MOVESTATUS_NOTVERYEFFECTIVE, 3)) + if (FindMonWithFlagsAndSuperEffective(MOVE_RESULT_DOESNT_AFFECT_FOE, 2) + || FindMonWithFlagsAndSuperEffective(MOVE_RESULT_NOT_VERY_EFFECTIVE, 3)) return TRUE; return FALSE; @@ -561,13 +561,13 @@ void AI_TrySwitchOrUseItem(void) { if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - bankIn1 = GetBankByIdentity(bankIdentity); + bankIn1 = GetBankByPosition(bankIdentity); bankIn2 = bankIn1; } else { - bankIn1 = GetBankByIdentity(bankIdentity); - bankIn2 = GetBankByIdentity(bankIdentity ^ BIT_MON); + bankIn1 = GetBankByPosition(bankIdentity); + bankIn2 = GetBankByPosition(bankIdentity ^ BIT_MON); } if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) @@ -659,10 +659,10 @@ u8 GetMostSuitableMonToSwitchInto(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { bankIn1 = gActiveBank; - if (gAbsentBankFlags & gBitTable[GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON)]) + if (gAbsentBankFlags & gBitTable[GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON)]) bankIn2 = gActiveBank; else - bankIn2 = GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_MON); + bankIn2 = GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_MON); // UB: It considers the opponent only player's side even though it can battle alongside player; opposingBank = Random() & BIT_MON; @@ -671,7 +671,7 @@ u8 GetMostSuitableMonToSwitchInto(void) } else { - opposingBank = GetBankByIdentity(GetBankPosition(gActiveBank) ^ BIT_SIDE); + opposingBank = GetBankByPosition(GetBankPosition(gActiveBank) ^ BIT_SIDE); bankIn1 = gActiveBank; bankIn2 = gActiveBank; } @@ -734,7 +734,7 @@ u8 GetMostSuitableMonToSwitchInto(void) for (i = 0; i < 4; i++) { move = GetMonData(&party[bestMonId], MON_DATA_MOVE1 + i); - if (move != MOVE_NONE && TypeCalc(move, gActiveBank, opposingBank) & MOVESTATUS_SUPEREFFECTIVE) + if (move != MOVE_NONE && TypeCalc(move, gActiveBank, opposingBank) & MOVE_RESULT_SUPER_EFFECTIVE) break; } @@ -752,7 +752,7 @@ u8 GetMostSuitableMonToSwitchInto(void) gDynamicBasePower = 0; gBattleStruct->dynamicMoveType = 0; gBattleScripting.dmgMultiplier = 1; - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gCritMultiplier = 1; bestDmg = 0; bestMonId = 6; @@ -877,27 +877,27 @@ static bool8 ShouldUseItem(void) break; case AI_ITEM_CURE_CONDITION: *(gBattleStruct->AI_itemFlags + gActiveBank / 2) = 0; - if (itemEffects[3] & 0x20 && gBattleMons[gActiveBank].status1 & STATUS_SLEEP) + if (itemEffects[3] & 0x20 && gBattleMons[gActiveBank].status1 & STATUS1_SLEEP) { *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x20; shouldUse = TRUE; } - if (itemEffects[3] & 0x10 && (gBattleMons[gActiveBank].status1 & STATUS_POISON || gBattleMons[gActiveBank].status1 & STATUS_TOXIC_POISON)) + if (itemEffects[3] & 0x10 && (gBattleMons[gActiveBank].status1 & STATUS1_POISON || gBattleMons[gActiveBank].status1 & STATUS1_TOXIC_POISON)) { *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x10; shouldUse = TRUE; } - if (itemEffects[3] & 0x8 && gBattleMons[gActiveBank].status1 & STATUS_BURN) + if (itemEffects[3] & 0x8 && gBattleMons[gActiveBank].status1 & STATUS1_BURN) { *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x8; shouldUse = TRUE; } - if (itemEffects[3] & 0x4 && gBattleMons[gActiveBank].status1 & STATUS_FREEZE) + if (itemEffects[3] & 0x4 && gBattleMons[gActiveBank].status1 & STATUS1_FREEZE) { *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x4; shouldUse = TRUE; } - if (itemEffects[3] & 0x2 && gBattleMons[gActiveBank].status1 & STATUS_PARALYSIS) + if (itemEffects[3] & 0x2 && gBattleMons[gActiveBank].status1 & STATUS1_PARALYSIS) { *(gBattleStruct->AI_itemFlags + gActiveBank / 2) |= 0x2; shouldUse = TRUE; diff --git a/src/battle_anim.c b/src/battle_anim.c index ecaff67a8..76da24383 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -26,7 +26,7 @@ #define ANIM_SPRITE_INDEX_COUNT 8 extern u8 gBankAttacker; -extern u8 gBankTarget; +extern u8 gBankDefender; extern u16 gBattle_WIN0H; extern u16 gBattle_WIN0V; extern u16 gBattle_WIN1H; @@ -222,7 +222,7 @@ void ClearBattleAnimationVars(void) void DoMoveAnim(u16 move) { gAnimBankAttacker = gBankAttacker; - gAnimBankTarget = gBankTarget; + gAnimBankTarget = gBankDefender; LaunchBattleAnimation(gBattleAnims_Moves, move, TRUE); } diff --git a/src/battle_bg.c b/src/battle_bg.c index 5d5bbf0e9..4bb1e65a9 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -273,13 +273,13 @@ static void sub_8035AE4(u8 taskId, u8 bank, u8 bgId, u8 destX, u8 destY) static void sub_8035C4C(void) { - if (gBattleOutcome == BATTLE_DREW) + if (gBattleOutcome == B_OUTCOME_DREW) { BattleHandleAddTextPrinter(gText_Draw, 0x15); } else if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - if (gBattleOutcome == BATTLE_WON) + if (gBattleOutcome == B_OUTCOME_WON) { switch (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18) { @@ -324,7 +324,7 @@ static void sub_8035C4C(void) } } } - else if (gBattleOutcome == BATTLE_WON) + else if (gBattleOutcome == B_OUTCOME_WON) { if (gLinkPlayers[gBattleScripting.multiplayerId].lp_field_18 != 0) { diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c index a72650537..1733ee966 100644 --- a/src/battle_controller_link_opponent.c +++ b/src/battle_controller_link_opponent.c @@ -28,7 +28,7 @@ extern u32 gBattleExecBuffer; extern u8 gActiveBank; extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern bool8 gDoingBattleAnim; extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); extern void (*gPreBattleCallback1)(void); @@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gAbsentBankFlags; extern u8 gUnknown_020244B4[]; extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; @@ -1875,10 +1875,10 @@ static void LinkOpponentHandleCmd55(void) { sub_81851A8(&gBattleBufferA[gActiveBank][4]); - if (gBattleBufferA[gActiveBank][1] == BATTLE_DREW) + if (gBattleBufferA[gActiveBank][1] == B_OUTCOME_DREW) gBattleOutcome = gBattleBufferA[gActiveBank][1]; else - gBattleOutcome = gBattleBufferA[gActiveBank][1] ^ BATTLE_DREW; + gBattleOutcome = gBattleBufferA[gActiveBank][1] ^ B_OUTCOME_DREW; gSaveBlock2Ptr->field_CA9_b = gBattleBufferA[gActiveBank][2]; FadeOutMapMusic(5); diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c index 14061b3a9..9835f6cb2 100644 --- a/src/battle_controller_link_partner.c +++ b/src/battle_controller_link_partner.c @@ -28,7 +28,7 @@ extern u32 gBattleExecBuffer; extern u8 gActiveBank; extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern bool8 gDoingBattleAnim; extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); extern void (*gPreBattleCallback1)(void); @@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gAbsentBankFlags; extern u8 gUnknown_020244B4[]; extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c index d3e72c0ad..6940fdc73 100644 --- a/src/battle_controller_opponent.c +++ b/src/battle_controller_opponent.c @@ -30,7 +30,7 @@ extern u32 gBattleExecBuffer; extern u8 gActiveBank; -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gAbsentBankFlags; extern bool8 gDoingBattleAnim; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; @@ -1581,18 +1581,18 @@ static void OpponentHandleChooseMove(void) EmitTwoReturnValues(1, ACTION_RUN, 0); break; case 6: - EmitTwoReturnValues(1, 15, gBankTarget); + EmitTwoReturnValues(1, 15, gBankDefender); break; default: if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_USER | MOVE_TARGET_x10)) - gBankTarget = gActiveBank; + gBankDefender = gActiveBank; if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH) { - gBankTarget = GetBankByIdentity(B_POSITION_PLAYER_LEFT); - if (gAbsentBankFlags & gBitTable[gBankTarget]) - gBankTarget = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + gBankDefender = GetBankByPosition(B_POSITION_PLAYER_LEFT); + if (gAbsentBankFlags & gBitTable[gBankDefender]) + gBankDefender = GetBankByPosition(B_POSITION_PLAYER_RIGHT); } - EmitTwoReturnValues(1, 10, (chosenMoveId) | (gBankTarget << 8)); + EmitTwoReturnValues(1, 10, (chosenMoveId) | (gBankDefender << 8)); break; } OpponentBufferExecCompleted(); @@ -1609,9 +1609,9 @@ static void OpponentHandleChooseMove(void) if (gBattleMoves[move].target & (MOVE_TARGET_USER | MOVE_TARGET_x10)) EmitTwoReturnValues(1, 10, (chosenMoveId) | (gActiveBank << 8)); else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBankByIdentity(Random() & 2) << 8)); + EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBankByPosition(Random() & 2) << 8)); else - EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBankByIdentity(B_POSITION_PLAYER_LEFT) << 8)); + EmitTwoReturnValues(1, 10, (chosenMoveId) | (GetBankByPosition(B_POSITION_PLAYER_LEFT) << 8)); OpponentBufferExecCompleted(); } @@ -1638,12 +1638,12 @@ static void OpponentHandleChoosePokemon(void) if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - bank2 = bank1 = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + bank2 = bank1 = GetBankByPosition(B_POSITION_OPPONENT_LEFT); } else { - bank1 = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); - bank2 = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + bank1 = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + bank2 = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); } if (gBattleTypeFlags & (BATTLE_TYPE_TWO_OPPONENTS | BATTLE_TYPE_x800000)) diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c index dfbf9df94..e8a6898f8 100644 --- a/src/battle_controller_player.c +++ b/src/battle_controller_player.c @@ -33,7 +33,7 @@ extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT]; extern u8 gAbsentBankFlags; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern bool8 gDoingBattleAnim; extern u8 gPlayerDpadHoldFrames; extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); @@ -358,7 +358,7 @@ static void HandleInputChooseAction(void) { if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE) && GetBankPosition(gActiveBank) == B_POSITION_PLAYER_RIGHT - && !(gAbsentBankFlags & gBitTable[GetBankByIdentity(B_POSITION_PLAYER_LEFT)]) + && !(gAbsentBankFlags & gBitTable[GetBankByPosition(B_POSITION_PLAYER_LEFT)]) && !(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { if (gBattleBufferA[gActiveBank][1] == ACTION_USE_ITEM) @@ -397,14 +397,14 @@ static void HandleInputChooseTarget(void) // what a weird loop i = 0; - if (gNoOfAllBanks != 0) + if (gBattleBanksCount != 0) { do { if (i != gMultiUsePlayerCursor) dp11b_obj_free(i, 1); i++; - } while (i < gNoOfAllBanks); + } while (i < gBattleBanksCount); } if (gMain.heldKeys & DPAD_ANY && gSaveBlock2Ptr->optionsButtonMode == 2) @@ -447,8 +447,8 @@ static void HandleInputChooseTarget(void) { if (--i < 0) i = 4; // UB: array out of range - gMultiUsePlayerCursor = GetBankByIdentity(identities[i]); - } while (gMultiUsePlayerCursor == gNoOfAllBanks); + gMultiUsePlayerCursor = GetBankByPosition(identities[i]); + } while (gMultiUsePlayerCursor == gBattleBanksCount); i = 0; switch (GetBankPosition(gMultiUsePlayerCursor)) @@ -489,8 +489,8 @@ static void HandleInputChooseTarget(void) { if (++i > 3) i = 0; - gMultiUsePlayerCursor = GetBankByIdentity(identities[i]); - } while (gMultiUsePlayerCursor == gNoOfAllBanks); + gMultiUsePlayerCursor = GetBankByPosition(identities[i]); + } while (gMultiUsePlayerCursor == gBattleBanksCount); i = 0; switch (GetBankPosition(gMultiUsePlayerCursor)) @@ -545,7 +545,7 @@ static void HandleInputChooseMove(void) if (moveTarget & MOVE_TARGET_x10) gMultiUsePlayerCursor = gActiveBank; else - gMultiUsePlayerCursor = GetBankByIdentity((GetBankPosition(gActiveBank) & BIT_SIDE) ^ BIT_SIDE); + gMultiUsePlayerCursor = GetBankByPosition((GetBankPosition(gActiveBank) & BIT_SIDE) ^ BIT_SIDE); if (!gBattleBufferA[gActiveBank][1]) // not a double battle { @@ -579,10 +579,10 @@ static void HandleInputChooseMove(void) if (moveTarget & (MOVE_TARGET_x10 | MOVE_TARGET_USER)) gMultiUsePlayerCursor = gActiveBank; - else if (gAbsentBankFlags & gBitTable[GetBankByIdentity(B_POSITION_OPPONENT_LEFT)]) - gMultiUsePlayerCursor = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + else if (gAbsentBankFlags & gBitTable[GetBankByPosition(B_POSITION_OPPONENT_LEFT)]) + gMultiUsePlayerCursor = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); else - gMultiUsePlayerCursor = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + gMultiUsePlayerCursor = GetBankByPosition(B_POSITION_OPPONENT_LEFT); gSprites[gBankSpriteIds[gMultiUsePlayerCursor]].callback = sub_8039AD8; } @@ -905,7 +905,7 @@ static void sub_80586F8(void) gMain.inBattle = 0; gMain.callback1 = gPreBattleCallback1; SetMainCallback2(sub_8038D64); - if (gBattleOutcome == BATTLE_WON) + if (gBattleOutcome == B_OUTCOME_WON) sub_817E3F4(); FreeAllWindowBuffers(); } @@ -918,7 +918,7 @@ static void sub_80586F8(void) gMain.inBattle = 0; gMain.callback1 = gPreBattleCallback1; SetMainCallback2(sub_8038D64); - if (gBattleOutcome == BATTLE_WON) + if (gBattleOutcome == B_OUTCOME_WON) sub_817E3F4(); FreeAllWindowBuffers(); } @@ -2463,7 +2463,7 @@ static void PlayerHandleSuccessBallThrowAnim(void) { gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; } @@ -2473,7 +2473,7 @@ static void PlayerHandleBallThrowAnim(void) gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; } diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c index 5d6f07a48..1da8ee04c 100644 --- a/src/battle_controller_player_partner.c +++ b/src/battle_controller_player_partner.c @@ -27,7 +27,7 @@ extern u32 gBattleExecBuffer; extern u8 gActiveBank; extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern bool8 gDoingBattleAnim; extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); extern void (*gPreBattleCallback1)(void); @@ -47,7 +47,7 @@ extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gAbsentBankFlags; extern u8 gUnknown_020244B4[]; extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; @@ -1545,15 +1545,15 @@ static void PlayerPartnerHandleChooseMove(void) chosenMoveId = BattleAI_ChooseMoveOrAction(); if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & (MOVE_TARGET_x10 | MOVE_TARGET_USER)) - gBankTarget = gActiveBank; + gBankDefender = gActiveBank; if (gBattleMoves[moveInfo->moves[chosenMoveId]].target & MOVE_TARGET_BOTH) { - gBankTarget = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); - if (gAbsentBankFlags & gBitTable[gBankTarget]) - gBankTarget = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + if (gAbsentBankFlags & gBitTable[gBankDefender]) + gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); } - EmitTwoReturnValues(1, 10, chosenMoveId | (gBankTarget << 8)); + EmitTwoReturnValues(1, 10, chosenMoveId | (gBankDefender << 8)); PlayerPartnerBufferExecCompleted(); } @@ -1568,8 +1568,8 @@ static void PlayerPartnerHandleChoosePokemon(void) if (chosenMonId == 6) // just switch to the next mon { - u8 playerMonIdentity = GetBankByIdentity(B_POSITION_PLAYER_LEFT); - u8 selfIdentity = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + u8 playerMonIdentity = GetBankByPosition(B_POSITION_PLAYER_LEFT); + u8 selfIdentity = GetBankByPosition(B_POSITION_PLAYER_RIGHT); for (chosenMonId = 3; chosenMonId < 6; chosenMonId++) { diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c index e5e0bef84..e970c5f58 100644 --- a/src/battle_controller_recorded_opponent.c +++ b/src/battle_controller_recorded_opponent.c @@ -29,7 +29,7 @@ extern u32 gBattleExecBuffer; extern u8 gActiveBank; extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern bool8 gDoingBattleAnim; extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); extern void (*gPreBattleCallback1)(void); @@ -48,7 +48,7 @@ extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gAbsentBankFlags; extern u8 gUnknown_020244B4[]; extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; @@ -1814,10 +1814,10 @@ static void RecordedOpponentHandleResetActionMoveSelection(void) static void RecordedOpponentHandleCmd55(void) { - if (gBattleBufferA[gActiveBank][1] == BATTLE_DREW) + if (gBattleBufferA[gActiveBank][1] == B_OUTCOME_DREW) gBattleOutcome = gBattleBufferA[gActiveBank][1]; else - gBattleOutcome = gBattleBufferA[gActiveBank][1] ^ BATTLE_DREW; + gBattleOutcome = gBattleBufferA[gActiveBank][1] ^ B_OUTCOME_DREW; FadeOutMapMusic(5); BeginFastPaletteFade(3); diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c index 183da6bfd..775ea3e7c 100644 --- a/src/battle_controller_recorded_player.c +++ b/src/battle_controller_recorded_player.c @@ -28,7 +28,7 @@ extern u32 gBattleExecBuffer; extern u8 gActiveBank; extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern bool8 gDoingBattleAnim; extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); extern void (*gPreBattleCallback1)(void); @@ -48,7 +48,7 @@ extern u8 gUnknown_03005D7C[BATTLE_BANKS_COUNT]; extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; extern u16 gPartnerTrainerId; extern u8 GetFrontierTrainerFrontSpriteId(u16 trainerId); -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gAbsentBankFlags; extern u8 gUnknown_020244B4[]; extern u32 gTransformedPersonalities[BATTLE_BANKS_COUNT]; @@ -1445,7 +1445,7 @@ static void RecordedPlayerHandlePrintSelectionString(void) static void ChooseActionInBattlePalace(void) { - if (gBattleCommunication[4] >= gNoOfAllBanks / 2) + if (gBattleCommunication[4] >= gBattleBanksCount / 2) { EmitTwoReturnValues(1, RecordedBattle_ReadBankAction(gActiveBank), 0); RecordedPlayerBufferExecCompleted(); diff --git a/src/battle_controller_safari.c b/src/battle_controller_safari.c index a04f06d8c..a605e4cb8 100644 --- a/src/battle_controller_safari.c +++ b/src/battle_controller_safari.c @@ -26,7 +26,7 @@ extern u32 gBattleExecBuffer; extern u8 gActiveBank; extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern bool8 gDoingBattleAnim; extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); extern void (*gPreBattleCallback1)(void); @@ -415,7 +415,7 @@ static void SafariHandleSuccessBallThrowAnim(void) { gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; } @@ -425,7 +425,7 @@ static void SafariHandleBallThrowAnim(void) gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnSpecialAnimDone; } diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c index 8a34763f6..11fb0074f 100644 --- a/src/battle_controller_wally.c +++ b/src/battle_controller_wally.c @@ -34,7 +34,7 @@ extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT]; extern u8 gAbsentBankFlags; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern bool8 gDoingBattleAnim; extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; @@ -1113,7 +1113,7 @@ static void WallyHandleSuccessBallThrowAnim(void) { gBattleSpritesDataPtr->animationData->ballThrowCaseId = BALL_3_SHAKES_SUCCESS; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnFinishedAnimation; } @@ -1123,7 +1123,7 @@ static void WallyHandleBallThrowAnim(void) gBattleSpritesDataPtr->animationData->ballThrowCaseId = ballThrowCaseId; gDoingBattleAnim = TRUE; - InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByIdentity(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); + InitAndLaunchSpecialAnimation(gActiveBank, gActiveBank, GetBankByPosition(B_POSITION_OPPONENT_LEFT), B_ANIM_SAFARI_BALL_THROW); gBattleBankFunc[gActiveBank] = CompleteOnFinishedAnimation; } diff --git a/src/battle_controllers.c b/src/battle_controllers.c index 467ce3640..91f014876 100644 --- a/src/battle_controllers.c +++ b/src/battle_controllers.c @@ -19,7 +19,7 @@ extern void (*gBattleBankFunc[BATTLE_BANKS_COUNT])(void); extern u8 gBankPositions[BATTLE_BANKS_COUNT]; extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; extern u8 gMoveSelectionCursor[BATTLE_BANKS_COUNT]; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern u8 gActiveBank; extern u8 gUnknown_0202428C; extern u32 gUnknown_02022FF4; @@ -32,7 +32,7 @@ extern u8 gUnknown_02022D08; extern u8 gUnknown_02022D09; extern u8 gUnknown_02022D0A; extern u8 gBankAttacker; -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gAbsentBankFlags; extern u8 gEffectBank; extern u16 gBattleWeather; @@ -124,7 +124,7 @@ void sub_8032768(void) if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) sub_81B8D64(i, 0); } @@ -172,7 +172,7 @@ static void SetControllersVariables(void) gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; } - gNoOfAllBanks = 4; + gBattleBanksCount = 4; sub_81B8D64(0, 0); sub_81B8D64(1, 0); @@ -200,7 +200,7 @@ static void SetControllersVariables(void) gBattleBankFunc[1] = SetControllerToOpponent; gBankPositions[1] = B_POSITION_OPPONENT_LEFT; - gNoOfAllBanks = 2; + gBattleBanksCount = 2; if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { @@ -216,7 +216,7 @@ static void SetControllersVariables(void) gBattleBankFunc[1] = SetControllerToRecordedOpponent; gBankPositions[1] = B_POSITION_OPPONENT_LEFT; - gNoOfAllBanks = 2; + gBattleBanksCount = 2; } else // see how the banks are switched { @@ -226,7 +226,7 @@ static void SetControllersVariables(void) gBattleBankFunc[0] = SetControllerToRecordedOpponent; gBankPositions[0] = B_POSITION_OPPONENT_LEFT; - gNoOfAllBanks = 2; + gBattleBanksCount = 2; } } else @@ -255,7 +255,7 @@ static void SetControllersVariables(void) gBattleBankFunc[3] = SetControllerToOpponent; gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; - gNoOfAllBanks = 4; + gBattleBanksCount = 4; if (gBattleTypeFlags & BATTLE_TYPE_RECORDED) { @@ -275,7 +275,7 @@ static void SetControllersVariables(void) gBattleBankFunc[3] = SetControllerToOpponent; gBankPositions[3] = 3; - gNoOfAllBanks = 4; + gBattleBanksCount = 4; sub_81B8D64(0, 0); sub_81B8D64(1, 0); @@ -430,7 +430,7 @@ static void SetControllersVariablesInLinkBattle(void) gBattleBankFunc[1] = SetControllerToLinkOpponent; gBankPositions[1] = B_POSITION_OPPONENT_LEFT; - gNoOfAllBanks = 2; + gBattleBanksCount = 2; } else { @@ -440,7 +440,7 @@ static void SetControllersVariablesInLinkBattle(void) gBattleBankFunc[0] = SetControllerToLinkOpponent; gBankPositions[0] = B_POSITION_OPPONENT_LEFT; - gNoOfAllBanks = 2; + gBattleBanksCount = 2; } } else if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI) && gBattleTypeFlags & BATTLE_TYPE_DOUBLE) @@ -461,7 +461,7 @@ static void SetControllersVariablesInLinkBattle(void) gBattleBankFunc[3] = SetControllerToLinkOpponent; gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; - gNoOfAllBanks = 4; + gBattleBanksCount = 4; } else { @@ -477,7 +477,7 @@ static void SetControllersVariablesInLinkBattle(void) gBattleBankFunc[2] = SetControllerToLinkOpponent; gBankPositions[2] = B_POSITION_OPPONENT_RIGHT; - gNoOfAllBanks = 4; + gBattleBanksCount = 4; } } else if (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER) @@ -498,7 +498,7 @@ static void SetControllersVariablesInLinkBattle(void) gBattleBankFunc[3] = SetControllerToOpponent; gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; - gNoOfAllBanks = 4; + gBattleBanksCount = 4; } else { @@ -514,7 +514,7 @@ static void SetControllersVariablesInLinkBattle(void) gBattleBankFunc[3] = SetControllerToLinkOpponent; gBankPositions[3] = B_POSITION_OPPONENT_RIGHT; - gNoOfAllBanks = 4; + gBattleBanksCount = 4; } sub_81B8D64(0, 0); @@ -604,7 +604,7 @@ static void SetControllersVariablesInLinkBattle(void) } } - gNoOfAllBanks = 4; + gBattleBanksCount = 4; } } @@ -614,7 +614,7 @@ static void SetBattlePartyIds(void) if (!(gBattleTypeFlags & BATTLE_TYPE_MULTI)) { - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { for (j = 0; j < 6; j++) { @@ -753,7 +753,7 @@ 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] = gActiveBank; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ATTACKER] = gBankAttacker; - gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_TARGET] = gBankTarget; + gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_TARGET] = gBankDefender; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_SIZE_LO] = alignedSize; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_SIZE_HI] = (alignedSize & 0x0000FF00) >> 8; gLinkBattleSendBuffer[gTasks[gUnknown_02022D08].data[14] + LINK_BUFF_ABSENT_BANK_FLAGS] = gAbsentBankFlags; @@ -921,7 +921,7 @@ static void Task_HandleCopyReceivedLinkBuffersData(u8 taskId) if (!(gBattleTypeFlags & BATTLE_TYPE_WILD)) { gBankAttacker = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 2]; - gBankTarget = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 3]; + gBankDefender = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 3]; gAbsentBankFlags = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 6]; gEffectBank = gLinkBattleRecvBuffer[gTasks[taskId].data[15] + 7]; } diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index 5ded24863..d6a52b898 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -25,7 +25,7 @@ extern u8 gBattleBufferA[BATTLE_BANKS_COUNT][0x200]; extern u8 gActiveBank; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern u16 gUnknown_020243FC; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; @@ -262,7 +262,7 @@ u16 ChooseMoveAndTargetInBattlePalace(void) else if (var1 == MOVE_TARGET_SELECTED) chosenMoveId |= (BattlePalaceGetTargetRetValue()); else - chosenMoveId |= (GetBankByIdentity((GetBankPosition(gActiveBank) & BIT_SIDE) ^ BIT_SIDE) << 8); + chosenMoveId |= (GetBankByPosition((GetBankPosition(gActiveBank) & BIT_SIDE) ^ BIT_SIDE) << 8); return chosenMoveId; } @@ -299,13 +299,13 @@ static u16 BattlePalaceGetTargetRetValue(void) if (GetBankSide(gActiveBank) == SIDE_PLAYER) { - opposing1 = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); - opposing2 = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + opposing1 = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + opposing2 = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); } else { - opposing1 = GetBankByIdentity(B_POSITION_PLAYER_LEFT); - opposing2 = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + opposing1 = GetBankByPosition(B_POSITION_PLAYER_LEFT); + opposing2 = GetBankByPosition(B_POSITION_PLAYER_RIGHT); } if (gBattleMons[opposing1].hp == gBattleMons[opposing2].hp) @@ -391,15 +391,15 @@ void InitAndLaunchChosenStatusAnimation(bool8 isStatus2, u32 status) gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 1; if (!isStatus2) { - if (status == STATUS_FREEZE) + if (status == STATUS1_FREEZE) LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_FRZ); - else if (status == STATUS_POISON || status & STATUS_TOXIC_POISON) + else if (status == STATUS1_POISON || status & STATUS1_TOXIC_POISON) LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_PSN); - else if (status == STATUS_BURN) + else if (status == STATUS1_BURN) LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_BRN); - else if (status & STATUS_SLEEP) + else if (status & STATUS1_SLEEP) LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_SLP); - else if (status == STATUS_PARALYSIS) + else if (status == STATUS1_PARALYSIS) LaunchStatusAnimation(gActiveBank, B_ANIM_STATUS_PRZ); else // no animation gBattleSpritesDataPtr->healthBoxesData[gActiveBank].statusAnimActive = 0; @@ -807,7 +807,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank) gHealthBoxesIds[*bank] = CreateBankHealthboxSprites(*bank); (*bank)++; - if (*bank == gNoOfAllBanks) + if (*bank == gBattleBanksCount) { *bank = 0; (*state1)++; @@ -821,7 +821,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank) DummyBattleInterfaceFunc(gHealthBoxesIds[*bank], TRUE); (*bank)++; - if (*bank == gNoOfAllBanks) + if (*bank == gBattleBanksCount) { *bank = 0; (*state1)++; @@ -839,7 +839,7 @@ bool8 BattleInitAllSprites(u8 *state1, u8 *bank) } SetHealthboxSpriteInvisible(gHealthBoxesIds[*bank]); (*bank)++; - if (*bank == gNoOfAllBanks) + if (*bank == gBattleBanksCount) { *bank = 0; (*state1)++; @@ -871,7 +871,7 @@ void CopyAllBattleSpritesInvisibilities(void) { s32 i; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) gBattleSpritesDataPtr->bankData[i].invisible = gSprites[gBankSpriteIds[i]].invisible; } @@ -1080,7 +1080,7 @@ void HandleLowHpMusicChange(struct Pokemon *mon, u8 bank) void BattleStopLowHpSound(void) { - u8 playerBank = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + u8 playerBank = GetBankByPosition(B_POSITION_PLAYER_LEFT); gBattleSpritesDataPtr->bankData[playerBank].lowHpSong = 0; if (IsDoubleBattle()) @@ -1101,8 +1101,8 @@ void sub_805EAE8(void) { if (gMain.inBattle) { - u8 playerBank1 = GetBankByIdentity(B_POSITION_PLAYER_LEFT); - u8 playerBank2 = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + u8 playerBank1 = GetBankByPosition(B_POSITION_PLAYER_LEFT); + u8 playerBank2 = GetBankByPosition(B_POSITION_PLAYER_RIGHT); u8 bank1PartyId = pokemon_order_func(gBattlePartyID[playerBank1]); u8 bank2PartyId = pokemon_order_func(gBattlePartyID[playerBank2]); @@ -1117,7 +1117,7 @@ void sub_805EB9C(u8 affineMode) { s32 i; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (IsBankSpritePresent(i)) { @@ -1143,13 +1143,13 @@ void LoadAndCreateEnemyShadowSprites(void) LoadCompressedObjectPic(&gSpriteSheet_EnemyShadow); - bank = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + bank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBankCoord(bank, 0), GetBankCoord(bank, 1) + 29, 0xC8); gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank; if (IsDoubleBattle()) { - bank = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + bank = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId = CreateSprite(&gSpriteTemplate_EnemyShadow, GetBankCoord(bank, 0), GetBankCoord(bank, 1) + 29, 0xC8); gSprites[gBattleSpritesDataPtr->healthBoxesData[bank].shadowSpriteId].data[0] = bank; } @@ -1286,7 +1286,7 @@ bool32 ShouldPlayNormalPokeCry(struct Pokemon *mon) s16 hp, maxHP; s32 barLevel; - if (GetMonData(mon, MON_DATA_STATUS) & (STATUS_ANY | STATUS_TOXIC_COUNTER)) + if (GetMonData(mon, MON_DATA_STATUS) & (STATUS1_ANY | STATUS1_TOXIC_COUNTER)) return FALSE; hp = GetMonData(mon, MON_DATA_HP); diff --git a/src/battle_interface.c b/src/battle_interface.c index 05f500860..da44d3a02 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -154,7 +154,7 @@ enum extern u8 gBankPositions[BATTLE_BANKS_COUNT]; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern u8 gHealthBoxesIds[BATTLE_BANKS_COUNT]; extern const u8 * const gNatureNamePointers[]; @@ -1086,7 +1086,7 @@ void UpdateOamPriorityInAllHealthboxes(u8 priority) { s32 i; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { u8 healthboxSpriteId_1 = gHealthBoxesIds[i]; u8 healthboxSpriteId_2 = gSprites[gHealthBoxesIds[i]].oam.affineParam; @@ -1414,7 +1414,7 @@ void SwapHpBarsWithHpText(void) s32 i; u8 spriteId; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gSprites[gHealthBoxesIds[i]].callback == SpriteCallbackDummy && GetBankSide(i) != SIDE_OPPONENT @@ -2029,27 +2029,27 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId) tileNumAdder = 0x11; } - if (status & STATUS_SLEEP) + if (status & STATUS1_SLEEP) { statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_SLP_BANK0, bank)); statusPalId = PAL_STATUS_SLP; } - else if (status & STATUS_PSN_ANY) + else if (status & STATUS1_PSN_ANY) { statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PSN_BANK0, bank)); statusPalId = PAL_STATUS_PSN; } - else if (status & STATUS_BURN) + else if (status & STATUS1_BURN) { statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_BRN_BANK0, bank)); statusPalId = PAL_STATUS_BRN; } - else if (status & STATUS_FREEZE) + else if (status & STATUS1_FREEZE) { statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_FRZ_BANK0, bank)); statusPalId = PAL_STATUS_FRZ; } - else if (status & STATUS_PARALYSIS) + else if (status & STATUS1_PARALYSIS) { statusGfxPtr = GetHealthboxElementGfxPtr(GetStatusIconForBankId(HEALTHBOX_GFX_STATUS_PRZ_BANK0, bank)); statusPalId = PAL_STATUS_PAR; diff --git a/src/battle_message.c b/src/battle_message.c index 80aa5e3f9..a08378058 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -18,7 +18,7 @@ extern u16 gLastUsedItem; extern u8 gLastUsedAbility; extern u8 gActiveBank; extern u8 gBankAttacker; -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gStringBank; extern u8 gEffectBank; extern u8 gAbilitiesPerBank[BATTLE_BANKS_COUNT]; @@ -1631,13 +1631,13 @@ void BufferStringBattle(u16 stringID) stringPtr = gText_AttackerUsedX; break; case STRINGID_BATTLEEND: // battle end - if (gBattleTextBuff1[0] & OUTCOME_LINK_BATTLE_RUN) + if (gBattleTextBuff1[0] & B_OUTCOME_LINK_BATTLE_RAN) { - gBattleTextBuff1[0] &= ~(OUTCOME_LINK_BATTLE_RUN); - if (GetBankSide(gActiveBank) == SIDE_OPPONENT && gBattleTextBuff1[0] != BATTLE_DREW) - gBattleTextBuff1[0] ^= (BATTLE_LOST | BATTLE_WON); + gBattleTextBuff1[0] &= ~(B_OUTCOME_LINK_BATTLE_RAN); + if (GetBankSide(gActiveBank) == SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW) + gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON); - if (gBattleTextBuff1[0] == BATTLE_LOST || gBattleTextBuff1[0] == BATTLE_DREW) + if (gBattleTextBuff1[0] == B_OUTCOME_LOST || gBattleTextBuff1[0] == B_OUTCOME_DREW) stringPtr = gText_GotAwaySafely; else if (gBattleTypeFlags & BATTLE_TYPE_MULTI) stringPtr = gText_TwoWildFled; @@ -1646,23 +1646,23 @@ void BufferStringBattle(u16 stringID) } else { - if (GetBankSide(gActiveBank) == SIDE_OPPONENT && gBattleTextBuff1[0] != BATTLE_DREW) - gBattleTextBuff1[0] ^= (BATTLE_LOST | BATTLE_WON); + if (GetBankSide(gActiveBank) == SIDE_OPPONENT && gBattleTextBuff1[0] != B_OUTCOME_DREW) + gBattleTextBuff1[0] ^= (B_OUTCOME_LOST | B_OUTCOME_WON); if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { switch (gBattleTextBuff1[0]) { - case BATTLE_WON: + case B_OUTCOME_WON: if (gBattleTypeFlags & BATTLE_TYPE_x800000) stringPtr = gText_TwoInGameTrainersDefeated; else stringPtr = gText_TwoLinkTrainersDefeated; break; - case BATTLE_LOST: + case B_OUTCOME_LOST: stringPtr = gText_PlayerLostToTwo; break; - case BATTLE_DREW: + case B_OUTCOME_DREW: stringPtr = gText_PlayerBattledToDrawVsTwo; break; } @@ -1671,13 +1671,13 @@ void BufferStringBattle(u16 stringID) { switch (gBattleTextBuff1[0]) { - case BATTLE_WON: + case B_OUTCOME_WON: stringPtr = gText_PlayerDefeatedLinkTrainerTrainer1; break; - case BATTLE_LOST: + case B_OUTCOME_LOST: stringPtr = gText_PlayerLostAgainstTrainer1; break; - case BATTLE_DREW: + case B_OUTCOME_DREW: stringPtr = gText_PlayerBattledToDrawTrainer1; break; } @@ -1686,13 +1686,13 @@ void BufferStringBattle(u16 stringID) { switch (gBattleTextBuff1[0]) { - case BATTLE_WON: + case B_OUTCOME_WON: stringPtr = gText_PlayerDefeatedLinkTrainer; break; - case BATTLE_LOST: + case B_OUTCOME_LOST: stringPtr = gText_PlayerLostAgainstLinkTrainer; break; - case BATTLE_DREW: + case B_OUTCOME_DREW: stringPtr = gText_PlayerBattledToDrawLinkTrainer; break; } @@ -1834,25 +1834,25 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = gStringVar3; break; case B_TXT_PLAYER_MON1_NAME: // first player poke name - GetMonData(&gPlayerParty[gBattlePartyID[GetBankByIdentity(B_POSITION_PLAYER_LEFT)]], + GetMonData(&gPlayerParty[gBattlePartyID[GetBankByPosition(B_POSITION_PLAYER_LEFT)]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; break; case B_TXT_OPPONENT_MON1_NAME: // first enemy poke name - GetMonData(&gEnemyParty[gBattlePartyID[GetBankByIdentity(B_POSITION_OPPONENT_LEFT)]], + GetMonData(&gEnemyParty[gBattlePartyID[GetBankByPosition(B_POSITION_OPPONENT_LEFT)]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; break; case B_TXT_PLAYER_MON2_NAME: // second player poke name - GetMonData(&gPlayerParty[gBattlePartyID[GetBankByIdentity(B_POSITION_PLAYER_RIGHT)]], + GetMonData(&gPlayerParty[gBattlePartyID[GetBankByPosition(B_POSITION_PLAYER_RIGHT)]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; break; case B_TXT_OPPONENT_MON2_NAME: // second enemy poke name - GetMonData(&gEnemyParty[gBattlePartyID[GetBankByIdentity(B_POSITION_OPPONENT_RIGHT)]], + GetMonData(&gEnemyParty[gBattlePartyID[GetBankByPosition(B_POSITION_OPPONENT_RIGHT)]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; @@ -1883,13 +1883,13 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) break; case B_TXT_ATK_NAME_WITH_PREFIX_MON1: // attacker name with prefix, only bank 0/1 HANDLE_NICKNAME_STRING_CASE(gBankAttacker, - gBattlePartyID[GetBankByIdentity(GET_BANK_SIDE(gBankAttacker))]) + gBattlePartyID[GetBankByPosition(GET_BANK_SIDE(gBankAttacker))]) break; case B_TXT_ATK_PARTNER_NAME: // attacker partner name if (GetBankSide(gBankAttacker) == SIDE_PLAYER) - GetMonData(&gPlayerParty[gBattlePartyID[GetBankByIdentity(GET_BANK_SIDE(gBankAttacker)) + 2]], MON_DATA_NICKNAME, text); + GetMonData(&gPlayerParty[gBattlePartyID[GetBankByPosition(GET_BANK_SIDE(gBankAttacker)) + 2]], MON_DATA_NICKNAME, text); else - GetMonData(&gEnemyParty[gBattlePartyID[GetBankByIdentity(GET_BANK_SIDE(gBankAttacker)) + 2]], MON_DATA_NICKNAME, text); + GetMonData(&gEnemyParty[gBattlePartyID[GetBankByPosition(GET_BANK_SIDE(gBankAttacker)) + 2]], MON_DATA_NICKNAME, text); StringGetEnd10(text); toCpy = text; @@ -1898,7 +1898,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) HANDLE_NICKNAME_STRING_CASE(gBankAttacker, gBattlePartyID[gBankAttacker]) break; case B_TXT_DEF_NAME_WITH_PREFIX: // target name with prefix - HANDLE_NICKNAME_STRING_CASE(gBankTarget, gBattlePartyID[gBankTarget]) + HANDLE_NICKNAME_STRING_CASE(gBankDefender, gBattlePartyID[gBankDefender]) break; case B_TXT_EFF_NAME_WITH_PREFIX: // effect bank name with prefix HANDLE_NICKNAME_STRING_CASE(gEffectBank, gBattlePartyID[gEffectBank]) @@ -1971,7 +1971,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = gAbilityNames[gAbilitiesPerBank[gBankAttacker]]; break; case B_TXT_DEF_ABILITY: // target ability - toCpy = gAbilityNames[gAbilitiesPerBank[gBankTarget]]; + toCpy = gAbilityNames[gAbilitiesPerBank[gBankDefender]]; break; case B_TXT_SCR_ACTIVE_ABILITY: // scripting active ability toCpy = gAbilityNames[gAbilitiesPerBank[gBattleScripting.bank]]; @@ -2098,7 +2098,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = gText_FoePkmnPrefix3; break; case B_TXT_DEF_PREFIX2: - if (GetBankSide(gBankTarget) == SIDE_PLAYER) + if (GetBankSide(gBankDefender) == SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix2; else toCpy = gText_FoePkmnPrefix3; @@ -2110,7 +2110,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = gText_FoePkmnPrefix2; break; case B_TXT_DEF_PREFIX1: - if (GetBankSide(gBankTarget) == SIDE_PLAYER) + if (GetBankSide(gBankDefender) == SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix; else toCpy = gText_FoePkmnPrefix2; @@ -2122,7 +2122,7 @@ u32 BattleStringExpandPlaceholders(const u8* src, u8* dst) toCpy = gText_FoePkmnPrefix4; break; case B_TXT_DEF_PREFIX3: - if (GetBankSide(gBankTarget) == SIDE_PLAYER) + if (GetBankSide(gBankDefender) == SIDE_PLAYER) toCpy = gText_AllyPkmnPrefix3; else toCpy = gText_FoePkmnPrefix4; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 18c094571..be20305fa 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -44,37 +44,30 @@ extern u8 gCritMultiplier; extern s32 gBattleMoveDamage; -extern u32 gStatuses3[BATTLE_BANKS_COUNT]; -extern u32 gBattleTypeFlags; extern struct BattleEnigmaBerry gEnigmaBerries[BATTLE_BANKS_COUNT]; extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; extern u8 gActiveBank; extern u32 gBattleExecBuffer; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; extern u8 gBanksByTurnOrder[BATTLE_BANKS_COUNT]; extern u8 gActionsByTurnOrder[BATTLE_BANKS_COUNT]; extern u16 gCurrentMove; extern u8 gLastUsedAbility; -extern u16 gBattleWeather; extern u8 gStringBank; extern u8 gEffectBank; extern u8 gAbsentBankFlags; extern u8 gMultiHitCounter; extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT]; -extern u16 gSideAffecting[2]; extern u16 gPauseCounterBattle; extern u16 gPaydayMoney; extern u16 gRandomTurnNumber; -extern u8 gBattleOutcome; -extern u8 gBattleTerrain; extern u8 gBankAttacker; -extern u8 gBankTarget; +extern u8 gBankDefender; extern const u8* gBattlescriptCurrInstr; extern u8 gCurrMovePos; extern u8 gCurrentActionFuncId; -extern u32 gHitMarker; -extern u8 gBattleMoveFlags; +extern u8 gMoveResultFlags; extern u8 gBattleCommunication[]; extern u16 gLastLandedMoves[4]; extern u16 gLastHitByType[4]; @@ -162,9 +155,10 @@ extern const u8 gText_BattleYesNoChoice[]; #define BS2ScriptRead16(ptr) ((ptr)[0] + ((ptr)[1] << 8)) #define BS2ScriptReadPtr(ptr) ((void *)BS2ScriptRead32(ptr)) -#define TARGET_PROTECT_AFFECTED ((gProtectStructs[gBankTarget].protected && gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED)) +#define DEFENDER_IS_PROTECTED ((gProtectStructs[gBankDefender].protected) && (gBattleMoves[gCurrentMove].flags & FLAG_PROTECT_AFFECTED)) -#define TARGET_TURN_DAMAGED (((gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special))) +#define TARGET_TURN_DAMAGED (gSpecialStatuses[gBankDefender].moveturnLostHP_physical != 0 \ + || gSpecialStatuses[gBankDefender].moveturnLostHP_special != 0) // this file's functions static bool8 IsTwoTurnsMove(u16 move); @@ -715,12 +709,12 @@ static const u16 sCriticalHitChance[] = {16, 8, 4, 3, 2}; static const u32 sStatusFlagsForMoveEffects[] = { 0x00000000, - STATUS_SLEEP, - STATUS_POISON, - STATUS_BURN, - STATUS_FREEZE, - STATUS_PARALYSIS, - STATUS_TOXIC_POISON, + STATUS1_SLEEP, + STATUS1_POISON, + STATUS1_BURN, + STATUS1_FREEZE, + STATUS1_PARALYSIS, + STATUS1_TOXIC_POISON, STATUS2_CONFUSION, STATUS2_FLINCHED, 0x00000000, @@ -1041,13 +1035,13 @@ static void atk00_attackcanceler(void) } if (AtkCanceller_UnableToUseMove()) return; - if (AbilityBattleEffects(ABILITYEFFECT_MOVES_BLOCK, gBankTarget, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_MOVES_BLOCK, gBankDefender, 0, 0, 0)) return; if (!gBattleMons[gBankAttacker].pp[gCurrMovePos] && gCurrentMove != MOVE_STRUGGLE && !(gHitMarker & 0x800200) && !(gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS)) { gBattlescriptCurrInstr = BattleScript_NoPPForMove; - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; return; } @@ -1064,23 +1058,23 @@ static void atk00_attackcanceler(void) gHitMarker |= HITMARKER_OBEYS; return; default: - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; return; } } gHitMarker |= HITMARKER_OBEYS; - if (gProtectStructs[gBankTarget].bounceMove && gBattleMoves[gCurrentMove].flags & FLAG_MAGICCOAT_AFFECTED) + if (gProtectStructs[gBankDefender].bounceMove && gBattleMoves[gCurrentMove].flags & FLAG_MAGICCOAT_AFFECTED) { - PressurePPLose(gBankAttacker, gBankTarget, MOVE_MAGIC_COAT); - gProtectStructs[gBankTarget].bounceMove = 0; + PressurePPLose(gBankAttacker, gBankDefender, MOVE_MAGIC_COAT); + gProtectStructs[gBankDefender].bounceMove = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MagicCoatBounce; return; } - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if ((gProtectStructs[gBanksByTurnOrder[i]].stealMove) && gBattleMoves[gCurrentMove].flags & FLAG_SNATCH_AFFECTED) { @@ -1093,22 +1087,22 @@ static void atk00_attackcanceler(void) } } - if (gSpecialStatuses[gBankTarget].lightningRodRedirected) + if (gSpecialStatuses[gBankDefender].lightningRodRedirected) { - gSpecialStatuses[gBankTarget].lightningRodRedirected = 0; + gSpecialStatuses[gBankDefender].lightningRodRedirected = 0; gLastUsedAbility = ABILITY_LIGHTNING_ROD; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_TookAttack; - RecordAbilityBattle(gBankTarget, gLastUsedAbility); + RecordAbilityBattle(gBankDefender, gLastUsedAbility); } - else if (TARGET_PROTECT_AFFECTED + else if (DEFENDER_IS_PROTECTED && (gCurrentMove != MOVE_CURSE || (gBattleMons[gBankAttacker].type1 == TYPE_GHOST || gBattleMons[gBankAttacker].type2 == TYPE_GHOST)) && ((!IsTwoTurnsMove(gCurrentMove) || (gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS)))) { CancelMultiTurnMoves(gBankAttacker); - gBattleMoveFlags |= MOVESTATUS_MISSED; - gLastLandedMoves[gBankTarget] = 0; - gLastHitByType[gBankTarget] = 0; + gMoveResultFlags |= MOVE_RESULT_MISSED; + gLastLandedMoves[gBankDefender] = 0; + gLastHitByType[gBankDefender] = 0; gBattleCommunication[6] = 1; gBattlescriptCurrInstr++; } @@ -1121,16 +1115,16 @@ static void atk00_attackcanceler(void) static void JumpIfMoveFailed(u8 adder, u16 move) { const u8 *BS_ptr = gBattlescriptCurrInstr + adder; - if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) + if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { - gLastLandedMoves[gBankTarget] = 0; - gLastHitByType[gBankTarget] = 0; + gLastLandedMoves[gBankDefender] = 0; + gLastHitByType[gBankDefender] = 0; BS_ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { TrySetDestinyBondToHappen(); - if (AbilityBattleEffects(ABILITYEFFECT_ABSORBING, gBankTarget, 0, 0, move)) + if (AbilityBattleEffects(ABILITYEFFECT_ABSORBING, gBankDefender, 0, 0, move)) return; } gBattlescriptCurrInstr = BS_ptr; @@ -1138,9 +1132,9 @@ static void JumpIfMoveFailed(u8 adder, u16 move) static void atk40_jumpifaffectedbyprotect(void) { - if (TARGET_PROTECT_AFFECTED) + if (DEFENDER_IS_PROTECTED) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; JumpIfMoveFailed(5, 0); gBattleCommunication[6] = 1; } @@ -1153,9 +1147,9 @@ static void atk40_jumpifaffectedbyprotect(void) bool8 JumpIfMoveAffectedByProtect(u16 move) { bool8 affected = FALSE; - if (TARGET_PROTECT_AFFECTED) + if (DEFENDER_IS_PROTECTED) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; JumpIfMoveFailed(7, move); gBattleCommunication[6] = 1; affected = TRUE; @@ -1165,33 +1159,33 @@ bool8 JumpIfMoveAffectedByProtect(u16 move) static bool8 AccuracyCalcHelper(u16 move) { - if (gStatuses3[gBankTarget] & STATUS3_ALWAYS_HITS && gDisableStructs[gBankTarget].bankWithSureHit == gBankAttacker) + if (gStatuses3[gBankDefender] & STATUS3_ALWAYS_HITS && gDisableStructs[gBankDefender].bankWithSureHit == gBankAttacker) { JumpIfMoveFailed(7, move); return TRUE; } - if (!(gHitMarker & HITMARKER_IGNORE_ON_AIR) && gStatuses3[gBankTarget] & STATUS3_ON_AIR) + if (!(gHitMarker & HITMARKER_IGNORE_ON_AIR) && gStatuses3[gBankDefender] & STATUS3_ON_AIR) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; JumpIfMoveFailed(7, move); return TRUE; } gHitMarker &= ~HITMARKER_IGNORE_ON_AIR; - if (!(gHitMarker & HITMARKER_IGNORE_UNDERGROUND) && gStatuses3[gBankTarget] & STATUS3_UNDERGROUND) + if (!(gHitMarker & HITMARKER_IGNORE_UNDERGROUND) && gStatuses3[gBankDefender] & STATUS3_UNDERGROUND) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; JumpIfMoveFailed(7, move); return TRUE; } gHitMarker &= ~HITMARKER_IGNORE_UNDERGROUND; - if (!(gHitMarker & HITMARKER_IGNORE_UNDERWATER) && gStatuses3[gBankTarget] & STATUS3_UNDERWATER) + if (!(gHitMarker & HITMARKER_IGNORE_UNDERWATER) && gStatuses3[gBankDefender] & STATUS3_UNDERWATER) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; JumpIfMoveFailed(7, move); return TRUE; } @@ -1214,9 +1208,9 @@ static void atk01_accuracycheck(void) if (move == 0xFFFE || move == 0xFFFF) { - if (gStatuses3[gBankTarget] & STATUS3_ALWAYS_HITS && move == 0xFFFF && gDisableStructs[gBankTarget].bankWithSureHit == gBankAttacker) + if (gStatuses3[gBankDefender] & STATUS3_ALWAYS_HITS && move == 0xFFFF && gDisableStructs[gBankDefender].bankWithSureHit == gBankAttacker) gBattlescriptCurrInstr += 7; - else if (gStatuses3[gBankTarget] & (STATUS3_ON_AIR | STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) + else if (gStatuses3[gBankDefender] & (STATUS3_ON_AIR | STATUS3_UNDERGROUND | STATUS3_UNDERWATER)) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); else if (!JumpIfMoveAffectedByProtect(0)) gBattlescriptCurrInstr += 7; @@ -1237,7 +1231,7 @@ static void atk01_accuracycheck(void) if (AccuracyCalcHelper(move)) return; - if (gBattleMons[gBankTarget].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBankDefender].status2 & STATUS2_FORESIGHT) { u8 acc = gBattleMons[gBankAttacker].statStages[STAT_STAGE_ACC]; buff = acc; @@ -1245,7 +1239,7 @@ static void atk01_accuracycheck(void) else { u8 acc = gBattleMons[gBankAttacker].statStages[STAT_STAGE_ACC]; - buff = acc + 6 - gBattleMons[gBankTarget].statStages[STAT_STAGE_EVASION]; + buff = acc + 6 - gBattleMons[gBankDefender].statStages[STAT_STAGE_EVASION]; } if (buff < 0) @@ -1263,23 +1257,23 @@ static void atk01_accuracycheck(void) if (gBattleMons[gBankAttacker].ability == ABILITY_COMPOUND_EYES) calc = (calc * 130) / 100; // 1.3 compound eyes boost - if (WEATHER_HAS_EFFECT && gBattleMons[gBankTarget].ability == ABILITY_SAND_VEIL && gBattleWeather & WEATHER_SANDSTORM_ANY) + if (WEATHER_HAS_EFFECT && gBattleMons[gBankDefender].ability == ABILITY_SAND_VEIL && gBattleWeather & WEATHER_SANDSTORM_ANY) calc = (calc * 80) / 100; // 1.2 sand veil loss if (gBattleMons[gBankAttacker].ability == ABILITY_HUSTLE && type < 9) calc = (calc * 80) / 100; // 1.2 hustle loss - if (gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBankTarget].holdEffect; - quality = gEnigmaBerries[gBankTarget].holdEffectParam; + holdEffect = gEnigmaBerries[gBankDefender].holdEffect; + quality = gEnigmaBerries[gBankDefender].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankTarget].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBankTarget].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankDefender].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBankDefender].item); } - gStringBank = gBankTarget; + gStringBank = gBankDefender; if (holdEffect == HOLD_EFFECT_EVASION_UP) calc = (calc * (100 - quality)) / 100; @@ -1287,7 +1281,7 @@ static void atk01_accuracycheck(void) // final calculation if ((Random() % 100 + 1) > calc) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && (gBattleMoves[move].target == MOVE_TARGET_BOTH || gBattleMoves[move].target == MOVE_TARGET_FOES_AND_ALLY)) gBattleCommunication[6] = 2; @@ -1332,7 +1326,7 @@ static void atk03_ppreduce(void) ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBankAttacker, ABILITY_PRESSURE, 0, 0); break; default: - if (gBankAttacker != gBankTarget && gBattleMons[gBankTarget].ability == ABILITY_PRESSURE) + if (gBankAttacker != gBankDefender && gBattleMons[gBankDefender].ability == ABILITY_PRESSURE) ppToDeduct++; break; } @@ -1386,7 +1380,7 @@ static void atk04_critcalc(void) if (critChance > 4) critChance = 4; - if ((gBattleMons[gBankTarget].ability != ABILITY_BATTLE_ARMOR && gBattleMons[gBankTarget].ability != ABILITY_SHELL_ARMOR) + if ((gBattleMons[gBankDefender].ability != ABILITY_BATTLE_ARMOR && gBattleMons[gBankDefender].ability != ABILITY_SHELL_ARMOR) && !(gStatuses3[gBankAttacker] & STATUS3_CANT_SCORE_A_CRIT) && !(gBattleTypeFlags & (BATTLE_TYPE_WALLY_TUTORIAL | BATTLE_TYPE_FIRST_BATTLE)) && !(Random() % sCriticalHitChance[critChance])) @@ -1399,10 +1393,10 @@ static void atk04_critcalc(void) static void atk05_damagecalc(void) { - u16 sideStatus = gSideAffecting[GET_BANK_SIDE(gBankTarget)]; - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankTarget], gCurrentMove, + u16 sideStatus = gSideStatuses[GET_BANK_SIDE(gBankDefender)]; + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankDefender], gCurrentMove, sideStatus, gDynamicBasePower, - gBattleStruct->dynamicMoveType, gBankAttacker, gBankTarget); + gBattleStruct->dynamicMoveType, gBankAttacker, gBankDefender); gBattleMoveDamage = gBattleMoveDamage * gCritMultiplier * gBattleScripting.dmgMultiplier; if (gStatuses3[gBankAttacker] & STATUS3_CHARGED_UP && gBattleMoves[gCurrentMove].type == TYPE_ELECTRIC) @@ -1415,7 +1409,7 @@ static void atk05_damagecalc(void) void AI_CalcDmg(u8 bankAtk, u8 bankDef) { - u16 sideStatus = gSideAffecting[GET_BANK_SIDE(bankDef)]; + u16 sideStatus = gSideStatuses[GET_BANK_SIDE(bankDef)]; gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[bankAtk], &gBattleMons[bankDef], gCurrentMove, sideStatus, gDynamicBasePower, gBattleStruct->dynamicMoveType, bankAtk, bankDef); @@ -1437,26 +1431,26 @@ static void ModulateDmgByType(u8 multiplier) switch (multiplier) { case TYPE_MUL_NO_EFFECT: - gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED; - gBattleMoveFlags &= ~MOVESTATUS_NOTVERYEFFECTIVE; - gBattleMoveFlags &= ~MOVESTATUS_SUPEREFFECTIVE; + gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; + gMoveResultFlags &= ~MOVE_RESULT_NOT_VERY_EFFECTIVE; + gMoveResultFlags &= ~MOVE_RESULT_SUPER_EFFECTIVE; break; case TYPE_MUL_NOT_EFFECTIVE: - if (gBattleMoves[gCurrentMove].power && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + if (gBattleMoves[gCurrentMove].power && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { - if (gBattleMoveFlags & MOVESTATUS_SUPEREFFECTIVE) - gBattleMoveFlags &= ~MOVESTATUS_SUPEREFFECTIVE; + if (gMoveResultFlags & MOVE_RESULT_SUPER_EFFECTIVE) + gMoveResultFlags &= ~MOVE_RESULT_SUPER_EFFECTIVE; else - gBattleMoveFlags |= MOVESTATUS_NOTVERYEFFECTIVE; + gMoveResultFlags |= MOVE_RESULT_NOT_VERY_EFFECTIVE; } break; case TYPE_MUL_SUPER_EFFECTIVE: - if (gBattleMoves[gCurrentMove].power && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + if (gBattleMoves[gCurrentMove].power && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { - if (gBattleMoveFlags & MOVESTATUS_NOTVERYEFFECTIVE) - gBattleMoveFlags &= ~MOVESTATUS_NOTVERYEFFECTIVE; + if (gMoveResultFlags & MOVE_RESULT_NOT_VERY_EFFECTIVE) + gMoveResultFlags &= ~MOVE_RESULT_NOT_VERY_EFFECTIVE; else - gBattleMoveFlags |= MOVESTATUS_SUPEREFFECTIVE; + gMoveResultFlags |= MOVE_RESULT_SUPER_EFFECTIVE; } break; } @@ -1482,14 +1476,14 @@ static void atk06_typecalc(void) gBattleMoveDamage = gBattleMoveDamage / 10; } - if (gBattleMons[gBankTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) + if (gBattleMons[gBankDefender].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { - gLastUsedAbility = gBattleMons[gBankTarget].ability; - gBattleMoveFlags |= (MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED); - gLastLandedMoves[gBankTarget] = 0; - gLastHitByType[gBankTarget] = 0; + gLastUsedAbility = gBattleMons[gBankDefender].ability; + gMoveResultFlags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE); + gLastLandedMoves[gBankDefender] = 0; + gLastHitByType[gBankDefender] = 0; gBattleCommunication[6] = moveType; - RecordAbilityBattle(gBankTarget, gLastUsedAbility); + RecordAbilityBattle(gBankDefender, gLastUsedAbility); } else { @@ -1497,7 +1491,7 @@ static void atk06_typecalc(void) { if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) { - if (gBattleMons[gBankTarget].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBankDefender].status2 & STATUS2_FORESIGHT) break; i += 3; continue; @@ -1505,29 +1499,29 @@ static void atk06_typecalc(void) else if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type1) ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i)); // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2 && - gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 && + gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2) ModulateDmgByType(TYPE_EFFECT_MULTIPLIER(i)); } i += 3; } } - if (gBattleMons[gBankTarget].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBankAttacker, gCurrentMove) == 2 - && (!(gBattleMoveFlags & MOVESTATUS_SUPEREFFECTIVE) || ((gBattleMoveFlags & (MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE)) == (MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE))) + if (gBattleMons[gBankDefender].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBankAttacker, 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; - gBattleMoveFlags |= MOVESTATUS_MISSED; - gLastLandedMoves[gBankTarget] = 0; - gLastHitByType[gBankTarget] = 0; + gMoveResultFlags |= MOVE_RESULT_MISSED; + gLastLandedMoves[gBankDefender] = 0; + gLastHitByType[gBankDefender] = 0; gBattleCommunication[6] = 3; - RecordAbilityBattle(gBankTarget, gLastUsedAbility); + RecordAbilityBattle(gBankDefender, gLastUsedAbility); } - if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) + if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) gProtectStructs[gBankAttacker].targetNotAffected = 1; gBattlescriptCurrInstr++; @@ -1544,11 +1538,11 @@ static void CheckWonderGuardAndLevitate(void) GET_MOVE_TYPE(gCurrentMove, moveType); - if (gBattleMons[gBankTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) + if (gBattleMons[gBankDefender].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { gLastUsedAbility = ABILITY_LEVITATE; gBattleCommunication[6] = moveType; - RecordAbilityBattle(gBankTarget, ABILITY_LEVITATE); + RecordAbilityBattle(gBankDefender, ABILITY_LEVITATE); return; } @@ -1556,7 +1550,7 @@ static void CheckWonderGuardAndLevitate(void) { if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) { - if (gBattleMons[gBankTarget].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBankDefender].status2 & STATUS2_FORESIGHT) break; i += 3; continue; @@ -1564,46 +1558,46 @@ static void CheckWonderGuardAndLevitate(void) if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check no effect - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type1 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { - gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED; + gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; gProtectStructs[gBankAttacker].targetNotAffected = 1; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2 && - gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2 && + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 && + gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { - gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED; + gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; gProtectStructs[gBankAttacker].targetNotAffected = 1; } // check super effective - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type1 && TYPE_EFFECT_MULTIPLIER(i) == 20) flags |= 1; - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2 - && gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 + && gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) flags |= 1; // check not very effective - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type1 && TYPE_EFFECT_MULTIPLIER(i) == 5) flags |= 2; - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2 - && gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 + && gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) flags |= 2; } i += 3; } - if (gBattleMons[gBankTarget].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBankAttacker, gCurrentMove) == 2) + if (gBattleMons[gBankDefender].ability == ABILITY_WONDER_GUARD && AttacksThisTurn(gBankAttacker, gCurrentMove) == 2) { if (((flags & 2) || !(flags & 1)) && gBattleMoves[gCurrentMove].power) { gLastUsedAbility = ABILITY_WONDER_GUARD; gBattleCommunication[6] = 3; - RecordAbilityBattle(gBankTarget, ABILITY_WONDER_GUARD); + RecordAbilityBattle(gBankDefender, ABILITY_WONDER_GUARD); } } } @@ -1617,26 +1611,26 @@ static void ModulateDmgByType2(u8 multiplier, u16 move, u8* flags) // same as Mo switch (multiplier) { case TYPE_MUL_NO_EFFECT: - *flags |= MOVESTATUS_NOTAFFECTED; - *flags &= ~MOVESTATUS_NOTVERYEFFECTIVE; - *flags &= ~MOVESTATUS_SUPEREFFECTIVE; + *flags |= MOVE_RESULT_DOESNT_AFFECT_FOE; + *flags &= ~MOVE_RESULT_NOT_VERY_EFFECTIVE; + *flags &= ~MOVE_RESULT_SUPER_EFFECTIVE; break; case TYPE_MUL_NOT_EFFECTIVE: - if (gBattleMoves[move].power && !(*flags & MOVESTATUS_NOEFFECT)) + if (gBattleMoves[move].power && !(*flags & MOVE_RESULT_NO_EFFECT)) { - if (*flags & MOVESTATUS_SUPEREFFECTIVE) - *flags &= ~MOVESTATUS_SUPEREFFECTIVE; + if (*flags & MOVE_RESULT_SUPER_EFFECTIVE) + *flags &= ~MOVE_RESULT_SUPER_EFFECTIVE; else - *flags |= MOVESTATUS_NOTVERYEFFECTIVE; + *flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE; } break; case TYPE_MUL_SUPER_EFFECTIVE: - if (gBattleMoves[move].power && !(*flags & MOVESTATUS_NOEFFECT)) + if (gBattleMoves[move].power && !(*flags & MOVE_RESULT_NO_EFFECT)) { - if (*flags & MOVESTATUS_NOTVERYEFFECTIVE) - *flags &= ~MOVESTATUS_NOTVERYEFFECTIVE; + if (*flags & MOVE_RESULT_NOT_VERY_EFFECTIVE) + *flags &= ~MOVE_RESULT_NOT_VERY_EFFECTIVE; else - *flags |= MOVESTATUS_SUPEREFFECTIVE; + *flags |= MOVE_RESULT_SUPER_EFFECTIVE; } break; } @@ -1662,7 +1656,7 @@ u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef) if (gBattleMons[bankDef].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { - flags |= (MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED); + flags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE); } else { @@ -1690,12 +1684,12 @@ u8 TypeCalc(u16 move, u8 bankAtk, u8 bankDef) } } - if (gBattleMons[bankDef].ability == ABILITY_WONDER_GUARD && !(flags & MOVESTATUS_MISSED) + if (gBattleMons[bankDef].ability == ABILITY_WONDER_GUARD && !(flags & MOVE_RESULT_MISSED) && AttacksThisTurn(bankAtk, move) == 2 - && (!(flags & MOVESTATUS_SUPEREFFECTIVE) || ((flags & (MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE)) == (MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE))) + && (!(flags & MOVE_RESULT_SUPER_EFFECTIVE) || ((flags & (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)) == (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE))) && gBattleMoves[move].power) { - flags |= MOVESTATUS_MISSED; + flags |= MOVE_RESULT_MISSED; } return flags; } @@ -1714,7 +1708,7 @@ u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility) if (targetAbility == ABILITY_LEVITATE && moveType == TYPE_GROUND) { - flags = MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED; + flags = MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE; } else { @@ -1738,9 +1732,9 @@ u8 AI_TypeCalc(u16 move, u16 targetSpecies, u8 targetAbility) } } if (targetAbility == ABILITY_WONDER_GUARD - && (!(flags & MOVESTATUS_SUPEREFFECTIVE) || ((flags & (MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE)) == (MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE))) + && (!(flags & MOVE_RESULT_SUPER_EFFECTIVE) || ((flags & (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE)) == (MOVE_RESULT_SUPER_EFFECTIVE | MOVE_RESULT_NOT_VERY_EFFECTIVE))) && gBattleMoves[move].power) - flags |= MOVESTATUS_NOTAFFECTED; + flags |= MOVE_RESULT_DOESNT_AFFECT_FOE; return flags; } @@ -1770,42 +1764,42 @@ static void atk07_adjustnormaldamage(void) ApplyRandomDmgMultiplier(); - if (gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBankTarget].holdEffect, quality = gEnigmaBerries[gBankTarget].holdEffectParam; + holdEffect = gEnigmaBerries[gBankDefender].holdEffect, quality = gEnigmaBerries[gBankDefender].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankTarget].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBankTarget].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankDefender].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBankDefender].item); } - gStringBank = gBankTarget; + gStringBank = gBankDefender; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < quality) { - RecordItemEffectBattle(gBankTarget, holdEffect); - gSpecialStatuses[gBankTarget].focusBanded = 1; + RecordItemEffectBattle(gBankDefender, holdEffect); + gSpecialStatuses[gBankDefender].focusBanded = 1; } - if (gBattleMons[gBankTarget].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBankDefender].status2 & STATUS2_SUBSTITUTE) goto END; - if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBankTarget].endured - && !gSpecialStatuses[gBankTarget].focusBanded) + if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBankDefender].endured + && !gSpecialStatuses[gBankDefender].focusBanded) goto END; - if (gBattleMons[gBankTarget].hp > gBattleMoveDamage) + if (gBattleMons[gBankDefender].hp > gBattleMoveDamage) goto END; - gBattleMoveDamage = gBattleMons[gBankTarget].hp - 1; + gBattleMoveDamage = gBattleMons[gBankDefender].hp - 1; - if (gProtectStructs[gBankTarget].endured) + if (gProtectStructs[gBankDefender].endured) { - gBattleMoveFlags |= MOVESTATUS_ENDURED; + gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBankTarget].focusBanded) + else if (gSpecialStatuses[gBankDefender].focusBanded) { - gBattleMoveFlags |= MOVESTATUS_HUNGON; - gLastUsedItem = gBattleMons[gBankTarget].item; + gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; + gLastUsedItem = gBattleMons[gBankDefender].item; } END: @@ -1818,40 +1812,40 @@ static void atk08_adjustnormaldamage2(void) // The same as 0x7 except it doesn't ApplyRandomDmgMultiplier(); - if (gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBankTarget].holdEffect, quality = gEnigmaBerries[gBankTarget].holdEffectParam; + holdEffect = gEnigmaBerries[gBankDefender].holdEffect, quality = gEnigmaBerries[gBankDefender].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankTarget].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBankTarget].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankDefender].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBankDefender].item); } - gStringBank = gBankTarget; + gStringBank = gBankDefender; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < quality) { - RecordItemEffectBattle(gBankTarget, holdEffect); - gSpecialStatuses[gBankTarget].focusBanded = 1; + RecordItemEffectBattle(gBankDefender, holdEffect); + gSpecialStatuses[gBankDefender].focusBanded = 1; } - if (gBattleMons[gBankTarget].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBankDefender].status2 & STATUS2_SUBSTITUTE) goto END; - if (!gProtectStructs[gBankTarget].endured && !gSpecialStatuses[gBankTarget].focusBanded) + if (!gProtectStructs[gBankDefender].endured && !gSpecialStatuses[gBankDefender].focusBanded) goto END; - if (gBattleMons[gBankTarget].hp > gBattleMoveDamage) + if (gBattleMons[gBankDefender].hp > gBattleMoveDamage) goto END; - gBattleMoveDamage = gBattleMons[gBankTarget].hp - 1; + gBattleMoveDamage = gBattleMons[gBankDefender].hp - 1; - if (gProtectStructs[gBankTarget].endured) + if (gProtectStructs[gBankDefender].endured) { - gBattleMoveFlags |= MOVESTATUS_ENDURED; + gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBankTarget].focusBanded) + else if (gSpecialStatuses[gBankDefender].focusBanded) { - gBattleMoveFlags |= MOVESTATUS_HUNGON; - gLastUsedItem = gBattleMons[gBankTarget].item; + gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; + gLastUsedItem = gBattleMons[gBankDefender].item; } END: @@ -1880,17 +1874,17 @@ static void atk09_attackanimation(void) gBattlescriptCurrInstr++; return; } - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { u8 multihit; gActiveBank = gBankAttacker; - if (gBattleMons[gBankTarget].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBankDefender].status2 & STATUS2_SUBSTITUTE) multihit = gMultiHitCounter; else if (gMultiHitCounter != 0 && gMultiHitCounter != 1) { - if (gBattleMons[gBankTarget].hp <= gBattleMoveDamage) + if (gBattleMons[gBankDefender].hp <= gBattleMoveDamage) multihit = 1; else multihit = gMultiHitCounter; @@ -1923,7 +1917,7 @@ static void atk0B_healthbarupdate(void) if (gBattleExecBuffer) return; - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); @@ -1968,7 +1962,7 @@ static void atk0C_datahpupdate(void) else moveType = gBattleMoves[gCurrentMove].type; - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); if (gBattleMons[gActiveBank].status2 & STATUS2_SUBSTITUTE && gDisableStructs[gActiveBank].substituteHP && !(gHitMarker & HITMARKER_IGNORE_SUBSTITUTE)) @@ -2018,7 +2012,7 @@ static void atk0C_datahpupdate(void) if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) gTakenDmgBanks[gActiveBank] = gBankAttacker; else - gTakenDmgBanks[gActiveBank] = gBankTarget; + gTakenDmgBanks[gActiveBank] = gBankDefender; } if (gBattleMons[gActiveBank].hp > gBattleMoveDamage) @@ -2046,8 +2040,8 @@ static void atk0C_datahpupdate(void) } else { - gProtectStructs[gActiveBank].physicalBank = gBankTarget; - gSpecialStatuses[gActiveBank].moveturnPhysicalBank = gBankTarget; + gProtectStructs[gActiveBank].physicalBank = gBankDefender; + gSpecialStatuses[gActiveBank].moveturnPhysicalBank = gBankDefender; } } else if (moveType > 8 && !(gHitMarker & HITMARKER_x100000)) @@ -2061,8 +2055,8 @@ static void atk0C_datahpupdate(void) } else { - gProtectStructs[gActiveBank].specialBank = gBankTarget; - gSpecialStatuses[gActiveBank].moveturnSpecialBank = gBankTarget; + gProtectStructs[gActiveBank].specialBank = gBankDefender; + gSpecialStatuses[gActiveBank].moveturnSpecialBank = gBankDefender; } } } @@ -2084,7 +2078,7 @@ static void atk0D_critmessage(void) { if (gBattleExecBuffer == 0) { - if (gCritMultiplier == 2 && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + if (gCritMultiplier == 2 && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { PrepareStringBattle(STRINGID_CRITICALHIT, gBankAttacker); gBattleCommunication[MSG_DISPLAY] = 1; @@ -2098,38 +2092,38 @@ static void atk0E_effectivenesssound(void) if (gBattleExecBuffer) return; - gActiveBank = gBankTarget; - if (!(gBattleMoveFlags & MOVESTATUS_MISSED)) + gActiveBank = gBankDefender; + if (!(gMoveResultFlags & MOVE_RESULT_MISSED)) { - switch (gBattleMoveFlags & (u8)(~(MOVESTATUS_MISSED))) + switch (gMoveResultFlags & (u8)(~(MOVE_RESULT_MISSED))) { - case MOVESTATUS_SUPEREFFECTIVE: + case MOVE_RESULT_SUPER_EFFECTIVE: EmitPlaySE(0, SE_KOUKA_H); MarkBufferBankForExecution(gActiveBank); break; - case MOVESTATUS_NOTVERYEFFECTIVE: + case MOVE_RESULT_NOT_VERY_EFFECTIVE: EmitPlaySE(0, SE_KOUKA_L); MarkBufferBankForExecution(gActiveBank); break; - case MOVESTATUS_NOTAFFECTED: - case MOVESTATUS_FAILED: + case MOVE_RESULT_DOESNT_AFFECT_FOE: + case MOVE_RESULT_FAILED: // no sound break; - case MOVESTATUS_ENDURED: - case MOVESTATUS_ONEHITKO: - case MOVESTATUS_HUNGON: + case MOVE_RESULT_FOE_ENDURED: + case MOVE_RESULT_ONE_HIT_KO: + case MOVE_RESULT_FOE_HUNG_ON: default: - if (gBattleMoveFlags & MOVESTATUS_SUPEREFFECTIVE) + if (gMoveResultFlags & MOVE_RESULT_SUPER_EFFECTIVE) { EmitPlaySE(0, SE_KOUKA_H); MarkBufferBankForExecution(gActiveBank); } - else if (gBattleMoveFlags & MOVESTATUS_NOTVERYEFFECTIVE) + else if (gMoveResultFlags & MOVE_RESULT_NOT_VERY_EFFECTIVE) { EmitPlaySE(0, SE_KOUKA_L); MarkBufferBankForExecution(gActiveBank); } - else if (!(gBattleMoveFlags & (MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED))) + else if (!(gMoveResultFlags & (MOVE_RESULT_DOESNT_AFFECT_FOE | MOVE_RESULT_FAILED))) { EmitPlaySE(0, SE_KOUKA_M); MarkBufferBankForExecution(gActiveBank); @@ -2147,7 +2141,7 @@ static void atk0F_resultmessage(void) if (gBattleExecBuffer) return; - if (gBattleMoveFlags & MOVESTATUS_MISSED && (!(gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) || gBattleCommunication[6] > 2)) + if (gMoveResultFlags & MOVE_RESULT_MISSED && (!(gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) || gBattleCommunication[6] > 2)) { stringId = gMissStringIds[gBattleCommunication[6]]; gBattleCommunication[MSG_DISPLAY] = 1; @@ -2155,64 +2149,64 @@ static void atk0F_resultmessage(void) else { gBattleCommunication[MSG_DISPLAY] = 1; - switch (gBattleMoveFlags & (u8)(~(MOVESTATUS_MISSED))) + switch (gMoveResultFlags & (u8)(~(MOVE_RESULT_MISSED))) { - case MOVESTATUS_SUPEREFFECTIVE: + case MOVE_RESULT_SUPER_EFFECTIVE: stringId = STRINGID_SUPEREFFECTIVE; break; - case MOVESTATUS_NOTVERYEFFECTIVE: + case MOVE_RESULT_NOT_VERY_EFFECTIVE: stringId = STRINGID_NOTVERYEFFECTIVE; break; - case MOVESTATUS_ONEHITKO: + case MOVE_RESULT_ONE_HIT_KO: stringId = STRINGID_ONEHITKO; break; - case MOVESTATUS_ENDURED: + case MOVE_RESULT_FOE_ENDURED: stringId = STRINGID_PKMNENDUREDHIT; break; - case MOVESTATUS_FAILED: + case MOVE_RESULT_FAILED: stringId = STRINGID_BUTITFAILED; break; - case MOVESTATUS_NOTAFFECTED: + case MOVE_RESULT_DOESNT_AFFECT_FOE: stringId = STRINGID_ITDOESNTAFFECT; break; - case MOVESTATUS_HUNGON: - gLastUsedItem = gBattleMons[gBankTarget].item; - gStringBank = gBankTarget; - gBattleMoveFlags &= ~(MOVESTATUS_ENDURED | MOVESTATUS_HUNGON); + case MOVE_RESULT_FOE_HUNG_ON: + gLastUsedItem = gBattleMons[gBankDefender].item; + gStringBank = gBankDefender; + gMoveResultFlags &= ~(MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_HangedOnMsg; return; default: - if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) + if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) { stringId = STRINGID_ITDOESNTAFFECT; } - else if (gBattleMoveFlags & MOVESTATUS_ONEHITKO) + else if (gMoveResultFlags & MOVE_RESULT_ONE_HIT_KO) { - gBattleMoveFlags &= ~(MOVESTATUS_ONEHITKO); - gBattleMoveFlags &= ~(MOVESTATUS_SUPEREFFECTIVE); - gBattleMoveFlags &= ~(MOVESTATUS_NOTVERYEFFECTIVE); + gMoveResultFlags &= ~(MOVE_RESULT_ONE_HIT_KO); + gMoveResultFlags &= ~(MOVE_RESULT_SUPER_EFFECTIVE); + gMoveResultFlags &= ~(MOVE_RESULT_NOT_VERY_EFFECTIVE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_OneHitKOMsg; return; } - else if (gBattleMoveFlags & MOVESTATUS_ENDURED) + else if (gMoveResultFlags & MOVE_RESULT_FOE_ENDURED) { - gBattleMoveFlags &= ~(MOVESTATUS_ENDURED | MOVESTATUS_HUNGON); + gMoveResultFlags &= ~(MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_EnduredMsg; return; } - else if (gBattleMoveFlags & MOVESTATUS_HUNGON) + else if (gMoveResultFlags & MOVE_RESULT_FOE_HUNG_ON) { - gLastUsedItem = gBattleMons[gBankTarget].item; - gStringBank = gBankTarget; - gBattleMoveFlags &= ~(MOVESTATUS_ENDURED | MOVESTATUS_HUNGON); + gLastUsedItem = gBattleMons[gBankDefender].item; + gStringBank = gBankDefender; + gMoveResultFlags &= ~(MOVE_RESULT_FOE_ENDURED | MOVE_RESULT_FOE_HUNG_ON); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_HangedOnMsg; return; } - else if (gBattleMoveFlags & MOVESTATUS_FAILED) + else if (gMoveResultFlags & MOVE_RESULT_FAILED) { stringId = STRINGID_BUTITFAILED; } @@ -2305,7 +2299,7 @@ static void atk14_printselectionstringfromtable(void) u8 BankGetTurnOrder(u8 bank) { s32 i; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBanksByTurnOrder[i] == bank) break; @@ -2337,11 +2331,11 @@ void SetMoveEffect(bool8 primary, u8 certain) gEffectBank = gBankAttacker; // bank that effects get applied on gBattleCommunication[MOVE_EFFECT_BYTE] &= ~(MOVE_EFFECT_AFFECTS_USER); affectsUser = MOVE_EFFECT_AFFECTS_USER; - gBattleScripting.bank = gBankTarget; // theoretically the attacker + gBattleScripting.bank = gBankDefender; // theoretically the attacker } else { - gEffectBank = gBankTarget; + gEffectBank = gBankDefender; gBattleScripting.bank = gBankAttacker; } @@ -2349,7 +2343,7 @@ void SetMoveEffect(bool8 primary, u8 certain) && !primary && gBattleCommunication[MOVE_EFFECT_BYTE] <= 9) INCREMENT_RESET_RETURN - if (gSideAffecting[GET_BANK_SIDE(gEffectBank)] & SIDE_STATUS_SAFEGUARD && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) + if (gSideStatuses[GET_BANK_SIDE(gEffectBank)] & SIDE_STATUS_SAFEGUARD && !(gHitMarker & HITMARKER_IGNORE_SAFEGUARD) && !primary && gBattleCommunication[MOVE_EFFECT_BYTE] <= 7) INCREMENT_RESET_RETURN @@ -2365,21 +2359,21 @@ void SetMoveEffect(bool8 primary, u8 certain) { switch (sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]) { - case STATUS_SLEEP: + case STATUS1_SLEEP: // check active uproar if (gBattleMons[gEffectBank].ability != ABILITY_SOUNDPROOF) { for (gActiveBank = 0; - gActiveBank < gNoOfAllBanks && !(gBattleMons[gActiveBank].status2 & STATUS2_UPROAR); + gActiveBank < gBattleBanksCount && !(gBattleMons[gActiveBank].status2 & STATUS2_UPROAR); gActiveBank++) {} } else - gActiveBank = gNoOfAllBanks; + gActiveBank = gBattleBanksCount; if (gBattleMons[gEffectBank].status1) break; - if (gActiveBank != gNoOfAllBanks) + if (gActiveBank != gBattleBanksCount) break; if (gBattleMons[gEffectBank].ability == ABILITY_VITAL_SPIRIT) break; @@ -2389,7 +2383,7 @@ void SetMoveEffect(bool8 primary, u8 certain) CancelMultiTurnMoves(gEffectBank); statusChanged = TRUE; break; - case STATUS_POISON: + case STATUS1_POISON: if (gBattleMons[gEffectBank].ability == ABILITY_IMMUNITY && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) { @@ -2436,7 +2430,7 @@ void SetMoveEffect(bool8 primary, u8 certain) statusChanged = TRUE; break; - case STATUS_BURN: + case STATUS1_BURN: if (gBattleMons[gEffectBank].ability == ABILITY_WATER_VEIL && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) { @@ -2478,7 +2472,7 @@ void SetMoveEffect(bool8 primary, u8 certain) statusChanged = TRUE; break; - case STATUS_FREEZE: + case STATUS1_FREEZE: if (WEATHER_HAS_EFFECT && gBattleWeather & WEATHER_SUN_ANY) noSunCanFreeze = FALSE; if (gBattleMons[gEffectBank].type1 == TYPE_ICE) @@ -2495,7 +2489,7 @@ void SetMoveEffect(bool8 primary, u8 certain) CancelMultiTurnMoves(gEffectBank); statusChanged = TRUE; break; - case STATUS_PARALYSIS: + case STATUS1_PARALYSIS: if (gBattleMons[gEffectBank].ability == ABILITY_LIMBER) { if (primary == TRUE || certain == MOVE_EFFECT_CERTAIN) @@ -2525,7 +2519,7 @@ void SetMoveEffect(bool8 primary, u8 certain) statusChanged = TRUE; break; - case STATUS_TOXIC_POISON: + case STATUS1_TOXIC_POISON: if (gBattleMons[gEffectBank].ability == ABILITY_IMMUNITY && (primary == TRUE || certain == MOVE_EFFECT_CERTAIN)) { gLastUsedAbility = ABILITY_IMMUNITY; @@ -2567,14 +2561,14 @@ void SetMoveEffect(bool8 primary, u8 certain) break; // It's redundant, because at this point we know the status1 value is 0. - gBattleMons[gEffectBank].status1 &= ~(STATUS_TOXIC_POISON); - gBattleMons[gEffectBank].status1 &= ~(STATUS_POISON); + gBattleMons[gEffectBank].status1 &= ~(STATUS1_TOXIC_POISON); + gBattleMons[gEffectBank].status1 &= ~(STATUS1_POISON); statusChanged = TRUE; break; } else { - gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED; + gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; } break; } @@ -2582,7 +2576,7 @@ void SetMoveEffect(bool8 primary, u8 certain) { BattleScriptPush(gBattlescriptCurrInstr + 1); - if (sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]] == STATUS_SLEEP) + if (sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]] == STATUS1_SLEEP) gBattleMons[gEffectBank].status1 |= ((Random() & 3) + 2); else gBattleMons[gEffectBank].status1 |= sStatusFlagsForMoveEffects[gBattleCommunication[MOVE_EFFECT_BYTE]]; @@ -2870,52 +2864,52 @@ void SetMoveEffect(bool8 primary, u8 certain) { gBattlescriptCurrInstr++; } - else if (gBattleMons[gBankTarget].item - && gBattleMons[gBankTarget].ability == ABILITY_STICKY_HOLD) + else if (gBattleMons[gBankDefender].item + && gBattleMons[gBankDefender].ability == ABILITY_STICKY_HOLD) { BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_NoItemSteal; - gLastUsedAbility = gBattleMons[gBankTarget].ability; - RecordAbilityBattle(gBankTarget, gLastUsedAbility); + gLastUsedAbility = gBattleMons[gBankDefender].ability; + RecordAbilityBattle(gBankDefender, gLastUsedAbility); } else if (gBattleMons[gBankAttacker].item != 0 - || gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY - || IS_ITEM_MAIL(gBattleMons[gBankTarget].item) - || gBattleMons[gBankTarget].item == 0) + || gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY + || IS_ITEM_MAIL(gBattleMons[gBankDefender].item) + || gBattleMons[gBankDefender].item == 0) { gBattlescriptCurrInstr++; } else { u16* changedItem = &gBattleStruct->changedItems[gBankAttacker]; - gLastUsedItem = *changedItem = gBattleMons[gBankTarget].item; - gBattleMons[gBankTarget].item = 0; + gLastUsedItem = *changedItem = gBattleMons[gBankDefender].item; + gBattleMons[gBankDefender].item = 0; gActiveBank = gBankAttacker; EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gLastUsedItem); MarkBufferBankForExecution(gBankAttacker); - gActiveBank = gBankTarget; - EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBankTarget].item); - MarkBufferBankForExecution(gBankTarget); + gActiveBank = gBankDefender; + EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBankDefender].item); + MarkBufferBankForExecution(gBankDefender); BattleScriptPush(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = BattleScript_ItemSteal; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankTarget]) + 0) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankTarget]) + 1) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankDefender]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankDefender]) + 1) = 0; } } break; case MOVE_EFFECT_PREVENT_ESCAPE: - gBattleMons[gBankTarget].status2 |= STATUS2_ESCAPE_PREVENTION; - gDisableStructs[gBankTarget].bankPreventingEscape = gBankAttacker; + gBattleMons[gBankDefender].status2 |= STATUS2_ESCAPE_PREVENTION; + gDisableStructs[gBankDefender].bankPreventingEscape = gBankAttacker; gBattlescriptCurrInstr++; break; case MOVE_EFFECT_NIGHTMARE: - gBattleMons[gBankTarget].status2 |= STATUS2_NIGHTMARE; + gBattleMons[gBankDefender].status2 |= STATUS2_NIGHTMARE; gBattlescriptCurrInstr++; break; case MOVE_EFFECT_ALL_STATS_UP: @@ -2927,15 +2921,15 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattlescriptCurrInstr = BattleScript_RapidSpinAway; break; case MOVE_EFFECT_REMOVE_PARALYSIS: // Smelling salts - if (!(gBattleMons[gBankTarget].status1 & STATUS_PARALYSIS)) + if (!(gBattleMons[gBankDefender].status1 & STATUS1_PARALYSIS)) { gBattlescriptCurrInstr++; } else { - gBattleMons[gBankTarget].status1 &= ~(STATUS_PARALYSIS); + gBattleMons[gBankDefender].status1 &= ~(STATUS1_PARALYSIS); - gActiveBank = gBankTarget; + gActiveBank = gBankDefender; EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); @@ -3022,14 +3016,14 @@ static void atk15_seteffectwithchance(void) percentChance = gBattleMoves[gCurrentMove].secondaryEffectChance; if (gBattleCommunication[MOVE_EFFECT_BYTE] & MOVE_EFFECT_CERTAIN - && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { gBattleCommunication[MOVE_EFFECT_BYTE] &= ~(MOVE_EFFECT_CERTAIN); SetMoveEffect(0, MOVE_EFFECT_CERTAIN); } else if (Random() % 100 < percentChance && gBattleCommunication[MOVE_EFFECT_BYTE] - && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { if (percentChance >= 100) SetMoveEffect(0, MOVE_EFFECT_CERTAIN); @@ -3082,7 +3076,7 @@ static void atk19_tryfaintmon(void) BattleScriptPop(); gBattlescriptCurrInstr = BS_ptr; - gSideAffecting[GetBankSide(gActiveBank)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); + gSideStatuses[GetBankSide(gActiveBank)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); } else { @@ -3096,12 +3090,12 @@ static void atk19_tryfaintmon(void) if (gBattlescriptCurrInstr[1] == BS_GET_ATTACKER) { gActiveBank = gBankAttacker; - bank = gBankTarget; + bank = gBankDefender; BS_ptr = BattleScript_FaintAttacker; } else { - gActiveBank = gBankTarget; + gActiveBank = gBankDefender; bank = gBankAttacker; BS_ptr = BattleScript_FaintTarget; } @@ -3131,9 +3125,9 @@ static void atk19_tryfaintmon(void) gBattleMoveDamage = gBattleMons[bank].hp; gBattlescriptCurrInstr = BattleScript_DestinyBondTakesLife; } - if ((gStatuses3[gBankTarget] & STATUS3_GRUDGE) + if ((gStatuses3[gBankDefender] & STATUS3_GRUDGE) && !(gHitMarker & HITMARKER_GRUDGE) - && GetBankSide(gBankAttacker) != GetBankSide(gBankTarget) + && GetBankSide(gBankAttacker) != GetBankSide(gBankDefender) && gBattleMons[gBankAttacker].hp != 0 && gCurrentMove != MOVE_STRUGGLE) { @@ -3265,12 +3259,12 @@ static void atk1F_jumpifsideaffecting(void) if (gBattlescriptCurrInstr[1] == BS_GET_ATTACKER) side = GET_BANK_SIDE(gBankAttacker); else - side = GET_BANK_SIDE(gBankTarget); + side = GET_BANK_SIDE(gBankDefender); flags = BS2ScriptRead16(gBattlescriptCurrInstr + 2); jumpPtr = BS2ScriptReadPtr(gBattlescriptCurrInstr + 4); - if (gSideAffecting[side] & flags) + if (gSideStatuses[side] & flags) gBattlescriptCurrInstr = jumpPtr; else gBattlescriptCurrInstr += 8; @@ -3660,7 +3654,7 @@ static void atk24(void) } if (HP_count == 0) - gBattleOutcome |= BATTLE_LOST; + gBattleOutcome |= B_OUTCOME_LOST; for (HP_count = 0, i = 0; i < 6; i++) { @@ -3672,7 +3666,7 @@ static void atk24(void) } if (HP_count == 0) - gBattleOutcome |= BATTLE_WON; + gBattleOutcome |= B_OUTCOME_WON; if (gBattleOutcome == 0 && (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000))) { @@ -3680,13 +3674,13 @@ static void atk24(void) s32 foundOpponent; // Impossible to decompile loops. - for (foundPlayer = 0, i = 0; i < gNoOfAllBanks; i += 2) + for (foundPlayer = 0, i = 0; i < gBattleBanksCount; i += 2) { if (HITMARKER_UNK(i) & gHitMarker && !gSpecialStatuses[i].flag40) foundPlayer++; } - for (foundOpponent = 0, i = 1; i < gNoOfAllBanks; i += 2) + for (foundOpponent = 0, i = 1; i < gBattleBanksCount; i += 2) { if (HITMARKER_UNK(i) & gHitMarker && !gSpecialStatuses[i].flag40) foundOpponent++; @@ -3895,7 +3889,7 @@ static void atk24(void) beq _0804AF1A\n\ movs r3, 0\n\ movs r5, 0\n\ - ldr r0, =gNoOfAllBanks\n\ + ldr r0, =gBattleBanksCount\n\ ldrb r1, [r0]\n\ mov r12, r0\n\ ldr r7, =gBattlescriptCurrInstr\n\ @@ -4010,7 +4004,7 @@ static void atk24(void) static void MoveValuesCleanUp(void) { - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gBattleScripting.dmgMultiplier = 1; gCritMultiplier = 1; gBattleCommunication[MOVE_EFFECT_BYTE] = 0; @@ -4329,7 +4323,7 @@ static void atk3A_waitstate(void) static void atk3B_healthbar_update(void) { if (gBattlescriptCurrInstr[1] == BS_GET_TARGET) - gActiveBank = gBankTarget; + gActiveBank = gBankDefender; else gActiveBank = gBankAttacker; @@ -4348,7 +4342,7 @@ static void atk3D_end(void) if (gBattleTypeFlags & BATTLE_TYPE_ARENA) sub_81A5718(gBankAttacker); - gBattleMoveFlags = 0; + gMoveResultFlags = 0; gActiveBank = 0; gCurrentActionFuncId = 0xB; } @@ -4884,13 +4878,13 @@ static void atk49_moveend(void) switch (gBattleScripting.atk49_state) { case 0: // rage check - if (gBattleMons[gBankTarget].status2 & STATUS2_RAGE - && gBattleMons[gBankTarget].hp != 0 && gBankAttacker != gBankTarget - && GetBankSide(gBankAttacker) != GetBankSide(gBankTarget) - && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && TARGET_TURN_DAMAGED - && gBattleMoves[gCurrentMove].power && gBattleMons[gBankTarget].statStages[STAT_STAGE_ATK] <= 0xB) + if (gBattleMons[gBankDefender].status2 & STATUS2_RAGE + && gBattleMons[gBankDefender].hp != 0 && gBankAttacker != gBankDefender + && GetBankSide(gBankAttacker) != GetBankSide(gBankDefender) + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && TARGET_TURN_DAMAGED + && gBattleMoves[gCurrentMove].power && gBattleMons[gBankDefender].statStages[STAT_STAGE_ATK] <= 0xB) { - gBattleMons[gBankTarget].statStages[STAT_STAGE_ATK]++; + gBattleMons[gBankDefender].statStages[STAT_STAGE_ATK]++; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_RageIsBuilding; effect = TRUE; @@ -4898,14 +4892,14 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case 1: // defrosting check - if (gBattleMons[gBankTarget].status1 & STATUS_FREEZE - && gBattleMons[gBankTarget].hp != 0 && gBankAttacker != gBankTarget - && gSpecialStatuses[gBankTarget].moveturnLostHP_special - && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT) && moveType == TYPE_FIRE) + if (gBattleMons[gBankDefender].status1 & STATUS1_FREEZE + && gBattleMons[gBankDefender].hp != 0 && gBankAttacker != gBankDefender + && gSpecialStatuses[gBankDefender].moveturnLostHP_special + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && moveType == TYPE_FIRE) { - gBattleMons[gBankTarget].status1 &= ~(STATUS_FREEZE); - gActiveBank = gBankTarget; - EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBankTarget].status1); + gBattleMons[gBankDefender].status1 &= ~(STATUS1_FREEZE); + gActiveBank = gBankDefender; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gBankDefender].status1); MarkBufferBankForExecution(gActiveBank); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_DefrostedViaFireMove; @@ -4914,12 +4908,12 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case 2: // target synchronize - if (AbilityBattleEffects(ABILITYEFFECT_SYNCHRONIZE, gBankTarget, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_SYNCHRONIZE, gBankDefender, 0, 0, 0)) effect = TRUE; gBattleScripting.atk49_state++; break; case 3: // contact abilities - if (AbilityBattleEffects(ABILITYEFFECT_CONTACT, gBankTarget, 0, 0, 0)) + if (AbilityBattleEffects(ABILITYEFFECT_CONTACT, gBankDefender, 0, 0, 0)) effect = TRUE; gBattleScripting.atk49_state++; break; @@ -4938,7 +4932,7 @@ static void atk49_moveend(void) if (!(gHitMarker & HITMARKER_OBEYS) || holdEffectAtk != HOLD_EFFECT_CHOICE_BAND || gChosenMove == MOVE_STRUGGLE || (*choicedMoveAtk != 0 && *choicedMoveAtk != 0xFFFF)) goto LOOP; - if (gChosenMove == MOVE_BATON_PASS && !(gBattleMoveFlags & MOVESTATUS_FAILED)) + if (gChosenMove == MOVE_BATON_PASS && !(gMoveResultFlags & MOVE_RESULT_FAILED)) { gBattleScripting.atk49_state++; break; @@ -4958,7 +4952,7 @@ static void atk49_moveend(void) } break; case 7: // changed held items - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { u16* changedItem = &gBattleStruct->changedItems[i]; if (*changedItem != 0) @@ -4993,7 +4987,7 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case 9: // make attacker sprite visible - if (gBattleMoveFlags & MOVESTATUS_NOEFFECT + if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT || !(gStatuses3[gBankAttacker] & (STATUS3_SEMI_INVULNERABLE)) || WasUnableToUseMove(gBankAttacker)) { @@ -5008,20 +5002,20 @@ static void atk49_moveend(void) gBattleScripting.atk49_state++; break; case 10: // make target sprite visible - if (!gSpecialStatuses[gBankTarget].restoredBankSprite && gBankTarget < gNoOfAllBanks - && !(gStatuses3[gBankTarget] & STATUS3_SEMI_INVULNERABLE)) + if (!gSpecialStatuses[gBankDefender].restoredBankSprite && gBankDefender < gBattleBanksCount + && !(gStatuses3[gBankDefender] & STATUS3_SEMI_INVULNERABLE)) { - gActiveBank = gBankTarget; + gActiveBank = gBankDefender; EmitSpriteInvisibility(0, FALSE); MarkBufferBankForExecution(gActiveBank); - gStatuses3[gBankTarget] &= ~(STATUS3_SEMI_INVULNERABLE); + gStatuses3[gBankDefender] &= ~(STATUS3_SEMI_INVULNERABLE); gBattleScripting.atk49_state++; return; } gBattleScripting.atk49_state++; break; case 13: // update substitute - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gDisableStructs[i].substituteHP == 0) gBattleMons[i].status2 &= ~(STATUS2_SUBSTITUTE); @@ -5032,8 +5026,8 @@ static void atk49_moveend(void) if (gHitMarker & HITMARKER_PURSUIT_TRAP) { gActiveBank = gBankAttacker; - gBankAttacker = gBankTarget; - gBankTarget = gActiveBank; + gBankAttacker = gBankDefender; + gBankDefender = gActiveBank; gHitMarker &= ~(HITMARKER_PURSUIT_TRAP); } if (gHitMarker & HITMARKER_ATTACKSTRING_PRINTED) @@ -5055,24 +5049,24 @@ static void atk49_moveend(void) gLastResultingMoves[gBankAttacker] = 0xFFFF; } - if (!(gHitMarker & HITMARKER_FAINTED(gBankTarget))) - gLastHitBy[gBankTarget] = gBankAttacker; + if (!(gHitMarker & HITMARKER_FAINTED(gBankDefender))) + gLastHitBy[gBankDefender] = gBankAttacker; - if (gHitMarker & HITMARKER_OBEYS && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + if (gHitMarker & HITMARKER_OBEYS && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { if (gChosenMove == 0xFFFF) { - gLastLandedMoves[gBankTarget] = gChosenMove; + gLastLandedMoves[gBankDefender] = gChosenMove; } else { - gLastLandedMoves[gBankTarget] = gCurrentMove; - GET_MOVE_TYPE(gCurrentMove, gLastHitByType[gBankTarget]); + gLastLandedMoves[gBankDefender] = gCurrentMove; + GET_MOVE_TYPE(gCurrentMove, gLastHitByType[gBankDefender]); } } else { - gLastLandedMoves[gBankTarget] = 0xFFFF; + gLastLandedMoves[gBankDefender] = 0xFFFF; } } gBattleScripting.atk49_state++; @@ -5080,19 +5074,19 @@ static void atk49_moveend(void) case 15: // mirror move if (!(gAbsentBankFlags & gBitTable[gBankAttacker]) && !(gBattleStruct->field_91 & gBitTable[gBankAttacker]) && gBattleMoves[originallyUsedMove].flags & FLAG_MIRROR_MOVE_AFFECTED && gHitMarker & HITMARKER_OBEYS - && gBankAttacker != gBankTarget && !(gHitMarker & HITMARKER_FAINTED(gBankTarget)) - && !(gBattleMoveFlags & MOVESTATUS_NOEFFECT)) + && gBankAttacker != gBankDefender && !(gHitMarker & HITMARKER_FAINTED(gBankDefender)) + && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) { u8 target, attacker; - *(gBattleStruct->mirrorMoves + gBankTarget * 2 + 0) = gChosenMove; - *(gBattleStruct->mirrorMoves + gBankTarget * 2 + 1) = gChosenMove >> 8; + *(gBattleStruct->mirrorMoves + gBankDefender * 2 + 0) = gChosenMove; + *(gBattleStruct->mirrorMoves + gBankDefender * 2 + 1) = gChosenMove >> 8; - target = gBankTarget; + target = gBankDefender; attacker = gBankAttacker; *(attacker * 2 + target * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 0) = gChosenMove; - target = gBankTarget; + target = gBankDefender; attacker = gBankAttacker; *(attacker * 2 + target * 8 + (u8*)(gBattleStruct->mirrorMoveArrays) + 1) = gChosenMove >> 8; } @@ -5103,10 +5097,10 @@ static void atk49_moveend(void) && !gProtectStructs[gBankAttacker].chargingTurn && gBattleMoves[gCurrentMove].target == MOVE_TARGET_BOTH && !(gHitMarker & HITMARKER_NO_ATTACKSTRING)) { - u8 bank = GetBankByIdentity(GetBankPosition(gBankTarget) ^ BIT_MON); + u8 bank = GetBankByPosition(B_POSITION_PARTNER(GetBankPosition(gBankDefender))); if (gBattleMons[bank].hp != 0) { - gBankTarget = bank; + gBankDefender = bank; gHitMarker |= HITMARKER_NO_ATTACKSTRING; gBattleScripting.atk49_state = 0; MoveValuesCleanUp(); @@ -5142,13 +5136,13 @@ static void atk4A_typecalc2(void) s32 i = 0; u8 moveType = gBattleMoves[gCurrentMove].type; - if (gBattleMons[gBankTarget].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) + if (gBattleMons[gBankDefender].ability == ABILITY_LEVITATE && moveType == TYPE_GROUND) { - gLastUsedAbility = gBattleMons[gBankTarget].ability; - gBattleMoveFlags |= (MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED); - gLastLandedMoves[gBankTarget] = 0; + gLastUsedAbility = gBattleMons[gBankDefender].ability; + gMoveResultFlags |= (MOVE_RESULT_MISSED | MOVE_RESULT_DOESNT_AFFECT_FOE); + gLastLandedMoves[gBankDefender] = 0; gBattleCommunication[6] = moveType; - RecordAbilityBattle(gBankTarget, gLastUsedAbility); + RecordAbilityBattle(gBankDefender, gLastUsedAbility); } else { @@ -5156,7 +5150,7 @@ static void atk4A_typecalc2(void) { if (TYPE_EFFECT_ATK_TYPE(i) == TYPE_FORESIGHT) { - if (gBattleMons[gBankTarget].status2 & STATUS2_FORESIGHT) + if (gBattleMons[gBankDefender].status2 & STATUS2_FORESIGHT) { break; } @@ -5170,42 +5164,42 @@ static void atk4A_typecalc2(void) if (TYPE_EFFECT_ATK_TYPE(i) == moveType) { // check type1 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type1) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type1) { if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { - gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED; + gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; break; } if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) { - flags |= MOVESTATUS_NOTVERYEFFECTIVE; + flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE; } if (TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) { - flags |= MOVESTATUS_SUPEREFFECTIVE; + flags |= MOVE_RESULT_SUPER_EFFECTIVE; } } // check type2 - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2) + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2) { - if (gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2 + if (gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NO_EFFECT) { - gBattleMoveFlags |= MOVESTATUS_NOTAFFECTED; + gMoveResultFlags |= MOVE_RESULT_DOESNT_AFFECT_FOE; break; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2 - && gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 + && gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_NOT_EFFECTIVE) { - flags |= MOVESTATUS_NOTVERYEFFECTIVE; + flags |= MOVE_RESULT_NOT_VERY_EFFECTIVE; } - if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankTarget].type2 - && gBattleMons[gBankTarget].type1 != gBattleMons[gBankTarget].type2 + if (TYPE_EFFECT_DEF_TYPE(i) == gBattleMons[gBankDefender].type2 + && gBattleMons[gBankDefender].type1 != gBattleMons[gBankDefender].type2 && TYPE_EFFECT_MULTIPLIER(i) == TYPE_MUL_SUPER_EFFECTIVE) { - flags |= MOVESTATUS_SUPEREFFECTIVE; + flags |= MOVE_RESULT_SUPER_EFFECTIVE; } } } @@ -5213,19 +5207,19 @@ static void atk4A_typecalc2(void) } } - if (gBattleMons[gBankTarget].ability == ABILITY_WONDER_GUARD - && !(flags & MOVESTATUS_NOEFFECT) + if (gBattleMons[gBankDefender].ability == ABILITY_WONDER_GUARD + && !(flags & MOVE_RESULT_NO_EFFECT) && AttacksThisTurn(gBankAttacker, gCurrentMove) == 2 - && (!(flags & MOVESTATUS_SUPEREFFECTIVE) || ((flags & (MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE)) == (MOVESTATUS_SUPEREFFECTIVE | MOVESTATUS_NOTVERYEFFECTIVE))) + && (!(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; - gBattleMoveFlags |= MOVESTATUS_MISSED; - gLastLandedMoves[gBankTarget] = 0; + gMoveResultFlags |= MOVE_RESULT_MISSED; + gLastLandedMoves[gBankDefender] = 0; gBattleCommunication[6] = 3; - RecordAbilityBattle(gBankTarget, gLastUsedAbility); + RecordAbilityBattle(gBankDefender, gLastUsedAbility); } - if (gBattleMoveFlags & MOVESTATUS_NOTAFFECTED) + if (gMoveResultFlags & MOVE_RESULT_DOESNT_AFFECT_FOE) gProtectStructs[gBankAttacker].targetNotAffected = 1; gBattlescriptCurrInstr++; @@ -5298,7 +5292,7 @@ static void atk4D_switchindataupdate(void) SwitchInClearSetData(); if (gBattleTypeFlags & BATTLE_TYPE_PALACE && gBattleMons[gActiveBank].maxHP / 2 >= gBattleMons[gActiveBank].hp - && gBattleMons[gActiveBank].hp != 0 && !(gBattleMons[gActiveBank].status1 & STATUS_SLEEP)) + && gBattleMons[gActiveBank].hp != 0 && !(gBattleMons[gActiveBank].status1 & STATUS1_SLEEP)) { gBattleStruct->field_92 |= gBitTable[gActiveBank]; } @@ -5454,10 +5448,10 @@ static void atk4F_jumpifcantswitch(void) { if (GetBankSide(gActiveBank) == SIDE_OPPONENT) { - r7 = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + r7 = GetBankByPosition(B_POSITION_OPPONENT_LEFT); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - compareVar = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + compareVar = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); else compareVar = r7; @@ -5465,10 +5459,10 @@ static void atk4F_jumpifcantswitch(void) } else { - r7 = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + r7 = GetBankByPosition(B_POSITION_PLAYER_LEFT); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) - compareVar = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + compareVar = GetBankByPosition(B_POSITION_PLAYER_RIGHT); else compareVar = r7; @@ -5515,7 +5509,7 @@ static void atk50_openpartyscreen(void) { if ((gBattleTypeFlags & (BATTLE_TYPE_DOUBLE | BATTLE_TYPE_MULTI)) != BATTLE_TYPE_DOUBLE) { - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (gHitMarker & HITMARKER_FAINTED(gActiveBank)) { @@ -5724,12 +5718,12 @@ static void atk50_openpartyscreen(void) { if (gBitTable[gBank1] & hitmarkerFaintBits) break; - if (gBank1 >= gNoOfAllBanks) + if (gBank1 >= gBattleBanksCount) break; gBank1++; } - if (gBank1 == gNoOfAllBanks) + if (gBank1 == gBattleBanksCount) gBattlescriptCurrInstr = jumpPtr; } else @@ -5768,7 +5762,7 @@ static void atk50_openpartyscreen(void) if (gBattleTypeFlags & BATTLE_TYPE_MULTI) { - for (gActiveBank = 0; gActiveBank < gNoOfAllBanks; gActiveBank++) + for (gActiveBank = 0; gActiveBank < gBattleBanksCount; gActiveBank++) { if (gActiveBank != bank) { @@ -5779,7 +5773,7 @@ static void atk50_openpartyscreen(void) } else { - gActiveBank = GetBankByIdentity(GetBankPosition(bank) ^ BIT_SIDE); + gActiveBank = GetBankByPosition(GetBankPosition(bank) ^ BIT_SIDE); if (gAbsentBankFlags & gBitTable[gActiveBank]) gActiveBank ^= BIT_MON; @@ -5801,7 +5795,7 @@ static void atk51_switchhandleorder(void) switch (gBattlescriptCurrInstr[2]) { case 0: - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBattleBufferB[i][0] == 0x22) { @@ -5867,15 +5861,15 @@ static void atk52_switchineffects(void) gHitMarker &= ~(HITMARKER_FAINTED(gActiveBank)); gSpecialStatuses[gActiveBank].flag40 = 0; - if (!(gSideAffecting[GetBankSide(gActiveBank)] & SIDE_STATUS_SPIKES_DAMAGED) - && (gSideAffecting[GetBankSide(gActiveBank)] & SIDE_STATUS_SPIKES) + if (!(gSideStatuses[GetBankSide(gActiveBank)] & SIDE_STATUS_SPIKES_DAMAGED) + && (gSideStatuses[GetBankSide(gActiveBank)] & SIDE_STATUS_SPIKES) && gBattleMons[gActiveBank].type1 != TYPE_FLYING && gBattleMons[gActiveBank].type2 != TYPE_FLYING && gBattleMons[gActiveBank].ability != ABILITY_LEVITATE) { u8 spikesDmg; - gSideAffecting[GetBankSide(gActiveBank)] |= SIDE_STATUS_SPIKES_DAMAGED; + gSideStatuses[GetBankSide(gActiveBank)] |= SIDE_STATUS_SPIKES_DAMAGED; gBattleMons[gActiveBank].status2 &= ~(STATUS2_DESTINY_BOND); gHitMarker &= ~(HITMARKER_DESTINYBOND); @@ -5905,15 +5899,15 @@ static void atk52_switchineffects(void) if (AbilityBattleEffects(ABILITYEFFECT_ON_SWITCHIN, gActiveBank, 0, 0, 0) == 0 && ItemBattleEffects(0, gActiveBank, 0) == 0) { - gSideAffecting[GetBankSide(gActiveBank)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); + gSideStatuses[GetBankSide(gActiveBank)] &= ~(SIDE_STATUS_SPIKES_DAMAGED); - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBanksByTurnOrder[i] == gActiveBank) gActionsByTurnOrder[i] = ACTION_CANCEL_PARTNER; } - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { u16* hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBankSide(i)]; *hpOnSwitchout = gBattleMons[i].hp; @@ -5928,7 +5922,7 @@ static void atk52_switchineffects(void) { if (hitmarkerFaintBits & gBitTable[gBank1] && !(gAbsentBankFlags & gBitTable[gBank1])) break; - if (gBank1 >= gNoOfAllBanks) + if (gBank1 >= gBattleBanksCount) break; gBank1++; } @@ -5940,7 +5934,7 @@ static void atk52_switchineffects(void) static void atk53_trainerslidein(void) { - gActiveBank = GetBankByIdentity(gBattlescriptCurrInstr[1]); + gActiveBank = GetBankByPosition(gBattlescriptCurrInstr[1]); EmitTrainerSlide(0); MarkBufferBankForExecution(gActiveBank); @@ -5976,7 +5970,7 @@ static void atk56_playfaintcry(void) static void atk57(void) { - gActiveBank = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + gActiveBank = GetBankByPosition(B_POSITION_PLAYER_LEFT); EmitCmd55(0, gBattleOutcome); MarkBufferBankForExecution(gActiveBank); @@ -6011,7 +6005,7 @@ static void atk59_handlelearnnewmove(void) } else { - gActiveBank = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + gActiveBank = GetBankByPosition(B_POSITION_PLAYER_LEFT); if (gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId && !(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) @@ -6020,7 +6014,7 @@ static void atk59_handlelearnnewmove(void) } if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - gActiveBank = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + gActiveBank = GetBankByPosition(B_POSITION_PLAYER_RIGHT); if (gBattlePartyID[gActiveBank] == gBattleStruct->expGetterId && !(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) { @@ -6202,7 +6196,7 @@ static void atk5C_hitanimation(void) { gActiveBank = GetBattleBank(gBattlescriptCurrInstr[1]); - if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) + if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { gBattlescriptCurrInstr += 2; } @@ -6318,8 +6312,8 @@ static void atk5E(void) static void atk5F(void) { gActiveBank = gBankAttacker; - gBankAttacker = gBankTarget; - gBankTarget = gActiveBank; + gBankAttacker = gBankDefender; + gBankDefender = gActiveBank; if (gHitMarker & HITMARKER_PURSUIT_TRAP) gHitMarker &= ~(HITMARKER_PURSUIT_TRAP); @@ -6494,7 +6488,7 @@ static void atk68_cancelallactions(void) { s32 i; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) gActionsByTurnOrder[i] = ACTION_CANCEL_PARTNER; gBattlescriptCurrInstr++; @@ -6504,42 +6498,42 @@ static void atk69_adjustsetdamage(void) // The same as 0x7, except there's no ra { u8 holdEffect, quality; - if (gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBankTarget].holdEffect, quality = gEnigmaBerries[gBankTarget].holdEffectParam; + holdEffect = gEnigmaBerries[gBankDefender].holdEffect, quality = gEnigmaBerries[gBankDefender].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankTarget].item); - quality = ItemId_GetHoldEffectParam(gBattleMons[gBankTarget].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankDefender].item); + quality = ItemId_GetHoldEffectParam(gBattleMons[gBankDefender].item); } - gStringBank = gBankTarget; + gStringBank = gBankDefender; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < quality) { - RecordItemEffectBattle(gBankTarget, holdEffect); - gSpecialStatuses[gBankTarget].focusBanded = 1; + RecordItemEffectBattle(gBankDefender, holdEffect); + gSpecialStatuses[gBankDefender].focusBanded = 1; } - if (gBattleMons[gBankTarget].status2 & STATUS2_SUBSTITUTE) + if (gBattleMons[gBankDefender].status2 & STATUS2_SUBSTITUTE) goto END; - if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBankTarget].endured - && !gSpecialStatuses[gBankTarget].focusBanded) + if (gBattleMoves[gCurrentMove].effect != EFFECT_FALSE_SWIPE && !gProtectStructs[gBankDefender].endured + && !gSpecialStatuses[gBankDefender].focusBanded) goto END; - if (gBattleMons[gBankTarget].hp > gBattleMoveDamage) + if (gBattleMons[gBankDefender].hp > gBattleMoveDamage) goto END; - gBattleMoveDamage = gBattleMons[gBankTarget].hp - 1; + gBattleMoveDamage = gBattleMons[gBankDefender].hp - 1; - if (gProtectStructs[gBankTarget].endured) + if (gProtectStructs[gBankDefender].endured) { - gBattleMoveFlags |= MOVESTATUS_ENDURED; + gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBankTarget].focusBanded) + else if (gSpecialStatuses[gBankDefender].focusBanded) { - gBattleMoveFlags |= MOVESTATUS_HUNGON; - gLastUsedItem = gBattleMons[gBankTarget].item; + gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; + gLastUsedItem = gBattleMons[gBankDefender].item; } END: @@ -6851,7 +6845,7 @@ static void atk6D_resetsentmonsvalue(void) static void atk6E_setatktoplayer0(void) { - gBankAttacker = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + gBankAttacker = GetBankByPosition(B_POSITION_PLAYER_LEFT); gBattlescriptCurrInstr++; } @@ -6964,18 +6958,18 @@ static void atk76_various(void) CancelMultiTurnMoves(gActiveBank); break; case VARIOUS_SET_MAGIC_COAT_TARGET: - gBankAttacker = gBankTarget; + gBankAttacker = gBankDefender; side = GetBankSide(gBankAttacker) ^ BIT_SIDE; if (gSideTimers[side].followmeTimer != 0 && gBattleMons[gSideTimers[side].followmeTarget].hp != 0) - gBankTarget = gSideTimers[side].followmeTarget; + gBankDefender = gSideTimers[side].followmeTarget; else - gBankTarget = gActiveBank; + gBankDefender = gActiveBank; break; case VARIOUS_IS_RUNNING_IMPOSSIBLE: gBattleCommunication[0] = IsRunningFromBattleImpossible(); break; case VARIOUS_GET_MOVE_TARGET: - gBankTarget = GetMoveTarget(gCurrentMove, 0); + gBankDefender = GetMoveTarget(gCurrentMove, 0); break; case 4: if (gHitMarker & HITMARKER_FAINTED(gActiveBank)) @@ -7023,7 +7017,7 @@ static void atk76_various(void) if (!(gBattleStruct->field_92 & gBitTable[gActiveBank]) && gBattleMons[gActiveBank].maxHP / 2 >= gBattleMons[gActiveBank].hp && gBattleMons[gActiveBank].hp != 0 - && !(gBattleMons[gActiveBank].status1 & STATUS_SLEEP)) + && !(gBattleMons[gActiveBank].status1 & STATUS1_SLEEP)) { gBattleStruct->field_92 |= gBitTable[gActiveBank]; gBattleCommunication[0] = 1; @@ -7092,7 +7086,7 @@ static void atk76_various(void) } break; case VARIOUS_RETURN_OPPONENT_MON2: - if (gNoOfAllBanks > 3) + if (gBattleBanksCount > 3) { gActiveBank = 3; if (gBattleMons[gActiveBank].hp != 0) @@ -7117,9 +7111,9 @@ static void atk76_various(void) break; case VARIOUS_SET_TELEPORT_OUTCOME: if (GetBankSide(gActiveBank) == SIDE_PLAYER) - gBattleOutcome = BATTLE_PLAYER_TELEPORTED; + gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; else - gBattleOutcome = BATTLE_OPPONENT_TELEPORTED; + gBattleOutcome = B_OUTCOME_POKE_TELEPORTED; break; case VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC: EmitPlayFanfareOrBGM(0, MUS_KACHI1, TRUE); @@ -7138,7 +7132,7 @@ static void atk77_setprotectlike(void) // protect and endure if (lastMove != MOVE_PROTECT && lastMove != MOVE_DETECT && lastMove != MOVE_ENDURE) gDisableStructs[gBankAttacker].protectUses = 0; - if (gCurrentTurnActionNumber == (gNoOfAllBanks - 1)) + if (gCurrentTurnActionNumber == (gBattleBanksCount - 1)) notLastTurn = FALSE; if (sProtectSuccessRates[gDisableStructs[gBankAttacker].protectUses] >= Random() && notLastTurn) @@ -7159,7 +7153,7 @@ static void atk77_setprotectlike(void) // protect and endure { gDisableStructs[gBankAttacker].protectUses = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 2; - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; } gBattlescriptCurrInstr++; @@ -7170,13 +7164,13 @@ static void atk78_faintifabilitynotdamp(void) if (gBattleExecBuffer) return; - for (gBankTarget = 0; gBankTarget < gNoOfAllBanks; gBankTarget++) + for (gBankDefender = 0; gBankDefender < gBattleBanksCount; gBankDefender++) { - if (gBattleMons[gBankTarget].ability == ABILITY_DAMP) + if (gBattleMons[gBankDefender].ability == ABILITY_DAMP) break; } - if (gBankTarget == gNoOfAllBanks) + if (gBankDefender == gBattleBanksCount) { gActiveBank = gBankAttacker; gBattleMoveDamage = gBattleMons[gActiveBank].hp; @@ -7184,18 +7178,18 @@ static void atk78_faintifabilitynotdamp(void) MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr++; - for (gBankTarget = 0; gBankTarget < gNoOfAllBanks; gBankTarget++) + for (gBankDefender = 0; gBankDefender < gBattleBanksCount; gBankDefender++) { - if (gBankTarget == gBankAttacker) + if (gBankDefender == gBankAttacker) continue; - if (!(gAbsentBankFlags & gBitTable[gBankTarget])) + if (!(gAbsentBankFlags & gBitTable[gBankDefender])) break; } } else { gLastUsedAbility = ABILITY_DAMP; - RecordAbilityBattle(gBankTarget, gBattleMons[gBankTarget].ability); + RecordAbilityBattle(gBankDefender, gBattleMons[gBankDefender].ability); gBattlescriptCurrInstr = BattleScript_DampStopsExplosion; } } @@ -7219,15 +7213,15 @@ static void atk7A_jumpifnexttargetvalid(void) if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { - for (gBankTarget++; ; gBankTarget++) + for (gBankDefender++; ; gBankDefender++) { - if (gBankTarget == gBankAttacker) + if (gBankDefender == gBankAttacker) continue; - if (!(gAbsentBankFlags & gBitTable[gBankTarget])) + if (!(gAbsentBankFlags & gBitTable[gBankDefender])) break; } - if (gBankTarget >= gNoOfAllBanks) + if (gBankDefender >= gBattleBanksCount) gBattlescriptCurrInstr += 5; else gBattlescriptCurrInstr = jumpPtr; @@ -7243,14 +7237,14 @@ static void atk7B_tryhealhalfhealth(void) const u8* failPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); if (gBattlescriptCurrInstr[5] == BS_GET_ATTACKER) - gBankTarget = gBankAttacker; + gBankDefender = gBankAttacker; - gBattleMoveDamage = gBattleMons[gBankTarget].maxHP / 2; + gBattleMoveDamage = gBattleMons[gBankDefender].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - if (gBattleMons[gBankTarget].hp == gBattleMons[gBankTarget].maxHP) + if (gBattleMons[gBankDefender].hp == gBattleMons[gBankDefender].maxHP) gBattlescriptCurrInstr = failPtr; else gBattlescriptCurrInstr += 6; @@ -7266,7 +7260,7 @@ static void atk7C_trymirrormove(void) for (i = 0; i < 3; i++) movesArray[i] = 0; - for (validMovesCount = 0, i = 0; i < gNoOfAllBanks; i++) + for (validMovesCount = 0, i = 0; i < gBattleBanksCount; i++) { if (i != gBankAttacker) { @@ -7288,7 +7282,7 @@ static void atk7C_trymirrormove(void) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = move; - gBankTarget = GetMoveTarget(gCurrentMove, 0); + gBankDefender = GetMoveTarget(gCurrentMove, 0); gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; } else if (validMovesCount) @@ -7296,7 +7290,7 @@ static void atk7C_trymirrormove(void) gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); i = Random() % validMovesCount; gCurrentMove = movesArray[i]; - gBankTarget = GetMoveTarget(gCurrentMove, 0); + gBankDefender = GetMoveTarget(gCurrentMove, 0); gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; } else @@ -7310,7 +7304,7 @@ static void atk7D_setrain(void) { if (gBattleWeather & WEATHER_RAIN_ANY) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 2; } else @@ -7324,14 +7318,14 @@ static void atk7D_setrain(void) static void atk7E_setreflect(void) { - if (gSideAffecting[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_REFLECT) + if (gSideStatuses[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_REFLECT) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } else { - gSideAffecting[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_REFLECT; + gSideStatuses[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_REFLECT; gSideTimers[GET_BANK_SIDE(gBankAttacker)].reflectTimer = 5; gSideTimers[GET_BANK_SIDE(gBankAttacker)].reflectBank = gBankAttacker; @@ -7345,20 +7339,20 @@ static void atk7E_setreflect(void) static void atk7F_setseeded(void) { - if (gBattleMoveFlags & MOVESTATUS_NOEFFECT || gStatuses3[gBankTarget] & STATUS3_LEECHSEED) + if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT || gStatuses3[gBankDefender] & STATUS3_LEECHSEED) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } - else if (gBattleMons[gBankTarget].type1 == TYPE_GRASS || gBattleMons[gBankTarget].type2 == TYPE_GRASS) + else if (gBattleMons[gBankDefender].type1 == TYPE_GRASS || gBattleMons[gBankDefender].type2 == TYPE_GRASS) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 2; } else { - gStatuses3[gBankTarget] |= gBankAttacker; - gStatuses3[gBankTarget] |= STATUS3_LEECHSEED; + gStatuses3[gBankDefender] |= gBankAttacker; + gStatuses3[gBankDefender] |= STATUS3_LEECHSEED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } @@ -7376,8 +7370,8 @@ static void atk80_manipulatedamage(void) gBattleMoveDamage /= 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - if ((gBattleMons[gBankTarget].maxHP / 2) < gBattleMoveDamage) - gBattleMoveDamage = gBattleMons[gBankTarget].maxHP / 2; + if ((gBattleMons[gBankDefender].maxHP / 2) < gBattleMoveDamage) + gBattleMoveDamage = gBattleMons[gBankDefender].maxHP / 2; break; case ATK80_DMG_DOUBLED: gBattleMoveDamage *= 2; @@ -7390,21 +7384,21 @@ static void atk80_manipulatedamage(void) static void atk81_trysetrest(void) { const u8 *failJump = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - gActiveBank = gBankTarget = gBankAttacker; - gBattleMoveDamage = gBattleMons[gBankTarget].maxHP * (-1); + gActiveBank = gBankDefender = gBankAttacker; + gBattleMoveDamage = gBattleMons[gBankDefender].maxHP * (-1); - if (gBattleMons[gBankTarget].hp == gBattleMons[gBankTarget].maxHP) + if (gBattleMons[gBankDefender].hp == gBattleMons[gBankDefender].maxHP) { gBattlescriptCurrInstr = failJump; } else { - if (gBattleMons[gBankTarget].status1 & ((u8)(~STATUS_SLEEP))) + if (gBattleMons[gBankDefender].status1 & ((u8)(~STATUS1_SLEEP))) gBattleCommunication[MULTISTRING_CHOOSER] = 1; else gBattleCommunication[MULTISTRING_CHOOSER] = 0; - gBattleMons[gBankTarget].status1 = 3; + gBattleMons[gBankDefender].status1 = 3; EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 5; @@ -7430,16 +7424,16 @@ bool8 UproarWakeUpCheck(u8 bank) { s32 i; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (!(gBattleMons[i].status2 & STATUS2_UPROAR) || gBattleMons[bank].ability == ABILITY_SOUNDPROOF) continue; gBattleScripting.bank = i; - if (gBankTarget == 0xFF) - gBankTarget = i; - else if (gBankTarget == i) + if (gBankDefender == 0xFF) + gBankDefender = i; + else if (gBankDefender == i) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -7447,7 +7441,7 @@ bool8 UproarWakeUpCheck(u8 bank) break; } - if (i == gNoOfAllBanks) + if (i == gBattleBanksCount) return FALSE; else return TRUE; @@ -7457,17 +7451,17 @@ static void atk84_jumpifcantmakeasleep(void) { const u8 *jumpPtr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - if (UproarWakeUpCheck(gBankTarget)) + if (UproarWakeUpCheck(gBankDefender)) { gBattlescriptCurrInstr = jumpPtr; } - else if (gBattleMons[gBankTarget].ability == ABILITY_INSOMNIA - || gBattleMons[gBankTarget].ability == ABILITY_VITAL_SPIRIT) + else if (gBattleMons[gBankDefender].ability == ABILITY_INSOMNIA + || gBattleMons[gBankDefender].ability == ABILITY_VITAL_SPIRIT) { - gLastUsedAbility = gBattleMons[gBankTarget].ability; + gLastUsedAbility = gBattleMons[gBankDefender].ability; gBattleCommunication[MULTISTRING_CHOOSER] = 2; gBattlescriptCurrInstr = jumpPtr; - RecordAbilityBattle(gBankTarget, gLastUsedAbility); + RecordAbilityBattle(gBankDefender, gLastUsedAbility); } else { @@ -7479,7 +7473,7 @@ static void atk85_stockpile(void) { if (gDisableStructs[gBankAttacker].stockpileCounter == 3) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else @@ -7504,9 +7498,9 @@ static void atk86_stockpiletobasedamage(void) { if (gBattleCommunication[6] != 1) { - gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankTarget], gCurrentMove, - gSideAffecting[GET_BANK_SIDE(gBankTarget)], 0, - 0, gBankAttacker, gBankTarget) + gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankDefender], gCurrentMove, + gSideStatuses[GET_BANK_SIDE(gBankDefender)], 0, + 0, gBankAttacker, gBankDefender) * gDisableStructs[gBankAttacker].stockpileCounter; gBattleScripting.animTurn = gDisableStructs[gBankAttacker].stockpileCounter; @@ -7532,7 +7526,7 @@ static void atk87_stockpiletohpheal(void) { gDisableStructs[gBankAttacker].stockpileCounter = 0; gBattlescriptCurrInstr = jumpPtr; - gBankTarget = gBankAttacker; + gBankDefender = gBankAttacker; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else @@ -7546,7 +7540,7 @@ static void atk87_stockpiletohpheal(void) gBattleScripting.animTurn = gDisableStructs[gBankAttacker].stockpileCounter; gDisableStructs[gBankAttacker].stockpileCounter = 0; gBattlescriptCurrInstr += 5; - gBankTarget = gBankAttacker; + gBankDefender = gBankAttacker; } } @@ -7568,7 +7562,7 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) if (flags & MOVE_EFFECT_AFFECTS_USER) gActiveBank = gBankAttacker; else - gActiveBank = gBankTarget; + gActiveBank = gBankDefender; flags &= ~(MOVE_EFFECT_AFFECTS_USER); @@ -7684,7 +7678,7 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) if (gBattleMons[gActiveBank].statStages[statId] == 0) gBattleCommunication[MULTISTRING_CHOOSER] = 2; else - gBattleCommunication[MULTISTRING_CHOOSER] = (gBankTarget == gActiveBank); + gBattleCommunication[MULTISTRING_CHOOSER] = (gBankDefender == gActiveBank); } } @@ -7711,7 +7705,7 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) if (gBattleMons[gActiveBank].statStages[statId] == 0xC) gBattleCommunication[MULTISTRING_CHOOSER] = 2; else - gBattleCommunication[MULTISTRING_CHOOSER] = (gBankTarget == gActiveBank); + gBattleCommunication[MULTISTRING_CHOOSER] = (gBankDefender == gActiveBank); } gBattleMons[gActiveBank].statStages[statId] += statValue; @@ -7721,7 +7715,7 @@ static u8 ChangeStatBuffs(s8 statValue, u8 statId, u8 flags, const u8 *BS_ptr) gBattleMons[gActiveBank].statStages[statId] = 0xC; if (gBattleCommunication[MULTISTRING_CHOOSER] == 2 && flags & STAT_CHANGE_BS_PTR) - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; if (gBattleCommunication[MULTISTRING_CHOOSER] == 2 && !(flags & STAT_CHANGE_BS_PTR)) return STAT_CHANGE_DIDNT_WORK; @@ -7740,7 +7734,7 @@ static void atk8A_normalisebuffs(void) // haze { s32 i, j; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { for (j = 0; j < BATTLE_STATS_NO; j++) gBattleMons[i].statStages[j] = 6; @@ -7794,19 +7788,19 @@ static void atk8E_initmultihitstring(void) static bool8 TryDoForceSwitchOut(void) { - if (gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) + if (gBattleMons[gBankAttacker].level >= gBattleMons[gBankDefender].level) { - *(gBattleStruct->field_58 + gBankTarget) = gBattlePartyID[gBankTarget]; + *(gBattleStruct->field_58 + gBankDefender) = gBattlePartyID[gBankDefender]; } else { u16 random = Random() & 0xFF; - if ((u32)((random * (gBattleMons[gBankAttacker].level + gBattleMons[gBankTarget].level) >> 8) + 1) <= (gBattleMons[gBankTarget].level / 4)) + if ((u32)((random * (gBattleMons[gBankAttacker].level + gBattleMons[gBankDefender].level) >> 8) + 1) <= (gBattleMons[gBankDefender].level / 4)) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); return FALSE; } - *(gBattleStruct->field_58 + gBankTarget) = gBattlePartyID[gBankTarget]; + *(gBattleStruct->field_58 + gBankDefender) = gBattlePartyID[gBankDefender]; } gBattlescriptCurrInstr = BattleScript_SuccessForceOut; @@ -7833,7 +7827,7 @@ static void atk8F_forcerandomswitch(void) if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER)) { - if (GetBankSide(gBankTarget) == SIDE_PLAYER) + if (GetBankSide(gBankDefender) == SIDE_PLAYER) party = gPlayerParty; else party = gEnemyParty; @@ -7842,7 +7836,7 @@ static void atk8F_forcerandomswitch(void) || (gBattleTypeFlags & BATTLE_TYPE_BATTLE_TOWER && gBattleTypeFlags & BATTLE_TYPE_x2000000) || (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)) { - if ((gBankTarget & BIT_MON) != 0) + if ((gBankDefender & BIT_MON) != 0) { firstMonId = 3; lastMonId = 6; @@ -7854,13 +7848,13 @@ static void atk8F_forcerandomswitch(void) } monsCount = 3; minNeeded = 1; - bank2PartyId = gBattlePartyID[gBankTarget]; - bank1PartyId = gBattlePartyID[gBankTarget ^ BIT_MON]; + bank2PartyId = gBattlePartyID[gBankDefender]; + bank1PartyId = gBattlePartyID[gBankDefender ^ BIT_MON]; } else if ((gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) || (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_x2000000)) { - if (sub_806D82C(GetBankMultiplayerId(gBankTarget)) == 1) + if (sub_806D82C(GetBankMultiplayerId(gBankDefender)) == 1) { firstMonId = 3; lastMonId = 6; @@ -7872,12 +7866,12 @@ static void atk8F_forcerandomswitch(void) } monsCount = 3; minNeeded = 1; - bank2PartyId = gBattlePartyID[gBankTarget]; - bank1PartyId = gBattlePartyID[gBankTarget ^ BIT_MON]; + bank2PartyId = gBattlePartyID[gBankDefender]; + bank1PartyId = gBattlePartyID[gBankDefender ^ BIT_MON]; } else if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) { - if (GetBankSide(gBankTarget) == SIDE_PLAYER) + if (GetBankSide(gBankDefender) == SIDE_PLAYER) { firstMonId = 0; lastMonId = 6; @@ -7886,7 +7880,7 @@ static void atk8F_forcerandomswitch(void) } else { - if ((gBankTarget & BIT_MON) != 0) + if ((gBankDefender & BIT_MON) != 0) { firstMonId = 3; lastMonId = 6; @@ -7899,8 +7893,8 @@ static void atk8F_forcerandomswitch(void) monsCount = 3; minNeeded = 1; } - bank2PartyId = gBattlePartyID[gBankTarget]; - bank1PartyId = gBattlePartyID[gBankTarget ^ BIT_MON]; + bank2PartyId = gBattlePartyID[gBankDefender]; + bank1PartyId = gBattlePartyID[gBankDefender ^ BIT_MON]; } else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { @@ -7908,8 +7902,8 @@ static void atk8F_forcerandomswitch(void) lastMonId = 6; monsCount = 6; minNeeded = 2; - bank2PartyId = gBattlePartyID[gBankTarget]; - bank1PartyId = gBattlePartyID[gBankTarget ^ BIT_MON]; + bank2PartyId = gBattlePartyID[gBankDefender]; + bank1PartyId = gBattlePartyID[gBankDefender ^ BIT_MON]; } else { @@ -7917,8 +7911,8 @@ static void atk8F_forcerandomswitch(void) lastMonId = 6; monsCount = 6; minNeeded = 1; - bank2PartyId = gBattlePartyID[gBankTarget]; // there is only one pokemon out in single battles - bank1PartyId = gBattlePartyID[gBankTarget]; + bank2PartyId = gBattlePartyID[gBankDefender]; // there is only one pokemon out in single battles + bank1PartyId = gBattlePartyID[gBankDefender]; } for (i = firstMonId; i < lastMonId; i++) @@ -7950,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 + gBankTarget) = i; + *(gBattleStruct->monToSwitchIntoId + gBankDefender) = i; if (!sub_81B1250()) - sub_803BDA0(gBankTarget); + sub_803BDA0(gBankDefender); 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(gBankTarget, i, 0); - sub_81B8E80(gBankTarget ^ BIT_MON, i, 1); + sub_81B8E80(gBankDefender, i, 0); + sub_81B8E80(gBankDefender ^ BIT_MON, i, 1); } if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER) - sub_80571DC(gBankTarget, i); + sub_80571DC(gBankDefender, i); } } else @@ -8058,14 +8052,14 @@ static void atk91_givepaydaymoney(void) static void atk92_setlightscreen(void) { - if (gSideAffecting[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_LIGHTSCREEN) + if (gSideStatuses[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_LIGHTSCREEN) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } else { - gSideAffecting[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_LIGHTSCREEN; + gSideStatuses[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_LIGHTSCREEN; gSideTimers[GET_BANK_SIDE(gBankAttacker)].lightscreenTimer = 5; gSideTimers[GET_BANK_SIDE(gBankAttacker)].lightscreenBank = gBankAttacker; @@ -8082,80 +8076,80 @@ static void atk93_tryKO(void) { u8 holdEffect, param; - if (gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY) + if (gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY) { - holdEffect = gEnigmaBerries[gBankTarget].holdEffect; - param = gEnigmaBerries[gBankTarget].holdEffectParam; + holdEffect = gEnigmaBerries[gBankDefender].holdEffect; + param = gEnigmaBerries[gBankDefender].holdEffectParam; } else { - holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankTarget].item); - param = ItemId_GetHoldEffectParam(gBattleMons[gBankTarget].item); + holdEffect = ItemId_GetHoldEffect(gBattleMons[gBankDefender].item); + param = ItemId_GetHoldEffectParam(gBattleMons[gBankDefender].item); } - gStringBank = gBankTarget; + gStringBank = gBankDefender; if (holdEffect == HOLD_EFFECT_FOCUS_BAND && (Random() % 100) < param) { - RecordItemEffectBattle(gBankTarget, HOLD_EFFECT_FOCUS_BAND); - gSpecialStatuses[gBankTarget].focusBanded = 1; + RecordItemEffectBattle(gBankDefender, HOLD_EFFECT_FOCUS_BAND); + gSpecialStatuses[gBankDefender].focusBanded = 1; } - if (gBattleMons[gBankTarget].ability == ABILITY_STURDY) + if (gBattleMons[gBankDefender].ability == ABILITY_STURDY) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; gLastUsedAbility = ABILITY_STURDY; gBattlescriptCurrInstr = BattleScript_SturdyPreventsOHKO; - RecordAbilityBattle(gBankTarget, ABILITY_STURDY); + RecordAbilityBattle(gBankDefender, ABILITY_STURDY); } else { u16 chance; - if (!(gStatuses3[gBankTarget] & STATUS3_ALWAYS_HITS)) + if (!(gStatuses3[gBankDefender] & STATUS3_ALWAYS_HITS)) { - chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBankAttacker].level - gBattleMons[gBankTarget].level); - if (Random() % 100 + 1 < chance && gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) + chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBankAttacker].level - gBattleMons[gBankDefender].level); + if (Random() % 100 + 1 < chance && gBattleMons[gBankAttacker].level >= gBattleMons[gBankDefender].level) chance = TRUE; else chance = FALSE; } - else if (gDisableStructs[gBankTarget].bankWithSureHit == gBankAttacker - && gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) + else if (gDisableStructs[gBankDefender].bankWithSureHit == gBankAttacker + && gBattleMons[gBankAttacker].level >= gBattleMons[gBankDefender].level) { chance = TRUE; } else { - chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBankAttacker].level - gBattleMons[gBankTarget].level); - if (Random() % 100 + 1 < chance && gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) + chance = gBattleMoves[gCurrentMove].accuracy + (gBattleMons[gBankAttacker].level - gBattleMons[gBankDefender].level); + if (Random() % 100 + 1 < chance && gBattleMons[gBankAttacker].level >= gBattleMons[gBankDefender].level) chance = TRUE; else chance = FALSE; } if (chance) { - if (gProtectStructs[gBankTarget].endured) + if (gProtectStructs[gBankDefender].endured) { - gBattleMoveDamage = gBattleMons[gBankTarget].hp - 1; - gBattleMoveFlags |= MOVESTATUS_ENDURED; + gBattleMoveDamage = gBattleMons[gBankDefender].hp - 1; + gMoveResultFlags |= MOVE_RESULT_FOE_ENDURED; } - else if (gSpecialStatuses[gBankTarget].focusBanded) + else if (gSpecialStatuses[gBankDefender].focusBanded) { - gBattleMoveDamage = gBattleMons[gBankTarget].hp - 1; - gBattleMoveFlags |= MOVESTATUS_HUNGON; - gLastUsedItem = gBattleMons[gBankTarget].item; + gBattleMoveDamage = gBattleMons[gBankDefender].hp - 1; + gMoveResultFlags |= MOVE_RESULT_FOE_HUNG_ON; + gLastUsedItem = gBattleMons[gBankDefender].item; } else { - gBattleMoveDamage = gBattleMons[gBankTarget].hp; - gBattleMoveFlags |= MOVESTATUS_ONEHITKO; + gBattleMoveDamage = gBattleMons[gBankDefender].hp; + gMoveResultFlags |= MOVE_RESULT_ONE_HIT_KO; } gBattlescriptCurrInstr += 5; } else { - gBattleMoveFlags |= MOVESTATUS_MISSED; - if (gBattleMons[gBankAttacker].level >= gBattleMons[gBankTarget].level) + gMoveResultFlags |= MOVE_RESULT_MISSED; + if (gBattleMons[gBankAttacker].level >= gBattleMons[gBankDefender].level) gBattleCommunication[MULTISTRING_CHOOSER] = 0; else gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -8166,7 +8160,7 @@ static void atk93_tryKO(void) static void atk94_damagetohalftargethp(void) // super fang { - gBattleMoveDamage = gBattleMons[gBankTarget].hp / 2; + gBattleMoveDamage = gBattleMons[gBankDefender].hp / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -8177,7 +8171,7 @@ static void atk95_setsandstorm(void) { if (gBattleWeather & WEATHER_SANDSTORM_ANY) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 2; } else @@ -8253,10 +8247,10 @@ static void atk97_tryinfatuating(void) else monAttacker = &gEnemyParty[gBattlePartyID[gBankAttacker]]; - if (GetBankSide(gBankTarget) == SIDE_PLAYER) - monTarget = &gPlayerParty[gBattlePartyID[gBankTarget]]; + if (GetBankSide(gBankDefender) == SIDE_PLAYER) + monTarget = &gPlayerParty[gBattlePartyID[gBankDefender]]; else - monTarget = &gEnemyParty[gBattlePartyID[gBankTarget]]; + monTarget = &gEnemyParty[gBattlePartyID[gBankDefender]]; speciesAttacker = GetMonData(monAttacker, MON_DATA_SPECIES); personalityAttacker = GetMonData(monAttacker, MON_DATA_PERSONALITY); @@ -8264,16 +8258,16 @@ static void atk97_tryinfatuating(void) speciesTarget = GetMonData(monTarget, MON_DATA_SPECIES); personalityTarget = GetMonData(monTarget, MON_DATA_PERSONALITY); - if (gBattleMons[gBankTarget].ability == ABILITY_OBLIVIOUS) + if (gBattleMons[gBankDefender].ability == ABILITY_OBLIVIOUS) { gBattlescriptCurrInstr = BattleScript_ObliviousPreventsAttraction; gLastUsedAbility = ABILITY_OBLIVIOUS; - RecordAbilityBattle(gBankTarget, ABILITY_OBLIVIOUS); + RecordAbilityBattle(gBankDefender, ABILITY_OBLIVIOUS); } else { if (GetGenderFromSpeciesAndPersonality(speciesAttacker, personalityAttacker) == GetGenderFromSpeciesAndPersonality(speciesTarget, personalityTarget) - || gBattleMons[gBankTarget].status2 & STATUS2_INFATUATION + || gBattleMons[gBankDefender].status2 & STATUS2_INFATUATION || GetGenderFromSpeciesAndPersonality(speciesAttacker, personalityAttacker) == MON_GENDERLESS || GetGenderFromSpeciesAndPersonality(speciesTarget, personalityTarget) == MON_GENDERLESS) { @@ -8281,7 +8275,7 @@ static void atk97_tryinfatuating(void) } else { - gBattleMons[gBankTarget].status2 |= STATUS2_INFATUATED_WITH(gBankAttacker); + gBattleMons[gBankDefender].status2 |= STATUS2_INFATUATED_WITH(gBankAttacker); gBattlescriptCurrInstr += 5; } } @@ -8309,7 +8303,7 @@ static void atk98_updatestatusicon(void) } if ((gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) { - gActiveBank = GetBankByIdentity(GetBankPosition(gBankAttacker) ^ BIT_MON); + gActiveBank = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_MON); if (!(gAbsentBankFlags & gBitTable[gActiveBank])) { EmitStatusIconUpdate(0, gBattleMons[gActiveBank].status1, gBattleMons[gActiveBank].status2); @@ -8324,14 +8318,14 @@ static void atk99_setmist(void) { if (gSideTimers[GET_BANK_SIDE(gBankAttacker)].mistTimer) { - gBattleMoveFlags |= MOVESTATUS_FAILED; + gMoveResultFlags |= MOVE_RESULT_FAILED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else { gSideTimers[GET_BANK_SIDE(gBankAttacker)].mistTimer = 5; gSideTimers[GET_BANK_SIDE(gBankAttacker)].mistBank = gBankAttacker; - gSideAffecting[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_MIST; + gSideStatuses[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_MIST; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } gBattlescriptCurrInstr++; @@ -8341,7 +8335,7 @@ static void atk9A_setfocusenergy(void) { if (gBattleMons[gBankAttacker].status2 & STATUS2_FOCUS_ENERGY) { - gBattleMoveFlags |= MOVESTATUS_FAILED; + gMoveResultFlags |= MOVE_RESULT_FAILED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else @@ -8356,10 +8350,10 @@ static void atk9B_transformdataexecution(void) { gChosenMove = 0xFFFF; gBattlescriptCurrInstr++; - if (gBattleMons[gBankTarget].status2 & STATUS2_TRANSFORMED - || gStatuses3[gBankTarget] & STATUS3_SEMI_INVULNERABLE) + if (gBattleMons[gBankDefender].status2 & STATUS2_TRANSFORMED + || gStatuses3[gBankDefender] & STATUS3_SEMI_INVULNERABLE) { - gBattleMoveFlags |= MOVESTATUS_FAILED; + gMoveResultFlags |= MOVE_RESULT_FAILED; gBattleCommunication[MULTISTRING_CHOOSER] = 1; } else @@ -8370,13 +8364,13 @@ static void atk9B_transformdataexecution(void) gBattleMons[gBankAttacker].status2 |= STATUS2_TRANSFORMED; gDisableStructs[gBankAttacker].disabledMove = 0; gDisableStructs[gBankAttacker].disableTimer1 = 0; - gDisableStructs[gBankAttacker].transformedMonPersonality = gBattleMons[gBankTarget].personality; + gDisableStructs[gBankAttacker].transformedMonPersonality = gBattleMons[gBankDefender].personality; gDisableStructs[gBankAttacker].unk18_b = 0; - PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBankTarget].species) + PREPARE_SPECIES_BUFFER(gBattleTextBuff1, gBattleMons[gBankDefender].species) battleMonAttacker = (u8*)(&gBattleMons[gBankAttacker]); - battleMonTarget = (u8*)(&gBattleMons[gBankTarget]); + battleMonTarget = (u8*)(&gBattleMons[gBankDefender]); for (i = 0; i < offsetof(struct BattlePokemon, pp); i++) battleMonAttacker[i] = battleMonTarget[i]; @@ -8436,10 +8430,10 @@ static void atk9D_mimicattackcopy(void) { gChosenMove = 0xFFFF; - if (IsMoveUncopyableByMimic(gLastMoves[gBankTarget]) + if (IsMoveUncopyableByMimic(gLastMoves[gBankDefender]) || gBattleMons[gBankAttacker].status2 & STATUS2_TRANSFORMED - || gLastMoves[gBankTarget] == 0 - || gLastMoves[gBankTarget] == 0xFFFF) + || gLastMoves[gBankDefender] == 0 + || gLastMoves[gBankDefender] == 0xFFFF) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -8449,20 +8443,20 @@ static void atk9D_mimicattackcopy(void) for (i = 0; i < 4; i++) { - if (gBattleMons[gBankAttacker].moves[i] == gLastMoves[gBankTarget]) + if (gBattleMons[gBankAttacker].moves[i] == gLastMoves[gBankDefender]) break; } if (i == 4) { - gBattleMons[gBankAttacker].moves[gCurrMovePos] = gLastMoves[gBankTarget]; - if (gBattleMoves[gLastMoves[gBankTarget]].pp < 5) - gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gLastMoves[gBankTarget]].pp; + gBattleMons[gBankAttacker].moves[gCurrMovePos] = gLastMoves[gBankDefender]; + if (gBattleMoves[gLastMoves[gBankDefender]].pp < 5) + gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gLastMoves[gBankDefender]].pp; else gBattleMons[gBankAttacker].pp[gCurrMovePos] = 5; - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBankTarget]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBankDefender]) gDisableStructs[gBankAttacker].unk18_b |= gBitTable[gCurrMovePos]; gBattlescriptCurrInstr += 5; @@ -8500,7 +8494,7 @@ static void atk9E_metronome(void) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gBattlescriptCurrInstr = gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]; - gBankTarget = GetMoveTarget(gCurrentMove, 0); + gBankDefender = GetMoveTarget(gCurrentMove, 0); return; } } @@ -8535,9 +8529,9 @@ static void atkA1_counterdamagecalculator(void) gBattleMoveDamage = gProtectStructs[gBankAttacker].physicalDmg * 2; if (gSideTimers[sideTarget].followmeTimer && gBattleMons[gSideTimers[sideTarget].followmeTarget].hp) - gBankTarget = gSideTimers[sideTarget].followmeTarget; + gBankDefender = gSideTimers[sideTarget].followmeTarget; else - gBankTarget = gProtectStructs[gBankAttacker].physicalBank; + gBankDefender = gProtectStructs[gBankAttacker].physicalBank; gBattlescriptCurrInstr += 5; } @@ -8558,9 +8552,9 @@ static void atkA2_mirrorcoatdamagecalculator(void) // a copy of atkA1 with the p gBattleMoveDamage = gProtectStructs[gBankAttacker].specialDmg * 2; if (gSideTimers[sideTarget].followmeTimer && gBattleMons[gSideTimers[sideTarget].followmeTarget].hp) - gBankTarget = gSideTimers[sideTarget].followmeTarget; + gBankDefender = gSideTimers[sideTarget].followmeTarget; else - gBankTarget = gProtectStructs[gBankAttacker].specialBank; + gBankDefender = gProtectStructs[gBankAttacker].specialBank; gBattlescriptCurrInstr += 5; } @@ -8577,17 +8571,17 @@ static void atkA3_disablelastusedattack(void) for (i = 0; i < 4; i++) { - if (gBattleMons[gBankTarget].moves[i] == gLastMoves[gBankTarget]) + if (gBattleMons[gBankDefender].moves[i] == gLastMoves[gBankDefender]) break; } - if (gDisableStructs[gBankTarget].disabledMove == 0 - && i != 4 && gBattleMons[gBankTarget].pp[i] != 0) + if (gDisableStructs[gBankDefender].disabledMove == 0 + && i != 4 && gBattleMons[gBankDefender].pp[i] != 0) { - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBankTarget].moves[i]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gBattleMons[gBankDefender].moves[i]) - gDisableStructs[gBankTarget].disabledMove = gBattleMons[gBankTarget].moves[i]; - gDisableStructs[gBankTarget].disableTimer1 = (Random() & 3) + 2; - gDisableStructs[gBankTarget].disableTimer2 = gDisableStructs[gBankTarget].disableTimer1; // used to save the random amount of turns? + gDisableStructs[gBankDefender].disabledMove = gBattleMons[gBankDefender].moves[i]; + gDisableStructs[gBankDefender].disableTimer1 = (Random() & 3) + 2; + gDisableStructs[gBankDefender].disableTimer2 = gDisableStructs[gBankDefender].disableTimer1; // used to save the random amount of turns? gBattlescriptCurrInstr += 5; } else @@ -8602,24 +8596,24 @@ static void atkA4_trysetencore(void) for (i = 0; i < 4; i++) { - if (gBattleMons[gBankTarget].moves[i] == gLastMoves[gBankTarget]) + if (gBattleMons[gBankDefender].moves[i] == gLastMoves[gBankDefender]) break; } - if (gLastMoves[gBankTarget] == MOVE_STRUGGLE - || gLastMoves[gBankTarget] == MOVE_ENCORE - || gLastMoves[gBankTarget] == MOVE_MIRROR_MOVE) + if (gLastMoves[gBankDefender] == MOVE_STRUGGLE + || gLastMoves[gBankDefender] == MOVE_ENCORE + || gLastMoves[gBankDefender] == MOVE_MIRROR_MOVE) { i = 4; } - if (gDisableStructs[gBankTarget].encoredMove == 0 - && i != 4 && gBattleMons[gBankTarget].pp[i] != 0) + if (gDisableStructs[gBankDefender].encoredMove == 0 + && i != 4 && gBattleMons[gBankDefender].pp[i] != 0) { - gDisableStructs[gBankTarget].encoredMove = gBattleMons[gBankTarget].moves[i]; - gDisableStructs[gBankTarget].encoredMovePos = i; - gDisableStructs[gBankTarget].encoreTimer1 = (Random() & 3) + 3; - gDisableStructs[gBankTarget].encoreTimer2 = gDisableStructs[gBankTarget].encoreTimer1; + gDisableStructs[gBankDefender].encoredMove = gBattleMons[gBankDefender].moves[i]; + gDisableStructs[gBankDefender].encoredMovePos = i; + gDisableStructs[gBankDefender].encoreTimer1 = (Random() & 3) + 3; + gDisableStructs[gBankDefender].encoreTimer2 = gDisableStructs[gBankDefender].encoreTimer1; gBattlescriptCurrInstr += 5; } else @@ -8630,10 +8624,10 @@ static void atkA4_trysetencore(void) static void atkA5_painsplitdmgcalc(void) { - if (!(gBattleMons[gBankTarget].status2 & STATUS2_SUBSTITUTE)) + if (!(gBattleMons[gBankDefender].status2 & STATUS2_SUBSTITUTE)) { - s32 hpDiff = (gBattleMons[gBankAttacker].hp + gBattleMons[gBankTarget].hp) / 2; - s32 painSplitHp = gBattleMoveDamage = gBattleMons[gBankTarget].hp - hpDiff; + s32 hpDiff = (gBattleMons[gBankAttacker].hp + gBattleMons[gBankDefender].hp) / 2; + s32 painSplitHp = gBattleMoveDamage = gBattleMons[gBankDefender].hp - hpDiff; u8* storeLoc = (void*)(&gBattleScripting.painSplitHp); storeLoc[0] = (painSplitHp); @@ -8642,7 +8636,7 @@ static void atkA5_painsplitdmgcalc(void) storeLoc[3] = (painSplitHp & 0xFF000000) >> 24; gBattleMoveDamage = gBattleMons[gBankAttacker].hp - hpDiff; - gSpecialStatuses[gBankTarget].moveturnLostHP = 0xFFFF; + gSpecialStatuses[gBankDefender].moveturnLostHP = 0xFFFF; gBattlescriptCurrInstr += 5; } @@ -8720,9 +8714,9 @@ static void atkA6_settypetorandomresistance(void) // conversion 2 static void atkA7_setalwayshitflag(void) { - gStatuses3[gBankTarget] &= ~(STATUS3_ALWAYS_HITS); - gStatuses3[gBankTarget] |= 0x10; - gDisableStructs[gBankTarget].bankWithSureHit = gBankAttacker; + gStatuses3[gBankDefender] &= ~(STATUS3_ALWAYS_HITS); + gStatuses3[gBankDefender] |= 0x10; + gDisableStructs[gBankDefender].bankWithSureHit = gBankAttacker; gBattlescriptCurrInstr++; } @@ -8731,10 +8725,10 @@ static void atkA8_copymovepermanently(void) // sketch gChosenMove = 0xFFFF; if (!(gBattleMons[gBankAttacker].status2 & STATUS2_TRANSFORMED) - && gLastPrintedMoves[gBankTarget] != MOVE_STRUGGLE - && gLastPrintedMoves[gBankTarget] != 0 - && gLastPrintedMoves[gBankTarget] != 0xFFFF - && gLastPrintedMoves[gBankTarget] != MOVE_SKETCH) + && gLastPrintedMoves[gBankDefender] != MOVE_STRUGGLE + && gLastPrintedMoves[gBankDefender] != 0 + && gLastPrintedMoves[gBankDefender] != 0xFFFF + && gLastPrintedMoves[gBankDefender] != MOVE_SKETCH) { s32 i; @@ -8742,7 +8736,7 @@ static void atkA8_copymovepermanently(void) // sketch { if (gBattleMons[gBankAttacker].moves[i] == MOVE_SKETCH) continue; - if (gBattleMons[gBankAttacker].moves[i] == gLastPrintedMoves[gBankTarget]) + if (gBattleMons[gBankAttacker].moves[i] == gLastPrintedMoves[gBankDefender]) break; } @@ -8754,8 +8748,8 @@ static void atkA8_copymovepermanently(void) // sketch { struct MovePpInfo movePpData; - gBattleMons[gBankAttacker].moves[gCurrMovePos] = gLastPrintedMoves[gBankTarget]; - gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gLastPrintedMoves[gBankTarget]].pp; + gBattleMons[gBankAttacker].moves[gCurrMovePos] = gLastPrintedMoves[gBankDefender]; + gBattleMons[gBankAttacker].pp[gCurrMovePos] = gBattleMoves[gLastPrintedMoves[gBankDefender]].pp; gActiveBank = gBankAttacker; for (i = 0; i < 4; i++) @@ -8768,7 +8762,7 @@ static void atkA8_copymovepermanently(void) // sketch EmitSetMonData(0, REQUEST_MOVES_PP_BATTLE, 0, sizeof(struct MovePpInfo), &movePpData); MarkBufferBankForExecution(gActiveBank); - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastPrintedMoves[gBankTarget]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastPrintedMoves[gBankDefender]) gBattlescriptCurrInstr += 5; } @@ -8855,7 +8849,7 @@ static void atkA9_trychoosesleeptalkmove(void) gRandomMove = gBattleMons[gBankAttacker].moves[movePosition]; gCurrMovePos = movePosition; gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); - gBankTarget = GetMoveTarget(gRandomMove, 0); + gBankDefender = GetMoveTarget(gRandomMove, 0); gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } } @@ -8869,8 +8863,8 @@ static void atkAA_setdestinybond(void) static void TrySetDestinyBondToHappen(void) { u8 sideAttacker = GetBankSide(gBankAttacker); - u8 sideTarget = GetBankSide(gBankTarget); - if (gBattleMons[gBankTarget].status2 & STATUS2_DESTINY_BOND + u8 sideTarget = GetBankSide(gBankDefender); + if (gBattleMons[gBankDefender].status2 & STATUS2_DESTINY_BOND && sideAttacker != sideTarget && !(gHitMarker & HITMARKER_GRUDGE)) { @@ -8901,31 +8895,31 @@ static void atkAC_remaininghptopower(void) static void atkAD_tryspiteppreduce(void) { - if (gLastMoves[gBankTarget] != 0 - && gLastMoves[gBankTarget] != 0xFFFF) + if (gLastMoves[gBankDefender] != 0 + && gLastMoves[gBankDefender] != 0xFFFF) { s32 i; for (i = 0; i < 4; i++) { - if (gLastMoves[gBankTarget] == gBattleMons[gBankTarget].moves[i]) + if (gLastMoves[gBankDefender] == gBattleMons[gBankDefender].moves[i]) break; } - if (i != 4 && gBattleMons[gBankTarget].pp[i] > 1) + if (i != 4 && gBattleMons[gBankDefender].pp[i] > 1) { s32 ppToDeduct = (Random() & 3) + 2; - if (gBattleMons[gBankTarget].pp[i] < ppToDeduct) - ppToDeduct = gBattleMons[gBankTarget].pp[i]; + if (gBattleMons[gBankDefender].pp[i] < ppToDeduct) + ppToDeduct = gBattleMons[gBankDefender].pp[i]; - PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBankTarget]) + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastMoves[gBankDefender]) ConvertIntToDecimalStringN(gBattleTextBuff2, ppToDeduct, 0, 1); PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff2, 1, ppToDeduct) - gBattleMons[gBankTarget].pp[i] -= ppToDeduct; - gActiveBank = gBankTarget; + gBattleMons[gBankDefender].pp[i] -= ppToDeduct; + gActiveBank = gBankDefender; if (!(gDisableStructs[gActiveBank].unk18_b & gBitTable[i]) && !(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) @@ -8936,8 +8930,8 @@ static void atkAD_tryspiteppreduce(void) gBattlescriptCurrInstr += 5; - if (gBattleMons[gBankTarget].pp[i] == 0) - CancelMultiTurnMoves(gBankTarget); + if (gBattleMons[gBankDefender].pp[i] == 0) + CancelMultiTurnMoves(gBankDefender); } else { @@ -8978,7 +8972,7 @@ static void atkAE_healpartystatus(void) gBattleCommunication[MULTISTRING_CHOOSER] |= 1; } - gActiveBank = gBattleScripting.bank = GetBankByIdentity(GetBankPosition(gBankAttacker) ^ BIT_MON); + gActiveBank = gBattleScripting.bank = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_MON); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBankFlags & gBitTable[gActiveBank])) @@ -9026,7 +9020,7 @@ static void atkAE_healpartystatus(void) gBattleMons[gBankAttacker].status1 = 0; gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); - gActiveBank = GetBankByIdentity(GetBankPosition(gBankAttacker) ^ BIT_MON); + gActiveBank = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_MON); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBankFlags & gBitTable[gActiveBank])) { @@ -9048,13 +9042,13 @@ static void atkAE_healpartystatus(void) static void atkAF_cursetarget(void) { - if (gBattleMons[gBankTarget].status2 & STATUS2_CURSED) + if (gBattleMons[gBankDefender].status2 & STATUS2_CURSED) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gBattleMons[gBankTarget].status2 |= STATUS2_CURSED; + gBattleMons[gBankDefender].status2 |= STATUS2_CURSED; gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; @@ -9074,7 +9068,7 @@ static void atkB0_trysetspikes(void) } else { - gSideAffecting[targetSide] |= SIDE_STATUS_SPIKES; + gSideStatuses[targetSide] |= SIDE_STATUS_SPIKES; gSideTimers[targetSide].spikesAmount++; gBattlescriptCurrInstr += 5; } @@ -9082,7 +9076,7 @@ static void atkB0_trysetspikes(void) static void atkB1_setforesight(void) { - gBattleMons[gBankTarget].status2 |= STATUS2_FORESIGHT; + gBattleMons[gBankDefender].status2 |= STATUS2_FORESIGHT; gBattlescriptCurrInstr++; } @@ -9091,7 +9085,7 @@ static void atkB2_trysetperishsong(void) s32 i; s32 notAffectedCount = 0; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gStatuses3[i] & STATUS3_PERISH_SONG || gBattleMons[i].ability == ABILITY_SOUNDPROOF) @@ -9108,7 +9102,7 @@ static void atkB2_trysetperishsong(void) PressurePPLoseOnUsingPerishSong(gBankAttacker); - if (notAffectedCount == gNoOfAllBanks) + if (notAffectedCount == gBattleBanksCount) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); else gBattlescriptCurrInstr += 5; @@ -9116,7 +9110,7 @@ static void atkB2_trysetperishsong(void) static void atkB3_rolloutdamagecalculation(void) { - if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) + if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { CancelMultiTurnMoves(gBankAttacker); gBattlescriptCurrInstr = BattleScript_MoveMissedPause; @@ -9151,8 +9145,8 @@ static void atkB3_rolloutdamagecalculation(void) static void atkB4_jumpifconfusedandstatmaxed(void) { - if (gBattleMons[gBankTarget].status2 & STATUS2_CONFUSION - && gBattleMons[gBankTarget].statStages[gBattlescriptCurrInstr[1]] == 0xC) + if (gBattleMons[gBankDefender].status2 & STATUS2_CONFUSION + && gBattleMons[gBankDefender].statStages[gBattlescriptCurrInstr[1]] == 0xC) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); else gBattlescriptCurrInstr += 6; @@ -9160,7 +9154,7 @@ static void atkB4_jumpifconfusedandstatmaxed(void) static void atkB5_furycuttercalc(void) { - if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) + if (gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { gDisableStructs[gBankAttacker].furyCutterCounter = 0; gBattlescriptCurrInstr = BattleScript_MoveMissedPause; @@ -9203,32 +9197,32 @@ static void atkB7_presentdamagecalculation(void) gDynamicBasePower = 120; else { - gBattleMoveDamage = gBattleMons[gBankTarget].maxHP / 4; + gBattleMoveDamage = gBattleMons[gBankDefender].maxHP / 4; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; } if (rand < 204) gBattlescriptCurrInstr = BattleScript_HitFromCritCalc; - else if (gBattleMons[gBankTarget].maxHP == gBattleMons[gBankTarget].hp) + else if (gBattleMons[gBankDefender].maxHP == gBattleMons[gBankDefender].hp) gBattlescriptCurrInstr = BattleScript_AlreadyAtFullHp; else { - gBattleMoveFlags &= ~(MOVESTATUS_NOTAFFECTED); + gMoveResultFlags &= ~(MOVE_RESULT_DOESNT_AFFECT_FOE); gBattlescriptCurrInstr = BattleScript_PresentHealTarget; } } static void atkB8_setsafeguard(void) { - if (gSideAffecting[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_SAFEGUARD) + if (gSideStatuses[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_SAFEGUARD) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 0; } else { - gSideAffecting[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_SAFEGUARD; + gSideStatuses[GET_BANK_SIDE(gBankAttacker)] |= SIDE_STATUS_SAFEGUARD; gSideTimers[GET_BANK_SIDE(gBankAttacker)].safeguardTimer = 5; gSideTimers[GET_BANK_SIDE(gBankAttacker)].safeguardBank = gBankAttacker; gBattleCommunication[MULTISTRING_CHOOSER] = 5; @@ -9280,11 +9274,11 @@ static void atkB9_magnitudedamagecalculation(void) PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 2, magnitude) - for (gBankTarget = 0; gBankTarget < gNoOfAllBanks; gBankTarget++) + for (gBankDefender = 0; gBankDefender < gBattleBanksCount; gBankDefender++) { - if (gBankTarget == gBankAttacker) + if (gBankDefender == gBankAttacker) continue; - if (!(gAbsentBankFlags & gBitTable[gBankTarget])) // a valid target was found + if (!(gAbsentBankFlags & gBitTable[gBankDefender])) // a valid target was found break; } @@ -9296,35 +9290,35 @@ static void atkBA_jumpifnopursuitswitchdmg(void) if (gMultiHitCounter == 1) { if (GetBankSide(gBankAttacker) == SIDE_PLAYER) - gBankTarget = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_LEFT); else - gBankTarget = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + gBankDefender = GetBankByPosition(B_POSITION_PLAYER_LEFT); } else { if (GetBankSide(gBankAttacker) == SIDE_PLAYER) - gBankTarget = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); else - gBankTarget = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + gBankDefender = GetBankByPosition(B_POSITION_PLAYER_RIGHT); } - if (gActionForBanks[gBankTarget] == ACTION_USE_MOVE - && gBankAttacker == *(gBattleStruct->moveTarget + gBankTarget) - && !(gBattleMons[gBankTarget].status1 & (STATUS_SLEEP | STATUS_FREEZE)) + if (gActionForBanks[gBankDefender] == ACTION_USE_MOVE + && gBankAttacker == *(gBattleStruct->moveTarget + gBankDefender) + && !(gBattleMons[gBankDefender].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) && gBattleMons[gBankAttacker].hp - && !gDisableStructs[gBankTarget].truantCounter - && gChosenMovesByBanks[gBankTarget] == MOVE_PURSUIT) + && !gDisableStructs[gBankDefender].truantCounter + && gChosenMovesByBanks[gBankDefender] == MOVE_PURSUIT) { s32 i; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { - if (gBanksByTurnOrder[i] == gBankTarget) + if (gBanksByTurnOrder[i] == gBankDefender) gActionsByTurnOrder[i] = 11; } gCurrentMove = MOVE_PURSUIT; - gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBankTarget); + gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovePositions + gBankDefender); gBattlescriptCurrInstr += 5; gBattleScripting.animTurn = 1; gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); @@ -9339,7 +9333,7 @@ static void atkBB_setsunny(void) { if (gBattleWeather & WEATHER_SUN_ANY) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 2; } else @@ -9381,7 +9375,7 @@ static void atkBD_copyfoestats(void) // psych up for (i = 0; i < BATTLE_STATS_NO; i++) { - gBattleMons[gBankAttacker].statStages[i] = gBattleMons[gBankTarget].statStages[i]; + gBattleMons[gBankAttacker].statStages[i] = gBattleMons[gBankDefender].statStages[i]; } gBattlescriptCurrInstr += 5; // Has an unused jump ptr(possibly for a failed attempt) parameter. @@ -9391,9 +9385,9 @@ static void atkBE_rapidspinfree(void) { if (gBattleMons[gBankAttacker].status2 & STATUS2_WRAPPED) { - gBattleScripting.bank = gBankTarget; + gBattleScripting.bank = gBankDefender; gBattleMons[gBankAttacker].status2 &= ~(STATUS2_WRAPPED); - gBankTarget = *(gBattleStruct->wrappedBy + gBankAttacker); + gBankDefender = *(gBattleStruct->wrappedBy + gBankAttacker); gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN; gBattleTextBuff1[1] = B_BUFF_MOVE; @@ -9411,9 +9405,9 @@ static void atkBE_rapidspinfree(void) BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_LeechSeedFree; } - else if (gSideAffecting[GetBankSide(gBankAttacker)] & SIDE_STATUS_SPIKES) + else if (gSideStatuses[GetBankSide(gBankAttacker)] & SIDE_STATUS_SPIKES) { - gSideAffecting[GetBankSide(gBankAttacker)] &= ~(SIDE_STATUS_SPIKES); + gSideStatuses[GetBankSide(gBankAttacker)] &= ~(SIDE_STATUS_SPIKES); gSideTimers[GetBankSide(gBankAttacker)].spikesAmount = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SpikesFree; @@ -9432,7 +9426,7 @@ static void atkBF_setdefensecurlbit(void) static void atkC0_recoverbasedonsunlight(void) { - gBankTarget = gBankAttacker; + gBankDefender = gBankAttacker; if (gBattleMons[gBankAttacker].hp != gBattleMons[gBankAttacker].maxHP) { @@ -9632,11 +9626,11 @@ _080544F0:\n\ static void atkC2_selectfirstvalidtarget(void) { - for (gBankTarget = 0; gBankTarget < gNoOfAllBanks; gBankTarget++) + for (gBankDefender = 0; gBankDefender < gBattleBanksCount; gBankDefender++) { - if (gBankTarget == gBankAttacker) + if (gBankDefender == gBankAttacker) continue; - if (!(gAbsentBankFlags & gBitTable[gBankTarget])) + if (!(gAbsentBankFlags & gBitTable[gBankDefender])) break; } gBattlescriptCurrInstr++; @@ -9644,22 +9638,22 @@ static void atkC2_selectfirstvalidtarget(void) static void atkC3_trysetfutureattack(void) { - if (gWishFutureKnock.futureSightCounter[gBankTarget] != 0) + if (gWishFutureKnock.futureSightCounter[gBankDefender] != 0) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gSideAffecting[GET_BANK_SIDE(gBankTarget)] |= SIDE_STATUS_FUTUREATTACK; - gWishFutureKnock.futureSightMove[gBankTarget] = gCurrentMove; - gWishFutureKnock.futureSightAttacker[gBankTarget] = gBankAttacker; - gWishFutureKnock.futureSightCounter[gBankTarget] = 3; - gWishFutureKnock.futureSightDmg[gBankTarget] = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankTarget], gCurrentMove, - gSideAffecting[GET_BANK_SIDE(gBankTarget)], 0, - 0, gBankAttacker, gBankTarget); + gSideStatuses[GET_BANK_SIDE(gBankDefender)] |= SIDE_STATUS_FUTUREATTACK; + gWishFutureKnock.futureSightMove[gBankDefender] = gCurrentMove; + gWishFutureKnock.futureSightAttacker[gBankDefender] = gBankAttacker; + gWishFutureKnock.futureSightCounter[gBankDefender] = 3; + gWishFutureKnock.futureSightDmg[gBankDefender] = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankDefender], gCurrentMove, + gSideStatuses[GET_BANK_SIDE(gBankDefender)], 0, + 0, gBankAttacker, gBankDefender); if (gProtectStructs[gBankAttacker].helpingHand) - gWishFutureKnock.futureSightDmg[gBankTarget] = gWishFutureKnock.futureSightDmg[gBankTarget] * 15 / 10; + gWishFutureKnock.futureSightDmg[gBankDefender] = gWishFutureKnock.futureSightDmg[gBankDefender] * 15 / 10; if (gCurrentMove == MOVE_DOOM_DESIRE) gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -9679,7 +9673,7 @@ static void atkC4_trydobeatup(void) else party = gEnemyParty; - if (gBattleMons[gBankTarget].hp == 0) + if (gBattleMons[gBankDefender].hp == 0) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -9703,7 +9697,7 @@ static void atkC4_trydobeatup(void) 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[gBankTarget].species].baseDefense; + gBattleMoveDamage /= gBaseStats[gBattleMons[gBankDefender].species].baseDefense; gBattleMoveDamage = (gBattleMoveDamage / 50) + 2; if (gProtectStructs[gBankAttacker].helpingHand) gBattleMoveDamage = gBattleMoveDamage * 15 / 10; @@ -9767,7 +9761,7 @@ static void atkC8_sethail(void) { if (gBattleWeather & WEATHER_HAIL_ANY) { - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; gBattleCommunication[MULTISTRING_CHOOSER] = 2; } else @@ -9782,8 +9776,8 @@ static void atkC8_sethail(void) static void atkC9_jumpifattackandspecialattackcannotfall(void) // memento { - if (gBattleMons[gBankTarget].statStages[STAT_STAGE_ATK] == 0 - && gBattleMons[gBankTarget].statStages[STAT_STAGE_SPATK] == 0 + if (gBattleMons[gBankDefender].statStages[STAT_STAGE_ATK] == 0 + && gBattleMons[gBankDefender].statStages[STAT_STAGE_SPATK] == 0 && gBattleCommunication[6] != 1) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); @@ -9817,14 +9811,14 @@ static void atkCC_callterrainattack(void) // nature power { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gCurrentMove = sNaturePowerMoves[gBattleTerrain]; - gBankTarget = GetMoveTarget(gCurrentMove, 0); + gBankDefender = GetMoveTarget(gCurrentMove, 0); BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]); gBattlescriptCurrInstr++; } static void atkCD_cureifburnedparalysedorpoisoned(void) // refresh { - if (gBattleMons[gBankAttacker].status1 & (STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON)) + if (gBattleMons[gBankAttacker].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)) { gBattleMons[gBankAttacker].status1 = 0; gBattlescriptCurrInstr += 5; @@ -9840,13 +9834,13 @@ static void atkCD_cureifburnedparalysedorpoisoned(void) // refresh static void atkCE_settorment(void) { - if (gBattleMons[gBankTarget].status2 & STATUS2_TORMENT) + if (gBattleMons[gBankDefender].status2 & STATUS2_TORMENT) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gBattleMons[gBankTarget].status2 |= STATUS2_TORMENT; + gBattleMons[gBankDefender].status2 |= STATUS2_TORMENT; gBattlescriptCurrInstr += 5; } } @@ -9861,10 +9855,10 @@ static void atkCF_jumpifnodamage(void) static void atkD0_settaunt(void) { - if (gDisableStructs[gBankTarget].tauntTimer1 == 0) + if (gDisableStructs[gBankDefender].tauntTimer1 == 0) { - gDisableStructs[gBankTarget].tauntTimer1 = 2; - gDisableStructs[gBankTarget].tauntTimer2 = 2; + gDisableStructs[gBankDefender].tauntTimer1 = 2; + gDisableStructs[gBankDefender].tauntTimer2 = 2; gBattlescriptCurrInstr += 5; } else @@ -9875,14 +9869,14 @@ static void atkD0_settaunt(void) static void atkD1_trysethelpinghand(void) { - gBankTarget = GetBankByIdentity(GetBankPosition(gBankAttacker) ^ BIT_MON); + gBankDefender = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_MON); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE - && !(gAbsentBankFlags & gBitTable[gBankTarget]) + && !(gAbsentBankFlags & gBitTable[gBankDefender]) && !gProtectStructs[gBankAttacker].helpingHand - && !gProtectStructs[gBankTarget].helpingHand) + && !gProtectStructs[gBankDefender].helpingHand) { - gProtectStructs[gBankTarget].helpingHand = 1; + gProtectStructs[gBankDefender].helpingHand = 1; gBattlescriptCurrInstr += 5; } else @@ -9907,7 +9901,7 @@ static void atkD2_tryswapitems(void) // trick else { u8 sideAttacker = GetBankSide(gBankAttacker); - u8 sideTarget = GetBankSide(gBankTarget); + u8 sideTarget = GetBankSide(gBankDefender); // you can't swap items if they were knocked off in regular battles if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK @@ -9916,26 +9910,26 @@ static void atkD2_tryswapitems(void) // trick | BATTLE_TYPE_SECRET_BASE | BATTLE_TYPE_x2000000)) && (gWishFutureKnock.knockedOffPokes[sideAttacker] & gBitTable[gBattlePartyID[gBankAttacker]] - || gWishFutureKnock.knockedOffPokes[sideTarget] & gBitTable[gBattlePartyID[gBankTarget]])) + || gWishFutureKnock.knockedOffPokes[sideTarget] & gBitTable[gBattlePartyID[gBankDefender]])) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } // can't swap if two pokemon don't have an item // or if either of them is an enigma berry or a mail - else if ((gBattleMons[gBankAttacker].item == 0 && gBattleMons[gBankTarget].item == 0) + else if ((gBattleMons[gBankAttacker].item == 0 && gBattleMons[gBankDefender].item == 0) || gBattleMons[gBankAttacker].item == ITEM_ENIGMA_BERRY - || gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY + || gBattleMons[gBankDefender].item == ITEM_ENIGMA_BERRY || IS_ITEM_MAIL(gBattleMons[gBankAttacker].item) - || IS_ITEM_MAIL(gBattleMons[gBankTarget].item)) + || IS_ITEM_MAIL(gBattleMons[gBankDefender].item)) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } // check if ability prevents swapping - else if (gBattleMons[gBankTarget].ability == ABILITY_STICKY_HOLD) + else if (gBattleMons[gBankDefender].ability == ABILITY_STICKY_HOLD) { gBattlescriptCurrInstr = BattleScript_StickyHoldActivates; - gLastUsedAbility = gBattleMons[gBankTarget].ability; - RecordAbilityBattle(gBankTarget, gLastUsedAbility); + gLastUsedAbility = gBattleMons[gBankDefender].ability; + RecordAbilityBattle(gBankDefender, gLastUsedAbility); } // took a while, but all checks passed and items can be safely swapped else @@ -9944,21 +9938,21 @@ static void atkD2_tryswapitems(void) // trick newItemAtk = &gBattleStruct->changedItems[gBankAttacker]; oldItemAtk = gBattleMons[gBankAttacker].item; - *newItemAtk = gBattleMons[gBankTarget].item; + *newItemAtk = gBattleMons[gBankDefender].item; gBattleMons[gBankAttacker].item = 0; - gBattleMons[gBankTarget].item = oldItemAtk; + gBattleMons[gBankDefender].item = oldItemAtk; gActiveBank = gBankAttacker; EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, newItemAtk); MarkBufferBankForExecution(gBankAttacker); - gActiveBank = gBankTarget; - EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBankTarget].item); - MarkBufferBankForExecution(gBankTarget); + gActiveBank = gBankDefender; + EmitSetMonData(0, REQUEST_HELDITEM_BATTLE, 0, 2, &gBattleMons[gBankDefender].item); + MarkBufferBankForExecution(gBankDefender); - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankTarget]) + 0) = 0; - *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankTarget]) + 1) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankDefender]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankDefender]) + 1) = 0; *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankAttacker]) + 0) = 0; *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankAttacker]) + 1) = 0; @@ -9980,11 +9974,11 @@ static void atkD2_tryswapitems(void) // trick static void atkD3_trycopyability(void) // role play { - if (gBattleMons[gBankTarget].ability != 0 - && gBattleMons[gBankTarget].ability != ABILITY_WONDER_GUARD) + if (gBattleMons[gBankDefender].ability != 0 + && gBattleMons[gBankDefender].ability != ABILITY_WONDER_GUARD) { - gBattleMons[gBankAttacker].ability = gBattleMons[gBankTarget].ability; - gLastUsedAbility = gBattleMons[gBankTarget].ability; + gBattleMons[gBankAttacker].ability = gBattleMons[gBankDefender].ability; + gLastUsedAbility = gBattleMons[gBankDefender].ability; gBattlescriptCurrInstr += 5; } else @@ -10010,14 +10004,14 @@ static void atkD4_trywish(void) } break; case 1: // heal effect - PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBankTarget, gWishFutureKnock.wishUserID[gBankTarget]) + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBankDefender, gWishFutureKnock.wishUserID[gBankDefender]) - gBattleMoveDamage = gBattleMons[gBankTarget].maxHP / 2; + gBattleMoveDamage = gBattleMons[gBankDefender].maxHP / 2; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; gBattleMoveDamage *= -1; - if (gBattleMons[gBankTarget].hp == gBattleMons[gBankTarget].maxHP) + if (gBattleMons[gBankDefender].hp == gBattleMons[gBankDefender].maxHP) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); else gBattlescriptCurrInstr += 6; @@ -10042,9 +10036,9 @@ static void atkD5_trysetroots(void) // ingrain static void atkD6_doubledamagedealtifdamaged(void) { if ((gProtectStructs[gBankAttacker].physicalDmg - && gProtectStructs[gBankAttacker].physicalBank == gBankTarget) + && gProtectStructs[gBankAttacker].physicalBank == gBankDefender) || (gProtectStructs[gBankAttacker].specialDmg - && gProtectStructs[gBankAttacker].specialBank == gBankTarget)) + && gProtectStructs[gBankAttacker].specialBank == gBankDefender)) { gBattleScripting.dmgMultiplier = 2; } @@ -10054,27 +10048,27 @@ static void atkD6_doubledamagedealtifdamaged(void) static void atkD7_setyawn(void) { - if (gStatuses3[gBankTarget] & STATUS3_YAWN - || gBattleMons[gBankTarget].status1 & STATUS_ANY) + if (gStatuses3[gBankDefender] & STATUS3_YAWN + || gBattleMons[gBankDefender].status1 & STATUS1_ANY) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gStatuses3[gBankTarget] |= 0x1000; + gStatuses3[gBankDefender] |= 0x1000; gBattlescriptCurrInstr += 5; } } static void atkD8_setdamagetohealthdifference(void) { - if (gBattleMons[gBankTarget].hp <= gBattleMons[gBankAttacker].hp) + if (gBattleMons[gBankDefender].hp <= gBattleMons[gBankAttacker].hp) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { - gBattleMoveDamage = gBattleMons[gBankTarget].hp - gBattleMons[gBankAttacker].hp; + gBattleMoveDamage = gBattleMons[gBankDefender].hp - gBattleMons[gBankAttacker].hp; gBattlescriptCurrInstr += 5; } } @@ -10094,18 +10088,18 @@ static void atkD9_scaledamagebyhealthratio(void) static void atkDA_tryswapabilities(void) // skill swap { if ((gBattleMons[gBankAttacker].ability == 0 - && gBattleMons[gBankTarget].ability == 0) + && gBattleMons[gBankDefender].ability == 0) || gBattleMons[gBankAttacker].ability == ABILITY_WONDER_GUARD - || gBattleMons[gBankTarget].ability == ABILITY_WONDER_GUARD - || gBattleMoveFlags & MOVESTATUS_NOEFFECT) + || gBattleMons[gBankDefender].ability == ABILITY_WONDER_GUARD + || gMoveResultFlags & MOVE_RESULT_NO_EFFECT) { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } else { u8 abilityAtk = gBattleMons[gBankAttacker].ability; - gBattleMons[gBankAttacker].ability = gBattleMons[gBankTarget].ability; - gBattleMons[gBankTarget].ability = abilityAtk; + gBattleMons[gBankAttacker].ability = gBattleMons[gBankDefender].ability; + gBattleMons[gBankDefender].ability = abilityAtk; gBattlescriptCurrInstr += 5; } @@ -10123,7 +10117,7 @@ static void atkDB_tryimprision(void) sideAttacker = GetBankSide(gBankAttacker); PressurePPLoseOnUsingImprision(gBankAttacker); - for (bank = 0; bank < gNoOfAllBanks; bank++) + for (bank = 0; bank < gBattleBanksCount; bank++) { if (sideAttacker != GetBankSide(bank)) { @@ -10148,7 +10142,7 @@ static void atkDB_tryimprision(void) } } } - if (bank == gNoOfAllBanks) // In Generation 3 games, Imprison fails if the user doesn't share any moves with any of the foes + if (bank == gBattleBanksCount) // In Generation 3 games, Imprison fails if the user doesn't share any moves with any of the foes gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } } @@ -10171,7 +10165,7 @@ static void atkDD_weightdamagecalculation(void) s32 i; for (i = 0; sWeightToDamageTable[i] != 0xFFFF; i += 2) { - if (sWeightToDamageTable[i] > GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBankTarget].species), 1)) + if (sWeightToDamageTable[i] > GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBankDefender].species), 1)) break; } @@ -10227,7 +10221,7 @@ static void atkDE_asistattackselect(void) { gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gRandomMove = movesArray[((Random() & 0xFF) * chooseableMovesNo) >> 8]; - gBankTarget = GetMoveTarget(gRandomMove, 0); + gBankDefender = GetMoveTarget(gRandomMove, 0); gBattlescriptCurrInstr += 5; } else @@ -10238,9 +10232,9 @@ static void atkDE_asistattackselect(void) static void atkDF_trysetmagiccoat(void) { - gBankTarget = gBankAttacker; + gBankDefender = gBankAttacker; gSpecialStatuses[gBankAttacker].flag20 = 1; - if (gCurrentTurnActionNumber == gNoOfAllBanks - 1) // moves last turn + if (gCurrentTurnActionNumber == gBattleBanksCount - 1) // moves last turn { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -10254,7 +10248,7 @@ static void atkDF_trysetmagiccoat(void) static void atkE0_trysetsnatch(void) // snatch { gSpecialStatuses[gBankAttacker].flag20 = 1; - if (gCurrentTurnActionNumber == gNoOfAllBanks - 1) // moves last turn + if (gCurrentTurnActionNumber == gBattleBanksCount - 1) // moves last turn { gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); } @@ -10274,15 +10268,15 @@ static void atkE1_trygetintimidatetarget(void) PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gBattleMons[gBattleScripting.bank].ability) - for (;gBankTarget < gNoOfAllBanks; gBankTarget++) + for (;gBankDefender < gBattleBanksCount; gBankDefender++) { - if (GetBankSide(gBankTarget) == side) + if (GetBankSide(gBankDefender) == side) continue; - if (!(gAbsentBankFlags & gBitTable[gBankTarget])) + if (!(gAbsentBankFlags & gBitTable[gBankDefender])) break; } - if (gBankTarget >= gNoOfAllBanks) + if (gBankDefender >= gBattleBanksCount) gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); else gBattlescriptCurrInstr += 5; @@ -10544,7 +10538,7 @@ static void atkEB_settypetoterrain(void) static void atkEC_pursuitrelated(void) { - gActiveBank = GetBankByIdentity(GetBankPosition(gBankAttacker) ^ BIT_MON); + gActiveBank = GetBankByPosition(GetBankPosition(gBankAttacker) ^ BIT_MON); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE && !(gAbsentBankFlags & gBitTable[gActiveBank]) @@ -10568,10 +10562,10 @@ static void atkEF_snatchsetbanks(void) { gEffectBank = gBankAttacker; - if (gBankAttacker == gBankTarget) - gBankAttacker = gBankTarget = gBattleScripting.bank; + if (gBankAttacker == gBankDefender) + gBankAttacker = gBankDefender = gBattleScripting.bank; else - gBankTarget = gBattleScripting.bank; + gBankDefender = gBattleScripting.bank; gBattleScripting.bank = gEffectBank; gBattlescriptCurrInstr++; @@ -10583,8 +10577,8 @@ static void atkEE_removelightscreenreflect(void) // brick break if (gSideTimers[opposingSide].reflectTimer || gSideTimers[opposingSide].lightscreenTimer) { - gSideAffecting[opposingSide] &= ~(SIDE_STATUS_REFLECT); - gSideAffecting[opposingSide] &= ~(SIDE_STATUS_LIGHTSCREEN); + gSideStatuses[opposingSide] &= ~(SIDE_STATUS_REFLECT); + gSideStatuses[opposingSide] &= ~(SIDE_STATUS_LIGHTSCREEN); gSideTimers[opposingSide].reflectTimer = 0; gSideTimers[opposingSide].lightscreenTimer = 0; gBattleScripting.animTurn = 1; @@ -10607,7 +10601,7 @@ static void atkEF_handleballthrow(void) return; gActiveBank = gBankAttacker; - gBankTarget = gBankAttacker ^ BIT_SIDE; + gBankDefender = gBankAttacker ^ BIT_SIDE; if (gBattleTypeFlags & BATTLE_TYPE_TRAINER) { @@ -10629,17 +10623,17 @@ static void atkEF_handleballthrow(void) if (gLastUsedItem == ITEM_SAFARI_BALL) catchRate = gBattleStruct->field_7C * 1275 / 100; else - catchRate = gBaseStats[gBattleMons[gBankTarget].species].catchRate; + catchRate = gBaseStats[gBattleMons[gBankDefender].species].catchRate; if (gLastUsedItem > ITEM_SAFARI_BALL) { switch (gLastUsedItem) { case ITEM_NET_BALL: - if (gBattleMons[gBankTarget].type1 == TYPE_WATER - || gBattleMons[gBankTarget].type2 == TYPE_WATER - || gBattleMons[gBankTarget].type1 == TYPE_BUG - || gBattleMons[gBankTarget].type2 == TYPE_BUG) + if (gBattleMons[gBankDefender].type1 == TYPE_WATER + || gBattleMons[gBankDefender].type2 == TYPE_WATER + || gBattleMons[gBankDefender].type1 == TYPE_BUG + || gBattleMons[gBankDefender].type2 == TYPE_BUG) ballMultiplier = 30; else ballMultiplier = 10; @@ -10651,9 +10645,9 @@ static void atkEF_handleballthrow(void) ballMultiplier = 10; break; case ITEM_NEST_BALL: - if (gBattleMons[gBankTarget].level < 40) + if (gBattleMons[gBankDefender].level < 40) { - ballMultiplier = 40 - gBattleMons[gBankTarget].level; + ballMultiplier = 40 - gBattleMons[gBankDefender].level; if (ballMultiplier <= 9) ballMultiplier = 10; } @@ -10663,7 +10657,7 @@ static void atkEF_handleballthrow(void) } break; case ITEM_REPEAT_BALL: - if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBankTarget].species), FLAG_GET_CAUGHT)) + if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(gBattleMons[gBankDefender].species), FLAG_GET_CAUGHT)) ballMultiplier = 30; else ballMultiplier = 10; @@ -10683,12 +10677,12 @@ static void atkEF_handleballthrow(void) ballMultiplier = sBallCatchBonuses[gLastUsedItem - 2]; odds = (catchRate * ballMultiplier / 10) - * (gBattleMons[gBankTarget].maxHP * 3 - gBattleMons[gBankTarget].hp * 2) - / (3 * gBattleMons[gBankTarget].maxHP); + * (gBattleMons[gBankDefender].maxHP * 3 - gBattleMons[gBankDefender].hp * 2) + / (3 * gBattleMons[gBankDefender].maxHP); - if (gBattleMons[gBankTarget].status1 & (STATUS_SLEEP | STATUS_FREEZE)) + if (gBattleMons[gBankDefender].status1 & (STATUS1_SLEEP | STATUS1_FREEZE)) odds *= 2; - if (gBattleMons[gBankTarget].status1 & (STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON)) + if (gBattleMons[gBankDefender].status1 & (STATUS1_POISON | STATUS1_BURN | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON)) odds = (odds * 15) / 10; if (gLastUsedItem != ITEM_SAFARI_BALL) @@ -10709,7 +10703,7 @@ static void atkEF_handleballthrow(void) EmitBallThrowAnim(0, BALL_3_SHAKES_SUCCESS); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr = BattleScript_SuccessBallThrow; - SetMonData(&gEnemyParty[gBattlePartyID[gBankTarget]], MON_DATA_POKEBALL, &gLastUsedItem); + SetMonData(&gEnemyParty[gBattlePartyID[gBankDefender]], MON_DATA_POKEBALL, &gLastUsedItem); if (CalculatePlayerPartyCount() == 6) gBattleCommunication[MULTISTRING_CHOOSER] = 0; @@ -10734,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[gBattlePartyID[gBankTarget]], MON_DATA_POKEBALL, &gLastUsedItem); + SetMonData(&gEnemyParty[gBattlePartyID[gBankDefender]], MON_DATA_POKEBALL, &gLastUsedItem); if (CalculatePlayerPartyCount() == 6) gBattleCommunication[MULTISTRING_CHOOSER] = 0; @@ -10810,8 +10804,8 @@ static void atkF2_displaydexinfo(void) { FreeAllWindowBuffers(); gBattleCommunication[TASK_ID] = CreateDexDisplayMonDataTask(SpeciesToNationalPokedexNum(species), - gBattleMons[gBankTarget].otId, - gBattleMons[gBankTarget].personality); + gBattleMons[gBankDefender].otId, + gBattleMons[gBankDefender].personality); gBattleCommunication[0]++; } break; @@ -11010,12 +11004,12 @@ static void atkF6_finishaction(void) static void atkF7_finishturn(void) { gCurrentActionFuncId = ACTION_FINISHED; - gCurrentTurnActionNumber = gNoOfAllBanks; + gCurrentTurnActionNumber = gBattleBanksCount; } static void atkF8_trainerslideout(void) { - gActiveBank = GetBankByIdentity(gBattlescriptCurrInstr[1]); + gActiveBank = GetBankByPosition(gBattlescriptCurrInstr[1]); EmitTrainerSlideBack(0); MarkBufferBankForExecution(gActiveBank); diff --git a/src/battle_setup.c b/src/battle_setup.c index 6d7a97844..96af536fe 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -990,14 +990,14 @@ static bool32 IsPlayerDefeated(u32 battleOutcome) { switch (battleOutcome) { - case BATTLE_LOST: - case BATTLE_DREW: + case B_OUTCOME_LOST: + case B_OUTCOME_DREW: return TRUE; - case BATTLE_WON: - case BATTLE_RAN: - case BATTLE_PLAYER_TELEPORTED: - case BATTLE_POKE_FLED: - case BATTLE_CAUGHT: + case B_OUTCOME_WON: + case B_OUTCOME_RAN: + case B_OUTCOME_PLAYER_TELEPORTED: + case B_OUTCOME_POKE_FLED: + case B_OUTCOME_CAUGHT_POKE: return FALSE; default: return FALSE; diff --git a/src/battle_util.c b/src/battle_util.c index 2a1b421f5..250976347 100644 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -31,14 +31,14 @@ extern u8 gActiveBank; extern u8 gStringBank; extern u16 gCurrentMove; extern u16 gLastUsedItem; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern u32 gStatuses3[BATTLE_BANKS_COUNT]; extern u8 gBankAttacker; -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gAbsentBankFlags; extern u16 gBattleWeather; extern u8 gBanksByTurnOrder[BATTLE_BANKS_COUNT]; -extern u16 gSideAffecting[2]; +extern u16 gSideStatuses[2]; extern u8 gBattleCommunication[]; extern void (*gBattleMainFunc)(void); extern s32 gBattleMoveDamage; @@ -51,7 +51,7 @@ extern u8 gEffectBank; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; extern u8 gBank1; extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT]; -extern u8 gBattleMoveFlags; +extern u8 gMoveResultFlags; extern s32 gTakenDmg[BATTLE_BANKS_COUNT]; extern u8 gTakenDmgBanks[BATTLE_BANKS_COUNT]; extern u8 gLastUsedAbility; @@ -79,7 +79,7 @@ u8 GetBattleBank(u8 caseId) switch (caseId) { case BS_GET_TARGET: - ret = gBankTarget; + ret = gBankDefender; break; case BS_GET_ATTACKER: ret = gBankAttacker; @@ -104,16 +104,16 @@ u8 GetBattleBank(u8 caseId) case 8: case 9: case BS_GET_PLAYER1: - ret = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + ret = GetBankByPosition(B_POSITION_PLAYER_LEFT); break; case BS_GET_OPPONENT1: - ret = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + ret = GetBankByPosition(B_POSITION_OPPONENT_LEFT); break; case BS_GET_PLAYER2: - ret = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + ret = GetBankByPosition(B_POSITION_PLAYER_RIGHT); break; case BS_GET_OPPONENT2: - ret = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + ret = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); break; } return ret; @@ -153,7 +153,7 @@ void PressurePPLoseOnUsingImprision(u8 bankAtk) s32 imprisionPos = 4; u8 atkSide = GetBankSide(bankAtk); - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (atkSide != GetBankSide(i) && gBattleMons[i].ability == ABILITY_PRESSURE) { @@ -186,7 +186,7 @@ void PressurePPLoseOnUsingPerishSong(u8 bankAtk) s32 i, j; s32 perishSongPos = 4; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBattleMons[i].ability == ABILITY_PRESSURE && i != bankAtk) { @@ -220,12 +220,12 @@ void MarkAllBufferBanksForExecution(void) // unused if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) gBattleExecBuffer |= gBitTable[i] << 0x1C; } else { - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) gBattleExecBuffer |= gBitTable[i]; } } @@ -296,10 +296,10 @@ void ResetSentPokesToOpponentValue(void) gSentPokesToOpponent[0] = 0; gSentPokesToOpponent[1] = 0; - for (i = 0; i < gNoOfAllBanks; i += 2) + for (i = 0; i < gBattleBanksCount; i += 2) bits |= gBitTable[gBattlePartyID[i]]; - for (i = 1; i < gNoOfAllBanks; i += 2) + for (i = 1; i < gBattleBanksCount; i += 2) gSentPokesToOpponent[(i & BIT_MON) >> 1] = bits; } @@ -313,7 +313,7 @@ void sub_803F9EC(u8 bank) u8 id = ((bank & BIT_MON) >> 1); gSentPokesToOpponent[id] = 0; - for (i = 0; i < gNoOfAllBanks; i += 2) + for (i = 0; i < gBattleBanksCount; i += 2) { if (!(gAbsentBankFlags & gBitTable[i])) bits |= gBitTable[gBattlePartyID[i]]; @@ -332,7 +332,7 @@ void sub_803FA70(u8 bank) else { s32 i; - for (i = 1; i < gNoOfAllBanks; i++) + for (i = 1; i < gBattleBanksCount; i++) gSentPokesToOpponent[(i & BIT_MON) >> 1] |= gBitTable[gBattlePartyID[bank]]; } } @@ -517,7 +517,7 @@ u8 GetImprisonedMovesCount(u8 bank, u16 move) u8 imprisionedMoves = 0; u8 bankSide = GetBankSide(bank); - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (bankSide != GetBankSide(i) && gStatuses3[i] & STATUS3_IMPRISONED_OTHERS) { @@ -540,10 +540,10 @@ u8 UpdateTurnCounters(void) u8 effect = 0; s32 i; - for (gBankAttacker = 0; gBankAttacker < gNoOfAllBanks && gAbsentBankFlags & gBitTable[gBankAttacker]; gBankAttacker++) + for (gBankAttacker = 0; gBankAttacker < gBattleBanksCount && gAbsentBankFlags & gBitTable[gBankAttacker]; gBankAttacker++) { } - for (gBankTarget = 0; gBankTarget < gNoOfAllBanks && gAbsentBankFlags & gBitTable[gBankTarget]; gBankTarget++) + for (gBankDefender = 0; gBankDefender < gBattleBanksCount && gAbsentBankFlags & gBitTable[gBankDefender]; gBankDefender++) { } @@ -554,14 +554,14 @@ u8 UpdateTurnCounters(void) switch (gBattleStruct->turncountersTracker) { case 0: - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { gBanksByTurnOrder[i] = i; } - for (i = 0; i < gNoOfAllBanks - 1; i++) + for (i = 0; i < gBattleBanksCount - 1; i++) { s32 j; - for (j = i + 1; j < gNoOfAllBanks; j++) + for (j = i + 1; j < gBattleBanksCount; j++) { if (GetWhoStrikesFirst(gBanksByTurnOrder[i], gBanksByTurnOrder[j], 0)) SwapTurnOrder(i, j); @@ -580,11 +580,11 @@ u8 UpdateTurnCounters(void) { sideBank = gBattleStruct->turnSideTracker; gActiveBank = gBankAttacker = gSideTimers[sideBank].reflectBank; - if (gSideAffecting[sideBank] & SIDE_STATUS_REFLECT) + if (gSideStatuses[sideBank] & SIDE_STATUS_REFLECT) { if (--gSideTimers[sideBank].reflectTimer == 0) { - gSideAffecting[sideBank] &= ~SIDE_STATUS_REFLECT; + gSideStatuses[sideBank] &= ~SIDE_STATUS_REFLECT; BattleScriptExecute(BattleScript_SideStatusWoreOff); PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_REFLECT); effect++; @@ -605,11 +605,11 @@ u8 UpdateTurnCounters(void) { sideBank = gBattleStruct->turnSideTracker; gActiveBank = gBankAttacker = gSideTimers[sideBank].lightscreenBank; - if (gSideAffecting[sideBank] & SIDE_STATUS_LIGHTSCREEN) + if (gSideStatuses[sideBank] & SIDE_STATUS_LIGHTSCREEN) { if (--gSideTimers[sideBank].lightscreenTimer == 0) { - gSideAffecting[sideBank] &= ~SIDE_STATUS_LIGHTSCREEN; + gSideStatuses[sideBank] &= ~SIDE_STATUS_LIGHTSCREEN; BattleScriptExecute(BattleScript_SideStatusWoreOff); gBattleCommunication[MULTISTRING_CHOOSER] = sideBank; PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_LIGHT_SCREEN); @@ -634,7 +634,7 @@ u8 UpdateTurnCounters(void) if (gSideTimers[sideBank].mistTimer != 0 && --gSideTimers[sideBank].mistTimer == 0) { - gSideAffecting[sideBank] &= ~SIDE_STATUS_MIST; + gSideStatuses[sideBank] &= ~SIDE_STATUS_MIST; BattleScriptExecute(BattleScript_SideStatusWoreOff); gBattleCommunication[MULTISTRING_CHOOSER] = sideBank; PREPARE_MOVE_BUFFER(gBattleTextBuff1, MOVE_MIST); @@ -655,11 +655,11 @@ u8 UpdateTurnCounters(void) { sideBank = gBattleStruct->turnSideTracker; gActiveBank = gBankAttacker = gSideTimers[sideBank].safeguardBank; - if (gSideAffecting[sideBank] & SIDE_STATUS_SAFEGUARD) + if (gSideStatuses[sideBank] & SIDE_STATUS_SAFEGUARD) { if (--gSideTimers[sideBank].safeguardTimer == 0) { - gSideAffecting[sideBank] &= ~SIDE_STATUS_SAFEGUARD; + gSideStatuses[sideBank] &= ~SIDE_STATUS_SAFEGUARD; BattleScriptExecute(BattleScript_SafeguardEnds); effect++; } @@ -675,14 +675,14 @@ u8 UpdateTurnCounters(void) } break; case 5: - while (gBattleStruct->turnSideTracker < gNoOfAllBanks) + while (gBattleStruct->turnSideTracker < gBattleBanksCount) { gActiveBank = gBanksByTurnOrder[gBattleStruct->turnSideTracker]; if (gWishFutureKnock.wishCounter[gActiveBank] != 0 && --gWishFutureKnock.wishCounter[gActiveBank] == 0 && gBattleMons[gActiveBank].hp != 0) { - gBankTarget = gActiveBank; + gBankDefender = gActiveBank; BattleScriptExecute(BattleScript_WishComesTrue); effect++; } @@ -798,7 +798,7 @@ u8 TurnBasedEffects(void) u8 effect = 0; gHitMarker |= (HITMARKER_GRUDGE | HITMARKER_x20); - while (gBattleStruct->turnEffectsBank < gNoOfAllBanks && gBattleStruct->turnEffectsTracker <= TURNBASED_MAX_CASE) + while (gBattleStruct->turnEffectsBank < gBattleBanksCount && gBattleStruct->turnEffectsTracker <= TURNBASED_MAX_CASE) { gActiveBank = gBankAttacker = gBanksByTurnOrder[gBattleStruct->turnEffectsBank]; if (gAbsentBankFlags & gBitTable[gActiveBank]) @@ -843,11 +843,11 @@ u8 TurnBasedEffects(void) && gBattleMons[gStatuses3[gActiveBank] & STATUS3_LEECHSEED_BANK].hp != 0 && gBattleMons[gActiveBank].hp != 0) { - gBankTarget = gStatuses3[gActiveBank] & STATUS3_LEECHSEED_BANK; //funny how the 'target' is actually the bank that receives HP + gBankDefender = gStatuses3[gActiveBank] & STATUS3_LEECHSEED_BANK; //funny how the 'target' is actually the bank that receives HP gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; if (gBattleMoveDamage == 0) gBattleMoveDamage = 1; - gBattleScripting.animArg1 = gBankTarget; + gBattleScripting.animArg1 = gBankDefender; gBattleScripting.animArg2 = gBankAttacker; BattleScriptExecute(BattleScript_LeechSeedTurnDrain); effect++; @@ -855,7 +855,7 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 4: // poison - if ((gBattleMons[gActiveBank].status1 & STATUS_POISON) && gBattleMons[gActiveBank].hp != 0) + if ((gBattleMons[gActiveBank].status1 & STATUS1_POISON) && gBattleMons[gActiveBank].hp != 0) { gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; if (gBattleMoveDamage == 0) @@ -866,7 +866,7 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 5: // toxic poison - if ((gBattleMons[gActiveBank].status1 & STATUS_TOXIC_POISON) && gBattleMons[gActiveBank].hp != 0) + if ((gBattleMons[gActiveBank].status1 & STATUS1_TOXIC_POISON) && gBattleMons[gActiveBank].hp != 0) { gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 16; if (gBattleMoveDamage == 0) @@ -880,7 +880,7 @@ u8 TurnBasedEffects(void) gBattleStruct->turnEffectsTracker++; break; case 6: // burn - if ((gBattleMons[gActiveBank].status1 & STATUS_BURN) && gBattleMons[gActiveBank].hp != 0) + if ((gBattleMons[gActiveBank].status1 & STATUS1_BURN) && gBattleMons[gActiveBank].hp != 0) { gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 8; if (gBattleMoveDamage == 0) @@ -895,7 +895,7 @@ u8 TurnBasedEffects(void) { // R/S does not perform this sleep check, which causes the nighmare effect to // persist even after the affected Pokemon has been awakened by Shed Skin - if (gBattleMons[gActiveBank].status1 & STATUS_SLEEP) + if (gBattleMons[gActiveBank].status1 & STATUS1_SLEEP) { gBattleMoveDamage = gBattleMons[gActiveBank].maxHP / 4; if (gBattleMoveDamage == 0) @@ -957,12 +957,12 @@ u8 TurnBasedEffects(void) case 10: // uproar if (gBattleMons[gActiveBank].status2 & STATUS2_UPROAR) { - for (gBankAttacker = 0; gBankAttacker < gNoOfAllBanks; gBankAttacker++) + for (gBankAttacker = 0; gBankAttacker < gBattleBanksCount; gBankAttacker++) { - if ((gBattleMons[gBankAttacker].status1 & STATUS_SLEEP) + if ((gBattleMons[gBankAttacker].status1 & STATUS1_SLEEP) && gBattleMons[gBankAttacker].ability != ABILITY_SOUNDPROOF) { - gBattleMons[gBankAttacker].status1 &= ~(STATUS_SLEEP); + gBattleMons[gBankAttacker].status1 &= ~(STATUS1_SLEEP); gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); gBattleCommunication[MULTISTRING_CHOOSER] = 1; BattleScriptExecute(BattleScript_MonWokeUpInUproar); @@ -972,7 +972,7 @@ u8 TurnBasedEffects(void) break; } } - if (gBankAttacker != gNoOfAllBanks) + if (gBankAttacker != gBattleBanksCount) { effect = 2; // a pokemon was awaken break; @@ -1086,7 +1086,7 @@ u8 TurnBasedEffects(void) if (gStatuses3[gActiveBank] & STATUS3_YAWN) { gStatuses3[gActiveBank] -= 0x800; - if (!(gStatuses3[gActiveBank] & STATUS3_YAWN) && !(gBattleMons[gActiveBank].status1 & STATUS_ANY) + if (!(gStatuses3[gActiveBank] & STATUS3_YAWN) && !(gBattleMons[gActiveBank].status1 & STATUS1_ANY) && gBattleMons[gActiveBank].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gActiveBank].ability != ABILITY_INSOMNIA && !UproarWakeUpCheck(gActiveBank)) { @@ -1121,7 +1121,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void) switch (gBattleStruct->wishPerishSongState) { case 0: - while (gBattleStruct->wishPerishSongBank < gNoOfAllBanks) + while (gBattleStruct->wishPerishSongBank < gBattleBanksCount) { gActiveBank = gBattleStruct->wishPerishSongBank; if (gAbsentBankFlags & gBitTable[gActiveBank]) @@ -1142,16 +1142,16 @@ bool8 HandleWishPerishSongOnTurnEnd(void) PREPARE_MOVE_BUFFER(gBattleTextBuff1, gWishFutureKnock.futureSightMove[gActiveBank]); - gBankTarget = gActiveBank; + gBankDefender = gActiveBank; gBankAttacker = gWishFutureKnock.futureSightAttacker[gActiveBank]; gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBank]; - gSpecialStatuses[gBankTarget].moveturnLostHP = 0xFFFF; + gSpecialStatuses[gBankDefender].moveturnLostHP = 0xFFFF; BattleScriptExecute(BattleScript_MonTookFutureAttack); if (gWishFutureKnock.futureSightCounter[gActiveBank] == 0 && gWishFutureKnock.futureSightCounter[gActiveBank ^ BIT_MON] == 0) { - gSideAffecting[GET_BANK_SIDE(gBankTarget)] &= ~(SIDE_STATUS_FUTUREATTACK); + gSideStatuses[GET_BANK_SIDE(gBankDefender)] &= ~(SIDE_STATUS_FUTUREATTACK); } return TRUE; } @@ -1164,7 +1164,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void) } // fall through case 1: - while (gBattleStruct->wishPerishSongBank < gNoOfAllBanks) + while (gBattleStruct->wishPerishSongBank < gBattleBanksCount) { gActiveBank = gBankAttacker = gBanksByTurnOrder[gBattleStruct->wishPerishSongBank]; if (gAbsentBankFlags & gBitTable[gActiveBank]) @@ -1235,7 +1235,7 @@ bool8 HandleFaintedMonActions(void) case 0: gBattleStruct->faintedActionsBank = 0; gBattleStruct->faintedActionsState++; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gAbsentBankFlags & gBitTable[i] && !sub_80423F4(i, 6, 6)) gAbsentBankFlags &= ~(gBitTable[i]); @@ -1244,7 +1244,7 @@ bool8 HandleFaintedMonActions(void) case 1: do { - gBank1 = gBankTarget = gBattleStruct->faintedActionsBank; + gBank1 = gBankDefender = gBattleStruct->faintedActionsBank; if (gBattleMons[gBattleStruct->faintedActionsBank].hp == 0 && !(gBattleStruct->field_DF & gBitTable[gBattlePartyID[gBattleStruct->faintedActionsBank]]) && !(gAbsentBankFlags & gBitTable[gBattleStruct->faintedActionsBank])) @@ -1253,12 +1253,12 @@ bool8 HandleFaintedMonActions(void) gBattleStruct->faintedActionsState = 2; return TRUE; } - } while (++gBattleStruct->faintedActionsBank != gNoOfAllBanks); + } while (++gBattleStruct->faintedActionsBank != gBattleBanksCount); gBattleStruct->faintedActionsState = 3; break; case 2: sub_803F9EC(gBank1); - if (++gBattleStruct->faintedActionsBank == gNoOfAllBanks) + if (++gBattleStruct->faintedActionsBank == gBattleBanksCount) gBattleStruct->faintedActionsState = 3; else gBattleStruct->faintedActionsState = 1; @@ -1270,7 +1270,7 @@ bool8 HandleFaintedMonActions(void) case 4: do { - gBank1 = gBankTarget = gBattleStruct->faintedActionsBank; + gBank1 = gBankDefender = gBattleStruct->faintedActionsBank; if (gBattleMons[gBattleStruct->faintedActionsBank].hp == 0 && !(gAbsentBankFlags & gBitTable[gBattleStruct->faintedActionsBank])) { @@ -1278,11 +1278,11 @@ bool8 HandleFaintedMonActions(void) gBattleStruct->faintedActionsState = 5; return TRUE; } - } while (++gBattleStruct->faintedActionsBank != gNoOfAllBanks); + } while (++gBattleStruct->faintedActionsBank != gBattleBanksCount); gBattleStruct->faintedActionsState = 6; break; case 5: - if (++gBattleStruct->faintedActionsBank == gNoOfAllBanks) + if (++gBattleStruct->faintedActionsBank == gBattleBanksCount) gBattleStruct->faintedActionsState = 6; else gBattleStruct->faintedActionsState = 4; @@ -1302,7 +1302,7 @@ bool8 HandleFaintedMonActions(void) void TryClearRageStatuses(void) { int i; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if ((gBattleMons[i].status2 & STATUS2_RAGE) && gChosenMovesByBanks[i] != MOVE_RAGE) gBattleMons[i].status2 &= ~(STATUS2_RAGE); @@ -1325,11 +1325,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 1: // check being asleep - if (gBattleMons[gBankAttacker].status1 & STATUS_SLEEP) + if (gBattleMons[gBankAttacker].status1 & STATUS1_SLEEP) { if (UproarWakeUpCheck(gBankAttacker)) { - gBattleMons[gBankAttacker].status1 &= ~(STATUS_SLEEP); + gBattleMons[gBankAttacker].status1 &= ~(STATUS1_SLEEP); gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); BattleScriptPushCursor(); gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -1343,11 +1343,11 @@ u8 AtkCanceller_UnableToUseMove(void) toSub = 2; else toSub = 1; - if ((gBattleMons[gBankAttacker].status1 & STATUS_SLEEP) < toSub) - gBattleMons[gBankAttacker].status1 &= ~(STATUS_SLEEP); + if ((gBattleMons[gBankAttacker].status1 & STATUS1_SLEEP) < toSub) + gBattleMons[gBankAttacker].status1 &= ~(STATUS1_SLEEP); else gBattleMons[gBankAttacker].status1 -= toSub; - if (gBattleMons[gBankAttacker].status1 & STATUS_SLEEP) + if (gBattleMons[gBankAttacker].status1 & STATUS1_SLEEP) { if (gCurrentMove != MOVE_SNORE && gCurrentMove != MOVE_SLEEP_TALK) { @@ -1369,7 +1369,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 2: // check being frozen - if (gBattleMons[gBankAttacker].status1 & STATUS_FREEZE) + if (gBattleMons[gBankAttacker].status1 & STATUS1_FREEZE) { if (Random() % 5) { @@ -1386,7 +1386,7 @@ u8 AtkCanceller_UnableToUseMove(void) } else // unfreeze { - gBattleMons[gBankAttacker].status1 &= ~(STATUS_FREEZE); + gBattleMons[gBankAttacker].status1 &= ~(STATUS1_FREEZE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; gBattleCommunication[MULTISTRING_CHOOSER] = 0; @@ -1402,7 +1402,7 @@ u8 AtkCanceller_UnableToUseMove(void) gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattlescriptCurrInstr = BattleScript_MoveUsedLoafingAround; - gBattleMoveFlags |= MOVESTATUS_MISSED; + gMoveResultFlags |= MOVE_RESULT_MISSED; effect = 1; } gBattleStruct->atkCancellerTracker++; @@ -1479,7 +1479,7 @@ u8 AtkCanceller_UnableToUseMove(void) else // confusion dmg { gBattleCommunication[MULTISTRING_CHOOSER] = 1; - gBankTarget = gBankAttacker; + gBankDefender = gBankAttacker; gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankAttacker], MOVE_POUND, 0, 40, 0, gBankAttacker, gBankAttacker); gProtectStructs[gBankAttacker].confusionSelfDmg = 1; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; @@ -1496,7 +1496,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 10: // paralysis - if ((gBattleMons[gBankAttacker].status1 & STATUS_PARALYSIS) && (Random() % 4) == 0) + if ((gBattleMons[gBankAttacker].status1 & STATUS1_PARALYSIS) && (Random() % 4) == 0) { gProtectStructs[gBankAttacker].prlzImmobility = 1; // This is removed in Emerald for some reason @@ -1539,9 +1539,9 @@ u8 AtkCanceller_UnableToUseMove(void) { gCurrentMove = MOVE_BIDE; *bideDmg = gTakenDmg[gBankAttacker] * 2; - gBankTarget = gTakenDmgBanks[gBankAttacker]; - if (gAbsentBankFlags & gBitTable[gBankTarget]) - gBankTarget = GetMoveTarget(MOVE_BIDE, 1); + gBankDefender = gTakenDmgBanks[gBankAttacker]; + if (gAbsentBankFlags & gBitTable[gBankDefender]) + gBankDefender = GetMoveTarget(MOVE_BIDE, 1); gBattlescriptCurrInstr = BattleScript_BideAttack; } else @@ -1552,11 +1552,11 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 13: // move thawing - if (gBattleMons[gBankAttacker].status1 & STATUS_FREEZE) + if (gBattleMons[gBankAttacker].status1 & STATUS1_FREEZE) { if (gBattleMoves[gCurrentMove].effect == EFFECT_THAW_HIT) { - gBattleMons[gBankAttacker].status1 &= ~(STATUS_FREEZE); + gBattleMons[gBankAttacker].status1 &= ~(STATUS1_FREEZE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -1667,14 +1667,14 @@ bool8 sub_80423F4(u8 bank, u8 r1, u8 r2) { if (GetBankSide(bank) == SIDE_OPPONENT) { - r7 = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); - r6 = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + r7 = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + r6 = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); party = gEnemyParty; } else { - r7 = GetBankByIdentity(B_POSITION_PLAYER_LEFT); - r6 = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + r7 = GetBankByPosition(B_POSITION_PLAYER_LEFT); + r6 = GetBankByPosition(B_POSITION_PLAYER_RIGHT); party = gPlayerParty; } if (r1 == 6) @@ -1754,19 +1754,19 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) u32 pidAtk; u32 pidDef; - if (gBankAttacker >= gNoOfAllBanks) + if (gBankAttacker >= gBattleBanksCount) gBankAttacker = bank; if (GetBankSide(gBankAttacker) == SIDE_PLAYER) pokeAtk = &gPlayerParty[gBattlePartyID[gBankAttacker]]; else pokeAtk = &gEnemyParty[gBattlePartyID[gBankAttacker]]; - if (gBankTarget >= gNoOfAllBanks) - gBankTarget = bank; - if (GetBankSide(gBankTarget) == SIDE_PLAYER) - pokeDef = &gPlayerParty[gBattlePartyID[gBankTarget]]; + if (gBankDefender >= gBattleBanksCount) + gBankDefender = bank; + if (GetBankSide(gBankDefender) == SIDE_PLAYER) + pokeDef = &gPlayerParty[gBattlePartyID[gBankDefender]]; else - pokeDef = &gEnemyParty[gBattlePartyID[gBankTarget]]; + pokeDef = &gEnemyParty[gBattlePartyID[gBankDefender]]; speciesAtk = GetMonData(pokeAtk, MON_DATA_SPECIES); pidAtk = GetMonData(pokeAtk, MON_DATA_PERSONALITY); @@ -1797,7 +1797,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) switch (caseID) { case ABILITYEFFECT_ON_SWITCHIN: // 0 - if (gBankAttacker >= gNoOfAllBanks) + if (gBankAttacker >= gBattleBanksCount) gBankAttacker = bank; switch (gLastUsedAbility) { @@ -1897,7 +1897,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) case ABILITY_AIR_LOCK: { // that's a weird choice for a variable, why not use i or bank? - for (target1 = 0; target1 < gNoOfAllBanks; target1++) + for (target1 = 0; target1 < gBattleBanksCount; target1++) { effect = CastformDataTypeChange(target1); if (effect != 0) @@ -1932,17 +1932,17 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_SHED_SKIN: - if ((gBattleMons[bank].status1 & STATUS_ANY) && (Random() % 3) == 0) + if ((gBattleMons[bank].status1 & STATUS1_ANY) && (Random() % 3) == 0) { - if (gBattleMons[bank].status1 & (STATUS_POISON | STATUS_TOXIC_POISON)) + if (gBattleMons[bank].status1 & (STATUS1_POISON | STATUS1_TOXIC_POISON)) StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); - if (gBattleMons[bank].status1 & STATUS_SLEEP) + if (gBattleMons[bank].status1 & STATUS1_SLEEP) StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn); - if (gBattleMons[bank].status1 & STATUS_PARALYSIS) + if (gBattleMons[bank].status1 & STATUS1_PARALYSIS) StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn); - if (gBattleMons[bank].status1 & STATUS_BURN) + if (gBattleMons[bank].status1 & STATUS1_BURN) StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn); - if (gBattleMons[bank].status1 & STATUS_FREEZE) + if (gBattleMons[bank].status1 & STATUS1_FREEZE) StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn); gBattleMons[bank].status1 = 0; gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); // fix nightmare glitch @@ -2015,7 +2015,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_FLASH_FIRE: - if (moveType == TYPE_FIRE && !(gBattleMons[bank].status1 & STATUS_FREEZE)) + if (moveType == TYPE_FIRE && !(gBattleMons[bank].status1 & STATUS1_FREEZE)) { if (!(gBattleResources->flags->flags[bank] & UNKNOWN_FLAG_FLASH_FIRE)) { @@ -2064,10 +2064,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) switch (gLastUsedAbility) { case ABILITY_COLOR_CHANGE: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && move != MOVE_STRUGGLE && gBattleMoves[move].power != 0 - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) && gBattleMons[bank].type1 != moveType && gBattleMons[bank].type2 != moveType && gBattleMons[bank].hp != 0) @@ -2081,10 +2081,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_ROUGH_SKIN: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBankAttacker].hp != 0 && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT)) { gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 16; @@ -2096,10 +2096,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_EFFECT_SPORE: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBankAttacker].hp != 0 && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (Random() % 10) == 0) { @@ -2119,10 +2119,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_POISON_POINT: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBankAttacker].hp != 0 && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (Random() % 3) == 0) { @@ -2134,10 +2134,10 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_STATIC: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBankAttacker].hp != 0 && !gProtectStructs[gBankAttacker].confusionSelfDmg - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) && (Random() % 3) == 0) { @@ -2149,11 +2149,11 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_FLAME_BODY: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBankAttacker].hp != 0 && !gProtectStructs[gBankAttacker].confusionSelfDmg && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) && (Random() % 3) == 0) { gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_AFFECTS_USER | MOVE_EFFECT_BURN; @@ -2164,12 +2164,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_CUTE_CHARM: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) && gBattleMons[gBankAttacker].hp != 0 && !gProtectStructs[gBankAttacker].confusionSelfDmg && (gBattleMoves[move].flags & FLAG_MAKES_CONTACT) - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) - && gBattleMons[gBankTarget].hp != 0 + && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) + && gBattleMons[gBankDefender].hp != 0 && (Random() % 3) == 0 && gBattleMons[gBankAttacker].ability != ABILITY_OBLIVIOUS && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) @@ -2177,7 +2177,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) && GetGenderFromSpeciesAndPersonality(speciesAtk, pidAtk) != MON_GENDERLESS && GetGenderFromSpeciesAndPersonality(speciesDef, pidDef) != MON_GENDERLESS) { - gBattleMons[gBankAttacker].status2 |= STATUS2_INFATUATED_WITH(gBankTarget); + gBattleMons[gBankAttacker].status2 |= STATUS2_INFATUATED_WITH(gBankDefender); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_CuteCharmActivates; effect++; @@ -2186,12 +2186,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_IMMUNITY: // 5 - for (bank = 0; bank < gNoOfAllBanks; bank++) + for (bank = 0; bank < gBattleBanksCount; bank++) { switch (gBattleMons[bank].ability) { case ABILITY_IMMUNITY: - if (gBattleMons[bank].status1 & (STATUS_POISON | STATUS_TOXIC_POISON | STATUS_TOXIC_COUNTER)) + if (gBattleMons[bank].status1 & (STATUS1_POISON | STATUS1_TOXIC_POISON | STATUS1_TOXIC_COUNTER)) { StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); effect = 1; @@ -2205,7 +2205,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_LIMBER: - if (gBattleMons[bank].status1 & STATUS_PARALYSIS) + if (gBattleMons[bank].status1 & STATUS1_PARALYSIS) { StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn); effect = 1; @@ -2213,7 +2213,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITY_INSOMNIA: case ABILITY_VITAL_SPIRIT: - if (gBattleMons[bank].status1 & STATUS_SLEEP) + if (gBattleMons[bank].status1 & STATUS1_SLEEP) { gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn); @@ -2221,14 +2221,14 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITY_WATER_VEIL: - if (gBattleMons[bank].status1 & STATUS_BURN) + if (gBattleMons[bank].status1 & STATUS1_BURN) { StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn); effect = 1; } break; case ABILITY_MAGMA_ARMOR: - if (gBattleMons[bank].status1 & STATUS_FREEZE) + if (gBattleMons[bank].status1 & STATUS1_FREEZE) { StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn); effect = 1; @@ -2268,7 +2268,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_FORECAST: // 6 - for (bank = 0; bank < gNoOfAllBanks; bank++) + for (bank = 0; bank < gBattleBanksCount; bank++) { if (gBattleMons[bank].ability == ABILITY_FORECAST) { @@ -2292,7 +2292,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) gBattleStruct->synchronizeMoveEffect = MOVE_EFFECT_POISON; gBattleCommunication[MOVE_EFFECT_BYTE] = gBattleStruct->synchronizeMoveEffect + MOVE_EFFECT_AFFECTS_USER; - gBattleScripting.bank = gBankTarget; + gBattleScripting.bank = gBankDefender; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_SynchronizeActivates; gHitMarker |= HITMARKER_IGNORE_SAFEGUARD; @@ -2316,7 +2316,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_INTIMIDATE1: // 9 - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBattleMons[i].ability == ABILITY_INTIMIDATE && gStatuses3[i] & STATUS3_INTIMIDATE_POKES) { @@ -2330,20 +2330,20 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_TRACE: // 11 - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBattleMons[i].ability == ABILITY_TRACE && (gStatuses3[i] & STATUS3_TRACE)) { u8 target2; side = (GetBankPosition(i) ^ BIT_SIDE) & BIT_SIDE; // side of the opposing pokemon - target1 = GetBankByIdentity(side); - target2 = GetBankByIdentity(side + BIT_MON); + target1 = GetBankByPosition(side); + target2 = GetBankByPosition(side + BIT_MON); if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) { if (gBattleMons[target1].ability != 0 && gBattleMons[target1].hp != 0 && gBattleMons[target2].ability != 0 && gBattleMons[target2].hp != 0) { - gActiveBank = GetBankByIdentity(((Random() & 1) * 2) | side); + gActiveBank = GetBankByPosition(((Random() & 1) * 2) | side); gBattleMons[i].ability = gBattleMons[gActiveBank].ability; gLastUsedAbility = gBattleMons[gActiveBank].ability; effect++; @@ -2387,7 +2387,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_INTIMIDATE2: // 10 - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBattleMons[i].ability == ABILITY_INTIMIDATE && (gStatuses3[i] & STATUS3_INTIMIDATE_POKES)) { @@ -2403,7 +2403,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITYEFFECT_CHECK_OTHER_SIDE: // 12 side = GetBankSide(bank); - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (GetBankSide(i) != side && gBattleMons[i].ability == ability) { @@ -2414,7 +2414,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITYEFFECT_CHECK_BANK_SIDE: // 13 side = GetBankSide(bank); - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (GetBankSide(i) == side && gBattleMons[i].ability == ability) { @@ -2427,21 +2427,21 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) switch (gLastUsedAbility) { case 0xFD: - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gStatuses3[i] & STATUS3_MUDSPORT) effect = i + 1; } break; case 0xFE: - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gStatuses3[i] & STATUS3_WATERSPORT) effect = i + 1; } break; default: - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBattleMons[i].ability == ability) { @@ -2453,7 +2453,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_CHECK_ON_FIELD: // 19 - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBattleMons[i].ability == ability && gBattleMons[i].hp != 0) { @@ -2463,7 +2463,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK: // 15 - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBattleMons[i].ability == ability && i != bank) { @@ -2474,7 +2474,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITYEFFECT_COUNT_OTHER_SIDE: // 16 side = GetBankSide(bank); - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (GetBankSide(i) != side && gBattleMons[i].ability == ability) { @@ -2485,7 +2485,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) break; case ABILITYEFFECT_COUNT_BANK_SIDE: // 17 side = GetBankSide(bank); - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (GetBankSide(i) == side && gBattleMons[i].ability == ability) { @@ -2495,7 +2495,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } break; case ABILITYEFFECT_COUNT_ON_FIELD: // 18 - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBattleMons[i].ability == ability && i != bank) { @@ -2573,11 +2573,11 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } // def variables are unused - defItem = gBattleMons[gBankTarget].item; + defItem = gBattleMons[gBankDefender].item; if (defItem == ITEM_ENIGMA_BERRY) { - defHoldEffect = gEnigmaBerries[gBankTarget].holdEffect; - defQuality = gEnigmaBerries[gBankTarget].holdEffectParam; + defHoldEffect = gEnigmaBerries[gBankDefender].holdEffect; + defQuality = gEnigmaBerries[gBankDefender].holdEffectParam; } else { @@ -2898,41 +2898,41 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } break; case HOLD_EFFECT_CURE_PAR: - if (gBattleMons[bank].status1 & STATUS_PARALYSIS) + if (gBattleMons[bank].status1 & STATUS1_PARALYSIS) { - gBattleMons[bank].status1 &= ~(STATUS_PARALYSIS); + gBattleMons[bank].status1 &= ~(STATUS1_PARALYSIS); BattleScriptExecute(BattleScript_BerryCurePrlzEnd2); effect = ITEM_STATUS_CHANGE; } break; case HOLD_EFFECT_CURE_PSN: - if (gBattleMons[bank].status1 & STATUS_PSN_ANY) + if (gBattleMons[bank].status1 & STATUS1_PSN_ANY) { - gBattleMons[bank].status1 &= ~(STATUS_PSN_ANY | STATUS_TOXIC_COUNTER); + gBattleMons[bank].status1 &= ~(STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER); BattleScriptExecute(BattleScript_BerryCurePsnEnd2); effect = ITEM_STATUS_CHANGE; } break; case HOLD_EFFECT_CURE_BRN: - if (gBattleMons[bank].status1 & STATUS_BURN) + if (gBattleMons[bank].status1 & STATUS1_BURN) { - gBattleMons[bank].status1 &= ~(STATUS_BURN); + gBattleMons[bank].status1 &= ~(STATUS1_BURN); BattleScriptExecute(BattleScript_BerryCureBrnEnd2); effect = ITEM_STATUS_CHANGE; } break; case HOLD_EFFECT_CURE_FRZ: - if (gBattleMons[bank].status1 & STATUS_FREEZE) + if (gBattleMons[bank].status1 & STATUS1_FREEZE) { - gBattleMons[bank].status1 &= ~(STATUS_FREEZE); + gBattleMons[bank].status1 &= ~(STATUS1_FREEZE); BattleScriptExecute(BattleScript_BerryCureFrzEnd2); effect = ITEM_STATUS_CHANGE; } break; case HOLD_EFFECT_CURE_SLP: - if (gBattleMons[bank].status1 & STATUS_SLEEP) + if (gBattleMons[bank].status1 & STATUS1_SLEEP) { - gBattleMons[bank].status1 &= ~(STATUS_SLEEP); + gBattleMons[bank].status1 &= ~(STATUS1_SLEEP); gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); BattleScriptExecute(BattleScript_BerryCureSlpEnd2); effect = ITEM_STATUS_CHANGE; @@ -2947,31 +2947,31 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } break; case HOLD_EFFECT_CURE_STATUS: - if (gBattleMons[bank].status1 & STATUS_ANY || gBattleMons[bank].status2 & STATUS2_CONFUSION) + if (gBattleMons[bank].status1 & STATUS1_ANY || gBattleMons[bank].status2 & STATUS2_CONFUSION) { i = 0; - if (gBattleMons[bank].status1 & STATUS_PSN_ANY) + if (gBattleMons[bank].status1 & STATUS1_PSN_ANY) { StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); i++; } - if (gBattleMons[bank].status1 & STATUS_SLEEP) + if (gBattleMons[bank].status1 & STATUS1_SLEEP) { gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn); i++; } - if (gBattleMons[bank].status1 & STATUS_PARALYSIS) + if (gBattleMons[bank].status1 & STATUS1_PARALYSIS) { StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn); i++; } - if (gBattleMons[bank].status1 & STATUS_BURN) + if (gBattleMons[bank].status1 & STATUS1_BURN) { StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn); i++; } - if (gBattleMons[bank].status1 & STATUS_FREEZE) + if (gBattleMons[bank].status1 & STATUS1_FREEZE) { StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn); i++; @@ -3024,7 +3024,7 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) case 2: break; case 3: - for (bank = 0; bank < gNoOfAllBanks; bank++) + for (bank = 0; bank < gBattleBanksCount; bank++) { gLastUsedItem = gBattleMons[bank].item; if (gBattleMons[bank].item == ITEM_ENIGMA_BERRY) @@ -3040,45 +3040,45 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) switch (bankHoldEffect) { case HOLD_EFFECT_CURE_PAR: - if (gBattleMons[bank].status1 & STATUS_PARALYSIS) + if (gBattleMons[bank].status1 & STATUS1_PARALYSIS) { - gBattleMons[bank].status1 &= ~(STATUS_PARALYSIS); + gBattleMons[bank].status1 &= ~(STATUS1_PARALYSIS); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_BerryCureParRet; effect = ITEM_STATUS_CHANGE; } break; case HOLD_EFFECT_CURE_PSN: - if (gBattleMons[bank].status1 & STATUS_PSN_ANY) + if (gBattleMons[bank].status1 & STATUS1_PSN_ANY) { - gBattleMons[bank].status1 &= ~(STATUS_PSN_ANY | STATUS_TOXIC_COUNTER); + gBattleMons[bank].status1 &= ~(STATUS1_PSN_ANY | STATUS1_TOXIC_COUNTER); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_BerryCurePsnRet; effect = ITEM_STATUS_CHANGE; } break; case HOLD_EFFECT_CURE_BRN: - if (gBattleMons[bank].status1 & STATUS_BURN) + if (gBattleMons[bank].status1 & STATUS1_BURN) { - gBattleMons[bank].status1 &= ~(STATUS_BURN); + gBattleMons[bank].status1 &= ~(STATUS1_BURN); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_BerryCureBrnRet; effect = ITEM_STATUS_CHANGE; } break; case HOLD_EFFECT_CURE_FRZ: - if (gBattleMons[bank].status1 & STATUS_FREEZE) + if (gBattleMons[bank].status1 & STATUS1_FREEZE) { - gBattleMons[bank].status1 &= ~(STATUS_FREEZE); + gBattleMons[bank].status1 &= ~(STATUS1_FREEZE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_BerryCureFrzRet; effect = ITEM_STATUS_CHANGE; } break; case HOLD_EFFECT_CURE_SLP: - if (gBattleMons[bank].status1 & STATUS_SLEEP) + if (gBattleMons[bank].status1 & STATUS1_SLEEP) { - gBattleMons[bank].status1 &= ~(STATUS_SLEEP); + gBattleMons[bank].status1 &= ~(STATUS1_SLEEP); gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_BerryCureSlpRet; @@ -3106,26 +3106,26 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } break; case HOLD_EFFECT_CURE_STATUS: - if (gBattleMons[bank].status1 & STATUS_ANY || gBattleMons[bank].status2 & STATUS2_CONFUSION) + if (gBattleMons[bank].status1 & STATUS1_ANY || gBattleMons[bank].status2 & STATUS2_CONFUSION) { - if (gBattleMons[bank].status1 & STATUS_PSN_ANY) + if (gBattleMons[bank].status1 & STATUS1_PSN_ANY) { StringCopy(gBattleTextBuff1, gStatusConditionString_PoisonJpn); } - if (gBattleMons[bank].status1 & STATUS_SLEEP) + if (gBattleMons[bank].status1 & STATUS1_SLEEP) { gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); StringCopy(gBattleTextBuff1, gStatusConditionString_SleepJpn); } - if (gBattleMons[bank].status1 & STATUS_PARALYSIS) + if (gBattleMons[bank].status1 & STATUS1_PARALYSIS) { StringCopy(gBattleTextBuff1, gStatusConditionString_ParalysisJpn); } - if (gBattleMons[bank].status1 & STATUS_BURN) + if (gBattleMons[bank].status1 & STATUS1_BURN) { StringCopy(gBattleTextBuff1, gStatusConditionString_BurnJpn); } - if (gBattleMons[bank].status1 & STATUS_FREEZE) + if (gBattleMons[bank].status1 & STATUS1_FREEZE) { StringCopy(gBattleTextBuff1, gStatusConditionString_IceJpn); } @@ -3177,11 +3177,11 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) switch (atkHoldEffect) { case HOLD_EFFECT_FLINCH: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) - && (gSpecialStatuses[gBankTarget].moveturnLostHP_physical || gSpecialStatuses[gBankTarget].moveturnLostHP_special) + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && (gSpecialStatuses[gBankDefender].moveturnLostHP_physical || gSpecialStatuses[gBankDefender].moveturnLostHP_special) && (Random() % 100) < atkQuality && gBattleMoves[gCurrentMove].flags & FLAG_KINGSROCK_AFFECTED - && gBattleMons[gBankTarget].hp) + && gBattleMons[gBankDefender].hp) { gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_FLINCH; BattleScriptPushCursor(); @@ -3190,20 +3190,20 @@ u8 ItemBattleEffects(u8 caseID, u8 bank, bool8 moveTurn) } break; case HOLD_EFFECT_SHELL_BELL: - if (!(gBattleMoveFlags & MOVESTATUS_NOEFFECT) - && gSpecialStatuses[gBankTarget].moveturnLostHP != 0 - && gSpecialStatuses[gBankTarget].moveturnLostHP != 0xFFFF - && gBankAttacker != gBankTarget + if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) + && gSpecialStatuses[gBankDefender].moveturnLostHP != 0 + && gSpecialStatuses[gBankDefender].moveturnLostHP != 0xFFFF + && gBankAttacker != gBankDefender && gBattleMons[gBankAttacker].hp != gBattleMons[gBankAttacker].maxHP && gBattleMons[gBankAttacker].hp != 0) { gLastUsedItem = atkItem; gStringBank = gBankAttacker; gBattleScripting.bank = gBankAttacker; - gBattleMoveDamage = (gSpecialStatuses[gBankTarget].moveturnLostHP / atkQuality) * -1; + gBattleMoveDamage = (gSpecialStatuses[gBankDefender].moveturnLostHP / atkQuality) * -1; if (gBattleMoveDamage == 0) gBattleMoveDamage = -1; - gSpecialStatuses[gBankTarget].moveturnLostHP = 0; + gSpecialStatuses[gBankDefender].moveturnLostHP = 0; BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_ItemHealHP_Ret; effect++; @@ -3252,7 +3252,7 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) side = GetBankSide(gBankAttacker); do { - targetBank = Random() % gNoOfAllBanks; + targetBank = Random() % gBattleBanksCount; } while (targetBank == gBankAttacker || side == GetBankSide(targetBank) || gAbsentBankFlags & gBitTable[targetBank]); if (gBattleMoves[move].type == TYPE_ELECTRIC && AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBankAttacker, ABILITY_LIGHTNING_ROD, 0, 0) @@ -3268,7 +3268,7 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) case MOVE_TARGET_BOTH: case MOVE_TARGET_FOES_AND_ALLY: case MOVE_TARGET_OPPONENTS_FIELD: - targetBank = GetBankByIdentity((GetBankPosition(gBankAttacker) & BIT_SIDE) ^ BIT_SIDE); + targetBank = GetBankByPosition((GetBankPosition(gBankAttacker) & BIT_SIDE) ^ BIT_SIDE); if (gAbsentBankFlags & gBitTable[targetBank]) targetBank ^= BIT_MON; break; @@ -3281,22 +3281,22 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) if (GetBankSide(gBankAttacker) == SIDE_PLAYER) { if (Random() & 1) - targetBank = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + targetBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); else - targetBank = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + targetBank = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); } else { if (Random() & 1) - targetBank = GetBankByIdentity(B_POSITION_PLAYER_LEFT); + targetBank = GetBankByPosition(B_POSITION_PLAYER_LEFT); else - targetBank = GetBankByIdentity(B_POSITION_PLAYER_RIGHT); + targetBank = GetBankByPosition(B_POSITION_PLAYER_RIGHT); } if (gAbsentBankFlags & gBitTable[targetBank]) targetBank ^= BIT_MON; } else - targetBank = GetBankByIdentity((GetBankPosition(gBankAttacker) & BIT_SIDE) ^ BIT_SIDE); + targetBank = GetBankByPosition((GetBankPosition(gBankAttacker) & BIT_SIDE) ^ BIT_SIDE); break; case MOVE_TARGET_USER: case MOVE_TARGET_x10: @@ -3363,7 +3363,7 @@ u8 IsMonDisobedient(void) // is not obedient if (gCurrentMove == MOVE_RAGE) gBattleMons[gBankAttacker].status2 &= ~(STATUS2_RAGE); - if (gBattleMons[gBankAttacker].status1 & STATUS_SLEEP && (gCurrentMove == MOVE_SNORE || gCurrentMove == MOVE_SLEEP_TALK)) + if (gBattleMons[gBankAttacker].status1 & STATUS1_SLEEP && (gCurrentMove == MOVE_SNORE || gCurrentMove == MOVE_SLEEP_TALK)) { gBattlescriptCurrInstr = BattleScript_82DB695; return 1; @@ -3389,7 +3389,7 @@ u8 IsMonDisobedient(void) gRandomMove = gBattleMons[gBankAttacker].moves[gCurrMovePos]; gBattlescriptCurrInstr = BattleScript_IgnoresAndUsesRandomMove; - gBankTarget = GetMoveTarget(gRandomMove, 0); + gBankDefender = GetMoveTarget(gRandomMove, 0); gHitMarker |= HITMARKER_x200000; return 2; } @@ -3399,16 +3399,16 @@ u8 IsMonDisobedient(void) obedienceLevel = gBattleMons[gBankAttacker].level - obedienceLevel; calc = (Random() & 255); - if (calc < obedienceLevel && !(gBattleMons[gBankAttacker].status1 & STATUS_ANY) && gBattleMons[gBankAttacker].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gBankAttacker].ability != ABILITY_INSOMNIA) + if (calc < obedienceLevel && !(gBattleMons[gBankAttacker].status1 & STATUS1_ANY) && gBattleMons[gBankAttacker].ability != ABILITY_VITAL_SPIRIT && gBattleMons[gBankAttacker].ability != ABILITY_INSOMNIA) { // try putting asleep int i; - for (i = 0; i < gNoOfAllBanks; i++) + for (i = 0; i < gBattleBanksCount; i++) { if (gBattleMons[i].status2 & STATUS2_UPROAR) break; } - if (i == gNoOfAllBanks) + if (i == gBattleBanksCount) { gBattlescriptCurrInstr = BattleScript_IgnoresAndFallsAsleep; return 1; @@ -3418,7 +3418,7 @@ u8 IsMonDisobedient(void) if (calc < obedienceLevel) { gBattleMoveDamage = CalculateBaseDamage(&gBattleMons[gBankAttacker], &gBattleMons[gBankAttacker], MOVE_POUND, 0, 40, 0, gBankAttacker, gBankAttacker); - gBankTarget = gBankAttacker; + gBankDefender = gBankAttacker; gBattlescriptCurrInstr = BattleScript_82DB6F0; gHitMarker |= HITMARKER_UNABLE_TO_USE_MOVE; return 2; diff --git a/src/battle_util2.c b/src/battle_util2.c index d242ab6c9..fb01865a4 100644 --- a/src/battle_util2.c +++ b/src/battle_util2.c @@ -87,15 +87,15 @@ void AdjustFriendshipOnBattleFaint(u8 bank) { u8 opposingBank2; - opposingBank = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); - opposingBank2 = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + opposingBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); + opposingBank2 = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); if (gBattleMons[opposingBank2].level > gBattleMons[opposingBank].level) opposingBank = opposingBank2; } else { - opposingBank = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + opposingBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); } if (gBattleMons[opposingBank].level > gBattleMons[bank].level) @@ -138,11 +138,11 @@ u32 sub_805725C(u8 bank) switch (gBattleCommunication[MULTIUSE_STATE]) { case 0: - if (gBattleMons[bank].status1 & STATUS_SLEEP) + if (gBattleMons[bank].status1 & STATUS1_SLEEP) { if (UproarWakeUpCheck(bank)) { - gBattleMons[bank].status1 &= ~(STATUS_SLEEP); + gBattleMons[bank].status1 &= ~(STATUS1_SLEEP); gBattleMons[bank].status2 &= ~(STATUS2_NIGHTMARE); BattleScriptPushCursor(); gBattleCommunication[MULTISTRING_CHOOSER] = 1; @@ -158,12 +158,12 @@ u32 sub_805725C(u8 bank) else toSub = 1; - if ((gBattleMons[bank].status1 & STATUS_SLEEP) < toSub) - gBattleMons[bank].status1 &= ~(STATUS_SLEEP); + if ((gBattleMons[bank].status1 & STATUS1_SLEEP) < toSub) + gBattleMons[bank].status1 &= ~(STATUS1_SLEEP); else gBattleMons[bank].status1 -= toSub; - if (gBattleMons[bank].status1 & STATUS_SLEEP) + if (gBattleMons[bank].status1 & STATUS1_SLEEP) { gBattlescriptCurrInstr = BattleScript_MoveUsedIsAsleep; effect = 2; @@ -181,7 +181,7 @@ u32 sub_805725C(u8 bank) gBattleCommunication[MULTIUSE_STATE]++; break; case 1: - if (gBattleMons[bank].status1 & STATUS_FREEZE) + if (gBattleMons[bank].status1 & STATUS1_FREEZE) { if (Random() % 5 != 0) { @@ -189,7 +189,7 @@ u32 sub_805725C(u8 bank) } else { - gBattleMons[bank].status1 &= ~(STATUS_FREEZE); + gBattleMons[bank].status1 &= ~(STATUS1_FREEZE); BattleScriptPushCursor(); gBattlescriptCurrInstr = BattleScript_MoveUsedUnfroze; gBattleCommunication[MULTISTRING_CHOOSER] = 0; diff --git a/src/calculate_base_damage.c b/src/calculate_base_damage.c index d30599607..b6b83086b 100644 --- a/src/calculate_base_damage.c +++ b/src/calculate_base_damage.c @@ -177,7 +177,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de damage = damage / damageHelper; damage /= 50; - if ((attacker->status1 & STATUS_BURN) && attacker->ability != ABILITY_GUTS) + if ((attacker->status1 & STATUS1_BURN) && attacker->ability != ABILITY_GUTS) damage /= 2; if ((sideStatus & SIDE_STATUS_REFLECT) && gCritMultiplier == 1) diff --git a/src/field_poison.c b/src/field_poison.c index b83788210..98819c450 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -42,7 +42,7 @@ static bool32 sub_80F958C(void) static void sub_80F95C0(u8 partyIdx) { struct Pokemon *pokemon = gPlayerParty + partyIdx; - unsigned int status = STATUS_NONE; + unsigned int status = STATUS1_NONE; AdjustFriendship(pokemon, 0x07); SetMonData(pokemon, MON_DATA_STATUS, &status); GetMonData(pokemon, MON_DATA_NICKNAME, gStringVar1); diff --git a/src/pokeball.c b/src/pokeball.c index 86ab85b6a..f16096429 100644 --- a/src/pokeball.c +++ b/src/pokeball.c @@ -17,7 +17,7 @@ extern bool8 gDoingBattleAnim; extern u8 gActiveBank; -extern u8 gBankTarget; +extern u8 gBankDefender; extern u16 gBattlePartyID[]; extern u8 gBankSpriteIds[]; extern u8 gHealthBoxesIds[]; @@ -378,7 +378,7 @@ static void Task_DoPokeballSendOutAnim(u8 taskId) switch (throwCaseId) { case POKEBALL_PLAYER_SENDOUT: - gBankTarget = bank; + gBankDefender = bank; gSprites[ballSpriteId].pos1.x = 24; gSprites[ballSpriteId].pos1.y = 68; gSprites[ballSpriteId].callback = SpriteCB_PlayerMonSendOut_1; @@ -386,17 +386,17 @@ static void Task_DoPokeballSendOutAnim(u8 taskId) case POKEBALL_OPPONENT_SENDOUT: gSprites[ballSpriteId].pos1.x = GetBankCoord(bank, BANK_X_POS); gSprites[ballSpriteId].pos1.y = GetBankCoord(bank, BANK_Y_POS) + 24; - gBankTarget = bank; + gBankDefender = bank; gSprites[ballSpriteId].data[0] = 0; gSprites[ballSpriteId].callback = SpriteCB_OpponentMonSendOut; break; default: - gBankTarget = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + gBankDefender = GetBankByPosition(B_POSITION_OPPONENT_LEFT); notSendOut = TRUE; break; } - gSprites[ballSpriteId].sBank = gBankTarget; + gSprites[ballSpriteId].sBank = gBankDefender; if (!notSendOut) { DestroyTask(taskId); @@ -405,12 +405,12 @@ static void Task_DoPokeballSendOutAnim(u8 taskId) // this will perform an unused ball throw animation gSprites[ballSpriteId].data[0] = 0x22; - gSprites[ballSpriteId].data[2] = GetBankCoord(gBankTarget, BANK_X_POS); - gSprites[ballSpriteId].data[4] = GetBankCoord(gBankTarget, BANK_Y_POS) - 16; + gSprites[ballSpriteId].data[2] = GetBankCoord(gBankDefender, BANK_X_POS); + gSprites[ballSpriteId].data[4] = GetBankCoord(gBankDefender, BANK_Y_POS) - 16; gSprites[ballSpriteId].data[5] = -40; sub_80A68D4(&gSprites[ballSpriteId]); gSprites[ballSpriteId].oam.affineParam = taskId; - gTasks[taskId].tOpponentBank = gBankTarget; + gTasks[taskId].tOpponentBank = gBankDefender; gTasks[taskId].func = TaskDummy; PlaySE(SE_NAGERU); } @@ -767,7 +767,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite) } species = GetMonData(mon, MON_DATA_SPECIES); - if ((bank == GetBankByIdentity(B_POSITION_PLAYER_LEFT) || bank == GetBankByIdentity(B_POSITION_OPPONENT_LEFT)) + if ((bank == GetBankByPosition(B_POSITION_PLAYER_LEFT) || bank == GetBankByPosition(B_POSITION_OPPONENT_LEFT)) && IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1) { if (gBattleTypeFlags & BATTLE_TYPE_MULTI && gBattleTypeFlags & BATTLE_TYPE_LINK) @@ -783,7 +783,7 @@ static void SpriteCB_ReleaseMonFromBall(struct Sprite *sprite) if (!IsDoubleBattle() || !gBattleSpritesDataPtr->animationData->field_9_x1) wantedCryCase = 0; - else if (bank == GetBankByIdentity(B_POSITION_PLAYER_LEFT) || bank == GetBankByIdentity(B_POSITION_OPPONENT_LEFT)) + else if (bank == GetBankByPosition(B_POSITION_PLAYER_LEFT) || bank == GetBankByPosition(B_POSITION_OPPONENT_LEFT)) wantedCryCase = 1; else wantedCryCase = 2; @@ -956,7 +956,7 @@ static void SpriteCB_PlayerMonSendOut_2(struct Sprite *sprite) sprite->data[0] = 0; if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1 - && sprite->sBank == GetBankByIdentity(B_POSITION_PLAYER_RIGHT)) + && sprite->sBank == GetBankByPosition(B_POSITION_PLAYER_RIGHT)) sprite->callback = SpriteCB_ReleaseMon2FromBall; else sprite->callback = SpriteCB_ReleaseMonFromBall; @@ -982,7 +982,7 @@ static void SpriteCB_OpponentMonSendOut(struct Sprite *sprite) { sprite->data[0] = 0; if (IsDoubleBattle() && gBattleSpritesDataPtr->animationData->field_9_x1 - && sprite->sBank == GetBankByIdentity(B_POSITION_OPPONENT_RIGHT)) + && sprite->sBank == GetBankByPosition(B_POSITION_OPPONENT_RIGHT)) sprite->callback = SpriteCB_ReleaseMon2FromBall; else sprite->callback = SpriteCB_ReleaseMonFromBall; diff --git a/src/pokemon_2.c b/src/pokemon_2.c index 8640eacde..f05453c52 100644 --- a/src/pokemon_2.c +++ b/src/pokemon_2.c @@ -17,7 +17,7 @@ struct Unknown_020249B4 extern u8 gAbsentBankFlags; extern u8 gActiveBank; extern u8 gBankAttacker; -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gLastUsedAbility; extern u16 gTrainerBattleOpponent_A; extern u32 gBattleTypeFlags; @@ -35,7 +35,7 @@ extern const u8 gText_BadEgg[]; extern const u8 gText_EggNickname[]; extern u8 GetBankSide(u8 bank); -extern u8 GetBankByIdentity(u8 bank); +extern u8 GetBankByPosition(u8 bank); extern u8 GetBankPosition(u8 bank); u8 CountAliveMonsInBattle(u8 caseId) @@ -62,7 +62,7 @@ u8 CountAliveMonsInBattle(u8 caseId) case BATTLE_ALIVE_DEF_SIDE: for (i = 0; i < 4; i++) { - if (GetBankSide(i) == GetBankSide(gBankTarget) && !(gAbsentBankFlags & gBitTable[i])) + if (GetBankSide(i) == GetBankSide(gBankDefender) && !(gAbsentBankFlags & gBitTable[i])) retVal++; } break; @@ -90,7 +90,7 @@ u8 GetDefaultMoveTarget(u8 bank) status ^= 1; if (!(gBattleTypeFlags & BATTLE_TYPE_DOUBLE)) - return GetBankByIdentity(status); + return GetBankByPosition(status); if (CountAliveMonsInBattle(BATTLE_ALIVE_EXCEPT_ACTIVE) > 1) { u8 val; @@ -99,14 +99,14 @@ u8 GetDefaultMoveTarget(u8 bank) val = status ^ 2; else val = status; - return GetBankByIdentity(val); + return GetBankByPosition(val); } else { if ((gAbsentBankFlags & gBitTable[status])) - return GetBankByIdentity(status ^ 2); + return GetBankByPosition(status ^ 2); else - return GetBankByIdentity(status); + return GetBankByPosition(status); } } diff --git a/src/pokemon_3.c b/src/pokemon_3.c index 95ec4b6a2..a31920ca0 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -27,7 +27,7 @@ extern struct BattlePokemon gBattleMons[4]; extern struct BattleEnigmaBerry gEnigmaBerries[4]; extern u8 gActiveBank; extern u8 gBankInMenu; -extern u8 gBankTarget; +extern u8 gBankDefender; extern u8 gBankAttacker; extern u8 gStringBank; extern u16 gTrainerBattleOpponent_A; @@ -212,7 +212,7 @@ u8 GetItemEffectParamOffset(u16 itemId, u8 effectByte, u8 effectBit) void sub_806CF24(s32 stat) { - gBankTarget = gBankInMenu; + gBankDefender = gBankInMenu; StringCopy(gBattleTextBuff1, gStatNamesTable[gUnknown_08329EC8[stat]]); StringCopy(gBattleTextBuff2, gText_StatRose); BattleStringExpandPlaceholdersToDisplayedString(gText_PkmnsStatChanged2); diff --git a/src/recorded_battle.c b/src/recorded_battle.c index c88229c61..b785d1ea1 100644 --- a/src/recorded_battle.c +++ b/src/recorded_battle.c @@ -26,7 +26,7 @@ extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; extern u16 gPartnerTrainerId; extern u8 gActiveBank; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; extern struct BattlePokemon gBattleMons[BATTLE_BANKS_COUNT]; extern u16 gChosenMovesByBanks[BATTLE_BANKS_COUNT]; @@ -226,7 +226,7 @@ u8 RecordedBattle_ReadBankAction(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) { - gSpecialVar_Result = gBattleOutcome = BATTLE_PLAYER_TELEPORTED; // hah + gSpecialVar_Result = gBattleOutcome = B_OUTCOME_PLAYER_TELEPORTED; // hah ResetPaletteFadeControl(); BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); SetMainCallback2(CB2_QuitRecordedBattle); @@ -1523,7 +1523,7 @@ void sub_818603C(u8 arg0) if (gBattleTypeFlags & (BATTLE_TYPE_LINK | BATTLE_TYPE_x2000000)) return; - for (bank = 0; bank < gNoOfAllBanks; bank++) + for (bank = 0; bank < gBattleBanksCount; bank++) { if (GetBankSide(bank) != SIDE_OPPONENT) // player's side only { diff --git a/src/reshow_battle_screen.c b/src/reshow_battle_screen.c index 16d902aaa..edbd24530 100644 --- a/src/reshow_battle_screen.c +++ b/src/reshow_battle_screen.c @@ -25,7 +25,7 @@ extern u8 gReservedSpritePaletteCount; extern u8 gActionSelectionCursor[BATTLE_BANKS_COUNT]; extern u8 gBankInMenu; extern u16 gBattlePartyID[BATTLE_BANKS_COUNT]; -extern u8 gNoOfAllBanks; +extern u8 gBattleBanksCount; extern u32 gBattleTypeFlags; extern u8 gBankSpriteIds[BATTLE_BANKS_COUNT]; extern u8 gBattleMonForms[BATTLE_BANKS_COUNT]; @@ -164,13 +164,13 @@ static void CB2_ReshowBattleScreenAfterMenu(void) LoadAndCreateEnemyShadowSprites(); - opponentBank = GetBankByIdentity(B_POSITION_OPPONENT_LEFT); + opponentBank = GetBankByPosition(B_POSITION_OPPONENT_LEFT); species = GetMonData(&gEnemyParty[gBattlePartyID[opponentBank]], MON_DATA_SPECIES); SetBankEnemyShadowSpriteCallback(opponentBank, species); if (IsDoubleBattle()) { - opponentBank = GetBankByIdentity(B_POSITION_OPPONENT_RIGHT); + opponentBank = GetBankByPosition(B_POSITION_OPPONENT_RIGHT); species = GetMonData(&gEnemyParty[gBattlePartyID[opponentBank]], MON_DATA_SPECIES); SetBankEnemyShadowSpriteCallback(opponentBank, species); } @@ -210,7 +210,7 @@ static void sub_80A95F4(void) static bool8 LoadBankSpriteGfx(u8 bank) { - if (bank < gNoOfAllBanks) + if (bank < gBattleBanksCount) { if (GetBankSide(bank) != SIDE_PLAYER) { @@ -245,7 +245,7 @@ extern const struct MonCoords gTrainerBackPicCoords[]; static void CreateBankSprite(u8 bank) { - if (bank < gNoOfAllBanks) + if (bank < gBattleBanksCount) { u8 posY; @@ -313,7 +313,7 @@ static void CreateBankSprite(u8 bank) static void CreateHealthboxSprite(u8 bank) { - if (bank < gNoOfAllBanks) + if (bank < gBattleBanksCount) { u8 healthboxSpriteId; diff --git a/src/safari_zone.c b/src/safari_zone.c index ce1eb65bc..12da73090 100644 --- a/src/safari_zone.c +++ b/src/safari_zone.c @@ -108,20 +108,20 @@ void SafariZoneRetirePrompt(void) void CB2_EndSafariBattle(void) { sSafariZoneFleedMons += gBattleResults.field_1F; - if (gBattleOutcome == BATTLE_CAUGHT) + if (gBattleOutcome == B_OUTCOME_CAUGHT_POKE) sSafariZoneCaughtMons++; if (gNumSafariBalls != 0) { SetMainCallback2(c2_exit_to_overworld_2_switch); } - else if (gBattleOutcome == BATTLE_SAFARI_OUT_OF_BALLS) + else if (gBattleOutcome == B_OUTCOME_NO_SAFARI_BALLS) { ScriptContext2_RunNewScript(EventScript_2A4B4C); warp_in(); gFieldCallback = sub_80AF6F0; SetMainCallback2(c2_load_new_map); } - else if (gBattleOutcome == BATTLE_CAUGHT) + else if (gBattleOutcome == B_OUTCOME_CAUGHT_POKE) { ScriptContext1_SetupScript(EventScript_2A4B9B); ScriptContext1_Stop(); diff --git a/src/tv.c b/src/tv.c index af0c7069c..0fb2997ad 100644 --- a/src/tv.c +++ b/src/tv.c @@ -1208,7 +1208,7 @@ void PutPokemonTodayFailedOnTheAir(void) { ct = 0xFF; } - if (ct > 2 && (gBattleOutcome == BATTLE_POKE_FLED || gBattleOutcome == BATTLE_WON)) + if (ct > 2 && (gBattleOutcome == B_OUTCOME_POKE_FLED || gBattleOutcome == B_OUTCOME_WON)) { sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows); if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_POKEMON_TODAY_FAILED, FALSE) != TRUE) @@ -2402,23 +2402,23 @@ void sub_80EE184(void) show->breakingNews.poke1Species = gBattleResults.playerMon1Species; switch (gBattleOutcome) { - case BATTLE_LOST: - case BATTLE_DREW: + case B_OUTCOME_LOST: + case B_OUTCOME_DREW: show->breakingNews.kind = TVSHOW_OFF_AIR; return; - case BATTLE_CAUGHT: + case B_OUTCOME_CAUGHT_POKE: show->breakingNews.outcome = 0; break; - case BATTLE_WON: + case B_OUTCOME_WON: show->breakingNews.outcome = 1; break; - case BATTLE_RAN: - case BATTLE_PLAYER_TELEPORTED: - case BATTLE_SAFARI_OUT_OF_BALLS: + case B_OUTCOME_RAN: + case B_OUTCOME_PLAYER_TELEPORTED: + case B_OUTCOME_NO_SAFARI_BALLS: show->breakingNews.outcome = 2; break; - case BATTLE_POKE_FLED: - case BATTLE_OPPONENT_TELEPORTED: + case B_OUTCOME_POKE_FLED: + case B_OUTCOME_POKE_TELEPORTED: show->breakingNews.outcome = 3; break; } diff --git a/sym_ewram.txt b/sym_ewram.txt index 092b30ccd..a472994a6 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -276,7 +276,7 @@ gActiveBank: @ 2024064 gBattleExecBuffer: @ 2024068 .space 0x4 -gNoOfAllBanks: @ 202406C +gBattleBanksCount: @ 202406C .space 0x2 gBattlePartyID: @ 202406E @@ -336,7 +336,7 @@ gLastUsedAbility: @ 202420A gBankAttacker: @ 202420B .space 0x1 -gBankTarget: @ 202420C +gBankDefender: @ 202420C .space 0x1 gBank1: @ 202420D @@ -393,7 +393,7 @@ gLastHitBy: @ 2024270 gChosenMovesByBanks: @ 2024274 .space 0x8 -gBattleMoveFlags: @ 202427C +gMoveResultFlags: @ 202427C .space 0x4 gHitMarker: @ 2024280 @@ -408,7 +408,7 @@ gTakenDmgBanks: @ 2024288 gUnknown_0202428C: @ 202428C .space 0x2 -gSideAffecting: @ 202428E +gSideStatuses: @ 202428E .space 0x6 gSideTimers: @ 2024294