diff --git a/asm/battle_1.s b/asm/battle_1.s index e74d12046..636bafbea 100644 --- a/asm/battle_1.s +++ b/asm/battle_1.s @@ -1548,7 +1548,7 @@ _080358E0: .4byte _08035A70 _08035904: ldr r4, =gUnknown_0831ABA8 - ldr r5, =gUnknown_02022FF0 + ldr r5, =gBattleTerrain ldrb r1, [r5] lsls r0, r1, 2 adds r0, r1 @@ -2633,7 +2633,7 @@ _08036350: cmp r0, 0 bne _0803639C ldr r4, =gUnknown_0831ABA8 - ldr r5, =gUnknown_02022FF0 + ldr r5, =gBattleTerrain ldrb r1, [r5] lsls r0, r1, 2 adds r0, r1 @@ -2779,7 +2779,7 @@ _080364A8: .4byte _08036518 _080364CC: ldr r2, =gUnknown_0831ABA8 - ldr r0, =gUnknown_02022FF0 + ldr r0, =gBattleTerrain ldrb r1, [r0] lsls r0, r1, 2 adds r0, r1 @@ -2889,7 +2889,7 @@ _080365B4: .4byte _08036624 _080365D8: ldr r2, =gUnknown_0831ABA8 - ldr r0, =gUnknown_02022FF0 + ldr r0, =gBattleTerrain ldrb r1, [r0] lsls r0, r1, 2 adds r0, r1 @@ -3004,7 +3004,7 @@ _080366C8: .4byte _08036740 _080366EC: ldr r2, =gUnknown_0831ABA8 - ldr r0, =gUnknown_02022FF0 + ldr r0, =gBattleTerrain ldrb r1, [r0] lsls r0, r1, 2 adds r0, r1 diff --git a/asm/battle_2.s b/asm/battle_2.s index d1119619c..c96b80b1c 100644 --- a/asm/battle_2.s +++ b/asm/battle_2.s @@ -170,7 +170,7 @@ _080368BE: ldr r0, =gUnknown_02022E22 strh r1, [r0] bl sub_80B0BD0 - ldr r2, =gUnknown_02022FF0 + ldr r2, =gBattleTerrain strb r0, [r2] ldr r4, =gBattleTypeFlags ldr r0, [r4] @@ -7852,7 +7852,7 @@ bc_load_battlefield: @ 803AC34 bl GetBankByIdentity ldr r4, =gActiveBank strb r0, [r4] - ldr r0, =gUnknown_02022FF0 + ldr r0, =gBattleTerrain ldrb r1, [r0] movs r0, 0 bl dp01_build_cmdbuf_x2E_a @@ -9207,7 +9207,7 @@ _0803B7DA: ldr r1, =gBattleStruct mov r8, r1 movs r7, 0x6 - ldr r6, =gUnknown_0202421C + ldr r6, =gActionForBanks ldr r2, =gChosenMovesByBanks movs r4, 0xFF movs r3, 0 @@ -9511,7 +9511,7 @@ _0803BAB2: ldrb r0, [r4] cmp r2, r0 bge _0803BAE0 - ldr r7, =gUnknown_0202421C + ldr r7, =gActionForBanks movs r6, 0xFF movs r5, 0 ldr r3, =gChosenMovesByBanks @@ -10049,7 +10049,7 @@ _0803BF68: ands r3, r0 cmp r3, 0 beq _0803BFD0 - ldr r0, =gUnknown_0202421C + ldr r0, =gActionForBanks adds r0, r2, r0 movs r1, 0xD strb r1, [r0] @@ -10092,7 +10092,7 @@ _0803BFD0: cmp r1, 0 beq _0803C00C _0803BFF0: - ldr r0, =gUnknown_0202421C + ldr r0, =gActionForBanks adds r0, r2, r0 strb r3, [r0] ldr r1, =gBattleCommunication @@ -10100,7 +10100,7 @@ _0803BFF0: bl _0803CC72 .pool _0803C00C: - ldr r0, =gUnknown_0202421C + ldr r0, =gActionForBanks ldrb r1, [r0] ldr r0, =gBattleBufferB ldrb r2, [r0, 0x1] @@ -10141,7 +10141,7 @@ _0803C058: ldrb r1, [r0] adds r0, r5, 0 bl RecordedBattle_SetBankAction - ldr r1, =gUnknown_0202421C + ldr r1, =gActionForBanks ldrb r0, [r6] adds r1, r0, r1 lsls r0, 9 @@ -10497,7 +10497,7 @@ _0803C3B0: adds r4, r0, 0 cmp r1, 0x2 bne _0803C3D8 - ldr r0, =gUnknown_0202421C + ldr r0, =gActionForBanks ldrb r0, [r0] cmp r0, 0x2 bne _0803C3D8 @@ -10511,7 +10511,7 @@ _0803C3D8: ldrb r0, [r4] cmp r0, 0x3 bne _0803C410 - ldr r0, =gUnknown_0202421C + ldr r0, =gActionForBanks ldrb r0, [r0, 0x1] cmp r0, 0x2 bne _0803C410 @@ -10664,7 +10664,7 @@ _0803C532: bl _0803CD70 .pool _0803C550: - ldr r4, =gUnknown_0202421C + ldr r4, =gActionForBanks ldrb r0, [r5] bl GetBankIdentity eors r0, r6 @@ -10763,7 +10763,7 @@ _0803C628: ands r0, r1 cmp r0, 0 beq _0803C690 - ldr r4, =gUnknown_0202421C + ldr r4, =gActionForBanks ldr r6, =gActiveBank ldrb r0, [r6] bl GetBankIdentity @@ -10945,7 +10945,7 @@ _0803C7D8: beq _0803C804 b _0803CD04 _0803C804: - ldr r1, =gUnknown_0202421C + ldr r1, =gActionForBanks adds r0, r5, r1 ldrb r0, [r0] adds r2, r1, 0 @@ -11410,7 +11410,7 @@ _0803CC38: lsls r1, 8 orrs r0, r1 str r0, [r2] - ldr r1, =gUnknown_0202421C + ldr r1, =gActionForBanks ldrb r0, [r5] adds r0, r1 movs r1, 0x3 @@ -11515,7 +11515,7 @@ _0803CD1E: cmp r4, r5 bge _0803CD70 _0803CD4A: - ldr r0, =gUnknown_0202421C + ldr r0, =gActionForBanks adds r0, r4, r0 ldrb r0, [r0] cmp r0, 0x2 @@ -12033,7 +12033,7 @@ _0803D198: b _0803D254 .pool _0803D1B8: - ldr r0, =gUnknown_0202421C + ldr r0, =gActionForBanks mov r3, r9 adds r1, r3, r0 ldrb r1, [r1] @@ -12209,7 +12209,7 @@ sub_803D2E8: @ 803D2E8 b _0803D54A _0803D310: ldr r7, =gUnknown_0202407A - ldr r6, =gUnknown_0202421C + ldr r6, =gActionForBanks mov r2, r8 ldr r5, =gTurnOrder _0803D318: @@ -12245,7 +12245,7 @@ _0803D354: ldrb r2, [r2] cmp r3, r2 bcs _0803D3C0 - ldr r0, =gUnknown_0202421C + ldr r0, =gActionForBanks ldrb r1, [r0] adds r4, r0, 0 cmp r1, 0x3 @@ -12269,7 +12269,7 @@ _0803D376: b _0803D3BE .pool _0803D3A4: - ldr r1, =gUnknown_0202421C + ldr r1, =gActionForBanks ldrb r0, [r1] ldr r4, =gActiveBank mov r8, r4 @@ -12289,7 +12289,7 @@ _0803D3C0: cmp r3, 0x5 bne _0803D448 ldr r6, =gUnknown_0202407A - ldr r1, =gUnknown_0202421C + ldr r1, =gActionForBanks mov r2, r8 ldrb r0, [r2] adds r0, r1 @@ -12349,7 +12349,7 @@ _0803D448: ldrb r0, [r1] cmp r0, 0 beq _0803D48E - ldr r6, =gUnknown_0202421C + ldr r6, =gActionForBanks mov r2, r8 ldr r5, =gUnknown_0202407A ldr r4, =gTurnOrder @@ -12387,7 +12387,7 @@ _0803D48E: ldrb r0, [r4] cmp r0, 0 beq _0803D4D2 - ldr r6, =gUnknown_0202421C + ldr r6, =gActionForBanks ldr r5, =gUnknown_0202407A ldr r4, =gTurnOrder _0803D4A2: @@ -15097,7 +15097,7 @@ sub_803EE48: @ 803EE48 cmp r1, 0 beq _0803EEE0 adds r4, r2, 0 - ldr r6, =gUnknown_0202421C + ldr r6, =gActionForBanks ldr r5, =gBattleOutcome _0803EE7C: ldrb r0, [r4] @@ -15797,8 +15797,8 @@ _0803F532: .pool thumb_func_end PressurePPLose - thumb_func_start sub_803F548 -sub_803F548: @ 803F548 + thumb_func_start PressurePPLoseOnUsingImprision +PressurePPLoseOnUsingImprision: @ 803F548 push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -15946,10 +15946,10 @@ _0803F658: pop {r0} bx r0 .pool - thumb_func_end sub_803F548 + thumb_func_end PressurePPLoseOnUsingImprision - thumb_func_start sub_803F67C -sub_803F67C: @ 803F67C + thumb_func_start PressurePPLoseOnUsingPerishSong +PressurePPLoseOnUsingPerishSong: @ 803F67C push {r4-r7,lr} mov r7, r10 mov r6, r9 @@ -16078,7 +16078,7 @@ _0803F762: pop {r0} bx r0 .pool - thumb_func_end sub_803F67C + thumb_func_end PressurePPLoseOnUsingPerishSong thumb_func_start sub_803F790 sub_803F790: @ 803F790 diff --git a/asm/battle_4.s b/asm/battle_4.s index 0714a0c22..096c195b0 100644 --- a/asm/battle_4.s +++ b/asm/battle_4.s @@ -5,5423 +5,6 @@ .text - thumb_func_start IsTwoTurnsMove -IsTwoTurnsMove: @ 8052F48 - push {lr} - lsls r0, 16 - lsrs r0, 16 - ldr r2, =gBattleMoves - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - ldrb r0, [r1] - cmp r0, 0x91 - beq _08052F72 - cmp r0, 0x27 - beq _08052F72 - cmp r0, 0x4B - beq _08052F72 - cmp r0, 0x97 - beq _08052F72 - cmp r0, 0x9B - beq _08052F72 - cmp r0, 0x1A - bne _08052F7C -_08052F72: - movs r0, 0x1 - b _08052F7E - .pool -_08052F7C: - movs r0, 0 -_08052F7E: - pop {r1} - bx r1 - thumb_func_end IsTwoTurnsMove - - thumb_func_start sub_8052F84 -sub_8052F84: @ 8052F84 - push {lr} - lsls r0, 16 - lsrs r1, r0, 16 - cmp r1, 0 - beq _08052FA2 - cmp r1, 0xD6 - beq _08052FA2 - movs r0, 0x89 - lsls r0, 1 - cmp r1, r0 - beq _08052FA2 - cmp r1, 0x77 - beq _08052FA2 - cmp r1, 0x76 - bne _08052FA6 -_08052FA2: - movs r0, 0x1 - b _08052FA8 -_08052FA6: - movs r0, 0 -_08052FA8: - pop {r1} - bx r1 - thumb_func_end sub_8052F84 - - thumb_func_start AttacksThisTurn -AttacksThisTurn: @ 8052FAC - push {lr} - lsls r1, 16 - lsrs r2, r1, 16 - ldr r1, =gBattleMoves - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r0, r1 - ldrb r0, [r0] - adds r3, r1, 0 - cmp r0, 0x97 - bne _08052FD0 - ldr r0, =gBattleWeather - ldrh r1, [r0] - movs r0, 0x60 - ands r0, r1 - cmp r0, 0 - bne _08053010 -_08052FD0: - lsls r0, r2, 1 - adds r0, r2 - lsls r0, 2 - adds r0, r3 - ldrb r0, [r0] - cmp r0, 0x91 - beq _08052FF2 - cmp r0, 0x27 - beq _08052FF2 - cmp r0, 0x4B - beq _08052FF2 - cmp r0, 0x97 - beq _08052FF2 - cmp r0, 0x9B - beq _08052FF2 - cmp r0, 0x1A - bne _08053010 -_08052FF2: - ldr r0, =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 20 - ands r0, r1 - cmp r0, 0 - beq _08053010 - movs r0, 0x1 - b _08053012 - .pool -_08053010: - movs r0, 0x2 -_08053012: - pop {r1} - bx r1 - thumb_func_end AttacksThisTurn - - thumb_func_start atkA9_sleeptalk_choose_move -atkA9_sleeptalk_choose_move: @ 8053018 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - movs r6, 0 - movs r5, 0 - ldr r0, =gBankAttacker - mov r9, r0 - movs r1, 0x58 - mov r8, r1 - ldr r7, =gBattleMons + 0xC - movs r0, 0x84 - lsls r0, 1 - mov r10, r0 -_08053036: - lsls r4, r5, 1 - mov r1, r9 - ldrb r0, [r1] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r0, r4, r0 - adds r0, r7 - ldrh r0, [r0] - bl sub_8052F84 - lsls r0, 24 - cmp r0, 0 - bne _08053076 - mov r1, r9 - ldrb r0, [r1] - mov r1, r8 - muls r1, r0 - adds r0, r1, 0 - adds r0, r4, r0 - adds r0, r7 - ldrh r1, [r0] - cmp r1, r10 - beq _08053076 - cmp r1, 0xFD - beq _08053076 - adds r0, r1, 0 - bl IsTwoTurnsMove - lsls r0, 24 - cmp r0, 0 - beq _08053084 -_08053076: - ldr r1, =gBitTable - lsls r0, r5, 2 - adds r0, r1 - ldr r0, [r0] - orrs r6, r0 - lsls r0, r6, 24 - lsrs r6, r0, 24 -_08053084: - adds r5, 0x1 - cmp r5, 0x3 - ble _08053036 - ldr r0, =gBankAttacker - ldrb r0, [r0] - adds r1, r6, 0 - movs r2, 0xFD - bl CheckMoveLimitations - lsls r0, 24 - lsrs r6, r0, 24 - cmp r6, 0xF - bne _080530B8 - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _0805311C - .pool -_080530B8: - movs r7, 0x3 - ldr r4, =gBitTable -_080530BC: - bl Random - adds r5, r7, 0 - ands r5, r0 - lsls r0, r5, 2 - adds r0, r4 - ldr r0, [r0] - ands r0, r6 - cmp r0, 0 - bne _080530BC - ldr r4, =gRandomMove - ldr r2, =gBattleMons - lsls r1, r5, 1 - ldr r0, =gBankAttacker - ldrb r3, [r0] - movs r0, 0x58 - muls r0, r3 - adds r1, r0 - adds r2, 0xC - adds r1, r2 - ldrh r0, [r1] - strh r0, [r4] - ldr r0, =gCurrMovePos - strb r5, [r0] - ldr r2, =gHitMarker - ldr r0, [r2] - ldr r1, =0xfffffbff - ands r0, r1 - str r0, [r2] - ldrh r0, [r4] - movs r1, 0 - bl GetMoveTarget - ldr r1, =gBankTarget - strb r0, [r1] - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_0805311C: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkA9_sleeptalk_choose_move - - thumb_func_start atkAA_set_destinybond -atkAA_set_destinybond: @ 8053150 - ldr r1, =gBattleMons - ldr r0, =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r2, r0 - adds r1, 0x50 - adds r2, r1 - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 18 - orrs r0, r1 - str r0, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - bx lr - .pool - thumb_func_end atkAA_set_destinybond - - thumb_func_start DestinyBondFlagUpdate -DestinyBondFlagUpdate: @ 8053180 - push {r4,r5,lr} - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - lsls r0, 24 - lsrs r5, r0, 24 - ldr r4, =gBankTarget - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - lsrs r3, r0, 24 - ldr r1, =gBattleMons - ldrb r2, [r4] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 18 - ands r0, r1 - cmp r0, 0 - beq _080531CA - cmp r5, r3 - beq _080531CA - ldr r2, =gHitMarker - ldr r1, [r2] - movs r0, 0x80 - lsls r0, 17 - ands r0, r1 - cmp r0, 0 - bne _080531CA - movs r0, 0x40 - orrs r1, r0 - str r1, [r2] -_080531CA: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end DestinyBondFlagUpdate - - thumb_func_start atkAB_DestinyBondFlagUpdate -atkAB_DestinyBondFlagUpdate: @ 80531E0 - push {lr} - bl DestinyBondFlagUpdate - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atkAB_DestinyBondFlagUpdate - - thumb_func_start atkAC_remaininghptopower -atkAC_remaininghptopower: @ 80531F8 - push {lr} - ldr r2, =gBattleMons - ldr r0, =gBankAttacker - ldrb r1, [r0] - movs r0, 0x58 - muls r1, r0 - adds r1, r2 - movs r2, 0x28 - ldrsh r0, [r1, r2] - movs r2, 0x2C - ldrsh r1, [r1, r2] - movs r2, 0x30 - bl sub_8075034 - lsls r0, 24 - lsrs r1, r0, 24 - movs r3, 0 - ldr r0, =gUnknown_0831C408 - ldrb r2, [r0] - cmp r1, r2 - ble _08053232 - adds r2, r0, 0 -_08053224: - adds r3, 0x2 - cmp r3, 0xB - bgt _08053232 - adds r0, r3, r2 - ldrb r0, [r0] - cmp r1, r0 - bgt _08053224 -_08053232: - ldr r2, =gDynamicBasePower - ldr r1, =gUnknown_0831C408 - adds r0, r3, 0x1 - adds r0, r1 - ldrb r0, [r0] - strh r0, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atkAC_remaininghptopower - - thumb_func_start atkAD_spite_ppreduce -atkAD_spite_ppreduce: @ 8053260 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r4, =gLastUsedMovesByBanks - ldr r1, =gBankTarget - ldrb r3, [r1] - lsls r0, r3, 1 - adds r0, r4 - ldrh r2, [r0] - mov r8, r1 - cmp r2, 0 - bne _08053280 - b _08053408 -_08053280: - ldr r0, =0x0000ffff - cmp r2, r0 - bne _08053288 - b _08053408 -_08053288: - movs r7, 0 - ldr r0, =gBattleMons - movs r1, 0x58 - muls r1, r3 - adds r3, r0, 0 - adds r3, 0xC - adds r1, r3 - ldrh r1, [r1] - cmp r2, r1 - beq _080532C0 - adds r6, r4, 0 - mov r5, r8 - adds r4, r3, 0 - movs r3, 0x58 -_080532A4: - adds r7, 0x1 - cmp r7, 0x3 - bgt _080532C0 - ldrb r0, [r5] - lsls r2, r0, 1 - adds r2, r6 - lsls r1, r7, 1 - muls r0, r3 - adds r1, r0 - adds r1, r4 - ldrh r0, [r2] - ldrh r1, [r1] - cmp r0, r1 - bne _080532A4 -_080532C0: - cmp r7, 0x4 - bne _080532C6 - b _08053408 -_080532C6: - mov r4, r8 - ldrb r0, [r4] - movs r1, 0x58 - mov r9, r1 - mov r3, r9 - muls r3, r0 - adds r0, r3, 0 - adds r0, r7, r0 - ldr r1, =gBattleMons - adds r1, 0x24 - mov r10, r1 - add r0, r10 - ldrb r0, [r0] - cmp r0, 0x1 - bhi _080532E6 - b _08053408 -_080532E6: - bl Random - movs r1, 0x3 - ands r1, r0 - adds r6, r1, 0x2 - ldrb r0, [r4] - mov r3, r9 - muls r3, r0 - adds r0, r3, 0 - adds r0, r7, r0 - add r0, r10 - ldrb r0, [r0] - cmp r0, r6 - bge _08053304 - adds r6, r0, 0 -_08053304: - ldr r1, =gBattleTextBuff1 - movs r5, 0xFD - strb r5, [r1] - movs r0, 0x2 - strb r0, [r1, 0x1] - ldr r2, =gLastUsedMovesByBanks - mov r3, r8 - ldrb r0, [r3] - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - strb r0, [r1, 0x2] - ldrb r0, [r3] - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - lsrs r0, 8 - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r4, =gBattleTextBuff2 - adds r0, r4, 0 - adds r1, r6, 0 - movs r2, 0 - movs r3, 0x1 - bl ConvertIntToDecimalStringN - strb r5, [r4] - movs r0, 0x1 - strb r0, [r4, 0x1] - strb r0, [r4, 0x2] - strb r0, [r4, 0x3] - strb r6, [r4, 0x4] - subs r0, 0x2 - strb r0, [r4, 0x5] - mov r1, r8 - ldrb r0, [r1] - mov r1, r9 - muls r1, r0 - adds r1, r7, r1 - add r1, r10 - ldrb r0, [r1] - subs r0, r6 - strb r0, [r1] - ldr r4, =gActiveBank - mov r3, r8 - ldrb r0, [r3] - strb r0, [r4] - ldr r1, =gDisableStructs - ldrb r3, [r4] - lsls r0, r3, 3 - subs r0, r3 - lsls r0, 2 - adds r0, r1 - ldrb r1, [r0, 0x18] - lsrs r1, 4 - ldr r2, =gBitTable - lsls r0, r7, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _080533B8 - mov r2, r9 - muls r2, r3 - ldr r0, =gBattleMons - adds r0, 0x50 - adds r0, r2, r0 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 14 - ands r0, r1 - cmp r0, 0 - bne _080533B8 - adds r1, r7, 0 - adds r1, 0x9 - lsls r1, 24 - lsrs r1, 24 - mov r3, r10 - adds r0, r2, r3 - adds r0, r7 - str r0, [sp] - movs r0, 0 - movs r2, 0 - movs r3, 0x1 - bl EmitSetMonData - ldrb r0, [r4] - bl MarkBufferBankForExecution -_080533B8: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - ldr r1, =gBattleMons - ldr r0, =gBankTarget - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r0, r7, r0 - adds r1, 0x24 - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - bne _08053422 - adds r0, r2, 0 - bl CancelMultiTurnMoves - b _08053422 - .pool -_08053408: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_08053422: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkAD_spite_ppreduce - - thumb_func_start atkAE_heal_party_status -atkAE_heal_party_status: @ 8053438 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x8 - movs r4, 0 - str r4, [sp, 0x4] - mov r8, r4 - ldr r0, =gCurrentMove - ldrh r0, [r0] - cmp r0, 0xD7 - beq _08053454 - b _0805363E -_08053454: - ldr r6, =gBattleCommunication - mov r0, r8 - strb r0, [r6, 0x5] - ldr r5, =gBankAttacker - ldrb r0, [r5] - bl GetBankSide - lsls r0, 24 - ldr r1, =gEnemyParty - mov r10, r1 - cmp r0, 0 - bne _08053470 - ldr r2, =gPlayerParty - mov r10, r2 -_08053470: - ldr r4, =gBattleMons - ldrb r3, [r5] - movs r7, 0x58 - adds r2, r3, 0 - muls r2, r7 - adds r0, r2, r4 - adds r1, r0, 0 - adds r1, 0x20 - ldrb r0, [r1] - cmp r0, 0x2B - beq _080534C4 - adds r0, r4, 0 - adds r0, 0x4C - adds r0, r2, r0 - mov r1, r8 - str r1, [r0] - ldrb r0, [r5] - adds r2, r0, 0 - muls r2, r7 - adds r0, r4, 0 - adds r0, 0x50 - adds r2, r0 - ldr r0, [r2] - ldr r1, =0xf7ffffff - ands r0, r1 - str r0, [r2] - b _080534D4 - .pool -_080534C4: - ldrb r1, [r1] - adds r0, r3, 0 - bl RecordAbilityBattle - ldrb r0, [r6, 0x5] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r6, 0x5] -_080534D4: - ldr r7, =gActiveBank - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl GetBankIdentity - movs r2, 0x2 - mov r9, r2 - mov r1, r9 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - ldr r1, =gBattleScripting - strb r0, [r1, 0x17] - strb r0, [r7] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _0805357A - ldr r0, =gAbsentBankFlags - ldrb r2, [r0] - ldr r1, =gBitTable - ldrb r3, [r7] - lsls r0, r3, 2 - adds r0, r1 - ldr r0, [r0] - ands r2, r0 - cmp r2, 0 - bne _0805357A - ldr r5, =gBattleMons - movs r6, 0x58 - adds r4, r3, 0 - muls r4, r6 - adds r0, r4, r5 - adds r1, r0, 0 - adds r1, 0x20 - ldrb r0, [r1] - cmp r0, 0x2B - beq _08053568 - adds r0, r5, 0 - adds r0, 0x4C - adds r0, r4, r0 - str r2, [r0] - ldrb r0, [r7] - adds r2, r0, 0 - muls r2, r6 - adds r0, r5, 0 - adds r0, 0x50 - adds r2, r0 - ldr r0, [r2] - ldr r1, =0xf7ffffff - ands r0, r1 - str r0, [r2] - b _0805357A - .pool -_08053568: - ldrb r1, [r1] - adds r0, r3, 0 - bl RecordAbilityBattle - ldr r1, =gBattleCommunication - ldrb r0, [r1, 0x5] - mov r2, r9 - orrs r0, r2 - strb r0, [r1, 0x5] -_0805357A: - movs r6, 0 - ldr r7, =gBattleMons -_0805357E: - movs r0, 0x64 - adds r4, r6, 0 - muls r4, r0 - add r4, r10 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r4, 0 - movs r1, 0x2E - bl GetMonData - lsls r0, 24 - lsrs r4, r0, 24 - cmp r5, 0 - beq _08053636 - movs r0, 0xCE - lsls r0, 1 - cmp r5, r0 - beq _08053636 - ldr r2, =gBattlePartyID - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r0, r1, 1 - adds r0, r2 - ldrh r0, [r0] - cmp r0, r6 - bne _080535D0 - movs r0, 0x58 - muls r0, r1 - b _08053600 - .pool -_080535D0: - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08053618 - ldr r0, =gActiveBank - ldrb r3, [r0] - lsls r0, r3, 1 - adds r0, r2 - ldrh r0, [r0] - cmp r0, r6 - bne _08053618 - ldr r0, =gAbsentBankFlags - ldrb r1, [r0] - ldr r2, =gBitTable - lsls r0, r3, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _08053618 - movs r0, 0x58 - muls r0, r3 -_08053600: - adds r0, r7 - adds r0, 0x20 - ldrb r0, [r0] - b _08053624 - .pool -_08053618: - adds r0, r5, 0 - adds r1, r4, 0 - bl GetAbilityBySpecies - lsls r0, 24 - lsrs r0, 24 -_08053624: - cmp r0, 0x2B - beq _08053636 - movs r0, 0x1 - lsls r0, r6 - mov r1, r8 - orrs r1, r0 - lsls r0, r1, 24 - lsrs r0, 24 - mov r8, r0 -_08053636: - adds r6, 0x1 - cmp r6, 0x5 - ble _0805357E - b _080536BC -_0805363E: - ldr r1, =gBattleCommunication - movs r0, 0x4 - strb r0, [r1, 0x5] - movs r2, 0x3F - mov r8, r2 - ldr r3, =gBattleMons - ldr r2, =gBankAttacker - ldrb r0, [r2] - movs r5, 0x58 - muls r0, r5 - movs r1, 0x4C - adds r1, r3 - mov r9, r1 - add r0, r9 - str r4, [r0] - ldrb r0, [r2] - adds r1, r0, 0 - muls r1, r5 - adds r7, r3, 0 - adds r7, 0x50 - adds r1, r7 - ldr r0, [r1] - ldr r6, =0xf7ffffff - ands r0, r6 - str r0, [r1] - ldrb r0, [r2] - bl GetBankIdentity - movs r1, 0x2 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - ldr r4, =gActiveBank - strb r0, [r4] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _080536BC - ldr r0, =gAbsentBankFlags - ldrb r2, [r0] - ldr r1, =gBitTable - ldrb r3, [r4] - lsls r0, r3, 2 - adds r0, r1 - ldr r0, [r0] - ands r2, r0 - cmp r2, 0 - bne _080536BC - adds r0, r3, 0 - muls r0, r5 - add r0, r9 - str r2, [r0] - ldrb r0, [r4] - adds r1, r0, 0 - muls r1, r5 - adds r1, r7 - ldr r0, [r1] - ands r0, r6 - str r0, [r1] -_080536BC: - mov r2, r8 - cmp r2, 0 - beq _080536DE - ldr r4, =gActiveBank - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r4] - add r0, sp, 0x4 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r3, 0x4 - bl EmitSetMonData - ldrb r0, [r4] - bl MarkBufferBankForExecution -_080536DE: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - add sp, 0x8 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkAE_heal_party_status - - thumb_func_start atkAF_cursetarget -atkAF_cursetarget: @ 805371C - push {r4,r5,lr} - ldr r5, =gBattleMons - ldr r0, =gBankTarget - ldrb r0, [r0] - movs r4, 0x58 - adds r1, r0, 0 - muls r1, r4 - adds r0, r5, 0 - adds r0, 0x50 - adds r1, r0 - ldr r2, [r1] - movs r3, 0x80 - lsls r3, 21 - adds r0, r2, 0 - ands r0, r3 - cmp r0, 0 - beq _08053768 - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _0805378C - .pool -_08053768: - orrs r2, r3 - str r2, [r1] - ldr r1, =gBattleMoveDamage - ldr r0, =gBankAttacker - ldrb r0, [r0] - muls r0, r4 - adds r0, r5 - ldrh r0, [r0, 0x2C] - lsrs r0, 1 - str r0, [r1] - cmp r0, 0 - bne _08053784 - movs r0, 0x1 - str r0, [r1] -_08053784: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_0805378C: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atkAF_cursetarget - - thumb_func_start atkB0_set_spikes -atkB0_set_spikes: @ 80537A0 - push {r4,lr} - ldr r4, =gBankAttacker - ldrb r0, [r4] - bl GetBankSide - movs r1, 0x1 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - ldr r1, =gSideTimers - lsls r2, r0, 1 - adds r0, r2, r0 - lsls r0, 2 - adds r3, r0, r1 - ldrb r0, [r3, 0xA] - cmp r0, 0x3 - bne _08053804 - ldr r2, =gSpecialStatuses - ldrb r1, [r4] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x20 - orrs r1, r2 - strb r1, [r0] - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _0805381E - .pool -_08053804: - ldr r1, =gSideAffecting - adds r1, r2, r1 - ldrh r2, [r1] - movs r0, 0x10 - orrs r0, r2 - strh r0, [r1] - ldrb r0, [r3, 0xA] - adds r0, 0x1 - strb r0, [r3, 0xA] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_0805381E: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkB0_set_spikes - - thumb_func_start atkB1_set_foresight -atkB1_set_foresight: @ 805382C - ldr r1, =gBattleMons - ldr r0, =gBankTarget - ldrb r2, [r0] - movs r0, 0x58 - muls r2, r0 - adds r1, 0x50 - adds r2, r1 - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 22 - orrs r0, r1 - str r0, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - bx lr - .pool - thumb_func_end atkB1_set_foresight - - thumb_func_start atkB2_setperishsong -atkB2_setperishsong: @ 805385C - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - movs r6, 0 - movs r3, 0 - ldr r0, =gNoOfAllBanks - adds r7, r0, 0 - ldr r0, =gBankAttacker - mov r8, r0 - ldrb r1, [r7] - cmp r6, r1 - bge _080538C8 - movs r5, 0x20 - ldr r0, =gBattleMons - mov r12, r0 - ldr r0, =gDisableStructs - adds r4, r0, 0 - adds r4, 0xF - ldr r2, =gStatuses3 -_08053884: - ldr r1, [r2] - adds r0, r1, 0 - ands r0, r5 - cmp r0, 0 - bne _0805389C - movs r0, 0x58 - muls r0, r3 - add r0, r12 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x2B - bne _080538B4 -_0805389C: - adds r6, 0x1 - b _080538BC - .pool -_080538B4: - orrs r1, r5 - str r1, [r2] - movs r0, 0x33 - strb r0, [r4] -_080538BC: - adds r4, 0x1C - adds r2, 0x4 - adds r3, 0x1 - ldrb r0, [r7] - cmp r3, r0 - blt _08053884 -_080538C8: - mov r1, r8 - ldrb r0, [r1] - bl sub_803F67C - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r6, r0 - bne _080538FC - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _08053904 - .pool -_080538FC: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_08053904: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkB2_setperishsong - - thumb_func_start atkB3_rolloutdamagecalculation -atkB3_rolloutdamagecalculation: @ 8053914 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - ldr r0, =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _08053948 - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl CancelMultiTurnMoves - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082D8A60 - str r0, [r1] - b _08053A60 - .pool -_08053948: - ldr r2, =gBattleMons - ldr r1, =gBankAttacker - ldrb r3, [r1] - movs r5, 0x58 - adds r0, r3, 0 - muls r0, r5 - adds r4, r2, 0 - adds r4, 0x50 - adds r0, r4 - ldr r0, [r0] - movs r7, 0x80 - lsls r7, 5 - ands r0, r7 - adds r6, r1, 0 - mov r9, r2 - ldr r1, =gDisableStructs - mov r12, r1 - ldr r2, =gCurrentMove - mov r8, r2 - cmp r0, 0 - bne _080539BA - lsls r0, r3, 3 - subs r0, r3 - lsls r0, 2 - add r0, r12 - ldrb r2, [r0, 0x11] - movs r1, 0x10 - negs r1, r1 - ands r1, r2 - movs r2, 0x5 - orrs r1, r2 - strb r1, [r0, 0x11] - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - add r0, r12 - ldrb r2, [r0, 0x11] - movs r1, 0xF - ands r1, r2 - movs r2, 0x50 - orrs r1, r2 - strb r1, [r0, 0x11] - ldrb r0, [r6] - adds r1, r0, 0 - muls r1, r5 - adds r1, r4 - ldr r0, [r1] - orrs r0, r7 - str r0, [r1] - ldr r1, =gLockedMoves - ldrb r0, [r6] - lsls r0, 1 - adds r0, r1 - mov r2, r8 - ldrh r1, [r2] - strh r1, [r0] -_080539BA: - ldrb r0, [r6] - lsls r2, r0, 3 - subs r2, r0 - lsls r2, 2 - add r2, r12 - ldrb r3, [r2, 0x11] - lsls r1, r3, 28 - lsrs r1, 28 - subs r1, 0x1 - movs r0, 0xF - ands r1, r0 - movs r0, 0x10 - negs r0, r0 - ands r0, r3 - orrs r0, r1 - strb r0, [r2, 0x11] - cmp r1, 0 - bne _080539EE - ldrb r0, [r6] - adds r1, r0, 0 - muls r1, r5 - adds r1, r4 - ldr r0, [r1] - ldr r2, =0xffffefff - ands r0, r2 - str r0, [r1] -_080539EE: - ldr r3, =gDynamicBasePower - ldr r2, =gBattleMoves - mov r0, r8 - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x1] - strh r0, [r3] - movs r2, 0x1 - ldrb r1, [r6] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - mov r1, r12 - adds r4, r0, r1 - ldrb r0, [r4, 0x11] - lsls r0, 28 - lsrs r0, 28 - movs r1, 0x5 - subs r1, r0 - ldr r7, =gBattlescriptCurrInstr - adds r5, r3, 0 - cmp r2, r1 - bge _08053A3C - adds r1, r5, 0 - adds r3, r4, 0 - movs r4, 0x5 -_08053A28: - ldrh r0, [r1] - lsls r0, 1 - strh r0, [r1] - adds r2, 0x1 - ldrb r0, [r3, 0x11] - lsls r0, 28 - lsrs r0, 28 - subs r0, r4, r0 - cmp r2, r0 - blt _08053A28 -_08053A3C: - ldrb r1, [r6] - movs r0, 0x58 - muls r0, r1 - mov r1, r9 - adds r1, 0x50 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 23 - ands r0, r1 - cmp r0, 0 - beq _08053A5A - ldrh r0, [r5] - lsls r0, 1 - strh r0, [r5] -_08053A5A: - ldr r0, [r7] - adds r0, 0x1 - str r0, [r7] -_08053A60: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkB3_rolloutdamagecalculation - - thumb_func_start atkB4_jumpifconfusedandstatmaxed -atkB4_jumpifconfusedandstatmaxed: @ 8053A90 - push {r4,r5,lr} - ldr r5, =gBattleMons - ldr r0, =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - adds r3, r1, 0 - muls r3, r0 - adds r0, r5, 0 - adds r0, 0x50 - adds r0, r3, r0 - ldr r0, [r0] - movs r1, 0x7 - ands r0, r1 - ldr r4, =gBattlescriptCurrInstr - cmp r0, 0 - beq _08053AEC - ldr r2, [r4] - ldrb r0, [r2, 0x1] - adds r0, r3 - adds r1, r5, 0 - adds r1, 0x18 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 24 - asrs r0, 24 - cmp r0, 0xC - bne _08053AEC - ldrb r1, [r2, 0x2] - ldrb r0, [r2, 0x3] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x5] - lsls r0, 24 - orrs r1, r0 - str r1, [r4] - b _08053AF2 - .pool -_08053AEC: - ldr r0, [r4] - adds r0, 0x6 - str r0, [r4] -_08053AF2: - pop {r4,r5} - pop {r0} - bx r0 - thumb_func_end atkB4_jumpifconfusedandstatmaxed - - thumb_func_start atkB5_furycuttercalc -atkB5_furycuttercalc: @ 8053AF8 - push {r4,r5,lr} - ldr r0, =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _08053B34 - ldr r2, =gDisableStructs - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r2 - movs r1, 0 - strb r1, [r0, 0x10] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082D8A60 - str r0, [r1] - b _08053B8C - .pool -_08053B34: - ldr r5, =gDisableStructs - ldr r4, =gBankAttacker - ldrb r1, [r4] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r1, r0, r5 - ldrb r0, [r1, 0x10] - cmp r0, 0x5 - beq _08053B4C - adds r0, 0x1 - strb r0, [r1, 0x10] -_08053B4C: - ldr r3, =gDynamicBasePower - ldr r2, =gBattleMoves - ldr r0, =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x1] - strh r0, [r3] - movs r2, 0x1 - ldrb r1, [r4] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r5 - ldr r4, =gBattlescriptCurrInstr - ldrb r1, [r0, 0x10] - cmp r2, r1 - bge _08053B86 - adds r1, r3, 0 - adds r3, r0, 0 -_08053B78: - ldrh r0, [r1] - lsls r0, 1 - strh r0, [r1] - adds r2, 0x1 - ldrb r0, [r3, 0x10] - cmp r2, r0 - blt _08053B78 -_08053B86: - ldr r0, [r4] - adds r0, 0x1 - str r0, [r4] -_08053B8C: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atkB5_furycuttercalc - - thumb_func_start atkB6_happinesstodamagecalculation -atkB6_happinesstodamagecalculation: @ 8053BAC - push {r4,lr} - ldr r2, =gBattleMoves - ldr r0, =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] - cmp r0, 0x79 - bne _08053BEC - ldr r4, =gDynamicBasePower - ldr r2, =gBattleMons - ldr r0, =gBankAttacker - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - adds r0, 0x2B - ldrb r1, [r0] - b _08053C02 - .pool -_08053BEC: - ldr r4, =gDynamicBasePower - ldr r2, =gBattleMons - ldr r0, =gBankAttacker - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - adds r0, 0x2B - ldrb r0, [r0] - movs r1, 0xFF - subs r1, r0 -_08053C02: - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 1 - movs r1, 0x19 - bl __divsi3 - strh r0, [r4] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkB6_happinesstodamagecalculation - - thumb_func_start atkB7_presentdamagecalculation -atkB7_presentdamagecalculation: @ 8053C30 - push {r4,lr} - bl Random - movs r4, 0xFF - ands r4, r0 - cmp r4, 0x65 - bgt _08053C4C - ldr r1, =gDynamicBasePower - movs r0, 0x28 - strh r0, [r1] - b _08053C8E - .pool -_08053C4C: - cmp r4, 0xB1 - bgt _08053C5C - ldr r1, =gDynamicBasePower - movs r0, 0x50 - strh r0, [r1] - b _08053C8E - .pool -_08053C5C: - cmp r4, 0xCB - bgt _08053C6C - ldr r1, =gDynamicBasePower - movs r0, 0x78 - strh r0, [r1] - b _08053C8E - .pool -_08053C6C: - ldr r3, =gBattleMoveDamage - ldr r2, =gBattleMons - ldr r0, =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r0, [r0, 0x2C] - lsrs r0, 2 - str r0, [r3] - cmp r0, 0 - bne _08053C88 - movs r0, 0x1 - str r0, [r3] -_08053C88: - ldr r0, [r3] - negs r0, r0 - str r0, [r3] -_08053C8E: - cmp r4, 0xCB - bgt _08053CAC - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082D8A30 - b _08053CE6 - .pool -_08053CAC: - ldr r2, =gBattleMons - ldr r0, =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r1, [r0, 0x2C] - ldrh r0, [r0, 0x28] - cmp r1, r0 - bne _08053CD8 - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082D9EFB - b _08053CE6 - .pool -_08053CD8: - ldr r2, =gBattleMoveFlags - ldrb r1, [r2] - movs r0, 0xF7 - ands r0, r1 - strb r0, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082D9EE1 -_08053CE6: - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkB7_presentdamagecalculation - - thumb_func_start atkB8_set_safeguard -atkB8_set_safeguard: @ 8053CFC - push {r4-r7,lr} - ldr r7, =gBankAttacker - ldrb r0, [r7] - bl GetBankIdentity - ldr r4, =gSideAffecting - movs r6, 0x1 - adds r1, r6, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - ldrh r1, [r1] - movs r0, 0x20 - ands r0, r1 - cmp r0, 0 - beq _08053D40 - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0 - strb r0, [r1, 0x5] - b _08053D88 - .pool -_08053D40: - ldrb r0, [r7] - bl GetBankIdentity - adds r1, r6, 0 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - ldrh r0, [r1] - movs r2, 0x20 - orrs r0, r2 - strh r0, [r1] - ldrb r0, [r7] - bl GetBankIdentity - ldr r5, =gSideTimers - adds r1, r6, 0 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - movs r4, 0x5 - strb r4, [r0, 0x6] - ldrb r0, [r7] - bl GetBankIdentity - adds r1, r6, 0 - ands r1, r0 - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r5 - ldrb r1, [r7] - strb r1, [r0, 0x7] - ldr r0, =gBattleCommunication - strb r4, [r0, 0x5] -_08053D88: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkB8_set_safeguard - - thumb_func_start atkB9_magnitudedamagecalculation -atkB9_magnitudedamagecalculation: @ 8053DA4 - push {r4-r7,lr} - mov r7, r8 - push {r7} - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r3, r0, 16 - cmp r3, 0x4 - bgt _08053DD0 - ldr r1, =gDynamicBasePower - movs r0, 0xA - strh r0, [r1] - movs r3, 0x4 - b _08053E3C - .pool -_08053DD0: - cmp r3, 0xE - bgt _08053DE4 - ldr r1, =gDynamicBasePower - movs r0, 0x1E - strh r0, [r1] - movs r3, 0x5 - b _08053E3C - .pool -_08053DE4: - cmp r3, 0x22 - bgt _08053DF8 - ldr r1, =gDynamicBasePower - movs r0, 0x32 - strh r0, [r1] - movs r3, 0x6 - b _08053E3C - .pool -_08053DF8: - cmp r3, 0x40 - bgt _08053E0C - ldr r1, =gDynamicBasePower - movs r0, 0x46 - strh r0, [r1] - movs r3, 0x7 - b _08053E3C - .pool -_08053E0C: - cmp r3, 0x54 - bgt _08053E20 - ldr r1, =gDynamicBasePower - movs r0, 0x5A - strh r0, [r1] - movs r3, 0x8 - b _08053E3C - .pool -_08053E20: - cmp r3, 0x5E - bgt _08053E34 - ldr r1, =gDynamicBasePower - movs r0, 0x6E - strh r0, [r1] - movs r3, 0x9 - b _08053E3C - .pool -_08053E34: - ldr r1, =gDynamicBasePower - movs r0, 0x96 - strh r0, [r1] - movs r3, 0xA -_08053E3C: - ldr r1, =gBattleTextBuff1 - movs r2, 0 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x1 - strb r0, [r1, 0x1] - strb r0, [r1, 0x2] - movs r0, 0x2 - strb r0, [r1, 0x3] - strb r3, [r1, 0x4] - movs r0, 0xFF - strb r0, [r1, 0x5] - ldr r1, =gBankTarget - strb r2, [r1] - ldr r0, =gNoOfAllBanks - ldrb r3, [r0] - adds r6, r1, 0 - ldr r0, =gBattlescriptCurrInstr - mov r8, r0 - cmp r2, r3 - bcs _08053E94 - adds r4, r6, 0 - ldr r0, =gBankAttacker - ldrb r5, [r0] - ldr r1, =gBitTable - mov r12, r1 - ldr r7, =gAbsentBankFlags -_08053E72: - ldrb r2, [r4] - cmp r2, r5 - beq _08053E88 - ldrb r0, [r7] - ldrb r1, [r6] - lsls r1, 2 - add r1, r12 - ldr r1, [r1] - ands r0, r1 - cmp r0, 0 - beq _08053E94 -_08053E88: - adds r0, r2, 0x1 - strb r0, [r4] - lsls r0, 24 - lsrs r0, 24 - cmp r0, r3 - bcc _08053E72 -_08053E94: - mov r1, r8 - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkB9_magnitudedamagecalculation - - thumb_func_start atkBA_jumpifnopursuitswitchdmg -atkBA_jumpifnopursuitswitchdmg: @ 8053EC8 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r0, =gMultiHitCounter - ldrb r0, [r0] - cmp r0, 0x1 - bne _08053EF8 - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _08053EF4 - movs r0, 0x1 - b _08053F12 - .pool -_08053EF4: - movs r0, 0 - b _08053F12 -_08053EF8: - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - lsls r0, 24 - cmp r0, 0 - bne _08053F10 - movs r0, 0x3 - b _08053F12 - .pool -_08053F10: - movs r0, 0x2 -_08053F12: - bl GetBankByIdentity - ldr r1, =gBankTarget - strb r0, [r1] - ldr r0, =gUnknown_0202421C - ldr r1, =gBankTarget - ldrb r3, [r1] - adds r0, r3, r0 - ldrb r0, [r0] - cmp r0, 0 - beq _08053F2A - b _08054030 -_08053F2A: - ldr r5, =gBankAttacker - ldr r0, =gBattleStruct - ldr r1, [r0] - adds r1, r3, r1 - ldrb r2, [r5] - ldrb r1, [r1, 0xC] - cmp r2, r1 - bne _08054030 - ldr r4, =gBattleMons - movs r2, 0x58 - adds r0, r3, 0 - muls r0, r2 - adds r1, r4, 0 - adds r1, 0x4C - adds r0, r1 - ldr r0, [r0] - movs r1, 0x27 - ands r0, r1 - cmp r0, 0 - bne _08054030 - ldrb r0, [r5] - muls r0, r2 - adds r0, r4 - ldrh r0, [r0, 0x28] - cmp r0, 0 - beq _08054030 - ldr r0, =gDisableStructs - lsls r1, r3, 3 - subs r1, r3 - lsls r1, 2 - adds r1, r0 - ldrb r0, [r1, 0x18] - lsls r0, 31 - cmp r0, 0 - bne _08054030 - ldr r0, =gChosenMovesByBanks - lsls r1, r3, 1 - adds r1, r0 - ldrh r0, [r1] - cmp r0, 0xE4 - bne _08054030 - movs r1, 0 - ldr r0, =gNoOfAllBanks - ldr r2, =gCurrentMove - mov r8, r2 - ldr r7, =gCurrMovePos - mov r10, r7 - ldr r2, =gUnknown_020241E9 - mov r9, r2 - ldr r7, =gHitMarker - mov r12, r7 - ldrb r2, [r0] - cmp r1, r2 - bge _08053FB6 - ldr r6, =gTurnOrder - ldr r5, =gBankTarget - ldr r4, =gUnknown_0202407A - movs r3, 0xB - adds r2, r0, 0 -_08053FA0: - adds r0, r1, r6 - ldrb r0, [r0] - ldrb r7, [r5] - cmp r0, r7 - bne _08053FAE - adds r0, r1, r4 - strb r3, [r0] -_08053FAE: - adds r1, 0x1 - ldrb r0, [r2] - cmp r1, r0 - blt _08053FA0 -_08053FB6: - movs r0, 0xE4 - mov r1, r8 - strh r0, [r1] - ldr r2, =gBankTarget - ldrb r0, [r2] - ldr r7, =gBattleStruct - ldr r1, [r7] - adds r0, r1 - adds r0, 0x80 - ldrb r0, [r0] - mov r1, r9 - strb r0, [r1] - mov r2, r10 - strb r0, [r2] - ldr r7, =gBattlescriptCurrInstr - ldr r0, [r7] - adds r0, 0x5 - str r0, [r7] - movs r0, 0x1 - ldr r1, =gBattleScripting - strb r0, [r1, 0x18] - mov r2, r12 - ldr r0, [r2] - ldr r1, =0xfffffbff - ands r0, r1 - str r0, [r2] - b _0805404A - .pool -_08054030: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_0805404A: - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkBA_jumpifnopursuitswitchdmg - - thumb_func_start atkBB_setsunny -atkBB_setsunny: @ 805405C - push {lr} - ldr r2, =gBattleWeather - ldrh r1, [r2] - movs r0, 0x60 - ands r0, r1 - cmp r0, 0 - beq _08054088 - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] - b _0805409A - .pool -_08054088: - movs r0, 0x20 - strh r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x4 - strb r0, [r1, 0x5] - ldr r0, =gWishFutureKnock - adds r0, 0x28 - movs r1, 0x5 - strb r1, [r0] -_0805409A: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atkBB_setsunny - - thumb_func_start atkBC_maxattackhalvehp -atkBC_maxattackhalvehp: @ 80540B4 - push {r4,r5,lr} - ldr r5, =gBattleMons - ldr r4, =gBankAttacker - ldrb r0, [r4] - movs r3, 0x58 - muls r0, r3 - adds r2, r0, r5 - ldrh r0, [r2, 0x2C] - lsrs r1, r0, 1 - cmp r1, 0 - bne _080540CC - movs r1, 0x1 -_080540CC: - movs r0, 0x19 - ldrsb r0, [r2, r0] - cmp r0, 0xB - bgt _08054110 - ldrh r0, [r2, 0x28] - cmp r0, r1 - bls _08054110 - movs r0, 0xC - strb r0, [r2, 0x19] - ldr r1, =gBattleMoveDamage - ldrb r0, [r4] - muls r0, r3 - adds r0, r5 - ldrh r0, [r0, 0x2C] - lsrs r0, 1 - str r0, [r1] - cmp r0, 0 - bne _080540F4 - movs r0, 0x1 - str r0, [r1] -_080540F4: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _0805412A - .pool -_08054110: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_0805412A: - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atkBC_maxattackhalvehp - - thumb_func_start atkBD_copyfoestats -atkBD_copyfoestats: @ 8054134 - push {r4-r7,lr} - movs r2, 0 - ldr r7, =gBattlescriptCurrInstr - ldr r6, =gBankAttacker - movs r4, 0x58 - ldr r3, =gBattleMons + 0x18 - ldr r5, =gBankTarget -_08054142: - ldrb r0, [r6] - adds r1, r0, 0 - muls r1, r4 - adds r1, r2, r1 - adds r1, r3 - ldrb r0, [r5] - muls r0, r4 - adds r0, r2, r0 - adds r0, r3 - ldrb r0, [r0] - strb r0, [r1] - adds r2, 0x1 - cmp r2, 0x7 - ble _08054142 - ldr r0, [r7] - adds r0, 0x5 - str r0, [r7] - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkBD_copyfoestats - - thumb_func_start atkBE_breakfree -atkBE_breakfree: @ 805417C - push {r4-r6,lr} - ldr r1, =gBattleMons - ldr r5, =gBankAttacker - ldrb r2, [r5] - movs r6, 0x58 - adds r0, r2, 0 - muls r0, r6 - adds r4, r1, 0 - adds r4, 0x50 - adds r0, r4 - ldr r0, [r0] - movs r1, 0xE0 - lsls r1, 8 - ands r0, r1 - cmp r0, 0 - beq _08054210 - ldr r1, =gBattleScripting - ldr r3, =gBankTarget - ldrb r0, [r3] - strb r0, [r1, 0x17] - ldrb r0, [r5] - adds r1, r0, 0 - muls r1, r6 - adds r1, r4 - ldr r0, [r1] - ldr r2, =0xffff1fff - ands r0, r2 - str r0, [r1] - ldrb r0, [r5] - ldr r1, =gBattleStruct - ldr r2, [r1] - adds r0, r2 - ldrb r0, [r0, 0x14] - strb r0, [r3] - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x2 - strb r0, [r1, 0x1] - ldrb r0, [r5] - lsls r0, 1 - adds r0, r2 - ldrb r0, [r0, 0x4] - strb r0, [r1, 0x2] - ldrb r0, [r5] - lsls r0, 1 - adds r0, r2 - ldrb r0, [r0, 0x5] - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - bl BattleScriptPushCursor - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAFC5 - b _080542BA - .pool -_08054210: - ldr r4, =gStatuses3 - lsls r0, r2, 2 - adds r3, r0, r4 - ldr r1, [r3] - movs r0, 0x4 - ands r0, r1 - cmp r0, 0 - beq _08054250 - movs r0, 0x5 - negs r0, r0 - ands r1, r0 - str r1, [r3] - ldrb r1, [r5] - lsls r1, 2 - adds r1, r4 - ldr r0, [r1] - movs r2, 0x4 - negs r2, r2 - ands r0, r2 - str r0, [r1] - bl BattleScriptPushCursor - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAFD6 - b _080542BA - .pool -_08054250: - adds r0, r2, 0 - bl GetBankSide - ldr r4, =gSideAffecting - lsls r0, 24 - lsrs r0, 23 - adds r0, r4 - ldrh r1, [r0] - movs r0, 0x10 - ands r0, r1 - cmp r0, 0 - beq _080542B4 - ldrb r0, [r5] - bl GetBankSide - lsls r0, 24 - lsrs r0, 23 - adds r0, r4 - ldrh r2, [r0] - ldr r1, =0x0000ffef - ands r1, r2 - movs r4, 0 - strh r1, [r0] - ldrb r0, [r5] - bl GetBankSide - ldr r2, =gSideTimers - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r2 - strb r4, [r1, 0xA] - bl BattleScriptPushCursor - ldr r1, =gBattlescriptCurrInstr - ldr r0, =gUnknown_082DAFDD - b _080542BA - .pool -_080542B4: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 -_080542BA: - str r0, [r1] - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atkBE_breakfree - - thumb_func_start atkBF_set_defense_curl -atkBF_set_defense_curl: @ 80542C8 - ldr r1, =gBattleMons - ldr r0, =gBankAttacker - ldrb r2, [r0] - movs r0, 0x58 - muls r2, r0 - adds r1, 0x50 - adds r2, r1 - ldr r0, [r2] - movs r1, 0x80 - lsls r1, 23 - orrs r0, r1 - str r0, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - bx lr - .pool - thumb_func_end atkBF_set_defense_curl - - thumb_func_start atkC0_recoverbasedonsunlight -atkC0_recoverbasedonsunlight: @ 80542F8 - push {r4-r7,lr} - sub sp, 0x4 - ldr r1, =gBankTarget - ldr r5, =gBankAttacker - ldrb r0, [r5] - strb r0, [r1] - ldr r7, =gBattleMons - ldrb r0, [r5] - movs r6, 0x58 - muls r0, r6 - adds r0, r7 - ldrh r1, [r0, 0x28] - ldrh r0, [r0, 0x2C] - cmp r1, r0 - beq _080543D8 - ldr r4, =gBattleWeather - ldrh r0, [r4] - cmp r0, 0 - beq _0805434A - movs r0, 0 - str r0, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0xD - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0 - bne _0805434A - str r0, [sp] - movs r0, 0x13 - movs r1, 0 - movs r2, 0x4D - movs r3, 0 - bl AbilityBattleEffects - lsls r0, 24 - cmp r0, 0 - beq _08054378 -_0805434A: - ldr r3, =gBattleMoveDamage - ldr r2, =gBattleMons - ldr r0, =gBankAttacker - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r0, [r0, 0x2C] - lsrs r0, 1 - str r0, [r3] - adds r1, r3, 0 - b _080543B2 - .pool -_08054378: - ldrh r1, [r4] - movs r0, 0x60 - ands r0, r1 - cmp r0, 0 - beq _080543A4 - ldr r4, =gBattleMoveDamage - ldrb r0, [r5] - muls r0, r6 - adds r0, r7 - ldrh r1, [r0, 0x2C] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - movs r1, 0x1E - bl __divsi3 - str r0, [r4] - adds r1, r4, 0 - b _080543B2 - .pool -_080543A4: - ldr r1, =gBattleMoveDamage - ldrb r0, [r5] - muls r0, r6 - adds r0, r7 - ldrh r0, [r0, 0x2C] - lsrs r0, 2 - str r0, [r1] -_080543B2: - adds r2, r1, 0 - ldr r0, [r2] - cmp r0, 0 - bne _080543BE - movs r0, 0x1 - str r0, [r2] -_080543BE: - ldr r0, [r1] - negs r0, r0 - str r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _080543F2 - .pool -_080543D8: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_080543F2: - add sp, 0x4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkC0_recoverbasedonsunlight - - thumb_func_start atkC1_hidden_power -atkC1_hidden_power: @ 8054400 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - ldr r2, =gBattleMons - ldr r0, =gBankAttacker - ldrb r1, [r0] - movs r0, 0x58 - adds r4, r1, 0 - muls r4, r0 - adds r4, r2 - ldrb r0, [r4, 0x14] - mov r10, r0 - mov r7, r10 - lsls r7, 27 - adds r0, r7, 0 - lsrs r0, 27 - mov r10, r0 - movs r1, 0x2 - mov r2, r10 - ands r2, r1 - asrs r2, 1 - ldrh r7, [r4, 0x14] - mov r9, r7 - mov r0, r9 - lsls r0, 22 - mov r9, r0 - lsrs r3, r0, 27 - adds r0, r1, 0 - ands r0, r3 - orrs r2, r0 - ldrb r7, [r4, 0x15] - mov r8, r7 - mov r0, r8 - lsls r0, 25 - mov r8, r0 - lsrs r3, r0, 27 - adds r0, r1, 0 - ands r0, r3 - lsls r0, 1 - orrs r2, r0 - ldr r6, [r4, 0x14] - lsls r6, 12 - lsrs r3, r6, 27 - adds r0, r1, 0 - ands r0, r3 - lsls r0, 2 - orrs r2, r0 - ldrh r5, [r4, 0x16] - lsls r5, 23 - lsrs r3, r5, 27 - adds r0, r1, 0 - ands r0, r3 - lsls r0, 3 - orrs r2, r0 - ldrb r3, [r4, 0x17] - lsls r3, 26 - lsrs r0, r3, 27 - ands r1, r0 - lsls r1, 4 - orrs r2, r1 - movs r1, 0x1 - adds r4, r1, 0 - mov r7, r10 - ands r4, r7 - mov r0, r9 - lsrs r0, 27 - mov r9, r0 - adds r0, r1, 0 - mov r7, r9 - ands r0, r7 - lsls r0, 1 - orrs r4, r0 - mov r0, r8 - lsrs r0, 27 - mov r8, r0 - adds r0, r1, 0 - mov r7, r8 - ands r0, r7 - lsls r0, 2 - orrs r4, r0 - lsrs r6, 27 - adds r0, r1, 0 - ands r0, r6 - lsls r0, 3 - orrs r4, r0 - lsrs r5, 27 - adds r0, r1, 0 - ands r0, r5 - lsls r0, 4 - orrs r4, r0 - lsrs r3, 27 - ands r1, r3 - lsls r1, 5 - orrs r4, r1 - ldr r5, =gDynamicBasePower - lsls r0, r2, 2 - adds r0, r2 - lsls r0, 3 - movs r1, 0x3F - bl __divsi3 - adds r0, 0x1E - strh r0, [r5] - ldr r6, =gBattleStruct - ldr r5, [r6] - lsls r0, r4, 4 - subs r0, r4 - movs r1, 0x3F - bl __divsi3 - adds r0, 0x1 - strb r0, [r5, 0x13] - ldr r1, [r6] - ldrb r0, [r1, 0x13] - cmp r0, 0x8 - bls _080544F0 - adds r0, 0x1 - strb r0, [r1, 0x13] -_080544F0: - ldr r2, [r6] - ldrb r0, [r2, 0x13] - movs r1, 0xC0 - orrs r0, r1 - strb r0, [r2, 0x13] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkC1_hidden_power - - thumb_func_start atkC2_selectnexttarget -atkC2_selectnexttarget: @ 8054524 - push {r4-r7,lr} - mov r7, r8 - push {r7} - ldr r0, =gBankTarget - movs r1, 0 - strb r1, [r0] - ldr r1, =gNoOfAllBanks - ldrb r1, [r1] - adds r6, r0, 0 - ldr r0, =gBattlescriptCurrInstr - mov r8, r0 - cmp r1, 0 - beq _0805456E - adds r3, r6, 0 - ldr r0, =gBankAttacker - ldrb r5, [r0] - ldr r0, =gBitTable - mov r12, r0 - adds r4, r1, 0 - ldr r7, =gAbsentBankFlags -_0805454C: - ldrb r2, [r3] - cmp r2, r5 - beq _08054562 - ldrb r0, [r7] - ldrb r1, [r6] - lsls r1, 2 - add r1, r12 - ldr r1, [r1] - ands r0, r1 - cmp r0, 0 - beq _0805456E -_08054562: - adds r0, r2, 0x1 - strb r0, [r3] - lsls r0, 24 - lsrs r0, 24 - cmp r0, r4 - bcc _0805454C -_0805456E: - mov r1, r8 - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkC2_selectnexttarget - - thumb_func_start atkC3_setfutureattack -atkC3_setfutureattack: @ 8054598 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x14 - ldr r0, =gWishFutureKnock - mov r8, r0 - ldr r6, =gBankTarget - ldrb r1, [r6] - adds r0, r1, r0 - ldrb r7, [r0] - cmp r7, 0 - beq _080545DC - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _080546CC - .pool -_080545DC: - adds r0, r1, 0 - bl GetBankIdentity - ldr r4, =gSideAffecting - lsls r0, 24 - lsrs r0, 24 - movs r1, 0x1 - mov r10, r1 - ands r0, r1 - lsls r0, 1 - adds r0, r4 - ldrh r2, [r0] - movs r1, 0x40 - movs r5, 0 - mov r3, sp - strh r5, [r3, 0x10] - orrs r1, r2 - strh r1, [r0] - ldrb r0, [r6] - lsls r0, 1 - mov r1, r8 - adds r1, 0x18 - adds r0, r1 - ldr r1, =gCurrentMove - mov r9, r1 - ldrh r1, [r1] - strh r1, [r0] - mov r0, r8 - adds r0, 0x4 - ldrb r2, [r6] - adds r0, r2 - ldr r5, =gBankAttacker - ldrb r1, [r5] - strb r1, [r0] - ldrb r0, [r6] - add r0, r8 - movs r1, 0x3 - strb r1, [r0] - ldrb r0, [r6] - bl GetBankIdentity - mov r1, r10 - ands r1, r0 - lsls r1, 1 - adds r1, r4 - ldrh r3, [r1] - ldrb r0, [r5] - movs r4, 0x58 - muls r0, r4 - ldr r2, =gBattleMons - adds r0, r2 - ldrb r1, [r6] - muls r1, r4 - adds r1, r2 - mov r4, r9 - ldrh r2, [r4] - str r7, [sp] - str r7, [sp, 0x4] - ldrb r4, [r5] - str r4, [sp, 0x8] - ldrb r4, [r6] - str r4, [sp, 0xC] - bl CalculateBaseDamage - ldrb r1, [r6] - lsls r1, 2 - mov r2, r8 - adds r2, 0x8 - adds r1, r2 - str r0, [r1] - ldr r1, =gProtectStructs - ldrb r0, [r5] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 28 - cmp r0, 0 - bge _0805468C - ldrb r4, [r6] - lsls r4, 2 - adds r4, r2 - ldr r1, [r4] - lsls r0, r1, 4 - subs r0, r1 - movs r1, 0xA - bl __divsi3 - str r0, [r4] -_0805468C: - mov r5, r9 - ldrh r1, [r5] - ldr r0, =0x00000161 - cmp r1, r0 - bne _080546BC - ldr r0, =gBattleCommunication - mov r1, r10 - strb r1, [r0, 0x5] - b _080546C4 - .pool -_080546BC: - ldr r0, =gBattleCommunication - mov r2, sp - ldrb r2, [r2, 0x10] - strb r2, [r0, 0x5] -_080546C4: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_080546CC: - add sp, 0x14 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkC3_setfutureattack - - thumb_func_start atkC4_beat_up -atkC4_beat_up: @ 80546E4 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - lsls r0, 24 - ldr r7, =gEnemyParty - cmp r0, 0 - bne _080546FE - ldr r7, =gPlayerParty -_080546FE: - ldr r2, =gBattleMons - ldr r0, =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r0, [r0, 0x28] - cmp r0, 0 - bne _08054740 - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - b _080548DC - .pool -_08054740: - ldr r6, =gBattleCommunication - ldrb r0, [r6] - mov r8, r0 - cmp r0, 0x5 - bls _0805474C - b _080548A8 -_0805474C: - adds r4, r6, 0 - movs r5, 0x64 -_08054750: - ldrb r0, [r4] - muls r0, r5 - adds r0, r7, r0 - movs r1, 0x39 - bl GetMonData - cmp r0, 0 - beq _08054794 - ldrb r0, [r6] - muls r0, r5 - adds r0, r7, r0 - movs r1, 0x41 - bl GetMonData - cmp r0, 0 - beq _08054794 - ldrb r0, [r4] - muls r0, r5 - adds r0, r7, r0 - movs r1, 0x41 - bl GetMonData - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - beq _08054794 - ldrb r0, [r4] - muls r0, r5 - adds r0, r7, r0 - movs r1, 0x37 - bl GetMonData - cmp r0, 0 - beq _080547A4 -_08054794: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - adds r6, r4, 0 - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x5 - bls _08054750 -_080547A4: - ldr r1, =gBattleCommunication - mov r9, r1 - ldrb r2, [r1] - cmp r2, 0x5 - bhi _080548A8 - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x4 - strb r0, [r1, 0x1] - ldr r6, =gBankAttacker - ldrb r0, [r6] - strb r0, [r1, 0x2] - strb r2, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x9 - str r0, [r1] - ldr r2, =gBattleMoveDamage - mov r8, r2 - ldr r5, =gBaseStats - mov r1, r9 - ldrb r0, [r1] - movs r4, 0x64 - muls r0, r4 - adds r0, r7, r0 - movs r1, 0xB - bl GetMonData - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r1, r5 - ldrb r3, [r1, 0x1] - mov r2, r8 - str r3, [r2] - ldr r2, =gBattleMoves - ldr r0, =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0, 0x1] - muls r0, r3 - mov r1, r8 - str r0, [r1] - mov r2, r9 - ldrb r0, [r2] - muls r0, r4 - adds r0, r7, r0 - movs r1, 0x38 - bl GetMonData - lsls r0, 1 - movs r1, 0x5 - bl __udivsi3 - adds r0, 0x2 - mov r2, r8 - ldr r1, [r2] - muls r0, r1 - str r0, [r2] - ldr r3, =gBattleMons - ldr r1, =gBankTarget - ldrb r2, [r1] - movs r1, 0x58 - muls r1, r2 - adds r1, r3 - ldrh r2, [r1] - lsls r1, r2, 3 - subs r1, r2 - lsls r1, 2 - adds r1, r5 - ldrb r1, [r1, 0x2] - bl __divsi3 - mov r1, r8 - str r0, [r1] - movs r1, 0x32 - bl __divsi3 - adds r2, r0, 0x2 - mov r0, r8 - str r2, [r0] - ldr r1, =gProtectStructs - ldrb r0, [r6] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 28 - cmp r0, 0 - bge _08054870 - lsls r0, r2, 4 - subs r0, r2 - movs r1, 0xA - bl __divsi3 - mov r1, r8 - str r0, [r1] -_08054870: - mov r2, r9 - ldrb r0, [r2] - adds r0, 0x1 - strb r0, [r2] - b _080548E2 - .pool -_080548A8: - mov r0, r8 - cmp r0, 0 - beq _080548C8 - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - b _080548DC - .pool -_080548C8: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x5] - ldrb r0, [r2, 0x6] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x7] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x8] -_080548DC: - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_080548E2: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkC4_beat_up - - thumb_func_start atkC5_hidepreattack -atkC5_hidepreattack: @ 80548F4 - push {lr} - ldr r0, =gCurrentMove - ldrh r1, [r0] - cmp r1, 0x5B - beq _08054934 - cmp r1, 0x5B - bgt _0805490C - cmp r1, 0x13 - beq _08054918 - b _08054960 - .pool -_0805490C: - ldr r0, =0x00000123 - cmp r1, r0 - beq _0805494C - adds r0, 0x31 - cmp r1, r0 - bne _08054960 -_08054918: - ldr r2, =gStatuses3 - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r1, 2 - adds r1, r2 - ldr r0, [r1] - movs r2, 0x40 - b _0805495C - .pool -_08054934: - ldr r2, =gStatuses3 - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r1, 2 - adds r1, r2 - ldr r0, [r1] - movs r2, 0x80 - b _0805495C - .pool -_0805494C: - ldr r2, =gStatuses3 - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r1, 2 - adds r1, r2 - ldr r0, [r1] - movs r2, 0x80 - lsls r2, 11 -_0805495C: - orrs r0, r2 - str r0, [r1] -_08054960: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atkC5_hidepreattack - - thumb_func_start atkC6_unhidepostattack -atkC6_unhidepostattack: @ 8054978 - push {lr} - ldr r0, =gCurrentMove - ldrh r1, [r0] - cmp r1, 0x5B - beq _080549BC - cmp r1, 0x5B - bgt _08054990 - cmp r1, 0x13 - beq _0805499C - b _080549EA - .pool -_08054990: - ldr r0, =0x00000123 - cmp r1, r0 - beq _080549D8 - adds r0, 0x31 - cmp r1, r0 - bne _080549EA -_0805499C: - ldr r2, =gStatuses3 - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r1, 2 - adds r1, r2 - ldr r0, [r1] - movs r2, 0x41 - negs r2, r2 - b _080549E6 - .pool -_080549BC: - ldr r2, =gStatuses3 - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r1, 2 - adds r1, r2 - ldr r0, [r1] - movs r2, 0x81 - negs r2, r2 - b _080549E6 - .pool -_080549D8: - ldr r2, =gStatuses3 - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r1, 2 - adds r1, r2 - ldr r0, [r1] - ldr r2, =0xfffbffff -_080549E6: - ands r0, r2 - str r0, [r1] -_080549EA: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atkC6_unhidepostattack - - thumb_func_start atkC7_setminimize -atkC7_setminimize: @ 8054A08 - push {lr} - ldr r0, =gHitMarker - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 18 - ands r0, r1 - cmp r0, 0 - beq _08054A2C - ldr r2, =gStatuses3 - ldr r0, =gBankAttacker - ldrb r1, [r0] - lsls r1, 2 - adds r1, r2 - ldr r0, [r1] - movs r2, 0x80 - lsls r2, 1 - orrs r0, r2 - str r0, [r1] -_08054A2C: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atkC7_setminimize - - thumb_func_start atkC8_sethail -atkC8_sethail: @ 8054A48 - push {lr} - ldr r3, =gBattleWeather - ldrh r1, [r3] - movs r2, 0x80 - adds r0, r2, 0 - ands r0, r1 - cmp r0, 0 - beq _08054A78 - ldr r2, =gBattleMoveFlags - ldrb r0, [r2] - movs r1, 0x1 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattleCommunication - movs r0, 0x2 - strb r0, [r1, 0x5] - b _08054A86 - .pool -_08054A78: - strh r2, [r3] - ldr r0, =gBattleCommunication - movs r1, 0x5 - strb r1, [r0, 0x5] - ldr r0, =gWishFutureKnock - adds r0, 0x28 - strb r1, [r0] -_08054A86: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atkC8_sethail - - thumb_func_start atkC9_jumpifattackandspecialattackcannotfall -atkC9_jumpifattackandspecialattackcannotfall: @ 8054AA0 - push {r4,lr} - ldr r2, =gBattleMons - ldr r0, =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - adds r1, r0, r2 - movs r0, 0x19 - ldrsb r0, [r1, r0] - adds r3, r2, 0 - cmp r0, 0 - bne _08054AF4 - movs r0, 0x1C - ldrsb r0, [r1, r0] - cmp r0, 0 - bne _08054AF4 - ldr r0, =gBattleCommunication - ldrb r0, [r0, 0x6] - cmp r0, 0x1 - beq _08054AF4 - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _08054B20 - .pool -_08054AF4: - ldr r4, =gActiveBank - ldr r0, =gBankAttacker - ldrb r0, [r0] - strb r0, [r4] - ldr r2, =gBattleMoveDamage - ldrb r1, [r4] - movs r0, 0x58 - muls r0, r1 - adds r0, r3 - ldrh r0, [r0, 0x28] - str r0, [r2] - ldr r1, =0x00007fff - movs r0, 0 - bl EmitHealthBarUpdate - ldrb r0, [r4] - bl MarkBufferBankForExecution - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_08054B20: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkC9_jumpifattackandspecialattackcannotfall - - thumb_func_start atkCA_setforcedtarget -atkCA_setforcedtarget: @ 8054B3C - push {r4,r5,lr} - ldr r4, =gBankAttacker - ldrb r0, [r4] - bl GetBankSide - ldr r5, =gSideTimers - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r5 - movs r0, 0x1 - strb r0, [r1, 0x8] - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - lsls r1, r0, 1 - adds r1, r0 - lsls r1, 2 - adds r1, r5 - ldrb r0, [r4] - strb r0, [r1, 0x9] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4,r5} - pop {r0} - bx r0 - .pool - thumb_func_end atkCA_setforcedtarget - - thumb_func_start atkCB_setcharge -atkCB_setcharge: @ 8054B88 - push {r4,lr} - ldr r0, =gStatuses3 - ldr r3, =gBankAttacker - ldrb r1, [r3] - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] - movs r2, 0x80 - lsls r2, 2 - orrs r0, r2 - str r0, [r1] - ldr r4, =gDisableStructs - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r2, [r0, 0x12] - movs r1, 0x10 - negs r1, r1 - ands r1, r2 - movs r2, 0x2 - orrs r1, r2 - strb r1, [r0, 0x12] - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r2, [r0, 0x12] - movs r1, 0xF - ands r1, r2 - movs r2, 0x20 - orrs r1, r2 - strb r1, [r0, 0x12] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkCB_setcharge - - thumb_func_start atkCC_callterrainattack -atkCC_callterrainattack: @ 8054BEC - push {r4,lr} - ldr r2, =gHitMarker - ldr r0, [r2] - ldr r1, =0xfffffbff - ands r0, r1 - str r0, [r2] - ldr r4, =gCurrentMove - ldr r1, =gUnknown_0831C414 - ldr r0, =gUnknown_02022FF0 - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - ldrh r0, [r0] - strh r0, [r4] - ldrh r0, [r4] - movs r1, 0 - bl GetMoveTarget - ldr r1, =gBankTarget - strb r0, [r1] - ldr r3, =gBattleScriptsForMoveEffects - ldr r2, =gBattleMoves - ldrh r1, [r4] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r3 - ldr r0, [r0] - bl BattleScriptPush - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkCC_callterrainattack - - thumb_func_start atkCD_cureifburnedparalysedorpoisoned -atkCD_cureifburnedparalysedorpoisoned: @ 8054C60 - push {r4-r6,lr} - sub sp, 0x4 - ldr r1, =gBattleMons - ldr r3, =gBankAttacker - ldrb r0, [r3] - movs r6, 0x58 - muls r0, r6 - adds r5, r1, 0 - adds r5, 0x4C - adds r2, r0, r5 - ldr r0, [r2] - movs r1, 0xD8 - ands r0, r1 - cmp r0, 0 - beq _08054CBC - movs r0, 0 - str r0, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - ldr r4, =gActiveBank - ldrb r0, [r3] - strb r0, [r4] - ldrb r0, [r4] - muls r0, r6 - adds r0, r5 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r2, 0 - movs r3, 0x4 - bl EmitSetMonData - ldrb r0, [r4] - bl MarkBufferBankForExecution - b _08054CD6 - .pool -_08054CBC: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_08054CD6: - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atkCD_cureifburnedparalysedorpoisoned - - thumb_func_start atkCE_settorment -atkCE_settorment: @ 8054CE4 - push {lr} - ldr r1, =gBattleMons - ldr r0, =gBankTarget - ldrb r2, [r0] - movs r0, 0x58 - muls r0, r2 - adds r1, 0x50 - adds r0, r1 - ldr r1, [r0] - movs r2, 0x80 - lsls r2, 24 - cmp r1, 0 - bge _08054D28 - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _08054D34 - .pool -_08054D28: - orrs r1, r2 - str r1, [r0] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_08054D34: - pop {r0} - bx r0 - .pool - thumb_func_end atkCE_settorment - - thumb_func_start atkCF_jumpifnodamage -atkCF_jumpifnodamage: @ 8054D3C - push {lr} - ldr r2, =gProtectStructs - ldr r0, =gBankAttacker - ldrb r0, [r0] - lsls r1, r0, 4 - adds r0, r2, 0x4 - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - bne _08054D5C - adds r0, r2, 0 - adds r0, 0x8 - adds r0, r1, r0 - ldr r0, [r0] - cmp r0, 0 - beq _08054D74 -_08054D5C: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _08054D8E - .pool -_08054D74: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_08054D8E: - pop {r0} - bx r0 - .pool - thumb_func_end atkCF_jumpifnodamage - - thumb_func_start atkD0_settaunt -atkD0_settaunt: @ 8054D98 - push {r4,lr} - ldr r4, =gDisableStructs - ldr r3, =gBankTarget - ldrb r0, [r3] - lsls r1, r0, 3 - subs r1, r0 - lsls r1, 2 - adds r2, r1, r4 - ldrb r1, [r2, 0x13] - lsls r0, r1, 28 - cmp r0, 0 - bne _08054DE8 - movs r0, 0x10 - negs r0, r0 - ands r0, r1 - movs r1, 0x2 - orrs r0, r1 - strb r0, [r2, 0x13] - ldrb r1, [r3] - lsls r0, r1, 3 - subs r0, r1 - lsls r0, 2 - adds r0, r4 - ldrb r2, [r0, 0x13] - movs r1, 0xF - ands r1, r2 - movs r2, 0x20 - orrs r1, r2 - strb r1, [r0, 0x13] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _08054E02 - .pool -_08054DE8: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_08054E02: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkD0_settaunt - - thumb_func_start atkD1_set_helpinghand -atkD1_set_helpinghand: @ 8054E0C - push {r4,lr} - ldr r4, =gBankAttacker - ldrb r0, [r4] - bl GetBankIdentity - movs r1, 0x2 - eors r0, r1 - lsls r0, 24 - lsrs r0, 24 - bl GetBankByIdentity - ldr r3, =gBankTarget - strb r0, [r3] - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - movs r1, 0x1 - ands r0, r1 - cmp r0, 0 - beq _08054E90 - ldr r0, =gAbsentBankFlags - ldrb r1, [r0] - ldr r2, =gBitTable - ldrb r3, [r3] - lsls r0, r3, 2 - adds r0, r2 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _08054E90 - ldr r1, =gProtectStructs - ldrb r0, [r4] - lsls r0, 4 - adds r0, r1 - ldrb r0, [r0] - lsls r0, 28 - cmp r0, 0 - blt _08054E90 - lsls r0, r3, 4 - adds r2, r0, r1 - ldrb r1, [r2] - lsls r0, r1, 28 - cmp r0, 0 - blt _08054E90 - movs r0, 0x8 - orrs r0, r1 - strb r0, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _08054EAA - .pool -_08054E90: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_08054EAA: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkD1_set_helpinghand - - thumb_func_start atkD2_swap_items -atkD2_swap_items: @ 8054EB4 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - ldr r4, =gBattleTypeFlags - ldr r0, [r4] - movs r1, 0x80 - lsls r1, 19 - ands r0, r1 - cmp r0, 0 - bne _08054F9A - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, 0x1 - bne _08054EE8 - ldr r0, [r4] - ldr r1, =0x0a3f0902 - ands r0, r1 - cmp r0, 0 - beq _08054F9A -_08054EE8: - ldr r6, =gBankAttacker - ldrb r0, [r6] - bl GetBankSide - lsls r0, 24 - lsrs r4, r0, 24 - ldr r7, =gBankTarget - ldrb r0, [r7] - bl GetBankSide - lsls r0, 24 - lsrs r5, r0, 24 - ldr r0, =gBattleTypeFlags - ldr r0, [r0] - ldr r1, =0x0a3f0902 - ands r0, r1 - cmp r0, 0 - bne _08054F46 - ldr r0, =gWishFutureKnock - adds r2, r0, 0 - adds r2, 0x29 - adds r0, r4, r2 - ldrb r1, [r0] - ldr r4, =gBitTable - ldr r3, =gBattlePartyID - ldrb r0, [r6] - lsls r0, 1 - adds r0, r3 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r4 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _08054F9A - adds r0, r5, r2 - ldrb r1, [r0] - ldrb r0, [r7] - lsls r0, 1 - adds r0, r3 - ldrh r0, [r0] - lsls r0, 2 - adds r0, r4 - ldr r0, [r0] - ands r1, r0 - cmp r1, 0 - bne _08054F9A -_08054F46: - ldr r0, =gBattleMons - mov r8, r0 - ldr r1, =gBankAttacker - ldrb r4, [r1] - movs r5, 0x58 - adds r0, r4, 0 - muls r0, r5 - add r0, r8 - mov r9, r0 - ldrh r3, [r0, 0x2E] - adds r1, r3, 0 - cmp r1, 0 - bne _08054F6E - ldr r0, =gBankTarget - ldrb r0, [r0] - muls r0, r5 - add r0, r8 - ldrh r0, [r0, 0x2E] - cmp r0, 0 - beq _08054F9A -_08054F6E: - cmp r1, 0xAF - beq _08054F9A - ldr r7, =gBankTarget - ldrb r0, [r7] - muls r0, r5 - mov r2, r8 - adds r1, r0, r2 - ldrh r2, [r1, 0x2E] - cmp r2, 0xAF - beq _08054F9A - adds r0, r3, 0 - subs r0, 0x79 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xB - bls _08054F9A - adds r0, r2, 0 - subs r0, 0x79 - lsls r0, 16 - lsrs r0, 16 - cmp r0, 0xB - bhi _08054FDC -_08054F9A: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _08055132 - .pool -_08054FDC: - adds r0, r1, 0 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x3C - bne _08055010 - ldr r1, =gBattlescriptCurrInstr - ldr r0, =BattleScript_StickyHoldOnKnockOff - str r0, [r1] - ldr r1, =gLastUsedAbility - ldrb r0, [r7] - muls r0, r5 - add r0, r8 - adds r0, 0x20 - ldrb r0, [r0] - strb r0, [r1] - ldrb r0, [r7] - ldrb r1, [r1] - bl RecordAbilityBattle - b _08055132 - .pool -_08055010: - ldr r3, =gBattleStruct - mov r10, r3 - lsls r0, r4, 1 - adds r0, 0xD0 - ldr r1, [r3] - adds r6, r1, r0 - mov r0, r9 - ldrh r0, [r0, 0x2E] - mov r9, r0 - strh r2, [r6] - ldr r1, =gBankAttacker - ldrb r0, [r1] - muls r0, r5 - add r0, r8 - movs r1, 0 - strh r1, [r0, 0x2E] - ldrb r0, [r7] - muls r0, r5 - add r0, r8 - mov r2, r9 - strh r2, [r0, 0x2E] - ldr r4, =gActiveBank - ldr r3, =gBankAttacker - ldrb r0, [r3] - strb r0, [r4] - str r6, [sp] - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - movs r3, 0x2 - bl EmitSetMonData - ldr r1, =gBankAttacker - ldrb r0, [r1] - bl MarkBufferBankForExecution - ldrb r0, [r7] - strb r0, [r4] - ldrb r0, [r7] - muls r0, r5 - mov r1, r8 - adds r1, 0x2E - adds r0, r1 - str r0, [sp] - movs r0, 0 - movs r1, 0x2 - movs r2, 0 - movs r3, 0x2 - bl EmitSetMonData - ldrb r0, [r7] - bl MarkBufferBankForExecution - ldrb r0, [r7] - mov r2, r10 - ldr r1, [r2] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC8 - movs r3, 0 - strb r3, [r0] - ldrb r0, [r7] - ldr r1, [r2] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC9 - strb r3, [r0] - ldr r1, =gBankAttacker - ldrb r0, [r1] - ldr r1, [r2] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC8 - strb r3, [r0] - ldr r2, =gBankAttacker - ldrb r0, [r2] - mov r3, r10 - ldr r1, [r3] - lsls r0, 1 - adds r0, r1 - adds r0, 0xC9 - movs r1, 0 - strb r1, [r0] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - ldr r1, =gBattleTextBuff1 - movs r3, 0xFD - strb r3, [r1] - movs r2, 0xA - strb r2, [r1, 0x1] - ldrh r0, [r6] - strb r0, [r1, 0x2] - ldrh r0, [r6] - lsrs r0, 8 - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r1, =gBattleTextBuff2 - strb r3, [r1] - strb r2, [r1, 0x1] - mov r2, r9 - strb r2, [r1, 0x2] - mov r3, r9 - lsrs r0, r3, 8 - strb r0, [r1, 0x3] - movs r0, 0x1 - negs r0, r0 - strb r0, [r1, 0x4] - cmp r3, 0 - beq _08055118 - ldrh r0, [r6] - cmp r0, 0 - beq _0805512C - ldr r1, =gBattleCommunication - movs r0, 0x2 - b _08055130 - .pool -_08055118: - ldrh r0, [r6] - cmp r0, 0 - beq _0805512C - ldr r0, =gBattleCommunication - movs r1, 0 - strb r1, [r0, 0x5] - b _08055132 - .pool -_0805512C: - ldr r1, =gBattleCommunication - movs r0, 0x1 -_08055130: - strb r0, [r1, 0x5] -_08055132: - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkD2_swap_items - - thumb_func_start atkD3_copy_ability -atkD3_copy_ability: @ 8055148 - push {r4,lr} - ldr r3, =gBattleMons - ldr r4, =gBankTarget - ldrb r0, [r4] - movs r2, 0x58 - muls r0, r2 - adds r0, r3 - adds r0, 0x20 - ldrb r1, [r0] - adds r0, r1, 0 - cmp r0, 0 - beq _0805519C - cmp r0, 0x19 - beq _0805519C - ldr r0, =gBankAttacker - ldrb r0, [r0] - muls r0, r2 - adds r0, r3 - adds r0, 0x20 - strb r1, [r0] - ldr r1, =gLastUsedAbility - ldrb r0, [r4] - muls r0, r2 - adds r0, r3 - adds r0, 0x20 - ldrb r0, [r0] - strb r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _080551B6 - .pool -_0805519C: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_080551B6: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkD3_copy_ability - - thumb_func_start atkD4_wish_effect -atkD4_wish_effect: @ 80551C0 - push {r4-r7,lr} - ldr r7, =gBattlescriptCurrInstr - ldr r2, [r7] - ldrb r3, [r2, 0x1] - cmp r3, 0 - beq _080551D8 - cmp r3, 0x1 - beq _08055210 - b _0805528C - .pool -_080551D8: - ldr r1, =gWishFutureKnock - ldr r4, =gBankAttacker - adds r0, r1, 0 - adds r0, 0x20 - ldrb r5, [r4] - adds r3, r0, r5 - ldrb r0, [r3] - cmp r0, 0 - bne _0805525C - movs r0, 0x2 - strb r0, [r3] - ldrb r0, [r4] - adds r1, 0x24 - adds r1, r0, r1 - ldr r2, =gBattlePartyID - lsls r0, 1 - adds r0, r2 - ldrh r0, [r0] - strb r0, [r1] - ldr r0, [r7] - adds r0, 0x6 - b _0805528A - .pool -_08055210: - ldr r1, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r1] - movs r0, 0x4 - strb r0, [r1, 0x1] - ldr r4, =gBankTarget - ldrb r0, [r4] - strb r0, [r1, 0x2] - ldr r0, =gWishFutureKnock - adds r0, 0x24 - ldrb r5, [r4] - adds r0, r5 - ldrb r0, [r0] - strb r0, [r1, 0x3] - movs r0, 0xFF - strb r0, [r1, 0x4] - ldr r1, =gBattleMoveDamage - ldr r6, =gBattleMons - ldrb r0, [r4] - movs r5, 0x58 - muls r0, r5 - adds r0, r6 - ldrh r0, [r0, 0x2C] - lsrs r0, 1 - str r0, [r1] - cmp r0, 0 - bne _08055248 - str r3, [r1] -_08055248: - ldr r0, [r1] - negs r0, r0 - str r0, [r1] - ldrb r0, [r4] - muls r0, r5 - adds r0, r6 - ldrh r1, [r0, 0x28] - ldrh r0, [r0, 0x2C] - cmp r1, r0 - bne _08055288 -_0805525C: - ldrb r1, [r2, 0x2] - ldrb r0, [r2, 0x3] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x5] - lsls r0, 24 - orrs r1, r0 - str r1, [r7] - b _0805528C - .pool -_08055288: - adds r0, r2, 0x6 -_0805528A: - str r0, [r7] -_0805528C: - pop {r4-r7} - pop {r0} - bx r0 - thumb_func_end atkD4_wish_effect - - thumb_func_start atkD5_setroots -atkD5_setroots: @ 8055294 - push {lr} - ldr r1, =gStatuses3 - ldr r0, =gBankAttacker - ldrb r0, [r0] - lsls r0, 2 - adds r2, r0, r1 - ldr r1, [r2] - movs r3, 0x80 - lsls r3, 3 - adds r0, r1, 0 - ands r0, r3 - cmp r0, 0 - beq _080552D8 - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _080552E4 - .pool -_080552D8: - orrs r1, r3 - str r1, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_080552E4: - pop {r0} - bx r0 - .pool - thumb_func_end atkD5_setroots - - thumb_func_start atkD6_doubledamagedealtifdamaged -atkD6_doubledamagedealtifdamaged: @ 80552EC - push {lr} - ldr r3, =gProtectStructs - ldr r0, =gBankAttacker - ldrb r0, [r0] - lsls r2, r0, 4 - adds r0, r3, 0x4 - adds r0, r2, r0 - ldr r0, [r0] - cmp r0, 0 - beq _0805530C - adds r0, r2, r3 - ldr r1, =gBankTarget - ldrb r0, [r0, 0xC] - ldrb r1, [r1] - cmp r0, r1 - beq _08055324 -_0805530C: - adds r0, r3, 0 - adds r0, 0x8 - adds r0, r2, r0 - ldr r0, [r0] - cmp r0, 0 - beq _0805532A - adds r0, r2, r3 - ldr r1, =gBankTarget - ldrb r0, [r0, 0xD] - ldrb r1, [r1] - cmp r0, r1 - bne _0805532A -_08055324: - ldr r1, =gBattleScripting - movs r0, 0x2 - strb r0, [r1, 0xE] -_0805532A: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atkD6_doubledamagedealtifdamaged - - thumb_func_start atkD7_setyawn -atkD7_setyawn: @ 805534C - push {r4,lr} - ldr r1, =gStatuses3 - ldr r0, =gBankTarget - ldrb r3, [r0] - lsls r0, r3, 2 - adds r4, r0, r1 - ldr r2, [r4] - movs r0, 0xC0 - lsls r0, 5 - ands r0, r2 - cmp r0, 0 - bne _08055374 - ldr r1, =gBattleMons - movs r0, 0x58 - muls r0, r3 - adds r1, 0x4C - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _080553A0 -_08055374: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _080553B0 - .pool -_080553A0: - movs r0, 0x80 - lsls r0, 5 - orrs r2, r0 - str r2, [r4] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_080553B0: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkD7_setyawn - - thumb_func_start atkD8_setdamagetohealthdifference -atkD8_setdamagetohealthdifference: @ 80553BC - push {lr} - ldr r2, =gBattleMons - ldr r0, =gBankTarget - ldrb r0, [r0] - movs r1, 0x58 - muls r0, r1 - adds r3, r0, r2 - ldr r0, =gBankAttacker - ldrb r0, [r0] - muls r0, r1 - adds r1, r0, r2 - ldrh r0, [r3, 0x28] - ldrh r2, [r1, 0x28] - cmp r0, r2 - bhi _08055408 - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _0805541A - .pool -_08055408: - ldr r2, =gBattleMoveDamage - ldrh r0, [r3, 0x28] - ldrh r1, [r1, 0x28] - subs r0, r1 - str r0, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_0805541A: - pop {r0} - bx r0 - .pool - thumb_func_end atkD8_setdamagetohealthdifference - - thumb_func_start atkD9_scaledamagebyhealthratio -atkD9_scaledamagebyhealthratio: @ 8055428 - push {r4,lr} - ldr r4, =gDynamicBasePower - ldrh r0, [r4] - cmp r0, 0 - bne _08055464 - ldr r2, =gBattleMoves - ldr r0, =gCurrentMove - ldrh r1, [r0] - lsls r0, r1, 1 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r3, [r0, 0x1] - ldr r2, =gBattleMons - ldr r0, =gBankAttacker - ldrb r1, [r0] - movs r0, 0x58 - muls r1, r0 - adds r1, r2 - ldrh r0, [r1, 0x28] - muls r0, r3 - ldrh r1, [r1, 0x2C] - bl __divsi3 - strh r0, [r4] - lsls r0, 16 - cmp r0, 0 - bne _08055464 - movs r0, 0x1 - strh r0, [r4] -_08055464: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end atkD9_scaledamagebyhealthratio - - thumb_func_start atkDA_abilityswap -atkDA_abilityswap: @ 805548C - push {r4-r6,lr} - ldr r5, =gBattleMons - ldr r0, =gBankAttacker - ldrb r0, [r0] - movs r4, 0x58 - muls r0, r4 - adds r0, r5 - adds r2, r0, 0 - adds r2, 0x20 - ldrb r1, [r2] - cmp r1, 0 - bne _080554B4 - ldr r0, =gBankTarget - ldrb r0, [r0] - muls r0, r4 - adds r0, r5 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0 - beq _080554D4 -_080554B4: - cmp r1, 0x19 - beq _080554D4 - ldr r6, =gBankTarget - ldrb r0, [r6] - muls r0, r4 - adds r0, r5 - adds r0, 0x20 - ldrb r3, [r0] - cmp r3, 0x19 - beq _080554D4 - ldr r0, =gBattleMoveFlags - ldrb r1, [r0] - movs r0, 0x29 - ands r0, r1 - cmp r0, 0 - beq _08055504 -_080554D4: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _0805551A - .pool -_08055504: - ldrb r1, [r2] - strb r3, [r2] - ldrb r0, [r6] - muls r0, r4 - adds r0, r5 - adds r0, 0x20 - strb r1, [r0] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_0805551A: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atkDA_abilityswap - - thumb_func_start atkDB_imprisoneffect -atkDB_imprisoneffect: @ 8055524 - push {r4-r7,lr} - mov r7, r9 - mov r6, r8 - push {r6,r7} - ldr r1, =gStatuses3 - ldr r4, =gBankAttacker - ldrb r2, [r4] - lsls r0, r2, 2 - adds r0, r1 - ldr r0, [r0] - movs r1, 0x80 - lsls r1, 6 - ands r0, r1 - cmp r0, 0 - beq _08055574 - b _080555F6 - .pool -_0805554C: - ldr r0, =gStatuses3 - mov r2, r9 - ldrb r1, [r2] - lsls r1, 2 - adds r1, r0 - ldr r0, [r1] - movs r2, 0x80 - lsls r2, 6 - orrs r0, r2 - str r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _080555EE - .pool -_08055574: - adds r0, r2, 0 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - mov r8, r0 - ldrb r0, [r4] - bl sub_803F548 - movs r6, 0 - b _080555E6 -_0805558A: - adds r0, r6, 0 - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r8, r0 - beq _080555E0 - movs r4, 0 - ldr r7, =gBankAttacker - mov r9, r7 - ldr r0, =gBattleMons - mov r12, r0 - mov r1, r9 - ldrb r0, [r1] - mov r2, r12 - adds r2, 0xC - movs r1, 0x58 - muls r0, r1 - adds r3, r0, r2 - adds r5, r6, 0 - muls r5, r1 -_080555B4: - movs r2, 0 - ldrh r1, [r3] - mov r0, r12 - adds r0, 0xC - adds r0, r5, r0 -_080555BE: - ldrh r7, [r0] - cmp r1, r7 - bne _080555C8 - cmp r1, 0 - bne _080555D0 -_080555C8: - adds r0, 0x2 - adds r2, 0x1 - cmp r2, 0x3 - ble _080555BE -_080555D0: - cmp r2, 0x4 - bne _080555DC - adds r3, 0x2 - adds r4, 0x1 - cmp r4, 0x3 - ble _080555B4 -_080555DC: - cmp r4, 0x4 - bne _0805554C -_080555E0: - adds r0, r6, 0x1 - lsls r0, 24 - lsrs r6, r0, 24 -_080555E6: - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r6, r0 - bcc _0805558A -_080555EE: - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - cmp r6, r0 - bne _08055610 -_080555F6: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_08055610: - pop {r3,r4} - mov r8, r3 - mov r9, r4 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkDB_imprisoneffect - - thumb_func_start atkDC_setgrudge -atkDC_setgrudge: @ 805562C - push {lr} - ldr r1, =gStatuses3 - ldr r0, =gBankAttacker - ldrb r0, [r0] - lsls r0, 2 - adds r2, r0, r1 - ldr r1, [r2] - movs r3, 0x80 - lsls r3, 7 - adds r0, r1, 0 - ands r0, r3 - cmp r0, 0 - beq _08055670 - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _0805567C - .pool -_08055670: - orrs r1, r3 - str r1, [r2] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_0805567C: - pop {r0} - bx r0 - .pool - thumb_func_end atkDC_setgrudge - - thumb_func_start atkDD_weightdamagecalculation -atkDD_weightdamagecalculation: @ 8055684 - push {r4-r7,lr} - mov r7, r8 - push {r7} - movs r5, 0 - ldr r2, =gUnknown_0831C428 - ldrh r0, [r2] - ldr r1, =0x0000ffff - cmp r0, r1 - beq _080556FC - adds r6, r2, 0 - ldr r0, =gBattleMons - mov r8, r0 - adds r7, r1, 0 - adds r4, r6, 0 -_080556A0: - ldr r0, =gBankTarget - ldrb r1, [r0] - movs r0, 0x58 - muls r0, r1 - add r0, r8 - ldrh r0, [r0] - bl SpeciesToNationalPokedexNum - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x1 - bl GetPokedexHeightWeight - ldrh r1, [r4] - lsls r0, 16 - lsrs r0, 16 - cmp r1, r0 - bhi _080556CE - adds r4, 0x4 - adds r5, 0x2 - ldrh r0, [r4] - cmp r0, r7 - bne _080556A0 -_080556CE: - lsls r0, r5, 1 - adds r0, r6 - ldrh r1, [r0] - ldr r0, =0x0000ffff - cmp r1, r0 - beq _080556FC - ldr r0, =gDynamicBasePower - adds r1, r5, 0x1 - lsls r1, 1 - adds r1, r6 - ldrh r1, [r1] - strh r1, [r0] - b _08055702 - .pool -_080556FC: - ldr r1, =gDynamicBasePower - movs r0, 0x78 - strh r0, [r1] -_08055702: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r3} - mov r8, r3 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkDD_weightdamagecalculation - - thumb_func_start atkDE_asistattackselect -atkDE_asistattackselect: @ 805571C - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0xC - movs r0, 0 - mov r10, r0 - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0x18 - str r0, [sp, 0x4] - ldr r0, =gBankAttacker - ldrb r0, [r0] - bl GetBankIdentity - movs r1, 0x1 - ands r1, r0 - ldr r0, =gPlayerParty - str r0, [sp] - cmp r1, 0 - beq _0805574C - ldr r1, =gEnemyParty - str r1, [sp] -_0805574C: - movs r2, 0 -_0805574E: - ldr r1, =gBattlePartyID - ldr r0, =gBankAttacker - ldrb r0, [r0] - lsls r0, 1 - adds r0, r1 - adds r1, r2, 0x1 - str r1, [sp, 0x8] - ldrh r0, [r0] - cmp r2, r0 - beq _080557F4 - movs r0, 0x64 - adds r6, r2, 0 - muls r6, r0 - ldr r0, [sp] - adds r4, r0, r6 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - cmp r0, 0 - beq _080557F4 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - movs r1, 0xCE - lsls r1, 1 - cmp r0, r1 - beq _080557F4 - movs r5, 0 - ldr r1, =0x0000ffff - mov r8, r1 - mov r9, r6 - mov r1, r10 - lsls r0, r1, 1 - ldr r1, [sp, 0x4] - adds r6, r0, r1 -_08055798: - movs r7, 0 - adds r1, r5, 0 - adds r1, 0xD - ldr r0, [sp] - add r0, r9 - bl GetMonData - lsls r0, 16 - lsrs r4, r0, 16 - adds r0, r4, 0 - bl sub_8052F84 - lsls r0, 24 - adds r1, r5, 0x1 - cmp r0, 0 - bne _080557EE - ldr r0, =gMovesForbiddenToCopy - ldrh r2, [r0] - adds r3, r0, 0 - cmp r2, r8 - beq _080557E2 - cmp r4, r2 - beq _080557D8 - ldr r5, =0x0000ffff - adds r2, r3, 0 -_080557CA: - adds r2, 0x2 - adds r7, 0x1 - ldrh r0, [r2] - cmp r0, r5 - beq _080557E2 - cmp r4, r0 - bne _080557CA -_080557D8: - lsls r0, r7, 1 - adds r0, r3 - ldrh r0, [r0] - cmp r0, r8 - bne _080557EE -_080557E2: - cmp r4, 0 - beq _080557EE - strh r4, [r6] - adds r6, 0x2 - movs r0, 0x1 - add r10, r0 -_080557EE: - adds r5, r1, 0 - cmp r5, 0x3 - ble _08055798 -_080557F4: - ldr r2, [sp, 0x8] - cmp r2, 0x5 - ble _0805574E - mov r1, r10 - cmp r1, 0 - beq _0805586C - ldr r2, =gHitMarker - ldr r0, [r2] - ldr r1, =0xfffffbff - ands r0, r1 - str r0, [r2] - ldr r4, =gRandomMove - bl Random - movs r1, 0xFF - ands r1, r0 - mov r0, r10 - muls r0, r1 - asrs r0, 8 - lsls r0, 1 - ldr r1, [sp, 0x4] - adds r0, r1 - ldrh r0, [r0] - strh r0, [r4] - ldrh r0, [r4] - movs r1, 0 - bl GetMoveTarget - ldr r1, =gBankTarget - strb r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] - b _08055886 - .pool -_0805586C: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] -_08055886: - add sp, 0xC - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkDE_asistattackselect - - thumb_func_start atkDF_setmagiccoat -atkDF_setmagiccoat: @ 805589C - push {lr} - ldr r1, =gBankTarget - ldr r3, =gBankAttacker - ldrb r0, [r3] - strb r0, [r1] - ldr r2, =gSpecialStatuses - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x20 - orrs r1, r2 - strb r1, [r0] - ldr r0, =gCurrentMoveTurn - ldrb r1, [r0] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - subs r0, 0x1 - cmp r1, r0 - bne _080558FC - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _08055914 - .pool -_080558FC: - ldr r0, =gProtectStructs - ldrb r1, [r3] - lsls r1, 4 - adds r1, r0 - ldrb r0, [r1] - movs r2, 0x10 - orrs r0, r2 - strb r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_08055914: - pop {r0} - bx r0 - .pool - thumb_func_end atkDF_setmagiccoat - - thumb_func_start atkE0_setstealstatchange -atkE0_setstealstatchange: @ 8055920 - push {lr} - ldr r2, =gSpecialStatuses - ldr r3, =gBankAttacker - ldrb r1, [r3] - lsls r0, r1, 2 - adds r0, r1 - lsls r0, 2 - adds r0, r2 - ldrb r1, [r0] - movs r2, 0x20 - orrs r1, r2 - strb r1, [r0] - ldr r0, =gCurrentMoveTurn - ldrb r1, [r0] - ldr r0, =gNoOfAllBanks - ldrb r0, [r0] - subs r0, 0x1 - cmp r1, r0 - bne _08055978 - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _0805598E - .pool -_08055978: - ldr r0, =gProtectStructs - ldrb r1, [r3] - lsls r1, 4 - adds r1, r0 - ldrb r0, [r1] - orrs r0, r2 - strb r0, [r1] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_0805598E: - pop {r0} - bx r0 - .pool - thumb_func_end atkE0_setstealstatchange - - thumb_func_start atkE1_intimidate_string_loader -atkE1_intimidate_string_loader: @ 805599C - push {r4-r6,lr} - ldr r4, =gBattleScripting - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, 0xD8 - ldrb r0, [r0] - strb r0, [r4, 0x17] - ldrb r0, [r4, 0x17] - bl GetBankSide - lsls r0, 24 - lsrs r5, r0, 24 - ldr r2, =gBattleTextBuff1 - movs r0, 0xFD - strb r0, [r2] - movs r0, 0x9 - strb r0, [r2, 0x1] - ldr r3, =gBattleMons - ldrb r1, [r4, 0x17] - movs r0, 0x58 - muls r0, r1 - adds r0, r3 - adds r0, 0x20 - ldrb r0, [r0] - strb r0, [r2, 0x2] - movs r0, 0xFF - strb r0, [r2, 0x3] - ldr r2, =gBankTarget - ldr r1, =gNoOfAllBanks - ldrb r0, [r2] - ldrb r1, [r1] - cmp r0, r1 - bcs _08055A22 - adds r4, r2, 0 - ldr r6, =gBitTable -_080559E2: - ldrb r0, [r4] - bl GetBankSide - lsls r0, 24 - lsrs r0, 24 - cmp r0, r5 - beq _08055A04 - ldr r0, =gAbsentBankFlags - ldrb r1, [r0] - ldrb r0, [r4] - lsls r0, 2 - adds r0, r6 - ldr r0, [r0] - ands r1, r0 - ldr r2, =gNoOfAllBanks - cmp r1, 0 - beq _08055A18 -_08055A04: - ldrb r0, [r4] - adds r0, 0x1 - strb r0, [r4] - ldr r1, =gNoOfAllBanks - lsls r0, 24 - lsrs r0, 24 - adds r2, r1, 0 - ldrb r1, [r2] - cmp r0, r1 - bcc _080559E2 -_08055A18: - ldr r0, =gBankTarget - ldrb r0, [r0] - ldrb r2, [r2] - cmp r0, r2 - bcc _08055A64 -_08055A22: - ldr r3, =gBattlescriptCurrInstr - ldr r2, [r3] - ldrb r1, [r2, 0x1] - ldrb r0, [r2, 0x2] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x3] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 24 - orrs r1, r0 - str r1, [r3] - b _08055A6C - .pool -_08055A64: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x5 - str r0, [r1] -_08055A6C: - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atkE1_intimidate_string_loader - - thumb_func_start atkE2_switchout_abilities -atkE2_switchout_abilities: @ 8055A78 - push {r4-r6,lr} - sub sp, 0x4 - ldr r5, =gBattlescriptCurrInstr - ldr r0, [r5] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r4, =gActiveBank - strb r0, [r4] - ldr r3, =gBattleMons - ldrb r0, [r4] - movs r6, 0x58 - adds r1, r0, 0 - muls r1, r6 - adds r0, r1, r3 - adds r0, 0x20 - ldrb r0, [r0] - cmp r0, 0x1E - bne _08055AD2 - adds r3, 0x4C - adds r1, r3 - movs r0, 0 - str r0, [r1] - ldr r2, =gBitTable - ldrb r1, [r4] - ldr r0, =gBattleStruct - ldr r0, [r0] - adds r0, r1, r0 - adds r0, 0x58 - ldrb r0, [r0] - lsls r0, 2 - adds r0, r2 - ldrb r2, [r0] - adds r0, r1, 0 - muls r0, r6 - adds r0, r3 - str r0, [sp] - movs r0, 0 - movs r1, 0x28 - movs r3, 0x4 - bl EmitSetMonData - ldrb r0, [r4] - bl MarkBufferBankForExecution -_08055AD2: - ldr r0, [r5] - adds r0, 0x2 - str r0, [r5] - add sp, 0x4 - pop {r4-r6} - pop {r0} - bx r0 - .pool - thumb_func_end atkE2_switchout_abilities - - thumb_func_start atkE3_jumpiffainted -atkE3_jumpiffainted: @ 8055AF4 - push {r4,lr} - ldr r4, =gBattlescriptCurrInstr - ldr r0, [r4] - ldrb r0, [r0, 0x1] - bl GetBattleBank - ldr r1, =gActiveBank - strb r0, [r1] - ldr r2, =gBattleMons - ldrb r1, [r1] - movs r0, 0x58 - muls r0, r1 - adds r0, r2 - ldrh r0, [r0, 0x28] - cmp r0, 0 - bne _08055B3C - ldr r2, [r4] - ldrb r1, [r2, 0x2] - ldrb r0, [r2, 0x3] - lsls r0, 8 - orrs r1, r0 - ldrb r0, [r2, 0x4] - lsls r0, 16 - orrs r1, r0 - ldrb r0, [r2, 0x5] - lsls r0, 24 - orrs r1, r0 - str r1, [r4] - b _08055B42 - .pool -_08055B3C: - ldr r0, [r4] - adds r0, 0x6 - str r0, [r4] -_08055B42: - pop {r4} - pop {r0} - bx r0 - thumb_func_end atkE3_jumpiffainted - - thumb_func_start atkE4_getsecretpowereffect -atkE4_getsecretpowereffect: @ 8055B48 - push {lr} - ldr r0, =gUnknown_02022FF0 - ldrb r0, [r0] - cmp r0, 0x7 - bhi _08055BE4 - lsls r0, 2 - ldr r1, =_08055B64 - adds r0, r1 - ldr r0, [r0] - mov pc, r0 - .pool - .align 2, 0 -_08055B64: - .4byte _08055B84 - .4byte _08055B90 - .4byte _08055B9C - .4byte _08055BA8 - .4byte _08055BB4 - .4byte _08055BC0 - .4byte _08055BCC - .4byte _08055BD8 -_08055B84: - ldr r1, =gBattleCommunication - movs r0, 0x2 - b _08055BE8 - .pool -_08055B90: - ldr r1, =gBattleCommunication - movs r0, 0x1 - b _08055BE8 - .pool -_08055B9C: - ldr r1, =gBattleCommunication - movs r0, 0x1B - b _08055BE8 - .pool -_08055BA8: - ldr r1, =gBattleCommunication - movs r0, 0x17 - b _08055BE8 - .pool -_08055BB4: - ldr r1, =gBattleCommunication - movs r0, 0x16 - b _08055BE8 - .pool -_08055BC0: - ldr r1, =gBattleCommunication - movs r0, 0x18 - b _08055BE8 - .pool -_08055BCC: - ldr r1, =gBattleCommunication - movs r0, 0x7 - b _08055BE8 - .pool -_08055BD8: - ldr r1, =gBattleCommunication - movs r0, 0x8 - b _08055BE8 - .pool -_08055BE4: - ldr r1, =gBattleCommunication - movs r0, 0x5 -_08055BE8: - strb r0, [r1, 0x3] - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - pop {r0} - bx r0 - .pool - thumb_func_end atkE4_getsecretpowereffect - - thumb_func_start atkE5_pickup -atkE5_pickup: @ 8055C00 - push {r4-r7,lr} - mov r7, r10 - mov r6, r9 - mov r5, r8 - push {r5-r7} - sub sp, 0x4 - bl InBattlePike - lsls r0, 24 - cmp r0, 0 - beq _08055C18 - b _08055DD8 -_08055C18: - bl InBattlePyramid - lsls r0, 24 - cmp r0, 0 - beq _08055CC4 - movs r6, 0 - mov r7, sp - ldr r0, =gBaseStats - mov r8, r0 -_08055C2A: - movs r0, 0x64 - adds r4, r6, 0 - muls r4, r0 - ldr r0, =gPlayerParty - adds r4, r0 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r4, 0 - movs r1, 0xC - bl GetMonData - strh r0, [r7] - adds r0, r4, 0 - movs r1, 0x2E - bl GetMonData - cmp r0, 0 - beq _08055C6C - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - add r0, r8 - ldrb r0, [r0, 0x17] - b _08055C76 - .pool -_08055C6C: - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - add r0, r8 - ldrb r0, [r0, 0x16] -_08055C76: - cmp r0, 0x35 - bne _08055CB6 - cmp r5, 0 - beq _08055CB6 - movs r0, 0xCE - lsls r0, 1 - cmp r5, r0 - beq _08055CB6 - ldrh r0, [r7] - cmp r0, 0 - bne _08055CB6 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xA - bl __umodsi3 - lsls r0, 16 - cmp r0, 0 - bne _08055CB6 - bl CalculateBattlePyramidPickupItemId - strh r0, [r7] - movs r0, 0x64 - muls r0, r6 - ldr r1, =gPlayerParty - adds r0, r1 - movs r1, 0xC - mov r2, sp - bl SetMonData -_08055CB6: - adds r6, 0x1 - cmp r6, 0x5 - ble _08055C2A - b _08055DD8 - .pool -_08055CC4: - movs r6, 0 - movs r1, 0x64 - mov r8, r1 - ldr r7, =gPlayerParty - mov r10, sp -_08055CCE: - mov r4, r8 - muls r4, r6 - adds r4, r7 - adds r0, r4, 0 - movs r1, 0x41 - bl GetMonData - lsls r0, 16 - lsrs r5, r0, 16 - adds r0, r4, 0 - movs r1, 0xC - bl GetMonData - mov r1, r10 - strh r0, [r1] - adds r0, r4, 0 - movs r1, 0x2E - bl GetMonData - cmp r0, 0 - beq _08055D30 - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - ldr r1, =gBaseStats - adds r0, r1 - ldrb r0, [r0, 0x17] - b _08055D3C - .pool -_08055D10: - mov r0, r8 - muls r0, r6 - adds r0, r7 - adds r2, r1, 0 - adds r2, 0x63 - subs r2, r4 - lsls r2, 1 - ldr r1, =gRarePickupItems - adds r2, r1 - movs r1, 0xC - bl SetMonData - b _08055DD0 - .pool -_08055D30: - lsls r0, r5, 3 - subs r0, r5 - lsls r0, 2 - ldr r1, =gBaseStats - adds r0, r1 - ldrb r0, [r0, 0x16] -_08055D3C: - adds r1, r6, 0x1 - mov r9, r1 - cmp r0, 0x35 - bne _08055DD0 - cmp r5, 0 - beq _08055DD0 - movs r0, 0xCE - lsls r0, 1 - cmp r5, r0 - beq _08055DD0 - mov r1, r10 - ldrh r0, [r1] - cmp r0, 0 - bne _08055DD0 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0xA - bl __umodsi3 - lsls r0, 16 - cmp r0, 0 - bne _08055DD0 - bl Random - lsls r0, 16 - lsrs r0, 16 - movs r1, 0x64 - bl __umodsi3 - lsls r0, 16 - lsrs r4, r0, 16 - mov r0, r8 - muls r0, r6 - adds r0, r7 - movs r1, 0x38 - bl GetMonData - subs r0, 0x1 - movs r1, 0xA - bl __udivsi3 - lsls r0, 24 - lsrs r1, r0, 24 - cmp r1, 0x9 - bls _08055D9C - movs r1, 0x9 -_08055D9C: - movs r2, 0 - b _08055DAE - .pool -_08055DA4: - adds r0, r4, 0 - subs r0, 0x62 - cmp r0, 0x1 - bls _08055D10 - adds r2, 0x1 -_08055DAE: - cmp r2, 0x8 - bgt _08055DD0 - ldr r0, =gPickupProbabilities - adds r0, r2, r0 - ldrb r0, [r0] - cmp r0, r4 - ble _08055DA4 - mov r0, r8 - muls r0, r6 - adds r0, r7 - adds r2, r1, r2 - lsls r2, 1 - ldr r1, =gPickupItems - adds r2, r1 - movs r1, 0xC - bl SetMonData -_08055DD0: - mov r6, r9 - cmp r6, 0x5 - bgt _08055DD8 - b _08055CCE -_08055DD8: - ldr r1, =gBattlescriptCurrInstr - ldr r0, [r1] - adds r0, 0x1 - str r0, [r1] - add sp, 0x4 - pop {r3-r5} - mov r8, r3 - mov r9, r4 - mov r10, r5 - pop {r4-r7} - pop {r0} - bx r0 - .pool - thumb_func_end atkE5_pickup - thumb_func_start atkE6_castform_change_animation atkE6_castform_change_animation: @ 8055DFC push {r4,lr} @@ -5757,7 +340,7 @@ atkEB_settypetoterrain: @ 80560BC adds r0, r3 mov r12, r0 ldr r5, =sTerrainToType - ldr r4, =gUnknown_02022FF0 + ldr r4, =gBattleTerrain ldrb r0, [r4] adds r0, r5 ldrb r2, [r0] @@ -5851,7 +434,7 @@ atkEC_pursuit_sth: @ 805616C ands r1, r0 cmp r1, 0 bne _0805620C - ldr r0, =gUnknown_0202421C + ldr r0, =gActionForBanks adds r0, r3, r0 ldrb r0, [r0] cmp r0, 0 diff --git a/asm/battle_anim_80FE840.s b/asm/battle_anim_80FE840.s index 78abd6a85..c6761bd9a 100644 --- a/asm/battle_anim_80FE840.s +++ b/asm/battle_anim_80FE840.s @@ -47348,7 +47348,7 @@ sub_811675C: @ 811675C ldrsh r0, [r0, r1] bl sub_811583C adds r2, r0, 0 - ldr r0, =gUnknown_02022FF0 + ldr r0, =gBattleTerrain ldrb r0, [r0] cmp r0, 0x9 bhi _08116832 @@ -49759,7 +49759,7 @@ sub_8117C24: @ 8117C24 lsls r0, 24 lsrs r0, 24 ldr r2, =gBattleAnimArgs - ldr r1, =gUnknown_02022FF0 + ldr r1, =gBattleTerrain ldrb r1, [r1] strh r1, [r2] bl move_anim_task_del diff --git a/asm/battle_frontier_2.s b/asm/battle_frontier_2.s index 2e48fdd72..36898e456 100755 --- a/asm/battle_frontier_2.s +++ b/asm/battle_frontier_2.s @@ -31263,8 +31263,8 @@ _081AAA9E: .pool thumb_func_end sub_81AAA7C - thumb_func_start CalculateBattlePyramidPickupItemId -CalculateBattlePyramidPickupItemId: @ 81AAAE0 + thumb_func_start GetBattlePyramidPickupItemId +GetBattlePyramidPickupItemId: @ 81AAAE0 push {r4-r6,lr} ldr r0, =gSaveBlock2Ptr ldr r1, [r0] @@ -31331,6 +31331,6 @@ _081AAB5A: pop {r1} bx r1 .pool - thumb_func_end CalculateBattlePyramidPickupItemId + thumb_func_end GetBattlePyramidPickupItemId .align 2, 0 @ Don't pad with nop. diff --git a/asm/battle_interface.s b/asm/battle_interface.s index 489366fe8..31ad9a330 100755 --- a/asm/battle_interface.s +++ b/asm/battle_interface.s @@ -5476,8 +5476,8 @@ _08075028: bx r1 thumb_func_end sub_8074FE8 - thumb_func_start sub_8075034 -sub_8075034: @ 8075034 + thumb_func_start GetScaledHPFraction +GetScaledHPFraction: @ 8075034 push {r4,lr} lsls r2, 24 lsrs r2, 24 @@ -5499,7 +5499,7 @@ _08075058: pop {r4} pop {r1} bx r1 - thumb_func_end sub_8075034 + thumb_func_end GetScaledHPFraction thumb_func_start sub_8075060 sub_8075060: @ 8075060 @@ -5514,7 +5514,7 @@ sub_8075060: @ 8075060 b _0807508E _08075072: movs r2, 0x30 - bl sub_8075034 + bl GetScaledHPFraction lsls r0, 24 lsrs r1, r0, 24 movs r0, 0x3 diff --git a/asm/evolution_scene.s b/asm/evolution_scene.s index f96a7355a..55a843b92 100644 --- a/asm/evolution_scene.s +++ b/asm/evolution_scene.s @@ -186,7 +186,7 @@ evolution_cutscene: @ 813DA8C ldr r0, =gUnknown_02022E22 movs r1, 0 strh r1, [r0] - ldr r1, =gUnknown_02022FF0 + ldr r1, =gBattleTerrain movs r0, 0x9 strb r0, [r1] bl c2_berry_program_update_menu @@ -479,7 +479,7 @@ sub_813DD7C: @ 813DD7C strh r0, [r1] ldr r0, =gUnknown_02022E22 strh r4, [r0] - ldr r1, =gUnknown_02022FF0 + ldr r1, =gBattleTerrain movs r0, 0x9 strb r0, [r1] bl c2_berry_program_update_menu diff --git a/asm/party_menu.s b/asm/party_menu.s index 2b320f86e..4eb080b13 100755 --- a/asm/party_menu.s +++ b/asm/party_menu.s @@ -5495,7 +5495,7 @@ _081B2F04: asrs r1, 16 ldr r2, [r6] ldrb r2, [r2, 0x1A] - bl sub_8075034 + bl GetScaledHPFraction lsls r0, 24 lsrs r5, r0, 24 ldrb r0, [r6, 0x8] diff --git a/data/battle_4.s b/data/battle_4.s index 8f1872733..0b8bd6e7e 100644 --- a/data/battle_4.s +++ b/data/battle_4.s @@ -43,18 +43,18 @@ gMovesForbiddenToCopy:: @ 831C3E0 .2byte MOVE_COVET, MOVE_TRICK, MOVE_FOCUS_PUNCH, 0xffff .align 2 -gUnknown_0831C408:: @ 831C408 +sFlailHpScaleToPowerTable:: @ 831C408 .byte 0x01, 0xc8, 0x04, 0x96, 0x09, 0x64, 0x10, 0x50 .byte 0x20, 0x28, 0x30, 0x14 .align 2 -gUnknown_0831C414:: @ 831C414 +sNaturePowerMoves:: @ 831C414 .2byte 0x004e, 0x004b, 0x0059, 0x0038 .2byte 0x0039, 0x003d, 0x009d, 0x00f7 .2byte 0x0081, 0x0081 .align 2 -gUnknown_0831C428:: @ 831C428 +sWeightToDamageTable:: @ 831C428 .2byte 0x0064, 0x0014, 0x00fa, 0x0028 .2byte 0x01f4, 0x003c, 0x03e8, 0x0050 .2byte 0x07d0, 0x0064, 0xffff, 0xffff diff --git a/data/battle_scripts_1.s b/data/battle_scripts_1.s index 1fb6b8189..206519f40 100644 --- a/data/battle_scripts_1.s +++ b/data/battle_scripts_1.s @@ -6,13 +6,13 @@ gBattleScriptsForMoveEffects:: @ 82D86A8 .incbin "baserom.gba", 0x2d86a8, 0x388 -gUnknown_082D8A30:: @ 82D8A30 +BattleScript_PresentDamageTarget:: @ 82D8A30 .incbin "baserom.gba", 0x2d8a30, 0x1e BattleScript_MoveEnd:: @ 82D8A4E .incbin "baserom.gba", 0x2d8a4e, 0x12 -gUnknown_082D8A60:: @ 82D8A60 +BattleScript_PauseEffectivenessSoundResultMsgEndMove:: @ 82D8A60 .incbin "baserom.gba", 0x2d8a60, 0x274 BattleScript_StatUp:: @ 82D8CD4 @@ -24,10 +24,10 @@ BattleScript_StatDown:: @ 82D8D65 BattleScript_MoveUsedMustRecharge:: @ 82D9462 .incbin "baserom.gba", 0x2d9462, 0xa7f -gUnknown_082D9EE1:: @ 82D9EE1 +BattleScript_PresentHealTarget:: @ 82D9EE1 .incbin "baserom.gba", 0x2d9ee1, 0x1a -gUnknown_082D9EFB:: @ 82D9EFB +BattleScript_AlreadyAtFullHp:: @ 82D9EFB .incbin "baserom.gba", 0x2d9efb, 0x21 BattleScript_ButItFailed:: @ 82D9F1C @@ -180,13 +180,13 @@ BattleScript_AllStatsUp:: @ 82DAF27 BattleScript_RapidSpinAway:: @ 82DAFC3 .incbin "baserom.gba", 0x2dafc3, 0x2 -gUnknown_082DAFC5:: @ 82DAFC5 +BattleScript_WrapFree:: @ 82DAFC5 .incbin "baserom.gba", 0x2dafc5, 0x11 -gUnknown_082DAFD6:: @ 82DAFD6 +BattleScript_LeechSeedFree:: @ 82DAFD6 .incbin "baserom.gba", 0x2dafd6, 0x7 -gUnknown_082DAFDD:: @ 82DAFDD +BattleScript_SpikesFree:: @ 82DAFDD .incbin "baserom.gba", 0x2dafdd, 0x7 gUnknown_082DAFE4:: @ 82DAFE4 @@ -444,7 +444,7 @@ BattleScript_SoundproofProtected:: @ 82DB61F BattleScript_AbilityNoSpecificStatLoss:: @ 82DB62F .incbin "baserom.gba", 0x2db62f, 0x10 -BattleScript_StickyHoldOnKnockOff:: @ 82DB63F +BattleScript_StickyHoldActivates:: @ 82DB63F .incbin "baserom.gba", 0x2db63f, 0xe BattleScript_ColorChangeActivates:: @ 82DB64D diff --git a/include/battle.h b/include/battle.h index f84a75cba..a0a50faf7 100644 --- a/include/battle.h +++ b/include/battle.h @@ -112,7 +112,7 @@ #define STATUS3_ROOTED 0x400 #define STATUS3_CHARGED_UP 0x200 #define STATUS3_YAWN 0x1800 //two bits -#define STATUS3_IMPRISIONED 0x2000 +#define STATUS3_IMPRISONED_OTHERS 0x2000 #define STATUS3_GRUDGE 0x4000 #define STATUS3_CANT_SCORE_A_CRIT 0x8000 #define STATUS3_MUDSPORT 0x10000 @@ -172,7 +172,7 @@ #define ABILITYEFFECT_CHECK_BANK_SIDE 0xD #define ABILITYEFFECT_FIELD_SPORT 0xE #define ABILITYEFFECT_CHECK_FIELD_EXCEPT_BANK 0xF -#define ABILITYEFFECT_COUNT_OTHER_SIZE 0x10 +#define ABILITYEFFECT_COUNT_OTHER_SIDE 0x10 #define ABILITYEFFECT_COUNT_BANK_SIDE 0x11 #define ABILITYEFFECT_COUNT_ON_FIELD 0x12 #define ABILITYEFFECT_CHECK_ON_FIELD 0x13 @@ -206,6 +206,15 @@ #define WEATHER_HAIL (1 << 7) #define WEATHER_HAIL_ANY ((WEATHER_HAIL)) +#define BATTLE_TERRAIN_GRASS 0 +#define BATTLE_TERRAIN_LONG_GRASS 1 +#define BATTLE_TERRAIN_SAND 2 +#define BATTLE_TERRAIN_UNDERWATER 3 +#define BATTLE_TERRAIN_WATER 4 +#define BATTLE_TERRAIN_POND 5 +#define BATTLE_TERRAIN_ROCK 6 +#define BATTLE_TERRAIN_CAVE 7 + // array entries for battle communication #define CURSOR_POSITION 0x1 #define MOVE_EFFECT_BYTE 0x3 @@ -554,46 +563,7 @@ struct BattleStruct u8 wildVictorySong; u8 dynamicMoveType; u8 wrappedBy[4]; - u8 field_18; - u8 field_19; - u8 field_1A; - u8 field_1B; - u8 field_1C; - u8 field_1D; - u8 field_1E; - u8 field_1F; - u8 field_20; - u8 field_21; - u8 field_22; - u8 field_23; - u8 field_24; - u8 field_25; - u8 field_26; - u8 field_27; - u8 field_28; - u8 field_29; - u8 field_2A; - u8 field_2B; - u8 field_2C; - u8 field_2D; - u8 field_2E; - u8 field_2F; - u8 field_30; - u8 field_31; - u8 field_32; - u8 field_33; - u8 field_34; - u8 field_35; - u8 field_36; - u8 field_37; - u8 field_38; - u8 field_39; - u8 field_3A; - u8 field_3B; - u8 field_3C; - u8 field_3D; - u8 field_3E; - u8 field_3F; + u16 assistPossibleMoves[5 * 4]; // 5 mons, each of them knowing 4 moves u8 field_40; u8 field_41; u8 field_42; @@ -710,28 +680,6 @@ extern struct BattleStruct* gBattleStruct; var2[offsetof(struct structName, offsetField)] = value; \ } -// This is a leftover from R/S direct use of ewram addresses -#define GET_CHANGED_ITEM_PTR_VIA_MEME_ACCESS(bank, varName) \ -{ \ - void** memes1 = (void**)(&gBattleStruct); \ - void* memes2 = (void*)((u32)(bank * 2 + offsetof(struct BattleStruct, changedItems))); \ - varName = (u16*)(((void*)(*memes1) + (u32)(memes2))); \ -} - -#define GET_USED_ITEM_PTR_VIA_MEME_ACCESS(bank, varName) \ -{ \ - void** memes1 = (void**)(&gBattleStruct); \ - void* memes2 = (void*)((u32)(bank * 2 + offsetof(struct BattleStruct, usedHeldItems))); \ - varName = (u16*)(((void*)(*memes1) + (u32)(memes2))); \ -} - -#define GET_HP_SWITCHOUT_PTR_VIA_MEME_ACCESS(bank, varName) \ -{ \ - void** memes1 = (void**)(&gBattleStruct); \ - void* memes2 = (void*)((u32)(bank * 2 + offsetof(struct BattleStruct, hpOnSwitchout))); \ - varName = (u16*)(((void*)(*memes1) + (u32)(memes2))); \ -} - #define GET_MOVE_TYPE(move, typeArg) \ { \ if (gBattleStruct->dynamicMoveType) \ @@ -917,15 +865,24 @@ void BattleMainCB2(void); void ResetSentPokesToOpponentValue(void); bool8 CanRunFromBattle(u8 bank); bool8 IsRunningFromBattleImpossible(void); +void PressurePPLoseOnUsingPerishSong(u8 bankAtk); +void PressurePPLoseOnUsingImprision(u8 bankAtk); // battle_3 +#define MOVE_LIMITATION_ZEROMOVE (1 << 0) +#define MOVE_LIMITATION_PP (1 << 1) +#define MOVE_LIMITATION_DISABLED (1 << 2) +#define MOVE_LIMITATION_TORMENTED (1 << 3) +#define MOVE_LIMITATION_TAUNT (1 << 4) +#define MOVE_LIMITATION_IMPRISION (1 << 5) + void BattleScriptPush(const u8* bsPtr); void BattleScriptPushCursor(void); void BattleScriptPop(void); u8 sub_803FB4C(void); // msg, can't select a move u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check); bool8 AreAllMovesUnusable(void); -u8 IsImprisoned(u8 bank, u16 move); +u8 GetImprisonedMovesCount(u8 bank, u16 move); u8 UpdateTurnCounters(void); u8 TurnBasedEffects(void); bool8 sub_8041364(void); diff --git a/include/battle_message.h b/include/battle_message.h index 3e28fa5e5..6e6616cf0 100644 --- a/include/battle_message.h +++ b/include/battle_message.h @@ -82,6 +82,14 @@ textVar[3] = B_BUFF_EOS; \ } +#define PREPARE_ABILITY_BUFFER(textVar, abilityId) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_ABILITY; \ + textVar[2] = abilityId; \ + textVar[3] = B_BUFF_EOS; \ +} + #define PREPARE_TYPE_BUFFER(textVar, typeId) \ { \ textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ @@ -142,6 +150,15 @@ textVar[4] = B_BUFF_EOS; \ } +#define PREPARE_ITEM_BUFFER(textVar, item) \ +{ \ + textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ + textVar[1] = B_BUFF_ITEM; \ + textVar[2] = item; \ + textVar[3] = (item & 0xFF00) >> 8; \ + textVar[4] = B_BUFF_EOS; \ +} + #define PREPARE_SPECIES_BUFFER(textVar, species) \ { \ textVar[0] = B_BUFF_PLACEHOLDER_BEGIN; \ diff --git a/include/mail.h b/include/mail.h new file mode 100644 index 000000000..16ca1f676 --- /dev/null +++ b/include/mail.h @@ -0,0 +1,19 @@ +#ifndef GUARD_MAIL_H +#define GUARD_MAIL_H + +#include "items.h" + +#define IS_ITEM_MAIL(itemId)((itemId == ITEM_ORANGE_MAIL \ + || itemId == ITEM_HARBOR_MAIL \ + || itemId == ITEM_GLITTER_MAIL \ + || itemId == ITEM_MECH_MAIL \ + || itemId == ITEM_WOOD_MAIL \ + || itemId == ITEM_WAVE_MAIL \ + || itemId == ITEM_BEAD_MAIL \ + || itemId == ITEM_SHADOW_MAIL \ + || itemId == ITEM_TROPIC_MAIL \ + || itemId == ITEM_DREAM_MAIL \ + || itemId == ITEM_FAB_MAIL \ + || itemId == ITEM_RETRO_MAIL)) + +#endif // GUARD_MAIL_H diff --git a/src/battle_3.c b/src/battle_3.c index 1fd84a61b..9ac439390 100644 --- a/src/battle_3.c +++ b/src/battle_3.c @@ -261,7 +261,7 @@ u8 sub_803FB4C(void) // msg, can't select a move } } - if (IsImprisoned(gActiveBank, move)) + if (GetImprisonedMovesCount(gActiveBank, move)) { gCurrentMove = move; if (gBattleTypeFlags & BATTLE_TYPE_PALACE) @@ -314,13 +314,6 @@ u8 sub_803FB4C(void) // msg, can't select a move return limitations; } -#define MOVE_LIMITATION_ZEROMOVE (1 << 0) -#define MOVE_LIMITATION_PP (1 << 1) -#define MOVE_LIMITATION_DISABLED (1 << 2) -#define MOVE_LIMITATION_TORMENTED (1 << 3) -#define MOVE_LIMITATION_TAUNT (1 << 4) -#define MOVE_LIMITATION_IMPRISION (1 << 5) - u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check) { u8 holdEffect; @@ -346,7 +339,7 @@ u8 CheckMoveLimitations(u8 bank, u8 unusableMoves, u8 check) unusableMoves |= gBitTable[i]; if (gDisableStructs[bank].tauntTimer1 && check & MOVE_LIMITATION_TAUNT && gBattleMoves[gBattleMons[bank].moves[i]].power == 0) unusableMoves |= gBitTable[i]; - if (IsImprisoned(bank, gBattleMons[bank].moves[i]) && check & MOVE_LIMITATION_IMPRISION) + if (GetImprisonedMovesCount(bank, gBattleMons[bank].moves[i]) && check & MOVE_LIMITATION_IMPRISION) unusableMoves |= gBitTable[i]; if (gDisableStructs[bank].encoreTimer1 && gDisableStructs[bank].encoredMove != gBattleMons[bank].moves[i]) unusableMoves |= gBitTable[i]; @@ -374,7 +367,7 @@ bool8 AreAllMovesUnusable(void) return (unusable == 0xF); } -u8 IsImprisoned(u8 bank, u16 move) +u8 GetImprisonedMovesCount(u8 bank, u16 move) { s32 i; u8 imprisionedMoves = 0; @@ -382,7 +375,7 @@ u8 IsImprisoned(u8 bank, u16 move) for (i = 0; i < gNoOfAllBanks; i++) { - if (bankSide != GetBankSide(i) && gStatuses3[i] & STATUS3_IMPRISIONED) + if (bankSide != GetBankSide(i) && gStatuses3[i] & STATUS3_IMPRISONED_OTHERS) { s32 j; for (j = 0; j < 4; j++) @@ -1327,7 +1320,7 @@ u8 AtkCanceller_UnableToUseMove(void) gBattleStruct->atkCancellerTracker++; break; case 8: // imprisoned - if (IsImprisoned(gBankAttacker, gCurrentMove)) + if (GetImprisonedMovesCount(gBankAttacker, gCurrentMove)) { gProtectStructs[gBankAttacker].usedImprisionedMove = 1; CancelMultiTurnMoves(gBankAttacker); @@ -2379,7 +2372,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 bank, u8 ability, u8 special, u16 moveArg) } } break; - case ABILITYEFFECT_COUNT_OTHER_SIZE: // 16 + case ABILITYEFFECT_COUNT_OTHER_SIDE: // 16 side = GetBankSide(bank); for (i = 0; i < gNoOfAllBanks; i++) { @@ -6238,7 +6231,7 @@ u8 GetMoveTarget(u16 move, u8 useMoveTarget) targetBank = Random() % gNoOfAllBanks; } while (targetBank == gBankAttacker || side == GetBankSide(targetBank) || gAbsentBankFlags & gBitTable[targetBank]); if (gBattleMoves[move].type == TYPE_ELECTRIC - && AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIZE, gBankAttacker, ABILITY_LIGHTNING_ROD, 0, 0) + && AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBankAttacker, ABILITY_LIGHTNING_ROD, 0, 0) && gBattleMons[targetBank].ability != ABILITY_LIGHTNING_ROD) { targetBank ^= 2; diff --git a/src/battle_4.c b/src/battle_4.c index 0f52ee0dd..9ef443b70 100644 --- a/src/battle_4.c +++ b/src/battle_4.c @@ -29,6 +29,7 @@ #include "pokemon_icon.h" #include "pokemon_item_effects.h" #include "m4a.h" +#include "mail.h" // variables @@ -96,6 +97,7 @@ extern u16 gUnknownMovesUsedByBanks[BATTLE_BANKS_COUNT]; extern u16 gLastUsedMovesByBanks[BATTLE_BANKS_COUNT]; extern u16 gTrainerBattleOpponent_A; extern u16 gTrainerBattleOpponent_B; +extern u8 gUnknown_020241E9; extern struct MusicPlayerInfo gMPlay_BGM; struct TrainerMoney @@ -127,6 +129,7 @@ extern void sub_81A5BF8(void); // battle frontier 2 extern void sub_81A5D44(void); // battle frontier 2 extern void sub_81B8E80(u8 bank, u8, u8); // party menu extern bool8 sub_81B1250(void); // ? +extern u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale); // battle interface // BattleScripts extern const u8 BattleScript_MoveEnd[]; @@ -150,7 +153,7 @@ extern const u8 BattleScript_ItemSteal[]; extern const u8 BattleScript_RapidSpinAway[]; extern const u8 BattleScript_TargetPRLZHeal[]; extern const u8 BattleScript_KnockedOff[]; -extern const u8 BattleScript_StickyHoldOnKnockOff[]; +extern const u8 BattleScript_StickyHoldActivates[]; extern const u8 BattleScript_AllStatsUp[]; extern const u8 BattleScript_AtkDefDown[]; extern const u8 BattleScript_SAtkDown2[]; @@ -197,6 +200,7 @@ extern const u8 gUnknown_082DADD8[]; extern const u8 BattleScript_PrintPayDayMoneyString[]; extern const u8 BattleScript_SturdyPreventsOHKO[]; extern const u8 BattleScript_ObliviousPreventsAttraction[]; +extern const u8 BattleScript_PauseEffectivenessSoundResultMsgEndMove[]; // strings extern const u8 gText_BattleYesNoChoice[]; @@ -252,7 +256,7 @@ void atk11_printstring_playeronly(void); void atk12_waitmessage(void); void atk13_printfromtable(void); void atk14_printfromtable_playeronly(void); -void atk15_seteffectwithchancetarget(void); +void atk15_seteffectwithchance(void); void atk16_seteffectprimary(void); void atk17_seteffectsecondary(void); void atk18_status_effect_clear(void); @@ -421,15 +425,15 @@ void atkBA_jumpifnopursuitswitchdmg(void); void atkBB_setsunny(void); void atkBC_maxattackhalvehp(void); void atkBD_copyfoestats(void); -void atkBE_breakfree(void); +void atkBE_rapidspinfree(void); void atkBF_set_defense_curl(void); void atkC0_recoverbasedonsunlight(void); void atkC1_hidden_power(void); void atkC2_selectnexttarget(void); void atkC3_setfutureattack(void); void atkC4_beat_up(void); -void atkC5_hidepreattack(void); -void atkC6_unhidepostattack(void); +void atkC5_setsemiinvulnerablebit(void); +void atkC6_clearsemiinvulnerablebit(void); void atkC7_setminimize(void); void atkC8_sethail(void); void atkC9_jumpifattackandspecialattackcannotfall(void); @@ -458,7 +462,7 @@ void atkDF_setmagiccoat(void); void atkE0_setstealstatchange(void); void atkE1_intimidate_string_loader(void); void atkE2_switchout_abilities(void); -void atkE3_jumpiffainted(void); +void atkE3_jumpifhasnohp(void); void atkE4_getsecretpowereffect(void); void atkE5_pickup(void); void atkE6_castform_change_animation(void); @@ -504,7 +508,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atk12_waitmessage, atk13_printfromtable, atk14_printfromtable_playeronly, - atk15_seteffectwithchancetarget, + atk15_seteffectwithchance, atk16_seteffectprimary, atk17_seteffectsecondary, atk18_status_effect_clear, @@ -673,15 +677,15 @@ void (* const gBattleScriptingCommandsTable[])(void) = atkBB_setsunny, atkBC_maxattackhalvehp, atkBD_copyfoestats, - atkBE_breakfree, + atkBE_rapidspinfree, atkBF_set_defense_curl, atkC0_recoverbasedonsunlight, atkC1_hidden_power, atkC2_selectnexttarget, atkC3_setfutureattack, atkC4_beat_up, - atkC5_hidepreattack, - atkC6_unhidepostattack, + atkC5_setsemiinvulnerablebit, + atkC6_clearsemiinvulnerablebit, atkC7_setminimize, atkC8_sethail, atkC9_jumpifattackandspecialattackcannotfall, @@ -710,7 +714,7 @@ void (* const gBattleScriptingCommandsTable[])(void) = atkE0_setstealstatchange, atkE1_intimidate_string_loader, atkE2_switchout_abilities, - atkE3_jumpiffainted, + atkE3_jumpifhasnohp, atkE4_getsecretpowereffect, atkE5_pickup, atkE6_castform_change_animation, @@ -871,6 +875,8 @@ static const struct WindowTemplate sUnusedWinTemplate = {0, 1, 3, 7, 0xF, 0x1F, extern const struct SpriteTemplate SpriteTemplate_MonIconOnLvlUpBox; extern const u16 sProtectSuccessRates[]; +extern const u16 sNaturePowerMoves[]; +extern const u16 sWeightToDamageTable[]; void atk00_attackcanceler(void) { @@ -1163,7 +1169,7 @@ void atk02_attackstring(void) void atk03_ppreduce(void) { - s32 to_deduct = 1; + s32 ppToDeduct = 1; if (gBattleExecBuffer) return; @@ -1173,15 +1179,15 @@ void atk03_ppreduce(void) switch (gBattleMoves[gCurrentMove].target) { case MOVE_TARGET_FOES_AND_ALLY: - to_deduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_ON_FIELD, gBankAttacker, ABILITY_PRESSURE, 0, 0); + ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_ON_FIELD, gBankAttacker, ABILITY_PRESSURE, 0, 0); break; case MOVE_TARGET_BOTH: case MOVE_TARGET_OPPONENTS_FIELD: - to_deduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIZE, gBankAttacker, ABILITY_PRESSURE, 0, 0); + ppToDeduct += AbilityBattleEffects(ABILITYEFFECT_COUNT_OTHER_SIDE, gBankAttacker, ABILITY_PRESSURE, 0, 0); break; default: if (gBankAttacker != gBankTarget && gBattleMons[gBankTarget].ability == ABILITY_PRESSURE) - to_deduct++; + ppToDeduct++; break; } } @@ -1190,8 +1196,8 @@ void atk03_ppreduce(void) { gProtectStructs[gBankAttacker].notFirstStrike = 1; - if (gBattleMons[gBankAttacker].pp[gCurrMovePos] > to_deduct) - gBattleMons[gBankAttacker].pp[gCurrMovePos] -= to_deduct; + if (gBattleMons[gBankAttacker].pp[gCurrMovePos] > ppToDeduct) + gBattleMons[gBankAttacker].pp[gCurrMovePos] -= ppToDeduct; else gBattleMons[gBankAttacker].pp[gCurrMovePos] = 0; @@ -2126,10 +2132,10 @@ void atk13_printfromtable(void) { if (gBattleExecBuffer == 0) { - u16 *ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + const u16 *ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); ptr += gBattleCommunication[MULTISTRING_CHOOSER]; - PrepareStringBattle(*(u16*)ptr, gBankAttacker); + PrepareStringBattle(*ptr, gBankAttacker); gBattlescriptCurrInstr += 5; gBattleCommunication[MSG_DISPLAY] = 1; @@ -2140,11 +2146,11 @@ void atk14_printfromtable_playeronly(void) { if (gBattleExecBuffer == 0) { - u16 *ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + const u16 *ptr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); ptr += gBattleCommunication[MULTISTRING_CHOOSER]; gActiveBank = gBankAttacker; - EmitPrintStringPlayerOnly(0, *(u16*)ptr); + EmitPrintStringPlayerOnly(0, *ptr); MarkBufferBankForExecution(gActiveBank); gBattlescriptCurrInstr += 5; @@ -2729,23 +2735,17 @@ void SetMoveEffect(bool8 primary, u8 certain) gLastUsedAbility = gBattleMons[gBankTarget].ability; RecordAbilityBattle(gBankTarget, gLastUsedAbility); } - else if (gBattleMons[gBankAttacker].item + else if (gBattleMons[gBankAttacker].item != 0 || gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY - || (gBattleMons[gBankTarget].item > 0x78 && gBattleMons[gBankTarget].item < 0x85) + || IS_ITEM_MAIL(gBattleMons[gBankTarget].item) || gBattleMons[gBankTarget].item == 0) { gBattlescriptCurrInstr++; } else { - // This is a leftover from R/S direct use of ewram addresses - u16* changedItem; - GET_CHANGED_ITEM_PTR_VIA_MEME_ACCESS(gBankAttacker, changedItem); + u16* changedItem = &gBattleStruct->changedItems[gBankAttacker]; gLastUsedItem = *changedItem = gBattleMons[gBankTarget].item; - - // A sane representation of this would simply be: - // gLastUsedItem = gBattleStruct->changedItems[gBankAttacker] = gBattleMons[gBankTarget].item; - gBattleMons[gBankTarget].item = 0; gActiveBank = gBankAttacker; @@ -2833,7 +2833,7 @@ void SetMoveEffect(bool8 primary, u8 certain) else { gLastUsedAbility = ABILITY_STICKY_HOLD; - gBattlescriptCurrInstr = BattleScript_StickyHoldOnKnockOff; + gBattlescriptCurrInstr = BattleScript_StickyHoldActivates; RecordAbilityBattle(gEffectBank, ABILITY_STICKY_HOLD); } break; @@ -2868,7 +2868,7 @@ void SetMoveEffect(bool8 primary, u8 certain) gBattleCommunication[MOVE_EFFECT_BYTE] = 0; } -void atk15_seteffectwithchancetarget(void) +void atk15_seteffectwithchance(void) { u32 percentChance; @@ -3351,8 +3351,8 @@ void atk23_getexp(void) } else { - i = 0x149; - } + i = 0x149; + } // get exp getter bank if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE) @@ -4816,8 +4816,7 @@ void atk49_moveend(void) case 7: // changed held items for (i = 0; i < gNoOfAllBanks; i++) { - u16* changedItem; - GET_CHANGED_ITEM_PTR_VIA_MEME_ACCESS(i, changedItem); + u16* changedItem = &gBattleStruct->changedItems[i]; if (*changedItem != 0) { gBattleMons[i].item = *changedItem; @@ -5775,8 +5774,7 @@ void atk52_switch_in_effects(void) for (i = 0; i < gNoOfAllBanks; i++) { - u16* hpOnSwitchout; - GET_HP_SWITCHOUT_PTR_VIA_MEME_ACCESS(GetBankSide(i), hpOnSwitchout) + u16* hpOnSwitchout = &gBattleStruct->hpOnSwitchout[GetBankSide(i)]; *hpOnSwitchout = gBattleMons[i].hp; } @@ -6413,7 +6411,7 @@ void atk6A_removeitem(void) gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); - GET_USED_ITEM_PTR_VIA_MEME_ACCESS(gActiveBank, usedHeldItem) + usedHeldItem = &gBattleStruct->usedHeldItems[gActiveBank]; *usedHeldItem = gBattleMons[gActiveBank].item; gBattleMons[gActiveBank].item = 0; @@ -6653,7 +6651,7 @@ bool8 sub_804F344(void) return (gBattle_BG2_X != 0x1A0); } -#define MON_ICON_LVLUP_BOX_TAG 0xD75A +#define MON_ICON_LVLUP_BOX_TAG 0xD75A #define sDestroy data0 #define sSavedLvlUpBoxXPosition data1 @@ -8148,9 +8146,9 @@ void atk97_try_infatuation(void) || gBattleMons[gBankTarget].status2 & STATUS2_INFATUATION || GetGenderFromSpeciesAndPersonality(speciesAttacker, personalityAttacker) == MON_GENDERLESS || GetGenderFromSpeciesAndPersonality(speciesTarget, personalityTarget) == MON_GENDERLESS) - { - gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); - } + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } else { gBattleMons[gBankTarget].status2 |= STATUS2_INFATUATED_WITH(gBankAttacker); @@ -8296,8 +8294,9 @@ void atk9C_set_substitute(void) } extern const u16 gMovesForbiddenToCopy[]; -#define MIMIC_FORBIDDEN_END 0xFFFE -#define METRONOME_SLEEPTALK_FORBIDDEN_END 0xFFFF +#define MIMIC_FORBIDDEN_END 0xFFFE +#define METRONOME_FORBIDDEN_END 0xFFFF +#define ASSIST_FORBIDDEN_END 0xFFFF static bool8 IsMoveUncopyableByMimic(u16 move) { @@ -8368,11 +8367,11 @@ void atk9E_metronome(void) { if (*move == gCurrentMove) break; - if (*move == METRONOME_SLEEPTALK_FORBIDDEN_END) + if (*move == METRONOME_FORBIDDEN_END) break; } - if (*move == METRONOME_SLEEPTALK_FORBIDDEN_END) + if (*move == METRONOME_FORBIDDEN_END) break; } @@ -8974,3 +8973,1666 @@ void atkA8_copymovepermanently(void) // sketch } } +bool8 IsTwoTurnsMove(u16 move) +{ + if (gBattleMoves[move].effect == EFFECT_SKULL_BASH + || gBattleMoves[move].effect == EFFECT_RAZOR_WIND + || gBattleMoves[move].effect == EFFECT_SKY_ATTACK + || gBattleMoves[move].effect == EFFECT_SOLARBEAM + || gBattleMoves[move].effect == EFFECT_FLY + || gBattleMoves[move].effect == EFFECT_BIDE) + return TRUE; + else + return FALSE; +} + +static bool8 IsInvalidForSleepTalkOrAssist(u16 move) +{ + if (move == 0 || move == MOVE_SLEEP_TALK || move == MOVE_ASSIST + || move == MOVE_MIRROR_MOVE || move == MOVE_METRONOME) + return TRUE; + else + return FALSE; +} + +u8 AttacksThisTurn(u8 bank, u16 move) // Note: returns 1 if it's a charging turn, otherwise 2 +{ + // first argument is unused + if (gBattleMoves[move].effect == EFFECT_SOLARBEAM + && (gBattleWeather & WEATHER_SUN_ANY)) + return 2; + + if (gBattleMoves[move].effect == EFFECT_SKULL_BASH + || gBattleMoves[move].effect == EFFECT_RAZOR_WIND + || gBattleMoves[move].effect == EFFECT_SKY_ATTACK + || gBattleMoves[move].effect == EFFECT_SOLARBEAM + || gBattleMoves[move].effect == EFFECT_FLY + || gBattleMoves[move].effect == EFFECT_BIDE) + { + if ((gHitMarker & HITMARKER_x8000000)) + return 1; + } + return 2; +} + +void atkA9_sleeptalk_choose_move(void) +{ + s32 i; + u8 unusableMovesBits = 0; + + for (i = 0; i < 4; i++) + { + if (IsInvalidForSleepTalkOrAssist(gBattleMons[gBankAttacker].moves[i]) + || gBattleMons[gBankAttacker].moves[i] == MOVE_FOCUS_PUNCH + || gBattleMons[gBankAttacker].moves[i] == MOVE_UPROAR + || IsTwoTurnsMove(gBattleMons[gBankAttacker].moves[i])) + { + unusableMovesBits |= gBitTable[i]; + } + + } + + unusableMovesBits = CheckMoveLimitations(gBankAttacker, unusableMovesBits, ~(MOVE_LIMITATION_PP)); + if (unusableMovesBits == 0xF) // all 4 moves cannot be chosen + { + gBattlescriptCurrInstr += 5; + } + else // at least one move can be chosen + { + u32 movePosition; + + do + { + movePosition = Random() & 3; + } while ((gBitTable[movePosition] & unusableMovesBits)); + + gRandomMove = gBattleMons[gBankAttacker].moves[movePosition]; + gCurrMovePos = movePosition; + gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gBankTarget = GetMoveTarget(gRandomMove, 0); + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkAA_set_destinybond(void) +{ + gBattleMons[gBankAttacker].status2 |= STATUS2_DESTINY_BOND; + gBattlescriptCurrInstr++; +} + +void DestinyBondFlagUpdate(void) +{ + u8 sideAttacker = GetBankSide(gBankAttacker); + u8 sideTarget = GetBankSide(gBankTarget); + if (gBattleMons[gBankTarget].status2 & STATUS2_DESTINY_BOND + && sideAttacker != sideTarget + && !(gHitMarker & HITMARKER_GRUDGE)) + { + gHitMarker |= HITMARKER_DESTINYBOND; + } +} + +void atkAB_DestinyBondFlagUpdate(void) +{ + DestinyBondFlagUpdate(); + gBattlescriptCurrInstr++; +} + +extern const u8 sFlailHpScaleToPowerTable[12]; + +void atkAC_remaininghptopower(void) +{ + s32 i; + s32 hpFraction = GetScaledHPFraction(gBattleMons[gBankAttacker].hp, gBattleMons[gBankAttacker].maxHP, 48); + + for (i = 0; i < (s32) sizeof(sFlailHpScaleToPowerTable); i += 2) + { + if (hpFraction <= sFlailHpScaleToPowerTable[i]) + break; + } + + gDynamicBasePower = sFlailHpScaleToPowerTable[i + 1]; + gBattlescriptCurrInstr++; +} + +void atkAD_spite_ppreduce(void) +{ + if (gLastUsedMovesByBanks[gBankTarget] != 0 + && gLastUsedMovesByBanks[gBankTarget] != 0xFFFF) + { + s32 i; + + for (i = 0; i < 4; i++) + { + if (gLastUsedMovesByBanks[gBankTarget] == gBattleMons[gBankTarget].moves[i]) + break; + } + + if (i != 4 && gBattleMons[gBankTarget].pp[i] > 1) + { + s32 ppToDeduct = (Random() & 3) + 2; + if (gBattleMons[gBankTarget].pp[i] < ppToDeduct) + ppToDeduct = gBattleMons[gBankTarget].pp[i]; + + PREPARE_MOVE_BUFFER(gBattleTextBuff1, gLastUsedMovesByBanks[gBankTarget]) + + ConvertIntToDecimalStringN(gBattleTextBuff2, ppToDeduct, 0, 1); + + PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff2, 1, ppToDeduct) + + gBattleMons[gBankTarget].pp[i] -= ppToDeduct; + gActiveBank = gBankTarget; + + if (!(gDisableStructs[gActiveBank].unk18_b & gBitTable[i]) + && !(gBattleMons[gActiveBank].status2 & STATUS2_TRANSFORMED)) + { + EmitSetMonData(0, REQUEST_PPMOVE1_BATTLE + i, 0, 1, &gBattleMons[gActiveBank].pp[i]); + MarkBufferBankForExecution(gActiveBank); + } + + gBattlescriptCurrInstr += 5; + + if (gBattleMons[gBankTarget].pp[i] == 0) + CancelMultiTurnMoves(gBankTarget); + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkAE_heal_party_status(void) +{ + u32 zero = 0; + u8 toHeal = 0; + + if (gCurrentMove == MOVE_HEAL_BELL) + { + struct Pokemon* party; + s32 i; + + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + + if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + party = gPlayerParty; + else + party = gEnemyParty; + + if (gBattleMons[gBankAttacker].ability != ABILITY_SOUNDPROOF) + { + gBattleMons[gBankAttacker].status1 = 0; + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); + } + else + { + RecordAbilityBattle(gBankAttacker, gBattleMons[gBankAttacker].ability); + gBattleCommunication[MULTISTRING_CHOOSER] |= 1; + } + + gActiveBank = gBattleScripting.bank = GetBankByIdentity(GetBankIdentity(gBankAttacker) ^ BIT_MON); + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && !(gAbsentBankFlags & gBitTable[gActiveBank])) + { + if (gBattleMons[gActiveBank].ability != ABILITY_SOUNDPROOF) + { + gBattleMons[gActiveBank].status1 = 0; + gBattleMons[gActiveBank].status2 &= ~(STATUS2_NIGHTMARE); + } + else + { + RecordAbilityBattle(gActiveBank, gBattleMons[gActiveBank].ability); + gBattleCommunication[MULTISTRING_CHOOSER] |= 2; + } + } + + for (i = 0; i < 6; i++) + { + u16 species = GetMonData(&party[i], MON_DATA_SPECIES2); + u8 abilityBit = GetMonData(&party[i], MON_DATA_ALT_ABILITY); + + if (species != 0 && species != SPECIES_EGG) + { + u8 ability; + + if (gBattlePartyID[gBankAttacker] == i) + ability = gBattleMons[gBankAttacker].ability; + else if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && gBattlePartyID[gActiveBank] == i + && !(gAbsentBankFlags & gBitTable[gActiveBank])) + ability = gBattleMons[gActiveBank].ability; + else + ability = GetAbilityBySpecies(species, abilityBit); + + if (ability != ABILITY_SOUNDPROOF) + toHeal |= (1 << i); + } + } + } + else // Aromatherapy + { + gBattleCommunication[MULTISTRING_CHOOSER] = 4; + toHeal = 0x3F; + + gBattleMons[gBankAttacker].status1 = 0; + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_NIGHTMARE); + + gActiveBank = GetBankByIdentity(GetBankIdentity(gBankAttacker) ^ 2); + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && !(gAbsentBankFlags & gBitTable[gActiveBank])) + { + gBattleMons[gActiveBank].status1 = 0; + gBattleMons[gActiveBank].status2 &= ~(STATUS2_NIGHTMARE); + } + + } + + if (toHeal) + { + gActiveBank = gBankAttacker; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, toHeal, 4, &zero); + MarkBufferBankForExecution(gActiveBank); + } + + gBattlescriptCurrInstr++; +} + +void atkAF_cursetarget(void) +{ + if (gBattleMons[gBankTarget].status2 & STATUS2_CURSED) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + gBattleMons[gBankTarget].status2 |= STATUS2_CURSED; + gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 2; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + + gBattlescriptCurrInstr += 5; + } +} + +void atkB0_set_spikes(void) +{ + u8 targetSide = GetBankSide(gBankAttacker) ^ BIT_SIDE; + + if (gSideTimers[targetSide].spikesAmount == 3) + { + gSpecialStatuses[gBankAttacker].flag20 = 1; + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + gSideAffecting[targetSide] |= SIDE_STATUS_SPIKES; + gSideTimers[targetSide].spikesAmount++; + gBattlescriptCurrInstr += 5; + } +} + +void atkB1_set_foresight(void) +{ + gBattleMons[gBankTarget].status2 |= STATUS2_FORESIGHT; + gBattlescriptCurrInstr++; +} + +void atkB2_setperishsong(void) +{ + s32 i; + s32 notAffectedCount = 0; + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gStatuses3[i] & STATUS3_PERISH_SONG + || gBattleMons[i].ability == ABILITY_SOUNDPROOF) + { + notAffectedCount++; + } + else + { + gStatuses3[i] |= STATUS3_PERISH_SONG; + gDisableStructs[i].perishSong1 = 3; + gDisableStructs[i].perishSong2 = 3; + } + } + + PressurePPLoseOnUsingPerishSong(gBankAttacker); + + if (notAffectedCount == gNoOfAllBanks) + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + else + gBattlescriptCurrInstr += 5; +} + +void atkB3_rolloutdamagecalculation(void) +{ + if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) + { + CancelMultiTurnMoves(gBankAttacker); + gBattlescriptCurrInstr = BattleScript_PauseEffectivenessSoundResultMsgEndMove; + } + else + { + s32 i; + + if (!(gBattleMons[gBankAttacker].status2 & STATUS2_MULTIPLETURNS)) // first hit + { + gDisableStructs[gBankAttacker].rolloutTimer1 = 5; + gDisableStructs[gBankAttacker].rolloutTimer2 = 5; + gBattleMons[gBankAttacker].status2 |= STATUS2_MULTIPLETURNS; + gLockedMoves[gBankAttacker] = gCurrentMove; + } + if (--gDisableStructs[gBankAttacker].rolloutTimer1 == 0) // last hit + { + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_MULTIPLETURNS); + } + + gDynamicBasePower = gBattleMoves[gCurrentMove].power; + + for (i = 1; i < (5 - gDisableStructs[gBankAttacker].rolloutTimer1); i++) + gDynamicBasePower *= 2; + + if (gBattleMons[gBankAttacker].status2 & STATUS2_DEFENSE_CURL) + gDynamicBasePower *= 2; + + gBattlescriptCurrInstr++; + } +} + +void atkB4_jumpifconfusedandstatmaxed(void) +{ + if (gBattleMons[gBankTarget].status2 & STATUS2_CONFUSION + && gBattleMons[gBankTarget].statStages[gBattlescriptCurrInstr[1]] == 0xC) + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); + else + gBattlescriptCurrInstr += 6; +} + +void atkB5_furycuttercalc(void) +{ + if (gBattleMoveFlags & MOVESTATUS_NOEFFECT) + { + gDisableStructs[gBankAttacker].furyCutterCounter = 0; + gBattlescriptCurrInstr = BattleScript_PauseEffectivenessSoundResultMsgEndMove; + } + else + { + s32 i; + + if (gDisableStructs[gBankAttacker].furyCutterCounter != 5) + gDisableStructs[gBankAttacker].furyCutterCounter++; + + gDynamicBasePower = gBattleMoves[gCurrentMove].power; + + for (i = 1; i < gDisableStructs[gBankAttacker].furyCutterCounter; i++) + gDynamicBasePower *= 2; + + gBattlescriptCurrInstr++; + } +} + +void atkB6_happinesstodamagecalculation(void) +{ + if (gBattleMoves[gCurrentMove].effect == EFFECT_RETURN) + gDynamicBasePower = 10 * (gBattleMons[gBankAttacker].friendship) / 25; + else // EFFECT_FRUSTRATION + gDynamicBasePower = 10 * (255 - gBattleMons[gBankAttacker].friendship) / 25; + + gBattlescriptCurrInstr++; +} + +extern const u8 BattleScript_PresentDamageTarget[]; +extern const u8 BattleScript_AlreadyAtFullHp[]; +extern const u8 BattleScript_PresentHealTarget[]; + +void atkB7_presentdamagecalculation(void) +{ + s32 rand = Random() & 0xFF; + + if (rand < 102) + gDynamicBasePower = 40; + else if (rand < 178) + gDynamicBasePower = 80; + else if (rand < 204) + gDynamicBasePower = 120; + else + { + gBattleMoveDamage = gBattleMons[gBankTarget].maxHP / 4; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + } + if (rand < 204) + gBattlescriptCurrInstr = BattleScript_PresentDamageTarget; + else if (gBattleMons[gBankTarget].maxHP == gBattleMons[gBankTarget].hp) + gBattlescriptCurrInstr = BattleScript_AlreadyAtFullHp; + else + { + gBattleMoveFlags &= ~(MOVESTATUS_NOTAFFECTED); + gBattlescriptCurrInstr = BattleScript_PresentHealTarget; + } +} + +void atkB8_set_safeguard(void) +{ + if (gSideAffecting[GET_BANK_SIDE(gBankAttacker)] & SIDE_STATUS_SAFEGUARD) + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + } + else + { + gSideAffecting[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; + } + + gBattlescriptCurrInstr++; +} + +void atkB9_magnitudedamagecalculation(void) +{ + s32 magnitude = Random() % 100; + + if (magnitude < 5) + { + gDynamicBasePower = 10; + magnitude = 4; + } + else if (magnitude < 15) + { + gDynamicBasePower = 30; + magnitude = 5; + } + else if (magnitude < 35) + { + gDynamicBasePower = 50; + magnitude = 6; + } + else if (magnitude < 65) + { + gDynamicBasePower = 70; + magnitude = 7; + } + else if (magnitude < 85) + { + gDynamicBasePower = 90; + magnitude = 8; + } + else if (magnitude < 95) + { + gDynamicBasePower = 110; + magnitude = 9; + } + else + { + gDynamicBasePower = 150; + magnitude = 10; + } + + + PREPARE_BYTE_NUMBER_BUFFER(gBattleTextBuff1, 2, magnitude) + + for (gBankTarget = 0; gBankTarget < gNoOfAllBanks; gBankTarget++) + { + if (gBankTarget == gBankAttacker) + continue; + if (!(gAbsentBankFlags & gBitTable[gBankTarget])) // a valid target was found + break; + } + + gBattlescriptCurrInstr++; +} + +void atkBA_jumpifnopursuitswitchdmg(void) +{ + if (gMultiHitCounter == 1) + { + if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + gBankTarget = GetBankByIdentity(IDENTITY_OPPONENT_MON1); + else + gBankTarget = GetBankByIdentity(IDENTITY_PLAYER_MON1); + } + else + { + if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + gBankTarget = GetBankByIdentity(IDENTITY_OPPONENT_MON2); + else + gBankTarget = GetBankByIdentity(IDENTITY_PLAYER_MON2); + } + + if (gActionForBanks[gBankTarget] == 0 + && gBankAttacker == *(gBattleStruct->moveTarget + gBankTarget) + && !(gBattleMons[gBankTarget].status1 & (STATUS_SLEEP | STATUS_FREEZE)) + && gBattleMons[gBankAttacker].hp + && !gDisableStructs[gBankTarget].truantCounter + && gChosenMovesByBanks[gBankTarget] == MOVE_PURSUIT) + { + s32 i; + + for (i = 0; i < gNoOfAllBanks; i++) + { + if (gTurnOrder[i] == gBankTarget) + gUnknown_0202407A[i] = 11; + } + + gCurrentMove = MOVE_PURSUIT; + gCurrMovePos = gUnknown_020241E9 = *(gBattleStruct->chosenMovesIds + gBankTarget); + gBattlescriptCurrInstr += 5; + gBattleScripting.animTurn = 1; + gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkBB_setsunny(void) +{ + if (gBattleWeather & WEATHER_SUN_ANY) + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + } + else + { + gBattleWeather = WEATHER_SUN_TEMPORARY; + gBattleCommunication[MULTISTRING_CHOOSER] = 4; + gWishFutureKnock.weatherDuration = 5; + } + + gBattlescriptCurrInstr++; +} + +void atkBC_maxattackhalvehp(void) // belly drum +{ + u32 halfHp = gBattleMons[gBankAttacker].maxHP / 2; + + if (!(gBattleMons[gBankAttacker].maxHP / 2)) + halfHp = 1; + + if (gBattleMons[gBankAttacker].statStages[STAT_STAGE_ATK] < 12 + && gBattleMons[gBankAttacker].hp > halfHp) + { + gBattleMons[gBankAttacker].statStages[STAT_STAGE_ATK] = 12; + gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 2; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkBD_copyfoestats(void) // psych up +{ + s32 i; + + for (i = 0; i < BATTLE_STATS_NO; i++) + { + gBattleMons[gBankAttacker].statStages[i] = gBattleMons[gBankTarget].statStages[i]; + } + + gBattlescriptCurrInstr += 5; // Has an unused jump ptr(possibly for a failed attempt) parameter. +} + +extern const u8 BattleScript_WrapFree[]; +extern const u8 BattleScript_LeechSeedFree[]; +extern const u8 BattleScript_SpikesFree[]; + +void atkBE_rapidspinfree(void) +{ + if (gBattleMons[gBankAttacker].status2 & STATUS2_WRAPPED) + { + gBattleScripting.bank = gBankTarget; + gBattleMons[gBankAttacker].status2 &= ~(STATUS2_WRAPPED); + gBankTarget = *(gBattleStruct->wrappedBy + gBankAttacker); + + gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN; + gBattleTextBuff1[1] = B_BUFF_MOVE; + gBattleTextBuff1[2] = *(gBattleStruct->wrappedMove + gBankAttacker * 2 + 0); + gBattleTextBuff1[3] = *(gBattleStruct->wrappedMove + gBankAttacker * 2 + 1); + gBattleTextBuff1[4] = B_BUFF_EOS; + + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_WrapFree; + } + else if (gStatuses3[gBankAttacker] & STATUS3_LEECHSEED) + { + gStatuses3[gBankAttacker] &= ~(STATUS3_LEECHSEED); + gStatuses3[gBankAttacker] &= ~(STATUS3_LEECHSEED_BANK); + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_LeechSeedFree; + } + else if (gSideAffecting[GetBankSide(gBankAttacker)] & SIDE_STATUS_SPIKES) + { + gSideAffecting[GetBankSide(gBankAttacker)] &= ~(SIDE_STATUS_SPIKES); + gSideTimers[GetBankSide(gBankAttacker)].spikesAmount = 0; + BattleScriptPushCursor(); + gBattlescriptCurrInstr = BattleScript_SpikesFree; + } + else + { + gBattlescriptCurrInstr++; + } +} + +void atkBF_set_defense_curl(void) +{ + gBattleMons[gBankAttacker].status2 |= STATUS2_DEFENSE_CURL; + gBattlescriptCurrInstr++; +} + +void atkC0_recoverbasedonsunlight(void) +{ + gBankTarget = gBankAttacker; + + if (gBattleMons[gBankAttacker].hp != gBattleMons[gBankAttacker].maxHP) + { + if (gBattleWeather == 0 || !WEATHER_HAS_EFFECT) + gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 2; + else if (gBattleWeather & WEATHER_SUN_ANY) + gBattleMoveDamage = 20 * gBattleMons[gBankAttacker].maxHP / 30; + else // not sunny weather + gBattleMoveDamage = gBattleMons[gBankAttacker].maxHP / 4; + + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +#ifdef NONMATCHING +void atkC1_hidden_power(void) +{ + s32 powerBits; + s32 typeBits; + + powerBits = ((gBattleMons[gBankAttacker].hpIV & 2) >> 1) + | ((gBattleMons[gBankAttacker].attackIV & 2) << 0) + | ((gBattleMons[gBankAttacker].defenseIV & 2) << 1) + | ((gBattleMons[gBankAttacker].speedIV & 2) << 2) + | ((gBattleMons[gBankAttacker].spAttackIV & 2) << 3) + | ((gBattleMons[gBankAttacker].spDefenseIV & 2) << 4); + + typeBits = ((gBattleMons[gBankAttacker].hpIV & 1) << 0) + | ((gBattleMons[gBankAttacker].attackIV & 1) << 1) + | ((gBattleMons[gBankAttacker].defenseIV & 1) << 2) + | ((gBattleMons[gBankAttacker].speedIV & 1) << 3) + | ((gBattleMons[gBankAttacker].spAttackIV & 1) << 4) + | ((gBattleMons[gBankAttacker].spDefenseIV & 1) << 5); + + gDynamicBasePower = (40 * powerBits) / 63 + 30; + + gBattleStruct->dynamicMoveType = (15 * typeBits) / 63 + 1; + if (gBattleStruct->dynamicMoveType > 8) + gBattleStruct->dynamicMoveType++; + gBattleStruct->dynamicMoveType |= 0xC0; + + gBattlescriptCurrInstr++; +} + +#else +__attribute__((naked)) +void atkC1_hidden_power(void) +{ + asm(".syntax unified\n\ + push {r4-r7,lr}\n\ + mov r7, r10\n\ + mov r6, r9\n\ + mov r5, r8\n\ + push {r5-r7}\n\ + ldr r2, =gBattleMons\n\ + ldr r0, =gBankAttacker\n\ + ldrb r1, [r0]\n\ + movs r0, 0x58\n\ + adds r4, r1, 0\n\ + muls r4, r0\n\ + adds r4, r2\n\ + ldrb r0, [r4, 0x14]\n\ + mov r10, r0\n\ + mov r7, r10\n\ + lsls r7, 27\n\ + adds r0, r7, 0\n\ + lsrs r0, 27\n\ + mov r10, r0\n\ + movs r1, 0x2\n\ + mov r2, r10\n\ + ands r2, r1\n\ + asrs r2, 1\n\ + ldrh r7, [r4, 0x14]\n\ + mov r9, r7\n\ + mov r0, r9\n\ + lsls r0, 22\n\ + mov r9, r0\n\ + lsrs r3, r0, 27\n\ + adds r0, r1, 0\n\ + ands r0, r3\n\ + orrs r2, r0\n\ + ldrb r7, [r4, 0x15]\n\ + mov r8, r7\n\ + mov r0, r8\n\ + lsls r0, 25\n\ + mov r8, r0\n\ + lsrs r3, r0, 27\n\ + adds r0, r1, 0\n\ + ands r0, r3\n\ + lsls r0, 1\n\ + orrs r2, r0\n\ + ldr r6, [r4, 0x14]\n\ + lsls r6, 12\n\ + lsrs r3, r6, 27\n\ + adds r0, r1, 0\n\ + ands r0, r3\n\ + lsls r0, 2\n\ + orrs r2, r0\n\ + ldrh r5, [r4, 0x16]\n\ + lsls r5, 23\n\ + lsrs r3, r5, 27\n\ + adds r0, r1, 0\n\ + ands r0, r3\n\ + lsls r0, 3\n\ + orrs r2, r0\n\ + ldrb r3, [r4, 0x17]\n\ + lsls r3, 26\n\ + lsrs r0, r3, 27\n\ + ands r1, r0\n\ + lsls r1, 4\n\ + orrs r2, r1\n\ + movs r1, 0x1\n\ + adds r4, r1, 0\n\ + mov r7, r10\n\ + ands r4, r7\n\ + mov r0, r9\n\ + lsrs r0, 27\n\ + mov r9, r0\n\ + adds r0, r1, 0\n\ + mov r7, r9\n\ + ands r0, r7\n\ + lsls r0, 1\n\ + orrs r4, r0\n\ + mov r0, r8\n\ + lsrs r0, 27\n\ + mov r8, r0\n\ + adds r0, r1, 0\n\ + mov r7, r8\n\ + ands r0, r7\n\ + lsls r0, 2\n\ + orrs r4, r0\n\ + lsrs r6, 27\n\ + adds r0, r1, 0\n\ + ands r0, r6\n\ + lsls r0, 3\n\ + orrs r4, r0\n\ + lsrs r5, 27\n\ + adds r0, r1, 0\n\ + ands r0, r5\n\ + lsls r0, 4\n\ + orrs r4, r0\n\ + lsrs r3, 27\n\ + ands r1, r3\n\ + lsls r1, 5\n\ + orrs r4, r1\n\ + ldr r5, =gDynamicBasePower\n\ + lsls r0, r2, 2\n\ + adds r0, r2\n\ + lsls r0, 3\n\ + movs r1, 0x3F\n\ + bl __divsi3\n\ + adds r0, 0x1E\n\ + strh r0, [r5]\n\ + ldr r6, =gBattleStruct\n\ + ldr r5, [r6]\n\ + lsls r0, r4, 4\n\ + subs r0, r4\n\ + movs r1, 0x3F\n\ + bl __divsi3\n\ + adds r0, 0x1\n\ + strb r0, [r5, 0x13]\n\ + ldr r1, [r6]\n\ + ldrb r0, [r1, 0x13]\n\ + cmp r0, 0x8\n\ + bls _080544F0\n\ + adds r0, 0x1\n\ + strb r0, [r1, 0x13]\n\ +_080544F0:\n\ + ldr r2, [r6]\n\ + ldrb r0, [r2, 0x13]\n\ + movs r1, 0xC0\n\ + orrs r0, r1\n\ + strb r0, [r2, 0x13]\n\ + ldr r1, =gBattlescriptCurrInstr\n\ + ldr r0, [r1]\n\ + adds r0, 0x1\n\ + str r0, [r1]\n\ + pop {r3-r5}\n\ + mov r8, r3\n\ + mov r9, r4\n\ + mov r10, r5\n\ + pop {r4-r7}\n\ + pop {r0}\n\ + bx r0\n\ + .pool\n\ + .syntax divided"); +} +#endif // NONMATCHING + +void atkC2_selectnexttarget(void) +{ + for (gBankTarget = 0; gBankTarget < gNoOfAllBanks; gBankTarget++) + { + if (gBankTarget == gBankAttacker) + continue; + if (!(gAbsentBankFlags & gBitTable[gBankTarget])) + break; + } + gBattlescriptCurrInstr++; +} + +void atkC3_setfutureattack(void) +{ + if (gWishFutureKnock.futureSightCounter[gBankTarget] != 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); + + if (gProtectStructs[gBankAttacker].helpingHand) + gWishFutureKnock.futureSightDmg[gBankTarget] = gWishFutureKnock.futureSightDmg[gBankTarget] * 15 / 10; + + if (gCurrentMove == MOVE_DOOM_DESIRE) + gBattleCommunication[MULTISTRING_CHOOSER] = 1; + else + gBattleCommunication[MULTISTRING_CHOOSER] = 0; + + gBattlescriptCurrInstr += 5; + } +} + +void atkC4_beat_up(void) +{ + struct Pokemon* party; + + if (GetBankSide(gBankAttacker) == SIDE_PLAYER) + party = gPlayerParty; + else + party = gEnemyParty; + + if (gBattleMons[gBankTarget].hp == 0) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + u8 beforeLoop = gBattleCommunication[0]; + for (;gBattleCommunication[0] < 6; gBattleCommunication[0]++) + { + if (GetMonData(&party[gBattleCommunication[0]], MON_DATA_HP) + && GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES2) + && GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES2) != SPECIES_EGG + && !GetMonData(&party[gBattleCommunication[0]], MON_DATA_STATUS)) + break; + } + if (gBattleCommunication[0] < 6) + { + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBankAttacker, gBattleCommunication[0]) + + gBattlescriptCurrInstr += 9; + + gBattleMoveDamage = gBaseStats[GetMonData(&party[gBattleCommunication[0]], MON_DATA_SPECIES)].baseAttack; + gBattleMoveDamage *= gBattleMoves[gCurrentMove].power; + gBattleMoveDamage *= (GetMonData(&party[gBattleCommunication[0]], MON_DATA_LEVEL) * 2 / 5 + 2); + gBattleMoveDamage /= gBaseStats[gBattleMons[gBankTarget].species].baseDefense; + gBattleMoveDamage = (gBattleMoveDamage / 50) + 2; + if (gProtectStructs[gBankAttacker].helpingHand) + gBattleMoveDamage = gBattleMoveDamage * 15 / 10; + + gBattleCommunication[0]++; + } + else if (beforeLoop != 0) + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + else + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 5); + } +} + +void atkC5_setsemiinvulnerablebit(void) +{ + switch (gCurrentMove) + { + case MOVE_FLY: + case MOVE_BOUNCE: + gStatuses3[gBankAttacker] |= STATUS3_ON_AIR; + break; + case MOVE_DIG: + gStatuses3[gBankAttacker] |= STATUS3_UNDERGROUND; + break; + case MOVE_DIVE: + gStatuses3[gBankAttacker] |= STATUS3_UNDERWATER; + break; + } + + gBattlescriptCurrInstr++; +} + +void atkC6_clearsemiinvulnerablebit(void) +{ + switch (gCurrentMove) + { + case MOVE_FLY: + case MOVE_BOUNCE: + gStatuses3[gBankAttacker] &= ~STATUS3_ON_AIR; + break; + case MOVE_DIG: + gStatuses3[gBankAttacker] &= ~STATUS3_UNDERGROUND; + break; + case MOVE_DIVE: + gStatuses3[gBankAttacker] &= ~STATUS3_UNDERWATER; + break; + } + + gBattlescriptCurrInstr++; +} + +void atkC7_setminimize(void) +{ + if (gHitMarker & HITMARKER_OBEYS) + gStatuses3[gBankAttacker] |= STATUS3_MINIMIZED; + + gBattlescriptCurrInstr++; +} + +void atkC8_sethail(void) +{ + if (gBattleWeather & WEATHER_HAIL_ANY) + { + gBattleMoveFlags |= MOVESTATUS_MISSED; + gBattleCommunication[MULTISTRING_CHOOSER] = 2; + } + else + { + gBattleWeather = WEATHER_HAIL; + gBattleCommunication[MULTISTRING_CHOOSER] = 5; + gWishFutureKnock.weatherDuration = 5; + } + + gBattlescriptCurrInstr++; +} + +void atkC9_jumpifattackandspecialattackcannotfall(void) // memento +{ + if (gBattleMons[gBankTarget].statStages[STAT_STAGE_ATK] == 0 + && gBattleMons[gBankTarget].statStages[STAT_STAGE_SPATK] == 0 + && gBattleCommunication[6] != 1) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + gActiveBank = gBankAttacker; + gBattleMoveDamage = gBattleMons[gActiveBank].hp; + EmitHealthBarUpdate(0, 0x7FFF); + MarkBufferBankForExecution(gActiveBank); + gBattlescriptCurrInstr += 5; + } +} + +void atkCA_setforcedtarget(void) // follow me +{ + gSideTimers[GetBankSide(gBankAttacker)].followmeTimer = 1; + gSideTimers[GetBankSide(gBankAttacker)].followmeTarget = gBankAttacker; + gBattlescriptCurrInstr++; +} + +void atkCB_setcharge(void) +{ + gStatuses3[gBankAttacker] |= STATUS3_CHARGED_UP; + gDisableStructs[gBankAttacker].chargeTimer1 = 2; + gDisableStructs[gBankAttacker].chargeTimer2 = 2; + gBattlescriptCurrInstr++; +} + +void atkCC_callterrainattack(void) // nature power +{ + gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gCurrentMove = sNaturePowerMoves[gBattleTerrain]; + gBankTarget = GetMoveTarget(gCurrentMove, 0); + BattleScriptPush(gBattleScriptsForMoveEffects[gBattleMoves[gCurrentMove].effect]); + gBattlescriptCurrInstr++; +} + +void atkCD_cureifburnedparalysedorpoisoned(void) // refresh +{ + if (gBattleMons[gBankAttacker].status1 & (STATUS_POISON | STATUS_BURN | STATUS_PARALYSIS | STATUS_TOXIC_POISON)) + { + gBattleMons[gBankAttacker].status1 = 0; + gBattlescriptCurrInstr += 5; + gActiveBank = gBankAttacker; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, 0, 4, &gBattleMons[gActiveBank].status1); + MarkBufferBankForExecution(gActiveBank); + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkCE_settorment(void) +{ + if (gBattleMons[gBankTarget].status2 & STATUS2_TORMENT) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + gBattleMons[gBankTarget].status2 |= STATUS2_TORMENT; + gBattlescriptCurrInstr += 5; + } +} + +void atkCF_jumpifnodamage(void) +{ + if (gProtectStructs[gBankAttacker].physicalDmg || gProtectStructs[gBankAttacker].specialDmg) + gBattlescriptCurrInstr += 5; + else + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); +} + +void atkD0_settaunt(void) +{ + if (gDisableStructs[gBankTarget].tauntTimer1 == 0) + { + gDisableStructs[gBankTarget].tauntTimer1 = 2; + gDisableStructs[gBankTarget].tauntTimer2 = 2; + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkD1_set_helpinghand(void) +{ + gBankTarget = GetBankByIdentity(GetBankIdentity(gBankAttacker) ^ BIT_MON); + + if (gBattleTypeFlags & BATTLE_TYPE_DOUBLE + && !(gAbsentBankFlags & gBitTable[gBankTarget]) + && !gProtectStructs[gBankAttacker].helpingHand + && !gProtectStructs[gBankTarget].helpingHand) + { + gProtectStructs[gBankTarget].helpingHand = 1; + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkD2_swap_items(void) // trick +{ + // opponent can't swap items with player in regular battles + if (gBattleTypeFlags & BATTLE_TYPE_x4000000 + || (GetBankSide(gBankAttacker) == SIDE_OPPONENT + && !(gBattleTypeFlags & (BATTLE_TYPE_LINK + | BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_FRONTIER + | BATTLE_TYPE_SECRET_BASE + | BATTLE_TYPE_x2000000)))) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + u8 sideAttacker = GetBankSide(gBankAttacker); + u8 sideTarget = GetBankSide(gBankTarget); + + // you can't swap items if they were knocked off in regular battles + if (!(gBattleTypeFlags & (BATTLE_TYPE_LINK + | BATTLE_TYPE_EREADER_TRAINER + | BATTLE_TYPE_FRONTIER + | BATTLE_TYPE_SECRET_BASE + | BATTLE_TYPE_x2000000)) + && (gWishFutureKnock.knockedOffPokes[sideAttacker] & gBitTable[gBattlePartyID[gBankAttacker]] + || gWishFutureKnock.knockedOffPokes[sideTarget] & gBitTable[gBattlePartyID[gBankTarget]])) + { + 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) + || gBattleMons[gBankAttacker].item == ITEM_ENIGMA_BERRY + || gBattleMons[gBankTarget].item == ITEM_ENIGMA_BERRY + || IS_ITEM_MAIL(gBattleMons[gBankAttacker].item) + || IS_ITEM_MAIL(gBattleMons[gBankTarget].item)) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + // check if ability prevents swapping + else if (gBattleMons[gBankTarget].ability == ABILITY_STICKY_HOLD) + { + gBattlescriptCurrInstr = BattleScript_StickyHoldActivates; + gLastUsedAbility = gBattleMons[gBankTarget].ability; + RecordAbilityBattle(gBankTarget, gLastUsedAbility); + } + // took a while, but all checks passed and items can be safely swapped + else + { + u16 oldItemAtk, *newItemAtk; + + newItemAtk = &gBattleStruct->changedItems[gBankAttacker]; + oldItemAtk = gBattleMons[gBankAttacker].item; + *newItemAtk = gBattleMons[gBankTarget].item; + + gBattleMons[gBankAttacker].item = 0; + gBattleMons[gBankTarget].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); + + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankTarget]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankTarget]) + 1) = 0; + + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankAttacker]) + 0) = 0; + *(u8*)((u8*)(&gBattleStruct->choicedMove[gBankAttacker]) + 1) = 0; + + gBattlescriptCurrInstr += 5; + + PREPARE_ITEM_BUFFER(gBattleTextBuff1, *newItemAtk) + PREPARE_ITEM_BUFFER(gBattleTextBuff2, oldItemAtk) + + if (oldItemAtk != 0 && *newItemAtk != 0) + gBattleCommunication[MULTISTRING_CHOOSER] = 2; // attacker's item -> <- target's item + else if (oldItemAtk == 0 && *newItemAtk != 0) + gBattleCommunication[MULTISTRING_CHOOSER] = 0; // nothing -> <- target's item + else + gBattleCommunication[MULTISTRING_CHOOSER] = 1; // attacker's item -> <- nothing + } + } +} + +void atkD3_copy_ability(void) // role play +{ + if (gBattleMons[gBankTarget].ability != 0 + && gBattleMons[gBankTarget].ability != ABILITY_WONDER_GUARD) + { + gBattleMons[gBankAttacker].ability = gBattleMons[gBankTarget].ability; + gLastUsedAbility = gBattleMons[gBankTarget].ability; + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkD4_wish_effect(void) +{ + switch (BSScriptRead8(gBattlescriptCurrInstr + 1)) + { + case 0: // use wish + if (gWishFutureKnock.wishCounter[gBankAttacker] == 0) + { + gWishFutureKnock.wishCounter[gBankAttacker] = 2; + gWishFutureKnock.wishUserID[gBankAttacker] = gBattlePartyID[gBankAttacker]; + gBattlescriptCurrInstr += 6; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); + } + break; + case 1: // heal effect + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff1, gBankTarget, gWishFutureKnock.wishUserID[gBankTarget]) + + gBattleMoveDamage = gBattleMons[gBankTarget].maxHP / 2; + if (gBattleMoveDamage == 0) + gBattleMoveDamage = 1; + gBattleMoveDamage *= -1; + + if (gBattleMons[gBankTarget].hp == gBattleMons[gBankTarget].maxHP) + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); + else + gBattlescriptCurrInstr += 6; + + break; + } +} + +void atkD5_setroots(void) // ingrain +{ + if (gStatuses3[gBankAttacker] & STATUS3_ROOTED) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + gStatuses3[gBankAttacker] |= STATUS3_ROOTED; + gBattlescriptCurrInstr += 5; + } +} + +void atkD6_doubledamagedealtifdamaged(void) +{ + if ((gProtectStructs[gBankAttacker].physicalDmg + && gProtectStructs[gBankAttacker].physicalBank == gBankTarget) + || (gProtectStructs[gBankAttacker].specialDmg + && gProtectStructs[gBankAttacker].specialBank == gBankTarget)) + { + gBattleScripting.dmgMultiplier = 2; + } + + gBattlescriptCurrInstr++; +} + +void atkD7_setyawn(void) +{ + if (gStatuses3[gBankTarget] & STATUS3_YAWN + || gBattleMons[gBankTarget].status1 & STATUS_ANY) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + gStatuses3[gBankTarget] |= 0x1000; + gBattlescriptCurrInstr += 5; + } +} + +void atkD8_setdamagetohealthdifference(void) +{ + if (gBattleMons[gBankTarget].hp <= gBattleMons[gBankAttacker].hp) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + gBattleMoveDamage = gBattleMons[gBankTarget].hp - gBattleMons[gBankAttacker].hp; + gBattlescriptCurrInstr += 5; + } +} + +void atkD9_scaledamagebyhealthratio(void) +{ + if (gDynamicBasePower == 0) + { + u8 power = gBattleMoves[gCurrentMove].power; + gDynamicBasePower = gBattleMons[gBankAttacker].hp * power / gBattleMons[gBankAttacker].maxHP; + if (gDynamicBasePower == 0) + gDynamicBasePower = 1; + } + gBattlescriptCurrInstr++; +} + +void atkDA_abilityswap(void) // skill swap +{ + if ((gBattleMons[gBankAttacker].ability == 0 + && gBattleMons[gBankTarget].ability == 0) + || gBattleMons[gBankAttacker].ability == ABILITY_WONDER_GUARD + || gBattleMons[gBankTarget].ability == ABILITY_WONDER_GUARD + || gBattleMoveFlags & MOVESTATUS_NOEFFECT) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + u8 abilityAtk = gBattleMons[gBankAttacker].ability; + gBattleMons[gBankAttacker].ability = gBattleMons[gBankTarget].ability; + gBattleMons[gBankTarget].ability = abilityAtk; + + gBattlescriptCurrInstr += 5; + } +} + +void atkDB_imprisoneffect(void) +{ + if ((gStatuses3[gBankAttacker] & STATUS3_IMPRISONED_OTHERS)) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + u8 bank, sideAttacker; + + sideAttacker = GetBankSide(gBankAttacker); + PressurePPLoseOnUsingImprision(gBankAttacker); + for (bank = 0; bank < gNoOfAllBanks; bank++) + { + if (sideAttacker != GetBankSide(bank)) + { + s32 attackerMoveId; + for (attackerMoveId = 0; attackerMoveId < 4; attackerMoveId++) + { + s32 i; + for (i = 0; i < 4; i++) + { + if (gBattleMons[gBankAttacker].moves[attackerMoveId] == gBattleMons[bank].moves[i] + && gBattleMons[gBankAttacker].moves[attackerMoveId] != MOVE_NONE) + break; + } + if (i != 4) + break; + } + if (attackerMoveId != 4) + { + gStatuses3[gBankAttacker] |= STATUS3_IMPRISONED_OTHERS; + gBattlescriptCurrInstr += 5; + break; + } + } + } + if (bank == gNoOfAllBanks) // In Generation 3 games, Imprison fails if the user doesn't share any moves with any of the foes + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkDC_setgrudge(void) +{ + if (gStatuses3[gBankAttacker] & STATUS3_GRUDGE) + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + gStatuses3[gBankAttacker] |= STATUS3_GRUDGE; + gBattlescriptCurrInstr += 5; + } +} + +void atkDD_weightdamagecalculation(void) +{ + s32 i; + for (i = 0; sWeightToDamageTable[i] != 0xFFFF; i += 2) + { + if (sWeightToDamageTable[i] > GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBankTarget].species), 1)) + break; + } + + if (sWeightToDamageTable[i] != 0xFFFF) + gDynamicBasePower = sWeightToDamageTable[i + 1]; + else + gDynamicBasePower = 120; + + gBattlescriptCurrInstr++; +} + +void atkDE_asistattackselect(void) +{ + s32 chooseableMovesNo = 0; + struct Pokemon* party; + s32 monId, moveId; + u16* movesArray = gBattleStruct->assistPossibleMoves; + + if (GET_BANK_SIDE(gBankAttacker) != SIDE_PLAYER) + party = gEnemyParty; + else + party = gPlayerParty; + + for (monId = 0; monId < 6; monId++) + { + if (monId == gBattlePartyID[gBankAttacker]) + continue; + if (GetMonData(&party[monId], MON_DATA_SPECIES2) == SPECIES_NONE) + continue; + if (GetMonData(&party[monId], MON_DATA_SPECIES2) == SPECIES_EGG) + continue; + + for (moveId = 0; moveId < 4; moveId++) + { + s32 i = 0; + u16 move = GetMonData(&party[monId], MON_DATA_MOVE1 + moveId); + + if (IsInvalidForSleepTalkOrAssist(move)) + continue; + + for (; gMovesForbiddenToCopy[i] != ASSIST_FORBIDDEN_END && move != gMovesForbiddenToCopy[i]; i++); + + if (gMovesForbiddenToCopy[i] != ASSIST_FORBIDDEN_END) + continue; + if (move == MOVE_NONE) + continue; + + movesArray[chooseableMovesNo] = move; + chooseableMovesNo++; + } + } + if (chooseableMovesNo) + { + gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); + gRandomMove = movesArray[((Random() & 0xFF) * chooseableMovesNo) >> 8]; + gBankTarget = GetMoveTarget(gRandomMove, 0); + gBattlescriptCurrInstr += 5; + } + else + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } +} + +void atkDF_setmagiccoat(void) +{ + gBankTarget = gBankAttacker; + gSpecialStatuses[gBankAttacker].flag20 = 1; + if (gCurrentMoveTurn == gNoOfAllBanks - 1) // moves last turn + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + gProtectStructs[gBankAttacker].bounceMove = 1; + gBattlescriptCurrInstr += 5; + } +} + +void atkE0_setstealstatchange(void) // snatch +{ + gSpecialStatuses[gBankAttacker].flag20 = 1; + if (gCurrentMoveTurn == gNoOfAllBanks - 1) // moves last turn + { + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + } + else + { + gProtectStructs[gBankAttacker].stealMove = 1; + gBattlescriptCurrInstr += 5; + } +} + +void atkE1_intimidate_string_loader(void) +{ + u8 side; + + gBattleScripting.bank = gBattleStruct->intimidateBank; + side = GetBankSide(gBattleScripting.bank); + + PREPARE_ABILITY_BUFFER(gBattleTextBuff1, gBattleMons[gBattleScripting.bank].ability) + + for (;gBankTarget < gNoOfAllBanks; gBankTarget++) + { + if (GetBankSide(gBankTarget) == side) + continue; + if (!(gAbsentBankFlags & gBitTable[gBankTarget])) + break; + } + + if (gBankTarget >= gNoOfAllBanks) + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 1); + else + gBattlescriptCurrInstr += 5; +} + +void atkE2_switchout_abilities(void) +{ + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + + switch (gBattleMons[gActiveBank].ability) + { + case ABILITY_NATURAL_CURE: + gBattleMons[gActiveBank].status1 = 0; + EmitSetMonData(0, REQUEST_STATUS_BATTLE, gBitTable[*(gBattleStruct->field_58 + gActiveBank)], 4, &gBattleMons[gActiveBank].status1); + MarkBufferBankForExecution(gActiveBank); + break; + } + + gBattlescriptCurrInstr += 2; +} + +void atkE3_jumpifhasnohp(void) +{ + gActiveBank = GetBattleBank(BSScriptRead8(gBattlescriptCurrInstr + 1)); + + if (gBattleMons[gActiveBank].hp == 0) + gBattlescriptCurrInstr = BSScriptReadPtr(gBattlescriptCurrInstr + 2); + else + gBattlescriptCurrInstr += 6; +} + +void atkE4_getsecretpowereffect(void) +{ + switch (gBattleTerrain) + { + case BATTLE_TERRAIN_GRASS: + gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_POISON; + break; + case BATTLE_TERRAIN_LONG_GRASS: + gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_SLEEP; + break; + case BATTLE_TERRAIN_SAND: + gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_ACC_MINUS_1; + break; + case BATTLE_TERRAIN_UNDERWATER: + gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_DEF_MINUS_1; + break; + case BATTLE_TERRAIN_WATER: + gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_ATK_MINUS_1; + break; + case BATTLE_TERRAIN_POND: + gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_SPD_MINUS_1; + break; + case BATTLE_TERRAIN_ROCK: + gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_CONFUSION; + break; + case BATTLE_TERRAIN_CAVE: + gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_FLINCH; + break; + default: + gBattleCommunication[MOVE_EFFECT_BYTE] = MOVE_EFFECT_PARALYSIS; + break; + } + gBattlescriptCurrInstr++; +} + +extern bool8 InBattlePike(void); +extern bool8 InBattlePyramid(void); +extern u16 GetBattlePyramidPickupItemId(void); + +extern const u16 gRarePickupItems[]; +extern const u16 gPickupItems[]; +extern const u8 gPickupProbabilities[]; + +void atkE5_pickup(void) +{ + if (!InBattlePike()) + { + s32 i; + u16 species, heldItem; + u8 ability; + + if (InBattlePyramid()) + { + for (i = 0; i < 6; i++) + { + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + + if (GetMonData(&gPlayerParty[i], MON_DATA_ALT_ABILITY)) + ability = gBaseStats[species].ability2; + else + ability = gBaseStats[species].ability1; + + if (ability == ABILITY_PICKUP + && species != 0 + && species != SPECIES_EGG + && heldItem == ITEM_NONE + && (Random() % 10) == 0) + { + heldItem = GetBattlePyramidPickupItemId(); + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &heldItem); + } + } + } + else + { + for (i = 0; i < 6; i++) + { + species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); + heldItem = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + + if (GetMonData(&gPlayerParty[i], MON_DATA_ALT_ABILITY)) + ability = gBaseStats[species].ability2; + else + ability = gBaseStats[species].ability1; + + if (ability == ABILITY_PICKUP + && species != 0 + && species != SPECIES_EGG + && heldItem == ITEM_NONE + && (Random() % 10) == 0) + { + s32 j; + s32 rand = Random() % 100; + u8 lvlDivBy10 = (GetMonData(&gPlayerParty[i], MON_DATA_LEVEL) - 1) / 10; + if (lvlDivBy10 > 9) + lvlDivBy10 = 9; + + for (j = 0; j < 9; j++) + { + if (gPickupProbabilities[j] > rand) + { + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &gPickupItems[lvlDivBy10 + j]); + break; + } + else if (rand == 99 || rand == 98) + { + SetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM, &gRarePickupItems[lvlDivBy10 + (99 - rand)]); + break; + } + } + } + } + } + } + + gBattlescriptCurrInstr++; +} diff --git a/src/pokemon_3.c b/src/pokemon_3.c index d381c7544..d44c0cb2f 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1361,20 +1361,20 @@ void BoxMonRestorePP(struct BoxPokemon *boxMon) void sub_806E994(void) { gLastUsedAbility = gBattleStruct->field_B0; - gBattleTextBuff1[0] = 0xFD; - gBattleTextBuff1[1] = 4; + + gBattleTextBuff1[0] = B_BUFF_PLACEHOLDER_BEGIN; + gBattleTextBuff1[1] = B_BUFF_MON_NICK_WITH_PREFIX; gBattleTextBuff1[2] = gBattleStruct->field_49; - gBattleTextBuff1[4] = EOS; + gBattleTextBuff1[4] = B_BUFF_EOS; + if (!GetBankSide(gBattleStruct->field_49)) gBattleTextBuff1[3] = pokemon_order_func(gBattlePartyID[gBattleStruct->field_49]); else gBattleTextBuff1[3] = gBattlePartyID[gBattleStruct->field_49]; - gBattleTextBuff2[0] = 0xFD; - gBattleTextBuff2[1] = 4; - gBattleTextBuff2[2] = gBankInMenu; - gBattleTextBuff2[3] = pokemon_order_func(gBattlePartyID[gBankInMenu]); - gBattleTextBuff2[4] = EOS; - BattleStringExpandPlaceholders(gText_PkmnsXPreventsSwitching, gStringVar4); + + PREPARE_MON_NICK_WITH_PREFIX_BUFFER(gBattleTextBuff2, gBankInMenu, pokemon_order_func(gBattlePartyID[gBankInMenu])) + + BattleStringExpandPlaceholders(gText_PkmnsXPreventsSwitching, gStringVar4); } struct PokeItem @@ -1388,7 +1388,7 @@ extern const struct PokeItem gAlteringCaveWildMonHeldItems[9]; static s32 GetWildMonTableIdInAlteringCave(u16 species) { s32 i; - for (i = 0; i < 9; i++) + for (i = 0; i < (s32) ARRAY_COUNT(gAlteringCaveWildMonHeldItems); i++) if (gAlteringCaveWildMonHeldItems[i].species == species) return i; return 0; diff --git a/sym_ewram.txt b/sym_ewram.txt index 7c18d8225..227f83385 100644 --- a/sym_ewram.txt +++ b/sym_ewram.txt @@ -268,7 +268,7 @@ gUnknown_02022F88: @ 2022F88 gBattleTypeFlags: @ 2022FEC .space 0x4 -gUnknown_02022FF0: @ 2022FF0 +gBattleTerrain: @ 2022FF0 .space 0x4 gUnknown_02022FF4: @ 2022FF4 @@ -382,7 +382,7 @@ gMultiHitCounter: @ 2024212 gBattlescriptCurrInstr: @ 2024214 .space 0x8 -gUnknown_0202421C: @ 202421C +gActionForBanks: @ 202421C .space 0x4 gUnknown_02024220: @ 2024220